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