[svn-commits] kmoore: branch kmoore/cel_transfers r393888 - in /team/kmoore/cel_transfers: ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jul 9 11:58:10 CDT 2013


Author: kmoore
Date: Tue Jul  9 11:58:08 2013
New Revision: 393888

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393888
Log:
Refactor extra text to key-value pairs

Modified:
    team/kmoore/cel_transfers/CHANGES
    team/kmoore/cel_transfers/apps/app_celgenuserevent.c
    team/kmoore/cel_transfers/include/asterisk/cel.h
    team/kmoore/cel_transfers/main/cel.c
    team/kmoore/cel_transfers/tests/test_cel.c

Modified: team/kmoore/cel_transfers/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_transfers/CHANGES?view=diff&rev=393888&r1=393887&r2=393888
==============================================================================
--- team/kmoore/cel_transfers/CHANGES (original)
+++ team/kmoore/cel_transfers/CHANGES Tue Jul  9 11:58:08 2013
@@ -309,17 +309,20 @@
 
 CEL (Channel Event Logging)
 ------------------
+ * The 'extra' field of all CEL events that use it now consists of a JSON blob
+   with key/value pairs which are defined in the Asterisk 12 CEL documentation.
+
  * AST_CEL_BLINDTRANSFER events now report the transferee bridge unique
-   identifier, extension, and context in the extra string instead of
-   the transferee channel name as the peer.
+   identifier, extension, and context in a JSON blob as the extra string
+   instead of the transferee channel name as the peer.
 
  * AST_CEL_ATTENDEDTRANSFER events now report the peer as NULL and additional
-   information in the 'extra' string. For transfers that occur between two
-   bridged channels, the 'extra' string contains the primary bridge unique
-   identifier, the secondary channel name, and the secondary bridge unique
-   identifier. For transfers that occur between a bridged channel and a
-   channel running an app, the 'extra' string contains the primary bridge
-   unique identifier, the secondary channel name, and the app name.
+   information in the 'extra' string as a JSON blob. For transfers that occur
+   between two bridged channels, the 'extra' JSON blob contains the primary
+   bridge unique identifier, the secondary channel name, and the secondary
+   bridge unique identifier. For transfers that occur between a bridged channel
+   and a channel running an app, the 'extra' JSON blob contains the primary
+   bridge unique identifier, the secondary channel name, and the app name.
 
 Features
 -------------------

Modified: team/kmoore/cel_transfers/apps/app_celgenuserevent.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_transfers/apps/app_celgenuserevent.c?view=diff&rev=393888&r1=393887&r2=393888
==============================================================================
--- team/kmoore/cel_transfers/apps/app_celgenuserevent.c (original)
+++ team/kmoore/cel_transfers/apps/app_celgenuserevent.c Tue Jul  9 11:58:08 2013
@@ -75,9 +75,9 @@
 	parse = ast_strdupa(data);
 	AST_STANDARD_APP_ARGS(args, parse);
 
-	blob = ast_json_pack("{s: s, s: s}",
+	blob = ast_json_pack("{s: s, s: {s: s}}",
 		"event", args.event,
-		"extra", args.extra);
+		"extra", "extra", args.extra);
 	if (!blob) {
 		return res;
 	}

Modified: team/kmoore/cel_transfers/include/asterisk/cel.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_transfers/include/asterisk/cel.h?view=diff&rev=393888&r1=393887&r2=393888
==============================================================================
--- team/kmoore/cel_transfers/include/asterisk/cel.h (original)
+++ team/kmoore/cel_transfers/include/asterisk/cel.h Tue Jul  9 11:58:08 2013
@@ -310,8 +310,8 @@
  *        with this channel event.
  * \param event_type The type of call event being reported.
  * \param userdefevname Custom name for the call event. (optional)
- * \param extra An opaque field that will go into the "CEL_EXTRA" information
- *        element of the call event. (optional)
+ * \param extra An event-specific opaque JSON blob to be rendered and placed
+ *        in the "CEL_EXTRA" information element of the call event. (optional)
  * \param peer_name The peer name to be placed into the event. (optional)
  *
  * \since 12
@@ -321,7 +321,7 @@
  */
 struct ast_event *ast_cel_create_event(struct ast_channel_snapshot *snapshot,
 		enum ast_cel_event_type event_type, const char *userdefevname,
-		const char *extra, const char *peer_name);
+		struct ast_json *extra, const char *peer_name);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: team/kmoore/cel_transfers/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_transfers/main/cel.c?view=diff&rev=393888&r1=393887&r2=393888
==============================================================================
--- team/kmoore/cel_transfers/main/cel.c (original)
+++ team/kmoore/cel_transfers/main/cel.c Tue Jul  9 11:58:08 2013
@@ -633,9 +633,13 @@
 static int cel_linkedid_ref(const char *linkedid);
 struct ast_event *ast_cel_create_event(struct ast_channel_snapshot *snapshot,
 		enum ast_cel_event_type event_type, const char *userdefevname,
-		const char *extra, const char *peer_name)
+		struct ast_json *extra, const char *peer_name)
 {
 	struct timeval eventtime = ast_tvnow();
+	RAII_VAR(char *, extra_txt, NULL, ast_free);
+	if (extra) {
+		extra_txt = ast_json_dump_string(extra);
+	}
 	return ast_event_new(AST_EVENT_CEL,
 		AST_EVENT_IE_CEL_EVENT_TYPE, AST_EVENT_IE_PLTYPE_UINT, event_type,
 		AST_EVENT_IE_CEL_EVENT_TIME, AST_EVENT_IE_PLTYPE_UINT, eventtime.tv_sec,
@@ -657,14 +661,14 @@
 		AST_EVENT_IE_CEL_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, snapshot->uniqueid,
 		AST_EVENT_IE_CEL_LINKEDID, AST_EVENT_IE_PLTYPE_STR, snapshot->linkedid,
 		AST_EVENT_IE_CEL_USERFIELD, AST_EVENT_IE_PLTYPE_STR, snapshot->userfield,
-		AST_EVENT_IE_CEL_EXTRA, AST_EVENT_IE_PLTYPE_STR, S_OR(extra, ""),
+		AST_EVENT_IE_CEL_EXTRA, AST_EVENT_IE_PLTYPE_STR, S_OR(extra_txt, ""),
 		AST_EVENT_IE_CEL_PEER, AST_EVENT_IE_PLTYPE_STR, S_OR(peer_name, ""),
 		AST_EVENT_IE_END);
 }
 
 static int report_event_snapshot(struct ast_channel_snapshot *snapshot,
 		enum ast_cel_event_type event_type, const char *userdefevname,
-		const char *extra, const char *peer2_name)
+		struct ast_json *extra, const char *peer2_name)
 {
 	struct ast_event *ev;
 	char *linkedid = ast_strdupa(snapshot->linkedid);
@@ -1087,17 +1091,17 @@
 	is_hungup = ast_test_flag(&new_snapshot->flags, AST_FLAG_DEAD) ? 1 : 0;
 
 	if (!was_hungup && is_hungup) {
-		RAII_VAR(struct ast_str *, extra_str, ast_str_create(128), ast_free);
+		RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
 		RAII_VAR(struct ast_multi_channel_blob *, blob, get_dialstatus_blob(new_snapshot->uniqueid), ao2_cleanup);
 		const char *dialstatus = "";
 		if (blob && !ast_strlen_zero(get_blob_variable(blob, "dialstatus"))) {
 			dialstatus = get_blob_variable(blob, "dialstatus");
 		}
-		ast_str_set(&extra_str, 0, "%d,%s,%s",
-			new_snapshot->hangupcause,
-			new_snapshot->hangupsource,
-			dialstatus);
-		report_event_snapshot(new_snapshot, AST_CEL_HANGUP, NULL, ast_str_buffer(extra_str), NULL);
+		extra = ast_json_pack("{s: i, s: s, s: s}",
+			"hangupcause", new_snapshot->hangupcause,
+			"hangupsource", new_snapshot->hangupsource,
+			"dialstatus", dialstatus);
+		report_event_snapshot(new_snapshot, AST_CEL_HANGUP, NULL, extra, NULL);
 		return;
 	}
 
@@ -1238,7 +1242,11 @@
 
 	if (snapshot->capabilities & (AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE)) {
 		if (assoc && assoc->track_as_conf) {
-			report_event_snapshot(chan_snapshot, AST_CEL_CONF_ENTER, NULL, snapshot->uniqueid, NULL);
+			RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
+			extra = ast_json_pack("{s: s}", "bridge_id", snapshot->uniqueid);
+			if (extra) {
+				report_event_snapshot(chan_snapshot, AST_CEL_CONF_ENTER, NULL, extra, NULL);
+			}
 			return;
 		}
 
@@ -1273,24 +1281,31 @@
 
 			/* this bridge will no longer be treated like a bridge, so mark the bridge_assoc as such */
 			if (!assoc->track_as_conf) {
-				RAII_VAR(struct ast_str *, extra, ast_str_create(64), ast_free);
+				RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
 				assoc->track_as_conf = 1;
 
+				extra = ast_json_pack("{s: s, s: s}",
+					"channel_name", chan_snapshot->name,
+					"bridge_id", snapshot->uniqueid);
+
 				if (extra) {
-					ast_str_set(&extra, 0, "%s,%s", chan_snapshot->name, snapshot->uniqueid);
 					report_event_snapshot(assoc->primary_snapshot, AST_CEL_BRIDGE_TO_CONF, NULL,
-						ast_str_buffer(extra), assoc->secondary_name);
+						extra, assoc->secondary_name);
 				}
 
 				ast_string_field_set(assoc, secondary_name, "");
 			}
 		}
 	} else if (snapshot->capabilities & AST_BRIDGE_CAPABILITY_MULTIMIX) {
+		RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
 		if (!assoc) {
 			add_bridge_primary(chan_snapshot, snapshot->uniqueid, "");
 			return;
 		}
-		report_event_snapshot(chan_snapshot, AST_CEL_CONF_ENTER, NULL, snapshot->uniqueid, NULL);
+		extra = ast_json_pack("{s: s}", "bridge_id", snapshot->uniqueid);
+		if (extra) {
+			report_event_snapshot(chan_snapshot, AST_CEL_CONF_ENTER, NULL, extra, NULL);
+		}
 	}
 }
 
@@ -1313,7 +1328,11 @@
 		}
 
 		if (assoc->track_as_conf) {
-			report_event_snapshot(chan_snapshot, AST_CEL_CONF_EXIT, NULL, snapshot->uniqueid, NULL);
+			RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
+			extra = ast_json_pack("{s: s}", "bridge_id", snapshot->uniqueid);
+			if (extra) {
+				report_event_snapshot(chan_snapshot, AST_CEL_CONF_EXIT, NULL, extra, NULL);
+			}
 			return;
 		}
 
@@ -1323,7 +1342,11 @@
 			return;
 		}
 	} else if (snapshot->capabilities & AST_BRIDGE_CAPABILITY_MULTIMIX) {
-		report_event_snapshot(chan_snapshot, AST_CEL_CONF_EXIT, NULL, snapshot->uniqueid, NULL);
+		RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
+		extra = ast_json_pack("{s: s}", "bridge_id", snapshot->uniqueid);
+		if (extra) {
+			report_event_snapshot(chan_snapshot, AST_CEL_CONF_EXIT, NULL, extra, NULL);
+		}
 	}
 }
 
@@ -1333,25 +1356,35 @@
 	struct stasis_message *message)
 {
 	struct ast_parked_call_payload *parked_payload = stasis_message_data(message);
+	RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
+	const char *reason = NULL;
 
 	switch (parked_payload->event_type) {
 	case PARKED_CALL:
-		report_event_snapshot(parked_payload->parkee, AST_CEL_PARK_START, NULL,
-			parked_payload->parkinglot,
-			parked_payload->parker_dial_string);
-		break;
+		extra = ast_json_pack("{s: s, s: s}",
+			"parker_dial_string", parked_payload->parker_dial_string,
+			"parking_lot", parked_payload->parkinglot);
+		if (extra) {
+			report_event_snapshot(parked_payload->parkee, AST_CEL_PARK_START, NULL, extra, NULL);
+		}
+		return;
 	case PARKED_CALL_TIMEOUT:
-		report_event_snapshot(parked_payload->parkee, AST_CEL_PARK_END, NULL, "ParkedCallTimeOut", NULL);
+		reason = "ParkedCallTimeOut";
 		break;
 	case PARKED_CALL_GIVEUP:
-		report_event_snapshot(parked_payload->parkee, AST_CEL_PARK_END, NULL, "ParkedCallGiveUp", NULL);
+		reason = "ParkedCallGiveUp";
 		break;
 	case PARKED_CALL_UNPARKED:
-		report_event_snapshot(parked_payload->parkee, AST_CEL_PARK_END, NULL, "ParkedCallUnparked", NULL);
+		reason = "ParkedCallUnparked";
 		break;
 	case PARKED_CALL_FAILED:
-		report_event_snapshot(parked_payload->parkee, AST_CEL_PARK_END, NULL, "ParkedCallFailed", NULL);
+		reason = "ParkedCallFailed";
 		break;
+	}
+
+	extra = ast_json_pack("{s: s}", "reason", reason);
+	if (extra) {
+		report_event_snapshot(parked_payload->parkee, AST_CEL_PARK_END, NULL, extra, NULL);
 	}
 }
 
@@ -1372,11 +1405,15 @@
 
 	if (!ast_strlen_zero(get_blob_variable(blob, "forward"))) {
 		struct ast_channel_snapshot *caller = ast_multi_channel_blob_get_channel(blob, "caller");
+		RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
 		if (!caller) {
 			return;
 		}
 
-		report_event_snapshot(caller, AST_CEL_FORWARD, NULL, get_blob_variable(blob, "forward"), NULL);
+		extra = ast_json_pack("{s: s}", "forward", get_blob_variable(blob, "forward"));
+		if (extra) {
+			report_event_snapshot(caller, AST_CEL_FORWARD, NULL, extra, NULL);
+		}
 	}
 
 	if (ast_strlen_zero(get_blob_variable(blob, "dialstatus"))) {
@@ -1399,7 +1436,7 @@
 	case AST_CEL_USER_DEFINED:
 		{
 			const char *event = ast_json_string_get(ast_json_object_get(event_details, "event"));
-			const char *extra = ast_json_string_get(ast_json_object_get(event_details, "extra"));
+			struct ast_json *extra = ast_json_object_get(event_details, "extra");
 			report_event_snapshot(obj->snapshot, event_type, event, extra, NULL);
 			break;
 		}
@@ -1420,10 +1457,10 @@
 	struct ast_json *blob = obj->blob;
 	struct ast_json *json_exten = ast_json_object_get(blob, "exten");
 	struct ast_json *json_context = ast_json_object_get(blob, "context");
-	RAII_VAR(struct ast_str *, extra, ast_str_create(64), ast_free);
+	RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
 	const char *exten, *context;
 
-	if (!json_exten || !json_context || !extra) {
+	if (!json_exten || !json_context) {
 		return;
 	}
 
@@ -1432,9 +1469,14 @@
 	if (!exten || !context) {
 		return;
 	}
-
-	ast_str_set(&extra, 0, "%s,%s,%s", bridge_snapshot->uniqueid, exten, context);
-	report_event_snapshot(chan_snapshot, AST_CEL_BLINDTRANSFER, NULL, ast_str_buffer(extra), NULL);
+	extra = ast_json_pack("{s: s, s: s, s: s}",
+		"extension", exten,
+		"context", context,
+		"bridge_id", bridge_snapshot->uniqueid);
+
+	if (extra) {
+		report_event_snapshot(chan_snapshot, AST_CEL_BLINDTRANSFER, NULL, extra, NULL);
+	}
 }
 
 static void cel_attended_transfer_cb(
@@ -1443,13 +1485,9 @@
 	struct stasis_message *message)
 {
 	struct ast_attended_transfer_message *xfer = stasis_message_data(message);
-	RAII_VAR(struct ast_str *, extra, ast_str_create(64), ast_free);
+	RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
 	struct ast_bridge_snapshot *bridge1, *bridge2;
 	struct ast_channel_snapshot *channel1, *channel2;
-
-	if (!extra) {
-		return;
-	}
 
 	/* Make sure bridge1 is always non-NULL */
 	if (!xfer->to_transferee.bridge_snapshot) {
@@ -1470,13 +1508,27 @@
 		/* handle these two the same */
 	case AST_ATTENDED_TRANSFER_DEST_BRIDGE_MERGE:
 	case AST_ATTENDED_TRANSFER_DEST_LINK:
-		ast_str_set(&extra, 0, "%s,%s,bridge:%s", bridge1->uniqueid, channel2->name, bridge2->uniqueid);
+		extra = ast_json_pack("{s: s, s: s, s: s}",
+			"bridge1_id", bridge1->uniqueid,
+			"channel2_name", channel2->name,
+			"bridge2_id", bridge2->uniqueid);
+
+		if (!extra) {
+			return;
+		}
 		break;
 	case AST_ATTENDED_TRANSFER_DEST_APP:
-		ast_str_set(&extra, 0, "%s,%s,app:%s", bridge1->uniqueid, channel2->name, xfer->dest.app);
+		extra = ast_json_pack("{s: s, s: s, s: s}",
+			"bridge1_id", bridge1->uniqueid,
+			"channel2_name", channel2->name,
+			"app", xfer->dest.app);
+
+		if (!extra) {
+			return;
+		}
 		break;
 	}
-	report_event_snapshot(channel1, AST_CEL_ATTENDEDTRANSFER, NULL, ast_str_buffer(extra), NULL);
+	report_event_snapshot(channel1, AST_CEL_ATTENDEDTRANSFER, NULL, extra, NULL);
 }
 
 static void ast_cel_engine_term(void)

Modified: team/kmoore/cel_transfers/tests/test_cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_transfers/tests/test_cel.c?view=diff&rev=393888&r1=393887&r2=393888
==============================================================================
--- team/kmoore/cel_transfers/tests/test_cel.c (original)
+++ team/kmoore/cel_transfers/tests/test_cel.c Tue Jul  9 11:58:08 2013
@@ -47,6 +47,7 @@
 #include "asterisk/bridging_basic.h"
 #include "asterisk/stasis_channels.h"
 #include "asterisk/stasis_bridging.h"
+#include "asterisk/json.h"
 
 #define TEST_CATEGORY "/main/cel/"
 
@@ -88,6 +89,61 @@
 	if (append_dummy_event()) { \
 		return AST_TEST_FAIL; \
 	} \
+	} while (0)
+
+#define CONF_EXIT(channel, bridge) do { \
+	ast_test_validate(test, 0 == ast_bridge_depart(channel)); \
+	CONF_EXIT_EVENT(channel, bridge); \
+	} while (0)
+
+#define CONF_EXIT_EVENT(channel, bridge) do { \
+	RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
+	extra = ast_json_pack("{s: s}", "bridge_id", bridge->uniqueid); \
+	ast_test_validate(test, extra != NULL); \
+	APPEND_EVENT(channel, AST_CEL_CONF_EXIT, NULL, extra, NULL); \
+	} while (0)
+
+#define CONF_EXIT_SNAPSHOT(channel, bridge) do { \
+	RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
+	extra = ast_json_pack("{s: s}", "bridge_id", bridge->uniqueid); \
+	ast_test_validate(test, extra != NULL); \
+	APPEND_EVENT_SNAPSHOT(channel, AST_CEL_CONF_EXIT, NULL, extra, NULL); \
+	} while (0)
+
+#define CONF_ENTER_EVENT(channel, bridge) do { \
+	RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
+	extra = ast_json_pack("{s: s}", "bridge_id", bridge->uniqueid); \
+	ast_test_validate(test, extra != NULL); \
+	APPEND_EVENT(channel, AST_CEL_CONF_ENTER, NULL, extra, NULL); \
+	} while (0)
+
+#define BRIDGE_TO_CONF(first, second, third, bridge) do { \
+	RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
+	extra = ast_json_pack("{s: s, s: s}", \
+		"channel_name", ast_channel_name(third), \
+		"bridge_id", bridge->uniqueid); \
+	ast_test_validate(test, extra != NULL); \
+	APPEND_EVENT(first, AST_CEL_BRIDGE_TO_CONF, NULL, extra, ast_channel_name(second)); \
+	} while (0)
+
+#define BLINDTRANSFER_EVENT(channel, bridge, extension, context) do { \
+	RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
+	extra = ast_json_pack("{s: s, s: s, s: s}", \
+		"extension", extension, \
+		"context", context, \
+		"bridge_id", bridge->uniqueid); \
+	ast_test_validate(test, extra != NULL); \
+	APPEND_EVENT(channel, AST_CEL_BLINDTRANSFER, NULL, extra, NULL); \
+	} while (0)
+
+#define ATTENDEDTRANSFER_BRIDGE(channel1, bridge1, channel2, bridge2) do { \
+	RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
+	extra = ast_json_pack("{s: s, s: s, s: s}", \
+		"bridge1_id", bridge1->uniqueid, \
+		"channel2_name", ast_channel_name(channel2), \
+		"bridge2_id", bridge2->uniqueid); \
+	ast_test_validate(test, extra != NULL); \
+	APPEND_EVENT(channel1, AST_CEL_ATTENDEDTRANSFER, NULL, extra, NULL); \
 	} while (0)
 
 /*! \brief Alice's Caller ID */
@@ -165,7 +221,13 @@
 	} while (0)
 
 /*! \brief Hang up a test channel safely */
-#define HANGUP_CHANNEL(channel, cause, hangup_extra) do { \
+#define HANGUP_CHANNEL(channel, cause, dialstatus) do { \
+	RAII_VAR(struct ast_json *, hangup_extra, NULL, ast_json_unref); \
+	hangup_extra = ast_json_pack("{s: i, s: s, s: s}", \
+		"hangupcause", cause, \
+		"hangupsource", "", \
+		"dialstatus", dialstatus); \
+	ast_test_validate(test, hangup_extra != NULL); \
 	ast_channel_hangupcause_set((channel), (cause)); \
 	ao2_ref(channel, +1); \
 	if (!ast_hangup((channel))) { \
@@ -188,13 +250,13 @@
 	struct ast_channel *chan,
 	enum ast_cel_event_type type,
 	const char *userdefevname,
-	const char *extra, const char *peer);
+	struct ast_json *extra, const char *peer);
 
 static int append_expected_event_snapshot(
 	struct ast_channel_snapshot *snapshot,
 	enum ast_cel_event_type type,
 	const char *userdefevname,
-	const char *extra, const char *peer);
+	struct ast_json *extra, const char *peer);
 
 static int append_dummy_event(void);
 
@@ -225,7 +287,7 @@
 
 	CREATE_ALICE_CHANNEL(chan, (&caller));
 
-	HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -253,7 +315,7 @@
 
 	EMULATE_APP_DATA(chan, 1, "Wait", "1");
 
-	HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -286,7 +348,7 @@
 	ast_channel_context_set(chan, "default");
 	ast_set_flag(ast_channel_flags(chan), AST_FLAG_ORIGINATED);
 	EMULATE_APP_DATA(chan, 0, "AppDial", "(Outgoing Line)");
-	HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -313,7 +375,7 @@
 	ANSWER_CHANNEL(chan);
 	EMULATE_APP_DATA(chan, 2, "VoiceMailMain", "1");
 
-	HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -352,7 +414,7 @@
 
 	ast_bridge_depart(chan);
 
-	HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -393,7 +455,7 @@
 	EMULATE_APP_DATA(chan, 3, "Wait", "");
 
 	/* And then it hangs up */
-	HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -443,8 +505,8 @@
 	ast_bridge_depart(chan_bob);
 	APPEND_EVENT(chan_alice, AST_CEL_BRIDGE_END, NULL, NULL, ast_channel_name(chan_bob));
 
-	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -495,8 +557,8 @@
 	ast_bridge_depart(chan_bob);
 	APPEND_EVENT(chan_bob, AST_CEL_BRIDGE_END, NULL, NULL, ast_channel_name(chan_alice));
 
-	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -507,7 +569,6 @@
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
 	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_str *, extra, ast_str_create(64), ast_free);
 	struct ast_party_caller caller_alice = ALICE_CALLERID;
 	struct ast_party_caller caller_bob = BOB_CALLERID;
 	struct ast_party_caller caller_charlie = CHARLIE_CALLERID;
@@ -551,19 +612,15 @@
 	EMULATE_APP_DATA(chan_charlie, 2, "Bridge", "");
 	ast_bridge_impart(bridge, chan_charlie, NULL, NULL, 0);
 	do_sleep();
-	ast_str_set(&extra, 0, "%s,%s", ast_channel_name(chan_charlie), bridge->uniqueid);
-	APPEND_EVENT(chan_alice, AST_CEL_BRIDGE_TO_CONF, NULL, ast_str_buffer(extra), ast_channel_name(chan_bob));
-
-	ast_bridge_depart(chan_alice);
-	APPEND_EVENT(chan_alice, AST_CEL_CONF_EXIT, NULL, bridge->uniqueid, NULL);
-	ast_bridge_depart(chan_bob);
-	APPEND_EVENT(chan_bob, AST_CEL_CONF_EXIT, NULL, bridge->uniqueid, NULL);
-	ast_bridge_depart(chan_charlie);
-	APPEND_EVENT(chan_charlie, AST_CEL_CONF_EXIT, NULL, bridge->uniqueid, NULL);
-
-	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "16,,");
+	BRIDGE_TO_CONF(chan_alice, chan_bob, chan_charlie, bridge);
+
+	CONF_EXIT(chan_alice, bridge);
+	CONF_EXIT(chan_bob, bridge);
+	CONF_EXIT(chan_charlie, bridge);
+
+	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -616,8 +673,8 @@
 	ast_channel_state_set(chan_caller, AST_STATE_RINGING);
 	ast_channel_publish_dial(chan_caller, chan_callee, NULL, "NOANSWER");
 
-	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NO_ANSWER, "19,,NOANSWER");
-	HANGUP_CHANNEL(chan_callee, AST_CAUSE_NO_ANSWER, "19,,");
+	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NO_ANSWER, "NOANSWER");
+	HANGUP_CHANNEL(chan_callee, AST_CAUSE_NO_ANSWER, "");
 
 	return AST_TEST_PASS;
 }
@@ -651,8 +708,8 @@
 	ast_channel_state_set(chan_caller, AST_STATE_RINGING);
 	ast_channel_publish_dial(chan_caller, chan_callee, NULL, "BUSY");
 
-	HANGUP_CHANNEL(chan_caller, AST_CAUSE_BUSY, "17,,BUSY");
-	HANGUP_CHANNEL(chan_callee, AST_CAUSE_BUSY, "17,,");
+	HANGUP_CHANNEL(chan_caller, AST_CAUSE_BUSY, "BUSY");
+	HANGUP_CHANNEL(chan_callee, AST_CAUSE_BUSY, "");
 
 	return AST_TEST_PASS;
 }
@@ -685,8 +742,8 @@
 	ast_channel_state_set(chan_caller, AST_STATE_RINGING);
 	ast_channel_publish_dial(chan_caller, chan_callee, NULL, "CONGESTION");
 
-	HANGUP_CHANNEL(chan_caller, AST_CAUSE_CONGESTION, "34,,CONGESTION");
-	HANGUP_CHANNEL(chan_callee, AST_CAUSE_CONGESTION, "34,,");
+	HANGUP_CHANNEL(chan_caller, AST_CAUSE_CONGESTION, "CONGESTION");
+	HANGUP_CHANNEL(chan_callee, AST_CAUSE_CONGESTION, "");
 
 	return AST_TEST_PASS;
 }
@@ -719,8 +776,8 @@
 	ast_channel_state_set(chan_caller, AST_STATE_RINGING);
 	ast_channel_publish_dial(chan_caller, chan_callee, NULL, "CHANUNAVAIL");
 
-	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NO_ROUTE_DESTINATION, "3,,CHANUNAVAIL");
-	HANGUP_CHANNEL(chan_callee, AST_CAUSE_NO_ROUTE_DESTINATION, "3,,");
+	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NO_ROUTE_DESTINATION, "CHANUNAVAIL");
+	HANGUP_CHANNEL(chan_callee, AST_CAUSE_NO_ROUTE_DESTINATION, "");
 
 	return AST_TEST_PASS;
 }
@@ -754,8 +811,8 @@
 	ast_channel_state_set(chan_caller, AST_STATE_RINGING);
 	ast_channel_publish_dial(chan_caller, chan_callee, NULL, "CANCEL");
 
-	HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "16,,CANCEL");
+	HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "CANCEL");
 
 	return AST_TEST_PASS;
 }
@@ -797,18 +854,18 @@
 
 	/* Charlie is busy */
 	ast_channel_publish_dial(chan_caller, chan_charlie, NULL, "BUSY");
-	HANGUP_CHANNEL(chan_charlie, AST_CAUSE_BUSY, "17,,");
+	HANGUP_CHANNEL(chan_charlie, AST_CAUSE_BUSY, "");
 
 	/* David is congested */
 	ast_channel_publish_dial(chan_caller, chan_david, NULL, "CONGESTION");
-	HANGUP_CHANNEL(chan_david, AST_CAUSE_CONGESTION, "34,,");
+	HANGUP_CHANNEL(chan_david, AST_CAUSE_CONGESTION, "");
 
 	/* Bob is canceled */
 	ast_channel_publish_dial(chan_caller, chan_bob, NULL, "CANCEL");
-	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
 
 	/* Alice hangs up */
-	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "16,,BUSY");
+	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "BUSY");
 
 	return AST_TEST_PASS;
 }
@@ -851,8 +908,8 @@
 	EMULATE_APP_DATA(chan_caller, 2, "Wait", "1");
 	EMULATE_APP_DATA(chan_callee, 1, "Wait", "1");
 
-	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "16,,ANSWER");
-	HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "ANSWER");
+	HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -902,8 +959,8 @@
 	ast_bridge_depart(chan_callee);
 	APPEND_EVENT(chan_caller, AST_CEL_BRIDGE_END, NULL, NULL, ast_channel_name(chan_callee));
 
-	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "16,,ANSWER");
-	HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "ANSWER");
+	HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -952,8 +1009,8 @@
 	ast_bridge_depart(chan_callee);
 	APPEND_EVENT(chan_callee, AST_CEL_BRIDGE_END, NULL, NULL, ast_channel_name(chan_caller));
 
-	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "16,,ANSWER");
-	HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "ANSWER");
+	HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -965,7 +1022,6 @@
 	RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_david, NULL, safe_channel_release);
 	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_str *, extra, ast_str_create(64), ast_free);
 	struct ast_party_caller alice_caller = ALICE_CALLERID;
 	struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
 
@@ -1013,29 +1069,21 @@
 
 	ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_bob, NULL, NULL, 0));
 	do_sleep();
-	ast_str_set(&extra, 0, "%s,%s", ast_channel_name(chan_bob), bridge->uniqueid);
-	APPEND_EVENT(chan_charlie, AST_CEL_BRIDGE_TO_CONF, NULL, ast_str_buffer(extra), ast_channel_name(chan_david));
+	BRIDGE_TO_CONF(chan_charlie, chan_david, chan_bob, bridge);
 
 	ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_alice, NULL, NULL, 0));
 	do_sleep();
-	APPEND_EVENT(chan_alice, AST_CEL_CONF_ENTER, NULL, bridge->uniqueid, NULL);
-
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_alice));
-	APPEND_EVENT(chan_alice, AST_CEL_CONF_EXIT, NULL, bridge->uniqueid, NULL);
-
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_bob));
-	APPEND_EVENT(chan_bob, AST_CEL_CONF_EXIT, NULL, bridge->uniqueid, NULL);
-
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_charlie));
-	APPEND_EVENT(chan_charlie, AST_CEL_CONF_EXIT, NULL, bridge->uniqueid, NULL);
-
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_david));
-	APPEND_EVENT(chan_david, AST_CEL_CONF_EXIT, NULL, bridge->uniqueid, NULL);
-
-	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "16,,ANSWER");
-	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "16,,ANSWER");
-	HANGUP_CHANNEL(chan_david, AST_CAUSE_NORMAL, "16,,");
+	CONF_ENTER_EVENT(chan_alice, bridge);
+
+	CONF_EXIT(chan_alice, bridge);
+	CONF_EXIT(chan_bob, bridge);
+	CONF_EXIT(chan_charlie, bridge);
+	CONF_EXIT(chan_david, bridge);
+
+	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "ANSWER");
+	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "ANSWER");
+	HANGUP_CHANNEL(chan_david, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -1045,7 +1093,6 @@
 	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
 	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_str *, extra, ast_str_create(32), ast_free);
 	struct ast_party_caller alice_caller = ALICE_CALLERID;
 	struct ast_party_caller bob_caller = BOB_CALLERID;
 
@@ -1061,8 +1108,6 @@
 	case TEST_EXECUTE:
 		break;
 	}
-	ast_test_validate(test, extra != NULL);
-
 	bridge = ast_bridge_basic_new();
 	ast_test_validate(test, bridge != NULL);
 
@@ -1079,8 +1124,7 @@
 	do_sleep();
 	APPEND_EVENT(chan_bob, AST_CEL_BRIDGE_START, NULL, NULL, ast_channel_name(chan_alice));
 
-	ast_str_set(&extra, 0, "%s,%s,%s", bridge->uniqueid, "transfer_extension", "transfer_context");
-	APPEND_EVENT(chan_alice, AST_CEL_BLINDTRANSFER, NULL, ast_str_buffer(extra), NULL);
+	BLINDTRANSFER_EVENT(chan_alice, bridge, "transfer_extension", "transfer_context");
 	APPEND_EVENT(chan_bob, AST_CEL_BRIDGE_END, NULL, NULL, ast_channel_name(chan_alice));
 
 	ast_bridge_transfer_blind(1, chan_alice, "transfer_extension", "transfer_context", NULL, NULL);
@@ -1088,8 +1132,8 @@
 	ast_test_validate(test, 0 == ast_bridge_depart(chan_bob));
 
 
-	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -1102,7 +1146,6 @@
 	RAII_VAR(struct ast_channel *, chan_fred, NULL, safe_channel_release);
 	RAII_VAR(struct ast_bridge *, bridge1, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_bridge *, bridge2, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_str *, extra, ast_str_create(64), ast_free);
 	struct ast_party_caller alice_caller = ALICE_CALLERID;
 	struct ast_party_caller bob_caller = BOB_CALLERID;
 	struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
@@ -1121,8 +1164,6 @@
 	case TEST_EXECUTE:
 		break;
 	}
-	ast_test_validate(test, extra != NULL);
-
 	/* Create first set of bridged parties */
 	bridge1 = ast_bridge_basic_new();
 	ast_test_validate(test, bridge1 != NULL);
@@ -1160,24 +1201,19 @@
 
 	ast_bridge_transfer_attended(chan_alice, chan_fred);
 	do_sleep();
-	ast_str_set(&extra, 0, "%s,%s", ast_channel_name(chan_bob), bridge2->uniqueid);
-	APPEND_EVENT(chan_charlie, AST_CEL_BRIDGE_TO_CONF, NULL, ast_str_buffer(extra), ast_channel_name(chan_fred));
-	APPEND_EVENT(chan_fred, AST_CEL_CONF_EXIT, NULL, bridge2->uniqueid, NULL);
-
-	ast_str_set(&extra, 0, "%s,%s,bridge:%s", bridge1->uniqueid, ast_channel_name(chan_fred), bridge2->uniqueid);
-	APPEND_EVENT(chan_alice, AST_CEL_ATTENDEDTRANSFER, NULL, ast_str_buffer(extra), NULL);
-
-
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_bob));
-	APPEND_EVENT(chan_bob, AST_CEL_CONF_EXIT, NULL, bridge2->uniqueid, NULL);
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_charlie));
-	APPEND_EVENT(chan_charlie, AST_CEL_CONF_EXIT, NULL, bridge2->uniqueid, NULL);
-
-	do_sleep();
-	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_fred, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "16,,");
+	BRIDGE_TO_CONF(chan_charlie, chan_fred, chan_bob, bridge2);
+	CONF_EXIT_EVENT(chan_fred, bridge2);
+
+	ATTENDEDTRANSFER_BRIDGE(chan_alice, bridge1, chan_fred, bridge2);
+
+	CONF_EXIT(chan_bob, bridge2);
+	CONF_EXIT(chan_charlie, bridge2);
+
+	do_sleep();
+	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_fred, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -1193,7 +1229,6 @@
 	RAII_VAR(struct ast_bridge *, bridge1, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_bridge *, bridge2, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_channel_snapshot *, eve_tmp_snapshot, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_str *, extra, ast_str_create(32), ast_free);
 	struct ast_party_caller alice_caller = ALICE_CALLERID;
 	struct ast_party_caller bob_caller = BOB_CALLERID;
 	struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
@@ -1215,8 +1250,6 @@
 	case TEST_EXECUTE:
 		break;
 	}
-	ast_test_validate(test, extra != NULL);
-
 	/* Create first set of bridged parties */
 	bridge1 = ast_bridge_basic_new();
 	ast_test_validate(test, bridge1 != NULL);
@@ -1237,8 +1270,7 @@
 
 	ast_test_validate(test, 0 == ast_bridge_impart(bridge1, chan_david, NULL, NULL, 0));
 	do_sleep();
-	ast_str_set(&extra, 0, "%s,%s", ast_channel_name(chan_david), bridge1->uniqueid);
-	APPEND_EVENT(chan_bob, AST_CEL_BRIDGE_TO_CONF, NULL, ast_str_buffer(extra), ast_channel_name(chan_alice));
+	BRIDGE_TO_CONF(chan_bob, chan_alice, chan_david, bridge1);
 
 	/* Create second set of bridged parties */
 	bridge2 = ast_bridge_basic_new();
@@ -1260,44 +1292,37 @@
 
 	ast_test_validate(test, 0 == ast_bridge_impart(bridge2, chan_eve, NULL, NULL, 0));
 	do_sleep();
-	ast_str_set(&extra, 0, "%s,%s", ast_channel_name(chan_eve), bridge2->uniqueid);
-	APPEND_EVENT(chan_charlie, AST_CEL_BRIDGE_TO_CONF, NULL, ast_str_buffer(extra), ast_channel_name(chan_fred));
+	BRIDGE_TO_CONF(chan_charlie, chan_fred, chan_eve, bridge2);
 
 	/* Perform attended transfer */
-	APPEND_EVENT(chan_charlie, AST_CEL_CONF_EXIT, NULL, bridge2->uniqueid, NULL);
+	CONF_EXIT_EVENT(chan_charlie, bridge2);
 	eve_tmp_snapshot = ast_channel_snapshot_create(chan_eve);
 	ast_bridge_transfer_attended(chan_alice, chan_fred);
 	do_sleep();
-	APPEND_EVENT(chan_charlie, AST_CEL_CONF_ENTER, NULL, bridge1->uniqueid, NULL);
+	CONF_ENTER_EVENT(chan_charlie, bridge1);
 
 	/* Fred goes away */
-	APPEND_EVENT(chan_fred, AST_CEL_CONF_EXIT, NULL, bridge2->uniqueid, NULL);
-	APPEND_EVENT_SNAPSHOT(eve_tmp_snapshot, AST_CEL_CONF_EXIT, NULL, bridge2->uniqueid, NULL);
-	APPEND_EVENT(chan_eve, AST_CEL_CONF_ENTER, NULL, bridge1->uniqueid, NULL);
+	CONF_EXIT_EVENT(chan_fred, bridge2);
+	CONF_EXIT_SNAPSHOT(eve_tmp_snapshot, bridge2);
+	CONF_ENTER_EVENT(chan_eve, bridge1);
 
 	/* Alice goes away */
-	APPEND_EVENT(chan_alice, AST_CEL_CONF_EXIT, NULL, bridge1->uniqueid, NULL);
-
-	ast_str_set(&extra, 0, "%s,%s,bridge:%s", bridge1->uniqueid, ast_channel_name(chan_fred), bridge2->uniqueid);
-	APPEND_EVENT(chan_alice, AST_CEL_ATTENDEDTRANSFER, NULL, ast_str_buffer(extra), NULL);
-
-
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_bob));
-	APPEND_EVENT(chan_bob, AST_CEL_CONF_EXIT, NULL, bridge1->uniqueid, NULL);
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_charlie));
-	APPEND_EVENT(chan_charlie, AST_CEL_CONF_EXIT, NULL, bridge1->uniqueid, NULL);
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_david));
-	APPEND_EVENT(chan_david, AST_CEL_CONF_EXIT, NULL, bridge1->uniqueid, NULL);
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_eve));
-	APPEND_EVENT(chan_eve, AST_CEL_CONF_EXIT, NULL, bridge1->uniqueid, NULL);
-
-	do_sleep();
-	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_fred, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_david, AST_CAUSE_NORMAL, "16,,");
-	HANGUP_CHANNEL(chan_eve, AST_CAUSE_NORMAL, "16,,");
+	CONF_EXIT_EVENT(chan_alice, bridge1);
+
+	ATTENDEDTRANSFER_BRIDGE(chan_alice, bridge1, chan_fred, bridge2);
+
+	CONF_EXIT(chan_bob, bridge1);
+	CONF_EXIT(chan_charlie, bridge1);
+	CONF_EXIT(chan_david, bridge1);
+	CONF_EXIT(chan_eve, bridge1);
+
+	do_sleep();
+	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_fred, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_david, AST_CAUSE_NORMAL, "");
+	HANGUP_CHANNEL(chan_eve, AST_CAUSE_NORMAL, "");
 
 	return AST_TEST_PASS;
 }
@@ -1313,7 +1338,6 @@
 	RAII_VAR(struct ast_bridge *, bridge1, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_bridge *, bridge2, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_channel_snapshot *, eve_tmp_snapshot, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_str *, extra, ast_str_create(32), ast_free);
 	struct ast_party_caller alice_caller = ALICE_CALLERID;
 	struct ast_party_caller bob_caller = BOB_CALLERID;
 	struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
@@ -1335,8 +1359,6 @@
 	case TEST_EXECUTE:
 		break;
 	}
-	ast_test_validate(test, extra != NULL);
-
 	/* Create first set of bridged parties */
 	bridge1 = ast_bridge_base_new(AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE | AST_BRIDGE_CAPABILITY_MULTIMIX,
 		AST_BRIDGE_FLAG_MERGE_INHIBIT_TO | AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM
@@ -1359,8 +1381,7 @@
 
 	ast_test_validate(test, 0 == ast_bridge_impart(bridge1, chan_david, NULL, NULL, 0));
 	do_sleep();
-	ast_str_set(&extra, 0, "%s,%s", ast_channel_name(chan_david), bridge1->uniqueid);
-	APPEND_EVENT(chan_bob, AST_CEL_BRIDGE_TO_CONF, NULL, ast_str_buffer(extra), ast_channel_name(chan_alice));
+	BRIDGE_TO_CONF(chan_bob, chan_alice, chan_david, bridge1);
 
 	/* Create second set of bridged parties */
 	bridge2 = ast_bridge_basic_new();
@@ -1382,8 +1403,7 @@
 
 	ast_test_validate(test, 0 == ast_bridge_impart(bridge2, chan_eve, NULL, NULL, 0));
 	do_sleep();
-	ast_str_set(&extra, 0, "%s,%s", ast_channel_name(chan_eve), bridge2->uniqueid);
-	APPEND_EVENT(chan_charlie, AST_CEL_BRIDGE_TO_CONF, NULL, ast_str_buffer(extra), ast_channel_name(chan_fred));
+	BRIDGE_TO_CONF(chan_charlie, chan_fred, chan_eve, bridge2);
 
 	/* Perform attended transfer */
 	ast_bridge_transfer_attended(chan_alice, chan_fred);
@@ -1398,8 +1418,7 @@
 	/* Append dummy event for the link channel ;2 answer */
 	APPEND_DUMMY_EVENT();
 
-	ast_str_set(&extra, 0, "%s,%s,bridge:%s", bridge1->uniqueid, ast_channel_name(chan_fred), bridge2->uniqueid);
-	APPEND_EVENT(chan_alice, AST_CEL_ATTENDEDTRANSFER, NULL, ast_str_buffer(extra), NULL);
+	ATTENDEDTRANSFER_BRIDGE(chan_alice, bridge1, chan_fred, bridge2);
 
 	/* Append dummy event for the link channel ;1 enter */
 	APPEND_DUMMY_EVENT();
@@ -1414,22 +1433,18 @@
 	APPEND_DUMMY_EVENT();
 	APPEND_DUMMY_EVENT();
 
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_bob));
-	APPEND_EVENT(chan_bob, AST_CEL_CONF_EXIT, NULL, bridge1->uniqueid, NULL);
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_charlie));
-	APPEND_EVENT(chan_charlie, AST_CEL_CONF_EXIT, NULL, bridge2->uniqueid, NULL);
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_david));
-	APPEND_EVENT(chan_david, AST_CEL_CONF_EXIT, NULL, bridge1->uniqueid, NULL);
-	ast_test_validate(test, 0 == ast_bridge_depart(chan_eve));
-	APPEND_EVENT(chan_eve, AST_CEL_CONF_EXIT, NULL, bridge2->uniqueid, NULL);
-
-	do_sleep();

[... 40 lines stripped ...]



More information about the svn-commits mailing list