[asterisk-commits] file: branch file/bridging-phase2 r193539 - in /team/file/bridging-phase2: br...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun May 10 12:38:21 CDT 2009


Author: file
Date: Sun May 10 12:38:14 2009
New Revision: 193539

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=193539
Log:
Add support for disabling threeway conference bridge completion on attended transfers and also add support for performing an external transfer on blind transfers.

Modified:
    team/file/bridging-phase2/bridges/bridge_builtin_features.c
    team/file/bridging-phase2/include/asterisk/bridging_features.h

Modified: team/file/bridging-phase2/bridges/bridge_builtin_features.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/file/bridging-phase2/bridges/bridge_builtin_features.c?view=diff&rev=193539&r1=193538&r2=193539
==============================================================================
--- team/file/bridging-phase2/bridges/bridge_builtin_features.c (original)
+++ team/file/bridging-phase2/bridges/bridge_builtin_features.c Sun May 10 12:38:14 2009
@@ -43,6 +43,7 @@
 #include "asterisk/file.h"
 #include "asterisk/app.h"
 #include "asterisk/astobj2.h"
+#include "asterisk/pbx.h"
 
 /*! \brief Helper function that presents dialtone and grabs extension */
 static int grab_transfer(struct ast_channel *chan, char *exten, size_t exten_len, const char *context)
@@ -91,6 +92,17 @@
 	return chan;
 }
 
+/*! \brief Helper function which gets the other channel in the bridge for an external blind transfer */
+static struct ast_channel *get_external_transfer_channel(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	/* If we have more then 2 channels in the bridge then we can not perform an external transfer */
+	if (bridge->num > 2) {
+		return NULL;
+	}
+
+	return AST_LIST_FIRST(&bridge->channels) == bridge_channel ? AST_LIST_LAST(&bridge->channels)->chan : AST_LIST_FIRST(&bridge->channels)->chan;
+}
+
 /*! \brief Internal built in feature for blind transfers */
 static int feature_blind_transfer(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
 {
@@ -106,15 +118,20 @@
 		return 0;
 	}
 
-	/* Get a channel that is the destination we wish to call */
-	if (!(chan = dial_transfer(bridge_channel->chan, exten, context))) {
-		ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_ANY);
-		ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
-		return 0;
-	}
-
-	/* This is sort of the fun part. We impart the above channel onto the bridge, and have it take our place. */
-	ast_bridge_impart(bridge, chan, bridge_channel->chan, NULL);
+	/* If the dialed channel should become part of the bridge then dial and add them */
+	if (!blind_transfer || !blind_transfer->external_transfer || !(chan = get_external_transfer_channel(bridge, bridge_channel))) {
+		/* Get a channel that is the destination we wish to call */
+		if (!(chan = dial_transfer(bridge_channel->chan, exten, context))) {
+			ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_ANY);
+			ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
+			return 0;
+		}
+
+		/* This is sort of the fun part. We impart the above channel onto the bridge, and have it take our place. */
+		ast_bridge_impart(bridge, chan, bridge_channel->chan, NULL);
+	} else {
+		ast_async_goto(chan, context, exten, 1);
+	}
 
 	return 0;
 }
@@ -197,8 +214,12 @@
 	ast_bridge_features_init(&caller_features);
 	ast_bridge_features_enable(&caller_features, AST_BRIDGE_BUILTIN_HANGUP,
 				   (attended_transfer && !ast_strlen_zero(attended_transfer->complete) ? attended_transfer->complete : "*1"), NULL);
-	ast_bridge_features_hook(&caller_features, (attended_transfer && !ast_strlen_zero(attended_transfer->threeway) ? attended_transfer->threeway : "*2"),
-				 attended_threeway_transfer, NULL);
+
+	if (!attended_transfer || !attended_transfer->disable_threeway) {
+		ast_bridge_features_hook(&caller_features, (attended_transfer && !ast_strlen_zero(attended_transfer->threeway) ? attended_transfer->threeway : "*2"),
+					 attended_threeway_transfer, NULL);
+	}
+
 	ast_bridge_features_hook(&caller_features, (attended_transfer && !ast_strlen_zero(attended_transfer->abort) ? attended_transfer->abort : "*3"),
 				 attended_abort_transfer, NULL);
 

Modified: team/file/bridging-phase2/include/asterisk/bridging_features.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/file/bridging-phase2/include/asterisk/bridging_features.h?view=diff&rev=193539&r1=193538&r2=193539
==============================================================================
--- team/file/bridging-phase2/include/asterisk/bridging_features.h (original)
+++ team/file/bridging-phase2/include/asterisk/bridging_features.h Sun May 10 12:38:14 2009
@@ -114,6 +114,8 @@
 struct ast_bridge_features_blind_transfer {
 	/*! Context to use for transfers */
 	char context[AST_MAX_CONTEXT];
+	/*! Bit used to indicate that the transfer should occur outside of the bridge (default is disabled, requires only 1 other channel be in the bridge) */
+	unsigned int external_transfer:1;
 };
 
 /*!
@@ -128,6 +130,8 @@
 	char complete[MAXIMUM_DTMF_FEATURE_STRING];
 	/*! Context to use for transfers */
 	char context[AST_MAX_CONTEXT];
+	/*! Bit used to indicate that the capability to turn the transfer into a three way conference should be disabled */
+	unsigned int disable_threeway:1;
 };
 
 /*!




More information about the asterisk-commits mailing list