From 65ba846a303788391525f12c9aae57a3ac269b99 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Fri, 22 Mar 2013 07:43:58 -0500 Subject: [PATCH 1/8] FS-5100 --resolve --- src/mod/applications/mod_nibblebill/mod_nibblebill.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mod/applications/mod_nibblebill/mod_nibblebill.c b/src/mod/applications/mod_nibblebill/mod_nibblebill.c index 296c730ba0..cdf022b2b9 100755 --- a/src/mod/applications/mod_nibblebill/mod_nibblebill.c +++ b/src/mod/applications/mod_nibblebill/mod_nibblebill.c @@ -197,6 +197,11 @@ static switch_status_t nibblebill_load_config(void) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "odbc_dsn is %s\n", val); switch_safe_free(globals.odbc_dsn); globals.odbc_dsn = strdup(val); + } else if (!strcasecmp(var, "db_dsn") && !zstr(val)) { + /* For backwards-compatibility */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "this nibblebill param(db_dsn) is deprecated and will be removed in 1.4 - odbc_dsn is %s\n", val); + switch_safe_free(globals.odbc_dsn); + globals.odbc_dsn = strdup(val); } else if (!strcasecmp(var, "db_table")) { set_global_db_table(val); } else if (!strcasecmp(var, "db_column_cash")) { From 5406fb8a1128277b658b1651caf139b7147894e2 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Fri, 22 Mar 2013 08:40:45 -0500 Subject: [PATCH 2/8] FS-5185 --resolve --- .../mod_voicemail/mod_voicemail.c | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index b18b64ec9c..a9309db19d 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -3869,37 +3869,31 @@ static void actual_message_query_handler(switch_event_t *event) char *id, *domain; dup = strdup(account); - id = dup; - if (!strncasecmp(account, "sip:", 4)) { - id += 4; - } + switch_split_user_domain(dup, &id, &domain); - if (!id) { + if (!id || !domain) { free(dup); return; } - if ((domain = strchr(id, '@'))) { - *domain++ = '\0'; - profile = NULL; + profile = NULL; - if (globals.message_query_exact_match) { - if ((profile = (vm_profile_t *) switch_core_hash_find(globals.profile_hash, domain))) { - parse_profile(); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, - "Cound not find a profile for domain: [%s] Returning 0 messages\nWhen message-query-exact-match is enabled you must have a dedicated vm profile per distinct domain name you wish to use.\n", domain); - } + if (globals.message_query_exact_match) { + if ((profile = (vm_profile_t *) switch_core_hash_find(globals.profile_hash, domain))) { + parse_profile(); } else { - for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) { - switch_hash_this(hi, NULL, NULL, &val); - profile = (vm_profile_t *) val; - parse_profile(); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, + "Cound not find a profile for domain: [%s] Returning 0 messages\nWhen message-query-exact-match is enabled you must have a dedicated vm profile per distinct domain name you wish to use.\n", domain); + } + } else { + for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, NULL, NULL, &val); + profile = (vm_profile_t *) val; + parse_profile(); - if (new_event) { - break; - } + if (new_event) { + break; } } } From 0ca2c2b0e74c380aafa2a976dfb18050e5ec8098 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 22 Mar 2013 10:28:15 -0500 Subject: [PATCH 3/8] print message before destroying obj --- src/mod/languages/mod_lua/freeswitch_lua.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/languages/mod_lua/freeswitch_lua.cpp b/src/mod/languages/mod_lua/freeswitch_lua.cpp index f4d5291db9..34edfaea93 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.cpp +++ b/src/mod/languages/mod_lua/freeswitch_lua.cpp @@ -366,8 +366,8 @@ Dbh::~Dbh() bool Dbh::release() { if (dbh) { - switch_cache_db_release_db_handle(&dbh); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DBH handle %p released.\n", (void *) dbh); + switch_cache_db_release_db_handle(&dbh); return true; } From 818f8521e046503e3e4d19ba22d073b8c01d6b57 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 22 Mar 2013 10:34:31 -0500 Subject: [PATCH 4/8] don't choose 0 port for proxy mode --- src/mod/endpoints/mod_sofia/sofia_glue.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 0d764391bd..6e3dde6407 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1541,7 +1541,11 @@ switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt, co } if ((p = (char *) switch_stristr("m=image ", sdp_str))) { - port_ptr = p + 8; + char *tmp = p + 8; + + if (tmp && atoi(tmp)) { + port_ptr = tmp; + } } if ((p = (char *) switch_stristr("m=video ", sdp_str))) { From 9c255aff76aa178e4e2f3c4fdbfb398fd96c7c8f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 22 Mar 2013 11:20:34 -0500 Subject: [PATCH 5/8] allow specific removal of media bugs by function name --- src/mod/applications/mod_dptools/mod_dptools.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index bd1a82fc80..c2052bede6 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -940,7 +940,13 @@ SWITCH_STANDARD_APP(ring_ready_function) SWITCH_STANDARD_APP(remove_bugs_function) { - switch_core_media_bug_remove_all(session); + const char *function = NULL; + + if (!zstr((char *)data)) { + function = data; + } + + switch_core_media_bug_remove_all_function(session, function); } SWITCH_STANDARD_APP(break_function) @@ -5605,7 +5611,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "unset", "Unset a channel variable", UNSET_LONG_DESC, unset_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC); SWITCH_ADD_APP(app_interface, "ring_ready", "Indicate Ring_Ready", "Indicate Ring_Ready on a channel.", ring_ready_function, "", SAF_SUPPORT_NOMEDIA); - SWITCH_ADD_APP(app_interface, "remove_bugs", "Remove media bugs", "Remove all media bugs from a channel.", remove_bugs_function, "", SAF_NONE); + SWITCH_ADD_APP(app_interface, "remove_bugs", "Remove media bugs", "Remove all media bugs from a channel.", remove_bugs_function, "[]", SAF_NONE); SWITCH_ADD_APP(app_interface, "break", "Break", "Set the break flag.", break_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "detect_speech", "Detect speech", "Detect speech on a channel.", detect_speech_function, DETECT_SPEECH_SYNTAX, SAF_NONE); SWITCH_ADD_APP(app_interface, "play_and_detect_speech", "Play and do speech recognition", "Play and do speech recognition", play_and_detect_speech_function, PLAY_AND_DETECT_SPEECH_SYNTAX, SAF_NONE); From 955b900f3e8fb9b3407f96785b761d726e415268 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 22 Mar 2013 13:47:38 -0500 Subject: [PATCH 6/8] FS-5011 catch sid frames and change them to cng --- src/switch_core_io.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/switch_core_io.c b/src/switch_core_io.c index b5ea2f6733..3acfea1383 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -269,6 +269,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi if (bp->ready) { if (switch_test_flag(bp, SMBF_TAP_NATIVE_READ)) { + if ((*frame)->codec && (*frame)->codec->implementation && + (*frame)->codec->implementation->encoded_bytes_per_packet && + (*frame)->datalen != (*frame)->codec->implementation->encoded_bytes_per_packet) { + switch_set_flag((*frame), SFF_CNG); + break; + } if (bp->callback) { bp->native_read_frame = *frame; ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_TAP_NATIVE_READ); @@ -308,7 +314,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi do_resample = 0; do_bugs = 0; - if (session->bugs && switch_test_flag(*frame, SFF_CNG)) { + if (session->bugs && switch_test_flag((*frame), SFF_CNG)) { switch_thread_rwlock_rdlock(session->bug_rwlock); for (bp = session->bugs; bp; bp = bp->next) { if (switch_channel_test_flag(session->channel, CF_PAUSE_BUGS) && !switch_core_media_bug_test_flag(bp, SMBF_NO_PAUSE)) { @@ -328,12 +334,32 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi if (bp->callback) { switch_frame_t tmp_frame = {0}; unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0}; - + unsigned char g729_filler[] = { + 114, 170, 250, 103, 54, 211, 203, 194, 94, 64, + 229, 127, 79, 96, 207, 82, 216, 110, 245, 81, + 114, 170, 250, 103, 54, 211, 203, 194, 94, 64, + 229, 127, 79, 96, 207, 82, 216, 110, 245, 81, + 114, 170, 250, 103, 54, 211, 203, 194, 94, 64, + 229, 127, 79, 96, 207, 82, 216, 110, 245, 81, + 114, 170, 250, 103, 54, 211, 203, 194, 94, 64, + 229, 127, 79, 96, 207, 82, 216, 110, 245, 81, + 114, 170, 250, 103, 54, 211, 203, 194, 94, 64, + 229, 127, 79, 96, 207, 82, 216, 110, 245, 81, + 114, 170, 250, 103, 54, 211, 203, 194, 94, 64, + 229, 127, 79, 96, 207, 82, 216, 110, 245, 81, + 114, 170, 250, 103, 54, 211, 203, 194, 94, 64, + 229, 127, 79, 96, 207, 82, 216, 110, 245, 81 + }; + tmp_frame.codec = (*frame)->codec; tmp_frame.datalen = (*frame)->codec->implementation->encoded_bytes_per_packet; tmp_frame.samples = (*frame)->codec->implementation->samples_per_packet; tmp_frame.data = data; + if ((*frame)->codec->implementation->ianacode == 18 || switch_stristr("g729", (*frame)->codec->implementation->iananame)) { + memcpy(tmp_frame.data, g729_filler, tmp_frame.datalen); + } + bp->native_read_frame = &tmp_frame; ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_TAP_NATIVE_READ); bp->native_read_frame = NULL; @@ -923,6 +949,12 @@ static switch_status_t perform_write(switch_core_session_t *session, switch_fram if (session->endpoint_interface->io_routines->write_frame) { + int i; + unsigned char *x = (unsigned char *) frame->data; + for (i = 0; i < frame->datalen; i++) { + printf("[%d] ", x[i]); + } + printf("\n"); if ((status = session->endpoint_interface->io_routines->write_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) { for (ptr = session->event_hooks.write_frame; ptr; ptr = ptr->next) { From 83ed0bd399854ccb9baad96dfbb513e3129cf55f Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Fri, 22 Mar 2013 15:52:36 -0500 Subject: [PATCH 7/8] remove debug code --- src/switch_core_io.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 3acfea1383..741ac0e556 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -949,13 +949,6 @@ static switch_status_t perform_write(switch_core_session_t *session, switch_fram if (session->endpoint_interface->io_routines->write_frame) { - int i; - unsigned char *x = (unsigned char *) frame->data; - for (i = 0; i < frame->datalen; i++) { - printf("[%d] ", x[i]); - } - printf("\n"); - if ((status = session->endpoint_interface->io_routines->write_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) { for (ptr = session->event_hooks.write_frame; ptr; ptr = ptr->next) { if ((status = ptr->write_frame(session, frame, flags, stream_id)) != SWITCH_STATUS_SUCCESS) { From 0ec0153b9999c98d0ffbff8e9340d638ea40f7af Mon Sep 17 00:00:00 2001 From: Michael S Collins Date: Fri, 22 Mar 2013 16:40:42 -0700 Subject: [PATCH 8/8] fs_encode: load mod_spandsp before loading mod_native_file so that the latter picks up all the codecs offered by the former --- src/fs_encode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fs_encode.c b/src/fs_encode.c index b1beb36b43..be28da01e3 100644 --- a/src/fs_encode.c +++ b/src/fs_encode.c @@ -137,6 +137,11 @@ int main(int argc, char *argv[]) } } + if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) "mod_spandsp", SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { + fprintf(stderr, "Cannot init mod_spandsp [%s]\n", err); + goto end; + } + if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) "mod_sndfile", SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { fprintf(stderr, "Cannot init mod_sndfile [%s]\n", err); goto end; @@ -147,11 +152,6 @@ int main(int argc, char *argv[]) goto end; } - if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) "mod_spandsp", SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { - fprintf(stderr, "Cannot init mod_spandsp [%s]\n", err); - goto end; - } - switch_core_new_memory_pool(&pool); if (verbose) { fprintf(stderr, "Opening file %s\n", input);