[asterisk-commits] kmoore: branch kmoore/stasis-bridging-channel_events r385914 - in /team/kmoor...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Apr 16 15:34:16 CDT 2013
Author: kmoore
Date: Tue Apr 16 15:34:12 2013
New Revision: 385914
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385914
Log:
Multiple revisions 385789,385807,385836,385865,385889
........
r385789 | root | 2013-04-15 13:17:20 -0500 (Mon, 15 Apr 2013) | 13 lines
Don't unnecessarily rebuild things on every run of 'make'.
Review: https://reviewboard.asterisk.org/r/2449/
........
Merged revisions 385745 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 385768 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 385782 from file:///srv/subversion/repos/asterisk/trunk
........
r385807 | rmudgett | 2013-04-15 13:32:09 -0500 (Mon, 15 Apr 2013) | 1 line
Remove some unnecessary NULL pointer checks.
........
r385836 | root | 2013-04-16 09:17:27 -0500 (Tue, 16 Apr 2013) | 5 lines
Fixed a typo
........
Merged revisions 385835 from file:///srv/subversion/repos/asterisk/trunk
........
r385865 | root | 2013-04-16 11:17:23 -0500 (Tue, 16 Apr 2013) | 31 lines
Multiple revisions 385860,385862
........
r385860 | kmoore | 2013-04-16 10:33:59 -0500 (Tue, 16 Apr 2013) | 12 lines
Move device state distribution to Stasis-core
In the move from Asterisk's event system to Stasis, this makes
distributed device state aggregation always-on, removes unnecessary
task processors where possible, and collapses aggregate and
non-aggregate states into a single cache for ease of retrieval. This
also removes an intermediary step in device state aggregation.
Review: https://reviewboard.asterisk.org/r/2389/
(closes issue ASTERISK-21101)
Patch-by: Kinsey Moore <kmoore at digium.com>
........
r385862 | kmoore | 2013-04-16 10:48:16 -0500 (Tue, 16 Apr 2013) | 9 lines
Move presence state distribution to Stasis-core
Convert presence state events to Stasis-core messages and remove
redundant serializers where possible.
Review: https://reviewboard.asterisk.org/r/2410/
(closes issue ASTERISK-21102)
Patch-by: Kinsey Moore <kmoore at digium.com>
........
Merged revisions 385860,385862 from file:///srv/subversion/repos/asterisk/trunk
........
r385889 | root | 2013-04-16 13:17:20 -0500 (Tue, 16 Apr 2013) | 8 lines
Allow res_corosync to build
ast_enable_distributed_devstate is no longer applicable to how the
distributed device state system works and is no longer necessary.
........
Merged revisions 385886 from file:///srv/subversion/repos/asterisk/trunk
........
Merged revisions 385789,385807,385836,385865,385889 from http://svn.asterisk.org/svn/asterisk/team/group/bridge_construction
Modified:
team/kmoore/stasis-bridging-channel_events/ (props changed)
team/kmoore/stasis-bridging-channel_events/Makefile
team/kmoore/stasis-bridging-channel_events/apps/app_queue.c
team/kmoore/stasis-bridging-channel_events/funcs/func_presencestate.c
team/kmoore/stasis-bridging-channel_events/include/asterisk/devicestate.h
team/kmoore/stasis-bridging-channel_events/include/asterisk/presencestate.h
team/kmoore/stasis-bridging-channel_events/include/asterisk/stasis_channels.h
team/kmoore/stasis-bridging-channel_events/include/asterisk/xmpp.h
team/kmoore/stasis-bridging-channel_events/main/asterisk.c
team/kmoore/stasis-bridging-channel_events/main/bridging.c
team/kmoore/stasis-bridging-channel_events/main/ccss.c
team/kmoore/stasis-bridging-channel_events/main/devicestate.c
team/kmoore/stasis-bridging-channel_events/main/pbx.c
team/kmoore/stasis-bridging-channel_events/main/presencestate.c
team/kmoore/stasis-bridging-channel_events/res/res_corosync.c
team/kmoore/stasis-bridging-channel_events/res/res_jabber.c
team/kmoore/stasis-bridging-channel_events/res/res_xmpp.c
team/kmoore/stasis-bridging-channel_events/tests/test_devicestate.c
Propchange: team/kmoore/stasis-bridging-channel_events/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.
Propchange: team/kmoore/stasis-bridging-channel_events/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Apr 16 15:34:12 2013
@@ -1,1 +1,1 @@
-/team/group/bridge_construction:1-385783
+/team/group/bridge_construction:1-385913
Modified: team/kmoore/stasis-bridging-channel_events/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/Makefile?view=diff&rev=385914&r1=385913&r2=385914
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/Makefile (original)
+++ team/kmoore/stasis-bridging-channel_events/Makefile Tue Apr 16 15:34:12 2013
@@ -356,7 +356,7 @@
+@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
+@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
-$(SUBDIRS): makeopts cleantest main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
+$(SUBDIRS): makeopts .lastclean main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
# Non-windows:
@@ -382,26 +382,25 @@
$(OTHER_SUBDIRS): makeopts
+ at _ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
-defaults.h: makeopts cleantest build_tools/make_defaults_h
+defaults.h: makeopts .lastclean build_tools/make_defaults_h
@build_tools/make_defaults_h > $@.tmp
@cmp -s $@.tmp $@ || mv $@.tmp $@
@rm -f $@.tmp
-main/version.c: FORCE cleantest
+main/version.c: FORCE .lastclean
@build_tools/make_version_c > $@.tmp
@cmp -s $@.tmp $@ || mv $@.tmp $@
@rm -f $@.tmp
-include/asterisk/buildopts.h: menuselect.makeopts cleantest
+include/asterisk/buildopts.h: menuselect.makeopts .lastclean
@build_tools/make_buildopts_h > $@.tmp
@cmp -s $@.tmp $@ || mv $@.tmp $@
@rm -f $@.tmp
-# build.h must depend on cleantest, or parallel make may wipe it out after it's
-# been created. But since build.h contains a timestamp, the cmp trick used above
-# won't work. Just testing for existence is good enough.
-include/asterisk/build.h: cleantest
- @test -f $@ || build_tools/make_build_h > $@
+# build.h must depend on .lastclean, or parallel make may wipe it out after it's
+# been created.
+include/asterisk/build.h: .lastclean
+ @build_tools/make_build_h > $@
$(SUBDIRS_CLEAN):
+@$(SUBMAKE) -C $(@:-clean=) clean
@@ -459,7 +458,7 @@
XML_core_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
endif
-doc/core-en_US.xml: makeopts cleantest $(XML_core_en_US)
+doc/core-en_US.xml: makeopts .lastclean $(XML_core_en_US)
@printf "Building Documentation For: "
@echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
@echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
@@ -477,7 +476,7 @@
XMX_full_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
endif
-doc/full-en_US.xml: makeopts cleantest $(XML_full_en_US)
+doc/full-en_US.xml: makeopts .lastclean $(XML_full_en_US)
ifeq ($(PYTHON),:)
@echo "--------------------------------------------------------------------------"
@echo "--- Please install python to build full documentation ---"
@@ -848,8 +847,8 @@
# .cleancount is the global clean count, and .lastclean is the
# last clean count we had
-cleantest:
- @cmp -s .cleancount .lastclean || $(MAKE) clean
+.lastclean: .cleancount
+ @$(MAKE) clean
@[ -f "$(DESTDIR)$(ASTDBDIR)/astdb.sqlite3" ] || [ ! -f "$(DESTDIR)$(ASTDBDIR)/astdb" ] || [ ! -f menuselect.makeopts ] || grep -q MENUSELECT_UTILS=.*astdb2sqlite3 menuselect.makeopts || (sed -i.orig -e's/MENUSELECT_UTILS=\(.*\)/MENUSELECT_UTILS=\1 astdb2sqlite3/' menuselect.makeopts && echo "Updating menuselect.makeopts to include astdb2sqlite3" && echo "Original version backed up to menuselect.makeopts.orig")
$(SUBDIRS_UNINSTALL):
@@ -927,19 +926,19 @@
CFLAGS="$(BUILD_CFLAGS)" LDFLAGS="$(BUILD_LDFLAGS)" \
$(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
-menuselect/menuselect: menuselect/makeopts cleantest
+menuselect/menuselect: menuselect/makeopts .lastclean
+$(MAKE_MENUSELECT) menuselect
-menuselect/cmenuselect: menuselect/makeopts cleantest
+menuselect/cmenuselect: menuselect/makeopts .lastclean
+$(MAKE_MENUSELECT) cmenuselect
-menuselect/gmenuselect: menuselect/makeopts cleantest
+menuselect/gmenuselect: menuselect/makeopts .lastclean
+$(MAKE_MENUSELECT) gmenuselect
-menuselect/nmenuselect: menuselect/makeopts cleantest
+menuselect/nmenuselect: menuselect/makeopts .lastclean
+$(MAKE_MENUSELECT) nmenuselect
-menuselect/makeopts: makeopts cleantest
+menuselect/makeopts: makeopts .lastclean
+$(MAKE_MENUSELECT) makeopts
menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml build_tools/embed_modules.xml utils/utils.xml agi/agi.xml configure makeopts
@@ -970,7 +969,6 @@
.PHONY: full
.PHONY: _full
.PHONY: prereqs
-.PHONY: cleantest
.PHONY: uninstall
.PHONY: _uninstall
.PHONY: uninstall-all
Modified: team/kmoore/stasis-bridging-channel_events/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/apps/app_queue.c?view=diff&rev=385914&r1=385913&r2=385914
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/apps/app_queue.c (original)
+++ team/kmoore/stasis-bridging-channel_events/apps/app_queue.c Tue Apr 16 15:34:12 2013
@@ -991,9 +991,6 @@
{ QUEUE_AUTOPAUSE_ALL,"all" },
};
-
-static struct ast_taskprocessor *devicestate_tps;
-
#define DEFAULT_RETRY 5
#define DEFAULT_TIMEOUT 15
#define RECHECK 1 /*!< Recheck every second to see we we're at the top yet */
@@ -1038,8 +1035,8 @@
/*! \brief queues.conf [general] option */
static int shared_lastcall = 1;
-/*! \brief Subscription to device state change events */
-static struct ast_event_sub *device_state_sub;
+/*! \brief Subscription to device state change messages */
+static struct stasis_subscription *device_state_sub;
/*! \brief queues.conf [general] option */
static int update_cdr = 0;
@@ -1619,12 +1616,6 @@
return -1;
}
-struct statechange {
- AST_LIST_ENTRY(statechange) entry;
- int state;
- char dev[0];
-};
-
/*! \brief set a member's status based on device state of that member's state_interface.
*
* Lock interface list find sc, iterate through each queues queue_member list for member to
@@ -1743,10 +1734,10 @@
}
/*! \brief set a member's status based on device state of that member's interface*/
-static int handle_statechange(void *datap)
-{
- struct statechange *sc = datap;
+static void device_state_cb(void *unused, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
+{
struct ao2_iterator miter, qiter;
+ struct ast_device_state_message *dev_state;
struct member *m;
struct call_queue *q;
char interface[80], *slash_pos;
@@ -1754,6 +1745,16 @@
int found_member; /* Found this member in this queue */
int avail = 0; /* Found an available member in this queue */
+ if (ast_device_state_message_type() != stasis_message_type(msg)) {
+ return;
+ }
+
+ dev_state = stasis_message_data(msg);
+ if (dev_state->eid) {
+ /* ignore non-aggregate states */
+ return;
+ }
+
qiter = ao2_iterator_init(queues, 0);
while ((q = ao2_t_iterator_next(&qiter, "Iterate over queues"))) {
ao2_lock(q);
@@ -1771,9 +1772,9 @@
}
}
- if (!strcasecmp(interface, sc->dev)) {
+ if (!strcasecmp(interface, dev_state->device)) {
found_member = 1;
- update_status(q, m, sc->state);
+ update_status(q, m, dev_state->state);
}
}
@@ -1805,39 +1806,18 @@
ao2_iterator_destroy(&qiter);
if (found) {
- ast_debug(1, "Device '%s' changed to state '%d' (%s)\n", sc->dev, sc->state, ast_devstate2str(sc->state));
+ ast_debug(1, "Device '%s' changed to state '%d' (%s)\n",
+ dev_state->device,
+ dev_state->state,
+ ast_devstate2str(dev_state->state));
} else {
- ast_debug(3, "Device '%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", sc->dev, sc->state, ast_devstate2str(sc->state));
- }
-
- ast_free(sc);
- return 0;
-}
-
-static void device_state_cb(const struct ast_event *event, void *unused)
-{
- enum ast_device_state state;
- const char *device;
- struct statechange *sc;
- size_t datapsize;
-
- state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
- device = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE);
-
- if (ast_strlen_zero(device)) {
- ast_log(LOG_ERROR, "Received invalid event that had no device IE\n");
- return;
- }
- datapsize = sizeof(*sc) + strlen(device) + 1;
- if (!(sc = ast_calloc(1, datapsize))) {
- ast_log(LOG_ERROR, "failed to calloc a state change struct\n");
- return;
- }
- sc->state = state;
- strcpy(sc->dev, device);
- if (ast_taskprocessor_push(devicestate_tps, handle_statechange, sc) < 0) {
- ast_free(sc);
- }
+ ast_debug(3, "Device '%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n",
+ dev_state->device,
+ dev_state->state,
+ ast_devstate2str(dev_state->state));
+ }
+
+ return;
}
/*! \brief Helper function which converts from extension state to device state values */
@@ -9885,8 +9865,9 @@
res |= ast_data_unregister(NULL);
- if (device_state_sub)
- ast_event_unsubscribe(device_state_sub);
+ if (device_state_sub) {
+ device_state_sub = stasis_unsubscribe(device_state_sub);
+ }
ast_extension_state_del(0, extension_state_cb);
@@ -9896,7 +9877,6 @@
queue_t_unref(q, "Done with iterator");
}
ao2_iterator_destroy(&q_iter);
- devicestate_tps = ast_taskprocessor_unreference(devicestate_tps);
ao2_ref(queues, -1);
ast_unload_realtime("queue_members");
return res;
@@ -9957,12 +9937,8 @@
res |= ast_custom_function_register(&queuewaitingcount_function);
res |= ast_custom_function_register(&queuememberpenalty_function);
- if (!(devicestate_tps = ast_taskprocessor_get("app_queue", 0))) {
- ast_log(LOG_WARNING, "devicestate taskprocessor reference failed - devicestate notifications will not occur\n");
- }
-
/* in the following subscribe call, do I use DEVICE_STATE, or DEVICE_STATE_CHANGE? */
- if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, device_state_cb, "AppQueue Device state", NULL, AST_EVENT_IE_END))) {
+ if (!(device_state_sub = stasis_subscribe(ast_device_state_topic_all(), device_state_cb, NULL))) {
res = -1;
}
Modified: team/kmoore/stasis-bridging-channel_events/funcs/func_presencestate.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/funcs/func_presencestate.c?view=diff&rev=385914&r1=385913&r2=385914
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/funcs/func_presencestate.c (original)
+++ team/kmoore/stasis-bridging-channel_events/funcs/func_presencestate.c Tue Apr 16 15:34:12 2013
@@ -645,21 +645,20 @@
}
struct test_cb_data {
- enum ast_presence_state presence;
- const char *provider;
- const char *subtype;
- const char *message;
+ struct ast_presence_state_message *presence_state;
/* That's right. I'm using a semaphore */
sem_t sem;
};
-static void test_cb(const struct ast_event *event, void *userdata)
+static void test_cb(void *userdata, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
{
struct test_cb_data *cb_data = userdata;
- cb_data->presence = ast_event_get_ie_uint(event, AST_EVENT_IE_PRESENCE_STATE);
- cb_data->provider = ast_strdup(ast_event_get_ie_str(event, AST_EVENT_IE_PRESENCE_PROVIDER));
- cb_data->subtype = ast_strdup(ast_event_get_ie_str(event, AST_EVENT_IE_PRESENCE_SUBTYPE));
- cb_data->message = ast_strdup(ast_event_get_ie_str(event, AST_EVENT_IE_PRESENCE_MESSAGE));
+ if (stasis_message_type(msg) != ast_presence_state_message_type()) {
+ return;
+ }
+ cb_data->presence_state = stasis_message_data(msg);
+ ao2_ref(cb_data->presence_state, +1);
+
sem_post(&cb_data->sem);
}
@@ -670,7 +669,7 @@
*/
AST_TEST_DEFINE(test_presence_state_change)
{
- struct ast_event_sub *test_sub;
+ struct stasis_subscription *test_sub;
struct test_cb_data *cb_data;
switch (cmd) {
@@ -690,8 +689,7 @@
return AST_TEST_FAIL;
}
- if (!(test_sub = ast_event_subscribe(AST_EVENT_PRESENCE_STATE,
- test_cb, "Test presence state callbacks", cb_data, AST_EVENT_IE_END))) {
+ if (!(test_sub = stasis_subscribe(ast_presence_state_topic_all(), test_cb, cb_data))) {
return AST_TEST_FAIL;
}
@@ -701,16 +699,16 @@
presence_write(NULL, "PRESENCESTATE", "CustomPresence:TestPresenceStateChange", "away,down the hall,Quarterly financial meeting");
sem_wait(&cb_data->sem);
- if (cb_data->presence != AST_PRESENCE_AWAY ||
- strcmp(cb_data->provider, "CustomPresence:TestPresenceStateChange") ||
- strcmp(cb_data->subtype, "down the hall") ||
- strcmp(cb_data->message, "Quarterly financial meeting")) {
+ if (cb_data->presence_state->state != AST_PRESENCE_AWAY ||
+ strcmp(cb_data->presence_state->provider, "CustomPresence:TestPresenceStateChange") ||
+ strcmp(cb_data->presence_state->subtype, "down the hall") ||
+ strcmp(cb_data->presence_state->message, "Quarterly financial meeting")) {
return AST_TEST_FAIL;
}
- ast_free((char *)cb_data->provider);
- ast_free((char *)cb_data->subtype);
- ast_free((char *)cb_data->message);
+ test_sub = stasis_unsubscribe(test_sub);
+
+ ao2_cleanup(cb_data->presence_state);
ast_free((char *)cb_data);
ast_db_del("CustomPresence", "TestPresenceStateChange");
Modified: team/kmoore/stasis-bridging-channel_events/include/asterisk/devicestate.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/include/asterisk/devicestate.h?view=diff&rev=385914&r1=385913&r2=385914
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/include/asterisk/devicestate.h (original)
+++ team/kmoore/stasis-bridging-channel_events/include/asterisk/devicestate.h Tue Apr 16 15:34:12 2013
@@ -38,6 +38,7 @@
#define _ASTERISK_DEVICESTATE_H
#include "asterisk/channelstate.h"
+#include "asterisk/utils.h"
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
@@ -270,19 +271,87 @@
};
/*!
- * \brief Enable distributed device state processing.
- *
- * \details
- * By default, Asterisk assumes that device state change events will only be
- * originating from one instance. If a module gets loaded and configured such
- * that multiple instances of Asterisk will be sharing device state, this
- * function should be called to enable distributed device state processing.
- * It is off by default to save on unnecessary processing.
- *
- * \retval 0 success
- * \retval -1 failure
- */
-int ast_enable_distributed_devstate(void);
+ * \brief The structure that contains device state
+ * \since 12
+ */
+struct ast_device_state_message {
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(cache_id); /*!< A unique ID used for hashing */
+ AST_STRING_FIELD(device); /*!< The name of the device */
+ );
+ enum ast_device_state state; /*!< The state of the device */
+ struct ast_eid *eid; /*!< The EID of the server where this message originated, NULL EID means aggregate state */
+ enum ast_devstate_cache cachable; /*!< Flag designating the cachability of this device state */
+};
+
+/*!
+ * \brief Get the Stasis topic for device state messages
+ * \retval The topic for device state messages
+ * \retval NULL if it has not been allocated
+ * \since 12
+ */
+struct stasis_topic *ast_device_state_topic_all(void);
+
+/*!
+ * \brief Get the Stasis topic for device state messages for a specific device
+ * \param uniqueid The device for which to get the topic
+ * \retval The topic structure for MWI messages for a given device
+ * \retval NULL if it failed to be found or allocated
+ * \since 12
+ */
+struct stasis_topic *ast_device_state_topic(const char *device);
+
+/*!
+ * \brief Get the Stasis caching topic for device state messages
+ * \retval The caching topic for device state messages
+ * \retval NULL if it has not been allocated
+ * \since 12
+ */
+struct stasis_caching_topic *ast_device_state_topic_cached(void);
+
+/*!
+ * \brief Get the Stasis message type for device state messages
+ * \retval The message type for device state messages
+ * \retval NULL if it has not been allocated
+ * \since 12
+ */
+struct stasis_message_type *ast_device_state_message_type(void);
+
+/*!
+ * \brief Initialize the device state core
+ * \retval 0 Success
+ * \retval -1 Failure
+ * \since 12
+ */
+int devstate_init(void);
+
+/*!
+ * \brief Publish a device state update
+ * \param[in] device The device name
+ * \param[in] state The state of the device
+ * \param[in] cachable Whether the device state can be cached
+ * \retval 0 Success
+ * \retval -1 Failure
+ * \since 12
+ */
+#define ast_publish_device_state(device, state, cachable) \
+ ast_publish_device_state_full(device, state, cachable, &ast_eid_default)
+
+/*!
+ * \brief Publish a device state update with EID
+ * \param[in] device The device name
+ * \param[in] state The state of the device
+ * \param[in] cachable Whether the device state can be cached
+ * \param[in] eid The EID of the server that originally published the message
+ * \retval 0 Success
+ * \retval -1 Failure
+ * \since 12
+ */
+int ast_publish_device_state_full(
+ const char *device,
+ enum ast_device_state state,
+ enum ast_devstate_cache cachable,
+ struct ast_eid *eid);
#if defined(__cplusplus) || defined(c_plusplus)
}
Modified: team/kmoore/stasis-bridging-channel_events/include/asterisk/presencestate.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/include/asterisk/presencestate.h?view=diff&rev=385914&r1=385913&r2=385914
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/include/asterisk/presencestate.h (original)
+++ team/kmoore/stasis-bridging-channel_events/include/asterisk/presencestate.h Tue Apr 16 15:34:12 2013
@@ -149,6 +149,40 @@
*/
int ast_presence_state_prov_del(const char *label);
+/*!
+ * \brief Get presence state message type
+ * \retval Stasis message type for presence state messages
+ * \since 12
+ */
+struct stasis_message_type *ast_presence_state_message_type(void);
+
+/*!
+ * \brief Get presence state topic
+ * \retval Stasis topic for presence state messages
+ * \since 12
+ */
+struct stasis_topic *ast_presence_state_topic_all(void);
+
+/*!
+ * \brief Get caching presence state topic
+ * \retval Caching Stasis topic for presence state messages
+ * \since 12
+ */
+struct stasis_caching_topic *ast_presence_state_topic_cached(void);
+
+/*!
+ * \brief Stasis message payload representing a presence state update
+ * \since 12
+ */
+struct ast_presence_state_message {
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(provider); /*!< Provider that produced this presence state message */
+ AST_STRING_FIELD(subtype); /*!< Subtype associated with this presence state message */
+ AST_STRING_FIELD(message); /*!< The message to convey */
+ );
+ enum ast_presence_state state; /*!< The state associated with this presence state message */
+};
+
int ast_presence_state_engine_init(void);
#endif
Modified: team/kmoore/stasis-bridging-channel_events/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/include/asterisk/stasis_channels.h?view=diff&rev=385914&r1=385913&r2=385914
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/include/asterisk/stasis_channels.h (original)
+++ team/kmoore/stasis-bridging-channel_events/include/asterisk/stasis_channels.h Tue Apr 16 15:34:12 2013
@@ -34,7 +34,7 @@
* \brief Structure representing a snapshot of channel state.
*
* While not enforced programmatically, this object is shared across multiple
- * threads, and should be threated as an immutable object.
+ * threads, and should be treated as an immutable object.
*/
struct ast_channel_snapshot {
AST_DECLARE_STRING_FIELDS(
Modified: team/kmoore/stasis-bridging-channel_events/include/asterisk/xmpp.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/include/asterisk/xmpp.h?view=diff&rev=385914&r1=385913&r2=385914
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/include/asterisk/xmpp.h (original)
+++ team/kmoore/stasis-bridging-channel_events/include/asterisk/xmpp.h Tue Apr 16 15:34:12 2013
@@ -47,6 +47,7 @@
#include "asterisk/linkedlists.h"
#include "asterisk/stringfields.h"
#include "asterisk/pbx.h"
+#include "asterisk/stasis.h"
/*
* As per RFC 3920 - section 3.1, the maximum length for a full Jabber ID
@@ -135,7 +136,7 @@
int timeout;
unsigned int reconnect:1; /*!< Reconnect this client */
struct stasis_subscription *mwi_sub; /*!< If distributing event information the MWI subscription */
- struct ast_event_sub *device_state_sub; /*!< If distributing event information the device state subscription */
+ struct stasis_subscription *device_state_sub; /*!< If distributing event information the device state subscription */
};
/*!
Modified: team/kmoore/stasis-bridging-channel_events/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/main/asterisk.c?view=diff&rev=385914&r1=385913&r2=385914
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/main/asterisk.c (original)
+++ team/kmoore/stasis-bridging-channel_events/main/asterisk.c Tue Apr 16 15:34:12 2013
@@ -4180,6 +4180,11 @@
aco_init();
+ if (devstate_init()) {
+ printf("Device state core initialization failed.\n%s", term_quit());
+ exit(1);
+ }
+
if (app_init()) {
printf("App core initialization failed.\n%s", term_quit());
exit(1);
Modified: team/kmoore/stasis-bridging-channel_events/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/main/bridging.c?view=diff&rev=385914&r1=385913&r2=385914
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/main/bridging.c (original)
+++ team/kmoore/stasis-bridging-channel_events/main/bridging.c Tue Apr 16 15:34:12 2013
@@ -463,8 +463,7 @@
case AST_BRIDGE_CHANNEL_STATE_END:
/* Do we need to dissolve the bridge because this channel hung up? */
if (ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_DISSOLVE_HANGUP)
- || (bridge_channel->features
- && bridge_channel->features->usable
+ || (bridge_channel->features->usable
&& ast_test_flag(&bridge_channel->features->feature_flags,
AST_BRIDGE_FLAG_DISSOLVE_HANGUP))) {
bridge_dissolve(bridge);
@@ -600,14 +599,9 @@
/*! \brief Internal function to handle DTMF from a channel */
static struct ast_frame *bridge_handle_dtmf(struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
{
- struct ast_bridge_features *features;
+ struct ast_bridge_features *features = bridge_channel->features;
struct ast_bridge_hook *hook;
char dtmf[2];
-
- features = bridge_channel->features;
- if (!features) {
- return frame;
- }
/* BUGBUG the feature hook matching needs to be done here. Any matching feature hook needs to be queued onto the bridge_channel. Also the feature hook digit timeout needs to be handled. */
/* BUGBUG the AMI atxfer action just sends DTMF end events to initiate DTMF atxfer and dial the extension. Another reason the DTMF hook matching needs rework. */
@@ -641,27 +635,23 @@
*/
static void bridge_handle_hangup(struct ast_bridge_channel *bridge_channel)
{
- struct ast_bridge_features *features;
-
- features = bridge_channel->features;
- if (features) {
- struct ast_bridge_hook *hook;
- struct ao2_iterator iter;
-
- /* Run any hangup hooks. */
- iter = ao2_iterator_init(features->hangup_hooks, 0);
- for (; (hook = ao2_iterator_next(&iter)); ao2_ref(hook, -1)) {
- int failed;
-
- failed = hook->callback(bridge_channel->bridge, bridge_channel, hook->hook_pvt);
- if (failed) {
- ast_debug(1, "Hangup hook %p is being removed from %p(%s)\n",
- hook, bridge_channel, ast_channel_name(bridge_channel->chan));
- ao2_unlink(features->hangup_hooks, hook);
- }
- }
- ao2_iterator_destroy(&iter);
- }
+ struct ast_bridge_features *features = bridge_channel->features;
+ struct ast_bridge_hook *hook;
+ struct ao2_iterator iter;
+
+ /* Run any hangup hooks. */
+ iter = ao2_iterator_init(features->hangup_hooks, 0);
+ for (; (hook = ao2_iterator_next(&iter)); ao2_ref(hook, -1)) {
+ int failed;
+
+ failed = hook->callback(bridge_channel->bridge, bridge_channel, hook->hook_pvt);
+ if (failed) {
+ ast_debug(1, "Hangup hook %p is being removed from %p(%s)\n",
+ hook, bridge_channel, ast_channel_name(bridge_channel->chan));
+ ao2_unlink(features->hangup_hooks, hook);
+ }
+ }
+ ao2_iterator_destroy(&iter);
/* Default hangup action. */
ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
@@ -669,14 +659,9 @@
static int bridge_channel_interval_ready(struct ast_bridge_channel *bridge_channel)
{
- struct ast_bridge_features *features;
+ struct ast_bridge_features *features = bridge_channel->features;
struct ast_bridge_hook *hook;
int ready;
-
- features = bridge_channel->features;
- if (!features || !features->interval_hooks) {
- return 0;
- }
ast_heap_wrlock(features->interval_hooks);
hook = ast_heap_peek(features->interval_hooks, 1);
@@ -932,7 +917,7 @@
{
struct ast_frame *frame;
- if (bridge_channel->features && bridge_channel->features->mute) {
+ if (bridge_channel->features->mute) {
frame = ast_read_noaudio(bridge_channel->chan);
} else {
frame = ast_read(bridge_channel->chan);
@@ -965,7 +950,7 @@
}
/* Fall through */
case AST_FRAME_DTMF_END:
- if (bridge_channel->features && !bridge_channel->features->dtmf_passthrough) {
+ if (!bridge_channel->features->dtmf_passthrough) {
ast_frfree(frame);
return;
}
@@ -1886,10 +1871,6 @@
char dtmf[MAXIMUM_DTMF_FEATURE_STRING] = "";
size_t dtmf_len = 0;
- if (!features) {
- return;
- }
-
/* The channel is now under our control and we don't really want any begin frames to do our DTMF matching so disable 'em at the core level */
ast_set_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_END_DTMF_ONLY);
@@ -1965,10 +1946,9 @@
static void bridge_channel_talking(struct ast_bridge_channel *bridge_channel, int talking)
{
- struct ast_bridge_features *features;
-
- features = bridge_channel->features;
- if (features && features->talker_cb) {
+ struct ast_bridge_features *features = bridge_channel->features;
+
+ if (features->talker_cb) {
features->talker_cb(bridge_channel, features->talker_pvt_data, talking);
}
}
@@ -2187,8 +2167,8 @@
{
struct ast_timer *interval_timer;
- if (bridge_channel->features
- && (interval_timer = bridge_channel->features->interval_timer)) {
+ interval_timer = bridge_channel->features->interval_timer;
+ if (interval_timer) {
if (ast_wait_for_input(ast_timer_fd(interval_timer), 0) == 1) {
ast_timer_ack(interval_timer, 1);
if (bridge_channel_interval_ready(bridge_channel)) {
@@ -2266,28 +2246,24 @@
*/
static void bridge_channel_handle_join(struct ast_bridge_channel *bridge_channel)
{
- struct ast_bridge_features *features;
-
- features = bridge_channel->features;
- if (features) {
- struct ast_bridge_hook *hook;
- struct ao2_iterator iter;
-
- /* Run any join hooks. */
- iter = ao2_iterator_init(features->join_hooks, AO2_ITERATOR_UNLINK);
- hook = ao2_iterator_next(&iter);
- if (hook) {
- bridge_channel_suspend(bridge_channel);
- ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
- do {
- hook->callback(bridge_channel->bridge, bridge_channel, hook->hook_pvt);
- ao2_ref(hook, -1);
- } while ((hook = ao2_iterator_next(&iter)));
- ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
- bridge_channel_unsuspend(bridge_channel);
- }
- ao2_iterator_destroy(&iter);
- }
+ struct ast_bridge_features *features = bridge_channel->features;
+ struct ast_bridge_hook *hook;
+ struct ao2_iterator iter;
+
+ /* Run any join hooks. */
+ iter = ao2_iterator_init(features->join_hooks, AO2_ITERATOR_UNLINK);
+ hook = ao2_iterator_next(&iter);
+ if (hook) {
+ bridge_channel_suspend(bridge_channel);
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
+ do {
+ hook->callback(bridge_channel->bridge, bridge_channel, hook->hook_pvt);
+ ao2_ref(hook, -1);
+ } while ((hook = ao2_iterator_next(&iter)));
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
+ bridge_channel_unsuspend(bridge_channel);
+ }
+ ao2_iterator_destroy(&iter);
}
/*!
@@ -2301,28 +2277,24 @@
*/
static void bridge_channel_handle_leave(struct ast_bridge_channel *bridge_channel)
{
- struct ast_bridge_features *features;
-
- features = bridge_channel->features;
- if (features) {
- struct ast_bridge_hook *hook;
- struct ao2_iterator iter;
-
- /* Run any leave hooks. */
- iter = ao2_iterator_init(features->leave_hooks, AO2_ITERATOR_UNLINK);
- hook = ao2_iterator_next(&iter);
- if (hook) {
- bridge_channel_suspend(bridge_channel);
- ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
- do {
- hook->callback(bridge_channel->bridge, bridge_channel, hook->hook_pvt);
- ao2_ref(hook, -1);
- } while ((hook = ao2_iterator_next(&iter)));
- ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
- bridge_channel_unsuspend(bridge_channel);
- }
- ao2_iterator_destroy(&iter);
- }
+ struct ast_bridge_features *features = bridge_channel->features;
+ struct ast_bridge_hook *hook;
+ struct ao2_iterator iter;
+
+ /* Run any leave hooks. */
+ iter = ao2_iterator_init(features->leave_hooks, AO2_ITERATOR_UNLINK);
+ hook = ao2_iterator_next(&iter);
+ if (hook) {
+ bridge_channel_suspend(bridge_channel);
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
+ do {
+ hook->callback(bridge_channel->bridge, bridge_channel, hook->hook_pvt);
+ ao2_ref(hook, -1);
+ } while ((hook = ao2_iterator_next(&iter)));
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
+ bridge_channel_unsuspend(bridge_channel);
+ }
+ ao2_iterator_destroy(&iter);
}
/*! \brief Join a channel to a bridge and handle anything the bridge may want us to do */
@@ -3448,7 +3420,7 @@
struct ast_bridge_hook *hook;
int res;
- if (!interval || !callback || !features || !features->interval_hooks) {
+ if (!features ||!interval || !callback) {
return -1;
}
@@ -3584,10 +3556,8 @@
*/
static void hooks_remove_on_pull_container(struct ao2_container *hooks)
{
- if (hooks) {
- ao2_callback(hooks, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE,
- hook_remove_on_pull_match, NULL);
- }
+ ao2_callback(hooks, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE,
+ hook_remove_on_pull_match, NULL);
}
/*!
@@ -3603,10 +3573,6 @@
{
struct ast_bridge_hook *hook;
int changed;
-
- if (!hooks) {
- return;
- }
ast_heap_wrlock(hooks);
do {
@@ -3636,10 +3602,6 @@
*/
static void bridge_features_remove_on_pull(struct ast_bridge_features *features)
{
- if (!features) {
- return;
- }
-
hooks_remove_on_pull_container(features->dtmf_hooks);
hooks_remove_on_pull_container(features->hangup_hooks);
hooks_remove_on_pull_container(features->join_hooks);
Modified: team/kmoore/stasis-bridging-channel_events/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/main/ccss.c?view=diff&rev=385914&r1=385913&r2=385914
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/main/ccss.c (original)
+++ team/kmoore/stasis-bridging-channel_events/main/ccss.c Tue Apr 16 15:34:12 2013
@@ -1209,7 +1209,7 @@
* recalled
*/
int fit_for_recall;
- struct ast_event_sub *sub;
+ struct stasis_subscription *sub;
AST_LIST_HEAD_NOLOCK(, generic_monitor_instance) list;
};
@@ -1260,19 +1260,20 @@
struct generic_monitor_instance_list *generic_list = obj;
struct generic_monitor_instance *generic_instance;
- generic_list->sub = ast_event_unsubscribe(generic_list->sub);
+ generic_list->sub = stasis_unsubscribe(generic_list->sub);
while ((generic_instance = AST_LIST_REMOVE_HEAD(&generic_list->list, next))) {
ast_free(generic_instance);
}
ast_free((char *)generic_list->device_name);
}
-static void generic_monitor_devstate_cb(const struct ast_event *event, void *userdata);
+static void generic_monitor_devstate_cb(void *userdata, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg);
static struct generic_monitor_instance_list *create_new_generic_list(struct ast_cc_monitor *monitor)
{
struct generic_monitor_instance_list *generic_list = ao2_t_alloc(sizeof(*generic_list),
generic_monitor_instance_list_destructor, "allocate generic monitor instance list");
char * device_name;
+ struct stasis_topic *device_specific_topic;
if (!generic_list) {
return NULL;
@@ -1285,11 +1286,12 @@
ast_tech_to_upper(device_name);
generic_list->device_name = device_name;
- if (!(generic_list->sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE,
- generic_monitor_devstate_cb, "Requesting CC", NULL,
- AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, monitor->interface->device_name,
- AST_EVENT_IE_STATE, AST_EVENT_IE_PLTYPE_EXISTS,
- AST_EVENT_IE_END))) {
+ device_specific_topic = ast_device_state_topic(device_name);
+ if (!device_specific_topic) {
+ return NULL;
+ }
+
+ if (!(generic_list->sub = stasis_subscribe(device_specific_topic, generic_monitor_devstate_cb, NULL))) {
cc_unref(generic_list, "Failed to subscribe to device state");
return NULL;
}
@@ -1298,35 +1300,25 @@
return generic_list;
}
-struct generic_tp_cb_data {
- const char *device_name;
- enum ast_device_state new_state;
-};
-
static int generic_monitor_devstate_tp_cb(void *data)
{
- struct generic_tp_cb_data *gtcd = data;
- enum ast_device_state new_state = gtcd->new_state;
- enum ast_device_state previous_state = gtcd->new_state;
- const char *monitor_name = gtcd->device_name;
+ RAII_VAR(struct ast_device_state_message *, dev_state, data, ao2_cleanup);
+ enum ast_device_state new_state = dev_state->state;
+ enum ast_device_state previous_state;
struct generic_monitor_instance_list *generic_list;
struct generic_monitor_instance *generic_instance;
- if (!(generic_list = find_generic_monitor_instance_list(monitor_name))) {
+ if (!(generic_list = find_generic_monitor_instance_list(dev_state->device))) {
/* The most likely cause for this is that we destroyed the monitor in the
* time between subscribing to its device state and the time this executes.
* Not really a big deal.
*/
- ast_free((char *) gtcd->device_name);
- ast_free(gtcd);
return 0;
}
if (generic_list->current_state == new_state) {
/* The device state hasn't actually changed, so we don't really care */
cc_unref(generic_list, "Kill reference of generic list in devstate taskprocessor callback");
- ast_free((char *) gtcd->device_name);
- ast_free(gtcd);
return 0;
}
@@ -1346,33 +1338,31 @@
}
}
[... 1936 lines stripped ...]
More information about the asterisk-commits
mailing list