[asterisk-commits] kmoore: branch kmoore/channel-state-caching r381034 - in /team/kmoore/channel...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Feb 7 09:45:40 CST 2013


Author: kmoore
Date: Thu Feb  7 09:45:36 2013
New Revision: 381034

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381034
Log:
Back out r380969

Removed:
    team/kmoore/channel-state-caching/include/asterisk/stasis.h
    team/kmoore/channel-state-caching/main/stasis.c
Modified:
    team/kmoore/channel-state-caching/include/asterisk/event.h
    team/kmoore/channel-state-caching/include/asterisk/event_defs.h
    team/kmoore/channel-state-caching/main/channel.c
    team/kmoore/channel-state-caching/main/event.c
    team/kmoore/channel-state-caching/main/manager.c

Modified: team/kmoore/channel-state-caching/include/asterisk/event.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel-state-caching/include/asterisk/event.h?view=diff&rev=381034&r1=381033&r2=381034
==============================================================================
--- team/kmoore/channel-state-caching/include/asterisk/event.h (original)
+++ team/kmoore/channel-state-caching/include/asterisk/event.h Thu Feb  7 09:45:36 2013
@@ -950,6 +950,16 @@
  */
 size_t ast_event_minimum_length(void);
 
+/*!
+ * \brief Send a channel state-related event.
+ *
+ * \param chan the channel about which to send information
+ *
+ * \return zero on success
+ * \return non-zero on failure
+ */
+int ast_event_queue_channel_state(struct ast_channel *chan);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/kmoore/channel-state-caching/include/asterisk/event_defs.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel-state-caching/include/asterisk/event_defs.h?view=diff&rev=381034&r1=381033&r2=381034
==============================================================================
--- team/kmoore/channel-state-caching/include/asterisk/event_defs.h (original)
+++ team/kmoore/channel-state-caching/include/asterisk/event_defs.h Thu Feb  7 09:45:36 2013
@@ -61,7 +61,7 @@
 	/*! Send out a ping for debugging distributed events */
 	AST_EVENT_PING                = 0x0c,
 	/*! A channel state snapshot */
-	AST_EVENT_STASIS              = 0x0d,
+	AST_EVENT_CHANNEL_STATE       = 0x0d,
 	/*! Number of event types.  This should be the last event type + 1 */
 	AST_EVENT_TOTAL               = 0x0e,
 };
@@ -308,28 +308,14 @@
 	AST_EVENT_IE_CACHABLE            = 0x003d,
 
 	/*!
-	 * \brief Stasis state message
-	 * Used by: AST_EVENT_STASIS
-	 * Payload type: RAW_LOCAL
-	 */
-	AST_EVENT_IE_STASIS_MESSAGE      = 0x003e,
-
-	/*!
-	 * \brief Stasis message type
-	 * Used by: AST_EVENT_STASIS
-	 * Payload type: UINT
-	 */
-	AST_EVENT_IE_STASIS_MESSAGE_TYPE = 0x003f,
-
-	/*!
-	 * \brief Stasis message key
-	 * Used by: AST_EVENT_STASIS
-	 * Payload type: UINT
-	 */
-	AST_EVENT_IE_STASIS_MESSAGE_KEY  = 0x0040,
+	 * \brief Channel state summary
+	 * Used by: AST_EVENT_CHANNEL_STATE
+	 * Payload type: RAW
+	 */
+	AST_EVENT_IE_CHANNEL_STATE       = 0x003e,
 
 	/*! \brief Must be the last IE value +1 */
-	AST_EVENT_IE_TOTAL               = 0x0041,
+	AST_EVENT_IE_TOTAL               = 0x003f,
 };
 
 /*!

Modified: team/kmoore/channel-state-caching/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel-state-caching/main/channel.c?view=diff&rev=381034&r1=381033&r2=381034
==============================================================================
--- team/kmoore/channel-state-caching/main/channel.c (original)
+++ team/kmoore/channel-state-caching/main/channel.c Thu Feb  7 09:45:36 2013
@@ -74,7 +74,6 @@
 #include "asterisk/channel_internal.h"
 #include "asterisk/features.h"
 #include "asterisk/test.h"
-#include "asterisk/stasis.h"
 
 /*** DOCUMENTATION
  ***/
@@ -1146,7 +1145,7 @@
 	 * a lot of data into this func to do it here!
 	 */
 	if (ast_get_channel_tech(tech) || (tech2 && ast_get_channel_tech(tech2))) {
-		ast_stasis_queue_channel_state(tmp);
+		ast_event_queue_channel_state(tmp);
 	}
 
 	ast_channel_internal_finalize(tmp);
@@ -2868,7 +2867,7 @@
 
 	ast_cc_offer(chan);
 
-	ast_stasis_queue_channel_state(chan);
+	ast_event_queue_channel_state(chan);
 
 	if (ast_channel_cdr(chan) && !ast_test_flag(ast_channel_cdr(chan), AST_CDR_FLAG_BRIDGED) &&
 		!ast_test_flag(ast_channel_cdr(chan), AST_CDR_FLAG_POST_DISABLED) &&
@@ -7380,7 +7379,7 @@
 	 * we override what they are saying the state is and things go amuck. */
 	ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_DEVSTATE_CACHE) ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), name);
 
-	ast_stasis_queue_channel_state(chan);
+	ast_event_queue_channel_state(chan);
 
 	return 0;
 }

Modified: team/kmoore/channel-state-caching/main/event.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel-state-caching/main/event.c?view=diff&rev=381034&r1=381033&r2=381034
==============================================================================
--- team/kmoore/channel-state-caching/main/event.c (original)
+++ team/kmoore/channel-state-caching/main/event.c Thu Feb  7 09:45:36 2013
@@ -145,7 +145,7 @@
 static int ast_event_hash_devstate(const void *obj, const int flags);
 static int ast_event_hash_devstate_change(const void *obj, const int flags);
 static int ast_event_hash_presence_state_change(const void *obj, const int flags);
-static int ast_event_hash_stasis_message(const void *obj, const int flags);
+static int ast_event_hash_channel_state(const void *obj, const int flags);
 
 #ifdef LOW_MEMORY
 #define NUM_CACHE_BUCKETS 17
@@ -201,9 +201,9 @@
 		.hash_fn = ast_event_hash_presence_state_change,
 		.cache_args = { AST_EVENT_IE_PRESENCE_STATE, },
 	},
-	[AST_EVENT_STASIS] = {
-		.hash_fn = ast_event_hash_stasis_message,
-		.cache_args = { AST_EVENT_IE_STASIS_MESSAGE_KEY, AST_EVENT_IE_STASIS_MESSAGE_TYPE },
+	[AST_EVENT_CHANNEL_STATE] = {
+		.hash_fn = ast_event_hash_channel_state,
+		.cache_args = { AST_EVENT_IE_CEL_CHANNAME},
 	},
 
 };
@@ -229,7 +229,7 @@
 	[AST_EVENT_CEL]                 = "CEL",
 	[AST_EVENT_SECURITY]            = "Security",
 	[AST_EVENT_NETWORK_CHANGE]      = "NetworkChange",
-	[AST_EVENT_STASIS]              = "Stasis",
+	[AST_EVENT_CHANNEL_STATE]       = "ChannelState",
 };
 
 /*!
@@ -295,9 +295,7 @@
 	[AST_EVENT_IE_USING_PASSWORD]      = { AST_EVENT_IE_PLTYPE_UINT, "UsingPassword" },
 	[AST_EVENT_IE_ATTEMPTED_TRANSPORT] = { AST_EVENT_IE_PLTYPE_STR,  "AttemptedTransport" },
 	[AST_EVENT_IE_CACHABLE]            = { AST_EVENT_IE_PLTYPE_UINT, "Cachable" },
-	[AST_EVENT_IE_STASIS_MESSAGE]      = { AST_EVENT_IE_PLTYPE_RAW_LOCAL, "StasisMessage" },
-	[AST_EVENT_IE_STASIS_MESSAGE_KEY]  = { AST_EVENT_IE_PLTYPE_STR,  "StasisMessageKey" },
-	[AST_EVENT_IE_STASIS_MESSAGE_TYPE] = { AST_EVENT_IE_PLTYPE_UINT, "StasisMessageType" },
+	[AST_EVENT_IE_CHANNEL_STATE]       = { AST_EVENT_IE_PLTYPE_RAW_LOCAL, "ChannelState" },
 };
 
 const char *ast_event_get_type_name(const struct ast_event *event)
@@ -1977,20 +1975,18 @@
 
 /*!
  * \internal
- * \brief Hash function for AST_EVENT_STASIS
+ * \brief Hash function for AST_EVENT_CHANNEL_STATE
  *
  * \param[in] obj an ast_event
  * \param[in] flags unused
  *
  * \return hash value
  */
-static int ast_event_hash_stasis_message(const void *obj, const int flags)
+static int ast_event_hash_channel_state(const void *obj, const int flags)
 {
 	const struct ast_event *event = obj;
-	const char *key = ast_event_get_ie_str(event, AST_EVENT_IE_STASIS_MESSAGE_KEY);
-	unsigned int type = ast_event_get_ie_uint(event, AST_EVENT_IE_STASIS_MESSAGE_TYPE);
-
-	return ast_str_hash_add(key, type);
+
+	return ast_str_hash(ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME));
 }
 
 /*!
@@ -2255,3 +2251,30 @@
 {
 	return sizeof(struct ast_event);
 }
+
+int ast_event_queue_channel_state(struct ast_channel *chan)
+{
+	struct ast_channel_snapshot *snapshot = ast_channel_snapshot_create(chan);
+	struct ast_event *newchannel_event;
+	if (!snapshot) {
+		return -1;
+	}
+	newchannel_event = ast_event_new(AST_EVENT_CHANNEL_STATE,
+		AST_EVENT_IE_CEL_CHANNAME,          AST_EVENT_IE_PLTYPE_STR, snapshot->uniqueid,
+		AST_EVENT_IE_CHANNEL_STATE,         AST_EVENT_IE_PLTYPE_RAW_LOCAL, snapshot, sizeof(*snapshot),
+			ast_channel_snapshot_copy, ast_channel_snapshot_cmp, ast_channel_snapshot_destroy, 
+		AST_EVENT_IE_END);
+
+	ast_channel_snapshot_destroy(snapshot, sizeof(*snapshot));
+	ast_free(snapshot);
+	if (!newchannel_event) {
+		return -1;
+	}
+
+	if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_DEVSTATE_CACHE)) {
+		ast_event_queue(newchannel_event);
+	} else {
+		ast_event_queue_and_cache(newchannel_event);
+	}
+	return 0;
+}

Modified: team/kmoore/channel-state-caching/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel-state-caching/main/manager.c?view=diff&rev=381034&r1=381033&r2=381034
==============================================================================
--- team/kmoore/channel-state-caching/main/manager.c (original)
+++ team/kmoore/channel-state-caching/main/manager.c Thu Feb  7 09:45:36 2013
@@ -91,7 +91,6 @@
 #include "asterisk/aoc.h"
 #include "asterisk/stringfields.h"
 #include "asterisk/presencestate.h"
-#include "asterisk/stasis.h"
 
 /*** DOCUMENTATION
 	<manager name="Ping" language="en_US">
@@ -7481,7 +7480,7 @@
 
 static void channel_state_cb(const struct ast_event *event, void *userdata)
 {
-	const struct ast_channel_snapshot *new_snapshot = ast_event_get_ie_raw_local(event, AST_EVENT_IE_STASIS_MESSAGE);
+	const struct ast_channel_snapshot *new_snapshot = ast_event_get_ie_raw_local(event, AST_EVENT_IE_CHANNEL_STATE);
 	struct ast_channel_snapshot *old_snapshot = NULL, *ao2_snapshot = NULL;
 	int is_hungup = ast_test_flag(&new_snapshot->flags, AST_FLAG_ZOMBIE) ? 1 : 0;
 	int find_flags = OBJ_KEY;
@@ -7523,9 +7522,8 @@
 	if (old_snapshot && is_hungup) {
 		manager_hangup(new_snapshot);
 		/* drop the cache for this channel */
-		ast_event_drop_cached(AST_EVENT_STASIS,
-			AST_EVENT_IE_STASIS_MESSAGE_KEY,        AST_EVENT_IE_PLTYPE_STR, new_snapshot->uniqueid,
-			AST_EVENT_IE_STASIS_MESSAGE_TYPE,       AST_EVENT_IE_PLTYPE_UINT, AST_STASIS_TYPE_CHANNEL,
+		ast_event_drop_cached(AST_EVENT_CHANNEL_STATE,
+			AST_EVENT_IE_CEL_CHANNAME,        AST_EVENT_IE_PLTYPE_STR, new_snapshot->uniqueid,
 			AST_EVENT_IE_END);
 	}
 
@@ -7672,10 +7670,9 @@
 	}
 
 	if (!channel_state_sub) {
-		channel_state_sub = ast_event_subscribe(AST_EVENT_STASIS,
-			channel_state_cb, "Manager Channel State Subscription", NULL,
-			AST_EVENT_IE_STASIS_MESSAGE_TYPE, AST_EVENT_IE_PLTYPE_UINT, AST_STASIS_TYPE_CHANNEL,
-			AST_EVENT_IE_END);
+		channel_state_sub = ast_event_subscribe(AST_EVENT_CHANNEL_STATE,
+			channel_state_cb, "Manager Channel State Subscription",
+			NULL, AST_EVENT_IE_END);
 		if (!channel_state_sub) {
 			ast_log(LOG_NOTICE, "Unable to create channel state subscription.\n");
 			return -1;




More information about the asterisk-commits mailing list