[svn-commits] oej: branch oej/pinedanish-copybridgeflags-1.6.0 r313098 - in /team/oej/pined...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Apr 8 05:08:04 CDT 2011
Author: oej
Date: Fri Apr 8 05:07:58 2011
New Revision: 313098
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=313098
Log:
And voila - it works.
Modified:
team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_dial.c
team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_local.c
team/oej/pinedanish-copybridgeflags-1.6.0/include/asterisk/channel.h
team/oej/pinedanish-copybridgeflags-1.6.0/main/features.c
Modified: team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_dial.c?view=diff&rev=313098&r1=313097&r2=313098
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_dial.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_dial.c Fri Apr 8 05:07:58 2011
@@ -2010,11 +2010,11 @@
ast_channel_setoption(chan, AST_OPTION_OPRMODE, &oprmode, sizeof(oprmode), 0);
}
- ast_debug(1, "--- Setting bridgeflags on %s\n", chan->name);
+ ast_debug(3, "--- Setting bridgeflags on %s\n", chan->name);
ast_copy_flags(&chan->bridgeflags, &config.features_callee,
AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |
AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON);
- ast_debug(1, "--- Setting bridgeflags on %s\n", peer->name);
+ ast_debug(3, "--- Setting bridgeflags on %s\n", peer->name);
ast_copy_flags(&peer->bridgeflags, &config.features_caller,
AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |
AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON);
Modified: team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_local.c?view=diff&rev=313098&r1=313097&r2=313098
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_local.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_local.c Fri Apr 8 05:07:58 2011
@@ -221,9 +221,6 @@
if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_RINGING) {
ast_setstate(other, AST_STATE_RINGING);
}
- if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_BRIDGEPARAM) {
- ast_debug(2, "Forwarding BRIDGE CONTROL packet aimed for %s\n", other->name);
- }
ast_queue_frame(other, f);
ast_channel_unlock(other);
}
@@ -269,6 +266,15 @@
if it has been bridged to another channel and if there are no pending
frames on the owner channel (because they would be transferred to the
outbound channel during the masquerade)
+
+ The call currently looks this way:
+
+ Inbound channel - <bridge one> - local channel;1 - <local bridge> - local channel;2 - <bridge two> - Outbound channel
+
+ During the masquerade the "local channel;1" takes over the pvt of the Outbound channel and replaces it by masquerading.
+
+ Inbound channel - <bridge one> Outbound channel
+
*/
if (p->chan->_bridge /* Not ast_bridged_channel! Only go one step! */ && AST_LIST_EMPTY(&p->owner->readq)) {
/* Masquerade bridged channel into owner */
@@ -278,6 +284,8 @@
if (!ast_channel_trylock(p->chan->_bridge)) {
if (!ast_check_hangup(p->chan->_bridge)) {
if (!ast_channel_trylock(p->owner)) {
+ struct ast_bridgeflags_envelope *message_upstream;
+
if (!ast_check_hangup(p->owner)) {
if (p->owner->monitor && !p->chan->_bridge->monitor) {
/* If a local channel is being monitored, we don't want a masquerade
@@ -301,12 +309,23 @@
}
/* Now, tell the owner's bridge that we had some interesting parameters in the bridge that
will disappear soon, so that we don't drop them */
- ast_queue_control_data(p->owner, AST_CONTROL_BRIDGEPARAM, &p->chan->bridgeflags, sizeof(p->chan->bridgeflags));
- ast_debug(1, "----- Sending bridge flags from channel %s upstream to %s\n", p->chan->name, p->owner->name);
- ast_debug(1, "----- We have these channels to play with: 1: %s 2: %s \n", p->chan->name, p->owner->name);
- if (ast_test_flag(&p->chan->bridgeflags, AST_FEATURE_REDIRECT)) {
- ast_debug(2, "--- Package includes transfer flag\n");
- }
+ message_upstream = alloca(sizeof(*message_upstream));
+ if (message_upstream) {
+ message_upstream->chan_bridgeflags = p->chan->_bridge->bridgeflags;
+ message_upstream->peer_bridgeflags = p->chan->bridgeflags;
+ ast_copy_string(message_upstream->secretmessage, p->chan->name, sizeof(message_upstream->secretmessage));
+
+ ast_queue_control_data(p->owner, AST_CONTROL_BRIDGEPARAM, message_upstream, sizeof(*message_upstream));
+ ast_debug(2, "Sending bridge flags from channel %s upstream to %s\n", p->chan->name, p->owner->name);
+ if (ast_test_flag(&p->chan->_bridge->bridgeflags, AST_FEATURE_REDIRECT)) {
+ ast_debug(2, "--- Package includes callee transfer flag\n");
+ }
+ if (ast_test_flag(&p->chan->bridgeflags, AST_FEATURE_REDIRECT)) {
+ ast_debug(2, "--- Package includes caller transfer flag\n");
+ }
+ } else {
+ ast_log(LOG_ERROR, "Can't allocate memory for bridge flag update\n");
+ }
ast_channel_unlock(p->owner);
}
ast_channel_unlock(p->chan->_bridge);
Modified: team/oej/pinedanish-copybridgeflags-1.6.0/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/include/asterisk/channel.h?view=diff&rev=313098&r1=313097&r2=313098
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/include/asterisk/channel.h (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/include/asterisk/channel.h Fri Apr 8 05:07:58 2011
@@ -167,6 +167,13 @@
};
typedef unsigned long long ast_group_t;
+
+/*! \brief Envelope for sending bridge flags between bridges in a call with multiple bridges, like a local channel call */
+struct ast_bridgeflags_envelope {
+ struct ast_flags chan_bridgeflags; /*!< Flags set for channel when creating bridge */
+ struct ast_flags peer_bridgeflags; /*!< Flags set for peer channel when creating bridge */
+ char secretmessage[50];
+};
/*! \todo Add an explanation of an Asterisk generator
*/
Modified: team/oej/pinedanish-copybridgeflags-1.6.0/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/main/features.c?view=diff&rev=313098&r1=313097&r2=313098
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/main/features.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/main/features.c Fri Apr 8 05:07:58 2011
@@ -2181,6 +2181,27 @@
return;
}
+static void bridge_set_feature_flags(struct ast_flags *features, struct ast_flags *param)
+{
+ if (ast_test_flag(param, AST_FEATURE_REDIRECT)) {
+ ast_debug(1, " --- Got redirect flag!\n");
+ ast_set_flag(features, AST_FEATURE_REDIRECT);
+ }
+ if (ast_test_flag(param, AST_FEATURE_DISCONNECT)) {
+ ast_debug(1, " --- Got disconnect flag!\n");
+ ast_set_flag(features, AST_FEATURE_DISCONNECT);
+ }
+ if (ast_test_flag(param, AST_FEATURE_AUTOMON)) {
+ ast_set_flag(features, AST_FEATURE_AUTOMON);
+ }
+ if (ast_test_flag(param, AST_FEATURE_AUTOMIXMON)) {
+ ast_set_flag(features, AST_FEATURE_AUTOMIXMON);
+ }
+ if (ast_test_flag(param, AST_FEATURE_PARKCALL)) {
+ ast_set_flag(features, AST_FEATURE_PARKCALL);
+ }
+}
+
/*!
* \brief bridge the call and set CDR
* \param chan,peer,config
@@ -2350,6 +2371,7 @@
}
for (;;) {
struct ast_channel *other; /* used later */
+ ast_debug(2, "---> Entering bridge loop for channel %s with peer %s\n", chan->name, peer->name);
res = ast_channel_bridge(chan, peer, config, &f, &who);
@@ -2373,6 +2395,8 @@
}
if (hasfeatures) {
+ ast_debug(2, "---> Entering feature check for channel %s with peer %s\n", chan->name, peer->name);
+
/* Running on backup config, meaning a feature might be being
activated, but that's no excuse to keep things going
indefinitely! */
@@ -2435,12 +2459,14 @@
(f->subclass == AST_CONTROL_HANGUP || f->subclass == AST_CONTROL_BUSY ||
f->subclass == AST_CONTROL_CONGESTION))) {
res = -1;
+ ast_debug(2, "---> Hangup/Busy/congestion: Exiting bridge for channel %s with peer %s\n", chan->name, peer->name);
break;
}
/* many things should be sent to the 'other' channel */
other = (who == chan) ? peer : chan;
if (f->frametype == AST_FRAME_CONTROL) {
- struct ast_flags *param;
+ struct ast_bridgeflags_envelope *message_upstream;
+
switch (f->subclass) {
case AST_CONTROL_RINGING:
case AST_CONTROL_FLASH:
@@ -2454,41 +2480,41 @@
case AST_CONTROL_BRIDGEPARAM:
/* We are getting an bridge update from chan_local before masquerade, update this bridge with the params */
/* We want to update the peer side, the outbound channel, with it */
- param = (struct ast_flags *) f->data;
+ message_upstream = (struct ast_bridgeflags_envelope *) f->data;
+ ast_debug(1, "--- Received bridge parameters sent from %s\n", message_upstream->secretmessage);
- if (ast_test_flag(param, AST_FEATURE_REDIRECT)) {
- ast_set_flag(&(config->features_callee), AST_FEATURE_REDIRECT);
- ast_debug(2, "--- Setting Transfer flag on callee in bridge! Chan %s Peer %s \n", chan->name, peer->name);
- hasfeatures = 1;
+ /* First set the calle side of things */
+ ast_debug(2, "--- Checking callee bridgeflags on %s\n", chan->name);
+ bridge_set_feature_flags(&config->features_callee, &message_upstream->chan_bridgeflags);
+ if (ast_test_flag(&(message_upstream->chan_bridgeflags), AST_FEATURE_PARKCALL | AST_FEATURE_DISCONNECT | AST_FEATURE_AUTOMON | AST_FEATURE_AUTOMIXMON | AST_FEATURE_PARKCALL)) {
+ ast_debug(2, "--- Got flags for callee! (%s) \n", chan->name);
ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1);
}
- if (ast_test_flag(param, AST_FEATURE_DISCONNECT)) {
- ast_set_flag(&(config->features_callee), AST_FEATURE_DISCONNECT);
- ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1);
+ ast_debug(2, "--- Checking caller bridgeflags on %s\n", peer->name);
+ bridge_set_feature_flags(&config->features_caller, &message_upstream->peer_bridgeflags);
+ if (ast_test_flag(&(message_upstream->peer_bridgeflags), AST_FEATURE_PARKCALL | AST_FEATURE_DISCONNECT | AST_FEATURE_AUTOMON | AST_FEATURE_AUTOMIXMON | AST_FEATURE_PARKCALL)) {
+ ast_debug(2, "--- Got flags for caller! (%s)\n", peer->name);
+ ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
}
- if (ast_test_flag(param, AST_FEATURE_AUTOMON)) {
- ast_set_flag(&(config->features_callee), AST_FEATURE_AUTOMON);
- ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1);
- }
- if (ast_test_flag(param, AST_FEATURE_AUTOMIXMON)) {
- ast_set_flag(&(config->features_callee), AST_FEATURE_AUTOMIXMON);
- ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1);
- }
- if (ast_test_flag(param, AST_FEATURE_PARKCALL)) {
- ast_set_flag(&(config->features_callee), AST_FEATURE_PARKCALL);
- ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1);
- }
-
- ast_debug(1, "--- Setting bridgeflags on %s\n", chan->name);
+
+ ast_debug(2, "--- Setting bridgeflags on %s\n", chan->name);
ast_copy_flags(&chan->bridgeflags, &(config->features_callee),
AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |
AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON);
- ast_debug(1, "--- Setting bridgeflags on %s\n", peer->name);
+ ast_debug(2, "--- Setting bridgeflags on %s\n", peer->name);
ast_copy_flags(&peer->bridgeflags, &(config->features_caller),
AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |
AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON);
+ ast_copy_flags(&(backup_config.features_caller), &(config->features_caller),
+ AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |
+ AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON);
+ ast_copy_flags(&(backup_config.features_callee), &(config->features_callee),
+ AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |
+ AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON);
+ set_config_flags(chan, peer, config);
- ast_debug(2, "--- Setting updated bridge flags from chan_local in this bridge for outgoing channel %s Peer %s\n", chan->name, peer->name);
+ ast_debug(1, "--- Setting updated bridge flags from chan_local in this bridge for outgoing channel %s Peer %s\n", chan->name, peer->name);
+
break;
case AST_CONTROL_OPTION:
aoh = f->data;
More information about the svn-commits
mailing list