[asterisk-commits] kmoore: branch kmoore/bridge_construction-cel_bridging r389474 - /team/kmoore...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 21 22:01:37 CDT 2013


Author: kmoore
Date: Tue May 21 22:01:33 2013
New Revision: 389474

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389474
Log:
Save the secondary channel's name directly instead of pulling it indirectly via the uniqueid

Modified:
    team/kmoore/bridge_construction-cel_bridging/main/cel.c

Modified: team/kmoore/bridge_construction-cel_bridging/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/bridge_construction-cel_bridging/main/cel.c?view=diff&rev=389474&r1=389473&r2=389474
==============================================================================
--- team/kmoore/bridge_construction-cel_bridging/main/cel.c (original)
+++ team/kmoore/bridge_construction-cel_bridging/main/cel.c Tue May 21 22:01:33 2013
@@ -323,7 +323,7 @@
 	AST_DECLARE_STRING_FIELDS(
 		AST_STRING_FIELD(channel_id);	/*!< UniqueID of the primary/dialing channel */
 		AST_STRING_FIELD(bridge_id);	/*!< UniqueID of the bridge */
-		AST_STRING_FIELD(secondary_id);	/*!< UniqueID of the secondary/dialed channel */
+		AST_STRING_FIELD(secondary_name);	/*!< UniqueID of the secondary/dialed channel */
 	);
 };
 
@@ -333,7 +333,7 @@
 	ast_string_field_free_memory(assoc);
 }
 
-static struct bridge_assoc *bridge_assoc_alloc(const char *channel_id, const char *bridge_id, const char *secondary_id)
+static struct bridge_assoc *bridge_assoc_alloc(const char *channel_id, const char *bridge_id, const char *secondary_name)
 {
 	RAII_VAR(struct bridge_assoc *, assoc, ao2_alloc(sizeof(*assoc), bridge_assoc_dtor), ao2_cleanup);
 	if (!assoc || ast_string_field_init(assoc, 64)) {
@@ -342,15 +342,15 @@
 
 	ast_string_field_set(assoc, channel_id, channel_id);
 	ast_string_field_set(assoc, bridge_id, bridge_id);
-	ast_string_field_set(assoc, secondary_id, secondary_id);
+	ast_string_field_set(assoc, secondary_name, secondary_name);
 
 	ao2_ref(assoc, +1);
 	return assoc;
 }
 
-static int add_bridge_primary(const char *channel_id, const char *bridge_id, const char *secondary_id)
-{
-	RAII_VAR(struct bridge_assoc *, assoc, bridge_assoc_alloc(channel_id, bridge_id, secondary_id), ao2_cleanup);
+static int add_bridge_primary(const char *channel_id, const char *bridge_id, const char *secondary_name)
+{
+	RAII_VAR(struct bridge_assoc *, assoc, bridge_assoc_alloc(channel_id, bridge_id, secondary_name), ao2_cleanup);
 	if (!assoc) {
 		return -1;
 	}
@@ -645,12 +645,12 @@
 
 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_id)
+		const char *extra, const char *peer2_name)
 {
 	struct timeval eventtime;
 	struct ast_event *ev;
 	char *linkedid = ast_strdupa(snapshot->linkedid);
-	char *peer_name = "";
+	const char *peer_name = "";
 	RAII_VAR(struct bridge_assoc *, assoc, NULL, ao2_cleanup);
 	RAII_VAR(struct cel_config *, cfg, ao2_global_obj_ref(cel_configs), ao2_cleanup);
 
@@ -664,20 +664,11 @@
 
 	assoc = ao2_find(bridge_primaries, snapshot->uniqueid, OBJ_KEY);
 	if (assoc) {
-		RAII_VAR(struct ast_channel_snapshot *, bridged_snapshot, NULL, ao2_cleanup);
-		bridged_snapshot = ast_channel_snapshot_get_latest(assoc->secondary_id);
-		if (bridged_snapshot) {
-			peer_name = ast_strdupa(bridged_snapshot->name);
-		}
-	}
-
-	if (ast_strlen_zero(peer_name) && peer2_id) {
-		RAII_VAR(struct ast_channel_snapshot *, peer2_snapshot, ast_channel_snapshot_get_latest(peer2_id), ao2_cleanup);
-		if (!peer2_snapshot) {
-			return -1;
-		}
-
-		peer_name = ast_strdupa(peer2_snapshot->name);
+		peer_name = assoc->secondary_name;
+	}
+
+	if (ast_strlen_zero(peer_name) && peer2_name) {
+		peer_name = peer2_name;
 	}
 
 	/* Record the linkedid of new channels if we are tracking LINKEDID_END even if we aren't
@@ -1250,8 +1241,8 @@
 			}
 			ao2_iterator_destroy(&i);
 
-			add_bridge_primary(channel_id, snapshot->uniqueid, chan_snapshot->uniqueid);
-			report_event_id(channel_id, AST_CEL_BRIDGE_START, NULL, NULL, chan_snapshot->uniqueid);
+			add_bridge_primary(channel_id, snapshot->uniqueid, chan_snapshot->name);
+			report_event_id(channel_id, AST_CEL_BRIDGE_START, NULL, NULL, chan_snapshot->name);
 		}
 	} else if (snapshot->capabilities | AST_BRIDGE_CAPABILITY_MULTIMIX) {
 		report_event_id(chan_snapshot->uniqueid, AST_CEL_CONF_ENTER, NULL, NULL, NULL);
@@ -1274,7 +1265,7 @@
 		if (ao2_container_count(snapshot->channels) == 1) {
 			RAII_VAR(struct bridge_assoc *, ao2_primary, ao2_find(bridge_primaries, chan_snapshot->uniqueid, OBJ_KEY), ao2_cleanup);
 			RAII_VAR(char *, channel_id_in_bridge, NULL, ao2_cleanup);
-			const char *primary, *secondary;
+			const char *primary;
 			struct ao2_iterator i;
 
 			/* get the only item in the container */
@@ -1286,14 +1277,13 @@
 
 			if (ao2_primary) {
 				primary = chan_snapshot->uniqueid;
-				secondary = channel_id_in_bridge;
 			} else {
 				primary = channel_id_in_bridge;
-				secondary = chan_snapshot->uniqueid;
+				ao2_primary = ao2_find(bridge_primaries, primary, OBJ_KEY);
 			}
 
 			remove_bridge_primary(primary);
-			report_event_id(primary, AST_CEL_BRIDGE_END, NULL, NULL, secondary);
+			report_event_id(primary, AST_CEL_BRIDGE_END, NULL, NULL, ao2_primary->secondary_name);
 		}
 		/* AST_CEL_BRIDGE_END when all parties have left */
 	} else if (snapshot->capabilities | AST_BRIDGE_CAPABILITY_MULTIMIX) {




More information about the asterisk-commits mailing list