From 6b35e576fcd65469b93a853bab5be8dd961bae34 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 1 Aug 2019 05:16:27 +0000 Subject: [PATCH] [core] Transfer with rtp_pass_codecs_on_stream_change one way audio --- src/include/switch_ivr.h | 3 +++ src/switch_core_media.c | 2 +- src/switch_ivr.c | 33 ++++++++++++++++++++++----------- src/switch_ivr_bridge.c | 3 +++ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 39e915edc5..34d6625541 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -559,6 +559,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_bridge_bleg(switch_core_session_t *se */ SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *session, switch_core_session_t *peer_session); +SWITCH_DECLARE(void) switch_ivr_check_hold(switch_core_session_t *session); + + /*! \brief Transfer an existing session to another location \param session the session to transfer diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 5e73a32862..65ea2f3a6b 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -10341,7 +10341,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess switch_core_session_get_partner(session, &orig_session); - if (orig_session) { + if (orig_session && !switch_channel_test_flag(session->channel, CF_ANSWERED)) { switch_core_media_set_smode(smh->session, SWITCH_MEDIA_TYPE_AUDIO, switch_core_session_remote_media_flow(orig_session, SWITCH_MEDIA_TYPE_AUDIO), sdp_type); switch_core_media_set_smode(smh->session, SWITCH_MEDIA_TYPE_VIDEO, diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 63237ed063..c1d232e1b7 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -2093,6 +2093,26 @@ SWITCH_DECLARE(void) switch_ivr_bg_media(const char *uuid, switch_media_flag_t f } +SWITCH_DECLARE(void) switch_ivr_check_hold(switch_core_session_t *session) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_media_flow_t flow; + + if (switch_channel_test_flag(channel, CF_ANSWERED) && + (flow = switch_core_session_media_flow(session, SWITCH_MEDIA_TYPE_AUDIO)) != SWITCH_MEDIA_FLOW_SENDRECV) { + switch_core_session_message_t msg = { 0 }; + + msg.message_id = SWITCH_MESSAGE_INDICATE_MEDIA_RENEG; + msg.from = __FILE__; + + switch_core_media_set_smode(session, SWITCH_MEDIA_TYPE_AUDIO, SWITCH_MEDIA_FLOW_SENDRECV, SDP_TYPE_REQUEST); + switch_core_session_receive_message(session, &msg); + } + + if (switch_channel_test_flag(channel, CF_HOLD)) { + switch_ivr_unhold(session); + } +} SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, const char *extension, const char *dialplan, const char *context) @@ -2108,7 +2128,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_ const char *forwardvar = switch_channel_get_variable(channel, forwardvar_name); int forwardval = 70; const char *use_dialplan = dialplan, *use_context = context; - switch_media_flow_t flow; if (zstr(forwardvar)) { forwardvar_name = SWITCH_MAX_FORWARDS_VARIABLE; /* fall back to max_forwards variable for setting maximum */ @@ -2122,16 +2141,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_ return SWITCH_STATUS_FALSE; } - if (switch_channel_test_flag(channel, CF_ANSWERED) && - (flow = switch_core_session_media_flow(session, SWITCH_MEDIA_TYPE_AUDIO)) != SWITCH_MEDIA_FLOW_SENDRECV) { - switch_core_session_message_t msg = { 0 }; - - msg.message_id = SWITCH_MESSAGE_INDICATE_MEDIA_RENEG; - msg.from = __FILE__; - - switch_core_media_set_smode(session, SWITCH_MEDIA_TYPE_AUDIO, SWITCH_MEDIA_FLOW_SENDRECV, SDP_TYPE_REQUEST); - switch_core_session_receive_message(session, &msg); - } + switch_ivr_check_hold(session); + max_forwards = switch_core_session_sprintf(session, "%d", forwardval); switch_channel_set_variable(channel, forwardvar_name, max_forwards); diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index d90ae88f89..3e5e2145be 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -2017,6 +2017,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uu originator_channel = switch_core_session_get_channel(originator_session); originatee_channel = switch_core_session_get_channel(originatee_session); + switch_ivr_check_hold(originator_session); + switch_ivr_check_hold(originatee_session); + if (switch_channel_test_flag(originator_channel, CF_LEG_HOLDING)) { switch_channel_set_flag(originator_channel, CF_HOLD_ON_BRIDGE);