Asterisk - The Open Source Telephony Project  GIT-master-44aef04
Data Fields
ast_format_def Struct Reference

Each supported file format is described by the following structure. More...

#include <mod_format.h>

Data Fields

int buf_size
 
void(* close )(struct ast_filestream *)
 
int desc_size
 
char exts [80]
 
struct ast_formatformat
 
char *(* getcomment )(struct ast_filestream *)
 
struct {
   struct ast_format_def *   next
 
list
 
char mime_types [80]
 
struct ast_modulemodule
 
char name [80]
 
int(* open )(struct ast_filestream *s)
 Prepare an input stream for playback. More...
 
struct ast_frame *(* read )(struct ast_filestream *, int *whennext)
 
int(* rewrite )(struct ast_filestream *s, const char *comment)
 Prepare a stream for output, and comment it appropriately if applicable. More...
 
int(* seek )(struct ast_filestream *, off_t, int)
 
off_t(* tell )(struct ast_filestream *fs)
 
int(* trunc )(struct ast_filestream *fs)
 
int(* write )(struct ast_filestream *, struct ast_frame *)
 

Detailed Description

Each supported file format is described by the following structure.

Not all are necessary, the support routine implement default values for some of them. A handler typically fills a structure initializing the desired fields, and then calls ast_format_def_register() with the (readonly) structure as an argument.

Definition at line 43 of file mod_format.h.

Field Documentation

◆ buf_size

int buf_size

If the handler needs a buffer (for read, typically) and/or a private descriptor, put here the required size (in bytes) and the support routine will allocate them for you, pointed by s->buf and s->private, respectively. When allocating a buffer, remember to leave AST_FRIENDLY_OFFSET spare bytes at the bginning.size of frame buffer, if any, aligned to 8 bytes.

Definition at line 90 of file mod_format.h.

Referenced by __ast_format_def_register(), and get_filestream().

◆ close

void(* close) (struct ast_filestream *)

Do any closing actions, if any. The descriptor and structure are closed and destroyed by the generic routines, so they must not be done here.

Definition at line 77 of file mod_format.h.

Referenced by filestream_destructor().

◆ desc_size

int desc_size

size of private descriptor, if any

Definition at line 91 of file mod_format.h.

Referenced by get_filestream(), load_module(), and unload_module().

◆ exts

char exts[80]

Extensions (separated by | if more than one) this format can read. First is assumed for writing (e.g. .mp3)

Definition at line 45 of file mod_format.h.

Referenced by __ast_format_def_register(), ast_format_str_reduce(), ast_get_extension_for_mime_type(), ast_get_format_for_file_ext(), ast_readfile(), ast_writefile(), filehelper(), handle_cli_core_show_file_formats(), and publish_format_update().

◆ format

struct ast_format* format

◆ getcomment

char*(* getcomment) (struct ast_filestream *)

Retrieve file comment

Definition at line 78 of file mod_format.h.

◆ list

struct { ... } list

◆ mime_types

char mime_types[80]

MIME Types related to the format (separated by | if more than one)

Definition at line 47 of file mod_format.h.

Referenced by ast_get_extension_for_mime_type().

◆ module

struct ast_module* module

Definition at line 93 of file mod_format.h.

Referenced by __ast_format_def_register(), filestream_destructor(), and get_filestream().

◆ name

char name[80]

◆ next

struct ast_format_def* next

Definition at line 80 of file mod_format.h.

◆ open

int(* open) (struct ast_filestream *s)

Prepare an input stream for playback.

Returns
0 on success, -1 on error. The FILE is already open (in s->f) so this function only needs to perform any applicable validity checks on the file. If none is required, the function can be omitted.

Definition at line 56 of file mod_format.h.

Referenced by fn_wrapper().

◆ read

struct ast_frame*(* read) (struct ast_filestream *, int *whennext)

Read the next frame from the filestream (if available) and report when to get next frame (in samples)

Definition at line 74 of file mod_format.h.

Referenced by read_frame().

◆ rewrite

int(* rewrite) (struct ast_filestream *s, const char *comment)

Prepare a stream for output, and comment it appropriately if applicable.

Returns
0 on success, -1 on error. Same as the open, the FILE is already open so the function just needs to prepare any header and other fields, if any. The function can be omitted if nothing is needed.

Definition at line 64 of file mod_format.h.

Referenced by fn_wrapper().

◆ seek

int(* seek) (struct ast_filestream *, off_t, int)

seek num samples into file, whence - like a normal seek but with offset in samples

Definition at line 68 of file mod_format.h.

Referenced by ast_seekstream(), and ast_writefile().

◆ tell

off_t(* tell) (struct ast_filestream *fs)

tell current position

Definition at line 70 of file mod_format.h.

Referenced by ast_tellstream().

◆ trunc

int(* trunc) (struct ast_filestream *fs)

trunc file to current position

Definition at line 69 of file mod_format.h.

Referenced by ast_truncstream().

◆ write

int(* write) (struct ast_filestream *, struct ast_frame *)

Write a frame to a channel

Definition at line 66 of file mod_format.h.

Referenced by ast_writestream(), and MultiOrderedConfigParser::write().


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