From 952c37d94038869f112933906eab6a6035009f55 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 22 Aug 2013 02:30:59 +0500 Subject: [PATCH] FS-5296 --resolve --- src/include/switch_types.h | 1 + src/switch_rtp.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 7f3aade715..9728062d4c 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -652,6 +652,7 @@ typedef enum { SWITCH_RTP_FLAG_VIDEO, SWITCH_RTP_FLAG_ENABLE_RTCP, SWITCH_RTP_FLAG_RTCP_MUX, + SWITCH_RTP_FLAG_KILL_JB, SWITCH_RTP_FLAG_INVALID } switch_rtp_flag_t; diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 106f9ec1aa..b75835a270 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -3126,9 +3126,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_deactivate_jitter_buffer(switch_rtp_t return SWITCH_STATUS_FALSE; } - READ_INC(rtp_session); - stfu_n_destroy(&rtp_session->jb); - READ_DEC(rtp_session); + rtp_session->flags[SWITCH_RTP_FLAG_KILL_JB]++; return SWITCH_STATUS_SUCCESS; } @@ -3638,6 +3636,9 @@ SWITCH_DECLARE(void) switch_rtp_set_flag(switch_rtp_t *rtp_session, switch_rtp_f rtp_session->autoadj_window = 20; rtp_session->autoadj_tally = 0; rtp_flush_read_buffer(rtp_session, SWITCH_RTP_FLUSH_ONCE); + if (rtp_session->jb) { + stfu_n_reset(rtp_session->jb); + } } else if (flag == SWITCH_RTP_FLAG_NOBLOCK && rtp_session->sock_input) { switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, TRUE); } @@ -4255,6 +4256,14 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t switch_swap_linear((int16_t *)RTP_BODY(rtp_session), (int) *bytes - rtp_header_len); } + if (rtp_session->flags[SWITCH_RTP_FLAG_KILL_JB]) { + rtp_session->flags[SWITCH_RTP_FLAG_KILL_JB] = 0; + if (rtp_session->jb) { + stfu_n_destroy(&rtp_session->jb); + } + } + + if (rtp_session->jb && !rtp_session->pause_jb && rtp_session->recv_msg.header.version == 2 && *bytes) { if (rtp_session->recv_msg.header.m && rtp_session->recv_msg.header.pt != rtp_session->recv_te && !rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && !(rtp_session->rtp_bugs & RTP_BUG_IGNORE_MARK_BIT)) {