Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:48:55 2009

## Asterisk developer's documentation

# frame.h File Reference

Asterisk internal frame definitions. More...

`#include <sys/types.h>`
`#include <sys/time.h>`
`#include "asterisk/endian.h"`

Include dependency graph for frame.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | ast_codec_pref
struct | ast_frame
| Data structure associated with a single frame of data. More...
struct | ast_option_header

## Defines

#define | AST_CONTROL_ANSWER 4
#define | AST_CONTROL_BUSY 5
#define | AST_CONTROL_CONGESTION 8
#define | AST_CONTROL_FLASH 9
#define | AST_CONTROL_HANGUP 1
#define | AST_CONTROL_HOLD 16
#define | AST_CONTROL_OFFHOOK 7
#define | AST_CONTROL_OPTION 11
#define | AST_CONTROL_PROCEEDING 15
#define | AST_CONTROL_PROGRESS 14
#define | AST_CONTROL_RADIO_KEY 12
#define | AST_CONTROL_RADIO_UNKEY 13
#define | AST_CONTROL_RING 2
#define | AST_CONTROL_RINGING 3
#define | AST_CONTROL_TAKEOFFHOOK 6
#define | AST_CONTROL_UNHOLD 17
#define | AST_CONTROL_VIDUPDATE 18
#define | AST_CONTROL_WINK 10
#define | AST_FORMAT_ADPCM (1 << 5)
#define | AST_FORMAT_ALAW (1 << 3)
#define | AST_FORMAT_G723_1 (1 << 0)
#define | AST_FORMAT_G726 (1 << 4)
#define | AST_FORMAT_G729A (1 << 8)
#define | AST_FORMAT_GSM (1 << 1)
#define | AST_FORMAT_H261 (1 << 18)
#define | AST_FORMAT_H263 (1 << 19)
#define | AST_FORMAT_H263_PLUS (1 << 20)
#define | AST_FORMAT_ILBC (1 << 10)
#define | AST_FORMAT_JPEG (1 << 16)
#define | AST_FORMAT_LPC10 (1 << 7)
#define | AST_FORMAT_MAX_AUDIO (1 << 15)
#define | AST_FORMAT_MAX_VIDEO (1 << 24)
#define | AST_FORMAT_PNG (1 << 17)
#define | AST_FORMAT_SLINEAR (1 << 6)
#define | AST_FORMAT_SPEEX (1 << 9)
#define | AST_FORMAT_ULAW (1 << 2)
#define | ast_frame_byteswap_be(fr) do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__f->data, __f->data, __f->samples); } while(0)
#define | ast_frame_byteswap_le(fr) do { ; } while(0)
#define | AST_FRAME_CNG 10
#define | AST_FRAME_CONTROL 4
#define | AST_FRAME_DTMF 1
#define | AST_FRAME_HTML 9
#define | AST_FRAME_IAX 6
#define | AST_FRAME_IMAGE 8
#define | AST_FRAME_NULL 5
#define | AST_FRAME_T38 11
#define | AST_FRAME_TEXT 7
#define | AST_FRAME_VIDEO 3
#define | AST_FRAME_VOICE 2
#define | AST_FRIENDLY_OFFSET 64
#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_OPTION_AUDIO_MODE 4
#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_RELAXDTMF 3
#define | AST_OPTION_RXGAIN 6
#define | AST_OPTION_TDD 2
#define | AST_OPTION_TONE_VERIFY 1
#define | AST_OPTION_TXGAIN 5
#define | ast_smoother_feed(s, f) __ast_smoother_feed(s, f, 0)
#define | ast_smoother_feed_be(s, f) __ast_smoother_feed(s, f, 1)
#define | ast_smoother_feed_le(s, f) __ast_smoother_feed(s, f, 0)
#define | AST_SMOOTHER_FLAG_G729 (1 << 0)

## Functions

int | __ast_smoother_feed (struct ast_smoother *s, struct ast_frame *f, int swap)
char * | ast_codec2str (int codec)
| Get a name from a format Gets a name from a format.
int | ast_codec_choose (struct ast_codec_pref *pref, int formats, int find_best)
| Select the best format according to preference list from supplied options. If "find_best" is non-zero then if nothing is found, the "Best" format of the format list is selected, otherwise 0 is returned.
int | ast_codec_get_len (int format, int samples)
| Returns the number of bytes for the number of samples of the given format.
int | ast_codec_get_samples (struct ast_frame *f)
| Returns the number of samples contained in the frame.
static int | ast_codec_interp_len (int format)
| Gets duration in ms of interpolation frame for a format.
int | ast_codec_pref_append (struct ast_codec_pref *pref, int format)
| Append a codec to a preference list, removing it first if it was already there.
void | ast_codec_pref_convert (struct ast_codec_pref *pref, char *buf, size_t size, int right)
| Shift a codec preference list up or down 65 bytes so that it becomes an ASCII string.
int | ast_codec_pref_index (struct ast_codec_pref *pref, int index)
| Codec located at a particular place in the preference index.
void | ast_codec_pref_init (struct ast_codec_pref *pref)
| Initialize a codec preference to "no preference".
void | ast_codec_pref_remove (struct ast_codec_pref *pref, int format)
| Remove a codec from a preference list.
int | ast_codec_pref_string (struct ast_codec_pref *pref, char *buf, size_t size)
| Dump codec preference list into a string.
int | ast_fr_fdhangup (int fd)
| Sends a hangup to an fd Send a hangup (NULL equivalent) on an fd.
struct ast_frame * | ast_fr_fdread (int fd)
| Reads a frame from an fd Read a frame from a stream or packet fd, as written by fd_write.
int | ast_fr_fdwrite (int fd, struct ast_frame *frame)
int | ast_frame_adjust_volume (struct ast_frame *f, int adjustment)
| Adjusts the volume of the audio samples contained in a frame.
void | ast_frame_dump (char *name, struct ast_frame *f, char *prefix)
int | ast_frame_slinear_sum (struct ast_frame *f1, struct ast_frame *f2)
| Sums two frames of audio samples.
struct ast_frame * | ast_frdup (struct ast_frame *fr)
| Copies a frame.
void | ast_frfree (struct ast_frame *fr)
| Requests a frame to be allocated.
struct ast_frame * | ast_frisolate (struct ast_frame *fr)
| Copies a frame.
struct ast_format_list * | ast_get_format_list (size_t *size)
struct ast_format_list * | ast_get_format_list_index (int index)
int | ast_getformatbyname (char *name)
| Gets a format from a name.
char * | ast_getformatname (int format)
| Get the name of a format.
char * | ast_getformatname_multiple (char *buf, size_t size, int format)
| Get the names of a set of formats.
void | ast_parse_allow_disallow (struct ast_codec_pref *pref, int *mask, const char *list, int allowing)
| Parse an "allow" or "deny" line and update the mask and pref if provided.
void | ast_smoother_free (struct ast_smoother *s)
int | ast_smoother_get_flags (struct ast_smoother *smoother)
struct ast_smoother * | ast_smoother_new (int bytes)
struct ast_frame * | ast_smoother_read (struct ast_smoother *s)
void | ast_smoother_reset (struct ast_smoother *s, int bytes)
void | ast_smoother_set_flags (struct ast_smoother *smoother, int flags)
void | ast_swapcopy_samples (void *dst, const void *src, int samples)

## Detailed Description

Asterisk internal frame definitions.

- For an explanation of frames, see AST Multimedia and signalling frames
- Frames are send of Asterisk channels, see Asterisk Channels

Definition in file frame.h.

## Define Documentation

#define AST_CONTROL_ANSWER 4

Remote end has answered

Definition at line 217 of file frame.h.

Referenced by __ast_dsp_call_progress(), __ast_request_and_dial(), agent_read(), alsa_call(), ast_dsp_process(), ast_feature_request_and_dial(), ast_frame_dump(), ast_pickup_call(), ast_read(), ast_waitfordigit_full(), ast_waitstream(), ast_waitstream_exten(), ast_waitstream_fr(), ast_waitstream_full(), cb_events(), connection_made(), console_answer(), console_sendtext(), control2str(), handle_hd_hf(), handle_message(), handle_response_invite(), i4l_handle_escape(), iax2_answer(), local_answer(), misdn_indication(), monitor_handle_owned(), nbs_call(), oss_answer(), oss_call(), phone_exception(), pickup_exec(), rpt(), vpb_indicate(), wait_for_answer(), zt_handle_dtmfup(), zt_handle_event(), and zt_read().

#define AST_CONTROL_BUSY 5

Remote end is busy

Definition at line 219 of file frame.h.

Referenced by __ast_dsp_call_progress(), __ast_request_and_dial(), alsa_indicate(), aopen_handle_escape(), ast_bridge_call(), ast_dsp_process(), ast_feature_request_and_dial(), ast_frame_dump(), ast_indicate(), ast_waitstream(), ast_waitstream_exten(), ast_waitstream_fr(), ast_waitstream_full(), async_wait(), bestdata_handle_escape(), builtin_atxfer(), cb_events(), control2str(), handle_response(), i4l_handle_escape(), mgcp_indicate(), misdn_indication(), monitor_handle_owned(), oh323_indicate(), oss_indicate(), pbx_builtin_busy(), rpt_exec(), send_cause2ast(), sip_indicate(), skinny_call(), skinny_indicate(), vpb_indicate(), wait_for_answer(), zt_indicate(), and zt_read().

#define AST_CONTROL_CONGESTION 8

Congestion (circuits busy)

Definition at line 225 of file frame.h.

Referenced by __ast_dsp_call_progress(), __ast_request_and_dial(), alsa_indicate(), ast_bridge_call(), ast_dsp_process(), ast_feature_request_and_dial(), ast_frame_dump(), ast_indicate(), ast_waitstream(), ast_waitstream_exten(), ast_waitstream_fr(), ast_waitstream_full(), async_wait(), auto_congest(), control2str(), disa_exec(), handle_response(), handle_response_invite(), mgcp_indicate(), misdn_indication(), monitor_handle_owned(), nbs_call(), oh323_indicate(), oss_hangup(), oss_indicate(), pbx_builtin_congestion(), sip_indicate(), skinny_indicate(), socket_read(), vpb_indicate(), wait_for_answer(), zt_indicate(), and zt_read().

#define AST_CONTROL_FLASH 9

Flash hook

Definition at line 227 of file frame.h.

Referenced by ast_bridge_call(), ast_frame_dump(), console_flash(), control2str(), handle_request_info(), misdn_indication(), monitor_handle_owned(), send_dtmf(), wait_for_answer(), zt_indicate(), and zt_read().

#define AST_CONTROL_HANGUP 1

Other end has hungup

Definition at line 211 of file frame.h.

Referenced by __ast_dsp_call_progress(), __ast_request_and_dial(), app_exec(), ast_bridge_call(), ast_dsp_process(), ast_feature_request_and_dial(), ast_frame_dump(), ast_queue_frame(), ast_queue_hangup(), ast_read(), ast_recvtext(), ast_waitfordigit_full(), ast_waitstream(), ast_waitstream_exten(), ast_waitstream_fr(), ast_waitstream_full(), attempt_transmit(), control2str(), disa_exec(), do_parking_thread(), local_hangup(), monitor_handle_owned(), receive_dtmf_digits(), rpt(), rpt_exec(), vpb_indicate(), and wait_for_answer().

#define AST_CONTROL_HOLD 16

Indicate call is placed on hold

Definition at line 241 of file frame.h.

Referenced by ast_generic_bridge(), ast_indicate(), ast_park_call(), ast_rtp_bridge(), builtin_atxfer(), builtin_blindtransfer(), control2str(), misdn_indication(), sip_indicate(), wait_for_answer(), and zt_indicate().

#define AST_CONTROL_OFFHOOK 7

Line is off hook

Definition at line 223 of file frame.h.

Referenced by ast_frame_dump(), control2str(), misdn_indication(), wait_for_answer(), and zt_handle_event().

#define AST_CONTROL_OPTION 11

Set a low-level option

Definition at line 231 of file frame.h.

Referenced by ast_bridge_call(), ast_frame_dump(), control2str(), and iax2_setoption().

#define AST_CONTROL_PROCEEDING 15

Indicate CALL PROCEEDING

Definition at line 239 of file frame.h.

Referenced by __ast_request_and_dial(), ast_indicate(), cb_events(), control2str(), misdn_indication(), oh323_indicate(), sip_indicate(), skinny_indicate(), wait_for_answer(), and zt_indicate().

#define AST_CONTROL_PROGRESS 14

Indicate PROGRESS

Definition at line 237 of file frame.h.

Referenced by __ast_request_and_dial(), ast_indicate(), cb_events(), control2str(), dial_exec_full(), handle_response(), handle_response_invite(), misdn_indication(), oh323_indicate(), pbx_builtin_progress(), progress(), setup_rtp_connection(), sip_indicate(), skinny_indicate(), socket_read(), wait_for_answer(), and zt_indicate().

#define AST_CONTROL_RADIO_KEY 12

Key Radio

Definition at line 233 of file frame.h.

Referenced by ast_frame_dump(), control2str(), function_remote(), handle_remote_data(), handle_remote_phone_dtmf(), rmt_telem_start(), rpt(), rpt_exec(), zt_handle_event(), zt_indicate(), and zt_read().

#define AST_CONTROL_RADIO_UNKEY 13

Un-Key Radio

Definition at line 235 of file frame.h.

Referenced by ast_frame_dump(), control2str(), function_remote(), handle_remote_data(), handle_remote_phone_dtmf(), rmt_telem_finish(), rmt_telem_start(), rpt(), rpt_exec(), zt_handle_event(), zt_indicate(), and zt_read().

#define AST_CONTROL_RING 2

Local ring

Definition at line 213 of file frame.h.

Referenced by aopen_handle_escape(), ast_frame_dump(), bestdata_handle_escape(), control2str(), i4l_handle_escape(), misdn_indication(), modem_mini_packet(), monitor_handle_owned(), oss_call(), ss_thread(), waitforring_exec(), and zt_handle_event().

#define AST_CONTROL_RINGING 3

Remote end is ringing

Definition at line 215 of file frame.h.

Referenced by __ast_dsp_call_progress(), __ast_request_and_dial(), alsa_call(), alsa_indicate(), ast_bridge_call(), ast_dsp_process(), ast_feature_request_and_dial(), ast_frame_dump(), ast_indicate(), ast_waitfordigit_full(), ast_waitstream(), ast_waitstream_exten(), ast_waitstream_fr(), ast_waitstream_full(), attempt_transfer(), cb_events(), chan_ringing(), control2str(), dial_exec_full(), handle_response_invite(), i4l_handle_escape(), mgcp_call(), mgcp_indicate(), misdn_indication(), oh323_indicate(), oss_call(), oss_indicate(), pbx_builtin_ringing(), phone_call(), progress(), queue_exec(), sip_indicate(), skinny_call(), skinny_indicate(), vpb_call(), vpb_fixup(), vpb_indicate(), wait_for_answer(), zt_fixup(), zt_handle_event(), zt_indicate(), and zt_read().

#define AST_CONTROL_TAKEOFFHOOK 6

Make it go off hook

Definition at line 221 of file frame.h.

Referenced by ast_frame_dump(), control2str(), and misdn_indication().

#define AST_CONTROL_UNHOLD 17

Indicate call is left from hold

Definition at line 243 of file frame.h.

Referenced by ast_feature_request_and_dial(), ast_generic_bridge(), ast_indicate(), ast_rtp_bridge(), builtin_atxfer(), builtin_blindtransfer(), control2str(), do_parking_thread(), misdn_indication(), park_exec(), sip_indicate(), wait_for_answer(), and zt_indicate().

#define AST_CONTROL_VIDUPDATE 18

Indicate video frame update

Definition at line 245 of file frame.h.

Referenced by alsa_indicate(), ast_generic_bridge(), ast_indicate(), ast_play_and_record_full(), ast_rtp_bridge(), ast_waitstream(), handle_recordfile(), handle_request_info(), oss_indicate(), record_exec(), sip_indicate(), and wait_for_answer().

#define AST_CONTROL_WINK 10

Wink

Definition at line 229 of file frame.h.

Referenced by ast_frame_dump(), and control2str().

#define AST_FORMAT_ADPCM (1 << 5)

ADPCM (IMA)

Definition at line 183 of file frame.h.

Referenced by adpcmtolin_sample(), ast2vpbformat(), ast2vpbformatname(), ast_best_codec(), ast_codec_get_len(), ast_codec_get_samples(), ast_rtp_write(), astformatbits(), convertcap(), lintoadpcm_frameout(), load_module(), vox_open(), vox_read(), and vox_write().

#define AST_FORMAT_ALAW (1 << 3)

Raw A-law data (G.711)

Definition at line 179 of file frame.h.

Referenced by alawtolin_sample(), alawtoulaw_sample(), ast2vpbformat(), ast2vpbformatname(), ast_best_codec(), ast_codec_get_len(), ast_codec_get_samples(), ast_dsp_process(), ast_rtp_write(), astformatbits(), cb_events(), convertcap(), lintoalaw_frameout(), load_module(), misdn_read(), misdn_set_opt_exec(), pcm_open(), pcm_read(), pcm_write(), reload_config(), sms_exec(), sms_generate(), ulawtoalaw_frameout(), zt_new(), zt_read(), and zt_write().

#define AST_FORMAT_G723_1 (1 << 0)

G.723.1 compression

Definition at line 173 of file frame.h.

Referenced by add_codec_to_sdp(), ast_best_codec(), ast_codec_get_samples(), ast_rtp_write(), convertcap(), g723_open(), g723_write(), g723tolin_sample(), lintog723_frameout(), load_module(), phone_request(), phone_setup(), phone_write(), and reload_config().

#define AST_FORMAT_G726 (1 << 4)

ADPCM (G.726, 32kbps)

Definition at line 181 of file frame.h.

Referenced by ast_best_codec(), ast_codec_get_len(), ast_codec_get_samples(), ast_rtp_write(), g726_16_open(), g726_24_open(), g726_32_open(), g726_40_open(), g726_read(), g726_write(), g726tolin_sample(), lintog726_frameout(), and load_module().

#define AST_FORMAT_G729A (1 << 8)

G.729A audio

Definition at line 189 of file frame.h.

Referenced by add_codec_to_sdp(), ast_best_codec(), ast_codec_get_len(), ast_codec_get_samples(), ast_rtp_write(), convertcap(), g729_open(), g729_read(), g729_write(), load_module(), and reload_config().

#define AST_FORMAT_GSM (1 << 1)

GSM compression

Definition at line 175 of file frame.h.

Referenced by ast_best_codec(), ast_codec_get_len(), ast_codec_get_samples(), ast_rtp_write(), convertcap(), gsm_open(), gsm_read(), gsm_write(), gsmtolin_sample(), lintogsm_frameout(), load_module(), reload_config(), wav_open(), wav_read(), and wav_write().

#define AST_FORMAT_H261 (1 << 18)

H.261 Video

Definition at line 201 of file frame.h.

Referenced by ast_rtp_write(), and reload_config().

#define AST_FORMAT_H263 (1 << 19)

H.263 Video

Definition at line 203 of file frame.h.

Referenced by ast_rtp_write(), h263_open(), h263_read(), h263_write(), and load_module().

#define AST_FORMAT_H263_PLUS (1 << 20)

H.263+ Video

Definition at line 205 of file frame.h.

Referenced by ast_rtp_write().

#define AST_FORMAT_ILBC (1 << 10)

iLBC Free Compression

Definition at line 193 of file frame.h.

Referenced by ast_best_codec(), ast_codec_get_len(), ast_codec_get_samples(), ast_codec_interp_len(), ast_rtp_write(), convertcap(), ilbc_open(), ilbc_read(), ilbc_write(), ilbctolin_sample(), lintoilbc_frameout(), and load_module().

#define AST_FORMAT_JPEG (1 << 16)

JPEG Images

Definition at line 197 of file frame.h.

Referenced by jpeg_read_image(), and jpeg_write_image().

#define AST_FORMAT_LPC10 (1 << 7)

LPC10, 180 samples/frame

Definition at line 187 of file frame.h.

Referenced by ast_best_codec(), ast_codec_get_samples(), ast_rtp_write(), lintolpc10_frameout(), and lpc10tolin_sample().

#define AST_FORMAT_MAX_AUDIO (1 << 15)

Maximum audio format

Definition at line 195 of file frame.h.

Referenced by add_sdp(), ast_closestream(), ast_filehelper(), ast_playstream(), ast_rtp_raw_write(), ast_rtp_read(), ast_writestream(), oh323_request(), phone_read(), sip_request_call(), transmit_connect_with_sdp(), and transmit_modify_with_sdp().

#define AST_FORMAT_MAX_VIDEO (1 << 24)

Maximum video format

Definition at line 207 of file frame.h.

Referenced by add_sdp().

#define AST_FORMAT_PNG (1 << 17)

PNG Images

Definition at line 199 of file frame.h.

Referenced by phone_read().

#define AST_FORMAT_SLINEAR (1 << 6)

Raw 16-bit Signed Linear (8000 Hz) PCM

Definition at line 185 of file frame.h.

Referenced by action_originate(), adpcmtolin_frameout(), agent_new(), alawtolin_frameout(), alsa_new(), alsa_read(), alsa_request(), aopen_read(), ast2vpbformat(), ast2vpbformatname(), ast_app_getvoice(), ast_best_codec(), ast_channel_make_compatible(), ast_channel_spy_add(), ast_channel_start_silence_generator(), ast_codec_get_len(), ast_codec_get_samples(), ast_dsp_call_progress(), ast_dsp_digitdetect(), ast_dsp_process(), ast_dsp_silence(), ast_frame_adjust_volume(), ast_frame_slinear_sum(), ast_play_and_prepend(), ast_play_and_record_full(), ast_rtp_read(), ast_rtp_write(), ast_slinfactory_feed(), astformatbits(), attempt_reconnect(), attempt_thread(), background_detect_exec(), bestdata_read(), channel_spy(), chanspy_exec(), conf_run(), dictate_exec(), do_chanreads(), do_waiting(), eagi_exec(), fast_originate(), function_ilink(), g723tolin_frameout(), g726tolin_frameout(), gsmtolin_frameout(), handle_recordfile(), i4l_read(), i4l_write(), iax_frame_wrap(), ices_exec(), ilbctolin_frameout(), launch_monitor_thread(), linear_alloc(), linear_generator(), lintoadpcm_sample(), lintoalaw_sample(), lintog723_sample(), lintog726_sample(), lintogsm_sample(), lintoilbc_sample(), lintolpc10_sample(), lintospeex_sample(), lintoulaw_sample(), load_module(), load_moh_classes(), lpc10tolin_frameout(), measurenoise(), misdn_set_opt_exec(), moh_class_malloc(), mp3_exec(), nbs_request(), nbs_xwrite(), NBScat_exec(), ogg_vorbis_read(), ogg_vorbis_write(), oss_new(), oss_read(), oss_request(), page_thread(), parkandannounce_exec(), phone_new(), phone_read(), phone_request(), phone_setup(), phone_write(), playtones_alloc(), playtones_generator(), queue_frame_to_spies(), record_exec(), rpt(), rpt_call(), rpt_exec(), rpt_tele_thread(), send_waveform_to_channel(), silence_generator_generate(), slinear_open(), slinear_read(), slinear_write(), sms_exec(), sms_generate(), socket_read(), speextolin_frameout(), tonepair_alloc(), tonepair_generator(), ulawtolin_frameout(), vpb_new(), wav_open(), wav_read(), wav_write(), zt_new(), zt_read(), zt_request(), and zt_write().

#define AST_FORMAT_SPEEX (1 << 9)

SpeeX Free Compression

Definition at line 191 of file frame.h.

Referenced by ast_best_codec(), ast_codec_get_samples(), ast_rtp_write(), convertcap(), lintospeex_frameout(), and speextolin_sample().

#define AST_FORMAT_ULAW (1 << 2)

Raw mu-law data (G.711)

Definition at line 177 of file frame.h.

Referenced by __adsi_transmit_messages(), adsi_careful_send(), adsi_transmit_message_full(), alarmreceiver_exec(), alawtoulaw_frameout(), ast2vpbformat(), ast2vpbformatname(), ast_best_codec(), ast_codec_get_len(), ast_codec_get_samples(), ast_dsp_process(), ast_rtp_write(), astformatbits(), au_open(), au_read(), au_write(), build_conf(), conf_run(), convertcap(), disa_exec(), get_callerid_ast(), lintoulaw_frameout(), load_module(), milliwatt_exec(), milliwatt_generate(), pcm_open(), pcm_read(), pcm_write(), phone_request(), phone_setup(), phone_write(), reload_config(), send_tone_burst(), ulawtoalaw_sample(), ulawtolin_sample(), zt_new(), zt_read(), zt_request(), and zt_write().

#define ast_frame_byteswap_be | ( | fr |  | ) | do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__f->data, __f->data, __f->samples); } while(0)

Definition at line 364 of file frame.h.

Referenced by ast_rtp_read(), and socket_read().

#define ast_frame_byteswap_le | ( | fr |  | ) | do { ; } while(0)

Definition at line 363 of file frame.h.

Referenced by phone_read().

#define AST_FRAME_CNG 10

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

Definition at line 147 of file frame.h.

Referenced by ast_read(), ast_translate(), calc_timestamp(), lintospeex_frameout(), process_rfc3389(), and schedule_delivery().

#define AST_FRAME_CONTROL 4

A control frame, subclass is AST_CONTROL_*

Definition at line 134 of file frame.h.

Referenced by __ast_request_and_dial(), agent_read(), alsa_call(), aopen_handle_escape(), app_exec(), ast_bridge_call(), ast_dsp_process(), ast_feature_request_and_dial(), ast_frame_dump(), ast_generic_bridge(), ast_queue_control(), ast_queue_frame(), ast_queue_hangup(), ast_read(), ast_recvtext(), ast_rtp_bridge(), ast_waitfordigit_full(), ast_waitstream(), ast_waitstream_exten(), ast_waitstream_fr(), ast_waitstream_full(), ast_write(), async_wait(), attempt_transmit(), auto_congest(), bestdata_handle_escape(), console_answer(), console_flash(), console_sendtext(), disa_exec(), do_parking_thread(), handle_request_info(), i4l_handle_escape(), iax2_answer(), iax2_bridge(), iax2_indicate(), iax2_setoption(), iax_showframe(), local_answer(), local_hangup(), local_indicate(), mgcp_queue_control(), misdn_bridge(), modem_mini_packet(), monitor_handle_owned(), oss_call(), phone_exception(), receive_dtmf_digits(), rpt(), rpt_exec(), send_dtmf(), socket_read(), ss_thread(), wait_for_answer(), waitforring_exec(), zt_bridge(), zt_handle_dtmfup(), zt_handle_event(), and zt_read().

#define AST_FRAME_DTMF 1

A DTMF digit, subclass is the digit

Definition at line 128 of file frame.h.

Referenced by __adsi_transmit_messages(), action_zapdialoffhook(), agent_ack_sleep(), agent_read(), app_exec(), ast_app_getvoice(), ast_bridge_call(), ast_dsp_process(), ast_dtmf_stream(), ast_feature_request_and_dial(), ast_frame_dump(), ast_generic_bridge(), ast_play_and_prepend(), ast_play_and_record_full(), ast_read(), ast_rtp_bridge(), ast_waitfordigit(), ast_waitfordigit_full(), ast_waitstream(), ast_waitstream_exten(), ast_waitstream_fr(), ast_waitstream_full(), ast_write(), background_detect_exec(), bestdata_handle_escape(), cb_events(), channel_spy(), conf_exec(), conf_run(), console_dial(), dictate_exec(), disa_exec(), do_chanreads(), do_immediate_setup(), echo_exec(), handle_message(), handle_recordfile(), handle_request(), handle_request_info(), i4l_handle_escape(), i4l_read(), iax2_bridge(), iax2_digit(), iax_showframe(), local_digit(), mgcp_rtp_read(), misdn_bridge(), monitor_handle_owned(), mp3_exec(), NBScat_exec(), oh323_rtp_read(), phone_exception(), process_ast_dsp(), receive_dtmf_digits(), record_exec(), rpt(), rpt_call(), rpt_exec(), send_digit(), send_dtmf(), send_waveform_to_channel(), sip_rtp_read(), ss_thread(), vpb_bridge(), wait_for_answer(), zt_bridge(), zt_handle_event(), and zt_read().

#define AST_FRAME_HTML 9

HTML Frame

Definition at line 144 of file frame.h.

Referenced by ast_frame_dump(), ast_generic_bridge(), ast_write(), iax2_sendhtml(), local_sendhtml(), sendurl_exec(), and wait_for_answer().

#define AST_FRAME_IAX 6

Inter Asterisk Exchange private frame type

Definition at line 138 of file frame.h.

Referenced by ast_frame_dump(), ast_write(), attempt_transmit(), auth_reject(), authenticate_reply(), authenticate_request(), auto_hangup(), cache_get_callno_locked(), calc_timestamp(), dp_lookup(), iax2_allow_new(), iax2_call(), iax2_do_register(), iax2_dprequest(), iax2_hangup(), iax2_poke_peer(), iax2_provision(), iax2_send(), iax2_start_transfer(), iax2_transfer(), iax2_vnak(), iax_showframe(), raw_hangup(), registry_authrequest(), registry_rerequest(), resend_with_token(), send_apathetic_reply(), send_lagrq(), send_ping(), socket_read(), try_transfer(), and update_registry().

#define AST_FRAME_IMAGE 8

Image Frames

Definition at line 142 of file frame.h.

Referenced by ast_frame_dump(), ast_generic_bridge(), iax2_bridge(), iax2_sendimage(), jpeg_read_image(), jpeg_write_image(), mgcp_write(), nbs_xwrite(), oh323_write(), phone_read(), phone_write(), sip_write(), skinny_write(), wait_for_answer(), and zt_write().

#define AST_FRAME_NULL 5

An empty, useless frame

Definition at line 136 of file frame.h.

Referenced by __zt_exception(), agent_new(), agent_read(), alsa_read(), aopen_handle_escape(), ast_channel_masquerade(), ast_channel_setwhentohangup(), ast_do_masquerade(), ast_dsp_process(), ast_frame_dump(), ast_read(), ast_rtcp_read(), ast_rtp_read(), ast_softhangup_nolock(), ast_write(), bestdata_handle_escape(), do_chanreads(), features_read(), handle_request_invite(), handle_response_invite(), i4l_handle_escape(), i4l_read(), iax2_read(), iax2_write(), local_read(), mgcp_rtp_read(), monitor_handle_owned(), oh323_rtp_read(), oss_read(), phone_exception(), phone_read(), process_ast_dsp(), process_sdp(), send_dtmf(), sip_rtp_read(), socket_read(), vpb_read(), wakeup_sub(), zt_handle_dtmfup(), zt_handle_event(), and zt_read().

#define AST_FRAME_T38 11

T.38 Fax-over-IP data stream

Definition at line 149 of file frame.h.

#define AST_FRAME_TEXT 7

Text messages

Definition at line 140 of file frame.h.

Referenced by ast_feature_request_and_dial(), ast_frame_dump(), ast_generic_bridge(), ast_recvtext(), ast_write(), console_sendtext(), function_ilink(), handle_link_data(), iax2_bridge(), iax2_sendtext(), receive_message(), rpt(), rpt_exec(), send_link_dtmf(), socket_read(), wait_for_answer(), and zt_read().

#define AST_FRAME_VIDEO 3

Video frame, maybe?? :)

Definition at line 132 of file frame.h.

Referenced by ast_frame_dump(), ast_generic_bridge(), ast_play_and_prepend(), ast_play_and_record_full(), ast_rtp_bridge(), ast_rtp_read(), ast_rtp_write(), ast_write(), ast_writestream(), decode_frame(), echo_exec(), h263_open(), h263_read(), h263_write(), handle_recordfile(), iax2_bridge(), iax2_send(), phone_read(), record_exec(), sip_write(), socket_read(), and vpb_bridge().

#define AST_FRAME_VOICE 2

Voice data, subclass is AST_FORMAT_*

Definition at line 130 of file frame.h.

Referenced by __ast_smoother_feed(), adpcmtolin_frameout(), adpcmtolin_sample(), adsi_careful_send(), agent_read(), agent_write(), alawtolin_frameout(), alawtolin_sample(), alawtoulaw_frameout(), alawtoulaw_sample(), alsa_read(), aopen_read(), ast_app_getvoice(), ast_channel_spy_read_frame(), ast_dsp_call_progress(), ast_dsp_digitdetect(), ast_dsp_process(), ast_dsp_silence(), ast_frame_adjust_volume(), ast_frame_dump(), ast_frame_slinear_sum(), ast_generic_bridge(), ast_play_and_prepend(), ast_play_and_record_full(), ast_prod(), ast_queue_frame(), ast_read(), ast_rtp_bridge(), ast_rtp_read(), ast_rtp_write(), ast_smoother_read(), ast_waitfordigit_full(), ast_waitstream_full(), ast_write(), ast_writestream(), au_open(), au_read(), au_write(), background_detect_exec(), bestdata_read(), calc_timestamp(), cb_events(), conf_run(), dictate_exec(), disa_exec(), do_chanreads(), do_waiting(), echo_exec(), fakesrc_sample(), g723_open(), g723_write(), g723tolin_frameout(), g723tolin_sample(), g726_16_open(), g726_24_open(), g726_32_open(), g726_40_open(), g726_read(), g726_write(), g726tolin_frameout(), g726tolin_sample(), g729_open(), g729_read(), g729_write(), get_from_jb(), gsm_open(), gsm_read(), gsm_write(), gsmtolin_frameout(), gsmtolin_sample(), handle_recordfile(), i4l_read(), i4l_write(), iax2_bridge(), iax2_send(), iax2_write(), iax_frame_wrap(), ices_exec(), ilbc_open(), ilbc_read(), ilbc_write(), ilbctolin_frameout(), ilbctolin_sample(), linear_generator(), lintoadpcm_frameout(), lintoadpcm_sample(), lintoalaw_frameout(), lintoalaw_sample(), lintog723_frameout(), lintog723_sample(), lintog726_frameout(), lintog726_sample(), lintogsm_frameout(), lintogsm_sample(), lintoilbc_frameout(), lintoilbc_sample(), lintolpc10_frameout(), lintolpc10_sample(), lintospeex_frameout(), lintospeex_sample(), lintoulaw_frameout(), lintoulaw_sample(), local_write(), lpc10tolin_frameout(), lpc10tolin_sample(), measurenoise(), mgcp_rtp_read(), mgcp_write(), milliwatt_generate(), misdn_bridge(), misdn_read(), moh_generate(), mp3_exec(), nbs_xwrite(), NBScat_exec(), ogg_vorbis_read(), ogg_vorbis_write(), oh323_rtp_read(), oh323_write(), oss_read(), pcm_open(), pcm_read(), pcm_write(), phone_read(), phone_write(), playtones_generator(), record_exec(), recordthread(), rpt(), rpt_exec(), run_agi(), schedule_delivery(), send_tone_burst(), send_waveform_to_channel(), silence_generator_generate(), sip_rtp_read(), sip_write(), skinny_rtp_read(), skinny_write(), slinear_open(), slinear_read(), slinear_write(), sms_exec(), sms_generate(), socket_read(), speextolin_frameout(), speextolin_sample(), tonepair_generator(), ulawtoalaw_frameout(), ulawtoalaw_sample(), ulawtolin_frameout(), ulawtolin_sample(), vox_open(), vox_read(), vox_write(), vpb_bridge(), vpb_write(), wait_for_answer(), wav_open(), wav_read(), wav_write(), zap_frameout(), zt_read(), and zt_write().

#define AST_FRIENDLY_OFFSET 64

Definition at line 114 of file frame.h.

Referenced by adpcmtolin_frameout(), alawtolin_frameout(), alawtoulaw_frameout(), alsa_read(), aopen_read(), ast_frisolate(), ast_prod(), ast_rtp_read(), ast_smoother_read(), au_read(), bestdata_read(), conf_run(), do_chanreads(), g723_read(), g723tolin_frameout(), g726_read(), g726tolin_frameout(), g729_read(), get_from_jb(), gsm_read(), gsmtolin_frameout(), h263_read(), i4l_read(), iax_frame_wrap(), ilbc_read(), ilbctolin_frameout(), linear_generator(), lintoadpcm_frameout(), lintoalaw_frameout(), lintog723_frameout(), lintog726_frameout(), lintogsm_frameout(), lintoilbc_frameout(), lintolpc10_frameout(), lintospeex_frameout(), lintoulaw_frameout(), lpc10tolin_frameout(), milliwatt_generate(), moh_generate(), mp3_exec(), NBScat_exec(), ogg_vorbis_read(), oss_read(), pcm_read(), phone_read(), playtones_generator(), process_rfc3389(), send_tone_burst(), send_waveform_to_channel(), slinear_read(), sms_generate(), speextolin_frameout(), tonepair_generator(), ulawtoalaw_frameout(), ulawtolin_frameout(), vox_read(), wav_read(), zap_frameout(), and zt_read().

#define AST_HTML_BEGIN 4

Beginning frame

Definition at line 157 of file frame.h.

Referenced by ast_frame_dump().

#define AST_HTML_DATA 2

Data frame

Definition at line 155 of file frame.h.

Referenced by ast_frame_dump().

#define AST_HTML_END 8

End frame

Definition at line 159 of file frame.h.

Referenced by ast_frame_dump().

#define AST_HTML_LDCOMPLETE 16

Load is complete

Definition at line 161 of file frame.h.

Referenced by ast_frame_dump(), and sendurl_exec().

#define AST_HTML_LINKREJECT 20

Reject link request

Definition at line 169 of file frame.h.

Referenced by ast_frame_dump().

#define AST_HTML_LINKURL 18

Send URL, and track

Definition at line 165 of file frame.h.

Referenced by ast_frame_dump().

#define AST_HTML_NOSUPPORT 17

Peer is unable to support HTML

Definition at line 163 of file frame.h.

Referenced by ast_frame_dump(), and sendurl_exec().

#define AST_HTML_UNLINK 19

No more HTML linkage

Definition at line 167 of file frame.h.

Referenced by ast_frame_dump().

#define AST_HTML_URL 1

Sending a URL

Definition at line 153 of file frame.h.

Referenced by ast_channel_sendurl(), and ast_frame_dump().

#define AST_MALLOCD_DATA (1 << 1)

Need the data be free'd?

Definition at line 122 of file frame.h.

Referenced by ast_frfree(), and ast_frisolate().

#define AST_MALLOCD_HDR (1 << 0)

Need the header be free'd?

Definition at line 120 of file frame.h.

Referenced by ast_frdup(), ast_frfree(), and ast_frisolate().

#define AST_MALLOCD_SRC (1 << 2)

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

Definition at line 124 of file frame.h.

Referenced by ast_frfree(), and ast_frisolate().

#define AST_MIN_OFFSET 32

Definition at line 117 of file frame.h.

Referenced by __ast_smoother_feed().

#define AST_OPTION_AUDIO_MODE 4

Set (or clear) Audio (Not-Clear) Mode

Definition at line 268 of file frame.h.

Referenced by zt_hangup(), and zt_setoption().

#define AST_OPTION_FLAG_ACCEPT 1

Definition at line 251 of file frame.h.

#define AST_OPTION_FLAG_ANSWER 5

Definition at line 254 of file frame.h.

#define AST_OPTION_FLAG_QUERY 4

Definition at line 253 of file frame.h.

#define AST_OPTION_FLAG_REJECT 2

Definition at line 252 of file frame.h.

#define AST_OPTION_FLAG_REQUEST 0

Definition at line 250 of file frame.h.

Referenced by ast_bridge_call(), and iax2_setoption().

#define AST_OPTION_FLAG_WTF 6

Definition at line 255 of file frame.h.

#define AST_OPTION_RELAXDTMF 3

Relax the parameters for DTMF reception (mainly for radio use)

Definition at line 265 of file frame.h.

Referenced by rpt(), and zt_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 284 of file frame.h.

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

#define AST_OPTION_TDD 2

Put a compatible channel into TDD (TTY for the hearing-impared) mode

Definition at line 262 of file frame.h.

Referenced by handle_tddmode(), zt_hangup(), and zt_setoption().

#define AST_OPTION_TONE_VERIFY 1

Verify touchtones by muting audio transmission (and reception) and verify the tone is still present

Definition at line 259 of file frame.h.

Referenced by conf_run(), rpt(), try_calling(), zt_hangup(), and zt_setoption().

#define AST_OPTION_TXGAIN 5

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

Definition at line 276 of file frame.h.

Referenced by chanspy_exec(), iax2_setoption(), reset_volumes(), set_listen_volume(), set_volume(), and zt_setoption().

#define ast_smoother_feed | ( | s,
|  | f |  | ) | __ast_smoother_feed(s, f, 0)

Definition at line 412 of file frame.h.

Referenced by ast_rtp_write().

#define ast_smoother_feed_be | ( | s,
|  | f |  | ) | __ast_smoother_feed(s, f, 1)

Definition at line 414 of file frame.h.

Referenced by ast_rtp_write().

#define ast_smoother_feed_le | ( | s,
|  | f |  | ) | __ast_smoother_feed(s, f, 0)

Definition at line 415 of file frame.h.

#define AST_SMOOTHER_FLAG_G729 (1 << 0)

Definition at line 247 of file frame.h.

Referenced by __ast_smoother_feed(), ast_rtp_write(), and ast_smoother_read().

## Function Documentation

int __ast_smoother_feed | ( | struct ast_smoother * | s,
|  | struct ast_frame * | f,
|  | int | swap |
| ) |  |  |

Definition at line 137 of file frame.c.

References AST_FRAME_VOICE, ast_log(), AST_MIN_OFFSET, AST_SMOOTHER_FLAG_G729, ast_swapcopy_samples(), ast_smoother::data, ast_frame::data, ast_frame::datalen, ast_smoother::delivery, ast_frame::delivery, ast_smoother::flags, ast_smoother::format, ast_frame::frametype, ast_smoother::len, LOG_NOTICE, LOG_WARNING, ast_frame::offset, ast_smoother::opt, ast_smoother::optimizablestream, ast_frame::samples, ast_smoother::samplesperbyte, ast_smoother::size, SMOOTHER_SIZE, and ast_frame::subclass.

    00138 {
    00139    if (f->frametype != AST_FRAME_VOICE) {
    00140       ast_log(LOG_WARNING, "Huh?  Can't smooth a non-voice frame!\n");
    00141       return -1;
    00142    }
    00143    if (!s->format) {
    00144       s->format = f->subclass;
    00145       s->samplesperbyte = (float)f->samples / (float)f->datalen;
    00146    } else if (s->format != f->subclass) {
    00147       ast_log(LOG_WARNING, "Smoother was working on %d format frames, now trying to feed %d?\n", s->format, f->subclass);
    00148       return -1;
    00149    }
    00150    if (s->len + f->datalen > SMOOTHER_SIZE) {
    00151       ast_log(LOG_WARNING, "Out of smoother space\n");
    00152       return -1;
    00153    }
    00154    if (((f->datalen == s->size) || ((f->datalen < 10) && (s->flags & AST_SMOOTHER_FLAG_G729)))
    00155              && !s->opt && (f->offset >= AST_MIN_OFFSET)) {
    00156       if (!s->len) {
    00157          /* Optimize by sending the frame we just got
    00158             on the next read, thus eliminating the douple
    00159             copy */
    00160          if (swap)
    00161             ast_swapcopy_samples(f->data, f->data, f->samples);
    00162          s->opt = f;
    00163          return 0;
    00164       } else {
    00165          s->optimizablestream++;
    00166          if (s->optimizablestream > 10) {
    00167             /* For the past 10 rounds, we have input and output
    00168                frames of the correct size for this smoother, yet
    00169                we were unable to optimize because there was still
    00170                some cruft left over.  Lets just drop the cruft so
    00171                we can move to a fully optimized path */
    00172             if (swap)
    00173                ast_swapcopy_samples(f->data, f->data, f->samples);
    00174             s->len = 0;
    00175             s->opt = f;
    00176             return 0;
    00177          }
    00178       }
    00179    } else
    00180       s->optimizablestream = 0;
    00181    if (s->flags & AST_SMOOTHER_FLAG_G729) {
    00182       if (s->len % 10) {
    00183          ast_log(LOG_NOTICE, "Dropping extra frame of G.729 since we already have a VAD frame at the end\n");
    00184          return 0;
    00185       }
    00186    }
    00187    if (swap)
    00188       ast_swapcopy_samples(s->data+s->len, f->data, f->samples);
    00189    else
    00190       memcpy(s->data + s->len, f->data, f->datalen);
    00191    /* If either side is empty, reset the delivery time */
    00192    if (!s->len || ast_tvzero(f->delivery) || ast_tvzero(s->delivery))   /* XXX really ? */
    00193       s->delivery = f->delivery;
    00194    s->len += f->datalen;
    00195    return 0;
    00196 }

char* ast_codec2str | ( | int | codec | ) |

Get a name from a format Gets a name from a format.

Parameters:

  | codec | codec number (1,2,4,8,16,etc.)

Returns:
  This returns a static string identifying the format on success, 0 on error.

Definition at line 589 of file frame.c.

References ast_format_list::desc.

Referenced by moh_alloc(), show_codec_n(), and show_codecs().

    00589                                {
    00590    int x = 0;
    00591    char *ret = "unknown";
    00592    for (x = 0 ; x < sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list) ; x++) {
    00593       if(AST_FORMAT_LIST[x].visible && AST_FORMAT_LIST[x].bits == codec) {
    00594          ret = AST_FORMAT_LIST[x].desc;
    00595          break;
    00596       }
    00597    }
    00598    return ret;
    00599 }

int ast_codec_choose | ( | struct ast_codec_pref * | pref,
|  | int | formats,
|  | int | find_best |
| ) |  |  |

Select the best format according to preference list from supplied options. If "find_best" is non-zero then if nothing is found, the "Best" format of the format list is selected, otherwise 0 is returned.

Definition at line 1003 of file frame.c.

References ast_best_codec(), ast_format_list::bits, and ast_codec_pref::order.

Referenced by process_sdp(), sip_new(), and socket_read().

    01004 {
    01005    size_t size = 0;
    01006    int x = 0, ret = 0, slot = 0;
    01007
    01008    size = sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list);
    01009    for (x = 0; x < size; x++) {
    01010       slot = pref->order[x];
    01011
    01012       if(!slot)
    01013          break;
    01014       if ( formats & AST_FORMAT_LIST[slot-1].bits ) {
    01015          ret = AST_FORMAT_LIST[slot-1].bits;
    01016          break;
    01017       }
    01018    }
    01019    if(ret)
    01020       return ret;
    01021
    01022       return find_best ? ast_best_codec(formats) : 0;
    01023 }

int ast_codec_get_len | ( | int | format,
|  | int | samples |
| ) |  |  |

Returns the number of bytes for the number of samples of the given format.

Definition at line 1244 of file frame.c.

References AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_G726, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_ILBC, AST_FORMAT_SLINEAR, AST_FORMAT_ULAW, ast_getformatname(), ast_log(), and LOG_WARNING.

Referenced by ast_channel_spy_read_frame(), copy_data_from_queue(), moh_generate(), and monmp3thread().

    01245 {
    01246    int len = 0;
    01247
    01248    /* XXX Still need speex, g723, and lpc10 XXX */
    01249    switch(format) {
    01250    case AST_FORMAT_ILBC:
    01251       len = (samples / 240) * 50;
    01252       break;
    01253    case AST_FORMAT_GSM:
    01254       len = (samples / 160) * 33;
    01255       break;
    01256    case AST_FORMAT_G729A:
    01257       len = samples / 8;
    01258       break;
    01259    case AST_FORMAT_SLINEAR:
    01260       len = samples * 2;
    01261       break;
    01262    case AST_FORMAT_ULAW:
    01263    case AST_FORMAT_ALAW:
    01264       len = samples;
    01265       break;
    01266    case AST_FORMAT_ADPCM:
    01267    case AST_FORMAT_G726:
    01268       len = samples / 2;
    01269       break;
    01270    default:
    01271       ast_log(LOG_WARNING, "Unable to calculate sample length for format %s\n", ast_getformatname(format));
    01272    }
    01273
    01274    return len;
    01275 }

int ast_codec_get_samples | ( | struct ast_frame * | f | ) |

Returns the number of samples contained in the frame.

Definition at line 1203 of file frame.c.

References AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G726, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_ILBC, AST_FORMAT_LPC10, AST_FORMAT_SLINEAR, AST_FORMAT_SPEEX, AST_FORMAT_ULAW, ast_getformatname(), ast_log(), ast_frame::data, ast_frame::datalen, g723_samples(), LOG_WARNING, speex_samples(), and ast_frame::subclass.

Referenced by ast_rtp_read(), moh_generate(), schedule_delivery(), and socket_read().

    01204 {
    01205    int samples=0;
    01206    switch(f->subclass) {
    01207    case AST_FORMAT_SPEEX:
    01208       samples = speex_samples(f->data, f->datalen);
    01209       break;
    01210    case AST_FORMAT_G723_1:
    01211                 samples = g723_samples(f->data, f->datalen);
    01212       break;
    01213    case AST_FORMAT_ILBC:
    01214       samples = 240 * (f->datalen / 50);
    01215       break;
    01216    case AST_FORMAT_GSM:
    01217       samples = 160 * (f->datalen / 33);
    01218       break;
    01219    case AST_FORMAT_G729A:
    01220       samples = f->datalen * 8;
    01221       break;
    01222    case AST_FORMAT_SLINEAR:
    01223       samples = f->datalen / 2;
    01224       break;
    01225    case AST_FORMAT_LPC10:
    01226                 /* assumes that the RTP packet contains one LPC10 frame */
    01227       samples = 22 * 8;
    01228       samples += (((char *)(f->data))[7] & 0x1) * 8;
    01229       break;
    01230    case AST_FORMAT_ULAW:
    01231    case AST_FORMAT_ALAW:
    01232       samples = f->datalen;
    01233       break;
    01234    case AST_FORMAT_ADPCM:
    01235    case AST_FORMAT_G726:
    01236       samples = f->datalen * 2;
    01237       break;
    01238    default:
    01239       ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname(f->subclass));
    01240    }
    01241    return samples;
    01242 }

static int ast_codec_interp_len | ( | int | format | ) | `[inline, static]`

Gets duration in ms of interpolation frame for a format.

Definition at line 456 of file frame.h.

References AST_FORMAT_ILBC.

Referenced by get_from_jb().

    00457 {
    00458    return (format == AST_FORMAT_ILBC) ? 30 : 20;
    00459 }

int ast_codec_pref_append | ( | struct ast_codec_pref * | pref,
|  | int | format |
| ) |  |  |

Append a codec to a preference list, removing it first if it was already there.

Definition at line 974 of file frame.c.

References ast_codec_pref_remove(), and ast_codec_pref::order.

Referenced by ast_parse_allow_disallow().

    00975 {
    00976    size_t size = 0;
    00977    int x = 0, newindex = -1;
    00978
    00979    ast_codec_pref_remove(pref, format);
    00980    size = sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list);
    00981
    00982    for (x = 0; x < size; x++) {
    00983       if(AST_FORMAT_LIST[x].bits == format) {
    00984          newindex = x + 1;
    00985          break;
    00986       }
    00987    }
    00988
    00989    if(newindex) {
    00990       for (x = 0; x < size; x++) {
    00991          if(!pref->order[x]) {
    00992             pref->order[x] = newindex;
    00993             break;
    00994          }
    00995       }
    00996    }
    00997
    00998    return x;
    00999 }

void ast_codec_pref_convert | ( | struct ast_codec_pref * | pref,
|  | char * | buf,
|  | size_t | size,
|  | int | right |
| ) |  |  |

Shift a codec preference list up or down 65 bytes so that it becomes an ASCII string.

Definition at line 877 of file frame.c.

References ast_codec_pref::order.

Referenced by check_access(), create_addr(), dump_prefs(), and socket_read().

    00878 {
    00879    int x = 0, differential = (int) 'A', mem = 0;
    00880    char *from = NULL, *to = NULL;
    00881
    00882    if(right) {
    00883       from = pref->order;
    00884       to = buf;
    00885       mem = size;
    00886    } else {
    00887       to = pref->order;
    00888       from = buf;
    00889       mem = 32;
    00890    }
    00891
    00892    memset(to, 0, mem);
    00893    for (x = 0; x < 32 ; x++) {
    00894       if(!from[x])
    00895          break;
    00896       to[x] = right ? (from[x] + differential) : (from[x] - differential);
    00897    }
    00898 }

int ast_codec_pref_index | ( | struct ast_codec_pref * | pref,
|  | int | index |
| ) |  |  |

Codec located at a particular place in the preference index.

Definition at line 935 of file frame.c.

References ast_format_list::bits, and ast_codec_pref::order.

Referenced by _sip_show_peer(), add_sdp(), ast_codec_pref_string(), function_iaxpeer(), function_sippeer(), iax2_show_peer(), print_codec_to_cli(), sip_show_user(), and socket_read().

    00936 {
    00937    int slot = 0;
    00938
    00939
    00940    if((index >= 0) && (index < sizeof(pref->order))) {
    00941       slot = pref->order[index];
    00942    }
    00943
    00944    return slot ? AST_FORMAT_LIST[slot-1].bits : 0;
    00945 }

void ast_codec_pref_init | ( | struct ast_codec_pref * | pref | ) |

Initialize a codec preference to "no preference".

void ast_codec_pref_remove | ( | struct ast_codec_pref * | pref,
|  | int | format |
| ) |  |  |

Remove a codec from a preference list.

Definition at line 948 of file frame.c.

References ast_codec_pref::order.

Referenced by ast_codec_pref_append(), and ast_parse_allow_disallow().

    00949 {
    00950    struct ast_codec_pref oldorder;
    00951    int x=0, y=0;
    00952    size_t size = 0;
    00953    int slot = 0;
    00954
    00955    if(!pref->order[0])
    00956       return;
    00957
    00958    size = sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list);
    00959
    00960    memcpy(&oldorder,pref,sizeof(struct ast_codec_pref));
    00961    memset(pref,0,sizeof(struct ast_codec_pref));
    00962
    00963    for (x = 0; x < size; x++) {
    00964       slot = oldorder.order[x];
    00965       if(! slot)
    00966          break;
    00967       if(AST_FORMAT_LIST[slot-1].bits != format)
    00968          pref->order[y++] = slot;
    00969    }
    00970
    00971 }

int ast_codec_pref_string | ( | struct ast_codec_pref * | pref,
|  | char * | buf,
|  | size_t | size |
| ) |  |  |

Dump codec preference list into a string.

Definition at line 900 of file frame.c.

References ast_codec_pref_index(), and ast_getformatname().

Referenced by dump_prefs(), and socket_read().

    00901 {
    00902    int x = 0, codec = 0;
    00903    size_t total_len = 0, slen = 0;
    00904    char *formatname = 0;
    00905
    00906    memset(buf,0,size);
    00907    total_len = size;
    00908    buf[0] = '(';
    00909    total_len--;
    00910    for(x = 0; x < 32 ; x++) {
    00911       if(total_len <= 0)
    00912          break;
    00913       if(!(codec = ast_codec_pref_index(pref,x)))
    00914          break;
    00915       if((formatname = ast_getformatname(codec))) {
    00916          slen = strlen(formatname);
    00917          if(slen > total_len)
    00918             break;
    00919          strncat(buf,formatname,total_len);
    00920          total_len -= slen;
    00921       }
    00922       if(total_len && x < 31 && ast_codec_pref_index(pref , x + 1)) {
    00923          strncat(buf,"|",total_len);
    00924          total_len--;
    00925       }
    00926    }
    00927    if(total_len) {
    00928       strncat(buf,")",total_len);
    00929       total_len--;
    00930    }
    00931
    00932    return size - total_len;
    00933 }

int ast_fr_fdhangup | ( | int | fd | ) |

Sends a hangup to an fd Send a hangup (NULL equivalent) on an fd.

Parameters:

  | fd | fd to write to

Returns:
  Returns 0 on success, -1 on failure

struct ast_frame* ast_fr_fdread | ( | int | fd | ) | `[read]`

Reads a frame from an fd Read a frame from a stream or packet fd, as written by fd_write.

Parameters:

  | fd | an opened fd to read from

Returns:
  returns a frame on success, NULL on error

int ast_fr_fdwrite | ( | int | fd,
|  | struct ast_frame * | frame |
| ) |  |  |

Writes a frame to an fd Write a frame to an fd

Parameters:

  | fd | Which fd to write to
  | frame | frame to write to the fd

Returns:
  Returns 0 on success, -1 on failure

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 1277 of file frame.c.

References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, ast_slinear_saturated_divide(), ast_slinear_saturated_multiply(), ast_frame::data, ast_frame::frametype, ast_frame::samples, and ast_frame::subclass.

Referenced by ast_channel_spy_read_frame(), and conf_run().

    01278 {
    01279    int count;
    01280    short *fdata = f->data;
    01281    short adjust_value = abs(adjustment);
    01282
    01283    if ((f->frametype != AST_FRAME_VOICE) || (f->subclass != AST_FORMAT_SLINEAR))
    01284       return -1;
    01285
    01286    if (!adjustment)
    01287       return 0;
    01288
    01289    for (count = 0; count < f->samples; count++) {
    01290       if (adjustment > 0) {
    01291          ast_slinear_saturated_multiply(&fdata[count], &adjust_value);
    01292       } else if (adjustment < 0) {
    01293          ast_slinear_saturated_divide(&fdata[count], &adjust_value);
    01294       }
    01295    }
    01296
    01297    return 0;
    01298 }

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

Dump a frame for debugging purposes

Definition at line 676 of file frame.c.

References AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_WINK, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_IMAGE, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_getformatname(), 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_strlen_zero(), ast_verbose(), COLOR_BLACK, COLOR_BRCYAN, COLOR_BRGREEN, COLOR_BRMAGENTA, COLOR_BRRED, COLOR_YELLOW, ast_frame::data, ast_frame::frametype, n, ast_frame::subclass, and term_color().

Referenced by ast_read(), and ast_write().

    00677 {
    00678    char *n = "unknown";
    00679    char ftype[40] = "Unknown Frametype";
    00680    char cft[80];
    00681    char subclass[40] = "Unknown Subclass";
    00682    char csub[80];
    00683    char moreinfo[40] = "";
    00684    char cn[60];
    00685    char cp[40];
    00686    char cmn[40];
    00687    if (name)
    00688       n = name;
    00689    if (!f) {
    00690       ast_verbose("%s [ %s (NULL) ] [%s]\n",
    00691          term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
    00692          term_color(cft, "HANGUP", COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
    00693          term_color(cn, n, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
    00694       return;
    00695    }
    00696    /* XXX We should probably print one each of voice and video when the format changes XXX */
    00697    if (f->frametype == AST_FRAME_VOICE)
    00698       return;
    00699    if (f->frametype == AST_FRAME_VIDEO)
    00700       return;
    00701    switch(f->frametype) {
    00702    case AST_FRAME_DTMF:
    00703       strcpy(ftype, "DTMF");
    00704       subclass[0] = f->subclass;
    00705       subclass[1] = '\0';
    00706       break;
    00707    case AST_FRAME_CONTROL:
    00708       strcpy(ftype, "Control");
    00709       switch(f->subclass) {
    00710       case AST_CONTROL_HANGUP:
    00711          strcpy(subclass, "Hangup");
    00712          break;
    00713       case AST_CONTROL_RING:
    00714          strcpy(subclass, "Ring");
    00715          break;
    00716       case AST_CONTROL_RINGING:
    00717          strcpy(subclass, "Ringing");
    00718          break;
    00719       case AST_CONTROL_ANSWER:
    00720          strcpy(subclass, "Answer");
    00721          break;
    00722       case AST_CONTROL_BUSY:
    00723          strcpy(subclass, "Busy");
    00724          break;
    00725       case AST_CONTROL_TAKEOFFHOOK:
    00726          strcpy(subclass, "Take Off Hook");
    00727          break;
    00728       case AST_CONTROL_OFFHOOK:
    00729          strcpy(subclass, "Line Off Hook");
    00730          break;
    00731       case AST_CONTROL_CONGESTION:
    00732          strcpy(subclass, "Congestion");
    00733          break;
    00734       case AST_CONTROL_FLASH:
    00735          strcpy(subclass, "Flash");
    00736          break;
    00737       case AST_CONTROL_WINK:
    00738          strcpy(subclass, "Wink");
    00739          break;
    00740       case AST_CONTROL_OPTION:
    00741          strcpy(subclass, "Option");
    00742          break;
    00743       case AST_CONTROL_RADIO_KEY:
    00744          strcpy(subclass, "Key Radio");
    00745          break;
    00746       case AST_CONTROL_RADIO_UNKEY:
    00747          strcpy(subclass, "Unkey Radio");
    00748          break;
    00749       case -1:
    00750          strcpy(subclass, "Stop generators");
    00751          break;
    00752       default:
    00753          snprintf(subclass, sizeof(subclass), "Unknown control '%d'", f->subclass);
    00754       }
    00755       break;
    00756    case AST_FRAME_NULL:
    00757       strcpy(ftype, "Null Frame");
    00758       strcpy(subclass, "N/A");
    00759       break;
    00760    case AST_FRAME_IAX:
    00761       /* Should never happen */
    00762       strcpy(ftype, "IAX Specific");
    00763       snprintf(subclass, sizeof(subclass), "IAX Frametype %d", f->subclass);
    00764       break;
    00765    case AST_FRAME_TEXT:
    00766       strcpy(ftype, "Text");
    00767       strcpy(subclass, "N/A");
    00768       ast_copy_string(moreinfo, f->data, sizeof(moreinfo));
    00769       break;
    00770    case AST_FRAME_IMAGE:
    00771       strcpy(ftype, "Image");
    00772       snprintf(subclass, sizeof(subclass), "Image format %s\n", ast_getformatname(f->subclass));
    00773       break;
    00774    case AST_FRAME_HTML:
    00775       strcpy(ftype, "HTML");
    00776       switch(f->subclass) {
    00777       case AST_HTML_URL:
    00778          strcpy(subclass, "URL");
    00779          ast_copy_string(moreinfo, f->data, sizeof(moreinfo));
    00780          break;
    00781       case AST_HTML_DATA:
    00782          strcpy(subclass, "Data");
    00783          break;
    00784       case AST_HTML_BEGIN:
    00785          strcpy(subclass, "Begin");
    00786          break;
    00787       case AST_HTML_END:
    00788          strcpy(subclass, "End");
    00789          break;
    00790       case AST_HTML_LDCOMPLETE:
    00791          strcpy(subclass, "Load Complete");
    00792          break;
    00793       case AST_HTML_NOSUPPORT:
    00794          strcpy(subclass, "No Support");
    00795          break;
    00796       case AST_HTML_LINKURL:
    00797          strcpy(subclass, "Link URL");
    00798          ast_copy_string(moreinfo, f->data, sizeof(moreinfo));
    00799          break;
    00800       case AST_HTML_UNLINK:
    00801          strcpy(subclass, "Unlink");
    00802          break;
    00803       case AST_HTML_LINKREJECT:
    00804          strcpy(subclass, "Link Reject");
    00805          break;
    00806       default:
    00807          snprintf(subclass, sizeof(subclass), "Unknown HTML frame '%d'\n", f->subclass);
    00808          break;
    00809       }
    00810       break;
    00811    default:
    00812       snprintf(ftype, sizeof(ftype), "Unknown Frametype '%d'", f->frametype);
    00813    }
    00814    if (!ast_strlen_zero(moreinfo))
    00815       ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) '%s' ] [%s]\n",
    00816          term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
    00817          term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
    00818          f->frametype,
    00819          term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
    00820          f->subclass,
    00821          term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK, sizeof(cmn)),
    00822          term_color(cn, n, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
    00823    else
    00824       ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) ] [%s]\n",
    00825          term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
    00826          term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
    00827          f->frametype,
    00828          term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
    00829          f->subclass,
    00830          term_color(cn, n, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
    00831
    00832 }

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 1300 of file frame.c.

References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, ast_slinear_saturated_add(), ast_frame::data, ast_frame::frametype, ast_frame::samples, and ast_frame::subclass.

Referenced by ast_channel_spy_read_frame().

    01301 {
    01302    int count;
    01303    short *data1, *data2;
    01304
    01305    if ((f1->frametype != AST_FRAME_VOICE) || (f1->subclass != AST_FORMAT_SLINEAR))
    01306       return -1;
    01307
    01308    if ((f2->frametype != AST_FRAME_VOICE) || (f2->subclass != AST_FORMAT_SLINEAR))
    01309       return -1;
    01310
    01311    if (f1->samples != f2->samples)
    01312       return -1;
    01313
    01314    for (count = 0, data1 = f1->data, data2 = f2->data;
    01315         count < f1->samples;
    01316         count++, data1++, data2++)
    01317       ast_slinear_saturated_add(data1, data2);
    01318
    01319    return 0;
    01320 }

struct ast_frame* ast_frdup | ( | struct ast_frame * | fr | ) | `[read]`

Copies a frame.

Parameters:

  | fr | frame to copy Dupliates a frame -- should only rarely be used, typically frisolate is good enough

Returns:
  Returns a frame on success, NULL on error

Definition at line 365 of file frame.c.

References AST_MALLOCD_HDR, calloc, ast_frame::data, ast_frame::datalen, ast_frame::delivery, ast_frame::frametype, ast_frame::mallocd, ast_frame::offset, ast_frame::samples, ast_frame::src, and ast_frame::subclass.

Referenced by ast_channel_spy_read_frame(), ast_queue_frame(), ast_rtp_write(), ast_slinfactory_feed(), and queue_frame_to_spies().

    00366 {
    00367    struct ast_frame *out;
    00368    int len, srclen = 0;
    00369    void *buf;
    00370    /* Start with standard stuff */
    00371    len = sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + f->datalen;
    00372    /* If we have a source, add space for it */
    00373    /*
    00374     * XXX Watch out here - if we receive a src which is not terminated
    00375     * properly, we can be easily attacked. Should limit the size we deal with.
    00376     */
    00377    if (f->src)
    00378       srclen = strlen(f->src);
    00379    if (srclen > 0)
    00380       len += srclen + 1;
    00381    buf = calloc(1, len);
    00382    if (!buf)
    00383       return NULL;
    00384    out = buf;
    00385    /* Set us as having malloc'd header only, so it will eventually
    00386       get freed. */
    00387    out->frametype = f->frametype;
    00388    out->subclass = f->subclass;
    00389    out->datalen = f->datalen;
    00390    out->samples = f->samples;
    00391    out->delivery = f->delivery;
    00392    out->mallocd = AST_MALLOCD_HDR;
    00393    out->offset = AST_FRIENDLY_OFFSET;
    00394    if (out->datalen) {
    00395       out->data = buf + sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET;
    00396       memcpy(out->data, f->data, out->datalen);
    00397    }
    00398    if (srclen > 0) {
    00399       out->src = buf + sizeof(*out) + AST_FRIENDLY_OFFSET + f->datalen;
    00400       /* Must have space since we allocated for it */
    00401       strcpy((char *)out->src, f->src);
    00402    }
    00403    return out;
    00404 }

void ast_frfree | ( | struct ast_frame * | fr | ) |

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

Parameters:

  | fr | Frame to free Free a frame, and the memory it used if applicable

Returns:
  no return.

Todo:
  Important: I should be made more efficient. Frame headers should most definitely be cached

Definition at line 277 of file frame.c.

References AST_MALLOCD_DATA, AST_MALLOCD_HDR, AST_MALLOCD_SRC, ast_mutex_lock(), ast_mutex_unlock(), ast_frame::data, free, ast_frame::mallocd, ast_frame::next, ast_frame::offset, ast_frame::prev, and ast_frame::src.

Referenced by __adsi_transmit_messages(), __ast_request_and_dial(), adsi_careful_send(), agent_ack_sleep(), agent_read(), app_exec(), ast_app_getvoice(), ast_bridge_call(), ast_channel_free(), ast_channel_spy_free(), ast_channel_spy_read_frame(), ast_dsp_process(), ast_feature_request_and_dial(), ast_generic_bridge(), ast_masq_park_call(), ast_play_and_prepend(), ast_play_and_record_full(), ast_queue_frame(), ast_read(), ast_recvtext(), ast_rtp_bridge(), ast_rtp_write(), ast_safe_sleep(), ast_safe_sleep_conditional(), ast_send_image(), ast_slinfactory_destroy(), ast_slinfactory_read(), ast_tonepair(), ast_translate(), ast_waitfordigit(), ast_waitfordigit_full(), ast_waitstream(), ast_waitstream_exten(), ast_waitstream_fr(), ast_waitstream_full(), ast_write(), async_wait(), autoservice_run(), background_detect_exec(), builtin_atxfer(), calc_cost(), channel_spy(), check_goto_on_transfer(), conf_exec(), conf_flush(), conf_run(), copy_data_from_queue(), dictate_exec(), disa_exec(), do_parking_thread(), do_waiting(), echo_exec(), find_cache(), gen_generate(), handle_recordfile(), iax2_bridge(), iax_park_thread(), ices_exec(), measurenoise(), mixmonitor_thread(), moh_files_generator(), mp3_exec(), NBScat_exec(), queue_frame_to_spies(), receive_dtmf_digits(), record_exec(), recordthread(), rpt(), rpt_exec(), run_agi(), send_tone_burst(), send_waveform_to_channel(), sendurl_exec(), sms_exec(), spy_generate(), ss_thread(), vpb_bridge(), wait_for_answer(), wait_for_hangup(), waitforring_exec(), and zt_bridge().

    00278 {
    00279    if (fr->mallocd & AST_MALLOCD_DATA) {
    00280       if (fr->data)
    00281          free(fr->data - fr->offset);
    00282    }
    00283    if (fr->mallocd & AST_MALLOCD_SRC) {
    00284       if (fr->src)
    00285          free((char *)fr->src);
    00286    }
    00287    if (fr->mallocd & AST_MALLOCD_HDR) {
    00288 #ifdef TRACE_FRAMES
    00289       ast_mutex_lock(&framelock);
    00290       headers--;
    00291       if (fr->next)
    00292          fr->next->prev = fr->prev;
    00293       if (fr->prev)
    00294          fr->prev->next = fr->next;
    00295       else
    00296          headerlist = fr->next;
    00297       ast_mutex_unlock(&framelock);
    00298 #endif
    00299       free(fr);
    00300    }
    00301 }

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

Copies a frame.

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

Definition at line 308 of file frame.c.

References ast_frame_header_new(), AST_FRIENDLY_OFFSET, ast_log(), AST_MALLOCD_DATA, AST_MALLOCD_HDR, AST_MALLOCD_SRC, ast_frame::data, ast_frame::datalen, ast_frame::frametype, free, LOG_WARNING, malloc, ast_frame::mallocd, ast_frame::offset, ast_frame::samples, ast_frame::src, strdup, and ast_frame::subclass.

Referenced by jpeg_read_image(), and monitor_handle_owned().

    00309 {
    00310    struct ast_frame *out;
    00311    void *newdata;
    00312
    00313    if (!(fr->mallocd & AST_MALLOCD_HDR)) {
    00314       /* Allocate a new header if needed */
    00315       out = ast_frame_header_new();
    00316       if (!out) {
    00317          ast_log(LOG_WARNING, "Out of memory\n");
    00318          return NULL;
    00319       }
    00320       out->frametype = fr->frametype;
    00321       out->subclass = fr->subclass;
    00322       out->datalen = fr->datalen;
    00323       out->samples = fr->samples;
    00324       out->offset = fr->offset;
    00325       out->src = NULL;
    00326       out->data = fr->data;
    00327    } else
    00328       out = fr;
    00329
    00330    if (!(fr->mallocd & AST_MALLOCD_SRC)) {
    00331       if (fr->src) {
    00332          out->src = strdup(fr->src);
    00333          if (!out->src) {
    00334             if (out != fr)
    00335                free(out);
    00336             ast_log(LOG_WARNING, "Out of memory\n");
    00337             return NULL;
    00338          }
    00339       }
    00340    } else
    00341       out->src = fr->src;
    00342
    00343    if (!(fr->mallocd & AST_MALLOCD_DATA))  {
    00344       newdata = malloc(fr->datalen + AST_FRIENDLY_OFFSET);
    00345       if (!newdata) {
    00346          if (out->src != fr->src)
    00347             free((void *) out->src);
    00348          if (out != fr)
    00349             free(out);
    00350          ast_log(LOG_WARNING, "Out of memory\n");
    00351          return NULL;
    00352       }
    00353       newdata += AST_FRIENDLY_OFFSET;
    00354       out->offset = AST_FRIENDLY_OFFSET;
    00355       out->datalen = fr->datalen;
    00356       memcpy(newdata, fr->data, fr->datalen);
    00357       out->data = newdata;
    00358    }
    00359
    00360    out->mallocd = AST_MALLOCD_HDR | AST_MALLOCD_SRC | AST_MALLOCD_DATA;
    00361
    00362    return out;
    00363 }

struct ast_format_list* ast_get_format_list | ( | size_t * | size | ) | `[read]`

Definition at line 506 of file frame.c.

    00507 {
    00508    *size = (sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list));
    00509    return AST_FORMAT_LIST;
    00510 }

struct ast_format_list* ast_get_format_list_index | ( | int | index | ) | `[read]`

Definition at line 501 of file frame.c.

    00502 {
    00503    return &AST_FORMAT_LIST[index];
    00504 }

int ast_getformatbyname | ( | char * | name | ) |

Gets a format from a name.

Parameters:

  | name | string of format

Returns:
  This returns the form of the format in binary on success, 0 on error.

Definition at line 571 of file frame.c.

References ast_expand_codec_alias(), ast_format_list::bits, and format.

Referenced by ast_parse_allow_disallow(), iax_template_parse(), load_moh_classes(), reload_config(), try_suggested_sip_codec(), and update_common_options().

    00572 {
    00573    int x = 0, all = 0, format = 0;
    00574
    00575    all = strcasecmp(name, "all") ? 0 : 1;
    00576    for (x = 0 ; x < sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list) ; x++) {
    00577       if(AST_FORMAT_LIST[x].visible && (all ||
    00578                                 !strcasecmp(AST_FORMAT_LIST[x].name,name) ||
    00579                                 !strcasecmp(AST_FORMAT_LIST[x].name,ast_expand_codec_alias(name)))) {
    00580          format |= AST_FORMAT_LIST[x].bits;
    00581          if(!all)
    00582             break;
    00583       }
    00584    }
    00585
    00586    return format;
    00587 }

char* ast_getformatname | ( | int | format | ) |

Get the name of a format.

Parameters:

  | format | id of format

Returns:
  A static string containing the name of the format or "UNKN" if unknown.

Definition at line 512 of file frame.c.

References ast_format_list::bits, ast_format_list::name, and ast_format_list::visible.

Referenced by __login_exec(), __sip_show_channels(), _sip_show_peer(), add_codec_to_sdp(), agent_call(), ast_channel_spy_add(), ast_codec_get_len(), ast_codec_get_samples(), ast_codec_pref_string(), ast_dsp_process(), ast_frame_dump(), ast_play_and_prepend(), ast_play_and_record_full(), ast_read(), ast_register_translator(), ast_rtp_write(), ast_slinfactory_feed(), ast_streamfile(), ast_translator_build_path(), ast_unregister_translator(), ast_writestream(), background_detect_exec(), do_waiting(), eagi_exec(), function_iaxpeer(), function_sippeer(), iax2_request(), iax2_show_channels(), iax2_show_peer(), iax_show_provisioning(), modem_request(), moh_classes_show(), moh_release(), phone_setup(), print_codec_to_cli(), queue_frame_to_spies(), rebuild_matrix(), register_translator(), set_format(), show_codecs(), show_file_formats(), show_image_formats(), show_translation(), sip_request_call(), sip_rtp_read(), sip_show_channel(), sip_show_user(), socket_read(), and zt_read().

    00513 {
    00514    int x = 0;
    00515    char *ret = "unknown";
    00516    for (x = 0 ; x < sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list) ; x++) {
    00517       if(AST_FORMAT_LIST[x].visible && AST_FORMAT_LIST[x].bits == format) {
    00518          ret = AST_FORMAT_LIST[x].name;
    00519          break;
    00520       }
    00521    }
    00522    return ret;
    00523 }

char* ast_getformatname_multiple | ( | char * | buf,
|  | size_t | size,
|  | int | format |
| ) |  |  |

Get the names of a set of formats.

Parameters:

  | buf | a buffer for the output string
  | size | size of buf (bytes)
  | format | the format (combined IDs of codecs) Prints a list of readable codec names corresponding to "format". ex: for format=AST_FORMAT_GSM|AST_FORMAT_SPEEX|AST_FORMAT_ILBC it will return "0x602 (GSM|SPEEX|ILBC)"

Returns:
  The return value is buf.

Definition at line 525 of file frame.c.

References ast_format_list::bits, name, and ast_format_list::visible.

Referenced by _sip_show_peer(), function_iaxpeer(), function_sippeer(), iax2_bridge(), iax2_show_peer(), and process_sdp().

    00525                                                                      {
    00526
    00527    int x = 0;
    00528    unsigned len;
    00529    char *end = buf;
    00530    char *start = buf;
    00531    if (!size) return buf;
    00532    snprintf(end, size, "0x%x (", format);
    00533    len = strlen(end);
    00534    end += len;
    00535    size -= len;
    00536    start = end;
    00537    for (x = 0 ; x < sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list) ; x++) {
    00538       if (AST_FORMAT_LIST[x].visible && (AST_FORMAT_LIST[x].bits & format)) {
    00539          snprintf(end, size,"%s|",AST_FORMAT_LIST[x].name);
    00540          len = strlen(end);
    00541          end += len;
    00542          size -= len;
    00543       }
    00544    }
    00545    if (start == end)
    00546       snprintf(start, size, "nothing)");
    00547    else if (size > 1)
    00548       *(end -1) = ')';
    00549    return buf;
    00550 }

void ast_parse_allow_disallow | ( | struct ast_codec_pref * | pref,
|  | int * | mask,
|  | const char * | list,
|  | int | allowing |
| ) |  |  |

Parse an "allow" or "deny" line and update the mask and pref if provided.

Definition at line 1025 of file frame.c.

References ast_codec_pref_append(), ast_codec_pref_remove(), ast_getformatbyname(), ast_log(), ast_strdupa, format, LOG_WARNING, parse(), and strsep().

Referenced by build_peer(), build_user(), reload_config(), and set_config().

    01026 {
    01027    char *parse;
    01028    char *this;
    01029    int format;
    01030
    01031    parse = ast_strdupa(list);
    01032    while ((this = strsep(&parse, ","))) {
    01033       if (!(format = ast_getformatbyname(this))) {
    01034          ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", allowing ? "allow" : "disallow", this);
    01035          continue;
    01036       }
    01037
    01038       if (mask) {
    01039          if (allowing)
    01040             *mask |= format;
    01041          else
    01042             *mask &= ~format;
    01043       }
    01044
    01045       if (pref) {
    01046          if (strcasecmp(this, "all")) {
    01047             if (allowing)
    01048                ast_codec_pref_append(pref, format);
    01049             else
    01050                ast_codec_pref_remove(pref, format);
    01051          } else if (!allowing) {
    01052             memset(pref, 0, sizeof(*pref));
    01053          }
    01054       }
    01055    }
    01056 }

void ast_smoother_free | ( | struct ast_smoother * | s | ) |

Definition at line 247 of file frame.c.

References free.

Referenced by ast_rtp_destroy(), and ast_rtp_write().

    00248 {
    00249    free(s);
    00250 }

int ast_smoother_get_flags | ( | struct ast_smoother * | smoother | ) |

Definition at line 127 of file frame.c.

References ast_smoother::flags.

    00128 {
    00129    return s->flags;
    00130 }

struct ast_smoother* ast_smoother_new | ( | int | bytes | ) | `[read]`

Definition at line 116 of file frame.c.

References ast_smoother_reset(), malloc, and s.

Referenced by ast_rtp_write().

    00117 {
    00118    struct ast_smoother *s;
    00119    if (size < 1)
    00120       return NULL;
    00121    s = malloc(sizeof(struct ast_smoother));
    00122    if (s)
    00123       ast_smoother_reset(s, size);
    00124    return s;
    00125 }

struct ast_frame* ast_smoother_read | ( | struct ast_smoother * | s | ) | `[read]`

Definition at line 198 of file frame.c.

References AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), AST_SMOOTHER_FLAG_G729, ast_tvadd(), ast_smoother::data, ast_frame::data, ast_frame::datalen, ast_smoother::delivery, ast_frame::delivery, ast_smoother::f, ast_smoother::flags, ast_smoother::format, ast_smoother::framedata, ast_frame::frametype, ast_smoother::len, LOG_WARNING, ast_frame::offset, ast_smoother::opt, ast_frame::samples, ast_smoother::samplesperbyte, ast_smoother::size, and ast_frame::subclass.

Referenced by ast_rtp_write().

    00199 {
    00200    struct ast_frame *opt;
    00201    int len;
    00202    /* IF we have an optimization frame, send it */
    00203    if (s->opt) {
    00204       if (s->opt->offset < AST_FRIENDLY_OFFSET)
    00205          ast_log(LOG_WARNING, "Returning a frame of inappropriate offset (%d).\n",
    00206                      s->opt->offset);
    00207       opt = s->opt;
    00208       s->opt = NULL;
    00209       return opt;
    00210    }
    00211
    00212    /* Make sure we have enough data */
    00213    if (s->len < s->size) {
    00214       /* Or, if this is a G.729 frame with VAD on it, send it immediately anyway */
    00215       if (!((s->flags & AST_SMOOTHER_FLAG_G729) && (s->size % 10)))
    00216          return NULL;
    00217    }
    00218    len = s->size;
    00219    if (len > s->len)
    00220       len = s->len;
    00221    /* Make frame */
    00222    s->f.frametype = AST_FRAME_VOICE;
    00223    s->f.subclass = s->format;
    00224    s->f.data = s->framedata + AST_FRIENDLY_OFFSET;
    00225    s->f.offset = AST_FRIENDLY_OFFSET;
    00226    s->f.datalen = len;
    00227    /* Samples will be improper given VAD, but with VAD the concept really doesn't even exist */
    00228    s->f.samples = len * s->samplesperbyte;   /* XXX rounding */
    00229    s->f.delivery = s->delivery;
    00230    /* Fill Data */
    00231    memcpy(s->f.data, s->data, len);
    00232    s->len -= len;
    00233    /* Move remaining data to the front if applicable */
    00234    if (s->len) {
    00235       /* In principle this should all be fine because if we are sending
    00236          G.729 VAD, the next timestamp will take over anyawy */
    00237       memmove(s->data, s->data + len, s->len);
    00238       if (!ast_tvzero(s->delivery)) {
    00239          /* If we have delivery time, increment it, otherwise, leave it at 0 */
    00240          s->delivery = ast_tvadd(s->delivery, ast_samp2tv(s->f.samples, 8000));
    00241       }
    00242    }
    00243    /* Return frame */
    00244    return &s->f;
    00245 }

void ast_smoother_reset | ( | struct ast_smoother * | s,
|  | int | bytes |
| ) |  |  |

Definition at line 110 of file frame.c.

References ast_smoother::size.

Referenced by ast_smoother_new().

    00111 {
    00112    memset(s, 0, sizeof(struct ast_smoother));
    00113    s->size = size;
    00114 }

void ast_smoother_set_flags | ( | struct ast_smoother * | smoother,
|  | int | flags |
| ) |  |  |

Definition at line 132 of file frame.c.

References ast_smoother::flags.

Referenced by ast_rtp_write().

    00133 {
    00134    s->flags = flags;
    00135 }

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

Definition at line 490 of file frame.c.

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

    00491 {
    00492    int i;
    00493    unsigned short *dst_s = dst;
    00494    const unsigned short *src_s = src;
    00495
    00496    for (i=0; i<samples; i++)
    00497       dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8);
    00498 }