[asterisk-commits] branch group/rtpjitterbuffer r30963 - in /team/group/rtpjitterbuffer: ./ incl...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue May 30 15:24:12 MST 2006


Author: russell
Date: Tue May 30 17:24:12 2006
New Revision: 30963

URL: http://svn.digium.com/view/asterisk?rev=30963&view=rev
Log:
keep track of whether a jitter buffer is in use on either of the channels so
that when not in use, there is no extra function call overhead inside of the
loop in ast_generic_bridge

Modified:
    team/group/rtpjitterbuffer/abstract_jb.c
    team/group/rtpjitterbuffer/channel.c
    team/group/rtpjitterbuffer/include/asterisk/abstract_jb.h

Modified: team/group/rtpjitterbuffer/abstract_jb.c
URL: http://svn.digium.com/view/asterisk/team/group/rtpjitterbuffer/abstract_jb.c?rev=30963&r1=30962&r2=30963&view=diff
==============================================================================
--- team/group/rtpjitterbuffer/abstract_jb.c (original)
+++ team/group/rtpjitterbuffer/abstract_jb.c Tue May 30 17:24:12 2006
@@ -195,7 +195,7 @@
 	}
 }
 
-void ast_jb_do_usecheck(struct ast_channel *c0, struct ast_channel *c1)
+int ast_jb_do_usecheck(struct ast_channel *c0, struct ast_channel *c1)
 {
 	struct ast_jb *jb0 = &c0->jb;
 	struct ast_jb *jb1 = &c1->jb;
@@ -213,6 +213,7 @@
 	int c1_force_jb = ast_test_flag(conf1, AST_JB_FORCED);
 	int c1_jb_timebase_initialized = ast_test_flag(jb1, JB_TIMEBASE_INITIALIZED);
 	int c1_jb_created = ast_test_flag(jb1, JB_CREATED);
+	int inuse = 0;
 
 	/* Determine whether audio going to c0 needs a jitter buffer */
 	if (((!c0_wants_jitter && c1_creates_jitter) || (c0_force_jb && c1_creates_jitter)) && c0_jb_enabled) {
@@ -229,6 +230,8 @@
 		if (!c0_jb_created) {
 			jb_choose_impl(c0);
 		}
+
+		inuse = 1;
 	}
 	
 	/* Determine whether audio going to c1 needs a jitter buffer */
@@ -246,7 +249,11 @@
 		if (!c1_jb_created) {
 			jb_choose_impl(c1);
 		}
-	}
+
+		inuse = 1;
+	}
+
+	return inuse;
 }
 
 int ast_jb_get_when_to_wakeup(struct ast_channel *c0, struct ast_channel *c1, int time_left)
@@ -508,7 +515,7 @@
 	}
 
 	if (option_verbose > 2) 
-		ast_verbose(VERBOSE_PREFIX_3 "%s jitterbuffer created on channel %s", jbimpl->name, chan->name);
+		ast_verbose(VERBOSE_PREFIX_3 "%s jitterbuffer created on channel %s\n", jbimpl->name, chan->name);
 	
 	/* Free the frame if it has not been queued in the jb */
 	if (res != JB_IMPL_OK)
@@ -542,7 +549,7 @@
 		ast_clear_flag(jb, JB_CREATED);
 
 		if (option_verbose > 2)
-			ast_verbose(VERBOSE_PREFIX_3 "%s jitterbuffer destroyed on channel %s", jbimpl->name, chan->name);
+			ast_verbose(VERBOSE_PREFIX_3 "%s jitterbuffer destroyed on channel %s\n", jbimpl->name, chan->name);
 	}
 }
 

Modified: team/group/rtpjitterbuffer/channel.c
URL: http://svn.digium.com/view/asterisk/team/group/rtpjitterbuffer/channel.c?rev=30963&r1=30962&r2=30963&view=diff
==============================================================================
--- team/group/rtpjitterbuffer/channel.c (original)
+++ team/group/rtpjitterbuffer/channel.c Tue May 30 17:24:12 2006
@@ -3303,6 +3303,7 @@
 	void *pvt0, *pvt1;
 	/* Indicates whether a frame was queued into a jitterbuffer */
 	int frame_put_in_jb;
+	int jb_in_use;
 	int to;
 	
 	cs[0] = c0;
@@ -3315,7 +3316,7 @@
 	watch_c1_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_1;
 
 	/* Check the need of a jitterbuffer for each channel */
-	ast_jb_do_usecheck(c0, c1);
+	jb_in_use = ast_jb_do_usecheck(c0, c1);
 
 	for (;;) {
 		struct ast_channel *who, *other;
@@ -3337,11 +3338,13 @@
 			to = -1;
 		/* Calculate the appropriate max sleep interval - in general, this is the time,
 		   left to the closest jb delivery moment */
-		to = ast_jb_get_when_to_wakeup(c0, c1, to);
+		if (jb_in_use)
+			to = ast_jb_get_when_to_wakeup(c0, c1, to);
 		who = ast_waitfor_n(cs, 2, &to);
 		if (!who) {
 			/* No frame received within the specified timeout - check if we have to deliver now */
-			ast_jb_get_and_deliver(c0, c1);
+			if (jb_in_use)
+				ast_jb_get_and_deliver(c0, c1);
 			if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE || c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) {
 				if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE)
 					c0->_softhangup = 0;
@@ -3362,7 +3365,8 @@
 
 		other = (who == c0) ? c1 : c0; /* the 'other' channel */
 		/* Try add the frame info the who's bridged channel jitterbuff */
-		frame_put_in_jb = !ast_jb_put(other, f);
+		if (jb_in_use)
+			frame_put_in_jb = !ast_jb_put(other, f);
 
 		if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) {
 			int bridge_exit = 0;
@@ -3404,7 +3408,8 @@
 				ast_write(other, f);
 				
 			/* Check if we have to deliver now */
-			ast_jb_get_and_deliver(c0, c1);
+			if (jb_in_use)
+				ast_jb_get_and_deliver(c0, c1);
 		}
 		/* XXX do we want to pass on also frames not matched above ? */
 		ast_frfree(f);

Modified: team/group/rtpjitterbuffer/include/asterisk/abstract_jb.h
URL: http://svn.digium.com/view/asterisk/team/group/rtpjitterbuffer/include/asterisk/abstract_jb.h?rev=30963&r1=30962&r2=30963&view=diff
==============================================================================
--- team/group/rtpjitterbuffer/include/asterisk/abstract_jb.h (original)
+++ team/group/rtpjitterbuffer/include/asterisk/abstract_jb.h Tue May 30 17:24:12 2006
@@ -112,8 +112,10 @@
  * configuration and technology properties. As a result, this function sets
  * appropriate internal jb flags to the channels, determining further behaviour
  * of the bridged jitterbuffers.
- */
-void ast_jb_do_usecheck(struct ast_channel *c0, struct ast_channel *c1);
+ *
+ * \return zero if there are no jitter buffers in use, non-zero if there are
+ */
+int ast_jb_do_usecheck(struct ast_channel *c0, struct ast_channel *c1);
 
 
 /*!



More information about the asterisk-commits mailing list