Asterisk - The Open Source Telephony Project GIT-master-7988d11
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 * \warning The channel passed to this function must NOT be locked.
1658 * ast_softhangup() calls ast_rtp_instance_set_stats_vars() to set RTP QOS variables.
1659 * If this channel is in a bridge, ast_rtp_instance_set_stats_vars() will
1660 * attempt to lock the bridge peer as well as this channel. This can cause
1661 * a lock inversion if we already have this channel locked and another
1662 * thread tries to set bridge variables on the peer because it will have
1663 * locked the peer first, then this channel. For this reason, we must
1664 * NOT have the channel locked when we call ast_softhangup().
1665 *
1666 * \return Returns 0 regardless
1667 */
1668int ast_softhangup(struct ast_channel *chan, int cause);
1669
1670/*!
1671 * \brief Softly hangup up a channel (no channel lock)
1672 * \param chan channel to be soft-hung-up
1673 * \param cause an AST_SOFTHANGUP_* reason code
1674 */
1675int ast_softhangup_nolock(struct ast_channel *chan, int cause);
1676
1677/*!
1678 * \brief Clear a set of softhangup flags from a channel
1679 *
1680 * Never clear a softhangup flag from a channel directly. Instead,
1681 * use this function. This ensures that all aspects of the softhangup
1682 * process are aborted.
1683 *
1684 * \param chan the channel to clear the flag on
1685 * \param flag the flag or flags to clear
1686 */
1687void ast_channel_clear_softhangup(struct ast_channel *chan, int flag);
1688
1689/*!
1690 * \brief Set the source of the hangup in this channel and it's bridge
1691 *
1692 * \param chan channel to set the field on
1693 * \param source a string describing the source of the hangup for this channel
1694 * \param force
1695 *
1696 * \note Absolutely _NO_ channel locks should be held before calling this function.
1697 *
1698 * \since 1.8
1699 *
1700 * Hangupsource is generally the channel name that caused the bridge to be
1701 * hung up, but it can also be other things such as "dialplan/agi"
1702 * This can then be logged in the CDR or CEL
1703 */
1704void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force);
1705
1706/*! \brief Check to see if a channel is needing hang up
1707 * \param chan channel on which to check for hang up
1708 * This function determines if the channel is being requested to be hung up.
1709 * \return Returns 0 if not, or 1 if hang up is requested (including time-out).
1710 */
1711int ast_check_hangup(struct ast_channel *chan);
1712
1713int ast_check_hangup_locked(struct ast_channel *chan);
1714
1715/*! \brief This function will check if the bridge needs to be re-evaluated due to
1716 * external changes.
1717 *
1718 * \param chan Channel on which to check the unbridge_eval flag
1719 *
1720 * \return Returns 0 if the flag is down or 1 if the flag is up.
1721 */
1722int ast_channel_unbridged(struct ast_channel *chan);
1723
1724/*! \brief ast_channel_unbridged variant. Use this if the channel
1725 * is already locked prior to calling.
1726 *
1727 * \param chan Channel on which to check the unbridge flag
1728 *
1729 * \return Returns 0 if the flag is down or 1 if the flag is up.
1730 */
1732
1733/*! \brief Sets the unbridged flag and queues a NULL frame on the channel to trigger
1734 * a check by bridge_channel_wait
1735 *
1736 * \param chan Which channel is having its unbridged value set
1737 * \param value What the unbridge value is being set to
1738 */
1739void ast_channel_set_unbridged(struct ast_channel *chan, int value);
1740
1741/*! \brief Variant of ast_channel_set_unbridged. Use this if the channel
1742 * is already locked prior to calling.
1743 *
1744 * \param chan Which channel is having its unbridged value set
1745 * \param value What the unbridge value is being set to
1746 */
1747void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value);
1748
1749/*!
1750 * \brief This function will check if T.38 is active on the channel.
1751 *
1752 * \param chan Channel on which to check the unbridge_eval flag
1753 *
1754 * \return Returns 0 if the flag is down or 1 if the flag is up.
1755 */
1756int ast_channel_is_t38_active(struct ast_channel *chan);
1757
1758/*!
1759 * \brief ast_channel_is_t38_active variant. Use this if the channel
1760 * is already locked prior to calling.
1761 *
1762 * \param chan Channel on which to check the is_t38_active flag
1763 *
1764 * \return Returns 0 if the flag is down or 1 if the flag is up.
1765 */
1767
1768/*!
1769 * \brief Sets the is_t38_active flag
1770 *
1771 * \param chan Which channel is having its is_t38_active value set
1772 * \param is_t38_active Non-zero if T.38 is active
1773 */
1774void ast_channel_set_is_t38_active(struct ast_channel *chan, int is_t38_active);
1775
1776/*!
1777 * \brief Variant of ast_channel_set_is_t38_active. Use this if the channel
1778 * is already locked prior to calling.
1779 *
1780 * \param chan Which channel is having its is_t38_active value set
1781 * \param is_t38_active Non-zero if T.38 is active
1782 */
1783void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active);
1784
1785/*!
1786 * \brief Lock the given channel, then request softhangup on the channel with the given causecode
1787 * \param chan channel on which to hang up
1788 * \param causecode cause code to use (Zero if don't use cause code)
1789 */
1790void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode);
1791
1792/*!
1793 * \brief Compare a offset with the settings of when to hang a channel up
1794 * \param chan channel on which to check for hangup
1795 * \param offset offset in seconds and microseconds from current time
1796 * \retval 1
1797 * \retval 0
1798 * \retval -1
1799 * This function compares a offset from current time with the absolute time
1800 * out on a channel (when to hang up). If the absolute time out on a channel
1801 * is earlier than current time plus the offset, it returns 1, if the two
1802 * time values are equal, it return 0, otherwise, it return -1.
1803 * \since 1.6.1
1804 */
1805int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1806
1807/*!
1808 * \brief Set when to hang a channel up
1809 *
1810 * \param chan channel on which to check for hang up
1811 * \param offset offset in seconds and useconds relative to the current time of when to hang up
1812 *
1813 * This function sets the absolute time out on a channel (when to hang up).
1814 *
1815 * \pre chan is locked
1816 *
1817 * \since 1.6.1
1818 */
1819void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1820
1821/*!
1822 * \brief Answer a channel
1823 *
1824 * \param chan channel to answer
1825 *
1826 * \details
1827 * This function answers a channel and handles all necessary call
1828 * setup functions.
1829 *
1830 * \note The channel passed does not need to be locked, but is locked
1831 * by the function when needed.
1832 *
1833 * \note This function will wait up to 500 milliseconds for media to
1834 * arrive on the channel before returning to the caller, so that the
1835 * caller can properly assume the channel is 'ready' for media flow.
1836 *
1837 * \retval 0 on success
1838 * \retval non-zero on failure
1839 */
1840int ast_answer(struct ast_channel *chan);
1841
1842/*!
1843 * \brief Answer a channel, if it's not already answered.
1844 *
1845 * \param chan channel to answer
1846 *
1847 * \details See ast_answer()
1848 *
1849 * \retval 0 on success
1850 * \retval non-zero on failure
1851 */
1852int ast_auto_answer(struct ast_channel *chan);
1853
1854/*!
1855 * \brief Answer a channel
1856 *
1857 * \param chan channel to answer
1858 *
1859 * This function answers a channel and handles all necessary call
1860 * setup functions.
1861 *
1862 * \note The channel passed does not need to be locked, but is locked
1863 * by the function when needed.
1864 *
1865 * \note Unlike ast_answer(), this function will not wait for media
1866 * flow to begin. The caller should be careful before sending media
1867 * to the channel before incoming media arrives, as the outgoing
1868 * media may be lost.
1869 *
1870 * \retval 0 on success
1871 * \retval non-zero on failure
1872 */
1873int ast_raw_answer(struct ast_channel *chan);
1874
1875/*!
1876 * \brief Answer a channel passing in a stream topology
1877 * \since 18.0.0
1878 *
1879 * \param chan channel to answer
1880 * \param topology the peer's stream topology
1881 *
1882 * This function answers a channel and handles all necessary call
1883 * setup functions.
1884 *
1885 * \note The channel passed does not need to be locked, but is locked
1886 * by the function when needed.
1887 *
1888 * \note Unlike ast_answer(), this function will not wait for media
1889 * flow to begin. The caller should be careful before sending media
1890 * to the channel before incoming media arrives, as the outgoing
1891 * media may be lost.
1892 *
1893 * \note The topology is usually that of the peer channel and may be NULL.
1894 *
1895 * \retval 0 on success
1896 * \retval non-zero on failure
1897 */
1898int ast_raw_answer_with_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology);
1899
1900/*!
1901 * \brief Answer a channel, with a selectable delay before returning
1902 *
1903 * \param chan channel to answer
1904 * \param delay maximum amount of time to wait for incoming media
1905 *
1906 * This function answers a channel and handles all necessary call
1907 * setup functions.
1908 *
1909 * \note The channel passed does not need to be locked, but is locked
1910 * by the function when needed.
1911 *
1912 * \note This function will wait up to 'delay' milliseconds for media to
1913 * arrive on the channel before returning to the caller, so that the
1914 * caller can properly assume the channel is 'ready' for media flow. If
1915 * 'delay' is less than 500, the function will wait up to 500 milliseconds.
1916 *
1917 * \retval 0 on success
1918 * \retval non-zero on failure
1919 */
1920int __ast_answer(struct ast_channel *chan, unsigned int delay);
1921
1922/*!
1923 * \brief Execute a Gosub call on the channel before a call is placed.
1924 * \since 11.0
1925 *
1926 * \details
1927 * This is called between ast_request() and ast_call() to
1928 * execute a predial routine on the newly created channel.
1929 *
1930 * \param chan Channel to execute Gosub.
1931 * \param sub_args Gosub application parameter string.
1932 *
1933 * \note Absolutely _NO_ channel locks should be held before calling this function.
1934 *
1935 * \retval 0 on success.
1936 * \retval -1 on error.
1937 */
1938int ast_pre_call(struct ast_channel *chan, const char *sub_args);
1939
1940/*!
1941 * \brief Make a call
1942 * \note Absolutely _NO_ channel locks should be held before calling this function.
1943 * \param chan which channel to make the call on
1944 * \param addr destination of the call
1945 * \param timeout time to wait on for connect (Doesn't seem to be used.)
1946 * \details
1947 * Place a call, take no longer than timeout ms.
1948 * \retval 0 on success
1949 * \retval -1 on failure
1950 */
1951int ast_call(struct ast_channel *chan, const char *addr, int timeout);
1952
1953/*!
1954 * \brief Indicates condition of channel
1955 * \note Absolutely _NO_ channel locks should be held before calling this function.
1956 * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel
1957 * \param chan channel to change the indication
1958 * \param condition which condition to indicate on the channel
1959 * \return Returns 0 on success, -1 on failure
1960 */
1961int ast_indicate(struct ast_channel *chan, int condition);
1962
1963/*!
1964 * \brief Indicates condition of channel, with payload
1965 * \note Absolutely _NO_ channel locks should be held before calling this function.
1966 * \note Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class
1967 * \param chan channel to change the indication
1968 * \param condition which condition to indicate on the channel
1969 * \param data pointer to payload data
1970 * \param datalen size of payload data
1971 * \return Returns 0 on success, -1 on failure
1972 */
1973int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen);
1974
1975/* Misc stuff ------------------------------------------------ */
1976
1977/*!
1978 * \brief Wait for input on a channel
1979 * \param chan channel to wait on
1980 * \param ms length of time to wait on the channel
1981 * \details
1982 * Wait for input on a channel for a given # of milliseconds (<0 for indefinite).
1983 * \retval < 0 on failure
1984 * \retval 0 if nothing ever arrived
1985 * \retval the # of ms remaining otherwise
1986 */
1987int ast_waitfor(struct ast_channel *chan, int ms);
1988
1989/*!
1990 * \brief Should we keep this frame for later?
1991 *
1992 * There are functions such as ast_safe_sleep which will
1993 * service a channel to ensure that it does not have a
1994 * large backlog of queued frames. When this happens,
1995 * we want to hold on to specific frame types and just drop
1996 * others. This function will tell if the frame we just
1997 * read should be held onto.
1998 *
1999 * \param frame The frame we just read
2000 * \retval 1 frame should be kept
2001 * \retval 0 frame should be dropped
2002 */
2003int ast_is_deferrable_frame(const struct ast_frame *frame);
2004
2005/*!
2006 * \brief Wait for a specified amount of time, looking for hangups
2007 * \param chan channel to wait for
2008 * \param ms length of time in milliseconds to sleep. This should never be less than zero.
2009 * \details
2010 * Waits for a specified amount of time, servicing the channel as required.
2011 * \return returns -1 on hangup, otherwise 0.
2012 */
2013int ast_safe_sleep(struct ast_channel *chan, int ms);
2014
2015/*!
2016 * \brief Wait for a specified amount of time, looking for hangups, and do not generate silence
2017 * \param chan channel to wait for
2018 * \param ms length of time in milliseconds to sleep. This should never be less than zero.
2019 * \details
2020 * Waits for a specified amount of time, servicing the channel as required.
2021 * \return returns -1 on hangup, otherwise 0.
2022 * \note Unlike ast_safe_sleep this will not generate silence if Asterisk is configured to do so.
2023 */
2024int ast_safe_sleep_without_silence(struct ast_channel *chan, int ms);
2025
2026/*!
2027 * \brief Wait for a specified amount of time, looking for hangups and a condition argument
2028 * \param chan channel to wait for
2029 * \param ms length of time in milliseconds to sleep.
2030 * \param cond a function pointer for testing continue condition
2031 * \param data argument to be passed to the condition test function
2032 * \return returns -1 on hangup, otherwise 0.
2033 * \details
2034 * Waits for a specified amount of time, servicing the channel as required. If cond
2035 * returns 0, this function returns.
2036 */
2037int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data );
2038
2039/*!
2040 * \brief Waits for activity on a group of channels
2041 * \param c an array of pointers to channels
2042 * \param n number of channels that are to be waited upon
2043 * \param fds an array of fds to wait upon
2044 * \param nfds the number of fds to wait upon
2045 * \param exception exception flag
2046 * \param outfd fd that had activity on it
2047 * \param ms On invocation, max wait time. Upon returning, how long the wait
2048 * actually was (in/out parameter).
2049 * \details
2050 * Big momma function here. Wait for activity on any of the n channels, or any of the nfds
2051 * file descriptors. -1 can be passed as the ms timeout to wait forever, 0 to
2052 * return instantly if theres no activity immediantely available.
2053 * \return Returns the channel with activity, or NULL on error or if an FD
2054 * came first. If the FD came first, it will be returned in outfd, otherwise, outfd
2055 * will be -1
2056 */
2057struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n,
2058 int *fds, int nfds, int *exception, int *outfd, int *ms);
2059
2060/*!
2061 * \brief Waits for input on a group of channels
2062 * Wait for input on an array of channels for a given # of milliseconds.
2063 * \return Return channel with activity, or NULL if none has activity.
2064 * \param chan an array of pointers to channels
2065 * \param n number of channels that are to be waited upon
2066 * \param ms time "ms" is modified in-place, if applicable
2067 */
2068struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms);
2069
2070/*!
2071 * \brief Waits for input on an fd
2072 * \note This version works on fd's only. Be careful with it.
2073 */
2074int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);
2075
2076
2077/*!
2078 * \brief Reads a frame
2079 *
2080 * \param chan channel to read a frame from
2081 *
2082 * \return Returns a frame, or NULL on error. If it returns NULL, you
2083 * best just stop reading frames and assume the channel has been
2084 * disconnected.
2085 *
2086 * \note This function will filter frames received from the channel so
2087 * that only frames from the default stream for each media type
2088 * are returned. All other media frames from other streams will
2089 * be absorbed internally and a NULL frame returned instead.
2090 */
2091struct ast_frame *ast_read(struct ast_channel *chan);
2092
2093/*!
2094 * \brief Reads a frame, but does not filter to just the default streams
2095 *
2096 * \param chan channel to read a frame from
2097 *
2098 * \return Returns a frame, or NULL on error. If it returns NULL, you
2099 * best just stop reading frames and assume the channel has been
2100 * disconnected.
2101 *
2102 * \note This function will not perform any filtering and will return
2103 * media frames from all streams on the channel. To determine which
2104 * stream a frame originated from the stream_num on it can be
2105 * examined.
2106 */
2107struct ast_frame *ast_read_stream(struct ast_channel *chan);
2108
2109/*!
2110 * \brief Reads a frame, returning AST_FRAME_NULL frame if audio.
2111 * \param chan channel to read a frame from
2112 * \return Returns a frame, or NULL on error. If it returns NULL, you
2113 * best just stop reading frames and assume the channel has been
2114 * disconnected.
2115 * \note Audio is replaced with AST_FRAME_NULL to avoid
2116 * transcode when the resulting audio is not necessary.
2117 */
2118struct ast_frame *ast_read_noaudio(struct ast_channel *chan);
2119
2120/*!
2121 * \brief Reads a frame, but does not filter to just the default streams,
2122 * returning AST_FRAME_NULL frame if audio.
2123 *
2124 * \param chan channel to read a frame from
2125 *
2126 * \return Returns a frame, or NULL on error. If it returns NULL, you
2127 * best just stop reading frames and assume the channel has been
2128 * disconnected.
2129 *
2130 * \note This function will not perform any filtering and will return
2131 * media frames from all streams on the channel. To determine which
2132 * stream a frame originated from the stream_num on it can be
2133 * examined.
2134 *
2135 * \note Audio is replaced with AST_FRAME_NULL to avoid
2136 * transcode when the resulting audio is not necessary.
2137 */
2138struct ast_frame *ast_read_stream_noaudio(struct ast_channel *chan);
2139
2140/*!
2141 * \brief Write a frame to a channel
2142 * This function writes the given frame to the indicated channel.
2143 * \param chan destination channel of the frame
2144 * \param frame frame that will be written
2145 * \return It returns 0 on success, -1 on failure.
2146 */
2147int ast_write(struct ast_channel *chan, struct ast_frame *frame);
2148
2149/*!
2150 * \brief Write video frame to a channel
2151 * This function writes the given frame to the indicated channel.
2152 * \param chan destination channel of the frame
2153 * \param frame frame that will be written
2154 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
2155 */
2156int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);
2157
2158/*!
2159 * \brief Write text frame to a channel
2160 * This function writes the given frame to the indicated channel.
2161 * \param chan destination channel of the frame
2162 * \param frame frame that will be written
2163 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
2164 */
2165int ast_write_text(struct ast_channel *chan, struct ast_frame *frame);
2166
2167/*!
2168 * \brief Write a frame to a stream
2169 * This function writes the given frame to the indicated stream on the channel.
2170 * \param chan destination channel of the frame
2171 * \param stream_num destination stream on the channel
2172 * \param frame frame that will be written
2173 * \return It returns 0 on success, -1 on failure.
2174 * \note If -1 is provided as the stream number and a media frame is provided the
2175 * function will write to the default stream of the type of media.
2176 */
2177int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *frame);
2178
2179/*! \brief Send empty audio to prime a channel driver */
2180int ast_prod(struct ast_channel *chan);
2181
2182/*!
2183 * \brief Set specific read path on channel.
2184 * \since 13.4.0
2185 *
2186 * \param chan Channel to setup read path.
2187 * \param raw_format Format to expect from the channel driver.
2188 * \param core_format What the core wants to read.
2189 *
2190 * \pre chan is locked
2191 *
2192 * \retval 0 on success.
2193 * \retval -1 on error.
2194 */
2195int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format);
2196
2197/*!
2198 * \brief Set specific write path on channel.
2199 * \since 13.13.0
2200 *
2201 * \param chan Channel to setup write path.
2202 * \param core_format What the core wants to write.
2203 * \param raw_format Raw write format.
2204 *
2205 * \pre chan is locked
2206 *
2207 * \retval 0 on success.
2208 * \retval -1 on error.
2209 */
2210int ast_set_write_format_path(struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format);
2211
2212/*!
2213 * \brief Sets read format on channel chan from capabilities
2214 * Set read format for channel to whichever component of "format" is best.
2215 * \param chan channel to change
2216 * \param formats new formats to pick from for reading
2217 * \return Returns 0 on success, -1 on failure
2218 */
2220
2221/*!
2222 * \brief Sets read format on channel chan
2223 * \param chan channel to change
2224 * \param format format to set for reading
2225 * \return Returns 0 on success, -1 on failure
2226 */
2227int ast_set_read_format(struct ast_channel *chan, struct ast_format *format);
2228
2229/*!
2230 * \brief Sets write format on channel chan
2231 * Set write format for channel to whichever component of "format" is best.
2232 * \param chan channel to change
2233 * \param formats new formats to pick from for writing
2234 * \return Returns 0 on success, -1 on failure
2235 */
2237
2238/*!
2239 * \brief Sets write format on channel chan
2240 * \param chan channel to change
2241 * \param format format to set for writing
2242 * \return Returns 0 on success, -1 on failure
2243 */
2244int ast_set_write_format(struct ast_channel *chan, struct ast_format *format);
2245
2246/*!
2247 * \brief Sets write format for a channel.
2248 * All internal data will than be handled in an interleaved format. (needed by binaural opus)
2249 *
2250 * \param chan channel to change
2251 * \param format format to set for writing
2252 * \return Returns 0 on success, -1 on failure
2253 */
2254int ast_set_write_format_interleaved_stereo(struct ast_channel *chan, struct ast_format *format);
2255
2256/*!
2257 * \brief Sends text to a channel
2258 *
2259 * \param chan channel to act upon
2260 * \param text string of text to send on the channel
2261 *
2262 * \details
2263 * Write text to a display on a channel
2264 *
2265 * \note The channel does not need to be locked before calling this function.
2266 *
2267 * \retval 0 on success
2268 * \retval -1 on failure
2269 */
2270int ast_sendtext(struct ast_channel *chan, const char *text);
2271
2272/*!
2273 * \brief Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback
2274 * \since 13.22.0
2275 * \since 15.5.0
2276 *
2277 * \param chan channel to act upon
2278 * \param msg ast_msg_data structure
2279 *
2280 * \details
2281 * Write text to a display on a channel. If the channel driver doesn't support the
2282 * send_text_data callback. then the original send_text callback will be used if
2283 * available.
2284 *
2285 * \note The channel does not need to be locked before calling this function.
2286 *
2287 * \retval 0 on success
2288 * \retval -1 on failure
2289 */
2290int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg);
2291
2292/*!
2293 * \brief Receives a text character from a channel
2294 * \param chan channel to act upon
2295 * \param timeout timeout in milliseconds (0 for infinite wait)
2296 * \details
2297 * Read a char of text from a channel
2298 * \return 0 on success, -1 on failure
2299 */
2300int ast_recvchar(struct ast_channel *chan, int timeout);
2301
2302/*!
2303 * \brief End sending an MF digit to a channel.
2304 * \param chan channel to act upon
2305 * \return Returns 0 on success, -1 on failure
2306 */
2307int ast_senddigit_mf_end(struct ast_channel *chan);
2308
2309/*!
2310 * \brief Send an MF digit to a channel.
2311 *
2312 * \param chan channel to act upon
2313 * \param digit the MF digit to send, encoded in ASCII
2314 * \param duration the duration of a numeric digit ending in ms
2315 * \param durationkp the duration of a KP digit ending in ms
2316 * \param durationst the duration of a ST, STP, ST2P, or ST3P digit ending in ms
2317 * \param is_external 1 if called by a thread that is not the channel's media
2318 * handler thread, 0 if called by the channel's media handler
2319 * thread.
2320 *
2321 * \return 0 on success, -1 on failure
2322 */
2323int ast_senddigit_mf(struct ast_channel *chan, char digit, unsigned int duration,
2324 unsigned int durationkp, unsigned int durationst, int is_external);
2325
2326/*!
2327 * \brief Send a DTMF digit to a channel.
2328 *
2329 * \param chan channel to act upon
2330 * \param digit the DTMF digit to send, encoded in ASCII
2331 * \param duration the duration of the digit ending in ms
2332 *
2333 * \pre This must only be called by the channel's media handler thread.
2334 *
2335 * \return 0 on success, -1 on failure
2336 */
2337int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
2338
2339/*!
2340 * \brief Send a DTMF digit to a channel from an external thread.
2341 *
2342 * \param chan channel to act upon
2343 * \param digit the DTMF digit to send, encoded in ASCII
2344 * \param duration the duration of the digit ending in ms
2345 *
2346 * \pre This must only be called by threads that are not the channel's
2347 * media handler thread.
2348 *
2349 * \return 0 on success, -1 on failure
2350 */
2351int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration);
2352
2353/*!
2354 * \brief Send an MF digit to a channel.
2355 * \param chan channel to act upon
2356 * \param digit the MF digit to send, encoded in ASCII
2357 * \return 0 on success, -1 on failure
2358 */
2359int ast_senddigit_mf_begin(struct ast_channel *chan, char digit);
2360
2361/*!
2362 * \brief Send a DTMF digit to a channel.
2363 * \param chan channel to act upon
2364 * \param digit the DTMF digit to send, encoded in ASCII
2365 * \return 0 on success, -1 on failure
2366 */
2367int ast_senddigit_begin(struct ast_channel *chan, char digit);
2368
2369/*!
2370 * \brief Send a DTMF digit to a channel.
2371 * \param chan channel to act upon
2372 * \param digit the DTMF digit to send, encoded in ASCII
2373 * \param duration the duration of the digit ending in ms
2374 * \return Returns 0 on success, -1 on failure
2375 */
2376int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration);
2377
2378/*!
2379 * \brief Receives a text string from a channel
2380 * Read a string of text from a channel
2381 * \param chan channel to act upon
2382 * \param timeout timeout in milliseconds (0 for infinite wait)
2383 * \return the received text, or NULL to signify failure.
2384 */
2385char *ast_recvtext(struct ast_channel *chan, int timeout);
2386
2387/*!
2388 * \brief Waits for a digit
2389 * \param c channel to wait for a digit on
2390 * \param ms how many milliseconds to wait (<0 for indefinite).
2391 * \return Returns <0 on error, 0 on no entry, and the digit on success.
2392 */
2393int ast_waitfordigit(struct ast_channel *c, int ms);
2394
2395/*!
2396 * \brief Wait for a digit
2397 * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
2398 * \param c channel to wait for a digit on
2399 * \param ms how many milliseconds to wait (<0 for indefinite).
2400 * \param breakon string of DTMF digits to break upon or NULL for any.
2401 * \param audiofd audio file descriptor to write to if audio frames are received
2402 * \param ctrlfd control file descriptor to monitor for reading
2403 * \return Returns 1 if ctrlfd becomes available
2404 */
2405int ast_waitfordigit_full(struct ast_channel *c, int ms, const char *breakon, int audiofd, int ctrlfd);
2406
2407/*!
2408 * \brief Reads multiple digits
2409 * \param c channel to read from
2410 * \param s string to read in to. Must be at least the size of your length
2411 * \param len how many digits to read (maximum)
2412 * \param timeout how long to timeout between digits
2413 * \param rtimeout timeout to wait on the first digit
2414 * \param enders digits to end the string
2415 * \details
2416 * Read in a digit string "s", max length "len", maximum timeout between
2417 * digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout
2418 * for the first digit.
2419 * \return Returns 0 on normal return, or 1 on a timeout. In the case of
2420 * a timeout, any digits that were read before the timeout will still be available in s.
2421 * RETURNS 2 in full version when ctrlfd is available, NOT 1
2422 */
2423int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders);
2424int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd);
2425
2426/*! \brief Report DTMF on channel 0 */
2427#define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0)
2428/*! \brief Report DTMF on channel 1 */
2429#define AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1)
2430
2431
2432/*!
2433 * \brief Make the frame formats of two channels compatible.
2434 *
2435 * \param chan First channel to make compatible. Should be the calling party.
2436 * \param peer Other channel to make compatible. Should be the called party.
2437 *
2438 * \note Absolutely _NO_ channel locks should be held before calling this function.
2439 *
2440 * \details
2441 * Set two channels to compatible frame formats in both
2442 * directions. The path from peer to chan is made compatible
2443 * first to allow for in-band audio in case the other direction
2444 * cannot be made compatible.
2445 *
2446 * \retval 0 on success.
2447 * \retval -1 on error.
2448 */
2449int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer);
2450
2451/*!
2452 * \brief Bridge two channels together (early)
2453 * \param c0 first channel to bridge
2454 * \param c1 second channel to bridge
2455 * \details
2456 * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
2457 * \return Returns 0 on success and -1 if it could not be done
2458 */
2459int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
2460
2461/*!
2462 * \brief Gives the string form of a given cause code.
2463 *
2464 * \param cause cause to get the description of
2465 * \return the text form of the binary cause code given
2466 */
2467const char *ast_cause2str(int cause) attribute_pure;
2468
2469/*!
2470 * \brief Convert the string form of a cause code to a number
2471 *
2472 * \param name string form of the cause
2473 * \return the cause code
2474 */
2475int ast_str2cause(const char *name) attribute_pure;
2476
2477/*!
2478 * \brief Gives the string form of a given channel state
2479 *
2480 * \param state state to get the name of
2481 * \return the text form of the binary state given
2482 *
2483 * \note This function is not reentrant.
2484 */
2485const char *ast_state2str(enum ast_channel_state state);
2486
2487/*!
2488 * \brief Gives the string form of a given transfer capability
2489 *
2490 * \param transfercapability transfer capability to get the name of
2491 * \return the text form of the binary transfer capability
2492 */
2493char *ast_transfercapability2str(int transfercapability) attribute_const;
2494
2495/*
2496 * Options: Some low-level drivers may implement "options" allowing fine tuning of the
2497 * low level channel. See frame.h for options. Note that many channel drivers may support
2498 * none or a subset of those features, and you should not count on this if you want your
2499 * asterisk application to be portable. They're mainly useful for tweaking performance
2500 */
2501
2502/*!
2503 * \brief Sets an option on a channel
2504 *
2505 * \param channel channel to set options on
2506 * \param option option to change
2507 * \param data data specific to option
2508 * \param datalen length of the data
2509 * \param block blocking or not
2510 * \details
2511 * Set an option on a channel (see frame.h), optionally blocking awaiting the reply
2512 * \return 0 on success and -1 on failure
2513 */
2514int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
2515
2516/*!
2517 * \brief Checks the value of an option
2518 *
2519 * Query the value of an option
2520 * Works similarly to setoption except only reads the options.
2521 */
2522int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block);
2523
2524/*!
2525 * \brief Checks for HTML support on a channel
2526 * \return 0 if channel does not support HTML or non-zero if it does
2527 */
2528int ast_channel_supports_html(struct ast_channel *channel);
2529
2530/*!
2531 * \brief Sends HTML on given channel
2532 * Send HTML or URL on link.
2533 * \return 0 on success or -1 on failure
2534 */
2535int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen);
2536
2537/*!
2538 * \brief Sends a URL on a given link
2539 * Send URL on link.
2540 * \return 0 on success or -1 on failure
2541 */
2542int ast_channel_sendurl(struct ast_channel *channel, const char *url);
2543
2544/*!
2545 * \brief Defers DTMF so that you only read things like hangups and audio.
2546 * \return non-zero if channel was already DTMF-deferred or
2547 * 0 if channel is just now being DTMF-deferred
2548 */
2549int ast_channel_defer_dtmf(struct ast_channel *chan);
2550
2551/*! Undo defer. ast_read will return any DTMF characters that were queued */
2552void ast_channel_undefer_dtmf(struct ast_channel *chan);
2553
2554/*! \return number of channels available for lookup */
2555int ast_active_channels(void);
2556
2557/*! \return the number of channels not yet destroyed */
2558int ast_undestroyed_channels(void);
2559
2560/*! Activate a given generator */
2561int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);
2562
2563/*! Deactivate an active generator */
2564void ast_deactivate_generator(struct ast_channel *chan);
2565
2566/*!
2567 * \since 13.27.0
2568 * \since 16.4.0
2569 * \brief Obtain how long it's been, in milliseconds, since the channel was created
2570 *
2571 * \param chan The channel object
2572 *
2573 * \retval 0 if the time value cannot be computed (or you called this really fast)
2574 * \retval The number of milliseconds since channel creation
2575 */
2576int64_t ast_channel_get_duration_ms(struct ast_channel *chan);
2577
2578/*!
2579 * \since 12
2580 * \brief Obtain how long the channel since the channel was created
2581 *
2582 * \param chan The channel object
2583 *
2584 * \retval 0 if the time value cannot be computed (or you called this really fast)
2585 * \retval The number of seconds the channel has been up
2586 */
2587int ast_channel_get_duration(struct ast_channel *chan);
2588
2589/*!
2590 * \since 13.27.0
2591 * \since 16.4.0
2592 * \brief Obtain how long it has been since the channel was answered in ms
2593 *
2594 * \param chan The channel object
2595 *
2596 * \retval 0 if the channel isn't answered (or you called this really fast)
2597 * \retval The number of milliseconds the channel has been up
2598 */
2599int64_t ast_channel_get_up_time_ms(struct ast_channel *chan);
2600
2601/*!
2602 * \since 12
2603 * \brief Obtain how long it has been since the channel was answered
2604 *
2605 * \param chan The channel object
2606 *
2607 * \retval 0 if the channel isn't answered (or you called this really fast)
2608 * \retval The number of seconds the channel has been up
2609 */
2610int ast_channel_get_up_time(struct ast_channel *chan);
2611
2612/*!
2613 * \brief Set caller ID number, name and ANI and generate AMI event.
2614 *
2615 * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead.
2616 * \note The channel does not need to be locked before calling this function.
2617 */
2618void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani);
2619
2620/*!
2621 * \brief Set the caller id information in the Asterisk channel
2622 * \since 1.8
2623 *
2624 * \param chan Asterisk channel to set caller id information
2625 * \param caller Caller id information
2626 * \param update What caller information to update. NULL if all.
2627 *
2628 * \note The channel does not need to be locked before calling this function.
2629 */
2630void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2631
2632/*!
2633 * \brief Set the caller id information in the Asterisk channel and generate an AMI event
2634 * if the caller id name or number changed.
2635 * \since 1.8
2636 *
2637 * \param chan Asterisk channel to set caller id information
2638 * \param caller Caller id information
2639 * \param update What caller information to update. NULL if all.
2640 *
2641 * \note The channel does not need to be locked before calling this function.
2642 */
2643void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2644
2645/*! Set the file descriptor on the channel */
2646void ast_channel_set_fd(struct ast_channel *chan, int which, int fd);
2647
2648/*! Start a tone going */
2649int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2650/*! Stop a tone from playing */
2651void ast_tonepair_stop(struct ast_channel *chan);
2652/*! Play a tone pair for a given amount of time */
2653int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2654
2655/*!
2656 * \brief Automatically service a channel for us...
2657 *
2658 * \retval 0 success
2659 * \retval -1 failure, or the channel is already being autoserviced
2660 */
2661int ast_autoservice_start(struct ast_channel *chan);
2662
2663/*!
2664 * \brief Stop servicing a channel for us...
2665 *
2666 * \note if chan is locked prior to calling ast_autoservice_stop, it
2667 * is likely that there will be a deadlock between the thread that calls
2668 * ast_autoservice_stop and the autoservice thread. It is important
2669 * that chan is not locked prior to this call
2670 *
2671 * \param chan
2672 * \retval 0 success
2673 * \retval -1 error, or the channel has been hungup
2674 */
2675int ast_autoservice_stop(struct ast_channel *chan);
2676
2677/*!
2678 * \brief Put chan into autoservice while hanging up peer.
2679 * \since 11.0
2680 *
2681 * \param chan Chan to put into autoservice.
2682 * \param peer Chan to run hangup handlers and hangup.
2683 */
2684void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer);
2685
2686/*!
2687 * \brief Ignore certain frame types
2688 * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames
2689 * while a channel is in autoservice and queue them up when taken out of
2690 * autoservice. When this is not desireable, this API may be used to
2691 * cause the channel to ignore those frametypes after the channel is put
2692 * into autoservice, but before autoservice is stopped.
2693 * \retval 0 success
2694 * \retval -1 channel is not in autoservice
2695 */
2696int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype);
2697
2698/*!
2699 * \brief Enable or disable timer ticks for a channel
2700 *
2701 * \param c channel
2702 * \param rate number of timer ticks per second
2703 * \param func callback function
2704 * \param data
2705 *
2706 * \details
2707 * If timers are supported, force a scheduled expiration on the
2708 * timer fd, at which point we call the callback function / data
2709 *
2710 * \note Call this function with a rate of 0 to turn off the timer ticks
2711 *
2712 * \version 1.6.1 changed samples parameter to rate, accommodates new timing methods
2713 */
2714int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data);
2715int ast_settimeout_full(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data, unsigned int is_ao2_obj);
2716
2717/*!
2718 * \brief Transfer a channel (if supported).
2719 * \retval -1 on error
2720 * \retval 0 if not supported
2721 * \retval 1 if supported and requested
2722 * \param chan current channel
2723 * \param dest destination extension for transfer
2724 */
2725int ast_transfer(struct ast_channel *chan, char *dest);
2726
2727/*!
2728 * \brief Transfer a channel (if supported) receieve protocol result.
2729 * \retval -1 on error
2730 * \retval 0 if not supported
2731 * \retval 1 if supported and requested
2732 * \param chan channel to transfer
2733 * \param dest destination extension to transfer to
2734 * \param protocol protocol is the protocol result
2735 * SIP example, 0=success, 3xx-6xx is SIP error code
2736 */
2737int ast_transfer_protocol(struct ast_channel *chan, char *dest, int *protocol);
2738
2739/*!
2740 * \brief Inherits channel variable from parent to child channel
2741 * \param parent Parent channel
2742 * \param child Child channel
2743 *
2744 * \details
2745 * Scans all channel variables in the parent channel, looking for those
2746 * that should be copied into the child channel.
2747 * Variables whose names begin with a single '_' are copied into the
2748 * child channel with the prefix removed.
2749 * Variables whose names begin with '__' are copied into the child
2750 * channel with their names unchanged.
2751 */
2752void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child);
2753
2754/*!
2755 * \brief adds a list of channel variables to a channel
2756 * \param chan the channel
2757 * \param vars a linked list of variables
2758 *
2759 * \pre chan is locked
2760 *
2761 * \details
2762 * Variable names can be for a regular channel variable or a dialplan function
2763 * that has the ability to be written to.
2764 */
2765void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars);
2766
2767/*!
2768 * \brief An opaque 'object' structure use by silence generators on channels.
2769 */
2771
2772/*!
2773 * \brief Starts a silence generator on the given channel.
2774 * \param chan The channel to generate silence on
2775 * \return An ast_silence_generator pointer, or NULL if an error occurs
2776 *
2777 * \details
2778 * This function will cause SLINEAR silence to be generated on the supplied
2779 * channel until it is disabled; if the channel cannot be put into SLINEAR
2780 * mode then the function will fail.
2781 *
2782 * \note
2783 * The pointer returned by this function must be preserved and passed to
2784 * ast_channel_stop_silence_generator when you wish to stop the silence
2785 * generation.
2786 */
2788
2789/*!
2790 * \brief Stops a previously-started silence generator on the given channel.
2791 * \param chan The channel to operate on
2792 * \param state The ast_silence_generator pointer return by a previous call to
2793 * ast_channel_start_silence_generator.
2794 *
2795 * \details
2796 * This function will stop the operating silence generator and return the channel
2797 * to its previous write format.
2798 */
2800
2801/*!
2802 * \brief Determine which channel has an older linkedid
2803 * \param a First channel
2804 * \param b Second channel
2805 * \return Returns an ast_channel structure that has oldest linkedid
2806 */
2808
2809/*!
2810 * \brief Copy the full linkedid channel id structure from one channel to another
2811 * \param dest Destination to copy linkedid to
2812 * \param source Source channel to copy linkedid from
2813 */
2814void ast_channel_internal_copy_linkedid(struct ast_channel *dest, struct ast_channel *source);
2815
2816/*!
2817 * \brief Swap uniqueid and linkedid beteween two channels
2818 * \param a First channel
2819 * \param b Second channel
2820 *
2821 * \note
2822 * This is used in masquerade to exchange identities
2823 */
2825
2826/*!
2827 * \brief Swap topics beteween two channels
2828 * \param a First channel
2829 * \param b Second channel
2830 *
2831 * \note
2832 * This is used in masquerade to exchange topics for message routing
2833 */
2835
2836/*!
2837 * \brief Swap endpoint_forward between two channels
2838 * \param a First channel
2839 * \param b Second channel
2840 *
2841 * \note
2842 * This is used in masquerade to exchange endpoint details if one of the two or both
2843 * the channels were created with endpoint
2844 */
2846
2847/*!
2848 * \brief Swap snapshots beteween two channels
2849 * \param a First channel
2850 * \param b Second channel
2851 *
2852 * \note
2853 * This is used in masquerade to exchange snapshots
2854 */
2856
2857/*!
2858 * \brief Swap endpoints between two channels
2859 * \param a First channel
2860 * \param b Second channel
2861 *
2862 * \note
2863 * This is used in masquerade to exchange endpoints
2864 */
2866
2867/*!
2868 * \brief Set uniqueid and linkedid string value only (not time)
2869 * \param chan The channel to set the uniqueid to
2870 * \param uniqueid The uniqueid to set
2871 * \param linkedid The linkedid to set
2872 *
2873 * \note
2874 * This is used only by ast_cel_fabricate_channel_from_event()
2875 * to create a temporary fake channel - time values are invalid
2876 */
2877void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid);
2878
2879/* Misc. functions below */
2880
2881/*!
2882 * \brief if fd is a valid descriptor, set *pfd with the descriptor
2883 * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the
2884 * return value to the index into the array)
2885 */
2886static inline int ast_add_fd(struct pollfd *pfd, int fd)
2887{
2888 pfd->fd = fd;
2889 pfd->events = POLLIN | POLLPRI;
2890 return fd >= 0;
2891}
2892
2893/*! \brief Helper function for migrating select to poll */
2894static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
2895{
2896 int x;
2897 int dummy = 0;
2898
2899 if (fd < 0)
2900 return 0;
2901 if (!start)
2902 start = &dummy;
2903 for (x = *start; x < maximum; x++)
2904 if (pfds[x].fd == fd) {
2905 if (x == *start)
2906 (*start)++;
2907 return pfds[x].revents;
2908 }
2909 return 0;
2910}
2911
2912/*!
2913 * \brief Retrieves the current T38 state of a channel
2914 *
2915 * \note Absolutely _NO_ channel locks should be held before calling this function.
2916 */
2918{
2920 int datalen = sizeof(state);
2921
2923
2924 return state;
2925}
2926
2927/*!
2928 * \brief Set the blocking indication on the channel.
2929 *
2930 * \details
2931 * Indicate that the thread handling the channel is about to do a blocking
2932 * operation to wait for media on the channel. (poll, read, or write)
2933 *
2934 * Masquerading and ast_queue_frame() use this indication to wake up the thread.
2935 *
2936 * \pre The channel needs to be locked
2937 */
2938#define CHECK_BLOCKING(c) \
2939 do { \
2940 if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) { \
2941 /* This should not happen as there should only be one thread handling a channel's media at a time. */ \
2942 ast_log(LOG_DEBUG, "Thread LWP %d is blocking '%s', already blocked by thread LWP %d in procedure %s\n", \
2943 ast_get_tid(), ast_channel_name(c), \
2944 ast_channel_blocker_tid(c), ast_channel_blockproc(c)); \
2945 ast_assert(0); \
2946 } \
2947 ast_channel_blocker_tid_set((c), ast_get_tid()); \
2948 ast_channel_blocker_set((c), pthread_self()); \
2949 ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
2950 ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
2951 } while (0)
2952
2953ast_group_t ast_get_group(const char *s);
2954
2955/*! \brief Print call and pickup groups into buffer */
2956char *ast_print_group(char *buf, int buflen, ast_group_t group);
2957
2958/*! \brief Opaque struct holding a namedgroups set, i.e. a set of group names */
2959struct ast_namedgroups;
2960
2961/*! \brief Create an ast_namedgroups set with group names from comma separated string */
2962struct ast_namedgroups *ast_get_namedgroups(const char *s);
2963struct ast_namedgroups *ast_unref_namedgroups(struct ast_namedgroups *groups);
2964struct ast_namedgroups *ast_ref_namedgroups(struct ast_namedgroups *groups);
2965/*! \brief Return TRUE if group a and b contain at least one common groupname */
2966int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups *b);
2967
2968/*! \brief Print named call groups and named pickup groups */
2969char *ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups);
2970
2971/*! \brief return an ast_variable list of channeltypes */
2973
2974/*!
2975 * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
2976 * \param reason The integer argument, usually taken from AST_CONTROL_ macros
2977 * \return char pointer explaining the code
2978 */
2979const char *ast_channel_reason2str(int reason);
2980
2981/*! \brief channel group info */
2988
2989#define ast_channel_lock(chan) ao2_lock(chan)
2990#define ast_channel_unlock(chan) ao2_unlock(chan)
2991#define ast_channel_trylock(chan) ao2_trylock(chan)
2992
2993/*!
2994 * \brief Lock two channels.
2995 */
2996#define ast_channel_lock_both(chan1, chan2) do { \
2997 ast_channel_lock(chan1); \
2998 while (ast_channel_trylock(chan2)) { \
2999 ast_channel_unlock(chan1); \
3000 sched_yield(); \
3001 ast_channel_lock(chan1); \
3002 } \
3003 } while (0)
3004
3005/*!
3006 * \brief Increase channel reference count
3007 *
3008 * \param c the channel
3009 *
3010 * \retval c always
3011 *
3012 * \since 1.8
3013 */
3014#define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); })
3015
3016/*!
3017 * \brief Decrease channel reference count
3018 *
3019 * \param c the channel
3020 *
3021 * \retval NULL always
3022 *
3023 * \since 1.8
3024 */
3025#define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
3026
3027/*!
3028 * \brief Cleanup a channel reference
3029 *
3030 * \param c the channel (NULL tolerant)
3031 *
3032 * \retval NULL always
3033 *
3034 * \since 12.0.0
3035 */
3036#define ast_channel_cleanup(c) ({ ao2_cleanup(c); (struct ast_channel *) (NULL); })
3037
3038/*! Channel Iterating @{ */
3039
3040/*!
3041 * \brief A channel iterator
3042 *
3043 * This is an opaque type.
3044 */
3046
3047/*!
3048 * \brief Destroy a channel iterator
3049 *
3050 * \param i the itereator to destroy
3051 *
3052 * \details
3053 * This function is used to destroy a channel iterator that was retrieved by
3054 * using one of the channel_iterator_xxx_new() functions.
3055 *
3056 * \retval NULL for convenience to clear out the pointer to the iterator that
3057 * was just destroyed.
3058 *
3059 * \since 1.8
3060 */
3062
3063/*!
3064 * \brief Create a new channel iterator based on extension
3065 *
3066 * \param exten The extension that channels must be in
3067 * \param context The context that channels must be in
3068 *
3069 * \details
3070 * After creating an iterator using this function, the ast_channel_iterator_next()
3071 * function can be used to iterate through all channels that are currently
3072 * in the specified context and extension.
3073 *
3074 * \note You must call ast_channel_iterator_destroy() when done.
3075 *
3076 * \retval NULL on failure
3077 * \retval a new channel iterator based on the specified parameters
3078 *
3079 * \since 1.8
3080 */
3081struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context);
3082
3083/*!
3084 * \brief Create a new channel iterator based on name
3085 *
3086 * \param name channel name or channel uniqueid to match
3087 * \param name_len number of characters in the channel name to match on. This
3088 * would be used to match based on name prefix. If matching on the full
3089 * channel name is desired, then this parameter should be 0.
3090 *
3091 * \details
3092 * After creating an iterator using this function, the ast_channel_iterator_next()
3093 * function can be used to iterate through all channels that exist that have
3094 * the specified name or name prefix.
3095 *
3096 * \note You must call ast_channel_iterator_destroy() when done.
3097 *
3098 * \retval NULL on failure
3099 * \retval a new channel iterator based on the specified parameters
3100 *
3101 * \since 1.8
3102 */
3103struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name, size_t name_len);
3104
3105/*!
3106 * \brief Create a new channel iterator
3107 *
3108 * \details
3109 * After creating an iterator using this function, the ast_channel_iterator_next()
3110 * function can be used to iterate through all channels that exist.
3111 *
3112 * \note You must call ast_channel_iterator_destroy() when done.
3113 *
3114 * \retval NULL on failure
3115 * \retval a new channel iterator
3116 *
3117 * \since 1.8
3118 */
3120
3121/*!
3122 * \brief Get the next channel for a channel iterator
3123 *
3124 * \param i the channel iterator that was created using one of the
3125 * channel_iterator_xxx_new() functions.
3126 *
3127 * \details
3128 * This function should be used to iterate through all channels that match a
3129 * specified set of parameters that were provided when the iterator was created.
3130 *
3131 * \retval the next channel that matches the parameters used when the iterator
3132 * was created.
3133 * \retval NULL if no more channels match the iterator parameters.
3134 *
3135 * \since 1.8
3136 */
3138
3139/*! @} End channel iterator definitions. */
3140
3141/*! @{ Channel search functions */
3142
3143/*!
3144* \warning Absolutely _NO_ channel locks should be held while calling any of
3145* these functions.
3146*/
3147
3148/*!
3149 * \brief Call a function with every active channel
3150 *
3151 * \details
3152 * This function executes a callback one time for each active channel on the
3153 * system. The channel is provided as an argument to the function.
3154 *
3155 * \since 1.8
3156 */
3157struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
3158 void *data, int ao2_flags);
3159
3160/*!
3161 * \brief Find a channel by name or uniqueid
3162 *
3163 * \param search the name or uniqueid of the channel to search for
3164 *
3165 * \details
3166 * First searches for a channel with a matching name. If not found
3167 * a search for a channel with a matching uniqueid is done.
3168 *
3169 * \retval a channel with a matching name or uniqueid
3170 * \retval NULL if no channel was found
3171 *
3172 *\note The fallback search by uniqueid is a historical thing. If you
3173 * know the search term is a uniqueid, use \ref ast_channel_get_by_uniqueid
3174 * instead.
3175 *
3176 * \since 1.8
3177 */
3178struct ast_channel *ast_channel_get_by_name(const char *search);
3179
3180/*!
3181 * \brief Find a channel by a name prefix
3182 *
3183 * \param search The channel name or uniqueid prefix to search for
3184 * \param len Only search for up to this many characters from the search term
3185 *
3186 * \details
3187 * Search for a channel that has the same name prefix as specified by the
3188 * search term. If not found, search for an exact match on the uniqueid.
3189 * Searching by partial uniqueid doesn't make any sense as it's usually
3190 * a system-name plus a timestamp and is not supported.
3191 *
3192 * \retval a channel with a matching name or uniqueid
3193 * \retval NULL if no channel was found
3194 *
3195 *\note The fallback search by uniqueid is a historical thing. If you
3196 * know the search term is a uniqueid, use \ref ast_channel_get_by_uniqueid
3197 * instead.
3198 *
3199 * \since 1.8
3200 */
3201struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
3202
3203/*!
3204 * \brief Find a channel by extension and context
3205 *
3206 * \param exten the extension to search for
3207 * \param context the context to search for
3208 *
3209 * \details
3210 * Return a channel that is currently at the specified extension and context.
3211 *
3212 * \retval a channel that is at the specified extension and context
3213 * \retval NULL if no channel was found
3214 *
3215 * \since 1.8
3216 */
3217struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
3218
3219/*!
3220 * \brief Find a channel by a uniqueid
3221 *
3222 * \param uniqueid The uniqueid to search for
3223 *
3224 * \retval a channel with the uniqueid specified by the arguments
3225 * \retval NULL if no channel was found
3226 */
3228
3229/*! @} End channel search functions. */
3230
3231/*!
3232 * \brief Initialize the given name structure.
3233 * \since 1.8
3234 *
3235 * \param init Name structure to initialize.
3236 */
3237void ast_party_name_init(struct ast_party_name *init);
3238
3239/*!
3240 * \brief Copy the source party name information to the destination party name.
3241 * \since 1.8
3242 *
3243 * \param dest Destination party name
3244 * \param src Source party name
3245 */
3246void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src);
3247
3248/*!
3249 * \brief Initialize the given party name structure using the given guide
3250 * for a set update operation.
3251 * \since 1.8
3252 *
3253 * \details
3254 * The initialization is needed to allow a set operation to know if a
3255 * value needs to be updated. Simple integers need the guide's original
3256 * value in case the set operation is not trying to set a new value.
3257 * String values are simply set to NULL pointers if they are not going
3258 * to be updated.
3259 *
3260 * \param init Party name structure to initialize.
3261 * \param guide Source party name to use as a guide in initializing.
3262 */
3263void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide);
3264
3265/*!
3266 * \brief Set the source party name information into the destination party name.
3267 * \since 1.8
3268 *
3269 * \param dest The name one wishes to update
3270 * \param src The new name values to update the dest
3271 */
3272void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src);
3273
3274/*!
3275 * \brief Destroy the party name contents
3276 * \since 1.8
3277 *
3278 * \param doomed The party name to destroy.
3279 */
3280void ast_party_name_free(struct ast_party_name *doomed);
3281
3282/*!
3283 * \brief Initialize the given number structure.
3284 * \since 1.8
3285 *
3286 * \param init Number structure to initialize.
3287 */
3288void ast_party_number_init(struct ast_party_number *init);
3289
3290/*!
3291 * \brief Copy the source party number information to the destination party number.
3292 * \since 1.8
3293 *
3294 * \param dest Destination party number
3295 * \param src Source party number
3296 */
3297void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src);
3298
3299/*!
3300 * \brief Initialize the given party number structure using the given guide
3301 * for a set update operation.
3302 * \since 1.8
3303 *
3304 * \details
3305 * The initialization is needed to allow a set operation to know if a
3306 * value needs to be updated. Simple integers need the guide's original
3307 * value in case the set operation is not trying to set a new value.
3308 * String values are simply set to NULL pointers if they are not going
3309 * to be updated.
3310 *
3311 * \param init Party number structure to initialize.
3312 * \param guide Source party number to use as a guide in initializing.
3313 */
3314void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide);
3315
3316/*!
3317 * \brief Set the source party number information into the destination party number.
3318 * \since 1.8
3319 *
3320 * \param dest The number one wishes to update
3321 * \param src The new number values to update the dest
3322 */
3323void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src);
3324
3325/*!
3326 * \brief Destroy the party number contents
3327 * \since 1.8
3328 *
3329 * \param doomed The party number to destroy.
3330 */
3331void ast_party_number_free(struct ast_party_number *doomed);
3332
3333/*!
3334 * \since 1.8
3335 * \brief Initialize the given subaddress structure.
3336 *
3337 * \param init Subaddress structure to initialize.
3338 */
3340
3341/*!
3342 * \since 1.8
3343 * \brief Copy the source party subaddress information to the destination party subaddress.
3344 *
3345 * \param dest Destination party subaddress
3346 * \param src Source party subaddress
3347 */
3348void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
3349
3350/*!
3351 * \since 1.8
3352 * \brief Initialize the given party subaddress structure using the given guide
3353 * for a set update operation.
3354 *
3355 * \details
3356 * The initialization is needed to allow a set operation to know if a
3357 * value needs to be updated. Simple integers need the guide's original
3358 * value in case the set operation is not trying to set a new value.
3359 * String values are simply set to NULL pointers if they are not going
3360 * to be updated.
3361 *
3362 * \param init Party subaddress structure to initialize.
3363 * \param guide Source party subaddress to use as a guide in initializing.
3364 */
3365void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide);
3366
3367/*!
3368 * \since 1.8
3369 * \brief Set the source party subaddress information into the destination party subaddress.
3370 *
3371 * \param dest The subaddress one wishes to update
3372 * \param src The new subaddress values to update the dest
3373 */
3374void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
3375
3376/*!
3377 * \since 1.8
3378 * \brief Destroy the party subaddress contents
3379 *
3380 * \param doomed The party subaddress to destroy.
3381 */
3383
3384/*!
3385 * \brief Set the update marker to update all information of a corresponding party id.
3386 * \since 11.0
3387 *
3388 * \param update_id The update marker for a corresponding party id.
3389 */
3390void ast_set_party_id_all(struct ast_set_party_id *update_id);
3391
3392/*!
3393 * \brief Initialize the given party id structure.
3394 * \since 1.8
3395 *
3396 * \param init Party id structure to initialize.
3397 */
3398void ast_party_id_init(struct ast_party_id *init);
3399
3400/*!
3401 * \brief Copy the source party id information to the destination party id.
3402 * \since 1.8
3403 *
3404 * \param dest Destination party id
3405 * \param src Source party id
3406 */
3407void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src);
3408
3409/*!
3410 * \brief Initialize the given party id structure using the given guide
3411 * for a set update operation.
3412 * \since 1.8
3413 *
3414 * \details
3415 * The initialization is needed to allow a set operation to know if a
3416 * value needs to be updated. Simple integers need the guide's original
3417 * value in case the set operation is not trying to set a new value.
3418 * String values are simply set to NULL pointers if they are not going
3419 * to be updated.
3420 *
3421 * \param init Party id structure to initialize.
3422 * \param guide Source party id to use as a guide in initializing.
3423 */
3424void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide);
3425
3426/*!
3427 * \brief Set the source party id information into the destination party id.
3428 * \since 1.8
3429 *
3430 * \param dest The id one wishes to update
3431 * \param src The new id values to update the dest
3432 * \param update What id information to update. NULL if all.
3433 */
3434void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update);
3435
3436/*!
3437 * \brief Destroy the party id contents
3438 * \since 1.8
3439 *
3440 * \param doomed The party id to destroy.
3441 */
3442void ast_party_id_free(struct ast_party_id *doomed);
3443
3444/*!
3445 * \brief Determine the overall presentation value for the given party.
3446 * \since 1.8
3447 *
3448 * \param id Party to determine the overall presentation value.
3449 *
3450 * \return Overall presentation value for the given party.
3451 */
3452int ast_party_id_presentation(const struct ast_party_id *id);
3453
3454/*!
3455 * \brief Invalidate all components of the given party id.
3456 * \since 11.0
3457 *
3458 * \param id The party id to invalidate.
3459 */
3460void ast_party_id_invalidate(struct ast_party_id *id);
3461
3462/*!
3463 * \brief Destroy and initialize the given party id structure.
3464 * \since 11.0
3465 *
3466 * \param id The party id to reset.
3467 */
3468void ast_party_id_reset(struct ast_party_id *id);
3469
3470/*!
3471 * \brief Merge a given party id into another given party id.
3472 * \since 11.0
3473 *
3474 * \details
3475 * This function will generate an effective party id.
3476 *
3477 * Each party id component of the party id 'base' is overwritten
3478 * by components of the party id 'overlay' if the overlay
3479 * component is marked as valid. However the component 'tag' of
3480 * the base party id remains untouched.
3481 *
3482 * \param base The party id which is merged.
3483 * \param overlay The party id which is used to merge into.
3484 *
3485 * \return The merged party id as a struct, not as a pointer.
3486 * \note The merged party id returned is a shallow copy and must not be freed.
3487 */
3488struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay);
3489
3490/*!
3491 * \brief Copy a merge of a given party id into another given party id to a given destination party id.
3492 * \since 11.0
3493 *
3494 * \details
3495 * Each party id component of the party id 'base' is overwritten by components
3496 * of the party id 'overlay' if the 'overlay' component is marked as valid.
3497 * However the component 'tag' of the 'base' party id remains untouched.
3498 * The result is copied into the given party id 'dest'.
3499 *
3500 * \note The resulting merged party id is a real copy and has to be freed.
3501 *
3502 * \param dest The resulting merged party id.
3503 * \param base The party id which is merged.
3504 * \param overlay The party id which is used to merge into.
3505 */
3506void ast_party_id_merge_copy(struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay);
3507
3508/*!
3509 * \brief Initialize the given dialed structure.
3510 * \since 1.8
3511 *
3512 * \param init Dialed structure to initialize.
3513 */
3514void ast_party_dialed_init(struct ast_party_dialed *init);
3515
3516/*!
3517 * \brief Copy the source dialed party information to the destination dialed party.
3518 * \since 1.8
3519 *
3520 * \param dest Destination dialed party
3521 * \param src Source dialed party
3522 */
3523void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3524
3525/*!
3526 * \brief Initialize the given dialed structure using the given
3527 * guide for a set update operation.
3528 * \since 1.8
3529 *
3530 * \details
3531 * The initialization is needed to allow a set operation to know if a
3532 * value needs to be updated. Simple integers need the guide's original
3533 * value in case the set operation is not trying to set a new value.
3534 * String values are simply set to NULL pointers if they are not going
3535 * to be updated.
3536 *
3537 * \param init Caller structure to initialize.
3538 * \param guide Source dialed to use as a guide in initializing.
3539 */
3540void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide);
3541
3542/*!
3543 * \brief Set the dialed information based on another dialed source
3544 * \since 1.8
3545 *
3546 * This is similar to ast_party_dialed_copy, except that NULL values for
3547 * strings in the src parameter indicate not to update the corresponding dest values.
3548 *
3549 * \param dest The dialed one wishes to update
3550 * \param src The new dialed values to update the dest
3551 */
3552void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3553
3554/*!
3555 * \brief Destroy the dialed party contents
3556 * \since 1.8
3557 *
3558 * \param doomed The dialed party to destroy.
3559 */
3560void ast_party_dialed_free(struct ast_party_dialed *doomed);
3561
3562/*!
3563 * \since 1.8
3564 * \brief Initialize the given caller structure.
3565 *
3566 * \param init Caller structure to initialize.
3567 */
3568void ast_party_caller_init(struct ast_party_caller *init);
3569
3570/*!
3571 * \since 1.8
3572 * \brief Copy the source caller information to the destination caller.
3573 *
3574 * \param dest Destination caller
3575 * \param src Source caller
3576 */
3577void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src);
3578
3579/*!
3580 * \brief Initialize the given caller structure using the given
3581 * guide for a set update operation.
3582 * \since 1.8
3583 *
3584 * \details
3585 * The initialization is needed to allow a set operation to know if a
3586 * value needs to be updated. Simple integers need the guide's original
3587 * value in case the set operation is not trying to set a new value.
3588 * String values are simply set to NULL pointers if they are not going
3589 * to be updated.
3590 *
3591 * \param init Caller structure to initialize.
3592 * \param guide Source caller to use as a guide in initializing.
3593 */
3594void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide);
3595
3596/*!
3597 * \brief Set the caller information based on another caller source
3598 * \since 1.8
3599 *
3600 * This is similar to ast_party_caller_copy, except that NULL values for
3601 * strings in the src parameter indicate not to update the corresponding dest values.
3602 *
3603 * \param dest The caller one wishes to update
3604 * \param src The new caller values to update the dest
3605 * \param update What caller information to update. NULL if all.
3606 */
3607void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update);
3608
3609/*!
3610 * \brief Destroy the caller party contents
3611 * \since 1.8
3612 *
3613 * \param doomed The caller party to destroy.
3614 */
3615void ast_party_caller_free(struct ast_party_caller *doomed);
3616
3617/*!
3618 * \since 1.8
3619 * \brief Initialize the given connected line structure.
3620 *
3621 * \param init Connected line structure to initialize.
3622 */
3624
3625/*!
3626 * \since 1.8
3627 * \brief Copy the source connected line information to the destination connected line.
3628 *
3629 * \param dest Destination connected line
3630 * \param src Source connected line
3631 */
3633
3634/*!
3635 * \since 1.8
3636 * \brief Initialize the given connected line structure using the given
3637 * guide for a set update operation.
3638 *
3639 * \details
3640 * The initialization is needed to allow a set operation to know if a
3641 * value needs to be updated. Simple integers need the guide's original
3642 * value in case the set operation is not trying to set a new value.
3643 * String values are simply set to NULL pointers if they are not going
3644 * to be updated.
3645 *
3646 * \param init Connected line structure to initialize.
3647 * \param guide Source connected line to use as a guide in initializing.
3648 */
3650
3651/*!
3652 * \since 1.8
3653 * \brief Set the connected line information based on another connected line source
3654 *
3655 * This is similar to ast_party_connected_line_copy, except that NULL values for
3656 * strings in the src parameter indicate not to update the corresponding dest values.
3657 *
3658 * \param dest The connected line one wishes to update
3659 * \param src The new connected line values to update the dest
3660 * \param update What connected line information to update. NULL if all.
3661 */
3663
3664/*!
3665 * \since 1.8
3666 * \brief Collect the caller party information into a connected line structure.
3667 *
3668 * \param connected Collected caller information for the connected line
3669 * \param caller Caller information.
3670 *
3671 * \warning This is a shallow copy.
3672 * \warning DO NOT call ast_party_connected_line_free() on the filled in
3673 * connected line structure!
3674 */
3676
3677/*!
3678 * \since 1.8
3679 * \brief Destroy the connected line information contents
3680 *
3681 * \param doomed The connected line information to destroy.
3682 */
3684
3685/*!
3686 * \brief Initialize the given redirecting reason structure
3687 *
3688 * \param init Redirecting reason structure to initialize
3689 */
3691
3692/*!
3693 * \brief Copy the source redirecting reason information to the destination redirecting reason.
3694 *
3695 * \param dest Destination redirecting reason
3696 * \param src Source redirecting reason
3697 */
3699 const struct ast_party_redirecting_reason *src);
3700
3701/*!
3702 * \brief Initialize the given redirecting reason structure using the given guide
3703 * for a set update operation.
3704 *
3705 * \details
3706 * The initialization is needed to allow a set operation to know if a
3707 * value needs to be updated. Simple integers need the guide's original
3708 * value in case the set operation is not trying to set a new value.
3709 * String values are simply set to NULL pointers if they are not going
3710 * to be updated.
3711 *
3712 * \param init Redirecting reason structure to initialize.
3713 * \param guide Source redirecting reason to use as a guide in initializing.
3714 */
3716 const struct ast_party_redirecting_reason *guide);
3717
3718/*!
3719 * \brief Set the redirecting reason information based on another redirecting reason source
3720 *
3721 * This is similar to ast_party_redirecting_reason_copy, except that NULL values for
3722 * strings in the src parameter indicate not to update the corresponding dest values.
3723 *
3724 * \param dest The redirecting reason one wishes to update
3725 * \param src The new redirecting reason values to update the dest
3726 */
3728 const struct ast_party_redirecting_reason *src);
3729
3730/*!
3731 * \brief Destroy the redirecting reason contents
3732 *
3733 * \param doomed The redirecting reason to destroy.
3734 */
3736
3737/*!
3738 * \brief Initialize the given redirecting structure.
3739 * \since 1.8
3740 *
3741 * \param init Redirecting structure to initialize.
3742 */
3744
3745/*!
3746 * \since 1.8
3747 * \brief Copy the source redirecting information to the destination redirecting.
3748 *
3749 * \param dest Destination redirecting
3750 * \param src Source redirecting
3751 */
3752void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src);
3753
3754/*!
3755 * \since 1.8
3756 * \brief Initialize the given redirecting id structure using the given guide
3757 * for a set update operation.
3758 *
3759 * \details
3760 * The initialization is needed to allow a set operation to know if a
3761 * value needs to be updated. Simple integers need the guide's original
3762 * value in case the set operation is not trying to set a new value.
3763 * String values are simply set to NULL pointers if they are not going
3764 * to be updated.
3765 *
3766 * \param init Redirecting id structure to initialize.
3767 * \param guide Source redirecting id to use as a guide in initializing.
3768 */
3769void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide);
3770
3771/*!
3772 * \brief Set the redirecting information based on another redirecting source
3773 * \since 1.8
3774 *
3775 * This is similar to ast_party_redirecting_copy, except that NULL values for
3776 * strings in the src parameter indicate not to update the corresponding dest values.
3777 *
3778 * \param dest The redirecting one wishes to update
3779 * \param src The new redirecting values to update the dest
3780 * \param update What redirecting information to update. NULL if all.
3781 */
3783
3784/*!
3785 * \since 1.8
3786 * \brief Destroy the redirecting information contents
3787 *
3788 * \param doomed The redirecting information to destroy.
3789 */
3791
3792/*!
3793 * \since 1.8
3794 * \brief Copy the caller information to the connected line information.
3795 *
3796 * \param dest Destination connected line information
3797 * \param src Source caller information
3798 *
3799 * \note Assumes locks are already acquired
3800 */
3802
3803/*!
3804 * \since 1.8
3805 * \brief Copy the connected line information to the caller information.
3806 *
3807 * \param dest Destination caller information
3808 * \param src Source connected line information
3809 *
3810 * \note Assumes locks are already acquired
3811 */
3813
3814/*!
3815 * \since 1.8
3816 * \brief Set the connected line information in the Asterisk channel
3817 *
3818 * \param chan Asterisk channel to set connected line information
3819 * \param connected Connected line information
3820 * \param update What connected line information to update. NULL if all.
3821 *
3822 * \note The channel does not need to be locked before calling this function.
3823 */
3825
3826/*!
3827 * \since 1.8
3828 * \brief Build the connected line information data frame.
3829 *
3830 * \param data Buffer to fill with the frame data
3831 * \param datalen Size of the buffer to fill
3832 * \param connected Connected line information
3833 * \param update What connected line information to build. NULL if all.
3834 *
3835 * \retval -1 if error
3836 * \retval Amount of data buffer used
3837 */
3838int 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);
3839
3840/*!
3841 * \since 1.8
3842 * \brief Parse connected line indication frame data
3843 *
3844 * \param data Buffer with the frame data to parse
3845 * \param datalen Size of the buffer
3846 * \param connected Extracted connected line information
3847 *
3848 * \retval 0 on success.
3849 * \retval -1 on error.
3850 *
3851 * \note The filled in connected line structure needs to be initialized by
3852 * ast_party_connected_line_set_init() before calling. If defaults are not
3853 * required use ast_party_connected_line_init().
3854 * \note The filled in connected line structure needs to be destroyed by
3855 * ast_party_connected_line_free() when it is no longer needed.
3856 */
3857int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected);
3858
3859/*!
3860 * \since 1.8
3861 * \brief Indicate that the connected line information has changed
3862 *
3863 * \param chan Asterisk channel to indicate connected line information
3864 * \param connected Connected line information
3865 * \param update What connected line information to update. NULL if all.
3866 */
3868
3869/*!
3870 * \since 1.8
3871 * \brief Queue a connected line update frame on a channel
3872 *
3873 * \param chan Asterisk channel to indicate connected line information
3874 * \param connected Connected line information
3875 * \param update What connected line information to update. NULL if all.
3876 */
3878
3879/*!
3880 * \since 1.8
3881 * \brief Set the redirecting id information in the Asterisk channel
3882 *
3883 * \param chan Asterisk channel to set redirecting id information
3884 * \param redirecting Redirecting id information
3885 * \param update What redirecting information to update. NULL if all.
3886 *
3887 * \note The channel does not need to be locked before calling this function.
3888 */
3889void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3890
3891/*!
3892 * \since 1.8
3893 * \brief Build the redirecting id data frame.
3894 *
3895 * \param data Buffer to fill with the frame data
3896 * \param datalen Size of the buffer to fill
3897 * \param redirecting Redirecting id information
3898 * \param update What redirecting information to build. NULL if all.
3899 *
3900 * \retval -1 if error
3901 * \retval Amount of data buffer used
3902 */
3903int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3904
3905/*!
3906 * \since 1.8
3907 * \brief Parse redirecting indication frame data
3908 *
3909 * \param data Buffer with the frame data to parse
3910 * \param datalen Size of the buffer
3911 * \param redirecting Extracted redirecting id information
3912 *
3913 * \retval 0 on success.
3914 * \retval -1 on error.
3915 *
3916 * \note The filled in id structure needs to be initialized by
3917 * ast_party_redirecting_set_init() before calling.
3918 * \note The filled in id structure needs to be destroyed by
3919 * ast_party_redirecting_free() when it is no longer needed.
3920 */
3921int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting);
3922
3923/*!
3924 * \since 1.8
3925 * \brief Indicate that the redirecting id has changed
3926 *
3927 * \param chan Asterisk channel to indicate redirecting id information
3928 * \param redirecting Redirecting id information
3929 * \param update What redirecting information to update. NULL if all.
3930 */
3931void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3932
3933/*!
3934 * \since 1.8
3935 * \brief Queue a redirecting update frame on a channel
3936 *
3937 * \param chan Asterisk channel to indicate redirecting id information
3938 * \param redirecting Redirecting id information
3939 * \param update What redirecting information to update. NULL if all.
3940 */
3941void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3942
3943/*!
3944 * \since 11
3945 * \brief Run a connected line interception subroutine and update a channel's connected line
3946 * information
3947 *
3948 * Whenever we want to update a channel's connected line information, we may need to run
3949 * a subroutine so that an administrator can manipulate the information before sending it
3950 * out. This function both runs the subroutine specified by CONNECTED_LINE_SEND_SUB and
3951 * sends the update to the channel.
3952 *
3953 * \param autoservice_chan Channel to place into autoservice while the sub is running.
3954 * It is perfectly safe for this to be NULL
3955 * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3956 * determine which subroutine we need to run.
3957 * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
3958 * AST_CONTROL_CONNECTED_LINE
3959 * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
3960 * ast_party_connected_line pointer.
3961 * \retval 0 Success
3962 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3963 * run the subroutine
3964 */
3965int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame);
3966
3967/*!
3968 * \since 11
3969 * \brief Run a redirecting interception subroutine and update a channel's redirecting information
3970 *
3971 * \details
3972 * Whenever we want to update a channel's redirecting information, we may need to run
3973 * a subroutine so that an administrator can manipulate the information before sending it
3974 * out. This function both runs the subroutine specified by REDIRECTING_SEND_SUB and
3975 * sends the update to the channel.
3976 *
3977 * \param autoservice_chan Channel to place into autoservice while the subroutine is running.
3978 * It is perfectly safe for this to be NULL
3979 * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3980 * determine which subroutine we need to run.
3981 * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
3982 * AST_CONTROL_REDIRECTING
3983 * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
3984 * ast_party_redirecting pointer.
3985 *
3986 * \retval 0 Success
3987 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3988 * run the subroutine
3989 */
3990int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame);
3991
3992#include "asterisk/ccss.h"
3993
3994/*!
3995 * \since 1.8
3996 * \brief Set up datastore with CCSS parameters for a channel
3997 *
3998 * \note
3999 * If base_params is NULL, the channel will get the default
4000 * values for all CCSS parameters.
4001 *
4002 * \details
4003 * This function makes use of datastore operations on the channel, so
4004 * it is important to lock the channel before calling this function.
4005 *
4006 * \warning You should call this function only if \ref ast_cc_is_enabled()
4007 * returns true.
4008 *
4009 * \param chan The channel to create the datastore on
4010 * \param base_params CCSS parameters we wish to copy into the channel
4011 * \retval 0 Success
4012 * \retval -1 Failure or CCSS is globally disabled.
4013 */
4015 const struct ast_cc_config_params *base_params);
4016
4017/*!
4018 * \since 1.8
4019 * \brief Get the CCSS parameters from a channel
4020 *
4021 * \details
4022 * This function makes use of datastore operations on the channel, so
4023 * it is important to lock the channel before calling this function.
4024 *
4025 * \warning You should call this function only if \ref ast_cc_is_enabled()
4026 * returns true.
4027 *
4028 * \param chan Channel to retrieve parameters from
4029 * \retval NULL Failure or CCSS is globally disabled.
4030 * \retval non-NULL The parameters desired
4031 */
4033
4034
4035/*!
4036 * \since 1.8
4037 * \brief Get a device name given its channel structure
4038 *
4039 * \details
4040 * A common practice in Asterisk is to determine the device being talked
4041 * to by dissecting the channel name. For certain channel types, this is not
4042 * accurate. For instance, an ISDN channel is named based on what B channel is
4043 * used, not the device being communicated with.
4044 *
4045 * This function interfaces with a channel tech's queryoption callback to
4046 * retrieve the name of the device being communicated with. If the channel does not
4047 * implement this specific option, then the traditional method of using the channel
4048 * name is used instead.
4049 *
4050 * \param chan The channel to retrieve the information from
4051 * \param[out] device_name The buffer to place the device's name into
4052 * \param name_buffer_length The allocated space for the device_name
4053 * \return 0 always
4054 */
4055int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length);
4056
4057/*!
4058 * \since 1.8
4059 * \brief Find the appropriate CC agent type to use given a channel
4060 *
4061 * \details
4062 * During call completion, we will need to create a call completion agent structure. To
4063 * figure out the type of agent to construct, we need to ask the channel driver for the
4064 * appropriate type.
4065 *
4066 * Prior to adding this function, the call completion core attempted to figure this
4067 * out for itself by stripping the technology off the channel's name. However, in the
4068 * case of chan_dahdi, there are multiple agent types registered, and so simply searching
4069 * for an agent type called "DAHDI" is not possible. In a case where multiple agent types
4070 * are defined, the channel driver must have a queryoption callback defined in its
4071 * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE
4072 *
4073 * If a channel driver does not have a queryoption callback or if the queryoption callback
4074 * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology
4075 * portion of the channel name is used instead. This is perfectly suitable for channel drivers
4076 * whose channel technologies are a one-to-one match with the agent types defined within.
4077 *
4078 * Note that this function is only called when the agent policy on a given channel is set
4079 * to "native." Generic agents' type can be determined automatically by the core.
4080 *
4081 * \param chan The channel for which we wish to retrieve the agent type
4082 * \param[out] agent_type The type of agent the channel driver wants us to use
4083 * \param size The size of the buffer to write to
4084 */
4085int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size);
4086#if defined(__cplusplus) || defined(c_plusplus)
4087}
4088#endif
4089
4090/*!
4091 * \brief Remove a channel from the global channels container
4092 *
4093 * \param chan channel to remove
4094 *
4095 * In a case where it is desired that a channel not be available in any lookups
4096 * in the global channels conatiner, use this function.
4097 */
4098void ast_channel_unlink(struct ast_channel *chan);
4099
4100/*!
4101 * \brief Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash
4102 * on the given channel
4103 *
4104 * \param chan channel on which to set the cause information
4105 * \param cause_code ast_control_pvt_cause_code structure containing cause information
4106 * \param datalen total length of the structure since it may vary
4107 */
4108void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen);
4109
4110/*!
4111 * \since 12
4112 * \brief Convert a string to a detail record AMA flag
4113 *
4114 * \param flag string form of flag
4115 *
4116 * \retval the enum (integer) form of the flag
4117 */
4118enum ama_flags ast_channel_string2amaflag(const char *flag);
4119
4120/*!
4121 * \since 12
4122 * \brief Convert the enum representation of an AMA flag to a string representation
4123 *
4124 * \param flags integer flag
4125 *
4126 * \retval A string representation of the flag
4127 */
4128const char *ast_channel_amaflags2string(enum ama_flags flags);
4129
4134
4135/* ACCESSOR FUNCTIONS */
4136
4137#define DECLARE_STRINGFIELD_SETTERS_FOR(field) \
4138 void ast_channel_##field##_set(struct ast_channel *chan, const char *field); \
4139 void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0))); \
4140 void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) __attribute__((format(printf, 2, 3)))
4141
4142/*!
4143 * The following string fields result in channel snapshot creation and
4144 * should have the channel locked when called:
4145 *
4146 * \li language
4147 * \li accountcode
4148 * \li peeraccount
4149 * \li linkedid
4150 */
4164
4165const char *ast_channel_name(const struct ast_channel *chan);
4166const char *ast_channel_language(const struct ast_channel *chan);
4167const char *ast_channel_musicclass(const struct ast_channel *chan);
4168const char *ast_channel_latest_musicclass(const struct ast_channel *chan);
4169const char *ast_channel_accountcode(const struct ast_channel *chan);
4170const char *ast_channel_peeraccount(const struct ast_channel *chan);
4171const char *ast_channel_userfield(const struct ast_channel *chan);
4172const char *ast_channel_call_forward(const struct ast_channel *chan);
4173const char *ast_channel_uniqueid(const struct ast_channel *chan);
4174const char *ast_channel_linkedid(const struct ast_channel *chan);
4175const char *ast_channel_tenantid(const struct ast_channel *chan);
4176void ast_channel_tenantid_set(struct ast_channel *chan, const char *value);
4177const char *ast_channel_parkinglot(const struct ast_channel *chan);
4178const char *ast_channel_hangupsource(const struct ast_channel *chan);
4179const char *ast_channel_dialcontext(const struct ast_channel *chan);
4180
4181const char *ast_channel_appl(const struct ast_channel *chan);
4182void ast_channel_appl_set(struct ast_channel *chan, const char *value);
4183const char *ast_channel_blockproc(const struct ast_channel *chan);
4184void ast_channel_blockproc_set(struct ast_channel *chan, const char *value);
4185const char *ast_channel_data(const struct ast_channel *chan);
4186void ast_channel_data_set(struct ast_channel *chan, const char *value);
4187
4188const char *ast_channel_lastcontext(const struct ast_channel *chan);
4189const char *ast_channel_context(const struct ast_channel *chan);
4190void ast_channel_context_set(struct ast_channel *chan, const char *value);
4191const char *ast_channel_lastexten(const struct ast_channel *chan);
4192const char *ast_channel_exten(const struct ast_channel *chan);
4193void ast_channel_exten_set(struct ast_channel *chan, const char *value);
4194
4195char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan);
4197char ast_channel_sending_dtmf_digit(const struct ast_channel *chan);
4199struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan);
4200void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value);
4201enum ama_flags ast_channel_amaflags(const struct ast_channel *chan);
4202
4203/*!
4204 * \pre chan is locked
4205 */
4206void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value);
4207int ast_channel_epfd(const struct ast_channel *chan);
4209int ast_channel_fdno(const struct ast_channel *chan);
4210void ast_channel_fdno_set(struct ast_channel *chan, int value);
4211int ast_channel_hangupcause(const struct ast_channel *chan);
4212void ast_channel_hangupcause_set(struct ast_channel *chan, int value);
4213int ast_channel_tech_hangupcause(const struct ast_channel *chan);
4214void ast_channel_tech_hangupcause_set(struct ast_channel *chan, int value);
4215int ast_channel_priority(const struct ast_channel *chan);
4216void ast_channel_priority_set(struct ast_channel *chan, int value);
4217int ast_channel_rings(const struct ast_channel *chan);
4218void ast_channel_rings_set(struct ast_channel *chan, int value);
4219int ast_channel_streamid(const struct ast_channel *chan);
4220void ast_channel_streamid_set(struct ast_channel *chan, int value);
4221int ast_channel_timingfd(const struct ast_channel *chan);
4222void ast_channel_timingfd_set(struct ast_channel *chan, int value);
4223int ast_channel_visible_indication(const struct ast_channel *chan);
4225int ast_channel_hold_state(const struct ast_channel *chan);
4226void ast_channel_hold_state_set(struct ast_channel *chan, int value);
4227int ast_channel_vstreamid(const struct ast_channel *chan);
4228void ast_channel_vstreamid_set(struct ast_channel *chan, int value);
4229unsigned short ast_channel_transfercapability(const struct ast_channel *chan);
4230void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value);
4231unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan);
4232void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value);
4233unsigned int ast_channel_fin(const struct ast_channel *chan);
4234void ast_channel_fin_set(struct ast_channel *chan, unsigned int value);
4235unsigned int ast_channel_fout(const struct ast_channel *chan);
4236void ast_channel_fout_set(struct ast_channel *chan, unsigned int value);
4237unsigned long ast_channel_insmpl(const struct ast_channel *chan);
4238void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value);
4239unsigned long ast_channel_outsmpl(const struct ast_channel *chan);
4240void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value);
4241void *ast_channel_generatordata(const struct ast_channel *chan);
4242void ast_channel_generatordata_set(struct ast_channel *chan, void *value);
4243void *ast_channel_music_state(const struct ast_channel *chan);
4244void ast_channel_music_state_set(struct ast_channel *chan, void *value);
4245void *ast_channel_tech_pvt(const struct ast_channel *chan);
4246void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value);
4247void *ast_channel_timingdata(const struct ast_channel *chan);
4248void ast_channel_timingdata_set(struct ast_channel *chan, void *value);
4249struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan);
4251struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan);
4252void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value);
4253struct ast_channel *ast_channel__bridge(const struct ast_channel *chan);
4255struct ast_channel *ast_channel_masq(const struct ast_channel *chan);
4256void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value);
4257struct ast_channel *ast_channel_masqr(const struct ast_channel *chan);
4258void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value);
4259struct ast_filestream *ast_channel_stream(const struct ast_channel *chan);
4260void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value);
4261struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan);
4262void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value);
4263struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan);
4265struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan);
4267struct ast_generator *ast_channel_generator(const struct ast_channel *chan);
4268void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value);
4269struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan);
4270void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value);
4271struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan);
4272void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value);
4273struct ast_timer *ast_channel_timer(const struct ast_channel *chan);
4274void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value);
4275struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan);
4276void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value);
4277struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan);
4278void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
4279struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan);
4280void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
4281const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan);
4282void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value);
4283enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan);
4285enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
4286ast_callid ast_channel_callid(const struct ast_channel *chan);
4287struct ast_channel_snapshot *ast_channel_snapshot(const struct ast_channel *chan);
4288void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot);
4290struct ast_endpoint *ast_channel_endpoint(const struct ast_channel *chan);
4291void ast_channel_endpoint_set(struct ast_channel *chan, struct ast_endpoint *endpoint);
4292
4293/*!
4294 * \pre chan is locked
4295 */
4297
4298/* XXX Internal use only, make sure to move later */
4299void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
4303void ast_channel_callid_cleanup(struct ast_channel *chan);
4305
4306/* Format getters */
4310struct ast_format *ast_channel_readformat(struct ast_channel *chan);
4311struct ast_format *ast_channel_writeformat(struct ast_channel *chan);
4312
4313/* Format setters - all of these functions will increment the reference count of the format passed in */
4314void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format);
4315void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format);
4316void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format);
4317void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format);
4318void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format);
4319
4320/* Other struct getters */
4321struct ast_frame *ast_channel_dtmff(struct ast_channel *chan);
4322struct ast_jb *ast_channel_jb(struct ast_channel *chan);
4323struct ast_party_caller *ast_channel_caller(struct ast_channel *chan);
4327struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan);
4332struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan);
4333struct timeval *ast_channel_whentohangup(struct ast_channel *chan);
4334struct varshead *ast_channel_varshead(struct ast_channel *chan);
4335
4336void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value);
4337void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value);
4338void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value);
4340void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value);
4342void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value);
4343
4344/*!
4345 * \pre chan is locked
4346 */
4347void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value);
4348void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value);
4349struct timeval ast_channel_creationtime(struct ast_channel *chan);
4350void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value);
4351struct timeval ast_channel_answertime(struct ast_channel *chan);
4352void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value);
4353
4354/* List getters */
4358struct ast_readq_list *ast_channel_readq(struct ast_channel *chan);
4359
4360/* Typedef accessors */
4362/*!
4363 * \pre chan is locked
4364 */
4367/*!
4368 * \pre chan is locked
4369 */
4371struct ast_namedgroups *ast_channel_named_callgroups(const struct ast_channel *chan);
4372void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
4373struct ast_namedgroups *ast_channel_named_pickupgroups(const struct ast_channel *chan);
4374void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
4375
4376/* Alertpipe accessors--the "internal" functions for channel.c use only */
4377int ast_channel_alert_write(struct ast_channel *chan);
4378int ast_channel_alert_writable(struct ast_channel *chan);
4386/*! \brief Swap the interal alertpipe between two channels
4387 * \note Handle all of the necessary locking before calling this
4388 */
4389void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2);
4390
4391/* file descriptor array accessors */
4392void ast_channel_internal_fd_clear(struct ast_channel *chan, int which);
4394void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value);
4395int ast_channel_fd(const struct ast_channel *chan, int which);
4396int ast_channel_fd_isset(const struct ast_channel *chan, int which);
4397
4398/*!
4399 * \since 15
4400 * \brief Retrieve the number of file decriptor positions present on the channel
4401 *
4402 * \param chan The channel to get the count of
4403 *
4404 * \pre chan is locked
4405 *
4406 * \return The number of file descriptor positions
4407 */
4408int ast_channel_fd_count(const struct ast_channel *chan);
4409
4410/*!
4411 * \since 15
4412 * \brief Add a file descriptor to the channel without a fixed position
4413 *
4414 * \param chan The channel to add the file descriptor to
4415 * \param value The file descriptor
4416 *
4417 * \pre chan is locked
4418 *
4419 * \return The position of the file descriptor
4420 */
4421int ast_channel_fd_add(struct ast_channel *chan, int value);
4422
4423pthread_t ast_channel_blocker(const struct ast_channel *chan);
4424void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value);
4425
4426int ast_channel_blocker_tid(const struct ast_channel *chan);
4427void ast_channel_blocker_tid_set(struct ast_channel *chan, int tid);
4428
4431
4432struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan);
4433/*!
4434 * \pre chan is locked
4435 */
4437
4440
4443
4444/*!
4445 * \since 11
4446 * \brief Retrieve a comma-separated list of channels for which dialed cause information is available
4447 *
4448 * \details
4449 * This function makes use of datastore operations on the channel, so
4450 * it is important to lock the channel before calling this function.
4451 *
4452 * \param chan The channel from which to retrieve information
4453 * \retval NULL on allocation failure
4454 * \retval Pointer to an ast_str object containing the desired information which must be freed
4455 */
4456struct ast_str *ast_channel_dialed_causes_channels(const struct ast_channel *chan);
4457
4458/*!
4459 * \since 20.19.0
4460 * \since 22.9.0
4461 * \since 23.3.0
4462 * \brief Retrieve an iterator for dialed cause information
4463 *
4464 * \details
4465 * Each call to ao2_iterator_next() will return a pointer to an ast_control_pvt_cause_code
4466 * structure containing the dialed cause information for one channel. One of the entries
4467 * may be for the channel itself if the channel was hung up because of a non-2XX SIP
4468 * response code. The rest of the entries will be for channels bridged to the channel for
4469 * which dialed cause information is being retrieved. The caller is responsible for
4470 * cleaning up the reference count of each entry returned and destroying the returned
4471 * iterator with ao2_iterator_destroy() when it is finished with it.
4472 *
4473 * \param chan The channel from which to retrieve cause information
4474 * \retval ao2_iterator
4475 */
4477
4478/*!
4479 * \since 11
4480 * \brief Retrieve a ref-counted cause code information structure
4481 *
4482 * \details
4483 * This function makes use of datastore operations on the channel, so
4484 * it is important to lock the channel before calling this function.
4485 * This function increases the ref count of the returned object, so the
4486 * calling function must decrease the reference count when it is finished
4487 * with the object.
4488 *
4489 * \param chan The channel from which to retrieve information
4490 * \param chan_name The name of the channel about which to retrieve information
4491 * \retval NULL on search failure
4492 * \retval Pointer to a ref-counted ast_control_pvt_cause_code object containing the desired information
4493 */
4495
4496/*!
4497 * \since 11
4498 * \brief Add cause code information to the channel
4499 *
4500 * \details
4501 * This function makes use of datastore operations on the channel, so
4502 * it is important to lock the channel before calling this function.
4503 * The passed in data is copied and so is still owned by the caller.
4504 *
4505 * \param chan The channel on which to add information
4506 * \param cause_code The cause information to be added to the channel
4507 * \param datalen The total length of the structure since its length is variable
4508 * \retval 0 on success
4509 * \retval -1 on error
4510 */
4511int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen);
4512
4513/*!
4514 * \since 11
4515 * \brief Clear all cause information from the channel
4516 *
4517 * \details
4518 * This function makes use of datastore operations on the channel, so
4519 * it is important to lock the channel before calling this function.
4520 *
4521 * \param chan The channel from which to clear information
4522 */
4523void ast_channel_dialed_causes_clear(const struct ast_channel *chan);
4524
4525struct ast_flags *ast_channel_flags(struct ast_channel *chan);
4526
4527/*!
4528 * \since 13.17.0
4529 * \brief Set a flag on a channel
4530 *
4531 * \param chan The channel to set the flag on
4532 * \param flag The flag to set
4533 *
4534 * \note This will lock the channel internally. If the channel is already
4535 * locked it is still safe to call.
4536 */
4537
4538void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag);
4539
4540/*!
4541 * \since 13.17.0
4542 * \brief Clear a flag on a channel
4543 *
4544 * \param chan The channel to clear the flag from
4545 * \param flag The flag to clear
4546 *
4547 * \note This will lock the channel internally. If the channel is already
4548 * locked it is still safe to call.
4549 */
4550void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag);
4551
4552/*!
4553 * \since 12.4.0
4554 * \brief Return whether or not any manager variables have been set
4555 *
4556 * \retval 0 if no manager variables are expected
4557 * \retval 1 if manager variables are expected
4558 */
4560
4561/*!
4562 * \since 12
4563 * \brief Sets the variables to be stored in the \a manager_vars field of all
4564 * snapshots.
4565 * \param varc Number of variable names.
4566 * \param vars Array of variable names.
4567 */
4568void ast_channel_set_manager_vars(size_t varc, char **vars);
4569
4570/*!
4571 * \since 12
4572 * \brief Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
4573 *
4574 * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4575 *
4576 * \param chan Channel to get variables for.
4577 * \return List of channel variables.
4578 * \retval NULL on error
4579 */
4581
4582/*!
4583 * \since 14.2.0
4584 * \brief Return whether or not any ARI variables have been set
4585 *
4586 * \retval 0 if no ARI variables are expected
4587 * \retval 1 if ARI variables are expected
4588 */
4589int ast_channel_has_ari_vars(void);
4590
4591/*!
4592 * \since 14.2.0
4593 * \brief Sets the variables to be stored in the \a ari_vars field of all
4594 * snapshots.
4595 * \param varc Number of variable names.
4596 * \param vars Array of variable names.
4597 */
4598void ast_channel_set_ari_vars(size_t varc, char **vars);
4599
4600/*!
4601 * \since 14.2.0
4602 * \brief Gets the variables for a given channel, as specified by ast_channel_set_ari_vars().
4603 *
4604 * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4605 *
4606 * \param chan Channel to get variables for.
4607 * \return List of channel variables.
4608 * \retval NULL on error
4609 */
4610struct varshead *ast_channel_get_ari_vars(struct ast_channel *chan);
4611
4612/*!
4613 * \since 12
4614 * \brief Gets the variables for a given channel, as set using pbx_builtin_setvar_helper().
4615 *
4616 * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4617 *
4618 * \param chan Channel to get variables for
4619 * \return List of channel variables.
4620 * \retval NULL on error
4621 */
4622struct varshead *ast_channel_get_vars(struct ast_channel *chan);
4623
4624/*!
4625 * \since 12
4626 * \brief A topic which publishes the events for a particular channel.
4627 *
4628 * If the given \a chan is \c NULL, ast_channel_topic_all() is returned.
4629 *
4630 * \param chan Channel, or \c NULL.
4631 *
4632 * \retval Topic for channel's events.
4633 * \retval ast_channel_topic_all() if \a chan is \c NULL.
4634 */
4635struct stasis_topic *ast_channel_topic(struct ast_channel *chan);
4636
4637/*!
4638 * \brief Get the bridge associated with a channel
4639 * \since 12.0.0
4640 *
4641 * \param chan The channel whose bridge we want
4642 *
4643 * \details
4644 * The bridge returned has its reference count incremented. Use
4645 * ao2_cleanup() or ao2_ref() in order to decrement the
4646 * reference count when you are finished with the bridge.
4647 *
4648 * \note This function expects the channel to be locked prior to
4649 * being called and will not grab the channel lock.
4650 *
4651 * \retval NULL No bridge present on the channel
4652 * \retval non-NULL The bridge the channel is in
4653 */
4654struct ast_bridge *ast_channel_get_bridge(const struct ast_channel *chan);
4655
4656/*!
4657 * \brief Determine if a channel is in a bridge
4658 * \since 12.0.0
4659 *
4660 * \param chan The channel to test
4661 *
4662 * \note This function expects the channel to be locked prior to
4663 * being called and will not grab the channel lock.
4664 *
4665 * \retval 0 The channel is not bridged
4666 * \retval non-zero The channel is bridged
4667 */
4668int ast_channel_is_bridged(const struct ast_channel *chan);
4669
4670/*!
4671 * \brief Determine if a channel is leaving a bridge, but \em not hung up
4672 * \since 12.4.0
4673 *
4674 * \param chan The channel to test
4675 *
4676 * \note If a channel is hung up, it is implicitly leaving any bridge it
4677 * may be in. This function is used to test if a channel is leaving a bridge
4678 * but may survive the experience, if it has a place to go to (dialplan or
4679 * otherwise)
4680 *
4681 * \retval 0 The channel is not leaving the bridge or is hung up
4682 * \retval non-zero The channel is leaving the bridge
4683 */
4685
4686/*!
4687 * \brief Get the channel's bridge peer only if the bridge is two-party.
4688 * \since 12.0.0
4689 *
4690 * \param chan Channel desiring the bridge peer channel.
4691 *
4692 * \note The returned peer channel is the current peer in the
4693 * bridge when called.
4694 *
4695 * \note Absolutely _NO_ channel locks should be held when calling this function.
4696 *
4697 * \retval NULL Channel not in a bridge or the bridge is not two-party.
4698 * \retval non-NULL Reffed peer channel at time of calling.
4699 */
4700struct ast_channel *ast_channel_bridge_peer(struct ast_channel *chan);
4701
4702/*!
4703 * \brief Get a reference to the channel's bridge pointer.
4704 * \since 12.0.0
4705 *
4706 * \param chan The channel whose bridge channel is desired
4707 *
4708 * \note This increases the reference count of the bridge_channel.
4709 * Use ao2_ref() or ao2_cleanup() to decrement the refcount when
4710 * you are finished with it.
4711 *
4712 * \note It is expected that the channel is locked prior to
4713 * placing this call.
4714 *
4715 * \retval NULL The channel has no bridge_channel
4716 * \retval non-NULL A reference to the bridge_channel
4717 */
4719
4720/*!
4721 * \since 12
4722 * \brief Gain control of a channel in the system
4723 *
4724 * The intention of this function is to take a channel that currently
4725 * is running in one thread and gain control of it in the current thread.
4726 * This can be used to redirect a channel to a different place in the dialplan,
4727 * for instance.
4728 *
4729 * \note This function is NOT intended to be used on bridged channels. If you
4730 * need to control a bridged channel, you can set a callback to be called
4731 * once the channel exits the bridge, and run your controlling logic in that
4732 * callback
4733 *
4734 * XXX Put name of callback-setting function in above paragraph once it is written
4735 *
4736 * \note When this function returns successfully, the yankee channel is in a state where
4737 * it cannot be used any further. Always use the returned channel instead.
4738 *
4739 * \note absolutely _NO_ channel locks should be held before calling this function.
4740 *
4741 * \note The dialplan location on the returned channel is where the channel
4742 * should be started in the dialplan if it is returned to it.
4743 *
4744 * \param yankee The channel to gain control of
4745 * \retval NULL Could not gain control of the channel
4746 * \retval non-NULL The channel
4747 */
4748struct ast_channel *ast_channel_yank(struct ast_channel *yankee);
4749
4750/*!
4751 * \since 12
4752 * \brief Move a channel from its current location to a new location
4753 *
4754 * The intention of this function is to have the destination channel
4755 * take on the identity of the source channel.
4756 *
4757 * \note This function is NOT intended to be used on bridged channels. If you
4758 * wish to move an unbridged channel into the place of a bridged channel, then
4759 * use ast_bridge_join() or ast_bridge_impart(). If you wish to move a bridged
4760 * channel into the place of another bridged channel, then use ast_bridge_move().
4761 *
4762 * \note When this function returns succesfully, the source channel is in a
4763 * state where its continued use is unreliable.
4764 *
4765 * \note absolutely _NO_ channel locks should be held before calling this function.
4766 *
4767 * \param dest The place to move the source channel
4768 * \param source The channel to move
4769 * \retval 0 Success
4770 * \retval non-zero Failure
4771 */
4772int ast_channel_move(struct ast_channel *dest, struct ast_channel *source);
4773
4774/*!
4775 * \since 12
4776 * \brief Forward channel stasis messages to the given endpoint
4777 *
4778 * \param chan The channel to forward from
4779 * \param endpoint The endpoint to forward to
4780 *
4781 * \retval 0 Success
4782 * \retval non-zero Failure
4783 */
4785
4786/*!
4787 * \brief Return the oldest linkedid between two channels.
4788 *
4789 * A channel linkedid is derived from the channel uniqueid which is formed like this:
4790 * [systemname-]ctime.seq
4791 *
4792 * The systemname, and the dash are optional, followed by the epoch time followed by an
4793 * integer sequence. Note that this is not a decimal number, since 1.2 is less than 1.11
4794 * in uniqueid land.
4795 *
4796 * To compare two uniqueids, we parse out the integer values of the time and the sequence
4797 * numbers and compare them, with time trumping sequence.
4798 *
4799 * \param a The linkedid value of the first channel to compare
4800 * \param b The linkedid value of the second channel to compare
4801 *
4802 * \retval NULL on failure
4803 * \retval The oldest linkedid value
4804 * \since 12.0.0
4805*/
4806const char *ast_channel_oldest_linkedid(const char *a, const char *b);
4807
4808/*!
4809 * \brief Check if the channel has active audiohooks, active framehooks, or a monitor.
4810 * \since 12.0.0
4811 *
4812 * \param chan The channel to check.
4813 *
4814 * \retval non-zero if channel has active audiohooks, framehooks, or monitor.
4815 */
4817
4818/*!
4819 * \brief Check if the channel has any active hooks that require audio.
4820 * \since 12.3.0
4821 *
4822 * \param chan The channel to check.
4823 *
4824 * \retval non-zero if channel has active audiohooks, audio framehooks, or monitor.
4825 */
4827
4828/*!
4829 * \brief Removes the trailing identifiers from a channel name string
4830 * \since 12.0.0
4831 *
4832 * \param channel_name string that you wish to turn into a dial string.
4833 * This string will be edited in place.
4834 */
4835void ast_channel_name_to_dial_string(char *channel_name);
4836
4837#define AST_MUTE_DIRECTION_READ (1 << 0)
4838#define AST_MUTE_DIRECTION_WRITE (1 << 1)
4839
4840/*!
4841 * \brief Suppress passing of a frame type on a channel
4842 *
4843 * \note The channel should be locked before calling this function.
4844 *
4845 * \param chan The channel to suppress
4846 * \param direction The direction in which to suppress
4847 * \param frametype The type of frame (AST_FRAME_VOICE, etc) to suppress
4848 *
4849 * \retval 0 Success
4850 * \retval -1 Failure
4851 */
4852int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype);
4853
4854/*!
4855 * \brief Stop suppressing of a frame type on a channel
4856 *
4857 * \note The channel should be locked before calling this function.
4858 *
4859 * \param chan The channel to stop suppressing
4860 * \param direction The direction in which to stop suppressing
4861 * \param frametype The type of frame (AST_FRAME_VOICE, etc) to stop suppressing
4862 *
4863 * \retval 0 Success
4864 * \retval -1 Failure
4865 */
4866int ast_channel_unsuppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype);
4867
4868/*!
4869 * \brief Simulate a DTMF end on a broken bridge channel.
4870 *
4871 * \param chan Channel sending DTMF that has not ended.
4872 * \param digit DTMF digit to stop.
4873 * \param start DTMF digit start time.
4874 * \param why Reason bridge broken.
4875 */
4876void ast_channel_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why);
4877
4878struct ast_bridge_features;
4879
4880/*!
4881 * \brief Gets the channel-attached features a channel has access to upon being bridged.
4882 *
4883 * \note The channel must be locked when calling this function.
4884 *
4885 * \param chan Which channel to get features for
4886 *
4887 * \retval non-NULL The features currently set for this channel
4888 * \retval NULL if the features have not been set
4889 */
4891
4892/*!
4893 * \brief Appends to the channel-attached features a channel has access to upon being bridged.
4894 *
4895 * \note The channel must be locked when calling this function.
4896 *
4897 * \param chan Which channel to set features for
4898 * \param features The feature set to append to the channel's features
4899 *
4900 * \retval 0 on success
4901 * \retval -1 on failure
4902 */
4903int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge_features *features);
4904
4905/*!
4906 * \brief Sets the channel-attached features a channel has access to upon being bridged.
4907 *
4908 * \note The channel must be locked when calling this function.
4909 *
4910 * \param chan Which channel to set features for
4911 * \param features The feature set with which to replace the channel's features
4912 *
4913 * \retval 0 on success
4914 * \retval -1 on failure
4915 */
4916int ast_channel_feature_hooks_replace(struct ast_channel *chan, struct ast_bridge_features *features);
4917
4919 /* Unable to determine what error occurred. */
4921 /* Channel with this ID already exists */
4923};
4924
4925/*!
4926 * \brief Get error code for latest channel operation.
4927 */
4929
4930/*!
4931 * \brief Am I currently running an intercept dialplan routine.
4932 * \since 13.14.0
4933 *
4934 * \details
4935 * A dialplan intercept routine is equivalent to an interrupt
4936 * routine. As such, the routine must be done quickly and you
4937 * do not have access to the media stream. These restrictions
4938 * are necessary because the media stream is the responsibility
4939 * of some other code and interfering with or delaying that
4940 * processing is bad.
4941 *
4942 * \retval 0 Not in an intercept routine.
4943 * \retval 1 In an intercept routine.
4944 */
4946
4947/*!
4948 * \brief Retrieve the topology of streams on a channel
4949 *
4950 * \param chan The channel to get the stream topology of
4951 *
4952 * \pre chan is locked
4953 *
4954 * \retval non-NULL success
4955 * \retval NULL failure
4956 */
4958 const struct ast_channel *chan);
4959
4960/*!
4961 * \brief Set the topology of streams on a channel
4962 *
4963 * \param chan The channel to set the stream topology on
4964 * \param topology The stream topology to set
4965 *
4966 * \pre chan is locked
4967 *
4968 * \note If topology is NULL a new empty topology will be created
4969 * and returned.
4970 *
4971 * \retval non-NULL Success
4972 * \retval NULL failure
4973 */
4975 struct ast_channel *chan, struct ast_stream_topology *topology);
4976
4977/*!
4978 * \brief Retrieve the default stream of a specific media type on a channel
4979 *
4980 * \param chan The channel to get the stream from
4981 * \param type The media type of the default stream
4982 *
4983 * \pre chan is locked
4984 *
4985 * \retval non-NULL success
4986 * \retval NULL failure
4987 */
4989
4990/*!
4991 * \brief Determine if a channel is multi-stream capable
4992 *
4993 * \param chan The channel to test
4994 *
4995 * \pre chan is locked
4996 *
4997 * \retval true if the channel is multi-stream capable.
4998 */
4999int ast_channel_is_multistream(struct ast_channel *chan);
5000
5001/*!
5002 * \brief Request that the stream topology of a channel change
5003 *
5004 * \param chan The channel to change
5005 * \param topology The new stream topology
5006 * \param change_source The source that initiated the change
5007 *
5008 * \note Absolutely _NO_ channel locks should be held before calling this function.
5009 *
5010 * \retval 0 request has been accepted to be attempted
5011 * \retval -1 request could not be attempted
5012 *
5013 * \note This function initiates an asynchronous request to change the stream topology. It is not
5014 * guaranteed that the topology will change and until an AST_CONTROL_STREAM_TOPOLOGY_CHANGED
5015 * frame is received from the channel the current handler of the channel must tolerate the
5016 * stream topology as it currently exists.
5017 *
5018 * \note This interface is provided for applications and resources to request that the topology change.
5019 * It is not for use by the channel driver itself.
5020 */
5022 struct ast_stream_topology *topology, void *change_source);
5023
5024/*!
5025 * \brief Provide notice to a channel that the stream topology has changed
5026 *
5027 * \param chan The channel to provide notice to
5028 * \param topology The new stream topology
5029 *
5030 * \pre chan is locked Absolutely _NO_ other channels can be locked.
5031 *
5032 * \retval 0 success
5033 * \retval -1 failure
5034 *
5035 * \note This interface is provided for applications and resources to accept a topology change.
5036 * It is not for use by the channel driver itself.
5037 */
5038int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology);
5039
5040/*!
5041 * \brief Provide notice from a channel that the topology has changed on it as a result
5042 * of the remote party renegotiating.
5043 *
5044 * \param chan The channel to provide notice from
5045 *
5046 * \retval 0 success
5047 * \retval -1 failure
5048 *
5049 * \note This interface is provided for channels to provide notice that a topology change
5050 * has occurred as a result of a remote party renegotiating the stream topology.
5051 */
5053
5054/*!
5055 * \brief Retrieve the source that initiated the last stream topology change
5056 *
5057 * \param chan The channel
5058 *
5059 * \retval The channel's stream topology change source
5060 */
5062
5063/*!
5064 * \brief Checks if a channel's technology implements a particular callback function
5065 * \since 18.0.0
5066 *
5067 * \param chan The channel
5068 * \param function The function to look for
5069 *
5070 * \retval 1 if the channel has a technology set and it implements the function
5071 * \retval 0 if the channel doesn't have a technology set or it doesn't implement the function
5072 */
5073#define ast_channel_has_tech_function(chan, function) \
5074 (ast_channel_tech(chan) ? ast_channel_tech(chan)->function != NULL : 0)
5075
5076/*!
5077 * \brief Get the name of the current channel storage driver
5078 *
5079 * \return The name of the current channel storage driver
5080 */
5082
5083/*!
5084 * \internal
5085 * \brief Set the current channel storage driver
5086 *
5087 * \param driver_name The name of the driver to set as the current driver
5088 *
5089 * \return 0 on success, -1 on failure
5090 *
5091 * \warning Changing the channel storage driver while Asterisk is running is
5092 * not supported. This function will return an error if called while
5093 * the ast_fully_booted flag is set. The function is exposed only
5094 * because options.c needs it to set the driver when reading
5095 * asterisk.conf.
5096 */
5097int internal_channel_set_current_storage_driver(const char *driver_name);
5098
5099#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:1791
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:361
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition chan_iax2.c:510
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:1692
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 ao2_iterator ast_channel_dialed_causes_iterator(const struct ast_channel *chan)
Retrieve an iterator for dialed cause information.
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:8030
int ast_senddigit_mf_begin(struct ast_channel *chan, char digit)
Send an MF digit to a channel.
Definition channel.c:4892
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition channel.c:3213
int ast_str2cause(const char *name) attribute_pure
Convert the string form of a cause code to a number.
Definition channel.c:626
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:2894
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:8162
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:494
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:11076
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:10979
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:2072
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:1430
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:1578
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:4774
enum ast_channel_error ast_channel_errno(void)
Get error code for latest channel operation.
Definition channel.c:11071
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition channel.c:2989
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:1336
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:1937
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:10606
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:673
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:3026
int ast_auto_answer(struct ast_channel *chan)
Answer a channel, if it's not already answered.
Definition channel.c:2845
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:2109
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:2917
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition channel.c:6518
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:9225
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:6620
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:11144
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition channel.c:2376
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:5955
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:2385
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:1744
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:5545
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
Definition channel.c:2423
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:1368
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:7958
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:5057
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:2729
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:10444
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:1631
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:2574
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:7433
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:4137
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:5074
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:2672
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:1349
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
Definition channel.c:1182
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:10674
int ast_transfer_protocol(struct ast_channel *chan, char *dest, int *protocol)
Transfer a channel (if supported) receieve protocol result.
Definition channel.c:6555
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:1706
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:8414
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition channel.c:4931
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition channel.c:1808
struct ast_channel * ast_channel_get_by_uniqueid(const char *uniqueid)
Find a channel by a uniqueid.
Definition channel.c:1442
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:1639
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:10639
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:6685
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:1661
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:1684
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:2557
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition channel.c:2059
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:2869
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:7934
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:4808
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:7656
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:7446
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:3195
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:5031
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:2153
const struct ast_channel_tech ast_kill_tech
Kill the channel channel driver technology descriptor.
Definition channel.c:435
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:6777
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:8035
@ 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
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:1798
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition channel.c:571
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:1714
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:1176
int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception)
Waits for input on an fd.
Definition channel.c:3018
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:11106
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:1775
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
Definition channel.c:1388
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition channel.c:8221
struct ast_namedgroups * ast_ref_namedgroups(struct ast_namedgroups *groups)
Definition channel.c:7812
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:11066
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition channel.c:8270
int internal_channel_set_current_storage_driver(const char *driver_name)
Definition channel.c:8085
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:2018
int ast_recvchar(struct ast_channel *chan, int timeout)
Receives a text character from a channel.
Definition channel.c:4763
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:10703
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:7516
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition channel.c:3200
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition channel.c:1289
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:10557
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:6033
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:4918
@ AST_CHANNEL_ERROR_ID_EXISTS
Definition channel.h:4922
@ AST_CHANNEL_ERROR_UNKNOWN
Definition channel.h:4920
int ast_channel_get_intercept_mode(void)
Am I currently running an intercept dialplan routine.
Definition channel.c:10439
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:2041
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:8316
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:3223
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:1915
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:8079
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:1973
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:2089
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:1171
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:8196
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:2359
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:1329
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:6491
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:2926
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:1907
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:1357
int ast_check_hangup_locked(struct ast_channel *chan)
Definition channel.c:460
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:524
unsigned long global_fin
Definition channel.c:99
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:967
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:8137
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:1400
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:2083
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:5842
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:5201
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:1994
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:10887
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:11061
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:469
int ast_channel_epfd(const struct ast_channel *chan)
int ast_undestroyed_channels(void)
Definition channel.c:505
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition channel.c:4312
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:2050
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:1296
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:11013
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:9199
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:5000
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:10776
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:10403
void ast_party_redirecting_reason_init(struct ast_party_redirecting_reason *init)
Initialize the given redirecting reason structure.
Definition channel.c:2066
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:5044
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:4866
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:4317
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:1986
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:1767
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
Definition channel.c:1625
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:7939
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:1958
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:7408
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:10489
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:6833
struct ast_channel * ast_channel_get_by_name(const char *search)
Find a channel by name or uniqueid.
Definition channel.c:1417
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:4327
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:2140
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:5819
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:1600
void ast_channel_fin_set(struct ast_channel *chan, unsigned int value)
@ 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
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition channel.c:1213
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:8891
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
Definition channel.c:2002
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:1007
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:1923
int ast_active_channels(void)
returns number of active/allocated channels
Definition channel.c:500
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:6416
struct ast_namedgroups * ast_get_namedgroups(const char *s)
Create an ast_namedgroups set with group names from comma separated string.
Definition channel.c:7749
int ast_channel_supports_html(struct ast_channel *channel)
Checks for HTML support on a channel.
Definition channel.c:6680
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:4130
@ AST_MONITOR_PAUSED
Definition channel.h:4132
@ AST_MONITOR_RUNNING
Definition channel.h:4131
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:446
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:1608
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:1737
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
Definition channel.c:10655
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:1945
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:5883
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:4322
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:2854
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition channel.c:10644
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:1571
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:4710
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:9374
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:2532
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition channel.c:11137
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
Definition channel.c:2462
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:6901
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:4402
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:986
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
Definition channel.c:1274
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:10390
int ast_channel_has_manager_vars(void)
Return whether or not any manager variables have been set.
Definition channel.c:7902
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:1883
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
Definition channel.c:4429
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:1876
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:1249
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:8803
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition channel.c:4981
int ast_channel_has_ari_vars(void)
Return whether or not any ARI variables have been set.
Definition channel.c:7907
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:540
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:1889
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:6231
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:11118
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:1653
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:3218
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition channel.c:5860
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:1752
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition channel.c:1678
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:2009
int ast_channel_get_up_time(struct ast_channel *chan)
Obtain how long it has been since the channel was answered.
Definition channel.c:2879
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:10660
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Set when to hang a channel up.
Definition channel.c:511
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:6692
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:9585
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:1555
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:189
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:10692
const char * ast_cause2str(int cause) attribute_pure
Gives the string form of a given cause code.
Definition channel.c:613
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:5009
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:6542
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:10949
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition channel.c:2166
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:2417
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:637
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:8399
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
Definition channel.c:2449
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:4416
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:6496
@ 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
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:2886
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:5581
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:6501
int ast_queue_answer(struct ast_channel *chan, const struct ast_stream_topology *topology)
Queue an ANSWER control frame with topology.
Definition channel.c:1304
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:7806
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition channel.c:1731
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:7496
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:5837
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:2864
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:9212
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:2032
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)
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:5206
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:1566
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:6615
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:8406
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:593
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:1315
int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition channel.c:7674
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition channel.c:2839
void ast_change_name(struct ast_channel *chan, const char *newname)
Change channel name.
Definition channel.c:6821
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:7692
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:7486
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:4332
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:1454
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:1380
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition channel.c:1561
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:6411
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.
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:10580
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:2724
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:3278
void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value)
@ 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_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:2122
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:1586
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)
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:10623
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:2390
void ast_party_redirecting_reason_free(struct ast_party_redirecting_reason *doomed)
Destroy the redirecting reason contents.
Definition channel.c:2103
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
Definition channel.c:1965
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:5878
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:7669
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:2551
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, int rdlock)
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::@235 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:2982
struct ast_group_info::@219 group_list
char * category
Definition channel.h:2984
struct ast_channel * chan
Definition channel.h:2983
struct ast_hangup_handler::@218 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::@217 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:216
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.