Don't translate time for packets with no delivery

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2631 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.0
Mark Spencer 21 years ago
parent 70dfab8be0
commit 1cf4ea2eb3

@ -140,42 +140,44 @@ struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f,
p = path; p = path;
/* Feed the first frame into the first translator */ /* Feed the first frame into the first translator */
p->step->framein(p->state, f); p->step->framein(p->state, f);
if (path->nextin.tv_sec || path->nextin.tv_usec) { if (f->delivery.tv_sec || f->delivery.tv_usec) {
/* Make sure this is in line with what we were expecting */ if (path->nextin.tv_sec || path->nextin.tv_usec) {
if ((path->nextin.tv_sec != f->delivery.tv_sec) || /* Make sure this is in line with what we were expecting */
(path->nextin.tv_usec != f->delivery.tv_usec)) { if ((path->nextin.tv_sec != f->delivery.tv_sec) ||
/* The time has changed between what we expected and this (path->nextin.tv_usec != f->delivery.tv_usec)) {
most recent time on the new packet. Adjust our output /* The time has changed between what we expected and this
time appropriately */ most recent time on the new packet. Adjust our output
long sdiff; time appropriately */
long udiff; long sdiff;
sdiff = f->delivery.tv_sec - path->nextin.tv_sec; long udiff;
udiff = f->delivery.tv_usec - path->nextin.tv_usec; sdiff = f->delivery.tv_sec - path->nextin.tv_sec;
udiff = f->delivery.tv_usec - path->nextin.tv_usec;
path->nextin.tv_sec = f->delivery.tv_sec;
path->nextin.tv_usec = f->delivery.tv_usec;
path->nextout.tv_sec += sdiff;
path->nextout.tv_usec += udiff;
if (path->nextout.tv_usec < 0) {
path->nextout.tv_usec += 1000000;
path->nextout.tv_sec--;
} else if (path->nextout.tv_usec >= 1000000) {
path->nextout.tv_usec -= 1000000;
path->nextout.tv_sec++;
}
}
} else {
/* This is our first pass. Make sure the timing looks good */
path->nextin.tv_sec = f->delivery.tv_sec; path->nextin.tv_sec = f->delivery.tv_sec;
path->nextin.tv_usec = f->delivery.tv_usec; path->nextin.tv_usec = f->delivery.tv_usec;
path->nextout.tv_sec += sdiff; path->nextout.tv_sec = f->delivery.tv_sec;
path->nextout.tv_usec += udiff; path->nextout.tv_usec = f->delivery.tv_usec;
if (path->nextout.tv_usec < 0) { }
path->nextout.tv_usec += 1000000; /* Predict next incoming sample */
path->nextout.tv_sec--; path->nextin.tv_sec += (f->samples / 8000);
} else if (path->nextout.tv_usec >= 1000000) { path->nextin.tv_usec += ((f->samples % 8000) * 125);
path->nextout.tv_usec -= 1000000; if (path->nextin.tv_usec >= 1000000) {
path->nextout.tv_sec++; path->nextin.tv_usec -= 1000000;
} path->nextin.tv_sec++;
} }
} else {
/* This is our first pass. Make sure the timing looks good */
path->nextin.tv_sec = f->delivery.tv_sec;
path->nextin.tv_usec = f->delivery.tv_usec;
path->nextout.tv_sec = f->delivery.tv_sec;
path->nextout.tv_usec = f->delivery.tv_usec;
}
/* Predict next incoming sample */
path->nextin.tv_sec += (f->samples / 8000);
path->nextin.tv_usec += ((f->samples % 8000) * 125);
if (path->nextin.tv_usec >= 1000000) {
path->nextin.tv_usec -= 1000000;
path->nextin.tv_sec++;
} }
if (consume) if (consume)
ast_frfree(f); ast_frfree(f);
@ -189,17 +191,22 @@ struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f,
if (p->next) if (p->next)
p->next->step->framein(p->next->state, out); p->next->step->framein(p->next->state, out);
else { else {
/* Use next predicted outgoing timestamp */ if (f->delivery.tv_sec || f->delivery.tv_usec) {
out->delivery.tv_sec = path->nextout.tv_sec; /* Use next predicted outgoing timestamp */
out->delivery.tv_usec = path->nextout.tv_usec; out->delivery.tv_sec = path->nextout.tv_sec;
out->delivery.tv_usec = path->nextout.tv_usec;
/* Predict next outgoing timestamp from samples in this
frame. */ /* Predict next outgoing timestamp from samples in this
path->nextout.tv_sec += (out->samples / 8000); frame. */
path->nextout.tv_usec += ((out->samples % 8000) * 125); path->nextout.tv_sec += (out->samples / 8000);
if (path->nextout.tv_usec >= 1000000) { path->nextout.tv_usec += ((out->samples % 8000) * 125);
path->nextout.tv_sec++; if (path->nextout.tv_usec >= 1000000) {
path->nextout.tv_usec -= 1000000; path->nextout.tv_sec++;
path->nextout.tv_usec -= 1000000;
}
} else {
out->delivery.tv_sec = 0;
out->delivery.tv_usec = 0;
} }
return out; return out;
} }

Loading…
Cancel
Save