summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorDavid M. Lee <dlee@digium.com>2013-03-22 14:06:46 +0000
committerDavid M. Lee <dlee@digium.com>2013-03-22 14:06:46 +0000
commitcf9324b25eb8a7dc5cef77f54e12758dfbcd6645 (patch)
tree67492a4753d03498d3b842939d1c4c9256efa013 /include/asterisk
parent401f7c188038a327ed40a7bff30a28f03b69f8a1 (diff)
Move more channel events to Stasis; move res_json.c to main/json.c.
This patch started out simply as fixing the bouncing tests introduced in r382685, but required some other changes to give it a decent implementation. To fix the bouncing tests, the UserEvent and Newexten AMI events needed to be refactored to dispatch via Stasis. Dispatching directly to AMI resulted in those events sometimes getting ahead of the associated Newchannel events, which would understandably confuse anyone. I found that instead of creating a zillion different message types and structures associated with them, it would be preferable to define a message type that has a channel snapshot and a blob of structured data with a small bit of additional information. The JSON object model provides a very nice way of representing structured data, so I went with that. * Move JSON support from res_json.c to main/json.c * Made libjansson-dev a required dependency * Added an ast_channel_blob message type, which has a channel snapshot and JSON blob of data. * Changed UserEvent and Newexten events so that they are dispatched via ast_channel_blob messages on the channel's topic. * Got rid of the ast_channel_varset message; used ast_channel_blob instead. * Extracted the manager functions converting Stasis channel events to AMI events into manager_channel.c. (issue ASTERISK-21096) Review: https://reviewboard.asterisk.org/r/2381/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383579 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/autoconfig.h.in5
-rw-r--r--include/asterisk/channel.h48
-rw-r--r--include/asterisk/manager.h8
3 files changed, 51 insertions, 10 deletions
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index a12f30603..f7294b36e 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -1229,6 +1229,11 @@
/* Define to 1 if running on Darwin. */
#undef _DARWIN_UNLIMITED_SELECT
+/* Enable large inode numbers on Mac OS X 10.5. */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif
+
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index eee0828be..8fef86d2c 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -151,6 +151,7 @@ extern "C" {
#include "asterisk/ccss.h"
#include "asterisk/framehook.h"
#include "asterisk/stasis.h"
+#include "asterisk/json.h"
#define DATASTORE_INHERIT_FOREVER INT_MAX
@@ -4187,24 +4188,51 @@ struct stasis_caching_topic *ast_channel_topic_all_cached(void);
/*!
* \since 12
- * \brief Variable set event.
+ * \brief Blob of data associated with a channel.
+ *
+ * The \c blob is actually a JSON object of structured data. It has a "type" field
+ * which contains the type string describing this blob.
*/
-struct ast_channel_varset {
- /*! Channel variable was set on (or NULL for global variable) */
+struct ast_channel_blob {
+ /*! Channel blob is associated with (or NULL for global/all channels) */
struct ast_channel_snapshot *snapshot;
- /*! Variable name */
- char *variable;
- /*! New value */
- char *value;
+ /*! JSON blob of data */
+ struct ast_json *blob;
};
/*!
* \since 12
- * \brief Message type for \ref ast_channel_varset messages.
+ * \brief Message type for \ref ast_channel_blob messages.
+ *
+ * \retval Message type for \ref ast_channel_blob messages.
+ */
+struct stasis_message_type *ast_channel_blob(void);
+
+/*!
+ * \since 12
+ * \brief Extracts the type field from a \ref ast_channel_blob.
+ * Returned \c char* is still owned by \a obj
+ * \param obj Channel blob object.
+ * \return Type field value from the blob.
+ * \return \c NULL on error.
+ */
+const char *ast_channel_blob_type(struct ast_channel_blob *obj);
+
+/*!
+ * \since 12
+ * \brief Creates a \ref ast_channel_blob message.
+ *
+ * The \a blob JSON object requires a \c "type" field describing the blob. It
+ * should also be treated as immutable and not modified after it is put into the
+ * message.
*
- * \retval Message type for \ref ast_channel_varset messages.
+ * \param chan Channel blob is associated with, or NULL for global/all channels.
+ * \param blob JSON object representing the data.
+ * \return \ref ast_channel_blob message.
+ * \return \c NULL on error
*/
-struct stasis_message_type *ast_channel_varset(void);
+struct stasis_message *ast_channel_blob_create(struct ast_channel *chan,
+ struct ast_json *blob);
/*!
* \since 12
diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h
index 2e58a119a..af25edbf9 100644
--- a/include/asterisk/manager.h
+++ b/include/asterisk/manager.h
@@ -316,4 +316,12 @@ int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastor
*/
struct ast_datastore *astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid);
+/*!
+ * \brief Initialize support for AMI channel events.
+ * \return 0 on success.
+ * \return non-zero on error.
+ * \since 12
+ */
+int manager_channels_init(void);
+
#endif /* _ASTERISK_MANAGER_H */