Sat Mar 24 23:51:50 2007

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.
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.
ast_frameast_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.
ast_frameast_frdup (struct ast_frame *fr)
 Copies a frame.
void ast_frfree (struct ast_frame *fr)
 Requests a frame to be allocated Frees a frame.
ast_frameast_frisolate (struct ast_frame *fr)
 Copies a frame.
ast_format_list * ast_get_format_list (size_t *size)
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)
ast_smoother * ast_smoother_new (int bytes)
ast_frameast_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.

Definition in file frame.h.


Define Documentation

#define AST_CONTROL_ANSWER   4

Remote end has answered

Definition at line 217 of file frame.h.

#define AST_CONTROL_BUSY   5

Remote end is busy

Definition at line 219 of file frame.h.

#define AST_CONTROL_CONGESTION   8

Congestion (circuits busy)

Definition at line 225 of file frame.h.

#define AST_CONTROL_FLASH   9

Flash hook

Definition at line 227 of file frame.h.

#define AST_CONTROL_HANGUP   1

Other end has hungup

Definition at line 211 of file frame.h.

#define AST_CONTROL_HOLD   16

Indicate call is placed on hold

Definition at line 241 of file frame.h.

#define AST_CONTROL_OFFHOOK   7

Line is off hook

Definition at line 223 of file frame.h.

#define AST_CONTROL_OPTION   11

Set a low-level option

Definition at line 231 of file frame.h.

#define AST_CONTROL_PROCEEDING   15

Indicate CALL PROCEEDING

Definition at line 239 of file frame.h.

#define AST_CONTROL_PROGRESS   14

Indicate PROGRESS

Definition at line 237 of file frame.h.

#define AST_CONTROL_RADIO_KEY   12

Key Radio

Definition at line 233 of file frame.h.

#define AST_CONTROL_RADIO_UNKEY   13

Un-Key Radio

Definition at line 235 of file frame.h.

#define AST_CONTROL_RING   2

Local ring

Definition at line 213 of file frame.h.

#define AST_CONTROL_RINGING   3

Remote end is ringing

Definition at line 215 of file frame.h.

#define AST_CONTROL_TAKEOFFHOOK   6

Make it go off hook

Definition at line 221 of file frame.h.

#define AST_CONTROL_UNHOLD   17

Indicate call is left from hold

Definition at line 243 of file frame.h.

#define AST_CONTROL_VIDUPDATE   18

Indicate video frame update

Definition at line 245 of file frame.h.

#define AST_CONTROL_WINK   10

Wink

Definition at line 229 of file frame.h.

#define AST_FORMAT_ADPCM   (1 << 5)

ADPCM (IMA)

Definition at line 183 of file frame.h.

#define AST_FORMAT_ALAW   (1 << 3)

Raw A-law data (G.711)

Definition at line 179 of file frame.h.

#define AST_FORMAT_G723_1   (1 << 0)

G.723.1 compression

Definition at line 173 of file frame.h.

#define AST_FORMAT_G726   (1 << 4)

ADPCM (G.726, 32kbps)

Definition at line 181 of file frame.h.

#define AST_FORMAT_G729A   (1 << 8)

G.729A audio

Definition at line 189 of file frame.h.

#define AST_FORMAT_GSM   (1 << 1)

GSM compression

Definition at line 175 of file frame.h.

#define AST_FORMAT_H261   (1 << 18)

H.261 Video

Definition at line 201 of file frame.h.

#define AST_FORMAT_H263   (1 << 19)

H.263 Video

Definition at line 203 of file frame.h.

#define AST_FORMAT_H263_PLUS   (1 << 20)

H.263+ Video

Definition at line 205 of file frame.h.

#define AST_FORMAT_ILBC   (1 << 10)

iLBC Free Compression

Definition at line 193 of file frame.h.

#define AST_FORMAT_JPEG   (1 << 16)

JPEG Images

Definition at line 197 of file frame.h.

#define AST_FORMAT_LPC10   (1 << 7)

LPC10, 180 samples/frame

Definition at line 187 of file frame.h.

#define AST_FORMAT_MAX_AUDIO   (1 << 15)

Maximum audio format

Definition at line 195 of file frame.h.

#define AST_FORMAT_MAX_VIDEO   (1 << 24)

Maximum video format

Definition at line 207 of file frame.h.

#define AST_FORMAT_PNG   (1 << 17)

PNG Images

Definition at line 199 of file frame.h.

#define AST_FORMAT_SLINEAR   (1 << 6)

Raw 16-bit Signed Linear (8000 Hz) PCM

Definition at line 185 of file frame.h.

#define AST_FORMAT_SPEEX   (1 << 9)

SpeeX Free Compression

Definition at line 191 of file frame.h.

#define AST_FORMAT_ULAW   (1 << 2)

Raw mu-law data (G.711)

Definition at line 177 of file frame.h.

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

#define AST_FRAME_CONTROL   4

A control frame, subclass is AST_CONTROL_*

Definition at line 134 of file frame.h.

#define AST_FRAME_DTMF   1

A DTMF digit, subclass is the digit

Definition at line 128 of file frame.h.

#define AST_FRAME_HTML   9

HTML Frame

Definition at line 144 of file frame.h.

#define AST_FRAME_IAX   6

Inter Asterisk Exchange private frame type

Definition at line 138 of file frame.h.

#define AST_FRAME_IMAGE   8

Image Frames

Definition at line 142 of file frame.h.

#define AST_FRAME_NULL   5

An empty, useless frame

Definition at line 136 of file frame.h.

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

#define AST_FRAME_VIDEO   3

Video frame, maybe?? :)

Definition at line 132 of file frame.h.

#define AST_FRAME_VOICE   2

Voice data, subclass is AST_FORMAT_*

Definition at line 130 of file frame.h.

#define AST_HTML_BEGIN   4

Beginning frame

Definition at line 157 of file frame.h.

#define AST_HTML_DATA   2

Data frame

Definition at line 155 of file frame.h.

#define AST_HTML_END   8

End frame

Definition at line 159 of file frame.h.

#define AST_HTML_LDCOMPLETE   16

Load is complete

Definition at line 161 of file frame.h.

#define AST_HTML_LINKREJECT   20

Reject link request

Definition at line 169 of file frame.h.

#define AST_HTML_LINKURL   18

Send URL, and track

Definition at line 165 of file frame.h.

#define AST_HTML_NOSUPPORT   17

Peer is unable to support HTML

Definition at line 163 of file frame.h.

#define AST_HTML_UNLINK   19

No more HTML linkage

Definition at line 167 of file frame.h.

#define AST_HTML_URL   1

Sending a URL

Definition at line 153 of file frame.h.

#define AST_MALLOCD_DATA   (1 << 1)

Need the data be free'd?

Definition at line 122 of file frame.h.

#define AST_MALLOCD_HDR   (1 << 0)

Need the header be free'd?

Definition at line 120 of file frame.h.

#define AST_MALLOCD_SRC   (1 << 2)

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

Definition at line 124 of file frame.h.

#define AST_OPTION_AUDIO_MODE   4

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

Definition at line 268 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.

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

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

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

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


Function Documentation

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.

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  ) 

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

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.

struct ast_frame* ast_frdup ( struct ast_frame fr  ) 

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

void ast_frfree ( struct ast_frame fr  ) 

Requests a frame to be allocated Frees a frame.

Parameters:
fr Frame to free Free a frame, and the memory it used if applicable
Returns:
no return.

struct ast_frame* ast_frisolate ( struct ast_frame fr  ) 

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

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.

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.

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.


Generated on Sat Mar 24 23:51:50 2007 for Asterisk - the Open Source PBX by  doxygen 1.5.1