[asterisk-commits] kmoore: branch kmoore/stasis-cel_bridging r388934 - /team/kmoore/stasis-cel_b...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 16 16:58:37 CDT 2013


Author: kmoore
Date: Thu May 16 16:58:36 2013
New Revision: 388934

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388934
Log:
Flesh out some more of the bridge-related events

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

Modified: team/kmoore/stasis-cel_bridging/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-cel_bridging/main/cel.c?view=diff&rev=388934&r1=388933&r2=388934
==============================================================================
--- team/kmoore/stasis-cel_bridging/main/cel.c (original)
+++ team/kmoore/stasis-cel_bridging/main/cel.c Thu May 16 16:58:36 2013
@@ -65,6 +65,12 @@
 
 /*! Message router for bridge state */
 static struct stasis_message_router *cel_bridge_state_router;
+
+/*! Container for primary channel listing for 2 party bridges */
+static struct ao2_container *bridge_primaries;
+
+/*! The number of buckets into which primary channel uniqueids will be hashed */
+#define BRIDGE_PRIMARY_BUCKETS 251
 
 /*! Is the CEL subsystem enabled ? */
 static unsigned char cel_enabled;
@@ -941,10 +947,11 @@
 	struct ast_channel_snapshot *chan_snapshot = blob->channel;
 
 	if (snapshot->capabilities | AST_BRIDGE_CAPABILITY_1TO1MIX || snapshot->capabilities | AST_BRIDGE_CAPABILITY_NATIVE) {
-		/* AST_CEL_BRIDGE_START when second party enters */
 		if (ao2_container_count(snapshot->channels) == 2) {
 			struct ao2_iterator i;
 			RAII_VAR(char *, channel_id, NULL, ao2_cleanup);
+
+			/* get the name of the channel in the container we don't already know the name of */
 			i = ao2_iterator_init(snapshot->channels, 0);
 			while ((channel_id = ao2_iterator_next(&i))) {
 				if (strcmp(channel_id, chan_snapshot->uniqueid)) {
@@ -955,12 +962,13 @@
 			}
 			ao2_iterator_destroy(&i);
 
+			ast_str_container_add(bridge_primaries, channel_id);
 			report_event_id(channel_id, AST_CEL_BRIDGE_START, NULL, NULL, chan_snapshot->uniqueid);
 		}
 	} else if (snapshot->capabilities | AST_BRIDGE_CAPABILITY_MULTIMIX) {
-		/* AST_CEL_CONF_START */
+		report_event_id(chan_snapshot->uniqueid, AST_CEL_CONF_ENTER, NULL, NULL, NULL);
 	} else if (snapshot->capabilities | AST_BRIDGE_CAPABILITY_HOLDING) {
-		/* AST_CEL_PARK_START */
+		/* XXX AST_CEL_PARK_START refactor to parking subscription */
 	}
 }
 
@@ -969,15 +977,42 @@
 	struct stasis_topic *topic,
 	struct stasis_message *message)
 {
-	struct ast_bridge_snapshot *snapshot = stasis_message_data(message);
+	struct ast_bridge_blob *blob = stasis_message_data(message);
+	struct ast_bridge_snapshot *snapshot = blob->bridge;
+	struct ast_channel_snapshot *chan_snapshot = blob->channel;
 
 	if ((snapshot->capabilities | AST_BRIDGE_CAPABILITY_1TO1MIX)
 		|| (snapshot->capabilities | AST_BRIDGE_CAPABILITY_NATIVE)) {
+		if (ao2_container_count(snapshot->channels) == 1) {
+			RAII_VAR(char *, ao2_primary, ao2_find(bridge_primaries, chan_snapshot->uniqueid, OBJ_KEY), ao2_cleanup);
+			RAII_VAR(char *, channel_id_in_bridge, NULL, ao2_cleanup);
+			char *primary, *secondary;
+			struct ao2_iterator i;
+
+			/* get the only item in the container */
+			i = ao2_iterator_init(snapshot->channels, 0);
+			while ((channel_id_in_bridge = ao2_iterator_next(&i))) {
+				break;
+			}
+			ao2_iterator_destroy(&i);
+
+			if (ao2_primary) {
+				primary = ao2_primary;
+				secondary = channel_id_in_bridge;
+			} else {
+				primary = channel_id_in_bridge;
+				secondary = ao2_primary;
+			}
+
+			ast_str_container_remove(bridge_primaries, primary);
+
+			report_event_id(primary, AST_CEL_BRIDGE_END, NULL, NULL, secondary);
+		}
 		/* AST_CEL_BRIDGE_END when all parties have left */
 	} else if (snapshot->capabilities | AST_BRIDGE_CAPABILITY_MULTIMIX) {
-		/* AST_CEL_CONF_END */
+		report_event_id(chan_snapshot->uniqueid, AST_CEL_CONF_EXIT, NULL, NULL, NULL);
 	} else if (snapshot->capabilities | AST_BRIDGE_CAPABILITY_HOLDING) {
-		/* AST_CEL_PARK_END */
+		/* XXX AST_CEL_PARK_END refactor to parking subscription */
 	}
 }
 
@@ -1030,6 +1065,12 @@
 		linkedids = NULL;
 	}
 	ast_cli_unregister(&cli_status);
+	stasis_message_router_unsubscribe(cel_channel_state_router);
+	cel_channel_state_router = NULL;
+	stasis_message_router_unsubscribe(cel_bridge_state_router);
+	cel_bridge_state_router = NULL;
+	ao2_cleanup(bridge_primaries);
+	bridge_primaries = NULL;
 }
 
 int ast_cel_engine_init(void)
@@ -1071,6 +1112,11 @@
 		return -1;
 	}
 
+	bridge_primaries = ast_str_container_alloc(BRIDGE_PRIMARY_BUCKETS);
+	if (!bridge_primaries) {
+		return -1;
+	}
+
 	cel_bridge_state_router = stasis_message_router_create(
 		stasis_caching_get_topic(ast_bridge_topic_all_cached()));
 
@@ -1101,7 +1147,6 @@
 		return -1;
 	}
 
-
 	ast_register_atexit(ast_cel_engine_term);
 
 	return 0;




More information about the asterisk-commits mailing list