Review Board 1.7.16


Use stasis cache in more places

Review Request #2645 - Created June 26, 2013 and submitted

Joshua Colp
stasis_cache_usage
ASTERISK-21883
Reviewers
asterisk-dev
Asterisk
This change moves CLI/AGI/AMI commands to accessing the Stasis cache for retrieving information instead of directly accessing the data structures. I have also added an AMI action to get bridge information, and extended the "status" action to include the same information available as "core show channel".

Stuff given up:
1. Number of frames being read and written
2. First file descriptor
3. What the channel is blocked in

An additional question:
I'm not currently storing channel trace information in the snapshot and as a result it is not displayed. Is this a feature we still want to support? How widespread is it?
Executed the changed CLI commands, AMI actions, and AGI commands and ensured that the output is as expected.
/trunk/include/asterisk/channel.h
Revision 392949 New Change
1
/*
1
/*
2
 * Asterisk -- An open source telephony toolkit.
2
 * Asterisk -- An open source telephony toolkit.
3
 *
3
 *
4
 * Copyright (C) 1999 - 2006, Digium, Inc.
4
 * Copyright (C) 1999 - 2006, Digium, Inc.
5
 *
5
 *
6
 * Mark Spencer <markster@digium.com>
6
 * Mark Spencer <markster@digium.com>
7
 *
7
 *
8
 * See http://www.asterisk.org for more information about
8
 * See http://www.asterisk.org for more information about
9
 * the Asterisk project. Please do not directly contact
9
 * the Asterisk project. Please do not directly contact
10
 * any of the maintainers of this project for assistance;
10
 * any of the maintainers of this project for assistance;
11
 * the project provides a web site, mailing lists and IRC
11
 * the project provides a web site, mailing lists and IRC
12
 * channels for your use.
12
 * channels for your use.
13
 *
13
 *
14
 * This program is free software, distributed under the terms of
14
 * This program is free software, distributed under the terms of
15
 * the GNU General Public License Version 2. See the LICENSE file
15
 * the GNU General Public License Version 2. See the LICENSE file
16
 * at the top of the source tree.
16
 * at the top of the source tree.
17
 */
17
 */
18

    
   
18

   
19
/*! \file
19
/*! \file
20
 * \brief General Asterisk PBX channel definitions.
20
 * \brief General Asterisk PBX channel definitions.
21
 * \par See also:
21
 * \par See also:
22
 *  \arg \ref Def_Channel
22
 *  \arg \ref Def_Channel
23
 *  \arg \ref channel_drivers
23
 *  \arg \ref channel_drivers
24
 */
24
 */
25

    
   
25

   
26
/*! \page Def_Channel Asterisk Channels
26
/*! \page Def_Channel Asterisk Channels
27
	\par What is a Channel?
27
	\par What is a Channel?
28
	A phone call through Asterisk consists of an incoming
28
	A phone call through Asterisk consists of an incoming
29
	connection and an outbound connection. Each call comes
29
	connection and an outbound connection. Each call comes
30
	in through a channel driver that supports one technology,
30
	in through a channel driver that supports one technology,
31
	like SIP, DAHDI, IAX2 etc.
31
	like SIP, DAHDI, IAX2 etc.
32
	\par
32
	\par
33
	Each channel driver, technology, has it's own private
33
	Each channel driver, technology, has it's own private
34
	channel or dialog structure, that is technology-dependent.
34
	channel or dialog structure, that is technology-dependent.
35
	Each private structure is "owned" by a generic Asterisk
35
	Each private structure is "owned" by a generic Asterisk
36
	channel structure, defined in channel.h and handled by
36
	channel structure, defined in channel.h and handled by
37
	channel.c .
37
	channel.c .
38
	\par Call scenario
38
	\par Call scenario
39
	This happens when an incoming call arrives to Asterisk
39
	This happens when an incoming call arrives to Asterisk
40
	-# Call arrives on a channel driver interface
40
	-# Call arrives on a channel driver interface
41
	-# Channel driver creates a PBX channel and starts a
41
	-# Channel driver creates a PBX channel and starts a
42
	   pbx thread on the channel
42
	   pbx thread on the channel
43
	-# The dial plan is executed
43
	-# The dial plan is executed
44
	-# At this point at least two things can happen:
44
	-# At this point at least two things can happen:
45
		-# The call is answered by Asterisk and
45
		-# The call is answered by Asterisk and
46
		   Asterisk plays a media stream or reads media
46
		   Asterisk plays a media stream or reads media
47
		-# The dial plan forces Asterisk to create an outbound
47
		-# The dial plan forces Asterisk to create an outbound
48
		   call somewhere with the dial (see \ref app_dial.c)
48
		   call somewhere with the dial (see \ref app_dial.c)
49
		   application
49
		   application
50
	.
50
	.
51

    
   
51

   
52
	\par Bridging channels
52
	\par Bridging channels
53
	If Asterisk dials out this happens:
53
	If Asterisk dials out this happens:
54
	-# Dial creates an outbound PBX channel and asks one of the
54
	-# Dial creates an outbound PBX channel and asks one of the
55
	   channel drivers to create a call
55
	   channel drivers to create a call
56
	-# When the call is answered, Asterisk bridges the media streams
56
	-# When the call is answered, Asterisk bridges the media streams
57
	   so the caller on the first channel can speak with the callee
57
	   so the caller on the first channel can speak with the callee
58
	   on the second, outbound channel
58
	   on the second, outbound channel
59
	-# In some cases where we have the same technology on both
59
	-# In some cases where we have the same technology on both
60
	   channels and compatible codecs, a native bridge is used.
60
	   channels and compatible codecs, a native bridge is used.
61
	   In a native bridge, the channel driver handles forwarding
61
	   In a native bridge, the channel driver handles forwarding
62
	   of incoming audio to the outbound stream internally, without
62
	   of incoming audio to the outbound stream internally, without
63
	   sending audio frames through the PBX.
63
	   sending audio frames through the PBX.
64
	-# In SIP, theres an "external native bridge" where Asterisk
64
	-# In SIP, theres an "external native bridge" where Asterisk
65
	   redirects the endpoint, so audio flows directly between the
65
	   redirects the endpoint, so audio flows directly between the
66
	   caller's phone and the callee's phone. Signalling stays in
66
	   caller's phone and the callee's phone. Signalling stays in
67
	   Asterisk in order to be able to provide a proper CDR record
67
	   Asterisk in order to be able to provide a proper CDR record
68
	   for the call.
68
	   for the call.
69

    
   
69

   
70

    
   
70

   
71
	\par Masquerading channels
71
	\par Masquerading channels
72
	In some cases, a channel can masquerade itself into another
72
	In some cases, a channel can masquerade itself into another
73
	channel. This happens frequently in call transfers, where
73
	channel. This happens frequently in call transfers, where
74
	a new channel takes over a channel that is already involved
74
	a new channel takes over a channel that is already involved
75
	in a call. The new channel sneaks in and takes over the bridge
75
	in a call. The new channel sneaks in and takes over the bridge
76
	and the old channel, now a zombie, is hung up.
76
	and the old channel, now a zombie, is hung up.
77

    
   
77

   
78
	\par Reference
78
	\par Reference
79
	\arg channel.c - generic functions
79
	\arg channel.c - generic functions
80
 	\arg channel.h - declarations of functions, flags and structures
80
 	\arg channel.h - declarations of functions, flags and structures
81
	\arg translate.h - Transcoding support functions
81
	\arg translate.h - Transcoding support functions
82
	\arg \ref channel_drivers - Implemented channel drivers
82
	\arg \ref channel_drivers - Implemented channel drivers
83
	\arg \ref Def_Frame Asterisk Multimedia Frames
83
	\arg \ref Def_Frame Asterisk Multimedia Frames
84
	\arg \ref Def_Bridge
84
	\arg \ref Def_Bridge
85

    
   
85

   
86
*/
86
*/
87
/*! \page Def_Bridge Asterisk Channel Bridges
87
/*! \page Def_Bridge Asterisk Channel Bridges
88

    
   
88

   
89
	In Asterisk, there's several media bridges.
89
	In Asterisk, there's several media bridges.
90

    
   
90

   
91
	The Core bridge handles two channels (a "phone call") and bridge
91
	The Core bridge handles two channels (a "phone call") and bridge
92
	them together.
92
	them together.
93

    
   
93

   
94
	The conference bridge (meetme) handles several channels simultaneously
94
	The conference bridge (meetme) handles several channels simultaneously
95
	with the support of an external timer (DAHDI timer). This is used
95
	with the support of an external timer (DAHDI timer). This is used
96
	not only by the Conference application (meetme) but also by the
96
	not only by the Conference application (meetme) but also by the
97
	page application and the SLA system introduced in 1.4.
97
	page application and the SLA system introduced in 1.4.
98
	The conference bridge does not handle video.
98
	The conference bridge does not handle video.
99

    
   
99

   
100
	When two channels of the same type connect, the channel driver
100
	When two channels of the same type connect, the channel driver
101
	or the media subsystem used by the channel driver (i.e. RTP)
101
	or the media subsystem used by the channel driver (i.e. RTP)
102
	can create a native bridge without sending media through the
102
	can create a native bridge without sending media through the
103
	core.
103
	core.
104

    
   
104

   
105
	Native bridging can be disabled by a number of reasons,
105
	Native bridging can be disabled by a number of reasons,
106
	like DTMF being needed by the core or codecs being incompatible
106
	like DTMF being needed by the core or codecs being incompatible
107
	so a transcoding module is needed.
107
	so a transcoding module is needed.
108

    
   
108

   
109
References:
109
References:
110
	\li \see ast_channel_early_bridge()
110
	\li \see ast_channel_early_bridge()
111
	\li \see ast_channel_bridge()
111
	\li \see ast_channel_bridge()
112
	\li \see app_meetme.c
112
	\li \see app_meetme.c
113
	\li \ref AstRTPbridge
113
	\li \ref AstRTPbridge
114
	\li \see ast_rtp_bridge()
114
	\li \see ast_rtp_bridge()
115
	\li \ref Def_Channel
115
	\li \ref Def_Channel
116
*/
116
*/
117

    
   
117

   
118
/*! \page AstFileDesc File descriptors
118
/*! \page AstFileDesc File descriptors
119
	Asterisk File descriptors are connected to each channel (see \ref Def_Channel)
119
	Asterisk File descriptors are connected to each channel (see \ref Def_Channel)
120
	in the \ref ast_channel structure.
120
	in the \ref ast_channel structure.
121
*/
121
*/
122

    
   
122

   
123
#ifndef _ASTERISK_CHANNEL_H
123
#ifndef _ASTERISK_CHANNEL_H
124
#define _ASTERISK_CHANNEL_H
124
#define _ASTERISK_CHANNEL_H
125

    
   
125

   
126
#include "asterisk/abstract_jb.h"
126
#include "asterisk/abstract_jb.h"
127
#include "asterisk/astobj2.h"
127
#include "asterisk/astobj2.h"
128
#include "asterisk/poll-compat.h"
128
#include "asterisk/poll-compat.h"
129

    
   
129

   
130
#if defined(__cplusplus) || defined(c_plusplus)
130
#if defined(__cplusplus) || defined(c_plusplus)
131
extern "C" {
131
extern "C" {
132
#endif
132
#endif
133

    
   
133

   
134
#define AST_MAX_EXTENSION       80  /*!< Max length of an extension */
134
#define AST_MAX_EXTENSION       80  /*!< Max length of an extension */
135
#define AST_MAX_CONTEXT         80  /*!< Max length of a context */
135
#define AST_MAX_CONTEXT         80  /*!< Max length of a context */
136
#define AST_MAX_ACCOUNT_CODE    20  /*!< Max length of an account code */
136
#define AST_MAX_ACCOUNT_CODE    20  /*!< Max length of an account code */
137
#define AST_CHANNEL_NAME        80  /*!< Max length of an ast_channel name */
137
#define AST_CHANNEL_NAME        80  /*!< Max length of an ast_channel name */
138
#define MAX_LANGUAGE            40  /*!< Max length of the language setting */
138
#define MAX_LANGUAGE            40  /*!< Max length of the language setting */
139
#define MAX_MUSICCLASS          80  /*!< Max length of the music class setting */
139
#define MAX_MUSICCLASS          80  /*!< Max length of the music class setting */
140
#define AST_MAX_USER_FIELD      256 /*!< Max length of the channel user field */
140
#define AST_MAX_USER_FIELD      256 /*!< Max length of the channel user field */
141

    
   
141

   
142
#include "asterisk/frame.h"
142
#include "asterisk/frame.h"
143
#include "asterisk/chanvars.h"
143
#include "asterisk/chanvars.h"
144
#include "asterisk/config.h"
144
#include "asterisk/config.h"
145
#include "asterisk/lock.h"
145
#include "asterisk/lock.h"
146
#include "asterisk/cdr.h"
146
#include "asterisk/cdr.h"
147
#include "asterisk/utils.h"
147
#include "asterisk/utils.h"
148
#include "asterisk/linkedlists.h"
148
#include "asterisk/linkedlists.h"
149
#include "asterisk/stringfields.h"
149
#include "asterisk/stringfields.h"
150
#include "asterisk/datastore.h"
150
#include "asterisk/datastore.h"
151
#include "asterisk/data.h"
151
#include "asterisk/data.h"
152
#include "asterisk/channelstate.h"
152
#include "asterisk/channelstate.h"
153
#include "asterisk/ccss.h"
153
#include "asterisk/ccss.h"
154
#include "asterisk/framehook.h"
154
#include "asterisk/framehook.h"
155
#include "asterisk/stasis.h"
155
#include "asterisk/stasis.h"
156
#include "asterisk/json.h"
156
#include "asterisk/json.h"
157
#include "asterisk/endpoints.h"
157
#include "asterisk/endpoints.h"
158

    
   
158

   
159
#define DATASTORE_INHERIT_FOREVER	INT_MAX
159
#define DATASTORE_INHERIT_FOREVER	INT_MAX
160

    
   
160

   
161
#define AST_MAX_FDS		11
161
#define AST_MAX_FDS		11
162
/*
162
/*
163
 * We have AST_MAX_FDS file descriptors in a channel.
163
 * We have AST_MAX_FDS file descriptors in a channel.
164
 * Some of them have a fixed use:
164
 * Some of them have a fixed use:
165
 */
165
 */
166
#define AST_ALERT_FD	(AST_MAX_FDS-1)		/*!< used for alertpipe */
166
#define AST_ALERT_FD	(AST_MAX_FDS-1)		/*!< used for alertpipe */
167
#define AST_TIMING_FD	(AST_MAX_FDS-2)		/*!< used for timingfd */
167
#define AST_TIMING_FD	(AST_MAX_FDS-2)		/*!< used for timingfd */
168
#define AST_AGENT_FD	(AST_MAX_FDS-3)		/*!< used by agents for pass through */
168
#define AST_AGENT_FD	(AST_MAX_FDS-3)		/*!< used by agents for pass through */
169
#define AST_GENERATOR_FD	(AST_MAX_FDS-4)	/*!< used by generator */
169
#define AST_GENERATOR_FD	(AST_MAX_FDS-4)	/*!< used by generator */
170
#define AST_JITTERBUFFER_FD	(AST_MAX_FDS-5)	/*!< used by generator */
170
#define AST_JITTERBUFFER_FD	(AST_MAX_FDS-5)	/*!< used by generator */
171

    
   
171

   
172
enum ast_bridge_result {
172
enum ast_bridge_result {
173
	AST_BRIDGE_COMPLETE = 0,
173
	AST_BRIDGE_COMPLETE = 0,
174
	AST_BRIDGE_FAILED = -1,
174
	AST_BRIDGE_FAILED = -1,
175
	AST_BRIDGE_FAILED_NOWARN = -2,
175
	AST_BRIDGE_FAILED_NOWARN = -2,
176
	AST_BRIDGE_RETRY = -3,
176
	AST_BRIDGE_RETRY = -3,
177
};
177
};
178

    
   
178

   
179
typedef unsigned long long ast_group_t;
179
typedef unsigned long long ast_group_t;
180

    
   
180

   
181
/*! \todo Add an explanation of an Asterisk generator
181
/*! \todo Add an explanation of an Asterisk generator
182
*/
182
*/
183
struct ast_generator {
183
struct ast_generator {
184
	void *(*alloc)(struct ast_channel *chan, void *params);
184
	void *(*alloc)(struct ast_channel *chan, void *params);
185
	/*! Channel is locked during this function callback. */
185
	/*! Channel is locked during this function callback. */
186
	void (*release)(struct ast_channel *chan, void *data);
186
	void (*release)(struct ast_channel *chan, void *data);
187
	/*! This function gets called with the channel unlocked, but is called in
187
	/*! This function gets called with the channel unlocked, but is called in
188
	 *  the context of the channel thread so we know the channel is not going
188
	 *  the context of the channel thread so we know the channel is not going
189
	 *  to disappear.  This callback is responsible for locking the channel as
189
	 *  to disappear.  This callback is responsible for locking the channel as
190
	 *  necessary. */
190
	 *  necessary. */
191
	int (*generate)(struct ast_channel *chan, void *data, int len, int samples);
191
	int (*generate)(struct ast_channel *chan, void *data, int len, int samples);
192
	/*! This gets called when DTMF_END frames are read from the channel */
192
	/*! This gets called when DTMF_END frames are read from the channel */
193
	void (*digit)(struct ast_channel *chan, char digit);
193
	void (*digit)(struct ast_channel *chan, char digit);
194
	/*! This gets called when the write format on a channel is changed while
194
	/*! This gets called when the write format on a channel is changed while
195
	 * generating. The channel is locked during this callback. */
195
	 * generating. The channel is locked during this callback. */
196
	void (*write_format_change)(struct ast_channel *chan, void *data);
196
	void (*write_format_change)(struct ast_channel *chan, void *data);
197
};
197
};
198

    
   
198

   
199
/*! Party name character set enumeration values (values from Q.SIG) */
199
/*! Party name character set enumeration values (values from Q.SIG) */
200
enum AST_PARTY_CHAR_SET {
200
enum AST_PARTY_CHAR_SET {
201
	AST_PARTY_CHAR_SET_UNKNOWN = 0,
201
	AST_PARTY_CHAR_SET_UNKNOWN = 0,
202
	AST_PARTY_CHAR_SET_ISO8859_1 = 1,
202
	AST_PARTY_CHAR_SET_ISO8859_1 = 1,
203
	AST_PARTY_CHAR_SET_WITHDRAWN = 2,/* ITU withdrew this enum value. */
203
	AST_PARTY_CHAR_SET_WITHDRAWN = 2,/* ITU withdrew this enum value. */
204
	AST_PARTY_CHAR_SET_ISO8859_2 = 3,
204
	AST_PARTY_CHAR_SET_ISO8859_2 = 3,
205
	AST_PARTY_CHAR_SET_ISO8859_3 = 4,
205
	AST_PARTY_CHAR_SET_ISO8859_3 = 4,
206
	AST_PARTY_CHAR_SET_ISO8859_4 = 5,
206
	AST_PARTY_CHAR_SET_ISO8859_4 = 5,
207
	AST_PARTY_CHAR_SET_ISO8859_5 = 6,
207
	AST_PARTY_CHAR_SET_ISO8859_5 = 6,
208
	AST_PARTY_CHAR_SET_ISO8859_7 = 7,
208
	AST_PARTY_CHAR_SET_ISO8859_7 = 7,
209
	AST_PARTY_CHAR_SET_ISO10646_BMPSTRING = 8,
209
	AST_PARTY_CHAR_SET_ISO10646_BMPSTRING = 8,
210
	AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING = 9,
210
	AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING = 9,
211
};
211
};
212

    
   
212

   
213
/*!
213
/*!
214
 * \since 1.8
214
 * \since 1.8
215
 * \brief Information needed to specify a name in a call.
215
 * \brief Information needed to specify a name in a call.
216
 * \note All string fields here are malloc'ed, so they need to be
216
 * \note All string fields here are malloc'ed, so they need to be
217
 * freed when the structure is deleted.
217
 * freed when the structure is deleted.
218
 * \note NULL and "" must be considered equivalent.
218
 * \note NULL and "" must be considered equivalent.
219
 */
219
 */
220
struct ast_party_name {
220
struct ast_party_name {
221
	/*! \brief Subscriber name (Malloced) */
221
	/*! \brief Subscriber name (Malloced) */
222
	char *str;
222
	char *str;
223
	/*!
223
	/*!
224
	 * \brief Character set the name is using.
224
	 * \brief Character set the name is using.
225
	 * \see enum AST_PARTY_CHAR_SET
225
	 * \see enum AST_PARTY_CHAR_SET
226
	 * \note
226
	 * \note
227
	 * Set to AST_PARTY_CHAR_SET_ISO8859_1 if unsure what to use.
227
	 * Set to AST_PARTY_CHAR_SET_ISO8859_1 if unsure what to use.
228
	 * \todo Start using the party name character set value.  Not currently used.
228
	 * \todo Start using the party name character set value.  Not currently used.
229
	 */
229
	 */
230
	int char_set;
230
	int char_set;
231
	/*!
231
	/*!
232
	 * \brief Q.931 encoded presentation-indicator encoded field
232
	 * \brief Q.931 encoded presentation-indicator encoded field
233
	 * \note Must tolerate the Q.931 screening-indicator field values being present.
233
	 * \note Must tolerate the Q.931 screening-indicator field values being present.
234
	 */
234
	 */
235
	int presentation;
235
	int presentation;
236
	/*! \brief TRUE if the name information is valid/present */
236
	/*! \brief TRUE if the name information is valid/present */
237
	unsigned char valid;
237
	unsigned char valid;
238
};
238
};
239

    
   
239

   
240
/*!
240
/*!
241
 * \since 1.8
241
 * \since 1.8
242
 * \brief Information needed to specify a number in a call.
242
 * \brief Information needed to specify a number in a call.
243
 * \note All string fields here are malloc'ed, so they need to be
243
 * \note All string fields here are malloc'ed, so they need to be
244
 * freed when the structure is deleted.
244
 * freed when the structure is deleted.
245
 * \note NULL and "" must be considered equivalent.
245
 * \note NULL and "" must be considered equivalent.
246
 */
246
 */
247
struct ast_party_number {
247
struct ast_party_number {
248
	/*! \brief Subscriber phone number (Malloced) */
248
	/*! \brief Subscriber phone number (Malloced) */
249
	char *str;
249
	char *str;
250
	/*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
250
	/*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
251
	int plan;
251
	int plan;
252
	/*! \brief Q.931 presentation-indicator and screening-indicator encoded fields */
252
	/*! \brief Q.931 presentation-indicator and screening-indicator encoded fields */
253
	int presentation;
253
	int presentation;
254
	/*! \brief TRUE if the number information is valid/present */
254
	/*! \brief TRUE if the number information is valid/present */
255
	unsigned char valid;
255
	unsigned char valid;
256
};
256
};
257

    
   
257

   
258
/*!
258
/*!
259
 * \since 1.8
259
 * \since 1.8
260
 * \brief Information needed to specify a subaddress in a call.
260
 * \brief Information needed to specify a subaddress in a call.
261
 * \note All string fields here are malloc'ed, so they need to be
261
 * \note All string fields here are malloc'ed, so they need to be
262
 * freed when the structure is deleted.
262
 * freed when the structure is deleted.
263
 * \note NULL and "" must be considered equivalent.
263
 * \note NULL and "" must be considered equivalent.
264
 */
264
 */
265
struct ast_party_subaddress {
265
struct ast_party_subaddress {
266
	/*!
266
	/*!
267
	 * \brief Malloced subaddress string.
267
	 * \brief Malloced subaddress string.
268
	 * \note If the subaddress type is user specified then the subaddress is
268
	 * \note If the subaddress type is user specified then the subaddress is
269
	 * a string of ASCII hex because the actual subaddress is likely BCD encoded.
269
	 * a string of ASCII hex because the actual subaddress is likely BCD encoded.
270
	 */
270
	 */
271
	char *str;
271
	char *str;
272
	/*!
272
	/*!
273
	 * \brief Q.931 subaddress type.
273
	 * \brief Q.931 subaddress type.
274
	 * \details
274
	 * \details
275
	 * nsap(0),
275
	 * nsap(0),
276
	 * user_specified(2)
276
	 * user_specified(2)
277
	 */
277
	 */
278
	int type;
278
	int type;
279
	/*!
279
	/*!
280
	 * \brief TRUE if odd number of address signals
280
	 * \brief TRUE if odd number of address signals
281
	 * \note The odd/even indicator is used when the type of subaddress is
281
	 * \note The odd/even indicator is used when the type of subaddress is
282
	 * user_specified and the coding is BCD.
282
	 * user_specified and the coding is BCD.
283
	 */
283
	 */
284
	unsigned char odd_even_indicator;
284
	unsigned char odd_even_indicator;
285
	/*! \brief TRUE if the subaddress information is valid/present */
285
	/*! \brief TRUE if the subaddress information is valid/present */
286
	unsigned char valid;
286
	unsigned char valid;
287
};
287
};
288

    
   
288

   
289
/*!
289
/*!
290
 * \since 1.8
290
 * \since 1.8
291
 * \brief Information needed to identify an endpoint in a call.
291
 * \brief Information needed to identify an endpoint in a call.
292
 * \note All string fields here are malloc'ed, so they need to be
292
 * \note All string fields here are malloc'ed, so they need to be
293
 * freed when the structure is deleted.
293
 * freed when the structure is deleted.
294
 * \note NULL and "" must be considered equivalent.
294
 * \note NULL and "" must be considered equivalent.
295
 */
295
 */
296
struct ast_party_id {
296
struct ast_party_id {
297
	/*! \brief Subscriber name */
297
	/*! \brief Subscriber name */
298
	struct ast_party_name name;
298
	struct ast_party_name name;
299
	/*! \brief Subscriber phone number */
299
	/*! \brief Subscriber phone number */
300
	struct ast_party_number number;
300
	struct ast_party_number number;
301
	/*! \brief Subscriber subaddress. */
301
	/*! \brief Subscriber subaddress. */
302
	struct ast_party_subaddress subaddress;
302
	struct ast_party_subaddress subaddress;
303

    
   
303

   
304
	/*!
304
	/*!
305
	 * \brief User-set "tag"
305
	 * \brief User-set "tag"
306
	 * \details
306
	 * \details
307
	 * A user-settable field used to help associate some extrinsic information
307
	 * A user-settable field used to help associate some extrinsic information
308
	 * about the channel or user of the channel to the party ID.  This information
308
	 * about the channel or user of the channel to the party ID.  This information
309
	 * is normally not transmitted over the wire and so is only useful within an
309
	 * is normally not transmitted over the wire and so is only useful within an
310
	 * Asterisk environment.
310
	 * Asterisk environment.
311
	 */
311
	 */
312
	char *tag;
312
	char *tag;
313
};
313
};
314

    
   
314

   
315
/*!
315
/*!
316
 * \since 1.8
316
 * \since 1.8
317
 * \brief Indicate what information in ast_party_id should be set.
317
 * \brief Indicate what information in ast_party_id should be set.
318
 */
318
 */
319
struct ast_set_party_id {
319
struct ast_set_party_id {
320
	/*! TRUE if the ast_party_name information should be set. */
320
	/*! TRUE if the ast_party_name information should be set. */
321
	unsigned char name;
321
	unsigned char name;
322
	/*! TRUE if the ast_party_number information should be set. */
322
	/*! TRUE if the ast_party_number information should be set. */
323
	unsigned char number;
323
	unsigned char number;
324
	/*! TRUE if the ast_party_subaddress information should be set. */
324
	/*! TRUE if the ast_party_subaddress information should be set. */
325
	unsigned char subaddress;
325
	unsigned char subaddress;
326
};
326
};
327

    
   
327

   
328
/*!
328
/*!
329
 * \since 1.8
329
 * \since 1.8
330
 * \brief Dialed/Called Party information.
330
 * \brief Dialed/Called Party information.
331
 * \note Dialed Number Identifier (DNID)
331
 * \note Dialed Number Identifier (DNID)
332
 * \note All string fields here are malloc'ed, so they need to be
332
 * \note All string fields here are malloc'ed, so they need to be
333
 * freed when the structure is deleted.
333
 * freed when the structure is deleted.
334
 * \note NULL and "" must be considered equivalent.
334
 * \note NULL and "" must be considered equivalent.
335
 */
335
 */
336
struct ast_party_dialed {
336
struct ast_party_dialed {
337
	/*!
337
	/*!
338
	 * \brief Dialed/Called number
338
	 * \brief Dialed/Called number
339
	 * \note Done this way in case we ever really need to use ast_party_number.
339
	 * \note Done this way in case we ever really need to use ast_party_number.
340
	 * We currently do not need all of the ast_party_number fields.
340
	 * We currently do not need all of the ast_party_number fields.
341
	 */
341
	 */
342
	struct {
342
	struct {
343
		/*! \brief Subscriber phone number (Malloced) */
343
		/*! \brief Subscriber phone number (Malloced) */
344
		char *str;
344
		char *str;
345
		/*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
345
		/*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
346
		int plan;
346
		int plan;
347
	} number;
347
	} number;
348
	/*! \brief Dialed/Called subaddress */
348
	/*! \brief Dialed/Called subaddress */
349
	struct ast_party_subaddress subaddress;
349
	struct ast_party_subaddress subaddress;
350
	/*!
350
	/*!
351
	 * \brief Transit Network Select
351
	 * \brief Transit Network Select
352
	 * \note Currently this value is just passed around the system.
352
	 * \note Currently this value is just passed around the system.
353
	 * You can read it and set it but it is never used for anything.
353
	 * You can read it and set it but it is never used for anything.
354
	 */
354
	 */
355
	int transit_network_select;
355
	int transit_network_select;
356
};
356
};
357

    
   
357

   
358
/*!
358
/*!
359
 * \since 1.8
359
 * \since 1.8
360
 * \brief Caller Party information.
360
 * \brief Caller Party information.
361
 * \note All string fields here are malloc'ed, so they need to be
361
 * \note All string fields here are malloc'ed, so they need to be
362
 * freed when the structure is deleted.
362
 * freed when the structure is deleted.
363
 * \note NULL and "" must be considered equivalent.
363
 * \note NULL and "" must be considered equivalent.
364
 *
364
 *
365
 * \note SIP and IAX2 has UTF8 encoded Unicode Caller ID names.
365
 * \note SIP and IAX2 has UTF8 encoded Unicode Caller ID names.
366
 * In some cases, we also have an alternative (RPID) E.164 number that can
366
 * In some cases, we also have an alternative (RPID) E.164 number that can
367
 * be used as Caller ID on numeric E.164 phone networks (DAHDI or SIP/IAX2 to
367
 * be used as Caller ID on numeric E.164 phone networks (DAHDI or SIP/IAX2 to
368
 * PSTN gateway).
368
 * PSTN gateway).
369
 *
369
 *
370
 * \todo Implement settings for transliteration between UTF8 Caller ID names in
370
 * \todo Implement settings for transliteration between UTF8 Caller ID names in
371
 *       to ASCII Caller ID's (DAHDI). Östen Åsklund might be transliterated into
371
 *       to ASCII Caller ID's (DAHDI). Östen Åsklund might be transliterated into
372
 *       Osten Asklund or Oesten Aasklund depending upon language and person...
372
 *       Osten Asklund or Oesten Aasklund depending upon language and person...
373
 *       We need automatic routines for incoming calls and static settings for
373
 *       We need automatic routines for incoming calls and static settings for
374
 *       our own accounts.
374
 *       our own accounts.
375
 */
375
 */
376
struct ast_party_caller {
376
struct ast_party_caller {
377
	/*! \brief Caller party ID */
377
	/*! \brief Caller party ID */
378
	struct ast_party_id id;
378
	struct ast_party_id id;
379

    
   
379

   
380
	/*!
380
	/*!
381
	 * \brief Automatic Number Identification (ANI)
381
	 * \brief Automatic Number Identification (ANI)
382
	 * \note The name subcomponent is only likely to be used by SIP.
382
	 * \note The name subcomponent is only likely to be used by SIP.
383
	 * \note The subaddress subcomponent is not likely to be used.
383
	 * \note The subaddress subcomponent is not likely to be used.
384
	 */
384
	 */
385
	struct ast_party_id ani;
385
	struct ast_party_id ani;
386

    
   
386

   
387
	/*! \brief Private caller party ID */
387
	/*! \brief Private caller party ID */
388
	struct ast_party_id priv;
388
	struct ast_party_id priv;
389

    
   
389

   
390
	/*! \brief Automatic Number Identification 2 (Info Digits) */
390
	/*! \brief Automatic Number Identification 2 (Info Digits) */
391
	int ani2;
391
	int ani2;
392
};
392
};
393

    
   
393

   
394
/*!
394
/*!
395
 * \since 1.8
395
 * \since 1.8
396
 * \brief Indicate what information in ast_party_caller should be set.
396
 * \brief Indicate what information in ast_party_caller should be set.
397
 */
397
 */
398
struct ast_set_party_caller {
398
struct ast_set_party_caller {
399
	/*! What caller id information to set. */
399
	/*! What caller id information to set. */
400
	struct ast_set_party_id id;
400
	struct ast_set_party_id id;
401
	/*! What ANI id information to set. */
401
	/*! What ANI id information to set. */
402
	struct ast_set_party_id ani;
402
	struct ast_set_party_id ani;
403
	/*! What private caller id information to set. */
403
	/*! What private caller id information to set. */
404
	struct ast_set_party_id priv;
404
	struct ast_set_party_id priv;
405
};
405
};
406

    
   
406

   
407
/*!
407
/*!
408
 * \since 1.8
408
 * \since 1.8
409
 * \brief Connected Line/Party information.
409
 * \brief Connected Line/Party information.
410
 * \note All string fields here are malloc'ed, so they need to be
410
 * \note All string fields here are malloc'ed, so they need to be
411
 * freed when the structure is deleted.
411
 * freed when the structure is deleted.
412
 * \note NULL and "" must be considered equivalent.
412
 * \note NULL and "" must be considered equivalent.
413
 */
413
 */
414
struct ast_party_connected_line {
414
struct ast_party_connected_line {
415
	/*! \brief Connected party ID */
415
	/*! \brief Connected party ID */
416
	struct ast_party_id id;
416
	struct ast_party_id id;
417

    
   
417

   
418
	/*!
418
	/*!
419
	 * \brief Automatic Number Identification (ANI)
419
	 * \brief Automatic Number Identification (ANI)
420
	 * \note Not really part of connected line data but needed to
420
	 * \note Not really part of connected line data but needed to
421
	 * save the corresponding caller id value.
421
	 * save the corresponding caller id value.
422
	 */
422
	 */
423
	struct ast_party_id ani;
423
	struct ast_party_id ani;
424

    
   
424

   
425
	/*! \brief Private connected party ID */
425
	/*! \brief Private connected party ID */
426
	struct ast_party_id priv;
426
	struct ast_party_id priv;
427

    
   
427

   
428
	/*!
428
	/*!
429
	 * \brief Automatic Number Identification 2 (Info Digits)
429
	 * \brief Automatic Number Identification 2 (Info Digits)
430
	 * \note Not really part of connected line data but needed to
430
	 * \note Not really part of connected line data but needed to
431
	 * save the corresponding caller id value.
431
	 * save the corresponding caller id value.
432
	 */
432
	 */
433
	int ani2;
433
	int ani2;
434

    
   
434

   
435
	/*!
435
	/*!
436
	 * \brief Information about the source of an update.
436
	 * \brief Information about the source of an update.
437
	 * \note enum AST_CONNECTED_LINE_UPDATE_SOURCE values
437
	 * \note enum AST_CONNECTED_LINE_UPDATE_SOURCE values
438
	 * for Normal-Answer and Call-transfer.
438
	 * for Normal-Answer and Call-transfer.
439
	 */
439
	 */
440
	int source;
440
	int source;
441
};
441
};
442

    
   
442

   
443
/*!
443
/*!
444
 * \since 1.8
444
 * \since 1.8
445
 * \brief Indicate what information in ast_party_connected_line should be set.
445
 * \brief Indicate what information in ast_party_connected_line should be set.
446
 */
446
 */
447
struct ast_set_party_connected_line {
447
struct ast_set_party_connected_line {
448
	/*! What connected line id information to set. */
448
	/*! What connected line id information to set. */
449
	struct ast_set_party_id id;
449
	struct ast_set_party_id id;
450
	/*! What ANI id information to set. */
450
	/*! What ANI id information to set. */
451
	struct ast_set_party_id ani;
451
	struct ast_set_party_id ani;
452
	/*! What private connected line id information to set. */
452
	/*! What private connected line id information to set. */
453
	struct ast_set_party_id priv;
453
	struct ast_set_party_id priv;
454
};
454
};
455

    
   
455

   
456
/*!
456
/*!
457
 * \brief Redirecting reason information
457
 * \brief Redirecting reason information
458
 */
458
 */
459
struct ast_party_redirecting_reason {
459
struct ast_party_redirecting_reason {
460
	/*! \brief a string value for the redirecting reason
460
	/*! \brief a string value for the redirecting reason
461
	 *
461
	 *
462
	 * Useful for cases where an endpoint has specified a redirecting reason
462
	 * Useful for cases where an endpoint has specified a redirecting reason
463
	 * that does not correspond to an enum AST_REDIRECTING_REASON
463
	 * that does not correspond to an enum AST_REDIRECTING_REASON
464
	 */
464
	 */
465
	char *str;
465
	char *str;
466

    
   
466

   
467
	/*! \brief enum AST_REDIRECTING_REASON value for redirection */
467
	/*! \brief enum AST_REDIRECTING_REASON value for redirection */
468
	int code;
468
	int code;
469
};
469
};
470

    
   
470

   
471
/*!
471
/*!
472
 * \since 1.8
472
 * \since 1.8
473
 * \brief Redirecting Line information.
473
 * \brief Redirecting Line information.
474
 * RDNIS (Redirecting Directory Number Information Service)
474
 * RDNIS (Redirecting Directory Number Information Service)
475
 * Where a call diversion or transfer was invoked.
475
 * Where a call diversion or transfer was invoked.
476
 * \note All string fields here are malloc'ed, so they need to be
476
 * \note All string fields here are malloc'ed, so they need to be
477
 * freed when the structure is deleted.
477
 * freed when the structure is deleted.
478
 * \note NULL and "" must be considered equivalent.
478
 * \note NULL and "" must be considered equivalent.
479
 */
479
 */
480
struct ast_party_redirecting {
480
struct ast_party_redirecting {
481
	/*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) */
481
	/*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) */
482
	struct ast_party_id orig;
482
	struct ast_party_id orig;
483

    
   
483

   
484
	/*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */
484
	/*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */
485
	struct ast_party_id from;
485
	struct ast_party_id from;
486

    
   
486

   
487
	/*! \brief Call is redirecting to a new party (Sent to the caller) */
487
	/*! \brief Call is redirecting to a new party (Sent to the caller) */
488
	struct ast_party_id to;
488
	struct ast_party_id to;
489

    
   
489

   
490
	/*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) - private representation */
490
	/*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) - private representation */
491
	struct ast_party_id priv_orig;
491
	struct ast_party_id priv_orig;
492

    
   
492

   
493
	/*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) - private representation */
493
	/*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) - private representation */
494
	struct ast_party_id priv_from;
494
	struct ast_party_id priv_from;
495

    
   
495

   
496
	/*! \brief Call is redirecting to a new party (Sent to the caller)  - private representation */
496
	/*! \brief Call is redirecting to a new party (Sent to the caller)  - private representation */
497
	struct ast_party_id priv_to;
497
	struct ast_party_id priv_to;
498

    
   
498

   
499
	/*! \brief Reason for the redirection */
499
	/*! \brief Reason for the redirection */
500
	struct ast_party_redirecting_reason reason;
500
	struct ast_party_redirecting_reason reason;
501

    
   
501

   
502
	/*! \brief Reason for the redirection by the original party */
502
	/*! \brief Reason for the redirection by the original party */
503
	struct ast_party_redirecting_reason orig_reason;
503
	struct ast_party_redirecting_reason orig_reason;
504

    
   
504

   
505
	/*! \brief Number of times the call was redirected */
505
	/*! \brief Number of times the call was redirected */
506
	int count;
506
	int count;
507
};
507
};
508

    
   
508

   
509
/*!
509
/*!
510
 * \since 1.8
510
 * \since 1.8
511
 * \brief Indicate what information in ast_party_redirecting should be set.
511
 * \brief Indicate what information in ast_party_redirecting should be set.
512
 */
512
 */
513
struct ast_set_party_redirecting {
513
struct ast_set_party_redirecting {
514
	/*! What redirecting-orig id information to set. */
514
	/*! What redirecting-orig id information to set. */
515
	struct ast_set_party_id orig;
515
	struct ast_set_party_id orig;
516
	/*! What redirecting-from id information to set. */
516
	/*! What redirecting-from id information to set. */
517
	struct ast_set_party_id from;
517
	struct ast_set_party_id from;
518
	/*! What redirecting-to id information to set. */
518
	/*! What redirecting-to id information to set. */
519
	struct ast_set_party_id to;
519
	struct ast_set_party_id to;
520
	/*! What private redirecting-orig id information to set. */
520
	/*! What private redirecting-orig id information to set. */
521
	struct ast_set_party_id priv_orig;
521
	struct ast_set_party_id priv_orig;
522
	/*! What private redirecting-from id information to set. */
522
	/*! What private redirecting-from id information to set. */
523
	struct ast_set_party_id priv_from;
523
	struct ast_set_party_id priv_from;
524
	/*! What private redirecting-to id information to set. */
524
	/*! What private redirecting-to id information to set. */
525
	struct ast_set_party_id priv_to;
525
	struct ast_set_party_id priv_to;
526
};
526
};
527

    
   
527

   
528
/*!
528
/*!
529
 * \brief Typedef for a custom read function
529
 * \brief Typedef for a custom read function
530
 * \note data should be treated as const char *.
530
 * \note data should be treated as const char *.
531
 */
531
 */
532
typedef int (*ast_acf_read_fn_t)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
532
typedef int (*ast_acf_read_fn_t)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
533

    
   
533

   
534
/*!
534
/*!
535
 * \brief Typedef for a custom read2 function
535
 * \brief Typedef for a custom read2 function
536
 * \note data should be treated as const char *.
536
 * \note data should be treated as const char *.
537
 */
537
 */
538
typedef int (*ast_acf_read2_fn_t)(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len);
538
typedef int (*ast_acf_read2_fn_t)(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len);
539

    
   
539

   
540
/*!
540
/*!
541
 * \brief Typedef for a custom write function
541
 * \brief Typedef for a custom write function
542
 * \note data should be treated as const char *.
542
 * \note data should be treated as const char *.
543
 */
543
 */
544
typedef int (*ast_acf_write_fn_t)(struct ast_channel *chan, const char *function, char *data, const char *value);
544
typedef int (*ast_acf_write_fn_t)(struct ast_channel *chan, const char *function, char *data, const char *value);
545

    
   
545

   
546
/*! \brief Structure to handle passing func_channel_write info to channels via setoption */
546
/*! \brief Structure to handle passing func_channel_write info to channels via setoption */
547
typedef struct {
547
typedef struct {
548
	/*! \brief ast_chan_write_info_t version. Must be incremented if structure is changed */
548
	/*! \brief ast_chan_write_info_t version. Must be incremented if structure is changed */
549
	#define AST_CHAN_WRITE_INFO_T_VERSION 1
549
	#define AST_CHAN_WRITE_INFO_T_VERSION 1
550
	uint32_t version;
550
	uint32_t version;
551
	ast_acf_write_fn_t write_fn;
551
	ast_acf_write_fn_t write_fn;
552
	struct ast_channel *chan;
552
	struct ast_channel *chan;
553
	const char *function;
553
	const char *function;
554
	char *data;
554
	char *data;
555
	const char *value;
555
	const char *value;
556
} ast_chan_write_info_t;
556
} ast_chan_write_info_t;
557

    
   
557

   
558
/*!
558
/*!
559
 * \brief
559
 * \brief
560
 * Structure to describe a channel "technology", ie a channel driver
560
 * Structure to describe a channel "technology", ie a channel driver
561
 * See for examples:
561
 * See for examples:
562
 * \arg chan_iax2.c - The Inter-Asterisk exchange protocol
562
 * \arg chan_iax2.c - The Inter-Asterisk exchange protocol
563
 * \arg chan_sip.c - The SIP channel driver
563
 * \arg chan_sip.c - The SIP channel driver
564
 * \arg chan_dahdi.c - PSTN connectivity (TDM, PRI, T1/E1, FXO, FXS)
564
 * \arg chan_dahdi.c - PSTN connectivity (TDM, PRI, T1/E1, FXO, FXS)
565
 *
565
 *
566
 * \details
566
 * \details
567
 * If you develop your own channel driver, this is where you
567
 * If you develop your own channel driver, this is where you
568
 * tell the PBX at registration of your driver what properties
568
 * tell the PBX at registration of your driver what properties
569
 * this driver supports and where different callbacks are
569
 * this driver supports and where different callbacks are
570
 * implemented.
570
 * implemented.
571
 */
571
 */
572
struct ast_channel_tech {
572
struct ast_channel_tech {
573
	const char * const type;
573
	const char * const type;
574
	const char * const description;
574
	const char * const description;
575

    
   
575

   
576
	struct ast_format_cap *capabilities;  /*!< format capabilities this channel can handle */
576
	struct ast_format_cap *capabilities;  /*!< format capabilities this channel can handle */
577

    
   
577

   
578
	int properties;         /*!< Technology Properties */
578
	int properties;         /*!< Technology Properties */
579

    
   
579

   
580
	/*!
580
	/*!
581
	 * \brief Requester - to set up call data structures (pvt's)
581
	 * \brief Requester - to set up call data structures (pvt's)
582
	 *
582
	 *
583
	 * \param type type of channel to request
583
	 * \param type type of channel to request
584
	 * \param cap Format capabilities for requested channel
584
	 * \param cap Format capabilities for requested channel
585
	 * \param requestor channel asking for data
585
	 * \param requestor channel asking for data
586
	 * \param addr destination of the call
586
	 * \param addr destination of the call
587
	 * \param cause Cause of failure
587
	 * \param cause Cause of failure
588
	 *
588
	 *
589
	 * \details
589
	 * \details
590
	 * Request a channel of a given type, with addr as optional information used
590
	 * Request a channel of a given type, with addr as optional information used
591
	 * by the low level module
591
	 * by the low level module
592
	 *
592
	 *
593
	 * \retval NULL failure
593
	 * \retval NULL failure
594
	 * \retval non-NULL channel on success
594
	 * \retval non-NULL channel on success
595
	 */
595
	 */
596
	struct ast_channel *(* const requester)(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr, int *cause);
596
	struct ast_channel *(* const requester)(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr, int *cause);
597

    
   
597

   
598
	int (* const devicestate)(const char *device_number);	/*!< Devicestate call back */
598
	int (* const devicestate)(const char *device_number);	/*!< Devicestate call back */
599

    
   
599

   
600
	/*!
600
	/*!
601
	 * \brief Start sending a literal DTMF digit
601
	 * \brief Start sending a literal DTMF digit
602
	 *
602
	 *
603
	 * \note The channel is not locked when this function gets called.
603
	 * \note The channel is not locked when this function gets called.
604
	 */
604
	 */
605
	int (* const send_digit_begin)(struct ast_channel *chan, char digit);
605
	int (* const send_digit_begin)(struct ast_channel *chan, char digit);
606

    
   
606

   
607
	/*!
607
	/*!
608
	 * \brief Stop sending a literal DTMF digit
608
	 * \brief Stop sending a literal DTMF digit
609
	 *
609
	 *
610
	 * \note The channel is not locked when this function gets called.
610
	 * \note The channel is not locked when this function gets called.
611
	 */
611
	 */
612
	int (* const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration);
612
	int (* const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration);
613

    
   
613

   
614
	/*!
614
	/*!
615
	 * \brief Make a call
615
	 * \brief Make a call
616
	 * \note The channel is locked when called.
616
	 * \note The channel is locked when called.
617
	 * \param chan which channel to make the call on
617
	 * \param chan which channel to make the call on
618
	 * \param addr destination of the call
618
	 * \param addr destination of the call
619
	 * \param timeout time to wait on for connect (Doesn't seem to be used.)
619
	 * \param timeout time to wait on for connect (Doesn't seem to be used.)
620
	 * \retval 0 on success
620
	 * \retval 0 on success
621
	 * \retval -1 on failure
621
	 * \retval -1 on failure
622
	 */
622
	 */
623
	int (* const call)(struct ast_channel *chan, const char *addr, int timeout);
623
	int (* const call)(struct ast_channel *chan, const char *addr, int timeout);
624

    
   
624

   
625
	/*! \brief Hangup (and possibly destroy) the channel */
625
	/*! \brief Hangup (and possibly destroy) the channel */
626
	int (* const hangup)(struct ast_channel *chan);
626
	int (* const hangup)(struct ast_channel *chan);
627

    
   
627

   
628
	/*! \brief Answer the channel */
628
	/*! \brief Answer the channel */
629
	int (* const answer)(struct ast_channel *chan);
629
	int (* const answer)(struct ast_channel *chan);
630

    
   
630

   
631
	/*! \brief Read a frame, in standard format (see frame.h) */
631
	/*! \brief Read a frame, in standard format (see frame.h) */
632
	struct ast_frame * (* const read)(struct ast_channel *chan);
632
	struct ast_frame * (* const read)(struct ast_channel *chan);
633

    
   
633

   
634
	/*! \brief Write a frame, in standard format (see frame.h) */
634
	/*! \brief Write a frame, in standard format (see frame.h) */
635
	int (* const write)(struct ast_channel *chan, struct ast_frame *frame);
635
	int (* const write)(struct ast_channel *chan, struct ast_frame *frame);
636

    
   
636

   
637
	/*! \brief Display or transmit text */
637
	/*! \brief Display or transmit text */
638
	int (* const send_text)(struct ast_channel *chan, const char *text);
638
	int (* const send_text)(struct ast_channel *chan, const char *text);
639

    
   
639

   
640
	/*! \brief Display or send an image */
640
	/*! \brief Display or send an image */
641
	int (* const send_image)(struct ast_channel *chan, struct ast_frame *frame);
641
	int (* const send_image)(struct ast_channel *chan, struct ast_frame *frame);
642

    
   
642

   
643
	/*! \brief Send HTML data */
643
	/*! \brief Send HTML data */
644
	int (* const send_html)(struct ast_channel *chan, int subclass, const char *data, int len);
644
	int (* const send_html)(struct ast_channel *chan, int subclass, const char *data, int len);
645

    
   
645

   
646
	/*! \brief Handle an exception, reading a frame */
646
	/*! \brief Handle an exception, reading a frame */
647
	struct ast_frame * (* const exception)(struct ast_channel *chan);
647
	struct ast_frame * (* const exception)(struct ast_channel *chan);
648

    
   
648

   
649
/* BUGBUG this tech callback is to be removed. */
649
/* BUGBUG this tech callback is to be removed. */
650
	/*! \brief Bridge two channels of the same type together */
650
	/*! \brief Bridge two channels of the same type together */
651
	enum ast_bridge_result (* const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags,
651
	enum ast_bridge_result (* const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags,
652
						struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
652
						struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
653

    
   
653

   
654
	/*! \brief Bridge two channels of the same type together (early) */
654
	/*! \brief Bridge two channels of the same type together (early) */
655
	enum ast_bridge_result (* const early_bridge)(struct ast_channel *c0, struct ast_channel *c1);
655
	enum ast_bridge_result (* const early_bridge)(struct ast_channel *c0, struct ast_channel *c1);
656

    
   
656

   
657
	/*! \brief Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */
657
	/*! \brief Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */
658
	int (* const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen);
658
	int (* const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen);
659

    
   
659

   
660
	/*! \brief Fix up a channel:  If a channel is consumed, this is called.  Basically update any ->owner links */
660
	/*! \brief Fix up a channel:  If a channel is consumed, this is called.  Basically update any ->owner links */
661
	int (* const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan);
661
	int (* const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan);
662

    
   
662

   
663
	/*! \brief Set a given option. Called with chan locked */
663
	/*! \brief Set a given option. Called with chan locked */
664
	int (* const setoption)(struct ast_channel *chan, int option, void *data, int datalen);
664
	int (* const setoption)(struct ast_channel *chan, int option, void *data, int datalen);
665

    
   
665

   
666
	/*! \brief Query a given option. Called with chan locked */
666
	/*! \brief Query a given option. Called with chan locked */
667
	int (* const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen);
667
	int (* const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen);
668

    
   
668

   
669
	/*! \brief Blind transfer other side (see app_transfer.c and ast_transfer() */
669
	/*! \brief Blind transfer other side (see app_transfer.c and ast_transfer() */
670
	int (* const transfer)(struct ast_channel *chan, const char *newdest);
670
	int (* const transfer)(struct ast_channel *chan, const char *newdest);
671

    
   
671

   
672
	/*! \brief Write a frame, in standard format */
672
	/*! \brief Write a frame, in standard format */
673
	int (* const write_video)(struct ast_channel *chan, struct ast_frame *frame);
673
	int (* const write_video)(struct ast_channel *chan, struct ast_frame *frame);
674

    
   
674

   
675
	/*! \brief Write a text frame, in standard format */
675
	/*! \brief Write a text frame, in standard format */
676
	int (* const write_text)(struct ast_channel *chan, struct ast_frame *frame);
676
	int (* const write_text)(struct ast_channel *chan, struct ast_frame *frame);
677

    
   
677

   
678
/* BUGBUG this tech callback is to be removed. */
678
/* BUGBUG this tech callback is to be removed. */
679
	/*! \brief Find bridged channel */
679
	/*! \brief Find bridged channel */
680
	struct ast_channel *(* const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge);
680
	struct ast_channel *(* const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge);
681

    
   
681

   
682
	/*!
682
	/*!
683
	 * \brief Provide additional read items for CHANNEL() dialplan function
683
	 * \brief Provide additional read items for CHANNEL() dialplan function
684
	 * \note data should be treated as a const char *.
684
	 * \note data should be treated as a const char *.
685
	 */
685
	 */
686
	int (* func_channel_read)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
686
	int (* func_channel_read)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
687

    
   
687

   
688
	/*!
688
	/*!
689
	 * \brief Provide additional write items for CHANNEL() dialplan function
689
	 * \brief Provide additional write items for CHANNEL() dialplan function
690
	 * \note data should be treated as a const char *.
690
	 * \note data should be treated as a const char *.
691
	 */
691
	 */
692
	int (* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value);
692
	int (* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value);
693

    
   
693

   
694
/* BUGBUG this tech callback is to be removed. */
694
/* BUGBUG this tech callback is to be removed. */
695
	/*! \brief Retrieve base channel (agent and local) */
695
	/*! \brief Retrieve base channel (agent and local) */
696
	struct ast_channel* (* get_base_channel)(struct ast_channel *chan);
696
	struct ast_channel* (* get_base_channel)(struct ast_channel *chan);
697

    
   
697

   
698
	/*! \brief Set base channel (agent and local) */
698
	/*! \brief Set base channel (agent and local) */
699
	int (* set_base_channel)(struct ast_channel *chan, struct ast_channel *base);
699
	int (* set_base_channel)(struct ast_channel *chan, struct ast_channel *base);
700

    
   
700

   
701
	/*! \brief Get the unique identifier for the PVT, i.e. SIP call-ID for SIP */
701
	/*! \brief Get the unique identifier for the PVT, i.e. SIP call-ID for SIP */
702
	const char * (* get_pvt_uniqueid)(struct ast_channel *chan);
702
	const char * (* get_pvt_uniqueid)(struct ast_channel *chan);
703

    
   
703

   
704
	/*! \brief Call a function with cc parameters as a function parameter
704
	/*! \brief Call a function with cc parameters as a function parameter
705
	 *
705
	 *
706
	 * \details
706
	 * \details
707
	 * This is a highly specialized callback that is not likely to be needed in many
707
	 * This is a highly specialized callback that is not likely to be needed in many
708
	 * channel drivers. When dealing with a busy channel, for instance, most channel
708
	 * channel drivers. When dealing with a busy channel, for instance, most channel
709
	 * drivers will successfully return a channel to the requester. Once called, the channel
709
	 * drivers will successfully return a channel to the requester. Once called, the channel
710
	 * can then queue a busy frame when it receives an appropriate message from the far end.
710
	 * can then queue a busy frame when it receives an appropriate message from the far end.
711
	 * In such a case, the channel driver has the opportunity to also queue a CC frame.
711
	 * In such a case, the channel driver has the opportunity to also queue a CC frame.
712
	 * The parameters for the CC channel can be retrieved from the channel structure.
712
	 * The parameters for the CC channel can be retrieved from the channel structure.
713
	 *
713
	 *
714
	 * For other channel drivers, notably those that deal with "dumb" phones, the channel
714
	 * For other channel drivers, notably those that deal with "dumb" phones, the channel
715
	 * driver will not return a channel when one is requested. In such a scenario, there is never
715
	 * driver will not return a channel when one is requested. In such a scenario, there is never
716
	 * an opportunity for the channel driver to queue a CC frame since the channel is never
716
	 * an opportunity for the channel driver to queue a CC frame since the channel is never
717
	 * called. Furthermore, it is not possible to retrieve the CC configuration parameters
717
	 * called. Furthermore, it is not possible to retrieve the CC configuration parameters
718
	 * for the desired channel because no channel is ever allocated or returned to the
718
	 * for the desired channel because no channel is ever allocated or returned to the
719
	 * requester. In such a case, call completion may still be a viable option. What we do is
719
	 * requester. In such a case, call completion may still be a viable option. What we do is
720
	 * pass the same string that the requester used originally to request the channel to the
720
	 * pass the same string that the requester used originally to request the channel to the
721
	 * channel driver. The channel driver can then find any potential channels/devices that
721
	 * channel driver. The channel driver can then find any potential channels/devices that
722
	 * match the input and return call the designated callback with the device's call completion
722
	 * match the input and return call the designated callback with the device's call completion
723
	 * parameters as a parameter.
723
	 * parameters as a parameter.
724
	 */
724
	 */
725
	int (* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback);
725
	int (* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback);
726

    
   
726

   
727
	/*!
727
	/*!
728
	 * \brief Execute a Gosub call on the channel in a technology specific way before a call is placed.
728
	 * \brief Execute a Gosub call on the channel in a technology specific way before a call is placed.
729
	 * \since 11.0
729
	 * \since 11.0
730
	 *
730
	 *
731
	 * \param chan Channel to execute Gosub in a tech specific way.
731
	 * \param chan Channel to execute Gosub in a tech specific way.
732
	 * \param sub_args Gosub application parameter string.
732
	 * \param sub_args Gosub application parameter string.
733
	 *
733
	 *
734
	 * \note The chan is locked before calling.
734
	 * \note The chan is locked before calling.
735
	 *
735
	 *
736
	 * \retval 0 on success.
736
	 * \retval 0 on success.
737
	 * \retval -1 on error.
737
	 * \retval -1 on error.
738
	 */
738
	 */
739
	int (*pre_call)(struct ast_channel *chan, const char *sub_args);
739
	int (*pre_call)(struct ast_channel *chan, const char *sub_args);
740
};
740
};
741

    
   
741

   
742
/*! Kill the channel channel driver technology descriptor. */
742
/*! Kill the channel channel driver technology descriptor. */
743
extern const struct ast_channel_tech ast_kill_tech;
743
extern const struct ast_channel_tech ast_kill_tech;
744

    
   
744

   
745
struct ast_epoll_data;
745
struct ast_epoll_data;
746

    
   
746

   
747
/*!
747
/*!
748
 * The high bit of the frame count is used as a debug marker, so
748
 * The high bit of the frame count is used as a debug marker, so
749
 * increments of the counters must be done with care.
749
 * increments of the counters must be done with care.
750
 * Please use c->fin = FRAMECOUNT_INC(c->fin) and the same for c->fout.
750
 * Please use c->fin = FRAMECOUNT_INC(c->fin) and the same for c->fout.
751
 */
751
 */
752
#define	DEBUGCHAN_FLAG  0x80000000
752
#define	DEBUGCHAN_FLAG  0x80000000
753

    
   
753

   
754
/* XXX not ideal to evaluate x twice... */
754
/* XXX not ideal to evaluate x twice... */
755
#define	FRAMECOUNT_INC(x)	( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) )
755
#define	FRAMECOUNT_INC(x)	( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) )
756

    
   
756

   
757
/*!
757
/*!
758
 * The current value of the debug flags is stored in the two
758
 * The current value of the debug flags is stored in the two
759
 * variables global_fin and global_fout (declared in main/channel.c)
759
 * variables global_fin and global_fout (declared in main/channel.c)
760
 */
760
 */
761
extern unsigned long global_fin, global_fout;
761
extern unsigned long global_fin, global_fout;
762

    
   
762

   
763
enum ast_channel_adsicpe {
763
enum ast_channel_adsicpe {
764
	AST_ADSI_UNKNOWN,
764
	AST_ADSI_UNKNOWN,
765
	AST_ADSI_AVAILABLE,
765
	AST_ADSI_AVAILABLE,
766
	AST_ADSI_UNAVAILABLE,
766
	AST_ADSI_UNAVAILABLE,
767
	AST_ADSI_OFFHOOKONLY,
767
	AST_ADSI_OFFHOOKONLY,
768
};
768
};
769

    
   
769

   
770
/*!
770
/*!
771
 * \brief Possible T38 states on channels
771
 * \brief Possible T38 states on channels
772
 */
772
 */
773
enum ast_t38_state {
773
enum ast_t38_state {
774
	T38_STATE_UNAVAILABLE,	/*!< T38 is unavailable on this channel or disabled by configuration */
774
	T38_STATE_UNAVAILABLE,	/*!< T38 is unavailable on this channel or disabled by configuration */
775
	T38_STATE_UNKNOWN,	/*!< The channel supports T38 but the current status is unknown */
775
	T38_STATE_UNKNOWN,	/*!< The channel supports T38 but the current status is unknown */
776
	T38_STATE_NEGOTIATING,	/*!< T38 is being negotiated */
776
	T38_STATE_NEGOTIATING,	/*!< T38 is being negotiated */
777
	T38_STATE_REJECTED,	/*!< Remote side has rejected our offer */
777
	T38_STATE_REJECTED,	/*!< Remote side has rejected our offer */
778
	T38_STATE_NEGOTIATED,	/*!< T38 established */
778
	T38_STATE_NEGOTIATED,	/*!< T38 established */
779
};
779
};
780

    
   
780

   
781
/*! Hangup handler instance node. */
781
/*! Hangup handler instance node. */
782
struct ast_hangup_handler {
782
struct ast_hangup_handler {
783
	/*! Next hangup handler node. */
783
	/*! Next hangup handler node. */
784
	AST_LIST_ENTRY(ast_hangup_handler) node;
784
	AST_LIST_ENTRY(ast_hangup_handler) node;
785
	/*! Hangup handler arg string passed to the Gosub application */
785
	/*! Hangup handler arg string passed to the Gosub application */
786
	char args[0];
786
	char args[0];
787
};
787
};
788

    
   
788

   
789
AST_LIST_HEAD_NOLOCK(ast_hangup_handler_list, ast_hangup_handler);
789
AST_LIST_HEAD_NOLOCK(ast_hangup_handler_list, ast_hangup_handler);
790
AST_LIST_HEAD_NOLOCK(ast_datastore_list, ast_datastore);
790
AST_LIST_HEAD_NOLOCK(ast_datastore_list, ast_datastore);
791
AST_LIST_HEAD_NOLOCK(ast_autochan_list, ast_autochan);
791
AST_LIST_HEAD_NOLOCK(ast_autochan_list, ast_autochan);
792
AST_LIST_HEAD_NOLOCK(ast_readq_list, ast_frame);
792
AST_LIST_HEAD_NOLOCK(ast_readq_list, ast_frame);
793

    
   
793

   
794
typedef int(*ast_timing_func_t)(const void *data);
794
typedef int(*ast_timing_func_t)(const void *data);
795
/*!
795
/*!
796
 * \page AstChannel ast_channel locking and reference tracking
796
 * \page AstChannel ast_channel locking and reference tracking
797
 *
797
 *
798
 * \par Creating Channels
798
 * \par Creating Channels
799
 * A channel is allocated using the ast_channel_alloc() function.  When created, it is
799
 * A channel is allocated using the ast_channel_alloc() function.  When created, it is
800
 * automatically inserted into the main channels hash table that keeps track of all
800
 * automatically inserted into the main channels hash table that keeps track of all
801
 * active channels in the system.  The hash key is based on the channel name.  Because
801
 * active channels in the system.  The hash key is based on the channel name.  Because
802
 * of this, if you want to change the name, you _must_ use ast_change_name(), not change
802
 * of this, if you want to change the name, you _must_ use ast_change_name(), not change
803
 * the name field directly.  When ast_channel_alloc() returns a channel pointer, you now
803
 * the name field directly.  When ast_channel_alloc() returns a channel pointer, you now
804
 * hold a reference to that channel.  In most cases this reference is given to ast_pbx_run().
804
 * hold a reference to that channel.  In most cases this reference is given to ast_pbx_run().
805
 *
805
 *
806
 * \par Channel Locking
806
 * \par Channel Locking
807
 * There is a lock associated with every ast_channel.  It is allocated internally via astobj2.
807
 * There is a lock associated with every ast_channel.  It is allocated internally via astobj2.
808
 * To lock or unlock a channel, you must use the ast_channel_lock() wrappers.
808
 * To lock or unlock a channel, you must use the ast_channel_lock() wrappers.
809
 *
809
 *
810
 * Previously, before ast_channel was converted to astobj2, the channel lock was used in some
810
 * Previously, before ast_channel was converted to astobj2, the channel lock was used in some
811
 * additional ways that are no longer necessary.  Before, the only way to ensure that a channel
811
 * additional ways that are no longer necessary.  Before, the only way to ensure that a channel
812
 * did not disappear out from under you if you were working with a channel outside of the channel
812
 * did not disappear out from under you if you were working with a channel outside of the channel
813
 * thread that owns it, was to hold the channel lock.  Now, that is no longer necessary.
813
 * thread that owns it, was to hold the channel lock.  Now, that is no longer necessary.
814
 * You simply must hold a reference to the channel to ensure it does not go away.
814
 * You simply must hold a reference to the channel to ensure it does not go away.
815
 *
815
 *
816
 * The channel must be locked if you need to ensure that data that you reading from the channel
816
 * The channel must be locked if you need to ensure that data that you reading from the channel
817
 * does not change while you access it.  Further, you must hold the channel lock if you are
817
 * does not change while you access it.  Further, you must hold the channel lock if you are
818
 * making a non-atomic change to channel data.
818
 * making a non-atomic change to channel data.
819
 *
819
 *
820
 * \par Channel References
820
 * \par Channel References
821
 * There are multiple ways to get a reference to a channel.  The first is that you hold a reference
821
 * There are multiple ways to get a reference to a channel.  The first is that you hold a reference
822
 * to a channel after creating it.  The other ways involve using the channel search or the channel
822
 * to a channel after creating it.  The other ways involve using the channel search or the channel
823
 * traversal APIs.  These functions are the ast_channel_get_*() functions or ast_channel_iterator_*()
823
 * traversal APIs.  These functions are the ast_channel_get_*() functions or ast_channel_iterator_*()
824
 * functions.  Once a reference is retrieved by one of these methods, you know that the channel will
824
 * functions.  Once a reference is retrieved by one of these methods, you know that the channel will
825
 * not go away.  So, the channel should only get locked as needed for data access or modification.
825
 * not go away.  So, the channel should only get locked as needed for data access or modification.
826
 * But, make sure that the reference gets released when you are done with it!
826
 * But, make sure that the reference gets released when you are done with it!
827
 *
827
 *
828
 * There are different things you can do when you are done with a reference to a channel.  The first
828
 * There are different things you can do when you are done with a reference to a channel.  The first
829
 * is to simply release the reference using ast_channel_unref().  The other option is to call
829
 * is to simply release the reference using ast_channel_unref().  The other option is to call
830
 * ast_channel_release().  This function is generally used where ast_channel_free() was used in
830
 * ast_channel_release().  This function is generally used where ast_channel_free() was used in
831
 * the past.  The release function releases a reference as well as ensures that the channel is no
831
 * the past.  The release function releases a reference as well as ensures that the channel is no
832
 * longer in the global channels container.  That way, the channel will get destroyed as soon as any
832
 * longer in the global channels container.  That way, the channel will get destroyed as soon as any
833
 * other pending references get released.
833
 * other pending references get released.
834
 *
834
 *
835
 * \par Exceptions to the rules
835
 * \par Exceptions to the rules
836
 * Even though ast_channel is reference counted, there are some places where pointers to an ast_channel
836
 * Even though ast_channel is reference counted, there are some places where pointers to an ast_channel
837
 * get stored, but the reference count does not reflect it.  The reason is mostly historical.
837
 * get stored, but the reference count does not reflect it.  The reason is mostly historical.
838
 * The only places where this happens should be places where because of how the code works, we
838
 * The only places where this happens should be places where because of how the code works, we
839
 * _know_ that the pointer to the channel will get removed before the channel goes away.  The main
839
 * _know_ that the pointer to the channel will get removed before the channel goes away.  The main
840
 * example of this is in channel drivers.  Channel drivers generally store a pointer to their owner
840
 * example of this is in channel drivers.  Channel drivers generally store a pointer to their owner
841
 * ast_channel in their technology specific pvt struct.  In this case, the channel drivers _know_
841
 * ast_channel in their technology specific pvt struct.  In this case, the channel drivers _know_
842
 * that this pointer to the channel will be removed in time, because the channel's hangup callback
842
 * that this pointer to the channel will be removed in time, because the channel's hangup callback
843
 * gets called before the channel goes away.
843
 * gets called before the channel goes away.
844
 */
844
 */
845

    
   
845

   
846
struct ast_channel;
846
struct ast_channel;
847

    
   
847

   
848
/*! \brief ast_channel_tech Properties */
848
/*! \brief ast_channel_tech Properties */
849
enum {
849
enum {
850
	/*!
850
	/*!
851
     * \brief Channels have this property if they can accept input with jitter;
851
     * \brief Channels have this property if they can accept input with jitter;
852
	 * i.e. most VoIP channels
852
	 * i.e. most VoIP channels
853
	 */
853
	 */
854
	AST_CHAN_TP_WANTSJITTER = (1 << 0),
854
	AST_CHAN_TP_WANTSJITTER = (1 << 0),
855
	/*!
855
	/*!
856
     * \brief Channels have this property if they can create jitter;
856
     * \brief Channels have this property if they can create jitter;
857
	 * i.e. most VoIP channels
857
	 * i.e. most VoIP channels
858
	 */
858
	 */
859
	AST_CHAN_TP_CREATESJITTER = (1 << 1),
859
	AST_CHAN_TP_CREATESJITTER = (1 << 1),
860
};
860
};
861

    
   
861

   
862
/*! \brief ast_channel flags */
862
/*! \brief ast_channel flags */
863
enum {
863
enum {
864
	/*! Queue incoming DTMF, to be released when this flag is turned off */
864
	/*! Queue incoming DTMF, to be released when this flag is turned off */
865
	AST_FLAG_DEFER_DTMF =    (1 << 1),
865
	AST_FLAG_DEFER_DTMF =    (1 << 1),
866
	/*! write should be interrupt generator */
866
	/*! write should be interrupt generator */
867
	AST_FLAG_WRITE_INT =     (1 << 2),
867
	AST_FLAG_WRITE_INT =     (1 << 2),
868
	/*! a thread is blocking on this channel */
868
	/*! a thread is blocking on this channel */
869
	AST_FLAG_BLOCKING =      (1 << 3),
869
	AST_FLAG_BLOCKING =      (1 << 3),
870
	/*! This is a zombie channel */
870
	/*! This is a zombie channel */
871
	AST_FLAG_ZOMBIE =        (1 << 4),
871
	AST_FLAG_ZOMBIE =        (1 << 4),
872
	/*! There is an exception pending */
872
	/*! There is an exception pending */
873
	AST_FLAG_EXCEPTION =     (1 << 5),
873
	AST_FLAG_EXCEPTION =     (1 << 5),
874
	/*! Listening to moh XXX anthm promises me this will disappear XXX */
874
	/*! Listening to moh XXX anthm promises me this will disappear XXX */
875
	AST_FLAG_MOH =           (1 << 6),
875
	AST_FLAG_MOH =           (1 << 6),
876
	/*! This channel is spying on another channel */
876
	/*! This channel is spying on another channel */
877
	AST_FLAG_SPYING =        (1 << 7),
877
	AST_FLAG_SPYING =        (1 << 7),
878
	/*! the channel is in an auto-incrementing dialplan processor,
878
	/*! the channel is in an auto-incrementing dialplan processor,
879
	 *  so when ->priority is set, it will get incremented before
879
	 *  so when ->priority is set, it will get incremented before
880
	 *  finding the next priority to run */
880
	 *  finding the next priority to run */
881
	AST_FLAG_IN_AUTOLOOP =   (1 << 9),
881
	AST_FLAG_IN_AUTOLOOP =   (1 << 9),
882
	/*! This is an outgoing call */
882
	/*! This is an outgoing call */
883
	AST_FLAG_OUTGOING =      (1 << 10),
883
	AST_FLAG_OUTGOING =      (1 << 10),
884
	/*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */
884
	/*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */
885
	AST_FLAG_IN_DTMF =       (1 << 12),
885
	AST_FLAG_IN_DTMF =       (1 << 12),
886
	/*! A DTMF_END was received when not IN_DTMF, so the length of the digit is
886
	/*! A DTMF_END was received when not IN_DTMF, so the length of the digit is
887
	 *  currently being emulated */
887
	 *  currently being emulated */
888
	AST_FLAG_EMULATE_DTMF =  (1 << 13),
888
	AST_FLAG_EMULATE_DTMF =  (1 << 13),
889
	/*! This is set to tell the channel not to generate DTMF begin frames, and
889
	/*! This is set to tell the channel not to generate DTMF begin frames, and
890
	 *  to instead only generate END frames. */
890
	 *  to instead only generate END frames. */
891
	AST_FLAG_END_DTMF_ONLY = (1 << 14),
891
	AST_FLAG_END_DTMF_ONLY = (1 << 14),
892
	/* OBSOLETED in favor of AST_CAUSE_ANSWERED_ELSEWHERE
892
	/* OBSOLETED in favor of AST_CAUSE_ANSWERED_ELSEWHERE
893
	Flag to show channels that this call is hangup due to the fact that the call
893
	Flag to show channels that this call is hangup due to the fact that the call
894
	    was indeed answered, but in another channel */
894
	    was indeed answered, but in another channel */
895
	/* AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), */
895
	/* AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), */
896
	/*! This flag indicates that on a masquerade, an active stream should not
896
	/*! This flag indicates that on a masquerade, an active stream should not
897
	 *  be carried over */
897
	 *  be carried over */
898
	AST_FLAG_MASQ_NOSTREAM = (1 << 16),
898
	AST_FLAG_MASQ_NOSTREAM = (1 << 16),
899
	/*! This flag indicates that the hangup exten was run when the bridge terminated,
899
	/*! This flag indicates that the hangup exten was run when the bridge terminated,
900
	 *  a message aimed at preventing a subsequent hangup exten being run at the pbx_run
900
	 *  a message aimed at preventing a subsequent hangup exten being run at the pbx_run
901
	 *  level */
901
	 *  level */
902
	AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17),
902
	AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17),
903
	/*! Disable certain workarounds.  This reintroduces certain bugs, but allows
903
	/*! Disable certain workarounds.  This reintroduces certain bugs, but allows
904
	 *  some non-traditional dialplans (like AGI) to continue to function.
904
	 *  some non-traditional dialplans (like AGI) to continue to function.
905
	 */
905
	 */
906
	AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20),
906
	AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20),
907
	/*!
907
	/*!
908
	 * Disable device state event caching.  This allows channel
908
	 * Disable device state event caching.  This allows channel
909
	 * drivers to selectively prevent device state events from being
909
	 * drivers to selectively prevent device state events from being
910
	 * cached by certain channels such as anonymous calls which have
910
	 * cached by certain channels such as anonymous calls which have
911
	 * no persistent represenatation that can be tracked.
911
	 * no persistent represenatation that can be tracked.
912
	 */
912
	 */
913
	AST_FLAG_DISABLE_DEVSTATE_CACHE = (1 << 21),
913
	AST_FLAG_DISABLE_DEVSTATE_CACHE = (1 << 21),
914
	/*!
914
	/*!
915
	 * This flag indicates that a dual channel redirect is in
915
	 * This flag indicates that a dual channel redirect is in
916
	 * progress.  The bridge needs to wait until the flag is cleared
916
	 * progress.  The bridge needs to wait until the flag is cleared
917
	 * to continue.
917
	 * to continue.
918
	 */
918
	 */
919
	AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT = (1 << 22),
919
	AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT = (1 << 22),
920
	/*!
920
	/*!
921
	 * This flag indicates that the channel was originated.
921
	 * This flag indicates that the channel was originated.
922
	 */
922
	 */
923
	AST_FLAG_ORIGINATED = (1 << 23),
923
	AST_FLAG_ORIGINATED = (1 << 23),
924
};
924
};
925

    
   
925

   
926
/*! \brief ast_bridge_config flags */
926
/*! \brief ast_bridge_config flags */
927
enum {
927
enum {
928
	AST_FEATURE_PLAY_WARNING = (1 << 0),
928
	AST_FEATURE_PLAY_WARNING = (1 << 0),
929
	AST_FEATURE_REDIRECT =     (1 << 1),
929
	AST_FEATURE_REDIRECT =     (1 << 1),
930
	AST_FEATURE_DISCONNECT =   (1 << 2),
930
	AST_FEATURE_DISCONNECT =   (1 << 2),
931
	AST_FEATURE_ATXFER =       (1 << 3),
931
	AST_FEATURE_ATXFER =       (1 << 3),
932
	AST_FEATURE_AUTOMON =      (1 << 4),
932
	AST_FEATURE_AUTOMON =      (1 << 4),
933
	AST_FEATURE_PARKCALL =     (1 << 5),
933
	AST_FEATURE_PARKCALL =     (1 << 5),
934
	AST_FEATURE_AUTOMIXMON =   (1 << 6),
934
	AST_FEATURE_AUTOMIXMON =   (1 << 6),
935
};
935
};
936

    
   
936

   
937
#define AST_FEATURE_DTMF_MASK (AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |\
937
#define AST_FEATURE_DTMF_MASK (AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |\
938
	AST_FEATURE_ATXFER | AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON)
938
	AST_FEATURE_ATXFER | AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON)
939

    
   
939

   
940
/*! \brief bridge configuration */
940
/*! \brief bridge configuration */
941
struct ast_bridge_config {
941
struct ast_bridge_config {
942
	struct ast_flags features_caller;
942
	struct ast_flags features_caller;
943
	struct ast_flags features_callee;
943
	struct ast_flags features_callee;
944
	struct timeval start_time;
944
	struct timeval start_time;
945
	struct timeval nexteventts;
945
	struct timeval nexteventts;
946
	struct timeval feature_start_time;
946
	struct timeval feature_start_time;
947
	long feature_timer;
947
	long feature_timer;
948
	long timelimit;
948
	long timelimit;
949
	long play_warning;
949
	long play_warning;
950
	long warning_freq;
950
	long warning_freq;
951
	const char *warning_sound;
951
	const char *warning_sound;
952
	const char *end_sound;
952
	const char *end_sound;
953
	const char *start_sound;
953
	const char *start_sound;
954
	unsigned int flags;
954
	unsigned int flags;
955
	void (* end_bridge_callback)(void *);   /*!< A callback that is called after a bridge attempt */
955
	void (* end_bridge_callback)(void *);   /*!< A callback that is called after a bridge attempt */
956
	void *end_bridge_callback_data;         /*!< Data passed to the callback */
956
	void *end_bridge_callback_data;         /*!< Data passed to the callback */
957
	/*! If the end_bridge_callback_data refers to a channel which no longer is going to
957
	/*! If the end_bridge_callback_data refers to a channel which no longer is going to
958
	 * exist when the end_bridge_callback is called, then it needs to be fixed up properly
958
	 * exist when the end_bridge_callback is called, then it needs to be fixed up properly
959
	 */
959
	 */
960
	void (*end_bridge_callback_data_fixup)(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator);
960
	void (*end_bridge_callback_data_fixup)(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator);
961
};
961
};
962

    
   
962

   
963
struct chanmon;
963
struct chanmon;
964

    
   
964

   
965
struct outgoing_helper {
965
struct outgoing_helper {
966
	const char *context;
966
	const char *context;
967
	const char *exten;
967
	const char *exten;
968
	int priority;
968
	int priority;
969
	int connect_on_early_media;	/* If set, treat session progress as answer */
969
	int connect_on_early_media;	/* If set, treat session progress as answer */
970
	const char *cid_num;
970
	const char *cid_num;
971
	const char *cid_name;
971
	const char *cid_name;
972
	const char *account;
972
	const char *account;
973
	struct ast_variable *vars;
973
	struct ast_variable *vars;
974
	struct ast_channel *parent_channel;
974
	struct ast_channel *parent_channel;
975
};
975
};
976

    
   
976

   
977
enum {
977
enum {
978
	/*!
978
	/*!
979
	 * Soft hangup requested by device or other internal reason.
979
	 * Soft hangup requested by device or other internal reason.
980
	 * Actual hangup needed.
980
	 * Actual hangup needed.
981
	 */
981
	 */
982
	AST_SOFTHANGUP_DEV =       (1 << 0),
982
	AST_SOFTHANGUP_DEV =       (1 << 0),
983
	/*!
983
	/*!
984
	 * Used to break the normal frame flow so an async goto can be
984
	 * Used to break the normal frame flow so an async goto can be
985
	 * done instead of actually hanging up.
985
	 * done instead of actually hanging up.
986
	 */
986
	 */
987
	AST_SOFTHANGUP_ASYNCGOTO = (1 << 1),
987
	AST_SOFTHANGUP_ASYNCGOTO = (1 << 1),
988
	/*!
988
	/*!
989
	 * Soft hangup requested by system shutdown.  Actual hangup
989
	 * Soft hangup requested by system shutdown.  Actual hangup
990
	 * needed.
990
	 * needed.
991
	 */
991
	 */
992
	AST_SOFTHANGUP_SHUTDOWN =  (1 << 2),
992
	AST_SOFTHANGUP_SHUTDOWN =  (1 << 2),
993
	/*!
993
	/*!
994
	 * Used to break the normal frame flow after a timeout so an
994
	 * Used to break the normal frame flow after a timeout so an
995
	 * implicit async goto can be done to the 'T' exten if it exists
995
	 * implicit async goto can be done to the 'T' exten if it exists
996
	 * instead of actually hanging up.  If the exten does not exist
996
	 * instead of actually hanging up.  If the exten does not exist
997
	 * then actually hangup.
997
	 * then actually hangup.
998
	 */
998
	 */
999
	AST_SOFTHANGUP_TIMEOUT =   (1 << 3),
999
	AST_SOFTHANGUP_TIMEOUT =   (1 << 3),
1000
	/*!
1000
	/*!
1001
	 * Soft hangup requested by application/channel-driver being
1001
	 * Soft hangup requested by application/channel-driver being
1002
	 * unloaded.  Actual hangup needed.
1002
	 * unloaded.  Actual hangup needed.
1003
	 */
1003
	 */
1004
	AST_SOFTHANGUP_APPUNLOAD = (1 << 4),
1004
	AST_SOFTHANGUP_APPUNLOAD = (1 << 4),
1005
	/*!
1005
	/*!
1006
	 * Soft hangup requested by non-associated party.  Actual hangup
1006
	 * Soft hangup requested by non-associated party.  Actual hangup
1007
	 * needed.
1007
	 * needed.
1008
	 */
1008
	 */
1009
	AST_SOFTHANGUP_EXPLICIT =  (1 << 5),
1009
	AST_SOFTHANGUP_EXPLICIT =  (1 << 5),
1010
	/*!
1010
	/*!
1011
	 * Used to break a bridge so the channel can be spied upon
1011
	 * Used to break a bridge so the channel can be spied upon
1012
	 * instead of actually hanging up.
1012
	 * instead of actually hanging up.
1013
	 */
1013
	 */
1014
	AST_SOFTHANGUP_UNBRIDGE =  (1 << 6),
1014
	AST_SOFTHANGUP_UNBRIDGE =  (1 << 6),
1015

    
   
1015

   
1016

    
   
1016

   
1017
	/*!
1017
	/*!
1018
	 * \brief All softhangup flags.
1018
	 * \brief All softhangup flags.
1019
	 *
1019
	 *
1020
	 * This can be used as an argument to ast_channel_clear_softhangup()
1020
	 * This can be used as an argument to ast_channel_clear_softhangup()
1021
	 * to clear all softhangup flags from a channel.
1021
	 * to clear all softhangup flags from a channel.
1022
	 */
1022
	 */
1023
	AST_SOFTHANGUP_ALL =       (0xFFFFFFFF)
1023
	AST_SOFTHANGUP_ALL =       (0xFFFFFFFF)
1024
};
1024
};
1025

    
   
1025

   
1026

    
   
1026

   
1027
/*! \brief Channel reload reasons for manager events at load or reload of configuration */
1027
/*! \brief Channel reload reasons for manager events at load or reload of configuration */
1028
enum channelreloadreason {
1028
enum channelreloadreason {
1029
	CHANNEL_MODULE_LOAD,
1029
	CHANNEL_MODULE_LOAD,
1030
	CHANNEL_MODULE_RELOAD,
1030
	CHANNEL_MODULE_RELOAD,
1031
	CHANNEL_CLI_RELOAD,
1031
	CHANNEL_CLI_RELOAD,
1032
	CHANNEL_MANAGER_RELOAD,
1032
	CHANNEL_MANAGER_RELOAD,
1033
	CHANNEL_ACL_RELOAD,
1033
	CHANNEL_ACL_RELOAD,
1034
};
1034
};
1035

    
   
1035

   
1036
/*!
1036
/*!
1037
 * \brief Channel AMA Flags
1037
 * \brief Channel AMA Flags
1038
 */
1038
 */
1039
enum ama_flags {
1039
enum ama_flags {
1040
	AST_AMA_NONE = 0,
1040
	AST_AMA_NONE = 0,
1041
	AST_AMA_OMIT,
1041
	AST_AMA_OMIT,
1042
	AST_AMA_BILLING,
1042
	AST_AMA_BILLING,
1043
	AST_AMA_DOCUMENTATION,
1043
	AST_AMA_DOCUMENTATION,
1044
};
1044
};
1045

    
   
1045

   
1046
/*!
1046
/*!
1047
 * \note None of the datastore API calls lock the ast_channel they are using.
1047
 * \note None of the datastore API calls lock the ast_channel they are using.
1048
 *       So, the channel should be locked before calling the functions that
1048
 *       So, the channel should be locked before calling the functions that
1049
 *       take a channel argument.
1049
 *       take a channel argument.
1050
 */
1050
 */
1051

    
   
1051

   
1052
/*!
1052
/*!
1053
 * \brief Create a channel data store object
1053
 * \brief Create a channel data store object
1054
 * \deprecated You should use the ast_datastore_alloc() generic function instead.
1054
 * \deprecated You should use the ast_datastore_alloc() generic function instead.
1055
 * \version 1.6.1 deprecated
1055
 * \version 1.6.1 deprecated
1056
 */
1056
 */
1057
struct ast_datastore * attribute_malloc ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
1057
struct ast_datastore * attribute_malloc ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
1058
	__attribute__((deprecated));
1058
	__attribute__((deprecated));
1059

    
   
1059

   
1060
/*!
1060
/*!
1061
 * \brief Free a channel data store object
1061
 * \brief Free a channel data store object
1062
 * \deprecated You should use the ast_datastore_free() generic function instead.
1062
 * \deprecated You should use the ast_datastore_free() generic function instead.
1063
 * \version 1.6.1 deprecated
1063
 * \version 1.6.1 deprecated
1064
 */
1064
 */
1065
int ast_channel_datastore_free(struct ast_datastore *datastore)
1065
int ast_channel_datastore_free(struct ast_datastore *datastore)
1066
	__attribute__((deprecated));
1066
	__attribute__((deprecated));
1067

    
   
1067

   
1068
/*! \brief Inherit datastores from a parent to a child. */
1068
/*! \brief Inherit datastores from a parent to a child. */
1069
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to);
1069
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to);
1070

    
   
1070

   
1071
/*!
1071
/*!
1072
 * \brief Add a datastore to a channel
1072
 * \brief Add a datastore to a channel
1073
 *
1073
 *
1074
 * \note The channel should be locked before calling this function.
1074
 * \note The channel should be locked before calling this function.
1075
 *
1075
 *
1076
 * \retval 0 success
1076
 * \retval 0 success
1077
 * \retval non-zero failure
1077
 * \retval non-zero failure
1078
 */
1078
 */
1079
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore);
1079
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore);
1080

    
   
1080

   
1081
/*!
1081
/*!
1082
 * \brief Remove a datastore from a channel
1082
 * \brief Remove a datastore from a channel
1083
 *
1083
 *
1084
 * \note The channel should be locked before calling this function.
1084
 * \note The channel should be locked before calling this function.
1085
 *
1085
 *
1086
 * \retval 0 success
1086
 * \retval 0 success
1087
 * \retval non-zero failure
1087
 * \retval non-zero failure
1088
 */
1088
 */
1089
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore);
1089
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore);
1090

    
   
1090

   
1091
/*!
1091
/*!
1092
 * \brief Find a datastore on a channel
1092
 * \brief Find a datastore on a channel
1093
 *
1093
 *
1094
 * \note The channel should be locked before calling this function.
1094
 * \note The channel should be locked before calling this function.
1095
 *
1095
 *
1096
 * \note The datastore returned from this function must not be used if the
1096
 * \note The datastore returned from this function must not be used if the
1097
 *       reference to the channel is released.
1097
 *       reference to the channel is released.
1098
 *
1098
 *
1099
 * \retval pointer to the datastore if found
1099
 * \retval pointer to the datastore if found
1100
 * \retval NULL if not found
1100
 * \retval NULL if not found
1101
 */
1101
 */
1102
struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid);
1102
struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid);
1103

    
   
1103

   
1104
/*!
1104
/*!
1105
 * \brief Create a channel structure
1105
 * \brief Create a channel structure
1106
 * \since 1.8
1106
 * \since 1.8
1107
 *
1107
 *
1108
 * \retval NULL failure
1108
 * \retval NULL failure
1109
 * \retval non-NULL successfully allocated channel
1109
 * \retval non-NULL successfully allocated channel
1110
 *
1110
 *
1111
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1111
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1112
 * \note By default, new channels are set to the "s" extension
1112
 * \note By default, new channels are set to the "s" extension
1113
 *       and "default" context.
1113
 *       and "default" context.
1114
 */
1114
 */
1115
struct ast_channel * attribute_malloc __attribute__((format(printf, 13, 14)))
1115
struct ast_channel * attribute_malloc __attribute__((format(printf, 13, 14)))
1116
	__ast_channel_alloc(int needqueue, int state, const char *cid_num,
1116
	__ast_channel_alloc(int needqueue, int state, const char *cid_num,
1117
			    const char *cid_name, const char *acctcode,
1117
			    const char *cid_name, const char *acctcode,
1118
			    const char *exten, const char *context,
1118
			    const char *exten, const char *context,
1119
			    const char *linkedid, enum ama_flags amaflag,
1119
			    const char *linkedid, enum ama_flags amaflag,
1120
			    const char *file, int line, const char *function,
1120
			    const char *file, int line, const char *function,
1121
			    const char *name_fmt, ...);
1121
			    const char *name_fmt, ...);
1122

    
   
1122

   
1123
/*!
1123
/*!
1124
 * \brief Create a channel structure
1124
 * \brief Create a channel structure
1125
 *
1125
 *
1126
 * \retval NULL failure
1126
 * \retval NULL failure
1127
 * \retval non-NULL successfully allocated channel
1127
 * \retval non-NULL successfully allocated channel
1128
 *
1128
 *
1129
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1129
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1130
 * \note By default, new channels are set to the "s" extension
1130
 * \note By default, new channels are set to the "s" extension
1131
 *       and "default" context.
1131
 *       and "default" context.
1132
 */
1132
 */
1133
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, ...) \
1133
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, ...) \
1134
	__ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, \
1134
	__ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, \
1135
			    __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
1135
			    __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
1136

    
   
1136

   
1137
#if defined(REF_DEBUG) || defined(__AST_DEBUG_MALLOC)
1137
#if defined(REF_DEBUG) || defined(__AST_DEBUG_MALLOC)
1138
/*!
1138
/*!
1139
 * \brief Create a fake channel structure
1139
 * \brief Create a fake channel structure
1140
 *
1140
 *
1141
 * \retval NULL failure
1141
 * \retval NULL failure
1142
 * \retval non-NULL successfully allocated channel
1142
 * \retval non-NULL successfully allocated channel
1143
 *
1143
 *
1144
 * \note This function should ONLY be used to create a fake channel
1144
 * \note This function should ONLY be used to create a fake channel
1145
 *       that can then be populated with data for use in variable
1145
 *       that can then be populated with data for use in variable
1146
 *       substitution when a real channel does not exist.
1146
 *       substitution when a real channel does not exist.
1147
 *
1147
 *
1148
 * \note The created dummy channel should be destroyed by
1148
 * \note The created dummy channel should be destroyed by
1149
 * ast_channel_unref().  Using ast_channel_release() needlessly
1149
 * ast_channel_unref().  Using ast_channel_release() needlessly
1150
 * grabs the channel container lock and can cause a deadlock as
1150
 * grabs the channel container lock and can cause a deadlock as
1151
 * a result.  Also grabbing the channel container lock reduces
1151
 * a result.  Also grabbing the channel container lock reduces
1152
 * system performance.
1152
 * system performance.
1153
 */
1153
 */
1154
#define ast_dummy_channel_alloc()	__ast_dummy_channel_alloc(__FILE__, __LINE__, __PRETTY_FUNCTION__)
1154
#define ast_dummy_channel_alloc()	__ast_dummy_channel_alloc(__FILE__, __LINE__, __PRETTY_FUNCTION__)
1155
struct ast_channel *__ast_dummy_channel_alloc(const char *file, int line, const char *function);
1155
struct ast_channel *__ast_dummy_channel_alloc(const char *file, int line, const char *function);
1156
#else
1156
#else
1157
/*!
1157
/*!
1158
 * \brief Create a fake channel structure
1158
 * \brief Create a fake channel structure
1159
 *
1159
 *
1160
 * \retval NULL failure
1160
 * \retval NULL failure
1161
 * \retval non-NULL successfully allocated channel
1161
 * \retval non-NULL successfully allocated channel
1162
 *
1162
 *
1163
 * \note This function should ONLY be used to create a fake channel
1163
 * \note This function should ONLY be used to create a fake channel
1164
 *       that can then be populated with data for use in variable
1164
 *       that can then be populated with data for use in variable
1165
 *       substitution when a real channel does not exist.
1165
 *       substitution when a real channel does not exist.
1166
 *
1166
 *
1167
 * \note The created dummy channel should be destroyed by
1167
 * \note The created dummy channel should be destroyed by
1168
 * ast_channel_unref().  Using ast_channel_release() needlessly
1168
 * ast_channel_unref().  Using ast_channel_release() needlessly
1169
 * grabs the channel container lock and can cause a deadlock as
1169
 * grabs the channel container lock and can cause a deadlock as
1170
 * a result.  Also grabbing the channel container lock reduces
1170
 * a result.  Also grabbing the channel container lock reduces
1171
 * system performance.
1171
 * system performance.
1172
 */
1172
 */
1173
struct ast_channel *ast_dummy_channel_alloc(void);
1173
struct ast_channel *ast_dummy_channel_alloc(void);
1174
#endif
1174
#endif
1175

    
   
1175

   
1176
/*!
1176
/*!
1177
 * \brief Queue one or more frames to a channel's frame queue
1177
 * \brief Queue one or more frames to a channel's frame queue
1178
 *
1178
 *
1179
 * \param chan the channel to queue the frame(s) on
1179
 * \param chan the channel to queue the frame(s) on
1180
 * \param f the frame(s) to queue.  Note that the frame(s) will be duplicated
1180
 * \param f the frame(s) to queue.  Note that the frame(s) will be duplicated
1181
 *        by this function.  It is the responsibility of the caller to handle
1181
 *        by this function.  It is the responsibility of the caller to handle
1182
 *        freeing the memory associated with the frame(s) being passed if
1182
 *        freeing the memory associated with the frame(s) being passed if
1183
 *        necessary.
1183
 *        necessary.
1184
 *
1184
 *
1185
 * \retval 0 success
1185
 * \retval 0 success
1186
 * \retval non-zero failure
1186
 * \retval non-zero failure
1187
 */
1187
 */
1188
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f);
1188
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f);
1189

    
   
1189

   
1190
/*!
1190
/*!
1191
 * \brief Queue one or more frames to the head of a channel's frame queue
1191
 * \brief Queue one or more frames to the head of a channel's frame queue
1192
 *
1192
 *
1193
 * \param chan the channel to queue the frame(s) on
1193
 * \param chan the channel to queue the frame(s) on
1194
 * \param f the frame(s) to queue.  Note that the frame(s) will be duplicated
1194
 * \param f the frame(s) to queue.  Note that the frame(s) will be duplicated
1195
 *        by this function.  It is the responsibility of the caller to handle
1195
 *        by this function.  It is the responsibility of the caller to handle
1196
 *        freeing the memory associated with the frame(s) being passed if
1196
 *        freeing the memory associated with the frame(s) being passed if
1197
 *        necessary.
1197
 *        necessary.
1198
 *
1198
 *
1199
 * \retval 0 success
1199
 * \retval 0 success
1200
 * \retval non-zero failure
1200
 * \retval non-zero failure
1201
 */
1201
 */
1202
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f);
1202
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f);
1203

    
   
1203

   
1204
/*!
1204
/*!
1205
 * \brief Queue a hangup frame
1205
 * \brief Queue a hangup frame
1206
 *
1206
 *
1207
 * \note The channel does not need to be locked before calling this function.
1207
 * \note The channel does not need to be locked before calling this function.
1208
 */
1208
 */
1209
int ast_queue_hangup(struct ast_channel *chan);
1209
int ast_queue_hangup(struct ast_channel *chan);
1210

    
   
1210

   
1211
/*!
1211
/*!
1212
 * \brief Queue a hangup frame with hangupcause set
1212
 * \brief Queue a hangup frame with hangupcause set
1213
 *
1213
 *
1214
 * \note The channel does not need to be locked before calling this function.
1214
 * \note The channel does not need to be locked before calling this function.
1215
 * \param[in] chan channel to queue frame onto
1215
 * \param[in] chan channel to queue frame onto
1216
 * \param[in] cause the hangup cause
1216
 * \param[in] cause the hangup cause
1217
 * \return 0 on success, -1 on error
1217
 * \return 0 on success, -1 on error
1218
 * \since 1.6.1
1218
 * \since 1.6.1
1219
 */
1219
 */
1220
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause);
1220
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause);
1221

    
   
1221

   
1222
/*!
1222
/*!
1223
 * \brief Queue a hold frame
1223
 * \brief Queue a hold frame
1224
 *
1224
 *
1225
 * \param chan channel to queue frame onto
1225
 * \param chan channel to queue frame onto
1226
 * \param musicclass The suggested musicclass for the other end to use
1226
 * \param musicclass The suggested musicclass for the other end to use
1227
 *
1227
 *
1228
 * \note The channel does not need to be locked before calling this function.
1228
 * \note The channel does not need to be locked before calling this function.
1229
 *
1229
 *
1230
 * \retval zero on success
1230
 * \retval zero on success
1231
 * \retval non-zero on failure
1231
 * \retval non-zero on failure
1232
 */
1232
 */
1233
int ast_queue_hold(struct ast_channel *chan, const char *musicclass);
1233
int ast_queue_hold(struct ast_channel *chan, const char *musicclass);
1234

    
   
1234

   
1235
/*!
1235
/*!
1236
 * \brief Queue an unhold frame
1236
 * \brief Queue an unhold frame
1237
 *
1237
 *
1238
 * \param chan channel to queue frame onto
1238
 * \param chan channel to queue frame onto
1239
 *
1239
 *
1240
 * \note The channel does not need to be locked before calling this function.
1240
 * \note The channel does not need to be locked before calling this function.
1241
 *
1241
 *
1242
 * \retval zero on success
1242
 * \retval zero on success
1243
 * \retval non-zero on failure
1243
 * \retval non-zero on failure
1244
 */
1244
 */
1245
int ast_queue_unhold(struct ast_channel *chan);
1245
int ast_queue_unhold(struct ast_channel *chan);
1246

    
   
1246

   
1247
/*!
1247
/*!
1248
 * \brief Queue a control frame without payload
1248
 * \brief Queue a control frame without payload
1249
 *
1249
 *
1250
 * \param chan channel to queue frame onto
1250
 * \param chan channel to queue frame onto
1251
 * \param control type of control frame
1251
 * \param control type of control frame
1252
 *
1252
 *
1253
 * \note The channel does not need to be locked before calling this function.
1253
 * \note The channel does not need to be locked before calling this function.
1254
 *
1254
 *
1255
 * \retval zero on success
1255
 * \retval zero on success
1256
 * \retval non-zero on failure
1256
 * \retval non-zero on failure
1257
 */
1257
 */
1258
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control);
1258
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control);
1259

    
   
1259

   
1260
/*!
1260
/*!
1261
 * \brief Queue a control frame with payload
1261
 * \brief Queue a control frame with payload
1262
 *
1262
 *
1263
 * \param chan channel to queue frame onto
1263
 * \param chan channel to queue frame onto
1264
 * \param control type of control frame
1264
 * \param control type of control frame
1265
 * \param data pointer to payload data to be included in frame
1265
 * \param data pointer to payload data to be included in frame
1266
 * \param datalen number of bytes of payload data
1266
 * \param datalen number of bytes of payload data
1267
 *
1267
 *
1268
 * \retval 0 success
1268
 * \retval 0 success
1269
 * \retval non-zero failure
1269
 * \retval non-zero failure
1270
 *
1270
 *
1271
 * \details
1271
 * \details
1272
 * The supplied payload data is copied into the frame, so the caller's copy
1272
 * The supplied payload data is copied into the frame, so the caller's copy
1273
 * is not modified nor freed, and the resulting frame will retain a copy of
1273
 * is not modified nor freed, and the resulting frame will retain a copy of
1274
 * the data even if the caller frees their local copy.
1274
 * the data even if the caller frees their local copy.
1275
 *
1275
 *
1276
 * \note This method should be treated as a 'network transport'; in other
1276
 * \note This method should be treated as a 'network transport'; in other
1277
 * words, your frames may be transferred across an IAX2 channel to another
1277
 * words, your frames may be transferred across an IAX2 channel to another
1278
 * system, which may be a different endianness than yours. Because of this,
1278
 * system, which may be a different endianness than yours. Because of this,
1279
 * you should ensure that either your frames will never be expected to work
1279
 * you should ensure that either your frames will never be expected to work
1280
 * across systems, or that you always put your payload data into 'network byte
1280
 * across systems, or that you always put your payload data into 'network byte
1281
 * order' before calling this function.
1281
 * order' before calling this function.
1282
 *
1282
 *
1283
 * \note The channel does not need to be locked before calling this function.
1283
 * \note The channel does not need to be locked before calling this function.
1284
 */
1284
 */
1285
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control,
1285
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control,
1286
			   const void *data, size_t datalen);
1286
			   const void *data, size_t datalen);
1287

    
   
1287

   
1288
/*!
1288
/*!
1289
 * \brief Change channel name
1289
 * \brief Change channel name
1290
 *
1290
 *
1291
 * \pre Absolutely all channels _MUST_ be unlocked before calling this function.
1291
 * \pre Absolutely all channels _MUST_ be unlocked before calling this function.
1292
 *
1292
 *
1293
 * \param chan the channel to change the name of
1293
 * \param chan the channel to change the name of
1294
 * \param newname the name to change to
1294
 * \param newname the name to change to
1295
 *
1295
 *
1296
 * \return nothing
1296
 * \return nothing
1297
 *
1297
 *
1298
 * \note this function must _NEVER_ be used when any channels are locked
1298
 * \note this function must _NEVER_ be used when any channels are locked
1299
 * regardless if it is the channel who's name is being changed or not because
1299
 * regardless if it is the channel who's name is being changed or not because
1300
 * it invalidates our channel container locking order... lock container first,
1300
 * it invalidates our channel container locking order... lock container first,
1301
 * then the individual channels, never the other way around.
1301
 * then the individual channels, never the other way around.
1302
 */
1302
 */
1303
void ast_change_name(struct ast_channel *chan, const char *newname);
1303
void ast_change_name(struct ast_channel *chan, const char *newname);
1304

    
   
1304

   
1305
/*!
1305
/*!
1306
 * \brief Unlink and release reference to a channel
1306
 * \brief Unlink and release reference to a channel
1307
 *
1307
 *
1308
 * This function will unlink the channel from the global channels container
1308
 * This function will unlink the channel from the global channels container
1309
 * if it is still there and also release the current reference to the channel.
1309
 * if it is still there and also release the current reference to the channel.
1310
 *
1310
 *
1311
 * \return NULL, convenient for clearing invalid pointers
1311
 * \return NULL, convenient for clearing invalid pointers
1312
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1312
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1313
 *
1313
 *
1314
 * \since 1.8
1314
 * \since 1.8
1315
 */
1315
 */
1316
struct ast_channel *ast_channel_release(struct ast_channel *chan);
1316
struct ast_channel *ast_channel_release(struct ast_channel *chan);
1317

    
   
1317

   
1318
/*!
1318
/*!
1319
 * \brief Requests a channel
1319
 * \brief Requests a channel
1320
 *
1320
 *
1321
 * \param type type of channel to request
1321
 * \param type type of channel to request
1322
 * \param request_cap Format capabilities for requested channel
1322
 * \param request_cap Format capabilities for requested channel
1323
 * \param requestor channel asking for data
1323
 * \param requestor channel asking for data
1324
 * \param addr destination of the call
1324
 * \param addr destination of the call
1325
 * \param cause Cause of failure
1325
 * \param cause Cause of failure
1326
 *
1326
 *
1327
 * \details
1327
 * \details
1328
 * Request a channel of a given type, with addr as optional information used
1328
 * Request a channel of a given type, with addr as optional information used
1329
 * by the low level module
1329
 * by the low level module
1330
 *
1330
 *
1331
 * \retval NULL failure
1331
 * \retval NULL failure
1332
 * \retval non-NULL channel on success
1332
 * \retval non-NULL channel on success
1333
 */
1333
 */
1334
struct ast_channel *ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_channel *requestor, const char *addr, int *cause);
1334
struct ast_channel *ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_channel *requestor, const char *addr, int *cause);
1335

    
   
1335

   
1336
/*!
1336
/*!
1337
 * \brief Request a channel of a given type, with data as optional information used
1337
 * \brief Request a channel of a given type, with data as optional information used
1338
 *        by the low level module and attempt to place a call on it
1338
 *        by the low level module and attempt to place a call on it
1339
 *
1339
 *
1340
 * \param type type of channel to request
1340
 * \param type type of channel to request
1341
 * \param cap format capabilities for requested channel
1341
 * \param cap format capabilities for requested channel
1342
 * \param requestor channel asking for data
1342
 * \param requestor channel asking for data
1343
 * \param addr destination of the call
1343
 * \param addr destination of the call
1344
 * \param timeout maximum amount of time to wait for an answer
1344
 * \param timeout maximum amount of time to wait for an answer
1345
 * \param reason why unsuccessful (if unsuccessful)
1345
 * \param reason why unsuccessful (if unsuccessful)
1346
 * \param cid_num Caller-ID Number
1346
 * \param cid_num Caller-ID Number
1347
 * \param cid_name Caller-ID Name (ascii)
1347
 * \param cid_name Caller-ID Name (ascii)
1348
 *
1348
 *
1349
 * \return Returns an ast_channel on success or no answer, NULL on failure.  Check the value of chan->_state
1349
 * \return Returns an ast_channel on success or no answer, NULL on failure.  Check the value of chan->_state
1350
 * to know if the call was answered or not.
1350
 * to know if the call was answered or not.
1351
 */
1351
 */
1352
struct ast_channel *ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr,
1352
struct ast_channel *ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr,
1353
	int timeout, int *reason, const char *cid_num, const char *cid_name);
1353
	int timeout, int *reason, const char *cid_num, const char *cid_name);
1354

    
   
1354

   
1355
/*!
1355
/*!
1356
 * \brief Request a channel of a given type, with data as optional information used
1356
 * \brief Request a channel of a given type, with data as optional information used
1357
 * by the low level module and attempt to place a call on it
1357
 * by the low level module and attempt to place a call on it
1358
 * \param type type of channel to request
1358
 * \param type type of channel to request
1359
 * \param cap format capabilities for requested channel
1359
 * \param cap format capabilities for requested channel
1360
 * \param requestor channel requesting data
1360
 * \param requestor channel requesting data
1361
 * \param addr destination of the call
1361
 * \param addr destination of the call
1362
 * \param timeout maximum amount of time to wait for an answer
1362
 * \param timeout maximum amount of time to wait for an answer
1363
 * \param reason why unsuccessful (if unsuccessful)
1363
 * \param reason why unsuccessful (if unsuccessful)
1364
 * \param cid_num Caller-ID Number
1364
 * \param cid_num Caller-ID Number
1365
 * \param cid_name Caller-ID Name (ascii)
1365
 * \param cid_name Caller-ID Name (ascii)
1366
 * \param oh Outgoing helper
1366
 * \param oh Outgoing helper
1367
 * \return Returns an ast_channel on success or no answer, NULL on failure.  Check the value of chan->_state
1367
 * \return Returns an ast_channel on success or no answer, NULL on failure.  Check the value of chan->_state
1368
 * to know if the call was answered or not.
1368
 * to know if the call was answered or not.
1369
 */
1369
 */
1370
struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr,
1370
struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr,
1371
	int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
1371
	int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
1372

    
   
1372

   
1373
/*!
1373
/*!
1374
 * \brief Forwards a call to a new channel specified by the original channel's call_forward str.  If possible, the new forwarded channel is created and returned while the original one is terminated.
1374
 * \brief Forwards a call to a new channel specified by the original channel's call_forward str.  If possible, the new forwarded channel is created and returned while the original one is terminated.
1375
 * \param caller in channel that requested orig
1375
 * \param caller in channel that requested orig
1376
 * \param orig channel being replaced by the call forward channel
1376
 * \param orig channel being replaced by the call forward channel
1377
 * \param timeout maximum amount of time to wait for setup of new forward channel
1377
 * \param timeout maximum amount of time to wait for setup of new forward channel
1378
 * \param cap format capabilities for requested channel
1378
 * \param cap format capabilities for requested channel
1379
 * \param oh outgoing helper used with original channel
1379
 * \param oh outgoing helper used with original channel
1380
 * \param outstate reason why unsuccessful (if uncuccessful)
1380
 * \param outstate reason why unsuccessful (if uncuccessful)
1381
 * \return Returns the forwarded call's ast_channel on success or NULL on failure
1381
 * \return Returns the forwarded call's ast_channel on success or NULL on failure
1382
 */
1382
 */
1383
struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate);
1383
struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate);
1384

    
   
1384

   
1385
/*!
1385
/*!
1386
 * \brief Register a channel technology (a new channel driver)
1386
 * \brief Register a channel technology (a new channel driver)
1387
 * Called by a channel module to register the kind of channels it supports.
1387
 * Called by a channel module to register the kind of channels it supports.
1388
 * \param tech Structure defining channel technology or "type"
1388
 * \param tech Structure defining channel technology or "type"
1389
 * \return Returns 0 on success, -1 on failure.
1389
 * \return Returns 0 on success, -1 on failure.
1390
 */
1390
 */
1391
int ast_channel_register(const struct ast_channel_tech *tech);
1391
int ast_channel_register(const struct ast_channel_tech *tech);
1392

    
   
1392

   
1393
/*!
1393
/*!
1394
 * \brief Unregister a channel technology
1394
 * \brief Unregister a channel technology
1395
 * \param tech Structure defining channel technology or "type" that was previously registered
1395
 * \param tech Structure defining channel technology or "type" that was previously registered
1396
 * \return No return value.
1396
 * \return No return value.
1397
 */
1397
 */
1398
void ast_channel_unregister(const struct ast_channel_tech *tech);
1398
void ast_channel_unregister(const struct ast_channel_tech *tech);
1399

    
   
1399

   
1400
/*!
1400
/*!
1401
 * \brief Get a channel technology structure by name
1401
 * \brief Get a channel technology structure by name
1402
 * \param name name of technology to find
1402
 * \param name name of technology to find
1403
 * \return a pointer to the structure, or NULL if no matching technology found
1403
 * \return a pointer to the structure, or NULL if no matching technology found
1404
 */
1404
 */
1405
const struct ast_channel_tech *ast_get_channel_tech(const char *name);
1405
const struct ast_channel_tech *ast_get_channel_tech(const char *name);
1406

    
   
1406

   
1407
#ifdef CHANNEL_TRACE
1407
#ifdef CHANNEL_TRACE
1408
/*!
1408
/*!
1409
 * \brief Update the context backtrace if tracing is enabled
1409
 * \brief Update the context backtrace if tracing is enabled
1410
 * \return Returns 0 on success, -1 on failure
1410
 * \return Returns 0 on success, -1 on failure
1411
 */
1411
 */
1412
int ast_channel_trace_update(struct ast_channel *chan);
1412
int ast_channel_trace_update(struct ast_channel *chan);
1413

    
   
1413

   
1414
/*!
1414
/*!
1415
 * \brief Enable context tracing in the channel
1415
 * \brief Enable context tracing in the channel
1416
 * \return Returns 0 on success, -1 on failure
1416
 * \return Returns 0 on success, -1 on failure
1417
 */
1417
 */
1418
int ast_channel_trace_enable(struct ast_channel *chan);
1418
int ast_channel_trace_enable(struct ast_channel *chan);
1419

    
   
1419

   
1420
/*!
1420
/*!
1421
 * \brief Disable context tracing in the channel.
1421
 * \brief Disable context tracing in the channel.
1422
 * \note Does not remove current trace entries
1422
 * \note Does not remove current trace entries
1423
 * \return Returns 0 on success, -1 on failure
1423
 * \return Returns 0 on success, -1 on failure
1424
 */
1424
 */
1425
int ast_channel_trace_disable(struct ast_channel *chan);
1425
int ast_channel_trace_disable(struct ast_channel *chan);
1426

    
   
1426

   
1427
/*!
1427
/*!
1428
 * \brief Whether or not context tracing is enabled
1428
 * \brief Whether or not context tracing is enabled
1429
 * \return Returns -1 when the trace is enabled. 0 if not.
1429
 * \return Returns -1 when the trace is enabled. 0 if not.
1430
 */
1430
 */
1431
int ast_channel_trace_is_enabled(struct ast_channel *chan);
1431
int ast_channel_trace_is_enabled(struct ast_channel *chan);
1432

    
   
1432

   
1433
/*!
1433
/*!
1434
 * \brief Put the channel backtrace in a string
1434
 * \brief Put the channel backtrace in a string
1435
 * \return Returns the amount of lines in the backtrace. -1 on error.
1435
 * \return Returns the amount of lines in the backtrace. -1 on error.
1436
 */
1436
 */
1437
int ast_channel_trace_serialize(struct ast_channel *chan, struct ast_str **out);
1437
int ast_channel_trace_serialize(struct ast_channel *chan, struct ast_str **out);
1438
#endif
1438
#endif
1439

    
   
1439

   
1440
/*!
1440
/*!
1441
 * \brief Hang up a channel
1441
 * \brief Hang up a channel
1442
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1442
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1443
 * \note This function performs a hard hangup on a channel.  Unlike the soft-hangup, this function
1443
 * \note This function performs a hard hangup on a channel.  Unlike the soft-hangup, this function
1444
 * performs all stream stopping, etc, on the channel that needs to end.
1444
 * performs all stream stopping, etc, on the channel that needs to end.
1445
 * chan is no longer valid after this call.
1445
 * chan is no longer valid after this call.
1446
 * \param chan channel to hang up
1446
 * \param chan channel to hang up
1447
 * \return Returns 0 on success, -1 on failure.
1447
 * \return Returns 0 on success, -1 on failure.
1448
 */
1448
 */
1449
int ast_hangup(struct ast_channel *chan);
1449
int ast_hangup(struct ast_channel *chan);
1450

    
   
1450

   
1451
/*!
1451
/*!
1452
 * \brief Softly hangup up a channel
1452
 * \brief Softly hangup up a channel
1453
 *
1453
 *
1454
 * \param chan channel to be soft-hung-up
1454
 * \param chan channel to be soft-hung-up
1455
 * \param reason an AST_SOFTHANGUP_* reason code
1455
 * \param reason an AST_SOFTHANGUP_* reason code
1456
 *
1456
 *
1457
 * \details
1457
 * \details
1458
 * Call the protocol layer, but don't destroy the channel structure
1458
 * Call the protocol layer, but don't destroy the channel structure
1459
 * (use this if you are trying to
1459
 * (use this if you are trying to
1460
 * safely hangup a channel managed by another thread.
1460
 * safely hangup a channel managed by another thread.
1461
 *
1461
 *
1462
 * \note The channel passed to this function does not need to be locked.
1462
 * \note The channel passed to this function does not need to be locked.
1463
 *
1463
 *
1464
 * \return Returns 0 regardless
1464
 * \return Returns 0 regardless
1465
 */
1465
 */
1466
int ast_softhangup(struct ast_channel *chan, int reason);
1466
int ast_softhangup(struct ast_channel *chan, int reason);
1467

    
   
1467

   
1468
/*!
1468
/*!
1469
 * \brief Softly hangup up a channel (no channel lock)
1469
 * \brief Softly hangup up a channel (no channel lock)
1470
 * \param chan channel to be soft-hung-up
1470
 * \param chan channel to be soft-hung-up
1471
 * \param reason an AST_SOFTHANGUP_* reason code
1471
 * \param reason an AST_SOFTHANGUP_* reason code
1472
 */
1472
 */
1473
int ast_softhangup_nolock(struct ast_channel *chan, int reason);
1473
int ast_softhangup_nolock(struct ast_channel *chan, int reason);
1474

    
   
1474

   
1475
/*!
1475
/*!
1476
 * \brief Clear a set of softhangup flags from a channel
1476
 * \brief Clear a set of softhangup flags from a channel
1477
 *
1477
 *
1478
 * Never clear a softhangup flag from a channel directly.  Instead,
1478
 * Never clear a softhangup flag from a channel directly.  Instead,
1479
 * use this function.  This ensures that all aspects of the softhangup
1479
 * use this function.  This ensures that all aspects of the softhangup
1480
 * process are aborted.
1480
 * process are aborted.
1481
 *
1481
 *
1482
 * \param chan the channel to clear the flag on
1482
 * \param chan the channel to clear the flag on
1483
 * \param flag the flag or flags to clear
1483
 * \param flag the flag or flags to clear
1484
 *
1484
 *
1485
 * \return Nothing.
1485
 * \return Nothing.
1486
 */
1486
 */
1487
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag);
1487
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag);
1488

    
   
1488

   
1489
/*!
1489
/*!
1490
 * \brief Set the source of the hangup in this channel and it's bridge
1490
 * \brief Set the source of the hangup in this channel and it's bridge
1491
 *
1491
 *
1492
 * \param chan channel to set the field on
1492
 * \param chan channel to set the field on
1493
 * \param source a string describing the source of the hangup for this channel
1493
 * \param source a string describing the source of the hangup for this channel
1494
 * \param force
1494
 * \param force
1495
 *
1495
 *
1496
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1496
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1497
 *
1497
 *
1498
 * \since 1.8
1498
 * \since 1.8
1499
 *
1499
 *
1500
 * Hangupsource is generally the channel name that caused the bridge to be
1500
 * Hangupsource is generally the channel name that caused the bridge to be
1501
 * hung up, but it can also be other things such as "dialplan/agi"
1501
 * hung up, but it can also be other things such as "dialplan/agi"
1502
 * This can then be logged in the CDR or CEL
1502
 * This can then be logged in the CDR or CEL
1503
 */
1503
 */
1504
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force);
1504
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force);
1505

    
   
1505

   
1506
/*! \brief Check to see if a channel is needing hang up
1506
/*! \brief Check to see if a channel is needing hang up
1507
 * \param chan channel on which to check for hang up
1507
 * \param chan channel on which to check for hang up
1508
 * This function determines if the channel is being requested to be hung up.
1508
 * This function determines if the channel is being requested to be hung up.
1509
 * \return Returns 0 if not, or 1 if hang up is requested (including time-out).
1509
 * \return Returns 0 if not, or 1 if hang up is requested (including time-out).
1510
 */
1510
 */
1511
int ast_check_hangup(struct ast_channel *chan);
1511
int ast_check_hangup(struct ast_channel *chan);
1512

    
   
1512

   
1513
int ast_check_hangup_locked(struct ast_channel *chan);
1513
int ast_check_hangup_locked(struct ast_channel *chan);
1514

    
   
1514

   
1515
/*!
1515
/*!
1516
 * \brief Lock the given channel, then request softhangup on the channel with the given causecode
1516
 * \brief Lock the given channel, then request softhangup on the channel with the given causecode
1517
 * \param chan channel on which to hang up
1517
 * \param chan channel on which to hang up
1518
 * \param causecode cause code to use (Zero if don't use cause code)
1518
 * \param causecode cause code to use (Zero if don't use cause code)
1519
 * \return Nothing
1519
 * \return Nothing
1520
 */
1520
 */
1521
void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode);
1521
void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode);
1522

    
   
1522

   
1523
/*!
1523
/*!
1524
 * \brief Compare a offset with the settings of when to hang a channel up
1524
 * \brief Compare a offset with the settings of when to hang a channel up
1525
 * \param chan channel on which to check for hang up
1525
 * \param chan channel on which to check for hang up
1526
 * \param offset offset in seconds from current time
1526
 * \param offset offset in seconds from current time
1527
 * \return 1, 0, or -1
1527
 * \return 1, 0, or -1
1528
 * \details
1528
 * \details
1529
 * This function compares a offset from current time with the absolute time
1529
 * This function compares a offset from current time with the absolute time
1530
 * out on a channel (when to hang up). If the absolute time out on a channel
1530
 * out on a channel (when to hang up). If the absolute time out on a channel
1531
 * is earlier than current time plus the offset, it returns 1, if the two
1531
 * is earlier than current time plus the offset, it returns 1, if the two
1532
 * time values are equal, it return 0, otherwise, it return -1.
1532
 * time values are equal, it return 0, otherwise, it return -1.
1533
 * \sa ast_channel_cmpwhentohangup_tv()
1533
 * \sa ast_channel_cmpwhentohangup_tv()
1534
 * \version 1.6.1 deprecated function (only had seconds precision)
1534
 * \version 1.6.1 deprecated function (only had seconds precision)
1535
 */
1535
 */
1536
int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated));
1536
int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated));
1537

    
   
1537

   
1538
/*!
1538
/*!
1539
 * \brief Compare a offset with the settings of when to hang a channel up
1539
 * \brief Compare a offset with the settings of when to hang a channel up
1540
 * \param chan channel on which to check for hangup
1540
 * \param chan channel on which to check for hangup
1541
 * \param offset offset in seconds and microseconds from current time
1541
 * \param offset offset in seconds and microseconds from current time
1542
 * \return 1, 0, or -1
1542
 * \return 1, 0, or -1
1543
 * This function compares a offset from current time with the absolute time
1543
 * This function compares a offset from current time with the absolute time
1544
 * out on a channel (when to hang up). If the absolute time out on a channel
1544
 * out on a channel (when to hang up). If the absolute time out on a channel
1545
 * is earlier than current time plus the offset, it returns 1, if the two
1545
 * is earlier than current time plus the offset, it returns 1, if the two
1546
 * time values are equal, it return 0, otherwise, it return -1.
1546
 * time values are equal, it return 0, otherwise, it return -1.
1547
 * \since 1.6.1
1547
 * \since 1.6.1
1548
 */
1548
 */
1549
int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1549
int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1550

    
   
1550

   
1551
/*!
1551
/*!
1552
 * \brief Set when to hang a channel up
1552
 * \brief Set when to hang a channel up
1553
 *
1553
 *
1554
 * \param chan channel on which to check for hang up
1554
 * \param chan channel on which to check for hang up
1555
 * \param offset offset in seconds relative to the current time of when to hang up
1555
 * \param offset offset in seconds relative to the current time of when to hang up
1556
 *
1556
 *
1557
 * \details
1557
 * \details
1558
 * This function sets the absolute time out on a channel (when to hang up).
1558
 * This function sets the absolute time out on a channel (when to hang up).
1559
 *
1559
 *
1560
 * \note This function does not require that the channel is locked before
1560
 * \note This function does not require that the channel is locked before
1561
 *       calling it.
1561
 *       calling it.
1562
 *
1562
 *
1563
 * \return Nothing
1563
 * \return Nothing
1564
 * \sa ast_channel_setwhentohangup_tv()
1564
 * \sa ast_channel_setwhentohangup_tv()
1565
 * \version 1.6.1 deprecated function (only had seconds precision)
1565
 * \version 1.6.1 deprecated function (only had seconds precision)
1566
 */
1566
 */
1567
void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated));
1567
void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated));
1568

    
   
1568

   
1569
/*!
1569
/*!
1570
 * \brief Set when to hang a channel up
1570
 * \brief Set when to hang a channel up
1571
 *
1571
 *
1572
 * \param chan channel on which to check for hang up
1572
 * \param chan channel on which to check for hang up
1573
 * \param offset offset in seconds and useconds relative to the current time of when to hang up
1573
 * \param offset offset in seconds and useconds relative to the current time of when to hang up
1574
 *
1574
 *
1575
 * This function sets the absolute time out on a channel (when to hang up).
1575
 * This function sets the absolute time out on a channel (when to hang up).
1576
 *
1576
 *
1577
 * \note This function does not require that the channel is locked before
1577
 * \note This function does not require that the channel is locked before
1578
 * calling it.
1578
 * calling it.
1579
 *
1579
 *
1580
 * \return Nothing
1580
 * \return Nothing
1581
 * \since 1.6.1
1581
 * \since 1.6.1
1582
 */
1582
 */
1583
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1583
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1584

    
   
1584

   
1585
/*!
1585
/*!
1586
 * \brief Answer a channel
1586
 * \brief Answer a channel
1587
 *
1587
 *
1588
 * \param chan channel to answer
1588
 * \param chan channel to answer
1589
 *
1589
 *
1590
 * \details
1590
 * \details
1591
 * This function answers a channel and handles all necessary call
1591
 * This function answers a channel and handles all necessary call
1592
 * setup functions.
1592
 * setup functions.
1593
 *
1593
 *
1594
 * \note The channel passed does not need to be locked, but is locked
1594
 * \note The channel passed does not need to be locked, but is locked
1595
 * by the function when needed.
1595
 * by the function when needed.
1596
 *
1596
 *
1597
 * \note This function will wait up to 500 milliseconds for media to
1597
 * \note This function will wait up to 500 milliseconds for media to
1598
 * arrive on the channel before returning to the caller, so that the
1598
 * arrive on the channel before returning to the caller, so that the
1599
 * caller can properly assume the channel is 'ready' for media flow.
1599
 * caller can properly assume the channel is 'ready' for media flow.
1600
 *
1600
 *
1601
 * \retval 0 on success
1601
 * \retval 0 on success
1602
 * \retval non-zero on failure
1602
 * \retval non-zero on failure
1603
 */
1603
 */
1604
int ast_answer(struct ast_channel *chan);
1604
int ast_answer(struct ast_channel *chan);
1605

    
   
1605

   
1606
/*!
1606
/*!
1607
 * \brief Answer a channel
1607
 * \brief Answer a channel
1608
 *
1608
 *
1609
 * \param chan channel to answer
1609
 * \param chan channel to answer
1610
 *
1610
 *
1611
 * This function answers a channel and handles all necessary call
1611
 * This function answers a channel and handles all necessary call
1612
 * setup functions.
1612
 * setup functions.
1613
 *
1613
 *
1614
 * \note The channel passed does not need to be locked, but is locked
1614
 * \note The channel passed does not need to be locked, but is locked
1615
 * by the function when needed.
1615
 * by the function when needed.
1616
 *
1616
 *
1617
 * \note Unlike ast_answer(), this function will not wait for media
1617
 * \note Unlike ast_answer(), this function will not wait for media
1618
 * flow to begin. The caller should be careful before sending media
1618
 * flow to begin. The caller should be careful before sending media
1619
 * to the channel before incoming media arrives, as the outgoing
1619
 * to the channel before incoming media arrives, as the outgoing
1620
 * media may be lost.
1620
 * media may be lost.
1621
 *
1621
 *
1622
 * \retval 0 on success
1622
 * \retval 0 on success
1623
 * \retval non-zero on failure
1623
 * \retval non-zero on failure
1624
 */
1624
 */
1625
int ast_raw_answer(struct ast_channel *chan);
1625
int ast_raw_answer(struct ast_channel *chan);
1626

    
   
1626

   
1627
/*!
1627
/*!
1628
 * \brief Answer a channel, with a selectable delay before returning
1628
 * \brief Answer a channel, with a selectable delay before returning
1629
 *
1629
 *
1630
 * \param chan channel to answer
1630
 * \param chan channel to answer
1631
 * \param delay maximum amount of time to wait for incoming media
1631
 * \param delay maximum amount of time to wait for incoming media
1632
 *
1632
 *
1633
 * This function answers a channel and handles all necessary call
1633
 * This function answers a channel and handles all necessary call
1634
 * setup functions.
1634
 * setup functions.
1635
 *
1635
 *
1636
 * \note The channel passed does not need to be locked, but is locked
1636
 * \note The channel passed does not need to be locked, but is locked
1637
 * by the function when needed.
1637
 * by the function when needed.
1638
 *
1638
 *
1639
 * \note This function will wait up to 'delay' milliseconds for media to
1639
 * \note This function will wait up to 'delay' milliseconds for media to
1640
 * arrive on the channel before returning to the caller, so that the
1640
 * arrive on the channel before returning to the caller, so that the
1641
 * caller can properly assume the channel is 'ready' for media flow. If
1641
 * caller can properly assume the channel is 'ready' for media flow. If
1642
 * 'delay' is less than 500, the function will wait up to 500 milliseconds.
1642
 * 'delay' is less than 500, the function will wait up to 500 milliseconds.
1643
 *
1643
 *
1644
 * \retval 0 on success
1644
 * \retval 0 on success
1645
 * \retval non-zero on failure
1645
 * \retval non-zero on failure
1646
 */
1646
 */
1647
int __ast_answer(struct ast_channel *chan, unsigned int delay);
1647
int __ast_answer(struct ast_channel *chan, unsigned int delay);
1648

    
   
1648

   
1649
/*!
1649
/*!
1650
 * \brief Execute a Gosub call on the channel before a call is placed.
1650
 * \brief Execute a Gosub call on the channel before a call is placed.
1651
 * \since 11.0
1651
 * \since 11.0
1652
 *
1652
 *
1653
 * \details
1653
 * \details
1654
 * This is called between ast_request() and ast_call() to
1654
 * This is called between ast_request() and ast_call() to
1655
 * execute a predial routine on the newly created channel.
1655
 * execute a predial routine on the newly created channel.
1656
 *
1656
 *
1657
 * \param chan Channel to execute Gosub.
1657
 * \param chan Channel to execute Gosub.
1658
 * \param sub_args Gosub application parameter string.
1658
 * \param sub_args Gosub application parameter string.
1659
 *
1659
 *
1660
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1660
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1661
 *
1661
 *
1662
 * \retval 0 on success.
1662
 * \retval 0 on success.
1663
 * \retval -1 on error.
1663
 * \retval -1 on error.
1664
 */
1664
 */
1665
int ast_pre_call(struct ast_channel *chan, const char *sub_args);
1665
int ast_pre_call(struct ast_channel *chan, const char *sub_args);
1666

    
   
1666

   
1667
/*!
1667
/*!
1668
 * \brief Make a call
1668
 * \brief Make a call
1669
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1669
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1670
 * \param chan which channel to make the call on
1670
 * \param chan which channel to make the call on
1671
 * \param addr destination of the call
1671
 * \param addr destination of the call
1672
 * \param timeout time to wait on for connect (Doesn't seem to be used.)
1672
 * \param timeout time to wait on for connect (Doesn't seem to be used.)
1673
 * \details
1673
 * \details
1674
 * Place a call, take no longer than timeout ms.
1674
 * Place a call, take no longer than timeout ms.
1675
 * \retval 0 on success
1675
 * \retval 0 on success
1676
 * \retval -1 on failure
1676
 * \retval -1 on failure
1677
 */
1677
 */
1678
int ast_call(struct ast_channel *chan, const char *addr, int timeout);
1678
int ast_call(struct ast_channel *chan, const char *addr, int timeout);
1679

    
   
1679

   
1680
/*!
1680
/*!
1681
 * \brief Indicates condition of channel
1681
 * \brief Indicates condition of channel
1682
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1682
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1683
 * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel
1683
 * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel
1684
 * \param chan channel to change the indication
1684
 * \param chan channel to change the indication
1685
 * \param condition which condition to indicate on the channel
1685
 * \param condition which condition to indicate on the channel
1686
 * \return Returns 0 on success, -1 on failure
1686
 * \return Returns 0 on success, -1 on failure
1687
 */
1687
 */
1688
int ast_indicate(struct ast_channel *chan, int condition);
1688
int ast_indicate(struct ast_channel *chan, int condition);
1689

    
   
1689

   
1690
/*!
1690
/*!
1691
 * \brief Indicates condition of channel, with payload
1691
 * \brief Indicates condition of channel, with payload
1692
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1692
 * \note Absolutely _NO_ channel locks should be held before calling this function.
1693
 * \note Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class
1693
 * \note Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class
1694
 * \param chan channel to change the indication
1694
 * \param chan channel to change the indication
1695
 * \param condition which condition to indicate on the channel
1695
 * \param condition which condition to indicate on the channel
1696
 * \param data pointer to payload data
1696
 * \param data pointer to payload data
1697
 * \param datalen size of payload data
1697
 * \param datalen size of payload data
1698
 * \return Returns 0 on success, -1 on failure
1698
 * \return Returns 0 on success, -1 on failure
1699
 */
1699
 */
1700
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen);
1700
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen);
1701

    
   
1701

   
1702
/* Misc stuff ------------------------------------------------ */
1702
/* Misc stuff ------------------------------------------------ */
1703

    
   
1703

   
1704
/*!
1704
/*!
1705
 * \brief Wait for input on a channel
1705
 * \brief Wait for input on a channel
1706
 * \param chan channel to wait on
1706
 * \param chan channel to wait on
1707
 * \param ms length of time to wait on the channel
1707
 * \param ms length of time to wait on the channel
1708
 * \details
1708
 * \details
1709
 * Wait for input on a channel for a given # of milliseconds (<0 for indefinite).
1709
 * Wait for input on a channel for a given # of milliseconds (<0 for indefinite).
1710
 * \retval < 0 on failure
1710
 * \retval < 0 on failure
1711
 * \retval 0 if nothing ever arrived
1711
 * \retval 0 if nothing ever arrived
1712
 * \retval the # of ms remaining otherwise
1712
 * \retval the # of ms remaining otherwise
1713
 */
1713
 */
1714
int ast_waitfor(struct ast_channel *chan, int ms);
1714
int ast_waitfor(struct ast_channel *chan, int ms);
1715

    
   
1715

   
1716
/*!
1716
/*!
1717
 * \brief Should we keep this frame for later?
1717
 * \brief Should we keep this frame for later?
1718
 *
1718
 *
1719
 * There are functions such as ast_safe_sleep which will
1719
 * There are functions such as ast_safe_sleep which will
1720
 * service a channel to ensure that it does not have a
1720
 * service a channel to ensure that it does not have a
1721
 * large backlog of queued frames. When this happens,
1721
 * large backlog of queued frames. When this happens,
1722
 * we want to hold on to specific frame types and just drop
1722
 * we want to hold on to specific frame types and just drop
1723
 * others. This function will tell if the frame we just
1723
 * others. This function will tell if the frame we just
1724
 * read should be held onto.
1724
 * read should be held onto.
1725
 *
1725
 *
1726
 * \param frame The frame we just read
1726
 * \param frame The frame we just read
1727
 * \retval 1 frame should be kept
1727
 * \retval 1 frame should be kept
1728
 * \retval 0 frame should be dropped
1728
 * \retval 0 frame should be dropped
1729
 */
1729
 */
1730
int ast_is_deferrable_frame(const struct ast_frame *frame);
1730
int ast_is_deferrable_frame(const struct ast_frame *frame);
1731

    
   
1731

   
1732
/*!
1732
/*!
1733
 * \brief Wait for a specified amount of time, looking for hangups
1733
 * \brief Wait for a specified amount of time, looking for hangups
1734
 * \param chan channel to wait for
1734
 * \param chan channel to wait for
1735
 * \param ms length of time in milliseconds to sleep. This should never be less than zero.
1735
 * \param ms length of time in milliseconds to sleep. This should never be less than zero.
1736
 * \details
1736
 * \details
1737
 * Waits for a specified amount of time, servicing the channel as required.
1737
 * Waits for a specified amount of time, servicing the channel as required.
1738
 * \return returns -1 on hangup, otherwise 0.
1738
 * \return returns -1 on hangup, otherwise 0.
1739
 */
1739
 */
1740
int ast_safe_sleep(struct ast_channel *chan, int ms);
1740
int ast_safe_sleep(struct ast_channel *chan, int ms);
1741

    
   
1741

   
1742
/*!
1742
/*!
1743
 * \brief Wait for a specified amount of time, looking for hangups and a condition argument
1743
 * \brief Wait for a specified amount of time, looking for hangups and a condition argument
1744
 * \param chan channel to wait for
1744
 * \param chan channel to wait for
1745
 * \param ms length of time in milliseconds to sleep.
1745
 * \param ms length of time in milliseconds to sleep.
1746
 * \param cond a function pointer for testing continue condition
1746
 * \param cond a function pointer for testing continue condition
1747
 * \param data argument to be passed to the condition test function
1747
 * \param data argument to be passed to the condition test function
1748
 * \return returns -1 on hangup, otherwise 0.
1748
 * \return returns -1 on hangup, otherwise 0.
1749
 * \details
1749
 * \details
1750
 * Waits for a specified amount of time, servicing the channel as required. If cond
1750
 * Waits for a specified amount of time, servicing the channel as required. If cond
1751
 * returns 0, this function returns.
1751
 * returns 0, this function returns.
1752
 */
1752
 */
1753
int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data );
1753
int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data );
1754

    
   
1754

   
1755
/*!
1755
/*!
1756
 * \brief Waits for activity on a group of channels
1756
 * \brief Waits for activity on a group of channels
1757
 * \param chan an array of pointers to channels
1757
 * \param chan an array of pointers to channels
1758
 * \param n number of channels that are to be waited upon
1758
 * \param n number of channels that are to be waited upon
1759
 * \param fds an array of fds to wait upon
1759
 * \param fds an array of fds to wait upon
1760
 * \param nfds the number of fds to wait upon
1760
 * \param nfds the number of fds to wait upon
1761
 * \param exception exception flag
1761
 * \param exception exception flag
1762
 * \param outfd fd that had activity on it
1762
 * \param outfd fd that had activity on it
1763
 * \param ms how long the wait was
1763
 * \param ms how long the wait was
1764
 * \details
1764
 * \details
1765
 * Big momma function here.  Wait for activity on any of the n channels, or any of the nfds
1765
 * Big momma function here.  Wait for activity on any of the n channels, or any of the nfds
1766
 * file descriptors.
1766
 * file descriptors.
1767
 * \return Returns the channel with activity, or NULL on error or if an FD
1767
 * \return Returns the channel with activity, or NULL on error or if an FD
1768
 * came first.  If the FD came first, it will be returned in outfd, otherwise, outfd
1768
 * came first.  If the FD came first, it will be returned in outfd, otherwise, outfd
1769
 * will be -1
1769
 * will be -1
1770
 */
1770
 */
1771
struct ast_channel *ast_waitfor_nandfds(struct ast_channel **chan, int n,
1771
struct ast_channel *ast_waitfor_nandfds(struct ast_channel **chan, int n,
1772
	int *fds, int nfds, int *exception, int *outfd, int *ms);
1772
	int *fds, int nfds, int *exception, int *outfd, int *ms);
1773

    
   
1773

   
1774
/*!
1774
/*!
1775
 * \brief Waits for input on a group of channels
1775
 * \brief Waits for input on a group of channels
1776
 * Wait for input on an array of channels for a given # of milliseconds.
1776
 * Wait for input on an array of channels for a given # of milliseconds.
1777
 * \return Return channel with activity, or NULL if none has activity.
1777
 * \return Return channel with activity, or NULL if none has activity.
1778
 * \param chan an array of pointers to channels
1778
 * \param chan an array of pointers to channels
1779
 * \param n number of channels that are to be waited upon
1779
 * \param n number of channels that are to be waited upon
1780
 * \param ms time "ms" is modified in-place, if applicable
1780
 * \param ms time "ms" is modified in-place, if applicable
1781
 */
1781
 */
1782
struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms);
1782
struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms);
1783

    
   
1783

   
1784
/*!
1784
/*!
1785
 * \brief Waits for input on an fd
1785
 * \brief Waits for input on an fd
1786
 * \note This version works on fd's only.  Be careful with it.
1786
 * \note This version works on fd's only.  Be careful with it.
1787
 */
1787
 */
1788
int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);
1788
int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);
1789

    
   
1789

   
1790

    
   
1790

   
1791
/*!
1791
/*!
1792
 * \brief Reads a frame
1792
 * \brief Reads a frame
1793
 * \param chan channel to read a frame from
1793
 * \param chan channel to read a frame from
1794
 * \return Returns a frame, or NULL on error.  If it returns NULL, you
1794
 * \return Returns a frame, or NULL on error.  If it returns NULL, you
1795
 * best just stop reading frames and assume the channel has been
1795
 * best just stop reading frames and assume the channel has been
1796
 * disconnected.
1796
 * disconnected.
1797
 */
1797
 */
1798
struct ast_frame *ast_read(struct ast_channel *chan);
1798
struct ast_frame *ast_read(struct ast_channel *chan);
1799

    
   
1799

   
1800
/*!
1800
/*!
1801
 * \brief Reads a frame, returning AST_FRAME_NULL frame if audio.
1801
 * \brief Reads a frame, returning AST_FRAME_NULL frame if audio.
1802
 * \param chan channel to read a frame from
1802
 * \param chan channel to read a frame from
1803
 * \return  Returns a frame, or NULL on error.  If it returns NULL, you
1803
 * \return  Returns a frame, or NULL on error.  If it returns NULL, you
1804
 * best just stop reading frames and assume the channel has been
1804
 * best just stop reading frames and assume the channel has been
1805
 * disconnected.
1805
 * disconnected.
1806
 * \note Audio is replaced with AST_FRAME_NULL to avoid
1806
 * \note Audio is replaced with AST_FRAME_NULL to avoid
1807
 * transcode when the resulting audio is not necessary.
1807
 * transcode when the resulting audio is not necessary.
1808
 */
1808
 */
1809
struct ast_frame *ast_read_noaudio(struct ast_channel *chan);
1809
struct ast_frame *ast_read_noaudio(struct ast_channel *chan);
1810

    
   
1810

   
1811
/*!
1811
/*!
1812
 * \brief Write a frame to a channel
1812
 * \brief Write a frame to a channel
1813
 * This function writes the given frame to the indicated channel.
1813
 * This function writes the given frame to the indicated channel.
1814
 * \param chan destination channel of the frame
1814
 * \param chan destination channel of the frame
1815
 * \param frame frame that will be written
1815
 * \param frame frame that will be written
1816
 * \return It returns 0 on success, -1 on failure.
1816
 * \return It returns 0 on success, -1 on failure.
1817
 */
1817
 */
1818
int ast_write(struct ast_channel *chan, struct ast_frame *frame);
1818
int ast_write(struct ast_channel *chan, struct ast_frame *frame);
1819

    
   
1819

   
1820
/*!
1820
/*!
1821
 * \brief Write video frame to a channel
1821
 * \brief Write video frame to a channel
1822
 * This function writes the given frame to the indicated channel.
1822
 * This function writes the given frame to the indicated channel.
1823
 * \param chan destination channel of the frame
1823
 * \param chan destination channel of the frame
1824
 * \param frame frame that will be written
1824
 * \param frame frame that will be written
1825
 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
1825
 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
1826
 */
1826
 */
1827
int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);
1827
int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);
1828

    
   
1828

   
1829
/*!
1829
/*!
1830
 * \brief Write text frame to a channel
1830
 * \brief Write text frame to a channel
1831
 * This function writes the given frame to the indicated channel.
1831
 * This function writes the given frame to the indicated channel.
1832
 * \param chan destination channel of the frame
1832
 * \param chan destination channel of the frame
1833
 * \param frame frame that will be written
1833
 * \param frame frame that will be written
1834
 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
1834
 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
1835
 */
1835
 */
1836
int ast_write_text(struct ast_channel *chan, struct ast_frame *frame);
1836
int ast_write_text(struct ast_channel *chan, struct ast_frame *frame);
1837

    
   
1837

   
1838
/*! \brief Send empty audio to prime a channel driver */
1838
/*! \brief Send empty audio to prime a channel driver */
1839
int ast_prod(struct ast_channel *chan);
1839
int ast_prod(struct ast_channel *chan);
1840

    
   
1840

   
1841
/*!
1841
/*!
1842
 * \brief Sets read format on channel chan from capabilities
1842
 * \brief Sets read format on channel chan from capabilities
1843
 * Set read format for channel to whichever component of "format" is best.
1843
 * Set read format for channel to whichever component of "format" is best.
1844
 * \param chan channel to change
1844
 * \param chan channel to change
1845
 * \param formats new formats to pick from for reading
1845
 * \param formats new formats to pick from for reading
1846
 * \return Returns 0 on success, -1 on failure
1846
 * \return Returns 0 on success, -1 on failure
1847
 */
1847
 */
1848
int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats);
1848
int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats);
1849

    
   
1849

   
1850
/*!
1850
/*!
1851
 * \brief Sets read format on channel chan
1851
 * \brief Sets read format on channel chan
1852
 * \param chan channel to change
1852
 * \param chan channel to change
1853
 * \param format format to set for reading
1853
 * \param format format to set for reading
1854
 * \return Returns 0 on success, -1 on failure
1854
 * \return Returns 0 on success, -1 on failure
1855
 */
1855
 */
1856
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format);
1856
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format);
1857

    
   
1857

   
1858
/*!
1858
/*!
1859
 * \brief Sets read format on channel chan by id
1859
 * \brief Sets read format on channel chan by id
1860
 * \param chan channel to change
1860
 * \param chan channel to change
1861
 * \param id format id to set for reading, only used for formats without attributes
1861
 * \param id format id to set for reading, only used for formats without attributes
1862
 * \return Returns 0 on success, -1 on failure
1862
 * \return Returns 0 on success, -1 on failure
1863
 */
1863
 */
1864
int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id);
1864
int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id);
1865

    
   
1865

   
1866
/*!
1866
/*!
1867
 * \brief Sets write format on channel chan
1867
 * \brief Sets write format on channel chan
1868
 * Set write format for channel to whichever component of "format" is best.
1868
 * Set write format for channel to whichever component of "format" is best.
1869
 * \param chan channel to change
1869
 * \param chan channel to change
1870
 * \param formats new formats to pick from for writing
1870
 * \param formats new formats to pick from for writing
1871
 * \return Returns 0 on success, -1 on failure
1871
 * \return Returns 0 on success, -1 on failure
1872
 */
1872
 */
1873
int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats);
1873
int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats);
1874

    
   
1874

   
1875
/*!
1875
/*!
1876
 * \brief Sets write format on channel chan
1876
 * \brief Sets write format on channel chan
1877
 * \param chan channel to change
1877
 * \param chan channel to change
1878
 * \param format format to set for writing
1878
 * \param format format to set for writing
1879
 * \return Returns 0 on success, -1 on failure
1879
 * \return Returns 0 on success, -1 on failure
1880
 */
1880
 */
1881
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format);
1881
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format);
1882

    
   
1882

   
1883
/*!
1883
/*!
1884
 * \brief Sets write format on channel chan
1884
 * \brief Sets write format on channel chan
1885
 * \param chan channel to change
1885
 * \param chan channel to change
1886
 * \param id format id to set for writing, only used for formats without attributes
1886
 * \param id format id to set for writing, only used for formats without attributes
1887
 * \return Returns 0 on success, -1 on failure
1887
 * \return Returns 0 on success, -1 on failure
1888
 */
1888
 */
1889
int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id);
1889
int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id);
1890

    
   
1890

   
1891
/*!
1891
/*!
1892
 * \brief Sends text to a channel
1892
 * \brief Sends text to a channel
1893
 *
1893
 *
1894
 * \param chan channel to act upon
1894
 * \param chan channel to act upon
1895
 * \param text string of text to send on the channel
1895
 * \param text string of text to send on the channel
1896
 *
1896
 *
1897
 * \details
1897
 * \details
1898
 * Write text to a display on a channel
1898
 * Write text to a display on a channel
1899
 *
1899
 *
1900
 * \note The channel does not need to be locked before calling this function.
1900
 * \note The channel does not need to be locked before calling this function.
1901
 *
1901
 *
1902
 * \retval 0 on success
1902
 * \retval 0 on success
1903
 * \retval -1 on failure
1903
 * \retval -1 on failure
1904
 */
1904
 */
1905
int ast_sendtext(struct ast_channel *chan, const char *text);
1905
int ast_sendtext(struct ast_channel *chan, const char *text);
1906

    
   
1906

   
1907
/*!
1907
/*!
1908
 * \brief Receives a text character from a channel
1908
 * \brief Receives a text character from a channel
1909
 * \param chan channel to act upon
1909
 * \param chan channel to act upon
1910
 * \param timeout timeout in milliseconds (0 for infinite wait)
1910
 * \param timeout timeout in milliseconds (0 for infinite wait)
1911
 * \details
1911
 * \details
1912
 * Read a char of text from a channel
1912
 * Read a char of text from a channel
1913
 * \return 0 on success, -1 on failure
1913
 * \return 0 on success, -1 on failure
1914
 */
1914
 */
1915
int ast_recvchar(struct ast_channel *chan, int timeout);
1915
int ast_recvchar(struct ast_channel *chan, int timeout);
1916

    
   
1916

   
1917
/*!
1917
/*!
1918
 * \brief Send a DTMF digit to a channel.
1918
 * \brief Send a DTMF digit to a channel.
1919
 * \param chan channel to act upon
1919
 * \param chan channel to act upon
1920
 * \param digit the DTMF digit to send, encoded in ASCII
1920
 * \param digit the DTMF digit to send, encoded in ASCII
1921
 * \param duration the duration of the digit ending in ms
1921
 * \param duration the duration of the digit ending in ms
1922
 * \return 0 on success, -1 on failure
1922
 * \return 0 on success, -1 on failure
1923
 */
1923
 */
1924
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
1924
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
1925

    
   
1925

   
1926
/*!
1926
/*!
1927
 * \brief Send a DTMF digit to a channel.
1927
 * \brief Send a DTMF digit to a channel.
1928
 * \param chan channel to act upon
1928
 * \param chan channel to act upon
1929
 * \param digit the DTMF digit to send, encoded in ASCII
1929
 * \param digit the DTMF digit to send, encoded in ASCII
1930
 * \return 0 on success, -1 on failure
1930
 * \return 0 on success, -1 on failure
1931
 */
1931
 */
1932
int ast_senddigit_begin(struct ast_channel *chan, char digit);
1932
int ast_senddigit_begin(struct ast_channel *chan, char digit);
1933

    
   
1933

   
1934
/*!
1934
/*!
1935
 * \brief Send a DTMF digit to a channel.
1935
 * \brief Send a DTMF digit to a channel.
1936
 * \param chan channel to act upon
1936
 * \param chan channel to act upon
1937
 * \param digit the DTMF digit to send, encoded in ASCII
1937
 * \param digit the DTMF digit to send, encoded in ASCII
1938
 * \param duration the duration of the digit ending in ms
1938
 * \param duration the duration of the digit ending in ms
1939
 * \return Returns 0 on success, -1 on failure
1939
 * \return Returns 0 on success, -1 on failure
1940
 */
1940
 */
1941
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration);
1941
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration);
1942

    
   
1942

   
1943
/*!
1943
/*!
1944
 * \brief Receives a text string from a channel
1944
 * \brief Receives a text string from a channel
1945
 * Read a string of text from a channel
1945
 * Read a string of text from a channel
1946
 * \param chan channel to act upon
1946
 * \param chan channel to act upon
1947
 * \param timeout timeout in milliseconds (0 for infinite wait)
1947
 * \param timeout timeout in milliseconds (0 for infinite wait)
1948
 * \return the received text, or NULL to signify failure.
1948
 * \return the received text, or NULL to signify failure.
1949
 */
1949
 */
1950
char *ast_recvtext(struct ast_channel *chan, int timeout);
1950
char *ast_recvtext(struct ast_channel *chan, int timeout);
1951

    
   
1951

   
1952
/*!
1952
/*!
1953
 * \brief Waits for a digit
1953
 * \brief Waits for a digit
1954
 * \param c channel to wait for a digit on
1954
 * \param c channel to wait for a digit on
1955
 * \param ms how many milliseconds to wait (<0 for indefinite).
1955
 * \param ms how many milliseconds to wait (<0 for indefinite).
1956
 * \return Returns <0 on error, 0 on no entry, and the digit on success.
1956
 * \return Returns <0 on error, 0 on no entry, and the digit on success.
1957
 */
1957
 */
1958
int ast_waitfordigit(struct ast_channel *c, int ms);
1958
int ast_waitfordigit(struct ast_channel *c, int ms);
1959

    
   
1959

   
1960
/*!
1960
/*!
1961
 * \brief Wait for a digit
1961
 * \brief Wait for a digit
1962
 * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
1962
 * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
1963
 * \param c channel to wait for a digit on
1963
 * \param c channel to wait for a digit on
1964
 * \param ms how many milliseconds to wait (<0 for indefinite).
1964
 * \param ms how many milliseconds to wait (<0 for indefinite).
1965
 * \param audiofd audio file descriptor to write to if audio frames are received
1965
 * \param audiofd audio file descriptor to write to if audio frames are received
1966
 * \param ctrlfd control file descriptor to monitor for reading
1966
 * \param ctrlfd control file descriptor to monitor for reading
1967
 * \return Returns 1 if ctrlfd becomes available
1967
 * \return Returns 1 if ctrlfd becomes available
1968
 */
1968
 */
1969
int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int ctrlfd);
1969
int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int ctrlfd);
1970

    
   
1970

   
1971
/*!
1971
/*!
1972
 * \brief Reads multiple digits
1972
 * \brief Reads multiple digits
1973
 * \param c channel to read from
1973
 * \param c channel to read from
1974
 * \param s string to read in to.  Must be at least the size of your length
1974
 * \param s string to read in to.  Must be at least the size of your length
1975
 * \param len how many digits to read (maximum)
1975
 * \param len how many digits to read (maximum)
1976
 * \param timeout how long to timeout between digits
1976
 * \param timeout how long to timeout between digits
1977
 * \param rtimeout timeout to wait on the first digit
1977
 * \param rtimeout timeout to wait on the first digit
1978
 * \param enders digits to end the string
1978
 * \param enders digits to end the string
1979
 * \details
1979
 * \details
1980
 * Read in a digit string "s", max length "len", maximum timeout between
1980
 * Read in a digit string "s", max length "len", maximum timeout between
1981
 * digits "timeout" (-1 for none), terminated by anything in "enders".  Give them rtimeout
1981
 * digits "timeout" (-1 for none), terminated by anything in "enders".  Give them rtimeout
1982
 * for the first digit.
1982
 * for the first digit.
1983
 * \return Returns 0 on normal return, or 1 on a timeout.  In the case of
1983
 * \return Returns 0 on normal return, or 1 on a timeout.  In the case of
1984
 * a timeout, any digits that were read before the timeout will still be available in s.
1984
 * a timeout, any digits that were read before the timeout will still be available in s.
1985
 * RETURNS 2 in full version when ctrlfd is available, NOT 1
1985
 * RETURNS 2 in full version when ctrlfd is available, NOT 1
1986
 */
1986
 */
1987
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders);
1987
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders);
1988
int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd);
1988
int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd);
1989

    
   
1989

   
1990
/*! \brief Report DTMF on channel 0 */
1990
/*! \brief Report DTMF on channel 0 */
1991
#define AST_BRIDGE_DTMF_CHANNEL_0		(1 << 0)
1991
#define AST_BRIDGE_DTMF_CHANNEL_0		(1 << 0)
1992
/*! \brief Report DTMF on channel 1 */
1992
/*! \brief Report DTMF on channel 1 */
1993
#define AST_BRIDGE_DTMF_CHANNEL_1		(1 << 1)
1993
#define AST_BRIDGE_DTMF_CHANNEL_1		(1 << 1)
1994
/*! \brief Return all voice frames on channel 0 */
1994
/*! \brief Return all voice frames on channel 0 */
1995
#define AST_BRIDGE_REC_CHANNEL_0		(1 << 2)
1995
#define AST_BRIDGE_REC_CHANNEL_0		(1 << 2)
1996
/*! \brief Return all voice frames on channel 1 */
1996
/*! \brief Return all voice frames on channel 1 */
1997
#define AST_BRIDGE_REC_CHANNEL_1		(1 << 3)
1997
#define AST_BRIDGE_REC_CHANNEL_1		(1 << 3)
1998
/*! \brief Ignore all signal frames except NULL */
1998
/*! \brief Ignore all signal frames except NULL */
1999
#define AST_BRIDGE_IGNORE_SIGS			(1 << 4)
1999
#define AST_BRIDGE_IGNORE_SIGS			(1 << 4)
2000

    
   
2000

   
2001

    
   
2001

   
2002
/*!
2002
/*!
2003
 * \brief Makes two channel formats compatible
2003
 * \brief Makes two channel formats compatible
2004
 * \param c0 first channel to make compatible
2004
 * \param c0 first channel to make compatible
2005
 * \param c1 other channel to make compatible
2005
 * \param c1 other channel to make compatible
2006
 * \details
2006
 * \details
2007
 * Set two channels to compatible formats -- call before ast_channel_bridge in general.
2007
 * Set two channels to compatible formats -- call before ast_channel_bridge in general.
2008
 * \return Returns 0 on success and -1 if it could not be done
2008
 * \return Returns 0 on success and -1 if it could not be done
2009
 */
2009
 */
2010
int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1);
2010
int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1);
2011

    
   
2011

   
2012
/*!
2012
/*!
2013
 * \brief Bridge two channels together (early)
2013
 * \brief Bridge two channels together (early)
2014
 * \param c0 first channel to bridge
2014
 * \param c0 first channel to bridge
2015
 * \param c1 second channel to bridge
2015
 * \param c1 second channel to bridge
2016
 * \details
2016
 * \details
2017
 * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
2017
 * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
2018
 * \return Returns 0 on success and -1 if it could not be done
2018
 * \return Returns 0 on success and -1 if it could not be done
2019
 */
2019
 */
2020
int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
2020
int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
2021

    
   
2021

   
2022
/*!
2022
/*!
2023
 * \brief Weird function made for call transfers
2023
 * \brief Weird function made for call transfers
2024
 *
2024
 *
2025
 * \param original channel to make a copy of
2025
 * \param original channel to make a copy of
2026
 * \param clone copy of the original channel
2026
 * \param clone copy of the original channel
2027
 *
2027
 *
2028
 * \details
2028
 * \details
2029
 * This is a very strange and freaky function used primarily for transfer.  Suppose that
2029
 * This is a very strange and freaky function used primarily for transfer.  Suppose that
2030
 * "original" and "clone" are two channels in random situations.  This function takes
2030
 * "original" and "clone" are two channels in random situations.  This function takes
2031
 * the guts out of "clone" and puts them into the "original" channel, then alerts the
2031
 * the guts out of "clone" and puts them into the "original" channel, then alerts the
2032
 * channel driver of the change, asking it to fixup any private information (like the
2032
 * channel driver of the change, asking it to fixup any private information (like the
2033
 * p->owner pointer) that is affected by the change.  The physical layer of the original
2033
 * p->owner pointer) that is affected by the change.  The physical layer of the original
2034
 * channel is hung up.
2034
 * channel is hung up.
2035
 *
2035
 *
2036
 * \note Neither channel passed here should be locked before
2036
 * \note Neither channel passed here should be locked before
2037
 * calling this function.  This function performs deadlock
2037
 * calling this function.  This function performs deadlock
2038
 * avoidance involving these two channels.
2038
 * avoidance involving these two channels.
2039
 */
2039
 */
2040
int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone);
2040
int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone);
2041

    
   
2041

   
2042
/*!
2042
/*!
2043
 * \brief Setup a masquerade to transfer a call.
2043
 * \brief Setup a masquerade to transfer a call.
2044
 * \since 1.8
2044
 * \since 1.8
2045
 *
2045
 *
2046
 * \param target_chan Target of the call transfer.  (Masquerade original channel)
2046
 * \param target_chan Target of the call transfer.  (Masquerade original channel)
2047
 * \param target_id New connected line information for the target channel.
2047
 * \param target_id New connected line information for the target channel.
2048
 * \param target_held TRUE if the target call is on hold.
2048
 * \param target_held TRUE if the target call is on hold.
2049
 * \param transferee_chan Transferee of the call transfer. (Masquerade clone channel)
2049
 * \param transferee_chan Transferee of the call transfer. (Masquerade clone channel)
2050
 * \param transferee_id New connected line information for the transferee channel.
2050
 * \param transferee_id New connected line information for the transferee channel.
2051
 * \param transferee_held TRUE if the transferee call is on hold.
2051
 * \param transferee_held TRUE if the transferee call is on hold.
2052
 *
2052
 *
2053
 * \details
2053
 * \details
2054
 * Party A - Transferee
2054
 * Party A - Transferee
2055
 * Party B - Transferer
2055
 * Party B - Transferer
2056
 * Party C - Target of transfer
2056
 * Party C - Target of transfer
2057
 *
2057
 *
2058
 * Party B transfers A to C.
2058
 * Party B transfers A to C.
2059
 *
2059
 *
2060
 * Party A is connected to bridged channel B1.
2060
 * Party A is connected to bridged channel B1.
2061
 * Party B is connected to channels C1 and C2.
2061
 * Party B is connected to channels C1 and C2.
2062
 * Party C is connected to bridged channel B2.
2062
 * Party C is connected to bridged channel B2.
2063
 *
2063
 *
2064
 * Party B -- C1 == B1 -- Party A
2064
 * Party B -- C1 == B1 -- Party A
2065
 *               __/
2065
 *               __/
2066
 *              /
2066
 *              /
2067
 * Party B -- C2 == B2 -- Party C
2067
 * Party B -- C2 == B2 -- Party C
2068
 *
2068
 *
2069
 * Bridged channel B1 is masqueraded into channel C2.  Where B1
2069
 * Bridged channel B1 is masqueraded into channel C2.  Where B1
2070
 * is the masquerade clone channel and C2 is the masquerade
2070
 * is the masquerade clone channel and C2 is the masquerade
2071
 * original channel.
2071
 * original channel.
2072
 *
2072
 *
2073
 * \see ast_channel_masquerade()
2073
 * \see ast_channel_masquerade()
2074
 *
2074
 *
2075
 * \note Has the same locking requirements as ast_channel_masquerade().
2075
 * \note Has the same locking requirements as ast_channel_masquerade().
2076
 *
2076
 *
2077
 * \retval 0 on success.
2077
 * \retval 0 on success.
2078
 * \retval -1 on error.
2078
 * \retval -1 on error.
2079
 */
2079
 */
2080
int ast_channel_transfer_masquerade(
2080
int ast_channel_transfer_masquerade(
2081
	struct ast_channel *target_chan,
2081
	struct ast_channel *target_chan,
2082
	const struct ast_party_connected_line *target_id,
2082
	const struct ast_party_connected_line *target_id,
2083
	int target_held,
2083
	int target_held,
2084
	struct ast_channel *transferee_chan,
2084
	struct ast_channel *transferee_chan,
2085
	const struct ast_party_connected_line *transferee_id,
2085
	const struct ast_party_connected_line *transferee_id,
2086
	int transferee_held);
2086
	int transferee_held);
2087

    
   
2087

   
2088
/*!
2088
/*!
2089
 * \brief Gives the string form of a given cause code.
2089
 * \brief Gives the string form of a given cause code.
2090
 *
2090
 *
2091
 * \param state cause to get the description of
2091
 * \param state cause to get the description of
2092
 * \return the text form of the binary cause code given
2092
 * \return the text form of the binary cause code given
2093
 */
2093
 */
2094
const char *ast_cause2str(int state) attribute_pure;
2094
const char *ast_cause2str(int state) attribute_pure;
2095

    
   
2095

   
2096
/*!
2096
/*!
2097
 * \brief Convert the string form of a cause code to a number
2097
 * \brief Convert the string form of a cause code to a number
2098
 *
2098
 *
2099
 * \param name string form of the cause
2099
 * \param name string form of the cause
2100
 * \return the cause code
2100
 * \return the cause code
2101
 */
2101
 */
2102
int ast_str2cause(const char *name) attribute_pure;
2102
int ast_str2cause(const char *name) attribute_pure;
2103

    
   
2103

   
2104
/*!
2104
/*!
2105
 * \brief Gives the string form of a given channel state
2105
 * \brief Gives the string form of a given channel state
2106
 *
2106
 *
2107
 * \param ast_channel_state state to get the name of
2107
 * \param ast_channel_state state to get the name of
2108
 * \return the text form of the binary state given
2108
 * \return the text form of the binary state given
2109
 */
2109
 */
2110
const char *ast_state2str(enum ast_channel_state);
2110
const char *ast_state2str(enum ast_channel_state);
2111

    
   
2111

   
2112
/*!
2112
/*!
2113
 * \brief Gives the string form of a given transfer capability
2113
 * \brief Gives the string form of a given transfer capability
2114
 *
2114
 *
2115
 * \param transfercapability transfer capability to get the name of
2115
 * \param transfercapability transfer capability to get the name of
2116
 * \return the text form of the binary transfer capability
2116
 * \return the text form of the binary transfer capability
2117
 */
2117
 */
2118
char *ast_transfercapability2str(int transfercapability) attribute_const;
2118
char *ast_transfercapability2str(int transfercapability) attribute_const;
2119

    
   
2119

   
2120
/*
2120
/*
2121
 * Options: Some low-level drivers may implement "options" allowing fine tuning of the
2121
 * Options: Some low-level drivers may implement "options" allowing fine tuning of the
2122
 * low level channel.  See frame.h for options.  Note that many channel drivers may support
2122
 * low level channel.  See frame.h for options.  Note that many channel drivers may support
2123
 * none or a subset of those features, and you should not count on this if you want your
2123
 * none or a subset of those features, and you should not count on this if you want your
2124
 * asterisk application to be portable.  They're mainly useful for tweaking performance
2124
 * asterisk application to be portable.  They're mainly useful for tweaking performance
2125
 */
2125
 */
2126

    
   
2126

   
2127
/*!
2127
/*!
2128
 * \brief Sets an option on a channel
2128
 * \brief Sets an option on a channel
2129
 *
2129
 *
2130
 * \param channel channel to set options on
2130
 * \param channel channel to set options on
2131
 * \param option option to change
2131
 * \param option option to change
2132
 * \param data data specific to option
2132
 * \param data data specific to option
2133
 * \param datalen length of the data
2133
 * \param datalen length of the data
2134
 * \param block blocking or not
2134
 * \param block blocking or not
2135
 * \details
2135
 * \details
2136
 * Set an option on a channel (see frame.h), optionally blocking awaiting the reply
2136
 * Set an option on a channel (see frame.h), optionally blocking awaiting the reply
2137
 * \return 0 on success and -1 on failure
2137
 * \return 0 on success and -1 on failure
2138
 */
2138
 */
2139
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
2139
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
2140

    
   
2140

   
2141
/*!
2141
/*!
2142
 * \brief Pick the best codec
2142
 * \brief Pick the best codec
2143
 *
2143
 *
2144
 * \param cap capabilities to pick best codec out of
2144
 * \param cap capabilities to pick best codec out of
2145
 * \param result stucture to store the best codec in.
2145
 * \param result stucture to store the best codec in.
2146
 * \retval on success, pointer to result structure
2146
 * \retval on success, pointer to result structure
2147
 * \retval on failure, NULL
2147
 * \retval on failure, NULL
2148
 */
2148
 */
2149
struct ast_format *ast_best_codec(struct ast_format_cap *cap, struct ast_format *result);
2149
struct ast_format *ast_best_codec(struct ast_format_cap *cap, struct ast_format *result);
2150

    
   
2150

   
2151

    
   
2151

   
2152
/*!
2152
/*!
2153
 * \brief Checks the value of an option
2153
 * \brief Checks the value of an option
2154
 *
2154
 *
2155
 * Query the value of an option
2155
 * Query the value of an option
2156
 * Works similarly to setoption except only reads the options.
2156
 * Works similarly to setoption except only reads the options.
2157
 */
2157
 */
2158
int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block);
2158
int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block);
2159

    
   
2159

   
2160
/*!
2160
/*!
2161
 * \brief Checks for HTML support on a channel
2161
 * \brief Checks for HTML support on a channel
2162
 * \return 0 if channel does not support HTML or non-zero if it does
2162
 * \return 0 if channel does not support HTML or non-zero if it does
2163
 */
2163
 */
2164
int ast_channel_supports_html(struct ast_channel *channel);
2164
int ast_channel_supports_html(struct ast_channel *channel);
2165

    
   
2165

   
2166
/*!
2166
/*!
2167
 * \brief Sends HTML on given channel
2167
 * \brief Sends HTML on given channel
2168
 * Send HTML or URL on link.
2168
 * Send HTML or URL on link.
2169
 * \return 0 on success or -1 on failure
2169
 * \return 0 on success or -1 on failure
2170
 */
2170
 */
2171
int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen);
2171
int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen);
2172

    
   
2172

   
2173
/*!
2173
/*!
2174
 * \brief Sends a URL on a given link
2174
 * \brief Sends a URL on a given link
2175
 * Send URL on link.
2175
 * Send URL on link.
2176
 * \return 0 on success or -1 on failure
2176
 * \return 0 on success or -1 on failure
2177
 */
2177
 */
2178
int ast_channel_sendurl(struct ast_channel *channel, const char *url);
2178
int ast_channel_sendurl(struct ast_channel *channel, const char *url);
2179

    
   
2179

   
2180
/*!
2180
/*!
2181
 * \brief Defers DTMF so that you only read things like hangups and audio.
2181
 * \brief Defers DTMF so that you only read things like hangups and audio.
2182
 * \return non-zero if channel was already DTMF-deferred or
2182
 * \return non-zero if channel was already DTMF-deferred or
2183
 * 0 if channel is just now being DTMF-deferred
2183
 * 0 if channel is just now being DTMF-deferred
2184
 */
2184
 */
2185
int ast_channel_defer_dtmf(struct ast_channel *chan);
2185
int ast_channel_defer_dtmf(struct ast_channel *chan);
2186

    
   
2186

   
2187
/*! Undo defer.  ast_read will return any DTMF characters that were queued */
2187
/*! Undo defer.  ast_read will return any DTMF characters that were queued */
2188
void ast_channel_undefer_dtmf(struct ast_channel *chan);
2188
void ast_channel_undefer_dtmf(struct ast_channel *chan);
2189

    
   
2189

   
2190
/*! Initiate system shutdown -- prevents new channels from being allocated.
2190
/*! Initiate system shutdown -- prevents new channels from being allocated.
2191
 * \param hangup  If "hangup" is non-zero, all existing channels will receive soft
2191
 * \param hangup  If "hangup" is non-zero, all existing channels will receive soft
2192
 *  hangups */
2192
 *  hangups */
2193
void ast_begin_shutdown(int hangup);
2193
void ast_begin_shutdown(int hangup);
2194

    
   
2194

   
2195
/*! Cancels an existing shutdown and returns to normal operation */
2195
/*! Cancels an existing shutdown and returns to normal operation */
2196
void ast_cancel_shutdown(void);
2196
void ast_cancel_shutdown(void);
2197

    
   
2197

   
2198
/*! \return number of channels available for lookup */
2198
/*! \return number of channels available for lookup */
2199
int ast_active_channels(void);
2199
int ast_active_channels(void);
2200

    
   
2200

   
2201
/*! \return the number of channels not yet destroyed */
2201
/*! \return the number of channels not yet destroyed */
2202
int ast_undestroyed_channels(void);
2202
int ast_undestroyed_channels(void);
2203

    
   
2203

   
2204
/*! \return non-zero if Asterisk is being shut down */
2204
/*! \return non-zero if Asterisk is being shut down */
2205
int ast_shutting_down(void);
2205
int ast_shutting_down(void);
2206

    
   
2206

   
2207
/*! Activate a given generator */
2207
/*! Activate a given generator */
2208
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);
2208
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);
2209

    
   
2209

   
2210
/*! Deactivate an active generator */
2210
/*! Deactivate an active generator */
2211
void ast_deactivate_generator(struct ast_channel *chan);
2211
void ast_deactivate_generator(struct ast_channel *chan);
2212

    
   
2212

   
2213
/*!
2213
/*!
2214
 * \since 12
2214
 * \since 12
2215
 * \brief Obtain how long the channel since the channel was created
2215
 * \brief Obtain how long the channel since the channel was created
2216
 *
2216
 *
2217
 * \param chan The channel object
2217
 * \param chan The channel object
2218
 *
2218
 *
2219
 * \retval 0 if the time value cannot be computed (or you called this really fast)
2219
 * \retval 0 if the time value cannot be computed (or you called this really fast)
2220
 * \retval The number of seconds the channel has been up
2220
 * \retval The number of seconds the channel has been up
2221
 */
2221
 */
2222
int ast_channel_get_duration(struct ast_channel *chan);
2222
int ast_channel_get_duration(struct ast_channel *chan);
2223

    
   
2223

   
2224
/*!
2224
/*!
2225
 * \since 12
2225
 * \since 12
2226
 * \brief Obtain how long it has been since the channel was answered
2226
 * \brief Obtain how long it has been since the channel was answered
2227
 *
2227
 *
2228
 * \param chan The channel object
2228
 * \param chan The channel object
2229
 *
2229
 *
2230
 * \retval 0 if the channel isn't answered (or you called this really fast)
2230
 * \retval 0 if the channel isn't answered (or you called this really fast)
2231
 * \retval The number of seconds the channel has been up
2231
 * \retval The number of seconds the channel has been up
2232
 */
2232
 */
2233
int ast_channel_get_up_time(struct ast_channel *chan);
2233
int ast_channel_get_up_time(struct ast_channel *chan);
2234

    
   
2234

   
2235
/*!
2235
/*!
2236
 * \brief Set caller ID number, name and ANI and generate AMI event.
2236
 * \brief Set caller ID number, name and ANI and generate AMI event.
2237
 *
2237
 *
2238
 * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead.
2238
 * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead.
2239
 * \note The channel does not need to be locked before calling this function.
2239
 * \note The channel does not need to be locked before calling this function.
2240
 */
2240
 */
2241
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani);
2241
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani);
2242

    
   
2242

   
2243
/*!
2243
/*!
2244
 * \brief Set the caller id information in the Asterisk channel
2244
 * \brief Set the caller id information in the Asterisk channel
2245
 * \since 1.8
2245
 * \since 1.8
2246
 *
2246
 *
2247
 * \param chan Asterisk channel to set caller id information
2247
 * \param chan Asterisk channel to set caller id information
2248
 * \param caller Caller id information
2248
 * \param caller Caller id information
2249
 * \param update What caller information to update.  NULL if all.
2249
 * \param update What caller information to update.  NULL if all.
2250
 *
2250
 *
2251
 * \return Nothing
2251
 * \return Nothing
2252
 *
2252
 *
2253
 * \note The channel does not need to be locked before calling this function.
2253
 * \note The channel does not need to be locked before calling this function.
2254
 */
2254
 */
2255
void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2255
void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2256

    
   
2256

   
2257
/*!
2257
/*!
2258
 * \brief Set the caller id information in the Asterisk channel and generate an AMI event
2258
 * \brief Set the caller id information in the Asterisk channel and generate an AMI event
2259
 * if the caller id name or number changed.
2259
 * if the caller id name or number changed.
2260
 * \since 1.8
2260
 * \since 1.8
2261
 *
2261
 *
2262
 * \param chan Asterisk channel to set caller id information
2262
 * \param chan Asterisk channel to set caller id information
2263
 * \param caller Caller id information
2263
 * \param caller Caller id information
2264
 * \param update What caller information to update.  NULL if all.
2264
 * \param update What caller information to update.  NULL if all.
2265
 *
2265
 *
2266
 * \return Nothing
2266
 * \return Nothing
2267
 *
2267
 *
2268
 * \note The channel does not need to be locked before calling this function.
2268
 * \note The channel does not need to be locked before calling this function.
2269
 */
2269
 */
2270
void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2270
void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2271

    
   
2271

   
2272
/*! Set the file descriptor on the channel */
2272
/*! Set the file descriptor on the channel */
2273
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd);
2273
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd);
2274

    
   
2274

   
2275
/*! Add a channel to an optimized waitfor */
2275
/*! Add a channel to an optimized waitfor */
2276
void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1);
2276
void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1);
2277

    
   
2277

   
2278
/*! Delete a channel from an optimized waitfor */
2278
/*! Delete a channel from an optimized waitfor */
2279
void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1);
2279
void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1);
2280

    
   
2280

   
2281
/*! Start a tone going */
2281
/*! Start a tone going */
2282
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2282
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2283
/*! Stop a tone from playing */
2283
/*! Stop a tone from playing */
2284
void ast_tonepair_stop(struct ast_channel *chan);
2284
void ast_tonepair_stop(struct ast_channel *chan);
2285
/*! Play a tone pair for a given amount of time */
2285
/*! Play a tone pair for a given amount of time */
2286
int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2286
int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2287

    
   
2287

   
2288
/*!
2288
/*!
2289
 * \brief Automatically service a channel for us...
2289
 * \brief Automatically service a channel for us...
2290
 *
2290
 *
2291
 * \retval 0 success
2291
 * \retval 0 success
2292
 * \retval -1 failure, or the channel is already being autoserviced
2292
 * \retval -1 failure, or the channel is already being autoserviced
2293
 */
2293
 */
2294
int ast_autoservice_start(struct ast_channel *chan);
2294
int ast_autoservice_start(struct ast_channel *chan);
2295

    
   
2295

   
2296
/*!
2296
/*!
2297
 * \brief Stop servicing a channel for us...
2297
 * \brief Stop servicing a channel for us...
2298
 *
2298
 *
2299
 * \note if chan is locked prior to calling ast_autoservice_stop, it
2299
 * \note if chan is locked prior to calling ast_autoservice_stop, it
2300
 * is likely that there will be a deadlock between the thread that calls
2300
 * is likely that there will be a deadlock between the thread that calls
2301
 * ast_autoservice_stop and the autoservice thread. It is important
2301
 * ast_autoservice_stop and the autoservice thread. It is important
2302
 * that chan is not locked prior to this call
2302
 * that chan is not locked prior to this call
2303
 *
2303
 *
2304
 * \param chan
2304
 * \param chan
2305
 * \retval 0 success
2305
 * \retval 0 success
2306
 * \retval -1 error, or the channel has been hungup
2306
 * \retval -1 error, or the channel has been hungup
2307
 */
2307
 */
2308
int ast_autoservice_stop(struct ast_channel *chan);
2308
int ast_autoservice_stop(struct ast_channel *chan);
2309

    
   
2309

   
2310
/*!
2310
/*!
2311
 * \brief Put chan into autoservice while hanging up peer.
2311
 * \brief Put chan into autoservice while hanging up peer.
2312
 * \since 11.0
2312
 * \since 11.0
2313
 *
2313
 *
2314
 * \param chan Chan to put into autoservice.
2314
 * \param chan Chan to put into autoservice.
2315
 * \param peer Chan to run hangup handlers and hangup.
2315
 * \param peer Chan to run hangup handlers and hangup.
2316
 *
2316
 *
2317
 * \return Nothing
2317
 * \return Nothing
2318
 */
2318
 */
2319
void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer);
2319
void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer);
2320

    
   
2320

   
2321
/*!
2321
/*!
2322
 * \brief Ignore certain frame types
2322
 * \brief Ignore certain frame types
2323
 * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames
2323
 * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames
2324
 * while a channel is in autoservice and queue them up when taken out of
2324
 * while a channel is in autoservice and queue them up when taken out of
2325
 * autoservice.  When this is not desireable, this API may be used to
2325
 * autoservice.  When this is not desireable, this API may be used to
2326
 * cause the channel to ignore those frametypes after the channel is put
2326
 * cause the channel to ignore those frametypes after the channel is put
2327
 * into autoservice, but before autoservice is stopped.
2327
 * into autoservice, but before autoservice is stopped.
2328
 * \retval 0 success
2328
 * \retval 0 success
2329
 * \retval -1 channel is not in autoservice
2329
 * \retval -1 channel is not in autoservice
2330
 */
2330
 */
2331
int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype);
2331
int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype);
2332

    
   
2332

   
2333
/*!
2333
/*!
2334
 * \brief Enable or disable timer ticks for a channel
2334
 * \brief Enable or disable timer ticks for a channel
2335
 *
2335
 *
2336
 * \param c channel
2336
 * \param c channel
2337
 * \param rate number of timer ticks per second
2337
 * \param rate number of timer ticks per second
2338
 * \param func callback function
2338
 * \param func callback function
2339
 * \param data
2339
 * \param data
2340
 *
2340
 *
2341
 * \details
2341
 * \details
2342
 * If timers are supported, force a scheduled expiration on the
2342
 * If timers are supported, force a scheduled expiration on the
2343
 * timer fd, at which point we call the callback function / data
2343
 * timer fd, at which point we call the callback function / data
2344
 *
2344
 *
2345
 * \note Call this function with a rate of 0 to turn off the timer ticks
2345
 * \note Call this function with a rate of 0 to turn off the timer ticks
2346
 *
2346
 *
2347
 * \version 1.6.1 changed samples parameter to rate, accomodates new timing methods
2347
 * \version 1.6.1 changed samples parameter to rate, accomodates new timing methods
2348
 */
2348
 */
2349
int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data);
2349
int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data);
2350

    
   
2350

   
2351
/*!
2351
/*!
2352
 * \brief Transfer a channel (if supported).
2352
 * \brief Transfer a channel (if supported).
2353
 * \retval -1 on error
2353
 * \retval -1 on error
2354
 * \retval 0 if not supported
2354
 * \retval 0 if not supported
2355
 * \retval 1 if supported and requested
2355
 * \retval 1 if supported and requested
2356
 * \param chan current channel
2356
 * \param chan current channel
2357
 * \param dest destination extension for transfer
2357
 * \param dest destination extension for transfer
2358
 */
2358
 */
2359
int ast_transfer(struct ast_channel *chan, char *dest);
2359
int ast_transfer(struct ast_channel *chan, char *dest);
2360

    
   
2360

   
2361
/*!
2361
/*!
2362
 * \brief Start masquerading a channel
2362
 * \brief Start masquerading a channel
2363
 * \note absolutely _NO_ channel locks should be held before calling this function.
2363
 * \note absolutely _NO_ channel locks should be held before calling this function.
2364
 * \details
2364
 * \details
2365
 * XXX This is a seriously whacked out operation.  We're essentially putting the guts of
2365
 * XXX This is a seriously whacked out operation.  We're essentially putting the guts of
2366
 *     the clone channel into the original channel.  Start by killing off the original
2366
 *     the clone channel into the original channel.  Start by killing off the original
2367
 *     channel's backend.   I'm not sure we're going to keep this function, because
2367
 *     channel's backend.   I'm not sure we're going to keep this function, because
2368
 *     while the features are nice, the cost is very high in terms of pure nastiness. XXX
2368
 *     while the features are nice, the cost is very high in terms of pure nastiness. XXX
2369
 * \param chan Channel to masquerade
2369
 * \param chan Channel to masquerade
2370
 */
2370
 */
2371
void ast_do_masquerade(struct ast_channel *chan);
2371
void ast_do_masquerade(struct ast_channel *chan);
2372

    
   
2372

   
2373
/*!
2373
/*!
2374
 * \brief Find bridged channel
2374
 * \brief Find bridged channel
2375
 *
2375
 *
2376
 * \note This function does _not_ return a reference to the bridged channel.
2376
 * \note This function does _not_ return a reference to the bridged channel.
2377
 * The reason for this is mostly historical.  It _should_ return a reference,
2377
 * The reason for this is mostly historical.  It _should_ return a reference,
2378
 * but it will take a lot of work to make the code base account for that.
2378
 * but it will take a lot of work to make the code base account for that.
2379
 * So, for now, the old rules still apply for how to handle this function.
2379
 * So, for now, the old rules still apply for how to handle this function.
2380
 * If this function is being used from the channel thread that owns the channel,
2380
 * If this function is being used from the channel thread that owns the channel,
2381
 * then a reference is already held, and channel locking is not required to
2381
 * then a reference is already held, and channel locking is not required to
2382
 * guarantee that the channel will stay around.  If this function is used
2382
 * guarantee that the channel will stay around.  If this function is used
2383
 * outside of the associated channel thread, the channel parameter 'chan'
2383
 * outside of the associated channel thread, the channel parameter 'chan'
2384
 * MUST be locked before calling this function.  Also, 'chan' must remain locked
2384
 * MUST be locked before calling this function.  Also, 'chan' must remain locked
2385
 * for the entire time that the result of this function is being used.
2385
 * for the entire time that the result of this function is being used.
2386
 *
2386
 *
2387
 * \param chan Current channel
2387
 * \param chan Current channel
2388
 *
2388
 *
2389
 * \return A pointer to the bridged channel
2389
 * \return A pointer to the bridged channel
2390
*/
2390
*/
2391
struct ast_channel *ast_bridged_channel(struct ast_channel *chan);
2391
struct ast_channel *ast_bridged_channel(struct ast_channel *chan);
2392

    
   
2392

   
2393
/*!
2393
/*!
2394
 * \brief Inherits channel variable from parent to child channel
2394
 * \brief Inherits channel variable from parent to child channel
2395
 * \param parent Parent channel
2395
 * \param parent Parent channel
2396
 * \param child Child channel
2396
 * \param child Child channel
2397
 *
2397
 *
2398
 * \details
2398
 * \details
2399
 * Scans all channel variables in the parent channel, looking for those
2399
 * Scans all channel variables in the parent channel, looking for those
2400
 * that should be copied into the child channel.
2400
 * that should be copied into the child channel.
2401
 * Variables whose names begin with a single '_' are copied into the
2401
 * Variables whose names begin with a single '_' are copied into the
2402
 * child channel with the prefix removed.
2402
 * child channel with the prefix removed.
2403
 * Variables whose names begin with '__' are copied into the child
2403
 * Variables whose names begin with '__' are copied into the child
2404
 * channel with their names unchanged.
2404
 * channel with their names unchanged.
2405
 */
2405
 */
2406
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child);
2406
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child);
2407

    
   
2407

   
2408
/*!
2408
/*!
2409
 * \brief adds a list of channel variables to a channel
2409
 * \brief adds a list of channel variables to a channel
2410
 * \param chan the channel
2410
 * \param chan the channel
2411
 * \param vars a linked list of variables
2411
 * \param vars a linked list of variables
2412
 *
2412
 *
2413
 * \details
2413
 * \details
2414
 * Variable names can be for a regular channel variable or a dialplan function
2414
 * Variable names can be for a regular channel variable or a dialplan function
2415
 * that has the ability to be written to.
2415
 * that has the ability to be written to.
2416
 */
2416
 */
2417
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars);
2417
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars);
2418

    
   
2418

   
2419
/*!
2419
/*!
2420
 * \brief An opaque 'object' structure use by silence generators on channels.
2420
 * \brief An opaque 'object' structure use by silence generators on channels.
2421
 */
2421
 */
2422
struct ast_silence_generator;
2422
struct ast_silence_generator;
2423

    
   
2423

   
2424
/*!
2424
/*!
2425
 * \brief Starts a silence generator on the given channel.
2425
 * \brief Starts a silence generator on the given channel.
2426
 * \param chan The channel to generate silence on
2426
 * \param chan The channel to generate silence on
2427
 * \return An ast_silence_generator pointer, or NULL if an error occurs
2427
 * \return An ast_silence_generator pointer, or NULL if an error occurs
2428
 *
2428
 *
2429
 * \details
2429
 * \details
2430
 * This function will cause SLINEAR silence to be generated on the supplied
2430
 * This function will cause SLINEAR silence to be generated on the supplied
2431
 * channel until it is disabled; if the channel cannot be put into SLINEAR
2431
 * channel until it is disabled; if the channel cannot be put into SLINEAR
2432
 * mode then the function will fail.
2432
 * mode then the function will fail.
2433
 *
2433
 *
2434
 * \note
2434
 * \note
2435
 * The pointer returned by this function must be preserved and passed to
2435
 * The pointer returned by this function must be preserved and passed to
2436
 * ast_channel_stop_silence_generator when you wish to stop the silence
2436
 * ast_channel_stop_silence_generator when you wish to stop the silence
2437
 * generation.
2437
 * generation.
2438
 */
2438
 */
2439
struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_channel *chan);
2439
struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_channel *chan);
2440

    
   
2440

   
2441
/*!
2441
/*!
2442
 * \brief Stops a previously-started silence generator on the given channel.
2442
 * \brief Stops a previously-started silence generator on the given channel.
2443
 * \param chan The channel to operate on
2443
 * \param chan The channel to operate on
2444
 * \param state The ast_silence_generator pointer return by a previous call to
2444
 * \param state The ast_silence_generator pointer return by a previous call to
2445
 * ast_channel_start_silence_generator.
2445
 * ast_channel_start_silence_generator.
2446
 * \return nothing
2446
 * \return nothing
2447
 *
2447
 *
2448
 * \details
2448
 * \details
2449
 * This function will stop the operating silence generator and return the channel
2449
 * This function will stop the operating silence generator and return the channel
2450
 * to its previous write format.
2450
 * to its previous write format.
2451
 */
2451
 */
2452
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state);
2452
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state);
2453

    
   
2453

   
2454
/*!
2454
/*!
2455
 * \brief Check if the channel can run in internal timing mode.
2455
 * \brief Check if the channel can run in internal timing mode.
2456
 * \param chan The channel to check
2456
 * \param chan The channel to check
2457
 * \return boolean
2457
 * \return boolean
2458
 *
2458
 *
2459
 * \details
2459
 * \details
2460
 * This function will return 1 if internal timing is enabled and the timing
2460
 * This function will return 1 if internal timing is enabled and the timing
2461
 * device is available.
2461
 * device is available.
2462
 */
2462
 */
2463
int ast_internal_timing_enabled(struct ast_channel *chan);
2463
int ast_internal_timing_enabled(struct ast_channel *chan);
2464

    
   
2464

   
2465
/* Misc. functions below */
2465
/* Misc. functions below */
2466

    
   
2466

   
2467
/*!
2467
/*!
2468
 * \brief if fd is a valid descriptor, set *pfd with the descriptor
2468
 * \brief if fd is a valid descriptor, set *pfd with the descriptor
2469
 * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the
2469
 * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the
2470
 * return value to the index into the array)
2470
 * return value to the index into the array)
2471
 */
2471
 */
2472
static inline int ast_add_fd(struct pollfd *pfd, int fd)
2472
static inline int ast_add_fd(struct pollfd *pfd, int fd)
2473
{
2473
{
2474
	pfd->fd = fd;
2474
	pfd->fd = fd;
2475
	pfd->events = POLLIN | POLLPRI;
2475
	pfd->events = POLLIN | POLLPRI;
2476
	return fd >= 0;
2476
	return fd >= 0;
2477
}
2477
}
2478

    
   
2478

   
2479
/*! \brief Helper function for migrating select to poll */
2479
/*! \brief Helper function for migrating select to poll */
2480
static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
2480
static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
2481
{
2481
{
2482
	int x;
2482
	int x;
2483
	int dummy = 0;
2483
	int dummy = 0;
2484

    
   
2484

   
2485
	if (fd < 0)
2485
	if (fd < 0)
2486
		return 0;
2486
		return 0;
2487
	if (!start)
2487
	if (!start)
2488
		start = &dummy;
2488
		start = &dummy;
2489
	for (x = *start; x < maximum; x++)
2489
	for (x = *start; x < maximum; x++)
2490
		if (pfds[x].fd == fd) {
2490
		if (pfds[x].fd == fd) {
2491
			if (x == *start)
2491
			if (x == *start)
2492
				(*start)++;
2492
				(*start)++;
2493
			return pfds[x].revents;
2493
			return pfds[x].revents;
2494
		}
2494
		}
2495
	return 0;
2495
	return 0;
2496
}
2496
}
2497

    
   
2497

   
2498
/*! \brief Retrieves the current T38 state of a channel */
2498
/*! \brief Retrieves the current T38 state of a channel */
2499
static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
2499
static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
2500
{
2500
{
2501
	enum ast_t38_state state = T38_STATE_UNAVAILABLE;
2501
	enum ast_t38_state state = T38_STATE_UNAVAILABLE;
2502
	int datalen = sizeof(state);
2502
	int datalen = sizeof(state);
2503

    
   
2503

   
2504
	ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0);
2504
	ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0);
2505

    
   
2505

   
2506
	return state;
2506
	return state;
2507
}
2507
}
2508

    
   
2508

   
2509
#define CHECK_BLOCKING(c) do { 	 \
2509
#define CHECK_BLOCKING(c) do { 	 \
2510
	if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) {\
2510
	if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) {\
2511
		ast_debug(1, "Thread %p is blocking '%s', already blocked by thread %p in procedure %s\n", \
2511
		ast_debug(1, "Thread %p is blocking '%s', already blocked by thread %p in procedure %s\n", \
2512
			(void *) pthread_self(), ast_channel_name(c), (void *) ast_channel_blocker(c), ast_channel_blockproc(c)); \
2512
			(void *) pthread_self(), ast_channel_name(c), (void *) ast_channel_blocker(c), ast_channel_blockproc(c)); \
2513
	} else { \
2513
	} else { \
2514
		ast_channel_blocker_set((c), pthread_self()); \
2514
		ast_channel_blocker_set((c), pthread_self()); \
2515
		ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
2515
		ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
2516
		ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
2516
		ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
2517
	} } while (0)
2517
	} } while (0)
2518

    
   
2518

   
2519
ast_group_t ast_get_group(const char *s);
2519
ast_group_t ast_get_group(const char *s);
2520

    
   
2520

   
2521
/*! \brief Print call and pickup groups into buffer */
2521
/*! \brief Print call and pickup groups into buffer */
2522
char *ast_print_group(char *buf, int buflen, ast_group_t group);
2522
char *ast_print_group(char *buf, int buflen, ast_group_t group);
2523

    
   
2523

   
2524
/*! \brief Opaque struct holding a namedgroups set, i.e. a set of group names */
2524
/*! \brief Opaque struct holding a namedgroups set, i.e. a set of group names */
2525
struct ast_namedgroups;
2525
struct ast_namedgroups;
2526

    
   
2526

   
2527
/*! \brief Create an ast_namedgroups set with group names from comma separated string */
2527
/*! \brief Create an ast_namedgroups set with group names from comma separated string */
2528
struct ast_namedgroups *ast_get_namedgroups(const char *s);
2528
struct ast_namedgroups *ast_get_namedgroups(const char *s);
2529
struct ast_namedgroups *ast_unref_namedgroups(struct ast_namedgroups *groups);
2529
struct ast_namedgroups *ast_unref_namedgroups(struct ast_namedgroups *groups);
2530
struct ast_namedgroups *ast_ref_namedgroups(struct ast_namedgroups *groups);
2530
struct ast_namedgroups *ast_ref_namedgroups(struct ast_namedgroups *groups);
2531
/*! \brief Return TRUE if group a and b contain at least one common groupname */
2531
/*! \brief Return TRUE if group a and b contain at least one common groupname */
2532
int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups *b);
2532
int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups *b);
2533

    
   
2533

   
2534
/*! \brief Print named call groups and named pickup groups */
2534
/*! \brief Print named call groups and named pickup groups */
2535
char *ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups);
2535
char *ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups);
2536

    
   
2536

   
2537
/*!
2537
/*!
2538
 * \brief Convert enum channelreloadreason to text string for manager event
2538
 * \brief Convert enum channelreloadreason to text string for manager event
2539
 * \param reason The reason for reload (manager, cli, start etc)
2539
 * \param reason The reason for reload (manager, cli, start etc)
2540
 */
2540
 */
2541
const char *channelreloadreason2txt(enum channelreloadreason reason);
2541
const char *channelreloadreason2txt(enum channelreloadreason reason);
2542

    
   
2542

   
2543
/*! \brief return an ast_variable list of channeltypes */
2543
/*! \brief return an ast_variable list of channeltypes */
2544
struct ast_variable *ast_channeltype_list(void);
2544
struct ast_variable *ast_channeltype_list(void);
2545

    
   
2545

   
2546
/*!
2546
/*!
2547
 * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
2547
 * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
2548
 * \param reason  The integer argument, usually taken from AST_CONTROL_ macros
2548
 * \param reason  The integer argument, usually taken from AST_CONTROL_ macros
2549
 * \return char pointer explaining the code
2549
 * \return char pointer explaining the code
2550
 */
2550
 */
2551
const char *ast_channel_reason2str(int reason);
2551
const char *ast_channel_reason2str(int reason);
2552

    
   
2552

   
2553
/*! \brief channel group info */
2553
/*! \brief channel group info */
2554
struct ast_group_info {
2554
struct ast_group_info {
2555
	struct ast_channel *chan;
2555
	struct ast_channel *chan;
2556
	char *category;
2556
	char *category;
2557
	char *group;
2557
	char *group;
2558
	AST_LIST_ENTRY(ast_group_info) group_list;
2558
	AST_LIST_ENTRY(ast_group_info) group_list;
2559
};
2559
};
2560

    
   
2560

   
2561
#define ast_channel_lock(chan) ao2_lock(chan)
2561
#define ast_channel_lock(chan) ao2_lock(chan)
2562
#define ast_channel_unlock(chan) ao2_unlock(chan)
2562
#define ast_channel_unlock(chan) ao2_unlock(chan)
2563
#define ast_channel_trylock(chan) ao2_trylock(chan)
2563
#define ast_channel_trylock(chan) ao2_trylock(chan)
2564

    
   
2564

   
2565
/*!
2565
/*!
2566
 * \brief Lock two channels.
2566
 * \brief Lock two channels.
2567
 */
2567
 */
2568
#define ast_channel_lock_both(chan1, chan2) do { \
2568
#define ast_channel_lock_both(chan1, chan2) do { \
2569
		ast_channel_lock(chan1); \
2569
		ast_channel_lock(chan1); \
2570
		while (ast_channel_trylock(chan2)) { \
2570
		while (ast_channel_trylock(chan2)) { \
2571
			ast_channel_unlock(chan1); \
2571
			ast_channel_unlock(chan1); \
2572
			sched_yield(); \
2572
			sched_yield(); \
2573
			ast_channel_lock(chan1); \
2573
			ast_channel_lock(chan1); \
2574
		} \
2574
		} \
2575
	} while (0)
2575
	} while (0)
2576

    
   
2576

   
2577
/*!
2577
/*!
2578
 * \brief Increase channel reference count
2578
 * \brief Increase channel reference count
2579
 *
2579
 *
2580
 * \param c the channel
2580
 * \param c the channel
2581
 *
2581
 *
2582
 * \retval c always
2582
 * \retval c always
2583
 *
2583
 *
2584
 * \since 1.8
2584
 * \since 1.8
2585
 */
2585
 */
2586
#define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); })
2586
#define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); })
2587

    
   
2587

   
2588
/*!
2588
/*!
2589
 * \brief Decrease channel reference count
2589
 * \brief Decrease channel reference count
2590
 *
2590
 *
2591
 * \param c the channel
2591
 * \param c the channel
2592
 *
2592
 *
2593
 * \retval NULL always
2593
 * \retval NULL always
2594
 *
2594
 *
2595
 * \since 1.8
2595
 * \since 1.8
2596
 */
2596
 */
2597
#define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
2597
#define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
2598

    
   
2598

   
2599
/*! Channel Iterating @{ */
2599
/*! Channel Iterating @{ */
2600

    
   
2600

   
2601
/*!
2601
/*!
2602
 * \brief A channel iterator
2602
 * \brief A channel iterator
2603
 *
2603
 *
2604
 * This is an opaque type.
2604
 * This is an opaque type.
2605
 */
2605
 */
2606
struct ast_channel_iterator;
2606
struct ast_channel_iterator;
2607

    
   
2607

   
2608
/*!
2608
/*!
2609
 * \brief Destroy a channel iterator
2609
 * \brief Destroy a channel iterator
2610
 *
2610
 *
2611
 * \param i the itereator to destroy
2611
 * \param i the itereator to destroy
2612
 *
2612
 *
2613
 * \details
2613
 * \details
2614
 * This function is used to destroy a channel iterator that was retrieved by
2614
 * This function is used to destroy a channel iterator that was retrieved by
2615
 * using one of the channel_iterator_xxx_new() functions.
2615
 * using one of the channel_iterator_xxx_new() functions.
2616
 *
2616
 *
2617
 * \return NULL, for convenience to clear out the pointer to the iterator that
2617
 * \return NULL, for convenience to clear out the pointer to the iterator that
2618
 * was just destroyed.
2618
 * was just destroyed.
2619
 *
2619
 *
2620
 * \since 1.8
2620
 * \since 1.8
2621
 */
2621
 */
2622
struct ast_channel_iterator *ast_channel_iterator_destroy(struct ast_channel_iterator *i);
2622
struct ast_channel_iterator *ast_channel_iterator_destroy(struct ast_channel_iterator *i);
2623

    
   
2623

   
2624
/*!
2624
/*!
2625
 * \brief Create a new channel iterator based on extension
2625
 * \brief Create a new channel iterator based on extension
2626
 *
2626
 *
2627
 * \param exten The extension that channels must be in
2627
 * \param exten The extension that channels must be in
2628
 * \param context The context that channels must be in
2628
 * \param context The context that channels must be in
2629
 *
2629
 *
2630
 * \details
2630
 * \details
2631
 * After creating an iterator using this function, the ast_channel_iterator_next()
2631
 * After creating an iterator using this function, the ast_channel_iterator_next()
2632
 * function can be used to iterate through all channels that are currently
2632
 * function can be used to iterate through all channels that are currently
2633
 * in the specified context and extension.
2633
 * in the specified context and extension.
2634
 *
2634
 *
2635
 * \note You must call ast_channel_iterator_destroy() when done.
2635
 * \note You must call ast_channel_iterator_destroy() when done.
2636
 *
2636
 *
2637
 * \retval NULL on failure
2637
 * \retval NULL on failure
2638
 * \retval a new channel iterator based on the specified parameters
2638
 * \retval a new channel iterator based on the specified parameters
2639
 *
2639
 *
2640
 * \since 1.8
2640
 * \since 1.8
2641
 */
2641
 */
2642
struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context);
2642
struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context);
2643

    
   
2643

   
2644
/*!
2644
/*!
2645
 * \brief Create a new channel iterator based on name
2645
 * \brief Create a new channel iterator based on name
2646
 *
2646
 *
2647
 * \param name channel name or channel uniqueid to match
2647
 * \param name channel name or channel uniqueid to match
2648
 * \param name_len number of characters in the channel name to match on.  This
2648
 * \param name_len number of characters in the channel name to match on.  This
2649
 *      would be used to match based on name prefix.  If matching on the full
2649
 *      would be used to match based on name prefix.  If matching on the full
2650
 *      channel name is desired, then this parameter should be 0.
2650
 *      channel name is desired, then this parameter should be 0.
2651
 *
2651
 *
2652
 * \details
2652
 * \details
2653
 * After creating an iterator using this function, the ast_channel_iterator_next()
2653
 * After creating an iterator using this function, the ast_channel_iterator_next()
2654
 * function can be used to iterate through all channels that exist that have
2654
 * function can be used to iterate through all channels that exist that have
2655
 * the specified name or name prefix.
2655
 * the specified name or name prefix.
2656
 *
2656
 *
2657
 * \note You must call ast_channel_iterator_destroy() when done.
2657
 * \note You must call ast_channel_iterator_destroy() when done.
2658
 *
2658
 *
2659
 * \retval NULL on failure
2659
 * \retval NULL on failure
2660
 * \retval a new channel iterator based on the specified parameters
2660
 * \retval a new channel iterator based on the specified parameters
2661
 *
2661
 *
2662
 * \since 1.8
2662
 * \since 1.8
2663
 */
2663
 */
2664
struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name,	size_t name_len);
2664
struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name,	size_t name_len);
2665

    
   
2665

   
2666
/*!
2666
/*!
2667
 * \brief Create a new channel iterator
2667
 * \brief Create a new channel iterator
2668
 *
2668
 *
2669
 * \details
2669
 * \details
2670
 * After creating an iterator using this function, the ast_channel_iterator_next()
2670
 * After creating an iterator using this function, the ast_channel_iterator_next()
2671
 * function can be used to iterate through all channels that exist.
2671
 * function can be used to iterate through all channels that exist.
2672
 *
2672
 *
2673
 * \note You must call ast_channel_iterator_destroy() when done.
2673
 * \note You must call ast_channel_iterator_destroy() when done.
2674
 *
2674
 *
2675
 * \retval NULL on failure
2675
 * \retval NULL on failure
2676
 * \retval a new channel iterator
2676
 * \retval a new channel iterator
2677
 *
2677
 *
2678
 * \since 1.8
2678
 * \since 1.8
2679
 */
2679
 */
2680
struct ast_channel_iterator *ast_channel_iterator_all_new(void);
2680
struct ast_channel_iterator *ast_channel_iterator_all_new(void);
2681

    
   
2681

   
2682
/*!
2682
/*!
2683
 * \brief Get the next channel for a channel iterator
2683
 * \brief Get the next channel for a channel iterator
2684
 *
2684
 *
2685
 * \param i the channel iterator that was created using one of the
2685
 * \param i the channel iterator that was created using one of the
2686
 *  channel_iterator_xxx_new() functions.
2686
 *  channel_iterator_xxx_new() functions.
2687
 *
2687
 *
2688
 * \details
2688
 * \details
2689
 * This function should be used to iterate through all channels that match a
2689
 * This function should be used to iterate through all channels that match a
2690
 * specified set of parameters that were provided when the iterator was created.
2690
 * specified set of parameters that were provided when the iterator was created.
2691
 *
2691
 *
2692
 * \retval the next channel that matches the parameters used when the iterator
2692
 * \retval the next channel that matches the parameters used when the iterator
2693
 *         was created.
2693
 *         was created.
2694
 * \retval NULL, if no more channels match the iterator parameters.
2694
 * \retval NULL, if no more channels match the iterator parameters.
2695
 *
2695
 *
2696
 * \since 1.8
2696
 * \since 1.8
2697
 */
2697
 */
2698
struct ast_channel *ast_channel_iterator_next(struct ast_channel_iterator *i);
2698
struct ast_channel *ast_channel_iterator_next(struct ast_channel_iterator *i);
2699

    
   
2699

   
2700
/*! @} End channel iterator definitions. */
2700
/*! @} End channel iterator definitions. */
2701

    
   
2701

   
2702
/*!
2702
/*!
2703
 * \brief Call a function with every active channel
2703
 * \brief Call a function with every active channel
2704
 *
2704
 *
2705
 * \details
2705
 * \details
2706
 * This function executes a callback one time for each active channel on the
2706
 * This function executes a callback one time for each active channel on the
2707
 * system.  The channel is provided as an argument to the function.
2707
 * system.  The channel is provided as an argument to the function.
2708
 *
2708
 *
2709
 * \note Absolutely _NO_ channel locks should be held before calling this function.
2709
 * \note Absolutely _NO_ channel locks should be held before calling this function.
2710
 * \since 1.8
2710
 * \since 1.8
2711
 */
2711
 */
2712
struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
2712
struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
2713
		void *data, int ao2_flags);
2713
		void *data, int ao2_flags);
2714

    
   
2714

   
2715
/*! @{ Channel search functions */
2715
/*! @{ Channel search functions */
2716

    
   
2716

   
2717
/*!
2717
/*!
2718
 * \brief Find a channel by name
2718
 * \brief Find a channel by name
2719
 *
2719
 *
2720
 * \param name the name or uniqueid of the channel to search for
2720
 * \param name the name or uniqueid of the channel to search for
2721
 *
2721
 *
2722
 * \details
2722
 * \details
2723
 * Find a channel that has the same name as the provided argument.
2723
 * Find a channel that has the same name as the provided argument.
2724
 *
2724
 *
2725
 * \retval a channel with the name specified by the argument
2725
 * \retval a channel with the name specified by the argument
2726
 * \retval NULL if no channel was found
2726
 * \retval NULL if no channel was found
2727
 *
2727
 *
2728
 * \since 1.8
2728
 * \since 1.8
2729
 */
2729
 */
2730
struct ast_channel *ast_channel_get_by_name(const char *name);
2730
struct ast_channel *ast_channel_get_by_name(const char *name);
2731

    
   
2731

   
2732
/*!
2732
/*!
2733
 * \brief Find a channel by a name prefix
2733
 * \brief Find a channel by a name prefix
2734
 *
2734
 *
2735
 * \param name The channel name or uniqueid prefix to search for
2735
 * \param name The channel name or uniqueid prefix to search for
2736
 * \param name_len Only search for up to this many characters from the name
2736
 * \param name_len Only search for up to this many characters from the name
2737
 *
2737
 *
2738
 * \details
2738
 * \details
2739
 * Find a channel that has the same name prefix as specified by the arguments.
2739
 * Find a channel that has the same name prefix as specified by the arguments.
2740
 *
2740
 *
2741
 * \retval a channel with the name prefix specified by the arguments
2741
 * \retval a channel with the name prefix specified by the arguments
2742
 * \retval NULL if no channel was found
2742
 * \retval NULL if no channel was found
2743
 *
2743
 *
2744
 * \since 1.8
2744
 * \since 1.8
2745
 */
2745
 */
2746
struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
2746
struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
2747

    
   
2747

   
2748
/*!
2748
/*!
2749
 * \brief Find a channel by extension and context
2749
 * \brief Find a channel by extension and context
2750
 *
2750
 *
2751
 * \param exten the extension to search for
2751
 * \param exten the extension to search for
2752
 * \param context the context to search for
2752
 * \param context the context to search for
2753
 *
2753
 *
2754
 * \details
2754
 * \details
2755
 * Return a channel that is currently at the specified extension and context.
2755
 * Return a channel that is currently at the specified extension and context.
2756
 *
2756
 *
2757
 * \retval a channel that is at the specified extension and context
2757
 * \retval a channel that is at the specified extension and context
2758
 * \retval NULL if no channel was found
2758
 * \retval NULL if no channel was found
2759
 *
2759
 *
2760
 * \since 1.8
2760
 * \since 1.8
2761
 */
2761
 */
2762
struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
2762
struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
2763

    
   
2763

   
2764
/*! @} End channel search functions. */
2764
/*! @} End channel search functions. */
2765

    
   
2765

   
2766
/*!
2766
/*!
2767
 * \brief Initialize the given name structure.
2767
 * \brief Initialize the given name structure.
2768
 * \since 1.8
2768
 * \since 1.8
2769
 *
2769
 *
2770
 * \param init Name structure to initialize.
2770
 * \param init Name structure to initialize.
2771
 *
2771
 *
2772
 * \return Nothing
2772
 * \return Nothing
2773
 */
2773
 */
2774
void ast_party_name_init(struct ast_party_name *init);
2774
void ast_party_name_init(struct ast_party_name *init);
2775

    
   
2775

   
2776
/*!
2776
/*!
2777
 * \brief Copy the source party name information to the destination party name.
2777
 * \brief Copy the source party name information to the destination party name.
2778
 * \since 1.8
2778
 * \since 1.8
2779
 *
2779
 *
2780
 * \param dest Destination party name
2780
 * \param dest Destination party name
2781
 * \param src Source party name
2781
 * \param src Source party name
2782
 *
2782
 *
2783
 * \return Nothing
2783
 * \return Nothing
2784
 */
2784
 */
2785
void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src);
2785
void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src);
2786

    
   
2786

   
2787
/*!
2787
/*!
2788
 * \brief Initialize the given party name structure using the given guide
2788
 * \brief Initialize the given party name structure using the given guide
2789
 * for a set update operation.
2789
 * for a set update operation.
2790
 * \since 1.8
2790
 * \since 1.8
2791
 *
2791
 *
2792
 * \details
2792
 * \details
2793
 * The initialization is needed to allow a set operation to know if a
2793
 * The initialization is needed to allow a set operation to know if a
2794
 * value needs to be updated.  Simple integers need the guide's original
2794
 * value needs to be updated.  Simple integers need the guide's original
2795
 * value in case the set operation is not trying to set a new value.
2795
 * value in case the set operation is not trying to set a new value.
2796
 * String values are simply set to NULL pointers if they are not going
2796
 * String values are simply set to NULL pointers if they are not going
2797
 * to be updated.
2797
 * to be updated.
2798
 *
2798
 *
2799
 * \param init Party name structure to initialize.
2799
 * \param init Party name structure to initialize.
2800
 * \param guide Source party name to use as a guide in initializing.
2800
 * \param guide Source party name to use as a guide in initializing.
2801
 *
2801
 *
2802
 * \return Nothing
2802
 * \return Nothing
2803
 */
2803
 */
2804
void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide);
2804
void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide);
2805

    
   
2805

   
2806
/*!
2806
/*!
2807
 * \brief Set the source party name information into the destination party name.
2807
 * \brief Set the source party name information into the destination party name.
2808
 * \since 1.8
2808
 * \since 1.8
2809
 *
2809
 *
2810
 * \param dest The name one wishes to update
2810
 * \param dest The name one wishes to update
2811
 * \param src The new name values to update the dest
2811
 * \param src The new name values to update the dest
2812
 *
2812
 *
2813
 * \return Nothing
2813
 * \return Nothing
2814
 */
2814
 */
2815
void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src);
2815
void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src);
2816

    
   
2816

   
2817
/*!
2817
/*!
2818
 * \brief Destroy the party name contents
2818
 * \brief Destroy the party name contents
2819
 * \since 1.8
2819
 * \since 1.8
2820
 *
2820
 *
2821
 * \param doomed The party name to destroy.
2821
 * \param doomed The party name to destroy.
2822
 *
2822
 *
2823
 * \return Nothing
2823
 * \return Nothing
2824
 */
2824
 */
2825
void ast_party_name_free(struct ast_party_name *doomed);
2825
void ast_party_name_free(struct ast_party_name *doomed);
2826

    
   
2826

   
2827
/*!
2827
/*!
2828
 * \brief Initialize the given number structure.
2828
 * \brief Initialize the given number structure.
2829
 * \since 1.8
2829
 * \since 1.8
2830
 *
2830
 *
2831
 * \param init Number structure to initialize.
2831
 * \param init Number structure to initialize.
2832
 *
2832
 *
2833
 * \return Nothing
2833
 * \return Nothing
2834
 */
2834
 */
2835
void ast_party_number_init(struct ast_party_number *init);
2835
void ast_party_number_init(struct ast_party_number *init);
2836

    
   
2836

   
2837
/*!
2837
/*!
2838
 * \brief Copy the source party number information to the destination party number.
2838
 * \brief Copy the source party number information to the destination party number.
2839
 * \since 1.8
2839
 * \since 1.8
2840
 *
2840
 *
2841
 * \param dest Destination party number
2841
 * \param dest Destination party number
2842
 * \param src Source party number
2842
 * \param src Source party number
2843
 *
2843
 *
2844
 * \return Nothing
2844
 * \return Nothing
2845
 */
2845
 */
2846
void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src);
2846
void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src);
2847

    
   
2847

   
2848
/*!
2848
/*!
2849
 * \brief Initialize the given party number structure using the given guide
2849
 * \brief Initialize the given party number structure using the given guide
2850
 * for a set update operation.
2850
 * for a set update operation.
2851
 * \since 1.8
2851
 * \since 1.8
2852
 *
2852
 *
2853
 * \details
2853
 * \details
2854
 * The initialization is needed to allow a set operation to know if a
2854
 * The initialization is needed to allow a set operation to know if a
2855
 * value needs to be updated.  Simple integers need the guide's original
2855
 * value needs to be updated.  Simple integers need the guide's original
2856
 * value in case the set operation is not trying to set a new value.
2856
 * value in case the set operation is not trying to set a new value.
2857
 * String values are simply set to NULL pointers if they are not going
2857
 * String values are simply set to NULL pointers if they are not going
2858
 * to be updated.
2858
 * to be updated.
2859
 *
2859
 *
2860
 * \param init Party number structure to initialize.
2860
 * \param init Party number structure to initialize.
2861
 * \param guide Source party number to use as a guide in initializing.
2861
 * \param guide Source party number to use as a guide in initializing.
2862
 *
2862
 *
2863
 * \return Nothing
2863
 * \return Nothing
2864
 */
2864
 */
2865
void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide);
2865
void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide);
2866

    
   
2866

   
2867
/*!
2867
/*!
2868
 * \brief Set the source party number information into the destination party number.
2868
 * \brief Set the source party number information into the destination party number.
2869
 * \since 1.8
2869
 * \since 1.8
2870
 *
2870
 *
2871
 * \param dest The number one wishes to update
2871
 * \param dest The number one wishes to update
2872
 * \param src The new number values to update the dest
2872
 * \param src The new number values to update the dest
2873
 *
2873
 *
2874
 * \return Nothing
2874
 * \return Nothing
2875
 */
2875
 */
2876
void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src);
2876
void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src);
2877

    
   
2877

   
2878
/*!
2878
/*!
2879
 * \brief Destroy the party number contents
2879
 * \brief Destroy the party number contents
2880
 * \since 1.8
2880
 * \since 1.8
2881
 *
2881
 *
2882
 * \param doomed The party number to destroy.
2882
 * \param doomed The party number to destroy.
2883
 *
2883
 *
2884
 * \return Nothing
2884
 * \return Nothing
2885
 */
2885
 */
2886
void ast_party_number_free(struct ast_party_number *doomed);
2886
void ast_party_number_free(struct ast_party_number *doomed);
2887

    
   
2887

   
2888
/*!
2888
/*!
2889
 * \since 1.8
2889
 * \since 1.8
2890
 * \brief Initialize the given subaddress structure.
2890
 * \brief Initialize the given subaddress structure.
2891
 *
2891
 *
2892
 * \param init Subaddress structure to initialize.
2892
 * \param init Subaddress structure to initialize.
2893
 *
2893
 *
2894
 * \return Nothing
2894
 * \return Nothing
2895
 */
2895
 */
2896
void ast_party_subaddress_init(struct ast_party_subaddress *init);
2896
void ast_party_subaddress_init(struct ast_party_subaddress *init);
2897

    
   
2897

   
2898
/*!
2898
/*!
2899
 * \since 1.8
2899
 * \since 1.8
2900
 * \brief Copy the source party subaddress information to the destination party subaddress.
2900
 * \brief Copy the source party subaddress information to the destination party subaddress.
2901
 *
2901
 *
2902
 * \param dest Destination party subaddress
2902
 * \param dest Destination party subaddress
2903
 * \param src Source party subaddress
2903
 * \param src Source party subaddress
2904
 *
2904
 *
2905
 * \return Nothing
2905
 * \return Nothing
2906
 */
2906
 */
2907
void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
2907
void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
2908

    
   
2908

   
2909
/*!
2909
/*!
2910
 * \since 1.8
2910
 * \since 1.8
2911
 * \brief Initialize the given party subaddress structure using the given guide
2911
 * \brief Initialize the given party subaddress structure using the given guide
2912
 * for a set update operation.
2912
 * for a set update operation.
2913
 *
2913
 *
2914
 * \details
2914
 * \details
2915
 * The initialization is needed to allow a set operation to know if a
2915
 * The initialization is needed to allow a set operation to know if a
2916
 * value needs to be updated.  Simple integers need the guide's original
2916
 * value needs to be updated.  Simple integers need the guide's original
2917
 * value in case the set operation is not trying to set a new value.
2917
 * value in case the set operation is not trying to set a new value.
2918
 * String values are simply set to NULL pointers if they are not going
2918
 * String values are simply set to NULL pointers if they are not going
2919
 * to be updated.
2919
 * to be updated.
2920
 *
2920
 *
2921
 * \param init Party subaddress structure to initialize.
2921
 * \param init Party subaddress structure to initialize.
2922
 * \param guide Source party subaddress to use as a guide in initializing.
2922
 * \param guide Source party subaddress to use as a guide in initializing.
2923
 *
2923
 *
2924
 * \return Nothing
2924
 * \return Nothing
2925
 */
2925
 */
2926
void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide);
2926
void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide);
2927

    
   
2927

   
2928
/*!
2928
/*!
2929
 * \since 1.8
2929
 * \since 1.8
2930
 * \brief Set the source party subaddress information into the destination party subaddress.
2930
 * \brief Set the source party subaddress information into the destination party subaddress.
2931
 *
2931
 *
2932
 * \param dest The subaddress one wishes to update
2932
 * \param dest The subaddress one wishes to update
2933
 * \param src The new subaddress values to update the dest
2933
 * \param src The new subaddress values to update the dest
2934
 *
2934
 *
2935
 * \return Nothing
2935
 * \return Nothing
2936
 */
2936
 */
2937
void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
2937
void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
2938

    
   
2938

   
2939
/*!
2939
/*!
2940
 * \since 1.8
2940
 * \since 1.8
2941
 * \brief Destroy the party subaddress contents
2941
 * \brief Destroy the party subaddress contents
2942
 *
2942
 *
2943
 * \param doomed The party subaddress to destroy.
2943
 * \param doomed The party subaddress to destroy.
2944
 *
2944
 *
2945
 * \return Nothing
2945
 * \return Nothing
2946
 */
2946
 */
2947
void ast_party_subaddress_free(struct ast_party_subaddress *doomed);
2947
void ast_party_subaddress_free(struct ast_party_subaddress *doomed);
2948

    
   
2948

   
2949
/*!
2949
/*!
2950
 * \brief Set the update marker to update all information of a corresponding party id.
2950
 * \brief Set the update marker to update all information of a corresponding party id.
2951
 * \since 11.0
2951
 * \since 11.0
2952
 *
2952
 *
2953
 * \param update_id The update marker for a corresponding party id.
2953
 * \param update_id The update marker for a corresponding party id.
2954
 *
2954
 *
2955
 * \return Nothing
2955
 * \return Nothing
2956
 */
2956
 */
2957
void ast_set_party_id_all(struct ast_set_party_id *update_id);
2957
void ast_set_party_id_all(struct ast_set_party_id *update_id);
2958

    
   
2958

   
2959
/*!
2959
/*!
2960
 * \brief Initialize the given party id structure.
2960
 * \brief Initialize the given party id structure.
2961
 * \since 1.8
2961
 * \since 1.8
2962
 *
2962
 *
2963
 * \param init Party id structure to initialize.
2963
 * \param init Party id structure to initialize.
2964
 *
2964
 *
2965
 * \return Nothing
2965
 * \return Nothing
2966
 */
2966
 */
2967
void ast_party_id_init(struct ast_party_id *init);
2967
void ast_party_id_init(struct ast_party_id *init);
2968

    
   
2968

   
2969
/*!
2969
/*!
2970
 * \brief Copy the source party id information to the destination party id.
2970
 * \brief Copy the source party id information to the destination party id.
2971
 * \since 1.8
2971
 * \since 1.8
2972
 *
2972
 *
2973
 * \param dest Destination party id
2973
 * \param dest Destination party id
2974
 * \param src Source party id
2974
 * \param src Source party id
2975
 *
2975
 *
2976
 * \return Nothing
2976
 * \return Nothing
2977
 */
2977
 */
2978
void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src);
2978
void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src);
2979

    
   
2979

   
2980
/*!
2980
/*!
2981
 * \brief Initialize the given party id structure using the given guide
2981
 * \brief Initialize the given party id structure using the given guide
2982
 * for a set update operation.
2982
 * for a set update operation.
2983
 * \since 1.8
2983
 * \since 1.8
2984
 *
2984
 *
2985
 * \details
2985
 * \details
2986
 * The initialization is needed to allow a set operation to know if a
2986
 * The initialization is needed to allow a set operation to know if a
2987
 * value needs to be updated.  Simple integers need the guide's original
2987
 * value needs to be updated.  Simple integers need the guide's original
2988
 * value in case the set operation is not trying to set a new value.
2988
 * value in case the set operation is not trying to set a new value.
2989
 * String values are simply set to NULL pointers if they are not going
2989
 * String values are simply set to NULL pointers if they are not going
2990
 * to be updated.
2990
 * to be updated.
2991
 *
2991
 *
2992
 * \param init Party id structure to initialize.
2992
 * \param init Party id structure to initialize.
2993
 * \param guide Source party id to use as a guide in initializing.
2993
 * \param guide Source party id to use as a guide in initializing.
2994
 *
2994
 *
2995
 * \return Nothing
2995
 * \return Nothing
2996
 */
2996
 */
2997
void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide);
2997
void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide);
2998

    
   
2998

   
2999
/*!
2999
/*!
3000
 * \brief Set the source party id information into the destination party id.
3000
 * \brief Set the source party id information into the destination party id.
3001
 * \since 1.8
3001
 * \since 1.8
3002
 *
3002
 *
3003
 * \param dest The id one wishes to update
3003
 * \param dest The id one wishes to update
3004
 * \param src The new id values to update the dest
3004
 * \param src The new id values to update the dest
3005
 * \param update What id information to update.  NULL if all.
3005
 * \param update What id information to update.  NULL if all.
3006
 *
3006
 *
3007
 * \return Nothing
3007
 * \return Nothing
3008
 */
3008
 */
3009
void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update);
3009
void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update);
3010

    
   
3010

   
3011
/*!
3011
/*!
3012
 * \brief Destroy the party id contents
3012
 * \brief Destroy the party id contents
3013
 * \since 1.8
3013
 * \since 1.8
3014
 *
3014
 *
3015
 * \param doomed The party id to destroy.
3015
 * \param doomed The party id to destroy.
3016
 *
3016
 *
3017
 * \return Nothing
3017
 * \return Nothing
3018
 */
3018
 */
3019
void ast_party_id_free(struct ast_party_id *doomed);
3019
void ast_party_id_free(struct ast_party_id *doomed);
3020

    
   
3020

   
3021
/*!
3021
/*!
3022
 * \brief Determine the overall presentation value for the given party.
3022
 * \brief Determine the overall presentation value for the given party.
3023
 * \since 1.8
3023
 * \since 1.8
3024
 *
3024
 *
3025
 * \param id Party to determine the overall presentation value.
3025
 * \param id Party to determine the overall presentation value.
3026
 *
3026
 *
3027
 * \return Overall presentation value for the given party.
3027
 * \return Overall presentation value for the given party.
3028
 */
3028
 */
3029
int ast_party_id_presentation(const struct ast_party_id *id);
3029
int ast_party_id_presentation(const struct ast_party_id *id);
3030

    
   
3030

   
3031
/*!
3031
/*!
3032
 * \brief Invalidate all components of the given party id.
3032
 * \brief Invalidate all components of the given party id.
3033
 * \since 11.0
3033
 * \since 11.0
3034
 *
3034
 *
3035
 * \param id The party id to invalidate.
3035
 * \param id The party id to invalidate.
3036
 *
3036
 *
3037
 * \return Nothing
3037
 * \return Nothing
3038
 */
3038
 */
3039
void ast_party_id_invalidate(struct ast_party_id *id);
3039
void ast_party_id_invalidate(struct ast_party_id *id);
3040

    
   
3040

   
3041
/*!
3041
/*!
3042
 * \brief Destroy and initialize the given party id structure.
3042
 * \brief Destroy and initialize the given party id structure.
3043
 * \since 11.0
3043
 * \since 11.0
3044
 *
3044
 *
3045
 * \param id The party id to reset.
3045
 * \param id The party id to reset.
3046
 *
3046
 *
3047
 * \return Nothing
3047
 * \return Nothing
3048
 */
3048
 */
3049
void ast_party_id_reset(struct ast_party_id *id);
3049
void ast_party_id_reset(struct ast_party_id *id);
3050

    
   
3050

   
3051
/*!
3051
/*!
3052
 * \brief Merge a given party id into another given party id.
3052
 * \brief Merge a given party id into another given party id.
3053
 * \since 11.0
3053
 * \since 11.0
3054
 *
3054
 *
3055
 * \details
3055
 * \details
3056
 * This function will generate an effective party id.
3056
 * This function will generate an effective party id.
3057
 *
3057
 *
3058
 * Each party id component of the party id 'base' is overwritten
3058
 * Each party id component of the party id 'base' is overwritten
3059
 * by components of the party id 'overlay' if the overlay
3059
 * by components of the party id 'overlay' if the overlay
3060
 * component is marked as valid.  However the component 'tag' of
3060
 * component is marked as valid.  However the component 'tag' of
3061
 * the base party id remains untouched.
3061
 * the base party id remains untouched.
3062
 *
3062
 *
3063
 * \param base The party id which is merged.
3063
 * \param base The party id which is merged.
3064
 * \param overlay The party id which is used to merge into.
3064
 * \param overlay The party id which is used to merge into.
3065
 *
3065
 *
3066
 * \return The merged party id as a struct, not as a pointer.
3066
 * \return The merged party id as a struct, not as a pointer.
3067
 * \note The merged party id returned is a shallow copy and must not be freed.
3067
 * \note The merged party id returned is a shallow copy and must not be freed.
3068
 */
3068
 */
3069
struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay);
3069
struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay);
3070

    
   
3070

   
3071
/*!
3071
/*!
3072
 * \brief Copy a merge of a given party id into another given party id to a given destination party id.
3072
 * \brief Copy a merge of a given party id into another given party id to a given destination party id.
3073
 * \since 11.0
3073
 * \since 11.0
3074
 *
3074
 *
3075
 * \details
3075
 * \details
3076
 * Each party id component of the party id 'base' is overwritten by components
3076
 * Each party id component of the party id 'base' is overwritten by components
3077
 * of the party id 'overlay' if the 'overlay' component is marked as valid.
3077
 * of the party id 'overlay' if the 'overlay' component is marked as valid.
3078
 * However the component 'tag' of the 'base' party id remains untouched.
3078
 * However the component 'tag' of the 'base' party id remains untouched.
3079
 * The result is copied into the given party id 'dest'.
3079
 * The result is copied into the given party id 'dest'.
3080
 *
3080
 *
3081
 * \note The resulting merged party id is a real copy and has to be freed.
3081
 * \note The resulting merged party id is a real copy and has to be freed.
3082
 *
3082
 *
3083
 * \param dest The resulting merged party id.
3083
 * \param dest The resulting merged party id.
3084
 * \param base The party id which is merged.
3084
 * \param base The party id which is merged.
3085
 * \param overlay The party id which is used to merge into.
3085
 * \param overlay The party id which is used to merge into.
3086
 *
3086
 *
3087
 * \return Nothing
3087
 * \return Nothing
3088
 */
3088
 */
3089
void ast_party_id_merge_copy(struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay);
3089
void ast_party_id_merge_copy(struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay);
3090

    
   
3090

   
3091
/*!
3091
/*!
3092
 * \brief Initialize the given dialed structure.
3092
 * \brief Initialize the given dialed structure.
3093
 * \since 1.8
3093
 * \since 1.8
3094
 *
3094
 *
3095
 * \param init Dialed structure to initialize.
3095
 * \param init Dialed structure to initialize.
3096
 *
3096
 *
3097
 * \return Nothing
3097
 * \return Nothing
3098
 */
3098
 */
3099
void ast_party_dialed_init(struct ast_party_dialed *init);
3099
void ast_party_dialed_init(struct ast_party_dialed *init);
3100

    
   
3100

   
3101
/*!
3101
/*!
3102
 * \brief Copy the source dialed party information to the destination dialed party.
3102
 * \brief Copy the source dialed party information to the destination dialed party.
3103
 * \since 1.8
3103
 * \since 1.8
3104
 *
3104
 *
3105
 * \param dest Destination dialed party
3105
 * \param dest Destination dialed party
3106
 * \param src Source dialed party
3106
 * \param src Source dialed party
3107
 *
3107
 *
3108
 * \return Nothing
3108
 * \return Nothing
3109
 */
3109
 */
3110
void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3110
void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3111

    
   
3111

   
3112
/*!
3112
/*!
3113
 * \brief Initialize the given dialed structure using the given
3113
 * \brief Initialize the given dialed structure using the given
3114
 * guide for a set update operation.
3114
 * guide for a set update operation.
3115
 * \since 1.8
3115
 * \since 1.8
3116
 *
3116
 *
3117
 * \details
3117
 * \details
3118
 * The initialization is needed to allow a set operation to know if a
3118
 * The initialization is needed to allow a set operation to know if a
3119
 * value needs to be updated.  Simple integers need the guide's original
3119
 * value needs to be updated.  Simple integers need the guide's original
3120
 * value in case the set operation is not trying to set a new value.
3120
 * value in case the set operation is not trying to set a new value.
3121
 * String values are simply set to NULL pointers if they are not going
3121
 * String values are simply set to NULL pointers if they are not going
3122
 * to be updated.
3122
 * to be updated.
3123
 *
3123
 *
3124
 * \param init Caller structure to initialize.
3124
 * \param init Caller structure to initialize.
3125
 * \param guide Source dialed to use as a guide in initializing.
3125
 * \param guide Source dialed to use as a guide in initializing.
3126
 *
3126
 *
3127
 * \return Nothing
3127
 * \return Nothing
3128
 */
3128
 */
3129
void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide);
3129
void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide);
3130

    
   
3130

   
3131
/*!
3131
/*!
3132
 * \brief Set the dialed information based on another dialed source
3132
 * \brief Set the dialed information based on another dialed source
3133
 * \since 1.8
3133
 * \since 1.8
3134
 *
3134
 *
3135
 * This is similar to ast_party_dialed_copy, except that NULL values for
3135
 * This is similar to ast_party_dialed_copy, except that NULL values for
3136
 * strings in the src parameter indicate not to update the corresponding dest values.
3136
 * strings in the src parameter indicate not to update the corresponding dest values.
3137
 *
3137
 *
3138
 * \param dest The dialed one wishes to update
3138
 * \param dest The dialed one wishes to update
3139
 * \param src The new dialed values to update the dest
3139
 * \param src The new dialed values to update the dest
3140
 *
3140
 *
3141
 * \return Nada
3141
 * \return Nada
3142
 */
3142
 */
3143
void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3143
void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3144

    
   
3144

   
3145
/*!
3145
/*!
3146
 * \brief Destroy the dialed party contents
3146
 * \brief Destroy the dialed party contents
3147
 * \since 1.8
3147
 * \since 1.8
3148
 *
3148
 *
3149
 * \param doomed The dialed party to destroy.
3149
 * \param doomed The dialed party to destroy.
3150
 *
3150
 *
3151
 * \return Nothing
3151
 * \return Nothing
3152
 */
3152
 */
3153
void ast_party_dialed_free(struct ast_party_dialed *doomed);
3153
void ast_party_dialed_free(struct ast_party_dialed *doomed);
3154

    
   
3154

   
3155
/*!
3155
/*!
3156
 * \since 1.8
3156
 * \since 1.8
3157
 * \brief Initialize the given caller structure.
3157
 * \brief Initialize the given caller structure.
3158
 *
3158
 *
3159
 * \param init Caller structure to initialize.
3159
 * \param init Caller structure to initialize.
3160
 *
3160
 *
3161
 * \return Nothing
3161
 * \return Nothing
3162
 */
3162
 */
3163
void ast_party_caller_init(struct ast_party_caller *init);
3163
void ast_party_caller_init(struct ast_party_caller *init);
3164

    
   
3164

   
3165
/*!
3165
/*!
3166
 * \since 1.8
3166
 * \since 1.8
3167
 * \brief Copy the source caller information to the destination caller.
3167
 * \brief Copy the source caller information to the destination caller.
3168
 *
3168
 *
3169
 * \param dest Destination caller
3169
 * \param dest Destination caller
3170
 * \param src Source caller
3170
 * \param src Source caller
3171
 *
3171
 *
3172
 * \return Nothing
3172
 * \return Nothing
3173
 */
3173
 */
3174
void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src);
3174
void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src);
3175

    
   
3175

   
3176
/*!
3176
/*!
3177
 * \brief Initialize the given caller structure using the given
3177
 * \brief Initialize the given caller structure using the given
3178
 * guide for a set update operation.
3178
 * guide for a set update operation.
3179
 * \since 1.8
3179
 * \since 1.8
3180
 *
3180
 *
3181
 * \details
3181
 * \details
3182
 * The initialization is needed to allow a set operation to know if a
3182
 * The initialization is needed to allow a set operation to know if a
3183
 * value needs to be updated.  Simple integers need the guide's original
3183
 * value needs to be updated.  Simple integers need the guide's original
3184
 * value in case the set operation is not trying to set a new value.
3184
 * value in case the set operation is not trying to set a new value.
3185
 * String values are simply set to NULL pointers if they are not going
3185
 * String values are simply set to NULL pointers if they are not going
3186
 * to be updated.
3186
 * to be updated.
3187
 *
3187
 *
3188
 * \param init Caller structure to initialize.
3188
 * \param init Caller structure to initialize.
3189
 * \param guide Source caller to use as a guide in initializing.
3189
 * \param guide Source caller to use as a guide in initializing.
3190
 *
3190
 *
3191
 * \return Nothing
3191
 * \return Nothing
3192
 */
3192
 */
3193
void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide);
3193
void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide);
3194

    
   
3194

   
3195
/*!
3195
/*!
3196
 * \brief Set the caller information based on another caller source
3196
 * \brief Set the caller information based on another caller source
3197
 * \since 1.8
3197
 * \since 1.8
3198
 *
3198
 *
3199
 * This is similar to ast_party_caller_copy, except that NULL values for
3199
 * This is similar to ast_party_caller_copy, except that NULL values for
3200
 * strings in the src parameter indicate not to update the corresponding dest values.
3200
 * strings in the src parameter indicate not to update the corresponding dest values.
3201
 *
3201
 *
3202
 * \param dest The caller one wishes to update
3202
 * \param dest The caller one wishes to update
3203
 * \param src The new caller values to update the dest
3203
 * \param src The new caller values to update the dest
3204
 * \param update What caller information to update.  NULL if all.
3204
 * \param update What caller information to update.  NULL if all.
3205
 *
3205
 *
3206
 * \return Nada
3206
 * \return Nada
3207
 */
3207
 */
3208
void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update);
3208
void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update);
3209

    
   
3209

   
3210
/*!
3210
/*!
3211
 * \brief Destroy the caller party contents
3211
 * \brief Destroy the caller party contents
3212
 * \since 1.8
3212
 * \since 1.8
3213
 *
3213
 *
3214
 * \param doomed The caller party to destroy.
3214
 * \param doomed The caller party to destroy.
3215
 *
3215
 *
3216
 * \return Nothing
3216
 * \return Nothing
3217
 */
3217
 */
3218
void ast_party_caller_free(struct ast_party_caller *doomed);
3218
void ast_party_caller_free(struct ast_party_caller *doomed);
3219

    
   
3219

   
3220
/*!
3220
/*!
3221
 * \since 1.8
3221
 * \since 1.8
3222
 * \brief Initialize the given connected line structure.
3222
 * \brief Initialize the given connected line structure.
3223
 *
3223
 *
3224
 * \param init Connected line structure to initialize.
3224
 * \param init Connected line structure to initialize.
3225
 *
3225
 *
3226
 * \return Nothing
3226
 * \return Nothing
3227
 */
3227
 */
3228
void ast_party_connected_line_init(struct ast_party_connected_line *init);
3228
void ast_party_connected_line_init(struct ast_party_connected_line *init);
3229

    
   
3229

   
3230
/*!
3230
/*!
3231
 * \since 1.8
3231
 * \since 1.8
3232
 * \brief Copy the source connected line information to the destination connected line.
3232
 * \brief Copy the source connected line information to the destination connected line.
3233
 *
3233
 *
3234
 * \param dest Destination connected line
3234
 * \param dest Destination connected line
3235
 * \param src Source connected line
3235
 * \param src Source connected line
3236
 *
3236
 *
3237
 * \return Nothing
3237
 * \return Nothing
3238
 */
3238
 */
3239
void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src);
3239
void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src);
3240

    
   
3240

   
3241
/*!
3241
/*!
3242
 * \since 1.8
3242
 * \since 1.8
3243
 * \brief Initialize the given connected line structure using the given
3243
 * \brief Initialize the given connected line structure using the given
3244
 * guide for a set update operation.
3244
 * guide for a set update operation.
3245
 *
3245
 *
3246
 * \details
3246
 * \details
3247
 * The initialization is needed to allow a set operation to know if a
3247
 * The initialization is needed to allow a set operation to know if a
3248
 * value needs to be updated.  Simple integers need the guide's original
3248
 * value needs to be updated.  Simple integers need the guide's original
3249
 * value in case the set operation is not trying to set a new value.
3249
 * value in case the set operation is not trying to set a new value.
3250
 * String values are simply set to NULL pointers if they are not going
3250
 * String values are simply set to NULL pointers if they are not going
3251
 * to be updated.
3251
 * to be updated.
3252
 *
3252
 *
3253
 * \param init Connected line structure to initialize.
3253
 * \param init Connected line structure to initialize.
3254
 * \param guide Source connected line to use as a guide in initializing.
3254
 * \param guide Source connected line to use as a guide in initializing.
3255
 *
3255
 *
3256
 * \return Nothing
3256
 * \return Nothing
3257
 */
3257
 */
3258
void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide);
3258
void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide);
3259

    
   
3259

   
3260
/*!
3260
/*!
3261
 * \since 1.8
3261
 * \since 1.8
3262
 * \brief Set the connected line information based on another connected line source
3262
 * \brief Set the connected line information based on another connected line source
3263
 *
3263
 *
3264
 * This is similar to ast_party_connected_line_copy, except that NULL values for
3264
 * This is similar to ast_party_connected_line_copy, except that NULL values for
3265
 * strings in the src parameter indicate not to update the corresponding dest values.
3265
 * strings in the src parameter indicate not to update the corresponding dest values.
3266
 *
3266
 *
3267
 * \param dest The connected line one wishes to update
3267
 * \param dest The connected line one wishes to update
3268
 * \param src The new connected line values to update the dest
3268
 * \param src The new connected line values to update the dest
3269
 * \param update What connected line information to update.  NULL if all.
3269
 * \param update What connected line information to update.  NULL if all.
3270
 *
3270
 *
3271
 * \return Nothing
3271
 * \return Nothing
3272
 */
3272
 */
3273
void ast_party_connected_line_set(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update);
3273
void ast_party_connected_line_set(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update);
3274

    
   
3274

   
3275
/*!
3275
/*!
3276
 * \since 1.8
3276
 * \since 1.8
3277
 * \brief Collect the caller party information into a connected line structure.
3277
 * \brief Collect the caller party information into a connected line structure.
3278
 *
3278
 *
3279
 * \param connected Collected caller information for the connected line
3279
 * \param connected Collected caller information for the connected line
3280
 * \param caller Caller information.
3280
 * \param caller Caller information.
3281
 *
3281
 *
3282
 * \return Nothing
3282
 * \return Nothing
3283
 *
3283
 *
3284
 * \warning This is a shallow copy.
3284
 * \warning This is a shallow copy.
3285
 * \warning DO NOT call ast_party_connected_line_free() on the filled in
3285
 * \warning DO NOT call ast_party_connected_line_free() on the filled in
3286
 * connected line structure!
3286
 * connected line structure!
3287
 */
3287
 */
3288
void ast_party_connected_line_collect_caller(struct ast_party_connected_line *connected, struct ast_party_caller *caller);
3288
void ast_party_connected_line_collect_caller(struct ast_party_connected_line *connected, struct ast_party_caller *caller);
3289

    
   
3289

   
3290
/*!
3290
/*!
3291
 * \since 1.8
3291
 * \since 1.8
3292
 * \brief Destroy the connected line information contents
3292
 * \brief Destroy the connected line information contents
3293
 *
3293
 *
3294
 * \param doomed The connected line information to destroy.
3294
 * \param doomed The connected line information to destroy.
3295
 *
3295
 *
3296
 * \return Nothing
3296
 * \return Nothing
3297
 */
3297
 */
3298
void ast_party_connected_line_free(struct ast_party_connected_line *doomed);
3298
void ast_party_connected_line_free(struct ast_party_connected_line *doomed);
3299