From 52377f0f65bc0075dd60d092407614b4cb5726bf Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 31 Dec 2013 00:30:20 +0500 Subject: [PATCH] FS-6007 --- src/switch_rtp.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 7c0dbcc2e0..f1ed3c6ba5 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -281,7 +281,8 @@ struct switch_rtp { int zrtp_mitm_tries; int zinit; #endif - + + uint32_t passing_dtmf; }; @@ -347,6 +348,15 @@ static void do_2833(switch_rtp_t *rtp_session, switch_core_session_t *session); static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_size_t bytes, int *do_cng) { + if (rtp_session->passing_dtmf) { + rtp_session->passing_dtmf++; + + if (rtp_session->passing_dtmf > 1000) { + rtp_session->passing_dtmf = 0; + } + } + + #ifdef DEBUG_2833 if (rtp_session->dtmf_data.in_digit_sanity && !(rtp_session->dtmf_data.in_digit_sanity % 100)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "sanity %d %ld\n", rtp_session->dtmf_data.in_digit_sanity, bytes); @@ -366,7 +376,7 @@ static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_ doing it right. Nice guys finish last! */ if (bytes > rtp_header_len && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) && - !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833) && rtp_session->recv_te && rtp_session->recv_msg.header.pt == rtp_session->recv_te) { + rtp_session->recv_te && rtp_session->recv_msg.header.pt == rtp_session->recv_te) { switch_size_t len = bytes - rtp_header_len; unsigned char *packet = (unsigned char *) RTP_BODY(rtp_session); int end; @@ -397,6 +407,17 @@ static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_ in_digit_seq = ntohs((uint16_t) rtp_session->recv_msg.header.seq); ts = htonl(rtp_session->recv_msg.header.ts); + if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833)) { + + if (end) { + rtp_session->passing_dtmf = 998; + } else if (!rtp_session->passing_dtmf) { + rtp_session->passing_dtmf = 1; + } + + return RESULT_CONTINUE; + } + if (in_digit_seq < rtp_session->dtmf_data.in_digit_seq) { if (rtp_session->dtmf_data.in_digit_seq - in_digit_seq > 100) { rtp_session->dtmf_data.in_digit_seq = 0; @@ -2875,10 +2896,11 @@ static void do_flush(switch_rtp_t *rtp_session) int was_blocking = 0; switch_size_t bytes; uint32_t flushed = 0; - + if (!switch_rtp_ready(rtp_session) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) || - switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO) + switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO) || + rtp_session->passing_dtmf ) { return; }