From d9d238b183fe6ca1a3bf1f45f76df08ae6a83780 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 5 Mar 2013 13:33:07 -0600 Subject: [PATCH 1/7] FS-5139 --resolve --- src/mod/endpoints/mod_sofia/sofia.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index b8eaff50dd..3be6ab2492 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1758,18 +1758,18 @@ void sofia_event_callback(nua_event_t event, case nua_i_info: if (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING) || !switch_core_ready_inbound()) { - nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); + nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), NUTAG_WITH_THIS(nua), TAG_END()); goto end; } if (switch_queue_size(mod_sofia_globals.msg_queue) > critical) { - nua_respond(nh, 503, "System Busy", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); + nua_respond(nh, 503, "System Busy", SIPTAG_RETRY_AFTER_STR("300"), NUTAG_WITH_THIS(nua), TAG_END()); goto end; } if (sofia_test_pflag(profile, PFLAG_STANDBY)) { - nua_respond(nh, 503, "System Paused", TAG_END()); + nua_respond(nh, 503, "System Paused", NUTAG_WITH_THIS(nua), TAG_END()); goto end; } break; From b084ba9955d5ad4f06b37aa4686ce6d46d70a120 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 5 Mar 2013 13:33:32 -0600 Subject: [PATCH 2/7] change fs_encode to support raw files to wav or to other raw --- src/fs_encode.c | 106 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 20 deletions(-) diff --git a/src/fs_encode.c b/src/fs_encode.c index 7606138234..364b336544 100644 --- a/src/fs_encode.c +++ b/src/fs_encode.c @@ -64,12 +64,16 @@ int main(int argc, char *argv[]) int rate = 8000; switch_file_handle_t fh_input = { 0 }, fh_output = { 0 }; switch_codec_t codec = { 0 }; + switch_codec_t raw_codec = { 0 }; char buf[2048]; switch_size_t len = sizeof(buf)/2; switch_memory_pool_t *pool = NULL; int bitrate = 0; int blocksize; - + int in_asis = 0; + int out_asis = 0; + int out_flags = SWITCH_FILE_FLAG_WRITE; + for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { switch(argv[i][1]) { @@ -142,6 +146,11 @@ int main(int argc, char *argv[]) fprintf(stderr, "Cannot init mod_native_file [%s]\n", err); 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) { @@ -156,22 +165,53 @@ int main(int argc, char *argv[]) if (verbose) { fprintf(stderr, "Opening file %s\n", output); } - if (switch_core_file_open(&fh_output, output, channels, rate, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_NATIVE, NULL) != SWITCH_STATUS_SUCCESS) { + + if (switch_stristr(".wav", output)) { + out_asis = 0; + out_flags |= SWITCH_FILE_DATA_SHORT; + } else { + out_asis = 1; + out_flags |= SWITCH_FILE_NATIVE; + } + + + if (switch_core_file_open(&fh_output, output, channels, rate, out_flags, NULL) != SWITCH_STATUS_SUCCESS) { fprintf(stderr, "Couldn't open %s\n", output); goto end; } - - if (switch_test_flag(&fh_input, SWITCH_FILE_NATIVE)) { - fprintf(stderr, "Input as native file is not implemented\n"); - goto end; - } - if (switch_core_codec_init_with_bitrate(&codec, format, fmtp, rate, ptime, channels, bitrate, SWITCH_CODEC_FLAG_ENCODE, NULL, pool) != SWITCH_STATUS_SUCCESS) { - fprintf(stderr, "Couldn't initialize codec for %s@%dh@%di\n", format, rate, ptime); - goto end; + if (switch_test_flag(&fh_input, SWITCH_FILE_NATIVE)) { + in_asis = 1; + } + + if (out_asis) { + if (switch_core_codec_init_with_bitrate(&codec, format, fmtp, rate, ptime, channels, bitrate, SWITCH_CODEC_FLAG_ENCODE, NULL, pool) != SWITCH_STATUS_SUCCESS) { + fprintf(stderr, "Couldn't initialize codec for %s@%dh@%di\n", format, rate, ptime); + goto end; + } + } else { + char *p; + + if ((p = strchr(input, '.'))) { + p++; + } + if (!p || switch_core_codec_init_with_bitrate(&codec, p, fmtp, rate, ptime, channels, bitrate, SWITCH_CODEC_FLAG_ENCODE|SWITCH_CODEC_FLAG_DECODE, NULL, pool) != SWITCH_STATUS_SUCCESS) { + fprintf(stderr, "Couldn't initialize codec for %s@%dh@%di\n", p, rate, ptime); + goto end; + } + + if (switch_core_codec_init_with_bitrate(&raw_codec, "L16", fmtp, rate, ptime, channels, bitrate, SWITCH_CODEC_FLAG_ENCODE|SWITCH_CODEC_FLAG_DECODE, NULL, pool) != SWITCH_STATUS_SUCCESS) { + fprintf(stderr, "Couldn't initialize codec for %s@%dh@%di\n", "L16", rate, ptime); + goto end; + } + } + + if (in_asis) { + blocksize = len = codec.implementation->encoded_bytes_per_packet; + } else { + blocksize = len = (rate*ptime)/1000; } - blocksize = len = (rate*ptime)/1000; switch_assert(sizeof(buf) >= len * 2); if (verbose) { @@ -183,13 +223,34 @@ int main(int argc, char *argv[]) uint32_t encoded_len = sizeof(buf); uint32_t encoded_rate = rate; unsigned int flags = 0; - - if (switch_core_codec_encode(&codec, NULL, buf, len*2, rate, encode_buf, &encoded_len, &encoded_rate, &flags) != SWITCH_STATUS_SUCCESS) { - fprintf(stderr, "Codec encoder error\n"); - goto end; + + if (out_asis) { + if (switch_core_codec_encode(&codec, NULL, buf, len*2, rate, encode_buf, &encoded_len, &encoded_rate, &flags) != SWITCH_STATUS_SUCCESS) { + fprintf(stderr, "Codec encoder error\n"); + goto end; + } + + len = encoded_len; + } else { + if (!in_asis) { + encoded_len = len; + } else if (in_asis) { + + switch_core_codec_decode(&codec, + &raw_codec, + buf, + len, + rate, + encode_buf, + &encoded_len, + &encoded_rate, + &flags); + encoded_len /= 2; + printf("WTF %ld %d %d\n", len, encoded_rate, encoded_len); + len = encoded_len; + } } - - len = encoded_len; + if (switch_core_file_write(&fh_output, encode_buf, &len) != SWITCH_STATUS_SUCCESS) { fprintf(stderr, "Write error\n"); @@ -206,9 +267,12 @@ int main(int argc, char *argv[]) r = 0; end: - + + switch_core_codec_destroy(&codec); - + switch_core_codec_destroy(&raw_codec); + + if (fh_input.file_interface) { switch_core_file_close(&fh_input); } @@ -220,7 +284,9 @@ end: if (pool) { switch_core_destroy_memory_pool(&pool); } - switch_core_destroy(); + + //switch_core_destroy(); + return r; usage: printf("Usage: %s [options] input output\n\n", argv[0]); From 3e4fb4b0a265e727e65a826e161f51d4f404f43a Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 6 Mar 2013 13:23:28 -0500 Subject: [PATCH 3/7] check for vm caller id info later so if its transfered it gets the updated details --- .../applications/mod_voicemail/mod_voicemail.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 6682cf5eec..ccb0811ddd 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -3271,14 +3271,6 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p switch_channel_set_variable(channel, "skip_greeting", NULL); switch_channel_set_variable(channel, "skip_instructions", NULL); - if (!(caller_id_name = switch_channel_get_variable(channel, "effective_caller_id_name"))) { - caller_id_name = caller_profile->caller_id_name; - } - - if (!(caller_id_number = switch_channel_get_variable(channel, "effective_caller_id_number"))) { - caller_id_number = caller_profile->caller_id_number; - } - memset(&cbt, 0, sizeof(cbt)); if (id) { @@ -3505,6 +3497,14 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p cc.noexit = 1; args.buf = &cc; + if (!(caller_id_name = switch_channel_get_variable(channel, "effective_caller_id_name"))) { + caller_id_name = caller_profile->caller_id_name; + } + + if (!(caller_id_number = switch_channel_get_variable(channel, "effective_caller_id_number"))) { + caller_id_number = caller_profile->caller_id_number; + } + switch_channel_set_variable_printf(channel, "RECORD_ARTIST", "%s (%s)", caller_id_name, caller_id_number); switch_time_exp_lt(&tm, ts); From 9b11dbe4b9f7c96fe0b8e6cc4af096cfdaecb79b Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 6 Mar 2013 12:58:22 -0600 Subject: [PATCH 4/7] FS-4452 --resolve --- libs/sofia-sip/.update | 2 +- libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index e6a01c6b43..0114190bd8 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Fri Mar 1 15:47:13 CST 2013 +Wed Mar 6 12:57:17 CST 2013 diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c index 2facb30d0d..828b3f313c 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c @@ -303,6 +303,7 @@ int tls_init_context(tls_t *tls, tls_issues_t const *ti) meth = SSLv23_method(); tls->ctx = SSL_CTX_new((SSL_METHOD*)meth); + SSL_CTX_sess_set_remove_cb(tls->ctx, NULL); } if (tls->ctx == NULL) { @@ -399,14 +400,14 @@ void tls_free(tls_t *tls) if (!tls) return; - if (tls->con != NULL) - SSL_shutdown(tls->con); + if (tls->con != NULL) { + SSL_shutdown(tls->con); + SSL_free(tls->con), tls->con = NULL; + } - if (tls->ctx != NULL && tls->type != tls_slave) + if (tls->ctx != NULL && tls->type != tls_slave) { SSL_CTX_free(tls->ctx); - - if (tls->bio_con != NULL) - BIO_free(tls->bio_con); + } su_home_unref(tls->home); } @@ -475,7 +476,6 @@ tls_t *tls_init_secondary(tls_t *master, int sock, int accept) if (tls) { tls->ctx = master->ctx; - tls->type = master->type; tls->accept = accept ? 1 : 0; tls->verify_outgoing = master->verify_outgoing; tls->verify_incoming = master->verify_incoming; From eb001cc844d65b2ae5c4ab0eabee6437136e3d50 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 6 Mar 2013 12:59:21 -0600 Subject: [PATCH 5/7] bump --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 6c99f97c5c..92662fbce2 100644 --- a/configure.in +++ b/configure.in @@ -3,10 +3,10 @@ # Must change all of the below together # For a release, set revision for that tagged release as well and uncomment -AC_INIT([freeswitch], [1.3.14b], bugs@freeswitch.org) +AC_INIT([freeswitch], [1.3.14], bugs@freeswitch.org) AC_SUBST(SWITCH_VERSION_MAJOR, [1]) AC_SUBST(SWITCH_VERSION_MINOR, [3]) -AC_SUBST(SWITCH_VERSION_MICRO, [14b]) +AC_SUBST(SWITCH_VERSION_MICRO, [14]) AC_SUBST(SWITCH_VERSION_REVISION, []) AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, []) From a5cbf1d9b944a6b6e4ce5229a01e03888b065d6d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 6 Mar 2013 13:00:41 -0600 Subject: [PATCH 6/7] bump --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 92662fbce2..a6c132c327 100644 --- a/configure.in +++ b/configure.in @@ -3,10 +3,10 @@ # Must change all of the below together # For a release, set revision for that tagged release as well and uncomment -AC_INIT([freeswitch], [1.3.14], bugs@freeswitch.org) +AC_INIT([freeswitch], [1.3.15b], bugs@freeswitch.org) AC_SUBST(SWITCH_VERSION_MAJOR, [1]) AC_SUBST(SWITCH_VERSION_MINOR, [3]) -AC_SUBST(SWITCH_VERSION_MICRO, [14]) +AC_SUBST(SWITCH_VERSION_MICRO, [15b]) AC_SUBST(SWITCH_VERSION_REVISION, []) AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, []) From a70a0ca05acb97cfe65c167594972df0edaf20e2 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 6 Mar 2013 13:59:02 -0600 Subject: [PATCH 7/7] declinatio mortuus obfirmo --- src/mod/endpoints/mod_sofia/sofia_glue.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 78ba3c2132..5c40dc10be 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -6467,7 +6467,8 @@ void sofia_glue_actually_execute_sql_trans(sofia_profile_t *profile, char *sql, if (!(dbh = sofia_glue_get_db_handle(profile))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n"); - return; + + goto end; } switch_cache_db_persistant_execute_trans_full(dbh, sql, 1, @@ -6479,6 +6480,8 @@ void sofia_glue_actually_execute_sql_trans(sofia_profile_t *profile, char *sql, switch_cache_db_release_db_handle(&dbh); + end: + if (mutex) { switch_mutex_unlock(mutex); } @@ -6495,6 +6498,11 @@ void sofia_glue_actually_execute_sql(sofia_profile_t *profile, char *sql, switch if (!(dbh = sofia_glue_get_db_handle(profile))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n"); + + if (mutex) { + switch_mutex_unlock(mutex); + } + return; } @@ -6525,6 +6533,11 @@ switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile, if (!(dbh = sofia_glue_get_db_handle(profile))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n"); + + if (mutex) { + switch_mutex_unlock(mutex); + } + return ret; } @@ -6559,6 +6572,11 @@ char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex if (!(dbh = sofia_glue_get_db_handle(profile))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n"); + + if (mutex) { + switch_mutex_unlock(mutex); + } + return NULL; }