res_ari: Add support for channel variables in ARI events.

This works the same as for AMI manager variables. Set
"channelvars=foo,bar" in your ari.conf general section, and then the
channel variables "foo" and "bar" (along with their values), will
appear in every Stasis websocket channel event.

ASTERISK-26492 #close
patches:
  ari_vars.diff submitted by Mark Michelson

Change-Id: I5609ba239259577c0948645df776d7f3bc864229
This commit is contained in:
Sebastien Duthil
2016-11-11 11:45:37 -05:00
parent 7540036427
commit c6d755de11
13 changed files with 169 additions and 19 deletions

View File

@@ -26,6 +26,8 @@
#include "asterisk/config_options.h"
#include "asterisk/http_websocket.h"
#include "asterisk/app.h"
#include "asterisk/channel.h"
#include "internal.h"
/*! \brief Locking container for safe configuration access. */
@@ -316,6 +318,22 @@ static int process_config(int reload)
return 0;
}
#define MAX_VARS 128
static int channelvars_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
{
char *parse = NULL;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(vars)[MAX_VARS];
);
parse = ast_strdupa(var->value);
AST_STANDARD_APP_ARGS(args, parse);
ast_channel_set_ari_vars(args.argc, args.vars);
return 0;
}
int ast_ari_config_init(void)
{
if (aco_info_init(&cfg_info)) {
@@ -339,6 +357,8 @@ int ast_ari_config_init(void)
aco_option_register(&cfg_info, "websocket_write_timeout", ACO_EXACT, general_options,
AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR, OPT_INT_T, PARSE_IN_RANGE,
FLDSET(struct ast_ari_conf_general, write_timeout), 1, INT_MAX);
aco_option_register_custom(&cfg_info, "channelvars", ACO_EXACT, general_options,
"", channelvars_handler, 0);
/* ARI type=user category options */
aco_option_register(&cfg_info, "type", ACO_EXACT, user, NULL,