Asterisk - The Open Source Telephony Project
21.4.1
|
Codec API. More...
Go to the source code of this file.
Data Structures | |
struct | ast_codec |
Represents a media codec within Asterisk. More... | |
Macros | |
#define | ast_codec_register(codec) __ast_codec_register(codec, AST_MODULE_SELF) |
This function is used to register a codec with the Asterisk core. Registering allows it to be passed through in frames and configured in channel drivers. More... | |
Enumerations | |
enum | ast_media_type { AST_MEDIA_TYPE_UNKNOWN = 0, AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_VIDEO, AST_MEDIA_TYPE_IMAGE, AST_MEDIA_TYPE_TEXT, AST_MEDIA_TYPE_END } |
Types of media. | |
Functions | |
int | __ast_codec_register (struct ast_codec *codec, struct ast_module *mod) |
This function is used to register a codec with the Asterisk core. Registering allows it to be passed through in frames and configured in channel drivers. More... | |
int | ast_codec_builtin_init (void) |
Initialize built-in codecs within the core. More... | |
unsigned int | ast_codec_determine_length (const struct ast_codec *codec, unsigned int samples) |
Get the length of media (in milliseconds) given a number of samples. More... | |
struct ast_codec * | ast_codec_get (const char *name, enum ast_media_type type, unsigned int sample_rate) |
Retrieve a codec given a name, type, and sample rate. More... | |
struct ast_codec * | ast_codec_get_by_id (int id) |
Retrieve a codec given the unique identifier. More... | |
int | ast_codec_get_max (void) |
Retrieve the current maximum identifier for codec iteration. More... | |
int | ast_codec_init (void) |
Initialize codec support within the core. More... | |
const char * | ast_codec_media_type2str (enum ast_media_type type) |
Conversion function to take a media type and turn it into a string. More... | |
unsigned int | ast_codec_samples_count (struct ast_frame *frame) |
Get the number of samples contained within a frame. More... | |
enum ast_media_type | ast_media_type_from_str (const char *media_type_str) |
Conversion function to take a media string and convert it to a media type. More... | |
Codec API.
Definition in file codec.h.
#define ast_codec_register | ( | codec | ) | __ast_codec_register(codec, AST_MODULE_SELF) |
int __ast_codec_register | ( | struct ast_codec * | codec, |
struct ast_module * | mod | ||
) |
This function is used to register a codec with the Asterisk core. Registering allows it to be passed through in frames and configured in channel drivers.
codec | to register |
mod | the module this codec is provided by |
0 | success |
-1 | failure |
int ast_codec_builtin_init | ( | void | ) |
Initialize built-in codecs within the core.
0 | success |
-1 | failure |
Definition at line 956 of file codec_builtin.c.
unsigned int ast_codec_determine_length | ( | const struct ast_codec * | codec, |
unsigned int | samples | ||
) |
Get the length of media (in milliseconds) given a number of samples.
codec | The codec itself |
samples | The number of samples |
length | of media (in milliseconds) |
Definition at line 408 of file codec.c.
References ast_codec::get_length.
Referenced by ast_format_determine_length().
struct ast_codec* ast_codec_get | ( | const char * | name, |
enum ast_media_type | type, | ||
unsigned int | sample_rate | ||
) |
Retrieve a codec given a name, type, and sample rate.
name | The name of the codec |
type | The type of the codec |
sample_rate | Optional sample rate, may not be applicable for some types |
non-NULL | success |
NULL | failure |
Definition at line 327 of file codec.c.
References ast_codec::name, OBJ_SEARCH_OBJECT, ast_codec::sample_rate, and ast_codec::type.
Referenced by __ast_register_translator(), and newpvt().
struct ast_codec* ast_codec_get_by_id | ( | int | id | ) |
Retrieve a codec given the unique identifier.
id | The unique identifier |
non-NULL | success |
NULL | failure |
Definition at line 338 of file codec.c.
References ao2_callback, and codec_id_cmp().
Referenced by ast_format_cap_append_by_type().
int ast_codec_get_max | ( | void | ) |
Retrieve the current maximum identifier for codec iteration.
Definition at line 343 of file codec.c.
References codec_id.
Referenced by ast_format_cap_append_by_type().
int ast_codec_init | ( | void | ) |
Initialize codec support within the core.
0 | success |
-1 | failure |
Definition at line 250 of file codec.c.
References AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_container_alloc_hash, ast_cli_register_multiple, ast_register_cleanup(), CODEC_BUCKETS, and codec_shutdown().
const char* ast_codec_media_type2str | ( | enum ast_media_type | type | ) |
Conversion function to take a media type and turn it into a string.
type | The media type |
string | representation of the media type |
Definition at line 348 of file codec.c.
Referenced by ast_rtp_engine_load_format(), ast_rtp_read(), ast_stream_create_resolved(), ast_stream_to_str(), ast_stream_topology_append_stream(), ast_stream_topology_create_from_format_cap(), ast_stream_topology_set_stream(), create_outgoing_sdp_stream(), handle_showchan(), negotiate_incoming_sdp_stream(), and rtp_check_timeout().
unsigned int ast_codec_samples_count | ( | struct ast_frame * | frame | ) |
Get the number of samples contained within a frame.
frame | The frame itself |
number | of samples in the frame |
Definition at line 379 of file codec.c.
References ao2_ref, ast_format_get_codec(), ast_format_get_name(), AST_FRAME_IMAGE, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frame_subclass::format, ast_frame::frametype, ast_codec::samples_count, and ast_frame::subclass.
Referenced by ogg_speex_read(), and schedule_delivery().
enum ast_media_type ast_media_type_from_str | ( | const char * | media_type_str | ) |