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