From a0c641aeb72c538fa5245e795ee52bf0d72acff0 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 18 Jun 2010 16:52:39 -0500 Subject: [PATCH] MODSOFIA-59 (part 2) --- src/include/switch_types.h | 1 + src/mod/endpoints/mod_sofia/mod_sofia.c | 13 +++++++++++++ src/switch_core_session.c | 4 ++++ src/switch_ivr_originate.c | 9 +++++++++ 4 files changed, 27 insertions(+) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 96e10f9c50..74d5920b24 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -740,6 +740,7 @@ typedef enum { SWITCH_MESSAGE_INDICATE_PHONE_EVENT, SWITCH_MESSAGE_INDICATE_T38_DESCRIPTION, SWITCH_MESSAGE_INDICATE_UDPTL_MODE, + SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS, SWITCH_MESSAGE_INVALID } switch_core_session_message_types_t; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 27f98edd47..d1f7d4cc1c 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1435,6 +1435,11 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } goto end; + case SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS: + if (!switch_channel_test_flag(channel, CF_ANSWERED)) { + sofia_clear_flag(tech_pvt, TFLAG_EARLY_MEDIA); + } + goto end; case SWITCH_MESSAGE_INDICATE_ANSWER: case SWITCH_MESSAGE_INDICATE_PROGRESS: { @@ -2179,6 +2184,14 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX); + if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) && + tech_pvt->early_sdp && strcmp(tech_pvt->early_sdp, tech_pvt->local_sdp_str)) { + /* The SIP RFC for SOA forbids sending a 183 with one sdp then a 200 with another but it won't do us much good unless + we do so in this case we will abandon the SOA rules and go rogue. + */ + sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA); + } + tech_pvt->early_sdp = switch_core_session_strdup(tech_pvt->session, tech_pvt->local_sdp_str); if (sofia_use_soa(tech_pvt)) { diff --git a/src/switch_core_session.c b/src/switch_core_session.c index ec9c988c5f..62f509239b 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -598,6 +598,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(swit switch_channel_get_name(session->channel), message_names[message->message_id]); + if (message->message_id == SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS) { + switch_channel_clear_flag(session->channel, CF_EARLY_MEDIA); + } + if (message->message_id == SWITCH_MESSAGE_INDICATE_DISPLAY && switch_true(switch_channel_get_variable(session->channel, SWITCH_IGNORE_DISPLAY_UPDATES_VARIABLE))) { switch_log_printf(SWITCH_CHANNEL_ID_LOG, message->_file, message->_func, message->_line, diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 1668f07ebd..11e5bc5d01 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -1797,6 +1797,15 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess } } + if (bypass_media && switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(caller_channel, CF_ANSWERED)) { + switch_core_session_message_t msg = { 0 }; + + msg.message_id = SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS; + msg.from = __FILE__; + switch_core_session_receive_message(session, &msg); + } + + if (!zstr(bypass_media) && !switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA)) { if (switch_true(bypass_media)) { switch_channel_set_flag(caller_channel, CF_PROXY_MODE);