aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-10-19 23:56:31 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-10-19 23:56:31 +0000
commit6f83de4317e7b3726a0813d85151e04af0915cc5 (patch)
tree2b264b7a7f30130bbb47c818be646bc744207fd8 /main
parente05b5a590d7a36475069314aef06f8da949ff488 (diff)
Merged revisions 224671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r224671 | kpfleming | 2009-10-19 18:47:39 -0500 (Mon, 19 Oct 2009) | 14 lines 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. ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@224673 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/rtp.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/main/rtp.c b/main/rtp.c
index f1231a576..e024858d0 100644
--- a/main/rtp.c
+++ b/main/rtp.c
@@ -1457,6 +1457,18 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
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;
@@ -1477,21 +1489,14 @@ static void calc_rxstamp(struct timeval *when, struct ast_rtp *rtp, unsigned int
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() */
when->tv_sec = rtp->rxcore.tv_sec + timestamp / rate;
when->tv_usec = rtp->rxcore.tv_usec + (timestamp % rate) * 125;
- if (when->tv_usec >= 1000000) {
- when->tv_usec -= 1000000;
- when->tv_sec += 1;
- }
+ sanitize_tv(when);
prog = (double)((timestamp-rtp->seedrxts)/(float)(rate));
dtv = (double)rtp->drxcore + (double)(prog);
current_time = (double)now.tv_sec + (double)now.tv_usec/1000000;