[asterisk-commits] mmichelson: branch mmichelson/issue11259 r135718 - in /team/mmichelson/issue1...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Aug 5 13:47:04 CDT 2008
Author: mmichelson
Date: Tue Aug 5 13:47:04 2008
New Revision: 135718
URL: http://svn.digium.com/view/asterisk?view=rev&rev=135718
Log:
Adding API calls to abstract_jb code to empty and
reset a jitterbuffer. The fixed implementation is just
a skeleton for now, but the adaptive implementation is
filled out completely. The only potential issue right
now with the adaptive method is that it assumes that
the jb_frame pointed to by jb_getall will have an
ast_frame structure as its data element. This may not
be safe in all cases. I'll have to double-check
Modified:
team/mmichelson/issue11259/include/asterisk/abstract_jb.h
team/mmichelson/issue11259/main/abstract_jb.c
Modified: team/mmichelson/issue11259/include/asterisk/abstract_jb.h
URL: http://svn.digium.com/view/asterisk/team/mmichelson/issue11259/include/asterisk/abstract_jb.h?view=diff&rev=135718&r1=135717&r2=135718
==============================================================================
--- team/mmichelson/issue11259/include/asterisk/abstract_jb.h (original)
+++ team/mmichelson/issue11259/include/asterisk/abstract_jb.h Tue Aug 5 13:47:04 2008
@@ -212,6 +212,12 @@
*/
void ast_jb_get_config(const struct ast_channel *chan, struct ast_jb_conf *conf);
+/*!
+ * \brief drops all frames from a jitterbuffer and resets it
+ * \param c0 one channel of a bridge
+ * \param c1 the other channel of the bridge
+ */
+void ast_jb_empty_and_reset(struct ast_channel *c0, struct ast_channel *c1);
#if defined(__cplusplus) || defined(c_plusplus)
}
Modified: team/mmichelson/issue11259/main/abstract_jb.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/issue11259/main/abstract_jb.c?view=diff&rev=135718&r1=135717&r2=135718
==============================================================================
--- team/mmichelson/issue11259/main/abstract_jb.c (original)
+++ team/mmichelson/issue11259/main/abstract_jb.c Tue Aug 5 13:47:04 2008
@@ -70,7 +70,8 @@
typedef int (*jb_remove_impl)(void *jb, struct ast_frame **fout);
/*! \brief Force resynch */
typedef void (*jb_force_resynch_impl)(void *jb);
-
+/*! \brief Empty and reset jb */
+typedef void (*jb_empty_and_reset_impl)(void *jb);
/*!
* \brief Jitterbuffer implementation private struct.
@@ -86,6 +87,7 @@
jb_next_impl next;
jb_remove_impl remove;
jb_force_resynch_impl force_resync;
+ jb_empty_and_reset_impl empty_and_reset;
};
/* Implementation functions */
@@ -98,6 +100,7 @@
static long jb_next_fixed(void *jb);
static int jb_remove_fixed(void *jb, struct ast_frame **fout);
static void jb_force_resynch_fixed(void *jb);
+static void jb_empty_and_reset_fixed(void *jb);
/* adaptive */
static void * jb_create_adaptive(struct ast_jb_conf *general_config, long resynch_threshold);
static void jb_destroy_adaptive(void *jb);
@@ -107,6 +110,7 @@
static long jb_next_adaptive(void *jb);
static int jb_remove_adaptive(void *jb, struct ast_frame **fout);
static void jb_force_resynch_adaptive(void *jb);
+static void jb_empty_and_reset_adaptive(void *jb);
/* Available jb implementations */
static struct ast_jb_impl avail_impl[] =
@@ -120,7 +124,8 @@
.get = jb_get_fixed,
.next = jb_next_fixed,
.remove = jb_remove_fixed,
- .force_resync = jb_force_resynch_fixed
+ .force_resync = jb_force_resynch_fixed,
+ .empty_and_reset = jb_empty_and_reset_fixed,
},
{
.name = "adaptive",
@@ -131,7 +136,8 @@
.get = jb_get_adaptive,
.next = jb_next_adaptive,
.remove = jb_remove_adaptive,
- .force_resync = jb_force_resynch_adaptive
+ .force_resync = jb_force_resynch_adaptive,
+ .empty_and_reset = jb_empty_and_reset_adaptive,
}
};
@@ -226,7 +232,7 @@
}
ast_set_flag(jb0, JB_TIMEBASE_INITIALIZED);
}
-
+
if (!c0_jb_created) {
jb_choose_impl(c0);
}
@@ -608,21 +614,36 @@
memcpy(conf, &chan->jb.conf, sizeof(*conf));
}
+void ast_jb_empty_and_reset(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 && jb0->impl->empty_and_reset) {
+ jb0->impl->empty_and_reset(jb0->jbobj);
+ }
+
+ if (c1_use_jb && c1_jb_is_created && jb1->impl->empty_and_reset) {
+ jb1->impl->empty_and_reset(jb1->jbobj);
+ }
+}
/* Implementation functions */
/* fixed */
-
static void * jb_create_fixed(struct ast_jb_conf *general_config, long resynch_threshold)
{
struct fixed_jb_conf conf;
-
+
conf.jbsize = general_config->max_size;
conf.resync_threshold = resynch_threshold;
-
+
return fixed_jb_new(&conf);
}
-
static void jb_destroy_fixed(void *jb)
{
@@ -696,6 +717,10 @@
fixed_jb_set_force_resynch(fixedjb);
}
+static void jb_empty_and_reset_fixed(void *jb)
+{
+ /* XXX Todo: Actually do this... */
+}
/* adaptive */
@@ -778,3 +803,15 @@
static void jb_force_resynch_adaptive(void *jb)
{
}
+
+static void jb_empty_and_reset_adaptive(void *jb)
+{
+ jitterbuf *adaptivejb = jb;
+ jb_frame *f = NULL;
+
+ while (jb_getall(adaptivejb, f) == JB_OK) {
+ ast_frfree(f->data);
+ }
+
+ jb_reset(adaptivejb);
+}
More information about the asterisk-commits
mailing list