[asterisk-commits] dvossel: branch dvossel/jb_ftw r312020 - /team/dvossel/jb_ftw/funcs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 31 14:28:29 CDT 2011


Author: dvossel
Date: Thu Mar 31 14:28:25 2011
New Revision: 312020

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=312020
Log:
Fixes a few issues found during testing, cleans some debug code up

Modified:
    team/dvossel/jb_ftw/funcs/func_jitterbuffer.c

Modified: team/dvossel/jb_ftw/funcs/func_jitterbuffer.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/jb_ftw/funcs/func_jitterbuffer.c?view=diff&rev=312020&r1=312019&r2=312020
==============================================================================
--- team/dvossel/jb_ftw/funcs/func_jitterbuffer.c (original)
+++ team/dvossel/jb_ftw/funcs/func_jitterbuffer.c Thu Mar 31 14:28:25 2011
@@ -43,10 +43,8 @@
 	struct ast_timer *timer;
 	int timer_rate;
 	int timer_fd;
-
+	int first;
 	struct timeval start_tv;
-	/* used for debug */
-	struct timeval last_tv;
 };
 
 static void jb_framedata_destroy(struct jb_framedata *framedata)
@@ -69,7 +67,7 @@
 {
 //todohere eventually this should take a custom jb config, for testing this is all hardcoded at the moment.
 	framedata->timer_fd = -1;
-	if (!(framedata->jb_impl = ast_jb_get_impl(AST_JB_FIXED))) {
+	if (!(framedata->jb_impl = ast_jb_get_impl(AST_JB_ADAPTIVE))) {
 		return -1;
 	}
 
@@ -80,22 +78,20 @@
 	ast_timer_set_rate(framedata->timer, 1000 / 20); //todohere move this to cb and check based on frame samples 
 
 	framedata->start_tv = ast_tvnow();
-	framedata->last_tv = framedata->start_tv;
-
 //todohere setup fake conf
-	framedata->jb_conf.max_size = 500;
-	framedata->jb_conf.resync_threshold = 2000;
-	ast_copy_string(framedata->jb_conf.impl, "fixed", sizeof(framedata->jb_conf.impl));
-	framedata->jb_conf.target_extra = 1000;
-
-	framedata->jb_obj = framedata->jb_impl->create(&framedata->jb_conf, 1000);
+	framedata->jb_conf.max_size = 1000;
+	framedata->jb_conf.resync_threshold = 4000;
+	ast_copy_string(framedata->jb_conf.impl, "adaptive", sizeof(framedata->jb_conf.impl));
+	framedata->jb_conf.target_extra = 2000;
+
+	framedata->jb_obj = framedata->jb_impl->create(&framedata->jb_conf, 4000);
 
 	return 0;
 }
 
 static void datastore_destroy_cb(void *data) {
 	ast_free(data);
-	ast_verb(1, "JITTERBUFFER datastore destroyed\n"); //todohere change to debug
+	ast_debug(1, "JITTERBUFFER datastore destroyed\n");
 }
 
 static const struct ast_datastore_info jb_datastore = {
@@ -105,7 +101,7 @@
 
 static void hook_destroy_cb(void *framedata)
 {
-	ast_verb(1, "JITTERBUFFER hook destroyed\n"); //todohere change to debug
+	ast_debug(1, "JITTERBUFFER hook destroyed\n");
 	jb_framedata_destroy((struct jb_framedata *) framedata);
 }
 
@@ -124,23 +120,28 @@
 		return frame;
 	}
 
+	if (chan->fdno == AST_JITTERBUFFER_FD && framedata->timer) {
+		ast_timer_ack(framedata->timer, 1);
+	}
+
+	if (!frame) {
+		return frame;
+	}
+
 	now_tv = ast_tvnow();
 	now = ast_tvdiff_ms(now_tv, framedata->start_tv);
 
-	if (chan->fdno == AST_JITTERBUFFER_FD && framedata->timer) {
-		ast_timer_ack(framedata->timer, 1);
-	}
-
-	if (!frame) {
-		return frame;
-	}
-
-	/* todohere add jb logic, just passing frame through right now. */
 	if (frame->frametype == AST_FRAME_VOICE) {
-
-		// ---todohere DEBUG 
-		framedata->jb_impl->put(framedata->jb_obj, frame, now);
-		printf("---> PUT\n");
+		int res;
+		long next;
+		struct ast_frame *jbframe = ast_frisolate(frame);
+		if (!framedata->first) {
+			framedata->first = 1;
+			res = framedata->jb_impl->put_first(framedata->jb_obj, jbframe, now);
+		} else {
+			res = framedata->jb_impl->put(framedata->jb_obj, jbframe, now);
+		}
+		next = framedata->jb_impl->next(framedata->jb_obj);
 		frame = &ast_null_frame;
 	}
 
@@ -151,22 +152,16 @@
 		if (now < next) {
 			return frame;
 		}
-		/* todohere may have to return multiple frames */
-
 		res = framedata->jb_impl->get(framedata->jb_obj, &frame, now, 20);
 		switch (res) {
 		case AST_JB_IMPL_OK:
-//			printf("----- diff: %lu now: %lu next: %lu\n", ast_tvdiff_ms(now_tv, framedata->last_tv), now, next);
-//			framedata->last_tv = now_tv;
-			printf("<--- get\n");
 			break;
 		case AST_JB_IMPL_DROP:
 			ast_frfree(frame);
 			frame = &ast_null_frame;
 			break;
 		case AST_JB_IMPL_INTERP:
-			/* todohere */
-			ast_log(LOG_NOTICE, "got interp frame err\n");
+			//todohere learn to handle dropped frames.
 			/* fall through */
 		case AST_JB_IMPL_NOFRAME:
 			frame = &ast_null_frame;




More information about the asterisk-commits mailing list