[asterisk-commits] [svn-commits] file: branch file/bridging r106327 - /team/file/bridging/main/bridging.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 5 22:06:31 CST 2008


Author: file
Date: Wed Mar  5 22:06:31 2008
New Revision: 106327

URL: http://svn.digium.com/view/asterisk?view=rev&rev=106327
Log:
Add support for turning the attended transfer into a threeway call.

Modified:
    team/file/bridging/main/bridging.c

Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=106327&r1=106326&r2=106327
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Wed Mar  5 22:06:31 2008
@@ -1322,6 +1322,14 @@
 	return 0;
 }
 
+/*! \brief Attended transfer feature to turn it into a threeway call */
+static int attended_threeway_transfer(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	/* This is sort of abusing the depart state but in this instance it is only going to be handled in the below function so it is okay */
+	bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_DEPART;
+	return 0;
+}
+
 /*! \brief Internal built in feature for attended transfers */
 static int feature_attended_transfer(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
 {
@@ -1329,6 +1337,7 @@
 	struct ast_channel *chan = NULL;
 	struct ast_bridge *attended_bridge = NULL;
 	struct ast_bridge_features features;
+	enum ast_bridge_channel_state attended_bridge_result;
 
 	/* Grab the extension to transfer to */
 	if (!grab_transfer(bridge_channel->chan, exten, sizeof(exten), bridge_channel->chan->context)) {
@@ -1358,17 +1367,26 @@
 	/* Before we join setup a features structure with the hangup option, just in case they want to use DTMF */
 	ast_bridge_features_init(&features);
 	ast_bridge_features_enable(&features, AST_BRIDGE_BUILTIN_HANGUP, "*");
+	ast_bridge_features_hook(&features, "#", attended_threeway_transfer, NULL);
 
 	/* But for the caller we want to join the bridge in a blocking fashion so we don't spin around in this function doing nothing while waiting */
-	ast_bridge_join(attended_bridge, bridge_channel->chan, NULL, &features);
+	attended_bridge_result = ast_bridge_join(attended_bridge, bridge_channel->chan, NULL, &features);
 
 	/* Since the above returned the features structure is of no more use and just needs to be cleaned up, or else we leak memory and that makes me sad. */
 	ast_bridge_features_cleanup(&features);
 
 	/* Drop the channel we are transferring to out of the above bridge since it has ended */
 	if (!ast_bridge_depart(attended_bridge, chan)) {
-		/* Just like in a blind transfer we impart this new channel upon the bridge in our place, once done we will be a goner */
-		ast_bridge_impart(bridge, chan, bridge_channel->chan, NULL);
+		/* If the user wants to turn this into a threeway transfer then do so, otherwise they take our place */
+		if (attended_bridge_result == AST_BRIDGE_CHANNEL_STATE_DEPART) {
+			/* We want to impart them upon the bridge and just have us return to it as normal */
+			ast_bridge_impart(bridge, chan, NULL, NULL);
+			bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
+		} else {
+			ast_bridge_impart(bridge, chan, bridge_channel->chan, NULL);
+		}
+	} else {
+		bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
 	}
 
 	/* Now that all channels are out of it we can destroy the bridge */


_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--

svn-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/svn-commits





More information about the asterisk-commits mailing list