[Asterisk-cvs] asterisk jitterbuf.c,1.7,1.8 jitterbuf.h,1.2,1.3
markster at lists.digium.com
markster at lists.digium.com
Mon May 9 10:18:42 CDT 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv29810
Modified Files:
jitterbuf.c jitterbuf.h
Log Message:
Fix jitter issues with out-of-order audio (bug #4163)
Index: jitterbuf.c
===================================================================
RCS file: /usr/cvsroot/asterisk/jitterbuf.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- jitterbuf.c 9 May 2005 13:56:43 -0000 1.7
+++ jitterbuf.c 9 May 2005 14:24:58 -0000 1.8
@@ -58,7 +58,7 @@
/* initialize length */
jb->info.current = jb->info.target = 0;
- jb->info.silence = 1;
+ jb->info.silence_begin_ts = -1;
}
jitterbuf * jb_new()
@@ -405,7 +405,7 @@
jb->info.frames_in, jb->info.frames_out, jb->info.frames_late, jb->info.frames_lost, jb->info.frames_dropped, jb->info.frames_cur);
jb_dbg("jitter=%ld current=%ld target=%ld min=%ld sil=%d len=%d len/fcur=%ld\n",
- jb->info.jitter, jb->info.current, jb->info.target, jb->info.min, jb->info.silence, jb->info.current - jb->info.min,
+ jb->info.jitter, jb->info.current, jb->info.target, jb->info.min, jb->info.silence_begin_ts, jb->info.current - jb->info.min,
jb->info.frames_cur ? (jb->info.current - jb->info.min)/jb->info.frames_cur : -8);
if (jb->info.frames_in > 0)
jb_dbg("jb info: Loss PCT = %ld%%, Late PCT = %ld%%\n",
@@ -506,7 +506,7 @@
jb->info.last_voice_ts += jb->info.last_voice_ms;
/* let's work on non-silent case first */
- if (!jb->info.silence) {
+ if (!jb->info.silence_begin_ts) {
/* we want to grow */
if ((diff > 0) &&
/* we haven't grown in the delay length */
@@ -528,7 +528,7 @@
jb->info.last_voice_ts -= jb->info.last_voice_ms;
if (frame->type == JB_TYPE_SILENCE)
- jb->info.silence = 1;
+ jb->info.silence_begin_ts = frame->ts;
*frameout = *frame;
jb->info.frames_out++;
@@ -625,31 +625,46 @@
* here, plus handle last_voice_ts a bit differently */
/* to disable silent special case altogether, just uncomment this: */
- /* jb->info.silence = 0; */
+ /* jb->info.silence_begin_ts = 0; */
frame = queue_get(jb, now - jb->info.current);
if (!frame) {
return JB_NOFRAME;
+ } else if (frame->type != JB_TYPE_VOICE) {
+ /* normal case; in silent mode, got a non-voice frame */
+ *frameout = *frame;
+ return JB_OK;
}
- if (frame && frame->type == JB_TYPE_VOICE) {
+ if (frame->ts < jb->info.silence_begin_ts) {
+ /* voice frame is late */
+ *frameout = *frame;
+ /* rewind last_voice, since we're just dumping */
+ jb->info.last_voice_ts -= jb->info.last_voice_ms;
+ jb->info.frames_out++;
+ decrement_losspct(jb);
+ jb->info.frames_late++;
+ jb->info.frames_lost--;
+ jb_dbg("l");
+ /*jb_warn("\nlate: wanted=%ld, this=%ld, next=%ld\n", jb->info.last_voice_ts - jb->info.current, frame->ts, queue_next(jb));
+ jb_warninfo(jb); */
+ return JB_DROP;
+ } else {
+ /* voice frame */
/* try setting current to target right away here */
jb->info.current = jb->info.target;
- jb->info.silence = 0;
+ jb->info.silence_begin_ts = 0;
jb->info.last_voice_ts = frame->ts + jb->info.current + frame->ms;
jb->info.last_voice_ms = frame->ms;
*frameout = *frame;
jb_dbg("V");
return JB_OK;
}
- /* normal case; in silent mode, got a non-voice frame */
- *frameout = *frame;
- return JB_OK;
}
}
long jb_next(jitterbuf *jb)
{
- if (jb->info.silence) {
+ if (jb->info.silence_begin_ts) {
long next = queue_next(jb);
if (next > 0) {
history_get(jb);
Index: jitterbuf.h
===================================================================
RCS file: /usr/cvsroot/asterisk/jitterbuf.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- jitterbuf.h 9 May 2005 13:56:43 -0000 1.2
+++ jitterbuf.h 9 May 2005 14:24:58 -0000 1.3
@@ -65,7 +65,7 @@
long losspct; /* recent lost frame percentage (* 1000) */
long last_voice_ts; /* the last ts that was read from the jb - in receiver's time */
long last_voice_ms; /* the duration of the last voice frame */
- long silence; /* we are presently playing out silence */
+ long silence_begin_ts; /* the time of the last CNG frame, when in silence */
long last_adjustment; /* the time of the last adjustment */
/* settings */
More information about the svn-commits
mailing list