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