[asterisk-commits] kmoore: branch kmoore/stasis-channel_events r383746 - in /team/kmoore/stasis-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Mar 25 14:23:24 CDT 2013


Author: kmoore
Date: Mon Mar 25 14:23:20 2013
New Revision: 383746

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383746
Log:
Move channels over to using a topic pool keyed on uniqueid

This change will allow sending messages to channel specific topics
without having to grab the channel itself (which may no longer be
available).

Modified:
    team/kmoore/stasis-channel_events/include/asterisk/channel.h
    team/kmoore/stasis-channel_events/main/channel.c
    team/kmoore/stasis-channel_events/main/channel_internal_api.c

Modified: team/kmoore/stasis-channel_events/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-channel_events/include/asterisk/channel.h?view=diff&rev=383746&r1=383745&r2=383746
==============================================================================
--- team/kmoore/stasis-channel_events/include/asterisk/channel.h (original)
+++ team/kmoore/stasis-channel_events/include/asterisk/channel.h Mon Mar 25 14:23:20 2013
@@ -4199,6 +4199,16 @@
 
 /*!
  * \since 12
+ * \brief Get the channel topic using the channel's uniqueid.
+ *
+ * \param uniqueid Unique ID of the channel for which to retreive the topic.
+ *
+ * \retval Topic for channel's events.
+ */
+struct stasis_topic *ast_channel_topic_by_uniqueid(const char *uniqueid);
+
+/*!
+ * \since 12
  * \brief A topic which publishes the events for all channels.
  * \retval Topic for all channel events.
  */

Modified: team/kmoore/stasis-channel_events/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-channel_events/main/channel.c?view=diff&rev=383746&r1=383745&r2=383746
==============================================================================
--- team/kmoore/stasis-channel_events/main/channel.c (original)
+++ team/kmoore/stasis-channel_events/main/channel.c Mon Mar 25 14:23:20 2013
@@ -160,6 +160,8 @@
 struct stasis_topic *__channel_topic_all;
 
 struct stasis_caching_topic *__channel_topic_all_cached;
+
+struct stasis_topic_pool *channel_topic_pool;
 
 /*! \brief map AST_CAUSE's to readable string representations
  *
@@ -8707,6 +8709,8 @@
 	__channel_blob = NULL;
 	ao2_cleanup(__channel_topic_all);
 	__channel_topic_all = NULL;
+	ao2_cleanup(channel_topic_pool);
+	channel_topic_pool = NULL;
 	__channel_topic_all_cached = stasis_caching_unsubscribe(__channel_topic_all_cached);
 	ast_data_unregister(NULL);
 	ast_cli_unregister_multiple(cli_channel, ARRAY_LEN(cli_channel));
@@ -8740,6 +8744,8 @@
 
 	__channel_topic_all = stasis_topic_create("ast_channel_topic_all");
 	__channel_topic_all_cached = stasis_caching_topic_create(__channel_topic_all, channel_snapshot_get_id);
+
+	channel_topic_pool = stasis_topic_pool_create(__channel_topic_all);
 
 	ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel));
 
@@ -11399,6 +11405,16 @@
 	return __channel_topic_all_cached;
 }
 
+struct stasis_topic *ast_channel_topic_by_uniqueid(const char *uniqueid)
+{
+	return stasis_topic_pool_get_topic(channel_topic_pool, uniqueid);
+}
+
+struct stasis_topic *ast_channel_topic(struct ast_channel *chan)
+{
+	return chan ? ast_channel_topic_by_uniqueid(ast_channel_uniqueid(chan)) : ast_channel_topic_all();
+}
+
 /* DO NOT PUT ADDITIONAL FUNCTIONS BELOW THIS BOUNDARY
  *
  * ONLY FUNCTIONS FOR PROVIDING BACKWARDS ABI COMPATIBILITY BELONG HERE

Modified: team/kmoore/stasis-channel_events/main/channel_internal_api.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-channel_events/main/channel_internal_api.c?view=diff&rev=383746&r1=383745&r2=383746
==============================================================================
--- team/kmoore/stasis-channel_events/main/channel_internal_api.c (original)
+++ team/kmoore/stasis-channel_events/main/channel_internal_api.c Mon Mar 25 14:23:20 2013
@@ -195,8 +195,6 @@
 	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_subscription *forwarder;		/*!< Subscription for event forwarding to all topic */
 };
 
 /* AST_DATA definitions, which will probably have to be re-thought since the channel will be opaque */
@@ -1366,11 +1364,6 @@
 	}
 
 	ast_string_field_free_memory(chan);
-
-	chan->forwarder = stasis_unsubscribe(chan->forwarder);
-
-	ao2_cleanup(chan->topic);
-	chan->topic = NULL;
 }
 
 void ast_channel_internal_finalize(struct ast_channel *chan)
@@ -1383,21 +1376,10 @@
 	return chan->finalized;
 }
 
-struct stasis_topic *ast_channel_topic(struct ast_channel *chan)
-{
-	return chan ? chan->topic : ast_channel_topic_all();
-}
-
 void 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);
-
-	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());
-}
+	struct stasis_topic *topic;
+
+	topic = ast_channel_topic_by_uniqueid(chan->uniqueid);
+	ast_assert(topic != NULL);
+}




More information about the asterisk-commits mailing list