[asterisk-commits] rmudgett: branch group/bridge_construction r384297 - in /team/group/bridge_co...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 28 14:01:50 CDT 2013
Author: rmudgett
Date: Thu Mar 28 14:01:47 2013
New Revision: 384297
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384297
Log:
Add AST_CONTROL_SRCCHANGE and AST_CONTROL_SRCUPDATE support.
* Add AST_CONTROL_SRCCHANGE events to a channel when it joins/leaves a bridge
and when the softmix bridging technology is activated on the bridge.
* Added some NULL pointer checks to the softmix bridge.
* Added AST_CONTROL_SRCUPDATE events when a channel handles DTMF features,
interval hooks, and DTMF streaming because the internal Asterisk media
source may be changing.
Modified:
team/group/bridge_construction/bridges/bridge_softmix.c
team/group/bridge_construction/main/bridging.c
Modified: team/group/bridge_construction/bridges/bridge_softmix.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/bridges/bridge_softmix.c?view=diff&rev=384297&r1=384296&r2=384297
==============================================================================
--- team/group/bridge_construction/bridges/bridge_softmix.c (original)
+++ team/group/bridge_construction/bridges/bridge_softmix.c Thu Mar 28 14:01:47 2013
@@ -366,19 +366,47 @@
/*! \brief Function called when a channel is unsuspended from the bridge */
static void softmix_bridge_unsuspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
{
- softmix_poke_thread(bridge->tech_pvt);
+ if (bridge->tech_pvt) {
+ softmix_poke_thread(bridge->tech_pvt);
+ }
+}
+
+/*!
+ * \internal
+ * \brief Indicate a source change to the channel.
+ * \since 12.0.0
+ *
+ * \param bridge_channel Which channel source is changing.
+ *
+ * \return Nothing
+ */
+static void softmix_src_change(struct ast_bridge_channel *bridge_channel)
+{
+ struct ast_frame frame = {
+ .frametype = AST_FRAME_CONTROL,
+ .subclass.integer = AST_CONTROL_SRCCHANGE
+ };
+
+ ast_bridge_channel_queue_frame(bridge_channel, &frame);
}
/*! \brief Function called when a channel is joined into the bridge */
static int softmix_bridge_join(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
{
struct softmix_channel *sc;
- struct softmix_bridge_data *softmix_data = bridge->tech_pvt;
+ struct softmix_bridge_data *softmix_data;
+
+ softmix_data = bridge->tech_pvt;
+ if (!softmix_data) {
+ return -1;
+ }
/* Create a new softmix_channel structure and allocate various things on it */
if (!(sc = ast_calloc(1, sizeof(*sc)))) {
return -1;
}
+
+ softmix_src_change(bridge_channel);
/* Can't forget the lock */
ast_mutex_init(&sc->lock);
@@ -405,6 +433,8 @@
return;
}
bridge_channel->tech_pvt = NULL;
+
+ softmix_src_change(bridge_channel);
/* Drop mutex lock */
ast_mutex_destroy(&sc->lock);
@@ -621,6 +651,10 @@
static int softmix_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
{
int res = 0;
+
+ if (!bridge->tech_pvt || !bridge_channel->tech_pvt) {
+ return -1;
+ }
switch (frame->frametype) {
case AST_FRAME_DTMF_BEGIN:
Modified: team/group/bridge_construction/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/bridging.c?view=diff&rev=384297&r1=384296&r2=384297
==============================================================================
--- team/group/bridge_construction/main/bridging.c (original)
+++ team/group/bridge_construction/main/bridging.c Thu Mar 28 14:01:47 2013
@@ -1658,17 +1658,23 @@
switch (action->subclass.integer) {
case AST_BRIDGE_ACTION_INTERVAL:
bridge_channel_suspend(bridge_channel);
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
bridge_channel_interval(bridge_channel);
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
bridge_channel_unsuspend(bridge_channel);
break;
case AST_BRIDGE_ACTION_FEATURE:
bridge_channel_suspend(bridge_channel);
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
bridge_channel_feature(bridge_channel);
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
bridge_channel_unsuspend(bridge_channel);
break;
case AST_BRIDGE_ACTION_DTMF_STREAM:
bridge_channel_suspend(bridge_channel);
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
bridge_channel_dtmf_stream(bridge_channel, action->data.ptr);
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
bridge_channel_unsuspend(bridge_channel);
break;
case AST_BRIDGE_ACTION_TALKING_START:
@@ -1919,6 +1925,16 @@
ast_bridge_channel_push(bridge_channel);
ast_bridge_reconfigured(bridge_channel->bridge);
+ /*
+ * Indicate a source change since this channel is entering the
+ * bridge system only if the bridge technology is not MULTIMIX
+ * capable. The MULTIMIX technology has already done it.
+ */
+ if (!(bridge_channel->bridge->technology->capabilities
+ & AST_BRIDGE_CAPABILITY_MULTIMIX)) {
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCCHANGE);
+ }
+
/* Wait for something to do. */
ast_bridge_unlock(bridge_channel->bridge);
while (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
@@ -1949,6 +1965,9 @@
ast_frfree(fr);
}
ast_bridge_channel_unlock(bridge_channel);
+
+ /* Indicate a source change since this channel is leaving the bridge system. */
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCCHANGE);
/* BUGBUG Revisit in regards to moving channels between bridges and local channel optimization. */
/* BUGBUG This is where outgoing HOLD/UNHOLD memory should write UNHOLD to channel. */
More information about the asterisk-commits
mailing list