[asterisk-commits] rmudgett: branch rmudgett/bridge_phase r381895 - in /team/rmudgett/bridge_pha...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Feb 22 13:50:30 CST 2013
Author: rmudgett
Date: Fri Feb 22 13:50:26 2013
New Revision: 381895
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381895
Log:
Add bridge action queue support stubs.
Modified:
team/rmudgett/bridge_phase/include/asterisk/bridging.h
team/rmudgett/bridge_phase/main/bridging.c
Modified: team/rmudgett/bridge_phase/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/include/asterisk/bridging.h?view=diff&rev=381895&r1=381894&r2=381895
==============================================================================
--- team/rmudgett/bridge_phase/include/asterisk/bridging.h (original)
+++ team/rmudgett/bridge_phase/include/asterisk/bridging.h Fri Feb 22 13:50:26 2013
@@ -264,6 +264,8 @@
AST_LIST_HEAD_NOLOCK(, ast_bridge_channel) channels;
/*! Linked list of channels removed from the bridge and waiting to be departed. */
AST_LIST_HEAD_NOLOCK(, ast_bridge_channel) depart_wait;
+ /*! Queue of actions to perform on the bridge. */
+ AST_LIST_HEAD_NOLOCK(, ast_frame) action_queue;
};
/*!
@@ -585,6 +587,21 @@
void ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
/*!
+ * \brief Put an action onto the specified bridge.
+ * \since 12.0.0
+ *
+ * \param bridge What to queue the action on.
+ * \param action What to do.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ *
+ * \note This API call is meant for internal bridging operations.
+ * \note BUGBUG This may get moved.
+ */
+int ast_bridge_queue_action(struct ast_bridge *bridge, struct ast_frame *action);
+
+/*!
* \brief Put an action onto the specified bridge_channel.
* \since 12.0.0
*
Modified: team/rmudgett/bridge_phase/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/bridging.c?view=diff&rev=381895&r1=381894&r2=381895
==============================================================================
--- team/rmudgett/bridge_phase/main/bridging.c (original)
+++ team/rmudgett/bridge_phase/main/bridging.c Fri Feb 22 13:50:26 2013
@@ -165,6 +165,26 @@
ao2_lock(bridge_channel);
ast_bridge_change_state_nolock(bridge_channel, new_state);
ao2_unlock(bridge_channel);
+}
+
+int ast_bridge_queue_action(struct ast_bridge *bridge, struct ast_frame *action)
+{
+ struct ast_frame *dup;
+
+ dup = ast_frdup(action);
+ if (!dup) {
+ return -1;
+ }
+
+ ast_debug(1, "BUGBUG Queueing action type:%d sub:%d on bridge %p\n",
+ action->frametype, action->subclass.integer, bridge);
+
+ ao2_lock(bridge);
+ AST_LIST_INSERT_TAIL(&bridge->action_queue, dup, frame_list);
+ bridge->interrupt = 1;
+ ast_bridge_poke(bridge);
+ ao2_unlock(bridge);
+ return 0;
}
int ast_bridge_channel_queue_action(struct ast_bridge_channel *bridge_channel, struct ast_frame *action)
@@ -763,6 +783,23 @@
}
/*!
+ * \internal
+ * \brief Handle bridge action frame.
+ * \since 12.0.0
+ *
+ * \param bridge What to execute the action on.
+ * \param action What to do.
+ *
+ * \note This function assumes the bridge is locked.
+ *
+ * \return Nothing
+ */
+static void bridge_action_bridge(struct ast_bridge *bridge, struct ast_frame *action)
+{
+ /*! \todo BUGBUG bridge_action() not written */
+}
+
+/*!
* \brief Bridge thread function
*
* \note The thread does not have its own reference to the
@@ -772,6 +809,7 @@
static void *bridge_thread(void *data)
{
struct ast_bridge *bridge = data;
+ struct ast_frame *action;
int res = 0;
if (bridge->callid) {
@@ -797,7 +835,21 @@
bridge_complete_join(bridge);
}
-/* BUGBUG process the bridge action queue here. */
+ /* Run a pending bridge action. */
+ action = AST_LIST_REMOVE_HEAD(&bridge->action_queue, frame_list);
+ if (action) {
+ switch (action->frametype) {
+ case AST_FRAME_BRIDGE_ACTION:
+ bridge_action_bridge(bridge, action);
+ break;
+ default:
+ /* Unexpected deferred frame type. Should never happen. */
+ ast_assert(0);
+ break;
+ }
+ ast_frfree(action);
+ continue;
+ }
if (!bridge->array_num || !bridge->technology->thread_loop) {
/* Wait for something to happen to the bridge. */
@@ -864,6 +916,7 @@
static void destroy_bridge(void *obj)
{
struct ast_bridge *bridge = obj;
+ struct ast_frame *action;
ast_debug(1, "Actually destroying bridge %p, nobody wants it anymore\n", bridge);
@@ -879,6 +932,11 @@
if (bridge->callid) {
bridge->callid = ast_callid_unref(bridge->callid);
+ }
+
+ /* Flush any unhandled actions. */
+ while ((action = AST_LIST_REMOVE_HEAD(&bridge->action_queue, frame_list))) {
+ ast_frfree(action);
}
cleanup_video_mode(bridge);
@@ -1451,7 +1509,7 @@
/*!
* \internal
- * \brief Handle bridge action.
+ * \brief Handle bridge channel bridge action frame.
* \since 12.0.0
*
* \param bridge_channel Channel to execute the action on.
@@ -1499,7 +1557,7 @@
/*!
* \internal
- * \brief Handle control frame action.
+ * \brief Handle bridge channel control frame action.
* \since 12.0.0
*
* \param bridge_channel Channel to execute the control frame action on.
@@ -1596,7 +1654,7 @@
ao2_lock(bridge_channel->bridge);
break;
default:
- /* Unexpected deferred frame type. Sould never happen. */
+ /* Unexpected deferred frame type. Should never happen. */
ast_assert(0);
break;
}
More information about the asterisk-commits
mailing list