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