Asterisk - The Open Source Telephony Project GIT-master-27fb039
Loading...
Searching...
No Matches
channel.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 1999 - 2006, Digium, Inc.
5 *
6 * Mark Spencer <markster@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*! \file
20 * \brief General Asterisk PBX channel definitions.
21 * \par See also:
22 * \arg \ref Def_Channel
23 * \arg \ref channel_drivers
24 */
25
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.
32 \par
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
37 channel.c .
38 \par Call scenario
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)
49 application
50 .
51
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
68 for the call.
69
70
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.
77
78 \par Reference
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
84 \arg \ref Def_Bridge
85
86*/
87/*! \page Def_Bridge Asterisk Channel Bridges
88
89 In Asterisk, there's several media bridges.
90
91 The Core bridge handles two channels (a "phone call") and bridge
92 them together.
93
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.
99
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
103 core.
104
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.
108
109References:
110 \li \see ast_channel_early_bridge()
111 \li \see ast_channel_bridge()
112 \li \see app_meetme.c
113 \li \see ast_rtp_bridge()
114 \li \ref Def_Channel
115*/
116
117/*! \page AstFileDesc File descriptors
118 Asterisk File descriptors are connected to each channel (see \ref Def_Channel)
119 in the \ref ast_channel structure.
120*/
121
122#ifndef _ASTERISK_CHANNEL_H
123#define _ASTERISK_CHANNEL_H
124
125#include "asterisk/alertpipe.h"
126#include "asterisk/abstract_jb.h"
127#include "asterisk/astobj2.h"
128#include "asterisk/poll-compat.h"
129
130#if defined(__cplusplus) || defined(c_plusplus)
131extern "C" {
132#endif
133
134#define AST_MAX_EXTENSION 80 /*!< Max length of an extension */
135#define AST_MAX_CONTEXT 80 /*!< Max length of a context */
136
137/*!
138 * Max length of a channel uniqueid reported to the outside world.
139 *
140 * \details
141 * 149 = 127 (max systemname) + "-" + 10 (epoch timestamp)
142 * + "." + 10 (monotonically incrementing integer).
143 *
144 * \note If this value is ever changed, MAX_CHANNEL_ID should
145 * be updated in rtp_engine.h.
146 */
147#define AST_MAX_PUBLIC_UNIQUEID 149
148
149#define AST_MAX_TENANT_ID 64 /*!< Max length of a channel tenant_id */
150
151/*!
152 * The number of buckets to store channels or channel information
153 */
154#ifdef LOW_MEMORY
155#define AST_NUM_CHANNEL_BUCKETS 61
156#else
157#define AST_NUM_CHANNEL_BUCKETS 1567
158#endif
159
160/*!
161 * Maximum size of an internal Asterisk channel unique ID.
162 *
163 * \details
164 * Add two for the Local;2 channel to append a ';2' if needed
165 * plus nul terminator.
166 *
167 * \note If this value is ever changed, MAX_CHANNEL_ID should
168 * be updated in rtp_engine.h.
169 */
170#define AST_MAX_UNIQUEID (AST_MAX_PUBLIC_UNIQUEID + 2 + 1)
171
172#define AST_MAX_ACCOUNT_CODE 80 /*!< Max length of an account code */
173#define AST_CHANNEL_NAME 80 /*!< Max length of an ast_channel name */
174#define MAX_LANGUAGE 40 /*!< Max length of the language setting */
175#define MAX_MUSICCLASS 80 /*!< Max length of the music class setting */
176#define AST_MAX_USER_FIELD 256 /*!< Max length of the channel user field */
177
178#include "asterisk/frame.h"
179#include "asterisk/chanvars.h"
180#include "asterisk/config.h"
181#include "asterisk/lock.h"
182#include "asterisk/cdr.h"
183#include "asterisk/utils.h"
184#include "asterisk/linkedlists.h"
186#include "asterisk/datastore.h"
187#include "asterisk/format_cap.h"
189#include "asterisk/ccss.h"
190#include "asterisk/framehook.h"
191#include "asterisk/stasis.h"
192#include "asterisk/endpoints.h"
193
194#define DATASTORE_INHERIT_FOREVER INT_MAX
195
196#define AST_MAX_FDS 11 /*!< original maximum number of file descriptors */
197#define AST_EXTENDED_FDS 12 /*!< the start of extended file descriptor positions */
198/*
199 * We have AST_MAX_FDS file descriptors in a channel.
200 * Some of them have a fixed use:
201 */
202#define AST_ALERT_FD (AST_MAX_FDS-1) /*!< used for alertpipe */
203#define AST_TIMING_FD (AST_MAX_FDS-2) /*!< used for timingfd */
204#define AST_AGENT_FD (AST_MAX_FDS-3) /*!< unused - formerly used by agents for pass through */
205#define AST_GENERATOR_FD (AST_MAX_FDS-4) /*!< unused - formerly used by generator */
206#define AST_JITTERBUFFER_FD (AST_MAX_FDS-5) /*!< used by generator */
207
214
215typedef unsigned long long ast_group_t;
216
218
219/*!
220 * \brief Set as the change source reason when a channel stream topology has
221 * been changed externally as a result of the remote side renegotiating.
222 */
223static const char ast_stream_topology_changed_external[] = "external";
224
225/*! \todo Add an explanation of an Asterisk generator
226*/
228 void *(*alloc)(struct ast_channel *chan, void *params);
229 /*! Channel is locked during this function callback. */
230 void (*release)(struct ast_channel *chan, void *data);
231 /*! This function gets called with the channel unlocked, but is called in
232 * the context of the channel thread so we know the channel is not going
233 * to disappear. This callback is responsible for locking the channel as
234 * necessary. */
235 int (*generate)(struct ast_channel *chan, void *data, int len, int samples);
236 /*! This gets called when DTMF_END frames are read from the channel */
237 void (*digit)(struct ast_channel *chan, char digit);
238 /*! This gets called when the write format on a channel is changed while
239 * generating. The channel is locked during this callback. */
240 void (*write_format_change)(struct ast_channel *chan, void *data);
241};
242
243/*! Party name character set enumeration values (values from Q.SIG) */
256
257/*!
258 * \since 1.8
259 * \brief Information needed to specify a name in a call.
260 * \note All string fields here are malloc'ed, so they need to be
261 * freed when the structure is deleted.
262 * \note NULL and "" must be considered equivalent.
263 */
265 /*! \brief Subscriber name (Malloced) */
266 char *str;
267 /*!
268 * \brief Character set the name is using.
269 * \see enum AST_PARTY_CHAR_SET
270 * \note
271 * Set to AST_PARTY_CHAR_SET_ISO8859_1 if unsure what to use.
272 * \todo Start using the party name character set value. Not currently used.
273 */
275 /*!
276 * \brief Q.931 encoded presentation-indicator encoded field
277 * \note Must tolerate the Q.931 screening-indicator field values being present.
278 */
280 /*! \brief TRUE if the name information is valid/present */
281 unsigned char valid;
282};
283
284/*!
285 * \since 1.8
286 * \brief Information needed to specify a number in a call.
287 * \note All string fields here are malloc'ed, so they need to be
288 * freed when the structure is deleted.
289 * \note NULL and "" must be considered equivalent.
290 */
292 /*! \brief Subscriber phone number (Malloced) */
293 char *str;
294 /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
295 int plan;
296 /*! \brief Q.931 presentation-indicator and screening-indicator encoded fields */
298 /*! \brief TRUE if the number information is valid/present */
299 unsigned char valid;
300};
301
302/*!
303 * \since 1.8
304 * \brief Information needed to specify a subaddress in a call.
305 * \note All string fields here are malloc'ed, so they need to be
306 * freed when the structure is deleted.
307 * \note NULL and "" must be considered equivalent.
308 */
310 /*!
311 * \brief Malloced subaddress string.
312 * \note If the subaddress type is user specified then the subaddress is
313 * a string of ASCII hex because the actual subaddress is likely BCD encoded.
314 */
315 char *str;
316 /*!
317 * \brief Q.931 subaddress type.
318 * \details
319 * nsap(0),
320 * user_specified(2)
321 */
322 int type;
323 /*!
324 * \brief TRUE if odd number of address signals
325 * \note The odd/even indicator is used when the type of subaddress is
326 * user_specified and the coding is BCD.
327 */
328 unsigned char odd_even_indicator;
329 /*! \brief TRUE if the subaddress information is valid/present */
330 unsigned char valid;
331};
332
333/*!
334 * \since 1.8
335 * \brief Information needed to identify an endpoint in a call.
336 * \note All string fields here are malloc'ed, so they need to be
337 * freed when the structure is deleted.
338 * \note NULL and "" must be considered equivalent.
339 */
341 /*! \brief Subscriber name */
343 /*! \brief Subscriber phone number */
345 /*! \brief Subscriber subaddress. */
347
348 /*!
349 * \brief User-set "tag"
350 * \details
351 * A user-settable field used to help associate some extrinsic information
352 * about the channel or user of the channel to the party ID. This information
353 * is normally not transmitted over the wire and so is only useful within an
354 * Asterisk environment.
355 */
356 char *tag;
357};
358
359/*!
360 * \since 1.8
361 * \brief Indicate what information in ast_party_id should be set.
362 */
364 /*! TRUE if the ast_party_name information should be set. */
365 unsigned char name;
366 /*! TRUE if the ast_party_number information should be set. */
367 unsigned char number;
368 /*! TRUE if the ast_party_subaddress information should be set. */
369 unsigned char subaddress;
370};
371
372/*!
373 * \since 1.8
374 * \brief Dialed/Called Party information.
375 * \note Dialed Number Identifier (DNID)
376 * \note All string fields here are malloc'ed, so they need to be
377 * freed when the structure is deleted.
378 * \note NULL and "" must be considered equivalent.
379 */
381 /*!
382 * \brief Dialed/Called number
383 * \note Done this way in case we ever really need to use ast_party_number.
384 * We currently do not need all of the ast_party_number fields.
385 */
386 struct {
387 /*! \brief Subscriber phone number (Malloced) */
388 char *str;
389 /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
390 int plan;
392 /*! \brief Dialed/Called subaddress */
394 /*!
395 * \brief Transit Network Select
396 * \note Currently this value is just passed around the system.
397 * You can read it and set it but it is never used for anything.
398 */
400};
401
402/*!
403 * \since 1.8
404 * \brief Caller Party information.
405 * \note All string fields here are malloc'ed, so they need to be
406 * freed when the structure is deleted.
407 * \note NULL and "" must be considered equivalent.
408 *
409 * \note SIP and IAX2 has UTF8 encoded Unicode Caller ID names.
410 * In some cases, we also have an alternative (RPID) E.164 number that can
411 * be used as Caller ID on numeric E.164 phone networks (DAHDI or SIP/IAX2 to
412 * PSTN gateway).
413 *
414 * \todo Implement settings for transliteration between UTF8 Caller ID names in
415 * to ASCII Caller ID's (DAHDI). Östen Åsklund might be transliterated into
416 * Osten Asklund or Oesten Aasklund depending upon language and person...
417 * We need automatic routines for incoming calls and static settings for
418 * our own accounts.
419 */
421 /*! \brief Caller party ID */
423
424 /*!
425 * \brief Automatic Number Identification (ANI)
426 * \note The name subcomponent is only likely to be used by SIP.
427 * \note The subaddress subcomponent is not likely to be used.
428 */
430
431 /*! \brief Private caller party ID */
433
434 /*! \brief Automatic Number Identification 2 (Info Digits) */
435 int ani2;
436};
437
438/*!
439 * \since 1.8
440 * \brief Indicate what information in ast_party_caller should be set.
441 */
443 /*! What caller id information to set. */
445 /*! What ANI id information to set. */
447 /*! What private caller id information to set. */
449};
450
451/*!
452 * \since 1.8
453 * \brief Connected Line/Party information.
454 * \note All string fields here are malloc'ed, so they need to be
455 * freed when the structure is deleted.
456 * \note NULL and "" must be considered equivalent.
457 */
459 /*! \brief Connected party ID */
461
462 /*!
463 * \brief Automatic Number Identification (ANI)
464 * \note Not really part of connected line data but needed to
465 * save the corresponding caller id value.
466 */
468
469 /*! \brief Private connected party ID */
471
472 /*!
473 * \brief Automatic Number Identification 2 (Info Digits)
474 * \note Not really part of connected line data but needed to
475 * save the corresponding caller id value.
476 */
477 int ani2;
478
479 /*!
480 * \brief Information about the source of an update.
481 * \note enum AST_CONNECTED_LINE_UPDATE_SOURCE values
482 * for Normal-Answer and Call-transfer.
483 */
485};
486
487/*!
488 * \since 1.8
489 * \brief Indicate what information in ast_party_connected_line should be set.
490 */
492 /*! What connected line id information to set. */
494 /*! What ANI id information to set. */
496 /*! What private connected line id information to set. */
498};
499
500/*!
501 * \brief Redirecting reason information
502 */
504 /*! \brief a string value for the redirecting reason
505 *
506 * Useful for cases where an endpoint has specified a redirecting reason
507 * that does not correspond to an enum AST_REDIRECTING_REASON
508 */
509 char *str;
510
511 /*! \brief enum AST_REDIRECTING_REASON value for redirection */
512 int code;
513};
514
515/*!
516 * \since 1.8
517 * \brief Redirecting Line information.
518 * RDNIS (Redirecting Directory Number Information Service)
519 * Where a call diversion or transfer was invoked.
520 * \note All string fields here are malloc'ed, so they need to be
521 * freed when the structure is deleted.
522 * \note NULL and "" must be considered equivalent.
523 */
525 /*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) */
527
528 /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */
530
531 /*! \brief Call is redirecting to a new party (Sent to the caller) */
533
534 /*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) - private representation */
536
537 /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) - private representation */
539
540 /*! \brief Call is redirecting to a new party (Sent to the caller) - private representation */
542
543 /*! \brief Reason for the redirection */
545
546 /*! \brief Reason for the redirection by the original party */
548
549 /*! \brief Number of times the call was redirected */
550 int count;
551};
552
553/*!
554 * \since 1.8
555 * \brief Indicate what information in ast_party_redirecting should be set.
556 */
558 /*! What redirecting-orig id information to set. */
560 /*! What redirecting-from id information to set. */
562 /*! What redirecting-to id information to set. */
564 /*! What private redirecting-orig id information to set. */
566 /*! What private redirecting-from id information to set. */
568 /*! What private redirecting-to id information to set. */
570};
571
572/*!
573 * \brief Typedef for a custom read function
574 * \note data should be treated as const char *.
575 */
576typedef int (*ast_acf_read_fn_t)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
577
578/*!
579 * \brief Typedef for a custom read2 function
580 * \note data should be treated as const char *.
581 */
582typedef int (*ast_acf_read2_fn_t)(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len);
583
584/*!
585 * \brief Typedef for a custom write function
586 * \note data should be treated as const char *.
587 */
588typedef int (*ast_acf_write_fn_t)(struct ast_channel *chan, const char *function, char *data, const char *value);
589
590/*! \brief Structure to handle passing func_channel_write info to channels via setoption */
591typedef struct {
592 /*! \brief ast_chan_write_info_t version. Must be incremented if structure is changed */
593 #define AST_CHAN_WRITE_INFO_T_VERSION 1
594 uint32_t version;
597 const char *function;
598 char *data;
599 const char *value;
601
602/*!
603 * \brief Structure to pass both assignedid values to channel drivers
604 * \note The second value is used only by core_unreal (LOCAL)
605 */
607 const char *uniqueid;
608 const char *uniqueid2;
609};
610
611/*!
612 * \brief Helper struct for initializing additional channel information on channel creation.
613 * \since 18.25.0
614 */
616 /*!
617 * \brief struct ABI version
618 * \note This \b must be incremented when the struct changes.
619 */
620 #define AST_CHANNEL_INITIALIZERS_VERSION 1
621 /*!
622 * \brief struct ABI version
623 * \note This \b must stay as the first member.
624 */
625 uint32_t version;
626 const char *tenantid;
627};
628
629/*!
630 * \brief Forward declaration
631 */
632struct ast_msg_data;
633
634/*!
635 * \brief
636 * Structure to describe a channel "technology", ie a channel driver
637 * See for examples:
638 * \arg chan_iax2.c - The Inter-Asterisk exchange protocol
639 * \arg chan_pjsip.c - The SIP channel driver
640 * \arg chan_dahdi.c - PSTN connectivity (TDM, PRI, T1/E1, FXO, FXS)
641 *
642 * \details
643 * If you develop your own channel driver, this is where you
644 * tell the PBX at registration of your driver what properties
645 * this driver supports and where different callbacks are
646 * implemented.
647 */
649 const char * const type;
650 const char * const description;
651
652 struct ast_format_cap *capabilities; /*!< format capabilities this channel can handle */
653
654 int properties; /*!< Technology Properties */
655
656 /*!
657 * \brief Requester - to set up call data structures (pvt's)
658 *
659 * \param type type of channel to request
660 * \param cap Format capabilities for requested channel
661 * \param assignedid Unique ID string to assign to channel
662 * \param requestor channel asking for data
663 * \param addr destination of the call
664 * \param cause Cause of failure
665 *
666 * \details
667 * Request a channel of a given type, with addr as optional information used
668 * by the low level module
669 *
670 * \retval NULL failure
671 * \retval non-NULL channel on success
672 */
673 struct ast_channel *(* const requester)(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause);
674
675 /*!
676 * \brief Requester - to set up call data structures (pvt's) with stream topology
677 *
678 * \param type type of channel to request
679 * \param topology Stream topology for requested channel
680 * \param assignedid Unique ID string to assign to channel
681 * \param requestor channel asking for data
682 * \param addr destination of the call
683 * \param cause Cause of failure
684 *
685 * \details
686 * Request a channel of a given type, with addr as optional information used
687 * by the low level module
688 *
689 * \retval NULL failure
690 * \retval non-NULL channel on success
691 */
692 struct ast_channel *(* const requester_with_stream_topology)(const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause);
693
694
695 int (* const devicestate)(const char *device_number); /*!< Devicestate call back */
696 int (* const presencestate)(const char *presence_provider, char **subtype, char **message); /*!< Presencestate callback */
697
698 /*!
699 * \brief Start sending a literal DTMF digit
700 *
701 * \note The channel is not locked when this function gets called.
702 */
703 int (* const send_digit_begin)(struct ast_channel *chan, char digit);
704
705 /*!
706 * \brief Stop sending a literal DTMF digit
707 *
708 * \note The channel is not locked when this function gets called.
709 */
710 int (* const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration);
711
712 /*!
713 * \brief Make a call
714 * \note The channel is locked when called.
715 * \param chan which channel to make the call on
716 * \param addr destination of the call
717 * \param timeout time to wait on for connect (Doesn't seem to be used.)
718 * \retval 0 on success
719 * \retval -1 on failure
720 */
721 int (* const call)(struct ast_channel *chan, const char *addr, int timeout);
722
723 /*! \brief Hangup (and possibly destroy) the channel */
724 int (* const hangup)(struct ast_channel *chan);
725
726 /*! \brief Answer the channel */
727 int (* const answer)(struct ast_channel *chan);
728
729 /*!
730 * \brief Answer the channel with topology
731 * \since 18.0.0
732 *
733 * \param chan The channel to answer
734 * \param topology The topology to use, probably the peer's.
735 *
736 * \note The topology may be NULL when the peer doesn't support streams
737 * or, in the case where transcoding is in effect, when this channel should use
738 * its existing topology.
739 */
740 int (* const answer_with_stream_topology)(struct ast_channel *chan, struct ast_stream_topology *topology);
741
742 /*!
743 * \brief Read a frame (or chain of frames from the same stream), in standard format (see frame.h)
744 *
745 * \param chan channel to read frames from
746 *
747 * \retval non-NULL on success
748 * \retval NULL on failure
749 *
750 * \note Each media frame from this callback will have the stream_num of it changed to the default
751 * stream num based on the type of media returned. As a result a multistream capable channel
752 * should not implement this callback.
753 */
754 struct ast_frame * (* const read)(struct ast_channel *chan);
755
756 /*!
757 * \brief Read a frame (or chain of frames from the same stream), in standard format (see frame.h), with stream num
758 *
759 * \param chan channel to read frames from
760 *
761 * \retval non-NULL on success
762 * \retval NULL on failure
763 *
764 * \note Each media frame from this callback should contain a stream_num value which is set to the
765 * stream that the media frame originated from.
766 */
767 struct ast_frame * (* const read_stream)(struct ast_channel *chan);
768
769 /*! \brief Write a frame, in standard format (see frame.h) */
770 int (* const write)(struct ast_channel *chan, struct ast_frame *frame);
771
772 /*! \brief Write a frame on a specific stream, in standard format (see frame.h) */
773 int (* const write_stream)(struct ast_channel *chan, int stream_num, struct ast_frame *frame);
774
775 /*! \brief Display or transmit text */
776 int (* const send_text)(struct ast_channel *chan, const char *text);
777
778 /*! \brief Display or send an image */
779 int (* const send_image)(struct ast_channel *chan, struct ast_frame *frame);
780
781 /*! \brief Send HTML data */
782 int (* const send_html)(struct ast_channel *chan, int subclass, const char *data, int len);
783
784 /*! \brief Handle an exception, reading a frame */
785 struct ast_frame * (* const exception)(struct ast_channel *chan);
786
787 /*! \brief Bridge two channels of the same type together (early) */
788 enum ast_bridge_result (* const early_bridge)(struct ast_channel *c0, struct ast_channel *c1);
789
790 /*! \brief Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */
791 int (* const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen);
792
793 /*! \brief Fix up a channel: If a channel is consumed, this is called. Basically update any ->owner links */
794 int (* const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan);
795
796 /*! \brief Set a given option. Called with chan locked */
797 int (* const setoption)(struct ast_channel *chan, int option, void *data, int datalen);
798
799 /*! \brief Query a given option. Called with chan locked */
800 int (* const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen);
801
802 /*! \brief Blind transfer other side (see app_transfer.c and ast_transfer() */
803 int (* const transfer)(struct ast_channel *chan, const char *newdest);
804
805 /*! \brief Write a frame, in standard format */
806 int (* const write_video)(struct ast_channel *chan, struct ast_frame *frame);
807
808 /*! \brief Write a text frame, in standard format */
809 int (* const write_text)(struct ast_channel *chan, struct ast_frame *frame);
810
811 /*!
812 * \brief Provide additional read items for CHANNEL() dialplan function
813 * \note data should be treated as a const char *.
814 */
815 int (* func_channel_read)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
816
817 /*!
818 * \brief Provide additional write items for CHANNEL() dialplan function
819 * \note data should be treated as a const char *.
820 */
821 int (* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value);
822
823 /*! \brief Get the unique identifier for the PVT, i.e. SIP call-ID for SIP */
824 const char * (* get_pvt_uniqueid)(struct ast_channel *chan);
825
826 /*! \brief Call a function with cc parameters as a function parameter
827 *
828 * \details
829 * This is a highly specialized callback that is not likely to be needed in many
830 * channel drivers. When dealing with a busy channel, for instance, most channel
831 * drivers will successfully return a channel to the requester. Once called, the channel
832 * can then queue a busy frame when it receives an appropriate message from the far end.
833 * In such a case, the channel driver has the opportunity to also queue a CC frame.
834 * The parameters for the CC channel can be retrieved from the channel structure.
835 *
836 * For other channel drivers, notably those that deal with "dumb" phones, the channel
837 * driver will not return a channel when one is requested. In such a scenario, there is never
838 * an opportunity for the channel driver to queue a CC frame since the channel is never
839 * called. Furthermore, it is not possible to retrieve the CC configuration parameters
840 * for the desired channel because no channel is ever allocated or returned to the
841 * requester. In such a case, call completion may still be a viable option. What we do is
842 * pass the same string that the requester used originally to request the channel to the
843 * channel driver. The channel driver can then find any potential channels/devices that
844 * match the input and return call the designated callback with the device's call completion
845 * parameters as a parameter.
846 */
847 int (* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback);
848
849 /*!
850 * \brief Execute a Gosub call on the channel in a technology specific way before a call is placed.
851 * \since 11.0
852 *
853 * \param chan Channel to execute Gosub in a tech specific way.
854 * \param sub_args Gosub application parameter string.
855 *
856 * \note The chan is locked before calling.
857 *
858 * \retval 0 on success.
859 * \retval -1 on error.
860 */
861 int (*pre_call)(struct ast_channel *chan, const char *sub_args);
862
863 /*! \brief Display or transmit text with data*/
864 int (* const send_text_data)(struct ast_channel *chan, struct ast_msg_data *data);
865};
866
867/*! Kill the channel channel driver technology descriptor. */
868extern const struct ast_channel_tech ast_kill_tech;
869
870struct ast_epoll_data;
871
872/*!
873 * The high bit of the frame count is used as a debug marker, so
874 * increments of the counters must be done with care.
875 * Please use c->fin = FRAMECOUNT_INC(c->fin) and the same for c->fout.
876 */
877#define DEBUGCHAN_FLAG 0x80000000
878
879/* XXX not ideal to evaluate x twice... */
880#define FRAMECOUNT_INC(x) ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) )
881
882/*!
883 * The current value of the debug flags is stored in the two
884 * variables global_fin and global_fout (declared in main/channel.c)
885 */
886extern unsigned long global_fin, global_fout;
887
894
895/*!
896 * \brief Possible T38 states on channels
897 */
899 T38_STATE_UNAVAILABLE, /*!< T38 is unavailable on this channel or disabled by configuration */
900 T38_STATE_UNKNOWN, /*!< The channel supports T38 but the current status is unknown */
901 T38_STATE_NEGOTIATING, /*!< T38 is being negotiated */
902 T38_STATE_REJECTED, /*!< Remote side has rejected our offer */
903 T38_STATE_NEGOTIATED, /*!< T38 established */
904};
905
906/*! Hangup handler instance node. */
908 /*! Next hangup handler node. */
910 /*! Hangup handler arg string passed to the Gosub application */
911 char args[0];
912};
913
918
919typedef int(*ast_timing_func_t)(const void *data);
920/*!
921 * \page AstChannel ast_channel locking and reference tracking
922 *
923 * \par Creating Channels
924 * A channel is allocated using the ast_channel_alloc() function. When created, it is
925 * automatically inserted into the main channels hash table that keeps track of all
926 * active channels in the system. The hash key is based on the channel name. Because
927 * of this, if you want to change the name, you _must_ use ast_change_name(), not change
928 * the name field directly. When ast_channel_alloc() returns a channel pointer, you now
929 * hold both a reference to that channel and a lock on the channel. Once the channel has
930 * been set up the lock can be released. In most cases the reference is given to ast_pbx_run().
931 *
932 * \par Channel Locking
933 * There is a lock associated with every ast_channel. It is allocated internally via astobj2.
934 * To lock or unlock a channel, you must use the ast_channel_lock() wrappers.
935 *
936 * Previously, before ast_channel was converted to astobj2, the channel lock was used in some
937 * additional ways that are no longer necessary. Before, the only way to ensure that a channel
938 * did not disappear out from under you if you were working with a channel outside of the channel
939 * thread that owns it, was to hold the channel lock. Now, that is no longer necessary.
940 * You simply must hold a reference to the channel to ensure it does not go away.
941 *
942 * The channel must be locked if you need to ensure that data that you reading from the channel
943 * does not change while you access it. Further, you must hold the channel lock if you are
944 * making a non-atomic change to channel data.
945 *
946 * \par Channel References
947 * There are multiple ways to get a reference to a channel. The first is that you hold a reference
948 * to a channel after creating it. The other ways involve using the channel search or the channel
949 * traversal APIs. These functions are the ast_channel_get_*() functions or ast_channel_iterator_*()
950 * functions. Once a reference is retrieved by one of these methods, you know that the channel will
951 * not go away. So, the channel should only get locked as needed for data access or modification.
952 * But, make sure that the reference gets released when you are done with it!
953 *
954 * There are different things you can do when you are done with a reference to a channel. The first
955 * is to simply release the reference using ast_channel_unref(). The other option is to call
956 * ast_channel_release(). This function is generally used where ast_channel_free() was used in
957 * the past. The release function releases a reference as well as ensures that the channel is no
958 * longer in the global channels container. That way, the channel will get destroyed as soon as any
959 * other pending references get released.
960 *
961 * \par Exceptions to the rules
962 * Even though ast_channel is reference counted, there are some places where pointers to an ast_channel
963 * get stored, but the reference count does not reflect it. The reason is mostly historical.
964 * The only places where this happens should be places where because of how the code works, we
965 * _know_ that the pointer to the channel will get removed before the channel goes away. The main
966 * example of this is in channel drivers. Channel drivers generally store a pointer to their owner
967 * ast_channel in their technology specific pvt struct. In this case, the channel drivers _know_
968 * that this pointer to the channel will be removed in time, because the channel's hangup callback
969 * gets called before the channel goes away.
970 */
971
972struct ast_channel;
973
974/*! \brief ast_channel_tech Properties */
975enum {
976 /*!
977 * \brief Channels have this property if they can accept input with jitter;
978 * i.e. most VoIP channels
979 */
981 /*!
982 * \brief Channels have this property if they can create jitter;
983 * i.e. most VoIP channels
984 */
986 /*!
987 * \brief Channels with this particular technology are an implementation detail of
988 * Asterisk and should generally not be exposed or manipulated by the outside
989 * world
990 */
992 /*!
993 * \brief Channels have this property if they implement send_text_data
994 */
996};
997
998/*! \brief ast_channel flags */
999enum {
1000 /*! Queue incoming DTMF, to be released when this flag is turned off */
1002 /*! write should be interrupt generator */
1004 /*! a thread is blocking on this channel */
1006 /*! This is a zombie channel */
1008 /*! There is an exception pending */
1010 /*! Listening to moh XXX anthm promises me this will disappear XXX */
1011 AST_FLAG_MOH = (1 << 6),
1012 /*! This channel is spying on another channel */
1014 /*! the channel is in an auto-incrementing dialplan processor,
1015 * so when ->priority is set, it will get incremented before
1016 * finding the next priority to run */
1018 /*! This is an outgoing call */
1020 /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */
1021 AST_FLAG_IN_DTMF = (1 << 12),
1022 /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is
1023 * currently being emulated */
1025 /*! This is set to tell the channel not to generate DTMF begin frames, and
1026 * to instead only generate END frames. */
1028 /* OBSOLETED in favor of AST_CAUSE_ANSWERED_ELSEWHERE
1029 * Flag to show channels that this call is hangup due to the fact that the call
1030 * was indeed answered, but in another channel */
1031 /* AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), */
1032 /*! This flag indicates that on a masquerade, an active stream should not
1033 * be carried over */
1035 /*! This flag indicates that the hangup exten was run when the bridge terminated,
1036 * a message aimed at preventing a subsequent hangup exten being run at the pbx_run
1037 * level */
1039 /*! Disable certain workarounds. This reintroduces certain bugs, but allows
1040 * some non-traditional dialplans (like AGI) to continue to function.
1041 */
1043 /*!
1044 * Disable device state event caching. This allows channel
1045 * drivers to selectively prevent device state events from being
1046 * cached by certain channels such as anonymous calls which have
1047 * no persistent represenatation that can be tracked.
1048 */
1050 /*!
1051 * This flag indicates that a dual channel redirect is in
1052 * progress. The bridge needs to wait until the flag is cleared
1053 * to continue.
1054 */
1056 /*!
1057 * This flag indicates that the channel was originated.
1058 */
1060 /*!
1061 * The channel is well and truly dead. Once this is set and published, no further
1062 * actions should be taken upon the channel, and no further publications should
1063 * occur.
1064 */
1065 AST_FLAG_DEAD = (1 << 24),
1066 /*!
1067 * Channel snapshot should not be published, it is being staged for an explicit
1068 * publish.
1069 */
1071 /*!
1072 * The data on chan->timingdata is an astobj2 object.
1073 */
1075 /*!
1076 * The channel is executing a subroutine or macro
1077 */
1079};
1080
1081/*! \brief ast_bridge_config flags */
1082enum {
1090};
1091
1092#define AST_FEATURE_DTMF_MASK (AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |\
1093 AST_FEATURE_ATXFER | AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON)
1094
1095/*! \brief bridge configuration */
1099 struct timeval start_time;
1100 struct timeval nexteventts;
1101 struct timeval feature_start_time;
1106 const char *warning_sound;
1107 const char *end_sound;
1108 const char *start_sound;
1109 unsigned int flags;
1110 void (* end_bridge_callback)(void *); /*!< A callback that is called after a bridge attempt */
1111 void *end_bridge_callback_data; /*!< Data passed to the callback */
1112 /*! If the end_bridge_callback_data refers to a channel which no longer is going to
1113 * exist when the end_bridge_callback is called, then it needs to be fixed up properly
1114 */
1115 void (*end_bridge_callback_data_fixup)(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator);
1116 /*! If the bridge answers the channel this topology should be passed to the channel
1117 * and used if the channel supports the answer_with_stream_topology callback.
1118 */
1120};
1121
1122struct chanmon;
1123
1125 const char *context;
1126 const char *exten;
1128 int connect_on_early_media; /* If set, treat session progress as answer */
1129 const char *cid_num;
1130 const char *cid_name;
1131 const char *account;
1134};
1135
1136enum {
1137 /*!
1138 * Soft hangup requested by device or other internal reason.
1139 * Actual hangup needed.
1140 */
1142 /*!
1143 * Used to break the normal frame flow so an async goto can be
1144 * done instead of actually hanging up.
1145 */
1147 /*!
1148 * Soft hangup requested by system shutdown. Actual hangup
1149 * needed.
1150 */
1152 /*!
1153 * Used to break the normal frame flow after a timeout so an
1154 * implicit async goto can be done to the 'T' exten if it exists
1155 * instead of actually hanging up. If the exten does not exist
1156 * then actually hangup.
1157 */
1159 /*!
1160 * Soft hangup requested by application/channel-driver being
1161 * unloaded. Actual hangup needed.
1162 */
1164 /*!
1165 * Soft hangup requested by non-associated party. Actual hangup
1166 * needed.
1167 */
1169 /*!
1170 * Used to indicate that the channel is currently executing hangup
1171 * logic in the dialplan. The channel has been hungup when this is
1172 * set.
1173 */
1175 /*!
1176 * \brief All softhangup flags.
1177 *
1178 * This can be used as an argument to ast_channel_clear_softhangup()
1179 * to clear all softhangup flags from a channel.
1180 */
1181 AST_SOFTHANGUP_ALL = (0xFFFFFFFF)
1183
1184
1185/*! \brief Channel reload reasons for manager events at load or reload of configuration */
1193
1194/*!
1195 * \brief Channel AMA Flags
1196 */
1203
1204/*!
1205 * \note None of the datastore API calls lock the ast_channel they are using.
1206 * So, the channel should be locked before calling the functions that
1207 * take a channel argument.
1208 */
1209
1210/*! \brief Inherit datastores from a parent to a child. */
1211int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to);
1212
1213/*!
1214 * \brief Add a datastore to a channel
1215 *
1216 * \note The channel should be locked before calling this function.
1217 *
1218 * \retval 0 success
1219 * \retval non-zero failure
1220 */
1221int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore);
1222
1223/*!
1224 * \brief Remove a datastore from a channel
1225 *
1226 * \note The channel should be locked before calling this function.
1227 *
1228 * \retval 0 success
1229 * \retval non-zero failure
1230 */
1231int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore);
1232
1233/*!
1234 * \brief Find a datastore on a channel
1235 *
1236 * \note The channel should be locked before calling this function.
1237 *
1238 * \note The datastore returned from this function must not be used if the
1239 * reference to the channel is released.
1240 *
1241 * \retval pointer to the datastore if found
1242 * \retval NULL if not found
1243 */
1244struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid);
1245
1246/*!
1247 * \brief Create a channel structure
1248 * \since 1.8
1249 *
1250 * \retval NULL failure
1251 * \retval non-NULL successfully allocated channel
1252 *
1253 * \note Absolutely _NO_ channel locks should be held before calling this function.
1254 * \note By default, new channels are set to the "s" extension
1255 * and "default" context.
1256 * \note Since 12.0.0 this function returns with the newly created channel locked.
1257 */
1258struct ast_channel * __attribute__((format(printf, 15, 16)))
1259 __ast_channel_alloc(int needqueue, int state, const char *cid_num,
1260 const char *cid_name, const char *acctcode,
1261 const char *exten, const char *context, const struct ast_assigned_ids *assignedids,
1262 const struct ast_channel *requestor, enum ama_flags amaflag,
1263 struct ast_endpoint *endpoint,
1264 const char *file, int line, const char *function,
1265 const char *name_fmt, ...);
1266
1267/*!
1268 * \brief Create a channel structure
1269 * \since 18.25.0
1270 *
1271 * \retval NULL failure
1272 * \retval non-NULL successfully allocated channel
1273 *
1274 * \note Absolutely _NO_ channel locks should be held before calling this function.
1275 * \note By default, new channels are set to the "s" extension
1276 * and "default" context.
1277 * \note Same as __ast_channel_alloc but with ast_channel_initializers struct.
1278 */
1279struct ast_channel * __attribute__((format(printf, 16, 17)))
1280 __ast_channel_alloc_with_initializers(int needqueue, int state, const char *cid_num,
1281 const char *cid_name, const char *acctcode,
1282 const char *exten, const char *context, const struct ast_assigned_ids *assignedids,
1283 const struct ast_channel *requestor, enum ama_flags amaflag,
1284 struct ast_endpoint *endpoint, struct ast_channel_initializers *initializers,
1285 const char *file, int line, const char *function,
1286 const char *name_fmt, ...);
1287
1288/*!
1289 * \brief Create a channel structure
1290 *
1291 * \retval NULL failure
1292 * \retval non-NULL successfully allocated channel
1293 *
1294 * \note Absolutely _NO_ channel locks should be held before calling this function.
1295 * \note By default, new channels are set to the "s" extension
1296 * and "default" context.
1297 * \note Since 12.0.0 this function returns with the newly created channel locked.
1298 */
1299#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, ...) \
1300 __ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, NULL, \
1301 __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
1302
1303#define ast_channel_alloc_with_endpoint(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, endpoint, ...) \
1304 __ast_channel_alloc((needqueue), (state), (cid_num), (cid_name), (acctcode), (exten), (context), (assignedids), (requestor), (amaflag), (endpoint), \
1305 __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
1306
1307#define ast_channel_alloc_with_initializers(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, endpoint, initializers, ...) \
1308 __ast_channel_alloc_with_initializers((needqueue), (state), (cid_num), (cid_name), (acctcode), (exten), (context), (assignedids), (requestor), (amaflag), (endpoint), \
1309 (initializers), __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
1310
1311
1312/*!
1313 * \brief Create a fake channel structure
1314 *
1315 * \retval NULL failure
1316 * \retval non-NULL successfully allocated channel
1317 *
1318 * \note This function should ONLY be used to create a fake channel
1319 * that can then be populated with data for use in variable
1320 * substitution when a real channel does not exist.
1321 *
1322 * \note The created dummy channel should be destroyed by
1323 * ast_channel_unref(). Using ast_channel_release() needlessly
1324 * grabs the channel container lock and can cause a deadlock as
1325 * a result. Also grabbing the channel container lock reduces
1326 * system performance.
1327 */
1328#define ast_dummy_channel_alloc() __ast_dummy_channel_alloc(__FILE__, __LINE__, __PRETTY_FUNCTION__)
1329struct ast_channel *__ast_dummy_channel_alloc(const char *file, int line, const char *function);
1330
1331/*!
1332 * \brief Queue one or more frames to a channel's frame queue
1333 *
1334 * \param chan the channel to queue the frame(s) on
1335 * \param f the frame(s) to queue. Note that the frame(s) will be duplicated
1336 * by this function. It is the responsibility of the caller to handle
1337 * freeing the memory associated with the frame(s) being passed if
1338 * necessary.
1339 *
1340 * \retval 0 success
1341 * \retval non-zero failure
1342 */
1343int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f);
1344
1345/*!
1346 * \brief Queue one or more frames to the head of a channel's frame queue
1347 *
1348 * \param chan the channel to queue the frame(s) on
1349 * \param f the frame(s) to queue. Note that the frame(s) will be duplicated
1350 * by this function. It is the responsibility of the caller to handle
1351 * freeing the memory associated with the frame(s) being passed if
1352 * necessary.
1353 *
1354 * \retval 0 success
1355 * \retval non-zero failure
1356 */
1357int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f);
1358
1359/*!
1360 * \brief Queue a hangup frame
1361 *
1362 * \note The channel does not need to be locked before calling this function.
1363 */
1364int ast_queue_hangup(struct ast_channel *chan);
1365
1366/*!
1367 * \brief Queue a hangup frame with hangupcause set
1368 *
1369 * \note The channel does not need to be locked before calling this function.
1370 * \param[in] chan channel to queue frame onto
1371 * \param[in] cause the hangup cause
1372 * \retval 0 on success
1373 * \retval -1 on error
1374 * \since 1.6.1
1375 */
1376int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause);
1377
1378/*!
1379 * \brief Queue a hold frame
1380 *
1381 * \param chan channel to queue frame onto
1382 * \param musicclass The suggested musicclass for the other end to use
1383 *
1384 * \note The channel does not need to be locked before calling this function.
1385 *
1386 * \retval zero on success
1387 * \retval non-zero on failure
1388 */
1389int ast_queue_hold(struct ast_channel *chan, const char *musicclass);
1390
1391/*!
1392 * \brief Queue an unhold frame
1393 *
1394 * \param chan channel to queue frame onto
1395 *
1396 * \note The channel does not need to be locked before calling this function.
1397 *
1398 * \retval zero on success
1399 * \retval non-zero on failure
1400 */
1401int ast_queue_unhold(struct ast_channel *chan);
1402
1403/*!
1404 * \brief Queue a control frame without payload
1405 *
1406 * \param chan channel to queue frame onto
1407 * \param control type of control frame
1408 *
1409 * \note The channel does not need to be locked before calling this function.
1410 *
1411 * \retval zero on success
1412 * \retval non-zero on failure
1413 */
1414int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control);
1415
1416/*!
1417 * \brief Queue a control frame with payload
1418 *
1419 * \param chan channel to queue frame onto
1420 * \param control type of control frame
1421 * \param data pointer to payload data to be included in frame
1422 * \param datalen number of bytes of payload data
1423 *
1424 * \retval 0 success
1425 * \retval non-zero failure
1426 *
1427 * \details
1428 * The supplied payload data is copied into the frame, so the caller's copy
1429 * is not modified nor freed, and the resulting frame will retain a copy of
1430 * the data even if the caller frees their local copy.
1431 *
1432 * \note This method should be treated as a 'network transport'; in other
1433 * words, your frames may be transferred across an IAX2 channel to another
1434 * system, which may be a different endianness than yours. Because of this,
1435 * you should ensure that either your frames will never be expected to work
1436 * across systems, or that you always put your payload data into 'network byte
1437 * order' before calling this function.
1438 *
1439 * \note The channel does not need to be locked before calling this function.
1440 */
1441int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control,
1442 const void *data, size_t datalen);
1443
1444/*!
1445 * \brief Queue an ANSWER control frame with topology
1446 *
1447 * \param chan channel to queue frame onto
1448 * \param topology topology to be passed through the core to the peer channel
1449 *
1450 * \retval 0 success
1451 * \retval non-zero failure
1452 */
1453int ast_queue_answer(struct ast_channel *chan, const struct ast_stream_topology *topology);
1454
1455/*!
1456 * \brief Change channel name
1457 *
1458 * \pre Absolutely all channels and the channel storage backend _MUST_ be
1459 * unlocked before calling this function.
1460 *
1461 * \param chan the channel to change the name of
1462 * \param newname the name to change to
1463 *
1464 * \note this function must _NEVER_ be used when any channels or the channel
1465 * storage backend are locked regardless if it is the channel who's name is
1466 * being changed or not because it invalidates our channel container locking
1467 * order... lock container first, then the individual channels, never the
1468 * other way around.
1469 */
1470void ast_change_name(struct ast_channel *chan, const char *newname);
1471
1472/*!
1473 * \brief Unlink and release reference to a channel
1474 *
1475 * This function will unlink the channel from the global channels container
1476 * if it is still there and also release the current reference to the channel.
1477 *
1478 * \retval NULL convenient for clearing invalid pointers
1479 * \note Absolutely _NO_ channel locks should be held before calling this function.
1480 *
1481 * \since 1.8
1482 */
1483struct ast_channel *ast_channel_release(struct ast_channel *chan);
1484
1485/*!
1486 * \brief Requests a channel
1487 *
1488 * \param type type of channel to request
1489 * \param request_cap Format capabilities for requested channel
1490 * \param assignedids Unique ID to create channel with
1491 * \param requestor channel asking for data
1492 * \param addr destination of the call
1493 * \param cause Cause of failure
1494 *
1495 * \details
1496 * Request a channel of a given type, with addr as optional information used
1497 * by the low level module
1498 *
1499 * \retval NULL failure
1500 * \retval non-NULL channel on success
1501 */
1502struct ast_channel *ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause);
1503
1504/*!
1505 * \brief Requests a channel (specifying stream topology)
1506 *
1507 * \param type type of channel to request
1508 * \param topology Stream topology for requested channel
1509 * \param assignedids Unique ID to create channel with
1510 * \param requestor channel asking for data
1511 * \param addr destination of the call
1512 * \param cause Cause of failure
1513 *
1514 * \details
1515 * Request a channel of a given type, with addr as optional information used
1516 * by the low level module
1517 *
1518 * \retval NULL failure
1519 * \retval non-NULL channel on success
1520 */
1521struct ast_channel *ast_request_with_stream_topology(const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause);
1522
1524 /*! The requestor is the future bridge peer of the channel. */
1526 /*! The requestor is to be replaced by the channel. */
1528};
1529
1530/*!
1531 * \brief Setup new channel accountcodes from the requestor channel after ast_request().
1532 * \since 13.0.0
1533 *
1534 * \param chan New channel to get accountcodes setup.
1535 * \param requestor Requesting channel to get accountcodes from.
1536 * \param relationship What the new channel was created for.
1537 *
1538 * \pre The chan and requestor channels are already locked.
1539 *
1540 * \note Pre-existing accountcodes on chan will be overwritten.
1541 */
1542void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship);
1543
1544/*!
1545 * \brief Setup new channel accountcodes from the requestor channel after ast_request().
1546 * \since 13.0.0
1547 *
1548 * \param chan New channel to get accountcodes setup.
1549 * \param requestor Requesting channel to get accountcodes from.
1550 * \param relationship What the new channel was created for.
1551 *
1552 * \pre The chan and requestor channels are already locked.
1553 *
1554 * \note Pre-existing accountcodes on chan will not be overwritten.
1555 */
1556void ast_channel_req_accountcodes_precious(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship);
1557
1558/*!
1559 * \brief Request a channel of a given type, with data as optional information used
1560 * by the low level module and attempt to place a call on it
1561 *
1562 * \param type type of channel to request
1563 * \param cap format capabilities for requested channel
1564 * \param assignedids Unique Id to assign to channel
1565 * \param requestor channel asking for data
1566 * \param addr destination of the call
1567 * \param timeout maximum amount of time to wait for an answer
1568 * \param reason why unsuccessful (if unsuccessful)
1569 * \param cid_num Caller-ID Number
1570 * \param cid_name Caller-ID Name (ascii)
1571 *
1572 * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
1573 * to know if the call was answered or not.
1574 */
1575struct ast_channel *ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr,
1576 int timeout, int *reason, const char *cid_num, const char *cid_name);
1577
1578/*!
1579 * \brief Request a channel of a given type, with data as optional information used
1580 * by the low level module and attempt to place a call on it
1581 * \param type type of channel to request
1582 * \param cap format capabilities for requested channel
1583 * \param assignedids Unique Id to assign to channel
1584 * \param requestor channel requesting data
1585 * \param addr destination of the call
1586 * \param timeout maximum amount of time to wait for an answer
1587 * \param reason why unsuccessful (if unsuccessful)
1588 * \param cid_num Caller-ID Number
1589 * \param cid_name Caller-ID Name (ascii)
1590 * \param oh Outgoing helper
1591 * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
1592 * to know if the call was answered or not.
1593 */
1594struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr,
1595 int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
1596
1597/*!
1598 * \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.
1599 * \param caller in channel that requested orig
1600 * \param orig channel being replaced by the call forward channel
1601 * \param timeout maximum amount of time to wait for setup of new forward channel
1602 * \param cap format capabilities for requested channel
1603 * \param oh outgoing helper used with original channel
1604 * \param outstate reason why unsuccessful (if unsuccessful)
1605 * \return Returns the forwarded call's ast_channel on success or NULL on failure
1606 */
1607struct 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);
1608
1609/*!
1610 * \brief Register a channel technology (a new channel driver)
1611 * Called by a channel module to register the kind of channels it supports.
1612 * \param tech Structure defining channel technology or "type"
1613 * \return Returns 0 on success, -1 on failure.
1614 */
1615int ast_channel_register(const struct ast_channel_tech *tech);
1616
1617/*!
1618 * \brief Unregister a channel technology
1619 * \param tech Structure defining channel technology or "type" that was previously registered
1620 */
1621void ast_channel_unregister(const struct ast_channel_tech *tech);
1622
1623/*!
1624 * \brief Get a channel technology structure by name
1625 * \param name name of technology to find
1626 * \return a pointer to the structure, or NULL if no matching technology found
1627 */
1628const struct ast_channel_tech *ast_get_channel_tech(const char *name);
1629
1630/*!
1631 * \brief Hang up a channel
1632 * \note Absolutely _NO_ channel locks should be held before calling this function.
1633 * \note This function performs a hard hangup on a channel. Unlike the soft-hangup, this function
1634 * performs all stream stopping, etc, on the channel that needs to end.
1635 * chan is no longer valid after this call.
1636 * \param chan channel to hang up (NULL tolerant)
1637 */
1638void ast_hangup(struct ast_channel *chan);
1639
1640/*!
1641 * \brief Soft hangup all active channels.
1642 * \since 13.3.0
1643 */
1644void ast_softhangup_all(void);
1645
1646/*!
1647 * \brief Softly hangup up a channel
1648 *
1649 * \param chan channel to be soft-hung-up
1650 * \param cause an AST_SOFTHANGUP_* reason code
1651 *
1652 * \details
1653 * Call the protocol layer, but don't destroy the channel structure
1654 * (use this if you are trying to
1655 * safely hangup a channel managed by another thread.
1656 *
1657 * \note The channel passed to this function does not need to be locked.
1658 *
1659 * \return Returns 0 regardless
1660 */
1661int ast_softhangup(struct ast_channel *chan, int cause);
1662
1663/*!
1664 * \brief Softly hangup up a channel (no channel lock)
1665 * \param chan channel to be soft-hung-up
1666 * \param cause an AST_SOFTHANGUP_* reason code
1667 */
1668int ast_softhangup_nolock(struct ast_channel *chan, int cause);
1669
1670/*!
1671 * \brief Clear a set of softhangup flags from a channel
1672 *
1673 * Never clear a softhangup flag from a channel directly. Instead,
1674 * use this function. This ensures that all aspects of the softhangup
1675 * process are aborted.
1676 *
1677 * \param chan the channel to clear the flag on
1678 * \param flag the flag or flags to clear
1679 */
1680void ast_channel_clear_softhangup(struct ast_channel *chan, int flag);
1681
1682/*!
1683 * \brief Set the source of the hangup in this channel and it's bridge
1684 *
1685 * \param chan channel to set the field on
1686 * \param source a string describing the source of the hangup for this channel
1687 * \param force
1688 *
1689 * \note Absolutely _NO_ channel locks should be held before calling this function.
1690 *
1691 * \since 1.8
1692 *
1693 * Hangupsource is generally the channel name that caused the bridge to be
1694 * hung up, but it can also be other things such as "dialplan/agi"
1695 * This can then be logged in the CDR or CEL
1696 */
1697void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force);
1698
1699/*! \brief Check to see if a channel is needing hang up
1700 * \param chan channel on which to check for hang up
1701 * This function determines if the channel is being requested to be hung up.
1702 * \return Returns 0 if not, or 1 if hang up is requested (including time-out).
1703 */
1704int ast_check_hangup(struct ast_channel *chan);
1705
1706int ast_check_hangup_locked(struct ast_channel *chan);
1707
1708/*! \brief This function will check if the bridge needs to be re-evaluated due to
1709 * external changes.
1710 *
1711 * \param chan Channel on which to check the unbridge_eval flag
1712 *
1713 * \return Returns 0 if the flag is down or 1 if the flag is up.
1714 */
1715int ast_channel_unbridged(struct ast_channel *chan);
1716
1717/*! \brief ast_channel_unbridged variant. Use this if the channel
1718 * is already locked prior to calling.
1719 *
1720 * \param chan Channel on which to check the unbridge flag
1721 *
1722 * \return Returns 0 if the flag is down or 1 if the flag is up.
1723 */
1725
1726/*! \brief Sets the unbridged flag and queues a NULL frame on the channel to trigger
1727 * a check by bridge_channel_wait
1728 *
1729 * \param chan Which channel is having its unbridged value set
1730 * \param value What the unbridge value is being set to
1731 */
1732void ast_channel_set_unbridged(struct ast_channel *chan, int value);
1733
1734/*! \brief Variant of ast_channel_set_unbridged. Use this if the channel
1735 * is already locked prior to calling.
1736 *
1737 * \param chan Which channel is having its unbridged value set
1738 * \param value What the unbridge value is being set to
1739 */
1740void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value);
1741
1742/*!
1743 * \brief This function will check if T.38 is active on the channel.
1744 *
1745 * \param chan Channel on which to check the unbridge_eval flag
1746 *
1747 * \return Returns 0 if the flag is down or 1 if the flag is up.
1748 */
1749int ast_channel_is_t38_active(struct ast_channel *chan);
1750
1751/*!
1752 * \brief ast_channel_is_t38_active variant. Use this if the channel
1753 * is already locked prior to calling.
1754 *
1755 * \param chan Channel on which to check the is_t38_active flag
1756 *
1757 * \return Returns 0 if the flag is down or 1 if the flag is up.
1758 */
1760
1761/*!
1762 * \brief Sets the is_t38_active flag
1763 *
1764 * \param chan Which channel is having its is_t38_active value set
1765 * \param is_t38_active Non-zero if T.38 is active
1766 */
1767void ast_channel_set_is_t38_active(struct ast_channel *chan, int is_t38_active);
1768
1769/*!
1770 * \brief Variant of ast_channel_set_is_t38_active. Use this if the channel
1771 * is already locked prior to calling.
1772 *
1773 * \param chan Which channel is having its is_t38_active value set
1774 * \param is_t38_active Non-zero if T.38 is active
1775 */
1776void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active);
1777
1778/*!
1779 * \brief Lock the given channel, then request softhangup on the channel with the given causecode
1780 * \param chan channel on which to hang up
1781 * \param causecode cause code to use (Zero if don't use cause code)
1782 */
1783void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode);
1784
1785/*!
1786 * \brief Compare a offset with the settings of when to hang a channel up
1787 * \param chan channel on which to check for hangup
1788 * \param offset offset in seconds and microseconds from current time
1789 * \retval 1
1790 * \retval 0
1791 * \retval -1
1792 * This function compares a offset from current time with the absolute time
1793 * out on a channel (when to hang up). If the absolute time out on a channel
1794 * is earlier than current time plus the offset, it returns 1, if the two
1795 * time values are equal, it return 0, otherwise, it return -1.
1796 * \since 1.6.1
1797 */
1798int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1799
1800/*!
1801 * \brief Set when to hang a channel up
1802 *
1803 * \param chan channel on which to check for hang up
1804 * \param offset offset in seconds and useconds relative to the current time of when to hang up
1805 *
1806 * This function sets the absolute time out on a channel (when to hang up).
1807 *
1808 * \pre chan is locked
1809 *
1810 * \since 1.6.1
1811 */
1812void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1813
1814/*!
1815 * \brief Answer a channel
1816 *
1817 * \param chan channel to answer
1818 *
1819 * \details
1820 * This function answers a channel and handles all necessary call
1821 * setup functions.
1822 *
1823 * \note The channel passed does not need to be locked, but is locked
1824 * by the function when needed.
1825 *
1826 * \note This function will wait up to 500 milliseconds for media to
1827 * arrive on the channel before returning to the caller, so that the
1828 * caller can properly assume the channel is 'ready' for media flow.
1829 *
1830 * \retval 0 on success
1831 * \retval non-zero on failure
1832 */
1833int ast_answer(struct ast_channel *chan);
1834
1835/*!
1836 * \brief Answer a channel, if it's not already answered.
1837 *
1838 * \param chan channel to answer
1839 *
1840 * \details See ast_answer()
1841 *
1842 * \retval 0 on success
1843 * \retval non-zero on failure
1844 */
1845int ast_auto_answer(struct ast_channel *chan);
1846
1847/*!
1848 * \brief Answer a channel
1849 *
1850 * \param chan channel to answer
1851 *
1852 * This function answers a channel and handles all necessary call
1853 * setup functions.
1854 *
1855 * \note The channel passed does not need to be locked, but is locked
1856 * by the function when needed.
1857 *
1858 * \note Unlike ast_answer(), this function will not wait for media
1859 * flow to begin. The caller should be careful before sending media
1860 * to the channel before incoming media arrives, as the outgoing
1861 * media may be lost.
1862 *
1863 * \retval 0 on success
1864 * \retval non-zero on failure
1865 */
1866int ast_raw_answer(struct ast_channel *chan);
1867
1868/*!
1869 * \brief Answer a channel passing in a stream topology
1870 * \since 18.0.0
1871 *
1872 * \param chan channel to answer
1873 * \param topology the peer's stream topology
1874 *
1875 * This function answers a channel and handles all necessary call
1876 * setup functions.
1877 *
1878 * \note The channel passed does not need to be locked, but is locked
1879 * by the function when needed.
1880 *
1881 * \note Unlike ast_answer(), this function will not wait for media
1882 * flow to begin. The caller should be careful before sending media
1883 * to the channel before incoming media arrives, as the outgoing
1884 * media may be lost.
1885 *
1886 * \note The topology is usually that of the peer channel and may be NULL.
1887 *
1888 * \retval 0 on success
1889 * \retval non-zero on failure
1890 */
1891int ast_raw_answer_with_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology);
1892
1893/*!
1894 * \brief Answer a channel, with a selectable delay before returning
1895 *
1896 * \param chan channel to answer
1897 * \param delay maximum amount of time to wait for incoming media
1898 *
1899 * This function answers a channel and handles all necessary call
1900 * setup functions.
1901 *
1902 * \note The channel passed does not need to be locked, but is locked
1903 * by the function when needed.
1904 *
1905 * \note This function will wait up to 'delay' milliseconds for media to
1906 * arrive on the channel before returning to the caller, so that the
1907 * caller can properly assume the channel is 'ready' for media flow. If
1908 * 'delay' is less than 500, the function will wait up to 500 milliseconds.
1909 *
1910 * \retval 0 on success
1911 * \retval non-zero on failure
1912 */
1913int __ast_answer(struct ast_channel *chan, unsigned int delay);
1914
1915/*!
1916 * \brief Execute a Gosub call on the channel before a call is placed.
1917 * \since 11.0
1918 *
1919 * \details
1920 * This is called between ast_request() and ast_call() to
1921 * execute a predial routine on the newly created channel.
1922 *
1923 * \param chan Channel to execute Gosub.
1924 * \param sub_args Gosub application parameter string.
1925 *
1926 * \note Absolutely _NO_ channel locks should be held before calling this function.
1927 *
1928 * \retval 0 on success.
1929 * \retval -1 on error.
1930 */
1931int ast_pre_call(struct ast_channel *chan, const char *sub_args);
1932
1933/*!
1934 * \brief Make a call
1935 * \note Absolutely _NO_ channel locks should be held before calling this function.
1936 * \param chan which channel to make the call on
1937 * \param addr destination of the call
1938 * \param timeout time to wait on for connect (Doesn't seem to be used.)
1939 * \details
1940 * Place a call, take no longer than timeout ms.
1941 * \retval 0 on success
1942 * \retval -1 on failure
1943 */
1944int ast_call(struct ast_channel *chan, const char *addr, int timeout);
1945
1946/*!
1947 * \brief Indicates condition of channel
1948 * \note Absolutely _NO_ channel locks should be held before calling this function.
1949 * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel
1950 * \param chan channel to change the indication
1951 * \param condition which condition to indicate on the channel
1952 * \return Returns 0 on success, -1 on failure
1953 */
1954int ast_indicate(struct ast_channel *chan, int condition);
1955
1956/*!
1957 * \brief Indicates condition of channel, with payload
1958 * \note Absolutely _NO_ channel locks should be held before calling this function.
1959 * \note Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class
1960 * \param chan channel to change the indication
1961 * \param condition which condition to indicate on the channel
1962 * \param data pointer to payload data
1963 * \param datalen size of payload data
1964 * \return Returns 0 on success, -1 on failure
1965 */
1966int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen);
1967
1968/* Misc stuff ------------------------------------------------ */
1969
1970/*!
1971 * \brief Wait for input on a channel
1972 * \param chan channel to wait on
1973 * \param ms length of time to wait on the channel
1974 * \details
1975 * Wait for input on a channel for a given # of milliseconds (<0 for indefinite).
1976 * \retval < 0 on failure
1977 * \retval 0 if nothing ever arrived
1978 * \retval the # of ms remaining otherwise
1979 */
1980int ast_waitfor(struct ast_channel *chan, int ms);
1981
1982/*!
1983 * \brief Should we keep this frame for later?
1984 *
1985 * There are functions such as ast_safe_sleep which will
1986 * service a channel to ensure that it does not have a
1987 * large backlog of queued frames. When this happens,
1988 * we want to hold on to specific frame types and just drop
1989 * others. This function will tell if the frame we just
1990 * read should be held onto.
1991 *
1992 * \param frame The frame we just read
1993 * \retval 1 frame should be kept
1994 * \retval 0 frame should be dropped
1995 */
1996int ast_is_deferrable_frame(const struct ast_frame *frame);
1997
1998/*!
1999 * \brief Wait for a specified amount of time, looking for hangups
2000 * \param chan channel to wait for
2001 * \param ms length of time in milliseconds to sleep. This should never be less than zero.
2002 * \details
2003 * Waits for a specified amount of time, servicing the channel as required.
2004 * \return returns -1 on hangup, otherwise 0.
2005 */
2006int ast_safe_sleep(struct ast_channel *chan, int ms);
2007
2008/*!
2009 * \brief Wait for a specified amount of time, looking for hangups, and do not generate silence
2010 * \param chan channel to wait for
2011 * \param ms length of time in milliseconds to sleep. This should never be less than zero.
2012 * \details
2013 * Waits for a specified amount of time, servicing the channel as required.
2014 * \return returns -1 on hangup, otherwise 0.
2015 * \note Unlike ast_safe_sleep this will not generate silence if Asterisk is configured to do so.
2016 */
2017int ast_safe_sleep_without_silence(struct ast_channel *chan, int ms);
2018
2019/*!
2020 * \brief Wait for a specified amount of time, looking for hangups and a condition argument
2021 * \param chan channel to wait for
2022 * \param ms length of time in milliseconds to sleep.
2023 * \param cond a function pointer for testing continue condition
2024 * \param data argument to be passed to the condition test function
2025 * \return returns -1 on hangup, otherwise 0.
2026 * \details
2027 * Waits for a specified amount of time, servicing the channel as required. If cond
2028 * returns 0, this function returns.
2029 */
2030int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data );
2031
2032/*!
2033 * \brief Waits for activity on a group of channels
2034 * \param c an array of pointers to channels
2035 * \param n number of channels that are to be waited upon
2036 * \param fds an array of fds to wait upon
2037 * \param nfds the number of fds to wait upon
2038 * \param exception exception flag
2039 * \param outfd fd that had activity on it
2040 * \param ms On invocation, max wait time. Upon returning, how long the wait
2041 * actually was (in/out parameter).
2042 * \details
2043 * Big momma function here. Wait for activity on any of the n channels, or any of the nfds
2044 * file descriptors. -1 can be passed as the ms timeout to wait forever, 0 to
2045 * return instantly if theres no activity immediantely available.
2046 * \return Returns the channel with activity, or NULL on error or if an FD
2047 * came first. If the FD came first, it will be returned in outfd, otherwise, outfd
2048 * will be -1
2049 */
2050struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n,
2051 int *fds, int nfds, int *exception, int *outfd, int *ms);
2052
2053/*!
2054 * \brief Waits for input on a group of channels
2055 * Wait for input on an array of channels for a given # of milliseconds.
2056 * \return Return channel with activity, or NULL if none has activity.
2057 * \param chan an array of pointers to channels
2058 * \param n number of channels that are to be waited upon
2059 * \param ms time "ms" is modified in-place, if applicable
2060 */
2061struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms);
2062
2063/*!
2064 * \brief Waits for input on an fd
2065 * \note This version works on fd's only. Be careful with it.
2066 */
2067int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);
2068
2069
2070/*!
2071 * \brief Reads a frame
2072 *
2073 * \param chan channel to read a frame from
2074 *
2075 * \return Returns a frame, or NULL on error. If it returns NULL, you
2076 * best just stop reading frames and assume the channel has been
2077 * disconnected.
2078 *
2079 * \note This function will filter frames received from the channel so
2080 * that only frames from the default stream for each media type
2081 * are returned. All other media frames from other streams will
2082 * be absorbed internally and a NULL frame returned instead.
2083 */
2084struct ast_frame *ast_read(struct ast_channel *chan);
2085
2086/*!
2087 * \brief Reads a frame, but does not filter to just the default streams
2088 *
2089 * \param chan channel to read a frame from
2090 *
2091 * \return Returns a frame, or NULL on error. If it returns NULL, you
2092 * best just stop reading frames and assume the channel has been
2093 * disconnected.
2094 *
2095 * \note This function will not perform any filtering and will return
2096 * media frames from all streams on the channel. To determine which
2097 * stream a frame originated from the stream_num on it can be
2098 * examined.
2099 */
2100struct ast_frame *ast_read_stream(struct ast_channel *chan);
2101
2102/*!
2103 * \brief Reads a frame, returning AST_FRAME_NULL frame if audio.
2104 * \param chan channel to read a frame from
2105 * \return Returns a frame, or NULL on error. If it returns NULL, you
2106 * best just stop reading frames and assume the channel has been
2107 * disconnected.
2108 * \note Audio is replaced with AST_FRAME_NULL to avoid
2109 * transcode when the resulting audio is not necessary.
2110 */
2111struct ast_frame *ast_read_noaudio(struct ast_channel *chan);
2112
2113/*!
2114 * \brief Reads a frame, but does not filter to just the default streams,
2115 * returning AST_FRAME_NULL frame if audio.
2116 *
2117 * \param chan channel to read a frame from
2118 *
2119 * \return Returns a frame, or NULL on error. If it returns NULL, you
2120 * best just stop reading frames and assume the channel has been
2121 * disconnected.
2122 *
2123 * \note This function will not perform any filtering and will return
2124 * media frames from all streams on the channel. To determine which
2125 * stream a frame originated from the stream_num on it can be
2126 * examined.
2127 *
2128 * \note Audio is replaced with AST_FRAME_NULL to avoid
2129 * transcode when the resulting audio is not necessary.
2130 */
2131struct ast_frame *ast_read_stream_noaudio(struct ast_channel *chan);
2132
2133/*!
2134 * \brief Write a frame to a channel
2135 * This function writes the given frame to the indicated channel.
2136 * \param chan destination channel of the frame
2137 * \param frame frame that will be written
2138 * \return It returns 0 on success, -1 on failure.
2139 */
2140int ast_write(struct ast_channel *chan, struct ast_frame *frame);
2141
2142/*!
2143 * \brief Write video frame to a channel
2144 * This function writes the given frame to the indicated channel.
2145 * \param chan destination channel of the frame
2146 * \param frame frame that will be written
2147 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
2148 */
2149int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);
2150
2151/*!
2152 * \brief Write text frame to a channel
2153 * This function writes the given frame to the indicated channel.
2154 * \param chan destination channel of the frame
2155 * \param frame frame that will be written
2156 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
2157 */
2158int ast_write_text(struct ast_channel *chan, struct ast_frame *frame);
2159
2160/*!
2161 * \brief Write a frame to a stream
2162 * This function writes the given frame to the indicated stream on the channel.
2163 * \param chan destination channel of the frame
2164 * \param stream_num destination stream on the channel
2165 * \param frame frame that will be written
2166 * \return It returns 0 on success, -1 on failure.
2167 * \note If -1 is provided as the stream number and a media frame is provided the
2168 * function will write to the default stream of the type of media.
2169 */
2170int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *frame);
2171
2172/*! \brief Send empty audio to prime a channel driver */
2173int ast_prod(struct ast_channel *chan);
2174
2175/*!
2176 * \brief Set specific read path on channel.
2177 * \since 13.4.0
2178 *
2179 * \param chan Channel to setup read path.
2180 * \param raw_format Format to expect from the channel driver.
2181 * \param core_format What the core wants to read.
2182 *
2183 * \pre chan is locked
2184 *
2185 * \retval 0 on success.
2186 * \retval -1 on error.
2187 */
2188int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format);
2189
2190/*!
2191 * \brief Set specific write path on channel.
2192 * \since 13.13.0
2193 *
2194 * \param chan Channel to setup write path.
2195 * \param core_format What the core wants to write.
2196 * \param raw_format Raw write format.
2197 *
2198 * \pre chan is locked
2199 *
2200 * \retval 0 on success.
2201 * \retval -1 on error.
2202 */
2203int ast_set_write_format_path(struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format);
2204
2205/*!
2206 * \brief Sets read format on channel chan from capabilities
2207 * Set read format for channel to whichever component of "format" is best.
2208 * \param chan channel to change
2209 * \param formats new formats to pick from for reading
2210 * \return Returns 0 on success, -1 on failure
2211 */
2213
2214/*!
2215 * \brief Sets read format on channel chan
2216 * \param chan channel to change
2217 * \param format format to set for reading
2218 * \return Returns 0 on success, -1 on failure
2219 */
2220int ast_set_read_format(struct ast_channel *chan, struct ast_format *format);
2221
2222/*!
2223 * \brief Sets write format on channel chan
2224 * Set write format for channel to whichever component of "format" is best.
2225 * \param chan channel to change
2226 * \param formats new formats to pick from for writing
2227 * \return Returns 0 on success, -1 on failure
2228 */
2230
2231/*!
2232 * \brief Sets write format on channel chan
2233 * \param chan channel to change
2234 * \param format format to set for writing
2235 * \return Returns 0 on success, -1 on failure
2236 */
2237int ast_set_write_format(struct ast_channel *chan, struct ast_format *format);
2238
2239/*!
2240 * \brief Sets write format for a channel.
2241 * All internal data will than be handled in an interleaved format. (needed by binaural opus)
2242 *
2243 * \param chan channel to change
2244 * \param format format to set for writing
2245 * \return Returns 0 on success, -1 on failure
2246 */
2247int ast_set_write_format_interleaved_stereo(struct ast_channel *chan, struct ast_format *format);
2248
2249/*!
2250 * \brief Sends text to a channel
2251 *
2252 * \param chan channel to act upon
2253 * \param text string of text to send on the channel
2254 *
2255 * \details
2256 * Write text to a display on a channel
2257 *
2258 * \note The channel does not need to be locked before calling this function.
2259 *
2260 * \retval 0 on success
2261 * \retval -1 on failure
2262 */
2263int ast_sendtext(struct ast_channel *chan, const char *text);
2264
2265/*!
2266 * \brief Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback
2267 * \since 13.22.0
2268 * \since 15.5.0
2269 *
2270 * \param chan channel to act upon
2271 * \param msg ast_msg_data structure
2272 *
2273 * \details
2274 * Write text to a display on a channel. If the channel driver doesn't support the
2275 * send_text_data callback. then the original send_text callback will be used if
2276 * available.
2277 *
2278 * \note The channel does not need to be locked before calling this function.
2279 *
2280 * \retval 0 on success
2281 * \retval -1 on failure
2282 */
2283int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg);
2284
2285/*!
2286 * \brief Receives a text character from a channel
2287 * \param chan channel to act upon
2288 * \param timeout timeout in milliseconds (0 for infinite wait)
2289 * \details
2290 * Read a char of text from a channel
2291 * \return 0 on success, -1 on failure
2292 */
2293int ast_recvchar(struct ast_channel *chan, int timeout);
2294
2295/*!
2296 * \brief End sending an MF digit to a channel.
2297 * \param chan channel to act upon
2298 * \return Returns 0 on success, -1 on failure
2299 */
2300int ast_senddigit_mf_end(struct ast_channel *chan);
2301
2302/*!
2303 * \brief Send an MF digit to a channel.
2304 *
2305 * \param chan channel to act upon
2306 * \param digit the MF digit to send, encoded in ASCII
2307 * \param duration the duration of a numeric digit ending in ms
2308 * \param durationkp the duration of a KP digit ending in ms
2309 * \param durationst the duration of a ST, STP, ST2P, or ST3P digit ending in ms
2310 * \param is_external 1 if called by a thread that is not the channel's media
2311 * handler thread, 0 if called by the channel's media handler
2312 * thread.
2313 *
2314 * \return 0 on success, -1 on failure
2315 */
2316int ast_senddigit_mf(struct ast_channel *chan, char digit, unsigned int duration,
2317 unsigned int durationkp, unsigned int durationst, int is_external);
2318
2319/*!
2320 * \brief Send a DTMF digit to a channel.
2321 *
2322 * \param chan channel to act upon
2323 * \param digit the DTMF digit to send, encoded in ASCII
2324 * \param duration the duration of the digit ending in ms
2325 *
2326 * \pre This must only be called by the channel's media handler thread.
2327 *
2328 * \return 0 on success, -1 on failure
2329 */
2330int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
2331
2332/*!
2333 * \brief Send a DTMF digit to a channel from an external thread.
2334 *
2335 * \param chan channel to act upon
2336 * \param digit the DTMF digit to send, encoded in ASCII
2337 * \param duration the duration of the digit ending in ms
2338 *
2339 * \pre This must only be called by threads that are not the channel's
2340 * media handler thread.
2341 *
2342 * \return 0 on success, -1 on failure
2343 */
2344int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration);
2345
2346/*!
2347 * \brief Send an MF digit to a channel.
2348 * \param chan channel to act upon
2349 * \param digit the MF digit to send, encoded in ASCII
2350 * \return 0 on success, -1 on failure
2351 */
2352int ast_senddigit_mf_begin(struct ast_channel *chan, char digit);
2353
2354/*!
2355 * \brief Send a DTMF digit to a channel.
2356 * \param chan channel to act upon
2357 * \param digit the DTMF digit to send, encoded in ASCII
2358 * \return 0 on success, -1 on failure
2359 */
2360int ast_senddigit_begin(struct ast_channel *chan, char digit);
2361
2362/*!
2363 * \brief Send a DTMF digit to a channel.
2364 * \param chan channel to act upon
2365 * \param digit the DTMF digit to send, encoded in ASCII
2366 * \param duration the duration of the digit ending in ms
2367 * \return Returns 0 on success, -1 on failure
2368 */
2369int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration);
2370
2371/*!
2372 * \brief Receives a text string from a channel
2373 * Read a string of text from a channel
2374 * \param chan channel to act upon
2375 * \param timeout timeout in milliseconds (0 for infinite wait)
2376 * \return the received text, or NULL to signify failure.
2377 */
2378char *ast_recvtext(struct ast_channel *chan, int timeout);
2379
2380/*!
2381 * \brief Waits for a digit
2382 * \param c channel to wait for a digit on
2383 * \param ms how many milliseconds to wait (<0 for indefinite).
2384 * \return Returns <0 on error, 0 on no entry, and the digit on success.
2385 */
2386int ast_waitfordigit(struct ast_channel *c, int ms);
2387
2388/*!
2389 * \brief Wait for a digit
2390 * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
2391 * \param c channel to wait for a digit on
2392 * \param ms how many milliseconds to wait (<0 for indefinite).
2393 * \param breakon string of DTMF digits to break upon or NULL for any.
2394 * \param audiofd audio file descriptor to write to if audio frames are received
2395 * \param ctrlfd control file descriptor to monitor for reading
2396 * \return Returns 1 if ctrlfd becomes available
2397 */
2398int ast_waitfordigit_full(struct ast_channel *c, int ms, const char *breakon, int audiofd, int ctrlfd);
2399
2400/*!
2401 * \brief Reads multiple digits
2402 * \param c channel to read from
2403 * \param s string to read in to. Must be at least the size of your length
2404 * \param len how many digits to read (maximum)
2405 * \param timeout how long to timeout between digits
2406 * \param rtimeout timeout to wait on the first digit
2407 * \param enders digits to end the string
2408 * \details
2409 * Read in a digit string "s", max length "len", maximum timeout between
2410 * digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout
2411 * for the first digit.
2412 * \return Returns 0 on normal return, or 1 on a timeout. In the case of
2413 * a timeout, any digits that were read before the timeout will still be available in s.
2414 * RETURNS 2 in full version when ctrlfd is available, NOT 1
2415 */
2416int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders);
2417int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd);
2418
2419/*! \brief Report DTMF on channel 0 */
2420#define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0)
2421/*! \brief Report DTMF on channel 1 */
2422#define AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1)
2423
2424
2425/*!
2426 * \brief Make the frame formats of two channels compatible.
2427 *
2428 * \param chan First channel to make compatible. Should be the calling party.
2429 * \param peer Other channel to make compatible. Should be the called party.
2430 *
2431 * \note Absolutely _NO_ channel locks should be held before calling this function.
2432 *
2433 * \details
2434 * Set two channels to compatible frame formats in both
2435 * directions. The path from peer to chan is made compatible
2436 * first to allow for in-band audio in case the other direction
2437 * cannot be made compatible.
2438 *
2439 * \retval 0 on success.
2440 * \retval -1 on error.
2441 */
2442int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer);
2443
2444/*!
2445 * \brief Bridge two channels together (early)
2446 * \param c0 first channel to bridge
2447 * \param c1 second channel to bridge
2448 * \details
2449 * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
2450 * \return Returns 0 on success and -1 if it could not be done
2451 */
2452int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
2453
2454/*!
2455 * \brief Gives the string form of a given cause code.
2456 *
2457 * \param cause cause to get the description of
2458 * \return the text form of the binary cause code given
2459 */
2460const char *ast_cause2str(int cause) attribute_pure;
2461
2462/*!
2463 * \brief Convert the string form of a cause code to a number
2464 *
2465 * \param name string form of the cause
2466 * \return the cause code
2467 */
2468int ast_str2cause(const char *name) attribute_pure;
2469
2470/*!
2471 * \brief Gives the string form of a given channel state
2472 *
2473 * \param state state to get the name of
2474 * \return the text form of the binary state given
2475 *
2476 * \note This function is not reentrant.
2477 */
2478const char *ast_state2str(enum ast_channel_state state);
2479
2480/*!
2481 * \brief Gives the string form of a given transfer capability
2482 *
2483 * \param transfercapability transfer capability to get the name of
2484 * \return the text form of the binary transfer capability
2485 */
2486char *ast_transfercapability2str(int transfercapability) attribute_const;
2487
2488/*
2489 * Options: Some low-level drivers may implement "options" allowing fine tuning of the
2490 * low level channel. See frame.h for options. Note that many channel drivers may support
2491 * none or a subset of those features, and you should not count on this if you want your
2492 * asterisk application to be portable. They're mainly useful for tweaking performance
2493 */
2494
2495/*!
2496 * \brief Sets an option on a channel
2497 *
2498 * \param channel channel to set options on
2499 * \param option option to change
2500 * \param data data specific to option
2501 * \param datalen length of the data
2502 * \param block blocking or not
2503 * \details
2504 * Set an option on a channel (see frame.h), optionally blocking awaiting the reply
2505 * \return 0 on success and -1 on failure
2506 */
2507int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
2508
2509/*!
2510 * \brief Checks the value of an option
2511 *
2512 * Query the value of an option
2513 * Works similarly to setoption except only reads the options.
2514 */
2515int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block);
2516
2517/*!
2518 * \brief Checks for HTML support on a channel
2519 * \return 0 if channel does not support HTML or non-zero if it does
2520 */
2521int ast_channel_supports_html(struct ast_channel *channel);
2522
2523/*!
2524 * \brief Sends HTML on given channel
2525 * Send HTML or URL on link.
2526 * \return 0 on success or -1 on failure
2527 */
2528int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen);
2529
2530/*!
2531 * \brief Sends a URL on a given link
2532 * Send URL on link.
2533 * \return 0 on success or -1 on failure
2534 */
2535int ast_channel_sendurl(struct ast_channel *channel, const char *url);
2536
2537/*!
2538 * \brief Defers DTMF so that you only read things like hangups and audio.
2539 * \return non-zero if channel was already DTMF-deferred or
2540 * 0 if channel is just now being DTMF-deferred
2541 */
2542int ast_channel_defer_dtmf(struct ast_channel *chan);
2543
2544/*! Undo defer. ast_read will return any DTMF characters that were queued */
2545void ast_channel_undefer_dtmf(struct ast_channel *chan);
2546
2547/*! \return number of channels available for lookup */
2548int ast_active_channels(void);
2549
2550/*! \return the number of channels not yet destroyed */
2551int ast_undestroyed_channels(void);
2552
2553/*! Activate a given generator */
2554int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);
2555
2556/*! Deactivate an active generator */
2557void ast_deactivate_generator(struct ast_channel *chan);
2558
2559/*!
2560 * \since 13.27.0
2561 * \since 16.4.0
2562 * \brief Obtain how long it's been, in milliseconds, since the channel was created
2563 *
2564 * \param chan The channel object
2565 *
2566 * \retval 0 if the time value cannot be computed (or you called this really fast)
2567 * \retval The number of milliseconds since channel creation
2568 */
2569int64_t ast_channel_get_duration_ms(struct ast_channel *chan);
2570
2571/*!
2572 * \since 12
2573 * \brief Obtain how long the channel since the channel was created
2574 *
2575 * \param chan The channel object
2576 *
2577 * \retval 0 if the time value cannot be computed (or you called this really fast)
2578 * \retval The number of seconds the channel has been up
2579 */
2580int ast_channel_get_duration(struct ast_channel *chan);
2581
2582/*!
2583 * \since 13.27.0
2584 * \since 16.4.0
2585 * \brief Obtain how long it has been since the channel was answered in ms
2586 *
2587 * \param chan The channel object
2588 *
2589 * \retval 0 if the channel isn't answered (or you called this really fast)
2590 * \retval The number of milliseconds the channel has been up
2591 */
2592int64_t ast_channel_get_up_time_ms(struct ast_channel *chan);
2593
2594/*!
2595 * \since 12
2596 * \brief Obtain how long it has been since the channel was answered
2597 *
2598 * \param chan The channel object
2599 *
2600 * \retval 0 if the channel isn't answered (or you called this really fast)
2601 * \retval The number of seconds the channel has been up
2602 */
2603int ast_channel_get_up_time(struct ast_channel *chan);
2604
2605/*!
2606 * \brief Set caller ID number, name and ANI and generate AMI event.
2607 *
2608 * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead.
2609 * \note The channel does not need to be locked before calling this function.
2610 */
2611void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani);
2612
2613/*!
2614 * \brief Set the caller id information in the Asterisk channel
2615 * \since 1.8
2616 *
2617 * \param chan Asterisk channel to set caller id information
2618 * \param caller Caller id information
2619 * \param update What caller information to update. NULL if all.
2620 *
2621 * \note The channel does not need to be locked before calling this function.
2622 */
2623void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2624
2625/*!
2626 * \brief Set the caller id information in the Asterisk channel and generate an AMI event
2627 * if the caller id name or number changed.
2628 * \since 1.8
2629 *
2630 * \param chan Asterisk channel to set caller id information
2631 * \param caller Caller id information
2632 * \param update What caller information to update. NULL if all.
2633 *
2634 * \note The channel does not need to be locked before calling this function.
2635 */
2636void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2637
2638/*! Set the file descriptor on the channel */
2639void ast_channel_set_fd(struct ast_channel *chan, int which, int fd);
2640
2641/*! Start a tone going */
2642int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2643/*! Stop a tone from playing */
2644void ast_tonepair_stop(struct ast_channel *chan);
2645/*! Play a tone pair for a given amount of time */
2646int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2647
2648/*!
2649 * \brief Automatically service a channel for us...
2650 *
2651 * \retval 0 success
2652 * \retval -1 failure, or the channel is already being autoserviced
2653 */
2654int ast_autoservice_start(struct ast_channel *chan);
2655
2656/*!
2657 * \brief Stop servicing a channel for us...
2658 *
2659 * \note if chan is locked prior to calling ast_autoservice_stop, it
2660 * is likely that there will be a deadlock between the thread that calls
2661 * ast_autoservice_stop and the autoservice thread. It is important
2662 * that chan is not locked prior to this call
2663 *
2664 * \param chan
2665 * \retval 0 success
2666 * \retval -1 error, or the channel has been hungup
2667 */
2668int ast_autoservice_stop(struct ast_channel *chan);
2669
2670/*!
2671 * \brief Put chan into autoservice while hanging up peer.
2672 * \since 11.0
2673 *
2674 * \param chan Chan to put into autoservice.
2675 * \param peer Chan to run hangup handlers and hangup.
2676 */
2677void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer);
2678
2679/*!
2680 * \brief Ignore certain frame types
2681 * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames
2682 * while a channel is in autoservice and queue them up when taken out of
2683 * autoservice. When this is not desireable, this API may be used to
2684 * cause the channel to ignore those frametypes after the channel is put
2685 * into autoservice, but before autoservice is stopped.
2686 * \retval 0 success
2687 * \retval -1 channel is not in autoservice
2688 */
2689int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype);
2690
2691/*!
2692 * \brief Enable or disable timer ticks for a channel
2693 *
2694 * \param c channel
2695 * \param rate number of timer ticks per second
2696 * \param func callback function
2697 * \param data
2698 *
2699 * \details
2700 * If timers are supported, force a scheduled expiration on the
2701 * timer fd, at which point we call the callback function / data
2702 *
2703 * \note Call this function with a rate of 0 to turn off the timer ticks
2704 *
2705 * \version 1.6.1 changed samples parameter to rate, accommodates new timing methods
2706 */
2707int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data);
2708int ast_settimeout_full(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data, unsigned int is_ao2_obj);
2709
2710/*!
2711 * \brief Transfer a channel (if supported).
2712 * \retval -1 on error
2713 * \retval 0 if not supported
2714 * \retval 1 if supported and requested
2715 * \param chan current channel
2716 * \param dest destination extension for transfer
2717 */
2718int ast_transfer(struct ast_channel *chan, char *dest);
2719
2720/*!
2721 * \brief Transfer a channel (if supported) receieve protocol result.
2722 * \retval -1 on error
2723 * \retval 0 if not supported
2724 * \retval 1 if supported and requested
2725 * \param chan channel to transfer
2726 * \param dest destination extension to transfer to
2727 * \param protocol protocol is the protocol result
2728 * SIP example, 0=success, 3xx-6xx is SIP error code
2729 */
2730int ast_transfer_protocol(struct ast_channel *chan, char *dest, int *protocol);
2731
2732/*!
2733 * \brief Inherits channel variable from parent to child channel
2734 * \param parent Parent channel
2735 * \param child Child channel
2736 *
2737 * \details
2738 * Scans all channel variables in the parent channel, looking for those
2739 * that should be copied into the child channel.
2740 * Variables whose names begin with a single '_' are copied into the
2741 * child channel with the prefix removed.
2742 * Variables whose names begin with '__' are copied into the child
2743 * channel with their names unchanged.
2744 */
2745void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child);
2746
2747/*!
2748 * \brief adds a list of channel variables to a channel
2749 * \param chan the channel
2750 * \param vars a linked list of variables
2751 *
2752 * \pre chan is locked
2753 *
2754 * \details
2755 * Variable names can be for a regular channel variable or a dialplan function
2756 * that has the ability to be written to.
2757 */
2758void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars);
2759
2760/*!
2761 * \brief An opaque 'object' structure use by silence generators on channels.
2762 */
2764
2765/*!
2766 * \brief Starts a silence generator on the given channel.
2767 * \param chan The channel to generate silence on
2768 * \return An ast_silence_generator pointer, or NULL if an error occurs
2769 *
2770 * \details
2771 * This function will cause SLINEAR silence to be generated on the supplied
2772 * channel until it is disabled; if the channel cannot be put into SLINEAR
2773 * mode then the function will fail.
2774 *
2775 * \note
2776 * The pointer returned by this function must be preserved and passed to
2777 * ast_channel_stop_silence_generator when you wish to stop the silence
2778 * generation.
2779 */
2781
2782/*!
2783 * \brief Stops a previously-started silence generator on the given channel.
2784 * \param chan The channel to operate on
2785 * \param state The ast_silence_generator pointer return by a previous call to
2786 * ast_channel_start_silence_generator.
2787 *
2788 * \details
2789 * This function will stop the operating silence generator and return the channel
2790 * to its previous write format.
2791 */
2793
2794/*!
2795 * \brief Determine which channel has an older linkedid
2796 * \param a First channel
2797 * \param b Second channel
2798 * \return Returns an ast_channel structure that has oldest linkedid
2799 */
2801
2802/*!
2803 * \brief Copy the full linkedid channel id structure from one channel to another
2804 * \param dest Destination to copy linkedid to
2805 * \param source Source channel to copy linkedid from
2806 */
2807void ast_channel_internal_copy_linkedid(struct ast_channel *dest, struct ast_channel *source);
2808
2809/*!
2810 * \brief Swap uniqueid and linkedid beteween two channels
2811 * \param a First channel
2812 * \param b Second channel
2813 *
2814 * \note
2815 * This is used in masquerade to exchange identities
2816 */
2818
2819/*!
2820 * \brief Swap topics beteween two channels
2821 * \param a First channel
2822 * \param b Second channel
2823 *
2824 * \note
2825 * This is used in masquerade to exchange topics for message routing
2826 */
2828
2829/*!
2830 * \brief Swap endpoint_forward between two channels
2831 * \param a First channel
2832 * \param b Second channel
2833 *
2834 * \note
2835 * This is used in masquerade to exchange endpoint details if one of the two or both
2836 * the channels were created with endpoint
2837 */
2839
2840/*!
2841 * \brief Swap snapshots beteween two channels
2842 * \param a First channel
2843 * \param b Second channel
2844 *
2845 * \note
2846 * This is used in masquerade to exchange snapshots
2847 */
2849
2850/*!
2851 * \brief Swap endpoints between two channels
2852 * \param a First channel
2853 * \param b Second channel
2854 *
2855 * \note
2856 * This is used in masquerade to exchange endpoints
2857 */
2859
2860/*!
2861 * \brief Set uniqueid and linkedid string value only (not time)
2862 * \param chan The channel to set the uniqueid to
2863 * \param uniqueid The uniqueid to set
2864 * \param linkedid The linkedid to set
2865 *
2866 * \note
2867 * This is used only by ast_cel_fabricate_channel_from_event()
2868 * to create a temporary fake channel - time values are invalid
2869 */
2870void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid);
2871
2872/* Misc. functions below */
2873
2874/*!
2875 * \brief if fd is a valid descriptor, set *pfd with the descriptor
2876 * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the
2877 * return value to the index into the array)
2878 */
2879static inline int ast_add_fd(struct pollfd *pfd, int fd)
2880{
2881 pfd->fd = fd;
2882 pfd->events = POLLIN | POLLPRI;
2883 return fd >= 0;
2884}
2885
2886/*! \brief Helper function for migrating select to poll */
2887static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
2888{
2889 int x;
2890 int dummy = 0;
2891
2892 if (fd < 0)
2893 return 0;
2894 if (!start)
2895 start = &dummy;
2896 for (x = *start; x < maximum; x++)
2897 if (pfds[x].fd == fd) {
2898 if (x == *start)
2899 (*start)++;
2900 return pfds[x].revents;
2901 }
2902 return 0;
2903}
2904
2905/*!
2906 * \brief Retrieves the current T38 state of a channel
2907 *
2908 * \note Absolutely _NO_ channel locks should be held before calling this function.
2909 */
2911{
2913 int datalen = sizeof(state);
2914
2916
2917 return state;
2918}
2919
2920/*!
2921 * \brief Set the blocking indication on the channel.
2922 *
2923 * \details
2924 * Indicate that the thread handling the channel is about to do a blocking
2925 * operation to wait for media on the channel. (poll, read, or write)
2926 *
2927 * Masquerading and ast_queue_frame() use this indication to wake up the thread.
2928 *
2929 * \pre The channel needs to be locked
2930 */
2931#define CHECK_BLOCKING(c) \
2932 do { \
2933 if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) { \
2934 /* This should not happen as there should only be one thread handling a channel's media at a time. */ \
2935 ast_log(LOG_DEBUG, "Thread LWP %d is blocking '%s', already blocked by thread LWP %d in procedure %s\n", \
2936 ast_get_tid(), ast_channel_name(c), \
2937 ast_channel_blocker_tid(c), ast_channel_blockproc(c)); \
2938 ast_assert(0); \
2939 } \
2940 ast_channel_blocker_tid_set((c), ast_get_tid()); \
2941 ast_channel_blocker_set((c), pthread_self()); \
2942 ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
2943 ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
2944 } while (0)
2945
2946ast_group_t ast_get_group(const char *s);
2947
2948/*! \brief Print call and pickup groups into buffer */
2949char *ast_print_group(char *buf, int buflen, ast_group_t group);
2950
2951/*! \brief Opaque struct holding a namedgroups set, i.e. a set of group names */
2952struct ast_namedgroups;
2953
2954/*! \brief Create an ast_namedgroups set with group names from comma separated string */
2955struct ast_namedgroups *ast_get_namedgroups(const char *s);
2956struct ast_namedgroups *ast_unref_namedgroups(struct ast_namedgroups *groups);
2957struct ast_namedgroups *ast_ref_namedgroups(struct ast_namedgroups *groups);
2958/*! \brief Return TRUE if group a and b contain at least one common groupname */
2959int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups *b);
2960
2961/*! \brief Print named call groups and named pickup groups */
2962char *ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups);
2963
2964/*! \brief return an ast_variable list of channeltypes */
2966
2967/*!
2968 * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
2969 * \param reason The integer argument, usually taken from AST_CONTROL_ macros
2970 * \return char pointer explaining the code
2971 */
2972const char *ast_channel_reason2str(int reason);
2973
2974/*! \brief channel group info */
2981
2982#define ast_channel_lock(chan) ao2_lock(chan)
2983#define ast_channel_unlock(chan) ao2_unlock(chan)
2984#define ast_channel_trylock(chan) ao2_trylock(chan)
2985
2986/*!
2987 * \brief Lock two channels.
2988 */
2989#define ast_channel_lock_both(chan1, chan2) do { \
2990 ast_channel_lock(chan1); \
2991 while (ast_channel_trylock(chan2)) { \
2992 ast_channel_unlock(chan1); \
2993 sched_yield(); \
2994 ast_channel_lock(chan1); \
2995 } \
2996 } while (0)
2997
2998/*!
2999 * \brief Increase channel reference count
3000 *
3001 * \param c the channel
3002 *
3003 * \retval c always
3004 *
3005 * \since 1.8
3006 */
3007#define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); })
3008
3009/*!
3010 * \brief Decrease channel reference count
3011 *
3012 * \param c the channel
3013 *
3014 * \retval NULL always
3015 *
3016 * \since 1.8
3017 */
3018#define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
3019
3020/*!
3021 * \brief Cleanup a channel reference
3022 *
3023 * \param c the channel (NULL tolerant)
3024 *
3025 * \retval NULL always
3026 *
3027 * \since 12.0.0
3028 */
3029#define ast_channel_cleanup(c) ({ ao2_cleanup(c); (struct ast_channel *) (NULL); })
3030
3031/*! Channel Iterating @{ */
3032
3033/*!
3034 * \brief A channel iterator
3035 *
3036 * This is an opaque type.
3037 */
3039
3040/*!
3041 * \brief Destroy a channel iterator
3042 *
3043 * \param i the itereator to destroy
3044 *
3045 * \details
3046 * This function is used to destroy a channel iterator that was retrieved by
3047 * using one of the channel_iterator_xxx_new() functions.
3048 *
3049 * \retval NULL for convenience to clear out the pointer to the iterator that
3050 * was just destroyed.
3051 *
3052 * \since 1.8
3053 */
3055
3056/*!
3057 * \brief Create a new channel iterator based on extension
3058 *
3059 * \param exten The extension that channels must be in
3060 * \param context The context that channels must be in
3061 *
3062 * \details
3063 * After creating an iterator using this function, the ast_channel_iterator_next()
3064 * function can be used to iterate through all channels that are currently
3065 * in the specified context and extension.
3066 *
3067 * \note You must call ast_channel_iterator_destroy() when done.
3068 *
3069 * \retval NULL on failure
3070 * \retval a new channel iterator based on the specified parameters
3071 *
3072 * \since 1.8
3073 */
3074struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context);
3075
3076/*!
3077 * \brief Create a new channel iterator based on name
3078 *
3079 * \param name channel name or channel uniqueid to match
3080 * \param name_len number of characters in the channel name to match on. This
3081 * would be used to match based on name prefix. If matching on the full
3082 * channel name is desired, then this parameter should be 0.
3083 *
3084 * \details
3085 * After creating an iterator using this function, the ast_channel_iterator_next()
3086 * function can be used to iterate through all channels that exist that have
3087 * the specified name or name prefix.
3088 *
3089 * \note You must call ast_channel_iterator_destroy() when done.
3090 *
3091 * \retval NULL on failure
3092 * \retval a new channel iterator based on the specified parameters
3093 *
3094 * \since 1.8
3095 */
3096struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name, size_t name_len);
3097
3098/*!
3099 * \brief Create a new channel iterator
3100 *
3101 * \details
3102 * After creating an iterator using this function, the ast_channel_iterator_next()
3103 * function can be used to iterate through all channels that exist.
3104 *
3105 * \note You must call ast_channel_iterator_destroy() when done.
3106 *
3107 * \retval NULL on failure
3108 * \retval a new channel iterator
3109 *
3110 * \since 1.8
3111 */
3113
3114/*!
3115 * \brief Get the next channel for a channel iterator
3116 *
3117 * \param i the channel iterator that was created using one of the
3118 * channel_iterator_xxx_new() functions.
3119 *
3120 * \details
3121 * This function should be used to iterate through all channels that match a
3122 * specified set of parameters that were provided when the iterator was created.
3123 *
3124 * \retval the next channel that matches the parameters used when the iterator
3125 * was created.
3126 * \retval NULL if no more channels match the iterator parameters.
3127 *
3128 * \since 1.8
3129 */
3131
3132/*! @} End channel iterator definitions. */
3133
3134/*! @{ Channel search functions */
3135
3136/*!
3137* \warning Absolutely _NO_ channel locks should be held while calling any of
3138* these functions.
3139*/
3140
3141/*!
3142 * \brief Call a function with every active channel
3143 *
3144 * \details
3145 * This function executes a callback one time for each active channel on the
3146 * system. The channel is provided as an argument to the function.
3147 *
3148 * \since 1.8
3149 */
3150struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
3151 void *data, int ao2_flags);
3152
3153/*!
3154 * \brief Find a channel by name or uniqueid
3155 *
3156 * \param search the name or uniqueid of the channel to search for
3157 *
3158 * \details
3159 * First searches for a channel with a matching name. If not found
3160 * a search for a channel with a matching uniqueid is done.
3161 *
3162 * \retval a channel with a matching name or uniqueid
3163 * \retval NULL if no channel was found
3164 *
3165 *\note The fallback search by uniqueid is a historical thing. If you
3166 * know the search term is a uniqueid, use \ref ast_channel_get_by_uniqueid
3167 * instead.
3168 *
3169 * \since 1.8
3170 */
3171struct ast_channel *ast_channel_get_by_name(const char *search);
3172
3173/*!
3174 * \brief Find a channel by a name prefix
3175 *
3176 * \param search The channel name or uniqueid prefix to search for
3177 * \param len Only search for up to this many characters from the search term
3178 *
3179 * \details
3180 * Search for a channel that has the same name prefix as specified by the
3181 * search term. If not found, search for an exact match on the uniqueid.
3182 * Searching by partial uniqueid doesn't make any sense as it's usually
3183 * a system-name plus a timestamp and is not supported.
3184 *
3185 * \retval a channel with a matching name or uniqueid
3186 * \retval NULL if no channel was found
3187 *
3188 *\note The fallback search by uniqueid is a historical thing. If you
3189 * know the search term is a uniqueid, use \ref ast_channel_get_by_uniqueid
3190 * instead.
3191 *
3192 * \since 1.8
3193 */
3194struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
3195
3196/*!
3197 * \brief Find a channel by extension and context
3198 *
3199 * \param exten the extension to search for
3200 * \param context the context to search for
3201 *
3202 * \details
3203 * Return a channel that is currently at the specified extension and context.
3204 *
3205 * \retval a channel that is at the specified extension and context
3206 * \retval NULL if no channel was found
3207 *
3208 * \since 1.8
3209 */
3210struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
3211
3212/*!
3213 * \brief Find a channel by a uniqueid
3214 *
3215 * \param uniqueid The uniqueid to search for
3216 *
3217 * \retval a channel with the uniqueid specified by the arguments
3218 * \retval NULL if no channel was found
3219 */
3221
3222/*! @} End channel search functions. */
3223
3224/*!
3225 * \brief Initialize the given name structure.
3226 * \since 1.8
3227 *
3228 * \param init Name structure to initialize.
3229 */
3230void ast_party_name_init(struct ast_party_name *init);
3231
3232/*!
3233 * \brief Copy the source party name information to the destination party name.
3234 * \since 1.8
3235 *
3236 * \param dest Destination party name
3237 * \param src Source party name
3238 */
3239void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src);
3240
3241/*!
3242 * \brief Initialize the given party name structure using the given guide
3243 * for a set update operation.
3244 * \since 1.8
3245 *
3246 * \details
3247 * The initialization is needed to allow a set operation to know if a
3248 * value needs to be updated. Simple integers need the guide's original
3249 * value in case the set operation is not trying to set a new value.
3250 * String values are simply set to NULL pointers if they are not going
3251 * to be updated.
3252 *
3253 * \param init Party name structure to initialize.
3254 * \param guide Source party name to use as a guide in initializing.
3255 */
3256void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide);
3257
3258/*!
3259 * \brief Set the source party name information into the destination party name.
3260 * \since 1.8
3261 *
3262 * \param dest The name one wishes to update
3263 * \param src The new name values to update the dest
3264 */
3265void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src);
3266
3267/*!
3268 * \brief Destroy the party name contents
3269 * \since 1.8
3270 *
3271 * \param doomed The party name to destroy.
3272 */
3273void ast_party_name_free(struct ast_party_name *doomed);
3274
3275/*!
3276 * \brief Initialize the given number structure.
3277 * \since 1.8
3278 *
3279 * \param init Number structure to initialize.
3280 */
3281void ast_party_number_init(struct ast_party_number *init);
3282
3283/*!
3284 * \brief Copy the source party number information to the destination party number.
3285 * \since 1.8
3286 *
3287 * \param dest Destination party number
3288 * \param src Source party number
3289 */
3290void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src);
3291
3292/*!
3293 * \brief Initialize the given party number structure using the given guide
3294 * for a set update operation.
3295 * \since 1.8
3296 *
3297 * \details
3298 * The initialization is needed to allow a set operation to know if a
3299 * value needs to be updated. Simple integers need the guide's original
3300 * value in case the set operation is not trying to set a new value.
3301 * String values are simply set to NULL pointers if they are not going
3302 * to be updated.
3303 *
3304 * \param init Party number structure to initialize.
3305 * \param guide Source party number to use as a guide in initializing.
3306 */
3307void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide);
3308
3309/*!
3310 * \brief Set the source party number information into the destination party number.
3311 * \since 1.8
3312 *
3313 * \param dest The number one wishes to update
3314 * \param src The new number values to update the dest
3315 */
3316void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src);
3317
3318/*!
3319 * \brief Destroy the party number contents
3320 * \since 1.8
3321 *
3322 * \param doomed The party number to destroy.
3323 */
3324void ast_party_number_free(struct ast_party_number *doomed);
3325
3326/*!
3327 * \since 1.8
3328 * \brief Initialize the given subaddress structure.
3329 *
3330 * \param init Subaddress structure to initialize.
3331 */
3333
3334/*!
3335 * \since 1.8
3336 * \brief Copy the source party subaddress information to the destination party subaddress.
3337 *
3338 * \param dest Destination party subaddress
3339 * \param src Source party subaddress
3340 */
3341void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
3342
3343/*!
3344 * \since 1.8
3345 * \brief Initialize the given party subaddress structure using the given guide
3346 * for a set update operation.
3347 *
3348 * \details
3349 * The initialization is needed to allow a set operation to know if a
3350 * value needs to be updated. Simple integers need the guide's original
3351 * value in case the set operation is not trying to set a new value.
3352 * String values are simply set to NULL pointers if they are not going
3353 * to be updated.
3354 *
3355 * \param init Party subaddress structure to initialize.
3356 * \param guide Source party subaddress to use as a guide in initializing.
3357 */
3358void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide);
3359
3360/*!
3361 * \since 1.8
3362 * \brief Set the source party subaddress information into the destination party subaddress.
3363 *
3364 * \param dest The subaddress one wishes to update
3365 * \param src The new subaddress values to update the dest
3366 */
3367void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
3368
3369/*!
3370 * \since 1.8
3371 * \brief Destroy the party subaddress contents
3372 *
3373 * \param doomed The party subaddress to destroy.
3374 */
3376
3377/*!
3378 * \brief Set the update marker to update all information of a corresponding party id.
3379 * \since 11.0
3380 *
3381 * \param update_id The update marker for a corresponding party id.
3382 */
3383void ast_set_party_id_all(struct ast_set_party_id *update_id);
3384
3385/*!
3386 * \brief Initialize the given party id structure.
3387 * \since 1.8
3388 *
3389 * \param init Party id structure to initialize.
3390 */
3391void ast_party_id_init(struct ast_party_id *init);
3392
3393/*!
3394 * \brief Copy the source party id information to the destination party id.
3395 * \since 1.8
3396 *
3397 * \param dest Destination party id
3398 * \param src Source party id
3399 */
3400void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src);
3401
3402/*!
3403 * \brief Initialize the given party id structure using the given guide
3404 * for a set update operation.
3405 * \since 1.8
3406 *
3407 * \details
3408 * The initialization is needed to allow a set operation to know if a
3409 * value needs to be updated. Simple integers need the guide's original
3410 * value in case the set operation is not trying to set a new value.
3411 * String values are simply set to NULL pointers if they are not going
3412 * to be updated.
3413 *
3414 * \param init Party id structure to initialize.
3415 * \param guide Source party id to use as a guide in initializing.
3416 */
3417void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide);
3418
3419/*!
3420 * \brief Set the source party id information into the destination party id.
3421 * \since 1.8
3422 *
3423 * \param dest The id one wishes to update
3424 * \param src The new id values to update the dest
3425 * \param update What id information to update. NULL if all.
3426 */
3427void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update);
3428
3429/*!
3430 * \brief Destroy the party id contents
3431 * \since 1.8
3432 *
3433 * \param doomed The party id to destroy.
3434 */
3435void ast_party_id_free(struct ast_party_id *doomed);
3436
3437/*!
3438 * \brief Determine the overall presentation value for the given party.
3439 * \since 1.8
3440 *
3441 * \param id Party to determine the overall presentation value.
3442 *
3443 * \return Overall presentation value for the given party.
3444 */
3445int ast_party_id_presentation(const struct ast_party_id *id);
3446
3447/*!
3448 * \brief Invalidate all components of the given party id.
3449 * \since 11.0
3450 *
3451 * \param id The party id to invalidate.
3452 */
3453void ast_party_id_invalidate(struct ast_party_id *id);
3454
3455/*!
3456 * \brief Destroy and initialize the given party id structure.
3457 * \since 11.0
3458 *
3459 * \param id The party id to reset.
3460 */
3461void ast_party_id_reset(struct ast_party_id *id);
3462
3463/*!
3464 * \brief Merge a given party id into another given party id.
3465 * \since 11.0
3466 *
3467 * \details
3468 * This function will generate an effective party id.
3469 *
3470 * Each party id component of the party id 'base' is overwritten
3471 * by components of the party id 'overlay' if the overlay
3472 * component is marked as valid. However the component 'tag' of
3473 * the base party id remains untouched.
3474 *
3475 * \param base The party id which is merged.
3476 * \param overlay The party id which is used to merge into.
3477 *
3478 * \return The merged party id as a struct, not as a pointer.
3479 * \note The merged party id returned is a shallow copy and must not be freed.
3480 */
3481struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay);
3482
3483/*!
3484 * \brief Copy a merge of a given party id into another given party id to a given destination party id.
3485 * \since 11.0
3486 *
3487 * \details
3488 * Each party id component of the party id 'base' is overwritten by components
3489 * of the party id 'overlay' if the 'overlay' component is marked as valid.
3490 * However the component 'tag' of the 'base' party id remains untouched.
3491 * The result is copied into the given party id 'dest'.
3492 *
3493 * \note The resulting merged party id is a real copy and has to be freed.
3494 *
3495 * \param dest The resulting merged party id.
3496 * \param base The party id which is merged.
3497 * \param overlay The party id which is used to merge into.
3498 */
3499void ast_party_id_merge_copy(struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay);
3500
3501/*!
3502 * \brief Initialize the given dialed structure.
3503 * \since 1.8
3504 *
3505 * \param init Dialed structure to initialize.
3506 */
3507void ast_party_dialed_init(struct ast_party_dialed *init);
3508
3509/*!
3510 * \brief Copy the source dialed party information to the destination dialed party.
3511 * \since 1.8
3512 *
3513 * \param dest Destination dialed party
3514 * \param src Source dialed party
3515 */
3516void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3517
3518/*!
3519 * \brief Initialize the given dialed structure using the given
3520 * guide for a set update operation.
3521 * \since 1.8
3522 *
3523 * \details
3524 * The initialization is needed to allow a set operation to know if a
3525 * value needs to be updated. Simple integers need the guide's original
3526 * value in case the set operation is not trying to set a new value.
3527 * String values are simply set to NULL pointers if they are not going
3528 * to be updated.
3529 *
3530 * \param init Caller structure to initialize.
3531 * \param guide Source dialed to use as a guide in initializing.
3532 */
3533void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide);
3534
3535/*!
3536 * \brief Set the dialed information based on another dialed source
3537 * \since 1.8
3538 *
3539 * This is similar to ast_party_dialed_copy, except that NULL values for
3540 * strings in the src parameter indicate not to update the corresponding dest values.
3541 *
3542 * \param dest The dialed one wishes to update
3543 * \param src The new dialed values to update the dest
3544 */
3545void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3546
3547/*!
3548 * \brief Destroy the dialed party contents
3549 * \since 1.8
3550 *
3551 * \param doomed The dialed party to destroy.
3552 */
3553void ast_party_dialed_free(struct ast_party_dialed *doomed);
3554
3555/*!
3556 * \since 1.8
3557 * \brief Initialize the given caller structure.
3558 *
3559 * \param init Caller structure to initialize.
3560 */
3561void ast_party_caller_init(struct ast_party_caller *init);
3562
3563/*!
3564 * \since 1.8
3565 * \brief Copy the source caller information to the destination caller.
3566 *
3567 * \param dest Destination caller
3568 * \param src Source caller
3569 */
3570void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src);
3571
3572/*!
3573 * \brief Initialize the given caller structure using the given
3574 * guide for a set update operation.
3575 * \since 1.8
3576 *
3577 * \details
3578 * The initialization is needed to allow a set operation to know if a
3579 * value needs to be updated. Simple integers need the guide's original
3580 * value in case the set operation is not trying to set a new value.
3581 * String values are simply set to NULL pointers if they are not going
3582 * to be updated.
3583 *
3584 * \param init Caller structure to initialize.
3585 * \param guide Source caller to use as a guide in initializing.
3586 */
3587void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide);
3588
3589/*!
3590 * \brief Set the caller information based on another caller source
3591 * \since 1.8
3592 *
3593 * This is similar to ast_party_caller_copy, except that NULL values for
3594 * strings in the src parameter indicate not to update the corresponding dest values.
3595 *
3596 * \param dest The caller one wishes to update
3597 * \param src The new caller values to update the dest
3598 * \param update What caller information to update. NULL if all.
3599 */
3600void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update);
3601
3602/*!
3603 * \brief Destroy the caller party contents
3604 * \since 1.8
3605 *
3606 * \param doomed The caller party to destroy.
3607 */
3608void ast_party_caller_free(struct ast_party_caller *doomed);
3609
3610/*!
3611 * \since 1.8
3612 * \brief Initialize the given connected line structure.
3613 *
3614 * \param init Connected line structure to initialize.
3615 */
3617
3618/*!
3619 * \since 1.8
3620 * \brief Copy the source connected line information to the destination connected line.
3621 *
3622 * \param dest Destination connected line
3623 * \param src Source connected line
3624 */
3626
3627/*!
3628 * \since 1.8
3629 * \brief Initialize the given connected line structure using the given
3630 * guide for a set update operation.
3631 *
3632 * \details
3633 * The initialization is needed to allow a set operation to know if a
3634 * value needs to be updated. Simple integers need the guide's original
3635 * value in case the set operation is not trying to set a new value.
3636 * String values are simply set to NULL pointers if they are not going
3637 * to be updated.
3638 *
3639 * \param init Connected line structure to initialize.
3640 * \param guide Source connected line to use as a guide in initializing.
3641 */
3643
3644/*!
3645 * \since 1.8
3646 * \brief Set the connected line information based on another connected line source
3647 *
3648 * This is similar to ast_party_connected_line_copy, except that NULL values for
3649 * strings in the src parameter indicate not to update the corresponding dest values.
3650 *
3651 * \param dest The connected line one wishes to update
3652 * \param src The new connected line values to update the dest
3653 * \param update What connected line information to update. NULL if all.
3654 */
3656
3657/*!
3658 * \since 1.8
3659 * \brief Collect the caller party information into a connected line structure.
3660 *
3661 * \param connected Collected caller information for the connected line
3662 * \param caller Caller information.
3663 *
3664 * \warning This is a shallow copy.
3665 * \warning DO NOT call ast_party_connected_line_free() on the filled in
3666 * connected line structure!
3667 */
3669
3670/*!
3671 * \since 1.8
3672 * \brief Destroy the connected line information contents
3673 *
3674 * \param doomed The connected line information to destroy.
3675 */
3677
3678/*!
3679 * \brief Initialize the given redirecting reason structure
3680 *
3681 * \param init Redirecting reason structure to initialize
3682 */
3684
3685/*!
3686 * \brief Copy the source redirecting reason information to the destination redirecting reason.
3687 *
3688 * \param dest Destination redirecting reason
3689 * \param src Source redirecting reason
3690 */
3692 const struct ast_party_redirecting_reason *src);
3693
3694/*!
3695 * \brief Initialize the given redirecting reason structure using the given guide
3696 * for a set update operation.
3697 *
3698 * \details
3699 * The initialization is needed to allow a set operation to know if a
3700 * value needs to be updated. Simple integers need the guide's original
3701 * value in case the set operation is not trying to set a new value.
3702 * String values are simply set to NULL pointers if they are not going
3703 * to be updated.
3704 *
3705 * \param init Redirecting reason structure to initialize.
3706 * \param guide Source redirecting reason to use as a guide in initializing.
3707 */
3709 const struct ast_party_redirecting_reason *guide);
3710
3711/*!
3712 * \brief Set the redirecting reason information based on another redirecting reason source
3713 *
3714 * This is similar to ast_party_redirecting_reason_copy, except that NULL values for
3715 * strings in the src parameter indicate not to update the corresponding dest values.
3716 *
3717 * \param dest The redirecting reason one wishes to update
3718 * \param src The new redirecting reason values to update the dest
3719 */
3721 const struct ast_party_redirecting_reason *src);
3722
3723/*!
3724 * \brief Destroy the redirecting reason contents
3725 *
3726 * \param doomed The redirecting reason to destroy.
3727 */
3729
3730/*!
3731 * \brief Initialize the given redirecting structure.
3732 * \since 1.8
3733 *
3734 * \param init Redirecting structure to initialize.
3735 */
3737
3738/*!
3739 * \since 1.8
3740 * \brief Copy the source redirecting information to the destination redirecting.
3741 *
3742 * \param dest Destination redirecting
3743 * \param src Source redirecting
3744 */
3745void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src);
3746
3747/*!
3748 * \since 1.8
3749 * \brief Initialize the given redirecting id structure using the given guide
3750 * for a set update operation.
3751 *
3752 * \details
3753 * The initialization is needed to allow a set operation to know if a
3754 * value needs to be updated. Simple integers need the guide's original
3755 * value in case the set operation is not trying to set a new value.
3756 * String values are simply set to NULL pointers if they are not going
3757 * to be updated.
3758 *
3759 * \param init Redirecting id structure to initialize.
3760 * \param guide Source redirecting id to use as a guide in initializing.
3761 */
3762void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide);
3763
3764/*!
3765 * \brief Set the redirecting information based on another redirecting source
3766 * \since 1.8
3767 *
3768 * This is similar to ast_party_redirecting_copy, except that NULL values for
3769 * strings in the src parameter indicate not to update the corresponding dest values.
3770 *
3771 * \param dest The redirecting one wishes to update
3772 * \param src The new redirecting values to update the dest
3773 * \param update What redirecting information to update. NULL if all.
3774 */
3776
3777/*!
3778 * \since 1.8
3779 * \brief Destroy the redirecting information contents
3780 *
3781 * \param doomed The redirecting information to destroy.
3782 */
3784
3785/*!
3786 * \since 1.8
3787 * \brief Copy the caller information to the connected line information.
3788 *
3789 * \param dest Destination connected line information
3790 * \param src Source caller information
3791 *
3792 * \note Assumes locks are already acquired
3793 */
3795
3796/*!
3797 * \since 1.8
3798 * \brief Copy the connected line information to the caller information.
3799 *
3800 * \param dest Destination caller information
3801 * \param src Source connected line information
3802 *
3803 * \note Assumes locks are already acquired
3804 */
3806
3807/*!
3808 * \since 1.8
3809 * \brief Set the connected line information in the Asterisk channel
3810 *
3811 * \param chan Asterisk channel to set connected line information
3812 * \param connected Connected line information
3813 * \param update What connected line information to update. NULL if all.
3814 *
3815 * \note The channel does not need to be locked before calling this function.
3816 */
3818
3819/*!
3820 * \since 1.8
3821 * \brief Build the connected line information data frame.
3822 *
3823 * \param data Buffer to fill with the frame data
3824 * \param datalen Size of the buffer to fill
3825 * \param connected Connected line information
3826 * \param update What connected line information to build. NULL if all.
3827 *
3828 * \retval -1 if error
3829 * \retval Amount of data buffer used
3830 */
3831int 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);
3832
3833/*!
3834 * \since 1.8
3835 * \brief Parse connected line indication frame data
3836 *
3837 * \param data Buffer with the frame data to parse
3838 * \param datalen Size of the buffer
3839 * \param connected Extracted connected line information
3840 *
3841 * \retval 0 on success.
3842 * \retval -1 on error.
3843 *
3844 * \note The filled in connected line structure needs to be initialized by
3845 * ast_party_connected_line_set_init() before calling. If defaults are not
3846 * required use ast_party_connected_line_init().
3847 * \note The filled in connected line structure needs to be destroyed by
3848 * ast_party_connected_line_free() when it is no longer needed.
3849 */
3850int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected);
3851
3852/*!
3853 * \since 1.8
3854 * \brief Indicate that the connected line information has changed
3855 *
3856 * \param chan Asterisk channel to indicate connected line information
3857 * \param connected Connected line information
3858 * \param update What connected line information to update. NULL if all.
3859 */
3861
3862/*!
3863 * \since 1.8
3864 * \brief Queue a connected line update frame on a channel
3865 *
3866 * \param chan Asterisk channel to indicate connected line information
3867 * \param connected Connected line information
3868 * \param update What connected line information to update. NULL if all.
3869 */
3871
3872/*!
3873 * \since 1.8
3874 * \brief Set the redirecting id information in the Asterisk channel
3875 *
3876 * \param chan Asterisk channel to set redirecting id information
3877 * \param redirecting Redirecting id information
3878 * \param update What redirecting information to update. NULL if all.
3879 *
3880 * \note The channel does not need to be locked before calling this function.
3881 */
3882void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3883
3884/*!
3885 * \since 1.8
3886 * \brief Build the redirecting id data frame.
3887 *
3888 * \param data Buffer to fill with the frame data
3889 * \param datalen Size of the buffer to fill
3890 * \param redirecting Redirecting id information
3891 * \param update What redirecting information to build. NULL if all.
3892 *
3893 * \retval -1 if error
3894 * \retval Amount of data buffer used
3895 */
3896int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3897
3898/*!
3899 * \since 1.8
3900 * \brief Parse redirecting indication frame data
3901 *
3902 * \param data Buffer with the frame data to parse
3903 * \param datalen Size of the buffer
3904 * \param redirecting Extracted redirecting id information
3905 *
3906 * \retval 0 on success.
3907 * \retval -1 on error.
3908 *
3909 * \note The filled in id structure needs to be initialized by
3910 * ast_party_redirecting_set_init() before calling.
3911 * \note The filled in id structure needs to be destroyed by
3912 * ast_party_redirecting_free() when it is no longer needed.
3913 */
3914int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting);
3915
3916/*!
3917 * \since 1.8
3918 * \brief Indicate that the redirecting id has changed
3919 *
3920 * \param chan Asterisk channel to indicate redirecting id information
3921 * \param redirecting Redirecting id information
3922 * \param update What redirecting information to update. NULL if all.
3923 */
3924void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3925
3926/*!
3927 * \since 1.8
3928 * \brief Queue a redirecting update frame on a channel
3929 *
3930 * \param chan Asterisk channel to indicate redirecting id information
3931 * \param redirecting Redirecting id information
3932 * \param update What redirecting information to update. NULL if all.
3933 */
3934void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3935
3936/*!
3937 * \since 11
3938 * \brief Run a connected line interception subroutine and update a channel's connected line
3939 * information
3940 *
3941 * Whenever we want to update a channel's connected line information, we may need to run
3942 * a subroutine so that an administrator can manipulate the information before sending it
3943 * out. This function both runs the subroutine specified by CONNECTED_LINE_SEND_SUB and
3944 * sends the update to the channel.
3945 *
3946 * \param autoservice_chan Channel to place into autoservice while the sub is running.
3947 * It is perfectly safe for this to be NULL
3948 * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3949 * determine which subroutine we need to run.
3950 * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
3951 * AST_CONTROL_CONNECTED_LINE
3952 * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
3953 * ast_party_connected_line pointer.
3954 * \retval 0 Success
3955 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3956 * run the subroutine
3957 */
3958int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame);
3959
3960/*!
3961 * \since 11
3962 * \brief Run a redirecting interception subroutine and update a channel's redirecting information
3963 *
3964 * \details
3965 * Whenever we want to update a channel's redirecting information, we may need to run
3966 * a subroutine so that an administrator can manipulate the information before sending it
3967 * out. This function both runs the subroutine specified by REDIRECTING_SEND_SUB and
3968 * sends the update to the channel.
3969 *
3970 * \param autoservice_chan Channel to place into autoservice while the subroutine is running.
3971 * It is perfectly safe for this to be NULL
3972 * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3973 * determine which subroutine we need to run.
3974 * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
3975 * AST_CONTROL_REDIRECTING
3976 * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
3977 * ast_party_redirecting pointer.
3978 *
3979 * \retval 0 Success
3980 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3981 * run the subroutine
3982 */
3983int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame);
3984
3985#include "asterisk/ccss.h"
3986
3987/*!
3988 * \since 1.8
3989 * \brief Set up datastore with CCSS parameters for a channel
3990 *
3991 * \note
3992 * If base_params is NULL, the channel will get the default
3993 * values for all CCSS parameters.
3994 *
3995 * \details
3996 * This function makes use of datastore operations on the channel, so
3997 * it is important to lock the channel before calling this function.
3998 *
3999 * \param chan The channel to create the datastore on
4000 * \param base_params CCSS parameters we wish to copy into the channel
4001 * \retval 0 Success
4002 * \retval -1 Failure
4003 */
4005 const struct ast_cc_config_params *base_params);
4006
4007/*!
4008 * \since 1.8
4009 * \brief Get the CCSS parameters from a channel
4010 *
4011 * \details
4012 * This function makes use of datastore operations on the channel, so
4013 * it is important to lock the channel before calling this function.
4014 *
4015 * \param chan Channel to retrieve parameters from
4016 * \retval NULL Failure
4017 * \retval non-NULL The parameters desired
4018 */
4020
4021
4022/*!
4023 * \since 1.8
4024 * \brief Get a device name given its channel structure
4025 *
4026 * \details
4027 * A common practice in Asterisk is to determine the device being talked
4028 * to by dissecting the channel name. For certain channel types, this is not
4029 * accurate. For instance, an ISDN channel is named based on what B channel is
4030 * used, not the device being communicated with.
4031 *
4032 * This function interfaces with a channel tech's queryoption callback to
4033 * retrieve the name of the device being communicated with. If the channel does not
4034 * implement this specific option, then the traditional method of using the channel
4035 * name is used instead.
4036 *
4037 * \param chan The channel to retrieve the information from
4038 * \param[out] device_name The buffer to place the device's name into
4039 * \param name_buffer_length The allocated space for the device_name
4040 * \return 0 always
4041 */
4042int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length);
4043
4044/*!
4045 * \since 1.8
4046 * \brief Find the appropriate CC agent type to use given a channel
4047 *
4048 * \details
4049 * During call completion, we will need to create a call completion agent structure. To
4050 * figure out the type of agent to construct, we need to ask the channel driver for the
4051 * appropriate type.
4052 *
4053 * Prior to adding this function, the call completion core attempted to figure this
4054 * out for itself by stripping the technology off the channel's name. However, in the
4055 * case of chan_dahdi, there are multiple agent types registered, and so simply searching
4056 * for an agent type called "DAHDI" is not possible. In a case where multiple agent types
4057 * are defined, the channel driver must have a queryoption callback defined in its
4058 * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE
4059 *
4060 * If a channel driver does not have a queryoption callback or if the queryoption callback
4061 * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology
4062 * portion of the channel name is used instead. This is perfectly suitable for channel drivers
4063 * whose channel technologies are a one-to-one match with the agent types defined within.
4064 *
4065 * Note that this function is only called when the agent policy on a given channel is set
4066 * to "native." Generic agents' type can be determined automatically by the core.
4067 *
4068 * \param chan The channel for which we wish to retrieve the agent type
4069 * \param[out] agent_type The type of agent the channel driver wants us to use
4070 * \param size The size of the buffer to write to
4071 */
4072int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size);
4073#if defined(__cplusplus) || defined(c_plusplus)
4074}
4075#endif
4076
4077/*!
4078 * \brief Remove a channel from the global channels container
4079 *
4080 * \param chan channel to remove
4081 *
4082 * In a case where it is desired that a channel not be available in any lookups
4083 * in the global channels conatiner, use this function.
4084 */
4085void ast_channel_unlink(struct ast_channel *chan);
4086
4087/*!
4088 * \brief Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash
4089 * on the given channel
4090 *
4091 * \param chan channel on which to set the cause information
4092 * \param cause_code ast_control_pvt_cause_code structure containing cause information
4093 * \param datalen total length of the structure since it may vary
4094 */
4095void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen);
4096
4097/*!
4098 * \since 12
4099 * \brief Convert a string to a detail record AMA flag
4100 *
4101 * \param flag string form of flag
4102 *
4103 * \retval the enum (integer) form of the flag
4104 */
4105enum ama_flags ast_channel_string2amaflag(const char *flag);
4106
4107/*!
4108 * \since 12
4109 * \brief Convert the enum representation of an AMA flag to a string representation
4110 *
4111 * \param flags integer flag
4112 *
4113 * \retval A string representation of the flag
4114 */
4115const char *ast_channel_amaflags2string(enum ama_flags flags);
4116
4121
4122/* ACCESSOR FUNCTIONS */
4123
4124#define DECLARE_STRINGFIELD_SETTERS_FOR(field) \
4125 void ast_channel_##field##_set(struct ast_channel *chan, const char *field); \
4126 void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0))); \
4127 void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) __attribute__((format(printf, 2, 3)))
4128
4129/*!
4130 * The following string fields result in channel snapshot creation and
4131 * should have the channel locked when called:
4132 *
4133 * \li language
4134 * \li accountcode
4135 * \li peeraccount
4136 * \li linkedid
4137 */
4151
4152const char *ast_channel_name(const struct ast_channel *chan);
4153const char *ast_channel_language(const struct ast_channel *chan);
4154const char *ast_channel_musicclass(const struct ast_channel *chan);
4155const char *ast_channel_latest_musicclass(const struct ast_channel *chan);
4156const char *ast_channel_accountcode(const struct ast_channel *chan);
4157const char *ast_channel_peeraccount(const struct ast_channel *chan);
4158const char *ast_channel_userfield(const struct ast_channel *chan);
4159const char *ast_channel_call_forward(const struct ast_channel *chan);
4160const char *ast_channel_uniqueid(const struct ast_channel *chan);
4161const char *ast_channel_linkedid(const struct ast_channel *chan);
4162const char *ast_channel_tenantid(const struct ast_channel *chan);
4163void ast_channel_tenantid_set(struct ast_channel *chan, const char *value);
4164const char *ast_channel_parkinglot(const struct ast_channel *chan);
4165const char *ast_channel_hangupsource(const struct ast_channel *chan);
4166const char *ast_channel_dialcontext(const struct ast_channel *chan);
4167
4168const char *ast_channel_appl(const struct ast_channel *chan);
4169void ast_channel_appl_set(struct ast_channel *chan, const char *value);
4170const char *ast_channel_blockproc(const struct ast_channel *chan);
4171void ast_channel_blockproc_set(struct ast_channel *chan, const char *value);
4172const char *ast_channel_data(const struct ast_channel *chan);
4173void ast_channel_data_set(struct ast_channel *chan, const char *value);
4174
4175const char *ast_channel_lastcontext(const struct ast_channel *chan);
4176const char *ast_channel_context(const struct ast_channel *chan);
4177void ast_channel_context_set(struct ast_channel *chan, const char *value);
4178const char *ast_channel_lastexten(const struct ast_channel *chan);
4179const char *ast_channel_exten(const struct ast_channel *chan);
4180void ast_channel_exten_set(struct ast_channel *chan, const char *value);
4181
4182char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan);
4184char ast_channel_sending_dtmf_digit(const struct ast_channel *chan);
4186struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan);
4187void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value);
4188enum ama_flags ast_channel_amaflags(const struct ast_channel *chan);
4189
4190/*!
4191 * \pre chan is locked
4192 */
4193void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value);
4194int ast_channel_epfd(const struct ast_channel *chan);
4196int ast_channel_fdno(const struct ast_channel *chan);
4197void ast_channel_fdno_set(struct ast_channel *chan, int value);
4198int ast_channel_hangupcause(const struct ast_channel *chan);
4199void ast_channel_hangupcause_set(struct ast_channel *chan, int value);
4200int ast_channel_tech_hangupcause(const struct ast_channel *chan);
4201void ast_channel_tech_hangupcause_set(struct ast_channel *chan, int value);
4202int ast_channel_priority(const struct ast_channel *chan);
4203void ast_channel_priority_set(struct ast_channel *chan, int value);
4204int ast_channel_rings(const struct ast_channel *chan);
4205void ast_channel_rings_set(struct ast_channel *chan, int value);
4206int ast_channel_streamid(const struct ast_channel *chan);
4207void ast_channel_streamid_set(struct ast_channel *chan, int value);
4208int ast_channel_timingfd(const struct ast_channel *chan);
4209void ast_channel_timingfd_set(struct ast_channel *chan, int value);
4210int ast_channel_visible_indication(const struct ast_channel *chan);
4212int ast_channel_hold_state(const struct ast_channel *chan);
4213void ast_channel_hold_state_set(struct ast_channel *chan, int value);
4214int ast_channel_vstreamid(const struct ast_channel *chan);
4215void ast_channel_vstreamid_set(struct ast_channel *chan, int value);
4216unsigned short ast_channel_transfercapability(const struct ast_channel *chan);
4217void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value);
4218unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan);
4219void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value);
4220unsigned int ast_channel_fin(const struct ast_channel *chan);
4221void ast_channel_fin_set(struct ast_channel *chan, unsigned int value);
4222unsigned int ast_channel_fout(const struct ast_channel *chan);
4223void ast_channel_fout_set(struct ast_channel *chan, unsigned int value);
4224unsigned long ast_channel_insmpl(const struct ast_channel *chan);
4225void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value);
4226unsigned long ast_channel_outsmpl(const struct ast_channel *chan);
4227void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value);
4228void *ast_channel_generatordata(const struct ast_channel *chan);
4229void ast_channel_generatordata_set(struct ast_channel *chan, void *value);
4230void *ast_channel_music_state(const struct ast_channel *chan);
4231void ast_channel_music_state_set(struct ast_channel *chan, void *value);
4232void *ast_channel_tech_pvt(const struct ast_channel *chan);
4233void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value);
4234void *ast_channel_timingdata(const struct ast_channel *chan);
4235void ast_channel_timingdata_set(struct ast_channel *chan, void *value);
4236struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan);
4238struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan);
4239void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value);
4240struct ast_channel *ast_channel__bridge(const struct ast_channel *chan);
4242struct ast_channel *ast_channel_masq(const struct ast_channel *chan);
4243void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value);
4244struct ast_channel *ast_channel_masqr(const struct ast_channel *chan);
4245void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value);
4246struct ast_filestream *ast_channel_stream(const struct ast_channel *chan);
4247void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value);
4248struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan);
4249void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value);
4250struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan);
4252struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan);
4254struct ast_generator *ast_channel_generator(const struct ast_channel *chan);
4255void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value);
4256struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan);
4257void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value);
4258struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan);
4259void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value);
4260struct ast_timer *ast_channel_timer(const struct ast_channel *chan);
4261void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value);
4262struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan);
4263void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value);
4264struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan);
4265void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
4266struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan);
4267void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
4268const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan);
4269void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value);
4270enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan);
4272enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
4273ast_callid ast_channel_callid(const struct ast_channel *chan);
4274struct ast_channel_snapshot *ast_channel_snapshot(const struct ast_channel *chan);
4275void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot);
4277struct ast_endpoint *ast_channel_endpoint(const struct ast_channel *chan);
4278void ast_channel_endpoint_set(struct ast_channel *chan, struct ast_endpoint *endpoint);
4279
4280/*!
4281 * \pre chan is locked
4282 */
4284
4285/* XXX Internal use only, make sure to move later */
4286void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
4290void ast_channel_callid_cleanup(struct ast_channel *chan);
4292
4293/* Format getters */
4297struct ast_format *ast_channel_readformat(struct ast_channel *chan);
4298struct ast_format *ast_channel_writeformat(struct ast_channel *chan);
4299
4300/* Format setters - all of these functions will increment the reference count of the format passed in */
4301void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format);
4302void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format);
4303void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format);
4304void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format);
4305void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format);
4306
4307/* Other struct getters */
4308struct ast_frame *ast_channel_dtmff(struct ast_channel *chan);
4309struct ast_jb *ast_channel_jb(struct ast_channel *chan);
4310struct ast_party_caller *ast_channel_caller(struct ast_channel *chan);
4314struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan);
4319struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan);
4320struct timeval *ast_channel_whentohangup(struct ast_channel *chan);
4321struct varshead *ast_channel_varshead(struct ast_channel *chan);
4322
4323void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value);
4324void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value);
4325void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value);
4327void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value);
4329void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value);
4330
4331/*!
4332 * \pre chan is locked
4333 */
4334void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value);
4335void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value);
4336struct timeval ast_channel_creationtime(struct ast_channel *chan);
4337void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value);
4338struct timeval ast_channel_answertime(struct ast_channel *chan);
4339void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value);
4340
4341/* List getters */
4345struct ast_readq_list *ast_channel_readq(struct ast_channel *chan);
4346
4347/* Typedef accessors */
4349/*!
4350 * \pre chan is locked
4351 */
4354/*!
4355 * \pre chan is locked
4356 */
4358struct ast_namedgroups *ast_channel_named_callgroups(const struct ast_channel *chan);
4359void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
4360struct ast_namedgroups *ast_channel_named_pickupgroups(const struct ast_channel *chan);
4361void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
4362
4363/* Alertpipe accessors--the "internal" functions for channel.c use only */
4364int ast_channel_alert_write(struct ast_channel *chan);
4365int ast_channel_alert_writable(struct ast_channel *chan);
4373/*! \brief Swap the interal alertpipe between two channels
4374 * \note Handle all of the necessary locking before calling this
4375 */
4376void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2);
4377
4378/* file descriptor array accessors */
4379void ast_channel_internal_fd_clear(struct ast_channel *chan, int which);
4381void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value);
4382int ast_channel_fd(const struct ast_channel *chan, int which);
4383int ast_channel_fd_isset(const struct ast_channel *chan, int which);
4384
4385/*!
4386 * \since 15
4387 * \brief Retrieve the number of file decriptor positions present on the channel
4388 *
4389 * \param chan The channel to get the count of
4390 *
4391 * \pre chan is locked
4392 *
4393 * \return The number of file descriptor positions
4394 */
4395int ast_channel_fd_count(const struct ast_channel *chan);
4396
4397/*!
4398 * \since 15
4399 * \brief Add a file descriptor to the channel without a fixed position
4400 *
4401 * \param chan The channel to add the file descriptor to
4402 * \param value The file descriptor
4403 *
4404 * \pre chan is locked
4405 *
4406 * \return The position of the file descriptor
4407 */
4408int ast_channel_fd_add(struct ast_channel *chan, int value);
4409
4410pthread_t ast_channel_blocker(const struct ast_channel *chan);
4411void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value);
4412
4413int ast_channel_blocker_tid(const struct ast_channel *chan);
4414void ast_channel_blocker_tid_set(struct ast_channel *chan, int tid);
4415
4418
4419struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan);
4420/*!
4421 * \pre chan is locked
4422 */
4424
4427
4430
4431/*!
4432 * \since 11
4433 * \brief Retrieve a comma-separated list of channels for which dialed cause information is available
4434 *
4435 * \details
4436 * This function makes use of datastore operations on the channel, so
4437 * it is important to lock the channel before calling this function.
4438 *
4439 * \param chan The channel from which to retrieve information
4440 * \retval NULL on allocation failure
4441 * \retval Pointer to an ast_str object containing the desired information which must be freed
4442 */
4443struct ast_str *ast_channel_dialed_causes_channels(const struct ast_channel *chan);
4444
4445/*!
4446 * \since 11
4447 * \brief Retrieve a ref-counted cause code information structure
4448 *
4449 * \details
4450 * This function makes use of datastore operations on the channel, so
4451 * it is important to lock the channel before calling this function.
4452 * This function increases the ref count of the returned object, so the
4453 * calling function must decrease the reference count when it is finished
4454 * with the object.
4455 *
4456 * \param chan The channel from which to retrieve information
4457 * \param chan_name The name of the channel about which to retrieve information
4458 * \retval NULL on search failure
4459 * \retval Pointer to a ref-counted ast_control_pvt_cause_code object containing the desired information
4460 */
4462
4463/*!
4464 * \since 20.17.0, 22.8.0, 23.1.0
4465 * \brief Retrieve a ref-counted cause code information structure iterator
4466 *
4467 * \details
4468 * This function makes use of datastore operations on the channel, so
4469 * it is important to lock the channel before calling this function.
4470 * This function increases the ref count of the returned object, so the
4471 * calling function must decrease the reference count when it is finished
4472 * with the object.
4473 *
4474 * \param chan The channel from which to retrieve information
4475 * \param chan_name The name of the channel about which to retrieve information
4476 * \retval NULL on search failure
4477 * \retval Pointer to a ao2_iterator object containing the desired information
4478 */
4479struct ao2_iterator *ast_channel_dialed_causes_find_multiple(const struct ast_channel *chan, const char *chan_name);
4480
4481/*!
4482 * \since 11
4483 * \brief Add cause code information to the channel
4484 *
4485 * \details
4486 * This function makes use of datastore operations on the channel, so
4487 * it is important to lock the channel before calling this function.
4488 * The passed in data is copied and so is still owned by the caller.
4489 *
4490 * \param chan The channel on which to add information
4491 * \param cause_code The cause information to be added to the channel
4492 * \param datalen The total length of the structure since its length is variable
4493 * \retval 0 on success
4494 * \retval -1 on error
4495 */
4496int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen);
4497
4498/*!
4499 * \since 11
4500 * \brief Clear all cause information from the channel
4501 *
4502 * \details
4503 * This function makes use of datastore operations on the channel, so
4504 * it is important to lock the channel before calling this function.
4505 *
4506 * \param chan The channel from which to clear information
4507 */
4508void ast_channel_dialed_causes_clear(const struct ast_channel *chan);
4509
4510struct ast_flags *ast_channel_flags(struct ast_channel *chan);
4511
4512/*!
4513 * \since 13.17.0
4514 * \brief Set a flag on a channel
4515 *
4516 * \param chan The channel to set the flag on
4517 * \param flag The flag to set
4518 *
4519 * \note This will lock the channel internally. If the channel is already
4520 * locked it is still safe to call.
4521 */
4522
4523void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag);
4524
4525/*!
4526 * \since 13.17.0
4527 * \brief Clear a flag on a channel
4528 *
4529 * \param chan The channel to clear the flag from
4530 * \param flag The flag to clear
4531 *
4532 * \note This will lock the channel internally. If the channel is already
4533 * locked it is still safe to call.
4534 */
4535void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag);
4536
4537/*!
4538 * \since 12.4.0
4539 * \brief Return whether or not any manager variables have been set
4540 *
4541 * \retval 0 if no manager variables are expected
4542 * \retval 1 if manager variables are expected
4543 */
4545
4546/*!
4547 * \since 12
4548 * \brief Sets the variables to be stored in the \a manager_vars field of all
4549 * snapshots.
4550 * \param varc Number of variable names.
4551 * \param vars Array of variable names.
4552 */
4553void ast_channel_set_manager_vars(size_t varc, char **vars);
4554
4555/*!
4556 * \since 12
4557 * \brief Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
4558 *
4559 * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4560 *
4561 * \param chan Channel to get variables for.
4562 * \return List of channel variables.
4563 * \retval NULL on error
4564 */
4566
4567/*!
4568 * \since 14.2.0
4569 * \brief Return whether or not any ARI variables have been set
4570 *
4571 * \retval 0 if no ARI variables are expected
4572 * \retval 1 if ARI variables are expected
4573 */
4574int ast_channel_has_ari_vars(void);
4575
4576/*!
4577 * \since 14.2.0
4578 * \brief Sets the variables to be stored in the \a ari_vars field of all
4579 * snapshots.
4580 * \param varc Number of variable names.
4581 * \param vars Array of variable names.
4582 */
4583void ast_channel_set_ari_vars(size_t varc, char **vars);
4584
4585/*!
4586 * \since 14.2.0
4587 * \brief Gets the variables for a given channel, as specified by ast_channel_set_ari_vars().
4588 *
4589 * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4590 *
4591 * \param chan Channel to get variables for.
4592 * \return List of channel variables.
4593 * \retval NULL on error
4594 */
4595struct varshead *ast_channel_get_ari_vars(struct ast_channel *chan);
4596
4597/*!
4598 * \since 12
4599 * \brief Gets the variables for a given channel, as set using pbx_builtin_setvar_helper().
4600 *
4601 * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4602 *
4603 * \param chan Channel to get variables for
4604 * \return List of channel variables.
4605 * \retval NULL on error
4606 */
4607struct varshead *ast_channel_get_vars(struct ast_channel *chan);
4608
4609/*!
4610 * \since 12
4611 * \brief A topic which publishes the events for a particular channel.
4612 *
4613 * If the given \a chan is \c NULL, ast_channel_topic_all() is returned.
4614 *
4615 * \param chan Channel, or \c NULL.
4616 *
4617 * \retval Topic for channel's events.
4618 * \retval ast_channel_topic_all() if \a chan is \c NULL.
4619 */
4620struct stasis_topic *ast_channel_topic(struct ast_channel *chan);
4621
4622/*!
4623 * \brief Get the bridge associated with a channel
4624 * \since 12.0.0
4625 *
4626 * \param chan The channel whose bridge we want
4627 *
4628 * \details
4629 * The bridge returned has its reference count incremented. Use
4630 * ao2_cleanup() or ao2_ref() in order to decrement the
4631 * reference count when you are finished with the bridge.
4632 *
4633 * \note This function expects the channel to be locked prior to
4634 * being called and will not grab the channel lock.
4635 *
4636 * \retval NULL No bridge present on the channel
4637 * \retval non-NULL The bridge the channel is in
4638 */
4639struct ast_bridge *ast_channel_get_bridge(const struct ast_channel *chan);
4640
4641/*!
4642 * \brief Determine if a channel is in a bridge
4643 * \since 12.0.0
4644 *
4645 * \param chan The channel to test
4646 *
4647 * \note This function expects the channel to be locked prior to
4648 * being called and will not grab the channel lock.
4649 *
4650 * \retval 0 The channel is not bridged
4651 * \retval non-zero The channel is bridged
4652 */
4653int ast_channel_is_bridged(const struct ast_channel *chan);
4654
4655/*!
4656 * \brief Determine if a channel is leaving a bridge, but \em not hung up
4657 * \since 12.4.0
4658 *
4659 * \param chan The channel to test
4660 *
4661 * \note If a channel is hung up, it is implicitly leaving any bridge it
4662 * may be in. This function is used to test if a channel is leaving a bridge
4663 * but may survive the experience, if it has a place to go to (dialplan or
4664 * otherwise)
4665 *
4666 * \retval 0 The channel is not leaving the bridge or is hung up
4667 * \retval non-zero The channel is leaving the bridge
4668 */
4670
4671/*!
4672 * \brief Get the channel's bridge peer only if the bridge is two-party.
4673 * \since 12.0.0
4674 *
4675 * \param chan Channel desiring the bridge peer channel.
4676 *
4677 * \note The returned peer channel is the current peer in the
4678 * bridge when called.
4679 *
4680 * \note Absolutely _NO_ channel locks should be held when calling this function.
4681 *
4682 * \retval NULL Channel not in a bridge or the bridge is not two-party.
4683 * \retval non-NULL Reffed peer channel at time of calling.
4684 */
4685struct ast_channel *ast_channel_bridge_peer(struct ast_channel *chan);
4686
4687/*!
4688 * \brief Get a reference to the channel's bridge pointer.
4689 * \since 12.0.0
4690 *
4691 * \param chan The channel whose bridge channel is desired
4692 *
4693 * \note This increases the reference count of the bridge_channel.
4694 * Use ao2_ref() or ao2_cleanup() to decrement the refcount when
4695 * you are finished with it.
4696 *
4697 * \note It is expected that the channel is locked prior to
4698 * placing this call.
4699 *
4700 * \retval NULL The channel has no bridge_channel
4701 * \retval non-NULL A reference to the bridge_channel
4702 */
4704
4705/*!
4706 * \since 12
4707 * \brief Gain control of a channel in the system
4708 *
4709 * The intention of this function is to take a channel that currently
4710 * is running in one thread and gain control of it in the current thread.
4711 * This can be used to redirect a channel to a different place in the dialplan,
4712 * for instance.
4713 *
4714 * \note This function is NOT intended to be used on bridged channels. If you
4715 * need to control a bridged channel, you can set a callback to be called
4716 * once the channel exits the bridge, and run your controlling logic in that
4717 * callback
4718 *
4719 * XXX Put name of callback-setting function in above paragraph once it is written
4720 *
4721 * \note When this function returns successfully, the yankee channel is in a state where
4722 * it cannot be used any further. Always use the returned channel instead.
4723 *
4724 * \note absolutely _NO_ channel locks should be held before calling this function.
4725 *
4726 * \note The dialplan location on the returned channel is where the channel
4727 * should be started in the dialplan if it is returned to it.
4728 *
4729 * \param yankee The channel to gain control of
4730 * \retval NULL Could not gain control of the channel
4731 * \retval non-NULL The channel
4732 */
4733struct ast_channel *ast_channel_yank(struct ast_channel *yankee);
4734
4735/*!
4736 * \since 12
4737 * \brief Move a channel from its current location to a new location
4738 *
4739 * The intention of this function is to have the destination channel
4740 * take on the identity of the source channel.
4741 *
4742 * \note This function is NOT intended to be used on bridged channels. If you
4743 * wish to move an unbridged channel into the place of a bridged channel, then
4744 * use ast_bridge_join() or ast_bridge_impart(). If you wish to move a bridged
4745 * channel into the place of another bridged channel, then use ast_bridge_move().
4746 *
4747 * \note When this function returns succesfully, the source channel is in a
4748 * state where its continued use is unreliable.
4749 *
4750 * \note absolutely _NO_ channel locks should be held before calling this function.
4751 *
4752 * \param dest The place to move the source channel
4753 * \param source The channel to move
4754 * \retval 0 Success
4755 * \retval non-zero Failure
4756 */
4757int ast_channel_move(struct ast_channel *dest, struct ast_channel *source);
4758
4759/*!
4760 * \since 12
4761 * \brief Forward channel stasis messages to the given endpoint
4762 *
4763 * \param chan The channel to forward from
4764 * \param endpoint The endpoint to forward to
4765 *
4766 * \retval 0 Success
4767 * \retval non-zero Failure
4768 */
4770
4771/*!
4772 * \brief Return the oldest linkedid between two channels.
4773 *
4774 * A channel linkedid is derived from the channel uniqueid which is formed like this:
4775 * [systemname-]ctime.seq
4776 *
4777 * The systemname, and the dash are optional, followed by the epoch time followed by an
4778 * integer sequence. Note that this is not a decimal number, since 1.2 is less than 1.11
4779 * in uniqueid land.
4780 *
4781 * To compare two uniqueids, we parse out the integer values of the time and the sequence
4782 * numbers and compare them, with time trumping sequence.
4783 *
4784 * \param a The linkedid value of the first channel to compare
4785 * \param b The linkedid value of the second channel to compare
4786 *
4787 * \retval NULL on failure
4788 * \retval The oldest linkedid value
4789 * \since 12.0.0
4790*/
4791const char *ast_channel_oldest_linkedid(const char *a, const char *b);
4792
4793/*!
4794 * \brief Check if the channel has active audiohooks, active framehooks, or a monitor.
4795 * \since 12.0.0
4796 *
4797 * \param chan The channel to check.
4798 *
4799 * \retval non-zero if channel has active audiohooks, framehooks, or monitor.
4800 */
4802
4803/*!
4804 * \brief Check if the channel has any active hooks that require audio.
4805 * \since 12.3.0
4806 *
4807 * \param chan The channel to check.
4808 *
4809 * \retval non-zero if channel has active audiohooks, audio framehooks, or monitor.
4810 */
4812
4813/*!
4814 * \brief Removes the trailing identifiers from a channel name string
4815 * \since 12.0.0
4816 *
4817 * \param channel_name string that you wish to turn into a dial string.
4818 * This string will be edited in place.
4819 */
4820void ast_channel_name_to_dial_string(char *channel_name);
4821
4822#define AST_MUTE_DIRECTION_READ (1 << 0)
4823#define AST_MUTE_DIRECTION_WRITE (1 << 1)
4824
4825/*!
4826 * \brief Suppress passing of a frame type on a channel
4827 *
4828 * \note The channel should be locked before calling this function.
4829 *
4830 * \param chan The channel to suppress
4831 * \param direction The direction in which to suppress
4832 * \param frametype The type of frame (AST_FRAME_VOICE, etc) to suppress
4833 *
4834 * \retval 0 Success
4835 * \retval -1 Failure
4836 */
4837int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype);
4838
4839/*!
4840 * \brief Stop suppressing of a frame type on a channel
4841 *
4842 * \note The channel should be locked before calling this function.
4843 *
4844 * \param chan The channel to stop suppressing
4845 * \param direction The direction in which to stop suppressing
4846 * \param frametype The type of frame (AST_FRAME_VOICE, etc) to stop suppressing
4847 *
4848 * \retval 0 Success
4849 * \retval -1 Failure
4850 */
4851int ast_channel_unsuppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype);
4852
4853/*!
4854 * \brief Simulate a DTMF end on a broken bridge channel.
4855 *
4856 * \param chan Channel sending DTMF that has not ended.
4857 * \param digit DTMF digit to stop.
4858 * \param start DTMF digit start time.
4859 * \param why Reason bridge broken.
4860 */
4861void ast_channel_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why);
4862
4863struct ast_bridge_features;
4864
4865/*!
4866 * \brief Gets the channel-attached features a channel has access to upon being bridged.
4867 *
4868 * \note The channel must be locked when calling this function.
4869 *
4870 * \param chan Which channel to get features for
4871 *
4872 * \retval non-NULL The features currently set for this channel
4873 * \retval NULL if the features have not been set
4874 */
4876
4877/*!
4878 * \brief Appends to the channel-attached features a channel has access to upon being bridged.
4879 *
4880 * \note The channel must be locked when calling this function.
4881 *
4882 * \param chan Which channel to set features for
4883 * \param features The feature set to append to the channel's features
4884 *
4885 * \retval 0 on success
4886 * \retval -1 on failure
4887 */
4888int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge_features *features);
4889
4890/*!
4891 * \brief Sets the channel-attached features a channel has access to upon being bridged.
4892 *
4893 * \note The channel must be locked when calling this function.
4894 *
4895 * \param chan Which channel to set features for
4896 * \param features The feature set with which to replace the channel's features
4897 *
4898 * \retval 0 on success
4899 * \retval -1 on failure
4900 */
4901int ast_channel_feature_hooks_replace(struct ast_channel *chan, struct ast_bridge_features *features);
4902
4904 /* Unable to determine what error occurred. */
4906 /* Channel with this ID already exists */
4908};
4909
4910/*!
4911 * \brief Get error code for latest channel operation.
4912 */
4914
4915/*!
4916 * \brief Am I currently running an intercept dialplan routine.
4917 * \since 13.14.0
4918 *
4919 * \details
4920 * A dialplan intercept routine is equivalent to an interrupt
4921 * routine. As such, the routine must be done quickly and you
4922 * do not have access to the media stream. These restrictions
4923 * are necessary because the media stream is the responsibility
4924 * of some other code and interfering with or delaying that
4925 * processing is bad.
4926 *
4927 * \retval 0 Not in an intercept routine.
4928 * \retval 1 In an intercept routine.
4929 */
4931
4932/*!
4933 * \brief Retrieve the topology of streams on a channel
4934 *
4935 * \param chan The channel to get the stream topology of
4936 *
4937 * \pre chan is locked
4938 *
4939 * \retval non-NULL success
4940 * \retval NULL failure
4941 */
4943 const struct ast_channel *chan);
4944
4945/*!
4946 * \brief Set the topology of streams on a channel
4947 *
4948 * \param chan The channel to set the stream topology on
4949 * \param topology The stream topology to set
4950 *
4951 * \pre chan is locked
4952 *
4953 * \note If topology is NULL a new empty topology will be created
4954 * and returned.
4955 *
4956 * \retval non-NULL Success
4957 * \retval NULL failure
4958 */
4960 struct ast_channel *chan, struct ast_stream_topology *topology);
4961
4962/*!
4963 * \brief Retrieve the default stream of a specific media type on a channel
4964 *
4965 * \param chan The channel to get the stream from
4966 * \param type The media type of the default stream
4967 *
4968 * \pre chan is locked
4969 *
4970 * \retval non-NULL success
4971 * \retval NULL failure
4972 */
4974
4975/*!
4976 * \brief Determine if a channel is multi-stream capable
4977 *
4978 * \param chan The channel to test
4979 *
4980 * \pre chan is locked
4981 *
4982 * \retval true if the channel is multi-stream capable.
4983 */
4984int ast_channel_is_multistream(struct ast_channel *chan);
4985
4986/*!
4987 * \brief Request that the stream topology of a channel change
4988 *
4989 * \param chan The channel to change
4990 * \param topology The new stream topology
4991 * \param change_source The source that initiated the change
4992 *
4993 * \note Absolutely _NO_ channel locks should be held before calling this function.
4994 *
4995 * \retval 0 request has been accepted to be attempted
4996 * \retval -1 request could not be attempted
4997 *
4998 * \note This function initiates an asynchronous request to change the stream topology. It is not
4999 * guaranteed that the topology will change and until an AST_CONTROL_STREAM_TOPOLOGY_CHANGED
5000 * frame is received from the channel the current handler of the channel must tolerate the
5001 * stream topology as it currently exists.
5002 *
5003 * \note This interface is provided for applications and resources to request that the topology change.
5004 * It is not for use by the channel driver itself.
5005 */
5007 struct ast_stream_topology *topology, void *change_source);
5008
5009/*!
5010 * \brief Provide notice to a channel that the stream topology has changed
5011 *
5012 * \param chan The channel to provide notice to
5013 * \param topology The new stream topology
5014 *
5015 * \pre chan is locked Absolutely _NO_ other channels can be locked.
5016 *
5017 * \retval 0 success
5018 * \retval -1 failure
5019 *
5020 * \note This interface is provided for applications and resources to accept a topology change.
5021 * It is not for use by the channel driver itself.
5022 */
5023int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology);
5024
5025/*!
5026 * \brief Provide notice from a channel that the topology has changed on it as a result
5027 * of the remote party renegotiating.
5028 *
5029 * \param chan The channel to provide notice from
5030 *
5031 * \retval 0 success
5032 * \retval -1 failure
5033 *
5034 * \note This interface is provided for channels to provide notice that a topology change
5035 * has occurred as a result of a remote party renegotiating the stream topology.
5036 */
5038
5039/*!
5040 * \brief Retrieve the source that initiated the last stream topology change
5041 *
5042 * \param chan The channel
5043 *
5044 * \retval The channel's stream topology change source
5045 */
5047
5048/*!
5049 * \brief Checks if a channel's technology implements a particular callback function
5050 * \since 18.0.0
5051 *
5052 * \param chan The channel
5053 * \param function The function to look for
5054 *
5055 * \retval 1 if the channel has a technology set and it implements the function
5056 * \retval 0 if the channel doesn't have a technology set or it doesn't implement the function
5057 */
5058#define ast_channel_has_tech_function(chan, function) \
5059 (ast_channel_tech(chan) ? ast_channel_tech(chan)->function != NULL : 0)
5060
5061/*!
5062 * \brief Get the name of the current channel storage driver
5063 *
5064 * \return The name of the current channel storage driver
5065 */
5067
5068/*!
5069 * \internal
5070 * \brief Set the current channel storage driver
5071 *
5072 * \param driver_name The name of the driver to set as the current driver
5073 *
5074 * \return 0 on success, -1 on failure
5075 *
5076 * \warning Changing the channel storage driver while Asterisk is running is
5077 * not supported. This function will return an error if called while
5078 * the ast_fully_booted flag is set. The function is exposed only
5079 * because options.c needs it to set the driver when reading
5080 * asterisk.conf.
5081 */
5082int internal_channel_set_current_storage_driver(const char *driver_name);
5083
5084#endif /* _ASTERISK_CHANNEL_H */
Common implementation-independent jitterbuffer stuff.
ast_alert_status_t
Definition alertpipe.h:24
static struct aco_type agent_type
char digit
static struct ast_generator gen
const char * str
Definition app_jack.c:150
char * text
Definition app_queue.c:1772
ast_cond_t cond
Definition app_sla.c:336
static char dialcontext[AST_MAX_CONTEXT]
int() ao2_callback_data_fn(void *obj, void *arg, void *data, int flags)
Type of a generic callback function.
Definition astobj2.h:1244
Call Completion Supplementary Services API.
void(* ast_cc_callback_fn)(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char *monitor_type, const char *const device_name, const char *const dialstring, void *private_data)
Callback made from ast_cc_callback for certain channel types.
Definition ccss.h:1562
Call Detail Record API.
static int connected
Definition cdr_pgsql.c:73
static char language[MAX_LANGUAGE]
Definition chan_iax2.c:348
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition chan_iax2.c:497
static const char type[]
static void dummy(char *unused,...)
void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
Copy the source party subaddress information to the destination party subaddress.
Definition channel.c:1691
void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2)
Swap the interal alertpipe between two channels.
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
struct varshead * ast_channel_get_manager_vars(struct ast_channel *chan)
Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
Definition channel.c:7968
int ast_senddigit_mf_begin(struct ast_channel *chan, char digit)
Send an MF digit to a channel.
Definition channel.c:4830
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition channel.c:3172
int ast_str2cause(const char *name) attribute_pure
Convert the string form of a cause code to a number.
Definition channel.c:625
const char * ast_channel_linkedid(const struct ast_channel *chan)
const char * ast_channel_name(const struct ast_channel *chan)
static int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
Helper function for migrating select to poll.
Definition channel.h:2887
int ast_channel_tech_hangupcause(const struct ast_channel *chan)
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
char * ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups)
Print named call groups and named pickup groups.
Definition channel.c:8100
struct ast_bridge * ast_channel_internal_bridge(const struct ast_channel *chan)
void * ast_channel_get_stream_topology_change_source(struct ast_channel *chan)
Retrieve the source that initiated the last stream topology change.
struct timeval ast_channel_answertime(struct ast_channel *chan)
void ast_softhangup_all(void)
Soft hangup all active channels.
Definition channel.c:493
int ast_channel_request_stream_topology_change(struct ast_channel *chan, struct ast_stream_topology *topology, void *change_source)
Request that the stream topology of a channel change.
Definition channel.c:11010
void ast_channel_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why)
Simulate a DTMF end on a broken bridge channel.
Definition channel.c:10913
void ast_party_redirecting_reason_copy(struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
Copy the source redirecting reason information to the destination redirecting reason.
Definition channel.c:2071
void ast_channel_rings_set(struct ast_channel *chan, int value)
void ast_channel_internal_copy_linkedid(struct ast_channel *dest, struct ast_channel *source)
Copy the full linkedid channel id structure from one channel to another.
void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
struct ast_channel * ast_channel_get_by_exten(const char *exten, const char *context)
Find a channel by extension and context.
Definition channel.c:1429
int(* ast_timing_func_t)(const void *data)
Definition channel.h:919
struct ast_channel * ast_channel_masq(const struct ast_channel *chan)
void ast_party_name_init(struct ast_party_name *init)
Initialize the given name structure.
Definition channel.c:1577
char * ast_recvtext(struct ast_channel *chan, int timeout)
Receives a text string from a channel Read a string of text from a channel.
Definition channel.c:4712
enum ast_channel_error ast_channel_errno(void)
Get error code for latest channel operation.
Definition channel.c:11005
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition channel.c:2948
struct ast_channel * ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
Call a function with every active channel.
Definition channel.c:1335
int ast_channel_blocker_tid(const struct ast_channel *chan)
void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value)
void ast_channel_appl_set(struct ast_channel *chan, const char *value)
void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value)
void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide)
Initialize the given dialed structure using the given guide for a set update operation.
Definition channel.c:1936
void ast_channel_internal_bridged_channel_set(struct ast_channel *chan, struct ast_channel *value)
void ast_channel_visible_indication_set(struct ast_channel *chan, int value)
int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length)
Get a device name given its channel structure.
Definition channel.c:10540
const char * ast_channel_blockproc(const struct ast_channel *chan)
void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value)
struct ast_stream_topology * ast_channel_set_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
Set the topology of streams on a channel.
char * ast_transfercapability2str(int transfercapability) attribute_const
Gives the string form of a given transfer capability.
Definition channel.c:672
void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value)
Variant of ast_channel_set_unbridged. Use this if the channel is already locked prior to calling.
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Waits for activity on a group of channels.
Definition channel.c:2985
int ast_auto_answer(struct ast_channel *chan)
Answer a channel, if it's not already answered.
Definition channel.c:2809
struct ast_namedgroups * ast_channel_named_pickupgroups(const struct ast_channel *chan)
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition channel.c:2108
void * ast_channel_tech_pvt(const struct ast_channel *chan)
void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid)
Set uniqueid and linkedid string value only (not time)
static enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
Retrieves the current T38 state of a channel.
Definition channel.h:2910
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition channel.c:6456
const char * ast_channel_data(const struct ast_channel *chan)
void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Set the redirecting id information in the Asterisk channel.
Definition channel.c:9163
int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd)
Definition channel.c:6558
void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value)
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
Definition channel.c:11078
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition channel.c:2375
struct ast_party_id ast_channel_redirecting_effective_to(struct ast_channel *chan)
struct ast_control_pvt_cause_code * ast_channel_dialed_causes_find(const struct ast_channel *chan, const char *chan_name)
Retrieve a ref-counted cause code information structure.
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)
Forwards a call to a new channel specified by the original channel's call_forward str....
Definition channel.c:5893
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
Definition channel.c:2384
struct ast_party_id ast_channel_redirecting_effective_from(struct ast_channel *chan)
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition channel.c:1743
int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format)
Set specific read path on channel.
Definition channel.c:5483
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
Definition channel.c:2422
void * ast_channel_music_state(const struct ast_channel *chan)
struct ast_channel_iterator * ast_channel_iterator_by_name_new(const char *name, size_t name_len)
Create a new channel iterator based on name.
Definition channel.c:1367
struct varshead * ast_channel_get_vars(struct ast_channel *chan)
Gets the variables for a given channel, as set using pbx_builtin_setvar_helper().
Definition channel.c:7896
void ast_channel_blockproc_set(struct ast_channel *chan, const char *value)
int ast_prod(struct ast_channel *chan)
Send empty audio to prime a channel driver.
Definition channel.c:4995
unsigned int ast_channel_fin(const struct ast_channel *chan)
void ast_channel_tech_hangupcause_set(struct ast_channel *chan, int value)
int __ast_answer(struct ast_channel *chan, unsigned int delay)
Answer a channel, with a selectable delay before returning.
Definition channel.c:2693
int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame)
Run a connected line interception subroutine and update a channel's connected line information.
Definition channel.c:10382
const char * ast_channel_latest_musicclass(const struct ast_channel *chan)
void ast_channel_callid_cleanup(struct ast_channel *chan)
void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value)
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
Definition channel.c:1630
void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value)
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition channel.c:2538
void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
Set the caller id information in the Asterisk channel.
Definition channel.c:7371
struct varshead * ast_channel_varshead(struct ast_channel *chan)
int ast_channel_rings(const struct ast_channel *chan)
#define DECLARE_STRINGFIELD_SETTERS_FOR(field)
Definition channel.h:4124
void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value)
int ast_write_video(struct ast_channel *chan, struct ast_frame *frame)
Write video frame to a channel This function writes the given frame to the indicated channel.
Definition channel.c:5012
int ast_raw_answer_with_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
Answer a channel passing in a stream topology.
Definition channel.c:2636
void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value)
void ast_channel_tenantid_set(struct ast_channel *chan, const char *value)
void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value)
void * ast_channel_timingdata(const struct ast_channel *chan)
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
Definition channel.c:1348
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
Definition channel.c:1181
int ast_channel_internal_alert_readfd(struct ast_channel *chan)
ast_channel_requestor_relationship
Definition channel.h:1523
@ AST_CHANNEL_REQUESTOR_BRIDGE_PEER
Definition channel.h:1525
@ AST_CHANNEL_REQUESTOR_REPLACEMENT
Definition channel.h:1527
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Definition channel.c:10608
int ast_transfer_protocol(struct ast_channel *chan, char *dest, int *protocol)
Transfer a channel (if supported) receieve protocol result.
Definition channel.c:6493
const char * ast_channel_tenantid(const struct ast_channel *chan)
void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide)
Initialize the given party subaddress structure using the given guide for a set update operation.
Definition channel.c:1705
void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value)
struct ast_flags * ast_channel_snapshot_segment_flags(struct ast_channel *chan)
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)
Set the connected line information in the Asterisk channel.
Definition channel.c:8352
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition channel.c:4869
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition channel.c:1807
struct ast_channel * ast_channel_get_by_uniqueid(const char *uniqueid)
Find a channel by a uniqueid.
Definition channel.c:1441
void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src)
Copy the source party number information to the destination party number.
Definition channel.c:1638
void ast_channel_internal_swap_endpoint_forward(struct ast_channel *a, struct ast_channel *b)
Swap endpoint_forward between two channels.
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
const char * ast_channel_musicclass(const struct ast_channel *chan)
void ast_channel_unlink(struct ast_channel *chan)
Remove a channel from the global channels container.
Definition channel.c:10573
int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen)
Sends HTML on given channel Send HTML or URL on link.
Definition channel.c:6623
int ast_channel_fdno(const struct ast_channel *chan)
void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src)
Set the source party number information into the destination party number.
Definition channel.c:1660
void ast_channel_internal_fd_clear_all(struct ast_channel *chan)
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition channel.c:1683
int ast_channel_has_hook_requiring_audio(struct ast_channel *chan)
Check if the channel has any active hooks that require audio.
Definition channel.c:2521
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition channel.c:2058
void ast_channel_internal_bridge_channel_set(struct ast_channel *chan, struct ast_bridge_channel *value)
void ast_channel_internal_alertpipe_close(struct ast_channel *chan)
int(* ast_acf_write_fn_t)(struct ast_channel *chan, const char *function, char *data, const char *value)
Typedef for a custom write function.
Definition channel.h:588
int64_t ast_channel_get_up_time_ms(struct ast_channel *chan)
Obtain how long it has been since the channel was answered in ms.
Definition channel.c:2833
void ast_channel_set_manager_vars(size_t varc, char **vars)
Sets the variables to be stored in the manager_vars field of all snapshots.
Definition channel.c:7872
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg)
Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback.
Definition channel.c:4746
void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value)
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition channel.c:7594
void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name...
Definition channel.c:7384
struct ast_channel * ast_waitfor_n(struct ast_channel **chan, int n, int *ms)
Waits for input on a group of channels Wait for input on an array of channels for a given # of millis...
Definition channel.c:3154
void ast_channel_hold_state_set(struct ast_channel *chan, int value)
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition channel.c:4969
struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan)
void ast_party_redirecting_set(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update)
Set the redirecting information based on another redirecting source.
Definition channel.c:2152
const struct ast_channel_tech ast_kill_tech
Kill the channel channel driver technology descriptor.
Definition channel.c:434
const char * ast_channel_lastexten(const struct ast_channel *chan)
int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer)
Make the frame formats of two channels compatible.
Definition channel.c:6715
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
ast_t38_state
Possible T38 states on channels.
Definition channel.h:898
@ T38_STATE_UNAVAILABLE
Definition channel.h:899
@ T38_STATE_UNKNOWN
Definition channel.h:900
@ T38_STATE_REJECTED
Definition channel.h:902
@ T38_STATE_NEGOTIATED
Definition channel.h:903
@ T38_STATE_NEGOTIATING
Definition channel.h:901
void ast_channel_data_set(struct ast_channel *chan, const char *value)
struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan)
struct varshead * ast_channel_get_ari_vars(struct ast_channel *chan)
Gets the variables for a given channel, as specified by ast_channel_set_ari_vars().
Definition channel.c:7973
void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value)
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot)
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition channel.c:1797
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition channel.c:570
struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
Set the source party subaddress information into the destination party subaddress.
Definition channel.c:1713
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to the head of a channel's frame queue.
Definition channel.c:1175
int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception)
Waits for input on an fd.
Definition channel.c:2977
unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology)
Provide notice to a channel that the stream topology has changed.
Definition channel.c:11040
struct ast_namedgroups * ast_channel_named_callgroups(const struct ast_channel *chan)
channelreloadreason
Channel reload reasons for manager events at load or reload of configuration.
Definition channel.h:1186
@ CHANNEL_CLI_RELOAD
Definition channel.h:1189
@ CHANNEL_MODULE_RELOAD
Definition channel.h:1188
@ CHANNEL_MODULE_LOAD
Definition channel.h:1187
@ CHANNEL_ACL_RELOAD
Definition channel.h:1191
@ CHANNEL_MANAGER_RELOAD
Definition channel.h:1190
ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
void ast_channel_blocker_tid_set(struct ast_channel *chan, int tid)
void ast_channel_vstreamid_set(struct ast_channel *chan, int value)
void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update)
Set the source party id information into the destination party id.
Definition channel.c:1774
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
Definition channel.c:1387
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition channel.c:8159
struct ast_namedgroups * ast_ref_namedgroups(struct ast_namedgroups *groups)
Definition channel.c:7750
int ast_channel_feature_hooks_replace(struct ast_channel *chan, struct ast_bridge_features *features)
Sets the channel-attached features a channel has access to upon being bridged.
Definition channel.c:11000
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition channel.c:8208
int internal_channel_set_current_storage_driver(const char *driver_name)
Definition channel.c:8023
static const char ast_stream_topology_changed_external[]
Set as the change source reason when a channel stream topology has been changed externally as a resul...
Definition channel.h:223
void ast_channel_timingdata_set(struct ast_channel *chan, void *value)
void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
Copy the source connected line information to the destination connected line.
Definition channel.c:2017
int ast_recvchar(struct ast_channel *chan, int timeout)
Receives a text character from a channel.
Definition channel.c:4701
struct ast_format * ast_channel_oldwriteformat(struct ast_channel *chan)
int ast_channel_internal_alert_readable(struct ast_channel *chan)
struct ast_cdr * ast_channel_cdr(const struct ast_channel *chan)
struct ast_channel * ast_channel_yank(struct ast_channel *yankee)
Gain control of a channel in the system.
Definition channel.c:10637
int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block)
Checks the value of an option.
Definition channel.c:7454
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition channel.c:3159
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition channel.c:1288
int ast_channel_cc_params_init(struct ast_channel *chan, const struct ast_cc_config_params *base_params)
Set up datastore with CCSS parameters for a channel.
Definition channel.c:10495
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
struct ast_channel * __ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
Request a channel of a given type, with data as optional information used by the low level module and...
Definition channel.c:5971
void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value)
unsigned long long ast_group_t
Definition channel.h:215
ast_channel_error
Definition channel.h:4903
@ AST_CHANNEL_ERROR_ID_EXISTS
Definition channel.h:4907
@ AST_CHANNEL_ERROR_UNKNOWN
Definition channel.h:4905
int ast_channel_get_intercept_mode(void)
Am I currently running an intercept dialplan routine.
Definition channel.c:10377
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)
Set the connected line information based on another connected line source.
Definition channel.c:2040
int ast_channel_priority(const struct ast_channel *chan)
void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
Definition channel.c:8254
int ast_settimeout_full(struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data, unsigned int is_ao2_obj)
Definition channel.c:3182
void ast_channel_streamid_set(struct ast_channel *chan, int value)
void ast_channel_generatordata_set(struct ast_channel *chan, void *value)
void ast_party_dialed_init(struct ast_party_dialed *init)
Initialize the given dialed structure.
Definition channel.c:1914
int(* ast_acf_read2_fn_t)(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len)
Typedef for a custom read2 function.
Definition channel.h:582
const char * ast_channel_get_current_storage_driver_name(void)
Get the name of the current channel storage driver.
Definition channel.c:8017
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src)
Copy the source caller information to the destination caller.
Definition channel.c:1972
struct ast_str * ast_channel_dialed_causes_channels(const struct ast_channel *chan)
Retrieve a comma-separated list of channels for which dialed cause information is available.
void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value)
ast_callid ast_channel_callid(const struct ast_channel *chan)
void ast_party_redirecting_reason_set(struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
Set the redirecting reason information based on another redirecting reason source.
Definition channel.c:2088
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
Definition channel.c:1170
int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups *b)
Return TRUE if group a and b contain at least one common groupname.
Definition channel.c:8134
const char * ast_channel_uniqueid(const struct ast_channel *chan)
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
Definition channel.c:2358
const char * ast_channel_accountcode(const struct ast_channel *chan)
void ast_channel_internal_swap_endpoints(struct ast_channel *a, struct ast_channel *b)
Swap endpoints between two channels.
struct ast_channel * ast_channel__bridge(const struct ast_channel *chan)
void ast_channel_undefer_dtmf(struct ast_channel *chan)
Unset defer DTMF flag on channel.
Definition channel.c:1328
void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
Definition channel.c:6429
const char * ast_channel_context(const struct ast_channel *chan)
const char * ast_channel_userfield(const struct ast_channel *chan)
char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan)
unsigned long ast_channel_insmpl(const struct ast_channel *chan)
int ast_channel_fd_add(struct ast_channel *chan, int value)
Add a file descriptor to the channel without a fixed position.
void ast_deactivate_generator(struct ast_channel *chan)
Definition channel.c:2890
ast_alert_status_t ast_channel_internal_alert_flush(struct ast_channel *chan)
void ast_party_id_merge_copy(struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay)
Copy a merge of a given party id into another given party id to a given destination party id.
Definition channel.c:1906
struct ast_channel_iterator * ast_channel_iterator_by_exten_new(const char *exten, const char *context)
Create a new channel iterator based on extension.
Definition channel.c:1356
int ast_check_hangup_locked(struct ast_channel *chan)
Definition channel.c:459
void ast_channel_timingfd_set(struct ast_channel *chan, int value)
int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Compare a offset with the settings of when to hang a channel up.
Definition channel.c:523
unsigned long global_fin
Definition channel.c:98
struct ast_channel * __ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, const char *file, int line, const char *function, const char *name_fmt,...)
Create a channel structure.
Definition channel.c:966
void ast_channel_endpoint_set(struct ast_channel *chan, struct ast_endpoint *endpoint)
char * ast_print_group(char *buf, int buflen, ast_group_t group)
Print call and pickup groups into buffer.
Definition channel.c:8075
struct ast_channel * ast_channel_get_by_name_prefix(const char *name, size_t name_len)
Find a channel by a name prefix.
Definition channel.c:1399
pthread_t ast_channel_blocker(const struct ast_channel *chan)
void ast_party_redirecting_reason_set_init(struct ast_party_redirecting_reason *init, const struct ast_party_redirecting_reason *guide)
Initialize the given redirecting reason structure using the given guide for a set update operation.
Definition channel.c:2082
ama_flags
Channel AMA Flags.
Definition channel.h:1197
@ AST_AMA_DOCUMENTATION
Definition channel.h:1201
@ AST_AMA_OMIT
Definition channel.h:1199
@ AST_AMA_NONE
Definition channel.h:1198
@ AST_AMA_BILLING
Definition channel.h:1200
int ast_set_write_format_interleaved_stereo(struct ast_channel *chan, struct ast_format *format)
Sets write format for a channel. All internal data will than be handled in an interleaved format....
Definition channel.c:5780
void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value)
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
Definition channel.c:5139
void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update)
Set the caller information based on another caller source.
Definition channel.c:1993
int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
Suppress passing of a frame type on a channel.
Definition channel.c:10821
int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge_features *features)
Appends to the channel-attached features a channel has access to upon being bridged.
Definition channel.c:10995
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode)
Lock the given channel, then request softhangup on the channel with the given causecode.
Definition channel.c:468
int ast_channel_epfd(const struct ast_channel *chan)
int ast_undestroyed_channels(void)
Definition channel.c:504
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition channel.c:4250
void ast_party_connected_line_collect_caller(struct ast_party_connected_line *connected, struct ast_party_caller *caller)
Collect the caller party information into a connected line structure.
Definition channel.c:2049
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
Definition channel.c:1295
struct ast_bridge_features * ast_channel_feature_hooks_get(struct ast_channel *chan)
Gets the channel-attached features a channel has access to upon being bridged.
Definition channel.c:10947
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)
Indicate that the connected line information has changed.
Definition channel.c:9137
int ast_channel_is_t38_active_nolock(struct ast_channel *chan)
ast_channel_is_t38_active variant. Use this if the channel is already locked prior to calling.
int ast_senddigit_mf_end(struct ast_channel *chan)
End sending an MF digit to a channel.
Definition channel.c:4938
int ast_channel_move(struct ast_channel *dest, struct ast_channel *source)
Move a channel from its current location to a new location.
Definition channel.c:10710
void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Queue a redirecting update frame on a channel.
Definition channel.c:10341
void ast_party_redirecting_reason_init(struct ast_party_redirecting_reason *init)
Initialize the given redirecting reason structure.
Definition channel.c:2065
const char * ast_channel_parkinglot(const struct ast_channel *chan)
ast_channel_adsicpe
Definition channel.h:888
@ AST_ADSI_UNKNOWN
Definition channel.h:889
@ AST_ADSI_UNAVAILABLE
Definition channel.h:891
@ AST_ADSI_AVAILABLE
Definition channel.h:890
@ AST_ADSI_OFFHOOKONLY
Definition channel.h:892
int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel from an external thread.
Definition channel.c:4982
void ast_channel_internal_swap_topics(struct ast_channel *a, struct ast_channel *b)
Swap topics beteween two channels.
int ast_sendtext(struct ast_channel *chan, const char *text)
Sends text to a channel.
Definition channel.c:4804
const char * ast_channel_appl(const struct ast_channel *chan)
struct ast_frame * ast_read_stream(struct ast_channel *chan)
Reads a frame, but does not filter to just the default streams.
Definition channel.c:4255
void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide)
Initialize the given caller structure using the given guide for a set update operation.
Definition channel.c:1985
int ast_channel_unbridged_nolock(struct ast_channel *chan)
ast_channel_unbridged variant. Use this if the channel is already locked prior to calling.
void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide)
Initialize the given party id structure using the given guide for a set update operation.
Definition channel.c:1766
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
Definition channel.c:1624
void ast_channel_set_ari_vars(size_t varc, char **vars)
Sets the variables to be stored in the ari_vars field of all snapshots.
Definition channel.c:7877
const char * ast_channel_peeraccount(const struct ast_channel *chan)
void ast_party_dialed_free(struct ast_party_dialed *doomed)
Destroy the dialed party contents.
Definition channel.c:1957
void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value)
struct timeval ast_channel_creationtime(struct ast_channel *chan)
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
Definition channel.c:7346
int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame)
Run a redirecting interception subroutine and update a channel's redirecting information.
Definition channel.c:10427
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
Inherits channel variable from parent to child channel.
Definition channel.c:6771
struct ast_channel * ast_channel_get_by_name(const char *search)
Find a channel by name or uniqueid.
Definition channel.c:1416
struct ast_bridge_channel * ast_channel_internal_bridge_channel(const struct ast_channel *chan)
struct ast_framehook_list * ast_channel_framehooks(const struct ast_channel *chan)
struct ast_frame * ast_read_stream_noaudio(struct ast_channel *chan)
Reads a frame, but does not filter to just the default streams, returning AST_FRAME_NULL frame if aud...
Definition channel.c:4265
void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value)
int ast_channel_fd(const struct ast_channel *chan, int which)
void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide)
Initialize the given redirecting id structure using the given guide for a set update operation.
Definition channel.c:2139
void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value)
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
Definition channel.c:5757
void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value)
void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide)
Initialize the given party name structure using the given guide for a set update operation.
Definition channel.c:1599
void ast_channel_fin_set(struct ast_channel *chan, unsigned int value)
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition channel.c:1212
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
struct ast_audiohook_list * ast_channel_audiohooks(const struct ast_channel *chan)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
enum ama_flags ast_channel_amaflags(const struct ast_channel *chan)
int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
Parse connected line indication frame data.
Definition channel.c:8829
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
Definition channel.c:2001
void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
struct ast_channel * __ast_dummy_channel_alloc(const char *file, int line, const char *function)
Definition channel.c:1006
void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src)
Copy the source dialed party information to the destination dialed party.
Definition channel.c:1922
int ast_active_channels(void)
returns number of active/allocated channels
Definition channel.c:499
struct ast_channel * ast_request_with_stream_topology(const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requests a channel (specifying stream topology)
Definition channel.c:6354
struct ast_namedgroups * ast_get_namedgroups(const char *s)
Create an ast_namedgroups set with group names from comma separated string.
Definition channel.c:7687
int ast_channel_supports_html(struct ast_channel *channel)
Checks for HTML support on a channel.
Definition channel.c:6618
void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value)
void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value)
void * ast_channel_generatordata(const struct ast_channel *chan)
struct ast_format * ast_channel_rawwriteformat(struct ast_channel *chan)
void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active)
Variant of ast_channel_set_is_t38_active. Use this if the channel is already locked prior to calling.
const char * ast_channel_hangupsource(const struct ast_channel *chan)
AST_MONITORING_STATE
Definition channel.h:4117
@ AST_MONITOR_PAUSED
Definition channel.h:4119
@ AST_MONITOR_RUNNING
Definition channel.h:4118
unsigned int ast_channel_fout(const struct ast_channel *chan)
const char * ast_channel_dialcontext(const struct ast_channel *chan)
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition channel.c:445
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
void ast_channel_set_unbridged(struct ast_channel *chan, int value)
Sets the unbridged flag and queues a NULL frame on the channel to trigger a check by bridge_channel_w...
void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value)
void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src)
Set the source party name information into the destination party name.
Definition channel.c:1607
int ast_channel_hangupcause(const struct ast_channel *chan)
void ast_set_party_id_all(struct ast_set_party_id *update_id)
Set the update marker to update all information of a corresponding party id.
Definition channel.c:1736
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
Definition channel.c:10589
void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src)
Set the dialed information based on another dialed source.
Definition channel.c:1944
const char * ast_channel_reason2str(int reason)
return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
Definition channel.c:5821
int ast_channel_timingfd(const struct ast_channel *chan)
void ast_channel_fdno_set(struct ast_channel *chan, int value)
struct ast_frame * ast_read_noaudio(struct ast_channel *chan)
Reads a frame, returning AST_FRAME_NULL frame if audio.
Definition channel.c:4260
int64_t ast_channel_get_duration_ms(struct ast_channel *chan)
Obtain how long it's been, in milliseconds, since the channel was created.
Definition channel.c:2818
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition channel.c:10578
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
AST_PARTY_CHAR_SET
Definition channel.h:244
@ AST_PARTY_CHAR_SET_UNKNOWN
Definition channel.h:245
@ AST_PARTY_CHAR_SET_ISO8859_4
Definition channel.h:250
@ AST_PARTY_CHAR_SET_WITHDRAWN
Definition channel.h:247
@ AST_PARTY_CHAR_SET_ISO8859_5
Definition channel.h:251
@ AST_PARTY_CHAR_SET_ISO8859_7
Definition channel.h:252
@ AST_PARTY_CHAR_SET_ISO8859_2
Definition channel.h:248
@ AST_PARTY_CHAR_SET_ISO8859_1
Definition channel.h:246
@ AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING
Definition channel.h:254
@ AST_PARTY_CHAR_SET_ISO10646_BMPSTRING
Definition channel.h:253
@ AST_PARTY_CHAR_SET_ISO8859_3
Definition channel.h:249
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
Definition channel.c:1570
struct ast_channel * ast_channel_internal_bridged_channel(const struct ast_channel *chan)
void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value)
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
Definition channel.c:4648
int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Build the redirecting id data frame.
Definition channel.c:9312
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it's bridge.
Definition channel.c:2496
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition channel.c:11071
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
Definition channel.c:2461
struct ast_party_id ast_channel_redirecting_effective_orig(struct ast_channel *chan)
void ast_channel_name_to_dial_string(char *channel_name)
Removes the trailing identifiers from a channel name string.
Definition channel.c:6839
int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Add cause code information to the channel.
void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
int ast_channel_alert_write(struct ast_channel *chan)
void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel.
Definition channel.c:4340
const char * ast_channel_lastcontext(const struct ast_channel *chan)
struct ast_channel * __ast_channel_alloc_with_initializers(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, struct ast_channel_initializers *initializers, const char *file, int line, const char *function, const char *name_fmt,...)
Create a channel structure.
Definition channel.c:985
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
Definition channel.c:1273
ast_bridge_result
Definition channel.h:208
@ AST_BRIDGE_FAILED_NOWARN
Definition channel.h:211
@ AST_BRIDGE_RETRY
Definition channel.h:212
@ AST_BRIDGE_COMPLETE
Definition channel.h:209
@ AST_BRIDGE_FAILED
Definition channel.h:210
int ast_channel_vstreamid(const struct ast_channel *chan)
struct ast_readq_list * ast_channel_readq(struct ast_channel *chan)
void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Indicate that the redirecting id has changed.
Definition channel.c:10328
int ast_channel_has_manager_vars(void)
Return whether or not any manager variables have been set.
Definition channel.c:7840
void ast_channel_set_is_t38_active(struct ast_channel *chan, int is_t38_active)
Sets the is_t38_active flag.
struct ast_jb * ast_channel_jb(struct ast_channel *chan)
void ast_party_id_reset(struct ast_party_id *id)
Destroy and initialize the given party id structure.
Definition channel.c:1882
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
Definition channel.c:4367
void ast_channel__bridge_set(struct ast_channel *chan, struct ast_channel *value)
void ast_party_id_invalidate(struct ast_party_id *id)
Invalidate all components of the given party id.
Definition channel.c:1875
ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
Definition channel.c:1248
int(* ast_acf_read_fn_t)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
Typedef for a custom read function.
Definition channel.h:576
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
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)
Build the connected line information data frame.
Definition channel.c:8741
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition channel.c:4919
int ast_channel_has_ari_vars(void)
Return whether or not any ARI variables have been set.
Definition channel.c:7845
void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value)
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
Definition channel.c:539
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay)
Merge a given party id into another given party id.
Definition channel.c:1888
struct ast_stream * ast_channel_get_default_stream(struct ast_channel *chan, enum ast_media_type type)
Retrieve the default stream of a specific media type on a channel.
struct ast_channel * ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int timeout, int *reason, const char *cid_num, const char *cid_name)
Request a channel of a given type, with data as optional information used by the low level module and...
Definition channel.c:6169
struct ast_filestream * ast_channel_vstream(const struct ast_channel *chan)
int ast_channel_stream_topology_changed_externally(struct ast_channel *chan)
Provide notice from a channel that the topology has changed on it as a result of the remote party ren...
Definition channel.c:11052
ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan)
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide)
Initialize the given party number structure using the given guide for a set update operation.
Definition channel.c:1652
int ast_settimeout(struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data)
Enable or disable timer ticks for a channel.
Definition channel.c:3177
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition channel.c:5798
void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src)
Copy the source party id information to the destination party id.
Definition channel.c:1751
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition channel.c:1677
void ast_channel_internal_swap_uniqueid_and_linkedid(struct ast_channel *a, struct ast_channel *b)
Swap uniqueid and linkedid beteween two channels.
struct ast_generator * ast_channel_generator(const struct ast_channel *chan)
ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
int ast_channel_unbridged(struct ast_channel *chan)
This function will check if the bridge needs to be re-evaluated due to external changes.
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition channel.c:2008
int ast_channel_get_up_time(struct ast_channel *chan)
Obtain how long it has been since the channel was answered.
Definition channel.c:2843
int ast_channel_is_leaving_bridge(struct ast_channel *chan)
Determine if a channel is leaving a bridge, but not hung up.
Definition channel.c:10594
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Set when to hang a channel up.
Definition channel.c:510
int ast_channel_hold_state(const struct ast_channel *chan)
int ast_channel_sendurl(struct ast_channel *channel, const char *url)
Sends a URL on a given link Send URL on link.
Definition channel.c:6630
int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting)
Parse redirecting indication frame data.
Definition channel.c:9523
void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value)
int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int(*cond)(void *), void *data)
Wait for a specified amount of time, looking for hangups and a condition argument.
Definition channel.c:1554
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
struct ast_variable * ast_channeltype_list(void)
return an ast_variable list of channeltypes
Definition channel.c:188
const char * ast_channel_oldest_linkedid(const char *a, const char *b)
Return the oldest linkedid between two channels.
const char * ast_channel_language(const struct ast_channel *chan)
struct ast_bridge_channel * ast_channel_get_bridge_channel(struct ast_channel *chan)
Get a reference to the channel's bridge pointer.
Definition channel.c:10626
const char * ast_cause2str(int cause) attribute_pure
Gives the string form of a given cause code.
Definition channel.c:612
int ast_senddigit_mf(struct ast_channel *chan, char digit, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
Send an MF digit to a channel.
Definition channel.c:4947
struct ao2_iterator * ast_channel_dialed_causes_find_multiple(const struct ast_channel *chan, const char *chan_name)
Retrieve a ref-counted cause code information structure iterator.
int ast_write_text(struct ast_channel *chan, struct ast_frame *frame)
Write text frame to a channel This function writes the given frame to the indicated channel.
struct ast_party_connected_line * ast_channel_connected_indicated(struct ast_channel *chan)
struct ast_endpoint * ast_channel_endpoint(const struct ast_channel *chan)
int ast_transfer(struct ast_channel *chan, char *dest)
Transfer a channel (if supported).
Definition channel.c:6480
void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value)
int ast_channel_unsuppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
Stop suppressing of a frame type on a channel.
Definition channel.c:10883
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition channel.c:2165
void ast_channel_context_set(struct ast_channel *chan, const char *value)
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition channel.c:2416
int ast_channel_streamid(const struct ast_channel *chan)
void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value)
const char * ast_state2str(enum ast_channel_state state)
Gives the string form of a given channel state.
Definition channel.c:636
@ AST_CHAN_TP_INTERNAL
Channels with this particular technology are an implementation detail of Asterisk and should generall...
Definition channel.h:991
@ AST_CHAN_TP_SEND_TEXT_DATA
Channels have this property if they implement send_text_data.
Definition channel.h:995
@ AST_CHAN_TP_WANTSJITTER
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
Definition channel.h:980
@ AST_CHAN_TP_CREATESJITTER
Channels have this property if they can create jitter; i.e. most VoIP channels.
Definition channel.h:985
void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value)
struct ast_sched_context * ast_channel_sched(const struct ast_channel *chan)
void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state)
void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src)
Copy the caller information to the connected line information.
Definition channel.c:8337
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
Definition channel.c:2448
int ast_channel_forward_endpoint(struct ast_channel *chan, struct ast_endpoint *endpoint)
Forward channel stasis messages to the given endpoint.
int ast_channel_fd_count(const struct ast_channel *chan)
Retrieve the number of file decriptor positions present on the channel.
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
Definition channel.c:4354
struct ast_frame * ast_channel_dtmff(struct ast_channel *chan)
void ast_channel_internal_swap_snapshots(struct ast_channel *a, struct ast_channel *b)
Swap snapshots beteween two channels.
void ast_channel_music_state_set(struct ast_channel *chan, void *value)
void ast_channel_req_accountcodes_precious(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
Definition channel.c:6434
unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan)
static int ast_add_fd(struct pollfd *pfd, int fd)
if fd is a valid descriptor, set *pfd with the descriptor
Definition channel.h:2879
const char * ast_channel_call_forward(const struct ast_channel *chan)
int ast_set_write_format_path(struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format)
Set specific write path on channel.
Definition channel.c:5519
struct ast_filestream * ast_channel_stream(const struct ast_channel *chan)
void ast_channel_internal_fd_clear(struct ast_channel *chan, int which)
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
void ast_channel_fout_set(struct ast_channel *chan, unsigned int value)
struct ast_autochan_list * ast_channel_autochans(struct ast_channel *chan)
int ast_pre_call(struct ast_channel *chan, const char *sub_args)
Execute a Gosub call on the channel before a call is placed.
Definition channel.c:6439
int ast_queue_answer(struct ast_channel *chan, const struct ast_stream_topology *topology)
Queue an ANSWER control frame with topology.
Definition channel.c:1303
void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value)
struct ast_channel * ast_channel_masqr(const struct ast_channel *chan)
struct ast_namedgroups * ast_unref_namedgroups(struct ast_namedgroups *groups)
Definition channel.c:7744
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition channel.c:1730
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block)
Sets an option on a channel.
Definition channel.c:7434
int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats)
Sets read format on channel chan from capabilities Set read format for channel to whichever component...
Definition channel.c:5775
struct timeval * ast_channel_dtmf_tv(struct ast_channel *chan)
int ast_channel_get_duration(struct ast_channel *chan)
Obtain how long the channel since the channel was created.
Definition channel.c:2828
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
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)
Queue a connected line update frame on a channel.
Definition channel.c:9150
void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
Initialize the given connected line structure using the given guide for a set update operation.
Definition channel.c:2031
unsigned long global_fout
Definition channel.h:886
char ast_channel_sending_dtmf_digit(const struct ast_channel *chan)
int ast_channel_visible_indication(const struct ast_channel *chan)
@ AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT
Definition channel.h:1055
@ AST_FLAG_ZOMBIE
Definition channel.h:1007
@ AST_FLAG_DISABLE_DEVSTATE_CACHE
Definition channel.h:1049
@ AST_FLAG_SNAPSHOT_STAGE
Definition channel.h:1070
@ AST_FLAG_OUTGOING
Definition channel.h:1019
@ AST_FLAG_BRIDGE_HANGUP_RUN
Definition channel.h:1038
@ AST_FLAG_MASQ_NOSTREAM
Definition channel.h:1034
@ AST_FLAG_IN_AUTOLOOP
Definition channel.h:1017
@ AST_FLAG_END_DTMF_ONLY
Definition channel.h:1027
@ AST_FLAG_DEAD
Definition channel.h:1065
@ AST_FLAG_EXCEPTION
Definition channel.h:1009
@ AST_FLAG_EMULATE_DTMF
Definition channel.h:1024
@ AST_FLAG_IN_DTMF
Definition channel.h:1021
@ AST_FLAG_WRITE_INT
Definition channel.h:1003
@ AST_FLAG_DEFER_DTMF
Definition channel.h:1001
@ AST_FLAG_BLOCKING
Definition channel.h:1005
@ AST_FLAG_SPYING
Definition channel.h:1013
@ AST_FLAG_DISABLE_WORKAROUNDS
Definition channel.h:1042
@ AST_FLAG_SUBROUTINE_EXEC
Definition channel.h:1078
@ AST_FLAG_ORIGINATED
Definition channel.h:1059
@ AST_FLAG_TIMINGDATA_IS_AO2_OBJ
Definition channel.h:1074
@ AST_FLAG_MOH
Definition channel.h:1011
struct ast_timer * ast_channel_timer(const struct ast_channel *chan)
struct ast_hangup_handler_list * ast_channel_hangup_handlers(struct ast_channel *chan)
void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value)
unsigned long ast_channel_outsmpl(const struct ast_channel *chan)
void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value)
void ast_channel_callid_set(struct ast_channel *chan, ast_callid value)
int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *frame)
Write a frame to a stream This function writes the given frame to the indicated stream on the channel...
Definition channel.c:5144
void ast_channel_internal_alertpipe_clear(struct ast_channel *chan)
void ast_channel_priority_set(struct ast_channel *chan, int value)
int ast_safe_sleep_without_silence(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups, and do not generate silence.
Definition channel.c:1565
int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype)
Ignore certain frame types.
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
Reads multiple digits.
Definition channel.c:6553
void ast_connected_line_copy_to_caller(struct ast_party_caller *dest, const struct ast_party_connected_line *src)
Copy the connected line information to the caller information.
Definition channel.c:8344
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer)
Put chan into autoservice while hanging up peer.
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
const struct ast_channel_tech * ast_get_channel_tech(const char *name)
Get a channel technology structure by name.
Definition channel.c:592
int ast_channel_fd_isset(const struct ast_channel *chan, int which)
int ast_channel_defer_dtmf(struct ast_channel *chan)
Defers DTMF so that you only read things like hangups and audio.
Definition channel.c:1314
int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition channel.c:7612
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition channel.c:2803
void ast_change_name(struct ast_channel *chan, const char *newname)
Change channel name.
Definition channel.c:6759
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
void ast_channel_dialed_causes_clear(const struct ast_channel *chan)
Clear all cause information from the channel.
void ast_channel_epfd_set(struct ast_channel *chan, int value)
ast_group_t ast_get_group(const char *s)
Definition channel.c:7630
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
Bridge two channels together (early)
Definition channel.c:7424
int ast_channel_internal_alertpipe_init(struct ast_channel *chan)
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition channel.c:4270
void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value)
int ast_is_deferrable_frame(const struct ast_frame *frame)
Should we keep this frame for later?
Definition channel.c:1453
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
struct ast_channel_iterator * ast_channel_iterator_all_new(void)
Create a new channel iterator.
Definition channel.c:1379
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition channel.c:1560
struct ast_channel * ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requests a channel.
Definition channel.c:6349
const char * ast_channel_exten(const struct ast_channel *chan)
int ast_channel_is_t38_active(struct ast_channel *chan)
This function will check if T.38 is active on the channel.
@ AST_SOFTHANGUP_ASYNCGOTO
Definition channel.h:1146
@ AST_SOFTHANGUP_EXPLICIT
Definition channel.h:1168
@ AST_SOFTHANGUP_DEV
Definition channel.h:1141
@ AST_SOFTHANGUP_HANGUP_EXEC
Definition channel.h:1174
@ AST_SOFTHANGUP_ALL
All softhangup flags.
Definition channel.h:1181
@ AST_SOFTHANGUP_TIMEOUT
Definition channel.h:1158
@ AST_SOFTHANGUP_SHUTDOWN
Definition channel.h:1151
@ AST_SOFTHANGUP_APPUNLOAD
Definition channel.h:1163
struct ast_datastore_list * ast_channel_datastores(struct ast_channel *chan)
struct ast_cc_config_params * ast_channel_get_cc_config_params(struct ast_channel *chan)
Get the CCSS parameters from a channel.
Definition channel.c:10518
void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value)
int ast_raw_answer(struct ast_channel *chan)
Answer a channel.
Definition channel.c:2688
int ast_waitfordigit_full(struct ast_channel *c, int ms, const char *breakon, int audiofd, int ctrlfd)
Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to mon...
Definition channel.c:3236
void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value)
void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
Copy the source redirecting information to the destination redirecting.
Definition channel.c:2121
void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value)
struct ast_channel * ast_channel_internal_oldest_linkedid(struct ast_channel *a, struct ast_channel *b)
Determine which channel has an older linkedid.
void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src)
Copy the source party name information to the destination party name.
Definition channel.c:1585
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value)
@ AST_FEATURE_AUTOMIXMON
Definition channel.h:1089
@ AST_FEATURE_REDIRECT
Definition channel.h:1084
@ AST_FEATURE_ATXFER
Definition channel.h:1086
@ AST_FEATURE_PARKCALL
Definition channel.h:1088
@ AST_FEATURE_AUTOMON
Definition channel.h:1087
@ AST_FEATURE_DISCONNECT
Definition channel.h:1085
@ AST_FEATURE_PLAY_WARNING
Definition channel.h:1083
int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size)
Find the appropriate CC agent type to use given a channel.
Definition channel.c:10557
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition channel.c:2389
void ast_party_redirecting_reason_free(struct ast_party_redirecting_reason *doomed)
Destroy the redirecting reason contents.
Definition channel.c:2102
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
Definition channel.c:1964
int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
Definition channel.c:5816
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
int ast_channel_alert_writable(struct ast_channel *chan)
void ast_tonepair_stop(struct ast_channel *chan)
Definition channel.c:7607
int ast_channel_has_audio_frame_or_monitor(struct ast_channel *chan)
Check if the channel has active audiohooks, active framehooks, or a monitor.
Definition channel.c:2515
Channel states.
ast_channel_state
ast_channel states
static struct ast_channel * callback(struct ast_channelstorage_instance *driver, ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
Channel Variables.
ast_media_type
Types of media.
Definition codec.h:30
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
Definition codec_g726.c:367
#define attribute_pure
Definition compiler.h:35
#define attribute_const
Definition compiler.h:41
Asterisk datastore objects.
char buf[BUFSIZE]
Definition eagi_proxy.c:66
Endpoint abstractions.
long int flag
Definition f2c.h:83
Format Capabilities API.
static const char name[]
Definition format_mp3.c:68
FrameHook Architecture.
direction
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Configuration File Parser.
Asterisk internal frame definitions.
#define AST_OPTION_T38_STATE
ast_frame_type
Frame types.
ast_control_frame_type
Internal control frame subtype field values.
unsigned int ast_callid
A set of macros to manage forward-linked lists.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Asterisk locking-related definitions:
static char url[512]
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition astobj2.h:1821
Structure to pass both assignedid values to channel drivers.
Definition channel.h:606
const char * uniqueid2
Definition channel.h:608
const char * uniqueid
Definition channel.h:607
Structure that contains information regarding a channel in a bridge.
struct ast_channel * chan
bridge configuration
Definition channel.h:1096
const char * end_sound
Definition channel.h:1107
struct timeval nexteventts
Definition channel.h:1100
const char * warning_sound
Definition channel.h:1106
struct ast_stream_topology * answer_topology
Definition channel.h:1119
void * end_bridge_callback_data
Definition channel.h:1111
struct ast_flags features_callee
Definition channel.h:1098
struct timeval feature_start_time
Definition channel.h:1101
struct ast_flags features_caller
Definition channel.h:1097
struct timeval start_time
Definition channel.h:1099
void(* end_bridge_callback)(void *)
Definition channel.h:1110
unsigned int flags
Definition channel.h:1109
void(* end_bridge_callback_data_fixup)(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator)
Definition channel.h:1115
const char * start_sound
Definition channel.h:1108
Structure that contains features information.
Structure that contains information about a bridge.
Definition bridge.h:353
Responsible for call detail data.
Definition cdr.h:281
Structure to handle passing func_channel_write info to channels via setoption.
Definition channel.h:591
ast_acf_write_fn_t write_fn
Definition channel.h:595
struct ast_channel * chan
Definition channel.h:596
const char * value
Definition channel.h:599
const char * function
Definition channel.h:597
Helper struct for initializing additional channel information on channel creation.
Definition channel.h:615
const char * tenantid
Definition channel.h:626
uint32_t version
struct ABI version
Definition channel.h:625
Structure representing a snapshot of channel state.
Structure to describe a channel "technology", ie a channel driver See for examples:
Definition channel.h:648
int(*const write)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format (see frame.h)
Definition channel.h:770
struct ast_format_cap * capabilities
Definition channel.h:652
struct ast_frame *(*const read)(struct ast_channel *chan)
Read a frame (or chain of frames from the same stream), in standard format (see frame....
Definition channel.h:754
int(*const write_stream)(struct ast_channel *chan, int stream_num, struct ast_frame *frame)
Write a frame on a specific stream, in standard format (see frame.h)
Definition channel.h:773
struct ast_frame *(*const read_stream)(struct ast_channel *chan)
Read a frame (or chain of frames from the same stream), in standard format (see frame....
Definition channel.h:767
int(*const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen)
Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTI...
Definition channel.h:791
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition channel.h:776
int(*const write_text)(struct ast_channel *chan, struct ast_frame *frame)
Write a text frame, in standard format.
Definition channel.h:809
struct ast_channel *(*const requester)(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requester - to set up call data structures (pvt's)
Definition channel.h:673
int(*const send_digit_begin)(struct ast_channel *chan, char digit)
Start sending a literal DTMF digit.
Definition channel.h:703
int(*const call)(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition channel.h:721
int(*const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan)
Fix up a channel: If a channel is consumed, this is called. Basically update any ->owner links.
Definition channel.h:794
enum ast_bridge_result(*const early_bridge)(struct ast_channel *c0, struct ast_channel *c1)
Bridge two channels of the same type together (early)
Definition channel.h:788
int(* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value)
Provide additional write items for CHANNEL() dialplan function.
Definition channel.h:821
int(*const send_image)(struct ast_channel *chan, struct ast_frame *frame)
Display or send an image.
Definition channel.h:779
int(*const send_text_data)(struct ast_channel *chan, struct ast_msg_data *data)
Display or transmit text with data.
Definition channel.h:864
int(*const hangup)(struct ast_channel *chan)
Hangup (and possibly destroy) the channel.
Definition channel.h:724
const char *const type
Definition channel.h:649
int(*const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen)
Query a given option. Called with chan locked.
Definition channel.h:800
int(*const setoption)(struct ast_channel *chan, int option, void *data, int datalen)
Set a given option. Called with chan locked.
Definition channel.h:797
int(*const answer)(struct ast_channel *chan)
Answer the channel.
Definition channel.h:727
const char *const description
Definition channel.h:650
int(*const presencestate)(const char *presence_provider, char **subtype, char **message)
Definition channel.h:696
struct ast_channel *(*const requester_with_stream_topology)(const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requester - to set up call data structures (pvt's) with stream topology.
Definition channel.h:692
int(* pre_call)(struct ast_channel *chan, const char *sub_args)
Execute a Gosub call on the channel in a technology specific way before a call is placed.
Definition channel.h:861
int(*const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration)
Stop sending a literal DTMF digit.
Definition channel.h:710
int(* func_channel_read)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
Provide additional read items for CHANNEL() dialplan function.
Definition channel.h:815
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition channel.h:803
int(*const write_video)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format.
Definition channel.h:806
struct ast_frame *(*const exception)(struct ast_channel *chan)
Handle an exception, reading a frame.
Definition channel.h:785
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition channel.h:782
int(*const answer_with_stream_topology)(struct ast_channel *chan, struct ast_stream_topology *topology)
Answer the channel with topology.
Definition channel.h:740
int(*const devicestate)(const char *device_number)
Definition channel.h:695
int(* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback)
Call a function with cc parameters as a function parameter.
Definition channel.h:847
Main Channel structure associated with a channel.
struct ast_channel_id uniqueid
char exten[AST_MAX_EXTENSION]
const char * data
const struct ast_channel_tech * tech
struct ast_endpoint * endpoint
struct ast_channel_id linkedid
enum ast_channel_state state
char context[AST_MAX_CONTEXT]
struct ast_party_caller caller
Channel Caller ID information.
Structure for a data store type.
Definition datastore.h:31
Structure for a data store object.
Definition datastore.h:64
const struct ast_datastore_info * info
Definition datastore.h:67
const char * uid
Definition datastore.h:65
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
Definition mod_format.h:101
Structure used to handle boolean flags.
Definition utils.h:220
Format capabilities structure, holds formats + preference order + etc.
Definition format_cap.c:54
Definition of a media format.
Definition format.c:43
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@239 data
void(* digit)(struct ast_channel *chan, char digit)
Definition channel.h:237
int(* generate)(struct ast_channel *chan, void *data, int len, int samples)
Definition channel.h:235
void(* release)(struct ast_channel *chan, void *data)
Definition channel.h:230
void(* write_format_change)(struct ast_channel *chan, void *data)
Definition channel.h:240
channel group info
Definition channel.h:2975
char * category
Definition channel.h:2977
struct ast_group_info::@223 group_list
struct ast_channel * chan
Definition channel.h:2976
struct ast_hangup_handler::@222 node
General jitterbuffer state.
Structure used to transport a message through the frame core.
Caller Party information.
Definition channel.h:420
struct ast_party_id priv
Private caller party ID.
Definition channel.h:432
struct ast_party_id id
Caller party ID.
Definition channel.h:422
int ani2
Automatic Number Identification 2 (Info Digits)
Definition channel.h:435
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition channel.h:429
Connected Line/Party information.
Definition channel.h:458
int source
Information about the source of an update.
Definition channel.h:484
struct ast_party_id priv
Private connected party ID.
Definition channel.h:470
struct ast_party_id id
Connected party ID.
Definition channel.h:460
int ani2
Automatic Number Identification 2 (Info Digits)
Definition channel.h:477
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition channel.h:467
Dialed/Called Party information.
Definition channel.h:380
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition channel.h:393
char * str
Subscriber phone number (Malloced)
Definition channel.h:388
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition channel.h:390
struct ast_party_dialed::@221 number
Dialed/Called number.
int transit_network_select
Transit Network Select.
Definition channel.h:399
Information needed to identify an endpoint in a call.
Definition channel.h:340
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition channel.h:346
char * tag
User-set "tag".
Definition channel.h:356
struct ast_party_name name
Subscriber name.
Definition channel.h:342
Information needed to specify a name in a call.
Definition channel.h:264
int char_set
Character set the name is using.
Definition channel.h:274
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition channel.h:279
unsigned char valid
TRUE if the name information is valid/present.
Definition channel.h:281
char * str
Subscriber name (Malloced)
Definition channel.h:266
Information needed to specify a number in a call.
Definition channel.h:291
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition channel.h:297
unsigned char valid
TRUE if the number information is valid/present.
Definition channel.h:299
char * str
Subscriber phone number (Malloced)
Definition channel.h:293
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition channel.h:295
Redirecting reason information.
Definition channel.h:503
int code
enum AST_REDIRECTING_REASON value for redirection
Definition channel.h:512
char * str
a string value for the redirecting reason
Definition channel.h:509
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition channel.h:524
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation.
Definition channel.h:541
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition channel.h:547
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition channel.h:544
struct ast_party_id priv_from
Who is redirecting the call (Sent to the party the call is redirected toward) - private representatio...
Definition channel.h:538
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition channel.h:529
int count
Number of times the call was redirected.
Definition channel.h:550
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition channel.h:532
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward)
Definition channel.h:526
struct ast_party_id priv_orig
Who originally redirected the call (Sent to the party the call is redirected toward) - private repres...
Definition channel.h:535
Information needed to specify a subaddress in a call.
Definition channel.h:309
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition channel.h:328
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition channel.h:330
char * str
Malloced subaddress string.
Definition channel.h:315
int type
Q.931 subaddress type.
Definition channel.h:322
Definition pbx.h:215
Indicate what information in ast_party_caller should be set.
Definition channel.h:442
struct ast_set_party_id priv
Definition channel.h:448
struct ast_set_party_id ani
Definition channel.h:446
struct ast_set_party_id id
Definition channel.h:444
Indicate what information in ast_party_connected_line should be set.
Definition channel.h:491
struct ast_set_party_id priv
Definition channel.h:497
struct ast_set_party_id ani
Definition channel.h:495
struct ast_set_party_id id
Definition channel.h:493
Indicate what information in ast_party_id should be set.
Definition channel.h:363
unsigned char subaddress
Definition channel.h:369
unsigned char number
Definition channel.h:367
unsigned char name
Definition channel.h:365
Indicate what information in ast_party_redirecting should be set.
Definition channel.h:557
struct ast_set_party_id priv_to
Definition channel.h:569
struct ast_set_party_id from
Definition channel.h:561
struct ast_set_party_id priv_orig
Definition channel.h:565
struct ast_set_party_id priv_from
Definition channel.h:567
struct ast_set_party_id orig
Definition channel.h:559
struct ast_set_party_id to
Definition channel.h:563
Support for dynamic strings.
Definition strings.h:623
A set of tones for a given locale.
Definition indications.h:74
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition translate.h:213
Structure for variables, used for configurations and for channel variables.
Definition file.c:70
Number structure.
const char * cid_num
Definition channel.h:1129
struct ast_variable * vars
Definition channel.h:1132
int connect_on_early_media
Definition channel.h:1128
const char * account
Definition channel.h:1131
const char * cid_name
Definition channel.h:1130
const char * exten
Definition channel.h:1126
const char * context
Definition channel.h:1125
struct ast_channel * parent_channel
Definition channel.h:1133
int value
Definition syslog.c:37
static struct test_val b
static struct test_val a
static struct test_val c
Utility functions.