[asterisk-commits] kharwell: branch kharwell/stasis-http-conf r384262 - in /team/kharwell/stasis...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 28 10:46:28 CDT 2013
Author: kharwell
Date: Thu Mar 28 10:46:24 2013
New Revision: 384262
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384262
Log:
reverting previous merge due to pulling from wrong source
Added:
team/kharwell/stasis-http-conf/res/res_json.c
- copied unchanged from r384152, team/kharwell/stasis-http-conf/res/res_json.c
team/kharwell/stasis-http-conf/res/res_json.exports.in
- copied unchanged from r384152, team/kharwell/stasis-http-conf/res/res_json.exports.in
Removed:
team/kharwell/stasis-http-conf/main/json.c
team/kharwell/stasis-http-conf/main/manager_channels.c
Modified:
team/kharwell/stasis-http-conf/ (props changed)
team/kharwell/stasis-http-conf/CHANGES
team/kharwell/stasis-http-conf/apps/app_mixmonitor.c
team/kharwell/stasis-http-conf/apps/app_stasis.c
team/kharwell/stasis-http-conf/apps/app_userevent.c
team/kharwell/stasis-http-conf/channels/chan_skinny.c
team/kharwell/stasis-http-conf/codecs/Makefile
team/kharwell/stasis-http-conf/configure
team/kharwell/stasis-http-conf/configure.ac
team/kharwell/stasis-http-conf/contrib/scripts/install_prereq
team/kharwell/stasis-http-conf/funcs/func_curl.c
team/kharwell/stasis-http-conf/include/asterisk/astobj2.h
team/kharwell/stasis-http-conf/include/asterisk/autoconfig.h.in
team/kharwell/stasis-http-conf/include/asterisk/channel.h
team/kharwell/stasis-http-conf/include/asterisk/json.h
team/kharwell/stasis-http-conf/include/asterisk/manager.h
team/kharwell/stasis-http-conf/include/asterisk/sorcery.h
team/kharwell/stasis-http-conf/include/asterisk/stasis.h
team/kharwell/stasis-http-conf/main/Makefile
team/kharwell/stasis-http-conf/main/asterisk.c
team/kharwell/stasis-http-conf/main/channel.c
team/kharwell/stasis-http-conf/main/channel_internal_api.c
team/kharwell/stasis-http-conf/main/manager.c
team/kharwell/stasis-http-conf/main/pbx.c
team/kharwell/stasis-http-conf/main/sorcery.c
team/kharwell/stasis-http-conf/main/stasis.c
team/kharwell/stasis-http-conf/main/stasis_message_router.c
team/kharwell/stasis-http-conf/pbx/pbx_realtime.c
team/kharwell/stasis-http-conf/res/res_config_curl.c
team/kharwell/stasis-http-conf/res/res_sorcery_memory.c
team/kharwell/stasis-http-conf/res/res_stasis_websocket.c
team/kharwell/stasis-http-conf/tests/test_json.c
team/kharwell/stasis-http-conf/tests/test_sorcery.c
Propchange: team/kharwell/stasis-http-conf/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.
Propchange: team/kharwell/stasis-http-conf/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Mar 28 10:46:24 2013
@@ -1,1 +1,1 @@
-/team/dlee/stasis-app:1-384117 /trunk:1-383057
+/team/dlee/stasis-app:1-383317 /trunk:1-383057
Modified: team/kharwell/stasis-http-conf/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/CHANGES?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/CHANGES (original)
+++ team/kharwell/stasis-http-conf/CHANGES Thu Mar 28 10:46:24 2013
@@ -40,18 +40,6 @@
stopped, restarted, reversed, or skipped forward. When initiated by other
mechanisms (such as the Playback application), the audio can be stopped,
reversed, or skipped forward.
-
- * Channel related events now contain a snapshot of channel state, adding new
- fields to many of these events.
-
- * The AMI event 'Newexten' field 'Extension' is deprecated, and may be removed
- in a future release. Please use the common 'Exten' field instead.
-
- * The AMI event 'UserEvent' from app_userevent now contains the channel state
- fields. The channel state fields will come before the body fields.
-
- * The deprecated use of | (pipe) as a separator in the channelvars setting in
- manager.conf has been removed.
Channel Drivers
------------------
Modified: team/kharwell/stasis-http-conf/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/apps/app_mixmonitor.c?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/apps/app_mixmonitor.c (original)
+++ team/kharwell/stasis-http-conf/apps/app_mixmonitor.c Thu Mar 28 10:46:24 2013
@@ -1042,7 +1042,7 @@
return 0;
}
-static int stop_mixmonitor_full(struct ast_channel *chan, const char *data)
+static int stop_mixmonitor_exec(struct ast_channel *chan, const char *data)
{
struct ast_datastore *datastore = NULL;
char *parse = "";
@@ -1093,12 +1093,6 @@
}
ast_channel_unlock(chan);
- return 0;
-}
-
-static int stop_mixmonitor_exec(struct ast_channel *chan, const char *data)
-{
- stop_mixmonitor_full(chan, data);
return 0;
}
@@ -1321,7 +1315,7 @@
return AMI_SUCCESS;
}
- res = stop_mixmonitor_full(c, mixmonitor_id);
+ res = stop_mixmonitor_exec(c, mixmonitor_id);
if (res) {
astman_send_error(s, m, "Could not stop monitoring channel");
Modified: team/kharwell/stasis-http-conf/apps/app_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/apps/app_stasis.c?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/apps/app_stasis.c (original)
+++ team/kharwell/stasis-http-conf/apps/app_stasis.c Thu Mar 28 10:46:24 2013
@@ -24,6 +24,7 @@
*/
/*** MODULEINFO
+ <depend>res_json</depend>
<support_level>core</support_level>
***/
@@ -35,6 +36,7 @@
#include "asterisk/app_stasis.h"
#include "asterisk/astobj2.h"
#include "asterisk/channel.h"
+#include "asterisk/lock.h"
#include "asterisk/module.h"
#include "asterisk/stasis.h"
#include "asterisk/strings.h"
@@ -47,7 +49,8 @@
<para>Name of the application to invoke.</para>
</parameter>
<parameter name="args">
- <para>Optional arguments for the application invocation.</para>
+ <para>Optional arguments for the application
+ invocation.</para>
</parameter>
</syntax>
<description>
@@ -58,6 +61,9 @@
</application>
***/
+/*! Time to wait for a frame in the application */
+#define MAX_WAIT_MS 200
+
/*! \brief Maximum number of arguments for the Stasis dialplan application */
#define MAX_ARGS 128
@@ -97,7 +103,7 @@
return __app_controls;
}
-struct app {
+struct stasis_app {
/*! Callback function for this application. */
stasis_app_cb handler;
/*! Opaque data to hand to callback function. */
@@ -106,10 +112,11 @@
char name[];
};
-/*! Constructor for \ref app. */
-static struct app *app_create(const char *name, stasis_app_cb handler, void *data)
-{
- struct app *app;
+/*! Constructor for \ref stasis_app. */
+static struct stasis_app *app_create(const char *name, stasis_app_cb handler,
+ void *data)
+{
+ struct stasis_app *app;
size_t size;
ast_assert(name != NULL);
@@ -132,7 +139,7 @@
/*! AO2 hash function for \ref stasis_app */
static int app_hash(const void *obj, const int flags)
{
- const struct app *app = obj;
+ const struct stasis_app *app = obj;
const char *name = flags & OBJ_KEY ? obj : app->name;
return ast_str_hash(name);
@@ -141,8 +148,8 @@
/*! AO2 comparison function for \ref stasis_app */
static int app_compare(void *lhs, void *rhs, int flags)
{
- const struct app *lhs_app = lhs;
- const struct app *rhs_app = rhs;
+ const struct stasis_app *lhs_app = lhs;
+ const struct stasis_app *rhs_app = rhs;
const char *rhs_name = flags & OBJ_KEY ? rhs : rhs_app->name;
if (strcmp(lhs_app->name, rhs_name) == 0) {
@@ -157,18 +164,78 @@
* \param app App to send the message to.
* \param message Message to send.
*/
-static void app_send(struct app *app, struct ast_json *message)
+static void app_send(struct stasis_app *app, struct ast_json *message)
{
app->handler(app->data, app->name, message);
}
+typedef void* (*stasis_app_command_cb)(struct stasis_app_control *control,
+ struct ast_channel *chan,
+ void *data);
+
+struct stasis_app_command {
+ ast_mutex_t lock;
+ ast_cond_t condition;
+ stasis_app_command_cb callback;
+ void *data;
+ void *retval;
+ int is_done:1;
+};
+
+static void command_dtor(void *obj)
+{
+ struct stasis_app_command *command = obj;
+ ast_mutex_destroy(&command->lock);
+ ast_cond_destroy(&command->condition);
+}
+
+static struct stasis_app_command *command_create(stasis_app_command_cb callback,
+ void *data)
+{
+ RAII_VAR(struct stasis_app_command *, command, NULL, ao2_cleanup);
+
+ command = ao2_alloc(sizeof(*command), command_dtor);
+ if (!command) {
+ return NULL;
+ }
+
+ ast_mutex_init(&command->lock);
+ ast_cond_init(&command->condition, 0);
+ command->callback = callback;
+ command->data = data;
+
+ ao2_ref(command, +1);
+ return command;
+}
+
+static void command_complete(struct stasis_app_command *command, void *retval)
+{
+ SCOPED_MUTEX(lock, &command->lock);
+
+ command->is_done = 1;
+ command->retval = retval;
+ ast_cond_signal(&command->condition);
+}
+
+static void *wait_for_command(struct stasis_app_command *command)
+{
+ SCOPED_MUTEX(lock, &command->lock);
+ while (!command->is_done) {
+ ast_cond_wait(&command->condition, &command->lock);
+ }
+
+ return command->retval;
+}
+
struct stasis_app_control {
+ /*! Queue of commands to dispatch on the channel */
+ struct ao2_container *command_queue;
/*!
* When set, /c app_stasis should exit and continue in the dialplan.
*/
int continue_to_dialplan:1;
/*! Uniqueid of the associated channel */
- char channel_uniqueid[];
+ char channel_id[];
};
static struct stasis_app_control *control_create(const char *uniqueid)
@@ -182,20 +249,65 @@
return NULL;
}
- strncpy(control->channel_uniqueid, uniqueid, size - sizeof(*control));
+ control->command_queue = ao2_container_alloc_list(0, 0, NULL, NULL);
+
+ strncpy(control->channel_id, uniqueid, size - sizeof(*control));
return control;
}
-struct stasis_app_control *stasis_app_control_find_by_channel(const struct ast_channel *chan)
-{
- RAII_VAR(struct ao2_container *, controls, NULL, ao2_cleanup);
+static void *exec_command(struct stasis_app_control *control,
+ struct stasis_app_command *command)
+{
+ ao2_lock(control);
+ ao2_ref(command, +1);
+ ao2_link(control->command_queue, command);
+ ao2_unlock(control);
+
+ return wait_for_command(command);
+}
+
+/*! AO2 hash function for \ref stasis_app_control */
+static int control_hash(const void *obj, const int flags)
+{
+ const struct stasis_app_control *control = obj;
+ const char *id = flags & OBJ_KEY ? obj : control->channel_id;
+
+ return ast_str_hash(id);
+}
+
+/*! AO2 comparison function for \ref stasis_app_control */
+static int control_compare(void *lhs, void *rhs, int flags)
+{
+ const struct stasis_app_control *lhs_control = lhs;
+ const struct stasis_app_control *rhs_control = rhs;
+ const char *rhs_name =
+ flags & OBJ_KEY ? rhs : rhs_control->channel_id;
+
+ if (strcmp(lhs_control->channel_id, rhs_name) == 0) {
+ return CMP_MATCH | CMP_STOP;
+ } else {
+ return 0;
+ }
+}
+
+struct stasis_app_control *stasis_app_control_find_by_channel(
+ const struct ast_channel *chan)
+{
if (chan == NULL) {
return NULL;
}
+ return stasis_app_control_find_by_channel_id(
+ ast_channel_uniqueid(chan));
+}
+
+struct stasis_app_control *stasis_app_control_find_by_channel_id(
+ const char *channel_id)
+{
+ RAII_VAR(struct ao2_container *, controls, NULL, ao2_cleanup);
controls = app_controls();
- return ao2_find(controls, ast_channel_uniqueid(chan), OBJ_KEY);
+ return ao2_find(controls, channel_id, OBJ_KEY);
}
/*!
@@ -223,9 +335,38 @@
control->continue_to_dialplan = 1;
}
-struct ast_json *stasis_app_event_create(const char *event_name,
- const struct ast_channel_snapshot *channel_info,
- const struct ast_json *extra_info) {
+static int OK = 0;
+static int FAIL = -1;
+
+static void *__app_control_answer(struct stasis_app_control *control,
+ struct ast_channel *chan, void *data)
+{
+ ast_debug(3, "%s: Answering", control->channel_id);
+ return __ast_answer(chan, 0, 1) == 0 ? &OK : &FAIL;
+}
+
+int stasis_app_control_answer(struct stasis_app_control *control)
+{
+ RAII_VAR(struct stasis_app_command *, command, NULL, ao2_cleanup);
+ int *retval;
+
+ ast_debug(3, "%s: Sending answer command\n", control->channel_id);
+
+ command = command_create(__app_control_answer, NULL);
+ retval = exec_command(control, command);
+
+ if (*retval != 0) {
+ ast_log(LOG_WARNING, "Failed to answer channel");
+ }
+
+ return *retval;
+}
+
+struct ast_json *stasis_app_event_create(
+ const char *event_name,
+ const struct ast_channel_snapshot *channel_info,
+ const struct ast_json *extra_info)
+{
RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
int r;
@@ -241,15 +382,21 @@
return NULL;
}
- r = ast_json_object_set(message, "event", ast_json_string_create(event_name));
+ r = ast_json_object_set(message,
+ "event", ast_json_string_create(event_name));
if (r != 0) {
ast_log(LOG_ERROR, "Failed to add event_name to message\n");
return NULL;
}
if (channel_info) {
- if (ast_json_object_set(message, "channel_info", ast_channel_snapshot_to_json(channel_info)) != 0) {
- ast_log(LOG_ERROR, "Failed to add channel info to event\n");
+ r = ast_json_object_set(
+ message,
+ "channel_info",
+ ast_channel_snapshot_to_json(channel_info));
+ if (r != 0) {
+ ast_log(LOG_ERROR,
+ "Failed to add channel info to event\n");
return NULL;
}
}
@@ -257,7 +404,8 @@
return ast_json_ref(message);
}
-static int send_start_msg(struct app *app, struct ast_channel *chan, int argc, char *argv[])
+static int send_start_msg(struct stasis_app *app, struct ast_channel *chan,
+ int argc, char *argv[])
{
RAII_VAR(struct ast_json *, msg_info, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, msg, NULL, ast_json_unref);
@@ -270,7 +418,8 @@
msg_info = ast_json_pack("{s: []}", "args");
if (!msg_info) {
- ast_log(LOG_ERROR, "Couldn't create message for %s\n", app->name);
+ ast_log(LOG_ERROR,
+ "Couldn't create message for %s\n", app->name);
return -1;
}
@@ -278,8 +427,11 @@
json_args = ast_json_object_get(msg_info, "args");
ast_assert(json_args != NULL);
for (i = 0; i < argc; ++i) {
- if (ast_json_array_append(json_args, ast_json_string_create(argv[i])) != 0) {
- ast_log(LOG_ERROR, "Error appending arg to start message\n");
+ int r = ast_json_array_append(json_args,
+ ast_json_string_create(argv[i]));
+ if (r != 0) {
+ ast_log(LOG_ERROR,
+ "Error appending arg to start message\n");
return -1;
}
}
@@ -299,7 +451,7 @@
return 0;
}
-static int send_end_msg(struct app *app, struct ast_channel *chan)
+static int send_end_msg(struct stasis_app *app, struct ast_channel *chan)
{
RAII_VAR(struct ast_json *, msg, NULL, ast_json_unref);
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
@@ -312,28 +464,25 @@
return -1;
}
msg = stasis_app_event_create("stasis-end", snapshot, NULL);
- if (!msg) {
- return -1;
- }
app_send(app, msg);
return 0;
}
-static void sub_handler(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message)
-{
- struct app *app = data;
- if (ast_channel_snapshot() == stasis_message_type(message)) {
- RAII_VAR(struct ast_json *, msg, NULL, ast_json_unref);
- struct ast_channel_snapshot *snapshot = stasis_message_data(message);
-
- msg = stasis_app_event_create("channel-state-change", snapshot, NULL);
- if (!msg) {
- return;
- }
- app_send(app, msg);
- }
- if (stasis_subscription_final_message(sub, message)) {
+static void sub_handler(void *data, struct stasis_subscription *sub,
+ struct stasis_topic *topic, struct stasis_message *msg)
+{
+ struct stasis_app *app = data;
+ if (ast_channel_snapshot() == stasis_message_type(msg)) {
+ RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ struct ast_channel_snapshot *snapshot =
+ stasis_message_data(msg);
+
+ json = stasis_app_event_create("channel-state-change", snapshot,
+ NULL);
+ app_send(app, json);
+ }
+ if (stasis_subscription_final_message(sub, msg)) {
ao2_cleanup(data);
}
}
@@ -351,17 +500,39 @@
}
controls = app_controls();
- ao2_unlink_flags(controls, control, OBJ_POINTER | OBJ_UNLINK | OBJ_NODATA);
+ ao2_unlink_flags(controls, control,
+ OBJ_POINTER | OBJ_UNLINK | OBJ_NODATA);
ao2_cleanup(control);
}
+
+static void dispatch_commands(struct stasis_app_control *control,
+ struct ast_channel *chan)
+{
+ struct ao2_iterator i;
+ void *obj;
+
+ SCOPED_AO2LOCK(lock, control);
+
+ i = ao2_iterator_init(control->command_queue, AO2_ITERATOR_UNLINK);
+
+ while ((obj = ao2_iterator_next(&i))) {
+ RAII_VAR(struct stasis_app_command *, command, obj, ao2_cleanup);
+ void *retval = command->callback(control, chan, command->data);
+ command_complete(command, retval);
+ }
+
+ ao2_iterator_destroy(&i);
+}
+
/*! /brief Stasis dialplan application callback */
static int app_stasis_exec(struct ast_channel *chan, const char *data)
{
RAII_VAR(struct ao2_container *, apps, apps_registry(), ao2_cleanup);
- RAII_VAR(struct app *, app, NULL, ao2_cleanup);
+ RAII_VAR(struct stasis_app *, app, NULL, ao2_cleanup);
RAII_VAR(struct stasis_app_control *, control, NULL, control_unlink);
- RAII_VAR(struct stasis_subscription *, subscription, NULL, stasis_unsubscribe);
+ RAII_VAR(struct stasis_subscription *, subscription, NULL,
+ stasis_unsubscribe);
int res = 0;
char *parse = NULL;
int hungup = 0;
@@ -385,7 +556,8 @@
app = ao2_find(apps, args.app_name, OBJ_KEY);
if (!app) {
- ast_log(LOG_ERROR, "Stasis app '%s' not registered\n", args.app_name);
+ ast_log(LOG_ERROR,
+ "Stasis app '%s' not registered\n", args.app_name);
return -1;
}
@@ -401,30 +573,63 @@
ao2_link(controls, control);
}
- subscription = stasis_subscribe(ast_channel_topic(chan), sub_handler, app);
+ subscription =
+ stasis_subscribe(ast_channel_topic(chan), sub_handler, app);
if (subscription == NULL) {
- ast_log(LOG_ERROR, "Error subscribing app %s to channel %s\n", args.app_name, ast_channel_name(chan));
+ ast_log(LOG_ERROR, "Error subscribing app %s to channel %s\n",
+ args.app_name, ast_channel_name(chan));
return -1;
}
ao2_ref(app, +1); /* subscription now has a reference */
res = send_start_msg(app, chan, args.argc - 1, args.app_argv);
if (res != 0) {
- ast_log(LOG_ERROR, "Error sending start message to %s\n", args.app_name);
+ ast_log(LOG_ERROR,
+ "Error sending start message to %s\n", args.app_name);
return res;
}
- while (!hungup && !control_continue_test_and_reset(control) && ast_waitfor(chan, -1) > -1) {
- RAII_VAR(struct ast_frame *, f, ast_read(chan), ast_frame_dtor);
+ while (1) {
+ RAII_VAR(struct ast_frame *, f, NULL, ast_frame_dtor);
+ int r;
+
+ if (hungup) {
+ ast_debug(3, "%s: Hangup\n",
+ ast_channel_uniqueid(chan));
+ break;
+ }
+
+ if (control_continue_test_and_reset(control)) {
+ ast_debug(3, "%s: Continue\n",
+ ast_channel_uniqueid(chan));
+ break;
+ }
+
+ r = ast_waitfor(chan, MAX_WAIT_MS);
+
+ if (r < 0) {
+ ast_debug(3, "%s: Poll error\n",
+ ast_channel_uniqueid(chan));
+ break;
+ }
+
+ dispatch_commands(control, chan);
+
+ if (r == 0) {
+ /* Timeout */
+ continue;
+ }
+
+ f = ast_read(chan);
if (!f) {
- ast_debug(3, "%s: No more frames. Must be done, I guess.\n", ast_channel_uniqueid(chan));
+ ast_debug(3, "%s: No more frames. Must be done, I guess.\n",
+ ast_channel_uniqueid(chan));
break;
}
switch (f->frametype) {
case AST_FRAME_CONTROL:
if (f->subclass.integer == AST_CONTROL_HANGUP) {
- ast_debug(3, "%s: Received hangup\n", ast_channel_uniqueid(chan));
hungup = 1;
}
break;
@@ -436,7 +641,8 @@
res = send_end_msg(app, chan);
if (res != 0) {
- ast_log(LOG_ERROR, "Error sending end message to %s\n", args.app_name);
+ ast_log(LOG_ERROR,
+ "Error sending end message to %s\n", args.app_name);
return res;
}
@@ -446,15 +652,16 @@
int stasis_app_send(const char *app_name, struct ast_json *message)
{
RAII_VAR(struct ao2_container *, apps, apps_registry(), ao2_cleanup);
- RAII_VAR(struct app *, app, NULL, ao2_cleanup);
+ RAII_VAR(struct stasis_app *, app, NULL, ao2_cleanup);
app = ao2_find(apps, app_name, OBJ_KEY);
if (!app) {
- /* XXX We can do a better job handling late binding, queueing up the call for a few seconds
- * to wait for the app to register.
+ /* XXX We can do a better job handling late binding, queueing up
+ * the call for a few seconds to wait for the app to register.
*/
- ast_log(LOG_WARNING, "Stasis app '%s' not registered\n", app_name);
+ ast_log(LOG_WARNING,
+ "Stasis app '%s' not registered\n", app_name);
return -1;
}
@@ -465,7 +672,7 @@
int stasis_app_register(const char *app_name, stasis_app_cb handler, void *data)
{
RAII_VAR(struct ao2_container *, apps, apps_registry(), ao2_cleanup);
- RAII_VAR(struct app *, app, NULL, ao2_cleanup);
+ RAII_VAR(struct stasis_app *, app, NULL, ao2_cleanup);
SCOPED_LOCK(apps_lock, apps, ao2_lock, ao2_unlock);
@@ -507,12 +714,14 @@
{
int r = 0;
- __apps_registry = ao2_container_alloc(APPS_NUM_BUCKETS, app_hash, app_compare);
+ __apps_registry =
+ ao2_container_alloc(APPS_NUM_BUCKETS, app_hash, app_compare);
if (__apps_registry == NULL) {
return AST_MODULE_LOAD_FAILURE;
}
- __app_controls = ao2_container_alloc(CONTROLS_NUM_BUCKETS, app_hash, app_compare);
+ __app_controls = ao2_container_alloc(CONTROLS_NUM_BUCKETS,
+ control_hash, control_compare);
if (__app_controls == NULL) {
return AST_MODULE_LOAD_FAILURE;
}
@@ -535,6 +744,8 @@
return r;
}
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Stasis dialplan application",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS,
+ "Stasis dialplan application",
.load = load_module,
- .unload = unload_module);
+ .unload = unload_module,
+ .nonoptreq = "res_json");
Modified: team/kharwell/stasis-http-conf/apps/app_userevent.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/apps/app_userevent.c?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/apps/app_userevent.c (original)
+++ team/kharwell/stasis-http-conf/apps/app_userevent.c Thu Mar 28 10:46:24 2013
@@ -33,7 +33,6 @@
#include "asterisk/module.h"
#include "asterisk/manager.h"
#include "asterisk/app.h"
-#include "asterisk/json.h"
/*** DOCUMENTATION
<application name="UserEvent" language="en_US">
@@ -69,12 +68,11 @@
AST_APP_ARG(eventname);
AST_APP_ARG(extra)[100];
);
- RAII_VAR(struct ast_str *, body, ast_str_create(16), ast_free);
- RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
- RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+ struct ast_str *body = ast_str_create(16);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "UserEvent requires an argument (eventname,optional event body)\n");
+ ast_free(body);
return -1;
}
@@ -91,21 +89,24 @@
ast_str_append(&body, 0, "%s\r\n", args.extra[x]);
}
- blob = ast_json_pack("{s: s, s: s, s: s}",
- "type", "userevent",
- "eventname", args.eventname,
- "body", ast_str_buffer(body));
- if (!blob) {
- ast_log(LOG_WARNING, "Unable to create message buffer\n");
- return -1;
- }
+ /*** DOCUMENTATION
+ <managerEventInstance>
+ <synopsis>A user defined event raised from the dialplan.</synopsis>
+ <parameter name="UserEvent">
+ <para>The event name, as specified in the dialplan.</para>
+ </parameter>
+ <see-also>
+ <ref type="application">UserEvent</ref>
+ </see-also>
+ </managerEventInstance>
+ ***/
+ manager_event(EVENT_FLAG_USER, "UserEvent",
+ "UserEvent: %s\r\n"
+ "Uniqueid: %s\r\n"
+ "%s",
+ args.eventname, ast_channel_uniqueid(chan), ast_str_buffer(body));
- msg = ast_channel_blob_create(chan, blob);
- if (!msg) {
- return -1;
- }
-
- stasis_publish(ast_channel_topic(chan), msg);
+ ast_free(body);
return 0;
}
Modified: team/kharwell/stasis-http-conf/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/channels/chan_skinny.c?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/channels/chan_skinny.c (original)
+++ team/kharwell/stasis-http-conf/channels/chan_skinny.c Thu Mar 28 10:46:24 2013
@@ -8571,9 +8571,6 @@
We do not want to free the line here, that
will happen below. */
while ((l = AST_LIST_REMOVE_HEAD(&d->lines, list))) {
- if (l->mwi_event_sub) {
- l->mwi_event_sub = stasis_unsubscribe(l->mwi_event_sub);
- }
}
/* Delete all speeddials for this device */
while ((sd = AST_LIST_REMOVE_HEAD(&d->speeddials, list))) {
Modified: team/kharwell/stasis-http-conf/codecs/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/codecs/Makefile?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/codecs/Makefile (original)
+++ team/kharwell/stasis-http-conf/codecs/Makefile Thu Mar 28 10:46:24 2013
@@ -53,8 +53,8 @@
for dir in $(SUB_DIRS); do \
$(MAKE) -C $$dir clean; \
done
- rm -f g722/*.[oai]
- rm -f speex/*.[oai]
+ rm -f g722/*.[oa]
+ rm -f speex/*.[oa]
.PHONY: $(SUB_DIRS)
Modified: team/kharwell/stasis-http-conf/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/configure.ac?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/configure.ac (original)
+++ team/kharwell/stasis-http-conf/configure.ac Thu Mar 28 10:46:24 2013
@@ -491,13 +491,12 @@
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/event.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h termios.h unistd.h utime.h arpa/nameser.h sys/io.h])
-# Any one of these packages support a mandatory requirement, so we want to check on them as early as possible.
+# Any one of these 5 packages support a mandatory requirement, so we want to check on them as early as possible.
AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
AST_EXT_LIB_CHECK([UUID], [uuid], [uuid_generate_random], [uuid/uuid.h], [-luuid])
-AST_EXT_LIB_CHECK([JANSSON], [jansson], [json_dumps], [jansson.h])
EDITLINE_LIB=""
if test "x$TERMCAP_LIB" != "x" ; then
@@ -515,10 +514,6 @@
if test "x$UUID_LIB" == "x"; then
AC_MSG_ERROR([*** uuid support not found (this typically means the uuid development package is missing)])
-fi
-
-if test "x$JANSSON_LIB" == "x"; then
- AC_MSG_ERROR([*** JSON support not found (this typically means the libjansson development package is missing)])
fi
# Another mandatory item (unless it's explicitly disabled)
@@ -1874,6 +1869,8 @@
AST_EXT_LIB_CHECK([JACK], [jack], [jack_activate], [jack/jack.h])
+AST_EXT_LIB_CHECK([JANSSON], [jansson], [json_dumps], [jansson.h])
+
# BSD (and OS X) equivalent of inotify
AST_EXT_LIB_CHECK([KQUEUE], [c], [kqueue], [sys/event.h])
Modified: team/kharwell/stasis-http-conf/contrib/scripts/install_prereq
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/contrib/scripts/install_prereq?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/contrib/scripts/install_prereq (original)
+++ team/kharwell/stasis-http-conf/contrib/scripts/install_prereq Thu Mar 28 10:46:24 2013
@@ -32,7 +32,6 @@
PACKAGES_RH="$PACKAGES_RH spandsp-devel freetds-devel net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libtool-ltdl-devel lua-devel"
PACKAGES_RH="$PACKAGES_RH libsqlite3x-devel radiusclient-ng-devel portaudio-devel postgresql-devel libresample-devel neon-devel libical-devel"
PACKAGES_RH="$PACKAGES_RH openldap-devel gmime22-devel sqlite2-devel mysql-devel bluez-libs-devel jack-audio-connection-kit-devel gsm-devel libedit-devel libuuid-devel"
-PACKAGES_RH="$PACKAGES_RH jansson-devel"
PACKAGES_OBSD="popt gmake wget libxml libogg libvorbis curl iksemel spandsp speex iodbc freetds-0.63p1-msdblib mysql-client gmime sqlite sqlite3 jack"
@@ -80,16 +79,20 @@
}
handle_debian() {
+ # echo "# Distribution is Debian or compatible"
extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
$testcmd aptitude install -y $extra_packs
}
handle_rh() {
+ # echo "# Distribution is RedHat-based or compatible"
extra_packs=`check_installed_rpms $PACKAGES_RH`
+ # FIXME: is there yum with RHEL 4?
$testcmd yum install -y $extra_packs
}
handle_obsd() {
+ # echo "# Distribution is OpenBSD or compatible"
extra_packs=`check_installed_pkgs $PACKAGES_OBSD`
$testcmd pkg_add $extra_packs
}
Modified: team/kharwell/stasis-http-conf/funcs/func_curl.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/funcs/func_curl.c?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/funcs/func_curl.c (original)
+++ team/kharwell/stasis-http-conf/funcs/func_curl.c Thu Mar 28 10:46:24 2013
@@ -581,7 +581,6 @@
struct ast_datastore *store = NULL;
int hashcompat = 0;
AST_LIST_HEAD(global_curl_info, curl_settings) *list = NULL;
- char curl_errbuf[CURL_ERROR_SIZE + 1]; /* add one to be safe */
if (buf) {
*buf = '\0';
@@ -643,19 +642,7 @@
curl_easy_setopt(*curl, CURLOPT_POSTFIELDS, args.postdata);
}
- /* Temporarily assign a buffer for curl to write errors to. */
- curl_errbuf[0] = curl_errbuf[CURL_ERROR_SIZE] = '\0';
- curl_easy_setopt(*curl, CURLOPT_ERRORBUFFER, curl_errbuf);
-
- if (curl_easy_perform(*curl) != 0) {
- ast_log(LOG_WARNING, "%s ('%s')\n", curl_errbuf, args.url);
- }
-
- /* Reset buffer to NULL so curl doesn't try to write to it when the
- * buffer is deallocated. Documentation is vague about allowing NULL
- * here, but the source allows it. See: "typecheck: allow NULL to unset
- * CURLOPT_ERRORBUFFER" (62bcf005f4678a93158358265ba905bace33b834). */
- curl_easy_setopt(*curl, CURLOPT_ERRORBUFFER, (char*)NULL);
+ curl_easy_perform(*curl);
if (store) {
AST_LIST_UNLOCK(list);
@@ -678,11 +665,20 @@
int rowcount = 0;
while (fields && values && (piece = strsep(&remainder, "&"))) {
char *name = strsep(&piece, "=");
- struct ast_flags mode = (hashcompat == HASHCOMPAT_LEGACY ? ast_uri_http_legacy : ast_uri_http);
- if (piece) {
- ast_uri_decode(piece, mode);
+ /* Do this before the decode, because if something has encoded
+ * a literal plus-sign, we don't want to translate that to a
+ * space. */
+ if (hashcompat == HASHCOMPAT_LEGACY) {
+ if (piece) {
+ ast_uri_decode(piece, ast_uri_http_legacy);
+ }
+ ast_uri_decode(name, ast_uri_http_legacy);
+ } else {
+ if (piece) {
+ ast_uri_decode(piece, ast_uri_http);
+ }
+ ast_uri_decode(name, ast_uri_http);
}
- ast_uri_decode(name, mode);
ast_str_append(&fields, 0, "%s%s", rowcount ? "," : "", ast_str_set_escapecommas(&escapebuf, 0, name, INT_MAX));
ast_str_append(&values, 0, "%s%s", rowcount ? "," : "", ast_str_set_escapecommas(&escapebuf, 0, S_OR(piece, ""), INT_MAX));
rowcount++;
Modified: team/kharwell/stasis-http-conf/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/include/asterisk/astobj2.h?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/include/asterisk/astobj2.h (original)
+++ team/kharwell/stasis-http-conf/include/asterisk/astobj2.h Thu Mar 28 10:46:24 2013
@@ -1433,8 +1433,8 @@
* \param flags search_flags to control linking the object. (OBJ_NOLOCK)
* \param tag used for debugging.
*
- * \retval 0 on errors.
- * \retval 1 on success.
+ * \retval NULL on errors.
+ * \retval !NULL on success.
*
* This function inserts an object in a container according its key.
*
Modified: team/kharwell/stasis-http-conf/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/include/asterisk/autoconfig.h.in?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/include/asterisk/autoconfig.h.in (original)
+++ team/kharwell/stasis-http-conf/include/asterisk/autoconfig.h.in Thu Mar 28 10:46:24 2013
@@ -1229,11 +1229,6 @@
/* 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
Modified: team/kharwell/stasis-http-conf/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/include/asterisk/channel.h?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/include/asterisk/channel.h (original)
+++ team/kharwell/stasis-http-conf/include/asterisk/channel.h Thu Mar 28 10:46:24 2013
@@ -151,7 +151,6 @@
#include "asterisk/ccss.h"
#include "asterisk/framehook.h"
#include "asterisk/stasis.h"
-#include "asterisk/json.h"
#define DATASTORE_INHERIT_FOREVER INT_MAX
@@ -4136,11 +4135,7 @@
int priority; /*!< Dialplan: Current extension priority */
int amaflags; /*!< AMA flags for billing */
int hangupcause; /*!< Why is the channel hanged up. See causes.h */
- int caller_pres; /*!< Caller ID presentation. */
-
struct ast_flags flags; /*!< channel flags of AST_FLAG_ type */
-
- struct varshead *manager_vars; /*!< Variables to be appended to manager events */
};
/*!
@@ -4157,27 +4152,6 @@
/*!
* \since 12
- * \brief Sets the variables to be stored in the \a manager_vars field of all
- * snapshots.
- * \param varc Number of variable names.
- * \param vars Array of variable names.
- */
-void ast_channel_set_manager_vars(size_t varc, char **vars);
-
-/*!
- * \since 12
- * \brief Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
- *
- * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
- *
- * \param chan Channel to get variables for.
- * \return List of channel variables.
- * \return \c NULL on error
- */
-struct varshead *ast_channel_get_manager_vars(struct ast_channel *chan);
-
-/*!
- * \since 12
* \brief Message type for \ref ast_channel_snapshot.
*
* \retval Message type for \ref ast_channel_snapshot.
@@ -4188,12 +4162,10 @@
* \since 12
* \brief A topic which publishes the events for a particular channel.
*
- * If the given \a chan is \c NULL, ast_channel_topic_all() is returned.
- *
- * \param chan Channel, or \c NULL.
+ * \param chan Channel.
*
* \retval Topic for channel's events.
- * \retval ast_channel_topic_all() if \a chan is \c NULL.
+ * \retval \c NULL if \a chan is \c NULL.
*/
struct stasis_topic *ast_channel_topic(struct ast_channel *chan);
@@ -4215,51 +4187,24 @@
/*!
* \since 12
- * \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_blob {
- /*! Channel blob is associated with (or NULL for global/all channels) */
+ * \brief Variable set event.
+ */
+struct ast_channel_varset {
+ /*! Channel variable was set on (or NULL for global variable) */
struct ast_channel_snapshot *snapshot;
- /*! JSON blob of data */
- struct ast_json *blob;
+ /*! Variable name */
+ char *variable;
+ /*! New value */
+ char *value;
};
/*!
* \since 12
- * \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.
- *
- * \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 *ast_channel_blob_create(struct ast_channel *chan,
- struct ast_json *blob);
+ * \brief Message type for \ref ast_channel_varset messages.
+ *
+ * \retval Message type for \ref ast_channel_varset messages.
+ */
+struct stasis_message_type *ast_channel_varset(void);
/*!
* \since 12
Modified: team/kharwell/stasis-http-conf/include/asterisk/json.h
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/include/asterisk/json.h?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/include/asterisk/json.h (original)
+++ team/kharwell/stasis-http-conf/include/asterisk/json.h Thu Mar 28 10:46:24 2013
@@ -31,11 +31,6 @@
*/
/*!@{*/
-
-/*!
- * \brief Initialize the JSON library.
- */
-void ast_json_init(void);
/*!
* \brief Set custom allocators instead of the standard ast_malloc() and ast_free().
Modified: team/kharwell/stasis-http-conf/include/asterisk/manager.h
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/include/asterisk/manager.h?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/include/asterisk/manager.h (original)
+++ team/kharwell/stasis-http-conf/include/asterisk/manager.h Thu Mar 28 10:46:24 2013
@@ -316,12 +316,4 @@
*/
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 */
Modified: team/kharwell/stasis-http-conf/include/asterisk/sorcery.h
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/stasis-http-conf/include/asterisk/sorcery.h?view=diff&rev=384262&r1=384261&r2=384262
==============================================================================
--- team/kharwell/stasis-http-conf/include/asterisk/sorcery.h (original)
+++ team/kharwell/stasis-http-conf/include/asterisk/sorcery.h Thu Mar 28 10:46:24 2013
@@ -203,7 +203,7 @@
[... 1643 lines stripped ...]
More information about the asterisk-commits
mailing list