Asterisk - The Open Source Telephony Project  18.5.0
bridge_roles.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2013, Digium, Inc.
5  *
6  * Jonathan Rose <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*! \file
20  * \brief Channel Bridging Roles API
21  * \author Jonathan Rose <[email protected]>
22  */
23 
24 #ifndef _ASTERISK_BRIDGING_ROLES_H
25 #define _ASTERISK_BRIDGING_ROLES_H
26 
27 #if defined(__cplusplus) || defined(c_plusplus)
28 extern "C" {
29 #endif
30 
31 #include "asterisk/linkedlists.h"
32 
33 #define AST_ROLE_LEN 32
34 
35 /*!
36  * \brief Adds a bridge role to a channel
37  *
38  * \param chan Acquirer of the requested role
39  * \param role_name Name of the role being attached
40  *
41  * \retval 0 on success
42  * \retval -1 on failure
43  */
44 int ast_channel_add_bridge_role(struct ast_channel *chan, const char *role_name);
45 
46 /*!
47  * \brief Removes a bridge role from a channel
48  *
49  * \param chan Channel the role is being removed from
50  * \param role_name Name of the role being removed
51  */
52 void ast_channel_remove_bridge_role(struct ast_channel *chan, const char *role_name);
53 
54 /*!
55  * \brief Removes all bridge roles currently on a channel
56  *
57  * \param chan Channel the roles are being removed from
58  */
60 
61 /*!
62  * \brief Set a role option on a channel
63  * \param channel Channel receiving the role option
64  * \param role_name Role the role option is applied to
65  * \param option Name of the option
66  * \param value Value of the option
67  *
68  * \param 0 on success
69  * \retval -1 on failure
70  */
71 int ast_channel_set_bridge_role_option(struct ast_channel *channel, const char *role_name, const char *option, const char *value);
72 
73 /*!
74  * \brief Check if a role exists on a channel
75  *
76  * \param channel The channel to check
77  * \param role_name The name of the role to search for
78  *
79  * \retval 0 The requested role does not exist on the channel
80  * \retval 1 The requested role exists on the channel
81  *
82  * This is an alternative to \ref ast_bridge_channel_has_role that is useful if bridge
83  * roles have not yet been established on a channel's bridge_channel. A possible example of
84  * when this could be used is in a bridge v_table's push() callback.
85  */
86 int ast_channel_has_role(struct ast_channel *channel, const char *role_name);
87 
88 /*!
89  * \brief Retrieve the value of a requested role option from a channel
90  *
91  * \param channel The channel to retrieve the requested option from
92  * \param role_name The role to which the option belongs
93  * \param option The name of the option to retrieve
94  *
95  * \retval NULL The option does not exist
96  * \retval non-NULL The value of the option
97  *
98  * This is an alternative to \ref ast_bridge_channel_get_role_option that is useful if bridge
99  * roles have not yet been esstablished on a channel's bridge_channel. A possible example of
100  * when this could be used is in a bridge v_table's push() callback.
101  */
102 const char *ast_channel_get_role_option(struct ast_channel *channel, const char *role_name, const char *option);
103 
104 /*!
105  * \brief Check to see if a bridge channel inherited a specific role from its channel
106  *
107  * \param bridge_channel The bridge channel being checked
108  * \param role_name Name of the role being checked
109  *
110  * \retval 0 The bridge channel does not have the requested role
111  * \retval 1 The bridge channel does have the requested role
112  *
113  * \note Before a bridge_channel can effectively check roles against a bridge, ast_bridge_channel_establish_roles
114  * should be called on the bridge_channel so that roles and their respective role options can be copied from the channel
115  * datastore into the bridge_channel roles list. Otherwise this function will just return 0 because the list will be NULL.
116  */
117 int ast_bridge_channel_has_role(struct ast_bridge_channel *bridge_channel, const char *role_name);
118 
119 /*!
120  * \brief Retrieve the value of a requested role option from a bridge channel
121  *
122  * \param bridge_channel The bridge channel we are retrieving the option from
123  * \param role_name Name of the role the option will be retrieved from
124  * \param option Name of the option we are retrieving the value of
125  *
126  * \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
127  * \retval The value of the option
128  *
129  * \note See ast_channel_set_role_option note about the need to call ast_bridge_channel_establish_roles.
130  *
131  * \note The returned character pointer is only valid as long as the bridge_channel is guaranteed to be alive and hasn't had
132  * ast_bridge_channel_clear_roles called against it (as this will free all roles and role options in the bridge
133  * channel). If you need this value after one of these destruction events occurs, you must make a local copy while it is
134  * still valid.
135  */
136 const char *ast_bridge_channel_get_role_option(struct ast_bridge_channel *bridge_channel, const char *role_name, const char *option);
137 
138 /*!
139  * \brief Clone the roles from a bridge_channel's attached ast_channel onto the bridge_channel's role list
140  *
141  * \param bridge_channel The bridge channel that we are preparing
142  *
143  * \retval 0 on success
144  * \retval -1 on failure
145  *
146  * \details
147  * This function should always be called when the bridge_channel binds to an ast_channel at some point before the bridge_channel
148  * joins or is imparted onto a bridge. Failure to do so will result in an empty role list. While the list remains established,
149  * changes to roles on the ast_channel will not propogate to the bridge channel and roles can not be re-established on the bridge
150  * channel without first clearing the roles with ast_bridge_roles_bridge_channel_clear_roles.
151  */
152 int ast_bridge_channel_establish_roles(struct ast_bridge_channel *bridge_channel);
153 
154 /*!
155  * \brief Clear all roles from a bridge_channel's role list
156  *
157  * \param bridge_channel the bridge channel that we are scrubbing
158  *
159  * \details
160  * If roles are already established on a bridge channel, ast_bridge_channel_establish_roles will fail unconditionally
161  * without changing any roles. In order to update a bridge channel's roles, they must first be cleared from the bridge channel using
162  * this function.
163  *
164  * \note
165  * ast_bridge_channel_clear_roles also serves as the destructor for the role list of a bridge channel.
166  */
167 void ast_bridge_channel_clear_roles(struct ast_bridge_channel *bridge_channel);
168 
169 #if defined(__cplusplus) || defined(c_plusplus)
170 }
171 #endif
172 
173 #endif /* _ASTERISK_BRIDGING_ROLES_H */
int ast_bridge_channel_has_role(struct ast_bridge_channel *bridge_channel, const char *role_name)
Check to see if a bridge channel inherited a specific role from its channel.
Definition: bridge_roles.c:418
Main Channel structure associated with a channel.
void ast_bridge_channel_clear_roles(struct ast_bridge_channel *bridge_channel)
Clear all roles from a bridge_channel&#39;s role list.
Definition: bridge_roles.c:495
void ast_channel_remove_bridge_role(struct ast_channel *chan, const char *role_name)
Removes a bridge role from a channel.
Definition: bridge_roles.c:336
Definition: muted.c:95
int ast_channel_add_bridge_role(struct ast_channel *chan, const char *role_name)
Adds a bridge role to a channel.
Definition: bridge_roles.c:317
int value
Definition: syslog.c:37
int ast_bridge_channel_establish_roles(struct ast_bridge_channel *bridge_channel)
Clone the roles from a bridge_channel&#39;s attached ast_channel onto the bridge_channel&#39;s role list...
Definition: bridge_roles.c:447
int ast_channel_set_bridge_role_option(struct ast_channel *channel, const char *role_name, const char *option, const char *value)
Set a role option on a channel.
Definition: bridge_roles.c:379
A set of macros to manage forward-linked lists.
int ast_channel_has_role(struct ast_channel *channel, const char *role_name)
Check if a role exists on a channel.
Definition: bridge_roles.c:398
void ast_channel_clear_bridge_roles(struct ast_channel *chan)
Removes all bridge roles currently on a channel.
Definition: bridge_roles.c:360
Structure that contains information regarding a channel in a bridge.
const char * ast_channel_get_role_option(struct ast_channel *channel, const char *role_name, const char *option)
Retrieve the value of a requested role option from a channel.
Definition: bridge_roles.c:403
const char * ast_bridge_channel_get_role_option(struct ast_bridge_channel *bridge_channel, const char *role_name, const char *option)
Retrieve the value of a requested role option from a bridge channel.
Definition: bridge_roles.c:427