[svn-commits] file: branch file/stasis_tweaking r390504 - in /team/file/stasis_tweaking: in...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jun 5 11:25:39 CDT 2013


Author: file
Date: Wed Jun  5 11:25:37 2013
New Revision: 390504

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390504
Log:
Make adding a channel to an endpoint an immediate operation.

Modified:
    team/file/stasis_tweaking/include/asterisk/channel.h
    team/file/stasis_tweaking/main/channel_internal_api.c
    team/file/stasis_tweaking/main/endpoints.c

Modified: team/file/stasis_tweaking/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/file/stasis_tweaking/include/asterisk/channel.h?view=diff&rev=390504&r1=390503&r2=390504
==============================================================================
--- team/file/stasis_tweaking/include/asterisk/channel.h (original)
+++ team/file/stasis_tweaking/include/asterisk/channel.h Wed Jun  5 11:25:37 2013
@@ -152,6 +152,7 @@
 #include "asterisk/framehook.h"
 #include "asterisk/stasis.h"
 #include "asterisk/json.h"
+#include "asterisk/endpoints.h"
 
 #define DATASTORE_INHERIT_FOREVER	INT_MAX
 
@@ -4262,4 +4263,16 @@
  */
 int ast_channel_move(struct ast_channel *dest, struct ast_channel *source);
 
+/*!
+ * \since 12
+ * \brief Forward channel stasis messages to the given endpoint
+ *
+ * \param chan The channel to forward from
+ * \param endpoint The endpoint to forward to
+ *
+ * \retval 0 Success
+ * \retval non-zero Failure
+ */
+int ast_channel_forward_endpoint(struct ast_channel *chan, struct ast_endpoint *endpoint);
+
 #endif /* _ASTERISK_CHANNEL_H */

Modified: team/file/stasis_tweaking/main/channel_internal_api.c
URL: http://svnview.digium.com/svn/asterisk/team/file/stasis_tweaking/main/channel_internal_api.c?view=diff&rev=390504&r1=390503&r2=390504
==============================================================================
--- team/file/stasis_tweaking/main/channel_internal_api.c (original)
+++ team/file/stasis_tweaking/main/channel_internal_api.c Wed Jun  5 11:25:37 2013
@@ -1406,8 +1406,7 @@
 	return chan ? chan->topic : ast_channel_topic_all();
 }
 
-int ast_endpoint_add_channel(struct ast_endpoint *endpoint,
-	struct ast_channel *chan)
+int ast_channel_forward_endpoint(struct ast_channel *chan, struct ast_endpoint *endpoint)
 {
 	ast_assert(chan != NULL);
 	ast_assert(endpoint != NULL);
@@ -1418,8 +1417,6 @@
 	if (chan->endpoint_forward == NULL) {
 		return -1;
 	}
-
-	ast_publish_channel_state(chan);
 
 	return 0;
 }

Modified: team/file/stasis_tweaking/main/endpoints.c
URL: http://svnview.digium.com/svn/asterisk/team/file/stasis_tweaking/main/endpoints.c?view=diff&rev=390504&r1=390503&r2=390504
==============================================================================
--- team/file/stasis_tweaking/main/endpoints.c (original)
+++ team/file/stasis_tweaking/main/endpoints.c Wed Jun  5 11:25:37 2013
@@ -119,30 +119,23 @@
 	ast_string_field_free_memory(endpoint);
 }
 
-static void endpoint_channel_snapshot(void *data,
-	struct stasis_subscription *sub, struct stasis_topic *topic,
-	struct stasis_message *message)
-{
-	struct ast_endpoint *endpoint = data;
-	struct ast_channel_snapshot *snapshot = stasis_message_data(message);
-	RAII_VAR(char *, existing_id, NULL, ao2_cleanup);
-	int publish = 0;
-
-	ast_assert(endpoint != NULL);
-	ast_assert(snapshot != NULL);
+
+int ast_endpoint_add_channel(struct ast_endpoint *endpoint,
+	struct ast_channel *chan)
+{
+	ast_assert(chan != NULL);
+	ast_assert(endpoint != NULL);
+
+	ast_channel_forward_endpoint(chan, endpoint);
 
 	ao2_lock(endpoint);
-	existing_id = ao2_find(endpoint->channel_ids, snapshot->uniqueid,
-		OBJ_POINTER);
-	if (!existing_id) {
-		ast_str_container_add(endpoint->channel_ids,
-			snapshot->uniqueid);
-		publish = 1;
-	}
+	ast_str_container_add(endpoint->channel_ids, ast_channel_uniqueid(chan));
 	ao2_unlock(endpoint);
-	if (publish) {
-		endpoint_publish_snapshot(endpoint);
-	}
+
+	ast_publish_channel_state(chan);
+	endpoint_publish_snapshot(endpoint);
+
+	return 0;
 }
 
 static void endpoint_cache_clear(void *data,
@@ -227,9 +220,6 @@
 		return NULL;
 	}
 	r |= stasis_message_router_add(endpoint->router,
-		ast_channel_snapshot_type(), endpoint_channel_snapshot,
-		endpoint);
-	r |= stasis_message_router_add(endpoint->router,
 		stasis_cache_clear_type(), endpoint_cache_clear,
 		endpoint);
 	r |= stasis_message_router_set_default(endpoint->router,




More information about the svn-commits mailing list