[asterisk-commits] jpeeler: branch 1.4 r289797 - in /branches/1.4: channels/ include/asterisk/ m...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 1 17:58:43 CDT 2010


Author: jpeeler
Date: Fri Oct  1 17:58:38 2010
New Revision: 289797

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=289797
Log:
Change RFC2833 DTMF event duration on end to report actual elapsed time.

The scenario here is with a non P2P early media session. The reported time
length of DTMF presses are coming up short when sending to the remote side.
Currently the event duration is a running total that is incremented when sending
continuation packets. These continuation packets are only triggered upon
incoming media from the remote side, which means that the running total probably
is not going to end up matching the actual length of time Asterisk received
DTMF. This patch changes the end event duration to be lengthened if it is
detected that the end event is going to come up short.

Review: https://reviewboard.asterisk.org/r/957/

ABE-2476

Modified:
    branches/1.4/channels/chan_sip.c
    branches/1.4/include/asterisk/rtp.h
    branches/1.4/main/rtp.c

Modified: branches/1.4/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.4/channels/chan_sip.c?view=diff&rev=289797&r1=289796&r2=289797
==============================================================================
--- branches/1.4/channels/chan_sip.c (original)
+++ branches/1.4/channels/chan_sip.c Fri Oct  1 17:58:38 2010
@@ -4182,7 +4182,7 @@
 		break;
 	case SIP_DTMF_RFC2833:
 		if (p->rtp)
-			ast_rtp_senddigit_end(p->rtp, digit);
+			ast_rtp_senddigit_end_with_duration(p->rtp, digit, duration);
 		break;
 	case SIP_DTMF_INBAND:
 		res = -1; /* Tell Asterisk to stop inband indications */

Modified: branches/1.4/include/asterisk/rtp.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.4/include/asterisk/rtp.h?view=diff&rev=289797&r1=289796&r2=289797
==============================================================================
--- branches/1.4/include/asterisk/rtp.h (original)
+++ branches/1.4/include/asterisk/rtp.h Fri Oct  1 17:58:38 2010
@@ -174,6 +174,7 @@
 int ast_rtp_senddigit_begin(struct ast_rtp *rtp, char digit);
 
 int ast_rtp_senddigit_end(struct ast_rtp *rtp, char digit);
+int ast_rtp_senddigit_end_with_duration(struct ast_rtp *rtp, char digit, unsigned int duration);
 
 int ast_rtp_sendcng(struct ast_rtp *rtp, int level);
 

Modified: branches/1.4/main/rtp.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.4/main/rtp.c?view=diff&rev=289797&r1=289796&r2=289797
==============================================================================
--- branches/1.4/main/rtp.c (original)
+++ branches/1.4/main/rtp.c Fri Oct  1 17:58:38 2010
@@ -186,6 +186,7 @@
 static unsigned int ast_rtcp_calc_interval(struct ast_rtp *rtp);
 static int ast_rtp_senddigit_continuation(struct ast_rtp *rtp);
 int ast_rtp_senddigit_end(struct ast_rtp *rtp, char digit);
+int ast_rtp_senddigit_end_with_duration(struct ast_rtp *rtp, char digit, unsigned int duration);
 
 #define FLAG_3389_WARNING		(1 << 0)
 #define FLAG_NAT_ACTIVE			(3 << 1)
@@ -2421,12 +2422,18 @@
 	return 0;
 }
 
+int ast_rtp_senddigit_end(struct ast_rtp *rtp, char digit)
+{
+	return ast_rtp_senddigit_end_with_duration(rtp, digit, 0);
+}
+
 /*! \brief Send end packets for DTMF */
-int ast_rtp_senddigit_end(struct ast_rtp *rtp, char digit)
+int ast_rtp_senddigit_end_with_duration(struct ast_rtp *rtp, char digit, unsigned int duration)
 {
 	unsigned int *rtpheader;
 	int hdrlen = 12, res = 0, i = 0;
 	char data[256];
+	unsigned int measured_samples;
 	
 	/* If no address, then bail out */
 	if (!rtp->them.sin_addr.s_addr || !rtp->them.sin_port)
@@ -2448,6 +2455,13 @@
 	}
 
 	rtp->dtmfmute = ast_tvadd(ast_tvnow(), ast_tv(0, 500000));
+
+	if (duration > 0 && (measured_samples = duration * rtp_get_rate(rtp->f.subclass) / 1000) > rtp->send_duration) {
+		if (option_debug > 1) {
+			ast_log(LOG_DEBUG, "Adjusting final end duration from %u to %u\n", rtp->send_duration, measured_samples);
+		}
+		rtp->send_duration = measured_samples;
+	}
 
 	rtpheader = (unsigned int *)data;
 	rtpheader[1] = htonl(rtp->lastdigitts);




More information about the asterisk-commits mailing list