Handle transitions in delivery time and non-delivery time
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2739 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
12bcd39583
commit
17563e2929
8
frame.c
8
frame.c
|
@ -122,8 +122,9 @@ int ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f)
|
|||
}
|
||||
}
|
||||
memcpy(s->data + s->len, f->data, f->datalen);
|
||||
/* If we're empty, reset delivery time */
|
||||
if (!s->len)
|
||||
/* If either side is empty, reset the delivery time */
|
||||
if (!s->len || (!f->delivery.tv_sec && !f->delivery.tv_usec) ||
|
||||
(!s->delivery.tv_sec && !s->delivery.tv_usec))
|
||||
s->delivery = f->delivery;
|
||||
s->len += f->datalen;
|
||||
return 0;
|
||||
|
@ -166,6 +167,8 @@ struct ast_frame *ast_smoother_read(struct ast_smoother *s)
|
|||
/* In principle this should all be fine because if we are sending
|
||||
G.729 VAD, the next timestamp will take over anyawy */
|
||||
memmove(s->data, s->data + len, s->len);
|
||||
if (s->delivery.tv_sec || s->delivery.tv_usec) {
|
||||
/* If we have delivery time, increment it, otherwise, leave it at 0 */
|
||||
s->delivery.tv_sec += (len * s->samplesperbyte) / 8000.0;
|
||||
s->delivery.tv_usec += (((int)(len * s->samplesperbyte)) % 8000) * 125;
|
||||
if (s->delivery.tv_usec > 1000000) {
|
||||
|
@ -173,6 +176,7 @@ struct ast_frame *ast_smoother_read(struct ast_smoother *s)
|
|||
s->delivery.tv_sec += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Return frame */
|
||||
return &s->f;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue