[asterisk-commits] oej: branch oej/pinedanish-copybridgeflags-trunk r336380 - in /team/oej/pined...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 19 05:02:29 CDT 2011


Author: oej
Date: Mon Sep 19 05:02:27 2011
New Revision: 336380

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=336380
Log:
Update, resolve conflict, get some lunch.

Modified:
    team/oej/pinedanish-copybridgeflags-trunk/   (props changed)
    team/oej/pinedanish-copybridgeflags-trunk/Makefile
    team/oej/pinedanish-copybridgeflags-trunk/apps/app_dial.c
    team/oej/pinedanish-copybridgeflags-trunk/channels/chan_local.c
    team/oej/pinedanish-copybridgeflags-trunk/include/asterisk/channel.h
    team/oej/pinedanish-copybridgeflags-trunk/include/asterisk/frame.h
    team/oej/pinedanish-copybridgeflags-trunk/main/channel.c
    team/oej/pinedanish-copybridgeflags-trunk/main/features.c
    team/oej/pinedanish-copybridgeflags-trunk/main/file.c
    team/oej/pinedanish-copybridgeflags-trunk/main/frame.c

Propchange: team/oej/pinedanish-copybridgeflags-trunk/
------------------------------------------------------------------------------
--- automerge (original)
+++ automerge Mon Sep 19 05:02:27 2011
@@ -1,1 +1,1 @@
-*
+Is-there-life-off-net?

Modified: team/oej/pinedanish-copybridgeflags-trunk/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-trunk/Makefile?view=diff&rev=336380&r1=336379&r2=336380
==============================================================================
--- team/oej/pinedanish-copybridgeflags-trunk/Makefile (original)
+++ team/oej/pinedanish-copybridgeflags-trunk/Makefile Mon Sep 19 05:02:27 2011
@@ -286,7 +286,7 @@
 ifneq ($(findstring darwin,$(OSARCH)),)
   _ASTCFLAGS+=-D__Darwin__
   SOLINK=-bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
-  ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.6)
+  ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.7)
     SOLINK+=/usr/lib/bundle1.o
   endif
   _ASTLDFLAGS+=-L/usr/local/lib

Modified: team/oej/pinedanish-copybridgeflags-trunk/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-trunk/apps/app_dial.c?view=diff&rev=336380&r1=336379&r2=336380
==============================================================================
--- team/oej/pinedanish-copybridgeflags-trunk/apps/app_dial.c (original)
+++ team/oej/pinedanish-copybridgeflags-trunk/apps/app_dial.c Mon Sep 19 05:02:27 2011
@@ -2804,6 +2804,14 @@
 
 				ast_channel_setoption(chan, AST_OPTION_OPRMODE, &oprmode, sizeof(oprmode), 0);
 			}
+			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(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);
 			res = ast_bridge_call(chan, peer, &config);
 		}
 

Modified: team/oej/pinedanish-copybridgeflags-trunk/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-trunk/channels/chan_local.c?view=diff&rev=336380&r1=336379&r2=336380
==============================================================================
--- team/oej/pinedanish-copybridgeflags-trunk/channels/chan_local.c (original)
+++ team/oej/pinedanish-copybridgeflags-trunk/channels/chan_local.c Mon Sep 19 05:02:27 2011
@@ -510,6 +510,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 Outbound channel takes over the pvt of the "local channel;1"  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 */
@@ -519,6 +528,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
@@ -572,6 +583,25 @@
 						ast_channel_masquerade(p->owner, p->chan->_bridge);
 						ast_set_flag(p, LOCAL_ALREADY_MASQED);
 					}
+					/* 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 */
+ 					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);
 				}
 			}

Modified: team/oej/pinedanish-copybridgeflags-trunk/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-trunk/include/asterisk/channel.h?view=diff&rev=336380&r1=336379&r2=336380
==============================================================================
--- team/oej/pinedanish-copybridgeflags-trunk/include/asterisk/channel.h (original)
+++ team/oej/pinedanish-copybridgeflags-trunk/include/asterisk/channel.h Mon Sep 19 05:02:27 2011
@@ -172,6 +172,13 @@
 	AST_BRIDGE_RETRY = -3,
 };
 
+/*! \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[AST_CHANNEL_NAME];			/*!< For debugging, sending the old channel name across */
+ };
+ 
 typedef unsigned long long ast_group_t;
 
 /*! \todo Add an explanation of an Asterisk generator
@@ -868,6 +875,7 @@
 	char macrocontext[AST_MAX_CONTEXT];		/*!< Macro: Current non-macro context. See app_macro.c */
 	char macroexten[AST_MAX_EXTENSION];		/*!< Macro: Current non-macro extension. See app_macro.c */
 	char emulate_dtmf_digit;			/*!< Digit being emulated */
+	struct ast_flags bridgeflags;                   /*!< Flags set for channel when creating bridge */
 };
 
 /*! \brief ast_channel_tech Properties */

Modified: team/oej/pinedanish-copybridgeflags-trunk/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-trunk/include/asterisk/frame.h?view=diff&rev=336380&r1=336379&r2=336380
==============================================================================
--- team/oej/pinedanish-copybridgeflags-trunk/include/asterisk/frame.h (original)
+++ team/oej/pinedanish-copybridgeflags-trunk/include/asterisk/frame.h Mon Sep 19 05:02:27 2011
@@ -85,6 +85,7 @@
  * \arg \b SRCCHANGE       Media source has changed (RTP marker bit and SSRC must change)
  * \arg \b CONNECTED_LINE  Connected line has changed
  * \arg \b REDIRECTING     Call redirecting information has changed.
+ * \arg \b BRIDGEPARAM     Bridge parameters to preserve from the outbound bridge when chan_local masquerades away
  */
 
 /*!
@@ -266,6 +267,7 @@
 	AST_CONTROL_INCOMPLETE = 30,	/*!< Indication that the extension dialed is incomplete */
 	AST_CONTROL_MCID = 31,			/*!< Indicate that the caller is being malicious. */
 	AST_CONTROL_UPDATE_RTP_PEER = 32, /*!< Interrupt the bridge and have it update the peer */
+ 	AST_CONTROL_BRIDGEPARAM = 33,           /*!< Bridge parameter update after masquerade */
 };
 
 enum ast_frame_read_action {

Modified: team/oej/pinedanish-copybridgeflags-trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-trunk/main/channel.c?view=diff&rev=336380&r1=336379&r2=336380
==============================================================================
--- team/oej/pinedanish-copybridgeflags-trunk/main/channel.c (original)
+++ team/oej/pinedanish-copybridgeflags-trunk/main/channel.c Mon Sep 19 05:02:27 2011
@@ -3610,6 +3610,7 @@
 					return -1;
 				case AST_CONTROL_RINGING:
 				case AST_CONTROL_ANSWER:
+				case AST_CONTROL_BRIDGEPARAM:
 				case AST_CONTROL_SRCUPDATE:
 				case AST_CONTROL_SRCCHANGE:
 				case AST_CONTROL_CONNECTED_LINE:
@@ -4334,6 +4335,7 @@
 	case AST_CONTROL_OFFHOOK:
 	case AST_CONTROL_TAKEOFFHOOK:
 	case AST_CONTROL_ANSWER:
+	case AST_CONTROL_BRIDGEPARAM:
 	case AST_CONTROL_HANGUP:
 	case AST_CONTROL_CONNECTED_LINE:
 	case AST_CONTROL_REDIRECTING:
@@ -4512,6 +4514,7 @@
 	case AST_CONTROL_PROGRESS:
 	case AST_CONTROL_PROCEEDING:
 	case AST_CONTROL_VIDUPDATE:
+	case AST_CONTROL_BRIDGEPARAM:
 	case AST_CONTROL_SRCUPDATE:
 	case AST_CONTROL_SRCCHANGE:
 	case AST_CONTROL_RADIO_KEY:

Modified: team/oej/pinedanish-copybridgeflags-trunk/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-trunk/main/features.c?view=diff&rev=336380&r1=336379&r2=336380
==============================================================================
--- team/oej/pinedanish-copybridgeflags-trunk/main/features.c (original)
+++ team/oej/pinedanish-copybridgeflags-trunk/main/features.c Mon Sep 19 05:02:27 2011
@@ -3674,6 +3674,27 @@
 	ast_channel_unlock(chan);
 }
 
+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
  *
@@ -3870,6 +3891,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);
 
@@ -3959,6 +3981,7 @@
 		/* many things should be sent to the 'other' channel */
 		other = (who == chan) ? peer : chan;
 		if (f->frametype == AST_FRAME_CONTROL) {
+			struct ast_bridgeflags_envelope *message_upstream;
 			switch (f->subclass.integer) {
 			case AST_CONTROL_RINGING:
 			case AST_CONTROL_FLASH:
@@ -3982,6 +4005,45 @@
 			case AST_CONTROL_HOLD:
 			case AST_CONTROL_UNHOLD:
 				ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
+				break;
+			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 */
+				message_upstream = (struct ast_bridgeflags_envelope *) f->data;
+				ast_debug(1, "--- Received bridge parameters sent from %s\n", message_upstream->secretmessage);
+				
+				/* 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->peer_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);
+				}
+				ast_debug(2, "--- Checking caller bridgeflags on %s\n", peer->name);
+				bridge_set_feature_flags(&config->features_caller, &message_upstream->chan_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);
+				}
+
+				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(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(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.ptr;

Modified: team/oej/pinedanish-copybridgeflags-trunk/main/file.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-trunk/main/file.c?view=diff&rev=336380&r1=336379&r2=336380
==============================================================================
--- team/oej/pinedanish-copybridgeflags-trunk/main/file.c (original)
+++ team/oej/pinedanish-copybridgeflags-trunk/main/file.c Mon Sep 19 05:02:27 2011
@@ -1340,6 +1340,7 @@
 				case AST_CONTROL_VIDUPDATE:
 				case AST_CONTROL_SRCUPDATE:
 				case AST_CONTROL_SRCCHANGE:
+				case AST_CONTROL_BRIDGEPARAM:
 				case AST_CONTROL_HOLD:
 				case AST_CONTROL_UNHOLD:
 				case AST_CONTROL_CONNECTED_LINE:

Modified: team/oej/pinedanish-copybridgeflags-trunk/main/frame.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-trunk/main/frame.c?view=diff&rev=336380&r1=336379&r2=336380
==============================================================================
--- team/oej/pinedanish-copybridgeflags-trunk/main/frame.c (original)
+++ team/oej/pinedanish-copybridgeflags-trunk/main/frame.c Mon Sep 19 05:02:27 2011
@@ -611,6 +611,9 @@
 		case AST_CONTROL_UNHOLD:
 			strcpy(subclass, "Unhold");
 			break;
+		case AST_CONTROL_BRIDGEPARAM:
+			strcpy(subclass, "Bridge parameters");
+			break;
 		case AST_CONTROL_T38_PARAMETERS:
 			if (f->datalen != sizeof(struct ast_control_t38_parameters)) {
 				message = "Invalid";




More information about the asterisk-commits mailing list