Asterisk - The Open Source Telephony Project GIT-master-a358458
Data Fields
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. More...
 
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). More...
 
int comp_cost
 
struct ast_codeccore_dst_codec
 
struct ast_codeccore_src_codec
 
int desc_size
 
void(* destroy )(struct ast_trans_pvt *pvt)
 
struct ast_codec dst_codec
 
int dst_fmt_index
 
void(* feedback )(struct ast_trans_pvt *pvt, struct ast_frame *feedback)
 
const char * format
 
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
 
char name [80]
 
int native_plc
 
int(* newpvt )(struct ast_trans_pvt *)
 
struct ast_frame *(* sample )(void)
 
struct ast_codec src_codec
 
int src_fmt_index
 
int table_cost
 

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, feedback, 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 137 of file translate.h.

Field Documentation

◆ active

int active

Whether this translator should be used or not

Definition at line 189 of file translate.h.

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

◆ buf_size

int buf_size

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

Definition at line 182 of file translate.h.

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

◆ buffer_samples

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

Definition at line 177 of file translate.h.

Referenced by framein(), and register_translator().

◆ comp_cost

int comp_cost

Cost value associated with this translator based on computation time. This cost value is computed based on the time required to translate sample data.

Definition at line 147 of file translate.h.

Referenced by __ast_register_translator(), generate_computational_cost(), and matrix_rebuild().

◆ core_dst_codec

struct ast_codec* core_dst_codec

Core registered destination codec

Definition at line 142 of file translate.h.

◆ core_src_codec

struct ast_codec* core_src_codec

Core registered source codec

Definition at line 141 of file translate.h.

◆ desc_size

int desc_size

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

Definition at line 184 of file translate.h.

Referenced by newpvt(), and register_translator().

◆ destroy

void(* destroy) (struct ast_trans_pvt *pvt)

cleanup private data, if needed (often unnecessary).

Definition at line 166 of file translate.h.

Referenced by destroy(), and register_translator().

◆ dst_codec

struct ast_codec dst_codec

◆ dst_fmt_index

int dst_fmt_index

index of the destination format in the matrix table

Definition at line 191 of file translate.h.

Referenced by __ast_register_translator(), ast_translator_build_path(), handle_show_translation_path(), and matrix_rebuild().

◆ feedback

void(* feedback) (struct ast_trans_pvt *pvt, struct ast_frame *feedback)

Feedback frame callback. Handle input frame.

Definition at line 162 of file translate.h.

Referenced by ast_translate().

◆ format

const char* format

Optional name of a cached format this translator produces

Definition at line 143 of file translate.h.

◆ framein

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

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

Definition at line 154 of file translate.h.

Referenced by framein(), and register_translator().

◆ frameout

struct ast_frame *(* frameout) (struct ast_trans_pvt *pvt)

Output frame callback. Generate a frame with outbuf content.

Definition at line 154 of file translate.h.

Referenced by __ast_register_translator(), ast_translate(), generate_computational_cost(), and register_translator().

◆ 

struct { ... } list

link field

Referenced by ast_unregister_translator(), and matrix_rebuild().

◆ module

struct ast_module* module

opaque reference to the parent module

Definition at line 187 of file translate.h.

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

◆ name

char name[80]

◆ native_plc

int native_plc

true if the translator can do native plc

Definition at line 185 of file translate.h.

Referenced by framein(), and register_translator().

◆ newpvt

int(* newpvt) (struct ast_trans_pvt *)

initialize private data associated with the translator

Definition at line 151 of file translate.h.

Referenced by newpvt(), and register_translator().

◆ next

struct ast_translator* next

Definition at line 192 of file translate.h.

◆ sample

struct ast_frame *(* sample) (void)

Generate an example frame

Definition at line 166 of file translate.h.

Referenced by generate_computational_cost(), and register_translator().

◆ src_codec

struct ast_codec src_codec

◆ src_fmt_index

int src_fmt_index

index of the source format in the matrix table

Definition at line 190 of file translate.h.

Referenced by __ast_register_translator(), and matrix_rebuild().

◆ table_cost

int table_cost

Cost value associated with this translator based on translation cost table.

Definition at line 145 of file translate.h.

Referenced by __ast_register_translator(), and matrix_rebuild().


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