Asterisk - The Open Source Telephony Project GIT-master-754dea3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
channel.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 1999 - 2006, Digium, Inc.
5 *
6 * Mark Spencer <markster@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*! \file
20 * \brief General Asterisk PBX channel definitions.
21 * \par See also:
22 * \arg \ref Def_Channel
23 * \arg \ref channel_drivers
24 */
25
26/*! \page Def_Channel Asterisk Channels
27 \par What is a Channel?
28 A phone call through Asterisk consists of an incoming
29 connection and an outbound connection. Each call comes
30 in through a channel driver that supports one technology,
31 like SIP, DAHDI, IAX2 etc.
32 \par
33 Each channel driver, technology, has it's own private
34 channel or dialog structure, that is technology-dependent.
35 Each private structure is "owned" by a generic Asterisk
36 channel structure, defined in channel.h and handled by
37 channel.c .
38 \par Call scenario
39 This happens when an incoming call arrives to Asterisk
40 -# Call arrives on a channel driver interface
41 -# Channel driver creates a PBX channel and starts a
42 pbx thread on the channel
43 -# The dial plan is executed
44 -# At this point at least two things can happen:
45 -# The call is answered by Asterisk and
46 Asterisk plays a media stream or reads media
47 -# The dial plan forces Asterisk to create an outbound
48 call somewhere with the dial (see \ref app_dial.c)
49 application
50 .
51
52 \par Bridging channels
53 If Asterisk dials out this happens:
54 -# Dial creates an outbound PBX channel and asks one of the
55 channel drivers to create a call
56 -# When the call is answered, Asterisk bridges the media streams
57 so the caller on the first channel can speak with the callee
58 on the second, outbound channel
59 -# In some cases where we have the same technology on both
60 channels and compatible codecs, a native bridge is used.
61 In a native bridge, the channel driver handles forwarding
62 of incoming audio to the outbound stream internally, without
63 sending audio frames through the PBX.
64 -# In SIP, theres an "external native bridge" where Asterisk
65 redirects the endpoint, so audio flows directly between the
66 caller's phone and the callee's phone. Signalling stays in
67 Asterisk in order to be able to provide a proper CDR record
68 for the call.
69
70
71 \par Masquerading channels
72 In some cases, a channel can masquerade itself into another
73 channel. This happens frequently in call transfers, where
74 a new channel takes over a channel that is already involved
75 in a call. The new channel sneaks in and takes over the bridge
76 and the old channel, now a zombie, is hung up.
77
78 \par Reference
79 \arg channel.c - generic functions
80 \arg channel.h - declarations of functions, flags and structures
81 \arg translate.h - Transcoding support functions
82 \arg \ref channel_drivers - Implemented channel drivers
83 \arg \ref Def_Frame Asterisk Multimedia Frames
84 \arg \ref Def_Bridge
85
86*/
87/*! \page Def_Bridge Asterisk Channel Bridges
88
89 In Asterisk, there's several media bridges.
90
91 The Core bridge handles two channels (a "phone call") and bridge
92 them together.
93
94 The conference bridge (meetme) handles several channels simultaneously
95 with the support of an external timer (DAHDI timer). This is used
96 not only by the Conference application (meetme) but also by the
97 page application and the SLA system introduced in 1.4.
98 The conference bridge does not handle video.
99
100 When two channels of the same type connect, the channel driver
101 or the media subsystem used by the channel driver (i.e. RTP)
102 can create a native bridge without sending media through the
103 core.
104
105 Native bridging can be disabled by a number of reasons,
106 like DTMF being needed by the core or codecs being incompatible
107 so a transcoding module is needed.
108
109References:
110 \li \see ast_channel_early_bridge()
111 \li \see ast_channel_bridge()
112 \li \see app_meetme.c
113 \li \see ast_rtp_bridge()
114 \li \ref Def_Channel
115*/
116
117/*! \page AstFileDesc File descriptors
118 Asterisk File descriptors are connected to each channel (see \ref Def_Channel)
119 in the \ref ast_channel structure.
120*/
121
122#ifndef _ASTERISK_CHANNEL_H
123#define _ASTERISK_CHANNEL_H
124
125#include "asterisk/alertpipe.h"
126#include "asterisk/abstract_jb.h"
127#include "asterisk/astobj2.h"
128#include "asterisk/poll-compat.h"
129
130#if defined(__cplusplus) || defined(c_plusplus)
131extern "C" {
132#endif
133
134#define AST_MAX_EXTENSION 80 /*!< Max length of an extension */
135#define AST_MAX_CONTEXT 80 /*!< Max length of a context */
136
137/*!
138 * Max length of a channel uniqueid reported to the outside world.
139 *
140 * \details
141 * 149 = 127 (max systemname) + "-" + 10 (epoch timestamp)
142 * + "." + 10 (monotonically incrementing integer).
143 *
144 * \note If this value is ever changed, MAX_CHANNEL_ID should
145 * be updated in rtp_engine.h.
146 */
147#define AST_MAX_PUBLIC_UNIQUEID 149
148
149#define AST_MAX_TENANT_ID 64 /*!< Max length of a channel tenant_id */
150
151/*!
152 * The number of buckets to store channels or channel information
153 */
154#ifdef LOW_MEMORY
155#define AST_NUM_CHANNEL_BUCKETS 61
156#else
157#define AST_NUM_CHANNEL_BUCKETS 1567
158#endif
159
160/*!
161 * Maximum size of an internal Asterisk channel unique ID.
162 *
163 * \details
164 * Add two for the Local;2 channel to append a ';2' if needed
165 * plus nul terminator.
166 *
167 * \note If this value is ever changed, MAX_CHANNEL_ID should
168 * be updated in rtp_engine.h.
169 */
170#define AST_MAX_UNIQUEID (AST_MAX_PUBLIC_UNIQUEID + 2 + 1)
171
172#define AST_MAX_ACCOUNT_CODE 80 /*!< Max length of an account code */
173#define AST_CHANNEL_NAME 80 /*!< Max length of an ast_channel name */
174#define MAX_LANGUAGE 40 /*!< Max length of the language setting */
175#define MAX_MUSICCLASS 80 /*!< Max length of the music class setting */
176#define AST_MAX_USER_FIELD 256 /*!< Max length of the channel user field */
177
178#include "asterisk/frame.h"
179#include "asterisk/chanvars.h"
180#include "asterisk/config.h"
181#include "asterisk/lock.h"
182#include "asterisk/cdr.h"
183#include "asterisk/utils.h"
184#include "asterisk/linkedlists.h"
186#include "asterisk/datastore.h"
187#include "asterisk/format_cap.h"
189#include "asterisk/ccss.h"
190#include "asterisk/framehook.h"
191#include "asterisk/stasis.h"
192#include "asterisk/endpoints.h"
193
194#define DATASTORE_INHERIT_FOREVER INT_MAX
195
196#define AST_MAX_FDS 11 /*!< original maximum number of file descriptors */
197#define AST_EXTENDED_FDS 12 /*!< the start of extended file descriptor positions */
198/*
199 * We have AST_MAX_FDS file descriptors in a channel.
200 * Some of them have a fixed use:
201 */
202#define AST_ALERT_FD (AST_MAX_FDS-1) /*!< used for alertpipe */
203#define AST_TIMING_FD (AST_MAX_FDS-2) /*!< used for timingfd */
204#define AST_AGENT_FD (AST_MAX_FDS-3) /*!< unused - formerly used by agents for pass through */
205#define AST_GENERATOR_FD (AST_MAX_FDS-4) /*!< unused - formerly used by generator */
206#define AST_JITTERBUFFER_FD (AST_MAX_FDS-5) /*!< used by generator */
207
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 On invocation, max wait time. Upon returning, how long the wait
2039 * actually was (in/out parameter).
2040 * \details
2041 * Big momma function here. Wait for activity on any of the n channels, or any of the nfds
2042 * file descriptors. -1 can be passed as the ms timeout to wait forever, 0 to
2043 * return instantly if theres no activity immediantely available.
2044 * \return Returns the channel with activity, or NULL on error or if an FD
2045 * came first. If the FD came first, it will be returned in outfd, otherwise, outfd
2046 * will be -1
2047 */
2048struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n,
2049 int *fds, int nfds, int *exception, int *outfd, int *ms);
2050
2051/*!
2052 * \brief Waits for input on a group of channels
2053 * Wait for input on an array of channels for a given # of milliseconds.
2054 * \return Return channel with activity, or NULL if none has activity.
2055 * \param chan an array of pointers to channels
2056 * \param n number of channels that are to be waited upon
2057 * \param ms time "ms" is modified in-place, if applicable
2058 */
2059struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms);
2060
2061/*!
2062 * \brief Waits for input on an fd
2063 * \note This version works on fd's only. Be careful with it.
2064 */
2065int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);
2066
2067
2068/*!
2069 * \brief Reads a frame
2070 *
2071 * \param chan channel to read a frame from
2072 *
2073 * \return Returns a frame, or NULL on error. If it returns NULL, you
2074 * best just stop reading frames and assume the channel has been
2075 * disconnected.
2076 *
2077 * \note This function will filter frames received from the channel so
2078 * that only frames from the default stream for each media type
2079 * are returned. All other media frames from other streams will
2080 * be absorbed internally and a NULL frame returned instead.
2081 */
2082struct ast_frame *ast_read(struct ast_channel *chan);
2083
2084/*!
2085 * \brief Reads a frame, but does not filter to just the default streams
2086 *
2087 * \param chan channel to read a frame from
2088 *
2089 * \return Returns a frame, or NULL on error. If it returns NULL, you
2090 * best just stop reading frames and assume the channel has been
2091 * disconnected.
2092 *
2093 * \note This function will not perform any filtering and will return
2094 * media frames from all streams on the channel. To determine which
2095 * stream a frame originated from the stream_num on it can be
2096 * examined.
2097 */
2098struct ast_frame *ast_read_stream(struct ast_channel *chan);
2099
2100/*!
2101 * \brief Reads a frame, returning AST_FRAME_NULL frame if audio.
2102 * \param chan channel to read a frame from
2103 * \return Returns a frame, or NULL on error. If it returns NULL, you
2104 * best just stop reading frames and assume the channel has been
2105 * disconnected.
2106 * \note Audio is replaced with AST_FRAME_NULL to avoid
2107 * transcode when the resulting audio is not necessary.
2108 */
2109struct ast_frame *ast_read_noaudio(struct ast_channel *chan);
2110
2111/*!
2112 * \brief Reads a frame, but does not filter to just the default streams,
2113 * returning AST_FRAME_NULL frame if audio.
2114 *
2115 * \param chan channel to read a frame from
2116 *
2117 * \return Returns a frame, or NULL on error. If it returns NULL, you
2118 * best just stop reading frames and assume the channel has been
2119 * disconnected.
2120 *
2121 * \note This function will not perform any filtering and will return
2122 * media frames from all streams on the channel. To determine which
2123 * stream a frame originated from the stream_num on it can be
2124 * examined.
2125 *
2126 * \note Audio is replaced with AST_FRAME_NULL to avoid
2127 * transcode when the resulting audio is not necessary.
2128 */
2129struct ast_frame *ast_read_stream_noaudio(struct ast_channel *chan);
2130
2131/*!
2132 * \brief Write a frame to a channel
2133 * This function writes the given frame to the indicated channel.
2134 * \param chan destination channel of the frame
2135 * \param frame frame that will be written
2136 * \return It returns 0 on success, -1 on failure.
2137 */
2138int ast_write(struct ast_channel *chan, struct ast_frame *frame);
2139
2140/*!
2141 * \brief Write video frame to a channel
2142 * This function writes the given frame to the indicated channel.
2143 * \param chan destination channel of the frame
2144 * \param frame frame that will be written
2145 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
2146 */
2147int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);
2148
2149/*!
2150 * \brief Write text frame to a channel
2151 * This function writes the given frame to the indicated channel.
2152 * \param chan destination channel of the frame
2153 * \param frame frame that will be written
2154 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
2155 */
2156int ast_write_text(struct ast_channel *chan, struct ast_frame *frame);
2157
2158/*!
2159 * \brief Write a frame to a stream
2160 * This function writes the given frame to the indicated stream on the channel.
2161 * \param chan destination channel of the frame
2162 * \param stream_num destination stream on the channel
2163 * \param frame frame that will be written
2164 * \return It returns 0 on success, -1 on failure.
2165 * \note If -1 is provided as the stream number and a media frame is provided the
2166 * function will write to the default stream of the type of media.
2167 */
2168int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *frame);
2169
2170/*! \brief Send empty audio to prime a channel driver */
2171int ast_prod(struct ast_channel *chan);
2172
2173/*!
2174 * \brief Set specific read path on channel.
2175 * \since 13.4.0
2176 *
2177 * \param chan Channel to setup read path.
2178 * \param raw_format Format to expect from the channel driver.
2179 * \param core_format What the core wants to read.
2180 *
2181 * \pre chan is locked
2182 *
2183 * \retval 0 on success.
2184 * \retval -1 on error.
2185 */
2186int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format);
2187
2188/*!
2189 * \brief Set specific write path on channel.
2190 * \since 13.13.0
2191 *
2192 * \param chan Channel to setup write path.
2193 * \param core_format What the core wants to write.
2194 * \param raw_format Raw write format.
2195 *
2196 * \pre chan is locked
2197 *
2198 * \retval 0 on success.
2199 * \retval -1 on error.
2200 */
2201int ast_set_write_format_path(struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format);
2202
2203/*!
2204 * \brief Sets read format on channel chan from capabilities
2205 * Set read format for channel to whichever component of "format" is best.
2206 * \param chan channel to change
2207 * \param formats new formats to pick from for reading
2208 * \return Returns 0 on success, -1 on failure
2209 */
2211
2212/*!
2213 * \brief Sets read format on channel chan
2214 * \param chan channel to change
2215 * \param format format to set for reading
2216 * \return Returns 0 on success, -1 on failure
2217 */
2218int ast_set_read_format(struct ast_channel *chan, struct ast_format *format);
2219
2220/*!
2221 * \brief Sets write format on channel chan
2222 * Set write format for channel to whichever component of "format" is best.
2223 * \param chan channel to change
2224 * \param formats new formats to pick from for writing
2225 * \return Returns 0 on success, -1 on failure
2226 */
2228
2229/*!
2230 * \brief Sets write format on channel chan
2231 * \param chan channel to change
2232 * \param format format to set for writing
2233 * \return Returns 0 on success, -1 on failure
2234 */
2235int ast_set_write_format(struct ast_channel *chan, struct ast_format *format);
2236
2237/*!
2238 * \brief Sets write format for a channel.
2239 * All internal data will than be handled in an interleaved format. (needed by binaural opus)
2240 *
2241 * \param chan channel to change
2242 * \param format format to set for writing
2243 * \return Returns 0 on success, -1 on failure
2244 */
2245int ast_set_write_format_interleaved_stereo(struct ast_channel *chan, struct ast_format *format);
2246
2247/*!
2248 * \brief Sends text to a channel
2249 *
2250 * \param chan channel to act upon
2251 * \param text string of text to send on the channel
2252 *
2253 * \details
2254 * Write text to a display on a channel
2255 *
2256 * \note The channel does not need to be locked before calling this function.
2257 *
2258 * \retval 0 on success
2259 * \retval -1 on failure
2260 */
2261int ast_sendtext(struct ast_channel *chan, const char *text);
2262
2263/*!
2264 * \brief Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback
2265 * \since 13.22.0
2266 * \since 15.5.0
2267 *
2268 * \param chan channel to act upon
2269 * \param msg ast_msg_data structure
2270 *
2271 * \details
2272 * Write text to a display on a channel. If the channel driver doesn't support the
2273 * send_text_data callback. then the original send_text callback will be used if
2274 * available.
2275 *
2276 * \note The channel does not need to be locked before calling this function.
2277 *
2278 * \retval 0 on success
2279 * \retval -1 on failure
2280 */
2281int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg);
2282
2283/*!
2284 * \brief Receives a text character from a channel
2285 * \param chan channel to act upon
2286 * \param timeout timeout in milliseconds (0 for infinite wait)
2287 * \details
2288 * Read a char of text from a channel
2289 * \return 0 on success, -1 on failure
2290 */
2291int ast_recvchar(struct ast_channel *chan, int timeout);
2292
2293/*!
2294 * \brief End sending an MF digit to a channel.
2295 * \param chan channel to act upon
2296 * \return Returns 0 on success, -1 on failure
2297 */
2298int ast_senddigit_mf_end(struct ast_channel *chan);
2299
2300/*!
2301 * \brief Send an MF digit to a channel.
2302 *
2303 * \param chan channel to act upon
2304 * \param digit the MF digit to send, encoded in ASCII
2305 * \param duration the duration of a numeric digit ending in ms
2306 * \param durationkp the duration of a KP digit ending in ms
2307 * \param durationst the duration of a ST, STP, ST2P, or ST3P digit ending in ms
2308 * \param is_external 1 if called by a thread that is not the channel's media
2309 * handler thread, 0 if called by the channel's media handler
2310 * thread.
2311 *
2312 * \return 0 on success, -1 on failure
2313 */
2314int ast_senddigit_mf(struct ast_channel *chan, char digit, unsigned int duration,
2315 unsigned int durationkp, unsigned int durationst, int is_external);
2316
2317/*!
2318 * \brief Send a DTMF digit to a channel.
2319 *
2320 * \param chan channel to act upon
2321 * \param digit the DTMF digit to send, encoded in ASCII
2322 * \param duration the duration of the digit ending in ms
2323 *
2324 * \pre This must only be called by the channel's media handler thread.
2325 *
2326 * \return 0 on success, -1 on failure
2327 */
2328int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
2329
2330/*!
2331 * \brief Send a DTMF digit to a channel from an external thread.
2332 *
2333 * \param chan channel to act upon
2334 * \param digit the DTMF digit to send, encoded in ASCII
2335 * \param duration the duration of the digit ending in ms
2336 *
2337 * \pre This must only be called by threads that are not the channel's
2338 * media handler thread.
2339 *
2340 * \return 0 on success, -1 on failure
2341 */
2342int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration);
2343
2344/*!
2345 * \brief Send an MF digit to a channel.
2346 * \param chan channel to act upon
2347 * \param digit the MF digit to send, encoded in ASCII
2348 * \return 0 on success, -1 on failure
2349 */
2350int ast_senddigit_mf_begin(struct ast_channel *chan, char digit);
2351
2352/*!
2353 * \brief Send a DTMF digit to a channel.
2354 * \param chan channel to act upon
2355 * \param digit the DTMF digit to send, encoded in ASCII
2356 * \return 0 on success, -1 on failure
2357 */
2358int ast_senddigit_begin(struct ast_channel *chan, char digit);
2359
2360/*!
2361 * \brief Send a DTMF digit to a channel.
2362 * \param chan channel to act upon
2363 * \param digit the DTMF digit to send, encoded in ASCII
2364 * \param duration the duration of the digit ending in ms
2365 * \return Returns 0 on success, -1 on failure
2366 */
2367int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration);
2368
2369/*!
2370 * \brief Receives a text string from a channel
2371 * Read a string of text from a channel
2372 * \param chan channel to act upon
2373 * \param timeout timeout in milliseconds (0 for infinite wait)
2374 * \return the received text, or NULL to signify failure.
2375 */
2376char *ast_recvtext(struct ast_channel *chan, int timeout);
2377
2378/*!
2379 * \brief Waits for a digit
2380 * \param c channel to wait for a digit on
2381 * \param ms how many milliseconds to wait (<0 for indefinite).
2382 * \return Returns <0 on error, 0 on no entry, and the digit on success.
2383 */
2384int ast_waitfordigit(struct ast_channel *c, int ms);
2385
2386/*!
2387 * \brief Wait for a digit
2388 * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
2389 * \param c channel to wait for a digit on
2390 * \param ms how many milliseconds to wait (<0 for indefinite).
2391 * \param breakon string of DTMF digits to break upon or NULL for any.
2392 * \param audiofd audio file descriptor to write to if audio frames are received
2393 * \param ctrlfd control file descriptor to monitor for reading
2394 * \return Returns 1 if ctrlfd becomes available
2395 */
2396int ast_waitfordigit_full(struct ast_channel *c, int ms, const char *breakon, int audiofd, int ctrlfd);
2397
2398/*!
2399 * \brief Reads multiple digits
2400 * \param c channel to read from
2401 * \param s string to read in to. Must be at least the size of your length
2402 * \param len how many digits to read (maximum)
2403 * \param timeout how long to timeout between digits
2404 * \param rtimeout timeout to wait on the first digit
2405 * \param enders digits to end the string
2406 * \details
2407 * Read in a digit string "s", max length "len", maximum timeout between
2408 * digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout
2409 * for the first digit.
2410 * \return Returns 0 on normal return, or 1 on a timeout. In the case of
2411 * a timeout, any digits that were read before the timeout will still be available in s.
2412 * RETURNS 2 in full version when ctrlfd is available, NOT 1
2413 */
2414int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders);
2415int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd);
2416
2417/*! \brief Report DTMF on channel 0 */
2418#define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0)
2419/*! \brief Report DTMF on channel 1 */
2420#define AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1)
2421
2422
2423/*!
2424 * \brief Make the frame formats of two channels compatible.
2425 *
2426 * \param chan First channel to make compatible. Should be the calling party.
2427 * \param peer Other channel to make compatible. Should be the called party.
2428 *
2429 * \note Absolutely _NO_ channel locks should be held before calling this function.
2430 *
2431 * \details
2432 * Set two channels to compatible frame formats in both
2433 * directions. The path from peer to chan is made compatible
2434 * first to allow for in-band audio in case the other direction
2435 * cannot be made compatible.
2436 *
2437 * \retval 0 on success.
2438 * \retval -1 on error.
2439 */
2440int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer);
2441
2442/*!
2443 * \brief Bridge two channels together (early)
2444 * \param c0 first channel to bridge
2445 * \param c1 second channel to bridge
2446 * \details
2447 * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
2448 * \return Returns 0 on success and -1 if it could not be done
2449 */
2450int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
2451
2452/*!
2453 * \brief Gives the string form of a given cause code.
2454 *
2455 * \param cause cause to get the description of
2456 * \return the text form of the binary cause code given
2457 */
2458const char *ast_cause2str(int cause) attribute_pure;
2459
2460/*!
2461 * \brief Convert the string form of a cause code to a number
2462 *
2463 * \param name string form of the cause
2464 * \return the cause code
2465 */
2466int ast_str2cause(const char *name) attribute_pure;
2467
2468/*!
2469 * \brief Gives the string form of a given channel state
2470 *
2471 * \param state state to get the name of
2472 * \return the text form of the binary state given
2473 *
2474 * \note This function is not reentrant.
2475 */
2476const char *ast_state2str(enum ast_channel_state state);
2477
2478/*!
2479 * \brief Gives the string form of a given transfer capability
2480 *
2481 * \param transfercapability transfer capability to get the name of
2482 * \return the text form of the binary transfer capability
2483 */
2484char *ast_transfercapability2str(int transfercapability) attribute_const;
2485
2486/*
2487 * Options: Some low-level drivers may implement "options" allowing fine tuning of the
2488 * low level channel. See frame.h for options. Note that many channel drivers may support
2489 * none or a subset of those features, and you should not count on this if you want your
2490 * asterisk application to be portable. They're mainly useful for tweaking performance
2491 */
2492
2493/*!
2494 * \brief Sets an option on a channel
2495 *
2496 * \param channel channel to set options on
2497 * \param option option to change
2498 * \param data data specific to option
2499 * \param datalen length of the data
2500 * \param block blocking or not
2501 * \details
2502 * Set an option on a channel (see frame.h), optionally blocking awaiting the reply
2503 * \return 0 on success and -1 on failure
2504 */
2505int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
2506
2507/*!
2508 * \brief Checks the value of an option
2509 *
2510 * Query the value of an option
2511 * Works similarly to setoption except only reads the options.
2512 */
2513int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block);
2514
2515/*!
2516 * \brief Checks for HTML support on a channel
2517 * \return 0 if channel does not support HTML or non-zero if it does
2518 */
2519int ast_channel_supports_html(struct ast_channel *channel);
2520
2521/*!
2522 * \brief Sends HTML on given channel
2523 * Send HTML or URL on link.
2524 * \return 0 on success or -1 on failure
2525 */
2526int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen);
2527
2528/*!
2529 * \brief Sends a URL on a given link
2530 * Send URL on link.
2531 * \return 0 on success or -1 on failure
2532 */
2533int ast_channel_sendurl(struct ast_channel *channel, const char *url);
2534
2535/*!
2536 * \brief Defers DTMF so that you only read things like hangups and audio.
2537 * \return non-zero if channel was already DTMF-deferred or
2538 * 0 if channel is just now being DTMF-deferred
2539 */
2540int ast_channel_defer_dtmf(struct ast_channel *chan);
2541
2542/*! Undo defer. ast_read will return any DTMF characters that were queued */
2543void ast_channel_undefer_dtmf(struct ast_channel *chan);
2544
2545/*! \return number of channels available for lookup */
2546int ast_active_channels(void);
2547
2548/*! \return the number of channels not yet destroyed */
2549int ast_undestroyed_channels(void);
2550
2551/*! Activate a given generator */
2552int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);
2553
2554/*! Deactivate an active generator */
2555void ast_deactivate_generator(struct ast_channel *chan);
2556
2557/*!
2558 * \since 13.27.0
2559 * \since 16.4.0
2560 * \brief Obtain how long it's been, in milliseconds, since the channel was created
2561 *
2562 * \param chan The channel object
2563 *
2564 * \retval 0 if the time value cannot be computed (or you called this really fast)
2565 * \retval The number of milliseconds since channel creation
2566 */
2567int64_t ast_channel_get_duration_ms(struct ast_channel *chan);
2568
2569/*!
2570 * \since 12
2571 * \brief Obtain how long the channel since the channel was created
2572 *
2573 * \param chan The channel object
2574 *
2575 * \retval 0 if the time value cannot be computed (or you called this really fast)
2576 * \retval The number of seconds the channel has been up
2577 */
2578int ast_channel_get_duration(struct ast_channel *chan);
2579
2580/*!
2581 * \since 13.27.0
2582 * \since 16.4.0
2583 * \brief Obtain how long it has been since the channel was answered in ms
2584 *
2585 * \param chan The channel object
2586 *
2587 * \retval 0 if the channel isn't answered (or you called this really fast)
2588 * \retval The number of milliseconds the channel has been up
2589 */
2590int64_t ast_channel_get_up_time_ms(struct ast_channel *chan);
2591
2592/*!
2593 * \since 12
2594 * \brief Obtain how long it has been since the channel was answered
2595 *
2596 * \param chan The channel object
2597 *
2598 * \retval 0 if the channel isn't answered (or you called this really fast)
2599 * \retval The number of seconds the channel has been up
2600 */
2601int ast_channel_get_up_time(struct ast_channel *chan);
2602
2603/*!
2604 * \brief Set caller ID number, name and ANI and generate AMI event.
2605 *
2606 * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead.
2607 * \note The channel does not need to be locked before calling this function.
2608 */
2609void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani);
2610
2611/*!
2612 * \brief Set the caller id information in the Asterisk channel
2613 * \since 1.8
2614 *
2615 * \param chan Asterisk channel to set caller id information
2616 * \param caller Caller id information
2617 * \param update What caller information to update. NULL if all.
2618 *
2619 * \note The channel does not need to be locked before calling this function.
2620 */
2621void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2622
2623/*!
2624 * \brief Set the caller id information in the Asterisk channel and generate an AMI event
2625 * if the caller id name or number changed.
2626 * \since 1.8
2627 *
2628 * \param chan Asterisk channel to set caller id information
2629 * \param caller Caller id information
2630 * \param update What caller information to update. NULL if all.
2631 *
2632 * \note The channel does not need to be locked before calling this function.
2633 */
2634void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2635
2636/*! Set the file descriptor on the channel */
2637void ast_channel_set_fd(struct ast_channel *chan, int which, int fd);
2638
2639/*! Start a tone going */
2640int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2641/*! Stop a tone from playing */
2642void ast_tonepair_stop(struct ast_channel *chan);
2643/*! Play a tone pair for a given amount of time */
2644int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2645
2646/*!
2647 * \brief Automatically service a channel for us...
2648 *
2649 * \retval 0 success
2650 * \retval -1 failure, or the channel is already being autoserviced
2651 */
2652int ast_autoservice_start(struct ast_channel *chan);
2653
2654/*!
2655 * \brief Stop servicing a channel for us...
2656 *
2657 * \note if chan is locked prior to calling ast_autoservice_stop, it
2658 * is likely that there will be a deadlock between the thread that calls
2659 * ast_autoservice_stop and the autoservice thread. It is important
2660 * that chan is not locked prior to this call
2661 *
2662 * \param chan
2663 * \retval 0 success
2664 * \retval -1 error, or the channel has been hungup
2665 */
2666int ast_autoservice_stop(struct ast_channel *chan);
2667
2668/*!
2669 * \brief Put chan into autoservice while hanging up peer.
2670 * \since 11.0
2671 *
2672 * \param chan Chan to put into autoservice.
2673 * \param peer Chan to run hangup handlers and hangup.
2674 */
2675void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer);
2676
2677/*!
2678 * \brief Ignore certain frame types
2679 * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames
2680 * while a channel is in autoservice and queue them up when taken out of
2681 * autoservice. When this is not desireable, this API may be used to
2682 * cause the channel to ignore those frametypes after the channel is put
2683 * into autoservice, but before autoservice is stopped.
2684 * \retval 0 success
2685 * \retval -1 channel is not in autoservice
2686 */
2687int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype);
2688
2689/*!
2690 * \brief Enable or disable timer ticks for a channel
2691 *
2692 * \param c channel
2693 * \param rate number of timer ticks per second
2694 * \param func callback function
2695 * \param data
2696 *
2697 * \details
2698 * If timers are supported, force a scheduled expiration on the
2699 * timer fd, at which point we call the callback function / data
2700 *
2701 * \note Call this function with a rate of 0 to turn off the timer ticks
2702 *
2703 * \version 1.6.1 changed samples parameter to rate, accommodates new timing methods
2704 */
2705int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data);
2706int ast_settimeout_full(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data, unsigned int is_ao2_obj);
2707
2708/*!
2709 * \brief Transfer a channel (if supported).
2710 * \retval -1 on error
2711 * \retval 0 if not supported
2712 * \retval 1 if supported and requested
2713 * \param chan current channel
2714 * \param dest destination extension for transfer
2715 */
2716int ast_transfer(struct ast_channel *chan, char *dest);
2717
2718/*!
2719 * \brief Transfer a channel (if supported) receieve protocol result.
2720 * \retval -1 on error
2721 * \retval 0 if not supported
2722 * \retval 1 if supported and requested
2723 * \param chan channel to transfer
2724 * \param dest destination extension to transfer to
2725 * \param protocol protocol is the protocol result
2726 * SIP example, 0=success, 3xx-6xx is SIP error code
2727 */
2728int ast_transfer_protocol(struct ast_channel *chan, char *dest, int *protocol);
2729
2730/*!
2731 * \brief Inherits channel variable from parent to child channel
2732 * \param parent Parent channel
2733 * \param child Child channel
2734 *
2735 * \details
2736 * Scans all channel variables in the parent channel, looking for those
2737 * that should be copied into the child channel.
2738 * Variables whose names begin with a single '_' are copied into the
2739 * child channel with the prefix removed.
2740 * Variables whose names begin with '__' are copied into the child
2741 * channel with their names unchanged.
2742 */
2743void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child);
2744
2745/*!
2746 * \brief adds a list of channel variables to a channel
2747 * \param chan the channel
2748 * \param vars a linked list of variables
2749 *
2750 * \pre chan is locked
2751 *
2752 * \details
2753 * Variable names can be for a regular channel variable or a dialplan function
2754 * that has the ability to be written to.
2755 */
2756void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars);
2757
2758/*!
2759 * \brief An opaque 'object' structure use by silence generators on channels.
2760 */
2762
2763/*!
2764 * \brief Starts a silence generator on the given channel.
2765 * \param chan The channel to generate silence on
2766 * \return An ast_silence_generator pointer, or NULL if an error occurs
2767 *
2768 * \details
2769 * This function will cause SLINEAR silence to be generated on the supplied
2770 * channel until it is disabled; if the channel cannot be put into SLINEAR
2771 * mode then the function will fail.
2772 *
2773 * \note
2774 * The pointer returned by this function must be preserved and passed to
2775 * ast_channel_stop_silence_generator when you wish to stop the silence
2776 * generation.
2777 */
2779
2780/*!
2781 * \brief Stops a previously-started silence generator on the given channel.
2782 * \param chan The channel to operate on
2783 * \param state The ast_silence_generator pointer return by a previous call to
2784 * ast_channel_start_silence_generator.
2785 *
2786 * \details
2787 * This function will stop the operating silence generator and return the channel
2788 * to its previous write format.
2789 */
2791
2792/*!
2793 * \brief Determine which channel has an older linkedid
2794 * \param a First channel
2795 * \param b Second channel
2796 * \return Returns an ast_channel structure that has oldest linkedid
2797 */
2799
2800/*!
2801 * \brief Copy the full linkedid channel id structure from one channel to another
2802 * \param dest Destination to copy linkedid to
2803 * \param source Source channel to copy linkedid from
2804 */
2805void ast_channel_internal_copy_linkedid(struct ast_channel *dest, struct ast_channel *source);
2806
2807/*!
2808 * \brief Swap uniqueid and linkedid beteween two channels
2809 * \param a First channel
2810 * \param b Second channel
2811 *
2812 * \note
2813 * This is used in masquerade to exchange identities
2814 */
2816
2817/*!
2818 * \brief Swap topics beteween two channels
2819 * \param a First channel
2820 * \param b Second channel
2821 *
2822 * \note
2823 * This is used in masquerade to exchange topics for message routing
2824 */
2826
2827/*!
2828 * \brief Swap endpoint_forward between two channels
2829 * \param a First channel
2830 * \param b Second channel
2831 *
2832 * \note
2833 * This is used in masquerade to exchange endpoint details if one of the two or both
2834 * the channels were created with endpoint
2835 */
2837
2838/*!
2839 * \brief Swap snapshots beteween two channels
2840 * \param a First channel
2841 * \param b Second channel
2842 *
2843 * \note
2844 * This is used in masquerade to exchange snapshots
2845 */
2847
2848/*!
2849 * \brief Set uniqueid and linkedid string value only (not time)
2850 * \param chan The channel to set the uniqueid to
2851 * \param uniqueid The uniqueid to set
2852 * \param linkedid The linkedid to set
2853 *
2854 * \note
2855 * This is used only by ast_cel_fabricate_channel_from_event()
2856 * to create a temporary fake channel - time values are invalid
2857 */
2858void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid);
2859
2860/* Misc. functions below */
2861
2862/*!
2863 * \brief if fd is a valid descriptor, set *pfd with the descriptor
2864 * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the
2865 * return value to the index into the array)
2866 */
2867static inline int ast_add_fd(struct pollfd *pfd, int fd)
2868{
2869 pfd->fd = fd;
2870 pfd->events = POLLIN | POLLPRI;
2871 return fd >= 0;
2872}
2873
2874/*! \brief Helper function for migrating select to poll */
2875static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
2876{
2877 int x;
2878 int dummy = 0;
2879
2880 if (fd < 0)
2881 return 0;
2882 if (!start)
2883 start = &dummy;
2884 for (x = *start; x < maximum; x++)
2885 if (pfds[x].fd == fd) {
2886 if (x == *start)
2887 (*start)++;
2888 return pfds[x].revents;
2889 }
2890 return 0;
2891}
2892
2893/*!
2894 * \brief Retrieves the current T38 state of a channel
2895 *
2896 * \note Absolutely _NO_ channel locks should be held before calling this function.
2897 */
2899{
2901 int datalen = sizeof(state);
2902
2904
2905 return state;
2906}
2907
2908/*!
2909 * \brief Set the blocking indication on the channel.
2910 *
2911 * \details
2912 * Indicate that the thread handling the channel is about to do a blocking
2913 * operation to wait for media on the channel. (poll, read, or write)
2914 *
2915 * Masquerading and ast_queue_frame() use this indication to wake up the thread.
2916 *
2917 * \pre The channel needs to be locked
2918 */
2919#define CHECK_BLOCKING(c) \
2920 do { \
2921 if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) { \
2922 /* This should not happen as there should only be one thread handling a channel's media at a time. */ \
2923 ast_log(LOG_DEBUG, "Thread LWP %d is blocking '%s', already blocked by thread LWP %d in procedure %s\n", \
2924 ast_get_tid(), ast_channel_name(c), \
2925 ast_channel_blocker_tid(c), ast_channel_blockproc(c)); \
2926 ast_assert(0); \
2927 } \
2928 ast_channel_blocker_tid_set((c), ast_get_tid()); \
2929 ast_channel_blocker_set((c), pthread_self()); \
2930 ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
2931 ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
2932 } while (0)
2933
2934ast_group_t ast_get_group(const char *s);
2935
2936/*! \brief Print call and pickup groups into buffer */
2937char *ast_print_group(char *buf, int buflen, ast_group_t group);
2938
2939/*! \brief Opaque struct holding a namedgroups set, i.e. a set of group names */
2940struct ast_namedgroups;
2941
2942/*! \brief Create an ast_namedgroups set with group names from comma separated string */
2943struct ast_namedgroups *ast_get_namedgroups(const char *s);
2944struct ast_namedgroups *ast_unref_namedgroups(struct ast_namedgroups *groups);
2945struct ast_namedgroups *ast_ref_namedgroups(struct ast_namedgroups *groups);
2946/*! \brief Return TRUE if group a and b contain at least one common groupname */
2947int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups *b);
2948
2949/*! \brief Print named call groups and named pickup groups */
2950char *ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups);
2951
2952/*! \brief return an ast_variable list of channeltypes */
2954
2955/*!
2956 * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
2957 * \param reason The integer argument, usually taken from AST_CONTROL_ macros
2958 * \return char pointer explaining the code
2959 */
2960const char *ast_channel_reason2str(int reason);
2961
2962/*! \brief channel group info */
2966 char *group;
2968};
2969
2970#define ast_channel_lock(chan) ao2_lock(chan)
2971#define ast_channel_unlock(chan) ao2_unlock(chan)
2972#define ast_channel_trylock(chan) ao2_trylock(chan)
2973
2974/*!
2975 * \brief Lock two channels.
2976 */
2977#define ast_channel_lock_both(chan1, chan2) do { \
2978 ast_channel_lock(chan1); \
2979 while (ast_channel_trylock(chan2)) { \
2980 ast_channel_unlock(chan1); \
2981 sched_yield(); \
2982 ast_channel_lock(chan1); \
2983 } \
2984 } while (0)
2985
2986/*!
2987 * \brief Increase channel reference count
2988 *
2989 * \param c the channel
2990 *
2991 * \retval c always
2992 *
2993 * \since 1.8
2994 */
2995#define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); })
2996
2997/*!
2998 * \brief Decrease channel reference count
2999 *
3000 * \param c the channel
3001 *
3002 * \retval NULL always
3003 *
3004 * \since 1.8
3005 */
3006#define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
3007
3008/*!
3009 * \brief Cleanup a channel reference
3010 *
3011 * \param c the channel (NULL tolerant)
3012 *
3013 * \retval NULL always
3014 *
3015 * \since 12.0.0
3016 */
3017#define ast_channel_cleanup(c) ({ ao2_cleanup(c); (struct ast_channel *) (NULL); })
3018
3019/*! Channel Iterating @{ */
3020
3021/*!
3022 * \brief A channel iterator
3023 *
3024 * This is an opaque type.
3025 */
3027
3028/*!
3029 * \brief Destroy a channel iterator
3030 *
3031 * \param i the itereator to destroy
3032 *
3033 * \details
3034 * This function is used to destroy a channel iterator that was retrieved by
3035 * using one of the channel_iterator_xxx_new() functions.
3036 *
3037 * \retval NULL for convenience to clear out the pointer to the iterator that
3038 * was just destroyed.
3039 *
3040 * \since 1.8
3041 */
3043
3044/*!
3045 * \brief Create a new channel iterator based on extension
3046 *
3047 * \param exten The extension that channels must be in
3048 * \param context The context that channels must be in
3049 *
3050 * \details
3051 * After creating an iterator using this function, the ast_channel_iterator_next()
3052 * function can be used to iterate through all channels that are currently
3053 * in the specified context and extension.
3054 *
3055 * \note You must call ast_channel_iterator_destroy() when done.
3056 *
3057 * \retval NULL on failure
3058 * \retval a new channel iterator based on the specified parameters
3059 *
3060 * \since 1.8
3061 */
3062struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context);
3063
3064/*!
3065 * \brief Create a new channel iterator based on name
3066 *
3067 * \param name channel name or channel uniqueid to match
3068 * \param name_len number of characters in the channel name to match on. This
3069 * would be used to match based on name prefix. If matching on the full
3070 * channel name is desired, then this parameter should be 0.
3071 *
3072 * \details
3073 * After creating an iterator using this function, the ast_channel_iterator_next()
3074 * function can be used to iterate through all channels that exist that have
3075 * the specified name or name prefix.
3076 *
3077 * \note You must call ast_channel_iterator_destroy() when done.
3078 *
3079 * \retval NULL on failure
3080 * \retval a new channel iterator based on the specified parameters
3081 *
3082 * \since 1.8
3083 */
3084struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name, size_t name_len);
3085
3086/*!
3087 * \brief Create a new channel iterator
3088 *
3089 * \details
3090 * After creating an iterator using this function, the ast_channel_iterator_next()
3091 * function can be used to iterate through all channels that exist.
3092 *
3093 * \note You must call ast_channel_iterator_destroy() when done.
3094 *
3095 * \retval NULL on failure
3096 * \retval a new channel iterator
3097 *
3098 * \since 1.8
3099 */
3101
3102/*!
3103 * \brief Get the next channel for a channel iterator
3104 *
3105 * \param i the channel iterator that was created using one of the
3106 * channel_iterator_xxx_new() functions.
3107 *
3108 * \details
3109 * This function should be used to iterate through all channels that match a
3110 * specified set of parameters that were provided when the iterator was created.
3111 *
3112 * \retval the next channel that matches the parameters used when the iterator
3113 * was created.
3114 * \retval NULL if no more channels match the iterator parameters.
3115 *
3116 * \since 1.8
3117 */
3119
3120/*! @} End channel iterator definitions. */
3121
3122/*!
3123 * \brief Call a function with every active channel
3124 *
3125 * \details
3126 * This function executes a callback one time for each active channel on the
3127 * system. The channel is provided as an argument to the function.
3128 *
3129 * \note Absolutely _NO_ channel locks should be held before calling this function.
3130 * \since 1.8
3131 */
3132struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
3133 void *data, int ao2_flags);
3134
3135/*! @{ Channel search functions */
3136
3137/*!
3138 * \brief Find a channel by name
3139 *
3140 * \param name the name or uniqueid of the channel to search for
3141 *
3142 * \details
3143 * Find a channel that has the same name as the provided argument.
3144 *
3145 * \retval a channel with the name specified by the argument
3146 * \retval NULL if no channel was found
3147 *
3148 * \since 1.8
3149 */
3150struct ast_channel *ast_channel_get_by_name(const char *name);
3151
3152/*!
3153 * \brief Find a channel by a name prefix
3154 *
3155 * \param name The channel name or uniqueid prefix to search for
3156 * \param name_len Only search for up to this many characters from the name
3157 *
3158 * \details
3159 * Find a channel that has the same name prefix as specified by the arguments.
3160 *
3161 * \retval a channel with the name prefix specified by the arguments
3162 * \retval NULL if no channel was found
3163 *
3164 * \since 1.8
3165 */
3166struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
3167
3168/*!
3169 * \brief Find a channel by extension and context
3170 *
3171 * \param exten the extension to search for
3172 * \param context the context to search for
3173 *
3174 * \details
3175 * Return a channel that is currently at the specified extension and context.
3176 *
3177 * \retval a channel that is at the specified extension and context
3178 * \retval NULL if no channel was found
3179 *
3180 * \since 1.8
3181 */
3182struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
3183
3184/*! @} End channel search functions. */
3185
3186/*!
3187 * \brief Initialize the given name structure.
3188 * \since 1.8
3189 *
3190 * \param init Name structure to initialize.
3191 */
3192void ast_party_name_init(struct ast_party_name *init);
3193
3194/*!
3195 * \brief Copy the source party name information to the destination party name.
3196 * \since 1.8
3197 *
3198 * \param dest Destination party name
3199 * \param src Source party name
3200 */
3201void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src);
3202
3203/*!
3204 * \brief Initialize the given party name structure using the given guide
3205 * for a set update operation.
3206 * \since 1.8
3207 *
3208 * \details
3209 * The initialization is needed to allow a set operation to know if a
3210 * value needs to be updated. Simple integers need the guide's original
3211 * value in case the set operation is not trying to set a new value.
3212 * String values are simply set to NULL pointers if they are not going
3213 * to be updated.
3214 *
3215 * \param init Party name structure to initialize.
3216 * \param guide Source party name to use as a guide in initializing.
3217 */
3218void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide);
3219
3220/*!
3221 * \brief Set the source party name information into the destination party name.
3222 * \since 1.8
3223 *
3224 * \param dest The name one wishes to update
3225 * \param src The new name values to update the dest
3226 */
3227void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src);
3228
3229/*!
3230 * \brief Destroy the party name contents
3231 * \since 1.8
3232 *
3233 * \param doomed The party name to destroy.
3234 */
3235void ast_party_name_free(struct ast_party_name *doomed);
3236
3237/*!
3238 * \brief Initialize the given number structure.
3239 * \since 1.8
3240 *
3241 * \param init Number structure to initialize.
3242 */
3243void ast_party_number_init(struct ast_party_number *init);
3244
3245/*!
3246 * \brief Copy the source party number information to the destination party number.
3247 * \since 1.8
3248 *
3249 * \param dest Destination party number
3250 * \param src Source party number
3251 */
3252void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src);
3253
3254/*!
3255 * \brief Initialize the given party number structure using the given guide
3256 * for a set update operation.
3257 * \since 1.8
3258 *
3259 * \details
3260 * The initialization is needed to allow a set operation to know if a
3261 * value needs to be updated. Simple integers need the guide's original
3262 * value in case the set operation is not trying to set a new value.
3263 * String values are simply set to NULL pointers if they are not going
3264 * to be updated.
3265 *
3266 * \param init Party number structure to initialize.
3267 * \param guide Source party number to use as a guide in initializing.
3268 */
3269void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide);
3270
3271/*!
3272 * \brief Set the source party number information into the destination party number.
3273 * \since 1.8
3274 *
3275 * \param dest The number one wishes to update
3276 * \param src The new number values to update the dest
3277 */
3278void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src);
3279
3280/*!
3281 * \brief Destroy the party number contents
3282 * \since 1.8
3283 *
3284 * \param doomed The party number to destroy.
3285 */
3286void ast_party_number_free(struct ast_party_number *doomed);
3287
3288/*!
3289 * \since 1.8
3290 * \brief Initialize the given subaddress structure.
3291 *
3292 * \param init Subaddress structure to initialize.
3293 */
3295
3296/*!
3297 * \since 1.8
3298 * \brief Copy the source party subaddress information to the destination party subaddress.
3299 *
3300 * \param dest Destination party subaddress
3301 * \param src Source party subaddress
3302 */
3303void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
3304
3305/*!
3306 * \since 1.8
3307 * \brief Initialize the given party subaddress structure using the given guide
3308 * for a set update operation.
3309 *
3310 * \details
3311 * The initialization is needed to allow a set operation to know if a
3312 * value needs to be updated. Simple integers need the guide's original
3313 * value in case the set operation is not trying to set a new value.
3314 * String values are simply set to NULL pointers if they are not going
3315 * to be updated.
3316 *
3317 * \param init Party subaddress structure to initialize.
3318 * \param guide Source party subaddress to use as a guide in initializing.
3319 */
3320void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide);
3321
3322/*!
3323 * \since 1.8
3324 * \brief Set the source party subaddress information into the destination party subaddress.
3325 *
3326 * \param dest The subaddress one wishes to update
3327 * \param src The new subaddress values to update the dest
3328 */
3329void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
3330
3331/*!
3332 * \since 1.8
3333 * \brief Destroy the party subaddress contents
3334 *
3335 * \param doomed The party subaddress to destroy.
3336 */
3338
3339/*!
3340 * \brief Set the update marker to update all information of a corresponding party id.
3341 * \since 11.0
3342 *
3343 * \param update_id The update marker for a corresponding party id.
3344 */
3345void ast_set_party_id_all(struct ast_set_party_id *update_id);
3346
3347/*!
3348 * \brief Initialize the given party id structure.
3349 * \since 1.8
3350 *
3351 * \param init Party id structure to initialize.
3352 */
3353void ast_party_id_init(struct ast_party_id *init);
3354
3355/*!
3356 * \brief Copy the source party id information to the destination party id.
3357 * \since 1.8
3358 *
3359 * \param dest Destination party id
3360 * \param src Source party id
3361 */
3362void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src);
3363
3364/*!
3365 * \brief Initialize the given party id structure using the given guide
3366 * for a set update operation.
3367 * \since 1.8
3368 *
3369 * \details
3370 * The initialization is needed to allow a set operation to know if a
3371 * value needs to be updated. Simple integers need the guide's original
3372 * value in case the set operation is not trying to set a new value.
3373 * String values are simply set to NULL pointers if they are not going
3374 * to be updated.
3375 *
3376 * \param init Party id structure to initialize.
3377 * \param guide Source party id to use as a guide in initializing.
3378 */
3379void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide);
3380
3381/*!
3382 * \brief Set the source party id information into the destination party id.
3383 * \since 1.8
3384 *
3385 * \param dest The id one wishes to update
3386 * \param src The new id values to update the dest
3387 * \param update What id information to update. NULL if all.
3388 */
3389void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update);
3390
3391/*!
3392 * \brief Destroy the party id contents
3393 * \since 1.8
3394 *
3395 * \param doomed The party id to destroy.
3396 */
3397void ast_party_id_free(struct ast_party_id *doomed);
3398
3399/*!
3400 * \brief Determine the overall presentation value for the given party.
3401 * \since 1.8
3402 *
3403 * \param id Party to determine the overall presentation value.
3404 *
3405 * \return Overall presentation value for the given party.
3406 */
3407int ast_party_id_presentation(const struct ast_party_id *id);
3408
3409/*!
3410 * \brief Invalidate all components of the given party id.
3411 * \since 11.0
3412 *
3413 * \param id The party id to invalidate.
3414 */
3415void ast_party_id_invalidate(struct ast_party_id *id);
3416
3417/*!
3418 * \brief Destroy and initialize the given party id structure.
3419 * \since 11.0
3420 *
3421 * \param id The party id to reset.
3422 */
3423void ast_party_id_reset(struct ast_party_id *id);
3424
3425/*!
3426 * \brief Merge a given party id into another given party id.
3427 * \since 11.0
3428 *
3429 * \details
3430 * This function will generate an effective party id.
3431 *
3432 * Each party id component of the party id 'base' is overwritten
3433 * by components of the party id 'overlay' if the overlay
3434 * component is marked as valid. However the component 'tag' of
3435 * the base party id remains untouched.
3436 *
3437 * \param base The party id which is merged.
3438 * \param overlay The party id which is used to merge into.
3439 *
3440 * \return The merged party id as a struct, not as a pointer.
3441 * \note The merged party id returned is a shallow copy and must not be freed.
3442 */
3443struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay);
3444
3445/*!
3446 * \brief Copy a merge of a given party id into another given party id to a given destination party id.
3447 * \since 11.0
3448 *
3449 * \details
3450 * Each party id component of the party id 'base' is overwritten by components
3451 * of the party id 'overlay' if the 'overlay' component is marked as valid.
3452 * However the component 'tag' of the 'base' party id remains untouched.
3453 * The result is copied into the given party id 'dest'.
3454 *
3455 * \note The resulting merged party id is a real copy and has to be freed.
3456 *
3457 * \param dest The resulting merged party id.
3458 * \param base The party id which is merged.
3459 * \param overlay The party id which is used to merge into.
3460 */
3461void ast_party_id_merge_copy(struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay);
3462
3463/*!
3464 * \brief Initialize the given dialed structure.
3465 * \since 1.8
3466 *
3467 * \param init Dialed structure to initialize.
3468 */
3469void ast_party_dialed_init(struct ast_party_dialed *init);
3470
3471/*!
3472 * \brief Copy the source dialed party information to the destination dialed party.
3473 * \since 1.8
3474 *
3475 * \param dest Destination dialed party
3476 * \param src Source dialed party
3477 */
3478void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3479
3480/*!
3481 * \brief Initialize the given dialed structure using the given
3482 * guide for a set update operation.
3483 * \since 1.8
3484 *
3485 * \details
3486 * The initialization is needed to allow a set operation to know if a
3487 * value needs to be updated. Simple integers need the guide's original
3488 * value in case the set operation is not trying to set a new value.
3489 * String values are simply set to NULL pointers if they are not going
3490 * to be updated.
3491 *
3492 * \param init Caller structure to initialize.
3493 * \param guide Source dialed to use as a guide in initializing.
3494 */
3495void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide);
3496
3497/*!
3498 * \brief Set the dialed information based on another dialed source
3499 * \since 1.8
3500 *
3501 * This is similar to ast_party_dialed_copy, except that NULL values for
3502 * strings in the src parameter indicate not to update the corresponding dest values.
3503 *
3504 * \param dest The dialed one wishes to update
3505 * \param src The new dialed values to update the dest
3506 */
3507void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3508
3509/*!
3510 * \brief Destroy the dialed party contents
3511 * \since 1.8
3512 *
3513 * \param doomed The dialed party to destroy.
3514 */
3515void ast_party_dialed_free(struct ast_party_dialed *doomed);
3516
3517/*!
3518 * \since 1.8
3519 * \brief Initialize the given caller structure.
3520 *
3521 * \param init Caller structure to initialize.
3522 */
3523void ast_party_caller_init(struct ast_party_caller *init);
3524
3525/*!
3526 * \since 1.8
3527 * \brief Copy the source caller information to the destination caller.
3528 *
3529 * \param dest Destination caller
3530 * \param src Source caller
3531 */
3532void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src);
3533
3534/*!
3535 * \brief Initialize the given caller structure using the given
3536 * guide for a set update operation.
3537 * \since 1.8
3538 *
3539 * \details
3540 * The initialization is needed to allow a set operation to know if a
3541 * value needs to be updated. Simple integers need the guide's original
3542 * value in case the set operation is not trying to set a new value.
3543 * String values are simply set to NULL pointers if they are not going
3544 * to be updated.
3545 *
3546 * \param init Caller structure to initialize.
3547 * \param guide Source caller to use as a guide in initializing.
3548 */
3549void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide);
3550
3551/*!
3552 * \brief Set the caller information based on another caller source
3553 * \since 1.8
3554 *
3555 * This is similar to ast_party_caller_copy, except that NULL values for
3556 * strings in the src parameter indicate not to update the corresponding dest values.
3557 *
3558 * \param dest The caller one wishes to update
3559 * \param src The new caller values to update the dest
3560 * \param update What caller information to update. NULL if all.
3561 */
3562void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update);
3563
3564/*!
3565 * \brief Destroy the caller party contents
3566 * \since 1.8
3567 *
3568 * \param doomed The caller party to destroy.
3569 */
3570void ast_party_caller_free(struct ast_party_caller *doomed);
3571
3572/*!
3573 * \since 1.8
3574 * \brief Initialize the given connected line structure.
3575 *
3576 * \param init Connected line structure to initialize.
3577 */
3579
3580/*!
3581 * \since 1.8
3582 * \brief Copy the source connected line information to the destination connected line.
3583 *
3584 * \param dest Destination connected line
3585 * \param src Source connected line
3586 */
3588
3589/*!
3590 * \since 1.8
3591 * \brief Initialize the given connected line structure using the given
3592 * guide for a set update operation.
3593 *
3594 * \details
3595 * The initialization is needed to allow a set operation to know if a
3596 * value needs to be updated. Simple integers need the guide's original
3597 * value in case the set operation is not trying to set a new value.
3598 * String values are simply set to NULL pointers if they are not going
3599 * to be updated.
3600 *
3601 * \param init Connected line structure to initialize.
3602 * \param guide Source connected line to use as a guide in initializing.
3603 */
3605
3606/*!
3607 * \since 1.8
3608 * \brief Set the connected line information based on another connected line source
3609 *
3610 * This is similar to ast_party_connected_line_copy, except that NULL values for
3611 * strings in the src parameter indicate not to update the corresponding dest values.
3612 *
3613 * \param dest The connected line one wishes to update
3614 * \param src The new connected line values to update the dest
3615 * \param update What connected line information to update. NULL if all.
3616 */
3618
3619/*!
3620 * \since 1.8
3621 * \brief Collect the caller party information into a connected line structure.
3622 *
3623 * \param connected Collected caller information for the connected line
3624 * \param caller Caller information.
3625 *
3626 * \warning This is a shallow copy.
3627 * \warning DO NOT call ast_party_connected_line_free() on the filled in
3628 * connected line structure!
3629 */
3631
3632/*!
3633 * \since 1.8
3634 * \brief Destroy the connected line information contents
3635 *
3636 * \param doomed The connected line information to destroy.
3637 */
3639
3640/*!
3641 * \brief Initialize the given redirecting reason structure
3642 *
3643 * \param init Redirecting reason structure to initialize
3644 */
3646
3647/*!
3648 * \brief Copy the source redirecting reason information to the destination redirecting reason.
3649 *
3650 * \param dest Destination redirecting reason
3651 * \param src Source redirecting reason
3652 */
3654 const struct ast_party_redirecting_reason *src);
3655
3656/*!
3657 * \brief Initialize the given redirecting reason structure using the given guide
3658 * for a set update operation.
3659 *
3660 * \details
3661 * The initialization is needed to allow a set operation to know if a
3662 * value needs to be updated. Simple integers need the guide's original
3663 * value in case the set operation is not trying to set a new value.
3664 * String values are simply set to NULL pointers if they are not going
3665 * to be updated.
3666 *
3667 * \param init Redirecting reason structure to initialize.
3668 * \param guide Source redirecting reason to use as a guide in initializing.
3669 */
3671 const struct ast_party_redirecting_reason *guide);
3672
3673/*!
3674 * \brief Set the redirecting reason information based on another redirecting reason source
3675 *
3676 * This is similar to ast_party_redirecting_reason_copy, except that NULL values for
3677 * strings in the src parameter indicate not to update the corresponding dest values.
3678 *
3679 * \param dest The redirecting reason one wishes to update
3680 * \param src The new redirecting reason values to update the dest
3681 */
3683 const struct ast_party_redirecting_reason *src);
3684
3685/*!
3686 * \brief Destroy the redirecting reason contents
3687 *
3688 * \param doomed The redirecting reason to destroy.
3689 */
3691
3692/*!
3693 * \brief Initialize the given redirecting structure.
3694 * \since 1.8
3695 *
3696 * \param init Redirecting structure to initialize.
3697 */
3699
3700/*!
3701 * \since 1.8
3702 * \brief Copy the source redirecting information to the destination redirecting.
3703 *
3704 * \param dest Destination redirecting
3705 * \param src Source redirecting
3706 */
3707void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src);
3708
3709/*!
3710 * \since 1.8
3711 * \brief Initialize the given redirecting id structure using the given guide
3712 * for a set update operation.
3713 *
3714 * \details
3715 * The initialization is needed to allow a set operation to know if a
3716 * value needs to be updated. Simple integers need the guide's original
3717 * value in case the set operation is not trying to set a new value.
3718 * String values are simply set to NULL pointers if they are not going
3719 * to be updated.
3720 *
3721 * \param init Redirecting id structure to initialize.
3722 * \param guide Source redirecting id to use as a guide in initializing.
3723 */
3724void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide);
3725
3726/*!
3727 * \brief Set the redirecting information based on another redirecting source
3728 * \since 1.8
3729 *
3730 * This is similar to ast_party_redirecting_copy, except that NULL values for
3731 * strings in the src parameter indicate not to update the corresponding dest values.
3732 *
3733 * \param dest The redirecting one wishes to update
3734 * \param src The new redirecting values to update the dest
3735 * \param update What redirecting information to update. NULL if all.
3736 */
3738
3739/*!
3740 * \since 1.8
3741 * \brief Destroy the redirecting information contents
3742 *
3743 * \param doomed The redirecting information to destroy.
3744 */
3746
3747/*!
3748 * \since 1.8
3749 * \brief Copy the caller information to the connected line information.
3750 *
3751 * \param dest Destination connected line information
3752 * \param src Source caller information
3753 *
3754 * \note Assumes locks are already acquired
3755 */
3757
3758/*!
3759 * \since 1.8
3760 * \brief Copy the connected line information to the caller information.
3761 *
3762 * \param dest Destination caller information
3763 * \param src Source connected line information
3764 *
3765 * \note Assumes locks are already acquired
3766 */
3768
3769/*!
3770 * \since 1.8
3771 * \brief Set the connected line information in the Asterisk channel
3772 *
3773 * \param chan Asterisk channel to set connected line information
3774 * \param connected Connected line information
3775 * \param update What connected line information to update. NULL if all.
3776 *
3777 * \note The channel does not need to be locked before calling this function.
3778 */
3780
3781/*!
3782 * \since 1.8
3783 * \brief Build the connected line information data frame.
3784 *
3785 * \param data Buffer to fill with the frame data
3786 * \param datalen Size of the buffer to fill
3787 * \param connected Connected line information
3788 * \param update What connected line information to build. NULL if all.
3789 *
3790 * \retval -1 if error
3791 * \retval Amount of data buffer used
3792 */
3793int 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);
3794
3795/*!
3796 * \since 1.8
3797 * \brief Parse connected line indication frame data
3798 *
3799 * \param data Buffer with the frame data to parse
3800 * \param datalen Size of the buffer
3801 * \param connected Extracted connected line information
3802 *
3803 * \retval 0 on success.
3804 * \retval -1 on error.
3805 *
3806 * \note The filled in connected line structure needs to be initialized by
3807 * ast_party_connected_line_set_init() before calling. If defaults are not
3808 * required use ast_party_connected_line_init().
3809 * \note The filled in connected line structure needs to be destroyed by
3810 * ast_party_connected_line_free() when it is no longer needed.
3811 */
3812int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected);
3813
3814/*!
3815 * \since 1.8
3816 * \brief Indicate that the connected line information has changed
3817 *
3818 * \param chan Asterisk channel to indicate connected line information
3819 * \param connected Connected line information
3820 * \param update What connected line information to update. NULL if all.
3821 */
3823
3824/*!
3825 * \since 1.8
3826 * \brief Queue a connected line update frame on a channel
3827 *
3828 * \param chan Asterisk channel to indicate connected line information
3829 * \param connected Connected line information
3830 * \param update What connected line information to update. NULL if all.
3831 */
3833
3834/*!
3835 * \since 1.8
3836 * \brief Set the redirecting id information in the Asterisk channel
3837 *
3838 * \param chan Asterisk channel to set redirecting id information
3839 * \param redirecting Redirecting id information
3840 * \param update What redirecting information to update. NULL if all.
3841 *
3842 * \note The channel does not need to be locked before calling this function.
3843 */
3844void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3845
3846/*!
3847 * \since 1.8
3848 * \brief Build the redirecting id data frame.
3849 *
3850 * \param data Buffer to fill with the frame data
3851 * \param datalen Size of the buffer to fill
3852 * \param redirecting Redirecting id information
3853 * \param update What redirecting information to build. NULL if all.
3854 *
3855 * \retval -1 if error
3856 * \retval Amount of data buffer used
3857 */
3858int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3859
3860/*!
3861 * \since 1.8
3862 * \brief Parse redirecting indication frame data
3863 *
3864 * \param data Buffer with the frame data to parse
3865 * \param datalen Size of the buffer
3866 * \param redirecting Extracted redirecting id information
3867 *
3868 * \retval 0 on success.
3869 * \retval -1 on error.
3870 *
3871 * \note The filled in id structure needs to be initialized by
3872 * ast_party_redirecting_set_init() before calling.
3873 * \note The filled in id structure needs to be destroyed by
3874 * ast_party_redirecting_free() when it is no longer needed.
3875 */
3876int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting);
3877
3878/*!
3879 * \since 1.8
3880 * \brief Indicate that the redirecting id has changed
3881 *
3882 * \param chan Asterisk channel to indicate redirecting id information
3883 * \param redirecting Redirecting id information
3884 * \param update What redirecting information to update. NULL if all.
3885 */
3886void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3887
3888/*!
3889 * \since 1.8
3890 * \brief Queue a redirecting update frame on a channel
3891 *
3892 * \param chan Asterisk channel to indicate redirecting id information
3893 * \param redirecting Redirecting id information
3894 * \param update What redirecting information to update. NULL if all.
3895 */
3896void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3897
3898/*!
3899 * \since 11
3900 * \brief Run a connected line interception subroutine and update a channel's connected line
3901 * information
3902 *
3903 * Whenever we want to update a channel's connected line information, we may need to run
3904 * a subroutine so that an administrator can manipulate the information before sending it
3905 * out. This function both runs the subroutine specified by CONNECTED_LINE_SEND_SUB and
3906 * sends the update to the channel.
3907 *
3908 * \param autoservice_chan Channel to place into autoservice while the sub is running.
3909 * It is perfectly safe for this to be NULL
3910 * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3911 * determine which subroutine we need to run.
3912 * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
3913 * AST_CONTROL_CONNECTED_LINE
3914 * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
3915 * ast_party_connected_line pointer.
3916 * \retval 0 Success
3917 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3918 * run the subroutine
3919 */
3920int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame);
3921
3922/*!
3923 * \since 11
3924 * \brief Run a redirecting interception subroutine and update a channel's redirecting information
3925 *
3926 * \details
3927 * Whenever we want to update a channel's redirecting information, we may need to run
3928 * a subroutine so that an administrator can manipulate the information before sending it
3929 * out. This function both runs the subroutine specified by REDIRECTING_SEND_SUB and
3930 * sends the update to the channel.
3931 *
3932 * \param autoservice_chan Channel to place into autoservice while the subroutine is running.
3933 * It is perfectly safe for this to be NULL
3934 * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3935 * determine which subroutine we need to run.
3936 * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
3937 * AST_CONTROL_REDIRECTING
3938 * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
3939 * ast_party_redirecting pointer.
3940 *
3941 * \retval 0 Success
3942 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3943 * run the subroutine
3944 */
3945int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame);
3946
3947#include "asterisk/ccss.h"
3948
3949/*!
3950 * \since 1.8
3951 * \brief Set up datastore with CCSS parameters for a channel
3952 *
3953 * \note
3954 * If base_params is NULL, the channel will get the default
3955 * values for all CCSS parameters.
3956 *
3957 * \details
3958 * This function makes use of datastore operations on the channel, so
3959 * it is important to lock the channel before calling this function.
3960 *
3961 * \param chan The channel to create the datastore on
3962 * \param base_params CCSS parameters we wish to copy into the channel
3963 * \retval 0 Success
3964 * \retval -1 Failure
3965 */
3967 const struct ast_cc_config_params *base_params);
3968
3969/*!
3970 * \since 1.8
3971 * \brief Get the CCSS parameters from a channel
3972 *
3973 * \details
3974 * This function makes use of datastore operations on the channel, so
3975 * it is important to lock the channel before calling this function.
3976 *
3977 * \param chan Channel to retrieve parameters from
3978 * \retval NULL Failure
3979 * \retval non-NULL The parameters desired
3980 */
3982
3983
3984/*!
3985 * \since 1.8
3986 * \brief Get a device name given its channel structure
3987 *
3988 * \details
3989 * A common practice in Asterisk is to determine the device being talked
3990 * to by dissecting the channel name. For certain channel types, this is not
3991 * accurate. For instance, an ISDN channel is named based on what B channel is
3992 * used, not the device being communicated with.
3993 *
3994 * This function interfaces with a channel tech's queryoption callback to
3995 * retrieve the name of the device being communicated with. If the channel does not
3996 * implement this specific option, then the traditional method of using the channel
3997 * name is used instead.
3998 *
3999 * \param chan The channel to retrieve the information from
4000 * \param[out] device_name The buffer to place the device's name into
4001 * \param name_buffer_length The allocated space for the device_name
4002 * \return 0 always
4003 */
4004int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length);
4005
4006/*!
4007 * \since 1.8
4008 * \brief Find the appropriate CC agent type to use given a channel
4009 *
4010 * \details
4011 * During call completion, we will need to create a call completion agent structure. To
4012 * figure out the type of agent to construct, we need to ask the channel driver for the
4013 * appropriate type.
4014 *
4015 * Prior to adding this function, the call completion core attempted to figure this
4016 * out for itself by stripping the technology off the channel's name. However, in the
4017 * case of chan_dahdi, there are multiple agent types registered, and so simply searching
4018 * for an agent type called "DAHDI" is not possible. In a case where multiple agent types
4019 * are defined, the channel driver must have a queryoption callback defined in its
4020 * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE
4021 *
4022 * If a channel driver does not have a queryoption callback or if the queryoption callback
4023 * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology
4024 * portion of the channel name is used instead. This is perfectly suitable for channel drivers
4025 * whose channel technologies are a one-to-one match with the agent types defined within.
4026 *
4027 * Note that this function is only called when the agent policy on a given channel is set
4028 * to "native." Generic agents' type can be determined automatically by the core.
4029 *
4030 * \param chan The channel for which we wish to retrieve the agent type
4031 * \param[out] agent_type The type of agent the channel driver wants us to use
4032 * \param size The size of the buffer to write to
4033 */
4034int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size);
4035#if defined(__cplusplus) || defined(c_plusplus)
4036}
4037#endif
4038
4039/*!
4040 * \brief Remove a channel from the global channels container
4041 *
4042 * \param chan channel to remove
4043 *
4044 * In a case where it is desired that a channel not be available in any lookups
4045 * in the global channels conatiner, use this function.
4046 */
4047void ast_channel_unlink(struct ast_channel *chan);
4048
4049/*!
4050 * \brief Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash
4051 * on the given channel
4052 *
4053 * \param chan channel on which to set the cause information
4054 * \param cause_code ast_control_pvt_cause_code structure containing cause information
4055 * \param datalen total length of the structure since it may vary
4056 */
4057void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen);
4058
4059/*!
4060 * \since 12
4061 * \brief Convert a string to a detail record AMA flag
4062 *
4063 * \param flag string form of flag
4064 *
4065 * \retval the enum (integer) form of the flag
4066 */
4067enum ama_flags ast_channel_string2amaflag(const char *flag);
4068
4069/*!
4070 * \since 12
4071 * \brief Convert the enum representation of an AMA flag to a string representation
4072 *
4073 * \param flags integer flag
4074 *
4075 * \retval A string representation of the flag
4076 */
4077const char *ast_channel_amaflags2string(enum ama_flags flags);
4078
4083
4084/* ACCESSOR FUNCTIONS */
4085
4086#define DECLARE_STRINGFIELD_SETTERS_FOR(field) \
4087 void ast_channel_##field##_set(struct ast_channel *chan, const char *field); \
4088 void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0))); \
4089 void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) __attribute__((format(printf, 2, 3)))
4090
4091/*!
4092 * The following string fields result in channel snapshot creation and
4093 * should have the channel locked when called:
4094 *
4095 * \li language
4096 * \li accountcode
4097 * \li peeraccount
4098 * \li linkedid
4099 */
4113
4114const char *ast_channel_name(const struct ast_channel *chan);
4115const char *ast_channel_language(const struct ast_channel *chan);
4116const char *ast_channel_musicclass(const struct ast_channel *chan);
4117const char *ast_channel_latest_musicclass(const struct ast_channel *chan);
4118const char *ast_channel_accountcode(const struct ast_channel *chan);
4119const char *ast_channel_peeraccount(const struct ast_channel *chan);
4120const char *ast_channel_userfield(const struct ast_channel *chan);
4121const char *ast_channel_call_forward(const struct ast_channel *chan);
4122const char *ast_channel_uniqueid(const struct ast_channel *chan);
4123const char *ast_channel_linkedid(const struct ast_channel *chan);
4124const char *ast_channel_tenantid(const struct ast_channel *chan);
4125void ast_channel_tenantid_set(struct ast_channel *chan, const char *value);
4126const char *ast_channel_parkinglot(const struct ast_channel *chan);
4127const char *ast_channel_hangupsource(const struct ast_channel *chan);
4128const char *ast_channel_dialcontext(const struct ast_channel *chan);
4129
4130const char *ast_channel_appl(const struct ast_channel *chan);
4131void ast_channel_appl_set(struct ast_channel *chan, const char *value);
4132const char *ast_channel_blockproc(const struct ast_channel *chan);
4133void ast_channel_blockproc_set(struct ast_channel *chan, const char *value);
4134const char *ast_channel_data(const struct ast_channel *chan);
4135void ast_channel_data_set(struct ast_channel *chan, const char *value);
4136
4137const char *ast_channel_lastcontext(const struct ast_channel *chan);
4138const char *ast_channel_context(const struct ast_channel *chan);
4139void ast_channel_context_set(struct ast_channel *chan, const char *value);
4140const char *ast_channel_lastexten(const struct ast_channel *chan);
4141const char *ast_channel_exten(const struct ast_channel *chan);
4142void ast_channel_exten_set(struct ast_channel *chan, const char *value);
4143
4144char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan);
4146char ast_channel_sending_dtmf_digit(const struct ast_channel *chan);
4148struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan);
4149void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value);
4150enum ama_flags ast_channel_amaflags(const struct ast_channel *chan);
4151
4152/*!
4153 * \pre chan is locked
4154 */
4155void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value);
4156int ast_channel_epfd(const struct ast_channel *chan);
4158int ast_channel_fdno(const struct ast_channel *chan);
4159void ast_channel_fdno_set(struct ast_channel *chan, int value);
4160int ast_channel_hangupcause(const struct ast_channel *chan);
4161void ast_channel_hangupcause_set(struct ast_channel *chan, int value);
4162int ast_channel_priority(const struct ast_channel *chan);
4163void ast_channel_priority_set(struct ast_channel *chan, int value);
4164int ast_channel_rings(const struct ast_channel *chan);
4165void ast_channel_rings_set(struct ast_channel *chan, int value);
4166int ast_channel_streamid(const struct ast_channel *chan);
4167void ast_channel_streamid_set(struct ast_channel *chan, int value);
4168int ast_channel_timingfd(const struct ast_channel *chan);
4169void ast_channel_timingfd_set(struct ast_channel *chan, int value);
4170int ast_channel_visible_indication(const struct ast_channel *chan);
4172int ast_channel_hold_state(const struct ast_channel *chan);
4173void ast_channel_hold_state_set(struct ast_channel *chan, int value);
4174int ast_channel_vstreamid(const struct ast_channel *chan);
4175void ast_channel_vstreamid_set(struct ast_channel *chan, int value);
4176unsigned short ast_channel_transfercapability(const struct ast_channel *chan);
4177void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value);
4178unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan);
4179void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value);
4180unsigned int ast_channel_fin(const struct ast_channel *chan);
4181void ast_channel_fin_set(struct ast_channel *chan, unsigned int value);
4182unsigned int ast_channel_fout(const struct ast_channel *chan);
4183void ast_channel_fout_set(struct ast_channel *chan, unsigned int value);
4184unsigned long ast_channel_insmpl(const struct ast_channel *chan);
4185void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value);
4186unsigned long ast_channel_outsmpl(const struct ast_channel *chan);
4187void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value);
4188void *ast_channel_generatordata(const struct ast_channel *chan);
4189void ast_channel_generatordata_set(struct ast_channel *chan, void *value);
4190void *ast_channel_music_state(const struct ast_channel *chan);
4191void ast_channel_music_state_set(struct ast_channel *chan, void *value);
4192void *ast_channel_tech_pvt(const struct ast_channel *chan);
4193void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value);
4194void *ast_channel_timingdata(const struct ast_channel *chan);
4195void ast_channel_timingdata_set(struct ast_channel *chan, void *value);
4196struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan);
4198struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan);
4199void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value);
4200struct ast_channel *ast_channel__bridge(const struct ast_channel *chan);
4202struct ast_channel *ast_channel_masq(const struct ast_channel *chan);
4203void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value);
4204struct ast_channel *ast_channel_masqr(const struct ast_channel *chan);
4205void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value);
4206struct ast_filestream *ast_channel_stream(const struct ast_channel *chan);
4207void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value);
4208struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan);
4209void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value);
4210struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan);
4212struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan);
4214struct ast_generator *ast_channel_generator(const struct ast_channel *chan);
4215void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value);
4216struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan);
4217void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value);
4218struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan);
4219void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value);
4220struct ast_timer *ast_channel_timer(const struct ast_channel *chan);
4221void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value);
4222struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan);
4223void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value);
4224struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan);
4225void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
4226struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan);
4227void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
4228const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan);
4229void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value);
4230enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan);
4232enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
4233ast_callid ast_channel_callid(const struct ast_channel *chan);
4234struct ast_channel_snapshot *ast_channel_snapshot(const struct ast_channel *chan);
4235void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot);
4237
4238/*!
4239 * \pre chan is locked
4240 */
4242
4243/* XXX Internal use only, make sure to move later */
4244void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
4248void ast_channel_callid_cleanup(struct ast_channel *chan);
4250
4251/* Format getters */
4255struct ast_format *ast_channel_readformat(struct ast_channel *chan);
4256struct ast_format *ast_channel_writeformat(struct ast_channel *chan);
4257
4258/* Format setters - all of these functions will increment the reference count of the format passed in */
4259void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format);
4260void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format);
4261void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format);
4262void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format);
4263void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format);
4264
4265/* Other struct getters */
4266struct ast_frame *ast_channel_dtmff(struct ast_channel *chan);
4267struct ast_jb *ast_channel_jb(struct ast_channel *chan);
4268struct ast_party_caller *ast_channel_caller(struct ast_channel *chan);
4272struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan);
4277struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan);
4278struct timeval *ast_channel_whentohangup(struct ast_channel *chan);
4279struct varshead *ast_channel_varshead(struct ast_channel *chan);
4280
4281void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value);
4282void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value);
4283void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value);
4285void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value);
4287void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value);
4288
4289/*!
4290 * \pre chan is locked
4291 */
4292void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value);
4293void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value);
4294struct timeval ast_channel_creationtime(struct ast_channel *chan);
4295void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value);
4296struct timeval ast_channel_answertime(struct ast_channel *chan);
4297void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value);
4298
4299/* List getters */
4303struct ast_readq_list *ast_channel_readq(struct ast_channel *chan);
4304
4305/* Typedef accessors */
4307/*!
4308 * \pre chan is locked
4309 */
4312/*!
4313 * \pre chan is locked
4314 */
4316struct ast_namedgroups *ast_channel_named_callgroups(const struct ast_channel *chan);
4317void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
4318struct ast_namedgroups *ast_channel_named_pickupgroups(const struct ast_channel *chan);
4319void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
4320
4321/* Alertpipe accessors--the "internal" functions for channel.c use only */
4322int ast_channel_alert_write(struct ast_channel *chan);
4323int ast_channel_alert_writable(struct ast_channel *chan);
4331/*! \brief Swap the interal alertpipe between two channels
4332 * \note Handle all of the necessary locking before calling this
4333 */
4334void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2);
4335
4336/* file descriptor array accessors */
4337void ast_channel_internal_fd_clear(struct ast_channel *chan, int which);
4339void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value);
4340int ast_channel_fd(const struct ast_channel *chan, int which);
4341int ast_channel_fd_isset(const struct ast_channel *chan, int which);
4342
4343/*!
4344 * \since 15
4345 * \brief Retrieve the number of file decriptor positions present on the channel
4346 *
4347 * \param chan The channel to get the count of
4348 *
4349 * \pre chan is locked
4350 *
4351 * \return The number of file descriptor positions
4352 */
4353int ast_channel_fd_count(const struct ast_channel *chan);
4354
4355/*!
4356 * \since 15
4357 * \brief Add a file descriptor to the channel without a fixed position
4358 *
4359 * \param chan The channel to add the file descriptor to
4360 * \param value The file descriptor
4361 *
4362 * \pre chan is locked
4363 *
4364 * \return The position of the file descriptor
4365 */
4366int ast_channel_fd_add(struct ast_channel *chan, int value);
4367
4368pthread_t ast_channel_blocker(const struct ast_channel *chan);
4369void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value);
4370
4371int ast_channel_blocker_tid(const struct ast_channel *chan);
4372void ast_channel_blocker_tid_set(struct ast_channel *chan, int tid);
4373
4376
4377struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan);
4378/*!
4379 * \pre chan is locked
4380 */
4382
4385
4388
4389/*!
4390 * \since 11
4391 * \brief Retrieve a comma-separated list of channels for which dialed cause information is available
4392 *
4393 * \details
4394 * This function makes use of datastore operations on the channel, so
4395 * it is important to lock the channel before calling this function.
4396 *
4397 * \param chan The channel from which to retrieve information
4398 * \retval NULL on allocation failure
4399 * \retval Pointer to an ast_str object containing the desired information which must be freed
4400 */
4401struct ast_str *ast_channel_dialed_causes_channels(const struct ast_channel *chan);
4402
4403/*!
4404 * \since 11
4405 * \brief Retrieve a ref-counted cause code information structure
4406 *
4407 * \details
4408 * This function makes use of datastore operations on the channel, so
4409 * it is important to lock the channel before calling this function.
4410 * This function increases the ref count of the returned object, so the
4411 * calling function must decrease the reference count when it is finished
4412 * with the object.
4413 *
4414 * \param chan The channel from which to retrieve information
4415 * \param chan_name The name of the channel about which to retrieve information
4416 * \retval NULL on search failure
4417 * \retval Pointer to a ref-counted ast_control_pvt_cause_code object containing the desired information
4418 */
4420
4421/*!
4422 * \since 11
4423 * \brief Add cause code information to the channel
4424 *
4425 * \details
4426 * This function makes use of datastore operations on the channel, so
4427 * it is important to lock the channel before calling this function.
4428 * The passed in data is copied and so is still owned by the caller.
4429 *
4430 * \param chan The channel on which to add information
4431 * \param cause_code The cause information to be added to the channel
4432 * \param datalen The total length of the structure since its length is variable
4433 * \retval 0 on success
4434 * \retval -1 on error
4435 */
4436int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen);
4437
4438/*!
4439 * \since 11
4440 * \brief Clear all cause information from the channel
4441 *
4442 * \details
4443 * This function makes use of datastore operations on the channel, so
4444 * it is important to lock the channel before calling this function.
4445 *
4446 * \param chan The channel from which to clear information
4447 */
4448void ast_channel_dialed_causes_clear(const struct ast_channel *chan);
4449
4450struct ast_flags *ast_channel_flags(struct ast_channel *chan);
4451
4452/*!
4453 * \since 13.17.0
4454 * \brief Set a flag on a channel
4455 *
4456 * \param chan The channel to set the flag on
4457 * \param flag The flag to set
4458 *
4459 * \note This will lock the channel internally. If the channel is already
4460 * locked it is still safe to call.
4461 */
4462
4463void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag);
4464
4465/*!
4466 * \since 13.17.0
4467 * \brief Clear a flag on a channel
4468 *
4469 * \param chan The channel to clear the flag from
4470 * \param flag The flag to clear
4471 *
4472 * \note This will lock the channel internally. If the channel is already
4473 * locked it is still safe to call.
4474 */
4475void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag);
4476
4477/*!
4478 * \since 12.4.0
4479 * \brief Return whether or not any manager variables have been set
4480 *
4481 * \retval 0 if no manager variables are expected
4482 * \retval 1 if manager variables are expected
4483 */
4485
4486/*!
4487 * \since 12
4488 * \brief Sets the variables to be stored in the \a manager_vars field of all
4489 * snapshots.
4490 * \param varc Number of variable names.
4491 * \param vars Array of variable names.
4492 */
4493void ast_channel_set_manager_vars(size_t varc, char **vars);
4494
4495/*!
4496 * \since 12
4497 * \brief Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
4498 *
4499 * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4500 *
4501 * \param chan Channel to get variables for.
4502 * \return List of channel variables.
4503 * \retval NULL on error
4504 */
4506
4507/*!
4508 * \since 14.2.0
4509 * \brief Return whether or not any ARI variables have been set
4510 *
4511 * \retval 0 if no ARI variables are expected
4512 * \retval 1 if ARI variables are expected
4513 */
4514int ast_channel_has_ari_vars(void);
4515
4516/*!
4517 * \since 14.2.0
4518 * \brief Sets the variables to be stored in the \a ari_vars field of all
4519 * snapshots.
4520 * \param varc Number of variable names.
4521 * \param vars Array of variable names.
4522 */
4523void ast_channel_set_ari_vars(size_t varc, char **vars);
4524
4525/*!
4526 * \since 14.2.0
4527 * \brief Gets the variables for a given channel, as specified by ast_channel_set_ari_vars().
4528 *
4529 * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4530 *
4531 * \param chan Channel to get variables for.
4532 * \return List of channel variables.
4533 * \retval NULL on error
4534 */
4535struct varshead *ast_channel_get_ari_vars(struct ast_channel *chan);
4536
4537/*!
4538 * \since 12
4539 * \brief Gets the variables for a given channel, as set using pbx_builtin_setvar_helper().
4540 *
4541 * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4542 *
4543 * \param chan Channel to get variables for
4544 * \return List of channel variables.
4545 * \retval NULL on error
4546 */
4547struct varshead *ast_channel_get_vars(struct ast_channel *chan);
4548
4549/*!
4550 * \since 12
4551 * \brief A topic which publishes the events for a particular channel.
4552 *
4553 * If the given \a chan is \c NULL, ast_channel_topic_all() is returned.
4554 *
4555 * \param chan Channel, or \c NULL.
4556 *
4557 * \retval Topic for channel's events.
4558 * \retval ast_channel_topic_all() if \a chan is \c NULL.
4559 */
4560struct stasis_topic *ast_channel_topic(struct ast_channel *chan);
4561
4562/*!
4563 * \brief Get the bridge associated with a channel
4564 * \since 12.0.0
4565 *
4566 * \param chan The channel whose bridge we want
4567 *
4568 * \details
4569 * The bridge returned has its reference count incremented. Use
4570 * ao2_cleanup() or ao2_ref() in order to decrement the
4571 * reference count when you are finished with the bridge.
4572 *
4573 * \note This function expects the channel to be locked prior to
4574 * being called and will not grab the channel lock.
4575 *
4576 * \retval NULL No bridge present on the channel
4577 * \retval non-NULL The bridge the channel is in
4578 */
4579struct ast_bridge *ast_channel_get_bridge(const struct ast_channel *chan);
4580
4581/*!
4582 * \brief Determine if a channel is in a bridge
4583 * \since 12.0.0
4584 *
4585 * \param chan The channel to test
4586 *
4587 * \note This function expects the channel to be locked prior to
4588 * being called and will not grab the channel lock.
4589 *
4590 * \retval 0 The channel is not bridged
4591 * \retval non-zero The channel is bridged
4592 */
4593int ast_channel_is_bridged(const struct ast_channel *chan);
4594
4595/*!
4596 * \brief Determine if a channel is leaving a bridge, but \em not hung up
4597 * \since 12.4.0
4598 *
4599 * \param chan The channel to test
4600 *
4601 * \note If a channel is hung up, it is implicitly leaving any bridge it
4602 * may be in. This function is used to test if a channel is leaving a bridge
4603 * but may survive the experience, if it has a place to go to (dialplan or
4604 * otherwise)
4605 *
4606 * \retval 0 The channel is not leaving the bridge or is hung up
4607 * \retval non-zero The channel is leaving the bridge
4608 */
4610
4611/*!
4612 * \brief Get the channel's bridge peer only if the bridge is two-party.
4613 * \since 12.0.0
4614 *
4615 * \param chan Channel desiring the bridge peer channel.
4616 *
4617 * \note The returned peer channel is the current peer in the
4618 * bridge when called.
4619 *
4620 * \note Absolutely _NO_ channel locks should be held when calling this function.
4621 *
4622 * \retval NULL Channel not in a bridge or the bridge is not two-party.
4623 * \retval non-NULL Reffed peer channel at time of calling.
4624 */
4625struct ast_channel *ast_channel_bridge_peer(struct ast_channel *chan);
4626
4627/*!
4628 * \brief Get a reference to the channel's bridge pointer.
4629 * \since 12.0.0
4630 *
4631 * \param chan The channel whose bridge channel is desired
4632 *
4633 * \note This increases the reference count of the bridge_channel.
4634 * Use ao2_ref() or ao2_cleanup() to decrement the refcount when
4635 * you are finished with it.
4636 *
4637 * \note It is expected that the channel is locked prior to
4638 * placing this call.
4639 *
4640 * \retval NULL The channel has no bridge_channel
4641 * \retval non-NULL A reference to the bridge_channel
4642 */
4644
4645/*!
4646 * \since 12
4647 * \brief Gain control of a channel in the system
4648 *
4649 * The intention of this function is to take a channel that currently
4650 * is running in one thread and gain control of it in the current thread.
4651 * This can be used to redirect a channel to a different place in the dialplan,
4652 * for instance.
4653 *
4654 * \note This function is NOT intended to be used on bridged channels. If you
4655 * need to control a bridged channel, you can set a callback to be called
4656 * once the channel exits the bridge, and run your controlling logic in that
4657 * callback
4658 *
4659 * XXX Put name of callback-setting function in above paragraph once it is written
4660 *
4661 * \note When this function returns successfully, the yankee channel is in a state where
4662 * it cannot be used any further. Always use the returned channel instead.
4663 *
4664 * \note absolutely _NO_ channel locks should be held before calling this function.
4665 *
4666 * \note The dialplan location on the returned channel is where the channel
4667 * should be started in the dialplan if it is returned to it.
4668 *
4669 * \param yankee The channel to gain control of
4670 * \retval NULL Could not gain control of the channel
4671 * \retval non-NULL The channel
4672 */
4673struct ast_channel *ast_channel_yank(struct ast_channel *yankee);
4674
4675/*!
4676 * \since 12
4677 * \brief Move a channel from its current location to a new location
4678 *
4679 * The intention of this function is to have the destination channel
4680 * take on the identity of the source channel.
4681 *
4682 * \note This function is NOT intended to be used on bridged channels. If you
4683 * wish to move an unbridged channel into the place of a bridged channel, then
4684 * use ast_bridge_join() or ast_bridge_impart(). If you wish to move a bridged
4685 * channel into the place of another bridged channel, then use ast_bridge_move().
4686 *
4687 * \note When this function returns succesfully, the source channel is in a
4688 * state where its continued use is unreliable.
4689 *
4690 * \note absolutely _NO_ channel locks should be held before calling this function.
4691 *
4692 * \param dest The place to move the source channel
4693 * \param source The channel to move
4694 * \retval 0 Success
4695 * \retval non-zero Failure
4696 */
4697int ast_channel_move(struct ast_channel *dest, struct ast_channel *source);
4698
4699/*!
4700 * \since 12
4701 * \brief Forward channel stasis messages to the given endpoint
4702 *
4703 * \param chan The channel to forward from
4704 * \param endpoint The endpoint to forward to
4705 *
4706 * \retval 0 Success
4707 * \retval non-zero Failure
4708 */
4709int ast_channel_forward_endpoint(struct ast_channel *chan, struct ast_endpoint *endpoint);
4710
4711/*!
4712 * \brief Return the oldest linkedid between two channels.
4713 *
4714 * A channel linkedid is derived from the channel uniqueid which is formed like this:
4715 * [systemname-]ctime.seq
4716 *
4717 * The systemname, and the dash are optional, followed by the epoch time followed by an
4718 * integer sequence. Note that this is not a decimal number, since 1.2 is less than 1.11
4719 * in uniqueid land.
4720 *
4721 * To compare two uniqueids, we parse out the integer values of the time and the sequence
4722 * numbers and compare them, with time trumping sequence.
4723 *
4724 * \param a The linkedid value of the first channel to compare
4725 * \param b The linkedid value of the second channel to compare
4726 *
4727 * \retval NULL on failure
4728 * \retval The oldest linkedid value
4729 * \since 12.0.0
4730*/
4731const char *ast_channel_oldest_linkedid(const char *a, const char *b);
4732
4733/*!
4734 * \brief Check if the channel has active audiohooks, active framehooks, or a monitor.
4735 * \since 12.0.0
4736 *
4737 * \param chan The channel to check.
4738 *
4739 * \retval non-zero if channel has active audiohooks, framehooks, or monitor.
4740 */
4742
4743/*!
4744 * \brief Check if the channel has any active hooks that require audio.
4745 * \since 12.3.0
4746 *
4747 * \param chan The channel to check.
4748 *
4749 * \retval non-zero if channel has active audiohooks, audio framehooks, or monitor.
4750 */
4752
4753/*!
4754 * \brief Removes the trailing identifiers from a channel name string
4755 * \since 12.0.0
4756 *
4757 * \param channel_name string that you wish to turn into a dial string.
4758 * This string will be edited in place.
4759 */
4760void ast_channel_name_to_dial_string(char *channel_name);
4761
4762#define AST_MUTE_DIRECTION_READ (1 << 0)
4763#define AST_MUTE_DIRECTION_WRITE (1 << 1)
4764
4765/*!
4766 * \brief Suppress passing of a frame type on a channel
4767 *
4768 * \note The channel should be locked before calling this function.
4769 *
4770 * \param chan The channel to suppress
4771 * \param direction The direction in which to suppress
4772 * \param frametype The type of frame (AST_FRAME_VOICE, etc) to suppress
4773 *
4774 * \retval 0 Success
4775 * \retval -1 Failure
4776 */
4777int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype);
4778
4779/*!
4780 * \brief Stop suppressing of a frame type on a channel
4781 *
4782 * \note The channel should be locked before calling this function.
4783 *
4784 * \param chan The channel to stop suppressing
4785 * \param direction The direction in which to stop suppressing
4786 * \param frametype The type of frame (AST_FRAME_VOICE, etc) to stop suppressing
4787 *
4788 * \retval 0 Success
4789 * \retval -1 Failure
4790 */
4791int ast_channel_unsuppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype);
4792
4793/*!
4794 * \brief Simulate a DTMF end on a broken bridge channel.
4795 *
4796 * \param chan Channel sending DTMF that has not ended.
4797 * \param digit DTMF digit to stop.
4798 * \param start DTMF digit start time.
4799 * \param why Reason bridge broken.
4800 */
4801void ast_channel_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why);
4802
4803struct ast_bridge_features;
4804
4805/*!
4806 * \brief Gets the channel-attached features a channel has access to upon being bridged.
4807 *
4808 * \note The channel must be locked when calling this function.
4809 *
4810 * \param chan Which channel to get features for
4811 *
4812 * \retval non-NULL The features currently set for this channel
4813 * \retval NULL if the features have not been set
4814 */
4816
4817/*!
4818 * \brief Appends to the channel-attached features a channel has access to upon being bridged.
4819 *
4820 * \note The channel must be locked when calling this function.
4821 *
4822 * \param chan Which channel to set features for
4823 * \param features The feature set to append to the channel's features
4824 *
4825 * \retval 0 on success
4826 * \retval -1 on failure
4827 */
4828int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge_features *features);
4829
4830/*!
4831 * \brief Sets the channel-attached features a channel has access to upon being bridged.
4832 *
4833 * \note The channel must be locked when calling this function.
4834 *
4835 * \param chan Which channel to set features for
4836 * \param features The feature set with which to replace the channel's features
4837 *
4838 * \retval 0 on success
4839 * \retval -1 on failure
4840 */
4841int ast_channel_feature_hooks_replace(struct ast_channel *chan, struct ast_bridge_features *features);
4842
4844 /* Unable to determine what error occurred. */
4846 /* Channel with this ID already exists */
4848};
4849
4850/*!
4851 * \brief Get error code for latest channel operation.
4852 */
4854
4855/*!
4856 * \brief Am I currently running an intercept dialplan routine.
4857 * \since 13.14.0
4858 *
4859 * \details
4860 * A dialplan intercept routine is equivalent to an interrupt
4861 * routine. As such, the routine must be done quickly and you
4862 * do not have access to the media stream. These restrictions
4863 * are necessary because the media stream is the responsibility
4864 * of some other code and interfering with or delaying that
4865 * processing is bad.
4866 *
4867 * \retval 0 Not in an intercept routine.
4868 * \retval 1 In an intercept routine.
4869 */
4871
4872/*!
4873 * \brief Retrieve the topology of streams on a channel
4874 *
4875 * \param chan The channel to get the stream topology of
4876 *
4877 * \pre chan is locked
4878 *
4879 * \retval non-NULL success
4880 * \retval NULL failure
4881 */
4883 const struct ast_channel *chan);
4884
4885/*!
4886 * \brief Set the topology of streams on a channel
4887 *
4888 * \param chan The channel to set the stream topology on
4889 * \param topology The stream topology to set
4890 *
4891 * \pre chan is locked
4892 *
4893 * \note If topology is NULL a new empty topology will be created
4894 * and returned.
4895 *
4896 * \retval non-NULL Success
4897 * \retval NULL failure
4898 */
4900 struct ast_channel *chan, struct ast_stream_topology *topology);
4901
4902/*!
4903 * \brief Retrieve the default stream of a specific media type on a channel
4904 *
4905 * \param chan The channel to get the stream from
4906 * \param type The media type of the default stream
4907 *
4908 * \pre chan is locked
4909 *
4910 * \retval non-NULL success
4911 * \retval NULL failure
4912 */
4914
4915/*!
4916 * \brief Determine if a channel is multi-stream capable
4917 *
4918 * \param chan The channel to test
4919 *
4920 * \pre chan is locked
4921 *
4922 * \retval true if the channel is multi-stream capable.
4923 */
4924int ast_channel_is_multistream(struct ast_channel *chan);
4925
4926/*!
4927 * \brief Request that the stream topology of a channel change
4928 *
4929 * \param chan The channel to change
4930 * \param topology The new stream topology
4931 * \param change_source The source that initiated the change
4932 *
4933 * \note Absolutely _NO_ channel locks should be held before calling this function.
4934 *
4935 * \retval 0 request has been accepted to be attempted
4936 * \retval -1 request could not be attempted
4937 *
4938 * \note This function initiates an asynchronous request to change the stream topology. It is not
4939 * guaranteed that the topology will change and until an AST_CONTROL_STREAM_TOPOLOGY_CHANGED
4940 * frame is received from the channel the current handler of the channel must tolerate the
4941 * stream topology as it currently exists.
4942 *
4943 * \note This interface is provided for applications and resources to request that the topology change.
4944 * It is not for use by the channel driver itself.
4945 */
4947 struct ast_stream_topology *topology, void *change_source);
4948
4949/*!
4950 * \brief Provide notice to a channel that the stream topology has changed
4951 *
4952 * \param chan The channel to provide notice to
4953 * \param topology The new stream topology
4954 *
4955 * \pre chan is locked Absolutely _NO_ other channels can be locked.
4956 *
4957 * \retval 0 success
4958 * \retval -1 failure
4959 *
4960 * \note This interface is provided for applications and resources to accept a topology change.
4961 * It is not for use by the channel driver itself.
4962 */
4963int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology);
4964
4965/*!
4966 * \brief Provide notice from a channel that the topology has changed on it as a result
4967 * of the remote party renegotiating.
4968 *
4969 * \param chan The channel to provide notice from
4970 *
4971 * \retval 0 success
4972 * \retval -1 failure
4973 *
4974 * \note This interface is provided for channels to provide notice that a topology change
4975 * has occurred as a result of a remote party renegotiating the stream topology.
4976 */
4978
4979/*!
4980 * \brief Retrieve the source that initiated the last stream topology change
4981 *
4982 * \param chan The channel
4983 *
4984 * \retval The channel's stream topology change source
4985 */
4987
4988/*!
4989 * \brief Checks if a channel's technology implements a particular callback function
4990 * \since 18.0.0
4991 *
4992 * \param chan The channel
4993 * \param function The function to look for
4994 *
4995 * \retval 1 if the channel has a technology set and it implements the function
4996 * \retval 0 if the channel doesn't have a technology set or it doesn't implement the function
4997 */
4998#define ast_channel_has_tech_function(chan, function) \
4999 (ast_channel_tech(chan) ? ast_channel_tech(chan)->function != NULL : 0)
5000
5001
5002#endif /* _ASTERISK_CHANNEL_H */
Common implementation-independent jitterbuffer stuff.
ast_alert_status_t
Definition: alertpipe.h:24
static struct aco_type agent_type
char digit
static struct ast_generator gen
const char * str
Definition: app_jack.c:150
char * text
Definition: app_queue.c:1809
ast_cond_t cond
Definition: app_sla.c:336
static char dialcontext[AST_MAX_CONTEXT]
int() ao2_callback_data_fn(void *obj, void *arg, void *data, int flags)
Type of a generic callback function.
Definition: astobj2.h:1244
enum cc_state state
Definition: ccss.c:399
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:348
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:497
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:1732
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:8009
int ast_senddigit_mf_begin(struct ast_channel *chan, char digit)
Send an MF digit to a channel.
Definition: channel.c:4852
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3203
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:2875
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
@ 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
char * ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups)
Print named call groups and named pickup groups.
Definition: channel.c:8082
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:10992
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:10895
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:2112
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:1486
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:1618
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:4734
enum ast_channel_error ast_channel_errno(void)
Get error code for latest channel operation.
Definition: channel.c:10987
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition: channel.c:2979
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:1305
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:1977
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:10522
const char * ast_channel_blockproc(const struct ast_channel *chan)
void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value)
struct ast_stream_topology * ast_channel_set_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
Set the topology of streams on a channel.
char * ast_transfercapability2str(int transfercapability) attribute_const
Gives the string form of a given transfer capability.
Definition: channel.c:672
void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value)
Variant of ast_channel_set_unbridged. Use this if the channel is already locked prior to calling.
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Waits for activity on a group of channels.
Definition: channel.c:3016
int ast_auto_answer(struct ast_channel *chan)
Answer a channel, if it's not already answered.
Definition: channel.c:2840
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:2149
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:2898
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition: channel.c:6478
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:9145
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:6580
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:11060
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2414
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:5915
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:2423
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:1784
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:5505
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
Definition: channel.c:2461
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:1415
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:7937
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:5017
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:2724
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:10364
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:1671
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:2570
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:7380
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:4086
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:5034
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:2668
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:1387
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:10590
int ast_transfer_protocol(struct ast_channel *chan, char *dest, int *protocol)
Transfer a channel (if supported) receieve protocol result.
Definition: channel.c:6515
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:1746
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:8334
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition: channel.c:4891
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:1848
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:1679
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:10555
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:6645
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:1701
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:1724
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:2553
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2099
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:2864
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:7913
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:4768
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:7603
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:7393
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:3185
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:4991
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:2193
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:6737
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_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 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:8014
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:1838
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:1754
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:3008
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:11022
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:1815
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
Definition: channel.c:1449
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition: channel.c:8141
struct ast_namedgroups * ast_ref_namedgroups(struct ast_namedgroups *groups)
Definition: channel.c:7759
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:10982
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition: channel.c:8190
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:2058
int ast_recvchar(struct ast_channel *chan, int timeout)
Receives a text character from a channel.
Definition: channel.c:4723
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:10619
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:7463
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3190
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition: channel.c:1258
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:10477
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:5993
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:4843
@ AST_CHANNEL_ERROR_ID_EXISTS
Definition: channel.h:4847
@ AST_CHANNEL_ERROR_UNKNOWN
Definition: channel.h:4845
int ast_channel_get_intercept_mode(void)
Am I currently running an intercept dialplan routine.
Definition: channel.c:10359
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:2081
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:8236
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:3213
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:1955
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:2013
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:2129
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:8116
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:2397
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:1298
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:6451
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:2921
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:1947
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:1395
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:8057
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:1461
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:2123
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:5802
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:5161
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:2034
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:10803
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:10977
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:4274
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:2090
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:1265
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:10929
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:9119
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:4960
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:10692
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:10323
void ast_party_redirecting_reason_init(struct ast_party_redirecting_reason *init)
Initialize the given redirecting reason structure.
Definition: channel.c:2106
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:5004
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:4826
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:4279
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:2026
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:1807
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
Definition: channel.c:1665
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:7918
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:1998
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:7355
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:10409
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:6793
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:4289
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:2180
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:5779
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:1640
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:1193
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:8811
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
Definition: channel.c:2042
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:1963
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:6376
struct ast_namedgroups * ast_get_namedgroups(const char *s)
Create an ast_namedgroups set with group names from comma separated string.
Definition: channel.c:7696
int ast_channel_supports_html(struct ast_channel *channel)
Checks for HTML support on a channel.
Definition: channel.c:6640
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:4079
@ AST_MONITOR_PAUSED
Definition: channel.h:4081
@ AST_MONITOR_RUNNING
Definition: channel.h:4080
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:1648
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:1777
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
Definition: channel.c:10571
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:1985
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:5843
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:4284
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:2849
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition: channel.c:10560
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:1611
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:4670
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:9294
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:2528
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition: channel.c:11053
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
Definition: channel.c:2500
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:6861
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:4363
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:1243
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:10310
int ast_channel_has_manager_vars(void)
Return whether or not any manager variables have been set.
Definition: channel.c:7881
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:1923
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
Definition: channel.c:4390
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:1916
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:1218
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:8723
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4941
int ast_channel_has_ari_vars(void)
Return whether or not any ARI variables have been set.
Definition: channel.c:7886
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:1929
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:6191
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:11034
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:1693
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:3208
@ 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(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition: channel.c:5820
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:1792
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition: channel.c:1718
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:2049
int ast_channel_get_up_time(struct ast_channel *chan)
Obtain how long it has been since the channel was answered.
Definition: channel.c:2874
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:10576
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:6652
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:9505
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:1595
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:10608
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:4969
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:6502
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:10865
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2206
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:2455
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:8319
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2487
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:4377
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:6456
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:2867
const char * ast_channel_call_forward(const struct ast_channel *chan)
int ast_set_write_format_path(struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format)
Set specific write path on channel.
Definition: channel.c:5541
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:6461
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:1273
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:7753
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition: channel.c:1771
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:7443
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:5797
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:2859
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:9132
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:2072
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:5166
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:1606
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:6575
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:8326
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:1481
int ast_channel_defer_dtmf(struct ast_channel *chan)
Defers DTMF so that you only read things like hangups and audio.
Definition: channel.c:1284
int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition: channel.c:7621
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2834
void ast_change_name(struct ast_channel *chan, const char *newname)
Change channel name.
Definition: channel.c:6781
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:7639
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:7433
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:4294
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:1494
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:1435
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1601
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:6371
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:10500
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:2719
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:3267
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:2162
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:1626
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:10539
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:2428
void ast_party_redirecting_reason_free(struct ast_party_redirecting_reason *doomed)
Destroy the redirecting reason contents.
Definition: channel.c:2143
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
Definition: channel.c:2005
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:5838
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
@ 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_channel_alert_writable(struct ast_channel *chan)
void ast_tonepair_stop(struct ast_channel *chan)
Definition: channel.c:7616
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:2547
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:353
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::@333 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.
union ast_frame::@228 data
struct ast_frame_subclass subclass
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:2963
char * category
Definition: channel.h:2965
char * group
Definition: channel.h:2966
struct ast_group_info::@212 group_list
struct ast_channel * chan
Definition: channel.h:2964
struct ast_hangup_handler::@211 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_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:393
struct ast_party_dialed::@210 number
Dialed/Called number.
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:215
Indicate what information in ast_party_caller should be set.
Definition: channel.h:442
struct ast_set_party_id priv
Definition: channel.h:448
struct ast_set_party_id ani
Definition: channel.h:446
struct ast_set_party_id id
Definition: channel.h:444
Indicate what information in ast_party_connected_line should be set.
Definition: channel.h:491
struct ast_set_party_id priv
Definition: channel.h:497
struct ast_set_party_id ani
Definition: channel.h:495
struct ast_set_party_id id
Definition: channel.h:493
Indicate what information in ast_party_id should be set.
Definition: channel.h:363
unsigned char subaddress
Definition: channel.h:369
unsigned char number
Definition: channel.h:367
unsigned char name
Definition: channel.h:365
Indicate what information in ast_party_redirecting should be set.
Definition: channel.h:557
struct ast_set_party_id priv_to
Definition: channel.h:569
struct ast_set_party_id from
Definition: channel.h:561
struct ast_set_party_id priv_orig
Definition: channel.h:565
struct ast_set_party_id priv_from
Definition: channel.h:567
struct ast_set_party_id orig
Definition: channel.h:559
struct ast_set_party_id to
Definition: channel.h:563
Support for dynamic strings.
Definition: strings.h:623
A set of tones for a given locale.
Definition: indications.h:74
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition: translate.h:213
Structure for variables, used for configurations and for channel variables.
Definition: file.c:69
Number structure.
Definition: app_followme.c:157
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.