[asterisk-commits] mmichelson: branch mmichelson/transfer_stasis r391426 - /team/mmichelson/tran...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 11 12:58:04 CDT 2013


Author: mmichelson
Date: Tue Jun 11 12:58:03 2013
New Revision: 391426

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391426
Log:
Change control flow so that attended transfers can publish appropriate stasis messages.


Modified:
    team/mmichelson/transfer_stasis/main/bridging.c

Modified: team/mmichelson/transfer_stasis/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/transfer_stasis/main/bridging.c?view=diff&rev=391426&r1=391425&r2=391426
==============================================================================
--- team/mmichelson/transfer_stasis/main/bridging.c (original)
+++ team/mmichelson/transfer_stasis/main/bridging.c Tue Jun 11 12:58:03 2013
@@ -5660,6 +5660,11 @@
 		return AST_BRIDGE_TRANSFER_FAIL;
 	}
 
+	if (bridge2) {
+		/* XXX Publish stasis link attended transfer */
+	} else {
+		/* XXX Publish stasis app attended transfer */
+	}
 	return AST_BRIDGE_TRANSFER_SUCCESS;
 }
 
@@ -6019,18 +6024,23 @@
 			to_transferee_bridge_channel,
 			to_target_bridge_channel,
 	};
+	enum ast_transfer_result res;
 
 	switch (ast_bridges_allow_optimization(to_transferee_bridge, to_target_bridge)) {
 	case AST_BRIDGE_OPTIMIZE_SWAP_TO_CHAN_BRIDGE:
-		return bridge_swap_attended_transfer(to_transferee_bridge, to_target_bridge_channel, to_transferee);
+		res = bridge_swap_attended_transfer(to_transferee_bridge, to_target_bridge_channel, to_transferee);
+		goto end;
 	case AST_BRIDGE_OPTIMIZE_SWAP_TO_PEER_BRIDGE:
-		return bridge_swap_attended_transfer(to_target_bridge, to_transferee_bridge_channel, to_transfer_target);
+		res = bridge_swap_attended_transfer(to_target_bridge, to_transferee_bridge_channel, to_transfer_target);
+		goto end;
 	case AST_BRIDGE_OPTIMIZE_MERGE_TO_CHAN_BRIDGE:
 		bridge_merge_do(to_transferee_bridge, to_target_bridge, kick_me, ARRAY_LEN(kick_me));
-		return AST_BRIDGE_TRANSFER_SUCCESS;
+		res = AST_BRIDGE_TRANSFER_SUCCESS;
+		goto end;
 	case AST_BRIDGE_OPTIMIZE_MERGE_TO_PEER_BRIDGE:
 		bridge_merge_do(to_target_bridge, to_transferee_bridge, kick_me, ARRAY_LEN(kick_me));
-		return AST_BRIDGE_TRANSFER_SUCCESS;
+		res = AST_BRIDGE_TRANSFER_SUCCESS;
+		goto end;
 	case AST_BRIDGE_OPTIMIZE_PROHIBITED:
 	default:
 		/* Just because optimization wasn't doable doesn't necessarily mean
@@ -6039,11 +6049,23 @@
 		 */
 		if (to_transferee_bridge->inhibit_merge || to_transferee_bridge->dissolved ||
 				to_target_bridge->inhibit_merge || to_target_bridge->dissolved) {
-			return AST_BRIDGE_TRANSFER_INVALID;
-		}
+			res = AST_BRIDGE_TRANSFER_INVALID;
+			goto end;
+		}
+
+		/* Don't goto end here. attended_transfer_bridge will publish its own
+		 * stasis message if it succeeds
+		 */
 		return attended_transfer_bridge(to_transferee, to_transfer_target,
 			to_transferee_bridge, to_target_bridge);
 	}
+
+end:
+	if (res == AST_BRIDGE_TRANSFER_SUCCESS) {
+		/* XXX Publish stasis bridge merge attended transfer */
+	}
+
+	return res;
 }
 
 enum ast_transfer_result ast_bridge_transfer_attended(struct ast_channel *to_transferee,
@@ -6060,13 +6082,15 @@
 	struct ast_channel *chan_unbridged;
 	int transfer_prohibited;
 	int do_bridge_transfer;
+	enum ast_transfer_result res;
 
 	to_transferee_bridge = acquire_bridge(to_transferee);
 	to_target_bridge = acquire_bridge(to_transfer_target);
 
 	/* They can't both be unbridged, you silly goose! */
 	if (!to_transferee_bridge && !to_target_bridge) {
-		return AST_BRIDGE_TRANSFER_INVALID;
+		res = AST_BRIDGE_TRANSFER_INVALID;
+		goto end;
 	}
 
 	ast_channel_lock(to_transferee);
@@ -6117,10 +6141,10 @@
 
 	/* Let's get the easy one out of the way first */
 	if (to_transferee_bridge && to_target_bridge) {
-		enum ast_transfer_result res;
 
 		if (!to_transferee_bridge_channel || !to_target_bridge_channel) {
-			return AST_BRIDGE_TRANSFER_INVALID;
+			res = AST_BRIDGE_TRANSFER_INVALID;
+			goto end;
 		}
 
 		ast_bridge_lock_both(to_transferee_bridge, to_target_bridge);
@@ -6130,7 +6154,7 @@
 		ast_bridge_unlock(to_transferee_bridge);
 		ast_bridge_unlock(to_target_bridge);
 
-		return res;
+		goto end;
 	}
 
 	the_bridge = to_transferee_bridge ?: to_target_bridge;
@@ -6143,11 +6167,13 @@
 
 		channels = ast_bridge_peers_nolock(the_bridge);
 		if (!channels) {
-			return AST_BRIDGE_TRANSFER_FAIL;
+			res = AST_BRIDGE_TRANSFER_FAIL;
+			goto end;
 		}
 		chan_count = ao2_container_count(channels);
 		if (chan_count <= 1) {
-			return AST_BRIDGE_TRANSFER_INVALID;
+			res = AST_BRIDGE_TRANSFER_INVALID;
+			goto end;
 		}
 		transfer_prohibited = ast_test_flag(&the_bridge->feature_flags,
 				AST_BRIDGE_FLAG_TRANSFER_PROHIBITED);
@@ -6157,24 +6183,38 @@
 	}
 
 	if (transfer_prohibited) {
-		return AST_BRIDGE_TRANSFER_NOT_PERMITTED;
+		res = AST_BRIDGE_TRANSFER_NOT_PERMITTED;
+		goto end;
 	}
 
 	if (do_bridge_transfer) {
-		return attended_transfer_bridge(chan_bridged, chan_unbridged, the_bridge, NULL);
+		 res = attended_transfer_bridge(chan_bridged, chan_unbridged, the_bridge, NULL);
+		 goto end;
 	}
 
 	transferee = get_transferee(channels, chan_bridged);
 	if (!transferee) {
-		return AST_BRIDGE_TRANSFER_FAIL;
+		res = AST_BRIDGE_TRANSFER_FAIL;
+		goto end;
 	}
 
 	if (bridge_channel_queue_attended_transfer(transferee, chan_unbridged)) {
-		return AST_BRIDGE_TRANSFER_FAIL;
+		res = AST_BRIDGE_TRANSFER_FAIL;
+		goto end;
 	}
 
 	ast_bridge_remove(the_bridge, chan_bridged);
+	/* XXX Publish stasis app attended transfer message */
 	return AST_BRIDGE_TRANSFER_SUCCESS;
+
+end:
+	/* All successful transfer paths have published an appropriate stasis message.
+	 * All failure paths have deferred publishing a stasis message until this point
+	 */
+	if (res != AST_BRIDGE_TRANSFER_SUCCESS) {
+		/* XXX Publish stasis failed attended transfer message */
+	}
+	return res;
 }
 
 /*!




More information about the asterisk-commits mailing list