[asterisk-commits] file: branch file/bridging r106998 - in /team/file/bridging: include/asterisk...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Mar 8 12:20:40 CST 2008
Author: file
Date: Sat Mar 8 12:20:39 2008
New Revision: 106998
URL: http://svn.digium.com/view/asterisk?view=rev&rev=106998
Log:
Add API calls to suspend/unsuspend a channel from the bridge. This essentially gives control of the channel to the calling thread.
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=106998&r1=106997&r2=106998
==============================================================================
--- team/file/bridging/include/asterisk/bridging.h (original)
+++ team/file/bridging/include/asterisk/bridging.h Sat Mar 8 12:20:39 2008
@@ -218,6 +218,20 @@
*/
int ast_bridge_merge(struct ast_bridge *bridge0, struct ast_bridge *bridge1);
+/*! \brief Suspend a channel temporarily from a bridge. Control will be given to the current thread.
+ * \param bridge Bridge to suspend the channel from
+ * \param chan Channel to suspend
+ * \param Returns 0 on success, -1 on failure
+ */
+int ast_bridge_suspend(struct ast_bridge *bridge, struct ast_channel *chan);
+
+/*! \brief Unsuspend a channel from a bridge.
+ * \param bridge Bridge to unsuspend the channel from
+ * \param chan Channel to unsuspend
+ * \param Returns 0 on success, -1 on failure
+ */
+int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan);
+
/*! \brief Suspend a bridge technology from consideration
* \param technology The bridge technology to suspend
*/
Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=106998&r1=106997&r2=106998
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Sat Mar 8 12:20:39 2008
@@ -1260,6 +1260,64 @@
return 0;
}
+/*! \brief Suspend a channel temporarily from a bridge. Control will be given to the current thread.
+ * \param bridge Bridge to suspend the channel from
+ * \param chan Channel to suspend
+ * \param Returns 0 on success, -1 on failure
+ */
+int ast_bridge_suspend(struct ast_bridge *bridge, struct ast_channel *chan)
+{
+ struct ast_bridge_channel *bridge_channel = NULL;
+
+ ast_mutex_lock(&bridge->lock);
+
+ /* Locate the channel we want to suspend */
+ if (!(bridge_channel = find_bridge_channel(bridge, chan))) {
+ ast_mutex_unlock(&bridge->lock);
+ return -1;
+ }
+
+ /* It's rather easy to suspend a channel, we just set a variable */
+ bridge_channel->suspended = 1;
+
+ /* Of course the real fun comes from making sure this variable has been respected... for that we get the bridge to rebuild. */
+ ast_bridge_rebuild(bridge);
+
+ ast_mutex_unlock(&bridge->lock);
+
+ /* Since the caller of this function wants control we have to be sure that we have it, so wait around until the bridge thread respects our above rebuild. */
+ while (bridge->rebuild)
+ usleep(1);
+
+ return 0;
+}
+
+/*! \brief Unsuspend a channel from a bridge.
+ * \param bridge Bridge to unsuspend the channel from
+ * \param chan Channel to unsuspend
+ * \param Returns 0 on success, -1 on failure
+ */
+int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan)
+{
+ struct ast_bridge_channel *bridge_channel = NULL;
+
+ /* Locate the channel we want to unsuspend */
+ if (!(bridge_channel = find_bridge_channel(bridge, chan))) {
+ ast_mutex_unlock(&bridge->lock);
+ return -1;
+ }
+
+ bridge_channel->suspended = 0;
+
+ ast_bridge_rebuild(bridge);
+
+ ast_mutex_unlock(&bridge->lock);
+
+ /* Unlike above we don't need to wait around as the caller of this function *should not* be touching the channel after they call this. */
+
+ return 0;
+}
+
/*! \brief Suspend a bridge technology from consideration
* \param technology The bridge technology to suspend
*/
More information about the asterisk-commits
mailing list