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
1391 * \note Absolutely _NO_ channel locks should be held before calling this function.
1395 * Hangupsource is generally the channel name that caused the bridge to be
1396 * hung up, but it can also be other things such as "dialplan/agi"
1397 * This can then be logged in the CDR or CEL
1399 void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force);
1401 /*! \brief Check to see if a channel is needing hang up
1402 * \param chan channel on which to check for hang up
1403 * This function determines if the channel is being requested to be hung up.
1404 * \return Returns 0 if not, or 1 if hang up is requested (including time-out).
1406 int ast_check_hangup(struct ast_channel *chan);
1408 int ast_check_hangup_locked(struct ast_channel *chan);
1411 * \brief Lock the given channel, then request softhangup on the channel with the given causecode
1412 * \param chan channel on which to hang up
1413 * \param causecode cause code to use (Zero if don't use cause code)
1416 void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode);
1419 * \brief Compare a offset with the settings of when to hang a channel up
1420 * \param chan channel on which to check for hang up
1421 * \param offset offset in seconds from current time
1422 * \return 1, 0, or -1
1424 * This function compares a offset from current time with the absolute time
1425 * out on a channel (when to hang up). If the absolute time out on a channel
1426 * is earlier than current time plus the offset, it returns 1, if the two
1427 * time values are equal, it return 0, otherwise, it return -1.
1428 * \sa ast_channel_cmpwhentohangup_tv()
1429 * \version 1.6.1 deprecated function (only had seconds precision)
1431 int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated));
1434 * \brief Compare a offset with the settings of when to hang a channel up
1435 * \param chan channel on which to check for hangup
1436 * \param offset offset in seconds and microseconds from current time
1437 * \return 1, 0, or -1
1438 * This function compares a offset from current time with the absolute time
1439 * out on a channel (when to hang up). If the absolute time out on a channel
1440 * is earlier than current time plus the offset, it returns 1, if the two
1441 * time values are equal, it return 0, otherwise, it return -1.
1444 int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1447 * \brief Set when to hang a channel up
1449 * \param chan channel on which to check for hang up
1450 * \param offset offset in seconds relative to the current time of when to hang up
1453 * This function sets the absolute time out on a channel (when to hang up).
1455 * \note This function does not require that the channel is locked before
1459 * \sa ast_channel_setwhentohangup_tv()
1460 * \version 1.6.1 deprecated function (only had seconds precision)
1462 void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated));
1465 * \brief Set when to hang a channel up
1467 * \param chan channel on which to check for hang up
1468 * \param offset offset in seconds and useconds relative to the current time of when to hang up
1470 * This function sets the absolute time out on a channel (when to hang up).
1472 * \note This function does not require that the channel is locked before
1478 void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1481 * \brief Answer a channel
1483 * \param chan channel to answer
1486 * This function answers a channel and handles all necessary call
1489 * \note The channel passed does not need to be locked, but is locked
1490 * by the function when needed.
1492 * \note This function will wait up to 500 milliseconds for media to
1493 * arrive on the channel before returning to the caller, so that the
1494 * caller can properly assume the channel is 'ready' for media flow.
1496 * \retval 0 on success
1497 * \retval non-zero on failure
1499 int ast_answer(struct ast_channel *chan);
1502 * \brief Answer a channel
1504 * \param chan channel to answer
1505 * \param cdr_answer flag to control whether any associated CDR should be marked as 'answered'
1507 * This function answers a channel and handles all necessary call
1510 * \note The channel passed does not need to be locked, but is locked
1511 * by the function when needed.
1513 * \note Unlike ast_answer(), this function will not wait for media
1514 * flow to begin. The caller should be careful before sending media
1515 * to the channel before incoming media arrives, as the outgoing
1516 * media may be lost.
1518 * \retval 0 on success
1519 * \retval non-zero on failure
1521 int ast_raw_answer(struct ast_channel *chan, int cdr_answer);
1524 * \brief Answer a channel, with a selectable delay before returning
1526 * \param chan channel to answer
1527 * \param delay maximum amount of time to wait for incoming media
1528 * \param cdr_answer flag to control whether any associated CDR should be marked as 'answered'
1530 * This function answers a channel and handles all necessary call
1533 * \note The channel passed does not need to be locked, but is locked
1534 * by the function when needed.
1536 * \note This function will wait up to 'delay' milliseconds for media to
1537 * arrive on the channel before returning to the caller, so that the
1538 * caller can properly assume the channel is 'ready' for media flow. If
1539 * 'delay' is less than 500, the function will wait up to 500 milliseconds.
1541 * \retval 0 on success
1542 * \retval non-zero on failure
1544 int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer);
1547 * \brief Execute a Gosub call on the channel before a call is placed.
1551 * This is called between ast_request() and ast_call() to
1552 * execute a predial routine on the newly created channel.
1554 * \param chan Channel to execute Gosub.
1555 * \param sub_args Gosub application parameter string.
1557 * \note Absolutely _NO_ channel locks should be held before calling this function.
1559 * \retval 0 on success.
1560 * \retval -1 on error.
1562 int ast_pre_call(struct ast_channel *chan, const char *sub_args);
1565 * \brief Make a call
1566 * \note Absolutely _NO_ channel locks should be held before calling this function.
1567 * \param chan which channel to make the call on
1568 * \param addr destination of the call
1569 * \param timeout time to wait on for connect (Doesn't seem to be used.)
1571 * Place a call, take no longer than timeout ms.
1572 * \retval 0 on success
1573 * \retval -1 on failure
1575 int ast_call(struct ast_channel *chan, const char *addr, int timeout);
1578 * \brief Indicates condition of channel
1579 * \note Absolutely _NO_ channel locks should be held before calling this function.
1580 * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel
1581 * \param chan channel to change the indication
1582 * \param condition which condition to indicate on the channel
1583 * \return Returns 0 on success, -1 on failure
1585 int ast_indicate(struct ast_channel *chan, int condition);
1588 * \brief Indicates condition of channel, with payload
1589 * \note Absolutely _NO_ channel locks should be held before calling this function.
1590 * \note Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class
1591 * \param chan channel to change the indication
1592 * \param condition which condition to indicate on the channel
1593 * \param data pointer to payload data
1594 * \param datalen size of payload data
1595 * \return Returns 0 on success, -1 on failure
1597 int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen);
1599 /* Misc stuff ------------------------------------------------ */
1602 * \brief Wait for input on a channel
1603 * \param chan channel to wait on
1604 * \param ms length of time to wait on the channel
1606 * Wait for input on a channel for a given # of milliseconds (<0 for indefinite).
1607 * \retval < 0 on failure
1608 * \retval 0 if nothing ever arrived
1609 * \retval the # of ms remaining otherwise
1611 int ast_waitfor(struct ast_channel *chan, int ms);
1614 * \brief Should we keep this frame for later?
1616 * There are functions such as ast_safe_sleep which will
1617 * service a channel to ensure that it does not have a
1618 * large backlog of queued frames. When this happens,
1619 * we want to hold on to specific frame types and just drop
1620 * others. This function will tell if the frame we just
1621 * read should be held onto.
1623 * \param frame The frame we just read
1624 * \retval 1 frame should be kept
1625 * \retval 0 frame should be dropped
1627 int ast_is_deferrable_frame(const struct ast_frame *frame);
1630 * \brief Wait for a specified amount of time, looking for hangups
1631 * \param chan channel to wait for
1632 * \param ms length of time in milliseconds to sleep
1634 * Waits for a specified amount of time, servicing the channel as required.
1635 * \return returns -1 on hangup, otherwise 0.
1637 int ast_safe_sleep(struct ast_channel *chan, int ms);
1640 * \brief Wait for a specified amount of time, looking for hangups and a condition argument
1641 * \param chan channel to wait for
1642 * \param ms length of time in milliseconds to sleep
1643 * \param cond a function pointer for testing continue condition
1644 * \param data argument to be passed to the condition test function
1645 * \return returns -1 on hangup, otherwise 0.
1647 * Waits for a specified amount of time, servicing the channel as required. If cond
1648 * returns 0, this function returns.
1650 int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data );
1653 * \brief Waits for activity on a group of channels
1654 * \param chan an array of pointers to channels
1655 * \param n number of channels that are to be waited upon
1656 * \param fds an array of fds to wait upon
1657 * \param nfds the number of fds to wait upon
1658 * \param exception exception flag
1659 * \param outfd fd that had activity on it
1660 * \param ms how long the wait was
1662 * Big momma function here. Wait for activity on any of the n channels, or any of the nfds
1664 * \return Returns the channel with activity, or NULL on error or if an FD
1665 * came first. If the FD came first, it will be returned in outfd, otherwise, outfd
1668 struct ast_channel *ast_waitfor_nandfds(struct ast_channel **chan, int n,
1669 int *fds, int nfds, int *exception, int *outfd, int *ms);
1672 * \brief Waits for input on a group of channels
1673 * Wait for input on an array of channels for a given # of milliseconds.
1674 * \return Return channel with activity, or NULL if none has activity.
1675 * \param chan an array of pointers to channels
1676 * \param n number of channels that are to be waited upon
1677 * \param ms time "ms" is modified in-place, if applicable
1679 struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms);
1682 * \brief Waits for input on an fd
1683 * \note This version works on fd's only. Be careful with it.
1685 int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);
1689 * \brief Reads a frame
1690 * \param chan channel to read a frame from
1691 * \return Returns a frame, or NULL on error. If it returns NULL, you
1692 * best just stop reading frames and assume the channel has been
1695 struct ast_frame *ast_read(struct ast_channel *chan);
1698 * \brief Reads a frame, returning AST_FRAME_NULL frame if audio.
1699 * \param chan channel to read a frame from
1700 * \return Returns a frame, or NULL on error. If it returns NULL, you
1701 * best just stop reading frames and assume the channel has been
1703 * \note Audio is replaced with AST_FRAME_NULL to avoid
1704 * transcode when the resulting audio is not necessary.
1706 struct ast_frame *ast_read_noaudio(struct ast_channel *chan);
1709 * \brief Write a frame to a channel
1710 * This function writes the given frame to the indicated channel.
1711 * \param chan destination channel of the frame
1712 * \param frame frame that will be written
1713 * \return It returns 0 on success, -1 on failure.
1715 int ast_write(struct ast_channel *chan, struct ast_frame *frame);
1718 * \brief Write video frame to a channel
1719 * This function writes the given frame to the indicated channel.
1720 * \param chan destination channel of the frame
1721 * \param frame frame that will be written
1722 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
1724 int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);
1727 * \brief Write text frame to a channel
1728 * This function writes the given frame to the indicated channel.
1729 * \param chan destination channel of the frame
1730 * \param frame frame that will be written
1731 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
1733 int ast_write_text(struct ast_channel *chan, struct ast_frame *frame);
1735 /*! \brief Send empty audio to prime a channel driver */
1736 int ast_prod(struct ast_channel *chan);
1739 * \brief Sets read format on channel chan from capabilities
1740 * Set read format for channel to whichever component of "format" is best.
1741 * \param chan channel to change
1742 * \param formats new formats to pick from for reading
1743 * \return Returns 0 on success, -1 on failure
1745 int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats);
1748 * \brief Sets read format on channel chan
1749 * \param chan channel to change
1750 * \param formats, format to set for reading
1751 * \return Returns 0 on success, -1 on failure
1753 int ast_set_read_format(struct ast_channel *chan, struct ast_format *format);
1756 * \brief Sets read format on channel chan by id
1757 * \param chan channel to change
1758 * \param format id to set for reading, only used for formats without attributes
1759 * \return Returns 0 on success, -1 on failure
1761 int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id);
1764 * \brief Sets write format on channel chan
1765 * Set write format for channel to whichever component of "format" is best.
1766 * \param chan channel to change
1767 * \param formats new formats to pick from for writing
1768 * \return Returns 0 on success, -1 on failure
1770 int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats);
1773 * \brief Sets write format on channel chan
1774 * \param chan channel to change
1775 * \param formats, format to set for writing
1776 * \return Returns 0 on success, -1 on failure
1778 int ast_set_write_format(struct ast_channel *chan, struct ast_format *format);
1781 * \brief Sets write format on channel chan
1782 * \param chan channel to change
1783 * \param format id to set for writing, only used for formats without attributes
1784 * \return Returns 0 on success, -1 on failure
1786 int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id);
1789 * \brief Sends text to a channel
1791 * \param chan channel to act upon
1792 * \param text string of text to send on the channel
1795 * Write text to a display on a channel
1797 * \note The channel does not need to be locked before calling this function.
1799 * \retval 0 on success
1800 * \retval -1 on failure
1802 int ast_sendtext(struct ast_channel *chan, const char *text);
1805 * \brief Receives a text character from a channel
1806 * \param chan channel to act upon
1807 * \param timeout timeout in milliseconds (0 for infinite wait)
1809 * Read a char of text from a channel
1810 * \return 0 on success, -1 on failure
1812 int ast_recvchar(struct ast_channel *chan, int timeout);
1815 * \brief Send a DTMF digit to a channel.
1816 * \param chan channel to act upon
1817 * \param digit the DTMF digit to send, encoded in ASCII
1818 * \param duration the duration of the digit ending in ms
1819 * \return 0 on success, -1 on failure
1821 int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
1824 * \brief Send a DTMF digit to a channel.
1825 * \param chan channel to act upon
1826 * \param digit the DTMF digit to send, encoded in ASCII
1827 * \return 0 on success, -1 on failure
1829 int ast_senddigit_begin(struct ast_channel *chan, char digit);
1832 * \brief Send a DTMF digit to a channel.
1833 * \param chan channel to act upon
1834 * \param digit the DTMF digit to send, encoded in ASCII
1835 * \param duration the duration of the digit ending in ms
1836 * \return Returns 0 on success, -1 on failure
1838 int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration);
1841 * \brief Receives a text string from a channel
1842 * Read a string of text from a channel
1843 * \param chan channel to act upon
1844 * \param timeout timeout in milliseconds (0 for infinite wait)
1845 * \return the received text, or NULL to signify failure.
1847 char *ast_recvtext(struct ast_channel *chan, int timeout);
1850 * \brief Waits for a digit
1851 * \param c channel to wait for a digit on
1852 * \param ms how many milliseconds to wait
1853 * \return Returns <0 on error, 0 on no entry, and the digit on success.
1855 int ast_waitfordigit(struct ast_channel *c, int ms);
1858 * \brief Wait for a digit
1859 * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
1860 * \param c channel to wait for a digit on
1861 * \param ms how many milliseconds to wait
1862 * \param audiofd audio file descriptor to write to if audio frames are received
1863 * \param ctrlfd control file descriptor to monitor for reading
1864 * \return Returns 1 if ctrlfd becomes available
1866 int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int ctrlfd);
1869 * \brief Reads multiple digits
1870 * \param c channel to read from
1871 * \param s string to read in to. Must be at least the size of your length
1872 * \param len how many digits to read (maximum)
1873 * \param timeout how long to timeout between digits
1874 * \param rtimeout timeout to wait on the first digit
1875 * \param enders digits to end the string
1877 * Read in a digit string "s", max length "len", maximum timeout between
1878 * digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout
1879 * for the first digit.
1880 * \return Returns 0 on normal return, or 1 on a timeout. In the case of
1881 * a timeout, any digits that were read before the timeout will still be available in s.
1882 * RETURNS 2 in full version when ctrlfd is available, NOT 1
1884 int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders);
1885 int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd);
1887 /*! \brief Report DTMF on channel 0 */
1888 #define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0)
1889 /*! \brief Report DTMF on channel 1 */
1890 #define AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1)
1891 /*! \brief Return all voice frames on channel 0 */
1892 #define AST_BRIDGE_REC_CHANNEL_0 (1 << 2)
1893 /*! \brief Return all voice frames on channel 1 */
1894 #define AST_BRIDGE_REC_CHANNEL_1 (1 << 3)
1895 /*! \brief Ignore all signal frames except NULL */
1896 #define AST_BRIDGE_IGNORE_SIGS (1 << 4)
1900 * \brief Makes two channel formats compatible
1901 * \param c0 first channel to make compatible
1902 * \param c1 other channel to make compatible
1904 * Set two channels to compatible formats -- call before ast_channel_bridge in general.
1905 * \return Returns 0 on success and -1 if it could not be done
1907 int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1);
1910 * \brief Bridge two channels together (early)
1911 * \param c0 first channel to bridge
1912 * \param c1 second channel to bridge
1914 * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
1915 * \return Returns 0 on success and -1 if it could not be done
1917 int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
1920 * \brief Bridge two channels together
1921 * \param c0 first channel to bridge
1922 * \param c1 second channel to bridge
1923 * \param config config for the channels
1924 * \param fo destination frame(?)
1925 * \param rc destination channel(?)
1927 * Bridge two channels (c0 and c1) together. If an important frame occurs, we return that frame in
1928 * *rf (remember, it could be NULL) and which channel (0 or 1) in rc
1930 /* int ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc); */
1931 int ast_channel_bridge(struct ast_channel *c0,struct ast_channel *c1,
1932 struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc);
1935 * \brief Weird function made for call transfers
1937 * \param original channel to make a copy of
1938 * \param clone copy of the original channel
1941 * This is a very strange and freaky function used primarily for transfer. Suppose that
1942 * "original" and "clone" are two channels in random situations. This function takes
1943 * the guts out of "clone" and puts them into the "original" channel, then alerts the
1944 * channel driver of the change, asking it to fixup any private information (like the
1945 * p->owner pointer) that is affected by the change. The physical layer of the original
1946 * channel is hung up.
1948 * \note Neither channel passed here should be locked before
1949 * calling this function. This function performs deadlock
1950 * avoidance involving these two channels.
1952 int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone);
1955 * \brief Setup a masquerade to transfer a call.
1958 * \param target_chan Target of the call transfer. (Masquerade original channel)
1959 * \param target_id New connected line information for the target channel.
1960 * \param target_held TRUE if the target call is on hold.
1961 * \param transferee_chan Transferee of the call transfer. (Masquerade clone channel)
1962 * \param transferee_id New connected line information for the transferee channel.
1963 * \param transferee_held TRUE if the transferee call is on hold.
1966 * Party A - Transferee
1967 * Party B - Transferer
1968 * Party C - Target of transfer
1970 * Party B transfers A to C.
1972 * Party A is connected to bridged channel B1.
1973 * Party B is connected to channels C1 and C2.
1974 * Party C is connected to bridged channel B2.
1976 * Party B -- C1 == B1 -- Party A
1979 * Party B -- C2 == B2 -- Party C
1981 * Bridged channel B1 is masqueraded into channel C2. Where B1
1982 * is the masquerade clone channel and C2 is the masquerade
1985 * \see ast_channel_masquerade()
1987 * \note Has the same locking requirements as ast_channel_masquerade().
1989 * \retval 0 on success.
1990 * \retval -1 on error.
1992 int ast_channel_transfer_masquerade(
1993 struct ast_channel *target_chan,
1994 const struct ast_party_connected_line *target_id,
1996 struct ast_channel *transferee_chan,
1997 const struct ast_party_connected_line *transferee_id,
1998 int transferee_held);
2001 * \brief Gives the string form of a given cause code.
2003 * \param state cause to get the description of
2004 * \return the text form of the binary cause code given
2006 const char *ast_cause2str(int state) attribute_pure;
2009 * \brief Convert the string form of a cause code to a number
2011 * \param name string form of the cause
2012 * \return the cause code
2014 int ast_str2cause(const char *name) attribute_pure;
2017 * \brief Gives the string form of a given channel state
2019 * \param ast_channel_state state to get the name of
2020 * \return the text form of the binary state given
2022 const char *ast_state2str(enum ast_channel_state);
2025 * \brief Gives the string form of a given transfer capability
2027 * \param transfercapability transfer capability to get the name of
2028 * \return the text form of the binary transfer capability
2030 char *ast_transfercapability2str(int transfercapability) attribute_const;
2033 * Options: Some low-level drivers may implement "options" allowing fine tuning of the
2034 * low level channel. See frame.h for options. Note that many channel drivers may support
2035 * none or a subset of those features, and you should not count on this if you want your
2036 * asterisk application to be portable. They're mainly useful for tweaking performance
2040 * \brief Sets an option on a channel
2042 * \param channel channel to set options on
2043 * \param option option to change
2044 * \param data data specific to option
2045 * \param datalen length of the data
2046 * \param block blocking or not
2048 * Set an option on a channel (see frame.h), optionally blocking awaiting the reply
2049 * \return 0 on success and -1 on failure
2051 int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
2054 * \brief Pick the best codec
2056 * \param capabilities to pick best codec out of
2057 * \param result stucture to store the best codec in.
2058 * \retval on success, pointer to result structure
2059 * \retval on failure, NULL
2061 struct ast_format *ast_best_codec(struct ast_format_cap *cap, struct ast_format *result);
2065 * \brief Checks the value of an option
2067 * Query the value of an option
2068 * Works similarly to setoption except only reads the options.
2070 int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block);
2073 * \brief Checks for HTML support on a channel
2074 * \return 0 if channel does not support HTML or non-zero if it does
2076 int ast_channel_supports_html(struct ast_channel *channel);
2079 * \brief Sends HTML on given channel
2080 * Send HTML or URL on link.
2081 * \return 0 on success or -1 on failure
2083 int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen);
2086 * \brief Sends a URL on a given link
2088 * \return 0 on success or -1 on failure
2090 int ast_channel_sendurl(struct ast_channel *channel, const char *url);
2093 * \brief Defers DTMF so that you only read things like hangups and audio.
2094 * \return non-zero if channel was already DTMF-deferred or
2095 * 0 if channel is just now being DTMF-deferred
2097 int ast_channel_defer_dtmf(struct ast_channel *chan);
2099 /*! Undo defer. ast_read will return any DTMF characters that were queued */
2100 void ast_channel_undefer_dtmf(struct ast_channel *chan);
2102 /*! Initiate system shutdown -- prevents new channels from being allocated.
2103 * \param hangup If "hangup" is non-zero, all existing channels will receive soft
2105 void ast_begin_shutdown(int hangup);
2107 /*! Cancels an existing shutdown and returns to normal operation */
2108 void ast_cancel_shutdown(void);
2110 /*! \return number of channels available for lookup */
2111 int ast_active_channels(void);
2113 /*! \return the number of channels not yet destroyed */
2114 int ast_undestroyed_channels(void);
2116 /*! \return non-zero if Asterisk is being shut down */
2117 int ast_shutting_down(void);
2119 /*! Activate a given generator */
2120 int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);
2122 /*! Deactivate an active generator */
2123 void ast_deactivate_generator(struct ast_channel *chan);
2126 * \brief Set caller ID number, name and ANI and generate AMI event.
2128 * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead.
2129 * \note The channel does not need to be locked before calling this function.
2131 void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani);
2134 * \brief Set the caller id information in the Asterisk channel
2137 * \param chan Asterisk channel to set caller id information
2138 * \param caller Caller id information
2139 * \param update What caller information to update. NULL if all.
2143 * \note The channel does not need to be locked before calling this function.
2145 void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2148 * \brief Set the caller id information in the Asterisk channel and generate an AMI event
2149 * if the caller id name or number changed.
2152 * \param chan Asterisk channel to set caller id information
2153 * \param caller Caller id information
2154 * \param update What caller information to update. NULL if all.
2158 * \note The channel does not need to be locked before calling this function.
2160 void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2162 /*! Set the file descriptor on the channel */
2163 void ast_channel_set_fd(struct ast_channel *chan, int which, int fd);
2165 /*! Add a channel to an optimized waitfor */
2166 void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1);
2168 /*! Delete a channel from an optimized waitfor */
2169 void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1);
2171 /*! Start a tone going */
2172 int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2173 /*! Stop a tone from playing */
2174 void ast_tonepair_stop(struct ast_channel *chan);
2175 /*! Play a tone pair for a given amount of time */
2176 int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2179 * \brief Automatically service a channel for us...
2182 * \retval -1 failure, or the channel is already being autoserviced
2184 int ast_autoservice_start(struct ast_channel *chan);
2187 * \brief Stop servicing a channel for us...
2189 * \note if chan is locked prior to calling ast_autoservice_stop, it
2190 * is likely that there will be a deadlock between the thread that calls
2191 * ast_autoservice_stop and the autoservice thread. It is important
2192 * that chan is not locked prior to this call
2196 * \retval -1 error, or the channel has been hungup
2198 int ast_autoservice_stop(struct ast_channel *chan);
2201 * \brief Ignore certain frame types
2202 * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames
2203 * while a channel is in autoservice and queue them up when taken out of
2204 * autoservice. When this is not desireable, this API may be used to
2205 * cause the channel to ignore those frametypes after the channel is put
2206 * into autoservice, but before autoservice is stopped.
2208 * \retval -1 channel is not in autoservice
2210 int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype);
2213 * \brief Enable or disable timer ticks for a channel
2216 * \param rate number of timer ticks per second
2217 * \param func callback function
2221 * If timers are supported, force a scheduled expiration on the
2222 * timer fd, at which point we call the callback function / data
2224 * \note Call this function with a rate of 0 to turn off the timer ticks
2226 * \version 1.6.1 changed samples parameter to rate, accomodates new timing methods
2228 int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data);
2231 * \brief Transfer a channel (if supported).
2232 * \retval -1 on error
2233 * \retval 0 if not supported
2234 * \retval 1 if supported and requested
2235 * \param chan current channel
2236 * \param dest destination extension for transfer
2238 int ast_transfer(struct ast_channel *chan, char *dest);
2241 * \brief Start masquerading a channel
2242 * \note absolutely _NO_ channel locks should be held before calling this function.
2244 * XXX This is a seriously whacked out operation. We're essentially putting the guts of
2245 * the clone channel into the original channel. Start by killing off the original
2246 * channel's backend. I'm not sure we're going to keep this function, because
2247 * while the features are nice, the cost is very high in terms of pure nastiness. XXX
2248 * \param chan Channel to masquerade
2250 int ast_do_masquerade(struct ast_channel *chan);
2253 * \brief Find bridged channel
2255 * \note This function does _not_ return a reference to the bridged channel.
2256 * The reason for this is mostly historical. It _should_ return a reference,
2257 * but it will take a lot of work to make the code base account for that.
2258 * So, for now, the old rules still apply for how to handle this function.
2259 * If this function is being used from the channel thread that owns the channel,
2260 * then a reference is already held, and channel locking is not required to
2261 * guarantee that the channel will stay around. If this function is used
2262 * outside of the associated channel thread, the channel parameter 'chan'
2263 * MUST be locked before calling this function. Also, 'chan' must remain locked
2264 * for the entire time that the result of this function is being used.
2266 * \param chan Current channel
2268 * \return A pointer to the bridged channel
2270 struct ast_channel *ast_bridged_channel(struct ast_channel *chan);
2273 * \brief Inherits channel variable from parent to child channel
2274 * \param parent Parent channel
2275 * \param child Child channel
2278 * Scans all channel variables in the parent channel, looking for those
2279 * that should be copied into the child channel.
2280 * Variables whose names begin with a single '_' are copied into the
2281 * child channel with the prefix removed.
2282 * Variables whose names begin with '__' are copied into the child
2283 * channel with their names unchanged.
2285 void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child);
2288 * \brief adds a list of channel variables to a channel
2289 * \param chan the channel
2290 * \param vars a linked list of variables
2293 * Variable names can be for a regular channel variable or a dialplan function
2294 * that has the ability to be written to.
2296 void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars);
2299 * \brief An opaque 'object' structure use by silence generators on channels.
2301 struct ast_silence_generator;
2304 * \brief Starts a silence generator on the given channel.
2305 * \param chan The channel to generate silence on
2306 * \return An ast_silence_generator pointer, or NULL if an error occurs
2309 * This function will cause SLINEAR silence to be generated on the supplied
2310 * channel until it is disabled; if the channel cannot be put into SLINEAR
2311 * mode then the function will fail.
2314 * The pointer returned by this function must be preserved and passed to
2315 * ast_channel_stop_silence_generator when you wish to stop the silence
2318 struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_channel *chan);
2321 * \brief Stops a previously-started silence generator on the given channel.
2322 * \param chan The channel to operate on
2323 * \param state The ast_silence_generator pointer return by a previous call to
2324 * ast_channel_start_silence_generator.
2328 * This function will stop the operating silence generator and return the channel
2329 * to its previous write format.
2331 void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state);
2334 * \brief Check if the channel can run in internal timing mode.
2335 * \param chan The channel to check
2339 * This function will return 1 if internal timing is enabled and the timing
2340 * device is available.
2342 int ast_internal_timing_enabled(struct ast_channel *chan);
2344 /* Misc. functions below */
2347 * \brief if fd is a valid descriptor, set *pfd with the descriptor
2348 * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the
2349 * return value to the index into the array)
2351 static inline int ast_add_fd(struct pollfd *pfd, int fd)
2354 pfd->events = POLLIN | POLLPRI;
2358 /*! \brief Helper function for migrating select to poll */
2359 static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
2368 for (x = *start; x < maximum; x++)
2369 if (pfds[x].fd == fd) {
2372 return pfds[x].revents;
2377 /*! \brief Retrieves the current T38 state of a channel */
2378 static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
2380 enum ast_t38_state state = T38_STATE_UNAVAILABLE;
2381 int datalen = sizeof(state);
2383 ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0);
2388 #define CHECK_BLOCKING(c) do { \
2389 if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) {\
2390 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)); \
2392 ast_channel_blocker_set((c), pthread_self()); \
2393 ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
2394 ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
2397 ast_group_t ast_get_group(const char *s);
2399 /*! \brief print call- and pickup groups into buffer */
2400 char *ast_print_group(char *buf, int buflen, ast_group_t group);
2403 * \brief Convert enum channelreloadreason to text string for manager event
2404 * \param reason The reason for reload (manager, cli, start etc)
2406 const char *channelreloadreason2txt(enum channelreloadreason reason);
2408 /*! \brief return an ast_variable list of channeltypes */
2409 struct ast_variable *ast_channeltype_list(void);
2412 * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
2413 * \param reason The integer argument, usually taken from AST_CONTROL_ macros
2414 * \return char pointer explaining the code
2416 const char *ast_channel_reason2str(int reason);
2418 /*! \brief channel group info */
2419 struct ast_group_info {
2420 struct ast_channel *chan;
2423 AST_LIST_ENTRY(ast_group_info) group_list;
2426 #define ast_channel_lock(chan) ao2_lock(chan)
2427 #define ast_channel_unlock(chan) ao2_unlock(chan)
2428 #define ast_channel_trylock(chan) ao2_trylock(chan)
2431 * \brief Lock two channels.
2433 #define ast_channel_lock_both(chan1, chan2) do { \
2434 ast_channel_lock(chan1); \
2435 while (ast_channel_trylock(chan2)) { \
2436 ast_channel_unlock(chan1); \
2438 ast_channel_lock(chan1); \
2443 * \brief Increase channel reference count
2445 * \param c the channel
2451 #define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); })
2454 * \brief Decrease channel reference count
2456 * \param c the channel
2458 * \retval NULL always
2462 #define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
2464 /*! Channel Iterating @{ */
2467 * \brief A channel iterator
2469 * This is an opaque type.
2471 struct ast_channel_iterator;
2474 * \brief Destroy a channel iterator
2476 * \param i the itereator to destroy
2479 * This function is used to destroy a channel iterator that was retrieved by
2480 * using one of the channel_iterator_xxx_new() functions.
2482 * \return NULL, for convenience to clear out the pointer to the iterator that
2483 * was just destroyed.
2487 struct ast_channel_iterator *ast_channel_iterator_destroy(struct ast_channel_iterator *i);
2490 * \brief Create a new channel iterator based on extension
2492 * \param exten The extension that channels must be in
2493 * \param context The context that channels must be in
2496 * After creating an iterator using this function, the ast_channel_iterator_next()
2497 * function can be used to iterate through all channels that are currently
2498 * in the specified context and extension.
2500 * \note You must call ast_channel_iterator_destroy() when done.
2502 * \retval NULL on failure
2503 * \retval a new channel iterator based on the specified parameters
2507 struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context);
2510 * \brief Create a new channel iterator based on name
2512 * \param name channel name or channel uniqueid to match
2513 * \param name_len number of characters in the channel name to match on. This
2514 * would be used to match based on name prefix. If matching on the full
2515 * channel name is desired, then this parameter should be 0.
2518 * After creating an iterator using this function, the ast_channel_iterator_next()
2519 * function can be used to iterate through all channels that exist that have
2520 * the specified name or name prefix.
2522 * \note You must call ast_channel_iterator_destroy() when done.
2524 * \retval NULL on failure
2525 * \retval a new channel iterator based on the specified parameters
2529 struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name, size_t name_len);
2532 * \brief Create a new channel iterator
2535 * After creating an iterator using this function, the ast_channel_iterator_next()
2536 * function can be used to iterate through all channels that exist.
2538 * \note You must call ast_channel_iterator_destroy() when done.
2540 * \retval NULL on failure
2541 * \retval a new channel iterator
2545 struct ast_channel_iterator *ast_channel_iterator_all_new(void);
2548 * \brief Get the next channel for a channel iterator
2550 * \param i the channel iterator that was created using one of the
2551 * channel_iterator_xxx_new() functions.
2554 * This function should be used to iterate through all channels that match a
2555 * specified set of parameters that were provided when the iterator was created.
2557 * \retval the next channel that matches the parameters used when the iterator
2559 * \retval NULL, if no more channels match the iterator parameters.
2563 struct ast_channel *ast_channel_iterator_next(struct ast_channel_iterator *i);
2565 /*! @} End channel iterator definitions. */
2568 * \brief Call a function with every active channel
2571 * This function executes a callback one time for each active channel on the
2572 * system. The channel is provided as an argument to the function.
2574 * \note Absolutely _NO_ channel locks should be held before calling this function.
2577 struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
2578 void *data, int ao2_flags);
2580 /*! @{ Channel search functions */
2583 * \brief Find a channel by name
2585 * \param name the name or uniqueid of the channel to search for
2588 * Find a channel that has the same name as the provided argument.
2590 * \retval a channel with the name specified by the argument
2591 * \retval NULL if no channel was found
2595 struct ast_channel *ast_channel_get_by_name(const char *name);
2598 * \brief Find a channel by a name prefix
2600 * \param name The channel name or uniqueid prefix to search for
2601 * \param name_len Only search for up to this many characters from the name
2604 * Find a channel that has the same name prefix as specified by the arguments.
2606 * \retval a channel with the name prefix specified by the arguments
2607 * \retval NULL if no channel was found
2611 struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
2614 * \brief Find a channel by extension and context
2616 * \param exten the extension to search for
2617 * \param context the context to search for
2620 * Return a channel that is currently at the specified extension and context.
2622 * \retval a channel that is at the specified extension and context
2623 * \retval NULL if no channel was found
2627 struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
2629 /*! @} End channel search functions. */
2632 \brief propagate the linked id between chan and peer
2634 void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer);
2638 * \brief Initialize the given name structure.
2641 * \param init Name structure to initialize.
2645 void ast_party_name_init(struct ast_party_name *init);
2648 * \brief Copy the source party name information to the destination party name.
2651 * \param dest Destination party name
2652 * \param src Source party name
2656 void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src);
2659 * \brief Initialize the given party name structure using the given guide
2660 * for a set update operation.
2664 * The initialization is needed to allow a set operation to know if a
2665 * value needs to be updated. Simple integers need the guide's original
2666 * value in case the set operation is not trying to set a new value.
2667 * String values are simply set to NULL pointers if they are not going
2670 * \param init Party name structure to initialize.
2671 * \param guide Source party name to use as a guide in initializing.
2675 void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide);
2678 * \brief Set the source party name information into the destination party name.
2681 * \param dest The name one wishes to update
2682 * \param src The new name values to update the dest
2686 void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src);
2689 * \brief Destroy the party name contents
2692 * \param doomed The party name to destroy.
2696 void ast_party_name_free(struct ast_party_name *doomed);
2699 * \brief Initialize the given number structure.
2702 * \param init Number structure to initialize.
2706 void ast_party_number_init(struct ast_party_number *init);
2709 * \brief Copy the source party number information to the destination party number.
2712 * \param dest Destination party number
2713 * \param src Source party number
2717 void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src);
2720 * \brief Initialize the given party number structure using the given guide
2721 * for a set update operation.
2725 * The initialization is needed to allow a set operation to know if a
2726 * value needs to be updated. Simple integers need the guide's original
2727 * value in case the set operation is not trying to set a new value.
2728 * String values are simply set to NULL pointers if they are not going
2731 * \param init Party number structure to initialize.
2732 * \param guide Source party number to use as a guide in initializing.
2736 void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide);
2739 * \brief Set the source party number information into the destination party number.
2742 * \param dest The number one wishes to update
2743 * \param src The new number values to update the dest
2747 void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src);
2750 * \brief Destroy the party number contents
2753 * \param doomed The party number to destroy.
2757 void ast_party_number_free(struct ast_party_number *doomed);
2761 * \brief Initialize the given subaddress structure.
2763 * \param init Subaddress structure to initialize.
2767 void ast_party_subaddress_init(struct ast_party_subaddress *init);
2771 * \brief Copy the source party subaddress information to the destination party subaddress.
2773 * \param dest Destination party subaddress
2774 * \param src Source party subaddress
2778 void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
2782 * \brief Initialize the given party subaddress structure using the given guide
2783 * for a set update operation.
2786 * The initialization is needed to allow a set operation to know if a
2787 * value needs to be updated. Simple integers need the guide's original
2788 * value in case the set operation is not trying to set a new value.
2789 * String values are simply set to NULL pointers if they are not going
2792 * \param init Party subaddress structure to initialize.
2793 * \param guide Source party subaddress to use as a guide in initializing.
2797 void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide);
2801 * \brief Set the source party subaddress information into the destination party subaddress.
2803 * \param dest The subaddress one wishes to update
2804 * \param src The new subaddress values to update the dest
2808 void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
2812 * \brief Destroy the party subaddress contents
2814 * \param doomed The party subaddress to destroy.
2818 void ast_party_subaddress_free(struct ast_party_subaddress *doomed);
2821 * \brief Initialize the given party id structure.
2824 * \param init Party id structure to initialize.
2828 void ast_party_id_init(struct ast_party_id *init);
2831 * \brief Copy the source party id information to the destination party id.
2834 * \param dest Destination party id
2835 * \param src Source party id
2839 void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src);
2842 * \brief Initialize the given party id structure using the given guide
2843 * for a set update operation.
2847 * The initialization is needed to allow a set operation to know if a
2848 * value needs to be updated. Simple integers need the guide's original
2849 * value in case the set operation is not trying to set a new value.
2850 * String values are simply set to NULL pointers if they are not going
2853 * \param init Party id structure to initialize.
2854 * \param guide Source party id to use as a guide in initializing.
2858 void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide);
2861 * \brief Set the source party id information into the destination party id.
2864 * \param dest The id one wishes to update
2865 * \param src The new id values to update the dest
2866 * \param update What id information to update. NULL if all.
2870 void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update);
2873 * \brief Destroy the party id contents
2876 * \param doomed The party id to destroy.
2880 void ast_party_id_free(struct ast_party_id *doomed);
2883 * \brief Determine the overall presentation value for the given party.
2886 * \param id Party to determine the overall presentation value.
2888 * \return Overall presentation value for the given party.
2890 int ast_party_id_presentation(const struct ast_party_id *id);
2893 * \brief Initialize the given dialed structure.
2896 * \param init Dialed structure to initialize.
2900 void ast_party_dialed_init(struct ast_party_dialed *init);
2903 * \brief Copy the source dialed party information to the destination dialed party.
2906 * \param dest Destination dialed party
2907 * \param src Source dialed party
2911 void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
2914 * \brief Initialize the given dialed structure using the given
2915 * guide for a set update operation.
2919 * The initialization is needed to allow a set operation to know if a
2920 * value needs to be updated. Simple integers need the guide's original
2921 * value in case the set operation is not trying to set a new value.
2922 * String values are simply set to NULL pointers if they are not going
2925 * \param init Caller structure to initialize.
2926 * \param guide Source dialed to use as a guide in initializing.
2930 void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide);
2933 * \brief Set the dialed information based on another dialed source
2936 * This is similar to ast_party_dialed_copy, except that NULL values for
2937 * strings in the src parameter indicate not to update the corresponding dest values.
2939 * \param dest The dialed one wishes to update
2940 * \param src The new dialed values to update the dest
2944 void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
2947 * \brief Destroy the dialed party contents
2950 * \param doomed The dialed party to destroy.
2954 void ast_party_dialed_free(struct ast_party_dialed *doomed);
2958 * \brief Initialize the given caller structure.
2960 * \param init Caller structure to initialize.
2964 void ast_party_caller_init(struct ast_party_caller *init);
2968 * \brief Copy the source caller information to the destination caller.
2970 * \param dest Destination caller
2971 * \param src Source caller
2975 void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src);
2978 * \brief Initialize the given caller structure using the given
2979 * guide for a set update operation.
2983 * The initialization is needed to allow a set operation to know if a
2984 * value needs to be updated. Simple integers need the guide's original
2985 * value in case the set operation is not trying to set a new value.
2986 * String values are simply set to NULL pointers if they are not going
2989 * \param init Caller structure to initialize.
2990 * \param guide Source caller to use as a guide in initializing.
2994 void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide);
2997 * \brief Set the caller information based on another caller source
3000 * This is similar to ast_party_caller_copy, except that NULL values for
3001 * strings in the src parameter indicate not to update the corresponding dest values.
3003 * \param dest The caller one wishes to update
3004 * \param src The new caller values to update the dest
3005 * \param update What caller information to update. NULL if all.
3009 void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update);
3012 * \brief Destroy the caller party contents
3015 * \param doomed The caller party to destroy.
3019 void ast_party_caller_free(struct ast_party_caller *doomed);
3023 * \brief Initialize the given connected line structure.
3025 * \param init Connected line structure to initialize.
3029 void ast_party_connected_line_init(struct ast_party_connected_line *init);
3033 * \brief Copy the source connected line information to the destination connected line.
3035 * \param dest Destination connected line
3036 * \param src Source connected line
3040 void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src);
3044 * \brief Initialize the given connected line structure using the given
3045 * guide for a set update operation.
3048 * The initialization is needed to allow a set operation to know if a
3049 * value needs to be updated. Simple integers need the guide's original
3050 * value in case the set operation is not trying to set a new value.
3051 * String values are simply set to NULL pointers if they are not going
3054 * \param init Connected line structure to initialize.
3055 * \param guide Source connected line to use as a guide in initializing.
3059 void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide);
3063 * \brief Set the connected line information based on another connected line source
3065 * This is similar to ast_party_connected_line_copy, except that NULL values for
3066 * strings in the src parameter indicate not to update the corresponding dest values.
3068 * \param dest The connected line one wishes to update
3069 * \param src The new connected line values to update the dest
3070 * \param update What connected line information to update. NULL if all.
3074 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);
3078 * \brief Collect the caller party information into a connected line structure.
3080 * \param connected Collected caller information for the connected line
3081 * \param caller Caller information.
3085 * \warning This is a shallow copy.
3086 * \warning DO NOT call ast_party_connected_line_free() on the filled in
3087 * connected line structure!
3089 void ast_party_connected_line_collect_caller(struct ast_party_connected_line *connected, struct ast_party_caller *caller);
3093 * \brief Destroy the connected line information contents
3095 * \param doomed The connected line information to destroy.
3099 void ast_party_connected_line_free(struct ast_party_connected_line *doomed);
3102 * \brief Initialize the given redirecting structure.
3105 * \param init Redirecting structure to initialize.
3109 void ast_party_redirecting_init(struct ast_party_redirecting *init);
3113 * \brief Copy the source redirecting information to the destination redirecting.
3115 * \param dest Destination redirecting
3116 * \param src Source redirecting
3120 void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src);
3124 * \brief Initialize the given redirecting id structure using the given guide
3125 * for a set update operation.
3128 * The initialization is needed to allow a set operation to know if a
3129 * value needs to be updated. Simple integers need the guide's original
3130 * value in case the set operation is not trying to set a new value.
3131 * String values are simply set to NULL pointers if they are not going
3134 * \param init Redirecting id structure to initialize.
3135 * \param guide Source redirecting id to use as a guide in initializing.
3139 void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide);
3142 * \brief Set the redirecting information based on another redirecting source
3145 * This is similar to ast_party_redirecting_copy, except that NULL values for
3146 * strings in the src parameter indicate not to update the corresponding dest values.
3148 * \param dest The redirecting one wishes to update
3149 * \param src The new redirecting values to update the dest
3150 * \param update What redirecting information to update. NULL if all.
3154 void ast_party_redirecting_set(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update);
3158 * \brief Destroy the redirecting information contents
3160 * \param doomed The redirecting information to destroy.
3164 void ast_party_redirecting_free(struct ast_party_redirecting *doomed);
3168 * \brief Copy the caller information to the connected line information.
3170 * \param dest Destination connected line information
3171 * \param src Source caller information
3175 * \note Assumes locks are already acquired
3177 void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src);
3181 * \brief Copy the connected line information to the caller information.
3183 * \param dest Destination caller information
3184 * \param src Source connected line information
3188 * \note Assumes locks are already acquired
3190 void ast_connected_line_copy_to_caller(struct ast_party_caller *dest, const struct ast_party_connected_line *src);
3194 * \brief Set the connected line information in the Asterisk channel
3196 * \param chan Asterisk channel to set connected line information
3197 * \param connected Connected line information
3198 * \param update What connected line information to update. NULL if all.
3202 * \note The channel does not need to be locked before calling this function.
3204 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);
3208 * \brief Build the connected line information data frame.
3210 * \param data Buffer to fill with the frame data
3211 * \param datalen Size of the buffer to fill
3212 * \param connected Connected line information
3213 * \param update What connected line information to build. NULL if all.
3215 * \retval -1 if error
3216 * \retval Amount of data buffer used
3218 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);
3222 * \brief Parse connected line indication frame data
3224 * \param data Buffer with the frame data to parse
3225 * \param datalen Size of the buffer
3226 * \param connected Extracted connected line information
3228 * \retval 0 on success.
3229 * \retval -1 on error.
3231 * \note The filled in connected line structure needs to be initialized by
3232 * ast_party_connected_line_set_init() before calling. If defaults are not
3233 * required use ast_party_connected_line_init().
3234 * \note The filled in connected line structure needs to be destroyed by
3235 * ast_party_connected_line_free() when it is no longer needed.
3237 int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected);
3241 * \brief Indicate that the connected line information has changed
3243 * \param chan Asterisk channel to indicate connected line information
3244 * \param connected Connected line information
3245 * \param update What connected line information to update. NULL if all.
3249 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);
3253 * \brief Queue a connected line update frame on a channel
3255 * \param chan Asterisk channel to indicate connected line information
3256 * \param connected Connected line information
3257 * \param update What connected line information to update. NULL if all.
3261 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);
3265 * \brief Set the redirecting id information in the Asterisk channel
3267 * \param chan Asterisk channel to set redirecting id information
3268 * \param redirecting Redirecting id information
3269 * \param update What redirecting information to update. NULL if all.
3273 * \note The channel does not need to be locked before calling this function.
3275 void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3279 * \brief Build the redirecting id data frame.
3281 * \param data Buffer to fill with the frame data
3282 * \param datalen Size of the buffer to fill
3283 * \param redirecting Redirecting id information
3284 * \param update What redirecting information to build. NULL if all.
3286 * \retval -1 if error
3287 * \retval Amount of data buffer used
3289 int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3293 * \brief Parse redirecting indication frame data
3295 * \param data Buffer with the frame data to parse
3296 * \param datalen Size of the buffer
3297 * \param redirecting Extracted redirecting id information
3299 * \retval 0 on success.
3300 * \retval -1 on error.
3302 * \note The filled in id structure needs to be initialized by
3303 * ast_party_redirecting_set_init() before calling.
3304 * \note The filled in id structure needs to be destroyed by
3305 * ast_party_redirecting_free() when it is no longer needed.
3307 int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting);
3311 * \brief Indicate that the redirecting id has changed
3313 * \param chan Asterisk channel to indicate redirecting id information
3314 * \param redirecting Redirecting id information
3315 * \param update What redirecting information to update. NULL if all.
3319 void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3323 * \brief Queue a redirecting update frame on a channel
3325 * \param chan Asterisk channel to indicate redirecting id information
3326 * \param redirecting Redirecting id information
3327 * \param update What redirecting information to update. NULL if all.
3331 void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3335 * \brief Run a connected line interception macro and update a channel's connected line
3337 * \deprecated You should use the ast_channel_connected_line_sub() function instead.
3339 * Whenever we want to update a channel's connected line information, we may need to run
3340 * a macro so that an administrator can manipulate the information before sending it
3341 * out. This function both runs the macro and sends the update to the channel.
3343 * \param autoservice_chan Channel to place into autoservice while the macro is running.
3344 * It is perfectly safe for this to be NULL
3345 * \param macro_chan The channel to run the macro on. Also the channel from which we
3346 * determine which macro we need to run.
3347 * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
3348 * AST_CONTROL_CONNECTED_LINE
3349 * \param is_caller If true, then run CONNECTED_LINE_CALLER_SEND_MACRO with arguments from
3350 * CONNECTED_LINE_CALLER_SEND_MACRO_ARGS, otherwise run CONNECTED_LINE_CALLEE_SEND_MACRO
3351 * with arguments from CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS
3352 * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
3353 * ast_party_connected_line pointer.
3355 * \retval -1 Either the macro does not exist, or there was an error while attempting to
3358 * \todo Have multiple return codes based on the MACRO_RESULT
3359 * \todo Make constants so that caller and frame can be more expressive than just '1' and
3362 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);
3366 * \brief Run a connected line interception subroutine and update a channel's connected line
3369 * Whenever we want to update a channel's connected line information, we may need to run
3370 * a subroutine so that an administrator can manipulate the information before sending it
3371 * out. This function both runs the subroutine specified by CONNECTED_LINE_SEND_SUB and
3372 * sends the update to the channel.
3374 * \param autoservice_chan Channel to place into autoservice while the sub is running.
3375 * It is perfectly safe for this to be NULL
3376 * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3377 * determine which subroutine we need to run.
3378 * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
3379 * AST_CONTROL_CONNECTED_LINE
3380 * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
3381 * ast_party_connected_line pointer.
3383 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3384 * run the subroutine
3386 int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame);
3389 * \brief Insert into an astdata tree, the channel structure.
3390 * \param[in] tree The ast data tree.
3391 * \param[in] chan The channel structure to add to tree.
3392 * \param[in] add_bridged Add the bridged channel to the structure.
3393 * \retval <0 on error.
3394 * \retval 0 on success.
3396 int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan, int add_bridged);
3399 * \brief Compare to channel structures using the data api.
3400 * \param[in] tree The search tree generated by the data api.
3401 * \param[in] chan The channel to compare.
3402 * \param[in] structure_name The name of the node of the channel structure.
3403 * \retval 0 The structure matches.
3404 * \retval 1 The structure doesn't matches.
3406 int ast_channel_data_cmp_structure(const struct ast_data_search *tree, struct ast_channel *chan,
3407 const char *structure_name);
3411 * \brief Run a redirecting interception macro and update a channel's redirecting information
3412 * \deprecated You should use the ast_channel_redirecting_sub() function instead.
3415 * Whenever we want to update a channel's redirecting information, we may need to run
3416 * a macro so that an administrator can manipulate the information before sending it
3417 * out. This function both runs the macro and sends the update to the channel.
3419 * \param autoservice_chan Channel to place into autoservice while the macro is running.
3420 * It is perfectly safe for this to be NULL
3421 * \param macro_chan The channel to run the macro on. Also the channel from which we
3422 * determine which macro we need to run.
3423 * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
3424 * AST_CONTROL_REDIRECTING
3425 * \param is_caller If true, then run REDIRECTING_CALLER_SEND_MACRO with arguments from
3426 * REDIRECTING_CALLER_SEND_MACRO_ARGS, otherwise run REDIRECTING_CALLEE_SEND_MACRO with
3427 * arguments from REDIRECTING_CALLEE_SEND_MACRO_ARGS
3428 * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
3429 * ast_party_redirecting pointer.
3432 * \retval -1 Either the macro does not exist, or there was an error while attempting to
3435 * \todo Have multiple return codes based on the MACRO_RESULT
3436 * \todo Make constants so that caller and frame can be more expressive than just '1' and
3439 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);
3443 * \brief Run a redirecting interception subroutine and update a channel's redirecting information
3446 * Whenever we want to update a channel's redirecting information, we may need to run
3447 * a subroutine so that an administrator can manipulate the information before sending it
3448 * out. This function both runs the subroutine specified by REDIRECTING_SEND_SUB and
3449 * sends the update to the channel.
3451 * \param autoservice_chan Channel to place into autoservice while the subroutine is running.
3452 * It is perfectly safe for this to be NULL
3453 * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3454 * determine which subroutine we need to run.
3455 * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
3456 * AST_CONTROL_REDIRECTING
3457 * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
3458 * ast_party_redirecting pointer.
3461 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3462 * run the subroutine
3464 int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame);
3466 #include "asterisk/ccss.h"
3470 * \brief Set up datastore with CCSS parameters for a channel
3473 * If base_params is NULL, the channel will get the default
3474 * values for all CCSS parameters.
3477 * This function makes use of datastore operations on the channel, so
3478 * it is important to lock the channel before calling this function.
3480 * \param chan The channel to create the datastore on
3481 * \param base_params CCSS parameters we wish to copy into the channel
3483 * \retval -1 Failure
3485 int ast_channel_cc_params_init(struct ast_channel *chan,
3486 const struct ast_cc_config_params *base_params);
3490 * \brief Get the CCSS parameters from a channel
3493 * This function makes use of datastore operations on the channel, so
3494 * it is important to lock the channel before calling this function.
3496 * \param chan Channel to retrieve parameters from
3497 * \retval NULL Failure
3498 * \retval non-NULL The parameters desired
3500 struct ast_cc_config_params *ast_channel_get_cc_config_params(struct ast_channel *chan);
3505 * \brief Get a device name given its channel structure
3508 * A common practice in Asterisk is to determine the device being talked
3509 * to by dissecting the channel name. For certain channel types, this is not
3510 * accurate. For instance, an ISDN channel is named based on what B channel is
3511 * used, not the device being communicated with.
3513 * This function interfaces with a channel tech's queryoption callback to
3514 * retrieve the name of the device being communicated with. If the channel does not
3515 * implement this specific option, then the traditional method of using the channel
3516 * name is used instead.
3518 * \param chan The channel to retrieve the information from
3519 * \param[out] device_name The buffer to place the device's name into
3520 * \param name_buffer_length The allocated space for the device_name
3523 int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length);
3527 * \brief Find the appropriate CC agent type to use given a channel
3530 * During call completion, we will need to create a call completion agent structure. To
3531 * figure out the type of agent to construct, we need to ask the channel driver for the
3534 * Prior to adding this function, the call completion core attempted to figure this
3535 * out for itself by stripping the technology off the channel's name. However, in the
3536 * case of chan_dahdi, there are multiple agent types registered, and so simply searching
3537 * for an agent type called "DAHDI" is not possible. In a case where multiple agent types
3538 * are defined, the channel driver must have a queryoption callback defined in its
3539 * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE
3541 * If a channel driver does not have a queryoption callback or if the queryoption callback
3542 * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology
3543 * portion of the channel name is used instead. This is perfectly suitable for channel drivers
3544 * whose channel technologies are a one-to-one match with the agent types defined within.
3546 * Note that this function is only called when the agent policy on a given channel is set
3547 * to "native." Generic agents' type can be determined automatically by the core.
3549 * \param chan The channel for which we wish to retrieve the agent type
3550 * \param[out] agent_type The type of agent the channel driver wants us to use
3551 * \param size The size of the buffer to write to
3553 int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size);
3554 #if defined(__cplusplus) || defined(c_plusplus)
3559 * \brief Remove a channel from the global channels container
3561 * \param chan channel to remove
3563 * In a case where it is desired that a channel not be available in any lookups
3564 * in the global channels conatiner, use this function.
3566 void ast_channel_unlink(struct ast_channel *chan);
3568 /* ACCESSOR FUNTIONS */
3569 /*! \brief Set the channel name */
3570 void ast_channel_name_set(struct ast_channel *chan, const char *name);
3572 #define DECLARE_STRINGFIELD_SETTERS_FOR(field) \
3573 void ast_channel_##field##_set(struct ast_channel *chan, const char *field); \
3574 void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0))); \
3575 void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) __attribute__((format(printf, 2, 3)))
3577 DECLARE_STRINGFIELD_SETTERS_FOR(name);
3578 DECLARE_STRINGFIELD_SETTERS_FOR(language);
3579 DECLARE_STRINGFIELD_SETTERS_FOR(musicclass);
3580 DECLARE_STRINGFIELD_SETTERS_FOR(accountcode);
3581 DECLARE_STRINGFIELD_SETTERS_FOR(peeraccount);
3582 DECLARE_STRINGFIELD_SETTERS_FOR(userfield);
3583 DECLARE_STRINGFIELD_SETTERS_FOR(call_forward);
3584 DECLARE_STRINGFIELD_SETTERS_FOR(uniqueid);
3585 DECLARE_STRINGFIELD_SETTERS_FOR(linkedid);
3586 DECLARE_STRINGFIELD_SETTERS_FOR(parkinglot);
3587 DECLARE_STRINGFIELD_SETTERS_FOR(hangupsource);
3588 DECLARE_STRINGFIELD_SETTERS_FOR(dialcontext);
3590 const char *ast_channel_name(const struct ast_channel *chan);
3591 const char *ast_channel_language(const struct ast_channel *chan);
3592 const char *ast_channel_musicclass(const struct ast_channel *chan);
3593 const char *ast_channel_accountcode(const struct ast_channel *chan);
3594 const char *ast_channel_peeraccount(const struct ast_channel *chan);
3595 const char *ast_channel_userfield(const struct ast_channel *chan);
3596 const char *ast_channel_call_forward(const struct ast_channel *chan);
3597 const char *ast_channel_uniqueid(const struct ast_channel *chan);
3598 const char *ast_channel_linkedid(const struct ast_channel *chan);
3599 const char *ast_channel_parkinglot(const struct ast_channel *chan);
3600 const char *ast_channel_hangupsource(const struct ast_channel *chan);
3601 const char *ast_channel_dialcontext(const struct ast_channel *chan);
3603 const char *ast_channel_appl(const struct ast_channel *chan);
3604 void ast_channel_appl_set(struct ast_channel *chan, const char *value);
3605 const char *ast_channel_blockproc(const struct ast_channel *chan);
3606 void ast_channel_blockproc_set(struct ast_channel *chan, const char *value);
3607 const char *ast_channel_data(const struct ast_channel *chan);
3608 void ast_channel_data_set(struct ast_channel *chan, const char *value);
3610 const char *ast_channel_context(const struct ast_channel *chan);
3611 void ast_channel_context_set(struct ast_channel *chan, const char *value);
3612 const char *ast_channel_exten(const struct ast_channel *chan);
3613 void ast_channel_exten_set(struct ast_channel *chan, const char *value);
3614 const char *ast_channel_macrocontext(const struct ast_channel *chan);
3615 void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value);
3616 const char *ast_channel_macroexten(const struct ast_channel *chan);
3617 void ast_channel_macroexten_set(struct ast_channel *chan, const char *value);
3619 char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan);
3620 void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value);
3621 int ast_channel_amaflags(const struct ast_channel *chan);
3622 void ast_channel_amaflags_set(struct ast_channel *chan, int value);
3623 int ast_channel_epfd(const struct ast_channel *chan);
3624 void ast_channel_epfd_set(struct ast_channel *chan, int value);
3625 int ast_channel_fdno(const struct ast_channel *chan);
3626 void ast_channel_fdno_set(struct ast_channel *chan, int value);
3627 int ast_channel_hangupcause(const struct ast_channel *chan);
3628 void ast_channel_hangupcause_set(struct ast_channel *chan, int value);
3629 int ast_channel_macropriority(const struct ast_channel *chan);
3630 void ast_channel_macropriority_set(struct ast_channel *chan, int value);
3631 int ast_channel_priority(const struct ast_channel *chan);
3632 void ast_channel_priority_set(struct ast_channel *chan, int value);
3633 int ast_channel_rings(const struct ast_channel *chan);
3634 void ast_channel_rings_set(struct ast_channel *chan, int value);
3635 int ast_channel_streamid(const struct ast_channel *chan);
3636 void ast_channel_streamid_set(struct ast_channel *chan, int value);
3637 int ast_channel_timingfd(const struct ast_channel *chan);
3638 void ast_channel_timingfd_set(struct ast_channel *chan, int value);
3639 int ast_channel_visible_indication(const struct ast_channel *chan);
3640 void ast_channel_visible_indication_set(struct ast_channel *chan, int value);
3641 int ast_channel_vstreamid(const struct ast_channel *chan);
3642 void ast_channel_vstreamid_set(struct ast_channel *chan, int value);
3643 unsigned short ast_channel_transfercapability(const struct ast_channel *chan);
3644 void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value);
3645 unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan);
3646 void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value);
3647 unsigned int ast_channel_fin(const struct ast_channel *chan);
3648 void ast_channel_fin_set(struct ast_channel *chan, unsigned int value);
3649 unsigned int ast_channel_fout(const struct ast_channel *chan);
3650 void ast_channel_fout_set(struct ast_channel *chan, unsigned int value);
3651 unsigned long ast_channel_insmpl(const struct ast_channel *chan);
3652 void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value);
3653 unsigned long ast_channel_outsmpl(const struct ast_channel *chan);
3654 void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value);
3655 void *ast_channel_generatordata(const struct ast_channel *chan);
3656 void ast_channel_generatordata_set(struct ast_channel *chan, void *value);
3657 void *ast_channel_music_state(const struct ast_channel *chan);
3658 void ast_channel_music_state_set(struct ast_channel *chan, void *value);
3659 void *ast_channel_tech_pvt(const struct ast_channel *chan);
3660 void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value);
3661 void *ast_channel_timingdata(const struct ast_channel *chan);
3662 void ast_channel_timingdata_set(struct ast_channel *chan, void *value);
3663 struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan);
3664 void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value);
3665 struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan);
3666 void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value);
3667 struct ast_channel *ast_channel__bridge(const struct ast_channel *chan);
3668 void ast_channel__bridge_set(struct ast_channel *chan, struct ast_channel *value);
3669 struct ast_channel *ast_channel_masq(const struct ast_channel *chan);
3670 void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value);
3671 struct ast_channel *ast_channel_masqr(const struct ast_channel *chan);
3672 void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value);
3673 struct ast_channel_monitor *ast_channel_monitor(const struct ast_channel *chan);
3674 void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value);
3675 struct ast_filestream *ast_channel_stream(const struct ast_channel *chan);
3676 void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value);
3677 struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan);
3678 void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value);
3679 struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan);
3680 void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value);
3681 struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan);
3682 void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value);
3683 struct ast_generator *ast_channel_generator(const struct ast_channel *chan);
3684 void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value);
3685 struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan);
3686 void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value);
3687 struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan);
3688 void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value);
3689 struct ast_timer *ast_channel_timer(const struct ast_channel *chan);
3690 void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value);
3691 struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan);
3692 void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value);
3693 struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan);
3694 void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
3695 struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan);
3696 void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
3697 const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan);
3698 void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value);
3699 enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan);
3700 void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value);
3701 enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
3702 struct ast_callid *ast_channel_callid(const struct ast_channel *chan);
3703 void ast_channel_callid_set(struct ast_channel *chan, struct ast_callid *value);
3705 /* XXX Internal use only, make sure to move later */
3706 void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
3707 void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value);
3708 void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value);
3709 void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value);
3710 void ast_channel_callid_cleanup(struct ast_channel *chan);
3711 int ast_channel_softhangup_internal_flag(struct ast_channel *chan);
3713 /* Format getters */
3714 struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan);
3715 struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan);
3716 struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan);
3717 struct ast_format *ast_channel_readformat(struct ast_channel *chan);
3718 struct ast_format *ast_channel_writeformat(struct ast_channel *chan);
3720 /* Other struct getters */
3721 struct ast_frame *ast_channel_dtmff(struct ast_channel *chan);
3722 struct ast_jb *ast_channel_jb(struct ast_channel *chan);
3723 struct ast_party_caller *ast_channel_caller(struct ast_channel *chan);
3724 struct ast_party_connected_line *ast_channel_connected(struct ast_channel *chan);
3725 struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan);
3726 struct ast_party_redirecting *ast_channel_redirecting(struct ast_channel *chan);
3727 struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan);
3728 struct timeval *ast_channel_whentohangup(struct ast_channel *chan);
3729 struct varshead *ast_channel_varshead(struct ast_channel *chan);
3731 void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value);
3732 void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value);
3733 void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value);
3734 void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value);
3735 void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value);
3736 void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value);
3737 void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value);
3738 void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value);
3739 void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value);
3742 struct ast_datastore_list *ast_channel_datastores(struct ast_channel *chan);
3743 struct ast_autochan_list *ast_channel_autochans(struct ast_channel *chan);
3744 struct ast_readq_list *ast_channel_readq(struct ast_channel *chan);
3746 /* Typedef accessors */
3747 ast_group_t ast_channel_callgroup(const struct ast_channel *chan);
3748 void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value);
3749 ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan);
3750 void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value);
3752 /* Alertpipe accessors--the "internal" functions for channel.c use only */
3754 AST_ALERT_READ_SUCCESS = 0,
3755 AST_ALERT_NOT_READABLE,
3756 AST_ALERT_READ_FAIL,
3757 AST_ALERT_READ_FATAL,
3758 } ast_alert_status_t;
3759 int ast_channel_alert_write(struct ast_channel *chan);
3760 int ast_channel_alert_writable(struct ast_channel *chan);
3761 ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan);
3762 int ast_channel_internal_alert_readable(struct ast_channel *chan);
3763 void ast_channel_internal_alertpipe_clear(struct ast_channel *chan);
3764 void ast_channel_internal_alertpipe_close(struct ast_channel *chan);
3765 int ast_channel_internal_alert_readfd(struct ast_channel *chan);
3766 int ast_channel_internal_alertpipe_init(struct ast_channel *chan);
3767 /*! \brief Swap the interal alertpipe between two channels
3768 * \note Handle all of the necessary locking before calling this
3770 void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2);
3772 /* file descriptor array accessors */
3773 void ast_channel_internal_fd_clear(struct ast_channel *chan, int which);
3774 void ast_channel_internal_fd_clear_all(struct ast_channel *chan);
3775 void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value);
3776 int ast_channel_fd(const struct ast_channel *chan, int which);
3777 int ast_channel_fd_isset(const struct ast_channel *chan, int which);
3779 /* epoll data internal accessors */
3781 struct ast_epoll_data *ast_channel_internal_epfd_data(const struct ast_channel *chan, int which);
3782 void ast_channel_internal_epfd_data_set(struct ast_channel *chan, int which , struct ast_epoll_data *value);
3785 pthread_t ast_channel_blocker(const struct ast_channel *chan);
3786 void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value);
3788 ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan);
3789 void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value);
3791 struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan);
3792 void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value);
3794 struct ast_channel *ast_channel_internal_bridged_channel(const struct ast_channel *chan);
3795 void ast_channel_internal_bridged_channel_set(struct ast_channel *chan, struct ast_channel *value);
3797 struct ast_flags *ast_channel_flags(struct ast_channel *chan);
3798 #endif /* _ASTERISK_CHANNEL_H */