[svn-commits] kpfleming: trunk r224671 - in /trunk: ./ res/res_rtp_asterisk.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Oct 19 18:47:43 CDT 2009


Author: kpfleming
Date: Mon Oct 19 18:47:39 2009
New Revision: 224671

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=224671
Log:
Merged revisions 224670 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r224670 | kpfleming | 2009-10-19 18:44:07 -0500 (Mon, 19 Oct 2009) | 7 lines
  
  Correct timestamp calculations when RTP sample rates over 8kHz are used.
  
  While testing some endpoints that support 16kHz and 32kHz sample rates, some
  log messages were generated due to calc_rxstamp() computing timestamps in a way
  that produced odd results, so this patch sanitizes the result of the
  computations.
........

Modified:
    trunk/   (props changed)
    trunk/res/res_rtp_asterisk.c

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

Modified: trunk/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_rtp_asterisk.c?view=diff&rev=224671&r1=224670&r2=224671
==============================================================================
--- trunk/res/res_rtp_asterisk.c (original)
+++ trunk/res/res_rtp_asterisk.c Mon Oct 19 18:47:39 2009
@@ -1212,6 +1212,18 @@
 	return 0;
 }
 
+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 *tv, struct ast_rtp *rtp, unsigned int timestamp, int mark)
 {
 	struct timeval now;
@@ -1232,21 +1244,14 @@
 		rtp->rxcore.tv_usec -= (timestamp % rate) * 125;
 		/* Round to 0.1ms for nice, pretty timestamps */
 		rtp->rxcore.tv_usec -= rtp->rxcore.tv_usec % 100;
-		if (rtp->rxcore.tv_usec < 0) {
-			/* Adjust appropriately if necessary */
-			rtp->rxcore.tv_usec += 1000000;
-			rtp->rxcore.tv_sec -= 1;
-		}
+		sanitize_tv(&rtp->rxcore);
 	}
 
 	gettimeofday(&now,NULL);
 	/* rxcore is the mapping between the RTP timestamp and _our_ real time from gettimeofday() */
 	tv->tv_sec = rtp->rxcore.tv_sec + timestamp / rate;
 	tv->tv_usec = rtp->rxcore.tv_usec + (timestamp % rate) * 125;
-	if (tv->tv_usec >= 1000000) {
-		tv->tv_usec -= 1000000;
-		tv->tv_sec += 1;
-	}
+	sanitize_tv(tv);
 	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 svn-commits mailing list