From 10a3fa55efba4d8effd5065c334695b700e2db13 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 2 Oct 2014 17:49:09 -0500 Subject: [PATCH] %FEATURE add bypass_media_resume_on_hold and bypass_media_after_hold variables to be set to true to enable these functions on a per channel basis --- src/mod/endpoints/mod_sofia/sofia.c | 6 ++++-- src/switch_core_media.c | 14 +++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 01230c4029..6d83a8191d 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -6910,8 +6910,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { switch_core_session_message_t *msg; private_object_t *other_tech_pvt; - - if (switch_channel_test_flag(channel, CF_PROXY_MODE) && !is_t38 && (profile->media_options & MEDIA_OPT_MEDIA_ON_HOLD)) { + int media_on_hold = switch_true(switch_channel_get_variable_dup(channel, "bypass_media_resume_on_hold", SWITCH_FALSE, -1)); + + if (switch_channel_test_flag(channel, CF_PROXY_MODE) && !is_t38 && + ((profile->media_options & MEDIA_OPT_MEDIA_ON_HOLD) || media_on_hold)) { if (switch_stristr("sendonly", r_sdp) || switch_stristr("0.0.0.0", r_sdp)) { tech_pvt->mparams.hold_laps = 1; switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp); diff --git a/src/switch_core_media.c b/src/switch_core_media.c index b0b5ee4ec3..9163fb1a2b 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -4073,11 +4073,23 @@ SWITCH_DECLARE(int) switch_core_media_toggle_hold(switch_core_session_t *session if (switch_channel_test_flag(session->channel, CF_PROTO_HOLD)) { const char *val; + int media_on_hold_a = switch_true(switch_channel_get_variable_dup(session->channel, "bypass_media_resume_on_hold", SWITCH_FALSE, -1)); + int media_on_hold_b = switch_true(switch_channel_get_variable_dup(b_channel, "bypass_media_resume_on_hold", SWITCH_FALSE, -1)); + int bypass_after_hold_a = 0; + int bypass_after_hold_b = 0; + + if (media_on_hold_a) { + bypass_after_hold_a = switch_true(switch_channel_get_variable_dup(session->channel, "bypass_media_after_hold", SWITCH_FALSE, -1)); + } + + if (media_on_hold_b) { + bypass_after_hold_b = switch_true(switch_channel_get_variable_dup(b_channel, "bypass_media_after_hold", SWITCH_FALSE, -1)); + } switch_yield(250000); if (b_channel && (switch_channel_test_flag(session->channel, CF_BYPASS_MEDIA_AFTER_HOLD) || - switch_channel_test_flag(b_channel, CF_BYPASS_MEDIA_AFTER_HOLD))) { + switch_channel_test_flag(b_channel, CF_BYPASS_MEDIA_AFTER_HOLD) || bypass_after_hold_a || bypass_after_hold_b)) { /* try to stay out from media stream */ switch_ivr_nomedia(switch_core_session_get_uuid(session), SMF_REBRIDGE); }