Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Enumerations | Functions | Variables
include/asterisk/frame.h File Reference

Asterisk internal frame definitions. More...

#include <sys/time.h>
#include "asterisk/format.h"
#include "asterisk/endian.h"
#include "asterisk/linkedlists.h"

Go to the source code of this file.

Data Structures

struct  ast_control_pvt_cause_code
 
struct  ast_control_read_action_payload
 
struct  ast_control_t38_parameters
 
struct  ast_frame
 Data structure associated with a single frame of data. More...
 
struct  ast_frame_subclass
 
struct  ast_option_header
 
struct  oprmode
 

Macros

#define ast_frame_byteswap_be(fr)   do { ; } while(0)
 
#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)
 
#define AST_FRAME_DTMF   AST_FRAME_DTMF_END
 
#define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)
 
#define ast_frdup(fr)   __ast_frdup(fr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 Copies a frame. More...
 
#define ast_frfree(fr)   ast_frame_free(fr, 1)
 
#define AST_FRIENDLY_OFFSET   64
 Offset into a frame's data buffer. More...
 
#define ast_frisolate(fr)   __ast_frisolate(fr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 Makes a frame independent of any static storage. More...
 
#define AST_HTML_BEGIN   4
 
#define AST_HTML_DATA   2
 
#define AST_HTML_END   8
 
#define AST_HTML_LDCOMPLETE   16
 
#define AST_HTML_LINKREJECT   20
 
#define AST_HTML_LINKURL   18
 
#define AST_HTML_NOSUPPORT   17
 
#define AST_HTML_UNLINK   19
 
#define AST_HTML_URL   1
 
#define AST_MALLOCD_DATA   (1 << 1)
 
#define AST_MALLOCD_HDR   (1 << 0)
 
#define AST_MALLOCD_SRC   (1 << 2)
 
#define AST_MIN_OFFSET   32 /*! Make sure we keep at least this much handy */
 
#define AST_MODEM_T38   1
 
#define AST_MODEM_V150   2
 
#define AST_OPTION_AUDIO_MODE   4
 
#define AST_OPTION_CC_AGENT_TYPE   17
 
#define AST_OPTION_CHANNEL_WRITE   9
 Handle channel write data If a channel needs to process the data from a func_channel write operation after func_channel_write executes, it can define the setoption callback and process this option. A pointer to an ast_chan_write_info_t will be passed. More...
 
#define AST_OPTION_DEVICE_NAME   16
 
#define AST_OPTION_DIGIT_DETECT   14
 
#define AST_OPTION_ECHOCAN   8
 
#define AST_OPTION_FAX_DETECT   15
 
#define AST_OPTION_FLAG_ACCEPT   1
 
#define AST_OPTION_FLAG_ANSWER   5
 
#define AST_OPTION_FLAG_QUERY   4
 
#define AST_OPTION_FLAG_REJECT   2
 
#define AST_OPTION_FLAG_REQUEST   0
 
#define AST_OPTION_FLAG_WTF   6
 
#define AST_OPTION_FORMAT_READ   11
 
#define AST_OPTION_FORMAT_WRITE   12
 
#define AST_OPTION_MAKE_COMPATIBLE   13
 
#define AST_OPTION_OPRMODE   7
 
#define AST_OPTION_RELAXDTMF   3
 
#define AST_OPTION_RXGAIN   6
 
#define AST_OPTION_SECURE_MEDIA   19
 
#define AST_OPTION_SECURE_SIGNALING   18
 
#define AST_OPTION_T38_STATE   10
 
#define AST_OPTION_TDD   2
 
#define AST_OPTION_TONE_VERIFY   1
 
#define AST_OPTION_TXGAIN   5
 

Enumerations

enum  { AST_FRFLAG_HAS_TIMING_INFO = (1 << 0), AST_FRFLAG_REQUEUED = (1 << 1), AST_FRFLAG_HAS_SEQUENCE_NUMBER = (1 << 2) }
 
enum  ast_control_frame_type {
  AST_CONTROL_HANGUP = 1, AST_CONTROL_RING = 2, AST_CONTROL_RINGING = 3, AST_CONTROL_ANSWER = 4,
  AST_CONTROL_BUSY = 5, AST_CONTROL_TAKEOFFHOOK = 6, AST_CONTROL_OFFHOOK = 7, AST_CONTROL_CONGESTION = 8,
  AST_CONTROL_FLASH = 9, AST_CONTROL_WINK = 10, AST_CONTROL_OPTION = 11, AST_CONTROL_RADIO_KEY = 12,
  AST_CONTROL_RADIO_UNKEY = 13, AST_CONTROL_PROGRESS = 14, AST_CONTROL_PROCEEDING = 15, AST_CONTROL_HOLD = 16,
  AST_CONTROL_UNHOLD = 17, AST_CONTROL_VIDUPDATE = 18, _XXX_AST_CONTROL_T38 = 19, AST_CONTROL_SRCUPDATE = 20,
  AST_CONTROL_TRANSFER = 21, AST_CONTROL_CONNECTED_LINE = 22, AST_CONTROL_REDIRECTING = 23, AST_CONTROL_T38_PARAMETERS = 24,
  AST_CONTROL_CC = 25, AST_CONTROL_SRCCHANGE = 26, AST_CONTROL_READ_ACTION = 27, AST_CONTROL_AOC = 28,
  AST_CONTROL_END_OF_Q = 29, AST_CONTROL_INCOMPLETE = 30, AST_CONTROL_MCID = 31, AST_CONTROL_UPDATE_RTP_PEER = 32,
  AST_CONTROL_PVT_CAUSE_CODE = 33, AST_CONTROL_MASQUERADE_NOTIFY = 34, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE = 35, AST_CONTROL_STREAM_TOPOLOGY_CHANGED = 36,
  AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED = 37, AST_CONTROL_STREAM_STOP = 1000, AST_CONTROL_STREAM_SUSPEND = 1001, AST_CONTROL_STREAM_RESTART = 1002,
  AST_CONTROL_STREAM_REVERSE = 1003, AST_CONTROL_STREAM_FORWARD = 1004, AST_CONTROL_RECORD_CANCEL = 1100, AST_CONTROL_RECORD_STOP = 1101,
  AST_CONTROL_RECORD_SUSPEND = 1102, AST_CONTROL_RECORD_MUTE = 1103
}
 Internal control frame subtype field values. More...
 
enum  ast_control_t38 {
  AST_T38_REQUEST_NEGOTIATE = 1, AST_T38_REQUEST_TERMINATE, AST_T38_NEGOTIATED, AST_T38_TERMINATED,
  AST_T38_REFUSED, AST_T38_REQUEST_PARMS
}
 
enum  ast_control_t38_rate {
  AST_T38_RATE_2400 = 1, AST_T38_RATE_4800, AST_T38_RATE_7200, AST_T38_RATE_9600,
  AST_T38_RATE_12000, AST_T38_RATE_14400 = 0
}
 
enum  ast_control_t38_rate_management { AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF = 0, AST_T38_RATE_MANAGEMENT_LOCAL_TCF }
 
enum  ast_control_transfer { AST_TRANSFER_SUCCESS = 0, AST_TRANSFER_FAILED }
 
enum  ast_frame_read_action { AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO, AST_FRAME_READ_ACTION_SEND_TEXT, AST_FRAME_READ_ACTION_SEND_TEXT_DATA }
 Actions to indicate to, and be handled on channel read. More...
 
enum  ast_frame_type {
  AST_FRAME_DTMF_END = 1, AST_FRAME_VOICE, AST_FRAME_VIDEO, AST_FRAME_CONTROL,
  AST_FRAME_NULL, AST_FRAME_IAX, AST_FRAME_TEXT, AST_FRAME_IMAGE,
  AST_FRAME_HTML, AST_FRAME_CNG, AST_FRAME_MODEM, AST_FRAME_DTMF_BEGIN,
  AST_FRAME_BRIDGE_ACTION, AST_FRAME_BRIDGE_ACTION_SYNC, AST_FRAME_RTCP, AST_FRAME_TEXT_DATA
}
 Frame types. More...
 

Functions

struct ast_frame__ast_frdup (const struct ast_frame *fr, const char *file, int line, const char *func)
 
struct ast_frame__ast_frisolate (struct ast_frame *fr, const char *file, int line, const char *func)
 'isolates' a frame by duplicating non-malloc'ed components (header, src, data). On return all components are malloc'ed
 
int ast_frame_adjust_volume (struct ast_frame *f, int adjustment)
 Adjusts the volume of the audio samples contained in a frame. More...
 
int ast_frame_adjust_volume_float (struct ast_frame *f, float adjustment)
 Adjusts the volume of the audio samples contained in a frame. More...
 
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.
 
void ast_frame_dtor (struct ast_frame *frame)
 NULL-safe wrapper for ast_frfree, good for RAII_VAR. More...
 
void ast_frame_dump (const char *name, struct ast_frame *f, char *prefix)
 
struct ast_frameast_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.
 
void ast_frame_free (struct ast_frame *frame, int cache)
 Frees a frame or list of frames. More...
 
int ast_frame_slinear_sum (struct ast_frame *f1, struct ast_frame *f2)
 Sums two frames of audio samples. More...
 
char * ast_frame_subclass2str (struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen)
 Copy the discription of a frame's subclass into the provided string. More...
 
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. More...
 
void ast_swapcopy_samples (void *dst, const void *src, int samples)
 

Variables

struct ast_frame ast_null_frame
 

Detailed Description

Asterisk internal frame definitions.

Definition in file include/asterisk/frame.h.

Macro Definition Documentation

#define AST_FRAME_SET_BUFFER (   fr,
  _base,
  _ofs,
  _datalen 
)
Value:
{ \
(fr)->data.ptr = (char *)_base + (_ofs); \
(fr)->offset = (_ofs); \
(fr)->datalen = (_datalen); \
}

Set the various field of a frame to point to a buffer. Typically you set the base address of the buffer, the offset as AST_FRIENDLY_OFFSET, and the datalen as the amount of bytes queued. The remaining things (to be done manually) is set the number of samples, which cannot be derived from the datalen unless you know the number of bits per sample.

Definition at line 208 of file include/asterisk/frame.h.

Referenced by ogg_speex_read(), ogg_vorbis_read(), spandsp_fax_gw_t30_gen(), and spandsp_fax_read().

#define ast_frdup (   fr)    __ast_frdup(fr, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Copies a frame.

Parameters
frframe to copy Duplicates a frame – should only rarely be used, typically frisolate is good enough
Returns
Returns a frame on success, NULL on error

Definition at line 590 of file include/asterisk/frame.h.

Referenced by ast_bridge_channel_queue_frame(), ast_bridge_queue_action(), ast_indicate_data(), ast_jb_put(), ast_rtp_read(), ast_rtp_write(), ast_slinfactory_feed(), multicast_rtp_write(), and t38_parameters_task_data_alloc().

#define AST_FRIENDLY_OFFSET   64

Offset into a frame's data buffer.

By providing some "empty" space prior to the actual data of an ast_frame, this gives any consumer of the frame ample space to prepend other necessary information without having to create a new buffer.

As an example, RTP can use the data from an ast_frame and simply prepend the RTP header information into the space provided by AST_FRIENDLY_OFFSET instead of having to create a new buffer with the necessary space allocated.

Definition at line 229 of file include/asterisk/frame.h.

Referenced by __ast_frisolate(), ast_prod(), ast_rtcp_interpret(), ast_rtcp_read(), ast_rtp_read(), newpvt(), ogg_speex_read(), ogg_vorbis_read(), sms_generate(), spandsp_fax_gw_t30_gen(), and spandsp_fax_read().

#define ast_frisolate (   fr)    __ast_frisolate(fr, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Makes a frame independent of any static storage.

Parameters
frframe to act upon Take a frame, and if it's not been malloc'd, make a malloc'd copy and if the data hasn't been malloced then make the data malloc'd. If you need to store frames, say for queueing, then you should call this function.
Returns
Returns a frame on success, NULL on error
Note
This function may modify the frame passed to it, so you must not assume the frame will be intact after the isolated frame has been produced. In other words, calling this function on a frame should be the last operation you do with that frame before freeing it (or exiting the block, if the frame is on the stack.)

Definition at line 582 of file include/asterisk/frame.h.

Referenced by __ast_answer(), ast_audiosocket_receive_frame(), ast_dsp_process(), ast_slinfactory_feed(), ast_trans_frameout(), ast_write_stream(), fax_gateway_framehook(), fax_gateway_request_t38(), lintospeex_frameout(), safe_sleep_conditional(), spandsp_fax_gw_t30_gen(), and spandsp_fax_read().

#define AST_HTML_BEGIN   4

Beginning frame

Definition at line 251 of file include/asterisk/frame.h.

Referenced by ast_frame_subclass2str().

#define AST_HTML_DATA   2

Data frame

Definition at line 249 of file include/asterisk/frame.h.

Referenced by ast_frame_subclass2str().

#define AST_HTML_END   8

End frame

Definition at line 253 of file include/asterisk/frame.h.

Referenced by ast_frame_subclass2str().

#define AST_HTML_LDCOMPLETE   16

Load is complete

Definition at line 255 of file include/asterisk/frame.h.

Referenced by ast_frame_subclass2str().

#define AST_HTML_LINKREJECT   20

Reject link request

Definition at line 263 of file include/asterisk/frame.h.

Referenced by ast_frame_subclass2str().

#define AST_HTML_LINKURL   18

Send URL, and track

Definition at line 259 of file include/asterisk/frame.h.

Referenced by ast_frame_subclass2str().

#define AST_HTML_NOSUPPORT   17

Peer is unable to support HTML

Definition at line 257 of file include/asterisk/frame.h.

Referenced by ast_frame_subclass2str().

#define AST_HTML_UNLINK   19

No more HTML linkage

Definition at line 261 of file include/asterisk/frame.h.

Referenced by ast_frame_subclass2str().

#define AST_HTML_URL   1

Sending a URL

Definition at line 247 of file include/asterisk/frame.h.

Referenced by ast_channel_sendurl(), and ast_frame_subclass2str().

#define AST_MALLOCD_DATA   (1 << 1)

Need the data be free'd?

Definition at line 235 of file include/asterisk/frame.h.

Referenced by __ast_frisolate(), ast_audiosocket_receive_frame(), ast_cc_build_frame(), and ast_sendtext_data().

#define AST_MALLOCD_HDR   (1 << 0)

Need the header be free'd?

Definition at line 233 of file include/asterisk/frame.h.

Referenced by __ast_frisolate(), and make_silence().

#define AST_MALLOCD_SRC   (1 << 2)

Need the source be free'd? (haha!)

Definition at line 237 of file include/asterisk/frame.h.

Referenced by __ast_frisolate().

#define AST_MODEM_T38   1
#define AST_MODEM_V150   2

V.150 Modem-over-IP

Definition at line 243 of file include/asterisk/frame.h.

Referenced by ast_frame_subclass2str().

#define AST_OPTION_AUDIO_MODE   4

Set (or clear) Audio (Not-Clear) Mode Option data is a single signed char value 0 or 1

Definition at line 443 of file include/asterisk/frame.h.

Referenced by dahdi_setoption().

#define AST_OPTION_CC_AGENT_TYPE   17

Get the CC agent type from the channel (Read only) Option data is a character buffer of suitable length

Definition at line 515 of file include/asterisk/frame.h.

Referenced by ast_channel_get_cc_agent_type().

#define AST_OPTION_CHANNEL_WRITE   9

Handle channel write data If a channel needs to process the data from a func_channel write operation after func_channel_write executes, it can define the setoption callback and process this option. A pointer to an ast_chan_write_info_t will be passed.

Note
This option should never be passed over the network.

Definition at line 479 of file include/asterisk/frame.h.

Referenced by ast_unreal_setoption().

#define AST_OPTION_DEVICE_NAME   16

Get the device name from the channel (Read only) Option data is a character buffer of suitable length

Definition at line 511 of file include/asterisk/frame.h.

Referenced by ast_channel_get_device_name().

#define AST_OPTION_DIGIT_DETECT   14

Get or set the digit detection state of the channel Option data is a single signed char value 0 or 1

Definition at line 503 of file include/asterisk/frame.h.

Referenced by dahdi_setoption().

#define AST_OPTION_ECHOCAN   8

Explicitly enable or disable echo cancelation for the given channel Option data is a single signed char value 0 or 1

Note
This option appears to be unused in the code. It is handled, but never set or queried. (chan_dahdi does allow setting via CHANNEL(echocan_mode), but this uses the func_write callback, not the setoption callback. If another channel driver added echocan support, it might make sense to move this to the setoption callback and then actually use this option.)

Definition at line 471 of file include/asterisk/frame.h.

Referenced by dahdi_setoption().

#define AST_OPTION_FAX_DETECT   15

Get or set the fax tone detection state of the channel Option data is a single signed char value 0 or 1

Definition at line 507 of file include/asterisk/frame.h.

Referenced by dahdi_setoption().

#define AST_OPTION_FORMAT_READ   11

Request that the channel driver deliver frames in a specific format Option data is a format_t

Definition at line 489 of file include/asterisk/frame.h.

#define AST_OPTION_FORMAT_WRITE   12

Request that the channel driver be prepared to accept frames in a specific format Option data is a format_t

Definition at line 493 of file include/asterisk/frame.h.

#define AST_OPTION_MAKE_COMPATIBLE   13

Request that the channel driver make two channels of the same tech type compatible if possible Option data is an ast_channel

Note
This option should never be passed over the network

Definition at line 499 of file include/asterisk/frame.h.

#define AST_OPTION_RELAXDTMF   3

Relax the parameters for DTMF reception (mainly for radio use) Option data is a single signed char value 0 or 1

Definition at line 439 of file include/asterisk/frame.h.

Referenced by dahdi_setoption().

#define AST_OPTION_RXGAIN   6

Set channel receive gain Option data is a single signed char representing number of decibels (dB) to set gain to (on top of any gain specified in channel driver)

Definition at line 453 of file include/asterisk/frame.h.

Referenced by dahdi_setoption(), and vm_forwardoptions().

#define AST_OPTION_SECURE_SIGNALING   18

Get or set the security options on a channel Option data is an integer value of 0 or 1

Definition at line 519 of file include/asterisk/frame.h.

#define AST_OPTION_TDD   2

Put a compatible channel into TDD (TTY for the hearing-impaired) mode Option data is a single signed char value 0 or 1

Definition at line 435 of file include/asterisk/frame.h.

Referenced by dahdi_setoption().

#define AST_OPTION_TONE_VERIFY   1

Verify touchtones by muting audio transmission (and reception) and verify the tone is still present Option data is a single signed char value 0 or 1

Definition at line 431 of file include/asterisk/frame.h.

Referenced by dahdi_setoption().

#define AST_OPTION_TXGAIN   5

Set channel transmit gain Option data is a single signed char representing number of decibels (dB) to set gain to (on top of any gain specified in channel driver)

Definition at line 448 of file include/asterisk/frame.h.

Referenced by dahdi_setoption().

Enumeration Type Documentation

anonymous enum
Enumerator
AST_FRFLAG_HAS_TIMING_INFO 

This frame contains valid timing information

AST_FRFLAG_REQUEUED 

This frame has been requeued

AST_FRFLAG_HAS_SEQUENCE_NUMBER 

This frame contains a valid sequence number

Definition at line 141 of file include/asterisk/frame.h.

141  {
142  /*! This frame contains valid timing information */
143  AST_FRFLAG_HAS_TIMING_INFO = (1 << 0),
144  /*! This frame has been requeued */
145  AST_FRFLAG_REQUEUED = (1 << 1),
146  /*! This frame contains a valid sequence number */
148 };

Internal control frame subtype field values.

Warning
IAX2 sends these values out over the wire. To prevent future incompatibilities, pick the next value in the enum from whatever is on the current trunk. If you lose the merge race you need to fix the previous branches to match what is on trunk. In addition you need to change chan_iax2 to explicitly allow the control frame over the wire if it makes sense for the frame to be passed to another Asterisk instance.
Enumerator
AST_CONTROL_HANGUP 

Other end has hungup

AST_CONTROL_RING 

Local ring

AST_CONTROL_RINGING 

Remote end is ringing

AST_CONTROL_ANSWER 

Remote end has answered

AST_CONTROL_BUSY 

Remote end is busy

AST_CONTROL_TAKEOFFHOOK 

Make it go off hook

AST_CONTROL_OFFHOOK 

Line is off hook

AST_CONTROL_CONGESTION 

Congestion (circuits busy)

AST_CONTROL_FLASH 

Flash hook

AST_CONTROL_WINK 

Wink

AST_CONTROL_OPTION 

Set a low-level option

AST_CONTROL_RADIO_KEY 

Key Radio

AST_CONTROL_RADIO_UNKEY 

Un-Key Radio

AST_CONTROL_PROGRESS 

Indicate PROGRESS

AST_CONTROL_PROCEEDING 

Indicate CALL PROCEEDING

AST_CONTROL_HOLD 

Indicate call is placed on hold

AST_CONTROL_UNHOLD 

Indicate call is left from hold

AST_CONTROL_VIDUPDATE 

Indicate video frame update

_XXX_AST_CONTROL_T38 

T38 state change request/notification

Deprecated:
This is no longer supported. Use AST_CONTROL_T38_PARAMETERS instead.
AST_CONTROL_SRCUPDATE 

Indicate source of media has changed

AST_CONTROL_TRANSFER 

Indicate status of a transfer request

AST_CONTROL_CONNECTED_LINE 

Indicate connected line has changed

AST_CONTROL_REDIRECTING 

Indicate redirecting id has changed

AST_CONTROL_T38_PARAMETERS 

T38 state change request/notification with parameters

AST_CONTROL_CC 

Indication that Call completion service is possible

AST_CONTROL_SRCCHANGE 

Media source has changed and requires a new RTP SSRC

AST_CONTROL_READ_ACTION 

Tell ast_read to take a specific action

AST_CONTROL_AOC 

Advice of Charge with encoded generic AOC payload

AST_CONTROL_END_OF_Q 

Indicate that this position was the end of the channel queue for a softhangup.

AST_CONTROL_INCOMPLETE 

Indication that the extension dialed is incomplete

AST_CONTROL_MCID 

Indicate that the caller is being malicious.

AST_CONTROL_UPDATE_RTP_PEER 

Interrupt the bridge and have it update the peer

AST_CONTROL_PVT_CAUSE_CODE 

Contains an update to the protocol-specific cause-code stored for branching dials

AST_CONTROL_MASQUERADE_NOTIFY 

A masquerade is about to begin/end. (Never sent as a frame but directly with ast_indicate_data().)

AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE 

Channel indication that a stream topology change has been requested

AST_CONTROL_STREAM_TOPOLOGY_CHANGED 

Channel indication that a stream topology change has occurred

AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED 

Channel indication that one of the source streams has changed its source

AST_CONTROL_STREAM_STOP 

Indicate to a channel in playback to stop the stream

AST_CONTROL_STREAM_SUSPEND 

Indicate to a channel in playback to suspend the stream

AST_CONTROL_STREAM_RESTART 

Indicate to a channel in playback to restart the stream

AST_CONTROL_STREAM_REVERSE 

Indicate to a channel in playback to rewind

AST_CONTROL_STREAM_FORWARD 

Indicate to a channel in playback to fast forward

AST_CONTROL_RECORD_CANCEL 

Indicated to a channel in record to stop recording and discard the file

AST_CONTROL_RECORD_STOP 

Indicated to a channel in record to stop recording

AST_CONTROL_RECORD_SUSPEND 

Indicated to a channel in record to suspend/unsuspend recording

AST_CONTROL_RECORD_MUTE 

Indicated to a channel in record to mute/unmute (i.e. write silence) recording

Definition at line 277 of file include/asterisk/frame.h.

277  {
278  AST_CONTROL_HANGUP = 1, /*!< Other end has hungup */
279  AST_CONTROL_RING = 2, /*!< Local ring */
280  AST_CONTROL_RINGING = 3, /*!< Remote end is ringing */
281  AST_CONTROL_ANSWER = 4, /*!< Remote end has answered */
282  AST_CONTROL_BUSY = 5, /*!< Remote end is busy */
283  AST_CONTROL_TAKEOFFHOOK = 6, /*!< Make it go off hook */
284  AST_CONTROL_OFFHOOK = 7, /*!< Line is off hook */
285  AST_CONTROL_CONGESTION = 8, /*!< Congestion (circuits busy) */
286  AST_CONTROL_FLASH = 9, /*!< Flash hook */
287  AST_CONTROL_WINK = 10, /*!< Wink */
288  AST_CONTROL_OPTION = 11, /*!< Set a low-level option */
289  AST_CONTROL_RADIO_KEY = 12, /*!< Key Radio */
290  AST_CONTROL_RADIO_UNKEY = 13, /*!< Un-Key Radio */
291  AST_CONTROL_PROGRESS = 14, /*!< Indicate PROGRESS */
292  AST_CONTROL_PROCEEDING = 15, /*!< Indicate CALL PROCEEDING */
293  AST_CONTROL_HOLD = 16, /*!< Indicate call is placed on hold */
294  AST_CONTROL_UNHOLD = 17, /*!< Indicate call is left from hold */
295  AST_CONTROL_VIDUPDATE = 18, /*!< Indicate video frame update */
296  _XXX_AST_CONTROL_T38 = 19, /*!< T38 state change request/notification \deprecated This is no longer supported. Use AST_CONTROL_T38_PARAMETERS instead. */
297  AST_CONTROL_SRCUPDATE = 20, /*!< Indicate source of media has changed */
298  AST_CONTROL_TRANSFER = 21, /*!< Indicate status of a transfer request */
299  AST_CONTROL_CONNECTED_LINE = 22,/*!< Indicate connected line has changed */
300  AST_CONTROL_REDIRECTING = 23, /*!< Indicate redirecting id has changed */
301  AST_CONTROL_T38_PARAMETERS = 24,/*!< T38 state change request/notification with parameters */
302  AST_CONTROL_CC = 25, /*!< Indication that Call completion service is possible */
303  AST_CONTROL_SRCCHANGE = 26, /*!< Media source has changed and requires a new RTP SSRC */
304  AST_CONTROL_READ_ACTION = 27, /*!< Tell ast_read to take a specific action */
305  AST_CONTROL_AOC = 28, /*!< Advice of Charge with encoded generic AOC payload */
306  AST_CONTROL_END_OF_Q = 29, /*!< Indicate that this position was the end of the channel queue for a softhangup. */
307  AST_CONTROL_INCOMPLETE = 30, /*!< Indication that the extension dialed is incomplete */
308  AST_CONTROL_MCID = 31, /*!< Indicate that the caller is being malicious. */
309  AST_CONTROL_UPDATE_RTP_PEER = 32, /*!< Interrupt the bridge and have it update the peer */
310  AST_CONTROL_PVT_CAUSE_CODE = 33, /*!< Contains an update to the protocol-specific cause-code stored for branching dials */
311  AST_CONTROL_MASQUERADE_NOTIFY = 34, /*!< A masquerade is about to begin/end. (Never sent as a frame but directly with ast_indicate_data().) */
312  AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE = 35, /*!< Channel indication that a stream topology change has been requested */
313  AST_CONTROL_STREAM_TOPOLOGY_CHANGED = 36, /*!< Channel indication that a stream topology change has occurred */
314  AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED = 37, /*!< Channel indication that one of the source streams has changed its source */
315 
316  /*
317  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
318  *
319  * IAX2 sends these values out over the wire. To prevent future
320  * incompatibilities, pick the next value in the enum from whatever
321  * is on the current trunk. If you lose the merge race you need to
322  * fix the previous branches to match what is on trunk. In addition
323  * you need to change chan_iax2 to explicitly allow the control
324  * frame over the wire if it makes sense for the frame to be passed
325  * to another Asterisk instance.
326  *
327  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
328  */
329 
330  /* Control frames used to manipulate a stream on a channel. The values for these
331  * must be greater than the allowed value for a 8-bit char, so that they avoid
332  * conflicts with DTMF values. */
333  AST_CONTROL_STREAM_STOP = 1000, /*!< Indicate to a channel in playback to stop the stream */
334  AST_CONTROL_STREAM_SUSPEND = 1001, /*!< Indicate to a channel in playback to suspend the stream */
335  AST_CONTROL_STREAM_RESTART = 1002, /*!< Indicate to a channel in playback to restart the stream */
336  AST_CONTROL_STREAM_REVERSE = 1003, /*!< Indicate to a channel in playback to rewind */
337  AST_CONTROL_STREAM_FORWARD = 1004, /*!< Indicate to a channel in playback to fast forward */
338  /* Control frames to manipulate recording on a channel. */
339  AST_CONTROL_RECORD_CANCEL = 1100, /*!< Indicated to a channel in record to stop recording and discard the file */
340  AST_CONTROL_RECORD_STOP = 1101, /*!< Indicated to a channel in record to stop recording */
341  AST_CONTROL_RECORD_SUSPEND = 1102, /*!< Indicated to a channel in record to suspend/unsuspend recording */
342  AST_CONTROL_RECORD_MUTE = 1103, /*!< Indicated to a channel in record to mute/unmute (i.e. write silence) recording */
343 };
Enumerator
AST_T38_REQUEST_NEGOTIATE 

Request T38 on a channel (voice to fax)

AST_T38_REQUEST_TERMINATE 

Terminate T38 on a channel (fax to voice)

AST_T38_NEGOTIATED 

T38 negotiated (fax mode)

AST_T38_TERMINATED 

T38 terminated (back to voice)

AST_T38_REFUSED 

T38 refused for some reason (usually rejected by remote end)

AST_T38_REQUEST_PARMS 

request far end T.38 parameters for a channel in 'negotiating' state

Definition at line 370 of file include/asterisk/frame.h.

370  {
371  AST_T38_REQUEST_NEGOTIATE = 1, /*!< Request T38 on a channel (voice to fax) */
372  AST_T38_REQUEST_TERMINATE, /*!< Terminate T38 on a channel (fax to voice) */
373  AST_T38_NEGOTIATED, /*!< T38 negotiated (fax mode) */
374  AST_T38_TERMINATED, /*!< T38 terminated (back to voice) */
375  AST_T38_REFUSED, /*!< T38 refused for some reason (usually rejected by remote end) */
376  AST_T38_REQUEST_PARMS, /*!< request far end T.38 parameters for a channel in 'negotiating' state */
377 };
Enumerator
AST_TRANSFER_SUCCESS 

Transfer request on the channel worked

AST_TRANSFER_FAILED 

Transfer request on the channel failed

Definition at line 408 of file include/asterisk/frame.h.

408  {
409  AST_TRANSFER_SUCCESS = 0, /*!< Transfer request on the channel worked */
410  AST_TRANSFER_FAILED, /*!< Transfer request on the channel failed */
411 };

Actions to indicate to, and be handled on channel read.

The subtype to specify for an AST_CONTROL_READ_ACTION frame. These frames are then to be enacted on within a channel's read thread.

Definition at line 351 of file include/asterisk/frame.h.

351  {
352  AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO,
353  AST_FRAME_READ_ACTION_SEND_TEXT,
354  AST_FRAME_READ_ACTION_SEND_TEXT_DATA,
355 };

Frame types.

Note
It is important that the values of each frame type are never changed, because it will break backwards compatability with older versions. This is because these constants are transmitted directly over IAX2.
Enumerator
AST_FRAME_DTMF_END 

DTMF end event, subclass is the digit

AST_FRAME_VOICE 

Voice data, subclass is AST_FORMAT_*

AST_FRAME_VIDEO 

Video frame, maybe?? :)

AST_FRAME_CONTROL 

A control frame, subclass is AST_CONTROL_*

AST_FRAME_NULL 

An empty, useless frame

AST_FRAME_IAX 

Inter Asterisk Exchange private frame type

AST_FRAME_TEXT 

Text messages. The character data may not be zero-terminated, so care should be taken when passing it to functions that expect a zero-terminated string. The frame's datalen member should be used as it indicates the actual number of bytes available.

AST_FRAME_IMAGE 

Image Frames

AST_FRAME_HTML 

HTML Frame

AST_FRAME_CNG 

Comfort Noise frame (subclass is level of CNG in -dBov), body may include zero or more 8-bit quantization coefficients

AST_FRAME_MODEM 

Modem-over-IP data streams

AST_FRAME_DTMF_BEGIN 

DTMF begin event, subclass is the digit

AST_FRAME_BRIDGE_ACTION 

Internal bridge module action.

AST_FRAME_BRIDGE_ACTION_SYNC 

Internal synchronous bridge module action. Synchronous bridge actions may be queued onto bridge channels, but they absolutely must not ever be written directly into bridges.

AST_FRAME_RTCP 

RTCP feedback (the subclass will contain the payload type)

AST_FRAME_TEXT_DATA 

Text message in an ast_msg_data structure

Definition at line 97 of file include/asterisk/frame.h.

97  {
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. The character data may not be zero-terminated, so
111  * care should be taken when passing it to functions that expect a
112  * zero-terminated string. The frame's datalen member should be used
113  * as it indicates the actual number of bytes available. */
115  /*! Image Frames */
117  /*! HTML Frame */
119  /*! Comfort Noise frame (subclass is level of CNG in -dBov),
120  body may include zero or more 8-bit quantization coefficients */
122  /*! Modem-over-IP data streams */
124  /*! DTMF begin event, subclass is the digit */
126  /*! Internal bridge module action. */
128  /*! Internal synchronous bridge module action.
129  * Synchronous bridge actions may be queued onto bridge
130  * channels, but they absolutely must not ever be written
131  * directly into bridges.
132  */
134  /*! RTCP feedback (the subclass will contain the payload type) */
136  /*! Text message in an ast_msg_data structure */
138 };

Function Documentation

int ast_frame_adjust_volume ( struct ast_frame f,
int  adjustment 
)

Adjusts the volume of the audio samples contained in a frame.

Parameters
fThe frame containing the samples (must be AST_FRAME_VOICE and AST_FORMAT_SLINEAR)
adjustmentThe number of dB to adjust up or down.
Returns
0 for success, non-zero for an error

Definition at line 787 of file main/frame.c.

References ast_format_cache_is_slinear(), AST_FRAME_VOICE, ast_frame::data, ast_frame_subclass::format, ast_frame::frametype, ast_frame::samples, and ast_frame::subclass.

Referenced by audiohook_volume_callback().

788 {
789  int count;
790  short *fdata = f->data.ptr;
791  short adjust_value = abs(adjustment);
792 
794  return -1;
795  }
796 
797  if (!adjustment) {
798  return 0;
799  }
800 
801  for (count = 0; count < f->samples; count++) {
802  if (adjustment > 0) {
803  ast_slinear_saturated_multiply(&fdata[count], &adjust_value);
804  } else if (adjustment < 0) {
805  ast_slinear_saturated_divide(&fdata[count], &adjust_value);
806  }
807  }
808 
809  return 0;
810 }
struct ast_frame_subclass subclass
int ast_format_cache_is_slinear(struct ast_format *format)
Determines if a format is one of the cached slin formats.
Definition: format_cache.c:534
union ast_frame::@224 data
enum ast_frame_type frametype
struct ast_format * format
int ast_frame_adjust_volume_float ( struct ast_frame f,
float  adjustment 
)

Adjusts the volume of the audio samples contained in a frame.

Parameters
fThe frame containing the samples (must be AST_FRAME_VOICE and AST_FORMAT_SLINEAR)
adjustmentThe number of dB to adjust up or down.
Returns
0 for success, non-zero for an error

Definition at line 812 of file main/frame.c.

References ast_format_cache_is_slinear(), AST_FRAME_VOICE, ast_frame::data, ast_frame_subclass::format, ast_frame::frametype, ast_frame::samples, and ast_frame::subclass.

813 {
814  int count;
815  short *fdata = f->data.ptr;
816  float adjust_value = fabs(adjustment);
817 
819  return -1;
820  }
821 
822  if (!adjustment) {
823  return 0;
824  }
825 
826  for (count = 0; count < f->samples; count++) {
827  if (adjustment > 0) {
828  ast_slinear_saturated_multiply_float(&fdata[count], &adjust_value);
829  } else if (adjustment < 0) {
830  ast_slinear_saturated_divide_float(&fdata[count], &adjust_value);
831  }
832  }
833 
834  return 0;
835 }
struct ast_frame_subclass subclass
int ast_format_cache_is_slinear(struct ast_format *format)
Determines if a format is one of the cached slin formats.
Definition: format_cache.c:534
union ast_frame::@224 data
enum ast_frame_type frametype
struct ast_format * format
void ast_frame_dtor ( struct ast_frame frame)

NULL-safe wrapper for ast_frfree, good for RAII_VAR.

Parameters
frameFrame to free, or head of list to free.

Definition at line 187 of file main/frame.c.

Referenced by __ast_play_and_record(), and stasis_app_exec().

188 {
189  ast_frfree(f);
190 }
void ast_frame_dump ( const char *  name,
struct ast_frame f,
char *  prefix 
)

Dump a frame for debugging purposes

Definition at line 731 of file main/frame.c.

References AST_FRAME_RTCP, ast_frame_subclass2str(), ast_frame_type2str(), AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::subclass, and term_color().

Referenced by __ast_read(), and ast_write_stream().

732 {
733  const char noname[] = "unknown";
734  char ftype[40] = "Unknown Frametype";
735  char cft[80];
736  char subclass[40] = "Unknown Subclass";
737  char csub[80];
738  char moreinfo[40] = "";
739  char cn[60];
740  char cp[40];
741  char cmn[40];
742 
743  if (!name) {
744  name = noname;
745  }
746 
747  if (!f) {
748  ast_verb(-1, "%s [ %s (NULL) ] [%s]\n",
749  term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
750  term_color(cft, "HANGUP", COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
751  term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
752  return;
753  }
754  /* XXX We should probably print one each of voice and video when the format changes XXX */
755  if (f->frametype == AST_FRAME_VOICE) {
756  return;
757  }
758  if (f->frametype == AST_FRAME_VIDEO) {
759  return;
760  }
761  if (f->frametype == AST_FRAME_RTCP) {
762  return;
763  }
764 
765  ast_frame_type2str(f->frametype, ftype, sizeof(ftype));
766  ast_frame_subclass2str(f, subclass, sizeof(subclass), moreinfo, sizeof(moreinfo));
767 
768  if (!ast_strlen_zero(moreinfo))
769  ast_verb(-1, "%s [ TYPE: %s (%u) SUBCLASS: %s (%d) '%s' ] [%s]\n",
770  term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
771  term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
772  f->frametype,
773  term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
774  f->subclass.integer,
775  term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK, sizeof(cmn)),
776  term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
777  else
778  ast_verb(-1, "%s [ TYPE: %s (%u) SUBCLASS: %s (%d) ] [%s]\n",
779  term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
780  term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
781  f->frametype,
782  term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
783  f->subclass.integer,
784  term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
785 }
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:671
char * ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen)
Copy the discription of a frame's subclass into the provided string.
Definition: main/frame.c:406
struct ast_frame_subclass subclass
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
Colorize a specified string by adding terminal color codes.
Definition: term.c:235
enum ast_frame_type frametype
void ast_frame_free ( struct ast_frame frame,
int  cache 
)

Frees a frame or list of frames.

Parameters
frameFrame to free, or head of list to free
cacheWhether to consider this frame for frame caching

Definition at line 176 of file main/frame.c.

References AST_LIST_NEXT.

Referenced by __ast_frisolate(), and ast_rtp_read().

177 {
178  struct ast_frame *next;
179 
180  while (frame) {
181  next = AST_LIST_NEXT(frame, frame_list);
182  __frame_free(frame, cache);
183  frame = next;
184  }
185 }
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:439
Data structure associated with a single frame of data.
static struct sorcery_test_caching cache
Global scope caching structure for testing.
Definition: test_sorcery.c:178
int ast_frame_slinear_sum ( struct ast_frame f1,
struct ast_frame f2 
)

Sums two frames of audio samples.

Parameters
f1The first frame (which will contain the result)
f2The second frame
Returns
0 for success, non-zero for an error

The frames must be AST_FRAME_VOICE and must contain AST_FORMAT_SLINEAR samples, and must contain the same number of samples.

Definition at line 837 of file main/frame.c.

References ast_format_cmp(), AST_FORMAT_CMP_NOT_EQUAL, ast_format_slin, AST_FRAME_VOICE, ast_frame::data, ast_frame_subclass::format, ast_frame::frametype, ast_frame::samples, and ast_frame::subclass.

838 {
839  int count;
840  short *data1, *data2;
841 
843  return -1;
844 
846  return -1;
847 
848  if (f1->samples != f2->samples)
849  return -1;
850 
851  for (count = 0, data1 = f1->data.ptr, data2 = f2->data.ptr;
852  count < f1->samples;
853  count++, data1++, data2++)
854  ast_slinear_saturated_add(data1, data2);
855 
856  return 0;
857 }
struct ast_frame_subclass subclass
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
union ast_frame::@224 data
enum ast_frame_type frametype
struct ast_format * format
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
char* ast_frame_subclass2str ( struct ast_frame f,
char *  subclass,
size_t  slen,
char *  moreinfo,
size_t  mlen 
)

Copy the discription of a frame's subclass into the provided string.

Parameters
fThe frame to get the information from
subclassBuffer to fill with subclass information
slenLength of subclass buffer
moreinfoBuffer to fill with additional information
mlenLength of moreinfo buffer
Returns
Pointer to subclass
Since
11

Definition at line 406 of file main/frame.c.

References AST_CONTROL_ANSWER, AST_CONTROL_AOC, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_END_OF_Q, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_MASQUERADE_NOTIFY, AST_CONTROL_MCID, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_PVT_CAUSE_CODE, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_READ_ACTION, AST_CONTROL_RECORD_CANCEL, AST_CONTROL_RECORD_MUTE, AST_CONTROL_RECORD_STOP, AST_CONTROL_RECORD_SUSPEND, AST_CONTROL_REDIRECTING, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_STREAM_FORWARD, AST_CONTROL_STREAM_RESTART, AST_CONTROL_STREAM_REVERSE, AST_CONTROL_STREAM_STOP, AST_CONTROL_STREAM_SUSPEND, AST_CONTROL_STREAM_TOPOLOGY_CHANGED, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_TRANSFER, AST_CONTROL_UNHOLD, AST_CONTROL_UPDATE_RTP_PEER, AST_CONTROL_VIDUPDATE, AST_CONTROL_WINK, ast_copy_string(), ast_format_get_name(), AST_FRAME_BRIDGE_ACTION, AST_FRAME_BRIDGE_ACTION_SYNC, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_RTCP, AST_FRAME_TEXT, AST_HTML_BEGIN, AST_HTML_DATA, AST_HTML_END, AST_HTML_LDCOMPLETE, AST_HTML_LINKREJECT, AST_HTML_LINKURL, AST_HTML_NOSUPPORT, AST_HTML_UNLINK, AST_HTML_URL, AST_MODEM_T38, AST_MODEM_V150, AST_T38_NEGOTIATED, AST_T38_REFUSED, AST_T38_REQUEST_NEGOTIATE, AST_T38_REQUEST_TERMINATE, AST_T38_TERMINATED, ast_frame::data, ast_frame::datalen, ast_frame_subclass::format, ast_frame::frametype, ast_frame_subclass::integer, ast_control_t38_parameters::request_response, and ast_frame::subclass.

Referenced by ast_frame_dump(), and chan_pjsip_indicate().

407 {
408  switch(f->frametype) {
410  if (slen > 1) {
411  subclass[0] = f->subclass.integer;
412  subclass[1] = '\0';
413  }
414  break;
415  case AST_FRAME_DTMF_END:
416  if (slen > 1) {
417  subclass[0] = f->subclass.integer;
418  subclass[1] = '\0';
419  }
420  break;
421  case AST_FRAME_CONTROL:
422  switch (f->subclass.integer) {
423  case AST_CONTROL_HANGUP:
424  ast_copy_string(subclass, "Hangup", slen);
425  break;
426  case AST_CONTROL_RING:
427  ast_copy_string(subclass, "Ring", slen);
428  break;
429  case AST_CONTROL_RINGING:
430  ast_copy_string(subclass, "Ringing", slen);
431  break;
432  case AST_CONTROL_ANSWER:
433  ast_copy_string(subclass, "Answer", slen);
434  break;
435  case AST_CONTROL_BUSY:
436  ast_copy_string(subclass, "Busy", slen);
437  break;
439  ast_copy_string(subclass, "Take Off Hook", slen);
440  break;
441  case AST_CONTROL_OFFHOOK:
442  ast_copy_string(subclass, "Line Off Hook", slen);
443  break;
445  ast_copy_string(subclass, "Congestion", slen);
446  break;
447  case AST_CONTROL_FLASH:
448  ast_copy_string(subclass, "Flash", slen);
449  break;
450  case AST_CONTROL_WINK:
451  ast_copy_string(subclass, "Wink", slen);
452  break;
453  case AST_CONTROL_OPTION:
454  ast_copy_string(subclass, "Option", slen);
455  break;
457  ast_copy_string(subclass, "Key Radio", slen);
458  break;
460  ast_copy_string(subclass, "Unkey Radio", slen);
461  break;
463  ast_copy_string(subclass, "Progress", slen);
464  break;
466  ast_copy_string(subclass, "Proceeding", slen);
467  break;
468  case AST_CONTROL_HOLD:
469  ast_copy_string(subclass, "Hold", slen);
470  break;
471  case AST_CONTROL_UNHOLD:
472  ast_copy_string(subclass, "Unhold", slen);
473  break;
475  ast_copy_string(subclass, "Video Update", slen);
476  break;
478  char *message = "Unknown";
479  if (f->datalen != sizeof(struct ast_control_t38_parameters)) {
480  message = "Invalid";
481  } else {
482  struct ast_control_t38_parameters *parameters = f->data.ptr;
483  enum ast_control_t38 state = parameters->request_response;
484  if (state == AST_T38_REQUEST_NEGOTIATE)
485  message = "Negotiation Requested";
486  else if (state == AST_T38_REQUEST_TERMINATE)
487  message = "Negotiation Request Terminated";
488  else if (state == AST_T38_NEGOTIATED)
489  message = "Negotiated";
490  else if (state == AST_T38_TERMINATED)
491  message = "Terminated";
492  else if (state == AST_T38_REFUSED)
493  message = "Refused";
494  }
495  snprintf(subclass, slen, "T38_Parameters/%s", message);
496  break;
497  }
498 
500  ast_copy_string(subclass, "Stop stream", slen);
501  break;
503  ast_copy_string(subclass, "Suspend stream", slen);
504  break;
506  ast_copy_string(subclass, "Restart stream", slen);
507  break;
509  ast_copy_string(subclass, "Reverse stream", slen);
510  break;
512  ast_copy_string(subclass, "Forward stream", slen);
513  break;
515  ast_copy_string(subclass, "Cancel stream", slen);
516  break;
518  ast_copy_string(subclass, "Record stop", slen);
519  break;
521  ast_copy_string(subclass, "Record suspend", slen);
522  break;
524  ast_copy_string(subclass, "Record mute", slen);
525  break;
527  ast_copy_string(subclass, "Media source update", slen);
528  break;
530  ast_copy_string(subclass, "Transfer", slen);
531  break;
533  ast_copy_string(subclass, "Connected line update", slen);
534  break;
536  ast_copy_string(subclass, "Redirect", slen);
537  break;
538  case AST_CONTROL_CC:
539  ast_copy_string(subclass, "CC", slen);
540  break;
542  ast_copy_string(subclass, "Media SSRC change", slen);
543  break;
545  ast_copy_string(subclass, "Read action", slen);
546  break;
547  case AST_CONTROL_AOC:
548  ast_copy_string(subclass, "AOC", slen);
549  break;
551  ast_copy_string(subclass, "Endof Q", slen);
552  break;
554  ast_copy_string(subclass, "Incomplete", slen);
555  break;
556  case AST_CONTROL_MCID:
557  ast_copy_string(subclass, "MCID", slen);
558  break;
560  ast_copy_string(subclass, "Update RTP peer", slen);
561  break;
563  ast_copy_string(subclass, "Private Cause Code", slen);
564  break;
566  ast_copy_string(subclass, "Masquerade notify", slen);
567  break;
569  ast_copy_string(subclass, "Stream topology request change", slen);
570  break;
572  ast_copy_string(subclass, "Stream topology changed", slen);
573  break;
575  ast_copy_string(subclass, "Stream topology source changed", slen);
576  break;
577  case -1:
578  ast_copy_string(subclass, "Stop generators", slen);
579  break;
580  default:
581  snprintf(subclass, slen, "Unknown control '%d'", f->subclass.integer);
582  }
583  break;
584  case AST_FRAME_NULL:
585  ast_copy_string(subclass, "N/A", slen);
586  break;
587  case AST_FRAME_IAX:
588  /* Should never happen */
589  snprintf(subclass, slen, "IAX Frametype %d", f->subclass.integer);
590  break;
592  /* Should never happen */
593  snprintf(subclass, slen, "Bridge Frametype %d", f->subclass.integer);
594  break;
596  /* Should never happen */
597  snprintf(subclass, slen, "Synchronous Bridge Frametype %d", f->subclass.integer);
598  break;
599  case AST_FRAME_TEXT:
600  ast_copy_string(subclass, "N/A", slen);
601  if (moreinfo) {
602  ast_copy_string(moreinfo, f->data.ptr, mlen);
603  }
604  break;
605  case AST_FRAME_IMAGE:
606  snprintf(subclass, slen, "Image format %s\n", ast_format_get_name(f->subclass.format));
607  break;
608  case AST_FRAME_HTML:
609  switch (f->subclass.integer) {
610  case AST_HTML_URL:
611  ast_copy_string(subclass, "URL", slen);
612  if (moreinfo) {
613  ast_copy_string(moreinfo, f->data.ptr, mlen);
614  }
615  break;
616  case AST_HTML_DATA:
617  ast_copy_string(subclass, "Data", slen);
618  break;
619  case AST_HTML_BEGIN:
620  ast_copy_string(subclass, "Begin", slen);
621  break;
622  case AST_HTML_END:
623  ast_copy_string(subclass, "End", slen);
624  break;
625  case AST_HTML_LDCOMPLETE:
626  ast_copy_string(subclass, "Load Complete", slen);
627  break;
628  case AST_HTML_NOSUPPORT:
629  ast_copy_string(subclass, "No Support", slen);
630  break;
631  case AST_HTML_LINKURL:
632  ast_copy_string(subclass, "Link URL", slen);
633  if (moreinfo) {
634  ast_copy_string(moreinfo, f->data.ptr, mlen);
635  }
636  break;
637  case AST_HTML_UNLINK:
638  ast_copy_string(subclass, "Unlink", slen);
639  break;
640  case AST_HTML_LINKREJECT:
641  ast_copy_string(subclass, "Link Reject", slen);
642  break;
643  default:
644  snprintf(subclass, slen, "Unknown HTML frame '%d'\n", f->subclass.integer);
645  break;
646  }
647  break;
648  case AST_FRAME_MODEM:
649  switch (f->subclass.integer) {
650  case AST_MODEM_T38:
651  ast_copy_string(subclass, "T.38", slen);
652  break;
653  case AST_MODEM_V150:
654  ast_copy_string(subclass, "V.150", slen);
655  break;
656  default:
657  snprintf(subclass, slen, "Unknown MODEM frame '%d'\n", f->subclass.integer);
658  break;
659  }
660  break;
661  case AST_FRAME_RTCP:
662  ast_copy_string(subclass, "RTCP", slen);
663  default:
664  ast_copy_string(subclass, "Unknown Subclass", slen);
665  break;
666  }
667 
668  return subclass;
669 }
#define AST_HTML_LINKURL
#define AST_MODEM_V150
#define AST_HTML_NOSUPPORT
#define AST_HTML_LDCOMPLETE
#define AST_HTML_LINKREJECT
enum ast_control_t38 request_response
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
#define AST_HTML_DATA
struct ast_frame_subclass subclass
#define AST_HTML_UNLINK
#define AST_HTML_BEGIN
union ast_frame::@224 data
#define AST_HTML_URL
#define AST_HTML_END
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
#define AST_MODEM_T38
enum ast_frame_type frametype
struct ast_format * format
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.

Parameters
frame_typeThe frame type to be described
ftypeBuffer to fill with frame type description
lenLength of subclass buffer
Returns
Pointer to ftype
Since
11

Definition at line 671 of file main/frame.c.

References ast_copy_string(), AST_FRAME_BRIDGE_ACTION, AST_FRAME_BRIDGE_ACTION_SYNC, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_RTCP, AST_FRAME_TEXT, AST_FRAME_TEXT_DATA, AST_FRAME_VIDEO, and AST_FRAME_VOICE.

Referenced by ast_frame_dump().

672 {
673  switch (frame_type) {
675  ast_copy_string(ftype, "DTMF Begin", len);
676  break;
677  case AST_FRAME_DTMF_END:
678  ast_copy_string(ftype, "DTMF End", len);
679  break;
680  case AST_FRAME_CONTROL:
681  ast_copy_string(ftype, "Control", len);
682  break;
683  case AST_FRAME_NULL:
684  ast_copy_string(ftype, "Null Frame", len);
685  break;
686  case AST_FRAME_IAX:
687  /* Should never happen */
688  ast_copy_string(ftype, "IAX Specific", len);
689  break;
691  /* Should never happen */
692  ast_copy_string(ftype, "Bridge Specific", len);
693  break;
695  /* Should never happen */
696  ast_copy_string(ftype, "Bridge Specific", len);
697  break;
698  case AST_FRAME_TEXT:
699  ast_copy_string(ftype, "Text", len);
700  break;
701  case AST_FRAME_TEXT_DATA:
702  ast_copy_string(ftype, "Text Data", len);
703  break;
704  case AST_FRAME_IMAGE:
705  ast_copy_string(ftype, "Image", len);
706  break;
707  case AST_FRAME_HTML:
708  ast_copy_string(ftype, "HTML", len);
709  break;
710  case AST_FRAME_MODEM:
711  ast_copy_string(ftype, "Modem", len);
712  break;
713  case AST_FRAME_VOICE:
714  ast_copy_string(ftype, "Voice", len);
715  break;
716  case AST_FRAME_VIDEO:
717  ast_copy_string(ftype, "Video", len);
718  break;
719  case AST_FRAME_RTCP:
720  ast_copy_string(ftype, "RTCP", len);
721  break;
722  default:
723  snprintf(ftype, len, "Unknown Frametype '%u'", frame_type);
724  break;
725  }
726 
727  return ftype;
728 }
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425

Variable Documentation

struct ast_frame ast_null_frame