Asterisk - The Open Source Telephony Project
21.4.1
|
Media Format Cache API. More...
#include "asterisk.h"
#include "asterisk/logger.h"
#include "asterisk/format.h"
#include "asterisk/format_cache.h"
#include "asterisk/astobj2.h"
#include "asterisk/strings.h"
Go to the source code of this file.
Macros | |
#define | CACHE_BUCKETS 53 |
Number of buckets to use for the media format cache (should be prime for performance reasons) | |
Functions | |
struct ast_format * | __ast_format_cache_get (const char *name, const char *tag, const char *file, int line, const char *func) |
struct ast_format * | ast_format_cache_get_by_codec (const struct ast_codec *codec) |
Retrieve a format from the cache by its codec. More... | |
struct ast_format * | ast_format_cache_get_slin_by_rate (unsigned int rate) |
Retrieve the best signed linear format given a sample rate. More... | |
int | ast_format_cache_init (void) |
Initialize format cache support within the core. More... | |
int | ast_format_cache_is_slinear (struct ast_format *format) |
Determines if a format is one of the cached slin formats. More... | |
int | ast_format_cache_set (struct ast_format *format) |
Set a named format cache entry. More... | |
static void | format_cache_shutdown (void) |
Function called when the process is shutting down. | |
static int | format_cmp_cb (void *obj, void *arg, int flags) |
static int | format_hash_cb (const void *obj, int flags) |
static void | set_cached_format (const char *name, struct ast_format *format) |
Variables | |
struct ast_format * | ast_format_adpcm |
Built-in cached adpcm format. | |
struct ast_format * | ast_format_alaw |
Built-in cached alaw format. | |
struct ast_format * | ast_format_codec2 |
Built-in cached codec2 format. More... | |
struct ast_format * | ast_format_g719 |
Built-in cached g719 format. | |
struct ast_format * | ast_format_g722 |
Built-in cached g722 format. | |
struct ast_format * | ast_format_g723 |
Built-in cached g723.1 format. | |
struct ast_format * | ast_format_g726 |
Built-in cached g726 format. | |
struct ast_format * | ast_format_g726_aal2 |
Built-in cached g726-aal2 format. More... | |
struct ast_format * | ast_format_g729 |
Built-in cached g729 format. | |
struct ast_format * | ast_format_gsm |
Built-in cached gsm format. | |
struct ast_format * | ast_format_h261 |
Built-in cached h261 format. | |
struct ast_format * | ast_format_h263 |
Built-in cached h263 format. | |
struct ast_format * | ast_format_h263p |
Built-in cached h263 plus format. | |
struct ast_format * | ast_format_h264 |
Built-in cached h264 format. | |
struct ast_format * | ast_format_h265 |
Built-in cached h265 format. | |
struct ast_format * | ast_format_ilbc |
Built-in cached ilbc format. | |
struct ast_format * | ast_format_jpeg |
Built-in cached jpeg format. | |
struct ast_format * | ast_format_lpc10 |
Built-in cached ilbc format. | |
struct ast_format * | ast_format_mp4 |
Built-in cached mp4 format. | |
struct ast_format * | ast_format_none |
Built-in "null" format. | |
struct ast_format * | ast_format_opus |
Built-in cached opus format. | |
struct ast_format * | ast_format_png |
Built-in cached png format. | |
struct ast_format * | ast_format_silk12 |
struct ast_format * | ast_format_silk16 |
struct ast_format * | ast_format_silk24 |
struct ast_format * | ast_format_silk8 |
Built-in "silk" format. More... | |
struct ast_format * | ast_format_siren14 |
Built-in cached siren14 format. | |
struct ast_format * | ast_format_siren7 |
Built-in cached siren7 format. | |
struct ast_format * | ast_format_slin |
Built-in cached signed linear 8kHz format. | |
struct ast_format * | ast_format_slin12 |
Built-in cached signed linear 12kHz format. | |
struct ast_format * | ast_format_slin16 |
Built-in cached signed linear 16kHz format. | |
struct ast_format * | ast_format_slin192 |
Built-in cached signed linear 192kHz format. | |
struct ast_format * | ast_format_slin24 |
Built-in cached signed linear 24kHz format. | |
struct ast_format * | ast_format_slin32 |
Built-in cached signed linear 32kHz format. | |
struct ast_format * | ast_format_slin44 |
Built-in cached signed linear 44kHz format. | |
struct ast_format * | ast_format_slin48 |
Built-in cached signed linear 48kHz format. | |
struct ast_format * | ast_format_slin96 |
Built-in cached signed linear 96kHz format. | |
struct ast_format * | ast_format_speex |
Built-in cached speex format. | |
struct ast_format * | ast_format_speex16 |
Built-in cached speex at 16kHz format. | |
struct ast_format * | ast_format_speex32 |
Built-in cached speex at 32kHz format. | |
struct ast_format * | ast_format_t140 |
Built-in cached t140 format. | |
struct ast_format * | ast_format_t140_red |
Built-in cached t140 red format. | |
struct ast_format * | ast_format_t38 |
Built-in cached T.38 format. | |
struct ast_format * | ast_format_ulaw |
Built-in cached ulaw format. | |
struct ast_format * | ast_format_vp8 |
Built-in cached vp8 format. | |
struct ast_format * | ast_format_vp9 |
Built-in cached vp9 format. | |
static struct ao2_container * | formats |
Cached formats. | |
Media Format Cache API.
Definition in file format_cache.c.
struct ast_format* ast_format_cache_get_by_codec | ( | const struct ast_codec * | codec | ) |
Retrieve a format from the cache by its codec.
codec | The codec to search by |
non-NULL | if found |
NULL | if not found |
Definition at line 551 of file format_cache.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_ref, and ast_format_get_codec().
Referenced by ast_format_cap_append_by_type().
struct ast_format* ast_format_cache_get_slin_by_rate | ( | unsigned int | rate | ) |
Retrieve the best signed linear format given a sample rate.
rate | The sample rate |
This is a convenience function that returns one of the global ast_format_slinxxx formats.
Definition at line 512 of file format_cache.c.
References ast_format_slin, ast_format_slin12, ast_format_slin16, ast_format_slin192, ast_format_slin24, ast_format_slin32, ast_format_slin44, ast_format_slin48, and ast_format_slin96.
Referenced by ast_channel_make_compatible_helper(), snoop_determine_format(), softmix_bridge_unsuspend(), and softmix_mixing_loop().
int ast_format_cache_init | ( | void | ) |
Initialize format cache support within the core.
0 | success |
-1 | failure |
Definition at line 364 of file format_cache.c.
References AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_container_alloc_hash, ast_register_cleanup(), CACHE_BUCKETS, and format_cache_shutdown().
int ast_format_cache_is_slinear | ( | struct ast_format * | format | ) |
Determines if a format is one of the cached slin formats.
format | The format to check |
0 | if the format is not an SLIN format |
1 | if the format is an SLIN format |
Definition at line 534 of file format_cache.c.
References ast_format_cmp(), and AST_FORMAT_CMP_EQUAL.
Referenced by __ast_read(), ast_channel_make_compatible_helper(), ast_dsp_call_progress(), ast_dsp_process(), ast_frame_adjust_volume(), ast_frame_adjust_volume_float(), ast_slinfactory_init_with_format(), and ast_write_stream().
int ast_format_cache_set | ( | struct ast_format * | format | ) |
Set a named format cache entry.
format | A pointer to the format to cache |
0 | success |
-1 | failure |
Definition at line 474 of file format_cache.c.
References ao2_link_flags, ao2_unlink_flags, ast_format_get_name(), lock, OBJ_NOLOCK, OBJ_SEARCH_KEY, and SCOPED_AO2WRLOCK.
struct ast_format* ast_format_codec2 |
Built-in cached codec2 format.
Built-in cached Codec 2 format.
Definition at line 226 of file format_cache.c.
struct ast_format* ast_format_g726_aal2 |
Built-in cached g726-aal2 format.
Built-in cached g726 aal2 format.
Definition at line 116 of file format_cache.c.
Referenced by ast_format_compatibility_bitfield2format(), ast_format_compatibility_codec2bitfield(), ast_format_compatibility_format2bitfield(), ast_rtp_codecs_payloads_set_rtpmap_type_rate(), ast_rtp_engine_init(), and ast_rtp_lookup_mime_subtype2().
struct ast_format* ast_format_silk8 |