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