From f2b836ff4f9f34c48f36b9aca18c633834dc0ace Mon Sep 17 00:00:00 2001
From: Joshua Colp <jcolp@digium.com>
Date: Thu, 31 Aug 2006 21:00:16 +0000
Subject: [PATCH] Tweak the DTMF muting stuff a bit to take into account VLDTMF
 and compensation.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@41632 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 main/rtp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/main/rtp.c b/main/rtp.c
index 619acc347f..b62ed1480a 100644
--- a/main/rtp.c
+++ b/main/rtp.c
@@ -545,7 +545,8 @@ void ast_rtp_setdtmfcompensate(struct ast_rtp *rtp, int compensate)
 
 static struct ast_frame *send_dtmf(struct ast_rtp *rtp, enum ast_frame_type type)
 {
-	if (ast_tvcmp(ast_tvnow(), rtp->dtmfmute) < 0) {
+	if (((ast_test_flag(rtp, FLAG_DTMF_COMPENSATE) && type == AST_FRAME_DTMF_END) ||
+	     (type == AST_FRAME_DTMF_BEGIN)) && ast_tvcmp(ast_tvnow(), rtp->dtmfmute) < 0) {
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Ignore potential DTMF echo from '%s'\n", ast_inet_ntoa(rtp->them.sin_addr));
 		rtp->resp = 0;
@@ -2078,6 +2079,8 @@ int ast_rtp_senddigit_end(struct ast_rtp *rtp, char digit)
 	if (digit_convert(digit))
 		return -1;
 
+	rtp->dtmfmute = ast_tvadd(ast_tvnow(), ast_tv(0, 500000));
+
 	rtpheader = (unsigned int *)data;
 	rtpheader[0] = htonl((2 << 30) | (1 << 23) | (rtp->send_payload << 16) | (rtp->seqno));
 	rtpheader[1] = htonl(rtp->lastdigitts);
-- 
GitLab