[asterisk-commits] mmichelson: branch mmichelson/more_transfer r387782 - /team/mmichelson/more_t...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 6 15:55:01 CDT 2013


Author: mmichelson
Date: Mon May  6 15:54:59 2013
New Revision: 387782

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=387782
Log:
Make builtin blind transfer use ast_bridge_transfer_blind()


Modified:
    team/mmichelson/more_transfer/bridges/bridge_builtin_features.c

Modified: team/mmichelson/more_transfer/bridges/bridge_builtin_features.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/more_transfer/bridges/bridge_builtin_features.c?view=diff&rev=387782&r1=387781&r2=387782
==============================================================================
--- team/mmichelson/more_transfer/bridges/bridge_builtin_features.c (original)
+++ team/mmichelson/more_transfer/bridges/bridge_builtin_features.c Mon May  6 15:54:59 2013
@@ -94,6 +94,16 @@
 	return res;
 }
 
+static void copy_caller_data(struct ast_channel *caller, struct ast_channel *dest)
+{
+	ast_channel_lock_both(caller, dest);
+	ast_connected_line_copy_from_caller(ast_channel_connected(dest), ast_channel_caller(caller));
+	ast_channel_inherit_variables(caller, dest);
+	ast_channel_datastore_inherit(caller, dest);
+	ast_channel_unlock(dest);
+	ast_channel_unlock(caller);
+}
+
 /*! \brief Helper function that creates an outgoing channel and returns it immediately */
 static struct ast_channel *dial_transfer(struct ast_channel *caller, const char *exten, const char *context)
 {
@@ -117,12 +127,7 @@
 	}
 
 	/* Before we actually dial out let's inherit appropriate information. */
-	ast_channel_lock_both(caller, chan);
-	ast_connected_line_copy_from_caller(ast_channel_connected(chan), ast_channel_caller(caller));
-	ast_channel_inherit_variables(caller, chan);
-	ast_channel_datastore_inherit(caller, chan);
-	ast_channel_unlock(chan);
-	ast_channel_unlock(caller);
+	copy_caller_data(caller, chan);
 
 	/* Since the above worked fine now we actually call it and return the channel */
 	if (ast_call(chan, destination, 0)) {
@@ -163,11 +168,17 @@
 	return "default";
 }
 
+static void blind_transfer_cb(struct ast_channel *new_channel, void *user_data)
+{
+	struct ast_channel *transferer_channel = user_data;
+
+	copy_caller_data(transferer_channel, new_channel);
+}
+
 /*! \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)
 {
 	char exten[AST_MAX_EXTENSION] = "";
-	struct ast_channel *chan = NULL;
 	struct ast_bridge_features_blind_transfer *blind_transfer = hook_pvt;
 	const char *context;
 
@@ -182,21 +193,8 @@
 		return 0;
 	}
 
-/* BUGBUG just need to ast_async_goto the peer so this bridge will go away and not accumulate local channels and bridges if the destination is to an application. */
-/* ast_async_goto actually is a blind transfer. */
-/* BUGBUG Use the bridge count to determine if can do DTMF transfer features.  If count is not 2 then don't allow it. */
-
-	/* Get a channel that is the destination we wish to call */
-	chan = dial_transfer(bridge_channel->chan, exten, context);
-	if (!chan) {
-		return 0;
-	}
-
-	/* Impart the new channel onto the bridge, and have it take our place. */
-	if (ast_bridge_impart(bridge_channel->bridge, chan, bridge_channel->chan, NULL, 1)) {
-		ast_hangup(chan);
-		return 0;
-	}
+	ast_bridge_transfer_blind(bridge_channel->chan, exten, context, blind_transfer_cb,
+			bridge_channel->chan);
 
 	return 0;
 }




More information about the asterisk-commits mailing list