[svn-commits] file: branch group/vldtmf r40304 - /team/group/vldtmf/rtp.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Aug 17 14:22:28 MST 2006


Author: file
Date: Thu Aug 17 16:22:28 2006
New Revision: 40304

URL: http://svn.digium.com/view/asterisk?rev=40304&view=rev
Log:
Someone set us up the VLDTMF, we have digit. Hey core, will you compensate for me? Yeah bro - for shizzle.

Modified:
    team/group/vldtmf/rtp.c

Modified: team/group/vldtmf/rtp.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/rtp.c?rev=40304&r1=40303&r2=40304&view=diff
==============================================================================
--- team/group/vldtmf/rtp.c (original)
+++ team/group/vldtmf/rtp.c Thu Aug 17 16:22:28 2006
@@ -133,11 +133,9 @@
 	unsigned int lasteventendseqn;
 	int dtmfcount;
 	unsigned int dtmfduration;
-	int receive_compensate;
 	/* DTMF Transmission Variables */
 	unsigned int lastdigitts;
 	char send_digit;
-	int send_compensate;
 	int send_payload;
 	int nat;
 	unsigned int flags;
@@ -669,15 +667,12 @@
 	if (((!(rtp->resp) && (!(event_end & 0x80))) || (rtp->resp && rtp->resp != resp)) && !ast_test_flag(rtp, FLAG_DTMF_COMPENSATE)) {
 		rtp->resp = resp;
 		f = send_dtmf(rtp, AST_FRAME_DTMF_BEGIN);
-	} else if (event_end & 0x80) {
-		if (!rtp->resp && ast_test_flag(rtp, FLAG_DTMF_COMPENSATE)) {
+	} else if (event_end & 0x80 && rtp->lasteventendseqn != seqno) {
+		if (ast_test_flag(rtp,  FLAG_DTMF_COMPENSATE))
 			rtp->resp = resp;
-			f = send_dtmf(rtp, AST_FRAME_DTMF_BEGIN);
-		} else if (rtp->resp && rtp->lasteventendseqn != seqno && !ast_test_flag(rtp, FLAG_DTMF_COMPENSATE)) {
-			rtp->lasteventendseqn = seqno;
-			f = send_dtmf(rtp, AST_FRAME_DTMF_END);
-			rtp->resp = 0;
-		}
+		f = send_dtmf(rtp, AST_FRAME_DTMF_END);
+		rtp->resp = 0;
+		rtp->lasteventendseqn = seqno;
 	}
 
 	rtp->dtmfcount = dtmftimeout;
@@ -959,15 +954,9 @@
 	unsigned int timestamp;
 	unsigned int *rtpheader;
 	struct rtpPayloadType rtpPT;
-	struct ast_frame *fr = NULL;
 	
 	/* If time is up, kill it */
-	if (rtp->send_compensate >= 1) {
-		if (rtp->send_compensate == 7)
-			ast_rtp_senddigit_end(rtp, rtp->send_digit);
-		else
-			rtp->send_compensate++;
-	} else if (rtp->send_digit)
+	if (rtp->send_digit)
 		ast_rtp_senddigit_continuation(rtp);
 
 	len = sizeof(sin);
@@ -1134,18 +1123,6 @@
 
 	rtp->rxseqno = seqno;
 
-	/* If we are compensating for lack of VLDTMF, then check to see if we need to send an AST_FRAME_DTMF_END */
-	if (rtp->resp && ast_test_flag(rtp, FLAG_DTMF_COMPENSATE)) {
-		/* We wait for 6 regular frames to come in before queueing the AST_FRAME_DTMF_END */
-		if (rtp->receive_compensate >= 6) {
-			fr = send_dtmf(rtp, AST_FRAME_DTMF_END);
-			rtp->lastrxts = timestamp;
-			rtp->resp = 0;
-			return fr;
-		} else
-			rtp->receive_compensate++;
-	}
-
 	/* Record received timestamp as last received now */
 	rtp->lastrxts = timestamp;
 
@@ -1948,7 +1925,6 @@
 
 	/* Since we received a begin, we can safely store the digit and disable any compensation */
 	rtp->send_digit = digit;
-	rtp->send_compensate = 0;
 	rtp->send_payload = payload;
 
 	return 0;
@@ -1997,7 +1973,6 @@
 	unsigned int *rtpheader;
 	int hdrlen = 12, res = 0, i = 0;
 	char data[256];
-	char original_digit = digit;
 	
 	/* If no address, then bail out */
 	if (!rtp->them.sin_addr.s_addr)
@@ -2007,44 +1982,34 @@
 	if (digit_convert(digit))
 		return -1;
 
-	/* If no digit was pressed initially, then we need to compensate */
-	if (rtp->send_digit == 0) {
-		if ((res = ast_rtp_senddigit_begin(rtp, original_digit)))
-			return res;
-		/* Initialize compensation */
-		rtp->send_compensate = 1;
-	} else {
-		/* We can safely send termination here */
-		rtpheader = (unsigned int *)data;
-		rtpheader[0] = htonl((2 << 30) | (1 << 23) | (rtp->send_payload << 16) | (rtp->seqno));
-		rtpheader[1] = htonl(rtp->lastdigitts);
-		rtpheader[2] = htonl(rtp->ssrc);
-		rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (0));
-		/* Send duration to 100ms */
-		rtpheader[3] |= htonl((800));
-		/* Set end bit */
-		rtpheader[3] |= htonl((1 << 23));
-		rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));
-		/* Send 3 termination packets */
-		for (i = 0; i < 3; i++) {
-			if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
-				res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them));
-				if (res < 0)
-					ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
-						ast_inet_ntoa(rtp->them.sin_addr),
-						ntohs(rtp->them.sin_port), strerror(errno));
-				if (rtp_debug_test_addr(&rtp->them))
-					ast_verbose("Sent RTP DTMF packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
-						    ast_inet_ntoa(rtp->them.sin_addr),
-						    ntohs(rtp->them.sin_port), rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
-			}
-		}
-		rtp->send_digit = 0;
-		rtp->send_compensate = 0;
-		/* Increment lastdigitts */
-		rtp->lastdigitts += 960;
-		rtp->seqno++;
-	}
+	rtpheader = (unsigned int *)data;
+	rtpheader[0] = htonl((2 << 30) | (1 << 23) | (rtp->send_payload << 16) | (rtp->seqno));
+	rtpheader[1] = htonl(rtp->lastdigitts);
+	rtpheader[2] = htonl(rtp->ssrc);
+	rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (0));
+	/* Send duration to 100ms */
+	rtpheader[3] |= htonl((800));
+	/* Set end bit */
+	rtpheader[3] |= htonl((1 << 23));
+	rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));
+	/* Send 3 termination packets */
+	for (i = 0; i < 3; i++) {
+		if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
+			res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them));
+			if (res < 0)
+				ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
+					ast_inet_ntoa(rtp->them.sin_addr),
+					ntohs(rtp->them.sin_port), strerror(errno));
+			if (rtp_debug_test_addr(&rtp->them))
+				ast_verbose("Sent RTP DTMF packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+					    ast_inet_ntoa(rtp->them.sin_addr),
+					    ntohs(rtp->them.sin_port), rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
+		}
+	}
+	rtp->send_digit = 0;
+	/* Increment lastdigitts */
+	rtp->lastdigitts += 960;
+	rtp->seqno++;
 
 	return res;
 }



More information about the svn-commits mailing list