diff options
author | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-01-20 21:27:56 +0000 |
---|---|---|
committer | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-01-20 21:27:56 +0000 |
commit | c9053817a812656689a0d4c3838decfc17f0b6a1 (patch) | |
tree | a83851ee039a53c36cc0c44698e5b30a578e83f6 /main | |
parent | 728fd9a8661aa65f9ce9db1af0071bc52acb07d3 (diff) |
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
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@241758 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/rtp.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/main/rtp.c b/main/rtp.c index 5cc93248c..393a9b137 100644 --- a/main/rtp.c +++ b/main/rtp.c @@ -1319,21 +1319,10 @@ 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 *tv, struct ast_rtp *rtp, unsigned int timestamp, int mark) { struct timeval now; + struct timeval tmp; double transit; double current_time; double d; @@ -1346,18 +1335,17 @@ static void calc_rxstamp(struct timeval *tv, struct ast_rtp *rtp, unsigned int t 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() */ - tv->tv_sec = rtp->rxcore.tv_sec + timestamp / rate; - tv->tv_usec = rtp->rxcore.tv_usec + (timestamp % rate) * 125; - sanitize_tv(tv); + tmp = ast_samp2tv(timestamp, rate); + *tv = 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; |