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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Mar 8 11:16:19 CST 2008


Author: file
Date: Sat Mar  8 11:16:19 2008
New Revision: 106995

URL: http://svn.digium.com/view/asterisk?view=rev&rev=106995
Log:
Add an API call that allows an outside influence to remove a channel from a bridge.

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

Modified: team/file/bridging/include/asterisk/bridging.h
URL: http://svn.digium.com/view/asterisk/team/file/bridging/include/asterisk/bridging.h?view=diff&rev=106995&r1=106994&r2=106995
==============================================================================
--- team/file/bridging/include/asterisk/bridging.h (original)
+++ team/file/bridging/include/asterisk/bridging.h Sat Mar  8 11:16:19 2008
@@ -191,6 +191,13 @@
  */
 int ast_bridge_depart(struct ast_bridge *bridge, struct ast_channel *chan);
 
+/*! \brief Remove a channel from a bridge
+ * \param bridge Bridge that the channel is to be removed from
+ * \param chan Channel to remove
+ * \return Returns 0 on success, -1 on failure
+ */
+int ast_bridge_remove(struct ast_bridge *bridge, struct ast_channel *chan);
+
 /*! \brief Change the state of a bridge channel
  * \param bridge_channel Bridge channel
  * \param new_state State to change to

Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=106995&r1=106994&r2=106995
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Sat Mar  8 11:16:19 2008
@@ -1096,6 +1096,37 @@
 	return 0;
 }
 
+/*! \brief Remove a channel from a bridge
+ * \param bridge Bridge that the channel is to be removed from
+ * \param chan Channel to remove
+ * \return Returns 0 on success, -1 on failure
+ */
+int ast_bridge_remove(struct ast_bridge *bridge, struct ast_channel *chan)
+{
+	struct ast_bridge_channel *bridge_channel = NULL;
+
+	ast_mutex_lock(&bridge->lock);
+
+	/* Try to find the specific channel we want to remove, and make sure it is in a state where we can */
+	if (!(bridge_channel = find_bridge_channel(bridge, chan)) || (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_HANGUP || bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_DEPART)) {
+		ast_mutex_unlock(&bridge->lock);
+		return -1;
+	}
+
+	/* Now that we have the channel we just change their state to hangup. This will cause the bridge thread to no longer care about them once rebuilt. */
+	ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+
+	/* Of course the above action could have caused the actual bridge to dissolve, if so we need to take care of it */
+	bridge_check_dissolve(bridge, bridge_channel);
+
+	/* Finally once all of the above is done we need to rebuild the bridge, as this channel is going bye bye. */
+	ast_bridge_rebuild(bridge);
+
+	ast_mutex_unlock(&bridge->lock);
+
+	return 0;
+}
+
 /*! \brief Change the state of a bridge channel
  * \param bridge_channel Bridge channel
  * \param new_state State to change to




More information about the asterisk-commits mailing list