From 43dedcac1f68cd9522d7e6f1fcbea84960dfd04a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 2 Jun 2010 11:17:43 -0500 Subject: [PATCH 01/10] add tab completion rule --- src/mod/applications/mod_commands/mod_commands.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index e0011e48c0..e2accf3652 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -4387,6 +4387,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add uuid_loglevel ::console::list_uuid info"); switch_console_set_complete("add uuid_loglevel ::console::list_uuid debug"); switch_console_set_complete("add uuid_media ::console::list_uuid"); + switch_console_set_complete("add uuid_media off ::console::list_uuid"); switch_console_set_complete("add uuid_park ::console::list_uuid"); switch_console_set_complete("add uuid_phone_event ::console::list_uuid talk"); switch_console_set_complete("add uuid_phone_event ::console::list_uuid hold"); From de90c627a0c29a029f3d06ee0088dfd664f975b1 Mon Sep 17 00:00:00 2001 From: Brian West Date: Wed, 2 Jun 2010 11:35:58 -0500 Subject: [PATCH 02/10] .gitignore --- .gitignore | 3 +++ libs/.gitignore | 2 ++ libs/openzap/.gitignore | 11 +++++++++++ 3 files changed, 16 insertions(+) diff --git a/.gitignore b/.gitignore index 7e54a61763..4964c914b4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ *.a *.la *.loT +*.orig +*.rej .libs .deps .\#* @@ -31,6 +33,7 @@ *.ilk *.bsc *.pch +core.* /Path /w32/Library/lastversion /w32/Library/tmpVersion.Bat diff --git a/libs/.gitignore b/libs/.gitignore index 068f67c001..24e32c1954 100644 --- a/libs/.gitignore +++ b/libs/.gitignore @@ -1,3 +1,5 @@ +/libg723_1/ +/libg729/ /apr-util/.make.dirs /apr-util/Makefile /apr-util/apr-util.pc diff --git a/libs/openzap/.gitignore b/libs/openzap/.gitignore index d90d79d08d..b0dc177c9a 100644 --- a/libs/openzap/.gitignore +++ b/libs/openzap/.gitignore @@ -11,3 +11,14 @@ config.* configure libtool aclocal.m4 + +detect_dtmf +detect_tones +testanalog +testapp +testboost +testcid +testisdn +testpri +testr2 +testtones From 22ebaaf8e22a5ad3fe0ae42e34bde0541d233947 Mon Sep 17 00:00:00 2001 From: Brian West Date: Wed, 2 Jun 2010 11:39:36 -0500 Subject: [PATCH 03/10] don't fail load of mod_spandsp just because we don't have tones in the conf file --- src/mod/applications/mod_spandsp/mod_spandsp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.c b/src/mod/applications/mod_spandsp/mod_spandsp.c index 3c1c64fe47..69b551dba7 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp.c @@ -198,16 +198,16 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) SWITCH_ADD_APP(app_interface, "spandsp_stop_dtmf", "stop inband dtmf", "Stop detecting inband dtmf.", stop_dtmf_session_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "spandsp_start_dtmf", "Detect dtmf", "Detect inband dtmf on the session", dtmf_session_function, "", SAF_MEDIA_TAP); - SWITCH_ADD_APP(app_interface, "start_tone_detect", "Start background tone detection with cadence", "", start_tone_detect_app, "[name]", SAF_NONE); - SWITCH_ADD_APP(app_interface, "stop_tone_detect", "Stop background tone detection with cadence", "", stop_tone_detect_app, "", SAF_NONE); - SWITCH_ADD_API(api_interface, "start_tone_detect", "Start background tone detection with cadence", start_tone_detect_api, "[name]"); - SWITCH_ADD_API(api_interface, "stop_tone_detect", "Stop background tone detection with cadence", stop_tone_detect_api, ""); - - mod_spandsp_fax_load(pool); mod_spandsp_codecs_load(module_interface, pool); + if (mod_spandsp_dsp_load(module_interface, pool) != SWITCH_STATUS_SUCCESS) { - return SWITCH_STATUS_FALSE; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't load spandsp.conf, not adding tone_detect applications\n"); + } else { + SWITCH_ADD_APP(app_interface, "start_tone_detect", "Start background tone detection with cadence", "", start_tone_detect_app, "[name]", SAF_NONE); + SWITCH_ADD_APP(app_interface, "stop_tone_detect", "Stop background tone detection with cadence", "", stop_tone_detect_app, "", SAF_NONE); + SWITCH_ADD_API(api_interface, "start_tone_detect", "Start background tone detection with cadence", start_tone_detect_api, "[name]"); + SWITCH_ADD_API(api_interface, "stop_tone_detect", "Stop background tone detection with cadence", stop_tone_detect_api, ""); } if ((switch_event_bind_removable(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL, &NODE) != SWITCH_STATUS_SUCCESS)) { From e80befba171fd39c7f67d0623ae0e521acad5a57 Mon Sep 17 00:00:00 2001 From: Brian West Date: Wed, 2 Jun 2010 11:52:27 -0500 Subject: [PATCH 04/10] fix log messages on spandsp.conf loading or processing failure --- src/mod/applications/mod_spandsp/mod_spandsp.c | 2 +- src/mod/applications/mod_spandsp/mod_spandsp_dsp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.c b/src/mod/applications/mod_spandsp/mod_spandsp.c index 69b551dba7..ea5385089f 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp.c @@ -202,7 +202,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) mod_spandsp_codecs_load(module_interface, pool); if (mod_spandsp_dsp_load(module_interface, pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't load spandsp.conf, not adding tone_detect applications\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't load or process spandsp.conf, not adding tone_detect applications\n"); } else { SWITCH_ADD_APP(app_interface, "start_tone_detect", "Start background tone detection with cadence", "", start_tone_detect_app, "[name]", SAF_NONE); SWITCH_ADD_APP(app_interface, "stop_tone_detect", "Stop background tone detection with cadence", "", stop_tone_detect_app, "", SAF_NONE); diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c index 7202db3208..096d967ff0 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c @@ -509,7 +509,7 @@ static switch_status_t do_config(void) switch_status_t status = SWITCH_STATUS_SUCCESS; switch_xml_t cfg = NULL, xml = NULL, callprogress = NULL, xdescriptor = NULL; if (!(xml = switch_xml_open_cfg("spandsp.conf", &cfg, NULL))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not open tone_detect.conf\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not open spandsp.conf\n"); status = SWITCH_STATUS_FALSE; goto done; } From e596fc2e7facb1b6f1eb6eb1f18cbc581cdfe63a Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Wed, 2 Jun 2010 14:48:37 -0400 Subject: [PATCH 05/10] freetdm: add logging when failing to read a frame in mod_freetdm --- libs/freetdm/mod_freetdm/mod_freetdm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 2b50d75b69..d2c142e7ff 100644 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -603,6 +603,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch assert(tech_pvt != NULL); if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { + ftdm_log(FTDM_LOG_DEBUG, "TFLAG_DEAD is set\n"); return SWITCH_STATUS_FALSE; } @@ -636,6 +637,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch } if (!switch_test_flag(tech_pvt, TFLAG_IO)) { + ftdm_log(FTDM_LOG_DEBUG, "TFLAG_IO is not set\n"); goto fail; } @@ -643,6 +645,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch status = ftdm_channel_wait(tech_pvt->ftdmchan, &wflags, chunk); if (status == FTDM_FAIL) { + ftdm_log(FTDM_LOG_WARNING, "failed to wait for I/O\n"); goto fail; } @@ -650,19 +653,21 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch if (!switch_test_flag(tech_pvt, TFLAG_HOLD)) { total_to -= chunk; if (total_to <= 0) { + ftdm_log(FTDM_LOG_WARNING, "Too many timeouts while waiting for I/O\n"); goto fail; } } - goto top; } if (!(wflags & FTDM_READ)) { + ftdm_log(FTDM_LOG_WARNING, "I/O waiting returned status %d but nothing to read is available\n", status); goto fail; } len = tech_pvt->read_frame.buflen; if (ftdm_channel_read(tech_pvt->ftdmchan, tech_pvt->read_frame.data, &len) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_WARNING, "failed to read from device\n"); goto fail; } From 64f58f2d677949010bfde9d942ada561f151f213 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 2 Jun 2010 15:14:49 -0500 Subject: [PATCH 06/10] only execute app once in app mode --- src/mod/endpoints/mod_loopback/mod_loopback.c | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_loopback/mod_loopback.c b/src/mod/endpoints/mod_loopback/mod_loopback.c index 11e180b076..0e52352b05 100644 --- a/src/mod/endpoints/mod_loopback/mod_loopback.c +++ b/src/mod/endpoints/mod_loopback/mod_loopback.c @@ -51,7 +51,8 @@ typedef enum { TFLAG_CNG = (1 << 3), TFLAG_BRIDGE = (1 << 4), TFLAG_BOWOUT = (1 << 5), - TFLAG_BLEG = (1 << 6) + TFLAG_BLEG = (1 << 6), + TFLAG_APP = (1 << 7) } TFLAGS; struct private_object { @@ -258,6 +259,11 @@ static switch_status_t channel_on_init(switch_core_session_t *session) //switch_ivr_transfer_variable(session, tech_pvt->other_session, "process_cdr"); switch_ivr_transfer_variable(session, tech_pvt->other_session, NULL); + if (switch_test_flag(tech_pvt, TFLAG_APP)) { + switch_set_flag(b_tech_pvt, TFLAG_APP); + switch_clear_flag(tech_pvt, TFLAG_APP); + } + switch_channel_set_variable(channel, "other_loopback_leg_uuid", switch_channel_get_uuid(b_channel)); switch_channel_set_variable(b_channel, "other_loopback_leg_uuid", switch_channel_get_uuid(channel)); @@ -313,10 +319,13 @@ static switch_status_t channel_on_routing(switch_core_session_t *session) do_reset(tech_pvt); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n", switch_channel_get_name(channel)); - - - if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND) && (app = switch_channel_get_variable(channel, "loopback_app"))) { + + if (switch_test_flag(tech_pvt, TFLAG_APP) && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND) && + (app = switch_channel_get_variable(channel, "loopback_app"))) { switch_caller_extension_t *extension = NULL; + + switch_clear_flag(tech_pvt, TFLAG_APP); + arg = switch_channel_get_variable(channel, "loopback_app_arg"); extension = switch_caller_extension_new(session, app, app); switch_caller_extension_add_application(session, extension, "pre_answer", NULL); @@ -862,10 +871,13 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi } switch_channel_set_variable(channel, "loopback_app", app); + if (arg) { switch_channel_set_variable(channel, "loopback_app_arg", arg); } + switch_set_flag(tech_pvt, TFLAG_APP); + caller_profile->destination_number = switch_core_strdup(caller_profile->pool, app); } From a0c78de27d50a80fa44551f6b9a825a22c8bda33 Mon Sep 17 00:00:00 2001 From: Brian West Date: Wed, 2 Jun 2010 15:17:06 -0500 Subject: [PATCH 07/10] don't use operator key when no operator ext is configured --- src/mod/applications/mod_voicemail/mod_voicemail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 45b0d1a00e..d06b0f4c5f 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -3042,7 +3042,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p greet_key_press: if (switch_stristr(buf, profile->login_keys)) { voicemail_check_main(session, profile, domain_name, id, 0); - } else if (!strcasecmp(buf, profile->operator_key) && !zstr(profile->operator_key)) { + } else if (!zstr(profile->operator_ext) && !zstr(profile->operator_key) && !strcasecmp(buf, profile->operator_key) ) { int argc; char *argv[4]; char *mycmd; From 75be3da8f94cf7010ca9ac564e2067e917200a68 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Wed, 2 Jun 2010 15:09:04 -0400 Subject: [PATCH 08/10] freetdm: add new logging macro --- libs/freetdm/src/ftdm_io.c | 22 +++++++------------- libs/freetdm/src/include/private/ftdm_core.h | 1 + 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 061cce80a7..c0e26de3b3 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -1157,31 +1157,27 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_set_state(const char *file, const char *f int waitms = DEFAULT_WAIT_TIME; if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_READY)) { - ftdm_log(file, func, line, FTDM_LOG_LEVEL_ERROR, "%d:%d Ignored state change request from %s to %s, the channel is not ready\n", - ftdmchan->span_id, ftdmchan->chan_id, + ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_ERROR, "Ignored state change request from %s to %s, the channel is not ready\n", ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); return FTDM_FAIL; } if (ftdm_test_flag(ftdmchan->span, FTDM_SPAN_SUSPENDED)) { if (state != FTDM_CHANNEL_STATE_RESTART && state != FTDM_CHANNEL_STATE_DOWN) { - ftdm_log(file, func, line, FTDM_LOG_LEVEL_ERROR, "%d:%d Ignored state change request from %s to %s, span %s is suspended\n", - ftdmchan->span_id, ftdmchan->chan_id, + ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_ERROR, "Ignored state change request from %s to %s, span %s is suspended\n", ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state), ftdmchan->span->name); return FTDM_FAIL; } } if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) { - ftdm_log(file, func, line, FTDM_LOG_LEVEL_ERROR, "%d:%d Ignored state change request from %s to %s, the previous state change has not been processed yet\n", - ftdmchan->span_id, ftdmchan->chan_id, + ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_ERROR, "Ignored state change request from %s to %s, the previous state change has not been processed yet\n", ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); return FTDM_FAIL; } if (ftdmchan->state == state) { - ftdm_log(file, func, line, FTDM_LOG_LEVEL_WARNING, "%d:%d Why bother changing state from %s to %s\n", - ftdmchan->span_id, ftdmchan->chan_id, ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); + ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_WARNING, "Why bother changing state from %s to %s\n", ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); return FTDM_FAIL; } @@ -1270,8 +1266,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_set_state(const char *file, const char *f end: if (ok) { - ftdm_log(file, func, line, FTDM_LOG_LEVEL_DEBUG, "%d:%d Changed state from %s to %s\n", - ftdmchan->span_id, ftdmchan->chan_id, ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); + ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Changed state from %s to %s\n", ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); ftdmchan->last_state = ftdmchan->state; ftdmchan->state = state; ftdm_set_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE); @@ -1283,8 +1278,7 @@ end: } ftdm_mutex_unlock(ftdmchan->span->mutex); } else { - ftdm_log(file, func, line, FTDM_LOG_LEVEL_WARNING, "%d:%d VETO state change from %s to %s\n", - ftdmchan->span_id, ftdmchan->chan_id, ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); + ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_WARNING, "VETO state change from %s to %s\n", ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); } /* there is an inherent race here between set and check of the change flag but we do not care because @@ -1311,8 +1305,8 @@ end: } if (waitms <= 0) { - ftdm_log(file, func, line, FTDM_LOG_LEVEL_WARNING, "%d:%d state change from %s to %s was most likely not processed after aprox %dms\n", - ftdmchan->span_id, ftdmchan->chan_id, ftdm_channel_state2str(ftdmchan->last_state), ftdm_channel_state2str(state), DEFAULT_WAIT_TIME); + ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_WARNING, "state change from %s to %s was most likely not processed after aprox %dms\n", + ftdm_channel_state2str(ftdmchan->last_state), ftdm_channel_state2str(state), DEFAULT_WAIT_TIME); } return ok ? FTDM_SUCCESS : FTDM_FAIL; diff --git a/libs/freetdm/src/include/private/ftdm_core.h b/libs/freetdm/src/include/private/ftdm_core.h index be1123e8b2..53e8cd5b85 100644 --- a/libs/freetdm/src/include/private/ftdm_core.h +++ b/libs/freetdm/src/include/private/ftdm_core.h @@ -561,6 +561,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_chan(ftdm_channel_t *ftdmchan); #define ftdm_channel_lock(chan) ftdm_mutex_lock(chan->mutex) #define ftdm_channel_unlock(chan) ftdm_mutex_unlock(chan->mutex) +#define ftdm_log_chan_ex(fchan, file, func, line, level, format, ...) ftdm_log(file, func, line, level, "s%dc%d " format, fchan->span_id, fchan->chan_id, __VA_ARGS__) #define ftdm_log_chan(fchan, level, format, ...) ftdm_log(level, "s%dc%d " format, fchan->span_id, fchan->chan_id, __VA_ARGS__) #define ftdm_log_chan_msg(fchan, level, msg) ftdm_log(level, "s%dc%d " msg, fchan->span_id, fchan->chan_id) From 52bda06b347c0255c3b2269901729384081c1e7e Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Wed, 2 Jun 2010 16:06:56 -0500 Subject: [PATCH 09/10] trivial path error --- libs/win32/pocketsphinx/pocketsphinx.2008.vcproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/win32/pocketsphinx/pocketsphinx.2008.vcproj b/libs/win32/pocketsphinx/pocketsphinx.2008.vcproj index 4ca287b2f8..68debfca09 100644 --- a/libs/win32/pocketsphinx/pocketsphinx.2008.vcproj +++ b/libs/win32/pocketsphinx/pocketsphinx.2008.vcproj @@ -256,7 +256,7 @@ SuppressStartupBanner="true" AdditionalLibraryDirectories="..\..\..\Debug" GenerateDebugInformation="true" - ProgramDatabaseFile=".\..\..\..\bin\Debug/pocketsphinx.pdb" + ProgramDatabaseFile="$(IntDir)/pocketsphinx.pdb" RandomizedBaseAddress="1" DataExecutionPrevention="0" TargetMachine="1" @@ -348,7 +348,7 @@ SuppressStartupBanner="true" AdditionalLibraryDirectories="..\..\..\Debug" GenerateDebugInformation="true" - ProgramDatabaseFile=".\..\..\..\bin\Debug/pocketsphinx.pdb" + ProgramDatabaseFile="$(IntDir)/pocketsphinx.pdb" RandomizedBaseAddress="1" DataExecutionPrevention="0" TargetMachine="17" From 4c20b020fc1d5473ef55cdd16e90521f6030865e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 2 Jun 2010 17:31:08 -0500 Subject: [PATCH 10/10] allow monitor_early_media and ignore_early_media to work for hmmhesays --- src/include/switch_types.h | 1 + src/switch_ivr_originate.c | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index c5781b5249..55cd26c148 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1006,6 +1006,7 @@ typedef enum { CF_BROADCAST_DROP_MEDIA, CF_EARLY_HANGUP, CF_MEDIA_SET, + CF_CONSUME_ON_ORIGINATE, /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ CF_FLAG_MAX } switch_channel_flag_t; diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 47875df4b2..2783125dcd 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -39,10 +39,9 @@ static switch_status_t originate_on_consume_media_transmit(switch_core_session_t { switch_channel_t *channel = switch_core_session_get_channel(session); - /* testing out not using this, we probably don't need it anymore now that we have audio sync */ -#if 0 - if (!switch_channel_test_flag(channel, CF_PROXY_MODE)) { - while (switch_channel_get_state(channel) == CS_CONSUME_MEDIA && !switch_channel_test_flag(channel, CF_TAGGED)) { + if (!switch_channel_test_flag(channel, CF_PROXY_MODE) && switch_channel_test_flag(channel, CF_CONSUME_ON_ORIGINATE)) { + while (switch_channel_test_flag(channel, CF_ORIGINATING) && + switch_channel_get_state(channel) == CS_CONSUME_MEDIA && !switch_channel_test_flag(channel, CF_TAGGED)) { if (!switch_channel_media_ready(channel)) { switch_yield(10000); } else { @@ -50,7 +49,6 @@ static switch_status_t originate_on_consume_media_transmit(switch_core_session_t } } } -#endif switch_channel_clear_state_handler(channel, &originate_state_handlers); @@ -2612,6 +2610,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess if (table) { switch_channel_add_state_handler(originate_status[i].peer_channel, table); } + + if (oglobals.monitor_early_media_ring || oglobals.monitor_early_media_fail) { + switch_channel_set_flag(originate_status[i].peer_channel, CF_CONSUME_ON_ORIGINATE); + } switch_channel_add_state_handler(originate_status[i].peer_channel, &originate_state_handlers);