From c6d755de11e98c1f6f33b1b35db9725f64f72053 Mon Sep 17 00:00:00 2001 From: Sebastien Duthil Date: Fri, 11 Nov 2016 11:45:37 -0500 Subject: 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 --- include/asterisk/channel.h | 30 ++++++++++++++++++++++++++++++ include/asterisk/json.h | 12 ++++++++++++ include/asterisk/stasis_channels.h | 1 + 3 files changed, 43 insertions(+) (limited to 'include/asterisk') diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index ff92cc878..cfd8384cb 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -4339,6 +4339,36 @@ void ast_channel_set_manager_vars(size_t varc, char **vars); */ struct varshead *ast_channel_get_manager_vars(struct ast_channel *chan); +/*! + * \since 14.2.0 + * \brief Return whether or not any ARI variables have been set + * + * \retval 0 if no ARI variables are expected + * \retval 1 if ARI variables are expected + */ +int ast_channel_has_ari_vars(void); + +/*! + * \since 14.2.0 + * \brief Sets the variables to be stored in the \a ari_vars field of all + * snapshots. + * \param varc Number of variable names. + * \param vars Array of variable names. + */ +void ast_channel_set_ari_vars(size_t varc, char **vars); + +/*! + * \since 14.2.0 + * \brief Gets the variables for a given channel, as specified by ast_channel_set_ari_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_ari_vars(struct ast_channel *chan); + /*! * \since 12 * \brief Gets the variables for a given channel, as set using pbx_builtin_setvar_helper(). diff --git a/include/asterisk/json.h b/include/asterisk/json.h index cfd9a2997..bd6ba86b9 100644 --- a/include/asterisk/json.h +++ b/include/asterisk/json.h @@ -1076,6 +1076,18 @@ enum ast_json_to_ast_vars_code { */ enum ast_json_to_ast_vars_code ast_json_to_ast_variables(struct ast_json *json_variables, struct ast_variable **variables); +struct varshead; + +/*! + * \brief Construct a JSON object from a \c ast_var_t list + * \since 14.2.0 + * + * \param channelvars The list of \c ast_var_t to represent as JSON + * + * \return JSON object with variable names as keys and variable values as values + */ +struct ast_json *ast_json_channel_vars(struct varshead *channelvars); + /*!@}*/ #endif /* _ASTERISK_JSON_H */ diff --git a/include/asterisk/stasis_channels.h b/include/asterisk/stasis_channels.h index 6c6cd51f1..deb79b0d0 100644 --- a/include/asterisk/stasis_channels.h +++ b/include/asterisk/stasis_channels.h @@ -73,6 +73,7 @@ struct ast_channel_snapshot { struct ast_flags softhangup_flags; /*!< softhangup channel flags */ struct varshead *manager_vars; /*!< Variables to be appended to manager events */ int tech_properties; /*!< Properties of the channel's technology */ + struct varshead *ari_vars; /*!< Variables to be appended to ARI events */ }; /*! -- cgit v1.2.3