[asterisk-commits] file: branch file/bridging r177693 - in /team/file/bridging: bridges/ include...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 20 12:54:34 CST 2009


Author: file
Date: Fri Feb 20 12:54:34 2009
New Revision: 177693

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=177693
Log:
Add two API calls for bridging technologies that tells them when control of a bridge channel is no longer theirs and when it returns. Use this in bridge_multiplexed to manipulate the multiplexed thread structure.

Modified:
    team/file/bridging/bridges/bridge_multiplexed.c
    team/file/bridging/include/asterisk/bridging_technology.h
    team/file/bridging/main/bridging.c

Modified: team/file/bridging/bridges/bridge_multiplexed.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/bridging/bridges/bridge_multiplexed.c?view=diff&rev=177693&r1=177692&r2=177693
==============================================================================
--- team/file/bridging/bridges/bridge_multiplexed.c (original)
+++ team/file/bridging/bridges/bridge_multiplexed.c Fri Feb 20 12:54:34 2009
@@ -258,18 +258,28 @@
 	return 0;
 }
 
-/*! \brief Poke function which notifies us of bridged channel state changes */
-static int multiplexed_bridge_poke(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
-{
-	struct multiplexed_thread *multiplexed_thread = bridge->bridge_pvt;
-
-	if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
-		multiplexed_add_or_remove(multiplexed_thread, bridge_channel->chan, 1);
-	} else if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_FEATURE || bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_DTMF) {
-		multiplexed_add_or_remove(multiplexed_thread, bridge_channel->chan, 0);
-	}
-
-	return 0;
+/*! \brief Suspend function which means control of the channel is going elsewhere */
+static void multiplexed_bridge_suspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	struct multiplexed_thread *multiplexed_thread = bridge->bridge_pvt;
+
+	ast_debug(1, "Suspending channel '%s' from multiplexed thread '%p'\n", bridge_channel->chan->name, multiplexed_thread);
+
+	multiplexed_add_or_remove(multiplexed_thread, bridge_channel->chan, 0);
+
+	return;
+}
+
+/*! \brief Unsuspend function which means control of the channel is coming back to us */
+static void multiplexed_bridge_unsuspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	struct multiplexed_thread *multiplexed_thread = bridge->bridge_pvt;
+
+	ast_debug(1, "Unsuspending channel '%s' from multiplexed thread '%p'\n", bridge_channel->chan->name, multiplexed_thread);
+
+	multiplexed_add_or_remove(multiplexed_thread, bridge_channel->chan, 1);
+
+	return;
 }
 
 /*! \brief Write function for writing frames into the bridge */
@@ -301,7 +311,8 @@
 	.destroy = multiplexed_bridge_destroy,
 	.join = multiplexed_bridge_join,
 	.leave = multiplexed_bridge_leave,
-	.poke = multiplexed_bridge_poke,
+	.suspend = multiplexed_bridge_suspend,
+	.unsuspend = multiplexed_bridge_unsuspend,
 	.write = multiplexed_bridge_write,
 };
 

Modified: team/file/bridging/include/asterisk/bridging_technology.h
URL: http://svn.digium.com/svn-view/asterisk/team/file/bridging/include/asterisk/bridging_technology.h?view=diff&rev=177693&r1=177692&r2=177693
==============================================================================
--- team/file/bridging/include/asterisk/bridging_technology.h (original)
+++ team/file/bridging/include/asterisk/bridging_technology.h Fri Feb 20 12:54:34 2009
@@ -56,6 +56,12 @@
 	int (*join)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
 	/*! Callback for when a channel is leaving a bridge */
 	int (*leave)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
+	/*! Callback for when a channel is suspended from the bridge */
+	void (*suspend)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
+	/*! Callback for when a channel is unsuspended from the bridge */
+	void (*unsuspend)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
+	/*! Callback to see if a channel is compatible with the bridging technology */
+	int (*compatible)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
 	/*! Callback for writing a frame into the bridging technology */
 	enum ast_bridge_write_result (*write)(struct ast_bridge *bridge, struct ast_bridge_channel *bridged_channel, struct ast_frame *frame);
 	/*! Callback for when a file descriptor trips */

Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=177693&r1=177692&r2=177693
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Fri Feb 20 12:54:34 2009
@@ -120,11 +120,6 @@
 	/* Change the state on the bridge channel */
 	bridge_channel->state = new_state;
 
-	/* Poke the bridge technology as well if it wants to know about this */
-	if (bridge_channel->bridge->technology->poke) {
-		bridge_channel->bridge->technology->poke(bridge_channel->bridge, bridge_channel);
-	}
-
 	/* Only poke the channel's thread if it is not us */
 	if (!pthread_equal(pthread_self(), bridge_channel->thread)) {
 		pthread_kill(bridge_channel->thread, SIGURG);
@@ -730,6 +725,34 @@
 	return bridge_channel->state;
 }
 
+/*! \brief Internal function that suspends a channel from a bridge */
+static void bridge_channel_suspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	bridge_channel->suspended = 1;
+
+	bridge_array_remove(bridge, bridge_channel->chan);
+
+	if (bridge->technology->suspend) {
+		bridge->technology->suspend(bridge, bridge_channel);
+	}
+
+	return;
+}
+
+/*! \brief Internal function that unsuspends a channel from a bridge */
+static void bridge_channel_unsuspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	bridge_channel->suspended =0;
+
+	bridge_array_add(bridge, bridge_channel->chan);
+
+	if (bridge->technology->unsuspend) {
+		bridge->technology->unsuspend(bridge, bridge_channel);
+	}
+
+	return;
+}
+
 /*! \brief Internal function that executes a feature on a bridge channel */
 static void bridge_channel_feature(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
 {
@@ -878,13 +901,13 @@
 		state = (bridge_channel->bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_MULTITHREADED ? bridge_channel_join_multithreaded(bridge_channel) : bridge_channel_join_singlethreaded(bridge_channel));
 		/* Depending on the above state see what we need to do */
 		if (state == AST_BRIDGE_CHANNEL_STATE_FEATURE) {
-			bridge_array_remove(bridge_channel->bridge, bridge_channel->chan);
+			bridge_channel_suspend(bridge_channel->bridge, bridge_channel);
 			bridge_channel_feature(bridge_channel->bridge, bridge_channel);
-			bridge_array_add(bridge_channel->bridge, bridge_channel->chan);
+			bridge_channel_unsuspend(bridge_channel->bridge, bridge_channel);
 		} else if (state == AST_BRIDGE_CHANNEL_STATE_DTMF) {
-			bridge_array_remove(bridge_channel->bridge, bridge_channel->chan);
+			bridge_channel_suspend(bridge_channel->bridge, bridge_channel);
 			bridge_channel_dtmf_stream(bridge_channel->bridge, bridge_channel);
-			bridge_array_add(bridge_channel->bridge, bridge_channel->chan);
+			bridge_channel_unsuspend(bridge_channel->bridge, bridge_channel);
 		}
 	}
 
@@ -1151,9 +1174,7 @@
 		return -1;
 	}
 
-	bridge_channel->suspended = 1;
-
-	bridge_array_remove(bridge, chan);
+	bridge_channel_suspend(bridge, bridge_channel);
 
 	ao2_unlock(bridge);
 
@@ -1171,9 +1192,7 @@
 		return -1;
 	}
 
-	bridge_channel->suspended = 0;
-
-	bridge_array_add(bridge, chan);
+	bridge_channel_unsuspend(bridge, bridge_channel);
 
 	ao2_unlock(bridge);
 




More information about the asterisk-commits mailing list