format_cache.h File Reference

Media Format Cache API. More...

Go to the source code of this file.

Defines

#define ast_format_cache_get(name)   __ast_format_cache_get((name))
#define ast_t_format_cache_get(name, tag)   __ast_format_cache_get((name))

Functions

struct ast_format__ast_format_cache_get (const char *name)
 Retrieve a named format from the cache.
struct ast_format__ast_format_cache_get_debug (const char *name, const char *tag, const char *file, int line, const char *func)
struct ast_formatast_format_cache_get_slin_by_rate (unsigned int rate)
 Retrieve the best signed linear format given a sample rate.
int ast_format_cache_init (void)
 Initialize format cache support within the core.
int ast_format_cache_is_slinear (struct ast_format *format)
 Determines if a format is one of the cached slin formats.
int ast_format_cache_set (struct ast_format *format)
 Set a named format cache entry.

Variables

struct ast_formatast_format_adpcm
 Built-in cached adpcm format.
struct ast_formatast_format_alaw
 Built-in cached alaw format.
struct ast_formatast_format_g719
 Built-in cached g719 format.
struct ast_formatast_format_g722
 Built-in cached g722 format.
struct ast_formatast_format_g723
 Built-in cached g723.1 format.
struct ast_formatast_format_g726
 Built-in cached g726 format.
struct ast_formatast_format_g726_aal2
 Built-in cached g726 aal2 format.
struct ast_formatast_format_g729
 Built-in cached g729 format.
struct ast_formatast_format_gsm
 Built-in cached gsm format.
struct ast_formatast_format_h261
 Built-in cached h261 format.
struct ast_formatast_format_h263
 Built-in cached h263 format.
struct ast_formatast_format_h263p
 Built-in cached h263 plus format.
struct ast_formatast_format_h264
 Built-in cached h264 format.
struct ast_formatast_format_ilbc
 Built-in cached ilbc format.
struct ast_formatast_format_jpeg
 Built-in cached jpeg format.
struct ast_formatast_format_lpc10
 Built-in cached ilbc format.
struct ast_formatast_format_mp4
 Built-in cached mp4 format.
struct ast_formatast_format_none
 Built-in "null" format.
struct ast_formatast_format_opus
 Built-in cached opus format.
struct ast_formatast_format_png
 Built-in cached png format.
struct ast_formatast_format_siren14
 Built-in cached siren14 format.
struct ast_formatast_format_siren7
 Built-in cached siren7 format.
struct ast_formatast_format_slin
 Built-in cached signed linear 8kHz format.
struct ast_formatast_format_slin12
 Built-in cached signed linear 12kHz format.
struct ast_formatast_format_slin16
 Built-in cached signed linear 16kHz format.
struct ast_formatast_format_slin192
 Built-in cached signed linear 192kHz format.
struct ast_formatast_format_slin24
 Built-in cached signed linear 24kHz format.
struct ast_formatast_format_slin32
 Built-in cached signed linear 32kHz format.
struct ast_formatast_format_slin44
 Built-in cached signed linear 44kHz format.
struct ast_formatast_format_slin48
 Built-in cached signed linear 48kHz format.
struct ast_formatast_format_slin96
 Built-in cached signed linear 96kHz format.
struct ast_formatast_format_speex
 Built-in cached speex format.
struct ast_formatast_format_speex16
 Built-in cached speex at 16kHz format.
struct ast_formatast_format_speex32
 Built-in cached speex at 32kHz format.
struct ast_formatast_format_t140
 Built-in cached t140 format.
struct ast_formatast_format_t140_red
 Built-in cached t140 red format.
struct ast_formatast_format_testlaw
 Built-in cached testlaw format.
struct ast_formatast_format_ulaw
 Built-in cached ulaw format.
struct ast_formatast_format_vp8
 Built-in cached vp8 format.


Detailed Description

Media Format Cache API.

Author:
Joshua Colp <jcolp@digium.com>

Definition in file format_cache.h.


Define Documentation

#define ast_format_cache_get ( name   )     __ast_format_cache_get((name))

#define ast_t_format_cache_get ( name,
tag   )     __ast_format_cache_get((name))

Definition at line 266 of file format_cache.h.


Function Documentation

struct ast_format* __ast_format_cache_get ( const char *  name  )  [read]

Retrieve a named format from the cache.

Parameters:
name Name of the cached format
Return values:
non-NULL if found
NULL if not found
Note:
The returned format has its reference count incremented. It must be dropped using ao2_ref or ao2_cleanup.

Definition at line 460 of file format_cache.c.

References ao2_find, ast_strlen_zero, NULL, and OBJ_SEARCH_KEY.

00461 {
00462    if (ast_strlen_zero(name)) {
00463       return NULL;
00464    }
00465 
00466    return ao2_find(formats, name, OBJ_SEARCH_KEY);
00467 }

struct ast_format* __ast_format_cache_get_debug ( const char *  name,
const char *  tag,
const char *  file,
int  line,
const char *  func 
) [read]

Definition at line 469 of file format_cache.c.

References __ao2_find_debug(), ast_strlen_zero, NULL, OBJ_SEARCH_KEY, and S_OR.

00470 {
00471    if (ast_strlen_zero(name)) {
00472       return NULL;
00473    }
00474 
00475    return __ao2_find_debug(formats, name, OBJ_SEARCH_KEY, S_OR(tag, "ast_format_cache_get"), file, line, func);
00476 }

struct ast_format* ast_format_cache_get_slin_by_rate ( unsigned int  rate  )  [read]

Retrieve the best signed linear format given a sample rate.

Parameters:
rate The sample rate
This is a convenience function that returns one of the global ast_format_slinxxx formats.

Returns:
pointer to the signed linear format
Note:
The returned format has NOT had its reference count incremented.

Definition at line 478 of file format_cache.c.

Referenced by ast_channel_make_compatible_helper(), audiohook_list_translate_to_slin(), audiohook_read_frame_both(), audiohook_read_frame_helper(), audiohook_read_frame_single(), audiohook_set_internal_rate(), init_jack_data(), mixmonitor_thread(), resamp_new(), set_softmix_bridge_data(), snoop_determine_format(), softmix_mixing_loop(), softmix_translate_helper_change_rate(), and softmix_translate_helper_init().

00479 {
00480    if (rate >= 192000) {
00481       return ast_format_slin192;
00482    } else if (rate >= 96000) {
00483       return ast_format_slin96;
00484    } else if (rate >= 48000) {
00485       return ast_format_slin48;
00486    } else if (rate >= 44100) {
00487       return ast_format_slin44;
00488    } else if (rate >= 32000) {
00489       return ast_format_slin32;
00490    } else if (rate >= 24000) {
00491       return ast_format_slin24;
00492    } else if (rate >= 16000) {
00493       return ast_format_slin16;
00494    } else if (rate >= 12000) {
00495       return ast_format_slin12;
00496    }
00497    return ast_format_slin;
00498 }

int ast_format_cache_init ( void   ) 

Initialize format cache support within the core.

Return values:
0 success
-1 failure

Definition at line 336 of file format_cache.c.

References AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_container_alloc_options, ast_register_cleanup(), CACHE_BUCKETS, format_cache_shutdown(), format_cmp_cb(), and format_hash_cb().

Referenced by main().

00337 {
00338    formats = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, CACHE_BUCKETS,
00339       format_hash_cb, format_cmp_cb);
00340    if (!formats) {
00341       return -1;
00342    }
00343 
00344    ast_register_cleanup(format_cache_shutdown);
00345 
00346    return 0;
00347 }

int ast_format_cache_is_slinear ( struct ast_format format  ) 

Determines if a format is one of the cached slin formats.

Parameters:
format The format to check
Return values:
0 if the format is not an SLIN format
1 if the format is an SLIN format

Definition at line 500 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_dsp_silence_noise_with_energy(), ast_frame_adjust_volume(), ast_rtp_read(), and ast_slinfactory_init_with_format().

int ast_format_cache_set ( struct ast_format format  ) 

Set a named format cache entry.

Parameters:
format A pointer to the format to cache
Return values:
0 success
-1 failure

Definition at line 432 of file format_cache.c.

References ao2_cleanup, ao2_find, ao2_link_flags, ao2_unlink_flags, ast_assert, ast_format_get_name(), ast_strlen_zero, ast_verb, lock, NULL, OBJ_NOLOCK, OBJ_SEARCH_KEY, SCOPED_AO2WRLOCK, and set_cached_format().

Referenced by AST_TEST_DEFINE().

00433 {
00434    SCOPED_AO2WRLOCK(lock, formats);
00435    struct ast_format *old_format;
00436 
00437    ast_assert(format != NULL);
00438 
00439    if (ast_strlen_zero(ast_format_get_name(format))) {
00440       return -1;
00441    }
00442 
00443    old_format = ao2_find(formats, ast_format_get_name(format), OBJ_SEARCH_KEY | OBJ_NOLOCK);
00444    if (old_format) {
00445       ao2_unlink_flags(formats, old_format, OBJ_NOLOCK);
00446    }
00447    ao2_link_flags(formats, format, OBJ_NOLOCK);
00448 
00449    set_cached_format(ast_format_get_name(format), format);
00450 
00451    ast_verb(2, "%s cached format with name '%s'\n",
00452       old_format ? "Updated" : "Created",
00453       ast_format_get_name(format));
00454 
00455    ao2_cleanup(old_format);
00456 
00457    return 0;
00458 }


Variable Documentation

Built-in cached signed linear 8kHz format.

Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 43 of file format_cache.c.

Referenced by _moh_class_malloc(), action_originate(), alloc_playback_chan(), alsa_new(), alsa_read(), alsa_request(), announce_to_dial(), ast_channel_start_silence_generator(), ast_format_compatibility_bitfield2format(), ast_format_compatibility_codec2bitfield(), ast_format_compatibility_format2bitfield(), ast_frame_slinear_sum(), ast_rtp_engine_init(), ast_slinfactory_init(), ast_speech_new(), ast_write(), background_detect_exec(), build_conf(), chanspy_exec(), conf_run(), conf_start_record(), create_test_frame(), dahdi_format_to_cached(), dahdi_read(), dahdi_write(), dahdiscan_exec(), dictate_exec(), do_notify(), do_waiting(), eagi_exec(), extenspy_exec(), fax_detect_framehook(), fax_gateway_framehook(), fax_generator_generate(), g722_sample(), generic_fax_exec(), generic_recall(), handle_participant_join(), handle_recordfile(), handle_speechcreate(), handle_speechrecognize(), holding_bridge_join(), iax_frame_wrap(), ices_exec(), isAnsweringMachine(), linear_alloc(), linear_generator(), load_module(), make_silence(), measurenoise(), meetme_menu_admin_extended(), moh_parse_options(), mp3_exec(), nbs_new(), nbs_request(), NBScat_exec(), new_outgoing(), ooh323_rtp_read(), orig_app(), orig_exten(), originate_exec(), oss_new(), oss_read(), oss_request(), participant_reaction_announcer_join(), phone_new(), phone_read(), phone_setup(), phone_write(), playtones_alloc(), playtones_generator(), prepare_bridge_media_channel(), prepare_bridge_moh_channel(), rec_request(), recalling_enter(), record_exec(), retransfer_enter(), send_waveform_to_channel(), set_read_to_slin(), silence_generator_generate(), slin8_sample(), socket_process_helper(), spandsp_fax_gateway_process(), spandsp_fax_gw_t30_gen(), spandsp_fax_read(), spandsp_v21_detect(), spy_generate(), tonepair_alloc(), tonepair_generator(), and transmit_audio().

Built-in cached signed linear 12kHz format.

Definition at line 48 of file format_cache.c.

Referenced by ast_rtp_engine_init(), load_module(), and originate_exec().

Built-in cached signed linear 192kHz format.

Definition at line 83 of file format_cache.c.

Referenced by ast_rtp_engine_init(), load_module(), and originate_exec().

Built-in cached signed linear 24kHz format.

Definition at line 58 of file format_cache.c.

Referenced by ast_rtp_engine_init(), load_module(), and originate_exec().

Built-in cached signed linear 32kHz format.

Definition at line 63 of file format_cache.c.

Referenced by ast_rtp_engine_init(), load_module(), and originate_exec().

Built-in cached signed linear 44kHz format.

Definition at line 68 of file format_cache.c.

Referenced by ast_rtp_engine_init(), load_module(), and originate_exec().

Built-in cached signed linear 48kHz format.

Definition at line 73 of file format_cache.c.

Referenced by ast_rtp_engine_init(), load_module(), and originate_exec().

Built-in cached signed linear 96kHz format.

Definition at line 78 of file format_cache.c.

Referenced by ast_rtp_engine_init(), load_module(), and originate_exec().

Built-in cached speex at 32kHz format.

Definition at line 148 of file format_cache.c.

Referenced by ast_rtp_engine_init().


Generated on Thu Apr 16 06:31:03 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6