Blindly merge jitter buffer patch of bug #4342)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5814 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2-netsec
Mark Spencer 20 years ago
parent 7b03b102c9
commit c01873574a

@ -857,13 +857,13 @@ static struct chan_iax2_pvt *new_iax(struct sockaddr_in *sin, int lockpeer, cons
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
}

@ -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 @@ static void decrement_losspct(jitterbuf *jb)
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 longcmp(const void *a, const void *b)
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 @@ static int history_put(jitterbuf *jb, long ts, long now, long ms)
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 @@ static int _jb_get(jitterbuf *jb, jb_frame *frameout, long now, long interpl)
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 @@ int jb_getinfo(jitterbuf *jb, jb_info *stats)
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;
}

@ -50,7 +50,16 @@ extern "C" {
#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 @@ typedef struct jb_info {
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 @@ long jb_next(jitterbuf *jb);
/* 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
}

Loading…
Cancel
Save