Asterisk - The Open Source Telephony Project  GIT-master-1f78ee9
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 More...
 
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. More...
 
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. More...
 
void ast_frame_free (struct ast_frame *fr, int cache)
 Requests a frame to be allocated. 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

◆ ast_frame_byteswap_be

#define ast_frame_byteswap_be (   fr)    do { ; } while(0)

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

Referenced by ast_rtp_interpret(), and socket_process_helper().

◆ ast_frame_byteswap_le

#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)

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

Referenced by phone_read().

◆ AST_FRAME_DTMF

#define AST_FRAME_DTMF   AST_FRAME_DTMF_END

◆ AST_FRAME_SET_BUFFER

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

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 201 of file include/asterisk/frame.h.

Referenced by fax_generator_generate(), g719read(), g723_read(), g726_read(), g729_read(), generic_read(), gsm_read(), h263_read(), h264_read(), ilbc_read(), mp3_read(), ogg_speex_read(), ogg_vorbis_read(), pcm_read(), siren14read(), siren7read(), spandsp_fax_gw_t30_gen(), spandsp_fax_read(), t38_tx_packet_handler(), vox_read(), and wav_read().

◆ ast_frdup

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

◆ ast_frfree

#define ast_frfree (   fr)    ast_frame_free(fr, 1)
Examples:
/tmp/asterisk-shallow/main/app.c.

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

Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_queue_frame(), __ast_read(), __ast_request_and_dial(), adsi_careful_send(), analog_ss_thread(), ast_autoservice_stop(), ast_channel_clear_softhangup(), ast_channel_destructor(), ast_dsp_process(), ast_frame_dtor(), ast_framehook_attach(), ast_indicate_data(), ast_jb_destroy(), ast_jb_put(), ast_queue_cc_frame(), ast_readaudio_callback(), ast_readvideo_callback(), ast_recvtext(), ast_rtp_interpret(), ast_rtp_write(), ast_safe_sleep_conditional(), ast_send_image(), ast_sendtext_data(), ast_slinfactory_destroy(), ast_slinfactory_feed(), ast_slinfactory_flush(), ast_slinfactory_read(), AST_TEST_DEFINE(), ast_tonepair(), ast_transfer(), ast_translate(), ast_waitfordigit_full(), ast_write_stream(), ast_writestream(), async_agi_read_frame(), audio_audiohook_write_list(), audiohook_read_frame_helper(), audiosocket_run(), autoservice_run(), background_detect_exec(), bridge_channel_destroy(), bridge_channel_queue_deferred_frames(), bridge_frame_free(), bridge_handle_actions(), chan_cleanup(), chan_pjsip_cng_tone_detected(), chan_pjsip_read_stream(), channel_spy(), conf_flush(), conf_free(), conf_run(), create_jb(), dahdi_read(), destroy_all_channels(), dial_exec_full(), dictate_exec(), disa_exec(), disable_t38(), do_waiting(), echo_exec(), eivr_comm(), fax_detect_framehook(), fax_gateway_framehook(), find_cache(), framehook_detach(), gen_generate(), generate_computational_cost(), generic_fax_exec(), handle_cli_file_convert(), handle_recordfile(), handle_speechrecognize(), hold_intercept_framehook(), hook_event_cb(), iax2_key_rotate(), ices_exec(), isAnsweringMachine(), jack_exec(), jb_empty_and_reset_adaptive(), jb_empty_and_reset_fixed(), jb_framedata_destroy(), jb_get_and_deliver(), jingle_read(), load_stream_readqueue(), measurenoise(), milliwatt_generate(), moh_channel_thread(), moh_files_generator(), monitor_dial(), mp3_exec(), multicast_rtp_write(), NBScat_exec(), ooh323_rtp_read(), read_frame(), read_test(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), run_agi(), send_waveform_to_channel(), sendfax_t38_init(), sendurl_exec(), session_destroy(), sip_read(), sip_rtp_read(), sms_exec(), sms_generate(), softmix_translate_helper_cleanup(), softmix_translate_helper_free_entry(), spandsp_fax_gw_t30_gen(), speech_background(), spy_generate(), stream_echo_perform(), t38_parameters_task_data_destroy(), t38_tx_packet_handler(), test_read_frames(), transmit_audio(), transmit_t38(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), and waitstream_core().

◆ AST_FRIENDLY_OFFSET

#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.

Examples:
/tmp/asterisk-shallow/main/app.c.

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

Referenced by __ast_frdup(), __ast_frisolate(), __get_from_jb(), adjust_frame_for_plc(), alsa_read(), ast_prod(), ast_rtcp_interpret(), ast_rtcp_read(), ast_rtp_interpret(), ast_rtp_read(), ast_smoother_read(), ast_udptl_read(), conf_run(), dahdi_read(), fax_generator_generate(), g719read(), g723_read(), g726_read(), g729_read(), generate_interpolated_slin(), generic_read(), gsm_read(), h263_read(), h264_read(), hook_event_cb(), iax_frame_wrap(), ilbc_read(), jb_get_and_deliver(), linear_generator(), mbl_read(), milliwatt_generate(), moh_generate(), mohalloc(), mp3_exec(), mp3_read(), NBScat_exec(), newpvt(), ogg_speex_read(), ogg_vorbis_read(), oss_read(), pcm_read(), phone_read(), playtones_generator(), process_cn_rfc3389(), send_waveform_to_channel(), siren14read(), siren7read(), sms_generate(), spandsp_fax_gw_t30_gen(), spandsp_fax_read(), tonepair_generator(), vox_read(), and wav_read().

◆ ast_frisolate

#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 570 of file include/asterisk/frame.h.

Referenced by __ast_answer(), ast_audiosocket_receive_frame(), ast_dsp_process(), ast_rtp_read(), ast_safe_sleep_conditional(), ast_slinfactory_feed(), ast_trans_frameout(), ast_write_stream(), autoservice_run(), create_test_frame(), dahdi_decoder_frameout(), dahdi_encoder_frameout(), fax_gateway_framehook(), fax_gateway_request_t38(), hook_event_cb(), lintospeex_frameout(), read_frame(), spandsp_fax_gw_t30_gen(), spandsp_fax_read(), and t38_tx_packet_handler().

◆ AST_HTML_BEGIN

#define AST_HTML_BEGIN   4

Beginning frame

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

Referenced by ast_frame_subclass2str().

◆ AST_HTML_DATA

#define AST_HTML_DATA   2

Data frame

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

Referenced by ast_frame_subclass2str().

◆ AST_HTML_END

#define AST_HTML_END   8

End frame

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

Referenced by ast_frame_subclass2str().

◆ AST_HTML_LDCOMPLETE

#define AST_HTML_LDCOMPLETE   16

Load is complete

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

Referenced by ast_frame_subclass2str(), and sendurl_exec().

◆ AST_HTML_LINKREJECT

#define AST_HTML_LINKREJECT   20

Reject link request

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

Referenced by ast_frame_subclass2str().

◆ AST_HTML_LINKURL

#define AST_HTML_LINKURL   18

Send URL, and track

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

Referenced by ast_frame_subclass2str().

◆ AST_HTML_NOSUPPORT

#define AST_HTML_NOSUPPORT   17

Peer is unable to support HTML

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

Referenced by ast_frame_subclass2str(), and sendurl_exec().

◆ AST_HTML_UNLINK

#define AST_HTML_UNLINK   19

No more HTML linkage

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

Referenced by ast_frame_subclass2str().

◆ AST_HTML_URL

#define AST_HTML_URL   1

Sending a URL

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

Referenced by ast_channel_sendurl(), ast_frame_subclass2str(), and sip_sendhtml().

◆ AST_MALLOCD_DATA

#define AST_MALLOCD_DATA   (1 << 1)

◆ AST_MALLOCD_HDR

#define AST_MALLOCD_HDR   (1 << 0)

Need the header be free'd?

Examples:
/tmp/asterisk-shallow/main/app.c.

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

Referenced by __ast_frdup(), __ast_frisolate(), __frame_free(), create_video_frame(), and make_silence().

◆ AST_MALLOCD_SRC

#define AST_MALLOCD_SRC   (1 << 2)

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

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

Referenced by __ast_frisolate(), __frame_free(), and speex_callback().

◆ AST_MIN_OFFSET

#define AST_MIN_OFFSET   32 /*! Make sure we keep at least this much handy */

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

Referenced by __ast_smoother_feed().

◆ AST_MODEM_T38

#define AST_MODEM_T38   1

◆ AST_MODEM_V150

#define AST_MODEM_V150   2

V.150 Modem-over-IP

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

Referenced by ast_frame_subclass2str().

◆ AST_OPTION_AUDIO_MODE

#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 436 of file include/asterisk/frame.h.

Referenced by bridge_channel_handle_control(), dahdi_hangup(), dahdi_setoption(), and iax2_setoption().

◆ AST_OPTION_CC_AGENT_TYPE

#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 503 of file include/asterisk/frame.h.

Referenced by ast_channel_get_cc_agent_type(), and dahdi_queryoption().

◆ AST_OPTION_CHANNEL_WRITE

#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 467 of file include/asterisk/frame.h.

Referenced by ast_unreal_setoption(), and func_channel_write().

◆ AST_OPTION_DEVICE_NAME

#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 499 of file include/asterisk/frame.h.

Referenced by ast_channel_get_device_name(), and sip_queryoption().

◆ AST_OPTION_DIGIT_DETECT

#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 491 of file include/asterisk/frame.h.

Referenced by bridge_channel_handle_control(), dahdi_queryoption(), dahdi_setoption(), iax2_setoption(), ooh323_queryoption(), rcvfax_exec(), sip_queryoption(), sip_setoption(), and sndfax_exec().

◆ AST_OPTION_ECHOCAN

#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.

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

Referenced by dahdi_setoption().

◆ AST_OPTION_FAX_DETECT

#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 495 of file include/asterisk/frame.h.

Referenced by bridge_channel_handle_control(), dahdi_queryoption(), dahdi_setoption(), iax2_setoption(), rcvfax_exec(), and sndfax_exec().

◆ AST_OPTION_FLAG_ACCEPT

#define AST_OPTION_FLAG_ACCEPT   1

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

◆ AST_OPTION_FLAG_ANSWER

#define AST_OPTION_FLAG_ANSWER   5

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

◆ AST_OPTION_FLAG_QUERY

#define AST_OPTION_FLAG_QUERY   4

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

◆ AST_OPTION_FLAG_REJECT

#define AST_OPTION_FLAG_REJECT   2

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

◆ AST_OPTION_FLAG_REQUEST

#define AST_OPTION_FLAG_REQUEST   0

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

Referenced by bridge_channel_handle_control(), and iax2_setoption().

◆ AST_OPTION_FLAG_WTF

#define AST_OPTION_FLAG_WTF   6

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

◆ AST_OPTION_FORMAT_READ

#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 477 of file include/asterisk/frame.h.

Referenced by sip_setoption().

◆ AST_OPTION_FORMAT_WRITE

#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 481 of file include/asterisk/frame.h.

Referenced by sip_setoption().

◆ AST_OPTION_MAKE_COMPATIBLE

#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 487 of file include/asterisk/frame.h.

◆ AST_OPTION_OPRMODE

#define AST_OPTION_OPRMODE   7

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

Referenced by dahdi_setoption(), dial_exec_full(), and iax2_setoption().

◆ AST_OPTION_RELAXDTMF

#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 432 of file include/asterisk/frame.h.

Referenced by bridge_channel_handle_control(), dahdi_setoption(), and iax2_setoption().

◆ AST_OPTION_RXGAIN

#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 446 of file include/asterisk/frame.h.

Referenced by dahdi_setoption(), func_channel_write_real(), iax2_setoption(), play_record_review(), reset_volumes(), set_talk_volume(), and vm_forwardoptions().

◆ AST_OPTION_SECURE_MEDIA

#define AST_OPTION_SECURE_MEDIA   19

◆ AST_OPTION_SECURE_SIGNALING

#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 507 of file include/asterisk/frame.h.

Referenced by iax2_queryoption(), iax2_setoption(), local_setoption(), set_security_requirements(), sip_queryoption(), and sip_setoption().

◆ AST_OPTION_T38_STATE

#define AST_OPTION_T38_STATE   10

◆ AST_OPTION_TDD

#define AST_OPTION_TDD   2

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

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

Referenced by analog_hangup(), bridge_channel_handle_control(), dahdi_hangup(), dahdi_setoption(), handle_tddmode(), and iax2_setoption().

◆ AST_OPTION_TONE_VERIFY

#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 424 of file include/asterisk/frame.h.

Referenced by analog_hangup(), bridge_channel_handle_control(), conf_run(), dahdi_hangup(), dahdi_setoption(), iax2_setoption(), and try_calling().

◆ AST_OPTION_TXGAIN

#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 441 of file include/asterisk/frame.h.

Referenced by common_exec(), dahdi_setoption(), func_channel_write_real(), iax2_setoption(), reset_volumes(), and set_listen_volume().

Enumeration Type Documentation

◆ anonymous enum

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 138 of file include/asterisk/frame.h.

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

◆ ast_control_frame_type

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 270 of file include/asterisk/frame.h.

270  {
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 };

◆ ast_control_t38

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 363 of file include/asterisk/frame.h.

363  {
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 };

◆ ast_control_t38_rate

Enumerator
AST_T38_RATE_2400 
AST_T38_RATE_4800 
AST_T38_RATE_7200 
AST_T38_RATE_9600 
AST_T38_RATE_12000 
AST_T38_RATE_14400 

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

372  {
373  AST_T38_RATE_2400 = 1,
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. */
382  AST_T38_RATE_14400 = 0,
383 };

◆ ast_control_t38_rate_management

Enumerator
AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF 
AST_T38_RATE_MANAGEMENT_LOCAL_TCF 

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

◆ ast_control_transfer

Enumerator
AST_TRANSFER_SUCCESS 

Transfer request on the channel worked

AST_TRANSFER_FAILED 

Transfer request on the channel failed

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

401  {
402  AST_TRANSFER_SUCCESS = 0, /*!< Transfer request on the channel worked */
403  AST_TRANSFER_FAILED, /*!< Transfer request on the channel failed */
404 };

◆ ast_frame_read_action

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.

Enumerator
AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO 
AST_FRAME_READ_ACTION_SEND_TEXT 
AST_FRAME_READ_ACTION_SEND_TEXT_DATA 

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

◆ ast_frame_type

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

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 */
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 };

Function Documentation

◆ __ast_frdup()

struct ast_frame* __ast_frdup ( const struct ast_frame fr,
const char *  file,
int  line,
const char *  func 
)

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

References __ast_calloc(), ao2_bump, ast_copy_flags, AST_FLAGS_ALL, AST_FRAME_IMAGE, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_MALLOCD_HDR, ast_threadstorage_get(), buf, ast_frame::data, ast_frame::datalen, ast_frame::delivery, ast_frame_subclass::format, frame_cache, frames, ast_frame::frametype, ast_frame::len, len(), ast_frame_cache::list, ast_frame::mallocd, ast_frame::mallocd_hdr_len, NULL, ast_frame::offset, out, ast_frame::ptr, ast_frame::samples, ast_frame::seqno, ast_frame_cache::size, ast_frame::src, ast_frame::stream_num, ast_frame::subclass, ast_frame::ts, and ast_frame::uint32.

Referenced by __ast_frisolate().

300 {
301  struct ast_frame *out = NULL;
302  int len, srclen = 0;
303  void *buf = NULL;
304 
305 #if !defined(NO_FRAME_CACHE)
306  struct ast_frame_cache *frames;
307 #endif
308 
309  /* Start with standard stuff */
310  len = sizeof(*out) + AST_FRIENDLY_OFFSET + f->datalen;
311  /* If we have a source, add space for it */
312  /*
313  * XXX Watch out here - if we receive a src which is not terminated
314  * properly, we can be easily attacked. Should limit the size we deal with.
315  */
316  if (f->src)
317  srclen = strlen(f->src);
318  if (srclen > 0)
319  len += srclen + 1;
320 
321 #if !defined(NO_FRAME_CACHE)
322  if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
324  if (out->mallocd_hdr_len >= len) {
325  size_t mallocd_len = out->mallocd_hdr_len;
326 
328  memset(out, 0, sizeof(*out));
329  out->mallocd_hdr_len = mallocd_len;
330  buf = out;
331  frames->size--;
332  break;
333  }
334  }
336  }
337 #endif
338 
339  if (!buf) {
340  if (!(buf = __ast_calloc(1, len, file, line, func)))
341  return NULL;
342  out = buf;
343  out->mallocd_hdr_len = len;
344  }
345 
346  out->frametype = f->frametype;
347  out->subclass = f->subclass;
348  if ((f->frametype == AST_FRAME_VOICE) || (f->frametype == AST_FRAME_VIDEO) ||
349  (f->frametype == AST_FRAME_IMAGE)) {
350  ao2_bump(out->subclass.format);
351  }
352  out->datalen = f->datalen;
353  out->samples = f->samples;
354  out->delivery = f->delivery;
355  /* Even though this new frame was allocated from the heap, we can't mark it
356  * with AST_MALLOCD_HDR, AST_MALLOCD_DATA and AST_MALLOCD_SRC, because that
357  * would cause ast_frfree() to attempt to individually free each of those
358  * under the assumption that they were separately allocated. Since this frame
359  * was allocated in a single allocation, we'll only mark it as if the header
360  * was heap-allocated; this will result in the entire frame being properly freed.
361  */
362  out->mallocd = AST_MALLOCD_HDR;
364  /* Make sure that empty text frames have a valid data.ptr */
365  if (out->datalen || f->frametype == AST_FRAME_TEXT) {
366  out->data.ptr = buf + sizeof(*out) + AST_FRIENDLY_OFFSET;
367  memcpy(out->data.ptr, f->data.ptr, out->datalen);
368  } else {
369  out->data.uint32 = f->data.uint32;
370  }
371  if (srclen > 0) {
372  /* This may seem a little strange, but it's to avoid a gcc (4.2.4) compiler warning */
373  char *src;
374  out->src = buf + sizeof(*out) + AST_FRIENDLY_OFFSET + f->datalen;
375  src = (char *) out->src;
376  /* Must have space since we allocated for it */
377  strcpy(src, f->src);
378  }
379  ast_copy_flags(out, f, AST_FLAGS_ALL);
380  out->ts = f->ts;
381  out->len = f->len;
382  out->seqno = f->seqno;
383  out->stream_num = f->stream_num;
384  return out;
385 }
void * __ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc
Definition: astmm.c:1635
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
struct ast_frames list
Definition: main/frame.c:74
#define ast_copy_flags(dest, src, flagz)
Definition: utils.h:84
#define NULL
Definition: resample.c:96
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:614
struct ast_frame_subclass subclass
#define ao2_bump(obj)
Definition: astobj2.h:491
union ast_frame::@255 data
#define AST_MALLOCD_HDR
#define AST_FRIENDLY_OFFSET
Offset into a frame&#39;s data buffer.
const char * src
static int frames
Definition: parser.c:51
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:556
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_FLAGS_ALL
Definition: utils.h:196
struct timeval delivery
FILE * out
Definition: utils/frame.c:33
Data structure associated with a single frame of data.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
enum ast_frame_type frametype
struct ast_format * format
static struct ast_threadstorage frame_cache
Definition: main/frame.c:56

◆ __ast_frisolate()

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

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

References __ast_frdup(), ao2_bump, ast_copy_flags, AST_FLAGS_ALL, ast_frame_free(), ast_frame_header_new(), AST_FRAME_IMAGE, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, AST_FRFLAG_HAS_TIMING_INFO, AST_FRIENDLY_OFFSET, ast_malloc, AST_MALLOCD_DATA, AST_MALLOCD_HDR, AST_MALLOCD_SRC, ast_strdup, ast_test_flag, ast_frame::data, ast_frame::datalen, ast_frame_subclass::format, ast_frame::frametype, ast_frame::len, ast_frame::mallocd, NULL, ast_frame::offset, out, ast_frame::ptr, ast_frame::samples, ast_frame::seqno, ast_frame::src, ast_frame::stream_num, ast_frame::subclass, ast_frame::ts, and ast_frame::uint32.

194 {
195  struct ast_frame *out;
196  void *newdata;
197 
198  /* if none of the existing frame is malloc'd, let ast_frdup() do it
199  since it is more efficient
200  */
201  if (fr->mallocd == 0) {
202  return __ast_frdup(fr, file, line, func);
203  }
204 
205  /* if everything is already malloc'd, we are done */
208  return fr;
209  }
210 
211  if (!(fr->mallocd & AST_MALLOCD_HDR)) {
212  /* Allocate a new header if needed */
213  if (!(out = ast_frame_header_new(file, line, func))) {
214  return NULL;
215  }
216  out->frametype = fr->frametype;
217  out->subclass = fr->subclass;
218  if ((fr->frametype == AST_FRAME_VOICE) || (fr->frametype == AST_FRAME_VIDEO) ||
219  (fr->frametype == AST_FRAME_IMAGE)) {
220  ao2_bump(out->subclass.format);
221  }
222  out->datalen = fr->datalen;
223  out->samples = fr->samples;
224  out->mallocd = AST_MALLOCD_HDR;
225  out->offset = fr->offset;
226  /* Copy the timing data */
227  ast_copy_flags(out, fr, AST_FLAGS_ALL);
229  out->ts = fr->ts;
230  out->len = fr->len;
231  out->seqno = fr->seqno;
232  }
233  out->stream_num = fr->stream_num;
234  } else {
235  out = fr;
236  }
237 
238  if (fr->src) {
239  /* The original frame has a source string */
240  if (!(fr->mallocd & AST_MALLOCD_SRC)) {
241  /*
242  * The original frame has a non-malloced source string.
243  *
244  * Duplicate the string and put it into the isolated frame
245  * which may also be the original frame.
246  */
247  newdata = ast_strdup(fr->src);
248  if (!newdata) {
249  if (out != fr) {
250  ast_frame_free(out, 0);
251  }
252  return NULL;
253  }
254  out->src = newdata;
255  out->mallocd |= AST_MALLOCD_SRC;
256  } else if (out != fr) {
257  /* Steal the source string from the original frame. */
258  out->src = fr->src;
259  fr->src = NULL;
260  fr->mallocd &= ~AST_MALLOCD_SRC;
261  out->mallocd |= AST_MALLOCD_SRC;
262  }
263  }
264 
265  if (!(fr->mallocd & AST_MALLOCD_DATA)) {
266  /* The original frame has a non-malloced data buffer. */
267  if (!fr->datalen && fr->frametype != AST_FRAME_TEXT) {
268  /* Actually it's just an int so we can simply copy it. */
269  out->data.uint32 = fr->data.uint32;
270  return out;
271  }
272  /*
273  * Duplicate the data buffer and put it into the isolated frame
274  * which may also be the original frame.
275  */
276  newdata = ast_malloc(fr->datalen + AST_FRIENDLY_OFFSET);
277  if (!newdata) {
278  if (out != fr) {
279  ast_frame_free(out, 0);
280  }
281  return NULL;
282  }
283  newdata += AST_FRIENDLY_OFFSET;
285  memcpy(newdata, fr->data.ptr, fr->datalen);
286  out->data.ptr = newdata;
287  out->mallocd |= AST_MALLOCD_DATA;
288  } else if (out != fr) {
289  /* Steal the data buffer from the original frame. */
290  out->data = fr->data;
291  memset(&fr->data, 0, sizeof(fr->data));
292  fr->mallocd &= ~AST_MALLOCD_DATA;
293  out->mallocd |= AST_MALLOCD_DATA;
294  }
295 
296  return out;
297 }
void ast_frame_free(struct ast_frame *frame, int cache)
Requests a frame to be allocated.
Definition: main/frame.c:172
struct ast_frame * __ast_frdup(const struct ast_frame *f, const char *file, int line, const char *func)
Definition: main/frame.c:299
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define AST_MALLOCD_DATA
#define ast_copy_flags(dest, src, flagz)
Definition: utils.h:84
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
struct ast_frame_subclass subclass
#define ao2_bump(obj)
Definition: astobj2.h:491
union ast_frame::@255 data
#define AST_MALLOCD_HDR
#define AST_FRIENDLY_OFFSET
Offset into a frame&#39;s data buffer.
const char * src
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
static struct ast_frame * ast_frame_header_new(const char *file, int line, const char *func)
Definition: main/frame.c:81
#define AST_FLAGS_ALL
Definition: utils.h:196
FILE * out
Definition: utils/frame.c:33
Data structure associated with a single frame of data.
enum ast_frame_type frametype
#define AST_MALLOCD_SRC
struct ast_format * format

◆ ast_frame_adjust_volume()

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 769 of file main/frame.c.

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

Referenced by audiohook_read_frame_single(), audiohook_volume_callback(), and conf_run().

770 {
771  int count;
772  short *fdata = f->data.ptr;
773  short adjust_value = abs(adjustment);
774 
776  return -1;
777  }
778 
779  if (!adjustment) {
780  return 0;
781  }
782 
783  for (count = 0; count < f->samples; count++) {
784  if (adjustment > 0) {
785  ast_slinear_saturated_multiply(&fdata[count], &adjust_value);
786  } else if (adjustment < 0) {
787  ast_slinear_saturated_divide(&fdata[count], &adjust_value);
788  }
789  }
790 
791  return 0;
792 }
struct ast_frame_subclass subclass
union ast_frame::@255 data
static force_inline void ast_slinear_saturated_multiply(short *input, short *value)
Definition: utils.h:391
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:542
static force_inline void ast_slinear_saturated_divide(short *input, short *value)
Definition: utils.h:417
#define abs(x)
Definition: f2c.h:195
enum ast_frame_type frametype
struct ast_format * format

◆ ast_frame_adjust_volume_float()

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 794 of file main/frame.c.

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

Referenced by volume_callback().

795 {
796  int count;
797  short *fdata = f->data.ptr;
798  float adjust_value = fabs(adjustment);
799 
801  return -1;
802  }
803 
804  if (!adjustment) {
805  return 0;
806  }
807 
808  for (count = 0; count < f->samples; count++) {
809  if (adjustment > 0) {
810  ast_slinear_saturated_multiply_float(&fdata[count], &adjust_value);
811  } else if (adjustment < 0) {
812  ast_slinear_saturated_divide_float(&fdata[count], &adjust_value);
813  }
814  }
815 
816  return 0;
817 }
struct ast_frame_subclass subclass
union ast_frame::@255 data
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:542
static force_inline void ast_slinear_saturated_divide_float(short *input, float *value)
Definition: utils.h:422
static force_inline void ast_slinear_saturated_multiply_float(short *input, float *value)
Definition: utils.h:404
enum ast_frame_type frametype
struct ast_format * format

◆ ast_frame_clear()

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 at line 841 of file main/frame.c.

References AST_LIST_NEXT, ast_frame::data, ast_frame::datalen, ast_frame::next, NULL, and ast_frame::ptr.

Referenced by audiohook_read_frame_single().

842 {
843  struct ast_frame *next;
844 
845  for (next = AST_LIST_NEXT(frame, frame_list);
846  frame;
847  frame = next, next = frame ? AST_LIST_NEXT(frame, frame_list) : NULL) {
848  memset(frame->data.ptr, 0, frame->datalen);
849  }
850  return 0;
851 }
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:438
#define NULL
Definition: resample.c:96
union ast_frame::@255 data
struct ast_frame * next
Data structure associated with a single frame of data.

◆ ast_frame_dtor()

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.
Examples:
/tmp/asterisk-shallow/main/app.c.

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

References ast_frfree.

Referenced by __ast_play_and_record(), snoop_read(), and stasis_app_exec().

184 {
185  ast_frfree(f);
186 }
#define ast_frfree(fr)

◆ ast_frame_dump()

void ast_frame_dump ( const char *  name,
struct ast_frame f,
char *  prefix 
)

Dump a frame for debugging purposes

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

References AST_FRAME_RTCP, ast_frame_subclass2str(), ast_frame_type2str(), AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_strlen_zero, ast_verb, COLOR_BLACK, COLOR_BRCYAN, COLOR_BRGREEN, COLOR_BRMAGENTA, COLOR_BRRED, COLOR_YELLOW, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::subclass, and term_color().

Referenced by __ast_read(), and ast_write_stream().

714 {
715  const char noname[] = "unknown";
716  char ftype[40] = "Unknown Frametype";
717  char cft[80];
718  char subclass[40] = "Unknown Subclass";
719  char csub[80];
720  char moreinfo[40] = "";
721  char cn[60];
722  char cp[40];
723  char cmn[40];
724 
725  if (!name) {
726  name = noname;
727  }
728 
729  if (!f) {
730  ast_verb(-1, "%s [ %s (NULL) ] [%s]\n",
731  term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
732  term_color(cft, "HANGUP", COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
733  term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
734  return;
735  }
736  /* XXX We should probably print one each of voice and video when the format changes XXX */
737  if (f->frametype == AST_FRAME_VOICE) {
738  return;
739  }
740  if (f->frametype == AST_FRAME_VIDEO) {
741  return;
742  }
743  if (f->frametype == AST_FRAME_RTCP) {
744  return;
745  }
746 
747  ast_frame_type2str(f->frametype, ftype, sizeof(ftype));
748  ast_frame_subclass2str(f, subclass, sizeof(subclass), moreinfo, sizeof(moreinfo));
749 
750  if (!ast_strlen_zero(moreinfo))
751  ast_verb(-1, "%s [ TYPE: %s (%u) SUBCLASS: %s (%d) '%s' ] [%s]\n",
752  term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
753  term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
754  f->frametype,
755  term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
756  f->subclass.integer,
757  term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK, sizeof(cmn)),
758  term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
759  else
760  ast_verb(-1, "%s [ TYPE: %s (%u) SUBCLASS: %s (%d) ] [%s]\n",
761  term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
762  term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
763  f->frametype,
764  term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
765  f->subclass.integer,
766  term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
767 }
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
#define COLOR_YELLOW
Definition: term.h:54
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
#define ast_verb(level,...)
Definition: logger.h:455
#define COLOR_BRCYAN
Definition: term.h:60
struct ast_frame_subclass subclass
#define COLOR_BRRED
Definition: term.h:50
#define COLOR_BRGREEN
Definition: term.h:52
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:184
#define COLOR_BRMAGENTA
Definition: term.h:58
#define COLOR_BLACK
Definition: term.h:47
#define ast_strlen_zero(a)
Definition: muted.c:73
static const char name[]
Definition: cdr_mysql.c:74
enum ast_frame_type frametype
static char prefix[MAX_PREFIX]
Definition: http.c:141

◆ ast_frame_enqueue()

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.

◆ ast_frame_free()

void ast_frame_free ( struct ast_frame fr,
int  cache 
)

Requests a frame to be allocated.

Parameters
sourceRequest a frame be allocated. source is an optional source of the frame, len is the requested length, or "0" if the caller will supply the buffer

Frees a frame or list of frames

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

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

References __frame_free(), AST_LIST_NEXT, and ast_frame::next.

Referenced by __ast_frisolate(), ast_rtp_read(), and mixmonitor_thread().

173 {
174  struct ast_frame *next;
175 
176  while (frame) {
177  next = AST_LIST_NEXT(frame, frame_list);
178  __frame_free(frame, cache);
179  frame = next;
180  }
181 }
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:438
static void __frame_free(struct ast_frame *fr, int cache)
Definition: main/frame.c:122
struct ao2_container * cache
Definition: pbx_realtime.c:77
struct ast_frame * next
Data structure associated with a single frame of data.

◆ ast_frame_slinear_sum()

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 819 of file main/frame.c.

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

820 {
821  int count;
822  short *data1, *data2;
823 
825  return -1;
826 
828  return -1;
829 
830  if (f1->samples != f2->samples)
831  return -1;
832 
833  for (count = 0, data1 = f1->data.ptr, data2 = f2->data.ptr;
834  count < f1->samples;
835  count++, data1++, data2++)
836  ast_slinear_saturated_add(data1, data2);
837 
838  return 0;
839 }
struct ast_frame_subclass subclass
union ast_frame::@255 data
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
static force_inline void ast_slinear_saturated_add(short *input, short *value)
Definition: utils.h:365
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

◆ ast_frame_subclass2str()

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 397 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_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_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_frame::ptr, ast_control_t38_parameters::request_response, and ast_frame::subclass.

Referenced by ast_frame_dump(), and chan_pjsip_indicate().

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

◆ ast_frame_type2str()

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 653 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(), softmix_bridge_write_text(), and stream_echo_write_error().

654 {
655  switch (frame_type) {
657  ast_copy_string(ftype, "DTMF Begin", len);
658  break;
659  case AST_FRAME_DTMF_END:
660  ast_copy_string(ftype, "DTMF End", len);
661  break;
662  case AST_FRAME_CONTROL:
663  ast_copy_string(ftype, "Control", len);
664  break;
665  case AST_FRAME_NULL:
666  ast_copy_string(ftype, "Null Frame", len);
667  break;
668  case AST_FRAME_IAX:
669  /* Should never happen */
670  ast_copy_string(ftype, "IAX Specific", len);
671  break;
673  /* Should never happen */
674  ast_copy_string(ftype, "Bridge Specific", len);
675  break;
677  /* Should never happen */
678  ast_copy_string(ftype, "Bridge Specific", len);
679  break;
680  case AST_FRAME_TEXT:
681  ast_copy_string(ftype, "Text", len);
682  break;
683  case AST_FRAME_TEXT_DATA:
684  ast_copy_string(ftype, "Text Data", len);
685  break;
686  case AST_FRAME_IMAGE:
687  ast_copy_string(ftype, "Image", len);
688  break;
689  case AST_FRAME_HTML:
690  ast_copy_string(ftype, "HTML", len);
691  break;
692  case AST_FRAME_MODEM:
693  ast_copy_string(ftype, "Modem", len);
694  break;
695  case AST_FRAME_VOICE:
696  ast_copy_string(ftype, "Voice", len);
697  break;
698  case AST_FRAME_VIDEO:
699  ast_copy_string(ftype, "Video", len);
700  break;
701  case AST_FRAME_RTCP:
702  ast_copy_string(ftype, "RTCP", len);
703  break;
704  default:
705  snprintf(ftype, len, "Unknown Frametype '%u'", frame_type);
706  break;
707  }
708 
709  return ftype;
710 }
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
frame_type
Definition: codec_builtin.c:44
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ ast_swapcopy_samples()

void ast_swapcopy_samples ( void *  dst,
const void *  src,
int  samples 
)

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

Referenced by __ast_smoother_feed(), iax_frame_wrap(), phone_write_buf(), and smoother_frame_feed().

388 {
389  int i;
390  unsigned short *dst_s = dst;
391  const unsigned short *src_s = src;
392 
393  for (i = 0; i < samples; i++)
394  dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8);
395 }

Variable Documentation

◆ ast_null_frame

struct ast_frame ast_null_frame

Queueing a null frame is fairly common, so we declare a global null frame object for this purpose instead of having to declare one on the stack

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

Referenced by __analog_handle_event(), __ast_read(), apply_negotiated_sdp_stream(), ast_audiosocket_receive_frame(), ast_channel_set_unbridged_nolock(), ast_channel_setwhentohangup_tv(), ast_rtcp_interpret(), ast_rtcp_read(), ast_rtp_interpret(), ast_rtp_read(), ast_softhangup_nolock(), AST_TEST_DEFINE(), ast_translate(), ast_udptl_read(), ast_unreal_read(), bridge_channel_internal_push_full(), bridge_channel_poke(), chan_msg_read(), chan_pjsip_cng_tone_detected(), chan_pjsip_read_stream(), channel_do_masquerade(), conf_run(), console_read(), create_dtmf_frame(), dahdi_handle_event(), dahdi_read(), fax_detect_framehook(), fax_gateway_detect_t38(), fax_gateway_framehook(), handle_negotiated_sdp(), handle_request_invite(), handle_response_invite(), hold_intercept_framehook(), hook_event_cb(), iax2_read(), jb_get_adaptive(), jb_get_fixed(), jingle_read(), mbl_read(), media_session_rtcp_read_callback(), media_session_rtp_read_callback(), media_session_udptl_read_callback(), mgcp_rtp_read(), multicast_rtp_read(), nbs_xread(), ooh323_rtp_read(), process_sdp(), rec_read(), rtp_read(), set_interval_hook(), sip_acf_channel_read(), sip_read(), sip_rtp_read(), skinny_rtp_read(), snoop_read(), spandsp_fax_read(), stream_periodic_frames(), suppress_framehook_event_cb(), test_vm_api_mock_channel_read(), unistim_rtp_read(), vmsayname_exec(), and wakeup_sub().