Asterisk - The Open Source Telephony Project  18.5.0
bridge_channel_internal.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  * Matt Jordan <[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 #ifndef _ASTERISK_PRIVATE_BRIDGING_CHANNEL_H
20 #define _ASTERISK_PRIVATE_BRIDGING_CHANNEL_H
21 
22 /*!
23  * \file
24  * \brief Private Bridging Channel API
25  *
26  * \author Matt Jordan <[email protected]>
27  *
28  * A private API to manipulate channels in a bridge. These can be called on a channel in
29  * a bridge by \ref bridge.c. These functions should not be called elsewhere, including
30  * by other members of the Bridging API.
31  *
32  * See Also:
33  * \arg \ref AstCREDITS
34  * \arg \ref Ast
35  */
36 
37 /*!
38  * \internal
39  * \brief Actions that can be taken on a channel in a bridge
40  */
42  /*! Bridged channel is to send a DTMF stream out */
44  /*! Bridged channel is to indicate talking start */
46  /*! Bridged channel is to indicate talking stop */
48  /*! Bridge channel is to play the indicated sound file. */
50  /*! Bridge channel is to run the indicated application. */
52  /*! Bridge channel is to run the custom callback routine. */
54  /*! Bridge channel is to get parked. */
56  /*! Bridge channel is to execute a blind transfer. */
58  /*! Bridge channel is to execute an attended transfer */
60 
61  /*
62  * Bridge actions put after this comment must never be put onto
63  * the bridge_channel wr_queue because they have other resources
64  * that must be freed.
65  */
66 
67  /*! Bridge reconfiguration deferred technology destruction. */
69  /*! Bridge deferred dissolving. */
71 };
72 
73 /*!
74  * \internal
75  * \brief Allocate a new ao2 ref counted bridge_channel
76  * \since 12.0.0
77  *
78  * \param bridge The bridge to make the bridge_channel for
79  *
80  * \retval NULL on error
81  * \retval ao2 ref counted object on success
82  */
84 
85 /*!
86  * \internal
87  * \brief Settle owed events by the channel to the original bridge.
88  * \since 12.0.0
89  *
90  * \param orig_bridge Original bridge the channel was in before leaving.
91  * \param bridge_channel Channel that owes events to the original bridge.
92  *
93  * \note On entry, the orig_bridge is already locked.
94  *
95  * \return Nothing
96  */
97 void bridge_channel_settle_owed_events(struct ast_bridge *orig_bridge, struct ast_bridge_channel *bridge_channel);
98 
99 /*!
100  * \internal
101  * \brief Queue any deferred frames on the channel.
102  * \since 13.17.0
103  *
104  * \param bridge_channel Channel that the deferred frames should be pulled from and queued to.
105  *
106  * \return Nothing
107  */
108 void bridge_channel_queue_deferred_frames(struct ast_bridge_channel *bridge_channel);
109 
110 /*!
111  * \internal
112  * \brief Push the bridge channel into its specified bridge.
113  * \since 12.0.0
114  *
115  * \param bridge_channel Channel to push.
116  *
117  * \note A ref is not held by bridge_channel->swap when calling because the
118  * push with swap happens immediately.
119  *
120  * \note On entry, bridge_channel->bridge is already locked.
121  *
122  * \retval 0 on success.
123  * \retval -1 on failure. The channel did not get pushed.
124  *
125  * \note On failure the caller must call
126  * ast_bridge_features_remove(bridge_channel->features, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
127  */
128 int bridge_channel_internal_push(struct ast_bridge_channel *bridge_channel);
129 
130 /*!
131  * \internal
132  * \brief Push the bridge channel into its specified bridge.
133  * \since 13.8.0
134  *
135  * \param bridge_channel Channel to push.
136  * \param optimized non-zero if the push with swap is for an optimization.
137  *
138  * \note A ref is not held by bridge_channel->swap when calling because the
139  * push with swap happens immediately.
140  *
141  * \note On entry, bridge_channel->bridge is already locked.
142  *
143  * \retval 0 on success.
144  * \retval -1 on failure. The channel did not get pushed.
145  *
146  * \note On failure the caller must call
147  * ast_bridge_features_remove(bridge_channel->features, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
148  */
149 int bridge_channel_internal_push_full(struct ast_bridge_channel *bridge_channel, int optimized);
150 
151 /*!
152  * \internal
153  * \brief Pull the bridge channel out of its current bridge.
154  * \since 12.0.0
155  *
156  * \param bridge_channel Channel to pull.
157  *
158  * \note On entry, bridge_channel->bridge is already locked.
159  *
160  * \return Nothing
161  */
162 void bridge_channel_internal_pull(struct ast_bridge_channel *bridge_channel);
163 
164 /*!
165  * \brief Signal imparting threads to wake up.
166  * \since 13.9.0
167  *
168  * \param chan Channel imparted that we need to signal.
169  *
170  * \return Nothing
171  */
173 
174 /*!
175  * \internal
176  * \brief Join the bridge_channel to the bridge (blocking)
177  *
178  * \param bridge_channel The Channel in the bridge
179  *
180  * \note The bridge_channel->swap holds a channel reference for the swap
181  * channel going into the bridging system. The ref ensures that the swap
182  * pointer is valid for the bridge subclass push callbacks. The pointer
183  * will be NULL on return if the ref was consumed.
184  *
185  * \details
186  * This API call puts the bridge_channel into the bridge and handles the
187  * bridge_channel's processing of events while it is in the bridge. It
188  * will return when the channel has been instructed to leave the bridge.
189  *
190  * \retval 0 bridge channel successfully joined the bridge
191  * \retval -1 bridge channel failed to join the bridge
192  */
193 int bridge_channel_internal_join(struct ast_bridge_channel *bridge_channel);
194 
195 /*!
196  * \internal
197  * \brief Temporarily suspend a channel from a bridge, handing control over to some
198  * other system
199  *
200  * \param bridge_channel The channel in the bridge
201  * \note This function assumes that \ref bridge_channel is already locked
202  */
204 
205 /*!
206  * \internal
207  * \brief Unsuspend a channel that was previously suspended
208  *
209  * \param bridge_channel The channel in the bridge
210  * \note This function assumes that \ref bridge_channel is already locked
211  */
213 
214 /*!
215  * \internal
216  * \brief Queue a blind transfer action on a transferee bridge channel
217  *
218  * This is only relevant for when a blind transfer is performed on a two-party
219  * bridge. The transferee's bridge channel will have a blind transfer bridge
220  * action queued onto it, resulting in the party being redirected to a new
221  * destination
222  *
223  * \param transferee The channel to have the action queued on
224  * \param exten The destination extension for the transferee
225  * \param context The destination context for the transferee
226  * \param hook Frame hook to attach to transferee
227  *
228  * \retval 0 on success.
229  * \retval -1 on error.
230  */
232  const char *exten, const char *context,
233  transfer_channel_cb new_channel_cb, void *user_data);
234 
235 /*!
236  * \internal
237  * \brief Queue an attended transfer action on a transferee bridge channel
238  *
239  * This is only relevant for when an attended transfer is performed on a two-party
240  * bridge. The transferee's bridge channel will have an attended transfer bridge
241  * action queued onto it.
242  *
243  * \param transferee The channel to have the action queued on
244  * \param unbridged_chan The unbridged channel who is the target of the attended
245  * transfer
246  *
247  * \retval 0 on success.
248  * \retval -1 on error.
249  */
251  struct ast_channel *unbridged_chan);
252 
253 /*!
254  * \internal
255  * \brief Return whether or not the bridge_channel would allow optimization
256  *
257  * \retval 0 if optimization is not allowed
258  * \retval non-zero if optimization is allowed
259  */
261 
262 #endif /* _ASTERISK_PRIVATE_BRIDGING_H */
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
Main Channel structure associated with a channel.
void bridge_channel_internal_suspend_nolock(struct ast_bridge_channel *bridge_channel)
void bridge_channel_internal_unsuspend_nolock(struct ast_bridge_channel *bridge_channel)
void bridge_channel_settle_owed_events(struct ast_bridge *orig_bridge, struct ast_bridge_channel *bridge_channel)
struct ast_bridge * bridge
Bridge this channel is participating in.
void bridge_channel_queue_deferred_frames(struct ast_bridge_channel *bridge_channel)
int bridge_channel_internal_allows_optimization(struct ast_bridge_channel *bridge_channel)
Structure that contains information about a bridge.
Definition: bridge.h:357
int bridge_channel_internal_queue_blind_transfer(struct ast_channel *transferee, const char *exten, const char *context, transfer_channel_cb new_channel_cb, void *user_data)
int bridge_channel_internal_push_full(struct ast_bridge_channel *bridge_channel, int optimized)
int bridge_channel_internal_push(struct ast_bridge_channel *bridge_channel)
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
void bridge_channel_impart_signal(struct ast_channel *chan)
Signal imparting threads to wake up.
Definition: bridge.c:1626
bridge_channel_action_type
struct ast_bridge_channel * bridge_channel_internal_alloc(struct ast_bridge *bridge)
int bridge_channel_internal_queue_attended_transfer(struct ast_channel *transferee, struct ast_channel *unbridged_chan)
int bridge_channel_internal_join(struct ast_bridge_channel *bridge_channel)
void(* transfer_channel_cb)(struct ast_channel *chan, struct transfer_channel_data *user_data, enum ast_transfer_type transfer_type)
Callback function type called during blind transfers.
Definition: bridge.h:1160
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
void bridge_channel_internal_pull(struct ast_bridge_channel *bridge_channel)