Asterisk - The Open Source Telephony Project  21.4.1
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"
45 #include "asterisk/stasis_channels.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. */
87  ast_timing_func_t timingfunc;
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 */
92  struct ast_audiohook_list *audiohooks;
93  struct ast_framehook_list *framehooks;
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  ast_callid callid; /*!< Bound call identifier pointer */
98  struct ao2_container *dialed_causes; /*!< Contains tech-specific and Asterisk cause data from dialed channels */
99 
101  AST_STRING_FIELD(name); /*!< ASCII unique channel name */
102  AST_STRING_FIELD(language); /*!< Language requested for voice prompts */
103  AST_STRING_FIELD(musicclass); /*!< Default music class */
104  AST_STRING_FIELD(latest_musicclass); /*!< Latest active music class */
105  AST_STRING_FIELD(accountcode); /*!< Account code for billing */
106  AST_STRING_FIELD(peeraccount); /*!< Peer account code for billing */
107  AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
108  AST_STRING_FIELD(call_forward); /*!< Where to forward to if asked to dial on this interface */
109  AST_STRING_FIELD(parkinglot); /*! Default parking lot, if empty, default parking lot */
110  AST_STRING_FIELD(hangupsource); /*! Who is responsible for hanging up this channel */
111  AST_STRING_FIELD(dialcontext); /*!< Dial: Extension context that we were called from */
112  );
113 
114  struct ast_channel_id uniqueid; /*!< Unique Channel Identifier - can be specified on creation */
115  struct ast_channel_id linkedid; /*!< Linked Channel Identifier - oldest propagated when bridged */
116 
117  struct timeval whentohangup; /*!< Non-zero, set to actual time when channel is to be hung up */
118  pthread_t blocker; /*!< If anyone is blocking, this is them */
119 
120  /*!
121  * \brief Dialed/Called information.
122  * \note Set on incoming channels to indicate the originally dialed party.
123  * \note Dialed Number Identifier (DNID)
124  */
126 
127  /*!
128  * \brief Channel Caller ID information.
129  * \note The caller id information is the caller id of this
130  * channel when it is used to initiate a call.
131  */
133 
134  /*!
135  * \brief Channel Connected Line ID information.
136  * \note The connected line information identifies the channel
137  * connected/bridged to this channel.
138  */
140 
141  /*!
142  * \brief Channel Connected Line ID information that was last indicated.
143  */
145 
146  /*! \brief Redirecting/Diversion information */
148 
149  struct ast_frame dtmff; /*!< DTMF frame */
150  struct varshead varshead; /*!< A linked list for channel variables. See \ref AstChanVar */
151  ast_group_t callgroup; /*!< Call group for call pickups */
152  ast_group_t pickupgroup; /*!< Pickup group - which calls groups can be picked up? */
153  struct ast_namedgroups *named_callgroups; /*!< Named call group for call pickups */
154  struct ast_namedgroups *named_pickupgroups; /*!< Named pickup group - which call groups can be picked up? */
155  struct timeval creationtime; /*!< The time of channel creation */
156  struct timeval answertime; /*!< The time the channel was answered */
157  struct ast_readq_list readq;
158  struct ast_jb jb; /*!< The jitterbuffer state */
159  struct timeval dtmf_tv; /*!< The time that an in process digit began, or the last digit ended */
160  struct ast_hangup_handler_list hangup_handlers;/*!< Hangup handlers on the channel. */
161  struct ast_datastore_list datastores; /*!< Data stores on the channel */
162  struct ast_autochan_list autochans; /*!< Autochans on the channel */
163  unsigned long insmpl; /*!< Track the read/written samples for monitor use */
164  unsigned long outsmpl; /*!< Track the read/written samples for monitor use */
165 
166  int blocker_tid; /*!< If anyone is blocking, this is their thread id */
167  AST_VECTOR(, int) fds; /*!< File descriptors for channel -- Drivers will poll on
168  * these file descriptors, so at least one must be non -1.
169  * See \arg \ref AstFileDesc */
170  int softhangup; /*!< Whether or not we have been hung up... Do not set this value
171  * directly, use ast_softhangup() */
172  int fdno; /*!< Which fd had an event detected on */
173  int streamid; /*!< For streaming playback, the schedule ID */
174  int vstreamid; /*!< For streaming video playback, the schedule ID */
175  struct ast_format *oldwriteformat; /*!< Original writer format */
176  int timingfd; /*!< Timing fd */
177  enum ast_channel_state state; /*!< State of line -- Don't write directly, use ast_setstate() */
178  int rings; /*!< Number of rings so far */
179  int priority; /*!< Dialplan: Current extension priority */
180  int amaflags; /*!< Set BEFORE PBX is started to determine AMA flags */
181  enum ast_channel_adsicpe adsicpe; /*!< Whether or not ADSI is detected on CPE */
182  unsigned int fin; /*!< Frames in counters. The high bit is a debug mask, so
183  * the counter is only in the remaining bits */
184  unsigned int fout; /*!< Frames out counters. The high bit is a debug mask, so
185  * the counter is only in the remaining bits */
186  int hangupcause; /*!< Why is the channel hanged up. See causes.h */
187  unsigned int finalized:1; /*!< Whether or not the channel has been successfully allocated */
188  struct ast_flags flags; /*!< channel flags of AST_FLAG_ type */
189  int alertpipe[2];
190  struct ast_format_cap *nativeformats; /*!< Kinds of data this channel can natively handle */
191  struct ast_format *readformat; /*!< Requested read format (after translation) */
192  struct ast_format *writeformat; /*!< Requested write format (before translation) */
193  struct ast_format *rawreadformat; /*!< Raw read format (before translation) */
194  struct ast_format *rawwriteformat; /*!< Raw write format (after translation) */
195  unsigned int emulate_dtmf_duration; /*!< Number of ms left to emulate DTMF for */
196  int visible_indication; /*!< Indication currently playing on the channel */
197  int hold_state; /*!< Current Hold/Unhold state */
198 
199  unsigned short transfercapability; /*!< ISDN Transfer Capability - AST_FLAG_DIGITAL is not enough */
200 
201  struct ast_bridge *bridge; /*!< Bridge this channel is participating in */
202  struct ast_bridge_channel *bridge_channel;/*!< The bridge_channel this channel is linked with. */
203  struct ast_timer *timer; /*!< timer object that provided timingfd */
204 
205  char context[AST_MAX_CONTEXT]; /*!< Dialplan: Current extension context */
206  char exten[AST_MAX_EXTENSION]; /*!< Dialplan: Current extension number */
207  char lastcontext[AST_MAX_CONTEXT]; /*!< Dialplan: Previous extension context */
208  char lastexten[AST_MAX_EXTENSION]; /*!< Dialplan: Previous extension number */
209  char unbridged; /*!< non-zero if the bridge core needs to re-evaluate the current
210  bridging technology which is in use by this channel's bridge. */
211  char is_t38_active; /*!< non-zero if T.38 is active on this channel. */
212  char dtmf_digit_to_emulate; /*!< Digit being emulated */
213  char sending_dtmf_digit; /*!< Digit this channel is currently sending out. (zero if not sending) */
214  struct timeval sending_dtmf_tv; /*!< The time this channel started sending the current digit. (Invalid if sending_dtmf_digit is zero.) */
215  struct stasis_topic *topic; /*!< Topic for this channel */
216  struct stasis_forward *channel_forward; /*!< Subscription for event forwarding to all channel topic */
217  struct stasis_forward *endpoint_forward; /*!< Subscription for event forwarding to endpoint's topic */
218  struct ast_stream_topology *stream_topology; /*!< Stream topology */
219  void *stream_topology_change_source; /*!< Source that initiated a stream topology change */
220  struct ast_stream *default_streams[AST_MEDIA_TYPE_END]; /*!< Default streams indexed by media type */
221  struct ast_channel_snapshot *snapshot; /*!< The current up to date snapshot of the channel */
222  struct ast_flags snapshot_segment_flags; /*!< Flags regarding the segments of the snapshot */
223 };
224 
225 /*! \brief The monotonically increasing integer counter for channel uniqueids */
226 static int uniqueint;
227 
228 /* ACCESSORS */
229 
230 #define DEFINE_STRINGFIELD_SETTERS_FOR(field, assert_on_null) \
231 void ast_channel_##field##_set(struct ast_channel *chan, const char *value) \
232 { \
233  if ((assert_on_null)) ast_assert(!ast_strlen_zero(value)); \
234  if (!strcmp(value, chan->field)) return; \
235  ast_string_field_set(chan, field, value); \
236 } \
237  \
238 void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) \
239 { \
240  ast_string_field_build_va(chan, field, fmt, ap); \
241 } \
242 void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) \
243 { \
244  va_list ap; \
245  va_start(ap, fmt); \
246  ast_channel_##field##_build_va(chan, fmt, ap); \
247  va_end(ap); \
248 }
249 
250 #define DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(field, publish, assert_on_null, invalidate) \
251 void ast_channel_##field##_set(struct ast_channel *chan, const char *value) \
252 { \
253  if ((assert_on_null)) ast_assert(!ast_strlen_zero(value)); \
254  if (!strcmp(value, chan->field)) return; \
255  ast_string_field_set(chan, field, value); \
256  ast_channel_snapshot_invalidate_segment(chan, invalidate); \
257  if (publish && ast_channel_internal_is_finalized(chan)) ast_channel_publish_snapshot(chan); \
258 } \
259  \
260 void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) \
261 { \
262  ast_string_field_build_va(chan, field, fmt, ap); \
263  ast_channel_snapshot_invalidate_segment(chan, invalidate); \
264  if (publish && ast_channel_internal_is_finalized(chan)) ast_channel_publish_snapshot(chan); \
265 } \
266 void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) \
267 { \
268  va_list ap; \
269  va_start(ap, fmt); \
270  ast_channel_##field##_build_va(chan, fmt, ap); \
271  va_end(ap); \
272 }
273 
274 DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(name, 0, 1, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
275 DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(language, 1, 0, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
276 DEFINE_STRINGFIELD_SETTERS_FOR(musicclass, 0);
277 DEFINE_STRINGFIELD_SETTERS_FOR(latest_musicclass, 0);
278 DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(accountcode, 1, 0, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
279 DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(peeraccount, 1, 0, AST_CHANNEL_SNAPSHOT_INVALIDATE_PEER);
280 DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(userfield, 0, 0, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
281 DEFINE_STRINGFIELD_SETTERS_FOR(call_forward, 0);
282 DEFINE_STRINGFIELD_SETTERS_FOR(parkinglot, 0);
283 DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(hangupsource, 0, 0, AST_CHANNEL_SNAPSHOT_INVALIDATE_HANGUP);
284 DEFINE_STRINGFIELD_SETTERS_FOR(dialcontext, 0);
285 
286 #define DEFINE_STRINGFIELD_GETTER_FOR(field) const char *ast_channel_##field(const struct ast_channel *chan) \
287 { \
288  return chan->field; \
289 }
290 
291 DEFINE_STRINGFIELD_GETTER_FOR(name);
292 DEFINE_STRINGFIELD_GETTER_FOR(language);
293 DEFINE_STRINGFIELD_GETTER_FOR(musicclass);
294 DEFINE_STRINGFIELD_GETTER_FOR(latest_musicclass);
295 DEFINE_STRINGFIELD_GETTER_FOR(accountcode);
296 DEFINE_STRINGFIELD_GETTER_FOR(peeraccount);
297 DEFINE_STRINGFIELD_GETTER_FOR(userfield);
298 DEFINE_STRINGFIELD_GETTER_FOR(call_forward);
299 DEFINE_STRINGFIELD_GETTER_FOR(parkinglot);
300 DEFINE_STRINGFIELD_GETTER_FOR(hangupsource);
301 DEFINE_STRINGFIELD_GETTER_FOR(dialcontext);
302 
303 const char *ast_channel_uniqueid(const struct ast_channel *chan)
304 {
305  ast_assert(chan->uniqueid.unique_id[0] != '\0');
306  return chan->uniqueid.unique_id;
307 }
308 
309 const char *ast_channel_linkedid(const struct ast_channel *chan)
310 {
311  ast_assert(chan->linkedid.unique_id[0] != '\0');
312  return chan->linkedid.unique_id;
313 }
314 
315 const char *ast_channel_appl(const struct ast_channel *chan)
316 {
317  return chan->appl;
318 }
319 void ast_channel_appl_set(struct ast_channel *chan, const char *value)
320 {
321  chan->appl = value;
323 }
324 const char *ast_channel_blockproc(const struct ast_channel *chan)
325 {
326  return chan->blockproc;
327 }
328 void ast_channel_blockproc_set(struct ast_channel *chan, const char *value)
329 {
330  chan->blockproc = value;
331 }
332 const char *ast_channel_data(const struct ast_channel *chan)
333 {
334  return chan->data;
335 }
336 void ast_channel_data_set(struct ast_channel *chan, const char *value)
337 {
338  chan->data = value;
340 }
341 
342 const char *ast_channel_context(const struct ast_channel *chan)
343 {
344  return chan->context;
345 }
346 const char *ast_channel_lastcontext(const struct ast_channel *chan)
347 {
348  return chan->lastcontext;
349 }
350 void ast_channel_context_set(struct ast_channel *chan, const char *value)
351 {
352  if (!*chan->lastcontext || strcmp(value, chan->context)) {
353  /* only copy to last context when it changes, unless it's empty to begin with */
354  ast_copy_string(chan->lastcontext, chan->context, sizeof(chan->lastcontext));
355  }
356  ast_copy_string(chan->context, value, sizeof(chan->context));
358 }
359 const char *ast_channel_exten(const struct ast_channel *chan)
360 {
361  return chan->exten;
362 }
363 const char *ast_channel_lastexten(const struct ast_channel *chan)
364 {
365  return chan->lastexten;
366 }
367 void ast_channel_exten_set(struct ast_channel *chan, const char *value)
368 {
369  if (!*chan->lastexten || strcmp(value, chan->exten)) {
370  /* only copy to last exten when it changes, unless it's empty to begin with */
371  ast_copy_string(chan->lastexten, chan->exten, sizeof(chan->lastexten));
372  }
373  ast_copy_string(chan->exten, value, sizeof(chan->exten));
375 }
376 
377 char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan)
378 {
379  return chan->dtmf_digit_to_emulate;
380 }
381 void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value)
382 {
383  chan->dtmf_digit_to_emulate = value;
384 }
385 
386 char ast_channel_sending_dtmf_digit(const struct ast_channel *chan)
387 {
388  return chan->sending_dtmf_digit;
389 }
390 void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value)
391 {
392  chan->sending_dtmf_digit = value;
393 }
394 
395 struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan)
396 {
397  return chan->sending_dtmf_tv;
398 }
399 void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value)
400 {
401  chan->sending_dtmf_tv = value;
402 }
403 
404 enum ama_flags ast_channel_amaflags(const struct ast_channel *chan)
405 {
406  return chan->amaflags;
407 }
408 
409 void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
410 {
411  if (chan->amaflags == value) {
412  return;
413  }
414  chan->amaflags = value;
416 }
417 int ast_channel_fdno(const struct ast_channel *chan)
418 {
419  return chan->fdno;
420 }
421 void ast_channel_fdno_set(struct ast_channel *chan, int value)
422 {
423  chan->fdno = value;
424 }
425 int ast_channel_hangupcause(const struct ast_channel *chan)
426 {
427  return chan->hangupcause;
428 }
429 void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
430 {
431  chan->hangupcause = value;
433 }
434 int ast_channel_priority(const struct ast_channel *chan)
435 {
436  return chan->priority;
437 }
438 void ast_channel_priority_set(struct ast_channel *chan, int value)
439 {
440  chan->priority = value;
442 }
443 int ast_channel_rings(const struct ast_channel *chan)
444 {
445  return chan->rings;
446 }
447 void ast_channel_rings_set(struct ast_channel *chan, int value)
448 {
449  chan->rings = value;
450 }
451 int ast_channel_streamid(const struct ast_channel *chan)
452 {
453  return chan->streamid;
454 }
455 void ast_channel_streamid_set(struct ast_channel *chan, int value)
456 {
457  chan->streamid = value;
458 }
459 int ast_channel_timingfd(const struct ast_channel *chan)
460 {
461  return chan->timingfd;
462 }
463 void ast_channel_timingfd_set(struct ast_channel *chan, int value)
464 {
465  chan->timingfd = value;
466 }
467 int ast_channel_visible_indication(const struct ast_channel *chan)
468 {
469  return chan->visible_indication;
470 }
471 void ast_channel_visible_indication_set(struct ast_channel *chan, int value)
472 {
473  chan->visible_indication = value;
474 }
475 int ast_channel_hold_state(const struct ast_channel *chan)
476 {
477  return chan->hold_state;
478 }
479 void ast_channel_hold_state_set(struct ast_channel *chan, int value)
480 {
481  chan->hold_state = value;
482 }
483 int ast_channel_vstreamid(const struct ast_channel *chan)
484 {
485  return chan->vstreamid;
486 }
487 void ast_channel_vstreamid_set(struct ast_channel *chan, int value)
488 {
489  chan->vstreamid = value;
490 }
491 unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
492 {
493  return chan->transfercapability;
494 }
495 void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value)
496 {
497  chan->transfercapability = value;
498 }
499 unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan)
500 {
501  return chan->emulate_dtmf_duration;
502 }
503 void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value)
504 {
505  chan->emulate_dtmf_duration = value;
506 }
507 unsigned int ast_channel_fin(const struct ast_channel *chan)
508 {
509  return chan->fin;
510 }
511 void ast_channel_fin_set(struct ast_channel *chan, unsigned int value)
512 {
513  chan->fin = value;
514 }
515 unsigned int ast_channel_fout(const struct ast_channel *chan)
516 {
517  return chan->fout;
518 }
519 void ast_channel_fout_set(struct ast_channel *chan, unsigned int value)
520 {
521  chan->fout = value;
522 }
523 unsigned long ast_channel_insmpl(const struct ast_channel *chan)
524 {
525  return chan->insmpl;
526 }
527 void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value)
528 {
529  chan->insmpl = value;
530 }
531 unsigned long ast_channel_outsmpl(const struct ast_channel *chan)
532 {
533  return chan->outsmpl;
534 }
535 void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value)
536 {
537  chan->outsmpl = value;
538 }
539 void *ast_channel_generatordata(const struct ast_channel *chan)
540 {
541  return chan->generatordata;
542 }
543 void ast_channel_generatordata_set(struct ast_channel *chan, void *value)
544 {
545  chan->generatordata = value;
546 }
547 void *ast_channel_music_state(const struct ast_channel *chan)
548 {
549  return chan->music_state;
550 }
551 void ast_channel_music_state_set(struct ast_channel *chan, void *value)
552 {
553  chan->music_state = value;
554 }
555 void *ast_channel_tech_pvt(const struct ast_channel *chan)
556 {
557  return chan->tech_pvt;
558 }
559 void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
560 {
561  chan->tech_pvt = value;
562  if (value != NULL) {
564  }
565 }
566 void *ast_channel_timingdata(const struct ast_channel *chan)
567 {
568  return chan->timingdata;
569 }
570 void ast_channel_timingdata_set(struct ast_channel *chan, void *value)
571 {
572  chan->timingdata = value;
573 }
574 struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan)
575 {
576  return chan->audiohooks;
577 }
578 void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value)
579 {
580  chan->audiohooks = value;
581 }
582 struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan)
583 {
584  return chan->cdr;
585 }
586 void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value)
587 {
588  chan->cdr = value;
589 }
590 struct ast_channel *ast_channel_masq(const struct ast_channel *chan)
591 {
592  return chan->masq;
593 }
594 void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value)
595 {
596  chan->masq = value;
597 }
598 struct ast_channel *ast_channel_masqr(const struct ast_channel *chan)
599 {
600  return chan->masqr;
601 }
602 void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value)
603 {
604  chan->masqr = value;
605 }
606 struct ast_filestream *ast_channel_stream(const struct ast_channel *chan)
607 {
608  return chan->stream;
609 }
610 void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value)
611 {
612  chan->stream = value;
613 }
614 struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan)
615 {
616  return chan->vstream;
617 }
618 void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value)
619 {
620  chan->vstream = value;
621 }
622 struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan)
623 {
624  return chan->nativeformats;
625 }
626 
627 static void channel_set_default_streams(struct ast_channel *chan)
628 {
629  enum ast_media_type type;
630 
631  ast_assert(chan != NULL);
632 
633  for (type = AST_MEDIA_TYPE_UNKNOWN; type < AST_MEDIA_TYPE_END; type++) {
634  if (chan->stream_topology) {
635  chan->default_streams[type] =
637  } else {
638  chan->default_streams[type] = NULL;
639  }
640  }
641 }
642 
643 void ast_channel_internal_set_stream_topology(struct ast_channel *chan,
644  struct ast_stream_topology *topology)
645 {
647  chan->stream_topology = topology;
648  channel_set_default_streams(chan);
649 }
650 
651 void ast_channel_internal_set_stream_topology_change_source(
652  struct ast_channel *chan, void *change_source)
653 {
654  chan->stream_topology_change_source = change_source;
655 }
656 
658 {
659  return chan->stream_topology_change_source;
660 }
661 
662 void ast_channel_nativeformats_set(struct ast_channel *chan,
663  struct ast_format_cap *value)
664 {
665  SCOPE_ENTER(2, "%s: %sFormats: %s\n", S_OR(ast_channel_name(chan), "<initializing>"),
666  S_COR(ast_channel_is_multistream(chan), "Multistream", ""),
667  ast_str_tmp(128, ast_format_cap_get_names(value, &STR_TMP)));
668 
669  ast_assert(chan != NULL);
670 
671  ao2_replace(chan->nativeformats, value);
672 
673  /* If chan->stream_topology is NULL, the channel is being destroyed
674  * and topology is destroyed.
675  */
676  if (!chan->stream_topology) {
677  SCOPE_EXIT_RTN("Channel is being initialized or destroyed\n");
678  }
679 
680  if (!ast_channel_is_multistream(chan) || !value) {
681  struct ast_stream_topology *new_topology;
682 
683  new_topology = ast_stream_topology_create_from_format_cap(value);
684  ast_channel_internal_set_stream_topology(chan, new_topology);
685  SCOPE_EXIT_RTN("New %stopology set\n", value ? "" : "empty ");
686  }
687  SCOPE_EXIT_RTN("Set native formats but not topology\n");
688 }
689 
690 struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan)
691 {
692  return chan->framehooks;
693 }
694 void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value)
695 {
696  chan->framehooks = value;
697 }
698 struct ast_generator *ast_channel_generator(const struct ast_channel *chan)
699 {
700  return chan->generator;
701 }
702 void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value)
703 {
704  chan->generator = value;
705 }
706 struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan)
707 {
708  return chan->pbx;
709 }
710 void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value)
711 {
712  chan->pbx = value;
713 }
714 struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan)
715 {
716  return chan->sched;
717 }
718 void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value)
719 {
720  chan->sched = value;
721 }
722 struct ast_timer *ast_channel_timer(const struct ast_channel *chan)
723 {
724  return chan->timer;
725 }
726 void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value)
727 {
728  chan->timer = value;
729 }
730 struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan)
731 {
732  return chan->zone;
733 }
734 void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value)
735 {
736  chan->zone = value;
737 }
738 struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan)
739 {
740  return chan->readtrans;
741 }
742 void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
743 {
744  chan->readtrans = value;
745 }
746 struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan)
747 {
748  return chan->writetrans;
749 }
750 void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
751 {
752  chan->writetrans = value;
753 }
754 const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan)
755 {
756  return chan->tech;
757 }
758 void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
759 {
760  if (value->read_stream || value->write_stream) {
761  ast_assert(value->read_stream && value->write_stream);
762  }
763 
764  chan->tech = value;
765 }
766 enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan)
767 {
768  return chan->adsicpe;
769 }
770 void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
771 {
772  chan->adsicpe = value;
773 }
774 enum ast_channel_state ast_channel_state(const struct ast_channel *chan)
775 {
776  return chan->state;
777 }
778 ast_callid ast_channel_callid(const struct ast_channel *chan)
779 {
780  return chan->callid;
781 }
782 void ast_channel_callid_set(struct ast_channel *chan, ast_callid callid)
783 {
784  char call_identifier_from[AST_CALLID_BUFFER_LENGTH];
785  char call_identifier_to[AST_CALLID_BUFFER_LENGTH];
786  call_identifier_from[0] = '\0';
787  ast_callid_strnprint(call_identifier_to, sizeof(call_identifier_to), callid);
788  if (chan->callid) {
789  ast_callid_strnprint(call_identifier_from, sizeof(call_identifier_from), chan->callid);
790  ast_debug(3, "Channel Call ID changing from %s to %s\n", call_identifier_from, call_identifier_to);
791  }
792 
793  chan->callid = callid;
794 
795  ast_test_suite_event_notify("CallIDChange",
796  "State: CallIDChange\r\n"
797  "Channel: %s\r\n"
798  "CallID: %s\r\n"
799  "PriorCallID: %s",
800  ast_channel_name(chan),
801  call_identifier_to,
802  call_identifier_from);
803 }
804 
805 void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state value)
806 {
807  chan->state = value;
808 }
809 void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format)
810 {
811  ao2_replace(chan->oldwriteformat, format);
812 }
813 void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
814 {
815  ao2_replace(chan->rawreadformat, format);
816 }
817 void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
818 {
819  ao2_replace(chan->rawwriteformat, format);
820 }
821 void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
822 {
823  ao2_replace(chan->readformat, format);
824 }
825 void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
826 {
827  ao2_replace(chan->writeformat, format);
828 }
829 struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan)
830 {
831  return chan->oldwriteformat;
832 }
833 struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan)
834 {
835  return chan->rawreadformat;
836 }
837 struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan)
838 {
839  return chan->rawwriteformat;
840 }
841 struct ast_format *ast_channel_readformat(struct ast_channel *chan)
842 {
843  return chan->readformat;
844 }
845 struct ast_format *ast_channel_writeformat(struct ast_channel *chan)
846 {
847  return chan->writeformat;
848 }
849 struct ast_hangup_handler_list *ast_channel_hangup_handlers(struct ast_channel *chan)
850 {
851  return &chan->hangup_handlers;
852 }
853 struct ast_datastore_list *ast_channel_datastores(struct ast_channel *chan)
854 {
855  return &chan->datastores;
856 }
857 struct ast_autochan_list *ast_channel_autochans(struct ast_channel *chan)
858 {
859  return &chan->autochans;
860 }
861 struct ast_readq_list *ast_channel_readq(struct ast_channel *chan)
862 {
863  return &chan->readq;
864 }
865 struct ast_frame *ast_channel_dtmff(struct ast_channel *chan)
866 {
867  return &chan->dtmff;
868 }
869 struct ast_jb *ast_channel_jb(struct ast_channel *chan)
870 {
871  return &chan->jb;
872 }
873 struct ast_party_caller *ast_channel_caller(struct ast_channel *chan)
874 {
875  return &chan->caller;
876 }
877 struct ast_party_connected_line *ast_channel_connected(struct ast_channel *chan)
878 {
879  return &chan->connected;
880 }
881 struct ast_party_connected_line *ast_channel_connected_indicated(struct ast_channel *chan)
882 {
883  return &chan->connected_indicated;
884 }
885 struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
886 {
887  return ast_party_id_merge(&chan->connected.id, &chan->connected.priv);
888 }
889 struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan)
890 {
891  return &chan->dialed;
892 }
893 struct ast_party_redirecting *ast_channel_redirecting(struct ast_channel *chan)
894 {
895  return &chan->redirecting;
896 }
897 struct ast_party_id ast_channel_redirecting_effective_orig(struct ast_channel *chan)
898 {
900 }
901 struct ast_party_id ast_channel_redirecting_effective_from(struct ast_channel *chan)
902 {
904 }
905 struct ast_party_id ast_channel_redirecting_effective_to(struct ast_channel *chan)
906 {
907  return ast_party_id_merge(&chan->redirecting.to, &chan->redirecting.priv_to);
908 }
909 struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan)
910 {
911  return &chan->dtmf_tv;
912 }
913 struct timeval *ast_channel_whentohangup(struct ast_channel *chan)
914 {
915  return &chan->whentohangup;
916 }
917 struct varshead *ast_channel_varshead(struct ast_channel *chan)
918 {
919  return &chan->varshead;
920 }
921 void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value)
922 {
923  chan->dtmff = *value;
924 }
925 void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value)
926 {
927  chan->jb = *value;
928 }
929 void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value)
930 {
931  chan->caller = *value;
933 }
934 void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value)
935 {
936  chan->connected = *value;
938 }
939 void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value)
940 {
941  chan->dialed = *value;
943 }
944 void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value)
945 {
946  chan->redirecting = *value;
948 }
949 void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value)
950 {
951  chan->dtmf_tv = *value;
952 }
953 void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
954 {
955  chan->whentohangup = *value;
956 }
957 void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value)
958 {
959  chan->varshead = *value;
960 }
961 struct timeval ast_channel_creationtime(struct ast_channel *chan)
962 {
963  return chan->creationtime;
964 }
965 void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value)
966 {
967  chan->creationtime = *value;
969 }
970 
971 struct timeval ast_channel_answertime(struct ast_channel *chan)
972 {
973  return chan->answertime;
974 }
975 
976 void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value)
977 {
978  chan->answertime = *value;
979 }
980 
981 /* Evil softhangup accessors */
982 int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
983 {
984  return chan->softhangup;
985 }
986 void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value)
987 {
988  chan->softhangup = value;
989 }
990 void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
991 {
992  chan->softhangup |= value;
993 }
994 void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value)
995 {
996  chan ->softhangup &= ~value;
997 }
998 
1000 {
1001  return chan->unbridged;
1002 }
1003 
1005 {
1006  int res;
1007  ast_channel_lock(chan);
1008  res = ast_channel_unbridged_nolock(chan);
1009  ast_channel_unlock(chan);
1010  return res;
1011 }
1012 
1013 void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value)
1014 {
1015  chan->unbridged = !!value;
1017 }
1018 
1019 void ast_channel_set_unbridged(struct ast_channel *chan, int value)
1020 {
1021  ast_channel_lock(chan);
1022  ast_channel_set_unbridged_nolock(chan, value);
1023  ast_channel_unlock(chan);
1024 }
1025 
1027 {
1028  return chan->is_t38_active;
1029 }
1030 
1032 {
1033  int res;
1034 
1035  ast_channel_lock(chan);
1037  ast_channel_unlock(chan);
1038  return res;
1039 }
1040 
1041 void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active)
1042 {
1043  chan->is_t38_active = !!is_t38_active;
1044 }
1045 
1046 void ast_channel_set_is_t38_active(struct ast_channel *chan, int is_t38_active)
1047 {
1048  ast_channel_lock(chan);
1049  ast_channel_set_is_t38_active_nolock(chan, is_t38_active);
1050  ast_channel_unlock(chan);
1051 }
1052 
1053 void ast_channel_callid_cleanup(struct ast_channel *chan)
1054 {
1055  chan->callid = 0;
1056 }
1057 
1058 /* Typedef accessors */
1059 ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
1060 {
1061  return chan->callgroup;
1062 }
1063 void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value)
1064 {
1065  chan->callgroup = value;
1066 }
1067 ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
1068 {
1069  return chan->pickupgroup;
1070 }
1071 void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
1072 {
1073  chan->pickupgroup = value;
1074 }
1075 struct ast_namedgroups *ast_channel_named_callgroups(const struct ast_channel *chan)
1076 {
1077  return chan->named_callgroups;
1078 }
1079 void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
1080 {
1081  ast_unref_namedgroups(chan->named_callgroups);
1082  chan->named_callgroups = ast_ref_namedgroups(value);
1083 }
1084 struct ast_namedgroups *ast_channel_named_pickupgroups(const struct ast_channel *chan)
1085 {
1086  return chan->named_pickupgroups;
1087 }
1088 void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
1089 {
1090  ast_unref_namedgroups(chan->named_pickupgroups);
1091  chan->named_pickupgroups = ast_ref_namedgroups(value);
1092 }
1093 
1094 /* Alertpipe functions */
1095 int ast_channel_alert_write(struct ast_channel *chan)
1096 {
1097  return ast_alertpipe_write(chan->alertpipe);
1098 }
1099 
1100 ast_alert_status_t ast_channel_internal_alert_flush(struct ast_channel *chan)
1101 {
1102  return ast_alertpipe_flush(chan->alertpipe);
1103 }
1104 
1105 ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan)
1106 {
1107  return ast_alertpipe_read(chan->alertpipe);
1108 }
1109 
1110 int ast_channel_alert_writable(struct ast_channel *chan)
1111 {
1112  return ast_alertpipe_writable(chan->alertpipe);
1113 }
1114 
1115 int ast_channel_internal_alert_readable(struct ast_channel *chan)
1116 {
1117  return ast_alertpipe_readable(chan->alertpipe);
1118 }
1119 
1120 void ast_channel_internal_alertpipe_clear(struct ast_channel *chan)
1121 {
1122  ast_alertpipe_clear(chan->alertpipe);
1123 }
1124 
1125 void ast_channel_internal_alertpipe_close(struct ast_channel *chan)
1126 {
1127  ast_alertpipe_close(chan->alertpipe);
1128 }
1129 
1130 int ast_channel_internal_alertpipe_init(struct ast_channel *chan)
1131 {
1132  return ast_alertpipe_init(chan->alertpipe);
1133 }
1134 
1135 int ast_channel_internal_alert_readfd(struct ast_channel *chan)
1136 {
1137  return ast_alertpipe_readfd(chan->alertpipe);
1138 }
1139 
1141 {
1142  ast_alertpipe_swap(chan1->alertpipe, chan2->alertpipe);
1143 }
1144 
1145 /* file descriptor array accessors */
1146 void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value)
1147 {
1148  int pos;
1149 
1150  /* This ensures that if the vector has to grow with unused positions they will be
1151  * initialized to -1.
1152  */
1153  for (pos = AST_VECTOR_SIZE(&chan->fds); pos < which; pos++) {
1154  AST_VECTOR_REPLACE(&chan->fds, pos, -1);
1155  }
1156 
1157  AST_VECTOR_REPLACE(&chan->fds, which, value);
1158 }
1159 void ast_channel_internal_fd_clear(struct ast_channel *chan, int which)
1160 {
1161  if (which >= AST_VECTOR_SIZE(&chan->fds)) {
1162  return;
1163  }
1164 
1165  AST_VECTOR_REPLACE(&chan->fds, which, -1);
1166 }
1167 void ast_channel_internal_fd_clear_all(struct ast_channel *chan)
1168 {
1170 }
1171 int ast_channel_fd(const struct ast_channel *chan, int which)
1172 {
1173  return (which >= AST_VECTOR_SIZE(&chan->fds)) ? -1 : AST_VECTOR_GET(&chan->fds, which);
1174 }
1175 int ast_channel_fd_isset(const struct ast_channel *chan, int which)
1176 {
1177  return ast_channel_fd(chan, which) > -1;
1178 }
1179 
1180 int ast_channel_fd_count(const struct ast_channel *chan)
1181 {
1182  return AST_VECTOR_SIZE(&chan->fds);
1183 }
1184 
1185 int ast_channel_fd_add(struct ast_channel *chan, int value)
1186 {
1187  int pos = AST_EXTENDED_FDS;
1188 
1189  while (ast_channel_fd_isset(chan, pos)) {
1190  pos += 1;
1191  }
1192 
1193  AST_VECTOR_REPLACE(&chan->fds, pos, value);
1194 
1195  return pos;
1196 }
1197 
1198 pthread_t ast_channel_blocker(const struct ast_channel *chan)
1199 {
1200  return chan->blocker;
1201 }
1202 void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value)
1203 {
1204  chan->blocker = value;
1205 }
1206 
1207 int ast_channel_blocker_tid(const struct ast_channel *chan)
1208 {
1209  return chan->blocker_tid;
1210 }
1211 void ast_channel_blocker_tid_set(struct ast_channel *chan, int value)
1212 {
1213  chan->blocker_tid = value;
1214 }
1215 
1216 ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
1217 {
1218  return chan->timingfunc;
1219 }
1220 void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value)
1221 {
1222  chan->timingfunc = value;
1223 }
1224 
1225 struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan)
1226 {
1227  return chan->bridge;
1228 }
1229 void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value)
1230 {
1231  chan->bridge = value;
1234 }
1235 
1236 struct ast_bridge_channel *ast_channel_internal_bridge_channel(const struct ast_channel *chan)
1237 {
1238  return chan->bridge_channel;
1239 }
1240 void ast_channel_internal_bridge_channel_set(struct ast_channel *chan, struct ast_bridge_channel *value)
1241 {
1242  chan->bridge_channel = value;
1243 }
1244 
1245 struct ast_flags *ast_channel_flags(struct ast_channel *chan)
1246 {
1247  return &chan->flags;
1248 }
1249 
1250 static int collect_names_cb(void *obj, void *arg, int flags)
1251 {
1252  struct ast_control_pvt_cause_code *cause_code = obj;
1253  struct ast_str **str = arg;
1254 
1255  ast_str_append(str, 0, "%s%s", (ast_str_strlen(*str) ? "," : ""), cause_code->chan_name);
1256 
1257  return 0;
1258 }
1259 
1261 {
1262  struct ast_str *chanlist = ast_str_create(128);
1263 
1264  if (!chanlist) {
1265  return NULL;
1266  }
1267 
1268  ao2_callback(chan->dialed_causes, 0, collect_names_cb, &chanlist);
1269 
1270  return chanlist;
1271 }
1272 
1274 {
1275  return ao2_find(chan->dialed_causes, chan_name, OBJ_KEY);
1276 }
1277 
1278 int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
1279 {
1280  struct ast_control_pvt_cause_code *ao2_cause_code;
1281  ao2_find(chan->dialed_causes, cause_code->chan_name, OBJ_KEY | OBJ_UNLINK | OBJ_NODATA);
1282  ao2_cause_code = ao2_alloc(datalen, NULL);
1283 
1284  if (ao2_cause_code) {
1285  memcpy(ao2_cause_code, cause_code, datalen);
1286  ao2_link(chan->dialed_causes, ao2_cause_code);
1287  ao2_ref(ao2_cause_code, -1);
1288  return 0;
1289  } else {
1290  return -1;
1291  }
1292 }
1293 
1295 {
1297 }
1298 
1299 /*! \brief Hash function for pvt cause code frames */
1300 static int pvt_cause_hash_fn(const void *vpc, const int flags)
1301 {
1302  const struct ast_control_pvt_cause_code *pc = vpc;
1304 }
1305 
1306 /*! \brief Comparison function for pvt cause code frames */
1307 static int pvt_cause_cmp_fn(void *obj, void *vstr, int flags)
1308 {
1309  struct ast_control_pvt_cause_code *pc = obj;
1310  char *str = ast_tech_to_upper(ast_strdupa(vstr));
1311  char *pc_str = ast_tech_to_upper(ast_strdupa(pc->chan_name));
1312  return !strcmp(pc_str, str) ? CMP_MATCH | CMP_STOP : 0;
1313 }
1314 
1315 #define DIALED_CAUSES_BUCKETS 37
1316 
1317 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)
1318 {
1319  struct ast_channel *tmp;
1320 
1321  tmp = __ao2_alloc(sizeof(*tmp), destructor,
1322  AO2_ALLOC_OPT_LOCK_MUTEX, "", file, line, function);
1323 
1324  if (!tmp) {
1325  return NULL;
1326  }
1327 
1328  if ((ast_string_field_init(tmp, 128))) {
1329  return ast_channel_unref(tmp);
1330  }
1331 
1333  DIALED_CAUSES_BUCKETS, pvt_cause_hash_fn, NULL, pvt_cause_cmp_fn);
1334  if (!tmp->dialed_causes) {
1335  return ast_channel_unref(tmp);
1336  }
1337 
1338  /* set the creation time in the uniqueid */
1339  tmp->uniqueid.creation_time = time(NULL);
1340  tmp->uniqueid.creation_unique = ast_atomic_fetchadd_int(&uniqueint, 1);
1341 
1342  /* use provided id or default to historical {system-}time.# format */
1343  if (assignedids && !ast_strlen_zero(assignedids->uniqueid)) {
1344  ast_copy_string(tmp->uniqueid.unique_id, assignedids->uniqueid, sizeof(tmp->uniqueid.unique_id));
1345  } else if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) {
1346  snprintf(tmp->uniqueid.unique_id, sizeof(tmp->uniqueid.unique_id), "%li.%d",
1347  (long)(tmp->uniqueid.creation_time),
1348  tmp->uniqueid.creation_unique);
1349  } else {
1350  snprintf(tmp->uniqueid.unique_id, sizeof(tmp->uniqueid.unique_id), "%s-%li.%d",
1351  ast_config_AST_SYSTEM_NAME,
1352  (long)(tmp->uniqueid.creation_time),
1353  tmp->uniqueid.creation_unique);
1354  }
1355 
1356  /* copy linked id from parent channel if known */
1357  if (requestor) {
1358  tmp->linkedid = requestor->linkedid;
1359  } else {
1360  tmp->linkedid = tmp->uniqueid;
1361  }
1362 
1364 
1365  /* Force all channel snapshot segments to be created on first use, so we don't have to check if
1366  * an old snapshot exists.
1367  */
1368  ast_set_flag(&tmp->snapshot_segment_flags, AST_FLAGS_ALL);
1369 
1370  return tmp;
1371 }
1372 
1374 {
1375  ast_assert(a->linkedid.creation_time != 0);
1376  ast_assert(b->linkedid.creation_time != 0);
1377 
1379  return a;
1380  }
1382  return b;
1383  }
1385  return a;
1386  }
1387  return b;
1388 }
1389 
1391 {
1392  if (dest->linkedid.creation_time == source->linkedid.creation_time
1393  && dest->linkedid.creation_unique == source->linkedid.creation_unique
1394  && !strcmp(dest->linkedid.unique_id, source->linkedid.unique_id)) {
1395  return;
1396  }
1397  dest->linkedid = source->linkedid;
1400 }
1401 
1403 {
1404  struct ast_channel_id temp;
1405 
1406  /* This operation is used as part of masquerading and so does not invalidate the peer
1407  * segment. This is due to the masquerade process invalidating all segments.
1408  */
1409 
1410  temp = a->uniqueid;
1411  a->uniqueid = b->uniqueid;
1412  b->uniqueid = temp;
1413 
1414  temp = a->linkedid;
1415  a->linkedid = b->linkedid;
1416  b->linkedid = temp;
1417 }
1418 
1420 {
1421  struct stasis_topic *topic;
1422  struct stasis_forward *forward;
1423 
1424  topic = a->topic;
1425  a->topic = b->topic;
1426  b->topic = topic;
1427 
1428  forward = a->channel_forward;
1430  b->channel_forward = forward;
1431 }
1432 
1434 {
1435  struct stasis_forward *temp;
1436 
1437  temp = a->endpoint_forward;
1439  b->endpoint_forward = temp;
1440 }
1441 
1443 {
1445 
1446  snapshot = a->snapshot;
1447  a->snapshot = b->snapshot;
1448  b->snapshot = snapshot;
1449 }
1450 
1451 void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid)
1452 {
1453  ast_copy_string(chan->uniqueid.unique_id, uniqueid, sizeof(chan->uniqueid.unique_id));
1454  ast_copy_string(chan->linkedid.unique_id, linkedid, sizeof(chan->linkedid.unique_id));
1455 }
1456 
1457 void ast_channel_internal_cleanup(struct ast_channel *chan)
1458 {
1459  if (chan->dialed_causes) {
1460  ao2_t_ref(chan->dialed_causes, -1,
1461  "done with dialed causes since the channel is going away");
1462  chan->dialed_causes = NULL;
1463  }
1464 
1466 
1467  chan->channel_forward = stasis_forward_cancel(chan->channel_forward);
1468  chan->endpoint_forward = stasis_forward_cancel(chan->endpoint_forward);
1469 
1470  ao2_cleanup(chan->topic);
1471  chan->topic = NULL;
1472 
1473  ast_channel_internal_set_stream_topology(chan, NULL);
1474 
1475  AST_VECTOR_FREE(&chan->fds);
1476 }
1477 
1478 void ast_channel_internal_finalize(struct ast_channel *chan)
1479 {
1480  chan->finalized = 1;
1481 }
1482 
1483 int ast_channel_internal_is_finalized(struct ast_channel *chan)
1484 {
1485  return chan->finalized;
1486 }
1487 
1489 {
1490  if (!chan) {
1491  return ast_channel_topic_all();
1492  }
1493 
1494  return chan->topic;
1495 }
1496 
1498  struct ast_endpoint *endpoint)
1499 {
1500  ast_assert(chan != NULL);
1501  ast_assert(endpoint != NULL);
1502 
1503  chan->endpoint_forward =
1505  ast_endpoint_topic(endpoint));
1506  if (!chan->endpoint_forward) {
1507  return -1;
1508  }
1509 
1510  return 0;
1511 }
1512 
1513 int ast_channel_internal_setup_topics(struct ast_channel *chan)
1514 {
1515  char *topic_name;
1516  int ret;
1517  ast_assert(chan->topic == NULL);
1518 
1519  if (ast_strlen_zero(chan->uniqueid.unique_id)) {
1520  static int dummy_id;
1521  ret = ast_asprintf(&topic_name, "channel:dummy-%d", ast_atomic_fetchadd_int(&dummy_id, +1));
1522  } else {
1523  ret = ast_asprintf(&topic_name, "channel:%s", chan->uniqueid.unique_id);
1524  }
1525 
1526  if (ret < 0) {
1527  return -1;
1528  }
1529 
1530  chan->topic = stasis_topic_create(topic_name);
1531  ast_free(topic_name);
1532  if (!chan->topic) {
1533  return -1;
1534  }
1535 
1538  if (!chan->channel_forward) {
1539  ao2_ref(chan->topic, -1);
1540  chan->topic = NULL;
1541  return -1;
1542  }
1543 
1544  return 0;
1545 }
1546 
1547 AST_THREADSTORAGE(channel_errno);
1548 
1549 void ast_channel_internal_errno_set(enum ast_channel_error error)
1550 {
1551  enum ast_channel_error *error_code = ast_threadstorage_get(&channel_errno, sizeof(*error_code));
1552  if (!error_code) {
1553  return;
1554  }
1555 
1556  *error_code = error;
1557 }
1558 
1559 enum ast_channel_error ast_channel_internal_errno(void)
1560 {
1561  enum ast_channel_error *error_code = ast_threadstorage_get(&channel_errno, sizeof(*error_code));
1562  if (!error_code) {
1563  return AST_CHANNEL_ERROR_UNKNOWN;
1564  }
1565 
1566  return *error_code;
1567 }
1568 
1570  const struct ast_channel *chan)
1571 {
1572  ast_assert(chan != NULL);
1573 
1574  return chan->stream_topology;
1575 }
1576 
1578  struct ast_stream_topology *topology)
1579 {
1580  struct ast_stream_topology *new_topology;
1581  SCOPE_ENTER(1, "%s: %s\n", ast_channel_name(chan),
1582  ast_str_tmp(256, ast_stream_topology_to_str(topology, &STR_TMP)));
1583 
1584  ast_assert(chan != NULL);
1585 
1586  /* A non-MULTISTREAM channel can't manipulate topology directly */
1587  ast_assert(ast_channel_is_multistream(chan));
1588 
1589  /* Unless the channel is being destroyed, we always want a topology on
1590  * it even if its empty.
1591  */
1592  if (!topology) {
1593  new_topology = ast_stream_topology_alloc();
1594  } else {
1595  new_topology = topology;
1596  }
1597 
1598  if (new_topology) {
1599  ast_channel_internal_set_stream_topology(chan, new_topology);
1600  }
1601 
1602  SCOPE_EXIT_RTN_VALUE(new_topology, "Used %s topology\n", topology ? "provided" : "empty");
1603 }
1604 
1606  enum ast_media_type type)
1607 {
1608  ast_assert(chan != NULL);
1609  ast_assert(type < AST_MEDIA_TYPE_END);
1610 
1611  return chan->default_streams[type];
1612 }
1613 
1614 void ast_channel_internal_swap_stream_topology(struct ast_channel *chan1,
1615  struct ast_channel *chan2)
1616 {
1617  struct ast_stream_topology *tmp_topology;
1618 
1619  ast_assert(chan1 != NULL && chan2 != NULL);
1620 
1621  tmp_topology = chan1->stream_topology;
1622  chan1->stream_topology = chan2->stream_topology;
1623  chan2->stream_topology = tmp_topology;
1624 
1625  channel_set_default_streams(chan1);
1626  channel_set_default_streams(chan2);
1627 }
1628 
1630 {
1631  return (chan && chan->tech && chan->tech->read_stream && chan->tech->write_stream);
1632 }
1633 
1634 struct ast_channel_snapshot *ast_channel_snapshot(const struct ast_channel *chan)
1635 {
1636  return chan->snapshot;
1637 }
1638 
1639 void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot)
1640 {
1641  ao2_cleanup(chan->snapshot);
1642  chan->snapshot = ao2_bump(snapshot);
1643 }
1644 
1645 struct ast_flags *ast_channel_snapshot_segment_flags(struct ast_channel *chan)
1646 {
1647  return &chan->snapshot_segment_flags;
1648 }
const ast_string_field peeraccount
int ast_channel_unbridged(struct ast_channel *chan)
This function will check if the bridge needs to be re-evaluated due to external changes.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
Definition: threadstorage.h:86
Information needed to identify an endpoint in a call.
Definition: channel.h:338
Tone Indication Support.
struct ast_channel * masqr
static int pvt_cause_hash_fn(const void *vpc, const int flags)
Hash function for pvt cause code frames.
Main Channel structure associated with a channel.
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
struct ast_channel * masq
struct ast_party_connected_line connected
Channel Connected Line ID information.
void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
struct stasis_forward * channel_forward
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_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...
Asterisk main include file. File version handling, generic pbx functions.
struct timeval answertime
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:539
char chan_name[AST_CHANNEL_NAME]
struct ast_flags flags
struct ast_party_caller caller
Channel Caller ID information.
struct ast_tone_zone * zone
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
char lastcontext[AST_MAX_CONTEXT]
struct ast_channel_id linkedid
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.
struct ast_channel::@335 fds
void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2)
Swap the interal alertpipe between two channels.
struct ast_party_id id
Connected party ID.
Definition: channel.h:458
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2958
struct ast_party_id priv_orig
Who originally redirected the call (Sent to the party the call is redirected toward) - private repres...
Definition: channel.h:533
#define OBJ_KEY
Definition: astobj2.h:1151
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:527
Channel UniqueId structure.
char context[AST_MAX_CONTEXT]
unsigned int fout
const char * blockproc
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container, as described below.
Definition: astobj2.h:1693
struct ast_timer * timer
struct ast_autochan_list autochans
struct ast_party_id priv_from
Who is redirecting the call (Sent to the party the call is redirected toward) - private representatio...
Definition: channel.h:536
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...
struct ast_generator * generator
unsigned int emulate_dtmf_duration
Structure representing a snapshot of channel state.
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.h), with stream num.
Definition: channel.h:747
int ast_channel_forward_endpoint(struct ast_channel *chan, struct ast_endpoint *endpoint)
Forward channel stasis messages to the given endpoint.
Test Framework API.
void ast_alertpipe_close(int alert_pipe[2])
Close an alert pipe.
Definition: alertpipe.c:79
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Structure to pass both assignedid values to channel drivers.
Definition: channel.h:604
unsigned long outsmpl
struct ast_sched_context * sched
ast_channel_state
ast_channel states
Definition: channelstate.h:35
char unique_id[AST_MAX_UNIQUEID]
struct stasis_topic * ast_endpoint_topic(struct ast_endpoint *endpoint)
Returns the topic for a specific endpoint.
Definition of a media format.
Definition: format.c:43
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:1139
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:341
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_cdr * cdr
unsigned short transfercapability
struct ast_format * oldwriteformat
Endpoint abstractions.
struct ast_format * rawreadformat
void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value)
const char * data
struct ast_format * rawwriteformat
struct ast_format_cap * nativeformats
enum ast_channel_adsicpe adsicpe
void ast_channel_dialed_causes_clear(const struct ast_channel *chan)
Clear all cause information from the channel.
ast_group_t pickupgroup
const char * appl
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:757
ast_group_t callgroup
void ast_channel_internal_swap_topics(struct ast_channel *a, struct ast_channel *b)
Swap topics beteween two channels.
Media Stream API.
struct ast_frame dtmff
int ast_channel_is_t38_active(struct ast_channel *chan)
This function will check if T.38 is active on the channel.
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:267
struct ast_format * writeformat
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value)
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:524
const struct ast_channel_tech * tech
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
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)
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
Definition: strings.h:1189
Definition: pbx.h:214
struct stasis_topic * ast_channel_topic_all(void)
A topic which publishes the events for all channels.
struct ast_bridge_channel * bridge_channel
struct ast_stream * default_streams[AST_MEDIA_TYPE_END]
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
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
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
General Asterisk PBX channel definitions.
Asterisk file paths, configured in asterisk.conf.
enum ast_media_type type
The type of media the stream is handling.
Definition: stream.c:85
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
Definition: vector.h:571
A set of tones for a given locale.
Definition: indications.h:74
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:359
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
ast_alert_status_t ast_alertpipe_read(int alert_pipe[2])
Read an event from an alert pipe.
Definition: alertpipe.c:102
struct stasis_topic * topic
enum ast_channel_state state
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define AST_MAX_EXTENSION
Definition: channel.h:134
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.
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:303
struct ast_stream_topology * stream_topology
void ast_channel_callid_set(struct ast_channel *chan, ast_callid callid)
Caller Party information.
Definition: channel.h:418
void ast_channel_internal_swap_snapshots(struct ast_channel *a, struct ast_channel *b)
Swap snapshots beteween two channels.
#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
List of channel drivers.
Definition: app_dial.c:797
int ast_channel_unbridged_nolock(struct ast_channel *chan)
ast_channel_unbridged variant. Use this if the channel is already locked prior to calling...
struct ao2_container * dialed_causes
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_VECTOR(name, type)
Define a vector structure.
Definition: vector.h:44
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition: stasis.c:617
struct ast_format * readformat
int ast_channel_fd_count(const struct ast_channel *chan)
Retrieve the number of file decriptor positions present on the channel.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
const ast_string_field dialcontext
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:1139
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.
int ast_alertpipe_init(int alert_pipe[2])
Initialize an alert pipe.
Definition: alertpipe.c:38
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:189
struct ast_party_dialed dialed
Dialed/Called information.
struct ast_trans_pvt * writetrans
Dialed/Called Party information.
Definition: channel.h:378
Responsible for call detail data.
Definition: cdr.h:279
Structure that contains information about a bridge.
Definition: bridge.h:349
struct ast_hangup_handler_list hangup_handlers
#define AST_EXTENDED_FDS
Definition: channel.h:195
char * ast_tech_to_upper(char *dev_str)
Convert the tech portion of a device string to upper case.
Definition: strings.h:1236
#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
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
Support for dynamic strings.
Definition: strings.h:623
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
Internal channel functions for channel.c to use.
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
unsigned int fin
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
Definition: stream.c:650
void * ast_channel_get_stream_topology_change_source(struct ast_channel *chan)
Retrieve the source that initiated the last stream topology change.
struct timeval sending_dtmf_tv
unsigned long insmpl
const ast_string_field call_forward
struct ast_namedgroups * named_pickupgroups
struct ast_channel * ast_channel_internal_oldest_linkedid(struct ast_channel *a, struct ast_channel *b)
Determine which channel has an older linkedid.
Connected Line/Party information.
Definition: channel.h:456
const ast_string_field name
void ast_channel_set_is_t38_active(struct ast_channel *chan, int is_t38_active)
Sets the is_t38_active flag.
const ast_string_field hangupsource
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:522
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
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
struct ast_bridge * bridge
General jitterbuffer state.
Definition: abstract_jb.h:140
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.
void * stream_topology_change_source
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 int finalized
#define AST_MAX_CONTEXT
Definition: channel.h:135
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
Definition: vector.h:625
struct ast_filestream * vstream
struct ast_jb jb
#define AST_MAX_FDS
Definition: channel.h:194
struct ast_datastore_list datastores
struct timeval creationtime
Vector container support.
const ast_string_field userfield
struct ast_flags snapshot_segment_flags
Structure used to handle boolean flags.
Definition: utils.h:199
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...
struct ast_party_connected_line connected_indicated
Channel Connected Line ID information that was last indicated.
void ast_channel_internal_swap_uniqueid_and_linkedid(struct ast_channel *a, struct ast_channel *b)
Swap uniqueid and linkedid beteween two channels.
struct ast_frame ast_null_frame
Definition: main/frame.c:79
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:730
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...
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:680
Structure that contains information regarding a channel in a bridge.
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
ast_alert_status_t ast_alertpipe_flush(int alert_pipe[2])
Consume all alerts written to the alert pipe.
Definition: alertpipe.c:134
ssize_t ast_alertpipe_write(int alert_pipe[2])
Write an event to an alert pipe.
Definition: alertpipe.c:120
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
Definition: astobj2.h:501
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:530
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
#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
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
#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
const ast_string_field musicclass
const ast_string_field accountcode
Data structure associated with a single frame of data.
struct ast_namedgroups * named_callgroups
struct stasis_forward * endpoint_forward
struct ast_channel_id uniqueid
Forwarding information.
Definition: stasis.c:1531
struct timeval dtmf_tv
struct timeval whentohangup
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
char lastexten[AST_MAX_EXTENSION]
ast_media_type
Types of media.
Definition: codec.h:30
Generic container type.
struct ast_trans_pvt * readtrans
ama_flags
Channel AMA Flags.
Definition: channel.h:1177
static int pvt_cause_cmp_fn(void *obj, void *vstr, int flags)
Comparison function for pvt cause code frames.
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:2288
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:1578
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_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
Definition: stream.c:743
struct ast_filestream * stream
#define AST_MAX_UNIQUEID
Definition: channel.h:168
struct ast_channel_snapshot * snapshot
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:374
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:468
const ast_string_field latest_musicclass
Endpoint abstractions.
void ast_channel_internal_swap_endpoint_forward(struct ast_channel *a, struct ast_channel *b)
Swap endpoint_forward between two channels.
struct varshead varshead
const ast_string_field language
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:609
char exten[AST_MAX_EXTENSION]
static int uniqueint
The monotonically increasing integer counter for channel uniqueids.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
int ast_channel_fd_add(struct ast_channel *chan, int value)
Add a file descriptor to the channel without a fixed position.
struct ast_pbx * pbx
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
Definition: strings.h:1259
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532