[asterisk-commits] branch oej/jitterbuffer-1.2 r12594 - in /team/oej/jitterbuffer-1.2: ./ channe...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Mar 12 11:03:03 MST 2006


Author: oej
Date: Sun Mar 12 12:02:48 2006
New Revision: 12594

URL: http://svn.digium.com/view/asterisk?rev=12594&view=rev
Log:
Adding patch for jitterbuffer Asterisk 1.2.0 (slav)

Added:
    team/oej/jitterbuffer-1.2/abstract_jb.c   (with props)
    team/oej/jitterbuffer-1.2/include/asterisk/abstract_jb.h   (with props)
    team/oej/jitterbuffer-1.2/scx_jitterbuf.c   (with props)
    team/oej/jitterbuffer-1.2/scx_jitterbuf.h   (with props)
Modified:
    team/oej/jitterbuffer-1.2/   (props changed)
    team/oej/jitterbuffer-1.2/Makefile
    team/oej/jitterbuffer-1.2/channel.c
    team/oej/jitterbuffer-1.2/channels/chan_iax2.c
    team/oej/jitterbuffer-1.2/channels/chan_sip.c
    team/oej/jitterbuffer-1.2/channels/chan_zap.c
    team/oej/jitterbuffer-1.2/configs/sip.conf.sample
    team/oej/jitterbuffer-1.2/configs/zapata.conf.sample
    team/oej/jitterbuffer-1.2/frame.c
    team/oej/jitterbuffer-1.2/include/asterisk/channel.h
    team/oej/jitterbuffer-1.2/include/asterisk/frame.h
    team/oej/jitterbuffer-1.2/rtp.c
    team/oej/jitterbuffer-1.2/translate.c

Propchange: team/oej/jitterbuffer-1.2/
------------------------------------------------------------------------------
    svnmerge-integrated = /branches/1.2:1-7221

Modified: team/oej/jitterbuffer-1.2/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/Makefile?rev=12594&r1=12593&r2=12594&view=diff
==============================================================================
--- team/oej/jitterbuffer-1.2/Makefile (original)
+++ team/oej/jitterbuffer-1.2/Makefile Sun Mar 12 12:02:48 2006
@@ -73,6 +73,9 @@
 
 # Uncomment next one to enable ast_frame tracing (for debugging)
 TRACE_FRAMES = #-DTRACE_FRAMES
+
+# Uncomment next one to enable the asterisk generic jitterbuffer
+GENERIC_JB = #-DAST_JB
 
 # Uncomment next one to enable malloc debugging
 # You can view malloc debugging with:
@@ -329,6 +332,7 @@
 
 ASTCFLAGS+= $(DEBUG_THREADS)
 ASTCFLAGS+= $(TRACE_FRAMES)
+ASTCFLAGS+= $(GENERIC_JB)
 ASTCFLAGS+= $(MALLOC_DEBUG)
 ASTCFLAGS+= $(BUSYDETECT)
 ASTCFLAGS+= $(OPTIONS)
@@ -341,7 +345,7 @@
 	cdr.o tdd.o acl.o rtp.o manager.o asterisk.o \
 	dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
 	astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
-	utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
+	utils.o plc.o jitterbuf.o scx_jitterbuf.o abstract_jb.o dnsmgr.o devicestate.o \
 	netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
 	cryptostub.o
 

Added: team/oej/jitterbuffer-1.2/abstract_jb.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/abstract_jb.c?rev=12594&view=auto
==============================================================================
--- team/oej/jitterbuffer-1.2/abstract_jb.c (added)
+++ team/oej/jitterbuffer-1.2/abstract_jb.c Sun Mar 12 12:02:48 2006
@@ -1,0 +1,887 @@
+/*
+ * abstract_jb: common implementation-independent jitterbuffer stuff
+ *
+ * Copyright (C) 2005, Attractel OOD
+ *
+ * Contributors:
+ * Slav Klenov <slav at securax.org>
+ *
+ * Copyright on this file is disclaimed to Digium for inclusion in Asterisk
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Common implementation-independent jitterbuffer stuff.
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/frame.h"
+#include "asterisk/channel.h"
+#include "asterisk/logger.h"
+#include "asterisk/term.h"
+#include "asterisk/options.h"
+#include "asterisk/utils.h"
+
+#ifdef AST_JB
+
+#include "asterisk/abstract_jb.h"
+#include "scx_jitterbuf.h"
+#include "jitterbuf.h"
+
+
+/* Internal jb flags */
+#define JB_USE (1 << 0)
+#define JB_TIMEBASE_INITIALIZED (1 << 1)
+#define JB_CREATED (1 << 2)
+
+
+/* Hooks for the abstract jb implementation */
+
+/* Create */
+typedef void * (*jb_create_impl)(struct ast_jb_conf *general_config, long resynch_threshold);
+/* Destroy */
+typedef void (*jb_destroy_impl)(void *jb);
+/* Put first frame */
+typedef int (*jb_put_first_impl)(void *jb, struct ast_frame *fin, long now);
+/* Put frame */
+typedef int (*jb_put_impl)(void *jb, struct ast_frame *fin, long now);
+/* Get frame for now */
+typedef int (*jb_get_impl)(void *jb, struct ast_frame **fout, long now, long interpl);
+/* Get next */
+typedef long (*jb_next_impl)(void *jb);
+/* Remove first frame */
+typedef int (*jb_remove_impl)(void *jb, struct ast_frame **fout);
+/* Force resynch */
+typedef void (*jb_force_resynch_impl)(void *jb);
+
+
+/*!
+ * \brief Jitterbuffer implementation private struct.
+ */
+struct ast_jb_impl
+{
+	char name[AST_JB_IMPL_NAME_SIZE];
+	jb_create_impl create;
+	jb_destroy_impl destroy;
+	jb_put_first_impl put_first;
+	jb_put_impl put;
+	jb_get_impl get;
+	jb_next_impl next;
+	jb_remove_impl remove;
+	jb_force_resynch_impl force_resync;
+};
+
+/* Implementation functions */
+/* scx */
+static void * jb_create_scx(struct ast_jb_conf *general_config, long resynch_threshold);
+static void jb_destroy_scx(void *jb);
+static int jb_put_first_scx(void *jb, struct ast_frame *fin, long now);
+static int jb_put_scx(void *jb, struct ast_frame *fin, long now);
+static int jb_get_scx(void *jb, struct ast_frame **fout, long now, long interpl);
+static long jb_next_scx(void *jb);
+static int jb_remove_scx(void *jb, struct ast_frame **fout);
+static void jb_force_resynch_scx(void *jb);
+/* stevek */
+static void * jb_create_stevek(struct ast_jb_conf *general_config, long resynch_threshold);
+static void jb_destroy_stevek(void *jb);
+static int jb_put_first_stevek(void *jb, struct ast_frame *fin, long now);
+static int jb_put_stevek(void *jb, struct ast_frame *fin, long now);
+static int jb_get_stevek(void *jb, struct ast_frame **fout, long now, long interpl);
+static long jb_next_stevek(void *jb);
+static int jb_remove_stevek(void *jb, struct ast_frame **fout);
+static void jb_force_resynch_stevek(void *jb);
+
+/* Available jb implementations */
+static struct ast_jb_impl avail_impl[] = 
+{
+	{
+		.name = "fixed",
+		.create = jb_create_scx,
+		.destroy = jb_destroy_scx,
+		.put_first = jb_put_first_scx,
+		.put = jb_put_scx,
+		.get = jb_get_scx,
+		.next = jb_next_scx,
+		.remove = jb_remove_scx,
+		.force_resync = jb_force_resynch_scx
+	},
+	{
+		.name = "adaptive",
+		.create = jb_create_stevek,
+		.destroy = jb_destroy_stevek,
+		.put_first = jb_put_first_stevek,
+		.put = jb_put_stevek,
+		.get = jb_get_stevek,
+		.next = jb_next_stevek,
+		.remove = jb_remove_stevek,
+		.force_resync = jb_force_resynch_stevek
+	}
+};
+
+static int default_impl = 0;
+
+
+/* Abstract return codes */
+#define JB_IMPL_OK 0
+#define JB_IMPL_DROP 1
+#define JB_IMPL_INTERP 2
+#define JB_IMPL_NOFRAME 3
+
+/* Translations between impl and abstract return codes */
+static int scx_to_abstract_code[] =
+	{JB_IMPL_OK, JB_IMPL_DROP, JB_IMPL_INTERP, JB_IMPL_NOFRAME};
+static int stevek_to_abstract_code[] =
+	{JB_IMPL_OK, JB_IMPL_NOFRAME, JB_IMPL_NOFRAME, JB_IMPL_INTERP, JB_IMPL_DROP, JB_IMPL_OK};
+
+/* JB_GET actions (used only for the frames log) */
+static char *jb_get_actions[] = {"Delivered", "Dropped", "Interpolated", "No"};
+
+/* Macros for JB logs */
+/*#define jb_verbose(...) ast_verbose(VERBOSE_PREFIX_3 " ***[JB LOG]*** " __VA_ARGS__)*/
+#define jb_verbose(...) if(1){\
+	char tmp[192];\
+	char msg[128];\
+	snprintf(msg, sizeof(msg), VERBOSE_PREFIX_3 "***[JB LOG]*** " __VA_ARGS__);\
+	ast_verbose("%s\n", term_color(tmp, msg, COLOR_BRGREEN, 0, sizeof(tmp)));}
+
+/* Macros for the frame log files */
+#define jb_framelog(...) \
+if(jb->logfile) \
+{ \
+	fprintf(jb->logfile, __VA_ARGS__); \
+	fflush(jb->logfile); \
+} \
+
+
+/* Internal utility functions */
+static void jb_choose_impl(struct ast_channel *chan);
+static void jb_get_and_deliver(struct ast_channel *chan);
+static int create_jb(struct ast_channel *chan, struct ast_frame *first_frame);
+static long get_now(struct ast_jb *jb, struct timeval *tv);
+
+
+/* Interface ast jb functions impl */
+
+
+static void jb_choose_impl(struct ast_channel *chan)
+{
+	struct ast_jb *jb = &chan->jb;
+	struct ast_jb_conf *jbconf = &jb->conf;
+	struct ast_jb_impl *test_impl;
+	int i, avail_impl_count = sizeof(avail_impl) / sizeof(avail_impl[0]);
+	
+	jb->impl = &avail_impl[default_impl];
+	
+	if(*jbconf->impl == '\0')
+	{
+		return;
+	}
+		
+	for(i=0; i<avail_impl_count; i++)
+	{
+		test_impl = &avail_impl[i];
+		if(strcmp(jbconf->impl, test_impl->name) == 0)
+		{
+			jb->impl = test_impl;
+			return;
+		}
+	}
+}
+
+
+void ast_jb_do_usecheck(struct ast_channel *c0, struct ast_channel *c1)
+{
+	struct ast_jb *jb0 = &c0->jb;
+	struct ast_jb *jb1 = &c1->jb;
+	struct ast_jb_conf *conf0 = &jb0->conf;
+	struct ast_jb_conf *conf1 = &jb1->conf;
+	int c0_wants_jitter = c0->tech->properties & AST_CHAN_TP_WANTSJITTER;
+	int c0_creates_jitter = c0->tech->properties & AST_CHAN_TP_CREATESJITTER;
+	int c0_jb_enabled = ast_test_flag(conf0, AST_JB_ENABLED);
+	int c0_force_jb = ast_test_flag(conf0, AST_JB_FORCED);
+	int c0_jb_timebase_initialized = ast_test_flag(jb0, JB_TIMEBASE_INITIALIZED);
+	int c0_jb_created = ast_test_flag(jb0, JB_CREATED);
+	int c1_wants_jitter = c1->tech->properties & AST_CHAN_TP_WANTSJITTER;
+	int c1_creates_jitter = c1->tech->properties & AST_CHAN_TP_CREATESJITTER;
+	int c1_jb_enabled = ast_test_flag(conf1, AST_JB_ENABLED);
+	int c1_force_jb = ast_test_flag(conf1, AST_JB_FORCED);
+	int c1_jb_timebase_initialized = ast_test_flag(jb1, JB_TIMEBASE_INITIALIZED);
+	int c1_jb_created = ast_test_flag(jb1, JB_CREATED);
+	
+	if(((!c0_wants_jitter && c1_creates_jitter) || c0_force_jb) && c0_jb_enabled)
+	{
+		ast_set_flag(jb0, JB_USE);
+		if(!c0_jb_timebase_initialized)
+		{
+			if(c1_jb_timebase_initialized)
+			{
+				memcpy(&jb0->timebase, &jb1->timebase, sizeof(struct timeval));
+			}
+			else
+			{
+				gettimeofday(&jb0->timebase, NULL);
+			}
+			ast_set_flag(jb0, JB_TIMEBASE_INITIALIZED);
+		}
+		
+		if(!c0_jb_created)
+		{
+			jb_choose_impl(c0);
+		}
+	}
+	
+	if(((!c1_wants_jitter && c0_creates_jitter) || c1_force_jb) && c1_jb_enabled)
+	{
+		ast_set_flag(jb1, JB_USE);
+		if(!c1_jb_timebase_initialized)
+		{
+			if(c0_jb_timebase_initialized)
+			{
+				memcpy(&jb1->timebase, &jb0->timebase, sizeof(struct timeval));
+			}
+			else
+			{
+				gettimeofday(&jb1->timebase, NULL);
+			}
+			ast_set_flag(jb1, JB_TIMEBASE_INITIALIZED);
+		}
+		
+		if(!c1_jb_created)
+		{
+			jb_choose_impl(c1);
+		}
+	}
+}
+
+
+int ast_jb_get_when_to_wakeup(struct ast_channel *c0, struct ast_channel *c1, int time_left)
+{
+	struct ast_jb *jb0 = &c0->jb;
+	struct ast_jb *jb1 = &c1->jb;
+	int c0_use_jb = ast_test_flag(jb0, JB_USE);
+	int c0_jb_is_created = ast_test_flag(jb0, JB_CREATED);
+	int c1_use_jb = ast_test_flag(jb1, JB_USE);
+	int c1_jb_is_created = ast_test_flag(jb1, JB_CREATED);
+	int wait, wait0, wait1;
+	struct timeval tv_now;
+	
+	if(time_left == 0)
+	{
+		/* No time left - the bridge will be retried */
+		/* TODO: Test disable this */
+		/*return 0;*/
+	}
+	
+	if(time_left < 0)
+	{
+		time_left = INT_MAX;
+	}
+	
+	gettimeofday(&tv_now, NULL);
+	
+	wait0 = (c0_use_jb && c0_jb_is_created) ? jb0->next - get_now(jb0, &tv_now) : time_left;
+	wait1 = (c1_use_jb && c1_jb_is_created) ? jb1->next - get_now(jb1, &tv_now) : time_left;
+	
+	wait = wait0 < wait1 ? wait0 : wait1;
+	wait = wait < time_left ? wait : time_left;
+	
+	if(wait == INT_MAX)
+	{
+		wait = -1;
+	}
+	else if(wait < 1)
+	{
+		/* don't let wait=0, because this can cause the pbx thread to loop without any sleeping at all */
+		wait = 1;
+	}
+	
+	return wait;
+}
+
+
+int ast_jb_put(struct ast_channel *chan, struct ast_frame *f)
+{
+	struct ast_jb *jb = &chan->jb;
+	struct ast_jb_impl *jbimpl = jb->impl;
+	void *jbobj = jb->jbobj;
+	struct ast_frame *frr;
+	long now = 0;
+	
+	if(!ast_test_flag(jb, JB_USE))
+	{
+		return -1;
+	}
+	
+	if(f->frametype != AST_FRAME_VOICE)
+	{
+		if(f->frametype == AST_FRAME_DTMF && ast_test_flag(jb, JB_CREATED))
+		{
+			jb_framelog("JB_PUT {now=%ld}: Received DTMF frame. Force resynching jb...\n", now);
+			jbimpl->force_resync(jbobj);
+		}
+		
+		return -1;
+	}
+	
+	/* We consider an enabled jitterbuffer should receive frames with valid timing info. */
+	if(!f->has_timing_info || f->len < 2 || f->ts < 0)
+	{
+		ast_log(LOG_WARNING, "Recieved frame with invalid timing info: "
+			"has_timing_info=%d, len=%ld, ts=%ld\n", f->has_timing_info, f->len, f->ts);
+		return -1;
+	}
+	
+	if(f->mallocd & AST_MALLOCD_HDR)
+	{
+		frr = ast_frdup(f);
+	}
+	else
+	{
+		frr = ast_frisolate(f);
+	}
+	if(frr == NULL)
+	{
+		ast_log(LOG_ERROR, "Failed to isolate frame for the jitterbuffer on channel '%s'\n", chan->name);
+		return -1;
+	}
+	
+	if(!ast_test_flag(jb, JB_CREATED))
+	{
+		if(create_jb(chan, frr))
+		{
+			ast_frfree(frr);
+			/* Disable the jitterbuffer */
+			ast_clear_flag(jb, JB_USE);
+			return -1;
+		}
+		
+		ast_set_flag(jb, JB_CREATED);
+		return 0;
+	}
+	else
+	{
+		now = get_now(jb, NULL);
+		if(jbimpl->put(jbobj, frr, now) != JB_IMPL_OK)
+		{
+			jb_framelog("JB_PUT {now=%ld}: Dropped frame with ts=%ld and len=%ld\n", now, frr->ts, frr->len);
+			ast_frfree(frr);
+			/*return -1;*/
+			/* TODO: Check this fix - should return 0 here, because the dropped frame shouldn't 
+			   be delivered at all */
+			return 0;
+		}
+		
+		jb->next = jbimpl->next(jbobj);
+		
+		jb_framelog("JB_PUT {now=%ld}: Queued frame with ts=%ld and len=%ld\n", now, frr->ts, frr->len);
+		
+		return 0;
+	}
+}
+
+
+void ast_jb_get_and_deliver(struct ast_channel *c0, struct ast_channel *c1)
+{
+	struct ast_jb *jb0 = &c0->jb;
+	struct ast_jb *jb1 = &c1->jb;
+	int c0_use_jb = ast_test_flag(jb0, JB_USE);
+	int c0_jb_is_created = ast_test_flag(jb0, JB_CREATED);
+	int c1_use_jb = ast_test_flag(jb1, JB_USE);
+	int c1_jb_is_created = ast_test_flag(jb1, JB_CREATED);
+	
+	if(c0_use_jb && c0_jb_is_created)
+	{
+		jb_get_and_deliver(c0);
+	}
+	
+	if(c1_use_jb && c1_jb_is_created)
+	{
+		jb_get_and_deliver(c1);
+	}
+}
+
+
+static void jb_get_and_deliver(struct ast_channel *chan)
+{
+	struct ast_jb *jb = &chan->jb;
+	struct ast_jb_impl *jbimpl = jb->impl;
+	void *jbobj = jb->jbobj;
+	struct ast_frame *f, finterp;
+	long now;
+	int interpolation_len, res;
+	
+	now = get_now(jb, NULL);
+	jb->next = jbimpl->next(jbobj);
+	if(now < jb->next)
+	{
+		jb_framelog("\tJB_GET {now=%ld}: now < next=%ld\n", now, jb->next);
+		return;
+	}
+	
+	while(now >= jb->next)
+	{
+		interpolation_len = ast_codec_interp_len(jb->last_format);
+		
+		res = jbimpl->get(jbobj, &f, now, interpolation_len);
+		
+		switch(res)
+		{
+		case JB_IMPL_OK:
+			/* deliver the frame */
+			ast_write(chan, f);
+		case JB_IMPL_DROP:
+			jb_framelog("\tJB_GET {now=%ld}: %s frame with ts=%ld and len=%ld\n",
+				now, jb_get_actions[res], f->ts, f->len);
+			jb->last_format = f->subclass;
+			ast_frfree(f);
+			break;
+		case JB_IMPL_INTERP:
+			/* interpolate a frame */
+			f = &finterp;
+			f->frametype = AST_FRAME_VOICE;
+			f->subclass = jb->last_format;
+			f->datalen  = 0;
+			f->samples  = interpolation_len * 8;
+			f->mallocd  = 0;
+			f->src  = "JB interpolation";
+			f->data  = NULL;
+			f->delivery = ast_tvadd(jb->timebase, ast_samp2tv(jb->next, 1000));
+			f->offset=AST_FRIENDLY_OFFSET;
+			/* deliver the interpolated frame */
+			ast_write(chan, f);
+			jb_framelog("\tJB_GET {now=%ld}: Interpolated frame with len=%d\n", now, interpolation_len);
+			break;
+		case JB_IMPL_NOFRAME:
+			ast_log(LOG_WARNING,
+				"JB_IMPL_NOFRAME is retuned from the %s jb when now=%ld >= next=%ld, jbnext=%ld!\n",
+				jbimpl->name, now, jb->next, jbimpl->next(jbobj));
+			jb_framelog("\tJB_GET {now=%ld}: No frame for now!?\n", now);
+			return;
+		default:
+			ast_log(LOG_ERROR, "This should never happen!\n");
+			CRASH;
+			break;
+		}
+		
+		jb->next = jbimpl->next(jbobj);
+	}
+}
+
+
+static int create_jb(struct ast_channel *chan, struct ast_frame *frr)
+{
+	struct ast_jb *jb = &chan->jb;
+	struct ast_jb_conf *jbconf = &jb->conf;
+	struct ast_jb_impl *jbimpl = jb->impl;
+	void *jbobj;
+	struct ast_channel *bridged;
+	long now;
+	char logfile_pathname[20 + AST_JB_IMPL_NAME_SIZE + 2*AST_CHANNEL_NAME + 1];
+	char name1[AST_CHANNEL_NAME], name2[AST_CHANNEL_NAME], *tmp;
+	int res;
+
+	jbobj = jb->jbobj = jbimpl->create(jbconf, jbconf->resync_threshold);
+	if(jbobj == NULL)
+	{
+		ast_log(LOG_WARNING, "Failed to create jitterbuffer on channel '%s'\n", chan->name);
+		return -1;
+	}
+	
+	now = get_now(jb, NULL);
+	res = jbimpl->put_first(jbobj, frr, now);
+	
+	/* The result of putting the first frame should not differ from OK. However, its possible
+	   some implementations (i.e. stevek's when resynch_threshold is specified) to drop it. */
+	if(res != JB_IMPL_OK)
+	{
+		ast_log(LOG_WARNING, "Failed to put first frame in the jitterbuffer on channel '%s'\n", chan->name);
+		/*
+		jbimpl->destroy(jbobj);
+		return -1;
+		*/
+	}
+	
+	/* Init next */
+	jb->next = jbimpl->next(jbobj);
+	
+	/* Init last format for a first time. */
+	jb->last_format = frr->subclass;
+	
+	/* Create a frame log file */
+	if(ast_test_flag(jbconf, AST_JB_LOG))
+	{
+		snprintf(name2, sizeof(name2), "%s", chan->name);
+		tmp = strchr(name2, '/');
+		if(tmp != NULL)
+		{
+			*tmp = '#';
+		}
+		bridged = ast_bridged_channel(chan);
+		if(bridged == NULL)
+		{
+			/* We should always have bridged chan if a jitterbuffer is in use */
+			CRASH;
+		}
+		snprintf(name1, sizeof(name1), "%s", bridged->name);
+		tmp = strchr(name1, '/');
+		if(tmp != NULL)
+		{
+			*tmp = '#';
+		}
+		snprintf(logfile_pathname, sizeof(logfile_pathname),
+			"/tmp/ast_%s_jb_%s--%s.log", jbimpl->name, name1, name2);
+		jb->logfile = fopen(logfile_pathname, "w+b");
+		
+		if(jb->logfile == NULL)
+		{
+			ast_log(LOG_WARNING, "Failed to create frame log file with pathname '%s'\n", logfile_pathname);
+		}
+		
+		if(res == JB_IMPL_OK)
+		{
+			jb_framelog("JB_PUT_FIRST {now=%ld}: Queued frame with ts=%ld and len=%ld\n",
+				now, frr->ts, frr->len);
+		}
+		else
+		{
+			jb_framelog("JB_PUT_FIRST {now=%ld}: Dropped frame with ts=%ld and len=%ld\n",
+				now, frr->ts, frr->len);
+		}
+	}
+	
+	jb_verbose("%s jitterbuffer created on channel %s", jbimpl->name, chan->name);
+	
+	/* Free the frame if it has not been queued in the jb */
+	if(res != JB_IMPL_OK)
+	{
+		ast_frfree(frr);
+	}
+	
+	return 0;
+}
+
+
+void ast_jb_destroy(struct ast_channel *chan)
+{
+	struct ast_jb *jb = &chan->jb;
+	struct ast_jb_impl *jbimpl = jb->impl;
+	void *jbobj = jb->jbobj;
+	struct ast_frame *f;
+
+	if(jb->logfile != NULL)
+	{
+		fclose(jb->logfile);
+		jb->logfile = NULL;
+	}
+	
+	if(ast_test_flag(jb, JB_CREATED))
+	{
+		/* Remove and free all frames still queued in jb */
+		while(jbimpl->remove(jbobj, &f) == JB_IMPL_OK)
+		{
+			ast_frfree(f);
+		}
+		
+		jbimpl->destroy(jbobj);
+		jb->jbobj = NULL;
+		
+		ast_clear_flag(jb, JB_CREATED);
+		
+		jb_verbose("%s jitterbuffer destroyed on channel %s", jbimpl->name, chan->name);
+	}
+}
+
+
+static long get_now(struct ast_jb *jb, struct timeval *tv)
+{
+	struct timeval now;
+	
+	if(tv == NULL)
+	{
+		tv = &now;
+		gettimeofday(tv, NULL);
+	}
+	
+	return (long) ((tv->tv_sec - jb->timebase.tv_sec) * 1000) +
+		(long) ((double) (tv->tv_usec - jb->timebase.tv_usec) / 1000.0);
+	
+	/* TODO: For asterisk complience, we should use: */
+	/* return ast_tvdiff_ms(*tv, jb->timebase); */
+}
+
+
+int ast_jb_read_conf(struct ast_jb_conf *conf, char *varname, char *value)
+{
+	int prefixlen = sizeof(AST_JB_CONF_PREFIX) - 1;
+	char *name;
+	int tmp;
+	
+	if(memcmp(AST_JB_CONF_PREFIX, varname, prefixlen) != 0)
+	{
+		return -1;
+	}
+	
+	name = varname + prefixlen;
+	
+	if(strcmp(name, AST_JB_CONF_ENABLE) == 0)
+	{
+		if(ast_true(value))
+		{
+			conf->flags |= AST_JB_ENABLED;
+		}
+	}
+	else if(strcmp(name, AST_JB_CONF_FORCE) == 0)
+	{
+		if(ast_true(value))
+		{
+			conf->flags |= AST_JB_FORCED;
+		}
+	}
+	else if(strcmp(name, AST_JB_CONF_MAX_SIZE) == 0)
+	{
+		if((tmp = atoi(value)) > 0)
+		{
+			conf->max_size = tmp;
+		}
+	}
+	else if(strcmp(name, AST_JB_CONF_RESYNCH_THRESHOLD) == 0)
+	{
+		if((tmp = atoi(value)) > 0)
+		{
+			conf->resync_threshold = tmp;
+		}
+	}
+	else if(strcmp(name, AST_JB_CONF_IMPL) == 0)
+	{
+		if(*value)
+		{
+			snprintf(conf->impl, sizeof(conf->impl), "%s", value);
+		}
+	}
+	else if(strcmp(name, AST_JB_CONF_LOG) == 0)
+	{
+		if(ast_true(value))
+		{
+			conf->flags |= AST_JB_LOG;
+		}
+	}
+	else
+	{
+		return -1;
+	}
+	
+	return 0;
+}
+
+
+void ast_jb_configure(struct ast_channel *chan, struct ast_jb_conf *conf)
+{
+	struct ast_jb *jb = &chan->jb;
+	struct ast_jb_conf *jbconf = &jb->conf;
+	
+	memcpy(jbconf, conf, sizeof(struct ast_jb_conf));
+}
+
+
+void ast_jb_get_config(struct ast_channel *chan, struct ast_jb_conf *conf)
+{
+	struct ast_jb *jb = &chan->jb;
+	struct ast_jb_conf *jbconf = &jb->conf;
+	
+	memcpy(conf, jbconf, sizeof(struct ast_jb_conf));
+}
+
+
+/* Implementation functions */
+
+/* scx */
+
+static void * jb_create_scx(struct ast_jb_conf *general_config, long resynch_threshold)
+{
+	struct scx_jb_conf conf;
+	
+	conf.jbsize = general_config->max_size;
+	conf.resync_threshold = resynch_threshold;
+	
+	return scx_jb_new(&conf);
+}
+
+
+static void jb_destroy_scx(void *jb)
+{
+	struct scx_jb *scxjb = (struct scx_jb *) jb;
+	
+	/* destroy the jb */
+	scx_jb_destroy(scxjb);
+}
+
+
+static int jb_put_first_scx(void *jb, struct ast_frame *fin, long now)
+{
+	struct scx_jb *scxjb = (struct scx_jb *) jb;
+	int res;
+	
+	res = scx_jb_put_first(scxjb, fin, fin->len, fin->ts, now);
+	
+	return scx_to_abstract_code[res];
+}
+
+
+static int jb_put_scx(void *jb, struct ast_frame *fin, long now)
+{
+	struct scx_jb *scxjb = (struct scx_jb *) jb;
+	int res;
+	
+	res = scx_jb_put(scxjb, fin, fin->len, fin->ts, now);
+	
+	return scx_to_abstract_code[res];
+}
+
+
+static int jb_get_scx(void *jb, struct ast_frame **fout, long now, long interpl)
+{
+	struct scx_jb *scxjb = (struct scx_jb *) jb;
+	struct scx_jb_frame frame;
+	int res;
+	
+	res = scx_jb_get(scxjb, &frame, now, interpl);
+	*fout = frame.data;
+	
+	return scx_to_abstract_code[res];
+}
+
+
+static long jb_next_scx(void *jb)
+{
+	struct scx_jb *scxjb = (struct scx_jb *) jb;
+	
+	return scx_jb_next(scxjb);
+}
+
+
+static int jb_remove_scx(void *jb, struct ast_frame **fout)
+{
+	struct scx_jb *scxjb = (struct scx_jb *) jb;
+	struct scx_jb_frame frame;
+	int res;
+	
+	res = scx_jb_remove(scxjb, &frame);
+	*fout = frame.data;
+	
+	return scx_to_abstract_code[res];
+}
+
+
+static void jb_force_resynch_scx(void *jb)
+{
+	struct scx_jb *scxjb = (struct scx_jb *) jb;
+	
+	scx_jb_set_force_resynch(scxjb);
+}
+
+
+/* stevek */
+
+static void * jb_create_stevek(struct ast_jb_conf *general_config, long resynch_threshold)
+{
+	jb_conf jbconf;
+	jitterbuf *stevekjb;
+
+	stevekjb = jb_new();
+	if(stevekjb != NULL)
+	{
+		jbconf.max_jitterbuf = general_config->max_size;
+		jbconf.resync_threshold = general_config->resync_threshold;
+		jbconf.max_contig_interp = 10;
+		jb_setconf(stevekjb, &jbconf);
+	}
+	
+	return stevekjb;
+}
+
+
+static void jb_destroy_stevek(void *jb)
+{
+	jitterbuf *stevekjb = (jitterbuf *) jb;
+	
+	jb_destroy(stevekjb);
+}
+
+
+static int jb_put_first_stevek(void *jb, struct ast_frame *fin, long now)
+{
+	return jb_put_stevek(jb, fin, now);
+}
+
+
+static int jb_put_stevek(void *jb, struct ast_frame *fin, long now)
+{
+	jitterbuf *stevekjb = (jitterbuf *) jb;
+	int res;
+	
+	res = jb_put(stevekjb, fin, JB_TYPE_VOICE, fin->len, fin->ts, now);
+	
+	return stevek_to_abstract_code[res];
+}
+
+
+static int jb_get_stevek(void *jb, struct ast_frame **fout, long now, long interpl)
+{
+	jitterbuf *stevekjb = (jitterbuf *) jb;
+	jb_frame frame;
+	int res;
+	
+	res = jb_get(stevekjb, &frame, now, interpl);
+	*fout = frame.data;
+	
+	return stevek_to_abstract_code[res];
+}
+
+
+static long jb_next_stevek(void *jb)
+{
+	jitterbuf *stevekjb = (jitterbuf *) jb;
+	
+	return jb_next(stevekjb);
+}
+
+
+static int jb_remove_stevek(void *jb, struct ast_frame **fout)
+{
+	jitterbuf *stevekjb = (jitterbuf *) jb;
+	jb_frame frame;
+	int res;
+	
+	res = jb_getall(stevekjb, &frame);
+	*fout = frame.data;
+	
+	return stevek_to_abstract_code[res];
+}
+
+
+static void jb_force_resynch_stevek(void *jb)
+{
+}
+
+
+#endif /* AST_JB */
+
+

Propchange: team/oej/jitterbuffer-1.2/abstract_jb.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/oej/jitterbuffer-1.2/abstract_jb.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/oej/jitterbuffer-1.2/abstract_jb.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/oej/jitterbuffer-1.2/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/channel.c?rev=12594&r1=12593&r2=12594&view=diff
==============================================================================
--- team/oej/jitterbuffer-1.2/channel.c (original)
+++ team/oej/jitterbuffer-1.2/channel.c Sun Mar 12 12:02:48 2006
@@ -949,6 +949,11 @@
 	
 	while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
 		ast_var_delete(vardata);
+
+#ifdef AST_JB
+	/* Destroy the jitterbuffer */
+	ast_jb_destroy(chan);
+#endif /* AST_JB */
 
 	free(chan);
 	ast_mutex_unlock(&chlock);
@@ -3200,6 +3205,10 @@
 	int watch_c0_dtmf;
 	int watch_c1_dtmf;
 	void *pvt0, *pvt1;
+#ifdef AST_JB
+	/* Indicates whether a frame was queued into a jitterbuffer */
+	int frame_put_in_jb;
+#endif /* AST_JB */
 	
 	cs[0] = c0;
 	cs[1] = c1;
@@ -3210,6 +3219,11 @@
 	watch_c0_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_0;
 	watch_c1_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_1;
 
+#ifdef AST_JB
+	/* Check the need of a jitterbuffer for each channel */
+	ast_jb_do_usecheck(c0, c1);
+#endif /* AST_JB */
+
 	for (;;) {
 		if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) ||
 		    (o0nativeformats != c0->nativeformats) ||
@@ -3218,8 +3232,17 @@
 			res = AST_BRIDGE_RETRY;
 			break;
 		}
+#ifdef AST_JB
+		/* Calculate the appropriate max sleep interval - in general, this is the time,
+		   left to the closest jb delivery moment */
+		toms = ast_jb_get_when_to_wakeup(c0, c1, toms);
+#endif /* AST_JB */
 		who = ast_waitfor_n(cs, 2, &toms);
 		if (!who) {
+#ifdef AST_JB
+			/* No frame received within the specified timeout - check if we have to deliver now */
+			ast_jb_get_and_deliver(c0, c1);
+#endif /* AST_JB */
 			if (!toms) {
 				res = AST_BRIDGE_RETRY;
 				break;
@@ -3243,6 +3266,11 @@
 			ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name);
 			break;
 		}
+
+#ifdef AST_JB
+		/* Try add the frame info the who's bridged channel jitterbuff */
+		frame_put_in_jb = !ast_jb_put((who == c0) ? c1 : c0, f);
+#endif /* AST_JB */
 
 		if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) {
 			if ((f->subclass == AST_CONTROL_HOLD) || (f->subclass == AST_CONTROL_UNHOLD) ||
@@ -3281,7 +3309,18 @@
 				last = who;
 #endif
 tackygoto:
+#ifdef AST_JB
+				/* Write immediately frames, not passed through jb */
+				if(!frame_put_in_jb)
+				{
+					ast_write((who == c0) ? c1 : c0, f);
+				}
+				
+				/* Check if we have to deliver now */
+				ast_jb_get_and_deliver(c0, c1);
+#else /* AST_JB */
 				ast_write((who == c0) ? c1 : c0, f);
+#endif /* AST_JB */
 			}
 		}
 		ast_frfree(f);

Modified: team/oej/jitterbuffer-1.2/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/channels/chan_iax2.c?rev=12594&r1=12593&r2=12594&view=diff
==============================================================================
--- team/oej/jitterbuffer-1.2/channels/chan_iax2.c (original)
+++ team/oej/jitterbuffer-1.2/channels/chan_iax2.c Sun Mar 12 12:02:48 2006
@@ -1410,6 +1410,9 @@
 	  the IAX thread with the iaxsl lock held. */
 	struct iax_frame *fr = data;
 	fr->retrans = -1;
+#ifdef AST_JB
+	fr->af.has_timing_info = 0;
+#endif /* AST_JB */
 	if (iaxs[fr->callno] && !ast_test_flag(iaxs[fr->callno], IAX_ALREADYGONE))
 		iax2_queue_frame(fr->callno, &fr->af);
 	/* Free our iax frame */

Modified: team/oej/jitterbuffer-1.2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/channels/chan_sip.c?rev=12594&r1=12593&r2=12594&view=diff
==============================================================================
--- team/oej/jitterbuffer-1.2/channels/chan_sip.c (original)
+++ team/oej/jitterbuffer-1.2/channels/chan_sip.c Sun Mar 12 12:02:48 2006
@@ -138,6 +138,19 @@
 
 #define DEBUG_READ	0			/* Recieved data	*/
 #define DEBUG_SEND	1			/* Transmit data	*/
+
+#ifdef AST_JB
+#include "asterisk/abstract_jb.h"
+/* Global jitterbuffer configuration - by default, jb is disabled */
+static struct ast_jb_conf default_jbconf =
+{
+	.flags = 0,
+	.max_size = -1,
+	.resync_threshold = -1,
+	.impl = ""
+};
+static struct ast_jb_conf global_jbconf;
+#endif /* AST_JB */
 
 static const char desc[] = "Session Initiation Protocol (SIP)";
 static const char channeltype[] = "SIP";
@@ -687,6 +700,9 @@
 	struct ast_variable *chanvars;		/*!< Channel variables to set for call */
 	struct sip_pvt *next;			/*!< Next call in chain */
 	struct sip_invite_param *options;	/*!< Options for INVITE */
+#ifdef AST_JB
+	struct ast_jb_conf jbconf;
+#endif /* AST_JB */
 } *iflist = NULL;
 
 #define FLAG_RESPONSE (1 << 0)
@@ -927,7 +943,11 @@
 	.type = channeltype,
 	.description = "Session Initiation Protocol (SIP)",
 	.capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
+#ifdef AST_JB
+	.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER,
+#else /* AST_JB */
 	.properties = AST_CHAN_TP_WANTSJITTER,
+#endif /* AST_JB */
 	.requester = sip_request_call,
 	.devicestate = sip_devicestate,
 	.call = sip_call,
@@ -2824,6 +2844,14 @@
 	for (v = i->chanvars ; v ; v = v->next)
 		pbx_builtin_setvar_helper(tmp,v->name,v->value);
 				
+#ifdef AST_JB
+	/* Configure the new channel jb */
+	if(tmp != NULL && i != NULL && i->rtp != NULL)
+	{
+		ast_jb_configure(tmp, &i->jbconf);
+	}
+#endif /* AST_JB */
+				
 	return tmp;
 }
 
@@ -3091,6 +3119,11 @@
 	if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO))
 		p->noncodeccapability |= AST_RTP_DTMF;
 	strcpy(p->context, default_context);
+
+#ifdef AST_JB
+	/* Assign default jb conf to the new sip_pvt */
+	memcpy(&p->jbconf, &global_jbconf, sizeof(struct ast_jb_conf));
+#endif /* AST_JB */
 
 	/* Add to active dialog list */
 	ast_mutex_lock(&iflock);
@@ -12297,6 +12330,11 @@
 	tos = 0;
 	expiry = DEFAULT_EXPIRY;
 	global_allowguest = 1;
+	
+#ifdef AST_JB
+	/* Copy the default jb config over global_jbconf */
+	memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
+#endif /* AST_JB */
 
 	/* Read the [general] config section of sip.conf (or from realtime config) */
 	v = ast_variable_browse(cfg, "general");
@@ -12305,6 +12343,14 @@
 			v = v->next;
 			continue;
 		}
+#ifdef AST_JB
+		/* handle jb conf */
+		if(ast_jb_read_conf(&global_jbconf, v->name, v->value) == 0)
+		{
+			v = v->next;
+			continue;
+		}
+#endif /* AST_JB */
 
 		/* Create the interface list */
 		if (!strcasecmp(v->name, "context")) {

Modified: team/oej/jitterbuffer-1.2/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/channels/chan_zap.c?rev=12594&r1=12593&r2=12594&view=diff
==============================================================================
--- team/oej/jitterbuffer-1.2/channels/chan_zap.c (original)
+++ team/oej/jitterbuffer-1.2/channels/chan_zap.c Sun Mar 12 12:02:48 2006
@@ -96,6 +96,19 @@
 #include "asterisk/term.h"
 #include "asterisk/utils.h"
 #include "asterisk/transcap.h"
+
+#ifdef AST_JB
+#include "asterisk/abstract_jb.h"
+/* Global jitterbuffer configuration - by default, jb is disabled */
+static struct ast_jb_conf default_jbconf =
+{
+	.flags = 0,
+	.max_size = -1,
+	.resync_threshold = -1,
+	.impl = ""
+};
+static struct ast_jb_conf global_jbconf;
+#endif /* AST_JB */
 
 #ifndef ZT_SIG_EM_E1
 #error "Your zaptel is too old.  please cvs update"
@@ -683,6 +696,9 @@
 #endif	
 	int polarity;
 	int dsp_features;
+#ifdef AST_JB
+	struct ast_jb_conf jbconf;
+#endif /* AST_JB */
 
 } *iflist = NULL, *ifend = NULL;
 
@@ -5121,6 +5137,13 @@
 		}
 	} else
 		ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
+#ifdef AST_JB
+	/* Configure the new channel jb */
+	if(tmp != NULL && i != NULL)
+	{
+		ast_jb_configure(tmp, &i->jbconf);
+	}
+#endif /* AST_JB */
 	return tmp;
 }
 
@@ -6833,6 +6856,10 @@
 		for (x=0;x<3;x++)
 			tmp->subs[x].zfd = -1;
 		tmp->channel = channel;
+#ifdef AST_JB
+		/* Assign default jb conf to the new zt_pvt */
+		memcpy(&tmp->jbconf, &global_jbconf, sizeof(struct ast_jb_conf));
+#endif /* AST_JB */
 	}
 
 	if (tmp) {
@@ -10158,8 +10185,20 @@
 		}
 	}
 #endif
+#ifdef AST_JB
+	/* Copy the default jb config over global_jbconf */
+	memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
+#endif /* AST_JB */
 	v = ast_variable_browse(cfg, "channels");
 	while(v) {
+#ifdef AST_JB
+		/* handle jb conf */
+		if(ast_jb_read_conf(&global_jbconf, v->name, v->value) == 0)
+		{
+			v = v->next;
+			continue;
+		}
+#endif /* AST_JB */
 		/* Create the interface list */
 		if (!strcasecmp(v->name, "channel")
 #ifdef ZAPATA_PRI

Modified: team/oej/jitterbuffer-1.2/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/configs/sip.conf.sample?rev=12594&r1=12593&r2=12594&view=diff
==============================================================================
--- team/oej/jitterbuffer-1.2/configs/sip.conf.sample (original)
+++ team/oej/jitterbuffer-1.2/configs/sip.conf.sample Sun Mar 12 12:02:48 2006
@@ -234,6 +234,32 @@
 ; To disallow requests for domains not serviced by this server:
 ; allowexternaldomains=no
 
+;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
+; jb-enable = yes             ; Enables the use of a jitterbuffer on the receiving side of a
+                              ; SIP channel. Defaults to "no". An enabled jitterbuffer will
+                              ; be used only if the sending side can create and the receiving
+                              ; side can not accept jitter. The SIP channel can accept jitter,
+                              ; thus a jitterbuffer on the receive SIP side will be used only
+                              ; if it is forced and enabled.
+
+; jb-force = no               ; Forces the use of a jitterbuffer on the receive side of a SIP
+                              ; channel. Defaults to "no".
+
+; jb-max-size = 200           ; Max length of the jitterbuffer in milliseconds.
+
+; jb-resynch-threshold = 1000 ; Jump in the frame timestamps over which the jitterbuffer is
+                              ; resynchronized. Useful to improve the quality of the voice, with
+                              ; big jumps in/broken timestamps, usualy sent from exotic devices
+                              ; and programs. Defaults to 1000.
+
+; jb-impl = fixed             ; Jitterbuffer implementation, used on the receiving side of a SIP
+                              ; channel. Two implementation are currenlty available - "fixed"
+                              ; (with size always equals to jb-max-size) and "adaptive" (with
+                              ; variable size, actually the new jb of IAX2). Defaults to fixed.
+
+; jb-log = no                 ; Enables jitterbuffer frame logging. Defaults to "no".
+;-----------------------------------------------------------------------------------
+
 [authentication]
 ; Global credentials for outbound calls, i.e. when a proxy challenges your
 ; Asterisk server for authentication. These credentials override

Modified: team/oej/jitterbuffer-1.2/configs/zapata.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/configs/zapata.conf.sample?rev=12594&r1=12593&r2=12594&view=diff
==============================================================================
--- team/oej/jitterbuffer-1.2/configs/zapata.conf.sample (original)
+++ team/oej/jitterbuffer-1.2/configs/zapata.conf.sample Sun Mar 12 12:02:48 2006
@@ -472,6 +472,33 @@
 ;
 ;jitterbuffers=4
 ;
+;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
+; jb-enable = yes             ; Enables the use of a jitterbuffer on the receiving side of a
+                              ; ZAP channel. Defaults to "no". An enabled jitterbuffer will
+                              ; be used only if the sending side can create and the receiving
+                              ; side can not accept jitter. The ZAP channel can't accept jitter,
+                              ; thus an enabled jitterbuffer on the receive ZAP side will always
+                              ; be used if the sending side can create jitter or if ZAP jb is
+                              ; forced.
+
+; jb-force = no               ; Forces the use of a jitterbuffer on the receive side of a ZAP
+                              ; channel. Defaults to "no".
+
+; jb-max-size = 200           ; Max length of the jitterbuffer in milliseconds.
+
+; jb-resynch-threshold = 1000 ; Jump in the frame timestamps over which the jitterbuffer is
+                              ; resynchronized. Useful to improve the quality of the voice, with
+                              ; big jumps in/broken timestamps, usualy sent from exotic devices
+                              ; and programs. Defaults to 1000.
+
+; jb-impl = fixed             ; Jitterbuffer implementation, used on the receiving side of a SIP
+                              ; channel. Two implementation are currenlty available - "fixed"
+                              ; (with size always equals to jb-max-size) and "adaptive" (with
+                              ; variable size, actually the new jb of IAX2). Defaults to fixed.
+
+; jb-log = no                 ; Enables jitterbuffer frame logging. Defaults to "no".
+;-----------------------------------------------------------------------------------
+;
 ; You can define your own custom ring cadences here.  You can define up to 8
 ; pairs.  If the silence is negative, it indicates where the callerid spill is
 ; to be placed.  Also, if you define any custom cadences, the default cadences

Modified: team/oej/jitterbuffer-1.2/frame.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/frame.c?rev=12594&r1=12593&r2=12594&view=diff
==============================================================================
--- team/oej/jitterbuffer-1.2/frame.c (original)
+++ team/oej/jitterbuffer-1.2/frame.c Sun Mar 12 12:02:48 2006
@@ -318,6 +318,16 @@
 		out->offset = fr->offset;
 		out->src = NULL;
 		out->data = fr->data;
+#ifdef AST_JB
+		/* Copy the timing data */
+		out->has_timing_info = fr->has_timing_info;
+		if(fr->has_timing_info)
+		{
+			out->ts = fr->ts;
+			out->len = fr->len;
+			out->seqno = fr->seqno;
+		}
+#endif /* AST_JB */
 	} else {
 		out = fr;
 	}
@@ -381,6 +391,15 @@
 	out->prev = NULL;
 	out->next = NULL;
 	memcpy(out->data, f->data, out->datalen);	
+#ifdef AST_JB
+	out->has_timing_info = f->has_timing_info;
+	if(f->has_timing_info)
+	{
+		out->ts = f->ts;
+		out->len = f->len;
+		out->seqno = f->seqno;
+	}
+#endif /* AST_JB */
 	return out;
 }
 

Added: team/oej/jitterbuffer-1.2/include/asterisk/abstract_jb.h
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/include/asterisk/abstract_jb.h?rev=12594&view=auto

[... 888 lines stripped ...]


More information about the asterisk-commits mailing list