From a239914926adfda08303336fe47ca8d83e72b97a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 26 Mar 2012 10:53:34 -0500 Subject: [PATCH] addition to a6a3ff1dc5574ded096ac1427cd7c6992d14092f --- src/include/switch_rtp.h | 1 + src/switch_ivr_bridge.c | 3 +++ src/switch_rtp.c | 32 +++++++++++++++++++++----------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index 94c9d671e9..a61326a6b8 100644 --- a/src/include/switch_rtp.h +++ b/src/include/switch_rtp.h @@ -196,6 +196,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_s SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session); SWITCH_DECLARE(void) switch_rtp_break(switch_rtp_t *rtp_session); +SWITCH_DECLARE(void) switch_rtp_flush(switch_rtp_t *rtp_session); /*! \brief Test if an RTP session is ready diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 266fa8d187..06dc31e1cb 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -1194,6 +1194,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses switch_channel_set_flag_recursive(caller_channel, CF_BRIDGE_ORIGINATOR); switch_channel_clear_flag(peer_channel, CF_BRIDGE_ORIGINATOR); + switch_channel_audio_sync(caller_channel); + switch_channel_audio_sync(peer_channel); + b_leg->session = peer_session; switch_copy_string(b_leg->b_uuid, switch_core_session_get_uuid(session), sizeof(b_leg->b_uuid)); b_leg->stream_id = stream_id; diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 56bc0e58ee..f9b2c1a7d8 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -2030,6 +2030,16 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio return SWITCH_STATUS_SUCCESS; } +SWITCH_DECLARE(void) switch_rtp_flush(switch_rtp_t *rtp_session) +{ + if (!switch_rtp_ready(rtp_session)) { + return; + } + + switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH); +} + + SWITCH_DECLARE(void) switch_rtp_break(switch_rtp_t *rtp_session) { if (!switch_rtp_ready(rtp_session)) { @@ -2038,7 +2048,6 @@ SWITCH_DECLARE(void) switch_rtp_break(switch_rtp_t *rtp_session) switch_mutex_lock(rtp_session->flag_mutex); switch_set_flag(rtp_session, SWITCH_RTP_FLAG_BREAK); - switch_set_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH); if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK)) { switch_mutex_unlock(rtp_session->flag_mutex); @@ -3095,25 +3104,26 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ check = !bytes; + if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH)) { + if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) { + do_flush(rtp_session); + bytes = 0; + } + switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH); + } + if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK) || (bytes && bytes == 4 && *((int *) &rtp_session->recv_msg) == UINT_MAX)) { switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK); - if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) || !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL) || (bytes && bytes < 5) || (!bytes && poll_loop)) { + if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) || !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) || + switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL) || + (bytes && bytes < 5) || (!bytes && poll_loop)) { do_2833(rtp_session, session); bytes = 0; return_cng_frame(); - } else { - switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH); } } - if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH)) { - if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) { - do_flush(rtp_session); - bytes = 0; - } - switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH); - } if (bytes && bytes < 5) { continue;