[Asterisk-cvs] asterisk/channels chan_iax2.c,1.106,1.107

markster at lists.digium.com markster at lists.digium.com
Tue Mar 16 18:00:33 CST 2004


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

Modified Files:
	chan_iax2.c 
Log Message:
Fix timestamp delivery calculation in IAX...  Still might be some mess left...


Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- chan_iax2.c	15 Mar 2004 07:51:22 -0000	1.106
+++ chan_iax2.c	16 Mar 2004 22:55:05 -0000	1.107
@@ -1581,27 +1581,30 @@
 	   IAX thread, with iaxsl lock held. */
 	ms = calc_rxstamp(iaxs[fr->callno]) - fr->ts;
 
-	fr->af.delivery.tv_sec = iaxs[fr->callno]->rxcore.tv_sec;
-	fr->af.delivery.tv_usec = iaxs[fr->callno]->rxcore.tv_usec;
-	fr->af.delivery.tv_sec += fr->ts / 1000;
-	fr->af.delivery.tv_usec += fr->ts % 1000;
-	if (fr->af.delivery.tv_usec >= 1000000) {
-		fr->af.delivery.tv_usec -= 1000000;
-		fr->af.delivery.tv_sec += 1;
-	}
-
 	if (ms > 32767) {
 		/* What likely happened here is that our counter has circled but we haven't
 		   gotten the update from the main packet.  We'll just pretend that we did, and
 		   update the timestamp appropriately. */
 		ms -= 65536;
+		fr->ts += 65536;
 	}
 
 	if (ms < -32768) {
 		/* We got this packet out of order.  Lets add 65536 to it to bring it into our new
 		   time frame */
 		ms += 65536;
+		fr->ts -= 65536;
 	}
+
+	fr->af.delivery.tv_sec = iaxs[fr->callno]->rxcore.tv_sec;
+	fr->af.delivery.tv_usec = iaxs[fr->callno]->rxcore.tv_usec;
+	fr->af.delivery.tv_sec += fr->ts / 1000;
+	fr->af.delivery.tv_usec += (fr->ts % 1000) * 1000;
+	if (fr->af.delivery.tv_usec >= 1000000) {
+		fr->af.delivery.tv_usec -= 1000000;
+		fr->af.delivery.tv_sec += 1;
+	}
+
 	
 	/* Rotate our history queue of "lateness".  Don't worry about those initial
 	   zeros because the first entry will always be zero */




More information about the svn-commits mailing list