[asterisk-commits] kmoore: branch kmoore/stasis-bridge_events r384684 - in /team/kmoore/stasis-b...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 3 15:12:22 CDT 2013
Author: kmoore
Date: Wed Apr 3 15:12:19 2013
New Revision: 384684
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384684
Log:
Add a publish function for ease of publishing bridge snapshots
Modified:
team/kmoore/stasis-bridge_events/include/asterisk/stasis_bridging.h
team/kmoore/stasis-bridge_events/main/stasis_bridging.c
Modified: team/kmoore/stasis-bridge_events/include/asterisk/stasis_bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridge_events/include/asterisk/stasis_bridging.h?view=diff&rev=384684&r1=384683&r2=384684
==============================================================================
--- team/kmoore/stasis-bridge_events/include/asterisk/stasis_bridging.h (original)
+++ team/kmoore/stasis-bridge_events/include/asterisk/stasis_bridging.h Wed Apr 3 15:12:19 2013
@@ -85,14 +85,14 @@
* \since 12
* \brief A topic which publishes the events for a particular bridge.
*
- * If the given \a bridge uniqueid is \c NULL, ast_bridge_topic_all() is returned.
+ * If the given \a bridge is \c NULL, ast_bridge_topic_all() is returned.
*
- * \param bridge_uniqueid Bridge's uniqueid or \c NULL.
+ * \param bridge Bridge for which to get a topic or \c NULL.
*
* \retval Topic for bridge's events.
- * \retval ast_bridge_topic_all() if \a bridge_uniqueid is \c NULL.
+ * \retval ast_bridge_topic_all() if \a bridge is \c NULL.
*/
-struct stasis_topic *ast_bridge_topic(const char *bridge_uniqueid);
+struct stasis_topic *ast_bridge_topic(struct ast_bridge *bridge);
/*!
* \since 12
@@ -111,6 +111,14 @@
struct stasis_caching_topic *ast_bridge_topic_all_cached(void);
/*!
+ * \since 12
+ * \brief Publish the state of a bridge
+ *
+ * \param bridge The bridge for which to publish state
+ */
+void ast_bridge_publish_state(struct ast_bridge *bridge);
+
+/*!
* \brief Dispose of the stasis bridging topics and message types
*/
void ast_stasis_bridging_shutdown(void);
Modified: team/kmoore/stasis-bridge_events/main/stasis_bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridge_events/main/stasis_bridging.c?view=diff&rev=384684&r1=384683&r2=384684
==============================================================================
--- team/kmoore/stasis-bridge_events/main/stasis_bridging.c (original)
+++ team/kmoore/stasis-bridge_events/main/stasis_bridging.c Wed Apr 3 15:12:19 2013
@@ -115,9 +115,9 @@
return bridge_snapshot_type;
}
-struct stasis_topic *ast_bridge_topic(const char *bridge_uniqueid)
+struct stasis_topic *ast_bridge_topic(struct ast_bridge *bridge)
{
- struct stasis_topic *bridge_topic = stasis_topic_pool_get_topic(bridge_topic_pool, bridge_uniqueid);
+ struct stasis_topic *bridge_topic = stasis_topic_pool_get_topic(bridge_topic_pool, bridge->uniqueid);
if (!bridge_topic) {
return ast_bridge_topic_all();
}
@@ -132,6 +132,27 @@
struct stasis_caching_topic *ast_bridge_topic_all_cached(void)
{
return bridge_topic_all_cached;
+}
+
+void ast_bridge_publish_state(struct ast_bridge *bridge)
+{
+ RAII_VAR(struct ast_bridge_snapshot *, snapshot, NULL, ao2_cleanup);
+ RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+
+ ast_assert(bridge != NULL);
+
+ snapshot = ast_bridge_snapshot_create(bridge);
+ if (!snapshot) {
+ return;
+ }
+
+ msg = stasis_message_create(ast_bridge_snapshot_type(), snapshot);
+ if (!msg) {
+ return;
+ }
+
+ ast_assert(ast_bridge_topic(bridge) != NULL);
+ stasis_publish(ast_bridge_topic(bridge), msg);
}
void ast_stasis_bridging_shutdown(void)
More information about the asterisk-commits
mailing list