Index: channels/chan_iax2.c =================================================================== --- channels/chan_iax2.c (revision 43263) +++ channels/chan_iax2.c (working copy) @@ -157,6 +157,7 @@ #ifdef NEWJB static int resyncthreshold=1000; static int maxjitterinterps=10; +static int jittertargetextra = 40; /* number of milliseconds the new jitter buffer adds on to its size */ #endif static int jittershrinkrate=2; static int trunkfreq = 20; @@ -932,6 +933,7 @@ jbconf.max_jitterbuf = maxjitterbuffer; jbconf.resync_threshold = resyncthreshold; jbconf.max_contig_interp = maxjitterinterps; + jbconf.target_extra = jittertargetextra; jb_setconf(tmp->jb,&jbconf); } #endif @@ -8772,6 +8774,8 @@ resyncthreshold = atoi(v->value); else if (!strcasecmp(v->name, "maxjitterinterps")) maxjitterinterps = atoi(v->value); + else if (!strcasecmp(v->name, "jittertargetextra")) + jittertargetextra = atoi(v->value); #endif else if (!strcasecmp(v->name, "jittershrinkrate")) jittershrinkrate = atoi(v->value); Index: jitterbuf.c =================================================================== --- jitterbuf.c (revision 43263) +++ jitterbuf.c (working copy) @@ -77,7 +77,7 @@ memset(jb,0,sizeof(jitterbuf)); jb->info.conf = s; - /* initialize length */ + /* initialize length, using the default value */ jb->info.current = jb->info.target = JB_TARGET_EXTRA; jb->info.silence_begin_ts = -1; } @@ -552,7 +552,7 @@ dbg_cnt++; /* target */ - jb->info.target = jb->info.jitter + jb->info.min + JB_TARGET_EXTRA; + jb->info.target = jb->info.jitter + jb->info.min + jb->info.conf.target_extra; /* if a hard clamp was requested, use it */ if ((jb->info.conf.max_jitterbuf) && ((jb->info.target - jb->info.min) > jb->info.conf.max_jitterbuf)) { @@ -638,7 +638,7 @@ /* unless we don't have a frame, then shrink 1 frame */ /* every 80ms (though perhaps we can shrink even faster */ /* in this case) */ - if (diff < -JB_TARGET_EXTRA && + if (diff < -jb->info.conf.target_extra && ((!frame && jb->info.last_adjustment + 80 < now) || (jb->info.last_adjustment + 500 < now))) { @@ -716,7 +716,7 @@ /* jb->info.silence_begin_ts = 0; */ /* shrink interpl len every 10ms during silence */ - if (diff < -JB_TARGET_EXTRA && + if (diff < -jb->info.conf.target_extra && jb->info.last_adjustment + 10 <= now) { jb->info.current -= interpl; jb->info.last_adjustment = now; @@ -765,7 +765,7 @@ if (next > 0) { history_get(jb); /* shrink during silence */ - if (jb->info.target - jb->info.current < -JB_TARGET_EXTRA) + if (jb->info.target - jb->info.current < -jb->info.conf.target_extra) return jb->info.last_adjustment + 10; return next + jb->info.target; } @@ -824,6 +824,16 @@ jb->info.conf.resync_threshold = conf->resync_threshold; jb->info.conf.max_contig_interp = conf->max_contig_interp; + /* -1 indicates use of the default JB_TARGET_EXTRA value */ + jb->info.conf.target_extra = ( conf->target_extra == -1 ) + ? JB_TARGET_EXTRA + : conf->target_extra + ; + + /* update these to match new target_extra setting */ + jb->info.current = jb->info.conf.target_extra; + jb->info.target = jb->info.conf.target_extra; + return JB_OK; } Index: jitterbuf.h =================================================================== --- jitterbuf.h (revision 43263) +++ jitterbuf.h (working copy) @@ -56,6 +56,7 @@ long max_jitterbuf; /* defines a hard clamp to use in setting the jitter buffer delay */ long resync_threshold; /* the jb will resync when delay increases to (2 * jitter) + this param */ long max_contig_interp; /* the max interp frames to return in a row */ + long target_extra ; /* amount of additional jitterbuffer adjustment, overrides JB_TARGET_EXTRA */ } jb_conf; typedef struct jb_info { Index: configs/iax.conf.sample =================================================================== --- configs/iax.conf.sample (revision 43263) +++ configs/iax.conf.sample (working copy) @@ -136,6 +136,13 @@ ; changing. An example: if you set this to 2, then the jitter buffer ; size will change by 100 millisecs per second. ; [This option is not applicable to, and ignored by the new jitterbuffer implementation] +; +; jittertargetextra: number of milliseconds by which the new jitter buffer +; will pad its size. the default is 40, so without modification, the new +; jitter buffer will set its size to the jitter value plus 40 milliseconds. +; increasing this value may help if your network normally has low jitter, +; but occasionally has spikes. +; jitterbuffer=no forcejitterbuffer=no @@ -146,6 +153,7 @@ ;maxexcessbuffer=80 ;minexcessbuffer=10 ;jittershrinkrate=1 +;jittertargetextra=40 ;trunkfreq=20 ; How frequently to send trunk msgs (in ms)