Asterisk - The Open Source Telephony Project  GIT-master-a24979a
channel_internal_api.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2012, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*! \file
20  *
21  * \brief Channel Accessor API
22  *
23  * This file is intended to be the only file that ever accesses the
24  * internals of an ast_channel. All other files should use the
25  * accessor functions defined here.
26  *
27  * \author Terry Wilson
28  */
29 
30 /*** MODULEINFO
31  <support_level>core</support_level>
32  ***/
33 
34 #include "asterisk.h"
35 
36 #include <unistd.h>
37 #include <fcntl.h>
38 
39 #include "asterisk/alertpipe.h"
40 #include "asterisk/paths.h"
41 #include "asterisk/channel.h"
43 #include "asterisk/endpoints.h"
44 #include "asterisk/indications.h"
47 #include "asterisk/stringfields.h"
48 #include "asterisk/stream.h"
49 #include "asterisk/test.h"
50 #include "asterisk/vector.h"
51 
52 /*!
53  * \brief Channel UniqueId structure
54  * \note channel creation time used for determining LinkedId Propagation
55  */
57  time_t creation_time; /*!< Creation time */
58  int creation_unique; /*!< sub-second unique value */
59  char unique_id[AST_MAX_UNIQUEID]; /*!< Unique Identifier */
60 };
61 
62 /*!
63  * \brief Main Channel structure associated with a channel.
64  *
65  * \note When adding fields to this structure, it is important to add the field
66  * 'in position' with like-aligned fields, so as to keep the compiler from
67  * having to add padding to align fields. The structure's fields are sorted
68  * in this order: pointers, structures, long, int/enum, short, char. This
69  * is especially important on 64-bit architectures, where mixing 4-byte
70  * and 8-byte fields causes 4 bytes of padding to be added before many
71  * 8-byte fields.
72  */
73 struct ast_channel {
74  const struct ast_channel_tech *tech; /*!< Technology (point to channel driver) */
75  void *tech_pvt; /*!< Private data used by the technology driver */
76  void *music_state; /*!< Music State*/
77  void *generatordata; /*!< Current generator data if there is any */
78  struct ast_generator *generator; /*!< Current active data generator */
79  struct ast_channel *masq; /*!< Channel that will masquerade as us */
80  struct ast_channel *masqr; /*!< Who we are masquerading as */
81  const char *blockproc; /*!< Procedure causing blocking */
82  const char *appl; /*!< Current application */
83  const char *data; /*!< Data passed to current application */
84  struct ast_sched_context *sched; /*!< Schedule context */
85  struct ast_filestream *stream; /*!< Stream itself. */
86  struct ast_filestream *vstream; /*!< Video Stream itself. */
88  void *timingdata;
89  struct ast_pbx *pbx; /*!< PBX private structure for this channel */
90  struct ast_trans_pvt *writetrans; /*!< Write translation path */
91  struct ast_trans_pvt *readtrans; /*!< Read translation path */
94  struct ast_cdr *cdr; /*!< Call Detail Record */
95  struct ast_tone_zone *zone; /*!< Tone zone as set in indications.conf or
96  * in the CHANNEL dialplan function */
97  struct ast_channel_monitor *monitor; /*!< Channel monitoring */
98  ast_callid callid; /*!< Bound call identifier pointer */
99  struct ao2_container *dialed_causes; /*!< Contains tech-specific and Asterisk cause data from dialed channels */
100 
102  AST_STRING_FIELD(name); /*!< ASCII unique channel name */
103  AST_STRING_FIELD(language); /*!< Language requested for voice prompts */
104  AST_STRING_FIELD(musicclass); /*!< Default music class */
105  AST_STRING_FIELD(latest_musicclass); /*!< Latest active music class */
106  AST_STRING_FIELD(accountcode); /*!< Account code for billing */
107  AST_STRING_FIELD(peeraccount); /*!< Peer account code for billing */
108  AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
109  AST_STRING_FIELD(call_forward); /*!< Where to forward to if asked to dial on this interface */
110  AST_STRING_FIELD(parkinglot); /*! Default parking lot, if empty, default parking lot */
111  AST_STRING_FIELD(hangupsource); /*! Who is responsible for hanging up this channel */
112  AST_STRING_FIELD(dialcontext); /*!< Dial: Extension context that we were called from */
113  );
114 
115  struct ast_channel_id uniqueid; /*!< Unique Channel Identifier - can be specified on creation */
116  struct ast_channel_id linkedid; /*!< Linked Channel Identifier - oldest propagated when bridged */
117 
118  struct timeval whentohangup; /*!< Non-zero, set to actual time when channel is to be hung up */
119  pthread_t blocker; /*!< If anyone is blocking, this is them */
120 
121  /*!
122  * \brief Dialed/Called information.
123  * \note Set on incoming channels to indicate the originally dialed party.
124  * \note Dialed Number Identifier (DNID)
125  */
126  struct ast_party_dialed dialed;
127 
128  /*!
129  * \brief Channel Caller ID information.
130  * \note The caller id information is the caller id of this
131  * channel when it is used to initiate a call.
132  */
133  struct ast_party_caller caller;
134 
135  /*!
136  * \brief Channel Connected Line ID information.
137  * \note The connected line information identifies the channel
138  * connected/bridged to this channel.
139  */
141 
142  /*!
143  * \brief Channel Connected Line ID information that was last indicated.
144  */
146 
147  /*! \brief Redirecting/Diversion information */
149 
150  struct ast_frame dtmff; /*!< DTMF frame */
151  struct varshead varshead; /*!< A linked list for channel variables. See \ref AstChanVar */
152  ast_group_t callgroup; /*!< Call group for call pickups */
153  ast_group_t pickupgroup; /*!< Pickup group - which calls groups can be picked up? */
154  struct ast_namedgroups *named_callgroups; /*!< Named call group for call pickups */
155  struct ast_namedgroups *named_pickupgroups; /*!< Named pickup group - which call groups can be picked up? */
156  struct timeval creationtime; /*!< The time of channel creation */
157  struct timeval answertime; /*!< The time the channel was answered */
158  struct ast_readq_list readq;
159  struct ast_jb jb; /*!< The jitterbuffer state */
160  struct timeval dtmf_tv; /*!< The time that an in process digit began, or the last digit ended */
161  struct ast_hangup_handler_list hangup_handlers;/*!< Hangup handlers on the channel. */
162  struct ast_datastore_list datastores; /*!< Data stores on the channel */
163  struct ast_autochan_list autochans; /*!< Autochans on the channel */
164  unsigned long insmpl; /*!< Track the read/written samples for monitor use */
165  unsigned long outsmpl; /*!< Track the read/written samples for monitor use */
166 
167  int blocker_tid; /*!< If anyone is blocking, this is their thread id */
168  AST_VECTOR(, int) fds; /*!< File descriptors for channel -- Drivers will poll on
169  * these file descriptors, so at least one must be non -1.
170  * See \arg \ref AstFileDesc */
171  int softhangup; /*!< Whether or not we have been hung up... Do not set this value
172  * directly, use ast_softhangup() */
173  int fdno; /*!< Which fd had an event detected on */
174  int streamid; /*!< For streaming playback, the schedule ID */
175  int vstreamid; /*!< For streaming video playback, the schedule ID */
176  struct ast_format *oldwriteformat; /*!< Original writer format */
177  int timingfd; /*!< Timing fd */
178  enum ast_channel_state state; /*!< State of line -- Don't write directly, use ast_setstate() */
179  int rings; /*!< Number of rings so far */
180  int priority; /*!< Dialplan: Current extension priority */
181  int macropriority; /*!< Macro: Current non-macro priority. See app_macro.c */
182  int amaflags; /*!< Set BEFORE PBX is started to determine AMA flags */
183  enum ast_channel_adsicpe adsicpe; /*!< Whether or not ADSI is detected on CPE */
184  unsigned int fin; /*!< Frames in counters. The high bit is a debug mask, so
185  * the counter is only in the remaining bits */
186  unsigned int fout; /*!< Frames out counters. The high bit is a debug mask, so
187  * the counter is only in the remaining bits */
188  int hangupcause; /*!< Why is the channel hanged up. See causes.h */
189  unsigned int finalized:1; /*!< Whether or not the channel has been successfully allocated */
190  struct ast_flags flags; /*!< channel flags of AST_FLAG_ type */
191  int alertpipe[2];
192  struct ast_format_cap *nativeformats; /*!< Kinds of data this channel can natively handle */
193  struct ast_format *readformat; /*!< Requested read format (after translation) */
194  struct ast_format *writeformat; /*!< Requested write format (before translation) */
195  struct ast_format *rawreadformat; /*!< Raw read format (before translation) */
196  struct ast_format *rawwriteformat; /*!< Raw write format (after translation) */
197  unsigned int emulate_dtmf_duration; /*!< Number of ms left to emulate DTMF for */
198  int visible_indication; /*!< Indication currently playing on the channel */
199  int hold_state; /*!< Current Hold/Unhold state */
200 
201  unsigned short transfercapability; /*!< ISDN Transfer Capability - AST_FLAG_DIGITAL is not enough */
202 
203  struct ast_bridge *bridge; /*!< Bridge this channel is participating in */
204  struct ast_bridge_channel *bridge_channel;/*!< The bridge_channel this channel is linked with. */
205  struct ast_timer *timer; /*!< timer object that provided timingfd */
206 
207  char context[AST_MAX_CONTEXT]; /*!< Dialplan: Current extension context */
208  char exten[AST_MAX_EXTENSION]; /*!< Dialplan: Current extension number */
209  char lastcontext[AST_MAX_CONTEXT]; /*!< Dialplan: Previous extension context */
210  char lastexten[AST_MAX_EXTENSION]; /*!< Dialplan: Previous extension number */
211  char macrocontext[AST_MAX_CONTEXT]; /*!< Macro: Current non-macro context. See app_macro.c */
212  char macroexten[AST_MAX_EXTENSION]; /*!< Macro: Current non-macro extension. See app_macro.c */
213  char unbridged; /*!< non-zero if the bridge core needs to re-evaluate the current
214  bridging technology which is in use by this channel's bridge. */
215  char is_t38_active; /*!< non-zero if T.38 is active on this channel. */
216  char dtmf_digit_to_emulate; /*!< Digit being emulated */
217  char sending_dtmf_digit; /*!< Digit this channel is currently sending out. (zero if not sending) */
218  struct timeval sending_dtmf_tv; /*!< The time this channel started sending the current digit. (Invalid if sending_dtmf_digit is zero.) */
219  struct stasis_topic *topic; /*!< Topic for this channel */
220  struct stasis_forward *channel_forward; /*!< Subscription for event forwarding to all channel topic */
221  struct stasis_forward *endpoint_forward; /*!< Subscription for event forwarding to endpoint's topic */
222  struct ast_stream_topology *stream_topology; /*!< Stream topology */
223  void *stream_topology_change_source; /*!< Source that initiated a stream topology change */
224  struct ast_stream *default_streams[AST_MEDIA_TYPE_END]; /*!< Default streams indexed by media type */
225  struct ast_channel_snapshot *snapshot; /*!< The current up to date snapshot of the channel */
226  struct ast_flags snapshot_segment_flags; /*!< Flags regarding the segments of the snapshot */
227 };
228 
229 /*! \brief The monotonically increasing integer counter for channel uniqueids */
230 static int uniqueint;
231 
232 /* ACCESSORS */
233 
234 #define DEFINE_STRINGFIELD_SETTERS_FOR(field, assert_on_null) \
235 void ast_channel_##field##_set(struct ast_channel *chan, const char *value) \
236 { \
237  if ((assert_on_null)) ast_assert(!ast_strlen_zero(value)); \
238  if (!strcmp(value, chan->field)) return; \
239  ast_string_field_set(chan, field, value); \
240 } \
241  \
242 void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) \
243 { \
244  ast_string_field_build_va(chan, field, fmt, ap); \
245 } \
246 void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) \
247 { \
248  va_list ap; \
249  va_start(ap, fmt); \
250  ast_channel_##field##_build_va(chan, fmt, ap); \
251  va_end(ap); \
252 }
253 
254 #define DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(field, publish, assert_on_null, invalidate) \
255 void ast_channel_##field##_set(struct ast_channel *chan, const char *value) \
256 { \
257  if ((assert_on_null)) ast_assert(!ast_strlen_zero(value)); \
258  if (!strcmp(value, chan->field)) return; \
259  ast_string_field_set(chan, field, value); \
260  ast_channel_snapshot_invalidate_segment(chan, invalidate); \
261  if (publish && ast_channel_internal_is_finalized(chan)) ast_channel_publish_snapshot(chan); \
262 } \
263  \
264 void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) \
265 { \
266  ast_string_field_build_va(chan, field, fmt, ap); \
267  ast_channel_snapshot_invalidate_segment(chan, invalidate); \
268  if (publish && ast_channel_internal_is_finalized(chan)) ast_channel_publish_snapshot(chan); \
269 } \
270 void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) \
271 { \
272  va_list ap; \
273  va_start(ap, fmt); \
274  ast_channel_##field##_build_va(chan, fmt, ap); \
275  va_end(ap); \
276 }
277 
281 DEFINE_STRINGFIELD_SETTERS_FOR(latest_musicclass, 0);
289 
290 #define DEFINE_STRINGFIELD_GETTER_FOR(field) const char *ast_channel_##field(const struct ast_channel *chan) \
291 { \
292  return chan->field; \
293 }
294 
298 DEFINE_STRINGFIELD_GETTER_FOR(latest_musicclass);
306 
307 const char *ast_channel_uniqueid(const struct ast_channel *chan)
308 {
309  ast_assert(chan->uniqueid.unique_id[0] != '\0');
310  return chan->uniqueid.unique_id;
311 }
312 
313 const char *ast_channel_linkedid(const struct ast_channel *chan)
314 {
315  ast_assert(chan->linkedid.unique_id[0] != '\0');
316  return chan->linkedid.unique_id;
317 }
318 
319 const char *ast_channel_appl(const struct ast_channel *chan)
320 {
321  return chan->appl;
322 }
323 void ast_channel_appl_set(struct ast_channel *chan, const char *value)
324 {
325  chan->appl = value;
327 }
328 const char *ast_channel_blockproc(const struct ast_channel *chan)
329 {
330  return chan->blockproc;
331 }
332 void ast_channel_blockproc_set(struct ast_channel *chan, const char *value)
333 {
334  chan->blockproc = value;
335 }
336 const char *ast_channel_data(const struct ast_channel *chan)
337 {
338  return chan->data;
339 }
340 void ast_channel_data_set(struct ast_channel *chan, const char *value)
341 {
342  chan->data = value;
344 }
345 
346 const char *ast_channel_context(const struct ast_channel *chan)
347 {
348  return chan->context;
349 }
350 const char *ast_channel_lastcontext(const struct ast_channel *chan)
351 {
352  return chan->lastcontext;
353 }
354 void ast_channel_context_set(struct ast_channel *chan, const char *value)
355 {
356  if (!*chan->lastcontext || strcmp(value, chan->context)) {
357  /* only copy to last context when it changes, unless it's empty to begin with */
358  ast_copy_string(chan->lastcontext, chan->context, sizeof(chan->lastcontext));
359  }
360  ast_copy_string(chan->context, value, sizeof(chan->context));
362 }
363 const char *ast_channel_exten(const struct ast_channel *chan)
364 {
365  return chan->exten;
366 }
367 const char *ast_channel_lastexten(const struct ast_channel *chan)
368 {
369  return chan->lastexten;
370 }
371 void ast_channel_exten_set(struct ast_channel *chan, const char *value)
372 {
373  if (!*chan->lastexten || strcmp(value, chan->exten)) {
374  /* only copy to last exten when it changes, unless it's empty to begin with */
375  ast_copy_string(chan->lastexten, chan->exten, sizeof(chan->lastexten));
376  }
377  ast_copy_string(chan->exten, value, sizeof(chan->exten));
379 }
380 const char *ast_channel_macrocontext(const struct ast_channel *chan)
381 {
382  return chan->macrocontext;
383 }
384 void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value)
385 {
386  ast_copy_string(chan->macrocontext, value, sizeof(chan->macrocontext));
387 }
388 const char *ast_channel_macroexten(const struct ast_channel *chan)
389 {
390  return chan->macroexten;
391 }
392 void ast_channel_macroexten_set(struct ast_channel *chan, const char *value)
393 {
394  ast_copy_string(chan->macroexten, value, sizeof(chan->macroexten));
395 }
396 
398 {
399  return chan->dtmf_digit_to_emulate;
400 }
402 {
404 }
405 
407 {
408  return chan->sending_dtmf_digit;
409 }
411 {
412  chan->sending_dtmf_digit = value;
413 }
414 
415 struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan)
416 {
417  return chan->sending_dtmf_tv;
418 }
419 void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value)
420 {
421  chan->sending_dtmf_tv = value;
422 }
423 
424 enum ama_flags ast_channel_amaflags(const struct ast_channel *chan)
425 {
426  return chan->amaflags;
427 }
428 
430 {
431  if (chan->amaflags == value) {
432  return;
433  }
434  chan->amaflags = value;
436 }
437 int ast_channel_fdno(const struct ast_channel *chan)
438 {
439  return chan->fdno;
440 }
441 void ast_channel_fdno_set(struct ast_channel *chan, int value)
442 {
443  chan->fdno = value;
444 }
445 int ast_channel_hangupcause(const struct ast_channel *chan)
446 {
447  return chan->hangupcause;
448 }
450 {
451  chan->hangupcause = value;
453 }
454 int ast_channel_macropriority(const struct ast_channel *chan)
455 {
456  return chan->macropriority;
457 }
459 {
460  chan->macropriority = value;
461 }
462 int ast_channel_priority(const struct ast_channel *chan)
463 {
464  return chan->priority;
465 }
467 {
468  chan->priority = value;
470 }
471 int ast_channel_rings(const struct ast_channel *chan)
472 {
473  return chan->rings;
474 }
475 void ast_channel_rings_set(struct ast_channel *chan, int value)
476 {
477  chan->rings = value;
478 }
479 int ast_channel_streamid(const struct ast_channel *chan)
480 {
481  return chan->streamid;
482 }
484 {
485  chan->streamid = value;
486 }
487 int ast_channel_timingfd(const struct ast_channel *chan)
488 {
489  return chan->timingfd;
490 }
492 {
493  chan->timingfd = value;
494 }
496 {
497  return chan->visible_indication;
498 }
500 {
501  chan->visible_indication = value;
502 }
503 int ast_channel_hold_state(const struct ast_channel *chan)
504 {
505  return chan->hold_state;
506 }
508 {
509  chan->hold_state = value;
510 }
511 int ast_channel_vstreamid(const struct ast_channel *chan)
512 {
513  return chan->vstreamid;
514 }
516 {
517  chan->vstreamid = value;
518 }
519 unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
520 {
521  return chan->transfercapability;
522 }
523 void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value)
524 {
525  chan->transfercapability = value;
526 }
527 unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan)
528 {
529  return chan->emulate_dtmf_duration;
530 }
532 {
534 }
535 unsigned int ast_channel_fin(const struct ast_channel *chan)
536 {
537  return chan->fin;
538 }
539 void ast_channel_fin_set(struct ast_channel *chan, unsigned int value)
540 {
541  chan->fin = value;
542 }
543 unsigned int ast_channel_fout(const struct ast_channel *chan)
544 {
545  return chan->fout;
546 }
547 void ast_channel_fout_set(struct ast_channel *chan, unsigned int value)
548 {
549  chan->fout = value;
550 }
551 unsigned long ast_channel_insmpl(const struct ast_channel *chan)
552 {
553  return chan->insmpl;
554 }
555 void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value)
556 {
557  chan->insmpl = value;
558 }
559 unsigned long ast_channel_outsmpl(const struct ast_channel *chan)
560 {
561  return chan->outsmpl;
562 }
563 void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value)
564 {
565  chan->outsmpl = value;
566 }
567 void *ast_channel_generatordata(const struct ast_channel *chan)
568 {
569  return chan->generatordata;
570 }
572 {
573  chan->generatordata = value;
574 }
575 void *ast_channel_music_state(const struct ast_channel *chan)
576 {
577  return chan->music_state;
578 }
580 {
581  chan->music_state = value;
582 }
583 void *ast_channel_tech_pvt(const struct ast_channel *chan)
584 {
585  return chan->tech_pvt;
586 }
587 void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
588 {
589  chan->tech_pvt = value;
590 }
591 void *ast_channel_timingdata(const struct ast_channel *chan)
592 {
593  return chan->timingdata;
594 }
596 {
597  chan->timingdata = value;
598 }
600 {
601  return chan->audiohooks;
602 }
604 {
605  chan->audiohooks = value;
606 }
607 struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan)
608 {
609  return chan->cdr;
610 }
611 void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value)
612 {
613  chan->cdr = value;
614 }
615 struct ast_channel *ast_channel_masq(const struct ast_channel *chan)
616 {
617  return chan->masq;
618 }
620 {
621  chan->masq = value;
622 }
623 struct ast_channel *ast_channel_masqr(const struct ast_channel *chan)
624 {
625  return chan->masqr;
626 }
628 {
629  chan->masqr = value;
630 }
632 {
633  return chan->monitor;
634 }
636 {
637  chan->monitor = value;
638 }
639 struct ast_filestream *ast_channel_stream(const struct ast_channel *chan)
640 {
641  return chan->stream;
642 }
644 {
645  chan->stream = value;
646 }
647 struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan)
648 {
649  return chan->vstream;
650 }
652 {
653  chan->vstream = value;
654 }
656 {
657  return chan->nativeformats;
658 }
659 
660 static void channel_set_default_streams(struct ast_channel *chan)
661 {
662  enum ast_media_type type;
663 
664  ast_assert(chan != NULL);
665 
667  if (chan->stream_topology) {
668  chan->default_streams[type] =
670  } else {
671  chan->default_streams[type] = NULL;
672  }
673  }
674 }
675 
677  struct ast_stream_topology *topology)
678 {
680  chan->stream_topology = topology;
682 }
683 
685  struct ast_channel *chan, void *change_source)
686 {
687  chan->stream_topology_change_source = change_source;
688 }
689 
691 {
692  return chan->stream_topology_change_source;
693 }
694 
696  struct ast_format_cap *value)
697 {
698  SCOPE_ENTER(2, "%s: %sFormats: %s\n", S_OR(ast_channel_name(chan), "<initializing>"),
699  S_COR(ast_channel_is_multistream(chan), "Multistream", ""),
700  ast_str_tmp(128, ast_format_cap_get_names(value, &STR_TMP)));
701 
702  ast_assert(chan != NULL);
703 
705 
706  /* If chan->stream_topology is NULL, the channel is being destroyed
707  * and topology is destroyed.
708  */
709  if (!chan->stream_topology) {
710  SCOPE_EXIT_RTN("Channel is being initialized or destroyed\n");
711  }
712 
713  if (!ast_channel_is_multistream(chan) || !value) {
714  struct ast_stream_topology *new_topology;
715 
717  ast_channel_internal_set_stream_topology(chan, new_topology);
718  SCOPE_EXIT_RTN("New %stopology set\n", value ? "" : "empty ");
719  }
720  SCOPE_EXIT_RTN("Set native formats but not topology\n");
721 }
722 
724 {
725  return chan->framehooks;
726 }
728 {
729  chan->framehooks = value;
730 }
732 {
733  return chan->generator;
734 }
736 {
737  chan->generator = value;
738 }
739 struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan)
740 {
741  return chan->pbx;
742 }
743 void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value)
744 {
745  chan->pbx = value;
746 }
748 {
749  return chan->sched;
750 }
752 {
753  chan->sched = value;
754 }
755 struct ast_timer *ast_channel_timer(const struct ast_channel *chan)
756 {
757  return chan->timer;
758 }
760 {
761  chan->timer = value;
762 }
763 struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan)
764 {
765  return chan->zone;
766 }
768 {
769  chan->zone = value;
770 }
772 {
773  return chan->readtrans;
774 }
776 {
777  chan->readtrans = value;
778 }
780 {
781  return chan->writetrans;
782 }
784 {
785  chan->writetrans = value;
786 }
787 const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan)
788 {
789  return chan->tech;
790 }
791 void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
792 {
793  if (value->read_stream || value->write_stream) {
794  ast_assert(value->read_stream && value->write_stream);
795  }
796 
797  chan->tech = value;
798 }
799 enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan)
800 {
801  return chan->adsicpe;
802 }
804 {
805  chan->adsicpe = value;
806 }
807 enum ast_channel_state ast_channel_state(const struct ast_channel *chan)
808 {
809  return chan->state;
810 }
812 {
813  return chan->callid;
814 }
816 {
817  char call_identifier_from[AST_CALLID_BUFFER_LENGTH];
818  char call_identifier_to[AST_CALLID_BUFFER_LENGTH];
819  call_identifier_from[0] = '\0';
820  ast_callid_strnprint(call_identifier_to, sizeof(call_identifier_to), callid);
821  if (chan->callid) {
822  ast_callid_strnprint(call_identifier_from, sizeof(call_identifier_from), chan->callid);
823  ast_debug(3, "Channel Call ID changing from %s to %s\n", call_identifier_from, call_identifier_to);
824  }
825 
826  chan->callid = callid;
827 
828  ast_test_suite_event_notify("CallIDChange",
829  "State: CallIDChange\r\n"
830  "Channel: %s\r\n"
831  "CallID: %s\r\n"
832  "PriorCallID: %s",
833  ast_channel_name(chan),
834  call_identifier_to,
835  call_identifier_from);
836 }
837 
839 {
840  chan->state = value;
841 }
843 {
845 }
847 {
849 }
851 {
853 }
855 {
856  ao2_replace(chan->readformat, format);
857 }
859 {
861 }
863 {
864  return chan->oldwriteformat;
865 }
867 {
868  return chan->rawreadformat;
869 }
871 {
872  return chan->rawwriteformat;
873 }
875 {
876  return chan->readformat;
877 }
879 {
880  return chan->writeformat;
881 }
883 {
884  return &chan->hangup_handlers;
885 }
887 {
888  return &chan->datastores;
889 }
891 {
892  return &chan->autochans;
893 }
895 {
896  return &chan->readq;
897 }
899 {
900  return &chan->dtmff;
901 }
902 struct ast_jb *ast_channel_jb(struct ast_channel *chan)
903 {
904  return &chan->jb;
905 }
907 {
908  return &chan->caller;
909 }
911 {
912  return &chan->connected;
913 }
915 {
916  return &chan->connected_indicated;
917 }
919 {
920  return ast_party_id_merge(&chan->connected.id, &chan->connected.priv);
921 }
923 {
924  return &chan->dialed;
925 }
927 {
928  return &chan->redirecting;
929 }
931 {
932  return ast_party_id_merge(&chan->redirecting.orig, &chan->redirecting.priv_orig);
933 }
935 {
936  return ast_party_id_merge(&chan->redirecting.from, &chan->redirecting.priv_from);
937 }
939 {
940  return ast_party_id_merge(&chan->redirecting.to, &chan->redirecting.priv_to);
941 }
942 struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan)
943 {
944  return &chan->dtmf_tv;
945 }
946 struct timeval *ast_channel_whentohangup(struct ast_channel *chan)
947 {
948  return &chan->whentohangup;
949 }
951 {
952  return &chan->varshead;
953 }
955 {
956  chan->dtmff = *value;
957 }
958 void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value)
959 {
960  chan->jb = *value;
961 }
963 {
964  chan->caller = *value;
966 }
968 {
969  chan->connected = *value;
971 }
973 {
974  chan->dialed = *value;
976 }
978 {
979  chan->redirecting = *value;
981 }
982 void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value)
983 {
984  chan->dtmf_tv = *value;
985 }
986 void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
987 {
988  chan->whentohangup = *value;
989 }
991 {
992  chan->varshead = *value;
993 }
994 struct timeval ast_channel_creationtime(struct ast_channel *chan)
995 {
996  return chan->creationtime;
997 }
998 void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value)
999 {
1000  chan->creationtime = *value;
1002 }
1003 
1004 struct timeval ast_channel_answertime(struct ast_channel *chan)
1005 {
1006  return chan->answertime;
1007 }
1008 
1009 void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value)
1010 {
1011  chan->answertime = *value;
1012 }
1013 
1014 /* Evil softhangup accessors */
1016 {
1017  return chan->softhangup;
1018 }
1020 {
1021  chan->softhangup = value;
1022 }
1024 {
1025  chan->softhangup |= value;
1026 }
1028 {
1029  chan ->softhangup &= ~value;
1030 }
1031 
1033 {
1034  return chan->unbridged;
1035 }
1036 
1038 {
1039  int res;
1040  ast_channel_lock(chan);
1041  res = ast_channel_unbridged_nolock(chan);
1042  ast_channel_unlock(chan);
1043  return res;
1044 }
1045 
1047 {
1048  chan->unbridged = !!value;
1050 }
1051 
1053 {
1054  ast_channel_lock(chan);
1056  ast_channel_unlock(chan);
1057 }
1058 
1060 {
1061  return chan->is_t38_active;
1062 }
1063 
1065 {
1066  int res;
1067 
1068  ast_channel_lock(chan);
1070  ast_channel_unlock(chan);
1071  return res;
1072 }
1073 
1074 void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active)
1075 {
1076  chan->is_t38_active = !!is_t38_active;
1077 }
1078 
1079 void ast_channel_set_is_t38_active(struct ast_channel *chan, int is_t38_active)
1080 {
1081  ast_channel_lock(chan);
1082  ast_channel_set_is_t38_active_nolock(chan, is_t38_active);
1083  ast_channel_unlock(chan);
1084 }
1085 
1087 {
1088  chan->callid = 0;
1089 }
1090 
1091 /* Typedef accessors */
1093 {
1094  return chan->callgroup;
1095 }
1097 {
1098  chan->callgroup = value;
1099 }
1101 {
1102  return chan->pickupgroup;
1103 }
1105 {
1106  chan->pickupgroup = value;
1107 }
1108 struct ast_namedgroups *ast_channel_named_callgroups(const struct ast_channel *chan)
1109 {
1110  return chan->named_callgroups;
1111 }
1112 void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
1113 {
1116 }
1117 struct ast_namedgroups *ast_channel_named_pickupgroups(const struct ast_channel *chan)
1118 {
1119  return chan->named_pickupgroups;
1120 }
1121 void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
1122 {
1125 }
1126 
1127 /* Alertpipe functions */
1129 {
1130  return ast_alertpipe_write(chan->alertpipe);
1131 }
1132 
1134 {
1135  return ast_alertpipe_flush(chan->alertpipe);
1136 }
1137 
1139 {
1140  return ast_alertpipe_read(chan->alertpipe);
1141 }
1142 
1144 {
1145  return ast_alertpipe_writable(chan->alertpipe);
1146 }
1147 
1149 {
1150  return ast_alertpipe_readable(chan->alertpipe);
1151 }
1152 
1154 {
1156 }
1157 
1159 {
1161 }
1162 
1164 {
1165  return ast_alertpipe_init(chan->alertpipe);
1166 }
1167 
1169 {
1170  return ast_alertpipe_readfd(chan->alertpipe);
1171 }
1172 
1174 {
1175  ast_alertpipe_swap(chan1->alertpipe, chan2->alertpipe);
1176 }
1177 
1178 /* file descriptor array accessors */
1179 void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value)
1180 {
1181  int pos;
1182 
1183  /* This ensures that if the vector has to grow with unused positions they will be
1184  * initialized to -1.
1185  */
1186  for (pos = AST_VECTOR_SIZE(&chan->fds); pos < which; pos++) {
1187  AST_VECTOR_REPLACE(&chan->fds, pos, -1);
1188  }
1189 
1190  AST_VECTOR_REPLACE(&chan->fds, which, value);
1191 }
1192 void ast_channel_internal_fd_clear(struct ast_channel *chan, int which)
1193 {
1194  if (which >= AST_VECTOR_SIZE(&chan->fds)) {
1195  return;
1196  }
1197 
1198  AST_VECTOR_REPLACE(&chan->fds, which, -1);
1199 }
1201 {
1203 }
1204 int ast_channel_fd(const struct ast_channel *chan, int which)
1205 {
1206  return (which >= AST_VECTOR_SIZE(&chan->fds)) ? -1 : AST_VECTOR_GET(&chan->fds, which);
1207 }
1208 int ast_channel_fd_isset(const struct ast_channel *chan, int which)
1209 {
1210  return ast_channel_fd(chan, which) > -1;
1211 }
1212 
1213 int ast_channel_fd_count(const struct ast_channel *chan)
1214 {
1215  return AST_VECTOR_SIZE(&chan->fds);
1216 }
1217 
1218 int ast_channel_fd_add(struct ast_channel *chan, int value)
1219 {
1220  int pos = AST_EXTENDED_FDS;
1221 
1222  while (ast_channel_fd_isset(chan, pos)) {
1223  pos += 1;
1224  }
1225 
1226  AST_VECTOR_REPLACE(&chan->fds, pos, value);
1227 
1228  return pos;
1229 }
1230 
1231 pthread_t ast_channel_blocker(const struct ast_channel *chan)
1232 {
1233  return chan->blocker;
1234 }
1235 void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value)
1236 {
1237  chan->blocker = value;
1238 }
1239 
1240 int ast_channel_blocker_tid(const struct ast_channel *chan)
1241 {
1242  return chan->blocker_tid;
1243 }
1245 {
1246  chan->blocker_tid = value;
1247 }
1248 
1250 {
1251  return chan->timingfunc;
1252 }
1254 {
1255  chan->timingfunc = value;
1256 }
1257 
1259 {
1260  return chan->bridge;
1261 }
1263 {
1264  chan->bridge = value;
1267 }
1268 
1270 {
1271  return chan->bridge_channel;
1272 }
1274 {
1276 }
1277 
1279 {
1280  return &chan->flags;
1281 }
1282 
1283 static int collect_names_cb(void *obj, void *arg, int flags) {
1284  struct ast_control_pvt_cause_code *cause_code = obj;
1285  struct ast_str **str = arg;
1286 
1287  ast_str_append(str, 0, "%s%s", (ast_str_strlen(*str) ? "," : ""), cause_code->chan_name);
1288 
1289  return 0;
1290 }
1291 
1293 {
1294  struct ast_str *chanlist = ast_str_create(128);
1295 
1296  if (!chanlist) {
1297  return NULL;
1298  }
1299 
1301 
1302  return chanlist;
1303 }
1304 
1306 {
1307  return ao2_find(chan->dialed_causes, chan_name, OBJ_KEY);
1308 }
1309 
1310 int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
1311 {
1312  struct ast_control_pvt_cause_code *ao2_cause_code;
1313  ao2_find(chan->dialed_causes, cause_code->chan_name, OBJ_KEY | OBJ_UNLINK | OBJ_NODATA);
1314  ao2_cause_code = ao2_alloc(datalen, NULL);
1315 
1316  if (ao2_cause_code) {
1317  memcpy(ao2_cause_code, cause_code, datalen);
1318  ao2_link(chan->dialed_causes, ao2_cause_code);
1319  ao2_ref(ao2_cause_code, -1);
1320  return 0;
1321  } else {
1322  return -1;
1323  }
1324 }
1325 
1327 {
1329 }
1330 
1331 /*! \brief Hash function for pvt cause code frames */
1332 static int pvt_cause_hash_fn(const void *vpc, const int flags)
1333 {
1334  const struct ast_control_pvt_cause_code *pc = vpc;
1336 }
1337 
1338 /*! \brief Comparison function for pvt cause code frames */
1339 static int pvt_cause_cmp_fn(void *obj, void *vstr, int flags)
1340 {
1341  struct ast_control_pvt_cause_code *pc = obj;
1342  char *str = ast_tech_to_upper(ast_strdupa(vstr));
1343  char *pc_str = ast_tech_to_upper(ast_strdupa(pc->chan_name));
1344  return !strcmp(pc_str, str) ? CMP_MATCH | CMP_STOP : 0;
1345 }
1346 
1347 #define DIALED_CAUSES_BUCKETS 37
1348 
1349 struct ast_channel *__ast_channel_internal_alloc(void (*destructor)(void *obj), const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *file, int line, const char *function)
1350 {
1351  struct ast_channel *tmp;
1352 
1353  tmp = __ao2_alloc(sizeof(*tmp), destructor,
1354  AO2_ALLOC_OPT_LOCK_MUTEX, "", file, line, function);
1355 
1356  if (!tmp) {
1357  return NULL;
1358  }
1359 
1360  if ((ast_string_field_init(tmp, 128))) {
1361  return ast_channel_unref(tmp);
1362  }
1363 
1366  if (!tmp->dialed_causes) {
1367  return ast_channel_unref(tmp);
1368  }
1369 
1370  /* set the creation time in the uniqueid */
1371  tmp->uniqueid.creation_time = time(NULL);
1372  tmp->uniqueid.creation_unique = ast_atomic_fetchadd_int(&uniqueint, 1);
1373 
1374  /* use provided id or default to historical {system-}time.# format */
1375  if (assignedids && !ast_strlen_zero(assignedids->uniqueid)) {
1376  ast_copy_string(tmp->uniqueid.unique_id, assignedids->uniqueid, sizeof(tmp->uniqueid.unique_id));
1378  snprintf(tmp->uniqueid.unique_id, sizeof(tmp->uniqueid.unique_id), "%li.%d",
1379  (long)(tmp->uniqueid.creation_time),
1380  tmp->uniqueid.creation_unique);
1381  } else {
1382  snprintf(tmp->uniqueid.unique_id, sizeof(tmp->uniqueid.unique_id), "%s-%li.%d",
1384  (long)(tmp->uniqueid.creation_time),
1385  tmp->uniqueid.creation_unique);
1386  }
1387 
1388  /* copy linked id from parent channel if known */
1389  if (requestor) {
1390  tmp->linkedid = requestor->linkedid;
1391  } else {
1392  tmp->linkedid = tmp->uniqueid;
1393  }
1394 
1396 
1397  /* Force all channel snapshot segments to be created on first use, so we don't have to check if
1398  * an old snapshot exists.
1399  */
1400  ast_set_flag(&tmp->snapshot_segment_flags, AST_FLAGS_ALL);
1401 
1402  return tmp;
1403 }
1404 
1406 {
1407  ast_assert(a->linkedid.creation_time != 0);
1408  ast_assert(b->linkedid.creation_time != 0);
1409 
1410  if (a->linkedid.creation_time < b->linkedid.creation_time) {
1411  return a;
1412  }
1413  if (b->linkedid.creation_time < a->linkedid.creation_time) {
1414  return b;
1415  }
1416  if (a->linkedid.creation_unique < b->linkedid.creation_unique) {
1417  return a;
1418  }
1419  return b;
1420 }
1421 
1423 {
1424  if (dest->linkedid.creation_time == source->linkedid.creation_time
1425  && dest->linkedid.creation_unique == source->linkedid.creation_unique
1426  && !strcmp(dest->linkedid.unique_id, source->linkedid.unique_id)) {
1427  return;
1428  }
1429  dest->linkedid = source->linkedid;
1432 }
1433 
1435 {
1436  struct ast_channel_id temp;
1437 
1438  /* This operation is used as part of masquerading and so does not invalidate the peer
1439  * segment. This is due to the masquerade process invalidating all segments.
1440  */
1441 
1442  temp = a->uniqueid;
1443  a->uniqueid = b->uniqueid;
1444  b->uniqueid = temp;
1445 
1446  temp = a->linkedid;
1447  a->linkedid = b->linkedid;
1448  b->linkedid = temp;
1449 }
1450 
1452 {
1453  struct stasis_topic *topic;
1454  struct stasis_forward *forward;
1455 
1456  topic = a->topic;
1457  a->topic = b->topic;
1458  b->topic = topic;
1459 
1460  forward = a->channel_forward;
1461  a->channel_forward = b->channel_forward;
1462  b->channel_forward = forward;
1463 }
1464 
1466 {
1467  struct stasis_forward *temp;
1468 
1469  temp = a->endpoint_forward;
1470  a->endpoint_forward = b->endpoint_forward;
1471  b->endpoint_forward = temp;
1472 }
1473 
1475 {
1476  struct ast_channel_snapshot *snapshot;
1477 
1478  snapshot = a->snapshot;
1479  a->snapshot = b->snapshot;
1480  b->snapshot = snapshot;
1481 }
1482 
1483 void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid)
1484 {
1485  ast_copy_string(chan->uniqueid.unique_id, uniqueid, sizeof(chan->uniqueid.unique_id));
1486  ast_copy_string(chan->linkedid.unique_id, linkedid, sizeof(chan->linkedid.unique_id));
1487 }
1488 
1490 {
1491  if (chan->dialed_causes) {
1492  ao2_t_ref(chan->dialed_causes, -1,
1493  "done with dialed causes since the channel is going away");
1494  chan->dialed_causes = NULL;
1495  }
1496 
1498 
1501 
1502  ao2_cleanup(chan->topic);
1503  chan->topic = NULL;
1504 
1506 
1507  AST_VECTOR_FREE(&chan->fds);
1508 }
1509 
1511 {
1512  chan->finalized = 1;
1513 }
1514 
1516 {
1517  return chan->finalized;
1518 }
1519 
1521 {
1522  if (!chan) {
1523  return ast_channel_topic_all();
1524  }
1525 
1526  return chan->topic;
1527 }
1528 
1530  struct ast_endpoint *endpoint)
1531 {
1532  ast_assert(chan != NULL);
1533  ast_assert(endpoint != NULL);
1534 
1535  chan->endpoint_forward =
1537  ast_endpoint_topic(endpoint));
1538  if (!chan->endpoint_forward) {
1539  return -1;
1540  }
1541 
1542  return 0;
1543 }
1544 
1546 {
1547  char *topic_name;
1548  int ret;
1549  ast_assert(chan->topic == NULL);
1550 
1551  if (ast_strlen_zero(chan->uniqueid.unique_id)) {
1552  static int dummy_id;
1553  ret = ast_asprintf(&topic_name, "channel:dummy-%d", ast_atomic_fetchadd_int(&dummy_id, +1));
1554  } else {
1555  ret = ast_asprintf(&topic_name, "channel:%s", chan->uniqueid.unique_id);
1556  }
1557 
1558  if (ret < 0) {
1559  return -1;
1560  }
1561 
1562  chan->topic = stasis_topic_create(topic_name);
1563  ast_free(topic_name);
1564  if (!chan->topic) {
1565  return -1;
1566  }
1567 
1570  if (!chan->channel_forward) {
1571  ao2_ref(chan->topic, -1);
1572  chan->topic = NULL;
1573  return -1;
1574  }
1575 
1576  return 0;
1577 }
1578 
1580 
1582 {
1583  enum ast_channel_error *error_code = ast_threadstorage_get(&channel_errno, sizeof(*error_code));
1584  if (!error_code) {
1585  return;
1586  }
1587 
1588  *error_code = error;
1589 }
1590 
1592 {
1593  enum ast_channel_error *error_code = ast_threadstorage_get(&channel_errno, sizeof(*error_code));
1594  if (!error_code) {
1596  }
1597 
1598  return *error_code;
1599 }
1600 
1602  const struct ast_channel *chan)
1603 {
1604  ast_assert(chan != NULL);
1605 
1606  return chan->stream_topology;
1607 }
1608 
1610  struct ast_stream_topology *topology)
1611 {
1612  struct ast_stream_topology *new_topology;
1613  SCOPE_ENTER(1, "%s: %s\n", ast_channel_name(chan),
1614  ast_str_tmp(256, ast_stream_topology_to_str(topology, &STR_TMP)));
1615 
1616  ast_assert(chan != NULL);
1617 
1618  /* A non-MULTISTREAM channel can't manipulate topology directly */
1620 
1621  /* Unless the channel is being destroyed, we always want a topology on
1622  * it even if its empty.
1623  */
1624  if (!topology) {
1625  new_topology = ast_stream_topology_alloc();
1626  } else {
1627  new_topology = topology;
1628  }
1629 
1630  if (new_topology) {
1631  ast_channel_internal_set_stream_topology(chan, new_topology);
1632  }
1633 
1634  SCOPE_EXIT_RTN_VALUE(new_topology, "Used %s topology\n", topology ? "provided" : "empty");
1635 }
1636 
1638  enum ast_media_type type)
1639 {
1640  ast_assert(chan != NULL);
1642 
1643  return chan->default_streams[type];
1644 }
1645 
1647  struct ast_channel *chan2)
1648 {
1649  struct ast_stream_topology *tmp_topology;
1650 
1651  ast_assert(chan1 != NULL && chan2 != NULL);
1652 
1653  tmp_topology = chan1->stream_topology;
1654  chan1->stream_topology = chan2->stream_topology;
1655  chan2->stream_topology = tmp_topology;
1656 
1659 }
1660 
1662 {
1663  return (chan && chan->tech && chan->tech->read_stream && chan->tech->write_stream);
1664 }
1665 
1667 {
1668  return chan->snapshot;
1669 }
1670 
1671 void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot)
1672 {
1673  ao2_cleanup(chan->snapshot);
1674  chan->snapshot = ao2_bump(snapshot);
1675 }
1676 
1678 {
1679  return &chan->snapshot_segment_flags;
1680 }
void ast_alertpipe_close(int alert_pipe[2])
Close an alert pipe.
Definition: alertpipe.c:79
ssize_t ast_alertpipe_write(int alert_pipe[2])
Write an event to an alert pipe.
Definition: alertpipe.c:120
void ast_alertpipe_swap(int alert_pipe_1[2], int alert_pipe_2[2])
Swap the file descriptors from two alert pipes.
Definition: alertpipe.h:161
void ast_alertpipe_clear(int alert_pipe[2])
Sets the alert pipe file descriptors to default values.
Definition: alertpipe.h:98
ast_alert_status_t ast_alertpipe_flush(int alert_pipe[2])
Consume all alerts written to the alert pipe.
Definition: alertpipe.c:134
int ast_alertpipe_readable(int alert_pipe[2])
Determine if the alert pipe is readable.
Definition: alertpipe.h:114
int ast_alertpipe_readfd(int alert_pipe[2])
Get the alert pipe's read file descriptor.
Definition: alertpipe.h:146
int ast_alertpipe_init(int alert_pipe[2])
Initialize an alert pipe.
Definition: alertpipe.c:38
ast_alert_status_t
Definition: alertpipe.h:24
int ast_alertpipe_writable(int alert_pipe[2])
Determine if the alert pipe is writable.
Definition: alertpipe.h:130
ast_alert_status_t ast_alertpipe_read(int alert_pipe[2])
Read an event from an alert pipe.
Definition: alertpipe.c:102
const char * str
Definition: app_jack.c:147
static char dialcontext[AST_MAX_CONTEXT]
Asterisk main include file. File version handling, generic pbx functions.
#define ast_free(a)
Definition: astmm.h:180
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:267
#define ao2_t_ref(o, delta, tag)
Definition: astobj2.h:460
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
@ CMP_MATCH
Definition: astobj2.h:1027
@ CMP_STOP
Definition: astobj2.h:1028
#define OBJ_KEY
Definition: astobj2.h:1151
@ AO2_ALLOC_OPT_LOCK_MUTEX
Definition: astobj2.h:363
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
Definition: astobj2.h:1693
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1736
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
Definition: astobj2.h:501
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
@ OBJ_NODATA
Definition: astobj2.h:1044
@ OBJ_MULTIPLE
Definition: astobj2.h:1049
@ OBJ_UNLINK
Definition: astobj2.h:1039
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:409
void * __ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, unsigned int options, const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result
Definition: astobj2.c:768
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition: astobj2.h:1303
static int tmp()
Definition: bt_open.c:389
static snd_pcm_format_t format
Definition: chan_alsa.c:106
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:121
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:425
static char parkinglot[AST_MAX_CONTEXT]
Definition: chan_mgcp.c:166
static char musicclass[MAX_MUSICCLASS]
Definition: chan_mgcp.c:165
static const char type[]
Definition: chan_ooh323.c:109
General Asterisk PBX channel definitions.
int(* ast_timing_func_t)(const void *data)
Definition: channel.h:899
#define AST_EXTENDED_FDS
Definition: channel.h:195
#define ast_channel_lock(chan)
Definition: channel.h:2922
unsigned long long ast_group_t
Definition: channel.h:213
ast_channel_error
Definition: channel.h:4881
@ AST_CHANNEL_ERROR_UNKNOWN
Definition: channel.h:4883
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1133
ama_flags
Channel AMA Flags.
Definition: channel.h:1177
const char * ast_channel_name(const struct ast_channel *chan)
ast_channel_adsicpe
Definition: channel.h:868
#define AST_MAX_FDS
Definition: channel.h:194
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2958
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:1896
#define AST_MAX_UNIQUEID
Definition: channel.h:168
#define AST_MAX_CONTEXT
Definition: channel.h:135
struct ast_namedgroups * ast_ref_namedgroups(struct ast_namedgroups *groups)
Definition: channel.c:7821
struct ast_namedgroups * ast_unref_namedgroups(struct ast_namedgroups *groups)
Definition: channel.c:7815
#define ast_channel_unlock(chan)
Definition: channel.h:2923
#define AST_MAX_EXTENSION
Definition: channel.h:134
Internal channel functions for channel.c to use.
void ast_channel_internal_set_stream_topology_change_source(struct ast_channel *chan, void *change_source)
void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2)
Swap the interal alertpipe between two channels.
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
static struct ast_threadstorage channel_errno
struct ast_filestream * ast_channel_stream(const struct ast_channel *chan)
struct ast_channel_snapshot * ast_channel_snapshot(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.
struct timeval ast_channel_answertime(struct ast_channel *chan)
static void channel_set_default_streams(struct ast_channel *chan)
void ast_channel_rings_set(struct ast_channel *chan, int value)
void ast_channel_internal_copy_linkedid(struct ast_channel *dest, struct ast_channel *source)
Copy the full linkedid channel id structure from one channel to another.
void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
struct ast_namedgroups * ast_channel_named_pickupgroups(const struct ast_channel *chan)
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
int ast_channel_blocker_tid(const struct ast_channel *chan)
void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value)
void ast_channel_appl_set(struct ast_channel *chan, const char *value)
void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value)
void ast_channel_visible_indication_set(struct ast_channel *chan, int value)
void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value)
void ast_channel_internal_set_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
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.
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)
void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value)
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
struct ast_timer * ast_channel_timer(const struct ast_channel *chan)
struct ast_party_id ast_channel_redirecting_effective_to(struct ast_channel *chan)
struct ast_party_id ast_channel_redirecting_effective_from(struct ast_channel *chan)
void * ast_channel_music_state(const struct ast_channel *chan)
struct ast_channel * __ast_channel_internal_alloc(void(*destructor)(void *obj), const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *file, int line, const char *function)
void ast_channel_blockproc_set(struct ast_channel *chan, const char *value)
const char * ast_channel_lastexten(const struct ast_channel *chan)
unsigned int ast_channel_fin(const struct ast_channel *chan)
void ast_channel_callid_cleanup(struct ast_channel *chan)
void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value)
void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value)
int ast_channel_rings(const struct ast_channel *chan)
void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value)
void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value)
struct ast_bridge * ast_channel_internal_bridge(const struct ast_channel *chan)
void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value)
#define DEFINE_STRINGFIELD_GETTER_FOR(field)
int ast_channel_internal_alert_readfd(struct ast_channel *chan)
struct ast_frame * ast_channel_dtmff(struct ast_channel *chan)
void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value)
int ast_channel_internal_is_finalized(struct ast_channel *chan)
int ast_channel_macropriority(const struct ast_channel *chan)
const char * ast_channel_uniqueid(const 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.
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
void * ast_channel_tech_pvt(const struct ast_channel *chan)
int ast_channel_fdno(const struct ast_channel *chan)
void ast_channel_internal_fd_clear_all(struct ast_channel *chan)
void ast_channel_internal_bridge_channel_set(struct ast_channel *chan, struct ast_bridge_channel *value)
void ast_channel_internal_alertpipe_close(struct ast_channel *chan)
void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value)
void ast_channel_hold_state_set(struct ast_channel *chan, int value)
const char * ast_channel_blockproc(const struct ast_channel *chan)
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
struct ast_format * ast_channel_oldwriteformat(struct ast_channel *chan)
void ast_channel_data_set(struct ast_channel *chan, const char *value)
void ast_channel_blocker_tid_set(struct ast_channel *chan, int value)
struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan)
struct ast_audiohook_list * ast_channel_audiohooks(const struct ast_channel *chan)
void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value)
enum ast_channel_error ast_channel_internal_errno(void)
const char * ast_channel_data(const struct ast_channel *chan)
void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot)
static int uniqueint
The monotonically increasing integer counter for channel uniqueids.
unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
void ast_channel_vstreamid_set(struct ast_channel *chan, int value)
#define DEFINE_STRINGFIELD_SETTERS_FOR(field, assert_on_null)
void ast_channel_internal_swap_stream_topology(struct ast_channel *chan1, struct ast_channel *chan2)
void ast_channel_timingdata_set(struct ast_channel *chan, void *value)
const char * ast_channel_lastcontext(const struct ast_channel *chan)
struct ast_bridge_channel * ast_channel_internal_bridge_channel(const struct ast_channel *chan)
int ast_channel_internal_alert_readable(struct ast_channel *chan)
void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
int ast_channel_priority(const struct ast_channel *chan)
void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
void ast_channel_streamid_set(struct ast_channel *chan, int value)
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
void ast_channel_callid_set(struct ast_channel *chan, ast_callid callid)
void ast_channel_macroexten_set(struct ast_channel *chan, const char *value)
void ast_channel_generatordata_set(struct ast_channel *chan, void *value)
struct ast_channel * ast_channel_internal_oldest_linkedid(struct ast_channel *a, struct ast_channel *b)
Determine which channel has an older linkedid.
struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan)
void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value)
ast_callid ast_channel_callid(const struct ast_channel *chan)
struct ast_autochan_list * ast_channel_autochans(struct ast_channel *chan)
struct ast_generator * ast_channel_generator(const struct ast_channel *chan)
char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan)
struct timeval * ast_channel_dtmf_tv(struct ast_channel *chan)
unsigned long ast_channel_insmpl(const struct ast_channel *chan)
int ast_channel_fd_add(struct ast_channel *chan, int value)
Add a file descriptor to the channel without a fixed position.
ast_alert_status_t ast_channel_internal_alert_flush(struct ast_channel *chan)
void ast_channel_timingfd_set(struct ast_channel *chan, int value)
pthread_t ast_channel_blocker(const struct ast_channel *chan)
struct ast_str * ast_channel_dialed_causes_channels(const struct ast_channel *chan)
Retrieve a comma-separated list of channels for which dialed cause information is available.
void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value)
struct ast_hangup_handler_list * ast_channel_hangup_handlers(struct ast_channel *chan)
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_internal_swap_topics(struct ast_channel *a, struct ast_channel *b)
Swap topics beteween two channels.
void ast_channel_internal_cleanup(struct ast_channel *chan)
int ast_channel_unbridged_nolock(struct ast_channel *chan)
ast_channel_unbridged variant. Use this if the channel is already locked prior to calling.
void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value)
struct timeval ast_channel_creationtime(struct ast_channel *chan)
struct ast_filestream * ast_channel_vstream(const struct ast_channel *chan)
void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value)
int ast_channel_fd(const struct ast_channel *chan, int which)
void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value)
void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value)
void ast_channel_fin_set(struct ast_channel *chan, unsigned int value)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
enum ama_flags ast_channel_amaflags(const struct ast_channel *chan)
void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
struct ast_channel * ast_channel_masqr(const struct ast_channel *chan)
struct ast_channel * ast_channel_masq(const struct ast_channel *chan)
void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value)
void * ast_channel_get_stream_topology_change_source(struct ast_channel *chan)
Retrieve the source that initiated the last stream topology change.
void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value)
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.
unsigned int ast_channel_fout(const struct ast_channel *chan)
void ast_channel_set_unbridged(struct ast_channel *chan, int value)
Sets the unbridged flag and queues a NULL frame on the channel to trigger a check by bridge_channel_w...
void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value)
struct ast_control_pvt_cause_code * ast_channel_dialed_causes_find(const struct ast_channel *chan, const char *chan_name)
Retrieve a ref-counted cause code information structure.
struct ast_namedgroups * ast_channel_named_callgroups(const struct ast_channel *chan)
int ast_channel_hangupcause(const struct ast_channel *chan)
int ast_channel_timingfd(const struct ast_channel *chan)
void ast_channel_fdno_set(struct ast_channel *chan, int value)
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value)
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
const char * ast_channel_linkedid(const struct ast_channel *chan)
void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value)
const char * ast_channel_exten(const struct ast_channel *chan)
struct ast_party_id ast_channel_redirecting_effective_orig(struct ast_channel *chan)
enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan)
int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Add cause code information to the channel.
void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
int ast_channel_alert_write(struct ast_channel *chan)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
int ast_channel_vstreamid(const struct ast_channel *chan)
struct ast_datastore_list * ast_channel_datastores(struct ast_channel *chan)
void * ast_channel_timingdata(const struct ast_channel *chan)
void ast_channel_set_is_t38_active(struct ast_channel *chan, int is_t38_active)
Sets the is_t38_active flag.
ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
static int collect_names_cb(void *obj, void *arg, int flags)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value)
struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan)
struct ast_cdr * ast_channel_cdr(const struct ast_channel *chan)
void ast_channel_internal_swap_uniqueid_and_linkedid(struct ast_channel *a, struct ast_channel *b)
Swap uniqueid and linkedid beteween two channels.
ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
struct ast_channel_monitor * ast_channel_monitor(const struct ast_channel *chan)
int ast_channel_unbridged(struct ast_channel *chan)
This function will check if the bridge needs to be re-evaluated due to external changes.
int ast_channel_hold_state(const struct ast_channel *chan)
void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value)
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
struct ast_flags * ast_channel_snapshot_segment_flags(struct ast_channel *chan)
void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value)
const char * ast_channel_appl(const struct ast_channel *chan)
const char * ast_channel_macroexten(const struct ast_channel *chan)
void ast_channel_macropriority_set(struct ast_channel *chan, int value)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
int ast_channel_streamid(const struct ast_channel *chan)
void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value)
void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state value)
int ast_channel_internal_setup_topics(struct ast_channel *chan)
void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value)
int ast_channel_forward_endpoint(struct ast_channel *chan, struct ast_endpoint *endpoint)
Forward channel stasis messages to the given endpoint.
struct ast_sched_context * ast_channel_sched(const struct ast_channel *chan)
int ast_channel_fd_count(const struct ast_channel *chan)
Retrieve the number of file decriptor positions present on the channel.
static int pvt_cause_cmp_fn(void *obj, void *vstr, int flags)
Comparison function for pvt cause code frames.
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.
void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value)
void ast_channel_internal_swap_snapshots(struct ast_channel *a, struct ast_channel *b)
Swap snapshots beteween two channels.
void ast_channel_music_state_set(struct ast_channel *chan, void *value)
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
struct ast_format * ast_channel_rawwriteformat(struct ast_channel *chan)
unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan)
struct ast_party_connected_line * ast_channel_connected_indicated(struct ast_channel *chan)
void ast_channel_internal_fd_clear(struct ast_channel *chan, int which)
void ast_channel_fout_set(struct ast_channel *chan, unsigned int value)
struct ast_readq_list * ast_channel_readq(struct ast_channel *chan)
void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value)
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
enum ast_channel_state ast_channel_state(const struct ast_channel *chan)
struct varshead * ast_channel_varshead(struct ast_channel *chan)
const char * ast_channel_macrocontext(const struct ast_channel *chan)
char ast_channel_sending_dtmf_digit(const struct ast_channel *chan)
int ast_channel_visible_indication(const struct ast_channel *chan)
void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value)
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
unsigned long ast_channel_outsmpl(const struct ast_channel *chan)
void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value)
void ast_channel_internal_finalize(struct ast_channel *chan)
void ast_channel_internal_alertpipe_clear(struct ast_channel *chan)
void ast_channel_priority_set(struct ast_channel *chan, int value)
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
#define DIALED_CAUSES_BUCKETS
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
void ast_channel_internal_errno_set(enum ast_channel_error error)
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
static int pvt_cause_hash_fn(const void *vpc, const int flags)
Hash function for pvt cause code frames.
int ast_channel_fd_isset(const struct ast_channel *chan, int which)
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
void ast_channel_dialed_causes_clear(const struct ast_channel *chan)
Clear all cause information from the channel.
#define DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(field, publish, assert_on_null, invalidate)
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
int ast_channel_internal_alertpipe_init(struct ast_channel *chan)
void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value)
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
int ast_channel_is_t38_active(struct ast_channel *chan)
This function will check if T.38 is active on the channel.
struct ast_jb * ast_channel_jb(struct ast_channel *chan)
void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value)
void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value)
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value)
void * ast_channel_generatordata(const struct ast_channel *chan)
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
int ast_channel_alert_writable(struct ast_channel *chan)
struct ast_framehook_list * ast_channel_framehooks(const struct ast_channel *chan)
ast_channel_state
ast_channel states
Definition: channelstate.h:35
ast_media_type
Types of media.
Definition: codec.h:30
@ AST_MEDIA_TYPE_UNKNOWN
Definition: codec.h:31
@ AST_MEDIA_TYPE_END
Definition: codec.h:36
Endpoint abstractions.
const char * ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf)
Get the names of codecs of a set of formats.
Definition: format_cap.c:734
static const char name[]
Definition: format_mp3.c:68
struct stasis_topic * ast_channel_topic_all(void)
A topic which publishes the events for all channels.
struct stasis_topic * ast_endpoint_topic(struct ast_endpoint *endpoint)
Returns the topic for a specific endpoint.
void ast_channel_snapshot_invalidate_segment(struct ast_channel *chan, enum ast_channel_snapshot_segment_invalidation segment)
Invalidate a channel snapshot segment from being reused.
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_PEER
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_HANGUP
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_BRIDGE
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_CONNECTED
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN
struct ast_frame ast_null_frame
Definition: main/frame.c:79
void ast_callid_strnprint(char *buffer, size_t buffer_size, ast_callid callid)
copy a string representation of the callid into a target string
Definition: logger.c:2038
#define ast_debug(level,...)
Log a DEBUG message.
#define SCOPE_EXIT_RTN(...)
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define AST_CALLID_BUFFER_LENGTH
#define SCOPE_ENTER(level,...)
unsigned int ast_callid
Tone Indication Support.
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
Definition: lock.h:755
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_SYSTEM_NAME
Definition: options.c:170
#define NULL
Definition: resample.c:96
struct stasis_forward * stasis_forward_all(struct stasis_topic *from_topic, struct stasis_topic *to_topic)
Create a subscription which forwards all messages from one topic to another.
Definition: stasis.c:1580
struct stasis_forward * stasis_forward_cancel(struct stasis_forward *forward)
Definition: stasis.c:1550
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition: stasis.c:619
Endpoint abstractions.
Media Stream API.
struct ast_stream * ast_stream_topology_get_first_stream_by_type(const struct ast_stream_topology *topology, enum ast_media_type type)
Gets the first active stream of a specific type from the topology.
Definition: stream.c:964
const char * ast_stream_topology_to_str(const struct ast_stream_topology *topology, struct ast_str **buf)
Get a string representing the topology for debugging/display purposes.
Definition: stream.c:936
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
Definition: stream.c:743
struct ast_stream_topology * ast_stream_topology_create_from_format_cap(struct ast_format_cap *cap)
A helper function that, given a format capabilities structure, creates a topology and separates the m...
Definition: stream.c:848
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
Definition: stream.c:650
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:341
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:303
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:359
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:374
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1117
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
Definition: strings.h:1237
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:87
char * ast_tech_to_upper(char *dev_str)
Convert the tech portion of a device string to upper case.
Definition: strings.h:1214
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
Definition: strings.h:1167
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:640
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:711
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:406
Generic container type.
Structure to pass both assignedid values to channel drivers.
Definition: channel.h:604
const char * uniqueid
Definition: channel.h:605
Structure that contains information regarding a channel in a bridge.
struct ast_channel * chan
Structure that contains information about a bridge.
Definition: bridge.h:349
Responsible for call detail data.
Definition: cdr.h:277
Channel UniqueId structure.
char unique_id[AST_MAX_UNIQUEID]
Structure representing a snapshot of channel state.
Structure to describe a channel "technology", ie a channel driver See for examples:
Definition: channel.h:628
struct ast_frame *(*const read_stream)(struct ast_channel *chan)
Read a frame (or chain of frames from the same stream), in standard format (see frame....
Definition: channel.h:747
int(*const write_stream)(struct ast_channel *chan, int stream_num, struct ast_frame *frame)
Write a frame on a specific stream, in standard format (see frame.h)
Definition: channel.h:753
Main Channel structure associated with a channel.
struct ast_filestream * stream
char macrocontext[AST_MAX_CONTEXT]
struct ast_cdr * cdr
struct ast_stream * default_streams[AST_MEDIA_TYPE_END]
struct ast_channel_id uniqueid
struct stasis_topic * topic
const ast_string_field language
const char * appl
const ast_string_field latest_musicclass
struct ast_bridge_channel * bridge_channel
struct ast_framehook_list * framehooks
const ast_string_field dialcontext
char lastexten[AST_MAX_EXTENSION]
struct timeval creationtime
struct ast_frame dtmff
char lastcontext[AST_MAX_CONTEXT]
const ast_string_field musicclass
struct ast_sched_context * sched
struct ast_channel_snapshot * snapshot
struct ast_datastore_list datastores
unsigned long outsmpl
struct ast_tone_zone * zone
struct ao2_container * dialed_causes
ast_timing_func_t timingfunc
struct ast_channel_monitor * monitor
const ast_string_field peeraccount
enum ast_channel_adsicpe adsicpe
struct ast_format * rawwriteformat
struct ast_generator * generator
struct ast_bridge * bridge
struct timeval sending_dtmf_tv
struct ast_party_connected_line connected
Channel Connected Line ID information.
const ast_string_field accountcode
char macroexten[AST_MAX_EXTENSION]
struct ast_trans_pvt * writetrans
struct timeval whentohangup
const ast_string_field userfield
unsigned short transfercapability
unsigned int emulate_dtmf_duration
void * stream_topology_change_source
struct ast_readq_list readq
const ast_string_field call_forward
struct ast_format * rawreadformat
char exten[AST_MAX_EXTENSION]
struct ast_channel::@361 fds
struct timeval dtmf_tv
const ast_string_field parkinglot
struct ast_party_connected_line connected_indicated
Channel Connected Line ID information that was last indicated.
const char * data
struct ast_namedgroups * named_pickupgroups
struct stasis_forward * endpoint_forward
struct ast_flags snapshot_segment_flags
unsigned long insmpl
struct ast_trans_pvt * readtrans
struct ast_namedgroups * named_callgroups
struct ast_hangup_handler_list hangup_handlers
struct ast_timer * timer
struct varshead varshead
unsigned int fin
const struct ast_channel_tech * tech
struct ast_format * writeformat
struct ast_channel_id linkedid
enum ast_channel_state state
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
struct ast_channel * masqr
ast_group_t pickupgroup
struct ast_party_dialed dialed
Dialed/Called information.
char context[AST_MAX_CONTEXT]
struct ast_jb jb
const ast_string_field name
struct ast_filestream * vstream
struct timeval answertime
struct ast_format * readformat
struct ast_audiohook_list * audiohooks
struct ast_format * oldwriteformat
struct stasis_forward * channel_forward
struct ast_channel * masq
struct ast_format_cap * nativeformats
const char * blockproc
struct ast_pbx * pbx
struct ast_flags flags
const ast_string_field hangupsource
ast_group_t callgroup
unsigned int fout
struct ast_autochan_list autochans
struct ast_stream_topology * stream_topology
unsigned int finalized
struct ast_party_caller caller
Channel Caller ID information.
char chan_name[AST_CHANNEL_NAME]
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
Definition: mod_format.h:101
Structure used to handle boolean flags.
Definition: utils.h:199
unsigned int flags
Definition: utils.h:200
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
Definition of a media format.
Definition: format.c:43
Data structure associated with a single frame of data.
General jitterbuffer state.
Definition: abstract_jb.h:141
Caller Party information.
Definition: channel.h:418
Connected Line/Party information.
Definition: channel.h:456
Dialed/Called Party information.
Definition: channel.h:378
Information needed to identify an endpoint in a call.
Definition: channel.h:338
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:522
Definition: pbx.h:214
Support for dynamic strings.
Definition: strings.h:604
A set of tones for a given locale.
Definition: indications.h:74
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition: translate.h:213
List of channel drivers.
Definition: app_dial.c:835
Forwarding information.
Definition: stasis.c:1533
int value
Definition: syslog.c:37
Test Framework API.
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:189
static struct test_val b
static struct test_val a
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
Definition: threadstorage.h:86
int error(const char *format,...)
Definition: utils/frame.c:999
#define ast_assert(a)
Definition: utils.h:734
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define AST_FLAGS_ALL
Definition: utils.h:196
Vector container support.
#define AST_VECTOR_REPLACE(vec, idx, elem)
Replace an element at a specific position in a vector, growing the vector if needed.
Definition: vector.h:284
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
Definition: vector.h:625
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
Definition: vector.h:571
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:609
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
#define AST_VECTOR(name, type)
Define a vector structure.
Definition: vector.h:44
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:680