[asterisk-commits] trunk r13096 - in /trunk: ./ rtp.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Mar 15 11:15:34 MST 2006


Author: tilghman
Date: Wed Mar 15 12:15:33 2006
New Revision: 13096

URL: http://svn.digium.com/view/asterisk?rev=13096&view=rev
Log:
Merged revisions 13095 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r13095 | tilghman | 2006-03-15 12:07:06 -0600 (Wed, 15 Mar 2006) | 2 lines

Reverting patch from bug 6667

........

Modified:
    trunk/   (props changed)
    trunk/rtp.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: trunk/rtp.c
URL: http://svn.digium.com/view/asterisk/trunk/rtp.c?rev=13096&r1=13095&r2=13096&view=diff
==============================================================================
--- trunk/rtp.c (original)
+++ trunk/rtp.c Wed Mar 15 12:15:33 2006
@@ -1193,7 +1193,6 @@
 	int hdrlen = 12;
 	int res;
 	int x;
-	unsigned short duration = 0;
 	int payload;
 	char data[256];
 	char iabuf[INET_ADDRSTRLEN];
@@ -1226,8 +1225,7 @@
 	rtpheader[1] = htonl(rtp->lastdigitts);
 	rtpheader[2] = htonl(rtp->ssrc); 
 	rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (0));
-
-	for (x = 0; x < 5; x++) {
+	for (x = 0; x < 6; x++) {
 		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) 
@@ -1239,48 +1237,35 @@
 					    ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr),
 					    ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
 		}
-
-		/* Sequence number must be incremented for every packet */
-		rtp->seqno++;
+		/* Sequence number of last two end packets does not get incremented */
+		if (x < 3)
+			rtp->seqno++;
 		/* Clear marker bit and set seqno */
 		rtpheader[0] = htonl((2 << 30) | (payload << 16) | (rtp->seqno));
-		/* Increment duration for 160 (20ms) */
-		duration += 160;
-		rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (duration));
-	}
-
-	/* Set the End bit */
-	rtpheader[3] |= htonl((1 << 23));
-
-	/* Send last packet and repeat it 2 times */
-	for (x = 0; x < 3; x++) {
-		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(iabuf, sizeof(iabuf), rtp->them.sin_addr),
-					ntohs(rtp->them.sin_port), strerror(errno));
-			}
-			if (rtp_debug_test_addr(&rtp->them)) {
-				ast_verbose("Sent RTP packet to %s:%d (type %d, seq %u, ts %u, len %u)\n",
-					    ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr),
-					    ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
-			}
-		}
-		
-		/* Sequence number must be incremented for every packet, even for retransmitted last two packets */
-		rtp->seqno++;
-		/* Set seqno */
-		rtpheader[0] = htonl((2 << 30) | (payload << 16) | (rtp->seqno));
-	}
-
+		/* For the last three packets, set the duration and the end bit */
+		if (x == 2) {
+#if 0
+			/* No, this is wrong...  Do not increment lastdigitts, that's not according
+			   to the RFC, as best we can determine */
+			rtp->lastdigitts++; /* or else the SPA3000 will click instead of beeping... */
+			rtpheader[1] = htonl(rtp->lastdigitts);
+#endif			
+			/* Make duration 800 (100ms) */
+			rtpheader[3] |= htonl((800));
+			/* Set the End bit */
+			rtpheader[3] |= htonl((1 << 23));
+		}
+	}
 	/* Increment the digit timestamp by 120ms, to ensure that digits
 	   sent sequentially with no intervening non-digit packets do not
 	   get sent with the same timestamp, and that sequential digits
 	   have some 'dead air' in between them
 	*/
-	duration += 160;
-	rtp->lastdigitts += duration;
+	rtp->lastdigitts += 960;
+	/* Increment the sequence number to reflect the last packet
+	   that was sent
+	*/
+	rtp->seqno++;
 	return 0;
 }
 



More information about the asterisk-commits mailing list