[asterisk-commits] file: branch file/bridging r161570 - in /team/file/bridging: include/asterisk...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Dec 7 14:40:43 CST 2008
Author: file
Date: Sun Dec 7 14:40:42 2008
New Revision: 161570
URL: http://svn.digium.com/view/asterisk?view=rev&rev=161570
Log:
Make bridge_change_state a public API call so that callbacks can use it to change the state of the channel.
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=161570&r1=161569&r2=161570
==============================================================================
--- team/file/bridging/include/asterisk/bridging.h (original)
+++ team/file/bridging/include/asterisk/bridging.h Sun Dec 7 14:40:42 2008
@@ -548,6 +548,26 @@
*/
int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan);
+/*! \brief Change the state of a bridged channel
+ *
+ * \param bridge_channel Channel to change the state on
+ * \param new_state The new state to place the channel into
+ *
+ * Example usage:
+ *
+ * \code
+ * ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
+ * \endcode
+ *
+ * This places the channel pointed to by bridge_channel into the state
+ * AST_BRIDGE_CHANNEL_STATE_WAIT.
+ *
+ * \note This API call is only meant to be used in feature hook callbacks to
+ * make sure the channel either hangs up or returns to the bridge.
+ */
+void ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
+
+
/*! \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=161570&r1=161569&r2=161570
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Sun Dec 7 14:40:42 2008
@@ -112,8 +112,7 @@
return current ? 0 : -1;
}
-/*! \brief Helper function to change the state of a bridge channel and poke the thread handling it */
-static int bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state)
+void ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state)
{
/* Change the state on the bridge channel */
bridge_channel->state = new_state;
@@ -131,7 +130,7 @@
ast_mutex_unlock(&bridge_channel->lock);
}
- return 0;
+ return;
}
/*! \brief Helper function to poke the bridge thread */
@@ -219,7 +218,7 @@
AST_LIST_TRAVERSE(&bridge->channels, bridge_channel2, entry) {
if (bridge_channel2->state != AST_BRIDGE_CHANNEL_STATE_END && bridge_channel2->state != AST_BRIDGE_CHANNEL_STATE_DEPART)
- bridge_change_state(bridge_channel2, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+ ast_bridge_change_state(bridge_channel2, AST_BRIDGE_CHANNEL_STATE_HANGUP);
}
/* Since all the channels are going away let's go ahead and stop our on thread */
@@ -243,7 +242,7 @@
if (hook->dtmf[0] == frame->subclass) {
ast_frfree(frame);
frame = NULL;
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_FEATURE);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_FEATURE);
break;
}
}
@@ -264,7 +263,7 @@
/* This is pretty simple... see if they hung up */
if (!frame || (frame->frametype == AST_FRAME_CONTROL && frame->subclass == AST_CONTROL_HANGUP)) {
/* Signal the thread that is handling the bridged channel that it should be ended */
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
} else if (frame->frametype == AST_FRAME_CONTROL && frame->subclass == AST_CONTROL_ANSWER) {
ast_debug(1, "Dropping answer frame from bridge channel %p\n", bridge_channel);
} else {
@@ -471,7 +470,7 @@
/* Drop every bridged channel, the last one will cause the bridge thread (if it exists) to exit */
AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
}
ao2_unlock(bridge);
@@ -744,7 +743,7 @@
hook->callback(bridge, bridge_channel, hook->hook_pvt);
} else {
ast_bridge_dtmf_stream(bridge, dtmf, bridge_channel->chan);
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
}
return;
@@ -761,7 +760,7 @@
ast_debug(1, "Playing DTMF stream '%s' out to bridge channel %p\n", dtmf_q, bridge_channel);
ast_dtmf_stream(bridge_channel->chan, NULL, dtmf_q, 250, 0);
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
return;
}
@@ -793,7 +792,7 @@
/* If we are performing a swap operation we do not need to execute the smart bridge operation as the actual number of channels involved will not have changed, we just need to tell the other channel to leave */
if ((bridge_channel2 = find_bridge_channel(bridge_channel->bridge, bridge_channel->swap))) {
ast_debug(1, "Swapping bridge channel %p out from bridge %p so bridge channel %p can slip in\n", bridge_channel2, bridge_channel->bridge, bridge_channel);
- bridge_change_state(bridge_channel2, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+ ast_bridge_change_state(bridge_channel2, AST_BRIDGE_CHANNEL_STATE_HANGUP);
}
bridge_channel->swap = NULL;
@@ -984,7 +983,7 @@
return -1;
}
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DEPART);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DEPART);
thread = bridge_channel->thread;
ao2_unlock(bridge);
@@ -1006,7 +1005,7 @@
return -1;
}
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
ao2_unlock(bridge);
@@ -1222,14 +1221,14 @@
/* Grab the extension to transfer to */
if (!grab_transfer(bridge_channel->chan, exten, sizeof(exten), bridge_channel->chan->context)) {
ast_stream_and_wait(bridge_channel->chan, "pbx-invalid", AST_DIGIT_ANY);
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
return 0;
}
/* Get a channel that is the destination we wish to call */
if (!(chan = dial_transfer(bridge_channel->chan, exten, bridge_channel->chan->context))) {
ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_ANY);
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
return 0;
}
@@ -1243,7 +1242,7 @@
static int attended_threeway_transfer(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
{
/* This is sort of abusing the depart state but in this instance it is only going to be handled in the below function so it is okay */
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DEPART);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DEPART);
return 0;
}
@@ -1254,14 +1253,14 @@
/* It is possible (albeit unlikely) that the bridge channels list may change, so we have to ensure we do all of our magic while locked */
if (!(called_bridge_channel = (AST_LIST_FIRST(&bridge->channels) != bridge_channel ? AST_LIST_FIRST(&bridge->channels) : AST_LIST_LAST(&bridge->channels)))) {
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
return 0;
}
/* Now we basically eject the other channel from the bridge. This will cause their thread to hang them up, and our own code to consider the transfer failed. */
- bridge_change_state(called_bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
-
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+ ast_bridge_change_state(called_bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
return 0;
}
@@ -1278,14 +1277,14 @@
/* Grab the extension to transfer to */
if (!grab_transfer(bridge_channel->chan, exten, sizeof(exten), bridge_channel->chan->context)) {
ast_stream_and_wait(bridge_channel->chan, "pbx-invalid", AST_DIGIT_ANY);
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
return 0;
}
/* Get a channel that is the destination we wish to call */
if (!(chan = dial_transfer(bridge_channel->chan, exten, bridge_channel->chan->context))) {
ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_ANY);
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
return 0;
}
@@ -1293,7 +1292,7 @@
if (!(attended_bridge = ast_bridge_new(AST_BRIDGE_CAPABILITY_1TO1MIX, 0))) {
ast_hangup(chan);
ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_ANY);
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
return 0;
}
@@ -1327,7 +1326,7 @@
}
} else {
ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_ANY);
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
}
/* Now that all channels are out of it we can destroy the bridge and the called features structure */
@@ -1341,7 +1340,7 @@
static int feature_hangup(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
{
/* This is very simple, we basically change the state on the bridge channel to end and the core takes care of the rest */
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
return 0;
}
@@ -1414,7 +1413,7 @@
if (bridge_channel->chan == chan)
continue;
ast_copy_string(bridge_channel->dtmf_stream_q, dtmf, sizeof(bridge_channel->dtmf_stream_q));
- bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DTMF);
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DTMF);
}
ao2_unlock(bridge);
More information about the asterisk-commits
mailing list