[svn-commits] oej: branch oej/pinedanish-copybridgeflags-1.8 r332019 - in /team/oej/pinedan...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Aug 16 04:48:53 CDT 2011


Author: oej
Date: Tue Aug 16 04:48:49 2011
New Revision: 332019

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=332019
Log:
See the README.pinedanish-copybridgeflags file for some intelligent information. 

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

Modified: team/oej/pinedanish-copybridgeflags-1.8/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.8/Makefile?view=diff&rev=332019&r1=332018&r2=332019
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.8/Makefile (original)
+++ team/oej/pinedanish-copybridgeflags-1.8/Makefile Tue Aug 16 04:48:49 2011
@@ -278,7 +278,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

Added: team/oej/pinedanish-copybridgeflags-1.8/README.pinedanish-copybridgeflags
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.8/README.pinedanish-copybridgeflags?view=auto&rev=332019
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.8/README.pinedanish-copybridgeflags (added)
+++ team/oej/pinedanish-copybridgeflags-1.8/README.pinedanish-copybridgeflags Tue Aug 16 04:48:49 2011
@@ -1,0 +1,33 @@
+Edvina AB
+Olle E. Johansson
+
+
+
+
+Pinedanish - copybridgeflags
+============================
+
+If you dialout through the local channel with a "t" option on the last dial to a phone,
+after the local channel disappears, the transfer option is gone and the callee can not
+transfer any calls.
+
+With this code, the bridge feature flags on the last call leg is saved to the channel.
+At local masquerade, they're sent as a control frame "upwards" and applied to the
+remaining bridge. This way, the callee will keep the rights to transfer even after
+the local channels are gone.
+
+Technichal details
+-------------------
+
+Before the optimization
+
+caller --------> B1 -------->LB----------> B2 -----------> callee
+       SIP/in	    local;1     local;2        SIP/out
+
+The flags to dial() is set on the B2 bridge. This bridge disappears when the local
+channels are optimized away, so that the flags will be gone.
+
+With this code, the bridge flags are copied to the channels. When the local;2 channel
+is about to disappear, it sends a new AST_CONTROL_BRIDGEFLAGS message upstream, which
+is caught by B1 and applied to the outbound side of the B1 bridge. 
+

Propchange: team/oej/pinedanish-copybridgeflags-1.8/README.pinedanish-copybridgeflags
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/oej/pinedanish-copybridgeflags-1.8/README.pinedanish-copybridgeflags
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/oej/pinedanish-copybridgeflags-1.8/README.pinedanish-copybridgeflags
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/oej/pinedanish-copybridgeflags-1.8/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.8/apps/app_dial.c?view=diff&rev=332019&r1=332018&r2=332019
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.8/apps/app_dial.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.8/apps/app_dial.c Tue Aug 16 04:48:49 2011
@@ -2812,6 +2812,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-1.8/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.8/channels/chan_local.c?view=diff&rev=332019&r1=332018&r2=332019
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.8/channels/chan_local.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.8/channels/chan_local.c Tue Aug 16 04:48:49 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-1.8/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.8/include/asterisk/channel.h?view=diff&rev=332019&r1=332018&r2=332019
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.8/include/asterisk/channel.h (original)
+++ team/oej/pinedanish-copybridgeflags-1.8/include/asterisk/channel.h Tue Aug 16 04:48:49 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
@@ -864,6 +871,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-1.8/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.8/include/asterisk/frame.h?view=diff&rev=332019&r1=332018&r2=332019
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.8/include/asterisk/frame.h (original)
+++ team/oej/pinedanish-copybridgeflags-1.8/include/asterisk/frame.h Tue Aug 16 04:48:49 2011
@@ -89,6 +89,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
  */
 
 /*!
@@ -334,6 +335,7 @@
 	AST_CONTROL_READ_ACTION = 27,	/*!< Tell ast_read to take a specific action */
 	AST_CONTROL_AOC = 28,			/*!< Advice of Charge with encoded generic AOC payload */
 	AST_CONTROL_END_OF_Q = 29,		/*!< Indicate that this position was the end of the channel queue for a softhangup. */
+	AST_CONTROL_BRIDGEPARAM = 26,   /*!< Bridge parameter update after masquerade */
 };
 
 enum ast_frame_read_action {

Modified: team/oej/pinedanish-copybridgeflags-1.8/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.8/main/channel.c?view=diff&rev=332019&r1=332018&r2=332019
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.8/main/channel.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.8/main/channel.c Tue Aug 16 04:48:49 2011
@@ -3540,6 +3540,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:
@@ -4262,6 +4263,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:
@@ -4436,6 +4438,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-1.8/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.8/main/features.c?view=diff&rev=332019&r1=332018&r2=332019
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.8/main/features.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.8/main/features.c Tue Aug 16 04:48:49 2011
@@ -3405,6 +3405,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
  *
@@ -3601,6 +3622,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);
 
@@ -3690,6 +3712,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:
@@ -3712,6 +3735,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-1.8/main/file.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.8/main/file.c?view=diff&rev=332019&r1=332018&r2=332019
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.8/main/file.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.8/main/file.c Tue Aug 16 04:48:49 2011
@@ -1286,6 +1286,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-1.8/main/frame.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.8/main/frame.c?view=diff&rev=332019&r1=332018&r2=332019
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.8/main/frame.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.8/main/frame.c Tue Aug 16 04:48:49 2011
@@ -854,6 +854,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 svn-commits mailing list