[Asterisk-cvs] asterisk frame.c,1.49,1.50 rtp.c,1.119,1.120

kpfleming at lists.digium.com kpfleming at lists.digium.com
Sun Apr 3 21:20:44 CDT 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv29257

Modified Files:
	frame.c rtp.c 
Log Message:
fix breakage from slin endianness commit earlier today (sorry :-()


Index: frame.c
===================================================================
RCS file: /usr/cvsroot/asterisk/frame.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- frame.c	3 Apr 2005 22:57:17 -0000	1.49
+++ frame.c	4 Apr 2005 02:13:40 -0000	1.50
@@ -402,11 +402,11 @@
 	return ast_fr_fdwrite(fd, &hangup);
 }
 
-void ast_swapcopy_samples(void *dst, void *src, int samples)
+void ast_swapcopy_samples(void *dst, const void *src, int samples)
 {
 	int i;
 	unsigned short *dst_s = dst;
-	unsigned short *src_s = src;
+	const unsigned short *src_s = src;
 
 	for (i=0; i<samples; i++)
 		dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8);

Index: rtp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/rtp.c,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- rtp.c	3 Apr 2005 22:57:17 -0000	1.119
+++ rtp.c	4 Apr 2005 02:13:40 -0000	1.120
@@ -76,6 +76,7 @@
 	unsigned char rawdata[8192 + AST_FRIENDLY_OFFSET];
 	unsigned int ssrc;
 	unsigned int lastts;
+	unsigned int lastdigitts;
 	unsigned int lastrxts;
 	unsigned int lastividtimestamp;
 	unsigned int lastovidtimestamp;
@@ -1014,6 +1015,7 @@
 	memset(&rtp->txcore, 0, sizeof(rtp->txcore));
 	memset(&rtp->dtmfmute, 0, sizeof(rtp->dtmfmute));
 	rtp->lastts = 0;
+	rtp->lastdigitts = 0;
 	rtp->lastrxts = 0;
 	rtp->lastividtimestamp = 0;
 	rtp->lastovidtimestamp = 0;
@@ -1107,30 +1109,34 @@
 	/* Get a pointer to the header */
 	rtpheader = (unsigned int *)data;
 	rtpheader[0] = htonl((2 << 30) | (1 << 23) | (payload << 16) | (rtp->seqno++));
-	rtpheader[1] = htonl(rtp->lastts);
+	rtpheader[1] = htonl(rtp->lastdigitts);
 	rtpheader[2] = htonl(rtp->ssrc); 
 	rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (0));
 	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) 
+			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 %d, ts %d, len %d)\n"
-						, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastts,res - hdrlen);		   
+						, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);		   
 		   
 		}
+		/* Clear marker bit and increment 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) {
-			/* Clear marker bit and increment seqno */
-			rtpheader[0] = htonl((2 << 30)  | (payload << 16) | (rtp->seqno++));
 			/* Make duration 800 (100ms) */
 			rtpheader[3] |= htonl((800));
 			/* Set the End bit for the last 3 */
 			rtpheader[3] |= htonl((1 << 23));
-		} else if ( x < 5) {
-			rtpheader[0] = htonl((2 << 30) | (payload << 16) | (rtp->seqno++));
 		}
 	}
+	/* Increment the digit timestamp by 100ms, to ensure that digits
+	   sent sequentially with no intervening non-digit packets do not
+	   get sent with the same timestamp.
+	*/
+	rtp->lastdigitts += 800;
 	return 0;
 }
 
@@ -1256,6 +1262,12 @@
 			}
 		}
 	}
+	/* If the timestamp for non-digit packets has moved beyond the timestamp
+	   for digits, update the digit timestamp.
+	*/
+	if (rtp->lastts > rtp->lastdigitts)
+		rtp->lastdigitts = rtp->lastts;
+
 	/* Get a pointer to the header */
 	rtpheader = (unsigned char *)(f->data - hdrlen);
 




More information about the svn-commits mailing list