[asterisk-commits] mmichelson: branch mmichelson/more_transfer r388599 - in /team/mmichelson/mor...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 13 15:39:50 CDT 2013


Author: mmichelson
Date: Mon May 13 15:39:49 2013
New Revision: 388599

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388599
Log:
Address more of Richard's comments.

This addresses all but one of his comments. The last deals
with connected line copying.


Modified:
    team/mmichelson/more_transfer/CHANGES
    team/mmichelson/more_transfer/bridges/bridge_builtin_features.c
    team/mmichelson/more_transfer/include/asterisk/bridging.h
    team/mmichelson/more_transfer/main/bridging.c
    team/mmichelson/more_transfer/main/features.c

Modified: team/mmichelson/more_transfer/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/more_transfer/CHANGES?view=diff&rev=388599&r1=388598&r2=388599
==============================================================================
--- team/mmichelson/more_transfer/CHANGES (original)
+++ team/mmichelson/more_transfer/CHANGES Mon May 13 15:39:49 2013
@@ -58,6 +58,12 @@
    ChanVariable: bar=baz. When multiple channels are present in a single AMI
    event, the various ChanVariable fields will contain a suffix that specifies
    which channel they correspond to.
+
+ * The Bridge Manager action's Playtone header now accepts more fine-grained
+   options. "Channel1" and "Channel2" may be specified in order to play a tone
+   to the specific channel. "Both" may be specified to play a tone to both
+   channels. The old "yes" options is still accepted as a way of playing the
+   tone to Channel2 only.
 
 Channel Drivers
 ------------------

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=388599&r1=388598&r2=388599
==============================================================================
--- team/mmichelson/more_transfer/bridges/bridge_builtin_features.c (original)
+++ team/mmichelson/more_transfer/bridges/bridge_builtin_features.c Mon May 13 15:39:49 2013
@@ -163,7 +163,8 @@
 	return "default";
 }
 
-static void blind_transfer_cb(struct ast_channel *new_channel, void *user_data)
+static void blind_transfer_cb(struct ast_channel *new_channel, void *user_data,
+		enum ast_transfer_type transfer_type)
 {
 	struct ast_channel *transferer_channel = user_data;
 
@@ -176,16 +177,26 @@
 	char exten[AST_MAX_EXTENSION] = "";
 	struct ast_bridge_features_blind_transfer *blind_transfer = hook_pvt;
 	const char *context;
+	char *goto_on_blindxfr;
 
 /* BUGBUG the peer needs to be put on hold for the transfer. */
 	ast_channel_lock(bridge_channel->chan);
 	context = ast_strdupa(get_transfer_context(bridge_channel->chan,
 		blind_transfer ? blind_transfer->context : NULL));
+	goto_on_blindxfr = ast_strdupa(S_OR(pbx_builtin_getvar_helper(bridge_channel->chan,
+		"GOTO_ON_BLINDXFR"), ""));
 	ast_channel_unlock(bridge_channel->chan);
 
 	/* Grab the extension to transfer to */
 	if (grab_transfer(bridge_channel->chan, exten, sizeof(exten), context)) {
 		return 0;
+	}
+
+	if (!ast_strlen_zero(goto_on_blindxfr)) {
+		ast_debug(1, "After transfer, transferer %s goes to %s\n",
+				ast_channel_name(bridge_channel->chan), goto_on_blindxfr);
+		ast_replace_subargument_delimiter(goto_on_blindxfr);
+		ast_after_bridge_set_go_on(bridge_channel->chan, NULL, NULL, 0, goto_on_blindxfr);
 	}
 
 	ast_bridge_transfer_blind(bridge_channel->chan, exten, context, blind_transfer_cb,

Modified: team/mmichelson/more_transfer/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/more_transfer/include/asterisk/bridging.h?view=diff&rev=388599&r1=388598&r2=388599
==============================================================================
--- team/mmichelson/more_transfer/include/asterisk/bridging.h (original)
+++ team/mmichelson/more_transfer/include/asterisk/bridging.h Mon May 13 15:39:49 2013
@@ -1258,7 +1258,26 @@
     AST_BRIDGE_TRANSFER_FAIL,
 };
 
-typedef void (*transfer_channel_cb)(struct ast_channel *chan, void *user_data);
+enum ast_transfer_type {
+	/*! Transfer of a single party */
+	AST_BRIDGE_TRANSFER_SINGLE_PARTY,
+	/*! Transfer of multiple parties */
+	AST_BRIDGE_TRANSFER_MULTI_PARTY,
+};
+
+/*!
+ * \brief Callback function type called during blind transfers
+ *
+ * A caller of ast_bridge_transfer_blind() may wish to set data on
+ * the channel that ends up running dialplan. For instance, it may
+ * be useful to set channel variables on the channel.
+ *
+ * \param chan The involved channel
+ * \param user_data User-provided data needed in the callback
+ * \param transfer_type The type of transfer being completed
+ */
+typedef void (*transfer_channel_cb)(struct ast_channel *chan, void *user_data,
+		enum ast_transfer_type transfer_type);
 
 /*!
  * \brief Blind transfer target to the extension and context provided

Modified: team/mmichelson/more_transfer/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/more_transfer/main/bridging.c?view=diff&rev=388599&r1=388598&r2=388599
==============================================================================
--- team/mmichelson/more_transfer/main/bridging.c (original)
+++ team/mmichelson/more_transfer/main/bridging.c Mon May 13 15:39:49 2013
@@ -4813,7 +4813,7 @@
 	}
 
 	if (new_channel_cb) {
-		new_channel_cb(local, user_data);
+		new_channel_cb(local, user_data, AST_BRIDGE_TRANSFER_MULTI_PARTY);
 	}
 
 	if (ast_call(local, chan_name, 0)) {
@@ -4841,9 +4841,7 @@
 	 * this function is a stub;
 	 */
 
-	/* XXX For now, transferring an entire bridge to an unbridged channel is invalid until
-	 * the local channel problem described above is cleared up
-	 */
+/* BUGBUG This needs unreal channel support */
 	return AST_BRIDGE_TRANSFER_INVALID;
 }
 
@@ -4910,7 +4908,7 @@
 	}
 
 	if (new_channel_cb) {
-		new_channel_cb(transferee, user_data);
+		new_channel_cb(transferee, user_data, AST_BRIDGE_TRANSFER_SINGLE_PARTY);
 	}
 
 	ast_copy_string(blind_data.exten, exten, sizeof(blind_data.exten));
@@ -5122,13 +5120,13 @@
 
 	/* Let's get the easy one out of the way first */
 	if (to_transferee_bridge && to_target_bridge) {
-		struct ast_channel *kick_chans[2] = {
-			to_transferee,
-			to_transfer_target,
-		};
-		return ast_bridge_merge(to_transferee_bridge, to_target_bridge,
-			1, kick_chans, 2) == 0 ? AST_BRIDGE_TRANSFER_SUCCESS :
-			AST_BRIDGE_TRANSFER_FAIL;
+		/* This needs to do the following:
+		 * 1) Create a local channel
+		 * 2) Impart the local ;1 channel to to_transferee_bridge, swapping out to_transferee
+		 * 3) Impart the local ;2 channel to to_target_bridge, swapping out to_target
+		 */
+/* BUGBUG This needs unreal channel support */
+		return AST_BRIDGE_TRANSFER_INVALID;
 	}
 
 	the_bridge = to_transferee_bridge ?: to_target_bridge;

Modified: team/mmichelson/more_transfer/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/more_transfer/main/features.c?view=diff&rev=388599&r1=388598&r2=388599
==============================================================================
--- team/mmichelson/more_transfer/main/features.c (original)
+++ team/mmichelson/more_transfer/main/features.c Mon May 13 15:39:49 2013
@@ -411,8 +411,10 @@
 			<parameter name="Tone">
 				<para>Play courtesy tone to Channel 2.</para>
 				<enumlist>
-					<enum name="yes" />
 					<enum name="no" />
+					<enum name="Channel1" />
+					<enum name="Channel2" />
+					<enum name="Both" />
 				</enumlist>
 			</parameter>
 		</syntax>
@@ -7171,7 +7173,6 @@
 	ast_channel_unlock(chan);
 
 	if (chan_bridge) {
-/* BUGBUG The supplied features are not applied in this case */
 		if (ast_bridge_move(bridge, chan_bridge, chan, NULL, 1)) {
 			return -1;
 		}
@@ -7211,6 +7212,29 @@
 	return 0;
 }
 
+enum play_tone_action {
+	PLAYTONE_NONE = 0,
+	PLAYTONE_CHANNEL1 = (1 << 0),
+	PLAYTONE_CHANNEL2 = (1 << 1),
+	PLAYTONE_BOTH = PLAYTONE_CHANNEL1 | PLAYTONE_CHANNEL2,
+};
+
+static enum play_tone_action parse_playtone(const char *playtone_val)
+{
+	if (ast_strlen_zero(playtone_val) || ast_false(playtone_val)) {
+		return PLAYTONE_NONE;
+	} if (!strcasecmp(playtone_val, "channel1")) {
+		return PLAYTONE_CHANNEL1;
+	} else if (!strcasecmp(playtone_val, "channel2") || ast_true(playtone_val)) {
+		return PLAYTONE_CHANNEL2;
+	} else if (!strcasecmp(playtone_val, "both")) {
+		return PLAYTONE_BOTH;
+	} else {
+		/* Invalid input. Assume none */
+		return PLAYTONE_NONE;
+	}
+}
+
 /*!
  * \brief Bridge channels together
  * \param s
@@ -7228,7 +7252,7 @@
 {
 	const char *channela = astman_get_header(m, "Channel1");
 	const char *channelb = astman_get_header(m, "Channel2");
-	const char *playtone = astman_get_header(m, "Tone");
+	enum play_tone_action playtone = parse_playtone(astman_get_header(m, "Tone"));
 	RAII_VAR(struct ast_channel *, chana, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_channel *, chanb, NULL, ao2_cleanup);
 	const char *chana_name;
@@ -7282,7 +7306,7 @@
 	}
 
 	ast_after_bridge_set_go_on(chana, chana_context, chana_exten, chana_priority, NULL);
-	if (add_to_bridge(bridge, chana, NULL, ast_true(playtone))) {
+	if (add_to_bridge(bridge, chana, NULL, playtone & PLAYTONE_CHANNEL1)) {
 		snprintf(buf, sizeof(buf), "Unable to add Channel1 to bridge: %s", ast_channel_name(chana));
 		astman_send_error(s, m, buf);
 		ast_bridge_destroy(bridge);
@@ -7290,7 +7314,7 @@
 	}
 
 	ast_after_bridge_set_go_on(chanb, chanb_context, chanb_exten, chanb_priority, NULL);
-	if (add_to_bridge(bridge, chanb, NULL, ast_true(playtone))) {
+	if (add_to_bridge(bridge, chanb, NULL, playtone & PLAYTONE_CHANNEL2)) {
 		snprintf(buf, sizeof(buf), "Unable to add Channel2 to bridge: %s", ast_channel_name(chanb));
 		astman_send_error(s, m, buf);
 		ast_bridge_destroy(bridge);




More information about the asterisk-commits mailing list