[asterisk-commits] mmichelson: trunk r135851 - in /trunk: ./ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 5 19:30:54 CDT 2008


Author: mmichelson
Date: Tue Aug  5 19:30:53 2008
New Revision: 135851

URL: http://svn.digium.com/view/asterisk?view=rev&rev=135851
Log:
Merged revisions 135841,135847,135850 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r135841 | mmichelson | 2008-08-05 19:25:10 -0500 (Tue, 05 Aug 2008) | 27 lines

Merging the issue11259 branch.

The purpose of this branch was to take into account
"burps" which could cause jitterbuffers to misbehave.
One such example is if the L option to Dial() were used
to inject audio into a bridged conversation at regular
intervals. Since the audio here was not passed through
the jitterbuffer, it would cause a gap in the jitterbuffer's
timestamps which would cause a frames to be dropped for a 
brief period.

Now ast_generic_bridge will empty and reset the jitterbuffer
each time it is called. This causes injected audio to be handled
properly.

ast_generic_bridge also will empty and reset the jitterbuffer
if it receives an AST_CONTROL_SRCUPDATE frame since the change
in audio source could negatively affect the jitterbuffer.

All of this was made possible by adding a new public API call
to the abstract_jb called ast_jb_empty_and_reset.

(closes issue #11259)
Reported by: plack
Tested by: putnopvut


........
r135847 | mmichelson | 2008-08-05 19:27:54 -0500 (Tue, 05 Aug 2008) | 4 lines

Revert inadvertent changes to app_skel that occurred when
I was testing for a memory leak


........
r135850 | mmichelson | 2008-08-05 19:29:54 -0500 (Tue, 05 Aug 2008) | 3 lines

Remove properties that should not be here


........

Modified:
    trunk/   (props changed)
    trunk/include/asterisk/abstract_jb.h
    trunk/main/abstract_jb.c
    trunk/main/channel.c
    trunk/main/fixedjitterbuf.h

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/include/asterisk/abstract_jb.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/abstract_jb.h?view=diff&rev=135851&r1=135850&r2=135851
==============================================================================
--- trunk/include/asterisk/abstract_jb.h (original)
+++ trunk/include/asterisk/abstract_jb.h Tue Aug  5 19:30:53 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: trunk/main/abstract_jb.c
URL: http://svn.digium.com/view/asterisk/trunk/main/abstract_jb.c?view=diff&rev=135851&r1=135850&r2=135851
==============================================================================
--- trunk/main/abstract_jb.c (original)
+++ trunk/main/abstract_jb.c Tue Aug  5 19:30:53 2008
@@ -67,7 +67,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.
@@ -83,6 +84,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 */
@@ -95,6 +97,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);
@@ -104,6 +107,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[] = 
@@ -117,7 +121,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",
@@ -128,7 +133,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,
 	}
 };
 
@@ -223,7 +229,7 @@
 			}
 			ast_set_flag(jb0, JB_TIMEBASE_INITIALIZED);
 		}
-		
+	
 		if (!c0_jb_created) {
 			jb_choose_impl(c0);
 		}
@@ -603,21 +609,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)
 {
@@ -691,6 +712,15 @@
 	fixed_jb_set_force_resynch(fixedjb);
 }
 
+static void jb_empty_and_reset_fixed(void *jb)
+{
+	struct fixed_jb *fixedjb = jb;
+	struct fixed_jb_frame f;
+
+	while (fixed_jb_remove(fixedjb, &f) == FIXED_JB_OK) {
+		ast_frfree(f.data);
+	}
+}
 
 /* adaptive */
 
@@ -773,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;
+
+	while (jb_getall(adaptivejb, &f) == JB_OK) {
+		ast_frfree(f.data);
+	}
+
+	jb_reset(adaptivejb);
+}

Modified: trunk/main/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/main/channel.c?view=diff&rev=135851&r1=135850&r2=135851
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Tue Aug  5 19:30:53 2008
@@ -4159,6 +4159,8 @@
 
 	/* Check the need of a jitterbuffer for each channel */
 	jb_in_use = ast_jb_do_usecheck(c0, c1);
+	if (jb_in_use)
+		ast_jb_empty_and_reset(c0, c1);
 
 	ast_poll_channel_add(c0, c1);
 
@@ -4224,6 +4226,9 @@
 			case AST_CONTROL_VIDUPDATE:
 			case AST_CONTROL_SRCUPDATE:
 				ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen);
+				if (jb_in_use) {
+					ast_jb_empty_and_reset(c0, c1);
+				}
 				break;
 			default:
 				*fo = f;

Modified: trunk/main/fixedjitterbuf.h
URL: http://svn.digium.com/view/asterisk/trunk/main/fixedjitterbuf.h?view=diff&rev=135851&r1=135850&r2=135851
==============================================================================
--- trunk/main/fixedjitterbuf.h (original)
+++ trunk/main/fixedjitterbuf.h Tue Aug  5 19:30:53 2008
@@ -85,7 +85,6 @@
 
 void fixed_jb_set_force_resynch(struct fixed_jb *jb);
 
-
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif




More information about the asterisk-commits mailing list