[asterisk-commits] dvossel: branch 1.6.1 r241740 - in /branches/1.6.1: ./ main/rtp.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 20 15:22:34 CST 2010


Author: dvossel
Date: Wed Jan 20 15:22:32 2010
New Revision: 241740

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=241740
Log:
Merged revisions 241714 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r241714 | dvossel | 2010-01-20 15:14:47 -0600 (Wed, 20 Jan 2010) | 10 lines
  
  rtp timestamp to timeval calculation fix
  
  The rtp timestamp to timeval calculation was only
  accurate for 8kHz audio. This patch corrects this.
  
  Review: https://reviewboard.asterisk.org/r/468/
  
  SWP-648
........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/main/rtp.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/main/rtp.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.1/main/rtp.c?view=diff&rev=241740&r1=241739&r2=241740
==============================================================================
--- branches/1.6.1/main/rtp.c (original)
+++ branches/1.6.1/main/rtp.c Wed Jan 20 15:22:32 2010
@@ -1456,21 +1456,10 @@
 	return f;
 }
 
-static void sanitize_tv(struct timeval *tv)
-{
-	while (tv->tv_usec < 0) {
-		tv->tv_usec += 1000000;
-		tv->tv_sec -= 1;
-	}
-	while (tv->tv_usec >= 1000000) {
-		tv->tv_usec -= 1000000;
-		tv->tv_sec += 1;
-	}
-}
-
 static void calc_rxstamp(struct timeval *when, struct ast_rtp *rtp, unsigned int timestamp, int mark)
 {
 	struct timeval now;
+	struct timeval tmp;
 	double transit;
 	double current_time;
 	double d;
@@ -1484,18 +1473,17 @@
 		rtp->drxcore = (double) rtp->rxcore.tv_sec + (double) rtp->rxcore.tv_usec / 1000000;
 		/* map timestamp to a real time */
 		rtp->seedrxts = timestamp; /* Their RTP timestamp started with this */
-		rtp->rxcore.tv_sec -= timestamp / rate;
-		rtp->rxcore.tv_usec -= (timestamp % rate) * 125;
+		tmp = ast_samp2tv(timestamp, rate);
+		rtp->rxcore = ast_tvsub(rtp->rxcore, tmp);
 		/* Round to 0.1ms for nice, pretty timestamps */
 		rtp->rxcore.tv_usec -= rtp->rxcore.tv_usec % 100;
-		sanitize_tv(&rtp->rxcore);
 	}
 
 	gettimeofday(&now,NULL);
 	/* rxcore is the mapping between the RTP timestamp and _our_ real time from gettimeofday() */
-	when->tv_sec = rtp->rxcore.tv_sec + timestamp / rate;
-	when->tv_usec = rtp->rxcore.tv_usec + (timestamp % rate) * 125;
-	sanitize_tv(when);
+	tmp = ast_samp2tv(timestamp, rate);
+	*when = ast_tvadd(rtp->rxcore, tmp);
+
 	prog = (double)((timestamp-rtp->seedrxts)/(float)(rate));
 	dtv = (double)rtp->drxcore + (double)(prog);
 	current_time = (double)now.tv_sec + (double)now.tv_usec/1000000;




More information about the asterisk-commits mailing list