From e4e9b1b9f93f3b1c6e344519d52d3854520ba29a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 10 Oct 2014 16:09:43 -0500 Subject: [PATCH] have resume media on hold not send invite back out at the holder but rather enable media in the 200ok --- src/include/switch_types.h | 4 +++- src/mod/endpoints/mod_sofia/mod_sofia.c | 14 +++++++------ src/mod/endpoints/mod_sofia/sofia.c | 2 +- src/switch_ivr.c | 26 +++++++++++++++++-------- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 910b44b338..9fd067c0f5 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -460,7 +460,9 @@ typedef enum { SMF_HOLD_BLEG = (1 << 5), SMF_IMMEDIATE = (1 << 6), SMF_EXEC_INLINE = (1 << 7), - SMF_PRIORITY = (1 << 8) + SMF_PRIORITY = (1 << 8), + SMF_REPLYONLY_A = (1 << 9), + SMF_REPLYONLY_B = (1 << 10) } switch_media_flag_enum_t; typedef uint32_t switch_media_flag_t; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index dde3c88e1a..11e73fff81 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1451,13 +1451,15 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, NULL, 0, NULL, 1); - if (send_invite) { - if (!switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { - switch_channel_set_flag(channel, CF_REQ_MEDIA); + if (!msg->numeric_arg) { + if (send_invite) { + if (!switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { + switch_channel_set_flag(channel, CF_REQ_MEDIA); + } + sofia_glue_do_invite(session); + } else { + status = SWITCH_STATUS_FALSE; } - sofia_glue_do_invite(session); - } else { - status = SWITCH_STATUS_FALSE; } } break; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 94adf806ec..496d95faf0 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -6367,7 +6367,7 @@ void *SWITCH_THREAD_FUNC media_on_hold_thread_run(switch_thread_t *thread, void switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL); switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL); - switch_ivr_media(switch_core_session_get_uuid(other_session), SMF_REBRIDGE); + switch_ivr_media(switch_core_session_get_uuid(other_session), SMF_REBRIDGE|SMF_REPLYONLY_B); if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) { switch_core_media_clear_rtp_flag(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, SWITCH_RTP_FLAG_AUTOADJ); diff --git a/src/switch_ivr.c b/src/switch_ivr.c index a08bb0a40d..c328e177f1 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -1568,20 +1568,30 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_ status = SWITCH_STATUS_SUCCESS; /* If we had early media in bypass mode before, it is no longer relevant */ - if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) { - switch_core_session_message_t msg2 = { 0 }; - - msg2.message_id = SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS; - msg2.from = __FILE__; - switch_core_session_receive_message(session, &msg2); - } - + if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) { + switch_core_session_message_t msg2 = { 0 }; + + msg2.message_id = SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS; + msg2.from = __FILE__; + switch_core_session_receive_message(session, &msg2); + } + + if ((flags & SMF_REPLYONLY_A)) { + msg.numeric_arg = 1; + } + if (switch_core_session_receive_message(session, &msg) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't re-establsh media on %s\n", switch_channel_get_name(channel)); switch_core_session_rwunlock(session); return SWITCH_STATUS_GENERR; } + if ((flags & SMF_REPLYONLY_B)) { + msg.numeric_arg = 1; + } else { + msg.numeric_arg = 0; + } + if ((flags & SMF_IMMEDIATE)) { switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 250, NULL); switch_yield(250000);