diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-07-25 19:41:39 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-07-25 19:41:39 +0000 |
commit | f2b81a38df26419e12d6f767c696e4fc22bfb598 (patch) | |
tree | e66390abf890e8e835045b0fe26fde60eb9e4a61 /translate.c | |
parent | e20730c85a57b4368084e95af324a4cdbc25e8df (diff) |
ensure translators don't generate old timestamps when silent periods end (bug #4707 with formatting fixes)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6203 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'translate.c')
-rwxr-xr-x | translate.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/translate.c b/translate.c index b53ea255e..6ff002735 100755 --- a/translate.c +++ b/translate.c @@ -152,10 +152,12 @@ struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f, /* Make sure this is in line with what we were expecting */ if (!ast_tveq(path->nextin, f->delivery)) { /* The time has changed between what we expected and this - most recent time on the new packet. Adjust our output - time appropriately */ - path->nextout = ast_tvadd(path->nextout, - ast_tvsub(f->delivery, path->nextin)); + most recent time on the new packet. If we have a + valid prediction adjust our output time appropriately */ + if (!ast_tvzero(path->nextout)) { + path->nextout = ast_tvadd(path->nextout, + ast_tvsub(f->delivery, path->nextin)); + } path->nextin = f->delivery; } } else { @@ -180,6 +182,10 @@ struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f, p->next->step->framein(p->next->state, out); else { if (!ast_tvzero(delivery)) { + /* Regenerate prediction after a discontinuity */ + if (ast_tvzero(path->nextout)) + path->nextout = ast_tvnow(); + /* Use next predicted outgoing timestamp */ out->delivery = path->nextout; @@ -189,6 +195,9 @@ struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f, } else { out->delivery = ast_tv(0, 0); } + /* Invalidate prediction if we're entering a silence period */ + if (out->frametype == AST_FRAME_CNG) + path->nextout = ast_tv(0, 0); return out; } p = p->next; |