2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2006, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
20 * \brief General Asterisk PBX channel definitions.
22 * \arg \ref Def_Channel
23 * \arg \ref channel_drivers
26 /*! \page Def_Channel Asterisk Channels
27 \par What is a Channel?
28 A phone call through Asterisk consists of an incoming
29 connection and an outbound connection. Each call comes
30 in through a channel driver that supports one technology,
31 like SIP, DAHDI, IAX2 etc.
33 Each channel driver, technology, has it's own private
34 channel or dialog structure, that is technology-dependent.
35 Each private structure is "owned" by a generic Asterisk
36 channel structure, defined in channel.h and handled by
39 This happens when an incoming call arrives to Asterisk
40 -# Call arrives on a channel driver interface
41 -# Channel driver creates a PBX channel and starts a
42 pbx thread on the channel
43 -# The dial plan is executed
44 -# At this point at least two things can happen:
45 -# The call is answered by Asterisk and
46 Asterisk plays a media stream or reads media
47 -# The dial plan forces Asterisk to create an outbound
48 call somewhere with the dial (see \ref app_dial.c)
52 \par Bridging channels
53 If Asterisk dials out this happens:
54 -# Dial creates an outbound PBX channel and asks one of the
55 channel drivers to create a call
56 -# When the call is answered, Asterisk bridges the media streams
57 so the caller on the first channel can speak with the callee
58 on the second, outbound channel
59 -# In some cases where we have the same technology on both
60 channels and compatible codecs, a native bridge is used.
61 In a native bridge, the channel driver handles forwarding
62 of incoming audio to the outbound stream internally, without
63 sending audio frames through the PBX.
64 -# In SIP, theres an "external native bridge" where Asterisk
65 redirects the endpoint, so audio flows directly between the
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
71 \par Masquerading channels
72 In some cases, a channel can masquerade itself into another
73 channel. This happens frequently in call transfers, where
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
76 and the old channel, now a zombie, is hung up.
79 \arg channel.c - generic functions
80 \arg channel.h - declarations of functions, flags and structures
81 \arg translate.h - Transcoding support functions
82 \arg \ref channel_drivers - Implemented channel drivers
83 \arg \ref Def_Frame Asterisk Multimedia Frames
87 /*! \page Def_Bridge Asterisk Channel Bridges
89 In Asterisk, there's several media bridges.
91 The Core bridge handles two channels (a "phone call") and bridge
94 The conference bridge (meetme) handles several channels simultaneously
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
97 page application and the SLA system introduced in 1.4.
98 The conference bridge does not handle video.
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)
102 can create a native bridge without sending media through the
105 Native bridging can be disabled by a number of reasons,
106 like DTMF being needed by the core or codecs being incompatible
107 so a transcoding module is needed.
110 \li \see ast_channel_early_bridge()
111 \li \see ast_channel_bridge()
112 \li \see app_meetme.c
113 \li \ref AstRTPbridge
114 \li \see ast_rtp_bridge()
118 /*! \page AstFileDesc File descriptors
119 Asterisk File descriptors are connected to each channel (see \ref Def_Channel)
120 in the \ref ast_channel structure.
123 #ifndef _ASTERISK_CHANNEL_H
124 #define _ASTERISK_CHANNEL_H
126 #include "asterisk/abstract_jb.h"
127 #include "asterisk/astobj2.h"
129 #include "asterisk/poll-compat.h"
131 #if defined(__cplusplus) || defined(c_plusplus)
135 #define AST_MAX_EXTENSION 80 /*!< Max length of an extension */
136 #define AST_MAX_CONTEXT 80 /*!< Max length of a context */
137 #define AST_CHANNEL_NAME 80 /*!< Max length of an ast_channel name */
138 #define MAX_LANGUAGE 40 /*!< Max length of the language setting */
139 #define MAX_MUSICCLASS 80 /*!< Max length of the music class setting */
141 #include "asterisk/frame.h"
142 #include "asterisk/chanvars.h"
143 #include "asterisk/config.h"
144 #include "asterisk/lock.h"
145 #include "asterisk/cdr.h"
146 #include "asterisk/utils.h"
147 #include "asterisk/linkedlists.h"
148 #include "asterisk/stringfields.h"
149 #include "asterisk/datastore.h"
150 #include "asterisk/data.h"
151 #include "asterisk/channelstate.h"
152 #include "asterisk/ccss.h"
153 #include "asterisk/framehook.h"
155 #define DATASTORE_INHERIT_FOREVER INT_MAX
157 #define AST_MAX_FDS 11
159 * We have AST_MAX_FDS file descriptors in a channel.
160 * Some of them have a fixed use:
162 #define AST_ALERT_FD (AST_MAX_FDS-1) /*!< used for alertpipe */
163 #define AST_TIMING_FD (AST_MAX_FDS-2) /*!< used for timingfd */
164 #define AST_AGENT_FD (AST_MAX_FDS-3) /*!< used by agents for pass through */
165 #define AST_GENERATOR_FD (AST_MAX_FDS-4) /*!< used by generator */
166 #define AST_JITTERBUFFER_FD (AST_MAX_FDS-5) /*!< used by generator */
168 enum ast_bridge_result {
169 AST_BRIDGE_COMPLETE = 0,
170 AST_BRIDGE_FAILED = -1,
171 AST_BRIDGE_FAILED_NOWARN = -2,
172 AST_BRIDGE_RETRY = -3,
175 typedef unsigned long long ast_group_t;
177 /*! \todo Add an explanation of an Asterisk generator
179 struct ast_generator {
180 void *(*alloc)(struct ast_channel *chan, void *params);
181 /*! Channel is locked during this function callback. */
182 void (*release)(struct ast_channel *chan, void *data);
183 /*! This function gets called with the channel unlocked, but is called in
184 * the context of the channel thread so we know the channel is not going
185 * to disappear. This callback is responsible for locking the channel as
187 int (*generate)(struct ast_channel *chan, void *data, int len, int samples);
188 /*! This gets called when DTMF_END frames are read from the channel */
189 void (*digit)(struct ast_channel *chan, char digit);
190 /*! This gets called when the write format on a channel is changed while
191 * generating. The channel is locked during this callback. */
192 void (*write_format_change)(struct ast_channel *chan, void *data);
195 /*! Party name character set enumeration values (values from Q.SIG) */
196 enum AST_PARTY_CHAR_SET {
197 AST_PARTY_CHAR_SET_UNKNOWN = 0,
198 AST_PARTY_CHAR_SET_ISO8859_1 = 1,
199 AST_PARTY_CHAR_SET_WITHDRAWN = 2,/* ITU withdrew this enum value. */
200 AST_PARTY_CHAR_SET_ISO8859_2 = 3,
201 AST_PARTY_CHAR_SET_ISO8859_3 = 4,
202 AST_PARTY_CHAR_SET_ISO8859_4 = 5,
203 AST_PARTY_CHAR_SET_ISO8859_5 = 6,
204 AST_PARTY_CHAR_SET_ISO8859_7 = 7,
205 AST_PARTY_CHAR_SET_ISO10646_BMPSTRING = 8,
206 AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING = 9,
211 * \brief Information needed to specify a name in a call.
212 * \note All string fields here are malloc'ed, so they need to be
213 * freed when the structure is deleted.
214 * \note NULL and "" must be considered equivalent.
216 struct ast_party_name {
217 /*! \brief Subscriber name (Malloced) */
220 * \brief Character set the name is using.
221 * \see enum AST_PARTY_CHAR_SET
223 * Set to AST_PARTY_CHAR_SET_ISO8859_1 if unsure what to use.
224 * \todo Start using the party name character set value. Not currently used.
228 * \brief Q.931 encoded presentation-indicator encoded field
229 * \note Must tolerate the Q.931 screening-indicator field values being present.
232 /*! \brief TRUE if the name information is valid/present */
238 * \brief Information needed to specify a number in a call.
239 * \note All string fields here are malloc'ed, so they need to be
240 * freed when the structure is deleted.
241 * \note NULL and "" must be considered equivalent.
243 struct ast_party_number {
244 /*! \brief Subscriber phone number (Malloced) */
246 /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
248 /*! \brief Q.931 presentation-indicator and screening-indicator encoded fields */
250 /*! \brief TRUE if the number information is valid/present */
256 * \brief Information needed to specify a subaddress in a call.
257 * \note All string fields here are malloc'ed, so they need to be
258 * freed when the structure is deleted.
259 * \note NULL and "" must be considered equivalent.
261 struct ast_party_subaddress {
263 * \brief Malloced subaddress string.
264 * \note If the subaddress type is user specified then the subaddress is
265 * a string of ASCII hex because the actual subaddress is likely BCD encoded.
269 * \brief Q.931 subaddress type.
276 * \brief TRUE if odd number of address signals
277 * \note The odd/even indicator is used when the type of subaddress is
278 * user_specified and the coding is BCD.
280 unsigned char odd_even_indicator;
281 /*! \brief TRUE if the subaddress information is valid/present */
287 * \brief Information needed to identify an endpoint in a call.
288 * \note All string fields here are malloc'ed, so they need to be
289 * freed when the structure is deleted.
290 * \note NULL and "" must be considered equivalent.
292 struct ast_party_id {
293 /*! \brief Subscriber name */
294 struct ast_party_name name;
295 /*! \brief Subscriber phone number */
296 struct ast_party_number number;
297 /*! \brief Subscriber subaddress. */
298 struct ast_party_subaddress subaddress;
301 * \brief User-set "tag"
303 * A user-settable field used to help associate some extrinsic information
304 * about the channel or user of the channel to the party ID. This information
305 * is normally not transmitted over the wire and so is only useful within an
306 * Asterisk environment.
313 * \brief Indicate what information in ast_party_id should be set.
315 struct ast_set_party_id {
316 /*! TRUE if the ast_party_name information should be set. */
318 /*! TRUE if the ast_party_number information should be set. */
319 unsigned char number;
320 /*! TRUE if the ast_party_subaddress information should be set. */
321 unsigned char subaddress;
326 * \brief Dialed/Called Party information.
327 * \note Dialed Number Identifier (DNID)
328 * \note All string fields here are malloc'ed, so they need to be
329 * freed when the structure is deleted.
330 * \note NULL and "" must be considered equivalent.
332 struct ast_party_dialed {
334 * \brief Dialed/Called number
335 * \note Done this way in case we ever really need to use ast_party_number.
336 * We currently do not need all of the ast_party_number fields.
339 /*! \brief Subscriber phone number (Malloced) */
341 /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
344 /*! \brief Dialed/Called subaddress */
345 struct ast_party_subaddress subaddress;
347 * \brief Transit Network Select
348 * \note Currently this value is just passed around the system.
349 * You can read it and set it but it is never used for anything.
351 int transit_network_select;
356 * \brief Caller Party information.
357 * \note All string fields here are malloc'ed, so they need to be
358 * freed when the structure is deleted.
359 * \note NULL and "" must be considered equivalent.
361 * \note SIP and IAX2 has UTF8 encoded Unicode Caller ID names.
362 * In some cases, we also have an alternative (RPID) E.164 number that can
363 * be used as Caller ID on numeric E.164 phone networks (DAHDI or SIP/IAX2 to
366 * \todo Implement settings for transliteration between UTF8 Caller ID names in
367 * to ASCII Caller ID's (DAHDI). Östen Åsklund might be transliterated into
368 * Osten Asklund or Oesten Aasklund depending upon language and person...
369 * We need automatic routines for incoming calls and static settings for
372 struct ast_party_caller {
373 /*! \brief Caller party ID */
374 struct ast_party_id id;
377 * \brief Automatic Number Identification (ANI)
378 * \note The name subcomponent is only likely to be used by SIP.
379 * \note The subaddress subcomponent is not likely to be used.
381 struct ast_party_id ani;
383 /*! \brief Automatic Number Identification 2 (Info Digits) */
389 * \brief Indicate what information in ast_party_caller should be set.
391 struct ast_set_party_caller {
392 /*! What caller id information to set. */
393 struct ast_set_party_id id;
394 /*! What ANI id information to set. */
395 struct ast_set_party_id ani;
400 * \brief Connected Line/Party information.
401 * \note All string fields here are malloc'ed, so they need to be
402 * freed when the structure is deleted.
403 * \note NULL and "" must be considered equivalent.
405 struct ast_party_connected_line {
406 /*! \brief Connected party ID */
407 struct ast_party_id id;
410 * \brief Automatic Number Identification (ANI)
411 * \note Not really part of connected line data but needed to
412 * save the corresponding caller id value.
414 struct ast_party_id ani;
417 * \brief Automatic Number Identification 2 (Info Digits)
418 * \note Not really part of connected line data but needed to
419 * save the corresponding caller id value.
424 * \brief Information about the source of an update.
425 * \note enum AST_CONNECTED_LINE_UPDATE_SOURCE values
426 * for Normal-Answer and Call-transfer.
433 * \brief Indicate what information in ast_party_connected_line should be set.
435 struct ast_set_party_connected_line {
436 /*! What connected line id information to set. */
437 struct ast_set_party_id id;
438 /*! What ANI id information to set. */
439 struct ast_set_party_id ani;
444 * \brief Redirecting Line information.
445 * RDNIS (Redirecting Directory Number Information Service)
446 * Where a call diversion or transfer was invoked.
447 * \note All string fields here are malloc'ed, so they need to be
448 * freed when the structure is deleted.
449 * \note NULL and "" must be considered equivalent.
451 struct ast_party_redirecting {
452 /*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) */
453 struct ast_party_id orig;
455 /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */
456 struct ast_party_id from;
458 /*! \brief Call is redirecting to a new party (Sent to the caller) */
459 struct ast_party_id to;
461 /*! \brief Number of times the call was redirected */
464 /*! \brief enum AST_REDIRECTING_REASON value for redirection */
467 /*! \brief enum AST_REDIRECTING_REASON value for redirection by original party */
473 * \brief Indicate what information in ast_party_redirecting should be set.
475 struct ast_set_party_redirecting {
476 /*! What redirecting-orig id information to set. */
477 struct ast_set_party_id orig;
478 /*! What redirecting-from id information to set. */
479 struct ast_set_party_id from;
480 /*! What redirecting-to id information to set. */
481 struct ast_set_party_id to;
485 * \brief Typedef for a custom read function
486 * \note data should be treated as const char *.
488 typedef int (*ast_acf_read_fn_t)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
491 * \brief Typedef for a custom read2 function
492 * \note data should be treated as const char *.
494 typedef int (*ast_acf_read2_fn_t)(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len);
497 * \brief Typedef for a custom write function
498 * \note data should be treated as const char *.
500 typedef int (*ast_acf_write_fn_t)(struct ast_channel *chan, const char *function, char *data, const char *value);
502 /*! \brief Structure to handle passing func_channel_write info to channels via setoption */
504 /*! \brief ast_chan_write_info_t version. Must be incremented if structure is changed */
505 #define AST_CHAN_WRITE_INFO_T_VERSION 1
507 ast_acf_write_fn_t write_fn;
508 struct ast_channel *chan;
509 const char *function;
512 } ast_chan_write_info_t;
516 * Structure to describe a channel "technology", ie a channel driver
518 * \arg chan_iax2.c - The Inter-Asterisk exchange protocol
519 * \arg chan_sip.c - The SIP channel driver
520 * \arg chan_dahdi.c - PSTN connectivity (TDM, PRI, T1/E1, FXO, FXS)
523 * If you develop your own channel driver, this is where you
524 * tell the PBX at registration of your driver what properties
525 * this driver supports and where different callbacks are
528 struct ast_channel_tech {
529 const char * const type;
530 const char * const description;
532 struct ast_format_cap *capabilities; /*!< format capabilities this channel can handle */
534 int properties; /*!< Technology Properties */
537 * \brief Requester - to set up call data structures (pvt's)
539 * \param type type of channel to request
540 * \param cap Format capabilities for requested channel
541 * \param requestor channel asking for data
542 * \param addr destination of the call
543 * \param cause Cause of failure
546 * Request a channel of a given type, with addr as optional information used
547 * by the low level module
549 * \retval NULL failure
550 * \retval non-NULL channel on success
552 struct ast_channel *(* const requester)(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr, int *cause);
554 int (* const devicestate)(const char *device_number); /*!< Devicestate call back */
557 * \brief Start sending a literal DTMF digit
559 * \note The channel is not locked when this function gets called.
561 int (* const send_digit_begin)(struct ast_channel *chan, char digit);
564 * \brief Stop sending a literal DTMF digit
566 * \note The channel is not locked when this function gets called.
568 int (* const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration);
572 * \note The channel is locked when called.
573 * \param chan which channel to make the call on
574 * \param addr destination of the call
575 * \param timeout time to wait on for connect (Doesn't seem to be used.)
576 * \retval 0 on success
577 * \retval -1 on failure
579 int (* const call)(struct ast_channel *chan, const char *addr, int timeout);
581 /*! \brief Hangup (and possibly destroy) the channel */
582 int (* const hangup)(struct ast_channel *chan);
584 /*! \brief Answer the channel */
585 int (* const answer)(struct ast_channel *chan);
587 /*! \brief Read a frame, in standard format (see frame.h) */
588 struct ast_frame * (* const read)(struct ast_channel *chan);
590 /*! \brief Write a frame, in standard format (see frame.h) */
591 int (* const write)(struct ast_channel *chan, struct ast_frame *frame);
593 /*! \brief Display or transmit text */
594 int (* const send_text)(struct ast_channel *chan, const char *text);
596 /*! \brief Display or send an image */
597 int (* const send_image)(struct ast_channel *chan, struct ast_frame *frame);
599 /*! \brief Send HTML data */
600 int (* const send_html)(struct ast_channel *chan, int subclass, const char *data, int len);
602 /*! \brief Handle an exception, reading a frame */
603 struct ast_frame * (* const exception)(struct ast_channel *chan);
605 /*! \brief Bridge two channels of the same type together */
606 enum ast_bridge_result (* const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags,
607 struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
609 /*! \brief Bridge two channels of the same type together (early) */
610 enum ast_bridge_result (* const early_bridge)(struct ast_channel *c0, struct ast_channel *c1);
612 /*! \brief Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */
613 int (* const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen);
615 /*! \brief Fix up a channel: If a channel is consumed, this is called. Basically update any ->owner links */
616 int (* const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan);
618 /*! \brief Set a given option. Called with chan locked */
619 int (* const setoption)(struct ast_channel *chan, int option, void *data, int datalen);
621 /*! \brief Query a given option. Called with chan locked */
622 int (* const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen);
624 /*! \brief Blind transfer other side (see app_transfer.c and ast_transfer() */
625 int (* const transfer)(struct ast_channel *chan, const char *newdest);
627 /*! \brief Write a frame, in standard format */
628 int (* const write_video)(struct ast_channel *chan, struct ast_frame *frame);
630 /*! \brief Write a text frame, in standard format */
631 int (* const write_text)(struct ast_channel *chan, struct ast_frame *frame);
633 /*! \brief Find bridged channel */
634 struct ast_channel *(* const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge);
637 * \brief Provide additional read items for CHANNEL() dialplan function
638 * \note data should be treated as a const char *.
640 int (* func_channel_read)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
643 * \brief Provide additional write items for CHANNEL() dialplan function
644 * \note data should be treated as a const char *.
646 int (* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value);
648 /*! \brief Retrieve base channel (agent and local) */
649 struct ast_channel* (* get_base_channel)(struct ast_channel *chan);
651 /*! \brief Set base channel (agent and local) */
652 int (* set_base_channel)(struct ast_channel *chan, struct ast_channel *base);
654 /*! \brief Get the unique identifier for the PVT, i.e. SIP call-ID for SIP */
655 const char * (* get_pvt_uniqueid)(struct ast_channel *chan);
657 /*! \brief Call a function with cc parameters as a function parameter
660 * This is a highly specialized callback that is not likely to be needed in many
661 * channel drivers. When dealing with a busy channel, for instance, most channel
662 * drivers will successfully return a channel to the requester. Once called, the channel
663 * can then queue a busy frame when it receives an appropriate message from the far end.
664 * In such a case, the channel driver has the opportunity to also queue a CC frame.
665 * The parameters for the CC channel can be retrieved from the channel structure.
667 * For other channel drivers, notably those that deal with "dumb" phones, the channel
668 * driver will not return a channel when one is requested. In such a scenario, there is never
669 * an opportunity for the channel driver to queue a CC frame since the channel is never
670 * called. Furthermore, it is not possible to retrieve the CC configuration parameters
671 * for the desired channel because no channel is ever allocated or returned to the
672 * requester. In such a case, call completion may still be a viable option. What we do is
673 * pass the same string that the requester used originally to request the channel to the
674 * channel driver. The channel driver can then find any potential channels/devices that
675 * match the input and return call the designated callback with the device's call completion
676 * parameters as a parameter.
678 int (* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback);
681 * \brief Execute a Gosub call on the channel in a technology specific way before a call is placed.
684 * \param chan Channel to execute Gosub in a tech specific way.
685 * \param sub_args Gosub application parameter string.
687 * \note The chan is locked before calling.
689 * \retval 0 on success.
690 * \retval -1 on error.
692 int (*pre_call)(struct ast_channel *chan, const char *sub_args);
695 /*! Kill the channel channel driver technology descriptor. */
696 extern const struct ast_channel_tech ast_kill_tech;
698 struct ast_epoll_data;
701 * The high bit of the frame count is used as a debug marker, so
702 * increments of the counters must be done with care.
703 * Please use c->fin = FRAMECOUNT_INC(c->fin) and the same for c->fout.
705 #define DEBUGCHAN_FLAG 0x80000000
707 /* XXX not ideal to evaluate x twice... */
708 #define FRAMECOUNT_INC(x) ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) )
711 * The current value of the debug flags is stored in the two
712 * variables global_fin and global_fout (declared in main/channel.c)
714 extern unsigned long global_fin, global_fout;
716 enum ast_channel_adsicpe {
719 AST_ADSI_UNAVAILABLE,
720 AST_ADSI_OFFHOOKONLY,
724 * \brief Possible T38 states on channels
727 T38_STATE_UNAVAILABLE, /*!< T38 is unavailable on this channel or disabled by configuration */
728 T38_STATE_UNKNOWN, /*!< The channel supports T38 but the current status is unknown */
729 T38_STATE_NEGOTIATING, /*!< T38 is being negotiated */
730 T38_STATE_REJECTED, /*!< Remote side has rejected our offer */
731 T38_STATE_NEGOTIATED, /*!< T38 established */
734 AST_LIST_HEAD_NOLOCK(ast_datastore_list, ast_datastore);
735 AST_LIST_HEAD_NOLOCK(ast_autochan_list, ast_autochan);
736 AST_LIST_HEAD_NOLOCK(ast_readq_list, ast_frame);
738 typedef int(*ast_timing_func_t)(const void *data);
740 * \page AstChannel ast_channel locking and reference tracking
742 * \par Creating Channels
743 * A channel is allocated using the ast_channel_alloc() function. When created, it is
744 * automatically inserted into the main channels hash table that keeps track of all
745 * active channels in the system. The hash key is based on the channel name. Because
746 * of this, if you want to change the name, you _must_ use ast_change_name(), not change
747 * the name field directly. When ast_channel_alloc() returns a channel pointer, you now
748 * hold a reference to that channel. In most cases this reference is given to ast_pbx_run().
750 * \par Channel Locking
751 * There is a lock associated with every ast_channel. It is allocated internally via astobj2.
752 * To lock or unlock a channel, you must use the ast_channel_lock() wrappers.
754 * Previously, before ast_channel was converted to astobj2, the channel lock was used in some
755 * additional ways that are no longer necessary. Before, the only way to ensure that a channel
756 * did not disappear out from under you if you were working with a channel outside of the channel
757 * thread that owns it, was to hold the channel lock. Now, that is no longer necessary.
758 * You simply must hold a reference to the channel to ensure it does not go away.
760 * The channel must be locked if you need to ensure that data that you reading from the channel
761 * does not change while you access it. Further, you must hold the channel lock if you are
762 * making a non-atomic change to channel data.
764 * \par Channel References
765 * There are multiple ways to get a reference to a channel. The first is that you hold a reference
766 * to a channel after creating it. The other ways involve using the channel search or the channel
767 * traversal APIs. These functions are the ast_channel_get_*() functions or ast_channel_iterator_*()
768 * functions. Once a reference is retrieved by one of these methods, you know that the channel will
769 * not go away. So, the channel should only get locked as needed for data access or modification.
770 * But, make sure that the reference gets released when you are done with it!
772 * There are different things you can do when you are done with a reference to a channel. The first
773 * is to simply release the reference using ast_channel_unref(). The other option is to call
774 * ast_channel_release(). This function is generally used where ast_channel_free() was used in
775 * the past. The release function releases a reference as well as ensures that the channel is no
776 * longer in the global channels container. That way, the channel will get destroyed as soon as any
777 * other pending references get released.
779 * \par Exceptions to the rules
780 * Even though ast_channel is reference counted, there are some places where pointers to an ast_channel
781 * get stored, but the reference count does not reflect it. The reason is mostly historical.
782 * The only places where this happens should be places where because of how the code works, we
783 * _know_ that the pointer to the channel will get removed before the channel goes away. The main
784 * example of this is in channel drivers. Channel drivers generally store a pointer to their owner
785 * ast_channel in their technology specific pvt struct. In this case, the channel drivers _know_
786 * that this pointer to the channel will be removed in time, because the channel's hangup callback
787 * gets called before the channel goes away.
792 /*! \brief ast_channel_tech Properties */
795 * \brief Channels have this property if they can accept input with jitter;
796 * i.e. most VoIP channels
798 AST_CHAN_TP_WANTSJITTER = (1 << 0),
800 * \brief Channels have this property if they can create jitter;
801 * i.e. most VoIP channels
803 AST_CHAN_TP_CREATESJITTER = (1 << 1),
806 /*! \brief ast_channel flags */
808 /*! Queue incoming DTMF, to be released when this flag is turned off */
809 AST_FLAG_DEFER_DTMF = (1 << 1),
810 /*! write should be interrupt generator */
811 AST_FLAG_WRITE_INT = (1 << 2),
812 /*! a thread is blocking on this channel */
813 AST_FLAG_BLOCKING = (1 << 3),
814 /*! This is a zombie channel */
815 AST_FLAG_ZOMBIE = (1 << 4),
816 /*! There is an exception pending */
817 AST_FLAG_EXCEPTION = (1 << 5),
818 /*! Listening to moh XXX anthm promises me this will disappear XXX */
819 AST_FLAG_MOH = (1 << 6),
820 /*! This channel is spying on another channel */
821 AST_FLAG_SPYING = (1 << 7),
822 /*! This channel is in a native bridge */
823 AST_FLAG_NBRIDGE = (1 << 8),
824 /*! the channel is in an auto-incrementing dialplan processor,
825 * so when ->priority is set, it will get incremented before
826 * finding the next priority to run */
827 AST_FLAG_IN_AUTOLOOP = (1 << 9),
828 /*! This is an outgoing call */
829 AST_FLAG_OUTGOING = (1 << 10),
830 /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */
831 AST_FLAG_IN_DTMF = (1 << 12),
832 /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is
833 * currently being emulated */
834 AST_FLAG_EMULATE_DTMF = (1 << 13),
835 /*! This is set to tell the channel not to generate DTMF begin frames, and
836 * to instead only generate END frames. */
837 AST_FLAG_END_DTMF_ONLY = (1 << 14),
838 /* OBSOLETED in favor of AST_CAUSE_ANSWERED_ELSEWHERE
839 Flag to show channels that this call is hangup due to the fact that the call
840 was indeed answered, but in another channel */
841 /* AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), */
842 /*! This flag indicates that on a masquerade, an active stream should not
844 AST_FLAG_MASQ_NOSTREAM = (1 << 16),
845 /*! This flag indicates that the hangup exten was run when the bridge terminated,
846 * a message aimed at preventing a subsequent hangup exten being run at the pbx_run
848 AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17),
849 /*! This flag indicates that the hangup exten should NOT be run when the
850 * bridge terminates, this will allow the hangup in the pbx loop to be run instead.
852 AST_FLAG_BRIDGE_HANGUP_DONT = (1 << 18),
853 /*! Disable certain workarounds. This reintroduces certain bugs, but allows
854 * some non-traditional dialplans (like AGI) to continue to function.
856 AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20),
859 /*! \brief ast_bridge_config flags */
861 AST_FEATURE_PLAY_WARNING = (1 << 0),
862 AST_FEATURE_REDIRECT = (1 << 1),
863 AST_FEATURE_DISCONNECT = (1 << 2),
864 AST_FEATURE_ATXFER = (1 << 3),
865 AST_FEATURE_AUTOMON = (1 << 4),
866 AST_FEATURE_PARKCALL = (1 << 5),
867 AST_FEATURE_AUTOMIXMON = (1 << 6),
868 AST_FEATURE_NO_H_EXTEN = (1 << 7),
869 AST_FEATURE_WARNING_ACTIVE = (1 << 8),
872 /*! \brief bridge configuration */
873 struct ast_bridge_config {
874 struct ast_flags features_caller;
875 struct ast_flags features_callee;
876 struct timeval start_time;
877 struct timeval nexteventts;
878 struct timeval feature_start_time;
883 const char *warning_sound;
884 const char *end_sound;
885 const char *start_sound;
887 void (* end_bridge_callback)(void *); /*!< A callback that is called after a bridge attempt */
888 void *end_bridge_callback_data; /*!< Data passed to the callback */
889 /*! If the end_bridge_callback_data refers to a channel which no longer is going to
890 * exist when the end_bridge_callback is called, then it needs to be fixed up properly
892 void (*end_bridge_callback_data_fixup)(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator);
897 struct outgoing_helper {
902 const char *cid_name;
904 struct ast_variable *vars;
905 struct ast_channel *parent_channel;
910 * Soft hangup requested by device or other internal reason.
911 * Actual hangup needed.
913 AST_SOFTHANGUP_DEV = (1 << 0),
915 * Used to break the normal frame flow so an async goto can be
916 * done instead of actually hanging up.
918 AST_SOFTHANGUP_ASYNCGOTO = (1 << 1),
920 * Soft hangup requested by system shutdown. Actual hangup
923 AST_SOFTHANGUP_SHUTDOWN = (1 << 2),
925 * Used to break the normal frame flow after a timeout so an
926 * implicit async goto can be done to the 'T' exten if it exists
927 * instead of actually hanging up. If the exten does not exist
928 * then actually hangup.
930 AST_SOFTHANGUP_TIMEOUT = (1 << 3),
932 * Soft hangup requested by application/channel-driver being
933 * unloaded. Actual hangup needed.
935 AST_SOFTHANGUP_APPUNLOAD = (1 << 4),
937 * Soft hangup requested by non-associated party. Actual hangup
940 AST_SOFTHANGUP_EXPLICIT = (1 << 5),
942 * Used to break a bridge so the channel can be spied upon
943 * instead of actually hanging up.
945 AST_SOFTHANGUP_UNBRIDGE = (1 << 6),
949 * \brief All softhangup flags.
951 * This can be used as an argument to ast_channel_clear_softhangup()
952 * to clear all softhangup flags from a channel.
954 AST_SOFTHANGUP_ALL = (0xFFFFFFFF)
958 /*! \brief Channel reload reasons for manager events at load or reload of configuration */
959 enum channelreloadreason {
961 CHANNEL_MODULE_RELOAD,
963 CHANNEL_MANAGER_RELOAD,
967 * \note None of the datastore API calls lock the ast_channel they are using.
968 * So, the channel should be locked before calling the functions that
969 * take a channel argument.
973 * \brief Create a channel data store object
974 * \deprecated You should use the ast_datastore_alloc() generic function instead.
975 * \version 1.6.1 deprecated
977 struct ast_datastore * attribute_malloc ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
978 __attribute__((deprecated));
981 * \brief Free a channel data store object
982 * \deprecated You should use the ast_datastore_free() generic function instead.
983 * \version 1.6.1 deprecated
985 int ast_channel_datastore_free(struct ast_datastore *datastore)
986 __attribute__((deprecated));
988 /*! \brief Inherit datastores from a parent to a child. */
989 int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to);
992 * \brief Add a datastore to a channel
994 * \note The channel should be locked before calling this function.
997 * \retval non-zero failure
999 int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore);
1002 * \brief Remove a datastore from a channel
1004 * \note The channel should be locked before calling this function.
1007 * \retval non-zero failure
1009 int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore);
1012 * \brief Find a datastore on a channel
1014 * \note The channel should be locked before calling this function.
1016 * \note The datastore returned from this function must not be used if the
1017 * reference to the channel is released.
1019 * \retval pointer to the datastore if found
1020 * \retval NULL if not found
1022 struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid);
1025 * \brief Create a channel structure
1028 * \retval NULL failure
1029 * \retval non-NULL successfully allocated channel
1031 * \note Absolutely _NO_ channel locks should be held before calling this function.
1032 * \note By default, new channels are set to the "s" extension
1033 * and "default" context.
1035 struct ast_channel * attribute_malloc __attribute__((format(printf, 13, 14)))
1036 __ast_channel_alloc(int needqueue, int state, const char *cid_num,
1037 const char *cid_name, const char *acctcode,
1038 const char *exten, const char *context,
1039 const char *linkedid, const int amaflag,
1040 const char *file, int line, const char *function,
1041 const char *name_fmt, ...);
1044 * \brief Create a channel structure
1046 * \retval NULL failure
1047 * \retval non-NULL successfully allocated channel
1049 * \note Absolutely _NO_ channel locks should be held before calling this function.
1050 * \note By default, new channels are set to the "s" extension
1051 * and "default" context.
1053 #define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, ...) \
1054 __ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, \
1055 __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
1057 #if defined(REF_DEBUG) || defined(__AST_DEBUG_MALLOC)
1059 * \brief Create a fake channel structure
1061 * \retval NULL failure
1062 * \retval non-NULL successfully allocated channel
1064 * \note This function should ONLY be used to create a fake channel
1065 * that can then be populated with data for use in variable
1066 * substitution when a real channel does not exist.
1068 * \note The created dummy channel should be destroyed by
1069 * ast_channel_unref(). Using ast_channel_release() needlessly
1070 * grabs the channel container lock and can cause a deadlock as
1071 * a result. Also grabbing the channel container lock reduces
1072 * system performance.
1074 #define ast_dummy_channel_alloc() __ast_dummy_channel_alloc(__FILE__, __LINE__, __PRETTY_FUNCTION__)
1075 struct ast_channel *__ast_dummy_channel_alloc(const char *file, int line, const char *function);
1078 * \brief Create a fake channel structure
1080 * \retval NULL failure
1081 * \retval non-NULL successfully allocated channel
1083 * \note This function should ONLY be used to create a fake channel
1084 * that can then be populated with data for use in variable
1085 * substitution when a real channel does not exist.
1087 * \note The created dummy channel should be destroyed by
1088 * ast_channel_unref(). Using ast_channel_release() needlessly
1089 * grabs the channel container lock and can cause a deadlock as
1090 * a result. Also grabbing the channel container lock reduces
1091 * system performance.
1093 struct ast_channel *ast_dummy_channel_alloc(void);
1097 * \brief Queue one or more frames to a channel's frame queue
1099 * \param chan the channel to queue the frame(s) on
1100 * \param f the frame(s) to queue. Note that the frame(s) will be duplicated
1101 * by this function. It is the responsibility of the caller to handle
1102 * freeing the memory associated with the frame(s) being passed if
1106 * \retval non-zero failure
1108 int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f);
1111 * \brief Queue one or more frames to the head of a channel's frame queue
1113 * \param chan the channel to queue the frame(s) on
1114 * \param f the frame(s) to queue. Note that the frame(s) will be duplicated
1115 * by this function. It is the responsibility of the caller to handle
1116 * freeing the memory associated with the frame(s) being passed if
1120 * \retval non-zero failure
1122 int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f);
1125 * \brief Queue a hangup frame
1127 * \note The channel does not need to be locked before calling this function.
1129 int ast_queue_hangup(struct ast_channel *chan);
1132 * \brief Queue a hangup frame with hangupcause set
1134 * \note The channel does not need to be locked before calling this function.
1135 * \param[in] chan channel to queue frame onto
1136 * \param[in] cause the hangup cause
1137 * \return 0 on success, -1 on error
1140 int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause);
1143 * \brief Queue a control frame with payload
1145 * \param chan channel to queue frame onto
1146 * \param control type of control frame
1148 * \note The channel does not need to be locked before calling this function.
1150 * \retval zero on success
1151 * \retval non-zero on failure
1153 int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control);
1156 * \brief Queue a control frame with payload
1158 * \param chan channel to queue frame onto
1159 * \param control type of control frame
1160 * \param data pointer to payload data to be included in frame
1161 * \param datalen number of bytes of payload data
1164 * \retval non-zero failure
1167 * The supplied payload data is copied into the frame, so the caller's copy
1168 * is not modified nor freed, and the resulting frame will retain a copy of
1169 * the data even if the caller frees their local copy.
1171 * \note This method should be treated as a 'network transport'; in other
1172 * words, your frames may be transferred across an IAX2 channel to another
1173 * system, which may be a different endianness than yours. Because of this,
1174 * you should ensure that either your frames will never be expected to work
1175 * across systems, or that you always put your payload data into 'network byte
1176 * order' before calling this function.
1178 * \note The channel does not need to be locked before calling this function.
1180 int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control,
1181 const void *data, size_t datalen);
1184 * \brief Change channel name
1186 * \pre Absolutely all channels _MUST_ be unlocked before calling this function.
1188 * \param chan the channel to change the name of
1189 * \param newname the name to change to
1193 * \note this function must _NEVER_ be used when any channels are locked
1194 * regardless if it is the channel who's name is being changed or not because
1195 * it invalidates our channel container locking order... lock container first,
1196 * then the individual channels, never the other way around.
1198 void ast_change_name(struct ast_channel *chan, const char *newname);
1201 * \brief Unlink and release reference to a channel
1203 * This function will unlink the channel from the global channels container
1204 * if it is still there and also release the current reference to the channel.
1206 * \return NULL, convenient for clearing invalid pointers
1207 * \note Absolutely _NO_ channel locks should be held before calling this function.
1211 struct ast_channel *ast_channel_release(struct ast_channel *chan);
1214 * \brief Requests a channel
1216 * \param type type of channel to request
1217 * \param request_cap Format capabilities for requested channel
1218 * \param requestor channel asking for data
1219 * \param addr destination of the call
1220 * \param cause Cause of failure
1223 * Request a channel of a given type, with addr as optional information used
1224 * by the low level module
1226 * \retval NULL failure
1227 * \retval non-NULL channel on success
1229 struct ast_channel *ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_channel *requestor, const char *addr, int *cause);
1232 * \brief Request a channel of a given type, with data as optional information used
1233 * by the low level module and attempt to place a call on it
1235 * \param type type of channel to request
1236 * \param format capabilities for requested channel
1237 * \param requestor channel asking for data
1238 * \param addr destination of the call
1239 * \param timeout maximum amount of time to wait for an answer
1240 * \param reason why unsuccessful (if unsuccessful)
1241 * \param cid_num Caller-ID Number
1242 * \param cid_name Caller-ID Name (ascii)
1244 * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
1245 * to know if the call was answered or not.
1247 struct ast_channel *ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr,
1248 int timeout, int *reason, const char *cid_num, const char *cid_name);
1251 * \brief Request a channel of a given type, with data as optional information used
1252 * by the low level module and attempt to place a call on it
1253 * \param type type of channel to request
1254 * \param format capabilities for requested channel
1255 * \param requestor channel requesting data
1256 * \param addr destination of the call
1257 * \param timeout maximum amount of time to wait for an answer
1258 * \param reason why unsuccessful (if unsuccessful)
1259 * \param cid_num Caller-ID Number
1260 * \param cid_name Caller-ID Name (ascii)
1261 * \param oh Outgoing helper
1262 * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
1263 * to know if the call was answered or not.
1265 struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr,
1266 int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
1269 * \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.
1270 * \param caller in channel that requested orig
1271 * \param orig channel being replaced by the call forward channel
1272 * \param timeout maximum amount of time to wait for setup of new forward channel
1273 * \param format capabilities for requested channel
1274 * \param oh outgoing helper used with original channel
1275 * \param outstate reason why unsuccessful (if uncuccessful)
1276 * \return Returns the forwarded call's ast_channel on success or NULL on failure
1278 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);
1281 * \brief Register a channel technology (a new channel driver)
1282 * Called by a channel module to register the kind of channels it supports.
1283 * \param tech Structure defining channel technology or "type"
1284 * \return Returns 0 on success, -1 on failure.
1286 int ast_channel_register(const struct ast_channel_tech *tech);
1289 * \brief Unregister a channel technology
1290 * \param tech Structure defining channel technology or "type" that was previously registered
1291 * \return No return value.
1293 void ast_channel_unregister(const struct ast_channel_tech *tech);
1296 * \brief Get a channel technology structure by name
1297 * \param name name of technology to find
1298 * \return a pointer to the structure, or NULL if no matching technology found
1300 const struct ast_channel_tech *ast_get_channel_tech(const char *name);
1302 #ifdef CHANNEL_TRACE
1304 * \brief Update the context backtrace if tracing is enabled
1305 * \return Returns 0 on success, -1 on failure
1307 int ast_channel_trace_update(struct ast_channel *chan);
1310 * \brief Enable context tracing in the channel
1311 * \return Returns 0 on success, -1 on failure
1313 int ast_channel_trace_enable(struct ast_channel *chan);
1316 * \brief Disable context tracing in the channel.
1317 * \note Does not remove current trace entries
1318 * \return Returns 0 on success, -1 on failure
1320 int ast_channel_trace_disable(struct ast_channel *chan);
1323 * \brief Whether or not context tracing is enabled
1324 * \return Returns -1 when the trace is enabled. 0 if not.
1326 int ast_channel_trace_is_enabled(struct ast_channel *chan);
1329 * \brief Put the channel backtrace in a string
1330 * \return Returns the amount of lines in the backtrace. -1 on error.
1332 int ast_channel_trace_serialize(struct ast_channel *chan, struct ast_str **out);
1336 * \brief Hang up a channel
1337 * \note Absolutely _NO_ channel locks should be held before calling this function.
1338 * \note This function performs a hard hangup on a channel. Unlike the soft-hangup, this function
1339 * performs all stream stopping, etc, on the channel that needs to end.
1340 * chan is no longer valid after this call.
1341 * \param chan channel to hang up
1342 * \return Returns 0 on success, -1 on failure.
1344 int ast_hangup(struct ast_channel *chan);
1347 * \brief Softly hangup up a channel
1349 * \param chan channel to be soft-hung-up
1350 * \param reason an AST_SOFTHANGUP_* reason code
1353 * Call the protocol layer, but don't destroy the channel structure
1354 * (use this if you are trying to
1355 * safely hangup a channel managed by another thread.
1357 * \note The channel passed to this function does not need to be locked.
1359 * \return Returns 0 regardless
1361 int ast_softhangup(struct ast_channel *chan, int reason);
1364 * \brief Softly hangup up a channel (no channel lock)
1365 * \param chan channel to be soft-hung-up
1366 * \param reason an AST_SOFTHANGUP_* reason code
1368 int ast_softhangup_nolock(struct ast_channel *chan, int reason);
1371 * \brief Clear a set of softhangup flags from a channel
1373 * Never clear a softhangup flag from a channel directly. Instead,
1374 * use this function. This ensures that all aspects of the softhangup
1375 * process are aborted.
1377 * \param chan the channel to clear the flag on
1378 * \param flag the flag or flags to clear
1382 void ast_channel_clear_softhangup(struct ast_channel *chan, int flag);
1385 * \brief Set the source of the hangup in this channel and it's bridge
1387 * \param chan channel to set the field on
1388 * \param source a string describing the source of the hangup for this channel
1393 * Hangupsource is generally the channel name that caused the bridge to be
1394 * hung up, but it can also be other things such as "dialplan/agi"
1395 * This can then be logged in the CDR or CEL
1397 void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force);
1399 /*! \brief Check to see if a channel is needing hang up
1400 * \param chan channel on which to check for hang up
1401 * This function determines if the channel is being requested to be hung up.
1402 * \return Returns 0 if not, or 1 if hang up is requested (including time-out).
1404 int ast_check_hangup(struct ast_channel *chan);
1406 int ast_check_hangup_locked(struct ast_channel *chan);
1409 * \brief Lock the given channel, then request softhangup on the channel with the given causecode
1410 * \param obj channel on which to hang up
1411 * \param causecode cause code to use
1414 int ast_channel_softhangup_withcause_locked(void *obj, int causecode);
1417 * \brief Compare a offset with the settings of when to hang a channel up
1418 * \param chan channel on which to check for hang up
1419 * \param offset offset in seconds from current time
1420 * \return 1, 0, or -1
1422 * This function compares a offset from current time with the absolute time
1423 * out on a channel (when to hang up). If the absolute time out on a channel
1424 * is earlier than current time plus the offset, it returns 1, if the two
1425 * time values are equal, it return 0, otherwise, it return -1.
1426 * \sa ast_channel_cmpwhentohangup_tv()
1427 * \version 1.6.1 deprecated function (only had seconds precision)
1429 int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated));
1432 * \brief Compare a offset with the settings of when to hang a channel up
1433 * \param chan channel on which to check for hangup
1434 * \param offset offset in seconds and microseconds from current time
1435 * \return 1, 0, or -1
1436 * This function compares a offset from current time with the absolute time
1437 * out on a channel (when to hang up). If the absolute time out on a channel
1438 * is earlier than current time plus the offset, it returns 1, if the two
1439 * time values are equal, it return 0, otherwise, it return -1.
1442 int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1445 * \brief Set when to hang a channel up
1447 * \param chan channel on which to check for hang up
1448 * \param offset offset in seconds relative to the current time of when to hang up
1451 * This function sets the absolute time out on a channel (when to hang up).
1453 * \note This function does not require that the channel is locked before
1457 * \sa ast_channel_setwhentohangup_tv()
1458 * \version 1.6.1 deprecated function (only had seconds precision)
1460 void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated));
1463 * \brief Set when to hang a channel up
1465 * \param chan channel on which to check for hang up
1466 * \param offset offset in seconds and useconds relative to the current time of when to hang up
1468 * This function sets the absolute time out on a channel (when to hang up).
1470 * \note This function does not require that the channel is locked before
1476 void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1479 * \brief Answer a channel
1481 * \param chan channel to answer
1484 * This function answers a channel and handles all necessary call
1487 * \note The channel passed does not need to be locked, but is locked
1488 * by the function when needed.
1490 * \note This function will wait up to 500 milliseconds for media to
1491 * arrive on the channel before returning to the caller, so that the
1492 * caller can properly assume the channel is 'ready' for media flow.
1494 * \retval 0 on success
1495 * \retval non-zero on failure
1497 int ast_answer(struct ast_channel *chan);
1500 * \brief Answer a channel
1502 * \param chan channel to answer
1503 * \param cdr_answer flag to control whether any associated CDR should be marked as 'answered'
1505 * This function answers a channel and handles all necessary call
1508 * \note The channel passed does not need to be locked, but is locked
1509 * by the function when needed.
1511 * \note Unlike ast_answer(), this function will not wait for media
1512 * flow to begin. The caller should be careful before sending media
1513 * to the channel before incoming media arrives, as the outgoing
1514 * media may be lost.
1516 * \retval 0 on success
1517 * \retval non-zero on failure
1519 int ast_raw_answer(struct ast_channel *chan, int cdr_answer);
1522 * \brief Answer a channel, with a selectable delay before returning
1524 * \param chan channel to answer
1525 * \param delay maximum amount of time to wait for incoming media
1526 * \param cdr_answer flag to control whether any associated CDR should be marked as 'answered'
1528 * This function answers a channel and handles all necessary call
1531 * \note The channel passed does not need to be locked, but is locked
1532 * by the function when needed.
1534 * \note This function will wait up to 'delay' milliseconds for media to
1535 * arrive on the channel before returning to the caller, so that the
1536 * caller can properly assume the channel is 'ready' for media flow. If
1537 * 'delay' is less than 500, the function will wait up to 500 milliseconds.
1539 * \retval 0 on success
1540 * \retval non-zero on failure
1542 int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer);
1545 * \brief Execute a Gosub call on the channel before a call is placed.
1549 * This is called between ast_request() and ast_call() to
1550 * execute a predial routine on the newly created channel.
1552 * \param chan Channel to execute Gosub.
1553 * \param sub_args Gosub application parameter string.
1555 * \note Absolutely _NO_ channel locks should be held before calling this function.
1557 * \retval 0 on success.
1558 * \retval -1 on error.
1560 int ast_pre_call(struct ast_channel *chan, const char *sub_args);
1563 * \brief Make a call
1564 * \note Absolutely _NO_ channel locks should be held before calling this function.
1565 * \param chan which channel to make the call on
1566 * \param addr destination of the call
1567 * \param timeout time to wait on for connect (Doesn't seem to be used.)
1569 * Place a call, take no longer than timeout ms.
1570 * \retval 0 on success
1571 * \retval -1 on failure
1573 int ast_call(struct ast_channel *chan, const char *addr, int timeout);
1576 * \brief Indicates condition of channel
1577 * \note Absolutely _NO_ channel locks should be held before calling this function.
1578 * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel
1579 * \param chan channel to change the indication
1580 * \param condition which condition to indicate on the channel
1581 * \return Returns 0 on success, -1 on failure
1583 int ast_indicate(struct ast_channel *chan, int condition);
1586 * \brief Indicates condition of channel, with payload
1587 * \note Absolutely _NO_ channel locks should be held before calling this function.
1588 * \note Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class
1589 * \param chan channel to change the indication
1590 * \param condition which condition to indicate on the channel
1591 * \param data pointer to payload data
1592 * \param datalen size of payload data
1593 * \return Returns 0 on success, -1 on failure
1595 int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen);
1597 /* Misc stuff ------------------------------------------------ */
1600 * \brief Wait for input on a channel
1601 * \param chan channel to wait on
1602 * \param ms length of time to wait on the channel
1604 * Wait for input on a channel for a given # of milliseconds (<0 for indefinite).
1605 * \retval < 0 on failure
1606 * \retval 0 if nothing ever arrived
1607 * \retval the # of ms remaining otherwise
1609 int ast_waitfor(struct ast_channel *chan, int ms);
1612 * \brief Should we keep this frame for later?
1614 * There are functions such as ast_safe_sleep which will
1615 * service a channel to ensure that it does not have a
1616 * large backlog of queued frames. When this happens,
1617 * we want to hold on to specific frame types and just drop
1618 * others. This function will tell if the frame we just
1619 * read should be held onto.
1621 * \param frame The frame we just read
1622 * \retval 1 frame should be kept
1623 * \retval 0 frame should be dropped
1625 int ast_is_deferrable_frame(const struct ast_frame *frame);
1628 * \brief Wait for a specified amount of time, looking for hangups
1629 * \param chan channel to wait for
1630 * \param ms length of time in milliseconds to sleep
1632 * Waits for a specified amount of time, servicing the channel as required.
1633 * \return returns -1 on hangup, otherwise 0.
1635 int ast_safe_sleep(struct ast_channel *chan, int ms);
1638 * \brief Wait for a specified amount of time, looking for hangups and a condition argument
1639 * \param chan channel to wait for
1640 * \param ms length of time in milliseconds to sleep
1641 * \param cond a function pointer for testing continue condition
1642 * \param data argument to be passed to the condition test function
1643 * \return returns -1 on hangup, otherwise 0.
1645 * Waits for a specified amount of time, servicing the channel as required. If cond
1646 * returns 0, this function returns.
1648 int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data );
1651 * \brief Waits for activity on a group of channels
1652 * \param chan an array of pointers to channels
1653 * \param n number of channels that are to be waited upon
1654 * \param fds an array of fds to wait upon
1655 * \param nfds the number of fds to wait upon
1656 * \param exception exception flag
1657 * \param outfd fd that had activity on it
1658 * \param ms how long the wait was
1660 * Big momma function here. Wait for activity on any of the n channels, or any of the nfds
1662 * \return Returns the channel with activity, or NULL on error or if an FD
1663 * came first. If the FD came first, it will be returned in outfd, otherwise, outfd
1666 struct ast_channel *ast_waitfor_nandfds(struct ast_channel **chan, int n,
1667 int *fds, int nfds, int *exception, int *outfd, int *ms);
1670 * \brief Waits for input on a group of channels
1671 * Wait for input on an array of channels for a given # of milliseconds.
1672 * \return Return channel with activity, or NULL if none has activity.
1673 * \param chan an array of pointers to channels
1674 * \param n number of channels that are to be waited upon
1675 * \param ms time "ms" is modified in-place, if applicable
1677 struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms);
1680 * \brief Waits for input on an fd
1681 * \note This version works on fd's only. Be careful with it.
1683 int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);
1687 * \brief Reads a frame
1688 * \param chan channel to read a frame from
1689 * \return Returns a frame, or NULL on error. If it returns NULL, you
1690 * best just stop reading frames and assume the channel has been
1693 struct ast_frame *ast_read(struct ast_channel *chan);
1696 * \brief Reads a frame, returning AST_FRAME_NULL frame if audio.
1697 * \param chan channel to read a frame from
1698 * \return Returns a frame, or NULL on error. If it returns NULL, you
1699 * best just stop reading frames and assume the channel has been
1701 * \note Audio is replaced with AST_FRAME_NULL to avoid
1702 * transcode when the resulting audio is not necessary.
1704 struct ast_frame *ast_read_noaudio(struct ast_channel *chan);
1707 * \brief Write a frame to a channel
1708 * This function writes the given frame to the indicated channel.
1709 * \param chan destination channel of the frame
1710 * \param frame frame that will be written
1711 * \return It returns 0 on success, -1 on failure.
1713 int ast_write(struct ast_channel *chan, struct ast_frame *frame);
1716 * \brief Write video frame to a channel
1717 * This function writes the given frame to the indicated channel.
1718 * \param chan destination channel of the frame
1719 * \param frame frame that will be written
1720 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
1722 int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);
1725 * \brief Write text frame to a channel
1726 * This function writes the given frame to the indicated channel.
1727 * \param chan destination channel of the frame
1728 * \param frame frame that will be written
1729 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
1731 int ast_write_text(struct ast_channel *chan, struct ast_frame *frame);
1733 /*! \brief Send empty audio to prime a channel driver */
1734 int ast_prod(struct ast_channel *chan);
1737 * \brief Sets read format on channel chan from capabilities
1738 * Set read format for channel to whichever component of "format" is best.
1739 * \param chan channel to change
1740 * \param formats new formats to pick from for reading
1741 * \return Returns 0 on success, -1 on failure
1743 int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats);
1746 * \brief Sets read format on channel chan
1747 * \param chan channel to change
1748 * \param formats, format to set for reading
1749 * \return Returns 0 on success, -1 on failure
1751 int ast_set_read_format(struct ast_channel *chan, struct ast_format *format);
1754 * \brief Sets read format on channel chan by id
1755 * \param chan channel to change
1756 * \param format id to set for reading, only used for formats without attributes
1757 * \return Returns 0 on success, -1 on failure
1759 int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id);
1762 * \brief Sets write format on channel chan
1763 * Set write format for channel to whichever component of "format" is best.
1764 * \param chan channel to change
1765 * \param formats new formats to pick from for writing
1766 * \return Returns 0 on success, -1 on failure
1768 int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats);
1771 * \brief Sets write format on channel chan
1772 * \param chan channel to change
1773 * \param formats, format to set for writing
1774 * \return Returns 0 on success, -1 on failure
1776 int ast_set_write_format(struct ast_channel *chan, struct ast_format *format);
1779 * \brief Sets write format on channel chan
1780 * \param chan channel to change
1781 * \param format id to set for writing, only used for formats without attributes
1782 * \return Returns 0 on success, -1 on failure
1784 int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id);
1787 * \brief Sends text to a channel
1789 * \param chan channel to act upon
1790 * \param text string of text to send on the channel
1793 * Write text to a display on a channel
1795 * \note The channel does not need to be locked before calling this function.
1797 * \retval 0 on success
1798 * \retval -1 on failure
1800 int ast_sendtext(struct ast_channel *chan, const char *text);
1803 * \brief Receives a text character from a channel
1804 * \param chan channel to act upon
1805 * \param timeout timeout in milliseconds (0 for infinite wait)
1807 * Read a char of text from a channel
1808 * \return 0 on success, -1 on failure
1810 int ast_recvchar(struct ast_channel *chan, int timeout);
1813 * \brief Send a DTMF digit to a channel.
1814 * \param chan channel to act upon
1815 * \param digit the DTMF digit to send, encoded in ASCII
1816 * \param duration the duration of the digit ending in ms
1817 * \return 0 on success, -1 on failure
1819 int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
1822 * \brief Send a DTMF digit to a channel.
1823 * \param chan channel to act upon
1824 * \param digit the DTMF digit to send, encoded in ASCII
1825 * \return 0 on success, -1 on failure
1827 int ast_senddigit_begin(struct ast_channel *chan, char digit);
1830 * \brief Send a DTMF digit to a channel.
1831 * \param chan channel to act upon
1832 * \param digit the DTMF digit to send, encoded in ASCII
1833 * \param duration the duration of the digit ending in ms
1834 * \return Returns 0 on success, -1 on failure
1836 int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration);
1839 * \brief Receives a text string from a channel
1840 * Read a string of text from a channel
1841 * \param chan channel to act upon
1842 * \param timeout timeout in milliseconds (0 for infinite wait)
1843 * \return the received text, or NULL to signify failure.
1845 char *ast_recvtext(struct ast_channel *chan, int timeout);
1848 * \brief Waits for a digit
1849 * \param c channel to wait for a digit on
1850 * \param ms how many milliseconds to wait
1851 * \return Returns <0 on error, 0 on no entry, and the digit on success.
1853 int ast_waitfordigit(struct ast_channel *c, int ms);
1856 * \brief Wait for a digit
1857 * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
1858 * \param c channel to wait for a digit on
1859 * \param ms how many milliseconds to wait
1860 * \param audiofd audio file descriptor to write to if audio frames are received
1861 * \param ctrlfd control file descriptor to monitor for reading
1862 * \return Returns 1 if ctrlfd becomes available
1864 int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int ctrlfd);
1867 * \brief Reads multiple digits
1868 * \param c channel to read from
1869 * \param s string to read in to. Must be at least the size of your length
1870 * \param len how many digits to read (maximum)
1871 * \param timeout how long to timeout between digits
1872 * \param rtimeout timeout to wait on the first digit
1873 * \param enders digits to end the string
1875 * Read in a digit string "s", max length "len", maximum timeout between
1876 * digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout
1877 * for the first digit.
1878 * \return Returns 0 on normal return, or 1 on a timeout. In the case of
1879 * a timeout, any digits that were read before the timeout will still be available in s.
1880 * RETURNS 2 in full version when ctrlfd is available, NOT 1
1882 int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders);
1883 int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd);
1885 /*! \brief Report DTMF on channel 0 */
1886 #define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0)
1887 /*! \brief Report DTMF on channel 1 */
1888 #define AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1)
1889 /*! \brief Return all voice frames on channel 0 */
1890 #define AST_BRIDGE_REC_CHANNEL_0 (1 << 2)
1891 /*! \brief Return all voice frames on channel 1 */
1892 #define AST_BRIDGE_REC_CHANNEL_1 (1 << 3)
1893 /*! \brief Ignore all signal frames except NULL */
1894 #define AST_BRIDGE_IGNORE_SIGS (1 << 4)
1898 * \brief Makes two channel formats compatible
1899 * \param c0 first channel to make compatible
1900 * \param c1 other channel to make compatible
1902 * Set two channels to compatible formats -- call before ast_channel_bridge in general.
1903 * \return Returns 0 on success and -1 if it could not be done
1905 int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1);
1908 * \brief Bridge two channels together (early)
1909 * \param c0 first channel to bridge
1910 * \param c1 second channel to bridge
1912 * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
1913 * \return Returns 0 on success and -1 if it could not be done
1915 int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
1918 * \brief Bridge two channels together
1919 * \param c0 first channel to bridge
1920 * \param c1 second channel to bridge
1921 * \param config config for the channels
1922 * \param fo destination frame(?)
1923 * \param rc destination channel(?)
1925 * Bridge two channels (c0 and c1) together. If an important frame occurs, we return that frame in
1926 * *rf (remember, it could be NULL) and which channel (0 or 1) in rc
1928 /* int ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc); */
1929 int ast_channel_bridge(struct ast_channel *c0,struct ast_channel *c1,
1930 struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc);
1933 * \brief Weird function made for call transfers
1935 * \param original channel to make a copy of
1936 * \param clone copy of the original channel
1939 * This is a very strange and freaky function used primarily for transfer. Suppose that
1940 * "original" and "clone" are two channels in random situations. This function takes
1941 * the guts out of "clone" and puts them into the "original" channel, then alerts the
1942 * channel driver of the change, asking it to fixup any private information (like the
1943 * p->owner pointer) that is affected by the change. The physical layer of the original
1944 * channel is hung up.
1946 * \note Neither channel passed here should be locked before
1947 * calling this function. This function performs deadlock
1948 * avoidance involving these two channels.
1950 int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone);
1953 * \brief Setup a masquerade to transfer a call.
1956 * \param target_chan Target of the call transfer. (Masquerade original channel)
1957 * \param target_id New connected line information for the target channel.
1958 * \param target_held TRUE if the target call is on hold.
1959 * \param transferee_chan Transferee of the call transfer. (Masquerade clone channel)
1960 * \param transferee_id New connected line information for the transferee channel.
1961 * \param transferee_held TRUE if the transferee call is on hold.
1964 * Party A - Transferee
1965 * Party B - Transferer
1966 * Party C - Target of transfer
1968 * Party B transfers A to C.
1970 * Party A is connected to bridged channel B1.
1971 * Party B is connected to channels C1 and C2.
1972 * Party C is connected to bridged channel B2.
1974 * Party B -- C1 == B1 -- Party A
1977 * Party B -- C2 == B2 -- Party C
1979 * Bridged channel B1 is masqueraded into channel C2. Where B1
1980 * is the masquerade clone channel and C2 is the masquerade
1983 * \see ast_channel_masquerade()
1985 * \note Has the same locking requirements as ast_channel_masquerade().
1987 * \retval 0 on success.
1988 * \retval -1 on error.
1990 int ast_channel_transfer_masquerade(
1991 struct ast_channel *target_chan,
1992 const struct ast_party_connected_line *target_id,
1994 struct ast_channel *transferee_chan,
1995 const struct ast_party_connected_line *transferee_id,
1996 int transferee_held);
1999 * \brief Gives the string form of a given cause code.
2001 * \param state cause to get the description of
2002 * \return the text form of the binary cause code given
2004 const char *ast_cause2str(int state) attribute_pure;
2007 * \brief Convert the string form of a cause code to a number
2009 * \param name string form of the cause
2010 * \return the cause code
2012 int ast_str2cause(const char *name) attribute_pure;
2015 * \brief Gives the string form of a given channel state
2017 * \param ast_channel_state state to get the name of
2018 * \return the text form of the binary state given
2020 const char *ast_state2str(enum ast_channel_state);
2023 * \brief Gives the string form of a given transfer capability
2025 * \param transfercapability transfer capability to get the name of
2026 * \return the text form of the binary transfer capability
2028 char *ast_transfercapability2str(int transfercapability) attribute_const;
2031 * Options: Some low-level drivers may implement "options" allowing fine tuning of the
2032 * low level channel. See frame.h for options. Note that many channel drivers may support
2033 * none or a subset of those features, and you should not count on this if you want your
2034 * asterisk application to be portable. They're mainly useful for tweaking performance
2038 * \brief Sets an option on a channel
2040 * \param channel channel to set options on
2041 * \param option option to change
2042 * \param data data specific to option
2043 * \param datalen length of the data
2044 * \param block blocking or not
2046 * Set an option on a channel (see frame.h), optionally blocking awaiting the reply
2047 * \return 0 on success and -1 on failure
2049 int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
2052 * \brief Pick the best codec
2054 * \param capabilities to pick best codec out of
2055 * \param result stucture to store the best codec in.
2056 * \retval on success, pointer to result structure
2057 * \retval on failure, NULL
2059 struct ast_format *ast_best_codec(struct ast_format_cap *cap, struct ast_format *result);
2063 * \brief Checks the value of an option
2065 * Query the value of an option
2066 * Works similarly to setoption except only reads the options.
2068 int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block);
2071 * \brief Checks for HTML support on a channel
2072 * \return 0 if channel does not support HTML or non-zero if it does
2074 int ast_channel_supports_html(struct ast_channel *channel);
2077 * \brief Sends HTML on given channel
2078 * Send HTML or URL on link.
2079 * \return 0 on success or -1 on failure
2081 int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen);
2084 * \brief Sends a URL on a given link
2086 * \return 0 on success or -1 on failure
2088 int ast_channel_sendurl(struct ast_channel *channel, const char *url);
2091 * \brief Defers DTMF so that you only read things like hangups and audio.
2092 * \return non-zero if channel was already DTMF-deferred or
2093 * 0 if channel is just now being DTMF-deferred
2095 int ast_channel_defer_dtmf(struct ast_channel *chan);
2097 /*! Undo defer. ast_read will return any DTMF characters that were queued */
2098 void ast_channel_undefer_dtmf(struct ast_channel *chan);
2100 /*! Initiate system shutdown -- prevents new channels from being allocated.
2101 * \param hangup If "hangup" is non-zero, all existing channels will receive soft
2103 void ast_begin_shutdown(int hangup);
2105 /*! Cancels an existing shutdown and returns to normal operation */
2106 void ast_cancel_shutdown(void);
2108 /*! \return number of channels available for lookup */
2109 int ast_active_channels(void);
2111 /*! \return the number of channels not yet destroyed */
2112 int ast_undestroyed_channels(void);
2114 /*! \return non-zero if Asterisk is being shut down */
2115 int ast_shutting_down(void);
2117 /*! Activate a given generator */
2118 int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);
2120 /*! Deactivate an active generator */
2121 void ast_deactivate_generator(struct ast_channel *chan);
2124 * \brief Set caller ID number, name and ANI and generate AMI event.
2126 * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead.
2127 * \note The channel does not need to be locked before calling this function.
2129 void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani);
2132 * \brief Set the caller id information in the Asterisk channel
2135 * \param chan Asterisk channel to set caller id information
2136 * \param caller Caller id information
2137 * \param update What caller information to update. NULL if all.
2141 * \note The channel does not need to be locked before calling this function.
2143 void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2146 * \brief Set the caller id information in the Asterisk channel and generate an AMI event
2147 * if the caller id name or number changed.
2150 * \param chan Asterisk channel to set caller id information
2151 * \param caller Caller id information
2152 * \param update What caller information to update. NULL if all.
2156 * \note The channel does not need to be locked before calling this function.
2158 void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2160 /*! Set the file descriptor on the channel */
2161 void ast_channel_set_fd(struct ast_channel *chan, int which, int fd);
2163 /*! Add a channel to an optimized waitfor */
2164 void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1);
2166 /*! Delete a channel from an optimized waitfor */
2167 void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1);
2169 /*! Start a tone going */
2170 int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2171 /*! Stop a tone from playing */
2172 void ast_tonepair_stop(struct ast_channel *chan);
2173 /*! Play a tone pair for a given amount of time */
2174 int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2177 * \brief Automatically service a channel for us...
2180 * \retval -1 failure, or the channel is already being autoserviced
2182 int ast_autoservice_start(struct ast_channel *chan);
2185 * \brief Stop servicing a channel for us...
2187 * \note if chan is locked prior to calling ast_autoservice_stop, it
2188 * is likely that there will be a deadlock between the thread that calls
2189 * ast_autoservice_stop and the autoservice thread. It is important
2190 * that chan is not locked prior to this call
2194 * \retval -1 error, or the channel has been hungup
2196 int ast_autoservice_stop(struct ast_channel *chan);
2199 * \brief Ignore certain frame types
2200 * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames
2201 * while a channel is in autoservice and queue them up when taken out of
2202 * autoservice. When this is not desireable, this API may be used to
2203 * cause the channel to ignore those frametypes after the channel is put
2204 * into autoservice, but before autoservice is stopped.
2206 * \retval -1 channel is not in autoservice
2208 int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype);
2211 * \brief Enable or disable timer ticks for a channel
2214 * \param rate number of timer ticks per second
2215 * \param func callback function
2219 * If timers are supported, force a scheduled expiration on the
2220 * timer fd, at which point we call the callback function / data
2222 * \note Call this function with a rate of 0 to turn off the timer ticks
2224 * \version 1.6.1 changed samples parameter to rate, accomodates new timing methods
2226 int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data);
2229 * \brief Transfer a channel (if supported).
2230 * \retval -1 on error
2231 * \retval 0 if not supported
2232 * \retval 1 if supported and requested
2233 * \param chan current channel
2234 * \param dest destination extension for transfer
2236 int ast_transfer(struct ast_channel *chan, char *dest);
2239 * \brief Start masquerading a channel
2240 * \note absolutely _NO_ channel locks should be held before calling this function.
2242 * XXX This is a seriously whacked out operation. We're essentially putting the guts of
2243 * the clone channel into the original channel. Start by killing off the original
2244 * channel's backend. I'm not sure we're going to keep this function, because
2245 * while the features are nice, the cost is very high in terms of pure nastiness. XXX
2246 * \param chan Channel to masquerade
2248 int ast_do_masquerade(struct ast_channel *chan);
2251 * \brief Find bridged channel
2253 * \note This function does _not_ return a reference to the bridged channel.
2254 * The reason for this is mostly historical. It _should_ return a reference,
2255 * but it will take a lot of work to make the code base account for that.
2256 * So, for now, the old rules still apply for how to handle this function.
2257 * If this function is being used from the channel thread that owns the channel,
2258 * then a reference is already held, and channel locking is not required to
2259 * guarantee that the channel will stay around. If this function is used
2260 * outside of the associated channel thread, the channel parameter 'chan'
2261 * MUST be locked before calling this function. Also, 'chan' must remain locked
2262 * for the entire time that the result of this function is being used.
2264 * \param chan Current channel
2266 * \return A pointer to the bridged channel
2268 struct ast_channel *ast_bridged_channel(struct ast_channel *chan);
2271 * \brief Inherits channel variable from parent to child channel
2272 * \param parent Parent channel
2273 * \param child Child channel
2276 * Scans all channel variables in the parent channel, looking for those
2277 * that should be copied into the child channel.
2278 * Variables whose names begin with a single '_' are copied into the
2279 * child channel with the prefix removed.
2280 * Variables whose names begin with '__' are copied into the child
2281 * channel with their names unchanged.
2283 void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child);
2286 * \brief adds a list of channel variables to a channel
2287 * \param chan the channel
2288 * \param vars a linked list of variables
2291 * Variable names can be for a regular channel variable or a dialplan function
2292 * that has the ability to be written to.
2294 void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars);
2297 * \brief An opaque 'object' structure use by silence generators on channels.
2299 struct ast_silence_generator;
2302 * \brief Starts a silence generator on the given channel.
2303 * \param chan The channel to generate silence on
2304 * \return An ast_silence_generator pointer, or NULL if an error occurs
2307 * This function will cause SLINEAR silence to be generated on the supplied
2308 * channel until it is disabled; if the channel cannot be put into SLINEAR
2309 * mode then the function will fail.
2312 * The pointer returned by this function must be preserved and passed to
2313 * ast_channel_stop_silence_generator when you wish to stop the silence
2316 struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_channel *chan);
2319 * \brief Stops a previously-started silence generator on the given channel.
2320 * \param chan The channel to operate on
2321 * \param state The ast_silence_generator pointer return by a previous call to
2322 * ast_channel_start_silence_generator.
2326 * This function will stop the operating silence generator and return the channel
2327 * to its previous write format.
2329 void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state);
2332 * \brief Check if the channel can run in internal timing mode.
2333 * \param chan The channel to check
2337 * This function will return 1 if internal timing is enabled and the timing
2338 * device is available.
2340 int ast_internal_timing_enabled(struct ast_channel *chan);
2342 /* Misc. functions below */
2345 * \brief if fd is a valid descriptor, set *pfd with the descriptor
2346 * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the
2347 * return value to the index into the array)
2349 static inline int ast_add_fd(struct pollfd *pfd, int fd)
2352 pfd->events = POLLIN | POLLPRI;
2356 /*! \brief Helper function for migrating select to poll */
2357 static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
2366 for (x = *start; x < maximum; x++)
2367 if (pfds[x].fd == fd) {
2370 return pfds[x].revents;
2375 /*! \brief Retrieves the current T38 state of a channel */
2376 static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
2378 enum ast_t38_state state = T38_STATE_UNAVAILABLE;
2379 int datalen = sizeof(state);
2381 ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0);
2386 #define CHECK_BLOCKING(c) do { \
2387 if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) {\
2388 ast_debug(1, "Thread %ld Blocking '%s', already blocked by thread %ld in procedure %s\n", (long) pthread_self(), ast_channel_name(c), (long) ast_channel_blocker(c), ast_channel_blockproc(c)); \
2390 ast_channel_blocker_set((c), pthread_self()); \
2391 ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
2392 ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
2395 ast_group_t ast_get_group(const char *s);
2397 /*! \brief print call- and pickup groups into buffer */
2398 char *ast_print_group(char *buf, int buflen, ast_group_t group);
2401 * \brief Convert enum channelreloadreason to text string for manager event
2402 * \param reason The reason for reload (manager, cli, start etc)
2404 const char *channelreloadreason2txt(enum channelreloadreason reason);
2406 /*! \brief return an ast_variable list of channeltypes */
2407 struct ast_variable *ast_channeltype_list(void);
2410 * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
2411 * \param reason The integer argument, usually taken from AST_CONTROL_ macros
2412 * \return char pointer explaining the code
2414 const char *ast_channel_reason2str(int reason);
2416 /*! \brief channel group info */
2417 struct ast_group_info {
2418 struct ast_channel *chan;
2421 AST_LIST_ENTRY(ast_group_info) group_list;
2424 #define ast_channel_lock(chan) ao2_lock(chan)
2425 #define ast_channel_unlock(chan) ao2_unlock(chan)
2426 #define ast_channel_trylock(chan) ao2_trylock(chan)
2429 * \brief Lock two channels.
2431 #define ast_channel_lock_both(chan1, chan2) do { \
2432 ast_channel_lock(chan1); \
2433 while (ast_channel_trylock(chan2)) { \
2434 ast_channel_unlock(chan1); \
2436 ast_channel_lock(chan1); \
2441 * \brief Increase channel reference count
2443 * \param c the channel
2449 #define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); })
2452 * \brief Decrease channel reference count
2454 * \param c the channel
2456 * \retval NULL always
2460 #define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
2462 /*! Channel Iterating @{ */
2465 * \brief A channel iterator
2467 * This is an opaque type.
2469 struct ast_channel_iterator;
2472 * \brief Destroy a channel iterator
2474 * \param i the itereator to destroy
2477 * This function is used to destroy a channel iterator that was retrieved by
2478 * using one of the channel_iterator_xxx_new() functions.
2480 * \return NULL, for convenience to clear out the pointer to the iterator that
2481 * was just destroyed.
2485 struct ast_channel_iterator *ast_channel_iterator_destroy(struct ast_channel_iterator *i);
2488 * \brief Create a new channel iterator based on extension
2490 * \param exten The extension that channels must be in
2491 * \param context The context that channels must be in
2494 * After creating an iterator using this function, the ast_channel_iterator_next()
2495 * function can be used to iterate through all channels that are currently
2496 * in the specified context and extension.
2498 * \note You must call ast_channel_iterator_destroy() when done.
2500 * \retval NULL on failure
2501 * \retval a new channel iterator based on the specified parameters
2505 struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context);
2508 * \brief Create a new channel iterator based on name
2510 * \param name channel name or channel uniqueid to match
2511 * \param name_len number of characters in the channel name to match on. This
2512 * would be used to match based on name prefix. If matching on the full
2513 * channel name is desired, then this parameter should be 0.
2516 * After creating an iterator using this function, the ast_channel_iterator_next()
2517 * function can be used to iterate through all channels that exist that have
2518 * the specified name or name prefix.
2520 * \note You must call ast_channel_iterator_destroy() when done.
2522 * \retval NULL on failure
2523 * \retval a new channel iterator based on the specified parameters
2527 struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name, size_t name_len);
2530 * \brief Create a new channel iterator
2533 * After creating an iterator using this function, the ast_channel_iterator_next()
2534 * function can be used to iterate through all channels that exist.
2536 * \note You must call ast_channel_iterator_destroy() when done.
2538 * \retval NULL on failure
2539 * \retval a new channel iterator
2543 struct ast_channel_iterator *ast_channel_iterator_all_new(void);
2546 * \brief Get the next channel for a channel iterator
2548 * \param i the channel iterator that was created using one of the
2549 * channel_iterator_xxx_new() functions.
2552 * This function should be used to iterate through all channels that match a
2553 * specified set of parameters that were provided when the iterator was created.
2555 * \retval the next channel that matches the parameters used when the iterator
2557 * \retval NULL, if no more channels match the iterator parameters.
2561 struct ast_channel *ast_channel_iterator_next(struct ast_channel_iterator *i);
2563 /*! @} End channel iterator definitions. */
2566 * \brief Call a function with every active channel
2569 * This function executes a callback one time for each active channel on the
2570 * system. The channel is provided as an argument to the function.
2572 * \note Absolutely _NO_ channel locks should be held before calling this function.
2575 struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
2576 void *data, int ao2_flags);
2578 /*! @{ Channel search functions */
2581 * \brief Find a channel by name
2583 * \param name the name or uniqueid of the channel to search for
2586 * Find a channel that has the same name as the provided argument.
2588 * \retval a channel with the name specified by the argument
2589 * \retval NULL if no channel was found
2593 struct ast_channel *ast_channel_get_by_name(const char *name);
2596 * \brief Find a channel by a name prefix
2598 * \param name The channel name or uniqueid prefix to search for
2599 * \param name_len Only search for up to this many characters from the name
2602 * Find a channel that has the same name prefix as specified by the arguments.
2604 * \retval a channel with the name prefix specified by the arguments
2605 * \retval NULL if no channel was found
2609 struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
2612 * \brief Find a channel by extension and context
2614 * \param exten the extension to search for
2615 * \param context the context to search for
2618 * Return a channel that is currently at the specified extension and context.
2620 * \retval a channel that is at the specified extension and context
2621 * \retval NULL if no channel was found
2625 struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
2627 /*! @} End channel search functions. */
2630 \brief propagate the linked id between chan and peer
2632 void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer);
2636 * \brief Initialize the given name structure.
2639 * \param init Name structure to initialize.
2643 void ast_party_name_init(struct ast_party_name *init);
2646 * \brief Copy the source party name information to the destination party name.
2649 * \param dest Destination party name
2650 * \param src Source party name
2654 void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src);
2657 * \brief Initialize the given party name structure using the given guide
2658 * for a set update operation.
2662 * The initialization is needed to allow a set operation to know if a
2663 * value needs to be updated. Simple integers need the guide's original
2664 * value in case the set operation is not trying to set a new value.
2665 * String values are simply set to NULL pointers if they are not going
2668 * \param init Party name structure to initialize.
2669 * \param guide Source party name to use as a guide in initializing.
2673 void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide);
2676 * \brief Set the source party name information into the destination party name.
2679 * \param dest The name one wishes to update
2680 * \param src The new name values to update the dest
2684 void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src);
2687 * \brief Destroy the party name contents
2690 * \param doomed The party name to destroy.
2694 void ast_party_name_free(struct ast_party_name *doomed);
2697 * \brief Initialize the given number structure.
2700 * \param init Number structure to initialize.
2704 void ast_party_number_init(struct ast_party_number *init);
2707 * \brief Copy the source party number information to the destination party number.
2710 * \param dest Destination party number
2711 * \param src Source party number
2715 void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src);
2718 * \brief Initialize the given party number structure using the given guide
2719 * for a set update operation.
2723 * The initialization is needed to allow a set operation to know if a
2724 * value needs to be updated. Simple integers need the guide's original
2725 * value in case the set operation is not trying to set a new value.
2726 * String values are simply set to NULL pointers if they are not going
2729 * \param init Party number structure to initialize.
2730 * \param guide Source party number to use as a guide in initializing.
2734 void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide);
2737 * \brief Set the source party number information into the destination party number.
2740 * \param dest The number one wishes to update
2741 * \param src The new number values to update the dest
2745 void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src);
2748 * \brief Destroy the party number contents
2751 * \param doomed The party number to destroy.
2755 void ast_party_number_free(struct ast_party_number *doomed);
2759 * \brief Initialize the given subaddress structure.
2761 * \param init Subaddress structure to initialize.
2765 void ast_party_subaddress_init(struct ast_party_subaddress *init);
2769 * \brief Copy the source party subaddress information to the destination party subaddress.
2771 * \param dest Destination party subaddress
2772 * \param src Source party subaddress
2776 void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
2780 * \brief Initialize the given party subaddress structure using the given guide
2781 * for a set update operation.
2784 * The initialization is needed to allow a set operation to know if a
2785 * value needs to be updated. Simple integers need the guide's original
2786 * value in case the set operation is not trying to set a new value.
2787 * String values are simply set to NULL pointers if they are not going
2790 * \param init Party subaddress structure to initialize.
2791 * \param guide Source party subaddress to use as a guide in initializing.
2795 void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide);
2799 * \brief Set the source party subaddress information into the destination party subaddress.
2801 * \param dest The subaddress one wishes to update
2802 * \param src The new subaddress values to update the dest
2806 void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
2810 * \brief Destroy the party subaddress contents
2812 * \param doomed The party subaddress to destroy.
2816 void ast_party_subaddress_free(struct ast_party_subaddress *doomed);
2819 * \brief Initialize the given party id structure.
2822 * \param init Party id structure to initialize.
2826 void ast_party_id_init(struct ast_party_id *init);
2829 * \brief Copy the source party id information to the destination party id.
2832 * \param dest Destination party id
2833 * \param src Source party id
2837 void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src);
2840 * \brief Initialize the given party id structure using the given guide
2841 * for a set update operation.
2845 * The initialization is needed to allow a set operation to know if a
2846 * value needs to be updated. Simple integers need the guide's original
2847 * value in case the set operation is not trying to set a new value.
2848 * String values are simply set to NULL pointers if they are not going
2851 * \param init Party id structure to initialize.
2852 * \param guide Source party id to use as a guide in initializing.
2856 void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide);
2859 * \brief Set the source party id information into the destination party id.
2862 * \param dest The id one wishes to update
2863 * \param src The new id values to update the dest
2864 * \param update What id information to update. NULL if all.
2868 void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update);
2871 * \brief Destroy the party id contents
2874 * \param doomed The party id to destroy.
2878 void ast_party_id_free(struct ast_party_id *doomed);
2881 * \brief Determine the overall presentation value for the given party.
2884 * \param id Party to determine the overall presentation value.
2886 * \return Overall presentation value for the given party.
2888 int ast_party_id_presentation(const struct ast_party_id *id);
2891 * \brief Initialize the given dialed structure.
2894 * \param init Dialed structure to initialize.
2898 void ast_party_dialed_init(struct ast_party_dialed *init);
2901 * \brief Copy the source dialed party information to the destination dialed party.
2904 * \param dest Destination dialed party
2905 * \param src Source dialed party
2909 void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
2912 * \brief Initialize the given dialed structure using the given
2913 * guide for a set update operation.
2917 * The initialization is needed to allow a set operation to know if a
2918 * value needs to be updated. Simple integers need the guide's original
2919 * value in case the set operation is not trying to set a new value.
2920 * String values are simply set to NULL pointers if they are not going
2923 * \param init Caller structure to initialize.
2924 * \param guide Source dialed to use as a guide in initializing.
2928 void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide);
2931 * \brief Set the dialed information based on another dialed source
2934 * This is similar to ast_party_dialed_copy, except that NULL values for
2935 * strings in the src parameter indicate not to update the corresponding dest values.
2937 * \param dest The dialed one wishes to update
2938 * \param src The new dialed values to update the dest
2942 void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
2945 * \brief Destroy the dialed party contents
2948 * \param doomed The dialed party to destroy.
2952 void ast_party_dialed_free(struct ast_party_dialed *doomed);
2956 * \brief Initialize the given caller structure.
2958 * \param init Caller structure to initialize.
2962 void ast_party_caller_init(struct ast_party_caller *init);
2966 * \brief Copy the source caller information to the destination caller.
2968 * \param dest Destination caller
2969 * \param src Source caller
2973 void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src);
2976 * \brief Initialize the given caller structure using the given
2977 * guide for a set update operation.
2981 * The initialization is needed to allow a set operation to know if a
2982 * value needs to be updated. Simple integers need the guide's original
2983 * value in case the set operation is not trying to set a new value.
2984 * String values are simply set to NULL pointers if they are not going
2987 * \param init Caller structure to initialize.
2988 * \param guide Source caller to use as a guide in initializing.
2992 void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide);
2995 * \brief Set the caller information based on another caller source
2998 * This is similar to ast_party_caller_copy, except that NULL values for
2999 * strings in the src parameter indicate not to update the corresponding dest values.
3001 * \param dest The caller one wishes to update
3002 * \param src The new caller values to update the dest
3003 * \param update What caller information to update. NULL if all.
3007 void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update);
3010 * \brief Destroy the caller party contents
3013 * \param doomed The caller party to destroy.
3017 void ast_party_caller_free(struct ast_party_caller *doomed);
3021 * \brief Initialize the given connected line structure.
3023 * \param init Connected line structure to initialize.
3027 void ast_party_connected_line_init(struct ast_party_connected_line *init);
3031 * \brief Copy the source connected line information to the destination connected line.
3033 * \param dest Destination connected line
3034 * \param src Source connected line
3038 void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src);
3042 * \brief Initialize the given connected line structure using the given
3043 * guide for a set update operation.
3046 * The initialization is needed to allow a set operation to know if a
3047 * value needs to be updated. Simple integers need the guide's original
3048 * value in case the set operation is not trying to set a new value.
3049 * String values are simply set to NULL pointers if they are not going
3052 * \param init Connected line structure to initialize.
3053 * \param guide Source connected line to use as a guide in initializing.
3057 void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide);
3061 * \brief Set the connected line information based on another connected line source
3063 * This is similar to ast_party_connected_line_copy, except that NULL values for
3064 * strings in the src parameter indicate not to update the corresponding dest values.
3066 * \param dest The connected line one wishes to update
3067 * \param src The new connected line values to update the dest
3068 * \param update What connected line information to update. NULL if all.
3072 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);
3076 * \brief Collect the caller party information into a connected line structure.
3078 * \param connected Collected caller information for the connected line
3079 * \param caller Caller information.
3083 * \warning This is a shallow copy.
3084 * \warning DO NOT call ast_party_connected_line_free() on the filled in
3085 * connected line structure!
3087 void ast_party_connected_line_collect_caller(struct ast_party_connected_line *connected, struct ast_party_caller *caller);
3091 * \brief Destroy the connected line information contents
3093 * \param doomed The connected line information to destroy.
3097 void ast_party_connected_line_free(struct ast_party_connected_line *doomed);
3100 * \brief Initialize the given redirecting structure.
3103 * \param init Redirecting structure to initialize.
3107 void ast_party_redirecting_init(struct ast_party_redirecting *init);
3111 * \brief Copy the source redirecting information to the destination redirecting.
3113 * \param dest Destination redirecting
3114 * \param src Source redirecting
3118 void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src);
3122 * \brief Initialize the given redirecting id structure using the given guide
3123 * for a set update operation.
3126 * The initialization is needed to allow a set operation to know if a
3127 * value needs to be updated. Simple integers need the guide's original
3128 * value in case the set operation is not trying to set a new value.
3129 * String values are simply set to NULL pointers if they are not going
3132 * \param init Redirecting id structure to initialize.
3133 * \param guide Source redirecting id to use as a guide in initializing.
3137 void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide);
3140 * \brief Set the redirecting information based on another redirecting source
3143 * This is similar to ast_party_redirecting_copy, except that NULL values for
3144 * strings in the src parameter indicate not to update the corresponding dest values.
3146 * \param dest The redirecting one wishes to update
3147 * \param src The new redirecting values to update the dest
3148 * \param update What redirecting information to update. NULL if all.
3152 void ast_party_redirecting_set(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update);
3156 * \brief Destroy the redirecting information contents
3158 * \param doomed The redirecting information to destroy.
3162 void ast_party_redirecting_free(struct ast_party_redirecting *doomed);
3166 * \brief Copy the caller information to the connected line information.
3168 * \param dest Destination connected line information
3169 * \param src Source caller information
3173 * \note Assumes locks are already acquired
3175 void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src);
3179 * \brief Copy the connected line information to the caller information.
3181 * \param dest Destination caller information
3182 * \param src Source connected line information
3186 * \note Assumes locks are already acquired
3188 void ast_connected_line_copy_to_caller(struct ast_party_caller *dest, const struct ast_party_connected_line *src);
3192 * \brief Set the connected line information in the Asterisk channel
3194 * \param chan Asterisk channel to set connected line information
3195 * \param connected Connected line information
3196 * \param update What connected line information to update. NULL if all.
3200 * \note The channel does not need to be locked before calling this function.
3202 void ast_channel_set_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update);
3206 * \brief Build the connected line information data frame.
3208 * \param data Buffer to fill with the frame data
3209 * \param datalen Size of the buffer to fill
3210 * \param connected Connected line information
3211 * \param update What connected line information to build. NULL if all.
3213 * \retval -1 if error
3214 * \retval Amount of data buffer used
3216 int ast_connected_line_build_data(unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update);
3220 * \brief Parse connected line indication frame data
3222 * \param data Buffer with the frame data to parse
3223 * \param datalen Size of the buffer
3224 * \param connected Extracted connected line information
3226 * \retval 0 on success.
3227 * \retval -1 on error.
3229 * \note The filled in connected line structure needs to be initialized by
3230 * ast_party_connected_line_set_init() before calling. If defaults are not
3231 * required use ast_party_connected_line_init().
3232 * \note The filled in connected line structure needs to be destroyed by
3233 * ast_party_connected_line_free() when it is no longer needed.
3235 int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected);
3239 * \brief Indicate that the connected line information has changed
3241 * \param chan Asterisk channel to indicate connected line information
3242 * \param connected Connected line information
3243 * \param update What connected line information to update. NULL if all.
3247 void ast_channel_update_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update);
3251 * \brief Queue a connected line update frame on a channel
3253 * \param chan Asterisk channel to indicate connected line information
3254 * \param connected Connected line information
3255 * \param update What connected line information to update. NULL if all.
3259 void ast_channel_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update);
3263 * \brief Set the redirecting id information in the Asterisk channel
3265 * \param chan Asterisk channel to set redirecting id information
3266 * \param redirecting Redirecting id information
3267 * \param update What redirecting information to update. NULL if all.
3271 * \note The channel does not need to be locked before calling this function.
3273 void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3277 * \brief Build the redirecting id data frame.
3279 * \param data Buffer to fill with the frame data
3280 * \param datalen Size of the buffer to fill
3281 * \param redirecting Redirecting id information
3282 * \param update What redirecting information to build. NULL if all.
3284 * \retval -1 if error
3285 * \retval Amount of data buffer used
3287 int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3291 * \brief Parse redirecting indication frame data
3293 * \param data Buffer with the frame data to parse
3294 * \param datalen Size of the buffer
3295 * \param redirecting Extracted redirecting id information
3297 * \retval 0 on success.
3298 * \retval -1 on error.
3300 * \note The filled in id structure needs to be initialized by
3301 * ast_party_redirecting_set_init() before calling.
3302 * \note The filled in id structure needs to be destroyed by
3303 * ast_party_redirecting_free() when it is no longer needed.
3305 int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting);
3309 * \brief Indicate that the redirecting id has changed
3311 * \param chan Asterisk channel to indicate redirecting id information
3312 * \param redirecting Redirecting id information
3313 * \param update What redirecting information to update. NULL if all.
3317 void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3321 * \brief Queue a redirecting update frame on a channel
3323 * \param chan Asterisk channel to indicate redirecting id information
3324 * \param redirecting Redirecting id information
3325 * \param update What redirecting information to update. NULL if all.
3329 void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3333 * \brief Run a connected line interception macro and update a channel's connected line
3335 * \deprecated You should use the ast_channel_connected_line_sub() function instead.
3337 * Whenever we want to update a channel's connected line information, we may need to run
3338 * a macro so that an administrator can manipulate the information before sending it
3339 * out. This function both runs the macro and sends the update to the channel.
3341 * \param autoservice_chan Channel to place into autoservice while the macro is running.
3342 * It is perfectly safe for this to be NULL
3343 * \param macro_chan The channel to run the macro on. Also the channel from which we
3344 * determine which macro we need to run.
3345 * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
3346 * AST_CONTROL_CONNECTED_LINE
3347 * \param is_caller If true, then run CONNECTED_LINE_CALLER_SEND_MACRO with arguments from
3348 * CONNECTED_LINE_CALLER_SEND_MACRO_ARGS, otherwise run CONNECTED_LINE_CALLEE_SEND_MACRO
3349 * with arguments from CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS
3350 * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
3351 * ast_party_connected_line pointer.
3353 * \retval -1 Either the macro does not exist, or there was an error while attempting to
3356 * \todo Have multiple return codes based on the MACRO_RESULT
3357 * \todo Make constants so that caller and frame can be more expressive than just '1' and
3360 int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int is_caller, int frame);
3364 * \brief Run a connected line interception subroutine and update a channel's connected line
3367 * Whenever we want to update a channel's connected line information, we may need to run
3368 * a subroutine so that an administrator can manipulate the information before sending it
3369 * out. This function both runs the subroutine specified by CONNECTED_LINE_SEND_SUB and
3370 * sends the update to the channel.
3372 * \param autoservice_chan Channel to place into autoservice while the sub is running.
3373 * It is perfectly safe for this to be NULL
3374 * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3375 * determine which subroutine we need to run.
3376 * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
3377 * AST_CONTROL_CONNECTED_LINE
3378 * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
3379 * ast_party_connected_line pointer.
3381 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3382 * run the subroutine
3384 int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame);
3387 * \brief Insert into an astdata tree, the channel structure.
3388 * \param[in] tree The ast data tree.
3389 * \param[in] chan The channel structure to add to tree.
3390 * \param[in] add_bridged Add the bridged channel to the structure.
3391 * \retval <0 on error.
3392 * \retval 0 on success.
3394 int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan, int add_bridged);
3397 * \brief Compare to channel structures using the data api.
3398 * \param[in] tree The search tree generated by the data api.
3399 * \param[in] chan The channel to compare.
3400 * \param[in] structure_name The name of the node of the channel structure.
3401 * \retval 0 The structure matches.
3402 * \retval 1 The structure doesn't matches.
3404 int ast_channel_data_cmp_structure(const struct ast_data_search *tree, struct ast_channel *chan,
3405 const char *structure_name);
3409 * \brief Run a redirecting interception macro and update a channel's redirecting information
3410 * \deprecated You should use the ast_channel_redirecting_sub() function instead.
3413 * Whenever we want to update a channel's redirecting information, we may need to run
3414 * a macro so that an administrator can manipulate the information before sending it
3415 * out. This function both runs the macro and sends the update to the channel.
3417 * \param autoservice_chan Channel to place into autoservice while the macro is running.
3418 * It is perfectly safe for this to be NULL
3419 * \param macro_chan The channel to run the macro on. Also the channel from which we
3420 * determine which macro we need to run.
3421 * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
3422 * AST_CONTROL_REDIRECTING
3423 * \param is_caller If true, then run REDIRECTING_CALLER_SEND_MACRO with arguments from
3424 * REDIRECTING_CALLER_SEND_MACRO_ARGS, otherwise run REDIRECTING_CALLEE_SEND_MACRO with
3425 * arguments from REDIRECTING_CALLEE_SEND_MACRO_ARGS
3426 * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
3427 * ast_party_redirecting pointer.
3430 * \retval -1 Either the macro does not exist, or there was an error while attempting to
3433 * \todo Have multiple return codes based on the MACRO_RESULT
3434 * \todo Make constants so that caller and frame can be more expressive than just '1' and
3437 int ast_channel_redirecting_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *redirecting_info, int is_caller, int is_frame);
3441 * \brief Run a redirecting interception subroutine and update a channel's redirecting information
3444 * Whenever we want to update a channel's redirecting information, we may need to run
3445 * a subroutine so that an administrator can manipulate the information before sending it
3446 * out. This function both runs the subroutine specified by REDIRECTING_SEND_SUB and
3447 * sends the update to the channel.
3449 * \param autoservice_chan Channel to place into autoservice while the subroutine is running.
3450 * It is perfectly safe for this to be NULL
3451 * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3452 * determine which subroutine we need to run.
3453 * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
3454 * AST_CONTROL_REDIRECTING
3455 * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
3456 * ast_party_redirecting pointer.
3459 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3460 * run the subroutine
3462 int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame);
3464 #include "asterisk/ccss.h"
3468 * \brief Set up datastore with CCSS parameters for a channel
3471 * If base_params is NULL, the channel will get the default
3472 * values for all CCSS parameters.
3475 * This function makes use of datastore operations on the channel, so
3476 * it is important to lock the channel before calling this function.
3478 * \param chan The channel to create the datastore on
3479 * \param base_params CCSS parameters we wish to copy into the channel
3481 * \retval -1 Failure
3483 int ast_channel_cc_params_init(struct ast_channel *chan,
3484 const struct ast_cc_config_params *base_params);
3488 * \brief Get the CCSS parameters from a channel
3491 * This function makes use of datastore operations on the channel, so
3492 * it is important to lock the channel before calling this function.
3494 * \param chan Channel to retrieve parameters from
3495 * \retval NULL Failure
3496 * \retval non-NULL The parameters desired
3498 struct ast_cc_config_params *ast_channel_get_cc_config_params(struct ast_channel *chan);
3503 * \brief Get a device name given its channel structure
3506 * A common practice in Asterisk is to determine the device being talked
3507 * to by dissecting the channel name. For certain channel types, this is not
3508 * accurate. For instance, an ISDN channel is named based on what B channel is
3509 * used, not the device being communicated with.
3511 * This function interfaces with a channel tech's queryoption callback to
3512 * retrieve the name of the device being communicated with. If the channel does not
3513 * implement this specific option, then the traditional method of using the channel
3514 * name is used instead.
3516 * \param chan The channel to retrieve the information from
3517 * \param[out] device_name The buffer to place the device's name into
3518 * \param name_buffer_length The allocated space for the device_name
3521 int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length);
3525 * \brief Find the appropriate CC agent type to use given a channel
3528 * During call completion, we will need to create a call completion agent structure. To
3529 * figure out the type of agent to construct, we need to ask the channel driver for the
3532 * Prior to adding this function, the call completion core attempted to figure this
3533 * out for itself by stripping the technology off the channel's name. However, in the
3534 * case of chan_dahdi, there are multiple agent types registered, and so simply searching
3535 * for an agent type called "DAHDI" is not possible. In a case where multiple agent types
3536 * are defined, the channel driver must have a queryoption callback defined in its
3537 * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE
3539 * If a channel driver does not have a queryoption callback or if the queryoption callback
3540 * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology
3541 * portion of the channel name is used instead. This is perfectly suitable for channel drivers
3542 * whose channel technologies are a one-to-one match with the agent types defined within.
3544 * Note that this function is only called when the agent policy on a given channel is set
3545 * to "native." Generic agents' type can be determined automatically by the core.
3547 * \param chan The channel for which we wish to retrieve the agent type
3548 * \param[out] agent_type The type of agent the channel driver wants us to use
3549 * \param size The size of the buffer to write to
3551 int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size);
3552 #if defined(__cplusplus) || defined(c_plusplus)
3557 * \brief Remove a channel from the global channels container
3559 * \param chan channel to remove
3561 * In a case where it is desired that a channel not be available in any lookups
3562 * in the global channels conatiner, use this function.
3564 void ast_channel_unlink(struct ast_channel *chan);
3566 /* ACCESSOR FUNTIONS */
3567 /*! \brief Set the channel name */
3568 void ast_channel_name_set(struct ast_channel *chan, const char *name);
3570 #define DECLARE_STRINGFIELD_SETTERS_FOR(field) \
3571 void ast_channel_##field##_set(struct ast_channel *chan, const char *field); \
3572 void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0))); \
3573 void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) __attribute__((format(printf, 2, 3)))
3575 DECLARE_STRINGFIELD_SETTERS_FOR(name);
3576 DECLARE_STRINGFIELD_SETTERS_FOR(language);
3577 DECLARE_STRINGFIELD_SETTERS_FOR(musicclass);
3578 DECLARE_STRINGFIELD_SETTERS_FOR(accountcode);
3579 DECLARE_STRINGFIELD_SETTERS_FOR(peeraccount);
3580 DECLARE_STRINGFIELD_SETTERS_FOR(userfield);
3581 DECLARE_STRINGFIELD_SETTERS_FOR(call_forward);
3582 DECLARE_STRINGFIELD_SETTERS_FOR(uniqueid);
3583 DECLARE_STRINGFIELD_SETTERS_FOR(linkedid);
3584 DECLARE_STRINGFIELD_SETTERS_FOR(parkinglot);
3585 DECLARE_STRINGFIELD_SETTERS_FOR(hangupsource);
3586 DECLARE_STRINGFIELD_SETTERS_FOR(dialcontext);
3588 const char *ast_channel_name(const struct ast_channel *chan);
3589 const char *ast_channel_language(const struct ast_channel *chan);
3590 const char *ast_channel_musicclass(const struct ast_channel *chan);
3591 const char *ast_channel_accountcode(const struct ast_channel *chan);
3592 const char *ast_channel_peeraccount(const struct ast_channel *chan);
3593 const char *ast_channel_userfield(const struct ast_channel *chan);
3594 const char *ast_channel_call_forward(const struct ast_channel *chan);
3595 const char *ast_channel_uniqueid(const struct ast_channel *chan);
3596 const char *ast_channel_linkedid(const struct ast_channel *chan);
3597 const char *ast_channel_parkinglot(const struct ast_channel *chan);
3598 const char *ast_channel_hangupsource(const struct ast_channel *chan);
3599 const char *ast_channel_dialcontext(const struct ast_channel *chan);
3601 const char *ast_channel_appl(const struct ast_channel *chan);
3602 void ast_channel_appl_set(struct ast_channel *chan, const char *value);
3603 const char *ast_channel_blockproc(const struct ast_channel *chan);
3604 void ast_channel_blockproc_set(struct ast_channel *chan, const char *value);
3605 const char *ast_channel_data(const struct ast_channel *chan);
3606 void ast_channel_data_set(struct ast_channel *chan, const char *value);
3608 const char *ast_channel_context(const struct ast_channel *chan);
3609 void ast_channel_context_set(struct ast_channel *chan, const char *value);
3610 const char *ast_channel_exten(const struct ast_channel *chan);
3611 void ast_channel_exten_set(struct ast_channel *chan, const char *value);
3612 const char *ast_channel_macrocontext(const struct ast_channel *chan);
3613 void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value);
3614 const char *ast_channel_macroexten(const struct ast_channel *chan);
3615 void ast_channel_macroexten_set(struct ast_channel *chan, const char *value);
3617 char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan);
3618 void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value);
3619 int ast_channel_amaflags(const struct ast_channel *chan);
3620 void ast_channel_amaflags_set(struct ast_channel *chan, int value);
3621 int ast_channel_epfd(const struct ast_channel *chan);
3622 void ast_channel_epfd_set(struct ast_channel *chan, int value);
3623 int ast_channel_fdno(const struct ast_channel *chan);
3624 void ast_channel_fdno_set(struct ast_channel *chan, int value);
3625 int ast_channel_hangupcause(const struct ast_channel *chan);
3626 void ast_channel_hangupcause_set(struct ast_channel *chan, int value);
3627 int ast_channel_macropriority(const struct ast_channel *chan);
3628 void ast_channel_macropriority_set(struct ast_channel *chan, int value);
3629 int ast_channel_priority(const struct ast_channel *chan);
3630 void ast_channel_priority_set(struct ast_channel *chan, int value);
3631 int ast_channel_rings(const struct ast_channel *chan);
3632 void ast_channel_rings_set(struct ast_channel *chan, int value);
3633 int ast_channel_streamid(const struct ast_channel *chan);
3634 void ast_channel_streamid_set(struct ast_channel *chan, int value);
3635 int ast_channel_timingfd(const struct ast_channel *chan);
3636 void ast_channel_timingfd_set(struct ast_channel *chan, int value);
3637 int ast_channel_visible_indication(const struct ast_channel *chan);
3638 void ast_channel_visible_indication_set(struct ast_channel *chan, int value);
3639 int ast_channel_vstreamid(const struct ast_channel *chan);
3640 void ast_channel_vstreamid_set(struct ast_channel *chan, int value);
3641 unsigned short ast_channel_transfercapability(const struct ast_channel *chan);
3642 void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value);
3643 unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan);
3644 void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value);
3645 unsigned int ast_channel_fin(const struct ast_channel *chan);
3646 void ast_channel_fin_set(struct ast_channel *chan, unsigned int value);
3647 unsigned int ast_channel_fout(const struct ast_channel *chan);
3648 void ast_channel_fout_set(struct ast_channel *chan, unsigned int value);
3649 unsigned long ast_channel_insmpl(const struct ast_channel *chan);
3650 void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value);
3651 unsigned long ast_channel_outsmpl(const struct ast_channel *chan);
3652 void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value);
3653 void *ast_channel_generatordata(const struct ast_channel *chan);
3654 void ast_channel_generatordata_set(struct ast_channel *chan, void *value);
3655 void *ast_channel_music_state(const struct ast_channel *chan);
3656 void ast_channel_music_state_set(struct ast_channel *chan, void *value);
3657 void *ast_channel_tech_pvt(const struct ast_channel *chan);
3658 void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value);
3659 void *ast_channel_timingdata(const struct ast_channel *chan);
3660 void ast_channel_timingdata_set(struct ast_channel *chan, void *value);
3661 struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan);
3662 void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value);
3663 struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan);
3664 void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value);
3665 struct ast_channel *ast_channel__bridge(const struct ast_channel *chan);
3666 void ast_channel__bridge_set(struct ast_channel *chan, struct ast_channel *value);
3667 struct ast_channel *ast_channel_masq(const struct ast_channel *chan);
3668 void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value);
3669 struct ast_channel *ast_channel_masqr(const struct ast_channel *chan);
3670 void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value);
3671 struct ast_channel_monitor *ast_channel_monitor(const struct ast_channel *chan);
3672 void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value);
3673 struct ast_filestream *ast_channel_stream(const struct ast_channel *chan);
3674 void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value);
3675 struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan);
3676 void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value);
3677 struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan);
3678 void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value);
3679 struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan);
3680 void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value);
3681 struct ast_generator *ast_channel_generator(const struct ast_channel *chan);
3682 void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value);
3683 struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan);
3684 void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value);
3685 struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan);
3686 void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value);
3687 struct ast_timer *ast_channel_timer(const struct ast_channel *chan);
3688 void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value);
3689 struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan);
3690 void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value);
3691 struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan);
3692 void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
3693 struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan);
3694 void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
3695 const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan);
3696 void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value);
3697 enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan);
3698 void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value);
3699 enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
3700 struct ast_callid *ast_channel_callid(const struct ast_channel *chan);
3701 void ast_channel_callid_set(struct ast_channel *chan, struct ast_callid *value);
3703 /* XXX Internal use only, make sure to move later */
3704 void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
3705 void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value);
3706 void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value);
3707 void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value);
3708 void ast_channel_callid_cleanup(struct ast_channel *chan);
3709 int ast_channel_softhangup_internal_flag(struct ast_channel *chan);
3711 /* Format getters */
3712 struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan);
3713 struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan);
3714 struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan);
3715 struct ast_format *ast_channel_readformat(struct ast_channel *chan);
3716 struct ast_format *ast_channel_writeformat(struct ast_channel *chan);
3718 /* Other struct getters */
3719 struct ast_frame *ast_channel_dtmff(struct ast_channel *chan);
3720 struct ast_jb *ast_channel_jb(struct ast_channel *chan);
3721 struct ast_party_caller *ast_channel_caller(struct ast_channel *chan);
3722 struct ast_party_connected_line *ast_channel_connected(struct ast_channel *chan);
3723 struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan);
3724 struct ast_party_redirecting *ast_channel_redirecting(struct ast_channel *chan);
3725 struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan);
3726 struct timeval *ast_channel_whentohangup(struct ast_channel *chan);
3727 struct varshead *ast_channel_varshead(struct ast_channel *chan);
3729 void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value);
3730 void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value);
3731 void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value);
3732 void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value);
3733 void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value);
3734 void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value);
3735 void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value);
3736 void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value);
3737 void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value);
3740 struct ast_datastore_list *ast_channel_datastores(struct ast_channel *chan);
3741 struct ast_autochan_list *ast_channel_autochans(struct ast_channel *chan);
3742 struct ast_readq_list *ast_channel_readq(struct ast_channel *chan);
3744 /* Typedef accessors */
3745 ast_group_t ast_channel_callgroup(const struct ast_channel *chan);
3746 void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value);
3747 ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan);
3748 void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value);
3750 /* Alertpipe accessors--the "internal" functions for channel.c use only */
3752 AST_ALERT_READ_SUCCESS = 0,
3753 AST_ALERT_NOT_READABLE,
3754 AST_ALERT_READ_FAIL,
3755 AST_ALERT_READ_FATAL,
3756 } ast_alert_status_t;
3757 int ast_channel_alert_write(struct ast_channel *chan);
3758 int ast_channel_alert_writable(struct ast_channel *chan);
3759 ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan);
3760 int ast_channel_internal_alert_readable(struct ast_channel *chan);
3761 void ast_channel_internal_alertpipe_clear(struct ast_channel *chan);
3762 void ast_channel_internal_alertpipe_close(struct ast_channel *chan);
3763 int ast_channel_internal_alert_readfd(struct ast_channel *chan);
3764 int ast_channel_internal_alertpipe_init(struct ast_channel *chan);
3765 /*! \brief Swap the interal alertpipe between two channels
3766 * \note Handle all of the necessary locking before calling this
3768 void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2);
3770 /* file descriptor array accessors */
3771 void ast_channel_internal_fd_clear(struct ast_channel *chan, int which);
3772 void ast_channel_internal_fd_clear_all(struct ast_channel *chan);
3773 void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value);
3774 int ast_channel_fd(const struct ast_channel *chan, int which);
3775 int ast_channel_fd_isset(const struct ast_channel *chan, int which);
3777 /* epoll data internal accessors */
3779 struct ast_epoll_data *ast_channel_internal_epfd_data(const struct ast_channel *chan, int which);
3780 void ast_channel_internal_epfd_data_set(struct ast_channel *chan, int which , struct ast_epoll_data *value);
3783 pthread_t ast_channel_blocker(const struct ast_channel *chan);
3784 void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value);
3786 ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan);
3787 void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value);
3789 struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan);
3790 void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value);
3792 struct ast_channel *ast_channel_internal_bridged_channel(const struct ast_channel *chan);
3793 void ast_channel_internal_bridged_channel_set(struct ast_channel *chan, struct ast_channel *value);
3795 struct ast_flags *ast_channel_flags(struct ast_channel *chan);
3796 #endif /* _ASTERISK_CHANNEL_H */