[asterisk-commits] jrose: trunk r396182 - in /trunk: include/asterisk/ main/ res/ res/ari/ res/s...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Aug 5 11:59:20 CDT 2013
Author: jrose
Date: Mon Aug 5 11:59:13 2013
New Revision: 396182
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396182
Log:
ARI: bridges/{bridgeID}/addChannel: add roles parameter
Roles are now cleared with each entry into a bridge with addChannel.
If the roles parameter is present, the role specified will be applied
to all channels being added with the addChannel command.
(closes issue ASTERISK-21973)
Reported by: Matt Jordan
https://reviewboard.asterisk.org/r/2691/
Modified:
trunk/include/asterisk/bridge_roles.h
trunk/include/asterisk/stasis_app.h
trunk/main/bridge_roles.c
trunk/res/ari/resource_bridges.c
trunk/res/ari/resource_bridges.h
trunk/res/res_ari_bridges.c
trunk/res/stasis/control.c
trunk/rest-api/api-docs/bridges.json
Modified: trunk/include/asterisk/bridge_roles.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/bridge_roles.h?view=diff&rev=396182&r1=396181&r2=396182
==============================================================================
--- trunk/include/asterisk/bridge_roles.h (original)
+++ trunk/include/asterisk/bridge_roles.h Mon Aug 5 11:59:13 2013
@@ -50,6 +50,13 @@
* \param role_name Name of the role being removed
*/
void ast_channel_remove_bridge_role(struct ast_channel *chan, const char *role_name);
+
+/*!
+ * \brief Removes all bridge roles currently on a channel
+ *
+ * \param chan Channel the roles are being removed from
+ */
+void ast_channel_clear_bridge_roles(struct ast_channel *chan);
/*!
* \brief Set a role option on a channel
Modified: trunk/include/asterisk/stasis_app.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/stasis_app.h?view=diff&rev=396182&r1=396181&r2=396182
==============================================================================
--- trunk/include/asterisk/stasis_app.h (original)
+++ trunk/include/asterisk/stasis_app.h Mon Aug 5 11:59:13 2013
@@ -174,6 +174,24 @@
int stasis_app_control_dial(struct stasis_app_control *control, const char *endpoint, int timeout);
/*!
+ * \brief Apply a bridge role to a channel controlled by a stasis app control
+ *
+ * \param control Control for \c res_stasis
+ * \param role Role to apply
+ *
+ * \return 0 for success
+ * \return -1 for error.
+ */
+int stasis_app_control_add_role(struct stasis_app_control *control, const char *role);
+
+/*!
+ * \brief Clear bridge roles currently applied to a channel controlled by a stasis app control
+ *
+ * \param control Control for \c res_stasis
+ */
+void stasis_app_control_clear_roles(struct stasis_app_control *control);
+
+/*!
* \brief Exit \c res_stasis and continue execution in the dialplan.
*
* If the channel is no longer in \c res_stasis, this function does nothing.
Modified: trunk/main/bridge_roles.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridge_roles.c?view=diff&rev=396182&r1=396181&r2=396182
==============================================================================
--- trunk/main/bridge_roles.c (original)
+++ trunk/main/bridge_roles.c Mon Aug 5 11:59:13 2013
@@ -355,6 +355,25 @@
ast_debug(2, "Role %s did not exist on channel %s\n", role_name, ast_channel_name(chan));
}
+void ast_channel_clear_bridge_roles(struct ast_channel *chan)
+{
+ struct bridge_roles_datastore *roles_datastore = fetch_bridge_roles_datastore(chan);
+ struct bridge_role *role;
+
+ if (!roles_datastore) {
+ /* The roles datastore didn't already exist, so there is no need to remove any roles */
+ ast_debug(2, "Roles did not exist on channel %s\n", ast_channel_name(chan));
+ return;
+ }
+
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&roles_datastore->role_list, role, list) {
+ ast_debug(2, "Removing bridge role %s from channel %s\n", role->role, ast_channel_name(chan));
+ AST_LIST_REMOVE_CURRENT(list);
+ bridge_role_destroy(role);
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+}
+
int ast_channel_set_bridge_role_option(struct ast_channel *channel, const char *role_name, const char *option, const char *value)
{
struct bridge_role *role = get_role_from_channel(channel, role_name);
Modified: trunk/res/ari/resource_bridges.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/ari/resource_bridges.c?view=diff&rev=396182&r1=396181&r2=396182
==============================================================================
--- trunk/res/ari/resource_bridges.c (original)
+++ trunk/res/ari/resource_bridges.c Mon Aug 5 11:59:13 2013
@@ -173,6 +173,16 @@
if (!list) {
/* Response filled in by control_list_create() */
return;
+ }
+
+ for (i = 0; i < list->count; ++i) {
+ stasis_app_control_clear_roles(list->controls[i]);
+ if (!ast_strlen_zero(args->role)) {
+ if (stasis_app_control_add_role(list->controls[i], args->role)) {
+ ast_ari_response_alloc_failed(response);
+ return;
+ }
+ }
}
for (i = 0; i < list->count; ++i) {
Modified: trunk/res/ari/resource_bridges.h
URL: http://svnview.digium.com/svn/asterisk/trunk/res/ari/resource_bridges.h?view=diff&rev=396182&r1=396181&r2=396182
==============================================================================
--- trunk/res/ari/resource_bridges.h (original)
+++ trunk/res/ari/resource_bridges.h Mon Aug 5 11:59:13 2013
@@ -103,6 +103,8 @@
size_t channel_count;
/*! \brief Parsing context for channel. */
char *channel_parse;
+ /*! \brief Channel's role in the bridge */
+ const char *role;
};
/*!
* \brief Add a channel to a bridge.
Modified: trunk/res/res_ari_bridges.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_ari_bridges.c?view=diff&rev=396182&r1=396181&r2=396182
==============================================================================
--- trunk/res/res_ari_bridges.c (original)
+++ trunk/res/res_ari_bridges.c Mon Aug 5 11:59:13 2013
@@ -323,6 +323,9 @@
for (j = 0; j < args.channel_count; ++j) {
args.channel[j] = (vals[j]);
}
+ } else
+ if (strcmp(i->name, "role") == 0) {
+ args.role = (i->value);
} else
{}
}
Modified: trunk/res/stasis/control.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/stasis/control.c?view=diff&rev=396182&r1=396181&r2=396182
==============================================================================
--- trunk/res/stasis/control.c (original)
+++ trunk/res/stasis/control.c Mon Aug 5 11:59:13 2013
@@ -168,6 +168,16 @@
return 0;
}
+int stasis_app_control_add_role(struct stasis_app_control *control, const char *role)
+{
+ return ast_channel_add_bridge_role(control->channel, role);
+}
+
+void stasis_app_control_clear_roles(struct stasis_app_control *control)
+{
+ ast_channel_clear_bridge_roles(control->channel);
+}
+
int control_is_done(struct stasis_app_control *control)
{
/* Called from stasis_app_exec thread; no lock needed */
Modified: trunk/rest-api/api-docs/bridges.json
URL: http://svnview.digium.com/svn/asterisk/trunk/rest-api/api-docs/bridges.json?view=diff&rev=396182&r1=396181&r2=396182
==============================================================================
--- trunk/rest-api/api-docs/bridges.json (original)
+++ trunk/rest-api/api-docs/bridges.json Mon Aug 5 11:59:13 2013
@@ -118,6 +118,14 @@
"paramType": "query",
"required": true,
"allowMultiple": true,
+ "dataType": "string"
+ },
+ {
+ "name": "role",
+ "description": "Channel's role in the bridge",
+ "paramType": "query",
+ "required": false,
+ "allowMultiple": false,
"dataType": "string"
}
],
More information about the asterisk-commits
mailing list