[asterisk-commits] mmichelson: trunk r396107 - in /trunk: include/asterisk/ main/ res/parking/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 2 09:13:12 CDT 2013


Author: mmichelson
Date: Fri Aug  2 09:13:04 2013
New Revision: 396107

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396107
Log:
Make a couple of changes to help AMI events to be more clear in what is occurring.

* BridgeEnter now contains the unique ID of the channel that is to be swapped out, if applicable.
* There is a ParkedCallSwap event that is sent when a parked channel has a new channel take its place.

(closes issue ASTERISK-22193)
reported by Mark Michelson

Review: https://reviewboard.asterisk.org/r/2712


Modified:
    trunk/include/asterisk/parking.h
    trunk/include/asterisk/stasis_bridges.h
    trunk/main/bridge_channel.c
    trunk/main/cel.c
    trunk/main/manager_bridges.c
    trunk/main/stasis_bridges.c
    trunk/res/parking/parking_bridge.c
    trunk/res/parking/parking_manager.c

Modified: trunk/include/asterisk/parking.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/parking.h?view=diff&rev=396107&r1=396106&r2=396107
==============================================================================
--- trunk/include/asterisk/parking.h (original)
+++ trunk/include/asterisk/parking.h Fri Aug  2 09:13:04 2013
@@ -45,6 +45,7 @@
 	PARKED_CALL_GIVEUP,
 	PARKED_CALL_UNPARKED,
 	PARKED_CALL_FAILED,
+	PARKED_CALL_SWAP,
 };
 
 /*!

Modified: trunk/include/asterisk/stasis_bridges.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/stasis_bridges.h?view=diff&rev=396107&r1=396106&r2=396107
==============================================================================
--- trunk/include/asterisk/stasis_bridges.h (original)
+++ trunk/include/asterisk/stasis_bridges.h Fri Aug  2 09:13:04 2013
@@ -215,8 +215,10 @@
  *
  * \param bridge The bridge a channel entered
  * \param chan The channel that entered the bridge
- */
-void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel *chan);
+ * \param swap The channel being swapped out of the bridge
+ */
+void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel *chan,
+		struct ast_channel *swap);
 
 /*!
  * \since 12

Modified: trunk/main/bridge_channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridge_channel.c?view=diff&rev=396107&r1=396106&r2=396107
==============================================================================
--- trunk/main/bridge_channel.c (original)
+++ trunk/main/bridge_channel.c Fri Aug  2 09:13:04 2013
@@ -1429,7 +1429,7 @@
 		bridge->v_table->name,
 		bridge->uniqueid);
 
-	ast_bridge_publish_enter(bridge, bridge_channel->chan);
+	ast_bridge_publish_enter(bridge, bridge_channel->chan, swap ? swap->chan : NULL);
 	if (swap) {
 		ast_bridge_channel_leave_bridge(swap, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 		bridge_channel_internal_pull(swap);

Modified: trunk/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cel.c?view=diff&rev=396107&r1=396106&r2=396107
==============================================================================
--- trunk/main/cel.c (original)
+++ trunk/main/cel.c Fri Aug  2 09:13:04 2013
@@ -1304,6 +1304,9 @@
 	case PARKED_CALL_FAILED:
 		reason = "ParkedCallFailed";
 		break;
+	case PARKED_CALL_SWAP:
+		reason = "ParkedCallSwap";
+		break;
 	}
 
 	extra = ast_json_pack("{s: s}", "reason", reason);

Modified: trunk/main/manager_bridges.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager_bridges.c?view=diff&rev=396107&r1=396106&r2=396107
==============================================================================
--- trunk/main/manager_bridges.c (original)
+++ trunk/main/manager_bridges.c Fri Aug  2 09:13:04 2013
@@ -58,6 +58,9 @@
 			<syntax>
 				<bridge_snapshot/>
 				<channel_snapshot/>
+				<parameter name="SwapUniqueid">
+					<para>The uniqueid of the channel being swapped out of the bridge</para>
+				</parameter>
 			</syntax>
 		</managerEventInstance>
 	</managerEvent>
@@ -247,9 +250,11 @@
 				    struct stasis_topic *topic,
 				    struct stasis_message *message)
 {
+	static const char *swap_name = "SwapUniqueid: ";
 	struct ast_bridge_blob *blob = stasis_message_data(message);
 	RAII_VAR(struct ast_str *, bridge_text, NULL, ast_free);
 	RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);
+	const char *swap_id;
 
 	bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
 	channel_text = ast_manager_build_channel_state_string(blob->channel);
@@ -257,11 +262,17 @@
 		return;
 	}
 
+	swap_id = ast_json_string_get(ast_json_object_get(blob->blob, "swap"));
+
 	manager_event(EVENT_FLAG_CALL, "BridgeEnter",
 		"%s"
-		"%s",
+		"%s"
+		"%s%s%s",
 		ast_str_buffer(bridge_text),
-		ast_str_buffer(channel_text));
+		ast_str_buffer(channel_text),
+		swap_id ? swap_name : "",
+		S_OR(swap_id, ""),
+		swap_id ? "\r\n" : "");
 }
 
 static void channel_leave_cb(void *data, struct stasis_subscription *sub,

Modified: trunk/main/stasis_bridges.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis_bridges.c?view=diff&rev=396107&r1=396106&r2=396107
==============================================================================
--- trunk/main/stasis_bridges.c (original)
+++ trunk/main/stasis_bridges.c Fri Aug  2 09:13:04 2013
@@ -380,11 +380,20 @@
 	return msg;
 }
 
-void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel *chan)
-{
-	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-
-	msg = ast_bridge_blob_create(ast_channel_entered_bridge_type(), bridge, chan, NULL);
+void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel *chan,
+		struct ast_channel *swap)
+{
+	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_json *, blob, NULL, ao2_cleanup);
+
+	if (swap) {
+		blob = ast_json_pack("{s: s}", "swap", ast_channel_uniqueid(swap));
+		if (!blob) {
+			return;
+		}
+	}
+
+	msg = ast_bridge_blob_create(ast_channel_entered_bridge_type(), bridge, chan, blob);
 	if (!msg) {
 		return;
 	}

Modified: trunk/res/parking/parking_bridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/parking/parking_bridge.c?view=diff&rev=396107&r1=396106&r2=396107
==============================================================================
--- trunk/res/parking/parking_bridge.c (original)
+++ trunk/res/parking/parking_bridge.c Fri Aug  2 09:13:04 2013
@@ -254,6 +254,8 @@
 				ast_channel_name(bridge_channel->chan));
 		}
 
+		publish_parked_call(pu, PARKED_CALL_SWAP);
+
 		return 0;
 	}
 

Modified: trunk/res/parking/parking_manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/parking/parking_manager.c?view=diff&rev=396107&r1=396106&r2=396107
==============================================================================
--- trunk/res/parking/parking_manager.c (original)
+++ trunk/res/parking/parking_manager.c Fri Aug  2 09:13:04 2013
@@ -526,6 +526,9 @@
 	case PARKED_CALL_UNPARKED:
 		event_type = "UnParkedCall";
 		break;
+	case PARKED_CALL_SWAP:
+		event_type = "ParkedCallSwap";
+		break;
 	case PARKED_CALL_FAILED:
 		/* PARKED_CALL_FAILED doesn't currently get a message and is used exclusively for bridging */
 		return;




More information about the asterisk-commits mailing list