aboutsummaryrefslogtreecommitdiffstats
path: root/rtp.c
diff options
context:
space:
mode:
authormatteo <matteo@f38db490-d61c-443f-a65b-d21fe96a405b>2003-02-24 21:10:24 +0000
committermatteo <matteo@f38db490-d61c-443f-a65b-d21fe96a405b>2003-02-24 21:10:24 +0000
commitd0ca959736365e73c760d77ebae3a4a49106c3f6 (patch)
tree39e3bee3784b2785df4b53edc4d8568c37611792 /rtp.c
parentf6a861f645e0b978daabe5c2095a22cb69978d5c (diff)
lun feb 24 22:10:09 CET 2003
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@623 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'rtp.c')
-rwxr-xr-xrtp.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/rtp.c b/rtp.c
index aba47dbb5..7dd6e997c 100755
--- a/rtp.c
+++ b/rtp.c
@@ -494,6 +494,9 @@ static unsigned int calc_txstamp(struct ast_rtp *rtp)
gettimeofday(&now, NULL);
ms = (now.tv_sec - rtp->txcore.tv_sec) * 1000;
ms += (now.tv_usec - rtp->txcore.tv_usec) / 1000;
+ /* Use what we just got for next time */
+ rtp->txcore.tv_sec = now.tv_sec;
+ rtp->txcore.tv_usec = now.tv_usec;
return ms;
}
@@ -529,7 +532,7 @@ int ast_rtp_senddigit(struct ast_rtp *rtp, char digit)
ms = calc_txstamp(rtp);
/* Default prediction */
- pred = ms * 8;
+ pred = rtp->lastts + ms * 8;
/* Get a pointer to the header */
rtpheader = (unsigned int *)data;
@@ -568,7 +571,7 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec
ms = calc_txstamp(rtp);
/* Default prediction */
- pred = ms * 8;
+ pred = rtp->lastts + ms * 8;
switch(f->subclass) {
case AST_FORMAT_ULAW:
@@ -591,16 +594,12 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec
}
/* Re-calculate last TS */
- rtp->lastts = ms * 8;
-#if 0 /* XXX Experiment -- Make timestamp always relative XXX */
+ rtp->lastts = rtp->lastts + ms * 8;
/* If it's close to ou prediction, go for it */
if (abs(rtp->lastts - pred) < 640)
-#endif
rtp->lastts = pred;
-#if 0
else
- printf("Difference is %d, ms is %d\n", abs(rtp->lastts - pred), ms);
-#endif
+ ast_log(LOG_DEBUG, "Difference is %d, ms is %d\n", abs(rtp->lastts - pred), ms);
/* Get a pointer to the header */
rtpheader = (unsigned int *)(f->data - hdrlen);
rtpheader[0] = htonl((2 << 30) | (codec << 16) | (rtp->seqno++));