[svn-commits] dlee: branch dlee/stasis-cache-split r394012 - in /team/dlee/stasis-cache-spl...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jul 10 15:20:24 CDT 2013


Author: dlee
Date: Wed Jul 10 15:20:22 2013
New Revision: 394012

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394012
Log:
Channel and endpoint topics

Modified:
    team/dlee/stasis-cache-split/include/asterisk/channel.h
    team/dlee/stasis-cache-split/include/asterisk/channel_internal.h
    team/dlee/stasis-cache-split/include/asterisk/stasis_channels.h
    team/dlee/stasis-cache-split/include/asterisk/stasis_endpoints.h
    team/dlee/stasis-cache-split/main/channel_internal_api.c
    team/dlee/stasis-cache-split/main/endpoints.c
    team/dlee/stasis-cache-split/main/stasis_channels.c
    team/dlee/stasis-cache-split/main/stasis_endpoints.c

Modified: team/dlee/stasis-cache-split/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/include/asterisk/channel.h?view=diff&rev=394012&r1=394011&r2=394012
==============================================================================
--- team/dlee/stasis-cache-split/include/asterisk/channel.h (original)
+++ team/dlee/stasis-cache-split/include/asterisk/channel.h Wed Jul 10 15:20:22 2013
@@ -4221,6 +4221,21 @@
 struct stasis_topic *ast_channel_topic(struct ast_channel *chan);
 
 /*!
+ * \since 12
+ * \brief A topic which publishes the events for a particular channel.
+ *
+ * \ref ast_channel_snapshot messages are replaced with \ref stasis_cache_update
+ *
+ * If the given \a chan is \c NULL, ast_channel_topic_all_cached() is returned.
+ *
+ * \param chan Channel, or \c NULL.
+ *
+ * \retval Topic for channel's events.
+ * \retval ast_channel_topic_all() if \a chan is \c NULL.
+ */
+struct stasis_topic *ast_channel_topic_cached(struct ast_channel *chan);
+
+/*!
  * \brief Get the bridge associated with a channel
  * \since 12.0.0
  *

Modified: team/dlee/stasis-cache-split/include/asterisk/channel_internal.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/include/asterisk/channel_internal.h?view=diff&rev=394012&r1=394011&r2=394012
==============================================================================
--- team/dlee/stasis-cache-split/include/asterisk/channel_internal.h (original)
+++ team/dlee/stasis-cache-split/include/asterisk/channel_internal.h Wed Jul 10 15:20:22 2013
@@ -23,5 +23,5 @@
 void ast_channel_internal_finalize(struct ast_channel *chan);
 int ast_channel_internal_is_finalized(struct ast_channel *chan);
 void ast_channel_internal_cleanup(struct ast_channel *chan);
-void ast_channel_internal_setup_topics(struct ast_channel *chan);
+int ast_channel_internal_setup_topics(struct ast_channel *chan);
 

Modified: team/dlee/stasis-cache-split/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/include/asterisk/stasis_channels.h?view=diff&rev=394012&r1=394011&r2=394012
==============================================================================
--- team/dlee/stasis-cache-split/include/asterisk/stasis_channels.h (original)
+++ team/dlee/stasis-cache-split/include/asterisk/stasis_channels.h Wed Jul 10 15:20:22 2013
@@ -105,6 +105,8 @@
  */
 struct ast_multi_channel_blob;
 
+struct stasis_cache_all *ast_channel_cache_all(void);
+
 /*!
  * \since 12
  * \brief A topic which publishes the events for all channels.

Modified: team/dlee/stasis-cache-split/include/asterisk/stasis_endpoints.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/include/asterisk/stasis_endpoints.h?view=diff&rev=394012&r1=394011&r2=394012
==============================================================================
--- team/dlee/stasis-cache-split/include/asterisk/stasis_endpoints.h (original)
+++ team/dlee/stasis-cache-split/include/asterisk/stasis_endpoints.h Wed Jul 10 15:20:22 2013
@@ -30,6 +30,7 @@
 #include "asterisk/endpoints.h"
 #include "asterisk/json.h"
 #include "asterisk/stasis.h"
+#include "asterisk/stasis_cache_pattern.h"
 #include "asterisk/stringfields.h"
 
 /*! \addtogroup StasisTopicsAndMessages
@@ -144,6 +145,12 @@
 struct stasis_topic *ast_endpoint_topic(struct ast_endpoint *endpoint);
 
 /*!
+ * \internal
+ * \since 12
+ */
+struct stasis_cache_all *ast_endpoint_cache_all(void);
+
+/*!
  * \brief Topic for all endpoint releated messages.
  * \since 12
  */

Modified: team/dlee/stasis-cache-split/main/channel_internal_api.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/channel_internal_api.c?view=diff&rev=394012&r1=394011&r2=394012
==============================================================================
--- team/dlee/stasis-cache-split/main/channel_internal_api.c (original)
+++ team/dlee/stasis-cache-split/main/channel_internal_api.c Wed Jul 10 15:20:22 2013
@@ -44,6 +44,7 @@
 #include "asterisk/data.h"
 #include "asterisk/endpoints.h"
 #include "asterisk/indications.h"
+#include "asterisk/stasis_cache_pattern.h"
 #include "asterisk/stasis_channels.h"
 #include "asterisk/stasis_endpoints.h"
 #include "asterisk/stringfields.h"
@@ -203,7 +204,7 @@
 	char dtmf_digit_to_emulate;			/*!< Digit being emulated */
 	char sending_dtmf_digit;			/*!< Digit this channel is currently sending out. (zero if not sending) */
 	struct timeval sending_dtmf_tv;		/*!< The time this channel started sending the current digit. (Invalid if sending_dtmf_digit is zero.) */
-	struct stasis_topic *topic;			/*!< Topic for all channel's events */
+	struct stasis_cache_one *topics;		/*!< Topic for all channel's events */
 	struct stasis_subscription *forwarder;		/*!< Subscription for event forwarding to all topic */
 	struct stasis_subscription *endpoint_forward;	/*!< Subscription for event forwarding to endpoint's topic */
 };
@@ -1425,8 +1426,8 @@
 	chan->forwarder = stasis_unsubscribe(chan->forwarder);
 	chan->endpoint_forward = stasis_unsubscribe(chan->endpoint_forward);
 
-	ao2_cleanup(chan->topic);
-	chan->topic = NULL;
+	ao2_cleanup(chan->topics);
+	chan->topics = NULL;
 }
 
 void ast_channel_internal_finalize(struct ast_channel *chan)
@@ -1441,16 +1442,31 @@
 
 struct stasis_topic *ast_channel_topic(struct ast_channel *chan)
 {
-	return chan ? chan->topic : ast_channel_topic_all();
-}
-
-int ast_channel_forward_endpoint(struct ast_channel *chan, struct ast_endpoint *endpoint)
+	if (!chan) {
+		return ast_channel_topic_all();
+	}
+
+	return stasis_cache_one_topic(chan->topics);
+}
+
+struct stasis_topic *ast_channel_topic_cached(struct ast_channel *chan)
+{
+	if (!chan) {
+		return ast_channel_topic_all_cached();
+	}
+
+	return stasis_cache_one_topic_cached(chan->topics);
+}
+
+int ast_channel_forward_endpoint(struct ast_channel *chan,
+	struct ast_endpoint *endpoint)
 {
 	ast_assert(chan != NULL);
 	ast_assert(endpoint != NULL);
 
 	chan->endpoint_forward =
-		stasis_forward_all(chan->topic, ast_endpoint_topic(endpoint));
+		stasis_forward_all(ast_channel_topic(chan),
+			ast_endpoint_topic(endpoint));
 
 	if (chan->endpoint_forward == NULL) {
 		return -1;
@@ -1459,19 +1475,21 @@
 	return 0;
 }
 
-void ast_channel_internal_setup_topics(struct ast_channel *chan)
+int ast_channel_internal_setup_topics(struct ast_channel *chan)
 {
 	const char *topic_name = chan->uniqueid;
-	ast_assert(chan->topic == NULL);
-	ast_assert(chan->forwarder == NULL);
+	ast_assert(chan->topics == NULL);
 
 	if (ast_strlen_zero(topic_name)) {
 		topic_name = "<dummy-channel>";
 	}
 
-	chan->topic = stasis_topic_create(topic_name);
-	chan->forwarder = stasis_forward_all(chan->topic, ast_channel_topic_all());
-
-	ast_assert(chan->topic != NULL);
-	ast_assert(chan->forwarder != NULL);
-}
+	chan->topics = stasis_cache_one_create(
+		ast_channel_cache_all(), topic_name);
+
+	if (!chan->topics) {
+		return -1;
+	}
+
+	return 0;
+}

Modified: team/dlee/stasis-cache-split/main/endpoints.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/endpoints.c?view=diff&rev=394012&r1=394011&r2=394012
==============================================================================
--- team/dlee/stasis-cache-split/main/endpoints.c (original)
+++ team/dlee/stasis-cache-split/main/endpoints.c Wed Jul 10 15:20:22 2013
@@ -58,11 +58,7 @@
 	 */
 	int max_channels;
 	/*! Topic for this endpoint's messages */
-	struct stasis_topic *topic;
-	/*!
-	 * Forwarding subscription sending messages to ast_endpoint_topic_all()
-	 */
-	struct stasis_subscription *forward;
+	struct stasis_cache_one *topics;
 	/*! Router for handling this endpoint's messages */
 	struct stasis_message_router *router;
 	/*! ast_str_container of channels associated with this endpoint */
@@ -88,7 +84,7 @@
 	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
 
 	ast_assert(endpoint != NULL);
-	ast_assert(endpoint->topic != NULL);
+	ast_assert(endpoint->topics != NULL);
 
 	snapshot = ast_endpoint_snapshot_create(endpoint);
 	if (!snapshot) {
@@ -98,7 +94,7 @@
 	if (!message) {
 		return;
 	}
-	stasis_publish(endpoint->topic, message);
+	stasis_publish(ast_endpoint_topic(endpoint), message);
 }
 
 static void endpoint_dtor(void *obj)
@@ -110,11 +106,8 @@
 	ao2_cleanup(endpoint->router);
 	endpoint->router = NULL;
 
-	stasis_unsubscribe(endpoint->forward);
-	endpoint->forward = NULL;
-
-	ao2_cleanup(endpoint->topic);
-	endpoint->topic = NULL;
+	ao2_cleanup(endpoint->topics);
+	endpoint->topics = NULL;
 
 	ao2_cleanup(endpoint->channel_ids);
 	endpoint->channel_ids = NULL;
@@ -214,18 +207,13 @@
 		return NULL;
 	}
 
-	endpoint->topic = stasis_topic_create(endpoint->id);
-	if (!endpoint->topic) {
-		return NULL;
-	}
-
-	endpoint->forward =
-		stasis_forward_all(endpoint->topic, ast_endpoint_topic_all());
-	if (!endpoint->forward) {
-		return NULL;
-	}
-
-	endpoint->router = stasis_message_router_create(endpoint->topic);
+	endpoint->topics = stasis_cache_one_create(ast_endpoint_cache_all(),
+		endpoint->id);
+	if (!endpoint->topics) {
+		return NULL;
+	}
+
+	endpoint->router = stasis_message_router_create(ast_endpoint_topic(endpoint));
 	if (!endpoint->router) {
 		return NULL;
 	}
@@ -271,7 +259,7 @@
 		RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
 		message = stasis_cache_clear_create(clear_msg);
 		if (message) {
-			stasis_publish(endpoint->topic, message);
+			stasis_publish(ast_endpoint_topic(endpoint), message);
 		}
 	}
 
@@ -283,11 +271,6 @@
 const char *ast_endpoint_get_resource(const struct ast_endpoint *endpoint)
 {
 	return endpoint->resource;
-}
-
-struct stasis_topic *ast_endpoint_topic(struct ast_endpoint *endpoint)
-{
-	return endpoint ? endpoint->topic : ast_endpoint_topic_all();
 }
 
 void ast_endpoint_set_state(struct ast_endpoint *endpoint,

Modified: team/dlee/stasis-cache-split/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/stasis_channels.c?view=diff&rev=394012&r1=394011&r2=394012
==============================================================================
--- team/dlee/stasis-cache-split/main/stasis_channels.c (original)
+++ team/dlee/stasis-cache-split/main/stasis_channels.c Wed Jul 10 15:20:22 2013
@@ -61,6 +61,11 @@
 
 static struct stasis_cache_all *channel_cache_all;
 static struct stasis_cache *channel_cache_by_name;
+
+struct stasis_cache_all *ast_channel_cache_all(void)
+{
+	return channel_cache_all;
+}
 
 struct stasis_cache *ast_channel_cache(void)
 {

Modified: team/dlee/stasis-cache-split/main/stasis_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/stasis_endpoints.c?view=diff&rev=394012&r1=394011&r2=394012
==============================================================================
--- team/dlee/stasis-cache-split/main/stasis_endpoints.c (original)
+++ team/dlee/stasis-cache-split/main/stasis_endpoints.c Wed Jul 10 15:20:22 2013
@@ -75,6 +75,11 @@
 
 static struct stasis_cache_all *endpoint_cache_all;
 
+struct stasis_cache_all *ast_endpoint_cache_all(void)
+{
+	return endpoint_cache_all;
+}
+
 struct stasis_cache *ast_endpoint_cache(void)
 {
 	return stasis_cache_all_cache(endpoint_cache_all);




More information about the svn-commits mailing list