[Asterisk-cvs] asterisk jitterbuf.c,1.13,1.14 jitterbuf.h,1.6,1.7
markster at lists.digium.com
markster at lists.digium.com
Thu Jun 2 13:42:33 CDT 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv2162
Modified Files:
jitterbuf.c jitterbuf.h
Log Message:
Blindly merge jitter buffer patch of bug #4342)
Index: jitterbuf.c
===================================================================
RCS file: /usr/cvsroot/asterisk/jitterbuf.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- jitterbuf.c 19 May 2005 01:24:09 -0000 1.13
+++ jitterbuf.c 2 Jun 2005 17:45:38 -0000 1.14
@@ -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
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- jitterbuf.h 19 May 2005 01:24:09 -0000 1.6
+++ jitterbuf.h 2 Jun 2005 17:45:38 -0000 1.7
@@ -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
}
More information about the svn-commits
mailing list