[asterisk-commits] mmichelson: branch mmichelson/atxfer_features r393462 - in /team/mmichelson/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 2 13:25:29 CDT 2013


Author: mmichelson
Date: Tue Jul  2 13:25:27 2013
New Revision: 393462

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393462
Log:
Add stasis publications for successful transfers.

I had to modify the attended transfer publish message a bit
to accommodate threeway calls.


Modified:
    team/mmichelson/atxfer_features/include/asterisk/stasis_bridging.h
    team/mmichelson/atxfer_features/main/bridging_basic.c
    team/mmichelson/atxfer_features/main/stasis_bridging.c

Modified: team/mmichelson/atxfer_features/include/asterisk/stasis_bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/include/asterisk/stasis_bridging.h?view=diff&rev=393462&r1=393461&r2=393462
==============================================================================
--- team/mmichelson/atxfer_features/include/asterisk/stasis_bridging.h (original)
+++ team/mmichelson/atxfer_features/include/asterisk/stasis_bridging.h Tue Jul  2 13:25:27 2013
@@ -274,6 +274,8 @@
 	AST_ATTENDED_TRANSFER_DEST_APP,
 	/*! The transfer results in both bridges remaining with a local channel linking them */
 	AST_ATTENDED_TRANSFER_DEST_LINK,
+	/*! The transfer results in a threeway call between transferer, transferee, and transfer target */
+	AST_ATTENDED_TRANSFER_DEST_THREEWAY,
 };
 
 /*!
@@ -297,6 +299,8 @@
 		char app[AST_MAX_APP];
 		/*! Pair of local channels linking the bridges. Applicable for AST_ATTENDED_TRANSFER_DEST_LINK */
 		struct ast_channel_snapshot *links[2];
+		/*! Transferer channel and bridge that survived the transition to a threeway call. Applicable for AST_ATTENDED_TRANSFER_DEST_THREEWAY */
+		struct ast_bridge_channel_snapshot_pair threeway;
 	} dest;
 };
 
@@ -348,6 +352,25 @@
 
 /*!
  * \since 12
+ * \brief Publish an attended transfer that results in a threeway call.
+ *
+ * Publish an \ref ast_attended_transfer_message with the dest_type set to
+ * \c AST_ATTENDED_TRANSFER_DEST_THREEWAY. Like with \ref ast_bridge_publish_attended_transfer_bridge_merge,
+ * this results from merging two bridges together. The difference is that a
+ * transferer channel survives the bridge merge
+ *
+ * \param is_external Indicates if the transfer was initiated externally
+ * \param result The result of the transfer.
+ * \param transferee The bridge between the transferer and transferees as well as the transferer channel from that bridge
+ * \param target The bridge between the transferer and transfer targets as well as the transferer channel from that bridge
+ * \param final_pair The bridge that the parties end up in, and the transferer channel that is in this bridge.
+ */
+void ast_bridge_publish_attended_transfer_threeway(int is_external, enum ast_transfer_result result,
+		struct ast_bridge_channel_pair *transferee, struct ast_bridge_channel_pair *target,
+		struct ast_bridge_channel_pair *final_pair);
+
+/*!
+ * \since 12
  * \brief Publish an attended transfer that results in an application being run
  *
  * Publish an \ref ast_attended_transfer_message with the dest_type set to

Modified: team/mmichelson/atxfer_features/main/bridging_basic.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/bridging_basic.c?view=diff&rev=393462&r1=393461&r2=393462
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging_basic.c (original)
+++ team/mmichelson/atxfer_features/main/bridging_basic.c Tue Jul  2 13:25:27 2013
@@ -43,6 +43,7 @@
 #include "asterisk/app.h"
 #include "asterisk/bridging_private.h"
 #include "asterisk/dial.h"
+#include "asterisk/stasis_bridging.h"
 
 #define NORMAL_FLAGS	AST_BRIDGE_FLAG_DISSOLVE_HANGUP | AST_BRIDGE_FLAG_DISSOLVE_EMPTY \
 			| AST_BRIDGE_FLAG_SMART
@@ -1056,6 +1057,40 @@
 	clear_stimulus_queue(props);
 
 	ao2_cleanup(props);
+}
+
+static void publish_transfer_success(struct attended_transfer_properties *props)
+{
+	struct ast_bridge_channel_pair transferee = {
+		.channel = props->transferer,
+		.bridge = props->transferee_bridge,
+	};
+	struct ast_bridge_channel_pair transfer_target = {
+		.channel = props->transferer,
+		.bridge = props->target_bridge,
+	};
+
+	ast_bridge_publish_attended_transfer_bridge_merge(0, AST_BRIDGE_TRANSFER_SUCCESS,
+			&transferee, &transfer_target, props->transferee_bridge);
+}
+
+static void publish_transfer_threeway(struct attended_transfer_properties *props)
+{
+	struct ast_bridge_channel_pair transferee = {
+		.channel = props->transferer,
+		.bridge = props->transferee_bridge,
+	};
+	struct ast_bridge_channel_pair transfer_target = {
+		.channel = props->transferer,
+		.bridge = props->target_bridge,
+	};
+	struct ast_bridge_channel_pair threeway = {
+		.channel = props->transferer,
+		.bridge = props->transferee_bridge,
+	};
+
+	ast_bridge_publish_attended_transfer_threeway(0, AST_BRIDGE_TRANSFER_SUCCESS,
+			&transferee, &transfer_target, &threeway);
 }
 
 static void play_sound(struct ast_channel *chan, const char *sound)
@@ -1465,6 +1500,7 @@
 static int threeway_enter(struct attended_transfer_properties *props)
 {
 	bridge_merge(props->transferee_bridge, props->target_bridge, NULL, 0);
+	publish_transfer_threeway(props);
 
 	return 0;
 }
@@ -1554,6 +1590,7 @@
 static int complete_enter(struct attended_transfer_properties *props)
 {
 	bridge_merge(props->transferee_bridge, props->target_bridge, &props->transferer, 1);
+	publish_transfer_success(props);
 	return 0;
 }
 
@@ -1561,6 +1598,7 @@
 {
 	bridge_merge(props->transferee_bridge, props->target_bridge, &props->transferer, 1);
 	ringing(props->transfer_target);
+	publish_transfer_success(props);
 	return 0;
 }
 

Modified: team/mmichelson/atxfer_features/main/stasis_bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/stasis_bridging.c?view=diff&rev=393462&r1=393461&r2=393462
==============================================================================
--- team/mmichelson/atxfer_features/main/stasis_bridging.c (original)
+++ team/mmichelson/atxfer_features/main/stasis_bridging.c Tue Jul  2 13:25:27 2013
@@ -221,12 +221,13 @@
 						<enum name="Bridge"><para>The transfer was accomplished by merging two bridges into one.</para></enum>
 						<enum name="App"><para>The transfer was accomplished by having a channel or bridge run a dialplan application.</para></enum>
 						<enum name="Link"><para>The transfer was accomplished by linking two bridges together using a local channel pair.</para></enum>
+						<enum name="Threeway"><para>The transfer was accomplished by placing all parties into a threeway call.</para></enum>
 						<enum name="Fail"><para>The transfer failed.</para></enum>
 					</enumlist>
 				</parameter>
 				<parameter name="DestBridgeUniqueid">
 					<para>Indicates the surviving bridge when bridges were merged to complete the transfer</para>
-					<note><para>This header is only present when <replaceable>DestType</replaceable> is <literal>Bridge</literal></para></note>
+					<note><para>This header is only present when <replaceable>DestType</replaceable> is <literal>Bridge</literal> or <literal>Threeway</literal></para></note>
 				</parameter>
 				<parameter name="DestApp">
 					<para>Indicates the application that is running when the transfer completes</para>
@@ -332,6 +333,10 @@
 				</parameter>
 				<parameter name="LocalTwoUniqueid">
 					<note><para>This header is only present when <replaceable>DestType</replaceable> is <literal>Link</literal></para></note>
+				</parameter>
+				<parameter name="DestTransfererChannel">
+					<para>The surviving transferer channel when a transfer results in a threeway call</para>
+					<note><para>This header is only present when <replaceable>DestType</replaceable> is <literal>Threeway</literal></para></note>
 				</parameter>
 			</syntax>
 			<description>
@@ -835,6 +840,10 @@
 		ast_str_append(&variable_data, 0, "%s", ast_str_buffer(local1_state));
 		ast_str_append(&variable_data, 0, "%s", ast_str_buffer(local2_state));
 		break;
+	case AST_ATTENDED_TRANSFER_DEST_THREEWAY:
+		ast_str_append(&variable_data, 0, "DestType: Threeway\r\n");
+		ast_str_append(&variable_data, 0, "DestBridgeUniqueid: %s\r\n", transfer_msg->dest.threeway.bridge_snapshot->uniqueid);
+		ast_str_append(&variable_data, 0, "DestTransfererChannel: %s\r\n", transfer_msg->dest.threeway.channel_snapshot->name);
 	case AST_ATTENDED_TRANSFER_DEST_FAIL:
 		ast_str_append(&variable_data, 0, "DestType: Fail\r\n");
 		break;
@@ -941,6 +950,39 @@
 	stasis_publish(ast_bridge_topic_all(), msg);
 }
 
+void ast_bridge_publish_attended_transfer_threeway(int is_external, enum ast_transfer_result result,
+		struct ast_bridge_channel_pair *transferee, struct ast_bridge_channel_pair *target,
+		struct ast_bridge_channel_pair *final_pair)
+{
+	RAII_VAR(struct ast_attended_transfer_message *, transfer_msg, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+
+	transfer_msg = attended_transfer_message_create(is_external, result, transferee, target);
+	if (!transfer_msg) {
+		return;
+	}
+
+	transfer_msg->dest_type = AST_ATTENDED_TRANSFER_DEST_THREEWAY;
+	if (final_pair->channel == transferee->channel) {
+		transfer_msg->dest.threeway.channel_snapshot = transfer_msg->to_transferee.channel_snapshot;
+	} else {
+		transfer_msg->dest.threeway.channel_snapshot = transfer_msg->to_transfer_target.channel_snapshot;
+	}
+
+	if (final_pair->bridge == transferee->bridge) {
+		transfer_msg->dest.threeway.bridge_snapshot = transfer_msg->to_transferee.bridge_snapshot;
+	} else {
+		transfer_msg->dest.threeway.bridge_snapshot = transfer_msg->to_transfer_target.bridge_snapshot;
+	}
+
+	msg = stasis_message_create(ast_attended_transfer_type(), transfer_msg);
+	if (!msg) {
+		return;
+	}
+
+	stasis_publish(ast_bridge_topic_all(), msg);
+}
+
 void ast_bridge_publish_attended_transfer_app(int is_external, enum ast_transfer_result result,
 		struct ast_bridge_channel_pair *transferee, struct ast_bridge_channel_pair *target,
 		const char *dest_app)




More information about the asterisk-commits mailing list