Review Board 1.7.16


Add ability to call a function when a channel leaves the bridging system.

Review Request #2535 - Created May 13, 2013 and submitted

rmudgett
team/group/bridge_construction
ASTERISK-21640
Reviewers
asterisk-dev
dlee, mjordan, mmichelson
Asterisk
There are times when a module would like to gain control of a channel that is already in the bridging system but the module does not want the channel in the bridging system when it gains control.

1) The mythical app_queue holding priority bridge when the channel is selected to dial an agent.
2) Stasis-HTTP when it needs to gain control before it initiates dialing.
3) Attended transferring a bridged channel to an application.

Example usage:
ast_after_bridge_callback_set(chan, callback_fn, failed_fn, data);
ast_bridge_remove(bridge, chan)

When the channel leaves the bridge the callback_fn(chan, data) will be made.
Added test code to add a callback when a channel leaves a bridge.
1) The callback was called when the channel left the bridge and was not hung up.
2) The failed callback was called when the channel simply hung up.

Added an explicit remove of the callback datastore.
The failed callback was called as expected.
/team/group/bridge_construction/include/asterisk/bridging.h
Revision 388574 New Change
1
/*
1
/*
2
 * Asterisk -- An open source telephony toolkit.
2
 * Asterisk -- An open source telephony toolkit.
3
 *
3
 *
4
 * Copyright (C) 2007 - 2009, 2013 Digium, Inc.
4
 * Copyright (C) 2007 - 2009, 2013 Digium, Inc.
5
 *
5
 *
6
 * Richard Mudgett <rmudgett@digium.com>
6
 * Richard Mudgett <rmudgett@digium.com>
7
 * Joshua Colp <jcolp@digium.com>
7
 * Joshua Colp <jcolp@digium.com>
8
 *
8
 *
9
 * See http://www.asterisk.org for more information about
9
 * See http://www.asterisk.org for more information about
10
 * the Asterisk project. Please do not directly contact
10
 * the Asterisk project. Please do not directly contact
11
 * any of the maintainers of this project for assistance;
11
 * any of the maintainers of this project for assistance;
12
 * the project provides a web site, mailing lists and IRC
12
 * the project provides a web site, mailing lists and IRC
13
 * channels for your use.
13
 * channels for your use.
14
 *
14
 *
15
 * This program is free software, distributed under the terms of
15
 * This program is free software, distributed under the terms of
16
 * the GNU General Public License Version 2. See the LICENSE file
16
 * the GNU General Public License Version 2. See the LICENSE file
17
 * at the top of the source tree.
17
 * at the top of the source tree.
18
 */
18
 */
19

    
   
19

   
20
/*!
20
/*!
21
 * \file
21
 * \file
22
 * \brief Channel Bridging API
22
 * \brief Channel Bridging API
23
 *
23
 *
24
 * \author Richard Mudgett <rmudgett@digium.com>
24
 * \author Richard Mudgett <rmudgett@digium.com>
25
 * \author Joshua Colp <jcolp@digium.com>
25
 * \author Joshua Colp <jcolp@digium.com>
26
 * \ref AstBridging
26
 * \ref AstBridging
27
 *
27
 *
28
 * See Also:
28
 * See Also:
29
 * \arg \ref AstCREDITS
29
 * \arg \ref AstCREDITS
30
 */
30
 */
31

    
   
31

   
32
/*!
32
/*!
33
 * \page AstBridging Channel Bridging API
33
 * \page AstBridging Channel Bridging API
34
 *
34
 *
35
 * The purpose of this API is to provide an easy and flexible way to bridge
35
 * The purpose of this API is to provide an easy and flexible way to bridge
36
 * channels of different technologies with different features.
36
 * channels of different technologies with different features.
37
 *
37
 *
38
 * Bridging technologies provide the mechanism that do the actual handling
38
 * Bridging technologies provide the mechanism that do the actual handling
39
 * of frames between channels. They provide capability information, codec information,
39
 * of frames between channels. They provide capability information, codec information,
40
 * and preference value to assist the bridging core in choosing a bridging technology when
40
 * and preference value to assist the bridging core in choosing a bridging technology when
41
 * creating a bridge. Different bridges may use different bridging technologies based on needs
41
 * creating a bridge. Different bridges may use different bridging technologies based on needs
42
 * but once chosen they all operate under the same premise; they receive frames and send frames.
42
 * but once chosen they all operate under the same premise; they receive frames and send frames.
43
 *
43
 *
44
 * Bridges are a combination of bridging technology, channels, and features. A
44
 * Bridges are a combination of bridging technology, channels, and features. A
45
 * developer creates a new bridge based on what they are currently expecting to do
45
 * developer creates a new bridge based on what they are currently expecting to do
46
 * with it or what they will do with it in the future. The bridging core determines what
46
 * with it or what they will do with it in the future. The bridging core determines what
47
 * available bridging technology will best fit the requirements and creates a new bridge.
47
 * available bridging technology will best fit the requirements and creates a new bridge.
48
 * Once created, channels can be added to the bridge in a blocking or non-blocking fashion.
48
 * Once created, channels can be added to the bridge in a blocking or non-blocking fashion.
49
 *
49
 *
50
 * Features are such things as channel muting or DTMF based features such as attended transfer,
50
 * Features are such things as channel muting or DTMF based features such as attended transfer,
51
 * blind transfer, and hangup. Feature information must be set at the most granular level, on
51
 * blind transfer, and hangup. Feature information must be set at the most granular level, on
52
 * the channel. While you can use features on a global scope the presence of a feature structure
52
 * the channel. While you can use features on a global scope the presence of a feature structure
53
 * on the channel will override the global scope. An example would be having the bridge muted
53
 * on the channel will override the global scope. An example would be having the bridge muted
54
 * at global scope and attended transfer enabled on a channel. Since the channel itself is not muted
54
 * at global scope and attended transfer enabled on a channel. Since the channel itself is not muted
55
 * it would be able to speak.
55
 * it would be able to speak.
56
 *
56
 *
57
 * Feature hooks allow a developer to tell the bridging core that when a DTMF string
57
 * Feature hooks allow a developer to tell the bridging core that when a DTMF string
58
 * is received from a channel a callback should be called in their application. For
58
 * is received from a channel a callback should be called in their application. For
59
 * example, a conference bridge application may want to provide an IVR to control various
59
 * example, a conference bridge application may want to provide an IVR to control various
60
 * settings on the conference bridge. This can be accomplished by attaching a feature hook
60
 * settings on the conference bridge. This can be accomplished by attaching a feature hook
61
 * that calls an IVR function when a DTMF string is entered.
61
 * that calls an IVR function when a DTMF string is entered.
62
 *
62
 *
63
 */
63
 */
64

    
   
64

   
65
#ifndef _ASTERISK_BRIDGING_H
65
#ifndef _ASTERISK_BRIDGING_H
66
#define _ASTERISK_BRIDGING_H
66
#define _ASTERISK_BRIDGING_H
67

    
   
67

   
68
#if defined(__cplusplus) || defined(c_plusplus)
68
#if defined(__cplusplus) || defined(c_plusplus)
69
extern "C" {
69
extern "C" {
70
#endif
70
#endif
71

    
   
71

   
72
#include "asterisk/bridging_features.h"
72
#include "asterisk/bridging_features.h"
73
#include "asterisk/bridging_roles.h"
73
#include "asterisk/bridging_roles.h"
74
#include "asterisk/dsp.h"
74
#include "asterisk/dsp.h"
75
#include "asterisk/uuid.h"
75
#include "asterisk/uuid.h"
76

    
   
76

   
77
/*! \brief Capabilities for a bridge technology */
77
/*! \brief Capabilities for a bridge technology */
78
enum ast_bridge_capability {
78
enum ast_bridge_capability {
79
	/*! Bridge technology can service calls on hold. */
79
	/*! Bridge technology can service calls on hold. */
80
	AST_BRIDGE_CAPABILITY_HOLDING = (1 << 0),
80
	AST_BRIDGE_CAPABILITY_HOLDING = (1 << 0),
81
	/*! Bridge waits for channel to answer.  Passes early media. (XXX Not supported yet) */
81
	/*! Bridge waits for channel to answer.  Passes early media. (XXX Not supported yet) */
82
	AST_BRIDGE_CAPABILITY_EARLY = (1 << 1),
82
	AST_BRIDGE_CAPABILITY_EARLY = (1 << 1),
83
	/*! Bridge is capable of natively bridging two channels. (Smart bridge only) */
83
	/*! Bridge is capable of natively bridging two channels. (Smart bridge only) */
84
	AST_BRIDGE_CAPABILITY_NATIVE = (1 << 2),
84
	AST_BRIDGE_CAPABILITY_NATIVE = (1 << 2),
85
	/*! Bridge is capable of mixing at most two channels. (Smart bridgeable) */
85
	/*! Bridge is capable of mixing at most two channels. (Smart bridgeable) */
86
	AST_BRIDGE_CAPABILITY_1TO1MIX = (1 << 3),
86
	AST_BRIDGE_CAPABILITY_1TO1MIX = (1 << 3),
87
	/*! Bridge is capable of mixing an arbitrary number of channels. (Smart bridgeable) */
87
	/*! Bridge is capable of mixing an arbitrary number of channels. (Smart bridgeable) */
88
	AST_BRIDGE_CAPABILITY_MULTIMIX = (1 << 4),
88
	AST_BRIDGE_CAPABILITY_MULTIMIX = (1 << 4),
89
};
89
};
90

    
   
90

   
91
/*! \brief State information about a bridged channel */
91
/*! \brief State information about a bridged channel */
92
enum ast_bridge_channel_state {
92
enum ast_bridge_channel_state {
93
	/*! Waiting for a signal (Channel in the bridge) */
93
	/*! Waiting for a signal (Channel in the bridge) */
94
	AST_BRIDGE_CHANNEL_STATE_WAIT = 0,
94
	AST_BRIDGE_CHANNEL_STATE_WAIT = 0,
95
	/*! Bridged channel was forced out and should be hung up (Bridge may dissolve.) */
95
	/*! Bridged channel was forced out and should be hung up (Bridge may dissolve.) */
96
	AST_BRIDGE_CHANNEL_STATE_END,
96
	AST_BRIDGE_CHANNEL_STATE_END,
97
	/*! Bridged channel was forced out and should be hung up */
97
	/*! Bridged channel was forced out and should be hung up */
98
	AST_BRIDGE_CHANNEL_STATE_HANGUP,
98
	AST_BRIDGE_CHANNEL_STATE_HANGUP,
99
};
99
};
100

    
   
100

   
101
enum ast_bridge_channel_thread_state {
101
enum ast_bridge_channel_thread_state {
102
	/*! Bridge channel thread is idle/waiting. */
102
	/*! Bridge channel thread is idle/waiting. */
103
	AST_BRIDGE_CHANNEL_THREAD_IDLE,
103
	AST_BRIDGE_CHANNEL_THREAD_IDLE,
104
	/*! Bridge channel thread is writing a normal/simple frame. */
104
	/*! Bridge channel thread is writing a normal/simple frame. */
105
	AST_BRIDGE_CHANNEL_THREAD_SIMPLE,
105
	AST_BRIDGE_CHANNEL_THREAD_SIMPLE,
106
	/*! Bridge channel thread is processing a frame. */
106
	/*! Bridge channel thread is processing a frame. */
107
	AST_BRIDGE_CHANNEL_THREAD_FRAME,
107
	AST_BRIDGE_CHANNEL_THREAD_FRAME,
108
};
108
};
109

    
   
109

   
110
struct ast_bridge_technology;
110
struct ast_bridge_technology;
111
struct ast_bridge;
111
struct ast_bridge;
112

    
   
112

   
113
/*!
113
/*!
114
 * \brief Structure specific to bridge technologies capable of
114
 * \brief Structure specific to bridge technologies capable of
115
 * performing talking optimizations.
115
 * performing talking optimizations.
116
 */
116
 */
117
struct ast_bridge_tech_optimizations {
117
struct ast_bridge_tech_optimizations {
118
	/*! The amount of time in ms that talking must be detected before
118
	/*! The amount of time in ms that talking must be detected before
119
	 *  the dsp determines that talking has occurred */
119
	 *  the dsp determines that talking has occurred */
120
	unsigned int talking_threshold;
120
	unsigned int talking_threshold;
121
	/*! The amount of time in ms that silence must be detected before
121
	/*! The amount of time in ms that silence must be detected before
122
	 *  the dsp determines that talking has stopped */
122
	 *  the dsp determines that talking has stopped */
123
	unsigned int silence_threshold;
123
	unsigned int silence_threshold;
124
	/*! Whether or not the bridging technology should drop audio
124
	/*! Whether or not the bridging technology should drop audio
125
	 *  detected as silence from the mix. */
125
	 *  detected as silence from the mix. */
126
	unsigned int drop_silence:1;
126
	unsigned int drop_silence:1;
127
};
127
};
128

    
   
128

   
129
/*!
129
/*!
130
 * \brief Structure that contains information regarding a channel in a bridge
130
 * \brief Structure that contains information regarding a channel in a bridge
131
 */
131
 */
132
struct ast_bridge_channel {
132
struct ast_bridge_channel {
133
/* BUGBUG cond is only here because of external party suspend/unsuspend support. */
133
/* BUGBUG cond is only here because of external party suspend/unsuspend support. */
134
	/*! Condition, used if we want to wake up a thread waiting on the bridged channel */
134
	/*! Condition, used if we want to wake up a thread waiting on the bridged channel */
135
	ast_cond_t cond;
135
	ast_cond_t cond;
136
	/*! Current bridged channel state */
136
	/*! Current bridged channel state */
137
	enum ast_bridge_channel_state state;
137
	enum ast_bridge_channel_state state;
138
	/*! Asterisk channel participating in the bridge */
138
	/*! Asterisk channel participating in the bridge */
139
	struct ast_channel *chan;
139
	struct ast_channel *chan;
140
	/*! Asterisk channel we are swapping with (if swapping) */
140
	/*! Asterisk channel we are swapping with (if swapping) */
141
	struct ast_channel *swap;
141
	struct ast_channel *swap;
142
	/*!
142
	/*!
143
	 * \brief Bridge this channel is participating in
143
	 * \brief Bridge this channel is participating in
144
	 *
144
	 *
145
	 * \note The bridge pointer cannot change while the bridge or
145
	 * \note The bridge pointer cannot change while the bridge or
146
	 * bridge_channel is locked.
146
	 * bridge_channel is locked.
147
	 */
147
	 */
148
	struct ast_bridge *bridge;
148
	struct ast_bridge *bridge;
149
	/*!
149
	/*!
150
	 * \brief Bridge class private channel data.
150
	 * \brief Bridge class private channel data.
151
	 *
151
	 *
152
	 * \note This information is added when the channel is pushed
152
	 * \note This information is added when the channel is pushed
153
	 * into the bridge and removed when it is pulled from the
153
	 * into the bridge and removed when it is pulled from the
154
	 * bridge.
154
	 * bridge.
155
	 */
155
	 */
156
	void *bridge_pvt;
156
	void *bridge_pvt;
157
	/*!
157
	/*!
158
	 * \brief Private information unique to the bridge technology.
158
	 * \brief Private information unique to the bridge technology.
159
	 *
159
	 *
160
	 * \note This information is added when the channel joins the
160
	 * \note This information is added when the channel joins the
161
	 * bridge's technology and removed when it leaves the bridge's
161
	 * bridge's technology and removed when it leaves the bridge's
162
	 * technology.
162
	 * technology.
163
	 */
163
	 */
164
	void *tech_pvt;
164
	void *tech_pvt;
165
	/*! Thread handling the bridged channel (Needed by ast_bridge_depart) */
165
	/*! Thread handling the bridged channel (Needed by ast_bridge_depart) */
166
	pthread_t thread;
166
	pthread_t thread;
167
	/* v-- These flags change while the bridge is locked or before the channel is in the bridge. */
167
	/* v-- These flags change while the bridge is locked or before the channel is in the bridge. */
168
	/*! TRUE if the channel is in a bridge. */
168
	/*! TRUE if the channel is in a bridge. */
169
	unsigned int in_bridge:1;
169
	unsigned int in_bridge:1;
170
	/*! TRUE if the channel just joined the bridge. */
170
	/*! TRUE if the channel just joined the bridge. */
171
	unsigned int just_joined:1;
171
	unsigned int just_joined:1;
172
	/*! TRUE if the channel is suspended from the bridge. */
172
	/*! TRUE if the channel is suspended from the bridge. */
173
	unsigned int suspended:1;
173
	unsigned int suspended:1;
174
	/*! TRUE if the channel must wait for an ast_bridge_depart to reclaim the channel. */
174
	/*! TRUE if the channel must wait for an ast_bridge_depart to reclaim the channel. */
175
	unsigned int depart_wait:1;
175
	unsigned int depart_wait:1;
176
	/* ^-- These flags change while the bridge is locked or before the channel is in the bridge. */
176
	/* ^-- These flags change while the bridge is locked or before the channel is in the bridge. */
177
	/*! Features structure for features that are specific to this channel */
177
	/*! Features structure for features that are specific to this channel */
178
	struct ast_bridge_features *features;
178
	struct ast_bridge_features *features;
179
	/*! Technology optimization parameters used by bridging technologies capable of
179
	/*! Technology optimization parameters used by bridging technologies capable of
180
	 *  optimizing based upon talk detection. */
180
	 *  optimizing based upon talk detection. */
181
	struct ast_bridge_tech_optimizations tech_args;
181
	struct ast_bridge_tech_optimizations tech_args;
182
	/*! Copy of read format used by chan before join */
182
	/*! Copy of read format used by chan before join */
183
	struct ast_format read_format;
183
	struct ast_format read_format;
184
	/*! Copy of write format used by chan before join */
184
	/*! Copy of write format used by chan before join */
185
	struct ast_format write_format;
185
	struct ast_format write_format;
186
	/*! Call ID associated with bridge channel */
186
	/*! Call ID associated with bridge channel */
187
	struct ast_callid *callid;
187
	struct ast_callid *callid;
188
	/*! A clone of the roles living on chan when the bridge channel joins the bridge. This may require some opacification */
188
	/*! A clone of the roles living on chan when the bridge channel joins the bridge. This may require some opacification */
189
	struct bridge_roles_datastore *bridge_roles;
189
	struct bridge_roles_datastore *bridge_roles;
190
	/*! Linked list information */
190
	/*! Linked list information */
191
	AST_LIST_ENTRY(ast_bridge_channel) entry;
191
	AST_LIST_ENTRY(ast_bridge_channel) entry;
192
	/*! Queue of outgoing frames to the channel. */
192
	/*! Queue of outgoing frames to the channel. */
193
	AST_LIST_HEAD_NOLOCK(, ast_frame) wr_queue;
193
	AST_LIST_HEAD_NOLOCK(, ast_frame) wr_queue;
194
	/*! Pipe to alert thread when frames are put into the wr_queue. */
194
	/*! Pipe to alert thread when frames are put into the wr_queue. */
195
	int alert_pipe[2];
195
	int alert_pipe[2];
196
	/*! TRUE if the bridge channel thread is waiting on channels (needs to be atomically settable) */
196
	/*! TRUE if the bridge channel thread is waiting on channels (needs to be atomically settable) */
197
	int waiting;
197
	int waiting;
198
	/*!
198
	/*!
199
	 * \brief The bridge channel thread activity.
199
	 * \brief The bridge channel thread activity.
200
	 *
200
	 *
201
	 * \details Used by local channel optimization to determine if
201
	 * \details Used by local channel optimization to determine if
202
	 * the thread is in an acceptable state to optimize.
202
	 * the thread is in an acceptable state to optimize.
203
	 *
203
	 *
204
	 * \note Needs to be atomically settable.
204
	 * \note Needs to be atomically settable.
205
	 */
205
	 */
206
	enum ast_bridge_channel_thread_state activity;
206
	enum ast_bridge_channel_thread_state activity;
207
};
207
};
208

    
   
208

   
209
enum ast_bridge_action_type {
209
enum ast_bridge_action_type {
210
	/*! Bridged channel is to detect a feature hook */
210
	/*! Bridged channel is to detect a feature hook */
211
	AST_BRIDGE_ACTION_FEATURE,
211
	AST_BRIDGE_ACTION_FEATURE,
212
	/*! Bridged channel is to act on an interval hook */
212
	/*! Bridged channel is to act on an interval hook */
213
	AST_BRIDGE_ACTION_INTERVAL,
213
	AST_BRIDGE_ACTION_INTERVAL,
214
	/*! Bridged channel is to send a DTMF stream out */
214
	/*! Bridged channel is to send a DTMF stream out */
215
	AST_BRIDGE_ACTION_DTMF_STREAM,
215
	AST_BRIDGE_ACTION_DTMF_STREAM,
216
	/*! Bridged channel is to indicate talking start */
216
	/*! Bridged channel is to indicate talking start */
217
	AST_BRIDGE_ACTION_TALKING_START,
217
	AST_BRIDGE_ACTION_TALKING_START,
218
	/*! Bridged channel is to indicate talking stop */
218
	/*! Bridged channel is to indicate talking stop */
219
	AST_BRIDGE_ACTION_TALKING_STOP,
219
	AST_BRIDGE_ACTION_TALKING_STOP,
220
	/*! Bridge channel is to play the indicated sound file. */
220
	/*! Bridge channel is to play the indicated sound file. */
221
	AST_BRIDGE_ACTION_PLAY_FILE,
221
	AST_BRIDGE_ACTION_PLAY_FILE,
222
	/*! Bridge channel is to get parked. */
222
	/*! Bridge channel is to get parked. */
223
	AST_BRIDGE_ACTION_PARK,
223
	AST_BRIDGE_ACTION_PARK,
224
	/*! Bridge channel is to run the indicated application. */
224
	/*! Bridge channel is to run the indicated application. */
225
	AST_BRIDGE_ACTION_RUN_APP,
225
	AST_BRIDGE_ACTION_RUN_APP,
226
	/*! Bridge channel is to execute a blind transfer. */
226
	/*! Bridge channel is to execute a blind transfer. */
227
	AST_BRIDGE_ACTION_BLIND_TRANSFER,
227
	AST_BRIDGE_ACTION_BLIND_TRANSFER,
228

    
   
228

   
229
	/*
229
	/*
230
	 * Bridge actions put after this comment must never be put onto
230
	 * Bridge actions put after this comment must never be put onto
231
	 * the bridge_channel wr_queue because they have other resources
231
	 * the bridge_channel wr_queue because they have other resources
232
	 * that must be freed.
232
	 * that must be freed.
233
	 */
233
	 */
234

    
   
234

   
235
	/*! Bridge reconfiguration deferred technology destruction. */
235
	/*! Bridge reconfiguration deferred technology destruction. */
236
	AST_BRIDGE_ACTION_DEFERRED_TECH_DESTROY = 1000,
236
	AST_BRIDGE_ACTION_DEFERRED_TECH_DESTROY = 1000,
237
	/*! Bridge deferred dissolving. */
237
	/*! Bridge deferred dissolving. */
238
	AST_BRIDGE_ACTION_DEFERRED_DISSOLVING,
238
	AST_BRIDGE_ACTION_DEFERRED_DISSOLVING,
239
};
239
};
240

    
   
240

   
241
enum ast_bridge_video_mode_type {
241
enum ast_bridge_video_mode_type {
242
	/*! Video is not allowed in the bridge */
242
	/*! Video is not allowed in the bridge */
243
	AST_BRIDGE_VIDEO_MODE_NONE = 0,
243
	AST_BRIDGE_VIDEO_MODE_NONE = 0,
244
	/*! A single user is picked as the only distributed of video across the bridge */
244
	/*! A single user is picked as the only distributed of video across the bridge */
245
	AST_BRIDGE_VIDEO_MODE_SINGLE_SRC,
245
	AST_BRIDGE_VIDEO_MODE_SINGLE_SRC,
246
	/*! A single user's video feed is distributed to all bridge channels, but
246
	/*! A single user's video feed is distributed to all bridge channels, but
247
	 *  that feed is automatically picked based on who is talking the most. */
247
	 *  that feed is automatically picked based on who is talking the most. */
248
	AST_BRIDGE_VIDEO_MODE_TALKER_SRC,
248
	AST_BRIDGE_VIDEO_MODE_TALKER_SRC,
249
};
249
};
250

    
   
250

   
251
/*! This is used for both SINGLE_SRC mode to set what channel
251
/*! This is used for both SINGLE_SRC mode to set what channel
252
 *  should be the current single video feed */
252
 *  should be the current single video feed */
253
struct ast_bridge_video_single_src_data {
253
struct ast_bridge_video_single_src_data {
254
	/*! Only accept video coming from this channel */
254
	/*! Only accept video coming from this channel */
255
	struct ast_channel *chan_vsrc;
255
	struct ast_channel *chan_vsrc;
256
};
256
};
257

    
   
257

   
258
/*! This is used for both SINGLE_SRC_TALKER mode to set what channel
258
/*! This is used for both SINGLE_SRC_TALKER mode to set what channel
259
 *  should be the current single video feed */
259
 *  should be the current single video feed */
260
struct ast_bridge_video_talker_src_data {
260
struct ast_bridge_video_talker_src_data {
261
	/*! Only accept video coming from this channel */
261
	/*! Only accept video coming from this channel */
262
	struct ast_channel *chan_vsrc;
262
	struct ast_channel *chan_vsrc;
263
	int average_talking_energy;
263
	int average_talking_energy;
264

    
   
264

   
265
	/*! Current talker see's this person */
265
	/*! Current talker see's this person */
266
	struct ast_channel *chan_old_vsrc;
266
	struct ast_channel *chan_old_vsrc;
267
};
267
};
268

    
   
268

   
269
struct ast_bridge_video_mode {
269
struct ast_bridge_video_mode {
270
	enum ast_bridge_video_mode_type mode;
270
	enum ast_bridge_video_mode_type mode;
271
	/* Add data for all the video modes here. */
271
	/* Add data for all the video modes here. */
272
	union {
272
	union {
273
		struct ast_bridge_video_single_src_data single_src_data;
273
		struct ast_bridge_video_single_src_data single_src_data;
274
		struct ast_bridge_video_talker_src_data talker_src_data;
274
		struct ast_bridge_video_talker_src_data talker_src_data;
275
	} mode_data;
275
	} mode_data;
276
};
276
};
277

    
   
277

   
278
/*!
278
/*!
279
 * \brief Destroy the bridge.
279
 * \brief Destroy the bridge.
280
 *
280
 *
281
 * \param self Bridge to operate upon.
281
 * \param self Bridge to operate upon.
282
 *
282
 *
283
 * \return Nothing
283
 * \return Nothing
284
 */
284
 */
285
typedef void (*ast_bridge_destructor_fn)(struct ast_bridge *self);
285
typedef void (*ast_bridge_destructor_fn)(struct ast_bridge *self);
286

    
   
286

   
287
/*!
287
/*!
288
 * \brief The bridge is being dissolved.
288
 * \brief The bridge is being dissolved.
289
 *
289
 *
290
 * \param self Bridge to operate upon.
290
 * \param self Bridge to operate upon.
291
 *
291
 *
292
 * \details
292
 * \details
293
 * The bridge is being dissolved.  Remove any external
293
 * The bridge is being dissolved.  Remove any external
294
 * references to the bridge so it can be destroyed.
294
 * references to the bridge so it can be destroyed.
295
 *
295
 *
296
 * \note On entry, self must NOT be locked.
296
 * \note On entry, self must NOT be locked.
297
 *
297
 *
298
 * \return Nothing
298
 * \return Nothing
299
 */
299
 */
300
typedef void (*ast_bridge_dissolving_fn)(struct ast_bridge *self);
300
typedef void (*ast_bridge_dissolving_fn)(struct ast_bridge *self);
301

    
   
301

   
302
/*!
302
/*!
303
 * \brief Push this channel into the bridge.
303
 * \brief Push this channel into the bridge.
304
 *
304
 *
305
 * \param self Bridge to operate upon.
305
 * \param self Bridge to operate upon.
306
 * \param bridge_channel Bridge channel to push.
306
 * \param bridge_channel Bridge channel to push.
307
 * \param swap Bridge channel to swap places with if not NULL.
307
 * \param swap Bridge channel to swap places with if not NULL.
308
 *
308
 *
309
 * \details
309
 * \details
310
 * Setup any channel hooks controlled by the bridge.  Allocate
310
 * Setup any channel hooks controlled by the bridge.  Allocate
311
 * bridge_channel->bridge_pvt and initialize any resources put
311
 * bridge_channel->bridge_pvt and initialize any resources put
312
 * in bridge_channel->bridge_pvt if needed.  If there is a swap
312
 * in bridge_channel->bridge_pvt if needed.  If there is a swap
313
 * channel, use it as a guide to setting up the bridge_channel.
313
 * channel, use it as a guide to setting up the bridge_channel.
314
 *
314
 *
315
 * \note On entry, self is already locked.
315
 * \note On entry, self is already locked.
316
 *
316
 *
317
 * \retval 0 on success.
317
 * \retval 0 on success.
318
 * \retval -1 on failure.  The channel did not get pushed.
318
 * \retval -1 on failure.  The channel did not get pushed.
319
 */
319
 */
320
typedef int (*ast_bridge_push_channel_fn)(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap);
320
typedef int (*ast_bridge_push_channel_fn)(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap);
321

    
   
321

   
322
/*!
322
/*!
323
 * \brief Pull this channel from the bridge.
323
 * \brief Pull this channel from the bridge.
324
 *
324
 *
325
 * \param self Bridge to operate upon.
325
 * \param self Bridge to operate upon.
326
 * \param bridge_channel Bridge channel to pull.
326
 * \param bridge_channel Bridge channel to pull.
327
 *
327
 *
328
 * \details
328
 * \details
329
 * Remove any channel hooks controlled by the bridge.  Release
329
 * Remove any channel hooks controlled by the bridge.  Release
330
 * any resources held by bridge_channel->bridge_pvt and release
330
 * any resources held by bridge_channel->bridge_pvt and release
331
 * bridge_channel->bridge_pvt.
331
 * bridge_channel->bridge_pvt.
332
 *
332
 *
333
 * \note On entry, self is already locked.
333
 * \note On entry, self is already locked.
334
 *
334
 *
335
 * \return Nothing
335
 * \return Nothing
336
 */
336
 */
337
typedef void (*ast_bridge_pull_channel_fn)(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel);
337
typedef void (*ast_bridge_pull_channel_fn)(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel);
338

    
   
338

   
339
/*!
339
/*!
340
 * \brief Notify the bridge that this channel was just masqueraded.
340
 * \brief Notify the bridge that this channel was just masqueraded.
341
 *
341
 *
342
 * \param self Bridge to operate upon.
342
 * \param self Bridge to operate upon.
343
 * \param bridge_channel Bridge channel that was masqueraded.
343
 * \param bridge_channel Bridge channel that was masqueraded.
344
 *
344
 *
345
 * \details
345
 * \details
346
 * A masquerade just happened to this channel.  The bridge needs
346
 * A masquerade just happened to this channel.  The bridge needs
347
 * to re-evaluate this a channel in the bridge.
347
 * to re-evaluate this a channel in the bridge.
348
 *
348
 *
349
 * \note On entry, self is already locked.
349
 * \note On entry, self is already locked.
350
 *
350
 *
351
 * \return Nothing
351
 * \return Nothing
352
 */
352
 */
353
typedef void (*ast_bridge_notify_masquerade_fn)(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel);
353
typedef void (*ast_bridge_notify_masquerade_fn)(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel);
354

    
   
354

   
355
/*!
355
/*!
356
 * \brief Get the merge priority of this bridge.
356
 * \brief Get the merge priority of this bridge.
357
 *
357
 *
358
 * \param self Bridge to operate upon.
358
 * \param self Bridge to operate upon.
359
 *
359
 *
360
 * \note On entry, self is already locked.
360
 * \note On entry, self is already locked.
361
 *
361
 *
362
 * \return Merge priority
362
 * \return Merge priority
363
 */
363
 */
364
typedef int (*ast_bridge_merge_priority_fn)(struct ast_bridge *self);
364
typedef int (*ast_bridge_merge_priority_fn)(struct ast_bridge *self);
365

    
   
365

   
366
/*!
366
/*!
367
 * \brief Bridge virtual methods table definition.
367
 * \brief Bridge virtual methods table definition.
368
 *
368
 *
369
 * \note Any changes to this struct must be reflected in
369
 * \note Any changes to this struct must be reflected in
370
 * ast_bridge_alloc() validity checking.
370
 * ast_bridge_alloc() validity checking.
371
 */
371
 */
372
struct ast_bridge_methods {
372
struct ast_bridge_methods {
373
	/*! Bridge class name for log messages. */
373
	/*! Bridge class name for log messages. */
374
	const char *name;
374
	const char *name;
375
	/*! Destroy the bridge. */
375
	/*! Destroy the bridge. */
376
	ast_bridge_destructor_fn destroy;
376
	ast_bridge_destructor_fn destroy;
377
	/*! The bridge is being dissolved.  Remove any references to the bridge. */
377
	/*! The bridge is being dissolved.  Remove any references to the bridge. */
378
	ast_bridge_dissolving_fn dissolving;
378
	ast_bridge_dissolving_fn dissolving;
379
	/*! Push the bridge channel into the bridge. */
379
	/*! Push the bridge channel into the bridge. */
380
	ast_bridge_push_channel_fn push;
380
	ast_bridge_push_channel_fn push;
381
	/*! Pull the bridge channel from the bridge. */
381
	/*! Pull the bridge channel from the bridge. */
382
	ast_bridge_pull_channel_fn pull;
382
	ast_bridge_pull_channel_fn pull;
383
	/*! Notify the bridge of a masquerade with the channel. */
383
	/*! Notify the bridge of a masquerade with the channel. */
384
	ast_bridge_notify_masquerade_fn notify_masquerade;
384
	ast_bridge_notify_masquerade_fn notify_masquerade;
385
	/*! Get the bridge merge priority. */
385
	/*! Get the bridge merge priority. */
386
	ast_bridge_merge_priority_fn get_merge_priority;
386
	ast_bridge_merge_priority_fn get_merge_priority;
387
};
387
};
388

    
   
388

   
389
/*!
389
/*!
390
 * \brief Structure that contains information about a bridge
390
 * \brief Structure that contains information about a bridge
391
 */
391
 */
392
struct ast_bridge {
392
struct ast_bridge {
393
	/*! Bridge virtual method table. */
393
	/*! Bridge virtual method table. */
394
	const struct ast_bridge_methods *v_table;
394
	const struct ast_bridge_methods *v_table;
395
	/*! Immutable bridge UUID. */
395
	/*! Immutable bridge UUID. */
396
	char uniqueid[AST_UUID_STR_LEN];
396
	char uniqueid[AST_UUID_STR_LEN];
397
	/*! Bridge technology that is handling the bridge */
397
	/*! Bridge technology that is handling the bridge */
398
	struct ast_bridge_technology *technology;
398
	struct ast_bridge_technology *technology;
399
	/*! Private information unique to the bridge technology */
399
	/*! Private information unique to the bridge technology */
400
	void *tech_pvt;
400
	void *tech_pvt;
401
	/*! Call ID associated with the bridge */
401
	/*! Call ID associated with the bridge */
402
	struct ast_callid *callid;
402
	struct ast_callid *callid;
403
	/*! Linked list of channels participating in the bridge */
403
	/*! Linked list of channels participating in the bridge */
404
	AST_LIST_HEAD_NOLOCK(, ast_bridge_channel) channels;
404
	AST_LIST_HEAD_NOLOCK(, ast_bridge_channel) channels;
405
	/*! Queue of actions to perform on the bridge. */
405
	/*! Queue of actions to perform on the bridge. */
406
	AST_LIST_HEAD_NOLOCK(, ast_frame) action_queue;
406
	AST_LIST_HEAD_NOLOCK(, ast_frame) action_queue;
407
	/*! The video mode this bridge is using */
407
	/*! The video mode this bridge is using */
408
	struct ast_bridge_video_mode video_mode;
408
	struct ast_bridge_video_mode video_mode;
409
	/*! Bridge flags to tweak behavior */
409
	/*! Bridge flags to tweak behavior */
410
	struct ast_flags feature_flags;
410
	struct ast_flags feature_flags;
411
	/*! Allowed bridge technology capabilities when AST_BRIDGE_FLAG_SMART enabled. */
411
	/*! Allowed bridge technology capabilities when AST_BRIDGE_FLAG_SMART enabled. */
412
	uint32_t allowed_capabilities;
412
	uint32_t allowed_capabilities;
413
	/*! Number of channels participating in the bridge */
413
	/*! Number of channels participating in the bridge */
414
	unsigned int num_channels;
414
	unsigned int num_channels;
415
	/*! Number of active channels in the bridge. */
415
	/*! Number of active channels in the bridge. */
416
	unsigned int num_active;
416
	unsigned int num_active;
417
	/*!
417
	/*!
418
	 * \brief Count of the active temporary requests to inhibit bridge merges.
418
	 * \brief Count of the active temporary requests to inhibit bridge merges.
419
	 * Zero if merges are allowed.
419
	 * Zero if merges are allowed.
420
	 *
420
	 *
421
	 * \note Temporary as in try again in a moment.
421
	 * \note Temporary as in try again in a moment.
422
	 */
422
	 */
423
	unsigned int inhibit_merge;
423
	unsigned int inhibit_merge;
424
	/*! The internal sample rate this bridge is mixed at when multiple channels are being mixed.
424
	/*! The internal sample rate this bridge is mixed at when multiple channels are being mixed.
425
	 *  If this value is 0, the bridge technology may auto adjust the internal mixing rate. */
425
	 *  If this value is 0, the bridge technology may auto adjust the internal mixing rate. */
426
	unsigned int internal_sample_rate;
426
	unsigned int internal_sample_rate;
427
	/*! The mixing interval indicates how quickly the bridges internal mixing should occur
427
	/*! The mixing interval indicates how quickly the bridges internal mixing should occur
428
	 * for bridge technologies that mix audio. When set to 0, the bridge tech must choose a
428
	 * for bridge technologies that mix audio. When set to 0, the bridge tech must choose a
429
	 * default interval for itself. */
429
	 * default interval for itself. */
430
	unsigned int internal_mixing_interval;
430
	unsigned int internal_mixing_interval;
431
	/*! TRUE if the bridge was reconfigured. */
431
	/*! TRUE if the bridge was reconfigured. */
432
	unsigned int reconfigured:1;
432
	unsigned int reconfigured:1;
433
	/*! TRUE if the bridge has been dissolved.  Any channel that now tries to join is immediately ejected. */
433
	/*! TRUE if the bridge has been dissolved.  Any channel that now tries to join is immediately ejected. */
434
	unsigned int dissolved:1;
434
	unsigned int dissolved:1;
435
};
435
};
436

    
   
436

   
437
/*!
437
/*!
438
 * \brief Register the new bridge with the system.
438
 * \brief Register the new bridge with the system.
439
 * \since 12.0.0
439
 * \since 12.0.0
440
 *
440
 *
441
 * \param bridge What to register. (Tolerates a NULL pointer)
441
 * \param bridge What to register. (Tolerates a NULL pointer)
442
 *
442
 *
443
 * \code
443
 * \code
444
 * struct ast_bridge *ast_bridge_basic_new(uint32_t capabilities, int flags, uint32 dtmf_features)
444
 * struct ast_bridge *ast_bridge_basic_new(uint32_t capabilities, int flags, uint32 dtmf_features)
445
 * {
445
 * {
446
 *     void *bridge;
446
 *     void *bridge;
447
 *
447
 *
448
 *     bridge = ast_bridge_alloc(sizeof(struct ast_bridge_basic), &ast_bridge_basic_v_table);
448
 *     bridge = ast_bridge_alloc(sizeof(struct ast_bridge_basic), &ast_bridge_basic_v_table);
449
 *     bridge = ast_bridge_base_init(bridge, capabilities, flags);
449
 *     bridge = ast_bridge_base_init(bridge, capabilities, flags);
450
 *     bridge = ast_bridge_basic_init(bridge, dtmf_features);
450
 *     bridge = ast_bridge_basic_init(bridge, dtmf_features);
451
 *     bridge = ast_bridge_register(bridge);
451
 *     bridge = ast_bridge_register(bridge);
452
 *     return bridge;
452
 *     return bridge;
453
 * }
453
 * }
454
 * \endcode
454
 * \endcode
455
 *
455
 *
456
 * \note This must be done after a bridge constructor has
456
 * \note This must be done after a bridge constructor has
457
 * completed setting up the new bridge but before it returns.
457
 * completed setting up the new bridge but before it returns.
458
 *
458
 *
459
 * \note After a bridge is registered, ast_bridge_destroy() must
459
 * \note After a bridge is registered, ast_bridge_destroy() must
460
 * eventually be called to get rid of the bridge.
460
 * eventually be called to get rid of the bridge.
461
 *
461
 *
462
 * \retval bridge on success.
462
 * \retval bridge on success.
463
 * \retval NULL on error.
463
 * \retval NULL on error.
464
 */
464
 */
465
struct ast_bridge *ast_bridge_register(struct ast_bridge *bridge);
465
struct ast_bridge *ast_bridge_register(struct ast_bridge *bridge);
466

    
   
466

   
467
/*!
467
/*!
468
 * \internal
468
 * \internal
469
 * \brief Allocate the bridge class object memory.
469
 * \brief Allocate the bridge class object memory.
470
 * \since 12.0.0
470
 * \since 12.0.0
471
 *
471
 *
472
 * \param size Size of the bridge class structure to allocate.
472
 * \param size Size of the bridge class structure to allocate.
473
 * \param v_table Bridge class virtual method table.
473
 * \param v_table Bridge class virtual method table.
474
 *
474
 *
475
 * \retval bridge on success.
475
 * \retval bridge on success.
476
 * \retval NULL on error.
476
 * \retval NULL on error.
477
 */
477
 */
478
struct ast_bridge *ast_bridge_alloc(size_t size, const struct ast_bridge_methods *v_table);
478
struct ast_bridge *ast_bridge_alloc(size_t size, const struct ast_bridge_methods *v_table);
479

    
   
479

   
480
/*! \brief Bridge base class virtual method table. */
480
/*! \brief Bridge base class virtual method table. */
481
extern struct ast_bridge_methods ast_bridge_base_v_table;
481
extern struct ast_bridge_methods ast_bridge_base_v_table;
482

    
   
482

   
483
/*!
483
/*!
484
 * \brief Initialize the base class of the bridge.
484
 * \brief Initialize the base class of the bridge.
485
 *
485
 *
486
 * \param self Bridge to operate upon. (Tolerates a NULL pointer)
486
 * \param self Bridge to operate upon. (Tolerates a NULL pointer)
487
 * \param capabilities The capabilities that we require to be used on the bridge
487
 * \param capabilities The capabilities that we require to be used on the bridge
488
 * \param flags Flags that will alter the behavior of the bridge
488
 * \param flags Flags that will alter the behavior of the bridge
489
 *
489
 *
490
 * \retval self on success
490
 * \retval self on success
491
 * \retval NULL on failure, self is already destroyed
491
 * \retval NULL on failure, self is already destroyed
492
 *
492
 *
493
 * Example usage:
493
 * Example usage:
494
 *
494
 *
495
 * \code
495
 * \code
496
 * struct ast_bridge *bridge;
496
 * struct ast_bridge *bridge;
497
 * bridge = ast_bridge_alloc(sizeof(*bridge), &ast_bridge_base_v_table);
497
 * bridge = ast_bridge_alloc(sizeof(*bridge), &ast_bridge_base_v_table);
498
 * bridge = ast_bridge_base_init(bridge, AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_FLAG_DISSOLVE_HANGUP);
498
 * bridge = ast_bridge_base_init(bridge, AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_FLAG_DISSOLVE_HANGUP);
499
 * \endcode
499
 * \endcode
500
 *
500
 *
501
 * This creates a no frills two party bridge that will be
501
 * This creates a no frills two party bridge that will be
502
 * destroyed once one of the channels hangs up.
502
 * destroyed once one of the channels hangs up.
503
 */
503
 */
504
struct ast_bridge *ast_bridge_base_init(struct ast_bridge *self, uint32_t capabilities, unsigned int flags);
504
struct ast_bridge *ast_bridge_base_init(struct ast_bridge *self, uint32_t capabilities, unsigned int flags);
505

    
   
505

   
506
/*!
506
/*!
507
 * \brief Create a new base class bridge
507
 * \brief Create a new base class bridge
508
 *
508
 *
509
 * \param capabilities The capabilities that we require to be used on the bridge
509
 * \param capabilities The capabilities that we require to be used on the bridge
510
 * \param flags Flags that will alter the behavior of the bridge
510
 * \param flags Flags that will alter the behavior of the bridge
511
 *
511
 *
512
 * \retval a pointer to a new bridge on success
512
 * \retval a pointer to a new bridge on success
513
 * \retval NULL on failure
513
 * \retval NULL on failure
514
 *
514
 *
515
 * Example usage:
515
 * Example usage:
516
 *
516
 *
517
 * \code
517
 * \code
518
 * struct ast_bridge *bridge;
518
 * struct ast_bridge *bridge;
519
 * bridge = ast_bridge_base_new(AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_FLAG_DISSOLVE_HANGUP);
519
 * bridge = ast_bridge_base_new(AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_FLAG_DISSOLVE_HANGUP);
520
 * \endcode
520
 * \endcode
521
 *
521
 *
522
 * This creates a no frills two party bridge that will be
522
 * This creates a no frills two party bridge that will be
523
 * destroyed once one of the channels hangs up.
523
 * destroyed once one of the channels hangs up.
524
 */
524
 */
525
struct ast_bridge *ast_bridge_base_new(uint32_t capabilities, unsigned int flags);
525
struct ast_bridge *ast_bridge_base_new(uint32_t capabilities, unsigned int flags);
526

    
   
526

   
527
/*!
527
/*!
528
 * \brief Try locking the bridge.
528
 * \brief Try locking the bridge.
529
 *
529
 *
530
 * \param bridge Bridge to try locking
530
 * \param bridge Bridge to try locking
531
 *
531
 *
532
 * \retval 0 on success.
532
 * \retval 0 on success.
533
 * \retval non-zero on error.
533
 * \retval non-zero on error.
534
 */
534
 */
535
#define ast_bridge_trylock(bridge)	_ast_bridge_trylock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge)
535
#define ast_bridge_trylock(bridge)	_ast_bridge_trylock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge)
536
static inline int _ast_bridge_trylock(struct ast_bridge *bridge, const char *file, const char *function, int line, const char *var)
536
static inline int _ast_bridge_trylock(struct ast_bridge *bridge, const char *file, const char *function, int line, const char *var)
537
{
537
{
538
	return __ao2_trylock(bridge, AO2_LOCK_REQ_MUTEX, file, function, line, var);
538
	return __ao2_trylock(bridge, AO2_LOCK_REQ_MUTEX, file, function, line, var);
539
}
539
}
540

    
   
540

   
541
/*!
541
/*!
542
 * \brief Lock the bridge.
542
 * \brief Lock the bridge.
543
 *
543
 *
544
 * \param bridge Bridge to lock
544
 * \param bridge Bridge to lock
545
 *
545
 *
546
 * \return Nothing
546
 * \return Nothing
547
 */
547
 */
548
#define ast_bridge_lock(bridge)	_ast_bridge_lock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge)
548
#define ast_bridge_lock(bridge)	_ast_bridge_lock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge)
549
static inline void _ast_bridge_lock(struct ast_bridge *bridge, const char *file, const char *function, int line, const char *var)
549
static inline void _ast_bridge_lock(struct ast_bridge *bridge, const char *file, const char *function, int line, const char *var)
550
{
550
{
551
	__ao2_lock(bridge, AO2_LOCK_REQ_MUTEX, file, function, line, var);
551
	__ao2_lock(bridge, AO2_LOCK_REQ_MUTEX, file, function, line, var);
552
}
552
}
553

    
   
553

   
554
/*!
554
/*!
555
 * \brief Unlock the bridge.
555
 * \brief Unlock the bridge.
556
 *
556
 *
557
 * \param bridge Bridge to unlock
557
 * \param bridge Bridge to unlock
558
 *
558
 *
559
 * \return Nothing
559
 * \return Nothing
560
 */
560
 */
561
#define ast_bridge_unlock(bridge)	_ast_bridge_unlock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge)
561
#define ast_bridge_unlock(bridge)	_ast_bridge_unlock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge)
562
static inline void _ast_bridge_unlock(struct ast_bridge *bridge, const char *file, const char *function, int line, const char *var)
562
static inline void _ast_bridge_unlock(struct ast_bridge *bridge, const char *file, const char *function, int line, const char *var)
563
{
563
{
564
	__ao2_unlock(bridge, file, function, line, var);
564
	__ao2_unlock(bridge, file, function, line, var);
565
}
565
}
566

    
   
566

   
567
/*! \brief Lock two bridges. */
567
/*! \brief Lock two bridges. */
568
#define ast_bridge_lock_both(bridge1, bridge2)		\
568
#define ast_bridge_lock_both(bridge1, bridge2)		\
569
	do {											\
569
	do {											\
570
		for (;;) {									\
570
		for (;;) {									\
571
			ast_bridge_lock(bridge1);				\
571
			ast_bridge_lock(bridge1);				\
572
			if (!ast_bridge_trylock(bridge2)) {		\
572
			if (!ast_bridge_trylock(bridge2)) {		\
573
				break;								\
573
				break;								\
574
			}										\
574
			}										\
575
			ast_bridge_unlock(bridge1);				\
575
			ast_bridge_unlock(bridge1);				\
576
			sched_yield();							\
576
			sched_yield();							\
577
		}											\
577
		}											\
578
	} while (0)
578
	} while (0)
579

    
   
579

   
580
/*!
580
/*!
581
 * \brief Destroy a bridge
581
 * \brief Destroy a bridge
582
 *
582
 *
583
 * \param bridge Bridge to destroy
583
 * \param bridge Bridge to destroy
584
 *
584
 *
585
 * \retval 0 on success
585
 * \retval 0 on success
586
 * \retval -1 on failure
586
 * \retval -1 on failure
587
 *
587
 *
588
 * Example usage:
588
 * Example usage:
589
 *
589
 *
590
 * \code
590
 * \code
591
 * ast_bridge_destroy(bridge);
591
 * ast_bridge_destroy(bridge);
592
 * \endcode
592
 * \endcode
593
 *
593
 *
594
 * This destroys a bridge that was previously created.
594
 * This destroys a bridge that was previously created.
595
 */
595
 */
596
int ast_bridge_destroy(struct ast_bridge *bridge);
596
int ast_bridge_destroy(struct ast_bridge *bridge);
597

    
   
597

   
598
/*!
598
/*!
599
 * \brief Notify bridging that this channel was just masqueraded.
599
 * \brief Notify bridging that this channel was just masqueraded.
600
 * \since 12.0.0
600
 * \since 12.0.0
601
 *
601
 *
602
 * \param chan Channel just involved in a masquerade
602
 * \param chan Channel just involved in a masquerade
603
 *
603
 *
604
 * \return Nothing
604
 * \return Nothing
605
 */
605
 */
606
void ast_bridge_notify_masquerade(struct ast_channel *chan);
606
void ast_bridge_notify_masquerade(struct ast_channel *chan);
607

    
   
607

   
608
/*!
608
/*!
609
 * \brief Join (blocking) a channel to a bridge
609
 * \brief Join (blocking) a channel to a bridge
610
 *
610
 *
611
 * \param bridge Bridge to join
611
 * \param bridge Bridge to join
612
 * \param chan Channel to join
612
 * \param chan Channel to join
613
 * \param swap Channel to swap out if swapping
613
 * \param swap Channel to swap out if swapping
614
 * \param features Bridge features structure
614
 * \param features Bridge features structure
615
 * \param tech_args Optional Bridging tech optimization parameters for this channel.
615
 * \param tech_args Optional Bridging tech optimization parameters for this channel.
616
 * \param pass_reference TRUE if the bridge reference is being passed by the caller.
616
 * \param pass_reference TRUE if the bridge reference is being passed by the caller.
617
 *
617
 *
618
 * \retval state that channel exited the bridge with
618
 * \retval state that channel exited the bridge with
619
 *
619
 *
620
 * Example usage:
620
 * Example usage:
621
 *
621
 *
622
 * \code
622
 * \code
623
 * ast_bridge_join(bridge, chan, NULL, NULL, NULL, 0);
623
 * ast_bridge_join(bridge, chan, NULL, NULL, NULL, 0);
624
 * \endcode
624
 * \endcode
625
 *
625
 *
626
 * This adds a channel pointed to by the chan pointer to the bridge pointed to by
626
 * This adds a channel pointed to by the chan pointer to the bridge pointed to by
627
 * the bridge pointer. This function will not return until the channel has been
627
 * the bridge pointer. This function will not return until the channel has been
628
 * removed from the bridge, swapped out for another channel, or has hung up.
628
 * removed from the bridge, swapped out for another channel, or has hung up.
629
 *
629
 *
630
 * If this channel will be replacing another channel the other channel can be specified
630
 * If this channel will be replacing another channel the other channel can be specified
631
 * in the swap parameter. The other channel will be thrown out of the bridge in an
631
 * in the swap parameter. The other channel will be thrown out of the bridge in an
632
 * atomic fashion.
632
 * atomic fashion.
633
 *
633
 *
634
 * If channel specific features are enabled a pointer to the features structure
634
 * If channel specific features are enabled a pointer to the features structure
635
 * can be specified in the features parameter.
635
 * can be specified in the features parameter.
636
 */
636
 */
637
enum ast_bridge_channel_state ast_bridge_join(struct ast_bridge *bridge,
637
enum ast_bridge_channel_state ast_bridge_join(struct ast_bridge *bridge,
638
	struct ast_channel *chan,
638
	struct ast_channel *chan,
639
	struct ast_channel *swap,
639
	struct ast_channel *swap,
640
	struct ast_bridge_features *features,
640
	struct ast_bridge_features *features,
641
	struct ast_bridge_tech_optimizations *tech_args,
641
	struct ast_bridge_tech_optimizations *tech_args,
642
	int pass_reference);
642
	int pass_reference);
643

    
   
643

   
644
/*!
644
/*!
645
 * \brief Impart (non-blocking) a channel onto a bridge
645
 * \brief Impart (non-blocking) a channel onto a bridge
646
 *
646
 *
647
 * \param bridge Bridge to impart on
647
 * \param bridge Bridge to impart on
648
 * \param chan Channel to impart
648
 * \param chan Channel to impart
649
 * \param swap Channel to swap out if swapping.  NULL if not swapping.
649
 * \param swap Channel to swap out if swapping.  NULL if not swapping.
650
 * \param features Bridge features structure.
650
 * \param features Bridge features structure.
651
 * \param independent TRUE if caller does not want to reclaim the channel using ast_bridge_depart().
651
 * \param independent TRUE if caller does not want to reclaim the channel using ast_bridge_depart().
652
 *
652
 *
653
 * \note The features parameter must be NULL or obtained by
653
 * \note The features parameter must be NULL or obtained by
654
 * ast_bridge_features_new().  You must not dereference features
654
 * ast_bridge_features_new().  You must not dereference features
655
 * after calling even if the call fails.
655
 * after calling even if the call fails.
656
 *
656
 *
657
 * \retval 0 on success
657
 * \retval 0 on success
658
 * \retval -1 on failure
658
 * \retval -1 on failure
659
 *
659
 *
660
 * Example usage:
660
 * Example usage:
661
 *
661
 *
662
 * \code
662
 * \code
663
 * ast_bridge_impart(bridge, chan, NULL, NULL, 0);
663
 * ast_bridge_impart(bridge, chan, NULL, NULL, 0);
664
 * \endcode
664
 * \endcode
665
 *
665
 *
666
 * \details
666
 * \details
667
 * This adds a channel pointed to by the chan pointer to the
667
 * This adds a channel pointed to by the chan pointer to the
668
 * bridge pointed to by the bridge pointer.  This function will
668
 * bridge pointed to by the bridge pointer.  This function will
669
 * return immediately and will not wait until the channel is no
669
 * return immediately and will not wait until the channel is no
670
 * longer part of the bridge.
670
 * longer part of the bridge.
671
 *
671
 *
672
 * If this channel will be replacing another channel the other
672
 * If this channel will be replacing another channel the other
673
 * channel can be specified in the swap parameter.  The other
673
 * channel can be specified in the swap parameter.  The other
674
 * channel will be thrown out of the bridge in an atomic
674
 * channel will be thrown out of the bridge in an atomic
675
 * fashion.
675
 * fashion.
676
 *
676
 *
677
 * If channel specific features are enabled, a pointer to the
677
 * If channel specific features are enabled, a pointer to the
678
 * features structure can be specified in the features
678
 * features structure can be specified in the features
679
 * parameter.
679
 * parameter.
680
 *
680
 *
681
 * \note If you impart a channel as not independent you MUST
681
 * \note If you impart a channel as not independent you MUST
682
 * ast_bridge_depart() the channel.  The bridge channel thread
682
 * ast_bridge_depart() the channel.  The bridge channel thread
683
 * is created join-able.  The implication is that the channel is
683
 * is created join-able.  The implication is that the channel is
684
 * special and will not behave like a normal channel.
684
 * special and will not behave like a normal channel.
685
 *
685
 *
686
 * \note If you impart a channel as independent you must not
686
 * \note If you impart a channel as independent you must not
687
 * ast_bridge_depart() the channel.  The bridge channel thread
687
 * ast_bridge_depart() the channel.  The bridge channel thread
688
 * is created non-join-able.  The channel must be treated as if
688
 * is created non-join-able.  The channel must be treated as if
689
 * it were placed into the bridge by ast_bridge_join().
689
 * it were placed into the bridge by ast_bridge_join().
690
 * Channels placed into a bridge by ast_bridge_join() are
690
 * Channels placed into a bridge by ast_bridge_join() are
691
 * removed by a third party using ast_bridge_remove().
691
 * removed by a third party using ast_bridge_remove().
692
 */
692
 */
693
int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, int independent);
693
int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, int independent);
694

    
   
694

   
695
/*!
695
/*!
696
 * \brief Depart a channel from a bridge
696
 * \brief Depart a channel from a bridge
697
 *
697
 *
698
 * \param chan Channel to depart
698
 * \param chan Channel to depart
699
 *
699
 *
700
 * \retval 0 on success
700
 * \retval 0 on success
701
 * \retval -1 on failure
701
 * \retval -1 on failure
702
 *
702
 *
703
 * Example usage:
703
 * Example usage:
704
 *
704
 *
705
 * \code
705
 * \code
706
 * ast_bridge_depart(chan);
706
 * ast_bridge_depart(chan);
707
 * \endcode
707
 * \endcode
708
 *
708
 *
709
 * This removes the channel pointed to by the chan pointer from any bridge
709
 * This removes the channel pointed to by the chan pointer from any bridge
710
 * it may be in and gives control to the calling thread.
710
 * it may be in and gives control to the calling thread.
711
 * This does not hang up the channel.
711
 * This does not hang up the channel.
712
 *
712
 *
713
 * \note This API call can only be used on channels that were added to the bridge
713
 * \note This API call can only be used on channels that were added to the bridge
714
 *       using the ast_bridge_impart API call with the independent flag FALSE.
714
 *       using the ast_bridge_impart API call with the independent flag FALSE.
715
 */
715
 */
716
int ast_bridge_depart(struct ast_channel *chan);
716
int ast_bridge_depart(struct ast_channel *chan);
717

    
   
717

   
718
/*!
718
/*!
719
 * \brief Remove a channel from a bridge
719
 * \brief Remove a channel from a bridge
720
 *
720
 *
721
 * \param bridge Bridge that the channel is to be removed from
721
 * \param bridge Bridge that the channel is to be removed from
722
 * \param chan Channel to remove
722
 * \param chan Channel to remove
723
 *
723
 *
724
 * \retval 0 on success
724
 * \retval 0 on success
725
 * \retval -1 on failure
725
 * \retval -1 on failure
726
 *
726
 *
727
 * Example usage:
727
 * Example usage:
728
 *
728
 *
729
 * \code
729
 * \code
730
 * ast_bridge_remove(bridge, chan);
730
 * ast_bridge_remove(bridge, chan);
731
 * \endcode
731
 * \endcode
732
 *
732
 *
733
 * This removes the channel pointed to by the chan pointer from the bridge
733
 * This removes the channel pointed to by the chan pointer from the bridge
734
 * pointed to by the bridge pointer and requests that it be hung up. Control
734
 * pointed to by the bridge pointer and requests that it be hung up. Control
735
 * over the channel will NOT be given to the calling thread.
735
 * over the channel will NOT be given to the calling thread.
736
 *
736
 *
737
 * \note This API call can be used on channels that were added to the bridge
737
 * \note This API call can be used on channels that were added to the bridge
738
 *       using both ast_bridge_join and ast_bridge_impart.
738
 *       using both ast_bridge_join and ast_bridge_impart.
739
 */
739
 */
740
int ast_bridge_remove(struct ast_bridge *bridge, struct ast_channel *chan);
740
int ast_bridge_remove(struct ast_bridge *bridge, struct ast_channel *chan);
741

    
   
741

   
742
/*!
742
/*!
743
 * \brief Merge two bridges together
743
 * \brief Merge two bridges together
744
 *
744
 *
745
 * \param dst_bridge Destination bridge of merge.
745
 * \param dst_bridge Destination bridge of merge.
746
 * \param src_bridge Source bridge of merge.
746
 * \param src_bridge Source bridge of merge.
747
 * \param merge_best_direction TRUE if don't care about which bridge merges into the other.
747
 * \param merge_best_direction TRUE if don't care about which bridge merges into the other.
748
 * \param kick_me Array of channels to kick from the bridges.
748
 * \param kick_me Array of channels to kick from the bridges.
749
 * \param num_kick Number of channels in the kick_me array.
749
 * \param num_kick Number of channels in the kick_me array.
750
 *
750
 *
751
 * \retval 0 on success
751
 * \retval 0 on success
752
 * \retval -1 on failure
752
 * \retval -1 on failure
753
 *
753
 *
754
 * Example usage:
754
 * Example usage:
755
 *
755
 *
756
 * \code
756
 * \code
757
 * ast_bridge_merge(dst_bridge, src_bridge, 0, NULL, 0);
757
 * ast_bridge_merge(dst_bridge, src_bridge, 0, NULL, 0);
758
 * \endcode
758
 * \endcode
759
 *
759
 *
760
 * This moves the channels in src_bridge into the bridge pointed
760
 * This moves the channels in src_bridge into the bridge pointed
761
 * to by dst_bridge.
761
 * to by dst_bridge.
762
 */
762
 */
763
int ast_bridge_merge(struct ast_bridge *dst_bridge, struct ast_bridge *src_bridge, int merge_best_direction, struct ast_channel **kick_me, unsigned int num_kick);
763
int ast_bridge_merge(struct ast_bridge *dst_bridge, struct ast_bridge *src_bridge, int merge_best_direction, struct ast_channel **kick_me, unsigned int num_kick);
764

    
   
764

   
765
/*!
765
/*!
766
 * \brief Move a channel from one bridge to another.
766
 * \brief Move a channel from one bridge to another.
767
 * \since 12.0.0
767
 * \since 12.0.0
768
 *
768
 *
769
 * \param dst_bridge Destination bridge of bridge channel move.
769
 * \param dst_bridge Destination bridge of bridge channel move.
770
 * \param src_bridge Source bridge of bridge channel move.
770
 * \param src_bridge Source bridge of bridge channel move.
771
 * \param chan Channel to move.
771
 * \param chan Channel to move.
772
 * \param swap Channel to replace in dst_bridge.
772
 * \param swap Channel to replace in dst_bridge.
773
 * \param attempt_recovery TRUE if failure attempts to push channel back into original bridge.
773
 * \param attempt_recovery TRUE if failure attempts to push channel back into original bridge.
774
 *
774
 *
775
 * \retval 0 on success.
775
 * \retval 0 on success.
776
 * \retval -1 on failure.
776
 * \retval -1 on failure.
777
 */
777
 */
778
int ast_bridge_move(struct ast_bridge *dst_bridge, struct ast_bridge *src_bridge, struct ast_channel *chan, struct ast_channel *swap, int attempt_recovery);
778
int ast_bridge_move(struct ast_bridge *dst_bridge, struct ast_bridge *src_bridge, struct ast_channel *chan, struct ast_channel *swap, int attempt_recovery);
779

    
   
779

   
780
/*!
780
/*!
781
 * \brief Adjust the bridge merge inhibit request count.
781
 * \brief Adjust the bridge merge inhibit request count.
782
 * \since 12.0.0
782
 * \since 12.0.0
783
 *
783
 *
784
 * \param bridge What to operate on.
784
 * \param bridge What to operate on.
785
 * \param request Inhibit request increment.
785
 * \param request Inhibit request increment.
786
 *     (Positive to add requests.  Negative to remove requests.)
786
 *     (Positive to add requests.  Negative to remove requests.)
787
 *
787
 *
788
 * \return Nothing
788
 * \return Nothing
789
 */
789
 */
790
void ast_bridge_merge_inhibit(struct ast_bridge *bridge, int request);
790
void ast_bridge_merge_inhibit(struct ast_bridge *bridge, int request);
791

    
   
791

   
792
/*!
792
/*!
793
 * \brief Adjust the bridge_channel's bridge merge inhibit request count.
793
 * \brief Adjust the bridge_channel's bridge merge inhibit request count.
794
 * \since 12.0.0
794
 * \since 12.0.0
795
 *
795
 *
796
 * \param bridge_channel What to operate on.
796
 * \param bridge_channel What to operate on.
797
 * \param request Inhibit request increment.
797
 * \param request Inhibit request increment.
798
 *     (Positive to add requests.  Negative to remove requests.)
798
 *     (Positive to add requests.  Negative to remove requests.)
799
 *
799
 *
800
 * \note This API call is meant for internal bridging operations.
800
 * \note This API call is meant for internal bridging operations.
801
 *
801
 *
802
 * \retval bridge adjusted merge inhibit with reference count.
802
 * \retval bridge adjusted merge inhibit with reference count.
803
 */
803
 */
804
struct ast_bridge *ast_bridge_channel_merge_inhibit(struct ast_bridge_channel *bridge_channel, int request);
804
struct ast_bridge *ast_bridge_channel_merge_inhibit(struct ast_bridge_channel *bridge_channel, int request);
805

    
   
805

   
806
/*!
806
/*!
807
 * \brief Suspend a channel temporarily from a bridge
807
 * \brief Suspend a channel temporarily from a bridge
808
 *
808
 *
809
 * \param bridge Bridge to suspend the channel from
809
 * \param bridge Bridge to suspend the channel from
810
 * \param chan Channel to suspend
810
 * \param chan Channel to suspend
811
 *
811
 *
812
 * \retval 0 on success
812
 * \retval 0 on success
813
 * \retval -1 on failure
813
 * \retval -1 on failure
814
 *
814
 *
815
 * Example usage:
815
 * Example usage:
816
 *
816
 *
817
 * \code
817
 * \code
818
 * ast_bridge_suspend(bridge, chan);
818
 * ast_bridge_suspend(bridge, chan);
819
 * \endcode
819
 * \endcode
820
 *
820
 *
821
 * This suspends the channel pointed to by chan from the bridge pointed to by bridge temporarily.
821
 * This suspends the channel pointed to by chan from the bridge pointed to by bridge temporarily.
822
 * Control of the channel is given to the calling thread. This differs from ast_bridge_depart as
822
 * Control of the channel is given to the calling thread. This differs from ast_bridge_depart as
823
 * the channel will not be removed from the bridge.
823
 * the channel will not be removed from the bridge.
824
 *
824
 *
825
 * \note This API call can be used on channels that were added to the bridge
825
 * \note This API call can be used on channels that were added to the bridge
826
 *       using both ast_bridge_join and ast_bridge_impart.
826
 *       using both ast_bridge_join and ast_bridge_impart.
827
 */
827
 */
828
int ast_bridge_suspend(struct ast_bridge *bridge, struct ast_channel *chan);
828
int ast_bridge_suspend(struct ast_bridge *bridge, struct ast_channel *chan);
829

    
   
829

   
830
/*!
830
/*!
831
 * \brief Unsuspend a channel from a bridge
831
 * \brief Unsuspend a channel from a bridge
832
 *
832
 *
833
 * \param bridge Bridge to unsuspend the channel from
833
 * \param bridge Bridge to unsuspend the channel from
834
 * \param chan Channel to unsuspend
834
 * \param chan Channel to unsuspend
835
 *
835
 *
836
 * \retval 0 on success
836
 * \retval 0 on success
837
 * \retval -1 on failure
837
 * \retval -1 on failure
838
 *
838
 *
839
 * Example usage:
839
 * Example usage:
840
 *
840
 *
841
 * \code
841
 * \code
842
 * ast_bridge_unsuspend(bridge, chan);
842
 * ast_bridge_unsuspend(bridge, chan);
843
 * \endcode
843
 * \endcode
844
 *
844
 *
845
 * This unsuspends the channel pointed to by chan from the bridge pointed to by bridge.
845
 * This unsuspends the channel pointed to by chan from the bridge pointed to by bridge.
846
 * The bridge will go back to handling the channel once this function returns.
846
 * The bridge will go back to handling the channel once this function returns.
847
 *
847
 *
848
 * \note You must not mess with the channel once this function returns.
848
 * \note You must not mess with the channel once this function returns.
849
 *       Doing so may result in bad things happening.
849
 *       Doing so may result in bad things happening.
850
 */
850
 */
851
int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan);
851
int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan);
852

    
   
852

   
853
/*!
853
/*!
854
 * \brief Check and optimize out the unreal channels between bridges.
854
 * \brief Check and optimize out the unreal channels between bridges.
855
 * \since 12.0.0
855
 * \since 12.0.0
856
 *
856
 *
857
 * \param chan Unreal channel writing a frame into the channel driver.
857
 * \param chan Unreal channel writing a frame into the channel driver.
858
 * \param peer Other unreal channel in the pair.
858
 * \param peer Other unreal channel in the pair.
859
 *
859
 *
860
 * \note It is assumed that chan is already locked.
860
 * \note It is assumed that chan is already locked.
861
 *
861
 *
862
 * \retval 0 if unreal channels were not optimized out.
862
 * \retval 0 if unreal channels were not optimized out.
863
 * \retval non-zero if unreal channels were optimized out.
863
 * \retval non-zero if unreal channels were optimized out.
864
 */
864
 */
865
int ast_bridge_unreal_optimized_out(struct ast_channel *chan, struct ast_channel *peer);
865
int ast_bridge_unreal_optimized_out(struct ast_channel *chan, struct ast_channel *peer);
866

    
   
866

   
867
/*!
867
/*!
868
 * \brief Try locking the bridge_channel.
868
 * \brief Try locking the bridge_channel.
869
 *
869
 *
870
 * \param bridge_channel What to try locking
870
 * \param bridge_channel What to try locking
871
 *
871
 *
872
 * \retval 0 on success.
872
 * \retval 0 on success.
873
 * \retval non-zero on error.
873
 * \retval non-zero on error.
874
 */
874
 */
875
#define ast_bridge_channel_trylock(bridge_channel)	_ast_bridge_channel_trylock(bridge_channel, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge_channel)
875
#define ast_bridge_channel_trylock(bridge_channel)	_ast_bridge_channel_trylock(bridge_channel, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge_channel)
876
static inline int _ast_bridge_channel_trylock(struct ast_bridge_channel *bridge_channel, const char *file, const char *function, int line, const char *var)
876
static inline int _ast_bridge_channel_trylock(struct ast_bridge_channel *bridge_channel, const char *file, const char *function, int line, const char *var)
877
{
877
{
878
	return __ao2_trylock(bridge_channel, AO2_LOCK_REQ_MUTEX, file, function, line, var);
878
	return __ao2_trylock(bridge_channel, AO2_LOCK_REQ_MUTEX, file, function, line, var);
879
}
879
}
880

    
   
880

   
881
/*!
881
/*!
882
 * \brief Lock the bridge_channel.
882
 * \brief Lock the bridge_channel.
883
 *
883
 *
884
 * \param bridge_channel What to lock
884
 * \param bridge_channel What to lock
885
 *
885
 *
886
 * \return Nothing
886
 * \return Nothing
887
 */
887
 */
888
#define ast_bridge_channel_lock(bridge_channel)	_ast_bridge_channel_lock(bridge_channel, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge_channel)
888
#define ast_bridge_channel_lock(bridge_channel)	_ast_bridge_channel_lock(bridge_channel, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge_channel)
889
static inline void _ast_bridge_channel_lock(struct ast_bridge_channel *bridge_channel, const char *file, const char *function, int line, const char *var)
889
static inline void _ast_bridge_channel_lock(struct ast_bridge_channel *bridge_channel, const char *file, const char *function, int line, const char *var)
890
{
890
{
891
	__ao2_lock(bridge_channel, AO2_LOCK_REQ_MUTEX, file, function, line, var);
891
	__ao2_lock(bridge_channel, AO2_LOCK_REQ_MUTEX, file, function, line, var);
892
}
892
}
893

    
   
893

   
894
/*!
894
/*!
895
 * \brief Unlock the bridge_channel.
895
 * \brief Unlock the bridge_channel.
896
 *
896
 *
897
 * \param bridge_channel What to unlock
897
 * \param bridge_channel What to unlock
898
 *
898
 *
899
 * \return Nothing
899
 * \return Nothing
900
 */
900
 */
901
#define ast_bridge_channel_unlock(bridge_channel)	_ast_bridge_channel_unlock(bridge_channel, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge_channel)
901
#define ast_bridge_channel_unlock(bridge_channel)	_ast_bridge_channel_unlock(bridge_channel, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge_channel)
902
static inline void _ast_bridge_channel_unlock(struct ast_bridge_channel *bridge_channel, const char *file, const char *function, int line, const char *var)
902
static inline void _ast_bridge_channel_unlock(struct ast_bridge_channel *bridge_channel, const char *file, const char *function, int line, const char *var)
903
{
903
{
904
	__ao2_unlock(bridge_channel, file, function, line, var);
904
	__ao2_unlock(bridge_channel, file, function, line, var);
905
}
905
}
906

    
   
906

   
907
/*!
907
/*!
908
 * \brief Lock the bridge associated with the bridge channel.
908
 * \brief Lock the bridge associated with the bridge channel.
909
 * \since 12.0.0
909
 * \since 12.0.0
910
 *
910
 *
911
 * \param bridge_channel Channel that wants to lock the bridge.
911
 * \param bridge_channel Channel that wants to lock the bridge.
912
 *
912
 *
913
 * \details
913
 * \details
914
 * This is an upstream lock operation.  The defined locking
914
 * This is an upstream lock operation.  The defined locking
915
 * order is bridge then bridge_channel.
915
 * order is bridge then bridge_channel.
916
 *
916
 *
917
 * \note On entry, neither the bridge nor bridge_channel is locked.
917
 * \note On entry, neither the bridge nor bridge_channel is locked.
918
 *
918
 *
919
 * \note The bridge_channel->bridge pointer changes because of a
919
 * \note The bridge_channel->bridge pointer changes because of a
920
 * bridge-merge/channel-move operation between bridges.
920
 * bridge-merge/channel-move operation between bridges.
921
 *
921
 *
922
 * \return Nothing
922
 * \return Nothing
923
 */
923
 */
924
void ast_bridge_channel_lock_bridge(struct ast_bridge_channel *bridge_channel);
924
void ast_bridge_channel_lock_bridge(struct ast_bridge_channel *bridge_channel);
925

    
   
925

   
926
/*!
926
/*!
927
 * \brief Set bridge channel state to leave bridge (if not leaving already) with no lock.
927
 * \brief Set bridge channel state to leave bridge (if not leaving already) with no lock.
928
 *
928
 *
929
 * \param bridge_channel Channel to change the state on
929
 * \param bridge_channel Channel to change the state on
930
 * \param new_state The new state to place the channel into
930
 * \param new_state The new state to place the channel into
931
 *
931
 *
932
 * \note This API call is only meant to be used within the
932
 * \note This API call is only meant to be used within the
933
 * bridging module and hook callbacks to request the channel
933
 * bridging module and hook callbacks to request the channel
934
 * exit the bridge.
934
 * exit the bridge.
935
 *
935
 *
936
 * \note This function assumes the bridge_channel is locked.
936
 * \note This function assumes the bridge_channel is locked.
937
 */
937
 */
938
void ast_bridge_change_state_nolock(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
938
void ast_bridge_change_state_nolock(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
939

    
   
939

   
940
/*!
940
/*!
941
 * \brief Set bridge channel state to leave bridge (if not leaving already).
941
 * \brief Set bridge channel state to leave bridge (if not leaving already).
942
 *
942
 *
943
 * \param bridge_channel Channel to change the state on
943
 * \param bridge_channel Channel to change the state on
944
 * \param new_state The new state to place the channel into
944
 * \param new_state The new state to place the channel into
945
 *
945
 *
946
 * Example usage:
946
 * Example usage:
947
 *
947
 *
948
 * \code
948
 * \code
949
 * ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
949
 * ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
950
 * \endcode
950
 * \endcode
951
 *
951
 *
952
 * This places the channel pointed to by bridge_channel into the
952
 * This places the channel pointed to by bridge_channel into the
953
 * state AST_BRIDGE_CHANNEL_STATE_HANGUP if it was
953
 * state AST_BRIDGE_CHANNEL_STATE_HANGUP if it was
954
 * AST_BRIDGE_CHANNEL_STATE_WAIT before.
954
 * AST_BRIDGE_CHANNEL_STATE_WAIT before.
955
 *
955
 *
956
 * \note This API call is only meant to be used within the
956
 * \note This API call is only meant to be used within the
957
 * bridging module and hook callbacks to request the channel
957
 * bridging module and hook callbacks to request the channel
958
 * exit the bridge.
958
 * exit the bridge.
959
 */
959
 */
960
void ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
960
void ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
961

    
   
961

   
962
/*!
962
/*!
963
 * \brief Put an action onto the specified bridge.
963
 * \brief Put an action onto the specified bridge.
964
 * \since 12.0.0
964
 * \since 12.0.0
965
 *
965
 *
966
 * \param bridge What to queue the action on.
966
 * \param bridge What to queue the action on.
967
 * \param action What to do.
967
 * \param action What to do.
968
 *
968
 *
969
 * \retval 0 on success.
969
 * \retval 0 on success.
970
 * \retval -1 on error.
970
 * \retval -1 on error.
971
 *
971
 *
972
 * \note This API call is meant for internal bridging operations.
972
 * \note This API call is meant for internal bridging operations.
973
 * \note BUGBUG This may get moved.
973
 * \note BUGBUG This may get moved.
974
 */
974
 */
975
int ast_bridge_queue_action(struct ast_bridge *bridge, struct ast_frame *action);
975
int ast_bridge_queue_action(struct ast_bridge *bridge, struct ast_frame *action);
976

    
   
976

   
977
/*!
977
/*!
978
 * \brief Write a frame to the specified bridge_channel.
978
 * \brief Write a frame to the specified bridge_channel.
979
 * \since 12.0.0
979
 * \since 12.0.0
980
 *
980
 *
981
 * \param bridge_channel Channel to queue the frame.
981
 * \param bridge_channel Channel to queue the frame.
982
 * \param fr Frame to write.
982
 * \param fr Frame to write.
983
 *
983
 *
984
 * \retval 0 on success.
984
 * \retval 0 on success.
985
 * \retval -1 on error.
985
 * \retval -1 on error.
986
 *
986
 *
987
 * \note This API call is meant for internal bridging operations.
987
 * \note This API call is meant for internal bridging operations.
988
 * \note BUGBUG This may get moved.
988
 * \note BUGBUG This may get moved.
989
 */
989
 */
990
int ast_bridge_channel_queue_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *fr);
990
int ast_bridge_channel_queue_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *fr);
991

    
   
991

   
992
/*!
992
/*!
993
 * \brief Used to queue an action frame onto a bridge channel and write an action frame into a bridge.
993
 * \brief Used to queue an action frame onto a bridge channel and write an action frame into a bridge.
994
 * \since 12.0.0
994
 * \since 12.0.0
995
 *
995
 *
996
 * \param bridge_channel Which channel work with.
996
 * \param bridge_channel Which channel work with.
997
 * \param action Type of bridge action frame.
997
 * \param action Type of bridge action frame.
998
 * \param data Frame payload data to pass.
998
 * \param data Frame payload data to pass.
999
 * \param datalen Frame payload data length to pass.
999
 * \param datalen Frame payload data length to pass.
1000
 *
1000
 *
1001
 * \return Nothing
1001
 * \return Nothing
1002
 */
1002
 */
1003
typedef void (*ast_bridge_channel_post_action_data)(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
1003
typedef void (*ast_bridge_channel_post_action_data)(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
1004

    
   
1004

   
1005
/*!
1005
/*!
1006
 * \brief Queue an action frame onto the bridge channel with data.
1006
 * \brief Queue an action frame onto the bridge channel with data.
1007
 * \since 12.0.0
1007
 * \since 12.0.0
1008
 *
1008
 *
1009
 * \param bridge_channel Which channel to queue the frame onto.
1009
 * \param bridge_channel Which channel to queue the frame onto.
1010
 * \param action Type of bridge action frame.
1010
 * \param action Type of bridge action frame.
1011
 * \param data Frame payload data to pass.
1011
 * \param data Frame payload data to pass.
1012
 * \param datalen Frame payload data length to pass.
1012
 * \param datalen Frame payload data length to pass.
1013
 *
1013
 *
1014
 * \return Nothing
1014
 * \return Nothing
1015
 */
1015
 */
1016
void ast_bridge_channel_queue_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
1016
void ast_bridge_channel_queue_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
1017

    
   
1017

   
1018
/*!
1018
/*!
1019
 * \brief Write an action frame into the bridge with data.
1019
 * \brief Write an action frame into the bridge with data.
1020
 * \since 12.0.0
1020
 * \since 12.0.0
1021
 *
1021
 *
1022
 * \param bridge_channel Which channel is putting the frame into the bridge.
1022
 * \param bridge_channel Which channel is putting the frame into the bridge.
1023
 * \param action Type of bridge action frame.
1023
 * \param action Type of bridge action frame.
1024
 * \param data Frame payload data to pass.
1024
 * \param data Frame payload data to pass.
1025
 * \param datalen Frame payload data length to pass.
1025
 * \param datalen Frame payload data length to pass.
1026
 *
1026
 *
1027
 * \return Nothing
1027
 * \return Nothing
1028
 */
1028
 */
1029
void ast_bridge_channel_write_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
1029
void ast_bridge_channel_write_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
1030

    
   
1030

   
1031
/*!
1031
/*!
1032
 * \brief Queue a control frame onto the bridge channel with data.
1032
 * \brief Queue a control frame onto the bridge channel with data.
1033
 * \since 12.0.0
1033
 * \since 12.0.0
1034
 *
1034
 *
1035
 * \param bridge_channel Which channel to queue the frame onto.
1035
 * \param bridge_channel Which channel to queue the frame onto.
1036
 * \param control Type of control frame.
1036
 * \param control Type of control frame.
1037
 * \param data Frame payload data to pass.
1037
 * \param data Frame payload data to pass.
1038
 * \param datalen Frame payload data length to pass.
1038
 * \param datalen Frame payload data length to pass.
1039
 *
1039
 *
1040
 * \return Nothing
1040
 * \return Nothing
1041
 */
1041
 */
1042
void ast_bridge_channel_queue_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen);
1042
void ast_bridge_channel_queue_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen);
1043

    
   
1043

   
1044
/*!
1044
/*!
1045
 * \brief Write a control frame into the bridge with data.
1045
 * \brief Write a control frame into the bridge with data.
1046
 * \since 12.0.0
1046
 * \since 12.0.0
1047
 *
1047
 *
1048
 * \param bridge_channel Which channel is putting the frame into the bridge.
1048
 * \param bridge_channel Which channel is putting the frame into the bridge.
1049
 * \param control Type of control frame.
1049
 * \param control Type of control frame.
1050
 * \param data Frame payload data to pass.
1050
 * \param data Frame payload data to pass.
1051
 * \param datalen Frame payload data length to pass.
1051
 * \param datalen Frame payload data length to pass.
1052
 *
1052
 *
1053
 * \return Nothing
1053
 * \return Nothing
1054
 */
1054
 */
1055
void ast_bridge_channel_write_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen);
1055
void ast_bridge_channel_write_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen);
1056

    
   
1056

   
1057
/*!
1057
/*!
1058
 * \brief Run an application on the bridge channel.
1058
 * \brief Run an application on the bridge channel.
1059
 * \since 12.0.0
1059
 * \since 12.0.0
1060
 *
1060
 *
1061
 * \param bridge_channel Which channel to run the application on.
1061
 * \param bridge_channel Which channel to run the application on.
1062
 * \param app_name Dialplan application name.
1062
 * \param app_name Dialplan application name.
1063
 * \param app_args Arguments for the application. (NULL tolerant)
1063
 * \param app_args Arguments for the application. (NULL tolerant)
1064
 * \param moh_class MOH class to request bridge peers to hear while application is running.
1064
 * \param moh_class MOH class to request bridge peers to hear while application is running.
1065
 *     NULL if no MOH.
1065
 *     NULL if no MOH.
1066
 *     Empty if default MOH class.
1066
 *     Empty if default MOH class.
1067
 *
1067
 *
1068
 * \note This is intended to be called by bridge hooks.
1068
 * \note This is intended to be called by bridge hooks.
1069
 *
1069
 *
1070
 * \return Nothing
1070
 * \return Nothing
1071
 */
1071
 */
1072
void ast_bridge_channel_run_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class);
1072
void ast_bridge_channel_run_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class);
1073

    
   
1073

   
1074
/*!
1074
/*!
1075
 * \brief Write a bridge action run application frame into the bridge.
1075
 * \brief Write a bridge action run application frame into the bridge.
1076
 * \since 12.0.0
1076
 * \since 12.0.0
1077
 *
1077
 *
1078
 * \param bridge_channel Which channel is putting the frame into the bridge
1078
 * \param bridge_channel Which channel is putting the frame into the bridge
1079
 * \param app_name Dialplan application name.
1079
 * \param app_name Dialplan application name.
1080
 * \param app_args Arguments for the application. (NULL or empty for no arguments)
1080
 * \param app_args Arguments for the application. (NULL or empty for no arguments)
1081
 * \param moh_class MOH class to request bridge peers to hear while application is running.
1081
 * \param moh_class MOH class to request bridge peers to hear while application is running.
1082
 *     NULL if no MOH.
1082
 *     NULL if no MOH.
1083
 *     Empty if default MOH class.
1083
 *     Empty if default MOH class.
1084
 *
1084
 *
1085
 * \note This is intended to be called by bridge hooks.
1085
 * \note This is intended to be called by bridge hooks.
1086
 *
1086
 *
1087
 * \return Nothing
1087
 * \return Nothing
1088
 */
1088
 */
1089
void ast_bridge_channel_write_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class);
1089
void ast_bridge_channel_write_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class);
1090

    
   
1090

   
1091
/*!
1091
/*!
1092
 * \brief Queue a bridge action run application frame onto the bridge channel.
1092
 * \brief Queue a bridge action run application frame onto the bridge channel.
1093
 * \since 12.0.0
1093
 * \since 12.0.0
1094
 *
1094
 *
1095
 * \param bridge_channel Which channel to put the frame onto
1095
 * \param bridge_channel Which channel to put the frame onto
1096
 * \param app_name Dialplan application name.
1096
 * \param app_name Dialplan application name.
1097
 * \param app_args Arguments for the application. (NULL or empty for no arguments)
1097
 * \param app_args Arguments for the application. (NULL or empty for no arguments)
1098
 * \param moh_class MOH class to request bridge peers to hear while application is running.
1098
 * \param moh_class MOH class to request bridge peers to hear while application is running.
1099
 *     NULL if no MOH.
1099
 *     NULL if no MOH.
1100
 *     Empty if default MOH class.
1100
 *     Empty if default MOH class.
1101
 *
1101
 *
1102
 * \note This is intended to be called by bridge hooks.
1102
 * \note This is intended to be called by bridge hooks.
1103
 *
1103
 *
1104
 * \return Nothing
1104
 * \return Nothing
1105
 */
1105
 */
1106
void ast_bridge_channel_queue_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class);
1106
void ast_bridge_channel_queue_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class);
1107

    
   
1107

   
1108
/*!
1108
/*!
1109
 * \brief Custom interpretation of the playfile name.
1109
 * \brief Custom interpretation of the playfile name.
1110
 *
1110
 *
1111
 * \param bridge_channel Which channel to play the file on
1111
 * \param bridge_channel Which channel to play the file on
1112
 * \param playfile Sound filename to play.
1112
 * \param playfile Sound filename to play.
1113
 *
1113
 *
1114
 * \return Nothing
1114
 * \return Nothing
1115
 */
1115
 */
1116
typedef void (*ast_bridge_custom_play_fn)(struct ast_bridge_channel *bridge_channel, const char *playfile);
1116
typedef void (*ast_bridge_custom_play_fn)(struct ast_bridge_channel *bridge_channel, const char *playfile);
1117

    
   
1117

   
1118
/*!
1118
/*!
1119
 * \brief Play a file on the bridge channel.
1119
 * \brief Play a file on the bridge channel.
1120
 * \since 12.0.0
1120
 * \since 12.0.0
1121
 *
1121
 *
1122
 * \param bridge_channel Which channel to play the file on
1122
 * \param bridge_channel Which channel to play the file on
1123
 * \param custom_play Call this function to play the playfile. (NULL if normal sound file to play)
1123
 * \param custom_play Call this function to play the playfile. (NULL if normal sound file to play)
1124
 * \param playfile Sound filename to play.
1124
 * \param playfile Sound filename to play.
1125
 * \param moh_class MOH class to request bridge peers to hear while file is played.
1125
 * \param moh_class MOH class to request bridge peers to hear while file is played.
1126
 *     NULL if no MOH.
1126
 *     NULL if no MOH.
1127
 *     Empty if default MOH class.
1127
 *     Empty if default MOH class.
1128
 *
1128
 *
1129
 * \note This is intended to be called by bridge hooks.
1129
 * \note This is intended to be called by bridge hooks.
1130
 *
1130
 *
1131
 * \return Nothing
1131
 * \return Nothing
1132
 */
1132
 */
1133
void ast_bridge_channel_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class);
1133
void ast_bridge_channel_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class);
1134

    
   
1134

   
1135
/*!
1135
/*!
1136
 * \brief Have a bridge channel park a channel in the bridge
1136
 * \brief Have a bridge channel park a channel in the bridge
1137
 * \since 12.0.0
1137
 * \since 12.0.0
1138
 *
1138
 *
1139
 * \param bridge_channel Bridge channel performing the parking
1139
 * \param bridge_channel Bridge channel performing the parking
1140
 * \param parkee_uuid Unique id of the channel we want to park
1140
 * \param parkee_uuid Unique id of the channel we want to park
1141
 * \param parker_uuid Unique id of the channel parking the call
1141
 * \param parker_uuid Unique id of the channel parking the call
1142
 * \param app_data string indicating data used for park application (NULL allowed)
1142
 * \param app_data string indicating data used for park application (NULL allowed)
1143
 *
1143
 *
1144
 * \note This is intended to be called by bridge hooks.
1144
 * \note This is intended to be called by bridge hooks.
1145
 *
1145
 *
1146
 * \return Nothing
1146
 * \return Nothing
1147
 */
1147
 */
1148
void ast_bridge_channel_write_park(struct ast_bridge_channel *bridge_channel, const char *parkee_uuid,
1148
void ast_bridge_channel_write_park(struct ast_bridge_channel *bridge_channel, const char *parkee_uuid,
1149
	const char *parker_uuid, const char *app_data);
1149
	const char *parker_uuid, const char *app_data);
1150

    
   
1150

   
1151
/*!
1151
/*!
1152
 * \brief Write a bridge action play file frame into the bridge.
1152
 * \brief Write a bridge action play file frame into the bridge.
1153
 * \since 12.0.0
1153
 * \since 12.0.0
1154
 *
1154
 *
1155
 * \param bridge_channel Which channel is putting the frame into the bridge
1155
 * \param bridge_channel Which channel is putting the frame into the bridge
1156
 * \param custom_play Call this function to play the playfile. (NULL if normal sound file to play)
1156
 * \param custom_play Call this function to play the playfile. (NULL if normal sound file to play)
1157
 * \param playfile Sound filename to play.
1157
 * \param playfile Sound filename to play.
1158
 * \param moh_class MOH class to request bridge peers to hear while file is played.
1158
 * \param moh_class MOH class to request bridge peers to hear while file is played.
1159
 *     NULL if no MOH.
1159
 *     NULL if no MOH.
1160
 *     Empty if default MOH class.
1160
 *     Empty if default MOH class.
1161
 *
1161
 *
1162
 * \note This is intended to be called by bridge hooks.
1162
 * \note This is intended to be called by bridge hooks.
1163
 *
1163
 *
1164
 * \return Nothing
1164
 * \return Nothing
1165
 */
1165
 */
1166
void ast_bridge_channel_write_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class);
1166
void ast_bridge_channel_write_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class);
1167

    
   
1167

   
1168
/*!
1168
/*!
1169
 * \brief Queue a bridge action play file frame onto the bridge channel.
1169
 * \brief Queue a bridge action play file frame onto the bridge channel.
1170
 * \since 12.0.0
1170
 * \since 12.0.0
1171
 *
1171
 *
1172
 * \param bridge_channel Which channel to put the frame onto.
1172
 * \param bridge_channel Which channel to put the frame onto.
1173
 * \param custom_play Call this function to play the playfile. (NULL if normal sound file to play)
1173
 * \param custom_play Call this function to play the playfile. (NULL if normal sound file to play)
1174
 * \param playfile Sound filename to play.
1174
 * \param playfile Sound filename to play.
1175
 * \param moh_class MOH class to request bridge peers to hear while file is played.
1175
 * \param moh_class MOH class to request bridge peers to hear while file is played.
1176
 *     NULL if no MOH.
1176
 *     NULL if no MOH.
1177
 *     Empty if default MOH class.
1177
 *     Empty if default MOH class.
1178
 *
1178
 *
1179
 * \note This is intended to be called by bridge hooks.
1179
 * \note This is intended to be called by bridge hooks.
1180
 *
1180
 *
1181
 * \return Nothing
1181
 * \return Nothing
1182
 */
1182
 */
1183
void ast_bridge_channel_queue_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class);
1183
void ast_bridge_channel_queue_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class);
1184

    
   
1184

   
1185
/*!
1185
/*!
1186
 * \brief Restore the formats of a bridge channel's channel to how they were before bridge_channel_join
1186
 * \brief Restore the formats of a bridge channel's channel to how they were before bridge_channel_join
1187
 * \since 12.0.0
1187
 * \since 12.0.0
1188
 *
1188
 *
1189
 * \param bridge_channel Channel to restore
1189
 * \param bridge_channel Channel to restore
1190
 */
1190
 */
1191
void ast_bridge_channel_restore_formats(struct ast_bridge_channel *bridge_channel);
1191
void ast_bridge_channel_restore_formats(struct ast_bridge_channel *bridge_channel);
1192

    
   
1192

   
1193
/*!
1193
/*!
1194
 * \brief Get the peer bridge channel of a two party bridge.
1194
 * \brief Get the peer bridge channel of a two party bridge.
1195
 * \since 12.0.0
1195
 * \since 12.0.0
1196
 *
1196
 *
1197
 * \param bridge_channel What to get the peer of.
1197
 * \param bridge_channel What to get the peer of.
1198
 *
1198
 *
1199
 * \note On entry, bridge_channel->bridge is already locked.
1199
 * \note On entry, bridge_channel->bridge is already locked.
1200
 *
1200
 *
1201
 * \note This is an internal bridge function.
1201
 * \note This is an internal bridge function.
1202
 *
1202
 *
1203
 * \retval peer on success.
1203
 * \retval peer on success.
1204
 * \retval NULL no peer channel.
1204
 * \retval NULL no peer channel.
1205
 */
1205
 */
1206
struct ast_bridge_channel *ast_bridge_channel_peer(struct ast_bridge_channel *bridge_channel);
1206
struct ast_bridge_channel *ast_bridge_channel_peer(struct ast_bridge_channel *bridge_channel);
1207

    
   
1207

   
1208
/*!
1208
/*!
1209
 * \brief Adjust the internal mixing sample rate of a bridge
1209
 * \brief Adjust the internal mixing sample rate of a bridge
1210
 * used during multimix mode.
1210
 * used during multimix mode.
1211
 *
1211
 *
1212
 * \param bridge Channel to change the sample rate on.
1212
 * \param bridge Channel to change the sample rate on.
1213
 * \param sample_rate the sample rate to change to. If a
1213
 * \param sample_rate the sample rate to change to. If a
1214
 *        value of 0 is passed here, the bridge will be free to pick
1214
 *        value of 0 is passed here, the bridge will be free to pick
1215
 *        what ever sample rate it chooses.
1215
 *        what ever sample rate it chooses.
1216
 *
1216
 *
1217
 */
1217
 */
1218
void ast_bridge_set_internal_sample_rate(struct ast_bridge *bridge, unsigned int sample_rate);
1218
void ast_bridge_set_internal_sample_rate(struct ast_bridge *bridge, unsigned int sample_rate);
1219

    
   
1219

   
1220
/*!
1220
/*!
1221
 * \brief Adjust the internal mixing interval of a bridge used
1221
 * \brief Adjust the internal mixing interval of a bridge used
1222
 * during multimix mode.
1222
 * during multimix mode.
1223
 *
1223
 *
1224
 * \param bridge Channel to change the sample rate on.
1224
 * \param bridge Channel to change the sample rate on.
1225
 * \param mixing_interval the sample rate to change to.  If 0 is set
1225
 * \param mixing_interval the sample rate to change to.  If 0 is set
1226
 * the bridge tech is free to choose any mixing interval it uses by default.
1226
 * the bridge tech is free to choose any mixing interval it uses by default.
1227
 */
1227
 */
1228
void ast_bridge_set_mixing_interval(struct ast_bridge *bridge, unsigned int mixing_interval);
1228
void ast_bridge_set_mixing_interval(struct ast_bridge *bridge, unsigned int mixing_interval);
1229

    
   
1229

   
1230
/*!
1230
/*!
1231
 * \brief Set a bridge to feed a single video source to all participants.
1231
 * \brief Set a bridge to feed a single video source to all participants.
1232
 */
1232
 */
1233
void ast_bridge_set_single_src_video_mode(struct ast_bridge *bridge, struct ast_channel *video_src_chan);
1233
void ast_bridge_set_single_src_video_mode(struct ast_bridge *bridge, struct ast_channel *video_src_chan);
1234

    
   
1234

   
1235
/*!
1235
/*!
1236
 * \brief Set the bridge to pick the strongest talker supporting
1236
 * \brief Set the bridge to pick the strongest talker supporting
1237
 * video as the single source video feed
1237
 * video as the single source video feed
1238
 */
1238
 */
1239
void ast_bridge_set_talker_src_video_mode(struct ast_bridge *bridge);
1239
void ast_bridge_set_talker_src_video_mode(struct ast_bridge *bridge);
1240

    
   
1240

   
1241
/*!
1241
/*!
1242
 * \brief Update information about talker energy for talker src video mode.
1242
 * \brief Update information about talker energy for talker src video mode.
1243
 */
1243
 */
1244
void ast_bridge_update_talker_src_video_mode(struct ast_bridge *bridge, struct ast_channel *chan, int talker_energy, int is_keyfame);
1244
void ast_bridge_update_talker_src_video_mode(struct ast_bridge *bridge, struct ast_channel *chan, int talker_energy, int is_keyfame);
1245

    
   
1245

   
1246
/*!
1246
/*!
1247
 * \brief Returns the number of video sources currently active in the bridge
1247
 * \brief Returns the number of video sources currently active in the bridge
1248
 */
1248
 */
1249
int ast_bridge_number_video_src(struct ast_bridge *bridge);
1249
int ast_bridge_number_video_src(struct ast_bridge *bridge);
1250

    
   
1250

   
1251
/*!
1251
/*!
1252
 * \brief Determine if a channel is a video src for the bridge
1252
 * \brief Determine if a channel is a video src for the bridge
1253
 *
1253
 *
1254
 * \retval 0 Not a current video source of the bridge.
1254
 * \retval 0 Not a current video source of the bridge.
1255
 * \retval None 0, is a video source of the bridge, The number
1255
 * \retval None 0, is a video source of the bridge, The number
1256
 *         returned represents the priority this video stream has
1256
 *         returned represents the priority this video stream has
1257
 *         on the bridge where 1 is the highest priority.
1257
 *         on the bridge where 1 is the highest priority.
1258
 */
1258
 */
1259
int ast_bridge_is_video_src(struct ast_bridge *bridge, struct ast_channel *chan);
1259
int ast_bridge_is_video_src(struct ast_bridge *bridge, struct ast_channel *chan);
1260

    
   
1260

   
1261
/*!
1261
/*!
1262
 * \brief remove a channel as a source of video for the bridge.
1262
 * \brief remove a channel as a source of video for the bridge.
1263
 */
1263
 */
1264
void ast_bridge_remove_video_src(struct ast_bridge *bridge, struct ast_channel *chan);
1264
void ast_bridge_remove_video_src(struct ast_bridge *bridge, struct ast_channel *chan);
1265

    
   
1265

   
1266
enum ast_transfer_result {
1266
enum ast_transfer_result {
1267
    /*! The transfer completed successfully */
1267
    /*! The transfer completed successfully */
1268
    AST_BRIDGE_TRANSFER_SUCCESS,
1268
    AST_BRIDGE_TRANSFER_SUCCESS,
1269
    /*! A bridge involved does not permit transferring */
1269
    /*! A bridge involved does not permit transferring */
1270
    AST_BRIDGE_TRANSFER_NOT_PERMITTED,
1270
    AST_BRIDGE_TRANSFER_NOT_PERMITTED,
1271
    /*! The current bridge setup makes transferring an invalid operation */
1271
    /*! The current bridge setup makes transferring an invalid operation */
1272
    AST_BRIDGE_TRANSFER_INVALID,
1272
    AST_BRIDGE_TRANSFER_INVALID,
1273
    /*! The transfer operation failed for a miscellaneous reason */
1273
    /*! The transfer operation failed for a miscellaneous reason */
1274
    AST_BRIDGE_TRANSFER_FAIL,
1274
    AST_BRIDGE_TRANSFER_FAIL,
1275
};
1275
};
1276

    
   
1276

   
1277
typedef void (*transfer_channel_cb)(struct ast_channel *chan, void *user_data);
1277
typedef void (*transfer_channel_cb)(struct ast_channel *chan, void *user_data);
1278

    
   
1278

   
1279
/*!
1279
/*!
1280
 * \brief Blind transfer target to the extension and context provided
1280
 * \brief Blind transfer target to the extension and context provided
1281
 *
1281
 *
1282
 * The channel given is bridged to one or multiple channels. Depending on
1282
 * The channel given is bridged to one or multiple channels. Depending on
1283
 * the bridge and the number of participants, the entire bridge could be
1283
 * the bridge and the number of participants, the entire bridge could be
1284
 * transferred to the given destination, or a single channel may be redirected.
1284
 * transferred to the given destination, or a single channel may be redirected.
1285
 *
1285
 *
1286
 * Callers may also provide a callback to be called on the channel that will
1286
 * Callers may also provide a callback to be called on the channel that will
1287
 * be running dialplan. The user data passed into ast_bridge_transfer_blind
1287
 * be running dialplan. The user data passed into ast_bridge_transfer_blind
1288
 * will be given as the argument to the callback to be interpreted as desired.
1288
 * will be given as the argument to the callback to be interpreted as desired.
1289
 * This callback is guaranteed to be called in the same thread as
1289
 * This callback is guaranteed to be called in the same thread as
1290
 * ast_bridge_transfer_blind() and before ast_bridge_transfer_blind() returns.
1290
 * ast_bridge_transfer_blind() and before ast_bridge_transfer_blind() returns.
1291
 *
1291
 *
1292
 * \note Do not call this function with the transferer or its tech_pvt locked.
1292
 * \note Do not call this function with the transferer or its tech_pvt locked.
1293
 *
1293
 *
1294
 * \param transferer The channel performing the blind transfer
1294
 * \param transferer The channel performing the blind transfer
1295
 * \param exten The dialplan extension to send the call to
1295
 * \param exten The dialplan extension to send the call to
1296
 * \param context The dialplan context to send the call to
1296
 * \param context The dialplan context to send the call to
1297
 * \param new_channel_cb A callback to be called on the channel that will
1297
 * \param new_channel_cb A callback to be called on the channel that will
1298
 *        be executing dialplan
1298
 *        be executing dialplan
1299
 * \param user_data Argument for new_channel_cb
1299
 * \param user_data Argument for new_channel_cb
1300
 * \return The success or failure result of the blind transfer
1300
 * \return The success or failure result of the blind transfer
1301
 */
1301
 */
1302
enum ast_transfer_result ast_bridge_transfer_blind(struct ast_channel *transferer,
1302
enum ast_transfer_result ast_bridge_transfer_blind(struct ast_channel *transferer,
1303
		const char *exten, const char *context,
1303
		const char *exten, const char *context,
1304
		transfer_channel_cb new_channel_cb, void *user_data);
1304
		transfer_channel_cb new_channel_cb, void *user_data);
1305

    
   
1305

   
1306
/*!
1306
/*!
1307
 * \brief Attended transfer
1307
 * \brief Attended transfer
1308
 *
1308
 *
1309
 * The two channels are both transferer channels. The first is the channel
1309
 * The two channels are both transferer channels. The first is the channel
1310
 * that is bridged to the transferee (or if unbridged, the 'first' call of
1310
 * that is bridged to the transferee (or if unbridged, the 'first' call of
1311
 * the transfer). The second is the channel that is bridged to the transfer
1311
 * the transfer). The second is the channel that is bridged to the transfer
1312
 * target (or if unbridged, the 'second' call of the transfer).
1312
 * target (or if unbridged, the 'second' call of the transfer).
1313
 *
1313
 *
1314
 * Like with a blind transfer, a frame hook can be provided to monitor the
1314
 * Like with a blind transfer, a frame hook can be provided to monitor the
1315
 * resulting call after the transfer completes. If the transfer fails, the
1315
 * resulting call after the transfer completes. If the transfer fails, the
1316
 * hook will not be attached to any call.
1316
 * hook will not be attached to any call.
1317
 *
1317
 *
1318
 * \note Do not call this function with either of the channels or their
1318
 * \note Do not call this function with either of the channels or their
1319
 * tech_pvts locked.
1319
 * tech_pvts locked.
1320
 *
1320
 *
1321
 * \param to_transferee Transferer channel on initial call (presumably bridged to transferee)
1321
 * \param to_transferee Transferer channel on initial call (presumably bridged to transferee)
1322
 * \param to_transfer_target Transferer channel on consultation call (presumably bridged to transfer target)
1322
 * \param to_transfer_target Transferer channel on consultation call (presumably bridged to transfer target)
1323
 * \param hook A frame hook to attach to the resultant call
1323
 * \param hook A frame hook to attach to the resultant call
1324
 * \return The success or failure of the attended transfer
1324
 * \return The success or failure of the attended transfer
1325
 */
1325
 */
1326
enum ast_transfer_result ast_bridge_transfer_attended(struct ast_channel *to_transferee,
1326
enum ast_transfer_result ast_bridge_transfer_attended(struct ast_channel *to_transferee,
1327
		struct ast_channel *to_transfer_target, struct ast_framehook *hook);
1327
		struct ast_channel *to_transfer_target, struct ast_framehook *hook);
1328
/*!
1328
/*!
1329
 * \brief Set channel to goto specific location after the bridge.
1329
 * \brief Set channel to goto specific location after the bridge.
1330
 * \since 12.0.0
1330
 * \since 12.0.0
1331
 *
1331
 *
1332
 * \param chan Channel to setup after bridge goto location.
1332
 * \param chan Channel to setup after bridge goto location.
1333
 * \param context Context to goto after bridge.
1333
 * \param context Context to goto after bridge.
1334
 * \param exten Exten to goto after bridge.
1334
 * \param exten Exten to goto after bridge.
1335
 * \param priority Priority to goto after bridge.
1335
 * \param priority Priority to goto after bridge.
1336
 *
1336
 *
1337
 * \details Add a channel datastore to setup the goto location
1337
 * \details Add a channel datastore to setup the goto location
1338
 * when the channel leaves the bridge and run a PBX from there.
1338
 * when the channel leaves the bridge and run a PBX from there.
1339
 *
1339
 *
1340
 * \return Nothing
1340
 * \return Nothing
1341
 */
1341
 */
1342
void ast_after_bridge_set_goto(struct ast_channel *chan, const char *context, const char *exten, int priority);
1342
void ast_after_bridge_set_goto(struct ast_channel *chan, const char *context, const char *exten, int priority);
1343

    
   
1343

   
1344
/*!
1344
/*!
1345
 * \brief Set channel to run the h exten after the bridge.
1345
 * \brief Set channel to run the h exten after the bridge.
1346
 * \since 12.0.0
1346
 * \since 12.0.0
1347
 *
1347
 *
1348
 * \param chan Channel to setup after bridge goto location.
1348
 * \param chan Channel to setup after bridge goto location.
1349
 * \param context Context to goto after bridge.
1349
 * \param context Context to goto after bridge.
1350
 *
1350
 *
1351
 * \details Add a channel datastore to setup the goto location
1351
 * \details Add a channel datastore to setup the goto location
1352
 * when the channel leaves the bridge and run a PBX from there.
1352
 * when the channel leaves the bridge and run a PBX from there.
1353
 *
1353
 *
1354
 * \return Nothing
1354
 * \return Nothing
1355
 */
1355
 */
1356
void ast_after_bridge_set_h(struct ast_channel *chan, const char *context);
1356
void ast_after_bridge_set_h(struct ast_channel *chan, const char *context);
1357

    
   
1357

   
1358
/*!
1358
/*!
1359
 * \brief Set channel to go on in the dialplan after the bridge.
1359
 * \brief Set channel to go on in the dialplan after the bridge.
1360
 * \since 12.0.0
1360
 * \since 12.0.0
1361
 *
1361
 *
1362
 * \param chan Channel to setup after bridge goto location.
1362
 * \param chan Channel to setup after bridge goto location.
1363
 * \param context Current context of the caller channel.
1363
 * \param context Current context of the caller channel.
1364
 * \param exten Current exten of the caller channel.
1364
 * \param exten Current exten of the caller channel.
1365
 * \param priority Current priority of the caller channel
1365
 * \param priority Current priority of the caller channel
1366
 * \param parseable_goto User specified goto string from dialplan.
1366
 * \param parseable_goto User specified goto string from dialplan.
1367
 *
1367
 *
1368
 * \details Add a channel datastore to setup the goto location
1368
 * \details Add a channel datastore to setup the goto location
1369
 * when the channel leaves the bridge and run a PBX from there.
1369
 * when the channel leaves the bridge and run a PBX from there.
1370
 *
1370
 *
1371
 * If parseable_goto then use the given context/exten/priority
1371
 * If parseable_goto then use the given context/exten/priority
1372
 *   as the relative position for the parseable_goto.
1372
 *   as the relative position for the parseable_goto.
1373
 * Else goto the given context/exten/priority+1.
1373
 * Else goto the given context/exten/priority+1.
1374
 *
1374
 *
1375
 * \return Nothing
1375
 * \return Nothing
1376
 */
1376
 */
1377
void ast_after_bridge_set_go_on(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *parseable_goto);
1377
void ast_after_bridge_set_go_on(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *parseable_goto);
1378

    
   
1378

   
1379
/*!
1379
/*!
1380
 * \brief Setup any after bridge goto location to begin execution.
1380
 * \brief Setup any after bridge goto location to begin execution.
1381
 * \since 12.0.0
1381
 * \since 12.0.0
1382
 *
1382
 *
1383
 * \param chan Channel to setup after bridge goto location.
1383
 * \param chan Channel to setup after bridge goto location.
1384
 *
1384
 *
1385
 * \details Pull off any after bridge goto location datastore and
1385
 * \details Pull off any after bridge goto location datastore and
1386
 * setup for dialplan execution there.
1386
 * setup for dialplan execution there.
1387
 *
1387
 *
1388
 * \retval 0 on success.  The goto location is set for a PBX to run it.
1388
 * \retval 0 on success.  The goto location is set for a PBX to run it.
1389
 * \retval non-zero on error or no goto location.
1389
 * \retval non-zero on error or no goto location.
1390
 *
1390
 *
1391
 * \note If the after bridge goto is set to run an h exten it is
1391
 * \note If the after bridge goto is set to run an h exten it is
1392
 * run here immediately.
1392
 * run here immediately.
1393
 */
1393
 */
1394
int ast_after_bridge_goto_setup(struct ast_channel *chan);
1394
int ast_after_bridge_goto_setup(struct ast_channel *chan);
1395

    
   
1395

   
1396
/*!
1396
/*!
1397
 * \brief Run a PBX on any after bridge goto location.
1397
 * \brief Run a PBX on any after bridge goto location.
1398
 * \since 12.0.0
1398
 * \since 12.0.0
1399
 *
1399
 *
1400
 * \param chan Channel to execute after bridge goto location.
1400
 * \param chan Channel to execute after bridge goto location.
1401
 *
1401
 *
1402
 * \details Pull off any after bridge goto location datastore
1402
 * \details Pull off any after bridge goto location datastore
1403
 * and run a PBX at that location.
1403
 * and run a PBX at that location.
1404
 *
1404
 *
1405
 * \note On return, the chan pointer is no longer valid because
1405
 * \note On return, the chan pointer is no longer valid because
1406
 * the channel has hung up.
1406
 * the channel has hung up.
1407
 *
1407
 *
1408
 * \return Nothing
1408
 * \return Nothing
1409
 */
1409
 */
1410
void ast_after_bridge_goto_run(struct ast_channel *chan);
1410
void ast_after_bridge_goto_run(struct ast_channel *chan);
1411

    
   
1411

   
1412
/*!
1412
/*!
1413
 * \brief Discard channel after bridge goto location.
1413
 * \brief Discard channel after bridge goto location.
1414
 * \since 12.0.0
1414
 * \since 12.0.0
1415
 *
1415
 *
1416
 * \param chan Channel to discard after bridge goto location.
1416
 * \param chan Channel to discard after bridge goto location.
1417
 *
1417
 *
1418
 * \return Nothing
1418
 * \return Nothing
1419
 */
1419
 */
1420
void ast_after_bridge_goto_discard(struct ast_channel *chan);
1420
void ast_after_bridge_goto_discard(struct ast_channel *chan);
1421

    
   
1421

   

    
   
1422
/*! Reason the the after bridge callback will not be called. */

    
   
1423
enum ast_after_bridge_cb_reason {

    
   
1424
	/*! The datastore is being destroyed.  Likely due to hangup. */

    
   
1425
	AST_AFTER_BRIDGE_CB_REASON_DESTROY,

    
   
1426
	/*! Something else replaced the callback with another. */

    
   
1427
	AST_AFTER_BRIDGE_CB_REASON_REPLACED,

    
   
1428
	/*! The callback was removed because of a masquerade. (fixup) */

    
   
1429
	AST_AFTER_BRIDGE_CB_REASON_MASQUERADE,

    
   
1430
	/*! The channel departed bridge. */

    
   
1431
	AST_AFTER_BRIDGE_CB_REASON_DEPART,

    
   
1432
	/*! Was explicitly removed by external code. */

    
   
1433
	AST_AFTER_BRIDGE_CB_REASON_REMOVED,

    
   
1434
};

    
   
1435

   

    
   
1436
/*!

    
   
1437
 * \brief After bridge callback failed.

    
   
1438
 * \since 12.0.0

    
   
1439
 *

    
   
1440
 * \param reason Reason callback is failing.

    
   
1441
 * \param data Extra data what setup the callback wanted to pass.

    
   
1442
 *

    
   
1443
 * \return Nothing

    
   
1444
 */

    
   
1445
typedef void (*ast_after_bridge_cb_failed)(enum ast_after_bridge_cb_reason reason, void *data);

    
   
1446

   

    
   
1447
/*!

    
   
1448
 * \brief After bridge callback function.

    
   
1449
 * \since 12.0.0

    
   
1450
 *

    
   
1451
 * \param chan Channel just leaving bridging system.

    
   
1452
 * \param data Extra data what setup the callback wanted to pass.

    
   
1453
 *

    
   
1454
 * \return Nothing

    
   
1455
 */

    
   
1456
typedef void (*ast_after_bridge_cb)(struct ast_channel *chan, void *data);

    
   
1457

   

    
   
1458
/*!

    
   
1459
 * \brief Discard channel after bridge callback.

    
   
1460
 * \since 12.0.0

    
   
1461
 *

    
   
1462
 * \param chan Channel to discard after bridge callback.

    
   
1463
 * \param reason Why are we doing this.

    
   
1464
 *

    
   
1465
 * \return Nothing

    
   
1466
 */

    
   
1467
void ast_after_bridge_callback_discard(struct ast_channel *chan, enum ast_after_bridge_cb_reason reason);

    
   
1468

   

    
   
1469
/*!

    
   
1470
 * \brief Setup an after bridge callback for when the channel leaves the bridging system.

    
   
1471
 * \since 12.0.0

    
   
1472
 *

    
   
1473
 * \param chan Channel to setup an after bridge callback on.

    
   
1474
 * \param callback Function to call when the channel leaves the bridging system.

    
   
1475
 * \param failed Function to call when will not be calling the callback.

    
   
1476
 * \param data Extra data to pass with the callback.

    
   
1477
 *

    
   
1478
 * \retval 0 on success.

    
   
1479
 * \retval -1 on error.

    
   
1480
 */

    
   
1481
int ast_after_bridge_callback_set(struct ast_channel *chan, ast_after_bridge_cb callback, ast_after_bridge_cb_failed failed, void *data);

    
   
1482

   
1422
/*!
1483
/*!
1423
 * \brief Get a container of all channels in the bridge
1484
 * \brief Get a container of all channels in the bridge
1424
 * \since 12.0.0
1485
 * \since 12.0.0
1425
 *
1486
 *
1426
 * \param bridge The bridge which is already locked.
1487
 * \param bridge The bridge which is already locked.
1427
 *
1488
 *
1428
 * \retval NULL Failed to create container
1489
 * \retval NULL Failed to create container
1429
 * \retval non-NULL Container of channels in the bridge
1490
 * \retval non-NULL Container of channels in the bridge
1430
 */
1491
 */
1431
struct ao2_container *ast_bridge_peers_nolock(struct ast_bridge *bridge);
1492
struct ao2_container *ast_bridge_peers_nolock(struct ast_bridge *bridge);
1432

    
   
1493

   
1433
/*!
1494
/*!
1434
 * \brief Get a container of all channels in the bridge
1495
 * \brief Get a container of all channels in the bridge
1435
 * \since 12.0.0
1496
 * \since 12.0.0
1436
 *
1497
 *
1437
 * \param bridge The bridge
1498
 * \param bridge The bridge
1438
 *
1499
 *
1439
 * \note The returned container is a snapshot of channels in the
1500
 * \note The returned container is a snapshot of channels in the
1440
 * bridge when called.
1501
 * bridge when called.
1441
 *
1502
 *
1442
 * \retval NULL Failed to create container
1503
 * \retval NULL Failed to create container
1443
 * \retval non-NULL Container of channels in the bridge
1504
 * \retval non-NULL Container of channels in the bridge
1444
 */
1505
 */
1445
struct ao2_container *ast_bridge_peers(struct ast_bridge *bridge);
1506
struct ao2_container *ast_bridge_peers(struct ast_bridge *bridge);
1446

    
   
1507

   
1447
/*!
1508
/*!
1448
 * \brief Get the channel's bridge peer only if the bridge is two-party.
1509
 * \brief Get the channel's bridge peer only if the bridge is two-party.
1449
 * \since 12.0.0
1510
 * \since 12.0.0
1450
 *
1511
 *
1451
 * \param bridge The bridge which is already locked.
1512
 * \param bridge The bridge which is already locked.
1452
 * \param chan Channel desiring the bridge peer channel.
1513
 * \param chan Channel desiring the bridge peer channel.
1453
 *
1514
 *
1454
 * \note The returned peer channel is the current peer in the
1515
 * \note The returned peer channel is the current peer in the
1455
 * bridge when called.
1516
 * bridge when called.
1456
 *
1517
 *
1457
 * \retval NULL Channel not in a bridge or the bridge is not two-party.
1518
 * \retval NULL Channel not in a bridge or the bridge is not two-party.
1458
 * \retval non-NULL Reffed peer channel at time of calling.
1519
 * \retval non-NULL Reffed peer channel at time of calling.
1459
 */
1520
 */
1460
struct ast_channel *ast_bridge_peer_nolock(struct ast_bridge *bridge, struct ast_channel *chan);
1521
struct ast_channel *ast_bridge_peer_nolock(struct ast_bridge *bridge, struct ast_channel *chan);
1461

    
   
1522

   
1462
/*!
1523
/*!
1463
 * \brief Get the channel's bridge peer only if the bridge is two-party.
1524
 * \brief Get the channel's bridge peer only if the bridge is two-party.
1464
 * \since 12.0.0
1525
 * \since 12.0.0
1465
 *
1526
 *
1466
 * \param bridge The bridge
1527
 * \param bridge The bridge
1467
 * \param chan Channel desiring the bridge peer channel.
1528
 * \param chan Channel desiring the bridge peer channel.
1468
 *
1529
 *
1469
 * \note The returned peer channel is the current peer in the
1530
 * \note The returned peer channel is the current peer in the
1470
 * bridge when called.
1531
 * bridge when called.
1471
 *
1532
 *
1472
 * \retval NULL Channel not in a bridge or the bridge is not two-party.
1533
 * \retval NULL Channel not in a bridge or the bridge is not two-party.
1473
 * \retval non-NULL Reffed peer channel at time of calling.
1534
 * \retval non-NULL Reffed peer channel at time of calling.
1474
 */
1535
 */
1475
struct ast_channel *ast_bridge_peer(struct ast_bridge *bridge, struct ast_channel *chan);
1536
struct ast_channel *ast_bridge_peer(struct ast_bridge *bridge, struct ast_channel *chan);
1476

    
   
1537

   
1477
#if defined(__cplusplus) || defined(c_plusplus)
1538
#if defined(__cplusplus) || defined(c_plusplus)
1478
}
1539
}
1479
#endif
1540
#endif
1480

    
   
1541

   
1481
#endif	/* _ASTERISK_BRIDGING_H */
1542
#endif	/* _ASTERISK_BRIDGING_H */
/team/group/bridge_construction/main/bridging.c
Revision 388574 New Change
 
  1. /team/group/bridge_construction/include/asterisk/bridging.h: Loading...
  2. /team/group/bridge_construction/main/bridging.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.