Asterisk - The Open Source Telephony Project  GIT-master-1f78ee9
include/asterisk/frame.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*! \file
20  * \brief Asterisk internal frame definitions.
21  * \arg For an explanation of frames, see \ref Def_Frame
22  * \arg Frames are send of Asterisk channels, see \ref Def_Channel
23  */
24 
25 #ifndef _ASTERISK_FRAME_H
26 #define _ASTERISK_FRAME_H
27 
28 #if defined(__cplusplus) || defined(c_plusplus)
29 extern "C" {
30 #endif
31 
32 #include <sys/time.h>
33 
34 #include "asterisk/format.h"
35 #include "asterisk/endian.h"
36 #include "asterisk/linkedlists.h"
37 
38 /*!
39  * \page Def_Frame AST Multimedia and signalling frames
40  * \section Def_AstFrame What is an ast_frame ?
41  * A frame of data read used to communicate between
42  * between channels and applications.
43  * Frames are divided into frame types and subclasses.
44  *
45  * \par Frame types
46  * \arg \b VOICE: Voice data, subclass is codec (AST_FORMAT_*)
47  * \arg \b VIDEO: Video data, subclass is codec (AST_FORMAT_*)
48  * \arg \b DTMF: A DTMF digit, subclass is the digit
49  * \arg \b IMAGE: Image transport, mostly used in IAX
50  * \arg \b TEXT: Text messages and character by character (real time text)
51  * \arg \b TEXT_DATA: Text messages in an ast_msg_data structure
52  * \arg \b HTML: URL's and web pages
53  * \arg \b MODEM: Modulated data encodings, such as T.38 and V.150
54  * \arg \b IAX: Private frame type for the IAX protocol
55  * \arg \b CNG: Comfort noice frames
56  * \arg \b CONTROL:A control frame, subclass defined as AST_CONTROL_
57  * \arg \b NULL: Empty, useless frame
58  *
59  * \par Files
60  * \arg frame.h Definitions
61  * \arg frame.c Function library
62  * \arg \ref Def_Channel Asterisk channels
63  * \section Def_ControlFrame Control Frames
64  * Control frames send signalling information between channels
65  * and devices. They are prefixed with AST_CONTROL_, like AST_CONTROL_FRAME_HANGUP
66  * \arg \b HANGUP The other end has hungup
67  * \arg \b RING Local ring
68  * \arg \b RINGING The other end is ringing
69  * \arg \b ANSWER The other end has answered
70  * \arg \b BUSY Remote end is busy
71  * \arg \b TAKEOFFHOOK Make it go off hook (what's "it" ? )
72  * \arg \b OFFHOOK Line is off hook
73  * \arg \b CONGESTION Congestion (circuit is busy, not available)
74  * \arg \b FLASH Other end sends flash hook
75  * \arg \b WINK Other end sends wink
76  * \arg \b OPTION Send low-level option
77  * \arg \b RADIO_KEY Key radio (see app_rpt.c)
78  * \arg \b RADIO_UNKEY Un-key radio (see app_rpt.c)
79  * \arg \b PROGRESS Other end indicates call progress
80  * \arg \b PROCEEDING Indicates proceeding
81  * \arg \b HOLD Call is placed on hold
82  * \arg \b UNHOLD Call is back from hold
83  * \arg \b VIDUPDATE Video update requested
84  * \arg \b SRCUPDATE The source of media has changed (RTP marker bit must change)
85  * \arg \b SRCCHANGE Media source has changed (RTP marker bit and SSRC must change)
86  * \arg \b CONNECTED_LINE Connected line has changed
87  * \arg \b REDIRECTING Call redirecting information has changed.
88  */
89 
90 /*!
91  * \brief Frame types
92  *
93  * \note It is important that the values of each frame type are never changed,
94  * because it will break backwards compatability with older versions.
95  * This is because these constants are transmitted directly over IAX2.
96  */
98  /*! DTMF end event, subclass is the digit */
100  /*! Voice data, subclass is AST_FORMAT_* */
102  /*! Video frame, maybe?? :) */
104  /*! A control frame, subclass is AST_CONTROL_* */
106  /*! An empty, useless frame */
108  /*! Inter Asterisk Exchange private frame type */
110  /*! Text messages */
112  /*! Image Frames */
114  /*! HTML Frame */
116  /*! Comfort Noise frame (subclass is level of CNG in -dBov),
117  body may include zero or more 8-bit quantization coefficients */
119  /*! Modem-over-IP data streams */
121  /*! DTMF begin event, subclass is the digit */
123  /*! Internal bridge module action. */
125  /*! Internal synchronous bridge module action.
126  * Synchronous bridge actions may be queued onto bridge
127  * channels, but they absolutely must not ever be written
128  * directly into bridges.
129  */
131  /*! RTCP feedback (the subclass will contain the payload type) */
133  /*! Text message in an ast_msg_data structure */
135 };
136 #define AST_FRAME_DTMF AST_FRAME_DTMF_END
137 
138 enum {
139  /*! This frame contains valid timing information */
141  /*! This frame has been requeued */
143  /*! This frame contains a valid sequence number */
145 };
146 
148  /*! A frame specific code */
149  int integer;
150  /*! The asterisk media format */
152  /*! For video formats, an indication that a frame ended */
153  unsigned int frame_ending;
154 };
155 
156 /*! \brief Data structure associated with a single frame of data
157  */
158 struct ast_frame {
159  /*! Kind of frame */
160  enum ast_frame_type frametype;
161  /*! Subclass, frame dependent */
162  struct ast_frame_subclass subclass;
163  /*! Length of data */
164  int datalen;
165  /*! Number of samples in this frame */
166  int samples;
167  /*! Was the data malloc'd? i.e. should we free it when we discard the frame? */
168  int mallocd;
169  /*! The number of bytes allocated for a malloc'd frame header */
171  /*! How many bytes exist _before_ "data" that can be used if needed */
172  int offset;
173  /*! Optional source of frame for debugging */
174  const char *src;
175  /*! Pointer to actual data */
176  union { void *ptr; uint32_t uint32; char pad[8]; } data;
177  /*! Global delivery time */
178  struct timeval delivery;
179  /*! For placing in a linked list */
181  /*! Misc. frame flags */
182  unsigned int flags;
183  /*! Timestamp in milliseconds */
184  long ts;
185  /*! Length in milliseconds */
186  long len;
187  /*! Sequence number */
188  int seqno;
189  /*! Stream number the frame originated from */
191 };
192 
193 /*!
194  * Set the various field of a frame to point to a buffer.
195  * Typically you set the base address of the buffer, the offset as
196  * AST_FRIENDLY_OFFSET, and the datalen as the amount of bytes queued.
197  * The remaining things (to be done manually) is set the number of
198  * samples, which cannot be derived from the datalen unless you know
199  * the number of bits per sample.
200  */
201 #define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen) \
202  { \
203  (fr)->data.ptr = (char *)_base + (_ofs); \
204  (fr)->offset = (_ofs); \
205  (fr)->datalen = (_datalen); \
206  }
207 
208 /*! Queueing a null frame is fairly common, so we declare a global null frame object
209  for this purpose instead of having to declare one on the stack */
210 extern struct ast_frame ast_null_frame;
211 
212 /*! \brief Offset into a frame's data buffer.
213  *
214  * By providing some "empty" space prior to the actual data of an ast_frame,
215  * this gives any consumer of the frame ample space to prepend other necessary
216  * information without having to create a new buffer.
217  *
218  * As an example, RTP can use the data from an ast_frame and simply prepend the
219  * RTP header information into the space provided by AST_FRIENDLY_OFFSET instead
220  * of having to create a new buffer with the necessary space allocated.
221  */
222 #define AST_FRIENDLY_OFFSET 64
223 #define AST_MIN_OFFSET 32 /*! Make sure we keep at least this much handy */
224 
225 /*! Need the header be free'd? */
226 #define AST_MALLOCD_HDR (1 << 0)
227 /*! Need the data be free'd? */
228 #define AST_MALLOCD_DATA (1 << 1)
229 /*! Need the source be free'd? (haha!) */
230 #define AST_MALLOCD_SRC (1 << 2)
231 
232 /* MODEM subclasses */
233 /*! T.38 Fax-over-IP */
234 #define AST_MODEM_T38 1
235 /*! V.150 Modem-over-IP */
236 #define AST_MODEM_V150 2
237 
238 /* HTML subclasses */
239 /*! Sending a URL */
240 #define AST_HTML_URL 1
241 /*! Data frame */
242 #define AST_HTML_DATA 2
243 /*! Beginning frame */
244 #define AST_HTML_BEGIN 4
245 /*! End frame */
246 #define AST_HTML_END 8
247 /*! Load is complete */
248 #define AST_HTML_LDCOMPLETE 16
249 /*! Peer is unable to support HTML */
250 #define AST_HTML_NOSUPPORT 17
251 /*! Send URL, and track */
252 #define AST_HTML_LINKURL 18
253 /*! No more HTML linkage */
254 #define AST_HTML_UNLINK 19
255 /*! Reject link request */
256 #define AST_HTML_LINKREJECT 20
257 
258 /*!
259  * \brief Internal control frame subtype field values.
260  *
261  * \warning
262  * IAX2 sends these values out over the wire. To prevent future
263  * incompatibilities, pick the next value in the enum from whatever
264  * is on the current trunk. If you lose the merge race you need to
265  * fix the previous branches to match what is on trunk. In addition
266  * you need to change chan_iax2 to explicitly allow the control
267  * frame over the wire if it makes sense for the frame to be passed
268  * to another Asterisk instance.
269  */
271  AST_CONTROL_HANGUP = 1, /*!< Other end has hungup */
272  AST_CONTROL_RING = 2, /*!< Local ring */
273  AST_CONTROL_RINGING = 3, /*!< Remote end is ringing */
274  AST_CONTROL_ANSWER = 4, /*!< Remote end has answered */
275  AST_CONTROL_BUSY = 5, /*!< Remote end is busy */
276  AST_CONTROL_TAKEOFFHOOK = 6, /*!< Make it go off hook */
277  AST_CONTROL_OFFHOOK = 7, /*!< Line is off hook */
278  AST_CONTROL_CONGESTION = 8, /*!< Congestion (circuits busy) */
279  AST_CONTROL_FLASH = 9, /*!< Flash hook */
280  AST_CONTROL_WINK = 10, /*!< Wink */
281  AST_CONTROL_OPTION = 11, /*!< Set a low-level option */
282  AST_CONTROL_RADIO_KEY = 12, /*!< Key Radio */
283  AST_CONTROL_RADIO_UNKEY = 13, /*!< Un-Key Radio */
284  AST_CONTROL_PROGRESS = 14, /*!< Indicate PROGRESS */
285  AST_CONTROL_PROCEEDING = 15, /*!< Indicate CALL PROCEEDING */
286  AST_CONTROL_HOLD = 16, /*!< Indicate call is placed on hold */
287  AST_CONTROL_UNHOLD = 17, /*!< Indicate call is left from hold */
288  AST_CONTROL_VIDUPDATE = 18, /*!< Indicate video frame update */
289  _XXX_AST_CONTROL_T38 = 19, /*!< T38 state change request/notification \deprecated This is no longer supported. Use AST_CONTROL_T38_PARAMETERS instead. */
290  AST_CONTROL_SRCUPDATE = 20, /*!< Indicate source of media has changed */
291  AST_CONTROL_TRANSFER = 21, /*!< Indicate status of a transfer request */
292  AST_CONTROL_CONNECTED_LINE = 22,/*!< Indicate connected line has changed */
293  AST_CONTROL_REDIRECTING = 23, /*!< Indicate redirecting id has changed */
294  AST_CONTROL_T38_PARAMETERS = 24,/*!< T38 state change request/notification with parameters */
295  AST_CONTROL_CC = 25, /*!< Indication that Call completion service is possible */
296  AST_CONTROL_SRCCHANGE = 26, /*!< Media source has changed and requires a new RTP SSRC */
297  AST_CONTROL_READ_ACTION = 27, /*!< Tell ast_read to take a specific action */
298  AST_CONTROL_AOC = 28, /*!< Advice of Charge with encoded generic AOC payload */
299  AST_CONTROL_END_OF_Q = 29, /*!< Indicate that this position was the end of the channel queue for a softhangup. */
300  AST_CONTROL_INCOMPLETE = 30, /*!< Indication that the extension dialed is incomplete */
301  AST_CONTROL_MCID = 31, /*!< Indicate that the caller is being malicious. */
302  AST_CONTROL_UPDATE_RTP_PEER = 32, /*!< Interrupt the bridge and have it update the peer */
303  AST_CONTROL_PVT_CAUSE_CODE = 33, /*!< Contains an update to the protocol-specific cause-code stored for branching dials */
304  AST_CONTROL_MASQUERADE_NOTIFY = 34, /*!< A masquerade is about to begin/end. (Never sent as a frame but directly with ast_indicate_data().) */
305  AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE = 35, /*!< Channel indication that a stream topology change has been requested */
306  AST_CONTROL_STREAM_TOPOLOGY_CHANGED = 36, /*!< Channel indication that a stream topology change has occurred */
307  AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED = 37, /*!< Channel indication that one of the source streams has changed its source */
308 
309  /*
310  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
311  *
312  * IAX2 sends these values out over the wire. To prevent future
313  * incompatibilities, pick the next value in the enum from whatever
314  * is on the current trunk. If you lose the merge race you need to
315  * fix the previous branches to match what is on trunk. In addition
316  * you need to change chan_iax2 to explicitly allow the control
317  * frame over the wire if it makes sense for the frame to be passed
318  * to another Asterisk instance.
319  *
320  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
321  */
322 
323  /* Control frames used to manipulate a stream on a channel. The values for these
324  * must be greater than the allowed value for a 8-bit char, so that they avoid
325  * conflicts with DTMF values. */
326  AST_CONTROL_STREAM_STOP = 1000, /*!< Indicate to a channel in playback to stop the stream */
327  AST_CONTROL_STREAM_SUSPEND = 1001, /*!< Indicate to a channel in playback to suspend the stream */
328  AST_CONTROL_STREAM_RESTART = 1002, /*!< Indicate to a channel in playback to restart the stream */
329  AST_CONTROL_STREAM_REVERSE = 1003, /*!< Indicate to a channel in playback to rewind */
330  AST_CONTROL_STREAM_FORWARD = 1004, /*!< Indicate to a channel in playback to fast forward */
331  /* Control frames to manipulate recording on a channel. */
332  AST_CONTROL_RECORD_CANCEL = 1100, /*!< Indicated to a channel in record to stop recording and discard the file */
333  AST_CONTROL_RECORD_STOP = 1101, /*!< Indicated to a channel in record to stop recording */
334  AST_CONTROL_RECORD_SUSPEND = 1102, /*!< Indicated to a channel in record to suspend/unsuspend recording */
335  AST_CONTROL_RECORD_MUTE = 1103, /*!< Indicated to a channel in record to mute/unmute (i.e. write silence) recording */
336 };
337 
338 /*!
339  * \brief Actions to indicate to, and be handled on channel read
340  *
341  * The subtype to specify for an AST_CONTROL_READ_ACTION frame. These
342  * frames are then to be enacted on within a channel's read thread.
343  */
348 };
349 
351  /* An indicator to ast_read of what action to
352  * take with the frame;
353  */
355  /* The size of the frame's payload
356  */
357  size_t payload_size;
358  /* A payload for the frame.
359  */
360  unsigned char payload[0];
361 };
362 
364  AST_T38_REQUEST_NEGOTIATE = 1, /*!< Request T38 on a channel (voice to fax) */
365  AST_T38_REQUEST_TERMINATE, /*!< Terminate T38 on a channel (fax to voice) */
366  AST_T38_NEGOTIATED, /*!< T38 negotiated (fax mode) */
367  AST_T38_TERMINATED, /*!< T38 terminated (back to voice) */
368  AST_T38_REFUSED, /*!< T38 refused for some reason (usually rejected by remote end) */
369  AST_T38_REQUEST_PARMS, /*!< request far end T.38 parameters for a channel in 'negotiating' state */
370 };
371 
378  /* Set to 0 so it's taken as default when unspecified.
379  * See ITU-T T.38 Implementors' Guide (11 May 2012),
380  * Table H.2: if the T38MaxBitRate attribute is omitted
381  * it should use a default of 14400. */
383 };
384 
388 };
389 
391  enum ast_control_t38 request_response; /*!< Request or response of the T38 control frame */
392  unsigned int version; /*!< Supported T.38 version */
393  unsigned int max_ifp; /*!< Maximum IFP size supported */
394  enum ast_control_t38_rate rate; /*!< Maximum fax rate supported */
395  enum ast_control_t38_rate_management rate_management; /*!< Rate management setting */
396  unsigned int fill_bit_removal:1; /*!< Set if fill bit removal can be used */
397  unsigned int transcoding_mmr:1; /*!< Set if MMR transcoding can be used */
398  unsigned int transcoding_jbig:1; /*!< Set if JBIG transcoding can be used */
399 };
400 
402  AST_TRANSFER_SUCCESS = 0, /*!< Transfer request on the channel worked */
403  AST_TRANSFER_FAILED, /*!< Transfer request on the channel failed */
404 };
405 
407  char chan_name[AST_CHANNEL_NAME]; /*!< Name of the channel that originated the cause information */
408  unsigned int emulate_sip_cause:1; /*!< Indicates whether this should be used to emulate SIP_CAUSE support */
409  int ast_cause; /*!< Asterisk cause code associated with this message */
410  char code[1]; /*!< Tech-specific cause code information, beginning with the name of the tech */
411 };
412 
413 /* Option identifiers and flags */
414 #define AST_OPTION_FLAG_REQUEST 0
415 #define AST_OPTION_FLAG_ACCEPT 1
416 #define AST_OPTION_FLAG_REJECT 2
417 #define AST_OPTION_FLAG_QUERY 4
418 #define AST_OPTION_FLAG_ANSWER 5
419 #define AST_OPTION_FLAG_WTF 6
420 
421 /*! Verify touchtones by muting audio transmission
422  * (and reception) and verify the tone is still present
423  * Option data is a single signed char value 0 or 1 */
424 #define AST_OPTION_TONE_VERIFY 1
425 
426 /*! Put a compatible channel into TDD (TTY for the hearing-impared) mode
427  * Option data is a single signed char value 0 or 1 */
428 #define AST_OPTION_TDD 2
429 
430 /*! Relax the parameters for DTMF reception (mainly for radio use)
431  * Option data is a single signed char value 0 or 1 */
432 #define AST_OPTION_RELAXDTMF 3
433 
434 /*! Set (or clear) Audio (Not-Clear) Mode
435  * Option data is a single signed char value 0 or 1 */
436 #define AST_OPTION_AUDIO_MODE 4
437 
438 /*! Set channel transmit gain
439  * Option data is a single signed char representing number of decibels (dB)
440  * to set gain to (on top of any gain specified in channel driver) */
441 #define AST_OPTION_TXGAIN 5
442 
443 /*! Set channel receive gain
444  * Option data is a single signed char representing number of decibels (dB)
445  * to set gain to (on top of any gain specified in channel driver) */
446 #define AST_OPTION_RXGAIN 6
447 
448 /* set channel into "Operator Services" mode
449  * Option data is a struct oprmode
450  *
451  * \note This option should never be sent over the network */
452 #define AST_OPTION_OPRMODE 7
453 
454 /*! Explicitly enable or disable echo cancelation for the given channel
455  * Option data is a single signed char value 0 or 1
456  *
457  * \note This option appears to be unused in the code. It is handled, but never
458  * set or queried. */
459 #define AST_OPTION_ECHOCAN 8
460 
461 /*! \brief Handle channel write data
462  * If a channel needs to process the data from a func_channel write operation
463  * after func_channel_write executes, it can define the setoption callback
464  * and process this option. A pointer to an ast_chan_write_info_t will be passed.
465  *
466  * \note This option should never be passed over the network. */
467 #define AST_OPTION_CHANNEL_WRITE 9
468 
469 /* !
470  * Read-only. Allows query current status of T38 on the channel.
471  * data: ast_t38state
472  */
473 #define AST_OPTION_T38_STATE 10
474 
475 /*! Request that the channel driver deliver frames in a specific format
476  * Option data is a format_t */
477 #define AST_OPTION_FORMAT_READ 11
478 
479 /*! Request that the channel driver be prepared to accept frames in a specific format
480  * Option data is a format_t */
481 #define AST_OPTION_FORMAT_WRITE 12
482 
483 /*! Request that the channel driver make two channels of the same tech type compatible if possible
484  * Option data is an ast_channel
485  *
486  * \note This option should never be passed over the network */
487 #define AST_OPTION_MAKE_COMPATIBLE 13
488 
489 /*! Get or set the digit detection state of the channel
490  * Option data is a single signed char value 0 or 1 */
491 #define AST_OPTION_DIGIT_DETECT 14
492 
493 /*! Get or set the fax tone detection state of the channel
494  * Option data is a single signed char value 0 or 1 */
495 #define AST_OPTION_FAX_DETECT 15
496 
497 /*! Get the device name from the channel (Read only)
498  * Option data is a character buffer of suitable length */
499 #define AST_OPTION_DEVICE_NAME 16
500 
501 /*! Get the CC agent type from the channel (Read only)
502  * Option data is a character buffer of suitable length */
503 #define AST_OPTION_CC_AGENT_TYPE 17
504 
505 /*! Get or set the security options on a channel
506  * Option data is an integer value of 0 or 1 */
507 #define AST_OPTION_SECURE_SIGNALING 18
508 #define AST_OPTION_SECURE_MEDIA 19
509 
510 struct oprmode {
511  struct ast_channel *peer;
512  int mode;
513 } ;
514 
516  /* Always keep in network byte order */
517 #if __BYTE_ORDER == __BIG_ENDIAN
518  uint16_t flag:3;
519  uint16_t option:13;
520 #else
521 #if __BYTE_ORDER == __LITTLE_ENDIAN
522  uint16_t option:13;
523  uint16_t flag:3;
524 #else
525 #error Byte order not defined
526 #endif
527 #endif
528  uint8_t data[0];
529 };
530 
531 /*! \brief Requests a frame to be allocated
532  *
533  * \param source
534  * Request a frame be allocated. source is an optional source of the frame,
535  * len is the requested length, or "0" if the caller will supply the buffer
536  */
537 #if 0 /* Unimplemented */
538 struct ast_frame *ast_fralloc(char *source, int len);
539 #endif
540 
541 /*!
542  * \brief Frees a frame or list of frames
543  *
544  * \param fr Frame to free, or head of list to free
545  * \param cache Whether to consider this frame for frame caching
546  */
547 void ast_frame_free(struct ast_frame *fr, int cache);
548 
549 #define ast_frfree(fr) ast_frame_free(fr, 1)
550 
551 /*!
552  * \brief NULL-safe wrapper for \ref ast_frfree, good for \ref RAII_VAR.
553  * \param frame Frame to free, or head of list to free.
554  */
555 void ast_frame_dtor(struct ast_frame *frame);
556 
557 /*! \brief Makes a frame independent of any static storage
558  * \param fr frame to act upon
559  * Take a frame, and if it's not been malloc'd, make a malloc'd copy
560  * and if the data hasn't been malloced then make the
561  * data malloc'd. If you need to store frames, say for queueing, then
562  * you should call this function.
563  * \return Returns a frame on success, NULL on error
564  * \note This function may modify the frame passed to it, so you must
565  * not assume the frame will be intact after the isolated frame has
566  * been produced. In other words, calling this function on a frame
567  * should be the last operation you do with that frame before freeing
568  * it (or exiting the block, if the frame is on the stack.)
569  */
570 #define ast_frisolate(fr) __ast_frisolate(fr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
571 struct ast_frame *__ast_frisolate(struct ast_frame *fr, const char *file, int line, const char *func);
572 
573 /*! \brief Copies a frame
574  * \param fr frame to copy
575  * Duplicates a frame -- should only rarely be used, typically frisolate is good enough
576  * \return Returns a frame on success, NULL on error
577  */
578 #define ast_frdup(fr) __ast_frdup(fr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
579 struct ast_frame *__ast_frdup(const struct ast_frame *fr, const char *file, int line, const char *func);
580 
581 void ast_swapcopy_samples(void *dst, const void *src, int samples);
582 
583 /* Helpers for byteswapping native samples to/from
584  little-endian and big-endian. */
585 #if __BYTE_ORDER == __LITTLE_ENDIAN
586 #define ast_frame_byteswap_le(fr) do { ; } while(0)
587 #define ast_frame_byteswap_be(fr) do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__f->data.ptr, __f->data.ptr, __f->samples); } while(0)
588 #else
589 #define ast_frame_byteswap_le(fr) do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__f->data.ptr, __f->data.ptr, __f->samples); } while(0)
590 #define ast_frame_byteswap_be(fr) do { ; } while(0)
591 #endif
592 
593 void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix);
594 
595 /*! \brief Appends a frame to the end of a list of frames, truncating the maximum length of the list */
596 struct ast_frame *ast_frame_enqueue(struct ast_frame *head, struct ast_frame *f, int maxlen, int dupe);
597 
598 /*!
599  \brief Adjusts the volume of the audio samples contained in a frame.
600  \param f The frame containing the samples (must be AST_FRAME_VOICE and AST_FORMAT_SLINEAR)
601  \param adjustment The number of dB to adjust up or down.
602  \return 0 for success, non-zero for an error
603  */
604 int ast_frame_adjust_volume(struct ast_frame *f, int adjustment);
605 
606 /*!
607  \brief Adjusts the volume of the audio samples contained in a frame.
608  \param f The frame containing the samples (must be AST_FRAME_VOICE and AST_FORMAT_SLINEAR)
609  \param adjustment The number of dB to adjust up or down.
610  \return 0 for success, non-zero for an error
611  */
612 int ast_frame_adjust_volume_float(struct ast_frame *f, float adjustment);
613 
614 /*!
615  \brief Sums two frames of audio samples.
616  \param f1 The first frame (which will contain the result)
617  \param f2 The second frame
618  \return 0 for success, non-zero for an error
619 
620  The frames must be AST_FRAME_VOICE and must contain AST_FORMAT_SLINEAR samples,
621  and must contain the same number of samples.
622  */
623 int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2);
624 
625 /*!
626  * \brief Clear all audio samples from an ast_frame. The frame must be AST_FRAME_VOICE and AST_FORMAT_SLINEAR
627  */
628 int ast_frame_clear(struct ast_frame *frame);
629 
630 /*!
631  * \brief Copy the discription of a frame's subclass into the provided string
632  *
633  * \param f The frame to get the information from
634  * \param subclass Buffer to fill with subclass information
635  * \param slen Length of subclass buffer
636  * \param moreinfo Buffer to fill with additional information
637  * \param mlen Length of moreinfo buffer
638  * \return Pointer to subclass
639  * \since 11
640  */
641 char *ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen);
642 
643 /*!
644  * \brief Copy the discription of a frame type into the provided string
645  *
646  * \param frame_type The frame type to be described
647  * \param ftype Buffer to fill with frame type description
648  * \param len Length of subclass buffer
649  * \return Pointer to ftype
650  * \since 11
651  */
652 char *ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len);
653 
654 #if defined(__cplusplus) || defined(c_plusplus)
655 }
656 #endif
657 
658 #endif /* _ASTERISK_FRAME_H */
Main Channel structure associated with a channel.
struct ast_frame * __ast_frdup(const struct ast_frame *fr, const char *file, int line, const char *func)
Definition: main/frame.c:299
int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2)
Sums two frames of audio samples.
Definition: main/frame.c:819
ast_control_transfer
void ast_swapcopy_samples(void *dst, const void *src, int samples)
Definition: main/frame.c:387
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
Definition: main/frame.c:713
Definition of a media format.
Definition: format.c:43
ast_control_frame_type
Internal control frame subtype field values.
void ast_frame_free(struct ast_frame *fr, int cache)
Requests a frame to be allocated.
Definition: main/frame.c:172
struct ast_frame * ast_frame_enqueue(struct ast_frame *head, struct ast_frame *f, int maxlen, int dupe)
Appends a frame to the end of a list of frames, truncating the maximum length of the list...
struct ast_frame_subclass subclass
Media Format API.
int ast_frame_adjust_volume_float(struct ast_frame *f, float adjustment)
Adjusts the volume of the audio samples contained in a frame.
Definition: main/frame.c:794
void ast_frame_dtor(struct ast_frame *frame)
NULL-safe wrapper for ast_frfree, good for RAII_VAR.
Definition: main/frame.c:183
const char * src
Asterisk architecture endianess compatibility definitions.
char * ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen)
Copy the discription of a frame&#39;s subclass into the provided string.
Definition: main/frame.c:397
A set of macros to manage forward-linked lists.
ast_frame_type
Frame types.
ast_control_t38_rate_management
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct ast_frame * __ast_frisolate(struct ast_frame *fr, const char *file, int line, const char *func)
&#39;isolates&#39; a frame by duplicating non-malloc&#39;ed components (header, src, data). On return all compone...
Definition: main/frame.c:193
frame_type
Definition: codec_builtin.c:44
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:409
long int flag
Definition: f2c.h:83
static const char name[]
Definition: cdr_mysql.c:74
ast_control_t38_rate
#define AST_CHANNEL_NAME
Definition: channel.h:172
unsigned int flags
char * ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len)
Copy the discription of a frame type into the provided string.
Definition: main/frame.c:653
struct ast_channel * peer
struct ao2_container * cache
Definition: pbx_realtime.c:77
struct ast_frame ast_null_frame
Definition: main/frame.c:79
int ast_frame_clear(struct ast_frame *frame)
Clear all audio samples from an ast_frame. The frame must be AST_FRAME_VOICE and AST_FORMAT_SLINEAR.
Definition: main/frame.c:841
Data structure associated with a single frame of data.
int ast_frame_adjust_volume(struct ast_frame *f, int adjustment)
Adjusts the volume of the audio samples contained in a frame.
Definition: main/frame.c:769
struct ast_format * format
ast_frame_read_action
Actions to indicate to, and be handled on channel read.
static char prefix[MAX_PREFIX]
Definition: http.c:141