Index: jitterbuf.c =================================================================== RCS file: /usr/cvsroot/asterisk/jitterbuf.c,v retrieving revision 1.13 diff -a -u -r1.13 jitterbuf.c --- jitterbuf.c 19 May 2005 01:24:09 -0000 1.13 +++ jitterbuf.c 20 May 2005 02:11:20 -0000 @@ -35,10 +35,10 @@ static jb_output_function_t warnf, errf, dbgf; -void jb_setoutput(jb_output_function_t warn, jb_output_function_t err, jb_output_function_t dbg) +void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg) { - warnf = warn; errf = err; + warnf = warn; dbgf = dbg; } @@ -54,7 +54,10 @@ void jb_reset(jitterbuf *jb) { + /* only save settings */ + jb_conf s = jb->info.conf; memset(jb,0,sizeof(jitterbuf)); + jb->info.conf = s; /* initialize length */ jb->info.current = jb->info.target = JB_TARGET_EXTRA; @@ -109,7 +112,7 @@ static int history_put(jitterbuf *jb, long ts, long now, long ms) { long delay = now - (ts - jb->info.resync_offset); - long threshold = 2 * jb->info.jitter + jb->info.resync_threshold; + long threshold = 2 * jb->info.jitter + jb->info.conf.resync_threshold; long kicked; /* don't add special/negative times to history */ @@ -117,7 +120,7 @@ return 0; /* check for drastic change in delay */ - if (jb->info.resync_threshold != -1) { + if (jb->info.conf.resync_threshold != -1) { if (abs(delay - jb->info.last_delay) > threshold) { jb->info.cnt_delay_discont++; if (jb->info.cnt_delay_discont > 3) { @@ -529,9 +532,9 @@ jb->info.target = jb->info.jitter + jb->info.min + JB_TARGET_EXTRA; /* if a hard clamp was requested, use it */ - if ((jb->info.max_jitterbuf) && ((jb->info.target - jb->info.min) > jb->info.max_jitterbuf)) { - jb_dbg("clamping target from %d to %d\n", (jb->info.target - jb->info.min), jb->info.max_jitterbuf); - jb->info.target = jb->info.min + jb->info.max_jitterbuf; + if ((jb->info.conf.max_jitterbuf) && ((jb->info.target - jb->info.min) > jb->info.conf.max_jitterbuf)) { + jb_dbg("clamping target from %d to %d\n", (jb->info.target - jb->info.min), jb->info.conf.max_jitterbuf); + jb->info.target = jb->info.min + jb->info.conf.max_jitterbuf; } diff = jb->info.target - jb->info.current; @@ -777,12 +780,12 @@ return JB_OK; } -int jb_setinfo(jitterbuf *jb, jb_info *settings) +int jb_setconf(jitterbuf *jb, jb_conf *conf) { /* take selected settings from the struct */ - jb->info.max_jitterbuf = settings->max_jitterbuf; - jb->info.resync_threshold = settings->resync_threshold; + jb->info.conf.max_jitterbuf = conf->max_jitterbuf; + jb->info.conf.resync_threshold = conf->resync_threshold; return JB_OK; } Index: jitterbuf.h =================================================================== RCS file: /usr/cvsroot/asterisk/jitterbuf.h,v retrieving revision 1.6 diff -a -u -r1.6 jitterbuf.h --- jitterbuf.h 19 May 2005 01:24:09 -0000 1.6 +++ jitterbuf.h 20 May 2005 02:11:20 -0000 @@ -50,7 +50,16 @@ #define JB_TYPE_VIDEO 2 /* reserved */ #define JB_TYPE_SILENCE 3 + +typedef struct jb_conf { + /* settings */ + 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 */ +} jb_conf; + typedef struct jb_info { + jb_conf conf; + /* statistics */ long frames_in; /* number of frames input to the jitterbuffer.*/ long frames_out; /* number of frames output from the jitterbuffer.*/ @@ -71,10 +80,6 @@ long last_delay; /* the last now added to history */ long cnt_delay_discont; /* the count of discontinuous delays */ long resync_offset; /* the amount to offset ts to support resyncs */ - - /* settings */ - 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 */ } jb_info; typedef struct jb_frame { @@ -139,11 +144,11 @@ /* get jitterbuf info: only "statistics" may be valid */ int jb_getinfo(jitterbuf *jb, jb_info *stats); -/* set jitterbuf info: only "settings" may be honored */ -int jb_setinfo(jitterbuf *jb, jb_info *settings); +/* set jitterbuf conf */ +int jb_setconf(jitterbuf *jb, jb_conf *conf); typedef void (*jb_output_function_t)(const char *fmt, ...); -void jb_setoutput(jb_output_function_t warn, jb_output_function_t err, jb_output_function_t dbg); +void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg); #ifdef __cplusplus } Index: channels/chan_iax2.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v retrieving revision 1.294 diff -a -u -r1.294 chan_iax2.c --- channels/chan_iax2.c 19 May 2005 04:31:02 -0000 1.294 +++ channels/chan_iax2.c 20 May 2005 02:11:24 -0000 @@ -857,13 +857,13 @@ ast_copy_string(tmp->host, host, sizeof(tmp->host)); #ifdef NEWJB { - jb_info jbinfo; + jb_conf jbconf; tmp->jb = jb_new(); tmp->jbid = -1; - jbinfo.max_jitterbuf = maxjitterbuffer; - jbinfo.resync_threshold = resyncthreshold; - jb_setinfo(tmp->jb,&jbinfo); + jbconf.max_jitterbuf = maxjitterbuffer; + jbconf.resync_threshold = resyncthreshold; + jb_setconf(tmp->jb,&jbconf); } #endif }