summaryrefslogtreecommitdiff
path: root/main/abstract_jb.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2012-07-23 21:15:26 +0000
committerMatthew Jordan <mjordan@digium.com>2012-07-23 21:15:26 +0000
commitb6a0ae0b35797bcdf5368e7d0e2223c6321c9b21 (patch)
tree708c28c7f73c2fd7981442f55213a60ee6d396c8 /main/abstract_jb.c
parenta28e6fc7bd86b31b7ed613f63f1dd0fb7fca5479 (diff)
Unit tests for the Jitter Buffer API; remove unnecessary resync
This patch includes the following: * Unit tests for the abstract Jitter Buffer API. This includes both fixed and adaptive flavors, testing nominal creation, frame input, frame retrieval, resyncing; off nominal frame input overflow, out of order, and others. * Tweaks to the abstract_jb API to remove the unnecessary resync_threshold parameter from the create function (resync_threshold is already in the struct passed into the create function) * Ensure the fixed jitter buffer is empty before destroying it, to avoid an ASSERT * Don't "resync" the adaptive jitter buffer. The mechanism that was being used actually causes the jitter buffer to think its being overflowed by going around the jitterbuf API and attempting to 'resynch' it improperly. If a resync is needed, the jitter buffer will do it properly by itself. Note that this is only an optimization needed for trunk, as the worst that happens is the loss of three voice packets before the adaptive jitter buffer will resync anyway. Review: https://reviewboard.asterisk.org/r/2035 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370387 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/abstract_jb.c')
-rw-r--r--main/abstract_jb.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/main/abstract_jb.c b/main/abstract_jb.c
index e2017c1c1..88a9b8e91 100644
--- a/main/abstract_jb.c
+++ b/main/abstract_jb.c
@@ -56,7 +56,7 @@ enum {
/* Implementation functions */
/* fixed */
-static void *jb_create_fixed(struct ast_jb_conf *general_config, long resynch_threshold);
+static void *jb_create_fixed(struct ast_jb_conf *general_config);
static void jb_destroy_fixed(void *jb);
static int jb_put_first_fixed(void *jb, struct ast_frame *fin, long now);
static int jb_put_fixed(void *jb, struct ast_frame *fin, long now);
@@ -66,7 +66,7 @@ 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_create_adaptive(struct ast_jb_conf *general_config);
static void jb_destroy_adaptive(void *jb);
static int jb_put_first_adaptive(void *jb, struct ast_frame *fin, long now);
static int jb_put_adaptive(void *jb, struct ast_frame *fin, long now);
@@ -413,7 +413,7 @@ static int create_jb(struct ast_channel *chan, struct ast_frame *frr)
char name1[AST_CHANNEL_NAME], name2[AST_CHANNEL_NAME], *tmp;
int res;
- jbobj = jb->jbobj = jbimpl->create(jbconf, jbconf->resync_threshold);
+ jbobj = jb->jbobj = jbimpl->create(jbconf);
if (!jbobj) {
ast_log(LOG_WARNING, "Failed to create jitterbuffer on channel '%s'\n", ast_channel_name(chan));
return -1;
@@ -600,12 +600,12 @@ void ast_jb_empty_and_reset(struct ast_channel *c0, struct ast_channel *c1)
/* Implementation functions */
/* fixed */
-static void * jb_create_fixed(struct ast_jb_conf *general_config, long resynch_threshold)
+static void * jb_create_fixed(struct ast_jb_conf *general_config)
{
struct fixed_jb_conf conf;
conf.jbsize = general_config->max_size;
- conf.resync_threshold = resynch_threshold;
+ conf.resync_threshold = general_config->resync_threshold;
return fixed_jb_new(&conf);
}
@@ -614,6 +614,9 @@ static void jb_destroy_fixed(void *jb)
{
struct fixed_jb *fixedjb = (struct fixed_jb *) jb;
+ /* Ensure the fixed jb is empty - otherwise it will raise an ASSERT */
+ jb_empty_and_reset_fixed(jb);
+
/* destroy the jb */
fixed_jb_destroy(fixedjb);
}
@@ -694,7 +697,7 @@ 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_create_adaptive(struct ast_jb_conf *general_config)
{
jb_conf jbconf;
jitterbuf *adaptivejb;
@@ -722,11 +725,6 @@ static void jb_destroy_adaptive(void *jb)
static int jb_put_first_adaptive(void *jb, struct ast_frame *fin, long now)
{
- jitterbuf *adaptivejb = (jitterbuf *) jb;
-
- /* Initialize the offset to that of the first frame's timestamp */
- adaptivejb->info.resync_offset = fin->ts;
-
return jb_put_adaptive(jb, fin, now);
}