From d0ca959736365e73c760d77ebae3a4a49106c3f6 Mon Sep 17 00:00:00 2001 From: matteo Date: Mon, 24 Feb 2003 21:10:24 +0000 Subject: lun feb 24 22:10:09 CET 2003 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@623 f38db490-d61c-443f-a65b-d21fe96a405b --- rtp.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'rtp.c') 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++)); -- cgit v1.2.3