[svn-commits] mmichelson: branch mmichelson/atxfer_features r392213 - in /team/mmichelson/a...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jun 18 18:30:33 CDT 2013


Author: mmichelson
Date: Tue Jun 18 18:30:31 2013
New Revision: 392213

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392213
Log:
Expand bridging_roles API.

This adds channel-based functions that already existed
for bridge_channels. The reason for this is that my attended
transfer push function needs to check for the existence of roles
on a channel. I can't use the bridge channel at that point because
bridging roles are not established until after the push callback
is called.


Modified:
    team/mmichelson/atxfer_features/include/asterisk/bridging_roles.h
    team/mmichelson/atxfer_features/main/bridging_basic.c
    team/mmichelson/atxfer_features/main/bridging_roles.c

Modified: team/mmichelson/atxfer_features/include/asterisk/bridging_roles.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/include/asterisk/bridging_roles.h?view=diff&rev=392213&r1=392212&r2=392213
==============================================================================
--- team/mmichelson/atxfer_features/include/asterisk/bridging_roles.h (original)
+++ team/mmichelson/atxfer_features/include/asterisk/bridging_roles.h Tue Jun 18 18:30:31 2013
@@ -64,6 +64,37 @@
 int ast_channel_set_bridge_role_option(struct ast_channel *channel, const char *role_name, const char *option, const char *value);
 
 /*!
+ * \brief Check if a role exists on a channel
+ *
+ * \param channel The channel to check
+ * \param role_name The name of the role to search for
+ *
+ * \retval 0 The requested role does not exist on the channel
+ * \retval 1 The requested role exists on the channel
+ *
+ * This is an alternative to \ref ast_bridge_channel_has_role that is useful if bridge
+ * roles have not yet been established on a channel's bridge_channel. A possible example of
+ * when this could be used is in a bridge v_table's push() callback.
+ */
+int ast_channel_has_role(struct ast_channel *channel, const char *role_name);
+
+/*!
+ * \brief Retrieve the value of a requested role option from a channel
+ *
+ * \param channel The channel to retrieve the requested option from
+ * \param role_name The role to which the option belongs
+ * \param option The name of the option to retrieve
+ *
+ * \retval NULL The option does not exist
+ * \retval non-NULL The value of the option
+ *
+ * This is an alternative to \ref ast_bridge_channel_get_role_option that is useful if bridge
+ * roles have not yet been esstablished on a channel's bridge_channel. A possible example of
+ * when this could be used is in a bridge v_table's push() callback.
+ */
+const char *ast_channel_get_role_option(struct ast_channel *channel, const char *role_name, const char *option);
+
+/*!
  * \brief Check to see if a bridge channel inherited a specific role from its channel
  *
  * \param bridge_channel The bridge channel being checked
@@ -72,7 +103,7 @@
  * \retval 0 The bridge channel does not have the requested role
  * \retval 1 The bridge channel does have the requested role
  *
- * \note Before a bridge_channel can effectively check roles against a bridge, ast_bridge_roles_bridge_channel_establish_roles
+ * \note Before a bridge_channel can effectively check roles against a bridge, ast_bridge_channel_establish_roles
  *       should be called on the bridge_channel so that roles and their respective role options can be copied from the channel
  *       datastore into the bridge_channel roles list. Otherwise this function will just return 0 because the list will be NULL.
  */
@@ -88,10 +119,10 @@
  * \retval NULL If either the role does not exist on the bridge_channel or the role does exist but the option has not been set
  * \retval The value of the option
  *
- * \note See ast_bridge_roles_channel_set_role_option note about the need to call ast_bridge_roles_bridge_channel_establish_roles.
+ * \note See ast_channel_set_role_option note about the need to call ast_bridge_channel_establish_roles.
  *
  * \note The returned character pointer is only valid as long as the bridge_channel is guaranteed to be alive and hasn't had
- *       ast_bridge_roles_bridge_channel_clear_roles called against it (as this will free all roles and role options in the bridge
+ *       ast_bridge_channel_clear_roles called against it (as this will free all roles and role options in the bridge
  *       channel). If you need this value after one of these destruction events occurs, you must make a local copy while it is
  *       still valid.
  */
@@ -119,12 +150,12 @@
  * \param bridge_channel the bridge channel that we are scrubbing
  *
  * \details
- * If roles are already established on a bridge channel, ast_bridge_roles_bridge_channel_establish_roles will fail unconditionally
+ * If roles are already established on a bridge channel, ast_bridge_channel_establish_roles will fail unconditionally
  * without changing any roles. In order to update a bridge channel's roles, they must first be cleared from the bridge channel using
  * this function.
  *
  * \note
- * ast_bridge_roles_bridge_channel_clear_roles also serves as the destructor for the role list of a bridge channel.
+ * ast_bridge_channel_clear_roles also serves as the destructor for the role list of a bridge channel.
  */
 void ast_bridge_channel_clear_roles(struct ast_bridge_channel *bridge_channel);
 

Modified: team/mmichelson/atxfer_features/main/bridging_basic.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/bridging_basic.c?view=diff&rev=392213&r1=392212&r2=392213
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging_basic.c (original)
+++ team/mmichelson/atxfer_features/main/bridging_basic.c Tue Jun 18 18:30:31 2013
@@ -217,7 +217,7 @@
 
 	if (bridge->personality != &bridge_atxfer_personality) {
 		bridge->personality = &bridge_atxfer_personality;
-		ast_clear_flag(&bridge->feature_flags, AST_FLAG_ALL);
+		ast_clear_flag(&bridge->feature_flags, AST_FLAGS_ALL);
 		ast_set_flag(&bridge->feature_flags, TRANSFER_FLAGS);
 		remove_hooks_on_personality_change(bridge);
 	}
@@ -231,8 +231,8 @@
 
 	if (bridge->personality != &bridge_normal_personality) {
 		bridge->personality = &bridge_normal_personality;
-		ast_clear_flag(&bridge->feature_flags, AST_FLAG_ALL);
-		ast_set_flag(&bridge->feature_flags, BASIC_FLAGS);
+		ast_clear_flag(&bridge->feature_flags, AST_FLAGS_ALL);
+		ast_set_flag(&bridge->feature_flags, NORMAL_FLAGS);
 		remove_hooks_on_personality_change(bridge);
 	}
 }

Modified: team/mmichelson/atxfer_features/main/bridging_roles.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/bridging_roles.c?view=diff&rev=392213&r1=392212&r2=392213
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging_roles.c (original)
+++ team/mmichelson/atxfer_features/main/bridging_roles.c Tue Jun 18 18:30:31 2013
@@ -376,6 +376,26 @@
 	return 0;
 }
 
+int ast_channel_has_role(struct ast_channel *channel, const char *role_name)
+{
+	return get_role_from_channel(channel, role_name) ? 1 : 0;
+}
+
+const char *ast_channel_get_role_option(struct ast_channel *channel, const char *role_name, const char *option)
+{
+	struct bridge_role *role;
+	struct bridge_role_option *role_option;
+
+	role = get_role_from_channel(channel, role_name);
+	if (!role) {
+		return NULL;
+	}
+
+	role_option = get_role_option(role, option);
+
+	return role_option ? role_option->value : NULL;
+}
+
 int ast_bridge_channel_has_role(struct ast_bridge_channel *bridge_channel, const char *role_name)
 {
 	if (!bridge_channel->bridge_roles) {




More information about the svn-commits mailing list