From d31a738bc5db4432dc2a9ff64b958e8671141cc2 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 30 Aug 2012 16:51:06 -0500 Subject: [PATCH] add uuid_early_ok --- src/include/switch_types.h | 1 + .../applications/mod_commands/mod_commands.c | 17 +++++++++++++++++ src/switch_ivr_originate.c | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 690f9f5bde..5c6ec620b6 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1242,6 +1242,7 @@ typedef enum { CF_TRACKED, CF_TRACKABLE, CF_NO_CDR, + CF_EARLY_OK, /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ /* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */ CF_FLAG_MAX diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index d199899e9e..c0dc16a7de 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -2738,6 +2738,21 @@ SWITCH_STANDARD_API(uuid_media_function) return SWITCH_STATUS_SUCCESS; } +SWITCH_STANDARD_API(uuid_early_ok_function) +{ + char *uuid = (char *) cmd; + switch_core_session_t *xsession; + + if (uuid && (xsession = switch_core_session_locate(uuid))) { + switch_channel_t *channel = switch_core_session_get_channel(xsession); + switch_channel_set_flag(channel, CF_EARLY_OK); + switch_core_session_rwunlock(xsession); + } else { + stream->write_function(stream, "-ERROR\n"); + } + + return SWITCH_STATUS_SUCCESS; +} SWITCH_STANDARD_API(uuid_pre_answer_function) { @@ -5603,6 +5618,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "url_decode", "url decode a string", url_decode_function, ""); SWITCH_ADD_API(commands_api_interface, "url_encode", "url encode a string", url_encode_function, ""); SWITCH_ADD_API(commands_api_interface, "user_data", "find user data", user_data_function, "@ [var|param|attr] "); + SWITCH_ADD_API(commands_api_interface, "uuid_early_ok", "stop ignoring early media", uuid_early_ok_function, ""); SWITCH_ADD_API(commands_api_interface, "user_exists", "find a user", user_exists_function, " "); SWITCH_ADD_API(commands_api_interface, "uuid_answer", "answer", uuid_answer_function, ""); SWITCH_ADD_API(commands_api_interface, "uuid_audio", "uuid_audio", session_audio_function, AUDIO_SYNTAX); @@ -5757,6 +5773,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add uuid_dump ::console::list_uuid"); switch_console_set_complete("add uuid_answer ::console::list_uuid"); switch_console_set_complete("add uuid_pre_answer ::console::list_uuid"); + switch_console_set_complete("add uuid_early_ok ::console::list_uuid"); switch_console_set_complete("add uuid_exists ::console::list_uuid"); switch_console_set_complete("add uuid_fileman ::console::list_uuid"); switch_console_set_complete("add uuid_flush_dtmf ::console::list_uuid"); diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index b9975ee6de..52e83f388d 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -694,6 +694,10 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat } } + if (!oglobals->early_ok && switch_channel_test_flag(originate_status[i].peer_channel, CF_EARLY_OK)) { + oglobals->early_ok = 1; + } + state = switch_channel_get_state(originate_status[i].peer_channel); if (state >= CS_HANGUP || state == CS_RESET || switch_channel_test_flag(originate_status[i].peer_channel, CF_TRANSFER) || switch_channel_test_flag(originate_status[i].peer_channel, CF_REDIRECT) ||