Freeswitch-trunk
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- 14172 discussions
[commit] r5123 - in freeswitch/trunk: . conf src src/include src/include/private
by Freeswitch SVN 10 May '07
by Freeswitch SVN 10 May '07
10 May '07
Author: anthm
Date: Thu May 10 12:56:29 2007
New Revision: 5123
Modified:
freeswitch/trunk/Makefile.am
freeswitch/trunk/conf/switch.conf.xml
freeswitch/trunk/configure.in
freeswitch/trunk/src/include/private/switch_core.h
freeswitch/trunk/src/include/switch_utils.h
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_core_memory.c
freeswitch/trunk/src/switch_core_session.c
freeswitch/trunk/src/switch_core_sqldb.c
freeswitch/trunk/src/switch_core_state_machine.c
Log:
make crash protection a runtime option instead of a compile-time option
Modified: freeswitch/trunk/Makefile.am
==============================================================================
--- freeswitch/trunk/Makefile.am (original)
+++ freeswitch/trunk/Makefile.am Thu May 10 12:56:29 2007
@@ -10,10 +10,6 @@
BASE = $(switch_srcdir)
OSARCH=`uname -s`
-if CRASHPROT
-AM_CFLAGS += -DCRASH_PROT
-endif
-
.DEFAULT:
@cd src/mod && $(MAKE) $(AM_MAKEFLAGS) $@
Modified: freeswitch/trunk/conf/switch.conf.xml
==============================================================================
--- freeswitch/trunk/conf/switch.conf.xml (original)
+++ freeswitch/trunk/conf/switch.conf.xml Thu May 10 12:56:29 2007
@@ -2,6 +2,8 @@
<settings>
<!--Most channels to allow at once -->
<param name="max-sessions" value="1000"/>
+ <!--Try to catch any crashes that can be recoverable (in the context of a call)-->
+ <param name="crash-protection" value="false"/>
<!--RTP port range -->
<!--<param name="rtp-start-port" value="16384"/>-->
<!--<param name="rtp-end-port" value="32768"/>-->
Modified: freeswitch/trunk/configure.in
==============================================================================
--- freeswitch/trunk/configure.in (original)
+++ freeswitch/trunk/configure.in Thu May 10 12:56:29 2007
@@ -311,9 +311,6 @@
LIBCURL_CHECK_CONFIG([yes], [7.13.0], [LIBCURL_DEPS=''], [LIBCURL_DEPS='${switch_srcdir}/libs/curl/lib/libcurl.la';LIBCURL='${switch_srcdir}/libs/curl/lib/libcurl.la';LIBCURL_CPPFLAGS='-I${switch_srcdir}/libs/curl/include'])
AC_SUBST(LIBCURL_DEPS)
-AC_ARG_ENABLE(crash-protection,
- [ --enable-crash-protection Compile with CRASH Protection],,[enable_crash_prot="no"])
-
AC_ARG_ENABLE(core-odbc-support,
[ --enable-core-odbc-support Compile with ODBC Support],,[enable_core_odbc_support="no"])
@@ -323,7 +320,6 @@
#AX_LIB_MYSQL([MINIMUM-VERSION])
AX_LIB_MYSQL
-AM_CONDITIONAL([CRASHPROT],[test "x$enable_crash_prot" != "xno"])
AM_CONDITIONAL([ADD_ODBC],[test "x$enable_core_odbc_support" != "xno"])
AM_CONDITIONAL([ADD_LIBEDIT],[test "x$enable_core_libedit_support" != "xno"])
AM_CONDITIONAL([HAVE_MYSQL],[test "$found_mysql" = "yes"])
Modified: freeswitch/trunk/src/include/private/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core.h (original)
+++ freeswitch/trunk/src/include/private/switch_core.h Thu May 10 12:56:29 2007
@@ -63,12 +63,6 @@
/* #define DEBUG_ALLOC */
#define DO_EVENTS
-#ifdef CRASH_PROT
-#define __CP "ENABLED"
-#else
-#define __CP "DISABLED"
-#endif
-
#define SWITCH_EVENT_QUEUE_LEN 256
#define SWITCH_MESSAGE_QUEUE_LEN 256
#define SWITCH_SQL_QUEUE_LEN 2000
@@ -145,6 +139,22 @@
struct switch_media_bug *next;
};
+struct switch_runtime {
+ switch_time_t initiated;
+ switch_hash_t *global_vars;
+ switch_memory_pool_t *memory_pool;
+ const switch_state_handler_table_t *state_handlers[SWITCH_MAX_STATE_HANDLERS];
+ int state_handler_index;
+ FILE *console;
+ uint8_t running;
+ char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
+ uint32_t no_new_sessions;
+ uint32_t shutting_down;
+ uint32_t crash_prot;
+};
+
+extern struct switch_runtime runtime;
+
void switch_core_sqldb_start(switch_memory_pool_t *pool);
void switch_core_sqldb_stop(void);
void switch_core_session_init(switch_memory_pool_t *pool);
Modified: freeswitch/trunk/src/include/switch_utils.h
==============================================================================
--- freeswitch/trunk/src/include/switch_utils.h (original)
+++ freeswitch/trunk/src/include/switch_utils.h Thu May 10 12:56:29 2007
@@ -76,6 +76,8 @@
(expr && ( !strcasecmp(expr, "yes") ||\
!strcasecmp(expr, "on") ||\
!strcasecmp(expr, "true") ||\
+!strcasecmp(expr, "enabled") ||\
+!strcasecmp(expr, "active") ||\
atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE
/*!
\brief find local ip of the box
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Thu May 10 12:56:29 2007
@@ -40,19 +40,7 @@
SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 };
/* The main runtime obj we keep this hidden for ourselves */
-static struct {
- switch_time_t initiated;
- switch_hash_t *global_vars;
- switch_memory_pool_t *memory_pool;
- const switch_state_handler_table_t *state_handlers[SWITCH_MAX_STATE_HANDLERS];
- int state_handler_index;
- FILE *console;
- uint8_t running;
- char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
- uint32_t no_new_sessions;
- uint32_t shutting_down;
-} runtime;
-
+struct switch_runtime runtime;
static void send_heartbeat(void)
{
@@ -424,7 +412,6 @@
switch_core_set_globals();
switch_core_session_init(runtime.memory_pool);
- switch_core_state_machine_init(runtime.memory_pool);
switch_core_hash_init(&runtime.global_vars, runtime.memory_pool);
@@ -443,7 +430,9 @@
const char *var = switch_xml_attr_soft(param, "name");
const char *val = switch_xml_attr_soft(param, "value");
- if (!strcasecmp(var, "max-sessions")) {
+ if (!strcasecmp(var, "crash-protection")) {
+ runtime.crash_prot = switch_true(val);
+ } else if (!strcasecmp(var, "max-sessions")) {
switch_core_session_limit(atoi(val));
}
else if (!strcasecmp(var, "rtp-start-port")) {
@@ -469,6 +458,8 @@
switch_xml_free(xml);
}
+ switch_core_state_machine_init(runtime.memory_pool);
+
*err = NULL;
if (console) {
@@ -583,7 +574,8 @@
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
- "\nFreeSWITCH Version %s Started.\nCrash Protection [%s]\nMax Sessions[%u]\n\n", SWITCH_VERSION_FULL, __CP,
+ "\nFreeSWITCH Version %s Started.\nCrash Protection [%s]\nMax Sessions[%u]\n\n", SWITCH_VERSION_FULL,
+ runtime.crash_prot ? "Enabled" : "Disabled",
switch_core_session_limit(0));
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/switch_core_memory.c
==============================================================================
--- freeswitch/trunk/src/switch_core_memory.c (original)
+++ freeswitch/trunk/src/switch_core_memory.c Thu May 10 12:56:29 2007
@@ -36,7 +36,7 @@
static struct {
switch_memory_pool_t *memory_pool;
-} runtime;
+} memory_manager;
SWITCH_DECLARE(switch_memory_pool_t *) switch_core_session_get_pool(switch_core_session_t *session)
{
@@ -68,14 +68,14 @@
SWITCH_DECLARE(void *) switch_core_permanent_alloc(switch_size_t memory)
{
void *ptr = NULL;
- assert(runtime.memory_pool != NULL);
+ assert(memory_manager.memory_pool != NULL);
#ifdef DEBUG_ALLOC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Perm Allocate %d\n", memory);
#endif
- if ((ptr = apr_palloc(runtime.memory_pool, memory)) != 0) {
+ if ((ptr = apr_palloc(memory_manager.memory_pool, memory)) != 0) {
memset(ptr, 0, memory);
}
return ptr;
@@ -85,7 +85,7 @@
{
char *duped = NULL;
switch_size_t len;
- assert(runtime.memory_pool != NULL);
+ assert(memory_manager.memory_pool != NULL);
if (!todup)
return NULL;
@@ -96,7 +96,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Perm Allocate %d\n", len);
#endif
- if (todup && (duped = apr_palloc(runtime.memory_pool, len)) != 0) {
+ if (todup && (duped = apr_palloc(memory_manager.memory_pool, len)) != 0) {
strncpy(duped, todup, len);
}
return duped;
@@ -214,8 +214,8 @@
switch_memory_pool_t *switch_core_memory_init(void)
{
- memset(&runtime, 0, sizeof(runtime));
+ memset(&memory_manager, 0, sizeof(memory_manager));
- apr_pool_create(&runtime.memory_pool, NULL);
- return runtime.memory_pool;
+ apr_pool_create(&memory_manager.memory_pool, NULL);
+ return memory_manager.memory_pool;
}
Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c (original)
+++ freeswitch/trunk/src/switch_core_session.c Thu May 10 12:56:29 2007
@@ -41,7 +41,7 @@
uint32_t session_count;
uint32_t session_limit;
switch_size_t session_id;
-} runtime;
+} session_manager;
#ifdef SWITCH_DEBUG_RWLOCKS
@@ -53,8 +53,8 @@
switch_core_session_t *session = NULL;
if (uuid_str) {
- switch_mutex_lock(runtime.session_table_mutex);
- if ((session = switch_core_hash_find(runtime.session_table, uuid_str))) {
+ switch_mutex_lock(session_manager.session_table_mutex);
+ if ((session = switch_core_hash_find(session_manager.session_table, uuid_str))) {
/* Acquire a read lock on the session */
#ifdef SWITCH_DEBUG_RWLOCKS
if (switch_core_session_perform_read_lock(session, file, func, line) != SWITCH_STATUS_SUCCESS) {
@@ -65,7 +65,7 @@
session = NULL;
}
}
- switch_mutex_unlock(runtime.session_table_mutex);
+ switch_mutex_unlock(session_manager.session_table_mutex);
}
/* if its not NULL, now it's up to you to rwunlock this */
@@ -80,8 +80,8 @@
switch_channel_t *channel;
uint32_t loops = 0;
- switch_mutex_lock(runtime.session_table_mutex);
- for (hi = switch_hash_first(runtime.memory_pool, runtime.session_table); hi; hi = switch_hash_next(hi)) {
+ switch_mutex_lock(session_manager.session_table_mutex);
+ for (hi = switch_hash_first(session_manager.memory_pool, session_manager.session_table); hi; hi = switch_hash_next(hi)) {
switch_hash_this(hi, NULL, NULL, &val);
if (val) {
session = (switch_core_session_t *) val;
@@ -90,13 +90,13 @@
switch_core_session_kill_channel(session, SWITCH_SIG_KILL);
}
}
- switch_mutex_unlock(runtime.session_table_mutex);
+ switch_mutex_unlock(session_manager.session_table_mutex);
- while (runtime.session_count > 0) {
+ while (session_manager.session_count > 0) {
switch_yield(100000);
if (++loops == 100) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Giving up with %d session%s remaining\n",
- runtime.session_count, runtime.session_count == 1 ? "" : "s");
+ session_manager.session_count, session_manager.session_count == 1 ? "" : "s");
break;
}
}
@@ -107,8 +107,8 @@
switch_core_session_t *session = NULL;
switch_status_t status = SWITCH_STATUS_FALSE;
- switch_mutex_lock(runtime.session_table_mutex);
- if ((session = switch_core_hash_find(runtime.session_table, uuid_str)) != 0) {
+ switch_mutex_lock(session_manager.session_table_mutex);
+ if ((session = switch_core_hash_find(session_manager.session_table, uuid_str)) != 0) {
/* Acquire a read lock on the session or forget it the channel is dead */
if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
if (switch_channel_get_state(session->channel) < CS_HANGUP) {
@@ -117,7 +117,7 @@
switch_core_session_rwunlock(session);
}
}
- switch_mutex_unlock(runtime.session_table_mutex);
+ switch_mutex_unlock(session_manager.session_table_mutex);
return status;
}
@@ -127,8 +127,8 @@
switch_core_session_t *session = NULL;
switch_status_t status = SWITCH_STATUS_FALSE;
- switch_mutex_lock(runtime.session_table_mutex);
- if ((session = switch_core_hash_find(runtime.session_table, uuid_str)) != 0) {
+ switch_mutex_lock(session_manager.session_table_mutex);
+ if ((session = switch_core_hash_find(session_manager.session_table, uuid_str)) != 0) {
/* Acquire a read lock on the session or forget it the channel is dead */
if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
if (switch_channel_get_state(session->channel) < CS_HANGUP) {
@@ -137,7 +137,7 @@
switch_core_session_rwunlock(session);
}
}
- switch_mutex_unlock(runtime.session_table_mutex);
+ switch_mutex_unlock(session_manager.session_table_mutex);
return status;
}
@@ -662,12 +662,12 @@
switch_scheduler_del_task_group((*session)->uuid_str);
- switch_mutex_lock(runtime.session_table_mutex);
- switch_core_hash_delete(runtime.session_table, (*session)->uuid_str);
- if (runtime.session_count) {
- runtime.session_count--;
+ switch_mutex_lock(session_manager.session_table_mutex);
+ switch_core_hash_delete(session_manager.session_table, (*session)->uuid_str);
+ if (session_manager.session_count) {
+ session_manager.session_count--;
}
- switch_mutex_unlock(runtime.session_table_mutex);
+ switch_mutex_unlock(session_manager.session_table_mutex);
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DESTROY) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data((*session)->channel, event);
@@ -750,11 +750,11 @@
assert(endpoint_interface != NULL);
- switch_mutex_lock(runtime.session_table_mutex);
- count = runtime.session_count;
- switch_mutex_unlock(runtime.session_table_mutex);
+ switch_mutex_lock(session_manager.session_table_mutex);
+ count = session_manager.session_count;
+ switch_mutex_unlock(session_manager.session_table_mutex);
- if ((count + 1) > runtime.session_limit) {
+ if ((count + 1) > session_manager.session_limit) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Over Session Limit!\n");
return NULL;
}
@@ -812,23 +812,23 @@
switch_thread_rwlock_create(&session->rwlock, session->pool);
snprintf(session->name, sizeof(session->name), "%"SWITCH_SIZE_T_FMT, session->id);
- switch_mutex_lock(runtime.session_table_mutex);
- session->id = runtime.session_id++;
- switch_core_hash_insert(runtime.session_table, session->uuid_str, session);
- runtime.session_count++;
- switch_mutex_unlock(runtime.session_table_mutex);
+ switch_mutex_lock(session_manager.session_table_mutex);
+ session->id = session_manager.session_id++;
+ switch_core_hash_insert(session_manager.session_table, session->uuid_str, session);
+ session_manager.session_count++;
+ switch_mutex_unlock(session_manager.session_table_mutex);
return session;
}
SWITCH_DECLARE(uint32_t) switch_core_session_count(void)
{
- return runtime.session_count;
+ return session_manager.session_count;
}
SWITCH_DECLARE(switch_size_t) switch_core_session_id(void)
{
- return runtime.session_id;
+ return session_manager.session_id;
}
@@ -867,21 +867,21 @@
SWITCH_DECLARE(uint32_t) switch_core_session_limit(uint32_t new_limit)
{
if (new_limit) {
- runtime.session_limit = new_limit;
+ session_manager.session_limit = new_limit;
}
- return runtime.session_limit;
+ return session_manager.session_limit;
}
void switch_core_session_init(switch_memory_pool_t *pool)
{
- memset(&runtime, 0, sizeof(runtime));
- runtime.session_limit = 1000;
- runtime.session_id = 1;
- runtime.memory_pool = pool;
- switch_core_hash_init(&runtime.session_table, runtime.memory_pool);
- switch_mutex_init(&runtime.session_table_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
+ memset(&session_manager, 0, sizeof(session_manager));
+ session_manager.session_limit = 1000;
+ session_manager.session_id = 1;
+ session_manager.memory_pool = pool;
+ switch_core_hash_init(&session_manager.session_table, session_manager.memory_pool);
+ switch_mutex_init(&session_manager.session_table_mutex, SWITCH_MUTEX_NESTED, session_manager.memory_pool);
}
Modified: freeswitch/trunk/src/switch_core_sqldb.c
==============================================================================
--- freeswitch/trunk/src/switch_core_sqldb.c (original)
+++ freeswitch/trunk/src/switch_core_sqldb.c Thu May 10 12:56:29 2007
@@ -40,7 +40,7 @@
switch_queue_t *sql_queue;
switch_memory_pool_t *memory_pool;
int thread_running;
-} runtime;
+} sql_manager;
static switch_status_t switch_core_db_persistant_execute_trans(switch_core_db_t *db, char *sql, uint32_t retries)
{
@@ -157,14 +157,14 @@
char *sql;
switch_size_t newlen;
- if (!runtime.event_db) {
- runtime.event_db = switch_core_db_handle();
+ if (!sql_manager.event_db) {
+ sql_manager.event_db = switch_core_db_handle();
}
- runtime.thread_running = 1;
+ sql_manager.thread_running = 1;
for (;;) {
- if (switch_queue_trypop(runtime.sql_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+ if (switch_queue_trypop(sql_manager.sql_queue, &pop) == SWITCH_STATUS_SUCCESS) {
sql = (char *) pop;
if (sql) {
@@ -199,7 +199,7 @@
if (trans && ((itterations == target) || nothing_in_queue)) {
- if (switch_core_db_persistant_execute_trans(runtime.event_db, sqlbuf, 1000) != SWITCH_STATUS_SUCCESS) {
+ if (switch_core_db_persistant_execute_trans(sql_manager.event_db, sqlbuf, 1000) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL thread unable to commit transaction, records lost!\n");
}
itterations = 0;
@@ -228,7 +228,7 @@
sql = switch_mprintf("insert into tasks values('%q','%q','%q','%q')",
switch_event_get_header(event, "task-id"),
switch_event_get_header(event, "task-desc"),
- switch_event_get_header(event, "task-group"), switch_event_get_header(event, "task-runtime")
+ switch_event_get_header(event, "task-group"), switch_event_get_header(event, "task-sql_manager")
);
break;
case SWITCH_EVENT_DEL_SCHEDULE:
@@ -236,8 +236,8 @@
sql = switch_mprintf("delete from tasks where task_id=%q", switch_event_get_header(event, "task-id"));
break;
case SWITCH_EVENT_RE_SCHEDULE:
- sql = switch_mprintf("update tasks set task_runtime='%q' where task_id=%q",
- switch_event_get_header(event, "task-runtime"), switch_event_get_header(event, "task-id"));
+ sql = switch_mprintf("update tasks set task_sql_manager='%q' where task_id=%q",
+ switch_event_get_header(event, "task-sql_manager"), switch_event_get_header(event, "task-id"));
break;
case SWITCH_EVENT_CHANNEL_DESTROY:
sql = switch_mprintf("delete from channels where uuid='%q'", switch_event_get_header(event, "unique-id"));
@@ -334,7 +334,7 @@
}
if (sql) {
- switch_queue_push(runtime.sql_queue, sql);
+ switch_queue_push(sql_manager.sql_queue, sql);
sql = NULL;
}
}
@@ -345,10 +345,10 @@
switch_thread_t *thread;
switch_threadattr_t *thd_attr;;
- runtime.memory_pool = pool;
+ sql_manager.memory_pool = pool;
/* Activate SQL database */
- if ((runtime.db = switch_core_db_handle()) == 0) {
+ if ((sql_manager.db = switch_core_db_handle()) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB!\n");
} else {
char create_channels_sql[] =
@@ -382,43 +382,43 @@
char create_tasks_sql[] =
"CREATE TABLE tasks (\n"
" task_id INTEGER(4),\n"
- " task_desc VARCHAR(255),\n" " task_group VARCHAR(255),\n" " task_runtime INTEGER(8)\n" ");\n";
+ " task_desc VARCHAR(255),\n" " task_group VARCHAR(255),\n" " task_sql_manager INTEGER(8)\n" ");\n";
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening DB\n");
- switch_core_db_exec(runtime.db, "drop table channels", NULL, NULL, NULL);
- switch_core_db_exec(runtime.db, "drop table calls", NULL, NULL, NULL);
- switch_core_db_exec(runtime.db, "drop table interfaces", NULL, NULL, NULL);
- switch_core_db_exec(runtime.db, "drop table tasks", NULL, NULL, NULL);
- switch_core_db_exec(runtime.db, create_channels_sql, NULL, NULL, NULL);
- switch_core_db_exec(runtime.db, create_calls_sql, NULL, NULL, NULL);
- switch_core_db_exec(runtime.db, create_interfaces_sql, NULL, NULL, NULL);
- switch_core_db_exec(runtime.db, create_tasks_sql, NULL, NULL, NULL);
+ switch_core_db_exec(sql_manager.db, "drop table channels", NULL, NULL, NULL);
+ switch_core_db_exec(sql_manager.db, "drop table calls", NULL, NULL, NULL);
+ switch_core_db_exec(sql_manager.db, "drop table interfaces", NULL, NULL, NULL);
+ switch_core_db_exec(sql_manager.db, "drop table tasks", NULL, NULL, NULL);
+ switch_core_db_exec(sql_manager.db, create_channels_sql, NULL, NULL, NULL);
+ switch_core_db_exec(sql_manager.db, create_calls_sql, NULL, NULL, NULL);
+ switch_core_db_exec(sql_manager.db, create_interfaces_sql, NULL, NULL, NULL);
+ switch_core_db_exec(sql_manager.db, create_tasks_sql, NULL, NULL, NULL);
if (switch_event_bind("core_db", SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event handler!\n");
}
}
- switch_queue_create(&runtime.sql_queue, SWITCH_SQL_QUEUE_LEN, runtime.memory_pool);
+ switch_queue_create(&sql_manager.sql_queue, SWITCH_SQL_QUEUE_LEN, sql_manager.memory_pool);
- switch_threadattr_create(&thd_attr, runtime.memory_pool);
+ switch_threadattr_create(&thd_attr, sql_manager.memory_pool);
switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&thread, thd_attr, switch_core_sql_thread, NULL, runtime.memory_pool);
- while (!runtime.thread_running) {
+ switch_thread_create(&thread, thd_attr, switch_core_sql_thread, NULL, sql_manager.memory_pool);
+ while (!sql_manager.thread_running) {
switch_yield(10000);
}
}
void switch_core_sqldb_stop(void)
{
- switch_queue_push(runtime.sql_queue, NULL);
+ switch_queue_push(sql_manager.sql_queue, NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Waiting for unfinished SQL transactions\n");
- while (switch_queue_size(runtime.sql_queue) > 0) {
+ while (switch_queue_size(sql_manager.sql_queue) > 0) {
switch_yield(10000);
}
- switch_core_db_close(runtime.db);
- switch_core_db_close(runtime.event_db);
+ switch_core_db_close(sql_manager.db);
+ switch_core_db_close(sql_manager.event_db);
}
Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c (original)
+++ freeswitch/trunk/src/switch_core_state_machine.c Thu May 10 12:56:29 2007
@@ -204,9 +204,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard HIBERNATE\n");
}
-
-#ifdef CRASH_PROT
-static switch_hash_t *stack_table;
+static switch_hash_t *stack_table = NULL;
#if defined (__GNUC__) && defined (LINUX)
#include <execinfo.h>
#include <stdio.h>
@@ -254,14 +252,13 @@
abort();
}
}
-#endif
+
void switch_core_state_machine_init(switch_memory_pool_t *pool)
{
- (void)0;
-#ifdef CRASH_PROT
- switch_core_hash_init(&stack_table, pool);
-#endif
+ if (runtime.crash_prot) {
+ switch_core_hash_init(&stack_table, pool);
+ }
}
SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
@@ -270,31 +267,33 @@
const switch_endpoint_interface_t *endpoint_interface;
const switch_state_handler_table_t *driver_state_handler = NULL;
const switch_state_handler_table_t *application_state_handler = NULL;
-
-#ifdef CRASH_PROT
- switch_thread_id_t thread_id = switch_thread_self();
+ switch_thread_id_t thread_id;
jmp_buf env;
int sig;
- signal(SIGSEGV, handle_fatality);
- signal(SIGFPE, handle_fatality);
+ if (runtime.crash_prot) {
+ thread_id = switch_thread_self();
+ signal(SIGSEGV, handle_fatality);
+ signal(SIGFPE, handle_fatality);
#ifndef WIN32
- signal(SIGBUS, handle_fatality);
+ signal(SIGBUS, handle_fatality);
#endif
- if ((sig = setjmp(env)) != 0) {
- switch_event_t *event;
+ if ((sig = setjmp(env)) != 0) {
+ switch_event_t *event;
- if (switch_event_create(&event, SWITCH_EVENT_SESSION_CRASH) == SWITCH_STATUS_SUCCESS) {
- switch_channel_event_set_data(session->channel, event);
- switch_event_fire(&event);
+ if (switch_event_create(&event, SWITCH_EVENT_SESSION_CRASH) == SWITCH_STATUS_SUCCESS) {
+ switch_channel_event_set_data(session->channel, event);
+ switch_event_fire(&event);
+ }
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Thread has crashed for channel %s\n", switch_channel_get_name(session->channel));
+ switch_channel_hangup(session->channel, SWITCH_CAUSE_CRASH);
+ } else {
+ apr_hash_set(stack_table, &thread_id, sizeof(thread_id), &env);
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Thread has crashed for channel %s\n", switch_channel_get_name(session->channel));
- switch_channel_hangup(session->channel, SWITCH_CAUSE_CRASH);
- } else {
- apr_hash_set(stack_table, &thread_id, sizeof(thread_id), &env);
}
-#endif
+
+
/*
Life of the channel. you have channel and pool in your session
everywhere you go you use the session to malloc with
@@ -646,9 +645,9 @@
done:
switch_mutex_unlock(session->mutex);
-#ifdef CRASH_PROT
- apr_hash_set(stack_table, &thread_id, sizeof(thread_id), NULL);
-#endif
+ if (runtime.crash_prot) {
+ apr_hash_set(stack_table, &thread_id, sizeof(thread_id), NULL);
+ }
session->thread_running = 0;
}
1
0
10 May '07
Author: anthm
Date: Thu May 10 12:15:07 2007
New Revision: 5122
Modified:
freeswitch/trunk/conf/sofia.conf.xml
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
Log:
fix sofia register stuff (update to this one if you use gateways)
Modified: freeswitch/trunk/conf/sofia.conf.xml
==============================================================================
--- freeswitch/trunk/conf/sofia.conf.xml (original)
+++ freeswitch/trunk/conf/sofia.conf.xml Thu May 10 12:15:07 2007
@@ -24,6 +24,8 @@
<!--<param name="expire-seconds" value="60"/>-->
<!--/// do not register ///-->
<!--<param name="register" value="false"/>-->
+ <!--How many seconds before a retry when a failure or timeout occurs -->
+ <!--<param name="retry_seconds" value="30"/>-->
<!--</gateway>-->
</gateways>
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Thu May 10 12:15:07 2007
@@ -1060,8 +1060,11 @@
for (gp = profile->gateways; gp; gp = gp->next) {
assert(gp->state < REG_STATE_LAST);
- stream->write_function(stream, "%25s\t%s\t %32s\t%s\n", gp->name, "gateway", gp->register_to, sofia_state_names[gp->state]);
-
+ stream->write_function(stream, "%25s\t%s\t %32s\t%s", gp->name, "gateway", gp->register_to, sofia_state_names[gp->state]);
+ if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) {
+ stream->write_function(stream, " (retry: %ds)", gp->retry - time(NULL));
+ }
+ stream->write_function(stream, "\n");
}
}
@@ -1087,6 +1090,7 @@
return SWITCH_STATUS_SUCCESS;
}
+
if (!strcasecmp(argv[1], "start")) {
if (argc > 2 && !strcasecmp(argv[2], "reloadxml")) {
if ((xml_root = switch_xml_open_root(1, &err))) {
@@ -1107,6 +1111,34 @@
return SWITCH_STATUS_SUCCESS;
}
+ if (!strcasecmp(argv[1], "register")) {
+ char *gname = argv[2];
+ sofia_gateway_t *gateway_ptr;
+
+ if (switch_strlen_zero(gname)) {
+ stream->write_function(stream, "No gateway name provided!\n");
+ goto done;
+ }
+
+ if (!strcasecmp(gname, "all")) {
+ for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
+ gateway_ptr->retry = 0;
+ gateway_ptr->state = REG_STATE_UNREGED;
+ }
+ stream->write_function(stream, "+OK\n");
+ } else if ((gateway_ptr = sofia_reg_find_gateway(gname))) {
+ gateway_ptr->retry = 0;
+ gateway_ptr->state = REG_STATE_UNREGED;
+ stream->write_function(stream, "+OK\n");
+ sofia_reg_release_gateway(gateway_ptr);
+ } else {
+ stream->write_function(stream, "Invalid gateway!\n");
+ }
+
+ goto done;
+ }
+
+
if (!strcasecmp(argv[1], "stop") || !strcasecmp(argv[1], "restart")) {
int rsec = 30;
int diff = (int) (time(NULL) - profile->started);
@@ -1134,6 +1166,8 @@
}
}
+ done:
+
if (profile) {
sofia_glue_release_profile(profile);
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Thu May 10 12:15:07 2007
@@ -192,6 +192,7 @@
time_t expires;
time_t retry;
uint32_t flags;
+ int32_t retry_seconds;
reg_state_t state;
switch_memory_pool_t *pool;
struct sofia_gateway *next;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Thu May 10 12:15:07 2007
@@ -480,8 +480,9 @@
*extension = NULL,
*proxy = NULL,
*context = "default",
- *expire_seconds = "3600";
-
+ *expire_seconds = "3600",
+ *retry_seconds = "30";
+
gateway->pool = profile->pool;
gateway->profile = profile;
gateway->name = switch_core_strdup(gateway->pool, name);
@@ -512,6 +513,8 @@
context = val;
} else if (!strcmp(var, "expire-seconds")) {
expire_seconds = val;
+ } else if (!strcmp(var, "retry-seconds")) {
+ retry_seconds = val;
}
}
@@ -540,6 +543,12 @@
if (!switch_true(register_str)) {
gateway->state = REG_STATE_NOREG;
}
+
+ gateway->retry_seconds = atoi(retry_seconds);
+ if (gateway->retry_seconds < 10) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "INVALID: retry_seconds correcting the value to 30\n");
+ gateway->retry_seconds = 30;
+ }
gateway->register_scheme = switch_core_strdup(gateway->pool, scheme);
gateway->register_context = switch_core_strdup(gateway->pool, context);
gateway->register_realm = switch_core_strdup(gateway->pool, realm);
@@ -568,9 +577,7 @@
}
gateway->freq -= 2;
- gateway->next = profile->gateways;
- profile->gateways = gateway;
-
+
if ((gp = sofia_reg_find_gateway(gateway->name))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", gateway->name);
sofia_reg_release_gateway(gp);
@@ -581,6 +588,8 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate contact '%s'\n", gateway->register_from);
sofia_reg_release_gateway(gp);
} else {
+ gateway->next = profile->gateways;
+ profile->gateways = gateway;
sofia_reg_add_gateway(gateway->name, gateway);
sofia_reg_add_gateway(gateway->register_from, gateway);
sofia_reg_add_gateway(gateway->register_contact, gateway);
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Thu May 10 12:15:07 2007
@@ -92,7 +92,7 @@
SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
NUTAG_REGISTRAR(gateway_ptr->register_proxy),
NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());
- gateway_ptr->retry = now + 10;
+ gateway_ptr->retry = now + gateway_ptr->retry_seconds;
} else {
nua_unregister(gateway_ptr->nh,
SIPTAG_FROM_STR(gateway_ptr->register_from),
@@ -102,7 +102,6 @@
NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());
}
- gateway_ptr->retry = now + time(NULL);
gateway_ptr->state = REG_STATE_TRYING;
} else {
@@ -111,6 +110,7 @@
}
break;
+ case REG_STATE_FAILED:
case REG_STATE_TRYING:
if (gateway_ptr->retry && now >= gateway_ptr->retry) {
gateway_ptr->state = REG_STATE_UNREGED;
1
0
[commit] r5120 - in freeswitch/trunk: . src/include src/mod/endpoints/mod_sofia
by Freeswitch SVN 10 May '07
by Freeswitch SVN 10 May '07
10 May '07
Author: mikej
Date: Thu May 10 11:23:07 2007
New Revision: 5120
Added:
freeswitch/trunk/src/mod/endpoints/mod_sofia/Makefile.am
Removed:
freeswitch/trunk/src/mod/endpoints/mod_sofia/Makefile
Modified:
freeswitch/trunk/configure.in
freeswitch/trunk/src/include/switch.h
Log:
switch mod_sofia to use a Makefile.am instead of Makefile for better dependency tracking.. you may need to re-bootstrap after this update
Modified: freeswitch/trunk/configure.in
==============================================================================
--- freeswitch/trunk/configure.in (original)
+++ freeswitch/trunk/configure.in Thu May 10 11:23:07 2007
@@ -332,6 +332,7 @@
src/Makefile
src/mod/Makefile
src/mod/event_handlers/mod_cdr/Makefile
+ src/mod/endpoints/mod_sofia/Makefile
src/include/switch_am_config.h
build/getlib.sh
build/modmake.rules])
Modified: freeswitch/trunk/src/include/switch.h
==============================================================================
--- freeswitch/trunk/src/include/switch.h (original)
+++ freeswitch/trunk/src/include/switch.h Thu May 10 11:23:07 2007
@@ -51,6 +51,7 @@
#define FREESWITCH_OID_PREFIX ".1.3.6.1.4.1." FREESWITCH_PEN
#define FREESWITCH_ITAD "543"
#define __EXTENSIONS__ 1
+#define _XOPEN_SOURCE 600
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
Added: freeswitch/trunk/src/mod/endpoints/mod_sofia/Makefile.am
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/Makefile.am Thu May 10 11:23:07 2007
@@ -0,0 +1,62 @@
+AM_CFLAGS = $(SWITCH_AM_CFLAGS)
+AM_CPPFLAGS = $(SWITCH_AM_CXXFLAGS)
+AM_LDFLAGS = $(SWITCH_AM_LDFLAGS)
+#we should set all these vars from configure, no reason to have these in each Makefile.am
+LIBTOOL = echo "`link=\`echo $@|grep .la;echo $@|grep .so;echo $@|grep .dll\`;if test -n "$$link"; then echo Creating $@;fi`";`if test -z "$(VERBOSE)" ; \
+then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(SHELL) $(switch_builddir)/libtool; fi`
+AM_MAKEFLAGS=`test -n "$(VERBOSE)" || echo -s`
+# Dirty trick to override the link output
+LIBS+=> $(MODNAME).log || error="yes";if test -n "$(VERBOSE)" -o "$$error" = "yes";then cat $(MODNAME).log;fi;if test "$$error" = "yes";then exit 1;fi
+
+moddir=$(prefix)/mod
+
+MODNAME=mod_sofia
+
+BASE=../../../..
+
+SOFIA_DIR=$(BASE)/libs/sofia-sip
+SOFIAUA_DIR=$(SOFIA_DIR)/libsofia-sip-ua
+SOFIALA=$(SOFIAUA_DIR)/libsofia-sip-ua.la
+
+mod_LTLIBRARIES = mod_sofia.la
+mod_sofia_la_SOURCES = mod_sofia.c sofia.c sofia_glue.c sofia_presence.c sofia_reg.c mod_sofia.h
+mod_sofia_la_CFLAGS = $(AM_CFLAGS)
+mod_sofia_la_CFLAGS += -I. -I$(SOFIAUA_DIR)/bnf -I$(SOFIAUA_DIR)/features
+mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/http -I$(SOFIAUA_DIR)/ipt
+mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/iptsec -I$(SOFIAUA_DIR)/msg
+mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/nea -I$(SOFIAUA_DIR)/nta
+mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/nth -I$(SOFIAUA_DIR)/nua
+mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/sdp -I$(SOFIAUA_DIR)/sip
+mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/soa -I$(SOFIAUA_DIR)/sresolv
+mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/stun -I$(SOFIAUA_DIR)/su
+mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/tport -I$(SOFIAUA_DIR)/url
+mod_sofia_la_LIBADD = $(SOFIALA) $(switch_builddir)/libfreeswitch.la
+mod_sofia_la_LDFLAGS = -module -avoid-version -no-undefined
+
+if ADD_ODBC
+mod_sofia_la_CFLAGS += -DSWITCH_HAVE_ODBC
+endif
+
+if ISMAC
+mod_sofia_la_LDFLAGS += -framework CoreFoundation -framework SystemConfiguration
+endif
+
+BUILT_SOURCES = $(SOFIALA)
+
+$(mod_sofia_la_SOURCES) : $(BUILT_SOURCES)
+
+$(SOFIALA): $(SOFIA_DIR) $(SOFIA_DIR)/.update
+ cd $(SOFIA_DIR) && $(MAKE)
+ $(TOUCH_TARGET)
+
+../../../../libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h: $(SOFIALA)
+
+install-data-am: $(DESTDIR)$(PREFIX)/$(moddir)/$(MODNAME).$(DYNAMIC_LIB_EXTEN)
+
+$(DESTDIR)$(PREFIX)/$(moddir)/$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).la
+ @echo installing $(MODNAME).$(DYNAMIC_LIB_EXTEN)
+ @if [ -f .libs/$(MODNAME).$(DYNAMIC_LIB_EXTEN) ] ; then \
+ $(LIBTOOL) --mode=install $(INSTALL) .libs/$(MODNAME).$(DYNAMIC_LIB_EXTEN) $(DESTDIR)$(PREFIX)/$(moddir) >/dev/null ; \
+ else \
+ $(LIBTOOL) --mode=install $(INSTALL) $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(DESTDIR)$(PREFIX)/$(moddir) >/dev/null ; \
+ fi
1
0
[commit] r5118 - in freeswitch/trunk/src: . mod/applications/mod_dptools mod/endpoints/mod_sofia
by Freeswitch SVN 10 May '07
by Freeswitch SVN 10 May '07
10 May '07
Author: anthm
Date: Thu May 10 10:11:26 2007
New Revision: 5118
Modified:
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/Makefile
freeswitch/trunk/src/switch_core_session.c
Log:
update
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Thu May 10 10:11:26 2007
@@ -340,7 +340,7 @@
static void export_function(switch_core_session_t *session, char *data)
{
switch_channel_t *channel;
- char *exports, *new_exports = NULL, *new_exports_d = NULL, *var, *val = NULL;
+ char *exports, *new_exports = NULL, *new_exports_d = NULL, *var, *val = NULL, *var_name = NULL;
int local = 1;
channel = switch_core_session_get_channel(session);
@@ -361,11 +361,13 @@
}
if (!strncasecmp(var, "nolocal:", 8)) {
- var += 8;
+ var_name = var + 8;
local = 0;
+ } else {
+ var_name = var;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXPORT %s[%s]=[%s]\n", local ? "" : "(REMOTE ONLY) ", var, val ? val : "UNDEF");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXPORT %s[%s]=[%s]\n", local ? "" : "(REMOTE ONLY) ", var_name, val ? val : "UNDEF");
switch_channel_set_variable(channel, var, val);
if (var && val) {
@@ -375,9 +377,9 @@
} else {
new_exports = var;
}
- if (local) {
- switch_channel_set_variable(channel, SWITCH_EXPORT_VARS_VARIABLE, new_exports);
- }
+
+ switch_channel_set_variable(channel, SWITCH_EXPORT_VARS_VARIABLE, new_exports);
+
switch_safe_free(new_exports_d);
}
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/Makefile (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/Makefile Thu May 10 10:11:26 2007
@@ -15,7 +15,7 @@
LOCAL_CFLAGS += `if test -f $(BASE)/.libs/libfreeswitch_la-switch_odbc.o ; then echo -DSWITCH_HAVE_ODBC; fi ;`
LOCAL_OBJS=sofia.o sofia_glue.o sofia_presence.o sofia_reg.o
-LOCAL_SOURCES=sofia.c sofia_glue.c sofia_presense.c sofia_reg.c mod_sofia.c
+LOCAL_SOURCES=sofia.c sofia_glue.c sofia_presense.c sofia_reg.c mod_sofia.c mod_sofia.h
SOFIALA=$(SOFIAUA_DIR)/libsofia-sip-ua.la
Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c (original)
+++ freeswitch/trunk/src/switch_core_session.c Thu May 10 10:11:26 2007
@@ -282,7 +282,11 @@
for (x = 0; x < argc; x++) {
char *val;
if ((val = switch_channel_get_variable(channel, argv[x]))) {
- switch_channel_set_variable(peer_channel, argv[x], val);
+ char *var = argv[x];
+ if (!strncasecmp(var, "nolocal:", 8)) {
+ var += 8;
+ }
+ switch_channel_set_variable(peer_channel, var, val);
}
}
}
1
0
09 May '07
Author: anthm
Date: Wed May 9 18:13:18 2007
New Revision: 5117
Modified:
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
Log:
update
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Wed May 9 18:13:18 2007
@@ -341,6 +341,7 @@
{
switch_channel_t *channel;
char *exports, *new_exports = NULL, *new_exports_d = NULL, *var, *val = NULL;
+ int local = 1;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -359,7 +360,12 @@
}
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXPORT [%s]=[%s]\n", var, val ? val : "UNDEF");
+ if (!strncasecmp(var, "nolocal:", 8)) {
+ var += 8;
+ local = 0;
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXPORT %s[%s]=[%s]\n", local ? "" : "(REMOTE ONLY) ", var, val ? val : "UNDEF");
switch_channel_set_variable(channel, var, val);
if (var && val) {
@@ -369,7 +375,9 @@
} else {
new_exports = var;
}
- switch_channel_set_variable(channel, SWITCH_EXPORT_VARS_VARIABLE, new_exports);
+ if (local) {
+ switch_channel_set_variable(channel, SWITCH_EXPORT_VARS_VARIABLE, new_exports);
+ }
switch_safe_free(new_exports_d);
}
}
1
0
[commit] r5115 - in freeswitch/trunk: libs/curl libs/curl/lib src src/include src/mod/applications/mod_bridgecall src/mod/applications/mod_esf
by Freeswitch SVN 09 May '07
by Freeswitch SVN 09 May '07
09 May '07
Author: anthm
Date: Wed May 9 15:44:15 2007
New Revision: 5115
Modified:
freeswitch/trunk/libs/curl/lib/config.h.in
freeswitch/trunk/libs/curl/mkinstalldirs
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c
freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_core_session.c
freeswitch/trunk/src/switch_core_state_machine.c
freeswitch/trunk/src/switch_ivr.c
freeswitch/trunk/src/switch_ivr_async.c
freeswitch/trunk/src/switch_ivr_bridge.c
freeswitch/trunk/src/switch_ivr_originate.c
freeswitch/trunk/src/switch_rtp.c
Log:
these aren't the droids you're looking for....
Modified: freeswitch/trunk/libs/curl/lib/config.h.in
==============================================================================
--- freeswitch/trunk/libs/curl/lib/config.h.in (original)
+++ freeswitch/trunk/libs/curl/lib/config.h.in Wed May 9 15:44:15 2007
@@ -621,16 +621,16 @@
/* Define to the function return type for send. */
#undef SEND_TYPE_RETV
-/* The size of a `curl_off_t', as computed by sizeof. */
+/* The size of `curl_off_t', as computed by sizeof. */
#undef SIZEOF_CURL_OFF_T
-/* The size of a `long', as computed by sizeof. */
+/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
-/* The size of a `size_t', as computed by sizeof. */
+/* The size of `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T
-/* The size of a `time_t', as computed by sizeof. */
+/* The size of `time_t', as computed by sizeof. */
#undef SIZEOF_TIME_T
/* Define to 1 if you have the ANSI C header files. */
@@ -685,7 +685,7 @@
/* type to use in place of in_addr_t if not defined */
#undef in_addr_t
-/* Define to `unsigned' if <sys/types.h> does not define. */
+/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
/* type to use in place of socklen_t if not defined */
Modified: freeswitch/trunk/libs/curl/mkinstalldirs
==============================================================================
--- freeswitch/trunk/libs/curl/mkinstalldirs (original)
+++ freeswitch/trunk/libs/curl/mkinstalldirs Wed May 9 15:44:15 2007
@@ -1,40 +1,150 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <friedman(a)prep.ai.mit.edu>
-# Created: 1993-05-16
-# Public domain
-# $Id: mkinstalldirs,v 1.2 2000/01/10 23:36:14 bagder Exp $
+scriptversion=2004-02-15.20
+
+# Original author: Noah Friedman <friedman(a)prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain.
+#
+# This file is maintained in Automake, please report
+# bugs to <bug-automake(a)gnu.org> or send patches to
+# <automake-patches(a)gnu.org>.
errstatus=0
+dirmode=""
+
+usage="\
+Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
+
+Create each directory DIR (with mode MODE, if specified), including all
+leading file name components.
+
+Report bugs to <bug-automake(a)gnu.org>."
+
+# process command line arguments
+while test $# -gt 0 ; do
+ case $1 in
+ -h | --help | --h*) # -h for help
+ echo "$usage"
+ exit 0
+ ;;
+ -m) # -m PERM arg
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ dirmode=$1
+ shift
+ ;;
+ --version)
+ echo "$0 $scriptversion"
+ exit 0
+ ;;
+ --) # stop option processing
+ shift
+ break
+ ;;
+ -*) # unknown option
+ echo "$usage" 1>&2
+ exit 1
+ ;;
+ *) # first non-opt arg
+ break
+ ;;
+ esac
+done
+
+for file
+do
+ if test -d "$file"; then
+ shift
+ else
+ break
+ fi
+done
+
+case $# in
+ 0) exit 0 ;;
+esac
+
+# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
+# mkdir -p a/c at the same time, both will detect that a is missing,
+# one will create a, then the other will try to create a and die with
+# a "File exists" error. This is a problem when calling mkinstalldirs
+# from a parallel make. We use --version in the probe to restrict
+# ourselves to GNU mkdir, which is thread-safe.
+case $dirmode in
+ '')
+ if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
+ echo "mkdir -p -- $*"
+ exec mkdir -p -- "$@"
+ else
+ # On NextStep and OpenStep, the `mkdir' command does not
+ # recognize any option. It will interpret all options as
+ # directories to create, and then abort because `.' already
+ # exists.
+ test -d ./-p && rmdir ./-p
+ test -d ./--version && rmdir ./--version
+ fi
+ ;;
+ *)
+ if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
+ test ! -d ./--version; then
+ echo "mkdir -m $dirmode -p -- $*"
+ exec mkdir -m "$dirmode" -p -- "$@"
+ else
+ # Clean up after NextStep and OpenStep mkdir.
+ for d in ./-m ./-p ./--version "./$dirmode";
+ do
+ test -d $d && rmdir $d
+ done
+ fi
+ ;;
+esac
for file
do
- set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
- shift
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
- pathcomp=
- for d
- do
- pathcomp="$pathcomp$d"
- case "$pathcomp" in
- -* ) pathcomp=./$pathcomp ;;
- esac
-
- if test ! -d "$pathcomp"; then
- echo "mkdir $pathcomp" 1>&2
-
- mkdir "$pathcomp" || lasterr=$?
-
- if test ! -d "$pathcomp"; then
- errstatus=$lasterr
- fi
- fi
+ pathcomp=
+ for d
+ do
+ pathcomp="$pathcomp$d"
+ case $pathcomp in
+ -*) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp"
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ else
+ if test ! -z "$dirmode"; then
+ echo "chmod $dirmode $pathcomp"
+ lasterr=""
+ chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+ if test ! -z "$lasterr"; then
+ errstatus=$lasterr
+ fi
+ fi
+ fi
+ fi
- pathcomp="$pathcomp/"
- done
+ pathcomp="$pathcomp/"
+ done
done
exit $errstatus
-# mkinstalldirs ends here
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Wed May 9 15:44:15 2007
@@ -95,6 +95,7 @@
#define SWITCH_PATH_SEPARATOR "/"
#endif
#define SWITCH_URL_SEPARATOR "://"
+#define SWITCH_BYPASS_MEDIA_VARIABLE "bypass_media"
#define SWITCH_ENDPOINT_DISPOSITION_VARIABLE "endpoint_disposition"
#define SWITCH_HOLD_MUSIC_VARIABLE "hold_music"
#define SWITCH_EXPORT_VARS_VARIABLE "export_vars"
@@ -544,7 +545,7 @@
CF_TAGGED = (1 << 10) - Channel is tagged
CF_WINNER = (1 << 11) - Channel is the winner
CF_CONTROLLED = (1 << 12) - Channel is under control
-CF_NOMEDIA = (1 << 13) - Channel has no media
+CF_BYPASS_MEDIA = (1 << 13) - Channel has no media
CF_SUSPEND = (1 << 14) - Suspend i/o
CF_EVENT_PARSE = (1 << 15) - Suspend control events
CF_REPEAT_STATE = (1 << 16) - Tell the state machine to repeat a state
@@ -571,7 +572,7 @@
CF_TAGGED = (1 << 10),
CF_WINNER = (1 << 11),
CF_CONTROLLED = (1 << 12),
- CF_NOMEDIA = (1 << 13),
+ CF_BYPASS_MEDIA = (1 << 13),
CF_SUSPEND = (1 << 14),
CF_EVENT_PARSE = (1 << 15),
CF_REPEAT_STATE = (1 << 16),
Modified: freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c Wed May 9 15:44:15 2007
@@ -61,11 +61,11 @@
do_continue = switch_true(var);
}
- if (switch_channel_test_flag(caller_channel, CF_NOMEDIA)
- || ((var = switch_channel_get_variable(caller_channel, "no_media")) && switch_true(var))) {
+ if (switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA)
+ || ((var = switch_channel_get_variable(caller_channel, SWITCH_BYPASS_MEDIA_VARIABLE)) && switch_true(var))) {
if (!switch_channel_test_flag(caller_channel, CF_ANSWERED)
&& !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
- switch_channel_set_flag(caller_channel, CF_NOMEDIA);
+ switch_channel_set_flag(caller_channel, CF_BYPASS_MEDIA);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already up, delaying point-to-point mode 'till both legs are up.\n");
no_media_bridge = 1;
@@ -107,7 +107,7 @@
switch_ivr_nomedia(switch_core_session_get_uuid(peer_session), SMF_FORCE);
switch_ivr_signal_bridge(session, peer_session);
} else {
- if (switch_channel_test_flag(caller_channel, CF_NOMEDIA)) {
+ if (switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA)) {
switch_ivr_signal_bridge(session, peer_session);
} else {
switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
Modified: freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c Wed May 9 15:44:15 2007
@@ -102,7 +102,7 @@
}
- if (switch_true(switch_channel_get_variable(channel, "no_media"))) {
+ if (switch_true(switch_channel_get_variable(channel, SWITCH_BYPASS_MEDIA_VARIABLE))) {
switch_core_session_message_t msg = { 0 };
ready = SEND_TYPE_NOMEDIA;
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Wed May 9 15:44:15 2007
@@ -431,7 +431,7 @@
assert(channel != NULL);
- if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE))) {
+ if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
switch_core_session_t *session;
if ((session = switch_core_session_locate(uuid))) {
switch_channel_set_flag(switch_core_session_get_channel(session), flags);
@@ -449,7 +449,7 @@
assert(channel != NULL);
- if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE))) {
+ if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
switch_core_session_t *session;
if ((session = switch_core_session_locate(uuid))) {
switch_channel_clear_flag(switch_core_session_get_channel(session), flags);
Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c (original)
+++ freeswitch/trunk/src/switch_core_session.c Wed May 9 15:44:15 2007
@@ -296,8 +296,8 @@
switch_channel_set_variable(peer_channel, SWITCH_MAX_FORWARDS_VARIABLE, val);
}
- if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
- switch_channel_set_flag(peer_channel, CF_NOMEDIA);
+ if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
+ switch_channel_set_flag(peer_channel, CF_BYPASS_MEDIA);
}
if (profile) {
@@ -606,6 +606,7 @@
switch_ivr_deactivate_unicast(session);
switch_channel_clear_flag(channel, CF_BREAK);
+
}
@@ -996,7 +997,7 @@
goto done;
}
- if (switch_channel_test_flag(session->channel, CF_NOMEDIA) && !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA)) {
+ if (switch_channel_test_flag(session->channel, CF_BYPASS_MEDIA) && !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Application %s Cannot be used with NO_MEDIA mode!\n",
extension->current_application->application_name);
status = SWITCH_STATUS_FALSE;
Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c (original)
+++ freeswitch/trunk/src/switch_core_state_machine.c Wed May 9 15:44:15 2007
@@ -129,7 +129,7 @@
return;
}
- if (switch_channel_test_flag(session->channel, CF_NOMEDIA) && !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA)) {
+ if (switch_channel_test_flag(session->channel, CF_BYPASS_MEDIA) && !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Application %s Cannot be used with NO_MEDIA mode!\n",
extension->current_application->application_name);
switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Wed May 9 15:44:15 2007
@@ -271,7 +271,8 @@
unsigned long CMD_HANGUP = switch_hashfunc_default("hangup", &hlen);
unsigned long CMD_NOMEDIA = switch_hashfunc_default("nomedia", &hlen);
unsigned long CMD_UNICAST = switch_hashfunc_default("unicast", &hlen);
-
+ char *lead_frames = switch_event_get_header(event, "lead-frames");
+
assert(channel != NULL);
assert(event != NULL);
@@ -285,6 +286,21 @@
switch_channel_set_flag(channel, CF_EVENT_PARSE);
+ if (lead_frames) {
+ switch_frame_t *read_frame;
+ int frame_count = atoi(lead_frames);
+ switch_status_t status;
+
+ while(frame_count > 0) {
+ status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+ if (!SWITCH_READ_ACCEPTABLE(status)) {
+ return status;
+ }
+ if (!switch_test_flag(read_frame, SFF_CNG)) {
+ frame_count--;
+ }
+ }
+ }
if (cmd_hash == CMD_EXECUTE) {
const switch_application_interface_t *application_interface;
@@ -304,7 +320,7 @@
switch_channel_set_flag(channel, CF_BROADCAST);
for (x = 0; x < loops || loops < 0; x++) {
switch_core_session_exec(session, application_interface, app_arg);
- if (!switch_channel_test_flag(channel, CF_BROADCAST)) {
+ if (!switch_channel_ready(channel) || !switch_channel_test_flag(channel, CF_BROADCAST)) {
break;
}
}
@@ -718,9 +734,9 @@
swap = 1;
}
- if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
+ if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
status = SWITCH_STATUS_SUCCESS;
- switch_channel_clear_flag(channel, CF_NOMEDIA);
+ switch_channel_clear_flag(channel, CF_BYPASS_MEDIA);
switch_core_session_receive_message(session, &msg);
if ((flags & SMF_REBRIDGE)
@@ -773,8 +789,8 @@
swap = 1;
}
- if ((flags & SMF_FORCE) || !switch_channel_test_flag(channel, CF_NOMEDIA)) {
- switch_channel_set_flag(channel, CF_NOMEDIA);
+ if ((flags & SMF_FORCE) || !switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
+ switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
switch_core_session_receive_message(session, &msg);
if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
(other_session = switch_core_session_locate(other_uuid))) {
Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c (original)
+++ freeswitch/trunk/src/switch_ivr_async.c Wed May 9 15:44:15 2007
@@ -779,10 +779,10 @@
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
- if ((nomedia = switch_channel_test_flag(channel, CF_NOMEDIA))) {
+ if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
switch_ivr_media(uuid, SMF_REBRIDGE);
}
-
+
if ((p = strchr(mypath, ':'))) {
app = mypath;
*p++ = '\0';
@@ -802,10 +802,11 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
if ((flags & SMF_LOOP)) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
}
-
+
switch_core_session_queue_private_event(other_session, &event);
}
@@ -819,6 +820,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
if ((flags & SMF_LOOP)) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
}
Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c (original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c Wed May 9 15:44:15 2007
@@ -52,7 +52,6 @@
switch_input_callback_function_t input_callback;
switch_core_session_message_t *message, msg = { 0 };
void *user_data;
-
switch_channel_t *chan_a, *chan_b;
switch_frame_t *read_frame;
switch_core_session_t *session_a, *session_b;
@@ -81,7 +80,7 @@
switch_channel_state_t b_state;
switch_status_t status;
switch_event_t *event;
-
+
/* if you really want to make sure it's not ready, test it twice because it might be just a break */
if (!switch_channel_ready(chan_a) && !switch_channel_ready(chan_a)) {
break;
@@ -97,12 +96,24 @@
break;
}
+ if (switch_channel_test_flag(chan_a, CF_SUSPEND) || switch_channel_test_flag(chan_b, CF_SUSPEND)) {
+ switch_yield(100000);
+ continue;
+ }
+
if (switch_core_session_dequeue_private_event(session_a, &event) == SWITCH_STATUS_SUCCESS) {
switch_channel_set_flag(chan_b, CF_SUSPEND);
+ msg.string_arg = data->b_uuid;
+ msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
+ msg.from = __FILE__;
+ switch_core_session_receive_message(session_a, &msg);
switch_ivr_parse_event(session_a, event);
+ msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
+ switch_core_session_receive_message(session_a, &msg);
switch_channel_clear_flag(chan_b, CF_SUSPEND);
switch_event_destroy(&event);
}
+
/* if 1 channel has DTMF pass it to the other */
if (switch_channel_has_dtmf(chan_a)) {
@@ -154,11 +165,6 @@
}
- if (switch_channel_test_flag(chan_a, CF_SUSPEND) || switch_channel_test_flag(chan_b, CF_SUSPEND)) {
- switch_yield(10000);
- continue;
- }
-
/* read audio from 1 channel and write it to the other */
status = switch_core_session_read_frame(session_a, &read_frame, -1, stream_id);
@@ -180,6 +186,7 @@
msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
msg.from = __FILE__;
switch_core_session_receive_message(session_a, &msg);
+
switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK);
switch_channel_set_variable(chan_a, SWITCH_BRIDGE_VARIABLE, NULL);
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Wed May 9 15:44:15 2007
@@ -607,7 +607,7 @@
}
if (session && (read_codec = switch_core_session_get_read_codec(session)) &&
- (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA))) {
+ (ringback_data || !switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA))) {
if (!(pass = (uint8_t) switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
if (switch_core_codec_init(&write_codec,
@@ -713,7 +713,7 @@
}
/* read from the channel while we wait if the audio is up on it */
- if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA)) &&
+ if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA)) &&
(switch_channel_test_flag(caller_channel, CF_ANSWERED)
|| switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA))) {
switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
@@ -777,7 +777,7 @@
idx = IDX_CANCEL;
}
- if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA))) {
+ if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA))) {
switch_core_session_reset(session);
}
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Wed May 9 15:44:15 2007
@@ -375,7 +375,7 @@
done:
if (status != SWITCH_STATUS_SUCCESS) {
- rtp_session->ready = 0;
+ rtp_session->ready = 1;
}
if (new_sock) {
@@ -817,7 +817,7 @@
switch_status_t status;
uint8_t check = 1;
stfu_frame_t *jb_frame;
-
+
if (!rtp_session->timer.interval) {
rtp_session->last_time = switch_time_now();
}
@@ -825,7 +825,7 @@
while (switch_rtp_ready(rtp_session)) {
bytes = sizeof(rtp_msg_t);
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *) &rtp_session->recv_msg, &bytes);
-
+
if (!SWITCH_STATUS_IS_BREAK(status) && rtp_session->timer.interval) {
switch_core_timer_step(&rtp_session->timer);
}
1
0
09 May '07
Author: anthm
Date: Wed May 9 15:30:41 2007
New Revision: 5114
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
Log:
change some log levels
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Wed May 9 15:30:41 2007
@@ -74,9 +74,9 @@
*/
static switch_status_t sofia_on_init(switch_core_session_t *session)
{
- private_object_t *tech_pvt;
switch_channel_t *channel = NULL;
-
+ private_object_t *tech_pvt;
+
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -86,8 +86,7 @@
tech_pvt->read_frame.buflen = SWITCH_RTP_MAX_BUF_LEN;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SOFIA INIT\n");
- if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
- switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
+ if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
sofia_glue_tech_absorb_sdp(tech_pvt);
}
@@ -283,9 +282,8 @@
if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_channel_test_flag(channel, CF_OUTBOUND)) {
switch_set_flag_locked(tech_pvt, TFLAG_ANS);
- if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
+ if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
char *sdp = NULL;
- switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
if ((sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
tech_pvt->local_sdp_str = switch_core_session_strdup(session, sdp);
}
@@ -692,8 +690,7 @@
switch_core_session_t *other_session;
switch_channel_t *other_channel;
char *ip = NULL, *port = NULL;
-
- switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
+ switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
tech_pvt->local_sdp_str = NULL;
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
&& (other_session = switch_core_session_locate(uuid))) {
@@ -712,7 +709,8 @@
}
break;
case SWITCH_MESSAGE_INDICATE_MEDIA:{
- switch_clear_flag_locked(tech_pvt, TFLAG_NOMEDIA);
+ uint32_t count = 0;
+ switch_channel_clear_flag(channel, CF_BYPASS_MEDIA);
tech_pvt->local_sdp_str = NULL;
if (!switch_rtp_ready(tech_pvt->rtp_session)) {
sofia_glue_tech_prepare_codecs(tech_pvt);
@@ -723,8 +721,18 @@
}
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
sofia_glue_do_invite(session);
- while (!switch_rtp_ready(tech_pvt->rtp_session) && switch_channel_get_state(channel) < CS_HANGUP) {
- switch_yield(1000);
+
+ /* wait for rtp to start and first real frame to arrive */
+ tech_pvt->read_frame.datalen = 0;
+ while (switch_test_flag(tech_pvt, TFLAG_IO) && switch_channel_get_state(channel) < CS_HANGUP && !switch_rtp_ready(tech_pvt->rtp_session)) {
+ if (++count > 1000) {
+ return SWITCH_STATUS_FALSE;
+ }
+ if (!switch_rtp_ready(tech_pvt->rtp_session)) {
+ switch_yield(1000);
+ continue;
+ }
+ break;
}
}
break;
@@ -741,7 +749,7 @@
}
break;
case SWITCH_MESSAGE_INDICATE_BRIDGE:
-
+
if (switch_test_flag(tech_pvt, TFLAG_XFER)) {
switch_clear_flag_locked(tech_pvt, TFLAG_XFER);
if (msg->pointer_arg) {
@@ -825,9 +833,8 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
/* Transmit 183 Progress with SDP */
- if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
+ if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
char *sdp = NULL;
- switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
if ((sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
tech_pvt->local_sdp_str = switch_core_session_strdup(session, sdp);
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Wed May 9 15:30:41 2007
@@ -135,7 +135,7 @@
TFLAG_REFER = (1 << 17),
TFLAG_NOHUP = (1 << 18),
TFLAG_XFER = (1 << 19),
- TFLAG_NOMEDIA = (1 << 20),
+ TFLAG_RESERVED = (1 << 20),
TFLAG_BUGGY_2833 = (1 << 21),
TFLAG_SIP_HOLD = (1 << 22),
TFLAG_INB_NOMEDIA = (1 << 23),
@@ -261,6 +261,7 @@
uint32_t flags;
switch_payload_t agreed_pt;
switch_core_session_t *session;
+ switch_channel_t *channel;
switch_frame_t read_frame;
char *codec_order[SWITCH_MAX_CODECS];
int codec_order_last;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Wed May 9 15:30:41 2007
@@ -56,9 +56,6 @@
if ((session = switch_core_session_locate(sofia_private->uuid))) {
tech_pvt = switch_core_session_get_private(session);
channel = switch_core_session_get_channel(tech_pvt->session);
- if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
- switch_set_flag(tech_pvt, TFLAG_NOMEDIA);
- }
if (!tech_pvt->call_id && sip && sip->sip_call_id && sip->sip_call_id->i_id) {
tech_pvt->call_id = switch_core_session_strdup(session, (char *) sip->sip_call_id->i_id);
switch_channel_set_variable(channel, "sip_call_id", tech_pvt->call_id);
@@ -988,10 +985,6 @@
- if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
- switch_set_flag(tech_pvt, TFLAG_NOMEDIA);
- }
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s entering state [%s]\n",
switch_channel_get_name(channel), nua_callstate_name(ss_state));
@@ -1000,7 +993,6 @@
tech_pvt->remote_sdp_str = switch_core_session_strdup(session, r_sdp);
switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp);
sofia_glue_pass_sdp(tech_pvt, (char *) r_sdp);
-
}
}
@@ -1020,7 +1012,7 @@
if (status == 180) {
switch_channel_mark_ring_ready(channel);
if (!switch_channel_test_flag(channel, CF_GEN_RINGBACK)) {
- if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+ if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
&& (other_session = switch_core_session_locate(uuid))) {
switch_core_session_message_t msg;
@@ -1037,7 +1029,7 @@
}
if (r_sdp) {
- if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+ if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
switch_channel_mark_pre_answered(channel);
if (!switch_channel_test_flag(channel, CF_GEN_RINGBACK) && (uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
@@ -1072,7 +1064,7 @@
case nua_callstate_received:
if (tech_pvt && !switch_test_flag(tech_pvt, TFLAG_SDP)) {
if (r_sdp && !switch_test_flag(tech_pvt, TFLAG_SDP)) {
- if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+ if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOMEDIA");
switch_set_flag_locked(tech_pvt, TFLAG_READY);
switch_channel_set_state(channel, CS_INIT);
@@ -1135,7 +1127,7 @@
switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
}
} else {
- if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+ if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
goto done;
} else {
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOSDP");
@@ -1155,14 +1147,14 @@
break;
case nua_callstate_completed:
if (tech_pvt && r_sdp) {
- if (r_sdp) { // && !switch_test_flag(tech_pvt, TFLAG_SDP)) {
- if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+ sdp_parser_t *parser;
+ sdp_session_t *sdp;
+ uint8_t match = 0;
+
+ if (r_sdp) {
+ if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
goto done;
} else {
- sdp_parser_t *parser;
- sdp_session_t *sdp;
- uint8_t match = 0;
-
if (tech_pvt->num_codecs) {
if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
if ((sdp = sdp_session(parser))) {
@@ -1222,7 +1214,7 @@
r_sdp = (const char *) switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
}
if (r_sdp && !switch_test_flag(tech_pvt, TFLAG_SDP)) {
- if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+ if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
switch_set_flag_locked(tech_pvt, TFLAG_ANS);
switch_channel_mark_answered(channel);
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
@@ -1337,7 +1329,7 @@
}
- if (switch_channel_test_flag(channel_a, CF_NOMEDIA)) {
+ if (switch_channel_test_flag(channel_a, CF_BYPASS_MEDIA)) {
nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"), SIPTAG_EVENT_STR(etmp), TAG_END());
goto done;
@@ -1819,8 +1811,7 @@
if (switch_test_flag(tech_pvt, TFLAG_INB_NOMEDIA)) {
- switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
- switch_channel_set_flag(channel, CF_NOMEDIA);
+ switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
}
if (!tech_pvt->call_id && sip->sip_call_id && sip->sip_call_id->i_id) {
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Wed May 9 15:30:41 2007
@@ -44,7 +44,7 @@
int rate = 0;
uint32_t v_port;
- if (!force && !ip && !sr && switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+ if (!force && !ip && !sr && switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA)) {
return;
}
@@ -225,11 +225,10 @@
void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt)
{
- switch_channel_t *channel;
char *abs, *codec_string = NULL;
char *ocodec = NULL;
- if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+ if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA)) {
goto end;
}
@@ -239,20 +238,17 @@
assert(tech_pvt->session != NULL);
- channel = switch_core_session_get_channel(tech_pvt->session);
- assert(channel != NULL);
-
- if ((abs = switch_channel_get_variable(channel, "absolute_codec_string"))) {
+ if ((abs = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) {
codec_string = abs;
} else {
- if (!(codec_string = switch_channel_get_variable(channel, "codec_string"))) {
+ if (!(codec_string = switch_channel_get_variable(tech_pvt->channel, "codec_string"))) {
if (tech_pvt->profile->codec_string) {
codec_string = tech_pvt->profile->codec_string;
}
}
- if ((ocodec = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {
+ if ((ocodec = switch_channel_get_variable(tech_pvt->channel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {
if (!codec_string || (tech_pvt->profile->pflags & PFLAG_DISABLE_TRANSCODING)) {
codec_string = ocodec;
} else {
@@ -301,7 +297,6 @@
void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *profile, private_object_t *tech_pvt, const char *channame)
{
- switch_channel_t *channel;
char name[256];
assert(session != NULL);
@@ -309,9 +304,6 @@
assert(tech_pvt != NULL);
switch_core_session_add_stream(session, NULL);
- channel = switch_core_session_get_channel(session);
-
- //switch_channel_set_flag(channel, CF_ACCEPT_CNG);
switch_mutex_lock(tech_pvt->flag_mutex);
@@ -335,11 +327,12 @@
}
tech_pvt->session = session;
+ tech_pvt->channel = switch_core_session_get_channel(session);
switch_core_session_set_private(session, tech_pvt);
snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
- switch_channel_set_name(channel, name);
+ switch_channel_set_name(tech_pvt->channel, name);
//sofia_glue_tech_prepare_codecs(tech_pvt);
}
@@ -362,7 +355,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, error);
return SWITCH_STATUS_FALSE;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success [%s]:[%d]\n", *ip, *port);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stun Success [%s]:[%d]\n", *ip, *port);
} else {
*ip = sourceip;
}
@@ -373,13 +366,11 @@
switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt)
{
char *ip = tech_pvt->profile->rtpip;
- switch_channel_t *channel;
switch_port_t sdp_port;
char tmp[50];
- channel = switch_core_session_get_channel(tech_pvt->session);
- if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA) || tech_pvt->adv_sdp_audio_port) {
+ if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA) || tech_pvt->adv_sdp_audio_port) {
return SWITCH_STATUS_SUCCESS;
}
@@ -398,8 +389,8 @@
tech_pvt->adv_sdp_audio_port = sdp_port;
snprintf(tmp, sizeof(tmp), "%d", sdp_port);
- switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
- switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
+ switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
+ switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
return SWITCH_STATUS_SUCCESS;
@@ -410,13 +401,11 @@
switch_status_t sofia_glue_tech_choose_video_port(private_object_t *tech_pvt)
{
char *ip = tech_pvt->profile->rtpip;
- switch_channel_t *channel;
switch_port_t sdp_port;
char tmp[50];
- channel = switch_core_session_get_channel(tech_pvt->session);
- if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA) || tech_pvt->adv_sdp_video_port) {
+ if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA) || tech_pvt->adv_sdp_video_port) {
return SWITCH_STATUS_SUCCESS;
}
@@ -434,8 +423,8 @@
tech_pvt->adv_sdp_video_port = sdp_port;
snprintf(tmp, sizeof(tmp), "%d", sdp_port);
- switch_channel_set_variable(channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
- switch_channel_set_variable(channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp);
+ switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
+ switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp);
return SWITCH_STATUS_SUCCESS;
@@ -471,6 +460,8 @@
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
assert(tech_pvt != NULL);
+ switch_clear_flag_locked(tech_pvt, TFLAG_SDP);
+
caller_profile = switch_channel_get_caller_profile(channel);
cid_name = (char *) caller_profile->caller_id_name;
@@ -655,13 +646,10 @@
void sofia_glue_tech_absorb_sdp(private_object_t *tech_pvt)
{
- switch_channel_t *channel;
char *sdp_str;
- channel = switch_core_session_get_channel(tech_pvt->session);
- assert(channel != NULL);
- if ((sdp_str = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
+ if ((sdp_str = switch_channel_get_variable(tech_pvt->channel, SWITCH_B_SDP_VARIABLE))) {
sdp_parser_t *parser;
sdp_session_t *sdp;
sdp_media_t *m;
@@ -711,7 +699,6 @@
switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int force)
{
- switch_channel_t *channel;
if (tech_pvt->video_read_codec.implementation) {
if (!force) {
@@ -731,8 +718,6 @@
}
}
- channel = switch_core_session_get_channel(tech_pvt->session);
- assert(channel != NULL);
if (!tech_pvt->video_rm_encoding) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec with no name?\n");
@@ -765,8 +750,8 @@
int ms;
tech_pvt->video_read_frame.rate = tech_pvt->video_rm_rate;
ms = tech_pvt->video_write_codec.implementation->microseconds_per_frame / 1000;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set VIDEO Codec %s %s/%ld %d ms\n",
- switch_channel_get_name(channel), tech_pvt->video_rm_encoding, tech_pvt->video_rm_rate, tech_pvt->video_codec_ms);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set VIDEO Codec %s %s/%ld %d ms\n",
+ switch_channel_get_name(tech_pvt->channel), tech_pvt->video_rm_encoding, tech_pvt->video_rm_rate, tech_pvt->video_codec_ms);
tech_pvt->video_read_frame.codec = &tech_pvt->video_read_codec;
//switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
@@ -779,7 +764,6 @@
switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
{
- switch_channel_t *channel;
if (tech_pvt->read_codec.implementation) {
if (!force) {
@@ -799,9 +783,6 @@
}
}
- channel = switch_core_session_get_channel(tech_pvt->session);
- assert(channel != NULL);
-
if (!tech_pvt->rm_encoding) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec with no name?\n");
return SWITCH_STATUS_FALSE;
@@ -832,8 +813,8 @@
int ms;
tech_pvt->read_frame.rate = tech_pvt->rm_rate;
ms = tech_pvt->write_codec.implementation->microseconds_per_frame / 1000;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set Codec %s %s/%ld %d ms\n",
- switch_channel_get_name(channel), tech_pvt->rm_encoding, tech_pvt->rm_rate, tech_pvt->codec_ms);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Codec %s %s/%ld %d ms\n",
+ switch_channel_get_name(tech_pvt->channel), tech_pvt->rm_encoding, tech_pvt->rm_rate, tech_pvt->codec_ms);
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
@@ -851,7 +832,6 @@
switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt)
{
int bw, ms;
- switch_channel_t *channel;
const char *err = NULL;
char *val = NULL;
switch_rtp_flag_t flags;
@@ -859,10 +839,8 @@
char tmp[50];
assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(tech_pvt->session);
- assert(channel != NULL);
- if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+ if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA)) {
return SWITCH_STATUS_SUCCESS;
}
@@ -884,12 +862,12 @@
}
if ((tech_pvt->profile->pflags & PFLAG_PASS_RFC2833)
- || ((val = switch_channel_get_variable(channel, "pass_rfc2833")) && switch_true(val))) {
+ || ((val = switch_channel_get_variable(tech_pvt->channel, "pass_rfc2833")) && switch_true(val))) {
flags |= SWITCH_RTP_FLAG_PASS_RFC2833;
}
if (!((tech_pvt->profile->pflags & PFLAG_REWRITE_TIMESTAMPS) ||
- ((val = switch_channel_get_variable(channel, "rtp_rewrite_timestamps")) && switch_true(val)))) {
+ ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_rewrite_timestamps")) && switch_true(val)))) {
flags |= SWITCH_RTP_FLAG_RAW_WRITE;
}
@@ -897,16 +875,16 @@
flags |= SWITCH_RTP_FLAG_AUTO_CNG;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "AUDIO RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n",
- switch_channel_get_name(channel),
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "AUDIO RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n",
+ switch_channel_get_name(tech_pvt->channel),
tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_audio_port,
tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port, tech_pvt->agreed_pt, tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
- switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
- switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
+ switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
+ switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_REINVITE)) {
switch_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
@@ -949,7 +927,7 @@
switch_channel_get_name(switch_core_session_get_channel(tech_pvt->session)), vad_in ? "in" : "", vad_out ? "out" : "");
}
- if ((val = switch_channel_get_variable(channel, "jitterbuffer_msec"))) {
+ if ((val = switch_channel_get_variable(tech_pvt->channel, "jitterbuffer_msec"))) {
int len = atoi(val);
if (len < 100 || len > 1000) {
@@ -959,7 +937,7 @@
qlen = len / (tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting Jitterbuffer to %dms (%d frames)\n", len, qlen);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames)\n", len, qlen);
switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen);
}
}
@@ -993,8 +971,8 @@
&err, switch_core_session_get_pool(tech_pvt->session));
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "VIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n",
- switch_channel_get_name(channel),
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n",
+ switch_channel_get_name(tech_pvt->channel),
tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_video_port,
tech_pvt->remote_sdp_video_ip,
@@ -1004,13 +982,13 @@
if (switch_rtp_ready(tech_pvt->video_rtp_session)) {
- switch_channel_set_flag(channel, CF_VIDEO);
+ switch_channel_set_flag(tech_pvt->channel, CF_VIDEO);
}
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err);
- switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
return SWITCH_STATUS_FALSE;
}
@@ -1024,7 +1002,6 @@
sdp_parser_t *parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0);
sdp_session_t *sdp;
uint8_t match = 0;
- switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
assert(tech_pvt != NULL);
@@ -1049,9 +1026,9 @@
if (sofia_glue_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
- switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "EARLY MEDIA");
+ switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "EARLY MEDIA");
switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
- switch_channel_mark_pre_answered(channel);
+ switch_channel_mark_pre_answered(tech_pvt->channel);
return SWITCH_STATUS_SUCCESS;
}
@@ -1065,13 +1042,12 @@
private_object_t *tech_pvt;
sdp_media_t *m;
sdp_attribute_t *a;
- switch_channel_t *channel;
+
int ptime = 0, dptime = 0;
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
if ((tech_pvt->origin = switch_core_session_strdup(session, (char *) sdp->sdp_origin->o_username))) {
if (strstr(tech_pvt->origin, "CiscoSystemsSIP-GW-UserAgent")) {
@@ -1088,10 +1064,8 @@
if (!strcasecmp(a->a_name, "sendonly")) {
if (!switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
char *stream;
-
switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
- switch_channel_set_flag(channel, CF_HOLD);
- if (!(stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
+ if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
stream = tech_pvt->profile->hold_music;
}
if (stream) {
@@ -1100,10 +1074,9 @@
}
} else if (!strcasecmp(a->a_name, "sendrecv")) {
if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
+ switch_channel_clear_flag_partner(tech_pvt->channel, CF_BROADCAST);
+ switch_channel_set_flag_partner(tech_pvt->channel, CF_BREAK);
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
- switch_channel_clear_flag(channel, CF_HOLD);
- switch_channel_clear_flag_partner(channel, CF_BROADCAST);
- switch_channel_set_flag_partner(channel, CF_BREAK);
}
} else if (!strcasecmp(a->a_name, "ptime")) {
dptime = atoi(a->a_value);
@@ -1230,8 +1203,8 @@
tech_pvt->remote_sdp_audio_port = (switch_port_t) m->m_port;
tech_pvt->agreed_pt = (switch_payload_t) map->rm_pt;
snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
- switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
- switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
+ switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
+ switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
} else {
match = 0;
}
@@ -1307,8 +1280,8 @@
tech_pvt->remote_sdp_video_port = (switch_port_t) m->m_port;
tech_pvt->video_agreed_pt = (switch_payload_t) map->rm_pt;
snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_video_port);
- switch_channel_set_variable(channel, SWITCH_REMOTE_VIDEO_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
- switch_channel_set_variable(channel, SWITCH_REMOTE_VIDEO_PORT_VARIABLE, tmp);
+ switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_VIDEO_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
+ switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_VIDEO_PORT_VARIABLE, tmp);
} else {
vmatch = 0;
}
@@ -1392,23 +1365,20 @@
void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp)
{
char *val;
- switch_channel_t *channel;
switch_core_session_t *other_session;
switch_channel_t *other_channel;
- channel = switch_core_session_get_channel(tech_pvt->session);
- assert(channel != NULL);
- if ((val = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
+ if ((val = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE))
&& (other_session = switch_core_session_locate(val))) {
other_channel = switch_core_session_get_channel(other_session);
assert(other_channel != NULL);
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp);
if (!switch_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (switch_channel_test_flag(other_channel, CF_OUTBOUND) &&
- //switch_channel_test_flag(other_channel, CF_NOMEDIA) &&
- switch_channel_test_flag(channel, CF_OUTBOUND) &&
- switch_channel_test_flag(channel, CF_NOMEDIA))) {
+ //switch_channel_test_flag(other_channel, CF_BYPASS_MEDIA) &&
+ switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND) &&
+ switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA))) {
switch_ivr_nomedia(val, SMF_FORCE);
switch_set_flag_locked(tech_pvt, TFLAG_CHANGE_MEDIA);
}
1
0
09 May '07
Author: mikej
Date: Wed May 9 13:41:32 2007
New Revision: 5113
Modified:
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c
Log:
missing header.
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c Wed May 9 13:41:32 2007
@@ -39,6 +39,7 @@
#include <assert.h>
#include <string.h>
+#include <time.h>
#define SU_ROOT_MAGIC_T struct stun_magic_t
1
0
09 May '07
Author: mikej
Date: Wed May 9 11:49:01 2007
New Revision: 5112
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Log:
make sure to initialize gateway->next
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Wed May 9 11:49:01 2007
@@ -489,7 +489,7 @@
gateway->profile = profile;
gateway->name = switch_core_strdup(gateway->pool, name);
gateway->freq = 0;
-
+ gateway->next = NULL;
for (param = switch_xml_child(gateway_tag, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
1
0
09 May '07
Author: mikej
Date: Wed May 9 10:43:35 2007
New Revision: 5111
Modified:
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
Log:
get event callbacks after you shutdown a ua so that we can handle call cleanup. Still to come on this is a tag to properly set this behavior.
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c Wed May 9 10:43:35 2007
@@ -271,7 +271,9 @@
if ((event > nua_r_authenticate && event <= nua_r_ack)
|| event < nua_i_error
|| (nh && !nh->nh_valid)
- || (nua->nua_shutdown && event != nua_r_shutdown)) {
+ /* disable hiding all events after shutdown so that we can get state callbacks to properly tear down our calls */
+ /* || (nua->nua_shutdown && event != nua_r_shutdown) */
+ ) {
if (msg)
msg_destroy(msg);
return event;
1
0