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"

Include dependency graph for include/asterisk/frame.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

Defines

#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_frfree(fr)   ast_frame_free(fr, 1)
#define AST_FRIENDLY_OFFSET   64
 Offset into a frame's data buffer.
#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
#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.
#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) }
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_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 }
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
}
 Frame types. More...

Functions

int ast_frame_adjust_volume (struct ast_frame *f, int adjustment)
 Adjusts the volume of the audio samples contained in a frame.
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.
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 *fr, int cache)
 Requests a frame to be allocated.
int ast_frame_slinear_sum (struct ast_frame *f1, struct ast_frame *f2)
 Sums two frames of audio samples.
void 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.
void 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.
struct ast_frameast_frdup (const struct ast_frame *fr)
 Copies a frame.
struct ast_frameast_frisolate (struct ast_frame *fr)
 Makes a frame independent of any static storage.
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.


Define Documentation

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

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

Referenced by ast_rtp_read(), and socket_process_helper().

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

Referenced by phone_read().

#define AST_FRAME_DTMF   AST_FRAME_DTMF_END

#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 190 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_vorbis_read(), pcm_read(), siren14read(), siren7read(), spandsp_fax_gw_t30_gen(), spandsp_fax_read(), t38_tx_packet_handler(), vox_read(), and wav_read().

#define ast_frfree ( fr   )     ast_frame_free(fr, 1)

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

Definition at line 527 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_write(), ast_safe_sleep_conditional(), ast_send_image(), ast_slinfactory_destroy(), ast_slinfactory_feed(), ast_slinfactory_flush(), ast_slinfactory_read(), ast_tonepair(), ast_transfer(), ast_translate(), ast_waitfordigit_full(), ast_write(), ast_writestream(), async_agi_read_frame(), audio_audiohook_write_list(), audiohook_read_frame_helper(), autoservice_run(), background_detect_exec(), bridge_frame_free(), bridge_handle_actions(), chan_pjsip_cng_tone_detected(), channel_spy(), conf_flush(), conf_free(), conf_run(), create_jb(), dahdi_read(), 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(), hook_event_cb(), ices_exec(), isAnsweringMachine(), jack_exec(), jb_empty_and_reset_adaptive(), jb_empty_and_reset_fixed(), jb_framedata_destroy(), jb_get_and_deliver(), jingle_read(), measurenoise(), milliwatt_generate(), moh_files_generator(), monitor_dial(), mp3_exec(), multicast_rtp_write(), NBScat_exec(), ooh323_rtp_read(), read_frame(), 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_generate(), softmix_translate_helper_cleanup(), softmix_translate_helper_free_entry(), spandsp_fax_gw_t30_gen(), speech_background(), spy_generate(), t38_parameters_task_data_destroy(), t38_tx_packet_handler(), transmit_audio(), transmit_t38(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), and waitstream_core().

#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-trunk/trunk/main/app.c.

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

Referenced by __get_from_jb(), adjust_frame_for_plc(), alsa_read(), ast_frdup(), ast_frisolate(), ast_prod(), ast_rtcp_read(), ast_rtp_read(), ast_smoother_read(), ast_udptl_read(), conf_run(), dahdi_read(), fax_generator_generate(), g719read(), g723_read(), g726_read(), g729_read(), 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_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().

#define AST_HTML_BEGIN   4

Beginning frame

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

Referenced by ast_frame_subclass2str().

#define AST_HTML_DATA   2

Data frame

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

Referenced by ast_frame_subclass2str().

#define AST_HTML_END   8

End frame

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

Referenced by ast_frame_subclass2str().

#define AST_HTML_LDCOMPLETE   16

Load is complete

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

Referenced by ast_frame_subclass2str(), and sendurl_exec().

#define AST_HTML_LINKREJECT   20

Reject link request

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

Referenced by ast_frame_subclass2str().

#define AST_HTML_LINKURL   18

Send URL, and track

Definition at line 241 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 239 of file include/asterisk/frame.h.

Referenced by ast_frame_subclass2str(), and sendurl_exec().

#define AST_HTML_UNLINK   19

No more HTML linkage

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

Referenced by ast_frame_subclass2str().

#define AST_HTML_URL   1

Sending a URL

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

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

#define AST_MALLOCD_DATA   (1 << 1)

Need the data be free'd?

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

Referenced by __frame_free(), ast_cc_build_frame(), ast_frisolate(), ast_sendtext(), and create_video_frame().

#define AST_MALLOCD_HDR   (1 << 0)

#define AST_MALLOCD_SRC   (1 << 2)

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

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

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

#define AST_MIN_OFFSET   32

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

Referenced by __ast_smoother_feed().

#define AST_MODEM_T38   1

#define AST_MODEM_V150   2

V.150 Modem-over-IP

Definition at line 225 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 414 of file include/asterisk/frame.h.

Referenced by bridge_channel_handle_control(), dahdi_hangup(), dahdi_setoption(), and iax2_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 481 of file include/asterisk/frame.h.

Referenced by ast_channel_get_cc_agent_type(), and dahdi_queryoption().

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

Referenced by ast_unreal_setoption(), and func_channel_write().

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

Referenced by ast_channel_get_device_name(), and sip_queryoption().

#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 469 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().

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

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

#define AST_OPTION_FLAG_ACCEPT   1

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

#define AST_OPTION_FLAG_ANSWER   5

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

#define AST_OPTION_FLAG_QUERY   4

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

#define AST_OPTION_FLAG_REJECT   2

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

#define AST_OPTION_FLAG_REQUEST   0

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

Referenced by bridge_channel_handle_control(), and iax2_setoption().

#define AST_OPTION_FLAG_WTF   6

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

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

Referenced by sip_setoption().

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

Referenced by sip_setoption().

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

#define AST_OPTION_OPRMODE   7

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

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

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

Referenced by bridge_channel_handle_control(), dahdi_setoption(), and iax2_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 424 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().

#define AST_OPTION_SECURE_MEDIA   19

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

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

#define AST_OPTION_T38_STATE   10

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

Referenced by analog_hangup(), bridge_channel_handle_control(), dahdi_hangup(), dahdi_setoption(), handle_tddmode(), and iax2_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 402 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().

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

Enumerator:
AST_FRFLAG_HAS_TIMING_INFO  This frame contains valid timing information

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

00133      {
00134    /*! This frame contains valid timing information */
00135    AST_FRFLAG_HAS_TIMING_INFO = (1 << 0),
00136 };

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

00259                             {
00260    AST_CONTROL_HANGUP = 1,       /*!< Other end has hungup */
00261    AST_CONTROL_RING = 2,         /*!< Local ring */
00262    AST_CONTROL_RINGING = 3,      /*!< Remote end is ringing */
00263    AST_CONTROL_ANSWER = 4,       /*!< Remote end has answered */
00264    AST_CONTROL_BUSY = 5,         /*!< Remote end is busy */
00265    AST_CONTROL_TAKEOFFHOOK = 6,  /*!< Make it go off hook */
00266    AST_CONTROL_OFFHOOK = 7,      /*!< Line is off hook */
00267    AST_CONTROL_CONGESTION = 8,      /*!< Congestion (circuits busy) */
00268    AST_CONTROL_FLASH = 9,        /*!< Flash hook */
00269    AST_CONTROL_WINK = 10,        /*!< Wink */
00270    AST_CONTROL_OPTION = 11,      /*!< Set a low-level option */
00271    AST_CONTROL_RADIO_KEY = 12,      /*!< Key Radio */
00272    AST_CONTROL_RADIO_UNKEY = 13, /*!< Un-Key Radio */
00273    AST_CONTROL_PROGRESS = 14,    /*!< Indicate PROGRESS */
00274    AST_CONTROL_PROCEEDING = 15,  /*!< Indicate CALL PROCEEDING */
00275    AST_CONTROL_HOLD = 16,        /*!< Indicate call is placed on hold */
00276    AST_CONTROL_UNHOLD = 17,      /*!< Indicate call is left from hold */
00277    AST_CONTROL_VIDUPDATE = 18,      /*!< Indicate video frame update */
00278    _XXX_AST_CONTROL_T38 = 19,    /*!< T38 state change request/notification \deprecated This is no longer supported. Use AST_CONTROL_T38_PARAMETERS instead. */
00279    AST_CONTROL_SRCUPDATE = 20,      /*!< Indicate source of media has changed */
00280    AST_CONTROL_TRANSFER = 21,    /*!< Indicate status of a transfer request */
00281    AST_CONTROL_CONNECTED_LINE = 22,/*!< Indicate connected line has changed */
00282    AST_CONTROL_REDIRECTING = 23, /*!< Indicate redirecting id has changed */
00283    AST_CONTROL_T38_PARAMETERS = 24,/*!< T38 state change request/notification with parameters */
00284    AST_CONTROL_CC = 25,       /*!< Indication that Call completion service is possible */
00285    AST_CONTROL_SRCCHANGE = 26,      /*!< Media source has changed and requires a new RTP SSRC */
00286    AST_CONTROL_READ_ACTION = 27, /*!< Tell ast_read to take a specific action */
00287    AST_CONTROL_AOC = 28,         /*!< Advice of Charge with encoded generic AOC payload */
00288    AST_CONTROL_END_OF_Q = 29,    /*!< Indicate that this position was the end of the channel queue for a softhangup. */
00289    AST_CONTROL_INCOMPLETE = 30,  /*!< Indication that the extension dialed is incomplete */
00290    AST_CONTROL_MCID = 31,        /*!< Indicate that the caller is being malicious. */
00291    AST_CONTROL_UPDATE_RTP_PEER = 32, /*!< Interrupt the bridge and have it update the peer */
00292    AST_CONTROL_PVT_CAUSE_CODE = 33, /*!< Contains an update to the protocol-specific cause-code stored for branching dials */
00293    AST_CONTROL_MASQUERADE_NOTIFY = 34, /*!< A masquerade is about to begin/end. (Never sent as a frame but directly with ast_indicate_data().) */
00294 
00295    /*
00296     * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
00297     *
00298     * IAX2 sends these values out over the wire.  To prevent future
00299     * incompatibilities, pick the next value in the enum from whatever
00300     * is on the current trunk.  If you lose the merge race you need to
00301     * fix the previous branches to match what is on trunk.  In addition
00302     * you need to change chan_iax2 to explicitly allow the control
00303     * frame over the wire if it makes sense for the frame to be passed
00304     * to another Asterisk instance.
00305     *
00306     * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
00307     */
00308 
00309    /* Control frames used to manipulate a stream on a channel. The values for these
00310     * must be greater than the allowed value for a 8-bit char, so that they avoid
00311     * conflicts with DTMF values. */
00312    AST_CONTROL_STREAM_STOP = 1000,     /*!< Indicate to a channel in playback to stop the stream */
00313    AST_CONTROL_STREAM_SUSPEND = 1001,  /*!< Indicate to a channel in playback to suspend the stream */
00314    AST_CONTROL_STREAM_RESTART = 1002,  /*!< Indicate to a channel in playback to restart the stream */
00315    AST_CONTROL_STREAM_REVERSE = 1003,  /*!< Indicate to a channel in playback to rewind */
00316    AST_CONTROL_STREAM_FORWARD = 1004,  /*!< Indicate to a channel in playback to fast forward */
00317    /* Control frames to manipulate recording on a channel. */
00318    AST_CONTROL_RECORD_CANCEL = 1100,   /*!< Indicated to a channel in record to stop recording and discard the file */
00319    AST_CONTROL_RECORD_STOP = 1101,  /*!< Indicated to a channel in record to stop recording */
00320    AST_CONTROL_RECORD_SUSPEND = 1102,  /*!< Indicated to a channel in record to suspend/unsuspend recording */
00321    AST_CONTROL_RECORD_MUTE = 1103,  /*!< Indicated to a channel in record to mute/unmute (i.e. write silence) recording */
00322 };

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

00341                      {
00342    AST_T38_REQUEST_NEGOTIATE = 1,   /*!< Request T38 on a channel (voice to fax) */
00343    AST_T38_REQUEST_TERMINATE, /*!< Terminate T38 on a channel (fax to voice) */
00344    AST_T38_NEGOTIATED,     /*!< T38 negotiated (fax mode) */
00345    AST_T38_TERMINATED,     /*!< T38 terminated (back to voice) */
00346    AST_T38_REFUSED,     /*!< T38 refused for some reason (usually rejected by remote end) */
00347    AST_T38_REQUEST_PARMS,     /*!< request far end T.38 parameters for a channel in 'negotiating' state */
00348 };

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

00350                           {
00351    AST_T38_RATE_2400 = 1,
00352    AST_T38_RATE_4800,
00353    AST_T38_RATE_7200,
00354    AST_T38_RATE_9600,
00355    AST_T38_RATE_12000,
00356    /* Set to 0 so it's taken as default when unspecified.
00357     * See ITU-T T.38 Implementors' Guide (11 May 2012),
00358     * Table H.2: if the T38MaxBitRate attribute is omitted
00359     * it should use a default of 14400. */
00360    AST_T38_RATE_14400 = 0,
00361 };

Enumerator:
AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF 
AST_T38_RATE_MANAGEMENT_LOCAL_TCF 

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

Enumerator:
AST_TRANSFER_SUCCESS  Transfer request on the channel worked
AST_TRANSFER_FAILED  Transfer request on the channel failed

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

00379                           {
00380    AST_TRANSFER_SUCCESS = 0, /*!< Transfer request on the channel worked */
00381    AST_TRANSFER_FAILED,      /*!< Transfer request on the channel failed */
00382 };

Enumerator:
AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO 

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

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.

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

00096                     {
00097    /*! DTMF end event, subclass is the digit */
00098    AST_FRAME_DTMF_END = 1,
00099    /*! Voice data, subclass is AST_FORMAT_* */
00100    AST_FRAME_VOICE,
00101    /*! Video frame, maybe?? :) */
00102    AST_FRAME_VIDEO,
00103    /*! A control frame, subclass is AST_CONTROL_* */
00104    AST_FRAME_CONTROL,
00105    /*! An empty, useless frame */
00106    AST_FRAME_NULL,
00107    /*! Inter Asterisk Exchange private frame type */
00108    AST_FRAME_IAX,
00109    /*! Text messages */
00110    AST_FRAME_TEXT,
00111    /*! Image Frames */
00112    AST_FRAME_IMAGE,
00113    /*! HTML Frame */
00114    AST_FRAME_HTML,
00115    /*! Comfort Noise frame (subclass is level of CNG in -dBov),
00116        body may include zero or more 8-bit quantization coefficients */
00117    AST_FRAME_CNG,
00118    /*! Modem-over-IP data streams */
00119    AST_FRAME_MODEM,
00120    /*! DTMF begin event, subclass is the digit */
00121    AST_FRAME_DTMF_BEGIN,
00122    /*! Internal bridge module action. */
00123    AST_FRAME_BRIDGE_ACTION,
00124    /*! Internal synchronous bridge module action.
00125     * Synchronous bridge actions may be queued onto bridge
00126     * channels, but they absolutely must not ever be written
00127     * directly into bridges.
00128     */
00129    AST_FRAME_BRIDGE_ACTION_SYNC,
00130 };


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:
f The frame containing the samples (must be AST_FRAME_VOICE and AST_FORMAT_SLINEAR)
adjustment The number of dB to adjust up or down.
Returns:
0 for success, non-zero for an error

Definition at line 650 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(), conf_run(), and volume_callback().

00651 {
00652    int count;
00653    short *fdata = f->data.ptr;
00654    short adjust_value = abs(adjustment);
00655 
00656    if ((f->frametype != AST_FRAME_VOICE) || !(ast_format_cache_is_slinear(f->subclass.format))) {
00657       return -1;
00658    }
00659 
00660    if (!adjustment) {
00661       return 0;
00662    }
00663 
00664    for (count = 0; count < f->samples; count++) {
00665       if (adjustment > 0) {
00666          ast_slinear_saturated_multiply(&fdata[count], &adjust_value);
00667       } else if (adjustment < 0) {
00668          ast_slinear_saturated_divide(&fdata[count], &adjust_value);
00669       }
00670    }
00671 
00672    return 0;
00673 }

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 697 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 ast_audiohook_write_frame().

00698 {
00699    struct ast_frame *next;
00700 
00701    for (next = AST_LIST_NEXT(frame, frame_list);
00702        frame;
00703        frame = next, next = frame ? AST_LIST_NEXT(frame, frame_list) : NULL) {
00704       memset(frame->data.ptr, 0, frame->datalen);
00705    }
00706    return 0;
00707 }

void ast_frame_dtor ( struct ast_frame frame  ) 

NULL-safe wrapper for ast_frfree, good for RAII_VAR.

Parameters:
frame Frame to free, or head of list to free.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

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

References ast_frfree.

Referenced by __ast_play_and_record(), and stasis_app_exec().

00176 {
00177    if (f) {
00178       ast_frfree(f);
00179    }
00180 }

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

Dump a frame for debugging purposes

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

References 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().

00598 {
00599    const char noname[] = "unknown";
00600    char ftype[40] = "Unknown Frametype";
00601    char cft[80];
00602    char subclass[40] = "Unknown Subclass";
00603    char csub[80];
00604    char moreinfo[40] = "";
00605    char cn[60];
00606    char cp[40];
00607    char cmn[40];
00608 
00609    if (!name) {
00610       name = noname;
00611    }
00612 
00613    if (!f) {
00614       ast_verb(-1, "%s [ %s (NULL) ] [%s]\n",
00615          term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
00616          term_color(cft, "HANGUP", COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
00617          term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
00618       return;
00619    }
00620    /* XXX We should probably print one each of voice and video when the format changes XXX */
00621    if (f->frametype == AST_FRAME_VOICE) {
00622       return;
00623    }
00624    if (f->frametype == AST_FRAME_VIDEO) {
00625       return;
00626    }
00627 
00628    ast_frame_type2str(f->frametype, ftype, sizeof(ftype));
00629    ast_frame_subclass2str(f, subclass, sizeof(subclass), moreinfo, sizeof(moreinfo));
00630 
00631    if (!ast_strlen_zero(moreinfo))
00632       ast_verb(-1, "%s [ TYPE: %s (%u) SUBCLASS: %s (%d) '%s' ] [%s]\n",
00633              term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
00634              term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
00635              f->frametype,
00636              term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
00637              f->subclass.integer,
00638              term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK, sizeof(cmn)),
00639              term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
00640    else
00641       ast_verb(-1, "%s [ TYPE: %s (%u) SUBCLASS: %s (%d) ] [%s]\n",
00642              term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
00643              term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
00644              f->frametype,
00645              term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
00646              f->subclass.integer,
00647              term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
00648 }

struct ast_frame* ast_frame_enqueue ( struct ast_frame head,
struct ast_frame f,
int  maxlen,
int  dupe 
) [read]

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 fr,
int  cache 
)

Requests a frame to be allocated.

Parameters:
source Request 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:
fr Frame to free, or head of list to free
cache Whether to consider this frame for frame caching

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

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

Referenced by mixmonitor_thread().

00165 {
00166    struct ast_frame *next;
00167 
00168    for (next = AST_LIST_NEXT(frame, frame_list);
00169         frame;
00170         frame = next, next = frame ? AST_LIST_NEXT(frame, frame_list) : NULL) {
00171       __frame_free(frame, cache);
00172    }
00173 }

int ast_frame_slinear_sum ( struct ast_frame f1,
struct ast_frame f2 
)

Sums two frames of audio samples.

Parameters:
f1 The first frame (which will contain the result)
f2 The 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 675 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.

00676 {
00677    int count;
00678    short *data1, *data2;
00679 
00680    if ((f1->frametype != AST_FRAME_VOICE) || (ast_format_cmp(f1->subclass.format, ast_format_slin) != AST_FORMAT_CMP_NOT_EQUAL))
00681       return -1;
00682 
00683    if ((f2->frametype != AST_FRAME_VOICE) || (ast_format_cmp(f2->subclass.format, ast_format_slin) != AST_FORMAT_CMP_NOT_EQUAL))
00684       return -1;
00685 
00686    if (f1->samples != f2->samples)
00687       return -1;
00688 
00689    for (count = 0, data1 = f1->data.ptr, data2 = f2->data.ptr;
00690         count < f1->samples;
00691         count++, data1++, data2++)
00692       ast_slinear_saturated_add(data1, data2);
00693 
00694    return 0;
00695 }

void 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:
f The frame to get the information from
subclass Buffer to fill with subclass information
slen Length of subclass buffer
moreinfo Buffer to fill with additional information
mlen Length of moreinfo buffer
Since:
11

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

References AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_UNHOLD, 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_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().

00373 {
00374    switch(f->frametype) {
00375    case AST_FRAME_DTMF_BEGIN:
00376       if (slen > 1) {
00377          subclass[0] = f->subclass.integer;
00378          subclass[1] = '\0';
00379       }
00380       break;
00381    case AST_FRAME_DTMF_END:
00382       if (slen > 1) {
00383          subclass[0] = f->subclass.integer;
00384          subclass[1] = '\0';
00385       }
00386       break;
00387    case AST_FRAME_CONTROL:
00388       switch (f->subclass.integer) {
00389       case AST_CONTROL_HANGUP:
00390          ast_copy_string(subclass, "Hangup", slen);
00391          break;
00392       case AST_CONTROL_RING:
00393          ast_copy_string(subclass, "Ring", slen);
00394          break;
00395       case AST_CONTROL_RINGING:
00396          ast_copy_string(subclass, "Ringing", slen);
00397          break;
00398       case AST_CONTROL_ANSWER:
00399          ast_copy_string(subclass, "Answer", slen);
00400          break;
00401       case AST_CONTROL_BUSY:
00402          ast_copy_string(subclass, "Busy", slen);
00403          break;
00404       case AST_CONTROL_TAKEOFFHOOK:
00405          ast_copy_string(subclass, "Take Off Hook", slen);
00406          break;
00407       case AST_CONTROL_OFFHOOK:
00408          ast_copy_string(subclass, "Line Off Hook", slen);
00409          break;
00410       case AST_CONTROL_CONGESTION:
00411          ast_copy_string(subclass, "Congestion", slen);
00412          break;
00413       case AST_CONTROL_FLASH:
00414          ast_copy_string(subclass, "Flash", slen);
00415          break;
00416       case AST_CONTROL_WINK:
00417          ast_copy_string(subclass, "Wink", slen);
00418          break;
00419       case AST_CONTROL_OPTION:
00420          ast_copy_string(subclass, "Option", slen);
00421          break;
00422       case AST_CONTROL_RADIO_KEY:
00423          ast_copy_string(subclass, "Key Radio", slen);
00424          break;
00425       case AST_CONTROL_RADIO_UNKEY:
00426          ast_copy_string(subclass, "Unkey Radio", slen);
00427          break;
00428       case AST_CONTROL_HOLD:
00429          ast_copy_string(subclass, "Hold", slen);
00430          break;
00431       case AST_CONTROL_UNHOLD:
00432          ast_copy_string(subclass, "Unhold", slen);
00433          break;
00434       case AST_CONTROL_T38_PARAMETERS: {
00435          char *message = "Unknown";
00436          if (f->datalen != sizeof(struct ast_control_t38_parameters)) {
00437             message = "Invalid";
00438          } else {
00439             struct ast_control_t38_parameters *parameters = f->data.ptr;
00440             enum ast_control_t38 state = parameters->request_response;
00441             if (state == AST_T38_REQUEST_NEGOTIATE)
00442                message = "Negotiation Requested";
00443             else if (state == AST_T38_REQUEST_TERMINATE)
00444                message = "Negotiation Request Terminated";
00445             else if (state == AST_T38_NEGOTIATED)
00446                message = "Negotiated";
00447             else if (state == AST_T38_TERMINATED)
00448                message = "Terminated";
00449             else if (state == AST_T38_REFUSED)
00450                message = "Refused";
00451          }
00452          snprintf(subclass, slen, "T38_Parameters/%s", message);
00453          break;
00454       }
00455       case -1:
00456          ast_copy_string(subclass, "Stop generators", slen);
00457          break;
00458       default:
00459          snprintf(subclass, slen, "Unknown control '%d'", f->subclass.integer);
00460       }
00461       break;
00462    case AST_FRAME_NULL:
00463       ast_copy_string(subclass, "N/A", slen);
00464       break;
00465    case AST_FRAME_IAX:
00466       /* Should never happen */
00467       snprintf(subclass, slen, "IAX Frametype %d", f->subclass.integer);
00468       break;
00469    case AST_FRAME_BRIDGE_ACTION:
00470       /* Should never happen */
00471       snprintf(subclass, slen, "Bridge Frametype %d", f->subclass.integer);
00472       break;
00473    case AST_FRAME_BRIDGE_ACTION_SYNC:
00474       /* Should never happen */
00475       snprintf(subclass, slen, "Synchronous Bridge Frametype %d", f->subclass.integer);
00476       break;
00477    case AST_FRAME_TEXT:
00478       ast_copy_string(subclass, "N/A", slen);
00479       if (moreinfo) {
00480          ast_copy_string(moreinfo, f->data.ptr, mlen);
00481       }
00482       break;
00483    case AST_FRAME_IMAGE:
00484       snprintf(subclass, slen, "Image format %s\n", ast_format_get_name(f->subclass.format));
00485       break;
00486    case AST_FRAME_HTML:
00487       switch (f->subclass.integer) {
00488       case AST_HTML_URL:
00489          ast_copy_string(subclass, "URL", slen);
00490          if (moreinfo) {
00491             ast_copy_string(moreinfo, f->data.ptr, mlen);
00492          }
00493          break;
00494       case AST_HTML_DATA:
00495          ast_copy_string(subclass, "Data", slen);
00496          break;
00497       case AST_HTML_BEGIN:
00498          ast_copy_string(subclass, "Begin", slen);
00499          break;
00500       case AST_HTML_END:
00501          ast_copy_string(subclass, "End", slen);
00502          break;
00503       case AST_HTML_LDCOMPLETE:
00504          ast_copy_string(subclass, "Load Complete", slen);
00505          break;
00506       case AST_HTML_NOSUPPORT:
00507          ast_copy_string(subclass, "No Support", slen);
00508          break;
00509       case AST_HTML_LINKURL:
00510          ast_copy_string(subclass, "Link URL", slen);
00511          if (moreinfo) {
00512             ast_copy_string(moreinfo, f->data.ptr, mlen);
00513          }
00514          break;
00515       case AST_HTML_UNLINK:
00516          ast_copy_string(subclass, "Unlink", slen);
00517          break;
00518       case AST_HTML_LINKREJECT:
00519          ast_copy_string(subclass, "Link Reject", slen);
00520          break;
00521       default:
00522          snprintf(subclass, slen, "Unknown HTML frame '%d'\n", f->subclass.integer);
00523          break;
00524       }
00525       break;
00526    case AST_FRAME_MODEM:
00527       switch (f->subclass.integer) {
00528       case AST_MODEM_T38:
00529          ast_copy_string(subclass, "T.38", slen);
00530          break;
00531       case AST_MODEM_V150:
00532          ast_copy_string(subclass, "V.150", slen);
00533          break;
00534       default:
00535          snprintf(subclass, slen, "Unknown MODEM frame '%d'\n", f->subclass.integer);
00536          break;
00537       }
00538       break;
00539    default:
00540       ast_copy_string(subclass, "Unknown Subclass", slen);
00541       break;
00542    }
00543 }

void 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_type The frame type to be described
ftype Buffer to fill with frame type description
len Length of subclass buffer
Since:
11

Definition at line 545 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_TEXT, AST_FRAME_VIDEO, and AST_FRAME_VOICE.

Referenced by ast_frame_dump().

00546 {
00547    switch (frame_type) {
00548    case AST_FRAME_DTMF_BEGIN:
00549       ast_copy_string(ftype, "DTMF Begin", len);
00550       break;
00551    case AST_FRAME_DTMF_END:
00552       ast_copy_string(ftype, "DTMF End", len);
00553       break;
00554    case AST_FRAME_CONTROL:
00555       ast_copy_string(ftype, "Control", len);
00556       break;
00557    case AST_FRAME_NULL:
00558       ast_copy_string(ftype, "Null Frame", len);
00559       break;
00560    case AST_FRAME_IAX:
00561       /* Should never happen */
00562       ast_copy_string(ftype, "IAX Specific", len);
00563       break;
00564    case AST_FRAME_BRIDGE_ACTION:
00565       /* Should never happen */
00566       ast_copy_string(ftype, "Bridge Specific", len);
00567       break;
00568    case AST_FRAME_BRIDGE_ACTION_SYNC:
00569       /* Should never happen */
00570       ast_copy_string(ftype, "Bridge Specific", len);
00571       break;
00572    case AST_FRAME_TEXT:
00573       ast_copy_string(ftype, "Text", len);
00574       break;
00575    case AST_FRAME_IMAGE:
00576       ast_copy_string(ftype, "Image", len);
00577       break;
00578    case AST_FRAME_HTML:
00579       ast_copy_string(ftype, "HTML", len);
00580       break;
00581    case AST_FRAME_MODEM:
00582       ast_copy_string(ftype, "Modem", len);
00583       break;
00584    case AST_FRAME_VOICE:
00585       ast_copy_string(ftype, "Voice", len);
00586       break;
00587    case AST_FRAME_VIDEO:
00588       ast_copy_string(ftype, "Video", len);
00589       break;
00590    default:
00591       snprintf(ftype, len, "Unknown Frametype '%u'", frame_type);
00592       break;
00593    }
00594 }

struct ast_frame* ast_frdup ( const struct ast_frame fr  )  [read]

Copies a frame.

Parameters:
fr frame 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 275 of file main/frame.c.

References ao2_bump, ast_calloc_cache, ast_copy_flags, AST_FLAGS_ALL, AST_FRAME_IMAGE, 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::subclass, ast_frame::ts, and ast_frame::uint32.

Referenced by __ast_queue_frame(), ast_bridge_channel_queue_frame(), ast_bridge_queue_action(), ast_frisolate(), ast_indicate_data(), ast_jb_put(), ast_rtp_write(), ast_slinfactory_feed(), audiohook_read_frame_both(), audiohook_read_frame_single(), autoservice_run(), hook_event_cb(), multicast_rtp_write(), ooh323_rtp_read(), process_dtmf_rfc2833(), recordthread(), smart_bridge_operation(), and t38_parameters_task_data_alloc().

00276 {
00277    struct ast_frame *out = NULL;
00278    int len, srclen = 0;
00279    void *buf = NULL;
00280 
00281 #if !defined(LOW_MEMORY)
00282    struct ast_frame_cache *frames;
00283 #endif
00284 
00285    /* Start with standard stuff */
00286    len = sizeof(*out) + AST_FRIENDLY_OFFSET + f->datalen;
00287    /* If we have a source, add space for it */
00288    /*
00289     * XXX Watch out here - if we receive a src which is not terminated
00290     * properly, we can be easily attacked. Should limit the size we deal with.
00291     */
00292    if (f->src)
00293       srclen = strlen(f->src);
00294    if (srclen > 0)
00295       len += srclen + 1;
00296 
00297 #if !defined(LOW_MEMORY)
00298    if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
00299       AST_LIST_TRAVERSE_SAFE_BEGIN(&frames->list, out, frame_list) {
00300          if (out->mallocd_hdr_len >= len) {
00301             size_t mallocd_len = out->mallocd_hdr_len;
00302 
00303             AST_LIST_REMOVE_CURRENT(frame_list);
00304             memset(out, 0, sizeof(*out));
00305             out->mallocd_hdr_len = mallocd_len;
00306             buf = out;
00307             frames->size--;
00308             break;
00309          }
00310       }
00311       AST_LIST_TRAVERSE_SAFE_END;
00312    }
00313 #endif
00314 
00315    if (!buf) {
00316       if (!(buf = ast_calloc_cache(1, len)))
00317          return NULL;
00318       out = buf;
00319       out->mallocd_hdr_len = len;
00320    }
00321 
00322    out->frametype = f->frametype;
00323    if ((f->frametype == AST_FRAME_VOICE) || (f->frametype == AST_FRAME_VIDEO) ||
00324       (f->frametype == AST_FRAME_IMAGE)) {
00325       out->subclass.format = ao2_bump(f->subclass.format);
00326    } else {
00327       memcpy(&out->subclass, &f->subclass, sizeof(out->subclass));
00328    }
00329    out->datalen = f->datalen;
00330    out->samples = f->samples;
00331    out->delivery = f->delivery;
00332    /* Even though this new frame was allocated from the heap, we can't mark it
00333     * with AST_MALLOCD_HDR, AST_MALLOCD_DATA and AST_MALLOCD_SRC, because that
00334     * would cause ast_frfree() to attempt to individually free each of those
00335     * under the assumption that they were separately allocated. Since this frame
00336     * was allocated in a single allocation, we'll only mark it as if the header
00337     * was heap-allocated; this will result in the entire frame being properly freed.
00338     */
00339    out->mallocd = AST_MALLOCD_HDR;
00340    out->offset = AST_FRIENDLY_OFFSET;
00341    if (out->datalen) {
00342       out->data.ptr = buf + sizeof(*out) + AST_FRIENDLY_OFFSET;
00343       memcpy(out->data.ptr, f->data.ptr, out->datalen);
00344    } else {
00345       out->data.uint32 = f->data.uint32;
00346    }
00347    if (srclen > 0) {
00348       /* This may seem a little strange, but it's to avoid a gcc (4.2.4) compiler warning */
00349       char *src;
00350       out->src = buf + sizeof(*out) + AST_FRIENDLY_OFFSET + f->datalen;
00351       src = (char *) out->src;
00352       /* Must have space since we allocated for it */
00353       strcpy(src, f->src);
00354    }
00355    ast_copy_flags(out, f, AST_FLAGS_ALL);
00356    out->ts = f->ts;
00357    out->len = f->len;
00358    out->seqno = f->seqno;
00359    return out;
00360 }

struct ast_frame* ast_frisolate ( struct ast_frame fr  )  [read]

Makes a frame independent of any static storage.

Parameters:
fr frame 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 187 of file main/frame.c.

References ao2_bump, ast_copy_flags, AST_FLAGS_ALL, ast_frame_header_new(), AST_FRAME_IMAGE, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frdup(), ast_free, 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::subclass, ast_frame::ts, and ast_frame::uint32.

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

00188 {
00189    struct ast_frame *out;
00190    void *newdata;
00191 
00192    /* if none of the existing frame is malloc'd, let ast_frdup() do it
00193       since it is more efficient
00194    */
00195    if (fr->mallocd == 0) {
00196       return ast_frdup(fr);
00197    }
00198 
00199    /* if everything is already malloc'd, we are done */
00200    if ((fr->mallocd & (AST_MALLOCD_HDR | AST_MALLOCD_SRC | AST_MALLOCD_DATA)) ==
00201        (AST_MALLOCD_HDR | AST_MALLOCD_SRC | AST_MALLOCD_DATA)) {
00202       return fr;
00203    }
00204 
00205    if (!(fr->mallocd & AST_MALLOCD_HDR)) {
00206       /* Allocate a new header if needed */
00207       if (!(out = ast_frame_header_new())) {
00208          return NULL;
00209       }
00210       out->frametype = fr->frametype;
00211       if ((fr->frametype == AST_FRAME_VOICE) || (fr->frametype == AST_FRAME_VIDEO) ||
00212          (fr->frametype == AST_FRAME_IMAGE)) {
00213          out->subclass.format = ao2_bump(fr->subclass.format);
00214       } else {
00215          memcpy(&out->subclass, &fr->subclass, sizeof(out->subclass));
00216       }
00217       out->datalen = fr->datalen;
00218       out->samples = fr->samples;
00219       out->offset = fr->offset;
00220       /* Copy the timing data */
00221       ast_copy_flags(out, fr, AST_FLAGS_ALL);
00222       if (ast_test_flag(fr, AST_FRFLAG_HAS_TIMING_INFO)) {
00223          out->ts = fr->ts;
00224          out->len = fr->len;
00225          out->seqno = fr->seqno;
00226       }
00227    } else {
00228       out = fr;
00229    }
00230 
00231    if (!(fr->mallocd & AST_MALLOCD_SRC) && fr->src) {
00232       if (!(out->src = ast_strdup(fr->src))) {
00233          if (out != fr) {
00234             ast_free(out);
00235          }
00236          return NULL;
00237       }
00238    } else {
00239       out->src = fr->src;
00240       fr->src = NULL;
00241       fr->mallocd &= ~AST_MALLOCD_SRC;
00242    }
00243 
00244    if (!(fr->mallocd & AST_MALLOCD_DATA))  {
00245       if (!fr->datalen) {
00246          out->data.uint32 = fr->data.uint32;
00247          out->mallocd = AST_MALLOCD_HDR | AST_MALLOCD_SRC;
00248          return out;
00249       }
00250       if (!(newdata = ast_malloc(fr->datalen + AST_FRIENDLY_OFFSET))) {
00251          if (out->src != fr->src) {
00252             ast_free((void *) out->src);
00253          }
00254          if (out != fr) {
00255             ast_free(out);
00256          }
00257          return NULL;
00258       }
00259       newdata += AST_FRIENDLY_OFFSET;
00260       out->offset = AST_FRIENDLY_OFFSET;
00261       out->datalen = fr->datalen;
00262       memcpy(newdata, fr->data.ptr, fr->datalen);
00263       out->data.ptr = newdata;
00264    } else {
00265       out->data = fr->data;
00266       memset(&fr->data, 0, sizeof(fr->data));
00267       fr->mallocd &= ~AST_MALLOCD_DATA;
00268    }
00269 
00270    out->mallocd = AST_MALLOCD_HDR | AST_MALLOCD_SRC | AST_MALLOCD_DATA;
00271 
00272    return out;
00273 }

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

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

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

00363 {
00364    int i;
00365    unsigned short *dst_s = dst;
00366    const unsigned short *src_s = src;
00367 
00368    for (i = 0; i < samples; i++)
00369       dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8);
00370 }


Variable Documentation


Generated on Thu Apr 16 06:31:09 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6