[asterisk-commits] kmoore: branch kmoore/stasis-cel_bridging r388890 - in /team/kmoore/stasis-ce...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 15 14:57:05 CDT 2013


Author: kmoore
Date: Wed May 15 14:57:04 2013
New Revision: 388890

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388890
Log:
Add basic framework for bridge message processing

Modified:
    team/kmoore/stasis-cel_bridging/   (props changed)
    team/kmoore/stasis-cel_bridging/main/cel.c

Propchange: team/kmoore/stasis-cel_bridging/
            ('automerge-propname' removed)

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=388890&r1=388889&r2=388890
==============================================================================
--- team/kmoore/stasis-cel_bridging/main/cel.c (original)
+++ team/kmoore/stasis-cel_bridging/main/cel.c Wed May 15 14:57:04 2013
@@ -60,6 +60,9 @@
 
 /*! Message router for channel state */
 static struct stasis_message_router *cel_channel_state_router;
+
+/*! Message router for bridge state */
+static struct stasis_message_router *cel_bridge_state_router;
 
 /*! Is the CEL subsystem enabled ? */
 static unsigned char cel_enabled;
@@ -805,7 +808,7 @@
 #define lid_cmp app_cmp
 
 /*! \brief Typedef for callbacks that get called on channel snapshot updates */
-typedef void (*cel_snapshot_monitor)(
+typedef void (*cel_channel_snapshot_monitor)(
 	struct ast_channel_snapshot *old_snapshot,
 	struct ast_channel_snapshot *new_snapshot);
 
@@ -879,17 +882,16 @@
 	}
 }
 
-cel_snapshot_monitor cel_monitors[] = {
+cel_channel_snapshot_monitor cel_channel_monitors[] = {
 	cel_channel_state_change,
 	cel_channel_app_change,
 	cel_channel_linkedid_change,
 };
 
-static void cel_channel_snapshot_update(void *data, struct stasis_subscription *sub,
+static void cel_channel_snapshot_update_cb(void *data, struct stasis_subscription *sub,
 				    struct stasis_topic *topic,
 				    struct stasis_message *message)
 {
-	RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
 	struct stasis_cache_update *update;
 	struct ast_channel_snapshot *old_snapshot;
 	struct ast_channel_snapshot *new_snapshot;
@@ -904,9 +906,27 @@
 	old_snapshot = stasis_message_data(update->old_snapshot);
 	new_snapshot = stasis_message_data(update->new_snapshot);
 
-	for (i = 0; i < ARRAY_LEN(cel_monitors); ++i) {
-		cel_monitors[i](old_snapshot, new_snapshot);
-	}
+	for (i = 0; i < ARRAY_LEN(cel_channel_monitors); ++i) {
+		cel_channel_monitors[i](old_snapshot, new_snapshot);
+	}
+}
+
+static void cel_bridge_enter_cb(
+	void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	struct ast_bridge_snapshot *snapshot = stasis_message_data(message);
+
+}
+
+static void cel_bridge_leave_cb(
+	void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	struct ast_bridge_snapshot *snapshot = stasis_message_data(message);
+
 }
 
 static void ast_cel_engine_term(void)
@@ -951,9 +971,9 @@
 	}
 
 	ret |= stasis_message_router_add(cel_channel_state_router,
-					 stasis_cache_update_type(),
-					 cel_channel_snapshot_update,
-					 NULL);
+		stasis_cache_update_type(),
+		cel_channel_snapshot_update_cb,
+		NULL);
 
 	/* If somehow we failed to add any routes, just shut down the whole
 	 * thing and fail it.
@@ -963,6 +983,32 @@
 		return -1;
 	}
 
+	cel_bridge_state_router = stasis_message_router_create(
+		stasis_caching_get_topic(ast_bridge_topic_all_cached()));
+
+	if (!cel_bridge_state_router) {
+		return -1;
+	}
+
+	ret |= stasis_message_router_add(cel_bridge_state_router,
+		ast_channel_entered_bridge_type(),
+		cel_bridge_enter_cb,
+		NULL);
+
+	ret |= stasis_message_router_add(cel_bridge_state_router,
+		ast_channel_left_bridge_type(),
+		cel_bridge_leave_cb,
+		NULL);
+
+	/* If somehow we failed to add any routes, just shut down the whole
+	 * thing and fail it.
+	 */
+	if (ret) {
+		ast_cel_engine_term();
+		return -1;
+	}
+
+
 	ast_register_atexit(ast_cel_engine_term);
 
 	return 0;




More information about the asterisk-commits mailing list