[asterisk-commits] file: branch group/media_formats r408267 - in /team/group/media_formats: incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 17 07:41:01 CST 2014


Author: file
Date: Mon Feb 17 07:40:59 2014
New Revision: 408267

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=408267
Log:
Move abstract jitterbuffer over.

Modified:
    team/group/media_formats/include/asterisk/abstract_jb.h
    team/group/media_formats/main/abstract_jb.c

Modified: team/group/media_formats/include/asterisk/abstract_jb.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/abstract_jb.h?view=diff&rev=408267&r1=408266&r2=408267
==============================================================================
--- team/group/media_formats/include/asterisk/abstract_jb.h (original)
+++ team/group/media_formats/include/asterisk/abstract_jb.h Mon Feb 17 07:40:59 2014
@@ -145,7 +145,7 @@
 	/*! \brief The time the next frame should be played. */
 	long next;
 	/*! \brief Voice format of the last frame in. */
-	struct ast_format last_format;
+	struct ast_format *last_format;
 	/*! \brief File for frame timestamp tracing. */
 	FILE *logfile;
 	/*! \brief Jitterbuffer internal state flags. */

Modified: team/group/media_formats/main/abstract_jb.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/abstract_jb.c?view=diff&rev=408267&r1=408266&r2=408267
==============================================================================
--- team/group/media_formats/main/abstract_jb.c (original)
+++ team/group/media_formats/main/abstract_jb.c Mon Feb 17 07:40:59 2014
@@ -360,7 +360,7 @@
 	}
 
 	while (now >= jb->next) {
-		interpolation_len = ast_codec_interp_len(&jb->last_format);
+		interpolation_len = jb->last_format->codec->default_ms;
 
 		res = jbimpl->get(jbobj, &f, now, interpolation_len);
 
@@ -371,13 +371,14 @@
 		case AST_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);
-			ast_format_copy(&jb->last_format, &f->subclass.format);
+			ao2_ref(jb->last_format, -1);
+			jb->last_format = ast_format_copy(f->subclass.format);
 			ast_frfree(f);
 			break;
 		case AST_JB_IMPL_INTERP:
 			/* interpolate a frame */
 			f = &finterp;
-			ast_format_copy(&f->subclass.format, &jb->last_format);
+			f->subclass.format = jb->last_format;
 			f->samples  = interpolation_len * 8;
 			f->src  = "JB interpolation";
 			f->delivery = ast_tvadd(jb->timebase, ast_samp2tv(jb->next, 1000));
@@ -437,7 +438,7 @@
 	jb->next = jbimpl->next(jbobj);
 
 	/* Init last format for a first time. */
-	ast_format_copy(&jb->last_format, &frr->subclass.format);
+	jb->last_format = ast_format_copy(frr->subclass.format);
 
 	/* Create a frame log file */
 	if (ast_test_flag(jbconf, AST_JB_LOG)) {
@@ -501,6 +502,8 @@
 		fclose(jb->logfile);
 		jb->logfile = NULL;
 	}
+
+	ao2_cleanup(jb->last_format);
 
 	if (ast_test_flag(jb, JB_CREATED)) {
 		/* Remove and free all frames still queued in jb */
@@ -820,7 +823,7 @@
 	const struct ast_jb_impl *jb_impl;
 	struct ast_jb_conf jb_conf;
 	struct timeval start_tv;
-	struct ast_format last_format;
+	struct ast_format *last_format;
 	struct ast_timer *timer;
 	int timer_interval; /* ms between deliveries */
 	int timer_fd;
@@ -842,6 +845,7 @@
 		framedata->jb_impl->destroy(framedata->jb_obj);
 		framedata->jb_obj = NULL;
 	}
+	ao2_cleanup(framedata->last_format);
 	ast_free(framedata);
 }
 
@@ -909,7 +913,7 @@
 		}
 
 		jbframe = ast_frisolate(frame);
-		ast_format_copy(&framedata->last_format, &frame->subclass.format);
+		framedata->last_format = ast_format_copy(frame->subclass.format);
 
 		if (frame->len && (frame->len != framedata->timer_interval)) {
 			framedata->timer_interval = frame->len;
@@ -959,12 +963,12 @@
 			frame = &ast_null_frame;
 			break;
 		case AST_JB_IMPL_INTERP:
-			if (framedata->last_format.id) {
+			if (framedata->last_format) {
 				struct ast_frame tmp = { 0, };
 				tmp.frametype = AST_FRAME_VOICE;
-				ast_format_copy(&tmp.subclass.format, &framedata->last_format);
+				tmp.subclass.format = framedata->last_format;
 				/* example: 8000hz / (1000 / 20ms) = 160 samples */
-				tmp.samples = ast_format_rate(&framedata->last_format) / (1000 / framedata->timer_interval);
+				tmp.samples = framedata->last_format->codec->sample_rate / (1000 / framedata->timer_interval);
 				tmp.delivery = ast_tvadd(framedata->start_tv, ast_samp2tv(next, 1000));
 				tmp.offset = AST_FRIENDLY_OFFSET;
 				tmp.src  = "func_jitterbuffer interpolation";




More information about the asterisk-commits mailing list