Wed Oct 28 11:46:48 2009

Asterisk developer's documentation


ast_translator Struct Reference

Descriptor of a translator. More...

#include <translate.h>

Collaboration diagram for ast_translator:

Collaboration graph
[legend]

Data Fields

int active
int buf_size
 size of outbuf, in bytes. Mandatory. The wrapper code will also allocate an AST_FRIENDLY_OFFSET space before.
int buffer_samples
 size of outbuf, in samples. Leave it 0 if you want the framein callback deal with the frame. Set it appropriately if you want the code to checks if the incoming frame fits the outbuf (this is e.g. required for plc).
int cost
int desc_size
void(* destroy )(struct ast_trans_pvt *pvt)
int dstfmt
int(* framein )(struct ast_trans_pvt *pvt, struct ast_frame *in)
struct ast_frame *(* frameout )(struct ast_trans_pvt *pvt)
struct {
   struct ast_translator *   next
list
struct ast_modulemodule
const char name [80]
int native_plc
int(* newpvt )(struct ast_trans_pvt *)
int plc_samples
struct ast_frame *(* sample )(void)
int srcfmt
int useplc

Detailed Description

Descriptor of a translator.

Name, callbacks, and various options related to run-time operation (size of buffers, auxiliary descriptors, etc).

A codec registers itself by filling the relevant fields of a structure and passing it as an argument to ast_register_translator(). The structure should not be modified after a successful registration, and its address must be used as an argument to ast_unregister_translator().

As a minimum, a translator should supply name, srcfmt and dstfmt, the required buf_size (in bytes) and buffer_samples (in samples), and a few callbacks (framein, frameout, sample). The outbuf is automatically prepended by AST_FRIENDLY_OFFSET spare bytes so generic routines can place data in there.

Note, the translator is not supposed to do any memory allocation or deallocation, nor any locking, because all of this is done in the generic code.

Translators using generic plc (packet loss concealment) should supply a non-zero plc_samples indicating the size (in samples) of artificially generated frames and incoming data. Generic plc is only available for dstfmt = SLINEAR

Definition at line 71 of file translate.h.


Field Documentation

int active

Whether this translator should be used or not

Definition at line 115 of file translate.h.

Referenced by __ast_register_translator(), ast_translator_activate(), ast_translator_deactivate(), and rebuild_matrix().

int buf_size

size of outbuf, in bytes. Mandatory. The wrapper code will also allocate an AST_FRIENDLY_OFFSET space before.

Definition at line 105 of file translate.h.

Referenced by __ast_register_translator(), dahdi_decoder_frameout(), dahdi_encoder_frameout(), lintospeex_frameout(), newpvt(), and register_translator().

size of outbuf, in samples. Leave it 0 if you want the framein callback deal with the frame. Set it appropriately if you want the code to checks if the incoming frame fits the outbuf (this is e.g. required for plc).

Definition at line 100 of file translate.h.

Referenced by __ast_register_translator(), framein(), and register_translator().

int cost

Cost in milliseconds for encoding/decoding 1 second of sound

Definition at line 114 of file translate.h.

Referenced by __ast_register_translator(), ast_translator_best_choice(), calc_cost(), handle_cli_core_show_translation(), and rebuild_matrix().

int desc_size

size of private descriptor in pvt->pvt, if any

Definition at line 107 of file translate.h.

Referenced by newpvt(), and register_translator().

void(* destroy)(struct ast_trans_pvt *pvt)

cleanup private data, if needed (often unnecessary).

Referenced by destroy(), and register_translator().

int dstfmt

int(* framein)(struct ast_trans_pvt *pvt, struct ast_frame *in)

Input frame callback. Store (and possibly convert) input frame.

Referenced by framein(), and register_translator().

struct ast_frame*(* frameout)(struct ast_trans_pvt *pvt) [read]

Output frame callback. Generate a frame with outbuf content.

Referenced by __ast_register_translator(), calc_cost(), and register_translator().

struct { ... } list

link field

Referenced by ast_unregister_translator(), and rebuild_matrix().

struct ast_module* module [read]

Definition at line 112 of file translate.h.

Referenced by __ast_register_translator(), destroy(), and newpvt().

const char name[80]

true if the translator can do native plc

Definition at line 110 of file translate.h.

Referenced by framein(), and register_translator().

int(* newpvt)(struct ast_trans_pvt *)

initialize private data associated with the translator

Referenced by newpvt(), and register_translator().

struct ast_translator* next [read]

Definition at line 116 of file translate.h.

set to the plc block size if used, 0 otherwise

Definition at line 108 of file translate.h.

Referenced by __ast_register_translator(), framein(), newpvt(), and register_translator().

struct ast_frame*(* sample)(void) [read]

Generate an example frame

Referenced by calc_cost(), and register_translator().

int srcfmt

Source format (note: bit position, converted to index during registration)

Definition at line 73 of file translate.h.

Referenced by __ast_register_translator(), ast_unregister_translator(), dahdi_new(), drop_translator(), is_encoder(), rebuild_matrix(), and register_translator().

int useplc

current status of plc, changed at runtime

Definition at line 109 of file translate.h.

Referenced by newpvt(), parse_config(), register_translator(), and reload().


The documentation for this struct was generated from the following file:

Generated on Wed Oct 28 11:46:49 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6