if (!iaxs[callno]->rxcore.tv_sec && !iaxs[callno]->rxcore.tv_usec) {
/* Initialize rxcore time if appropriate */
gettimeofday(&iaxs[callno]->rxcore, NULL);
+ /* Round to nearest 20ms */
+ iaxs[callno]->rxcore.tv_usec -= iaxs[callno]->rxcore.tv_usec % 20000;
}
/* Calculate difference between trunk and channel */
ms = (peer->rxtrunktime.tv_sec - iaxs[callno]->rxcore.tv_sec) * 1000 +
{
struct timeval tv;
unsigned int ms;
- if (!p->offset.tv_sec && !p->offset.tv_usec)
+ if (!p->offset.tv_sec && !p->offset.tv_usec) {
gettimeofday(&p->offset, NULL);
+ /* Round to nearest 20ms */
+ p->offset.tv_usec -= p->offset.tv_usec % 20000;
+ }
/* If the timestamp is specified, just send it as is */
if (ts)
return ts;
ms = (tv.tv_sec - p->offset.tv_sec) * 1000 + (tv.tv_usec - p->offset.tv_usec) / 1000;
}
/* We never send the same timestamp twice, so fudge a little if we must */
- if (ms <= p->lastsent)
+ if (ms <= p->lastsent) {
ms = p->lastsent + 1;
+ }
p->lastsent = ms;
return ms;
}
gettimeofday(&rtp->rxcore, NULL);
rtp->rxcore.tv_sec -= timestamp / 8000;
rtp->rxcore.tv_usec -= (timestamp % 8000) * 125;
+ rtp->rxcore.tv_usec -= rtp->rxcore.tv_usec % 20000;
if (rtp->rxcore.tv_usec < 0) {
/* Adjust appropriately if necessary */
rtp->rxcore.tv_usec += 1000000;