Format API. More...
#include "asterisk.h"#include "asterisk/_private.h"#include "asterisk/format.h"#include "asterisk/astobj2.h"#include "asterisk/lock.h"#include "asterisk/frame.h"#include "asterisk/utils.h"#include "asterisk/cli.h"#include "asterisk/rtp_engine.h"#include "asterisk/config.h"
Go to the source code of this file.
Data Structures | |
| struct | ast_codec_alias_table |
| struct | interface_ao2_wrapper |
Defines | |
| #define | FORMAT_CONFIG "codecs.conf" |
Functions | |
| const char * | ast_codec2str (struct ast_format *format) |
| Get a name from a format. | |
| static const char * | ast_expand_codec_alias (const char *in) |
| struct ast_format * | ast_format_append (struct ast_format *format,...) |
| After ast_format_set has been used on a function, this function can be used to set additional format attributes to the structure. | |
| int | ast_format_attr_init (void) |
| Init the ast_format attribute interface register container. | |
| int | ast_format_attr_reg_interface (const struct ast_format_attr_interface *interface) |
| register ast_format_attr_interface with core. | |
| int | ast_format_attr_unreg_interface (const struct ast_format_attr_interface *interface) |
| unregister format_attr interface with core. | |
| void | ast_format_clear (struct ast_format *format) |
| Clears the format stucture. | |
| enum ast_format_cmp_res | ast_format_cmp (const struct ast_format *format1, const struct ast_format *format2) |
| Compare ast_formats structures. | |
| void | ast_format_copy (struct ast_format *dst, const struct ast_format *src) |
| copy format src into format dst. | |
| struct ast_format * | ast_format_from_old_bitfield (struct ast_format *dst, uint64_t src) |
| convert old bitfield format to ast_format represenatation | |
| int | ast_format_get_value (const struct ast_format *format, int key, void *value) |
| Get a value from a format containing attributes. | |
| int | ast_format_get_video_mark (const struct ast_format *format) |
| Determine of the marker bit is set or not on this format. | |
| enum ast_format_id | ast_format_id_from_old_bitfield (uint64_t src) |
| convert old bitfield format to ast_format_id value | |
| uint64_t | ast_format_id_to_old_bitfield (enum ast_format_id id) |
| ast_format_id to old bitfield format represenatation | |
| int | ast_format_is_slinear (const struct ast_format *format) |
| Determine if a format is 16bit signed linear of any sample rate. | |
| int | ast_format_isset (const struct ast_format *format,...) |
| This function is used to set an ast_format object to represent a media format with optional capability attributes represented by format specific key value pairs. | |
| int | ast_format_joint (const struct ast_format *format1, const struct ast_format *format2, struct ast_format *result) |
| Find joint format attributes of two ast_format structures containing the same uid and return the intersection in the result structure. | |
| struct ast_format_list * | ast_format_list_destroy (const struct ast_format_list *list) |
| Destroy an ast_format_list gotten from ast_format_list_get() | |
| struct ast_format_list * | ast_format_list_get (size_t *size) |
| Retrieve the global format list in a read only array. | |
| int | ast_format_list_init (void) |
| Init the Asterisk global format list after all format attribute modules have been loaded. | |
| int | ast_format_rate (const struct ast_format *format) |
| Get the sample rate for a given format. | |
| void | ast_format_sdp_generate (const struct ast_format *format, unsigned int payload, struct ast_str **str) |
| This function is used to produce an fmtp SDP line for an Asterisk format. The attributes present on the Asterisk format are translated into the SDP equivalent. | |
| int | ast_format_sdp_parse (struct ast_format *format, const char *attributes) |
| This function is used to have a media format aware module parse and interpret SDP attribute information. Once interpreted this information is stored on the format itself using Asterisk format attributes. | |
| struct ast_format * | ast_format_set (struct ast_format *format, enum ast_format_id id, int set_attributes,...) |
| This function is used to set an ast_format object to represent a media format with optional format attributes represented by format specific key value pairs. | |
| void | ast_format_set_video_mark (struct ast_format *format) |
| Set the rtp mark value on the format to indicate to the interface writing this format's payload that a new RTP marker is necessary. | |
| enum ast_format_id | ast_format_slin_by_rate (unsigned int rate) |
| Get the best slinear format id for a given sample rate. | |
| uint64_t | ast_format_to_old_bitfield (const struct ast_format *format) |
| ast_format to old bitfield format represenatation | |
| struct ast_format * | ast_getformatbyname (const char *name, struct ast_format *result) |
| Gets a format from a name. | |
| const char * | ast_getformatname (const struct ast_format *format) |
| Get the name of a format. | |
| char * | ast_getformatname_multiple_byid (char *buf, size_t size, enum ast_format_id id) |
| Returns a string containing all formats pertaining to an format id. | |
| ASTERISK_FILE_VERSION (__FILE__,"$Revision: 411310 $") | |
| static int | build_format_list_array (void) |
| static int | conf_process_format_name (const char *name, enum ast_format_id *id) |
| static int | conf_process_sample_rate (const char *rate, unsigned int *result) |
| static int | custom_celt_format (struct ast_format_list *entry, unsigned int maxbitrate, unsigned int framesize) |
| static int | custom_silk_format (struct ast_format_list *entry, unsigned int maxbitrate, int usedtx, int usefec, int packetloss_percentage) |
| static struct interface_ao2_wrapper * | find_interface (const struct ast_format *format) |
| static void | format_attr_shutdown (void) |
| static enum ast_format_cmp_res | format_cmp_helper (const struct ast_format *format1, const struct ast_format *format2) |
| static int | format_isset_helper (const struct ast_format *format, va_list ap) |
| static int | format_joint_helper (const struct ast_format *format1, const struct ast_format *format2, struct ast_format *result) |
| static int | format_list_add_custom (struct ast_format_list *new) |
| static int | format_list_add_static (const struct ast_format *format, const char *name, int samplespersecond, const char *description, int fr_len, int min_ms, int max_ms, int inc_ms, int def_ms, unsigned int flags, int cur_ms) |
| static int | format_list_init (void) |
| static void | format_list_shutdown (void) |
| static int | format_set_helper (struct ast_format *format, va_list ap) |
| static int | has_interface (const struct ast_format *format) |
| int | init_framer (void) |
| static int | interface_cmp_cb (void *obj, void *arg, int flags) |
| static int | interface_hash_cb (const void *obj, const int flags) |
| static int | list_all_custom (void *obj, void *arg, int flag) |
| static int | list_cmp_cb (void *obj, void *arg, int flags) |
| static int | list_hash_cb (const void *obj, const int flags) |
| static int | load_format_config (void) |
| static char * | show_codec_n (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | show_codecs (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
Variables | |
| static struct ast_codec_alias_table | ast_codec_alias_table [] |
| static struct ao2_container * | format_list |
| Format List container, This container is never directly accessed outside of this file, and It only exists for building the format_list_array. | |
| static struct ast_format_list * | format_list_array |
| Format List array is a read only array protected by a read write lock. This array may be used outside this file with the use of reference counting to guarantee safety for access by multiple threads. | |
| static size_t | format_list_array_len = 0 |
| static ast_rwlock_t | format_list_array_lock |
| Locks the format list array so a reference can be taken safely. | |
| static struct ao2_container * | interfaces |
| Container for all the format attribute interfaces. | |
| static struct ast_cli_entry | my_clis [] |
Format API.
Definition in file format.c.
| #define FORMAT_CONFIG "codecs.conf" |
Definition at line 46 of file format.c.
Referenced by load_format_config().
| const char* ast_codec2str | ( | struct ast_format * | format | ) |
Get a name from a format.
| format | to get name of |
Definition at line 713 of file format.c.
References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_list_destroy(), ast_format_list_get(), and ast_format_list::desc.
Referenced by moh_alloc().
{
int x;
const char *ret = "unknown";
size_t f_len;
const struct ast_format_list *f_list = ast_format_list_get(&f_len);
for (x = 0; x < f_len; x++) {
if (ast_format_cmp(&f_list[x].format, format) == AST_FORMAT_CMP_EQUAL) {
ret = f_list[x].desc;
break;
}
}
f_list = ast_format_list_destroy(f_list);
return ret;
}
| static const char* ast_expand_codec_alias | ( | const char * | in | ) | [static] |
Definition at line 682 of file format.c.
References ARRAY_LEN.
Referenced by ast_getformatbyname().
{
int x;
for (x = 0; x < ARRAY_LEN(ast_codec_alias_table); x++) {
if (!strcmp(in,ast_codec_alias_table[x].alias))
return ast_codec_alias_table[x].realname;
}
return in;
}
| struct ast_format* ast_format_append | ( | struct ast_format * | format, |
| ... | |||
| ) | [read] |
After ast_format_set has been used on a function, this function can be used to set additional format attributes to the structure.
| format | to set |
| var | list of attribute key value pairs, must end with AST_FORMAT_ATTR_END; |
Example usage. ast_format_set(format, AST_FORMAT_SILK, 0); ast_format_append(format, // SILK has capability attributes. AST_FORMAT_SILK_ATTR_RATE, 24000, AST_FORMAT_SILK_ATTR_RATE, 16000, AST_FORMAT_SILK_ATTR_RATE, 12000, AST_FORMAT_SILK_ATTR_RATE, 8000, AST_FORMAT_ATTR_END);
Definition at line 194 of file format.c.
References format, and format_set_helper().
Referenced by custom_celt_format(), and custom_silk_format().
{
va_list ap;
va_start(ap, format);
format_set_helper(format, ap);
va_end(ap);
return format;
}
| int ast_format_attr_init | ( | void | ) |
Init the ast_format attribute interface register container.
Definition at line 1122 of file format.c.
References AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_container_alloc_options, ARRAY_LEN, ast_cli_register_multiple(), ast_register_cleanup(), format_attr_shutdown(), interface_cmp_cb(), and interface_hash_cb().
Referenced by main().
{
interfaces = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK,
283, interface_hash_cb, interface_cmp_cb);
if (!interfaces) {
return -1;
}
ast_cli_register_multiple(my_clis, ARRAY_LEN(my_clis));
ast_register_cleanup(format_attr_shutdown);
return 0;
}
| int ast_format_attr_reg_interface | ( | const struct ast_format_attr_interface * | interface | ) |
register ast_format_attr_interface with core.
| 0 | success |
| -1 | failure |
Definition at line 1347 of file format.c.
References AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_alloc_options, ao2_find, ao2_link_flags, ao2_ref, ao2_unlock, ao2_wrlock, ast_format_list_destroy(), ast_format_list_get(), ast_log(), ast_rtp_engine_load_format(), format, interface_ao2_wrapper::id, ast_format_attr_interface::id, interface_ao2_wrapper::interface, load_format_config(), LOG_WARNING, OBJ_NOLOCK, and OBJ_POINTER.
Referenced by load_module().
{
int x;
size_t f_len;
const struct ast_format_list *f_list;
struct interface_ao2_wrapper *wrapper;
struct interface_ao2_wrapper tmp_wrapper = {
.id = interface->id,
};
/*
* Grab the write lock before checking for duplicates in
* anticipation of adding a new interface and to prevent a
* duplicate from sneaking in between the check and add.
*/
ao2_wrlock(interfaces);
/* check for duplicates first*/
if ((wrapper = ao2_find(interfaces, &tmp_wrapper, (OBJ_POINTER | OBJ_NOLOCK)))) {
ao2_unlock(interfaces);
ast_log(LOG_WARNING, "Can not register attribute interface for format id %d, interface already exists.\n", interface->id);
ao2_ref(wrapper, -1);
return -1;
}
wrapper = ao2_alloc_options(sizeof(*wrapper), NULL, AO2_ALLOC_OPT_LOCK_RWLOCK);
if (!wrapper) {
ao2_unlock(interfaces);
return -1;
}
wrapper->interface = interface;
wrapper->id = interface->id;
/* The write lock is already held. */
ao2_link_flags(interfaces, wrapper, OBJ_NOLOCK);
ao2_unlock(interfaces);
ao2_ref(wrapper, -1);
/* This will find all custom formats in codecs.conf for this new registered interface */
load_format_config();
/* update the RTP engine to all custom formats created for this interface */
f_list = ast_format_list_get(&f_len);
for (x = 0; x < f_len; x++) {
if (f_list[x].format.id == tmp_wrapper.id) {
ast_rtp_engine_load_format(&f_list[x].format);
}
}
f_list = ast_format_list_destroy(f_list);
return 0;
}
| int ast_format_attr_unreg_interface | ( | const struct ast_format_attr_interface * | interface | ) |
unregister format_attr interface with core.
| 0 | success |
| -1 | failure |
Definition at line 1401 of file format.c.
References ao2_find, ao2_ref, ao2_unlock, ao2_wrlock, ast_format_list_destroy(), ast_format_list_get(), ast_rtp_engine_unload_format(), format, interface_ao2_wrapper::id, ast_format_attr_interface::id, interface_ao2_wrapper::interface, load_format_config(), OBJ_POINTER, and OBJ_UNLINK.
Referenced by load_module(), and unload_module().
{
int x;
size_t f_len;
const struct ast_format_list *f_list;
struct interface_ao2_wrapper *wrapper;
struct interface_ao2_wrapper tmp_wrapper = {
.id = interface->id,
};
if (!(wrapper = ao2_find(interfaces, &tmp_wrapper, (OBJ_POINTER | OBJ_UNLINK)))) {
return -1;
}
ao2_wrlock(wrapper);
wrapper->interface = NULL;
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
/* update the RTP engine to remove all custom formats created for this interface */
f_list = ast_format_list_get(&f_len);
for (x = 0; x < f_len; x++) {
if (f_list[x].format.id == tmp_wrapper.id) {
ast_rtp_engine_unload_format(&f_list[x].format);
}
}
/* This will remove all custom formats previously created for this interface */
load_format_config();
f_list = ast_format_list_destroy(f_list);
return 0;
}
| void ast_format_clear | ( | struct ast_format * | format | ) |
Clears the format stucture.
Definition at line 221 of file format.c.
References ast_format::fattr, and ast_format::id.
Referenced by __ast_play_and_record(), ast_best_codec(), ast_codec_choose(), ast_codec_pref_index(), ast_format_cap_best_byid(), ast_format_cap_get_compatible_format(), ast_format_from_old_bitfield(), ast_format_set(), ast_request(), ast_translator_best_choice(), background_detect_exec(), chanspy_exec(), codec_skinny2ast(), dahdi_decoder_frameout(), dahdi_encoder_frameout(), dahdi_new(), dahdiscan_exec(), dictate_exec(), extenspy_exec(), free_translation(), generic_fax_exec(), handle_recordfile(), handle_show_translation_path(), iax2_best_codec(), iax2_codec_choose(), ices_exec(), isAnsweringMachine(), mkif(), moh_files_release(), moh_files_write_format_change(), mp3_exec(), NBScat_exec(), phone_check_exception(), phone_digit_end(), phone_hangup(), phone_indicate(), record_exec(), send_waveform_to_channel(), speech_background(), transmit_audio(), and try_suggested_sip_codec().
| enum ast_format_cmp_res ast_format_cmp | ( | const struct ast_format * | format1, |
| const struct ast_format * | format2 | ||
| ) |
Compare ast_formats structures.
| ast_format_cmp_res | representing the result of comparing format1 and format2. |
Definition at line 333 of file format.c.
References AST_FORMAT_CMP_NOT_EQUAL, format_cmp_helper(), and ast_format::id.
Referenced by __ast_smoother_feed(), agent_write(), ast_channel_bridge(), ast_channel_make_compatible_helper(), ast_codec2str(), ast_codec_pref_append(), ast_codec_pref_getsize(), ast_codec_pref_prepend(), ast_codec_pref_remove(), ast_codec_pref_setsize(), ast_data_add_codec(), ast_getformatname(), ast_read_generator_actions(), ast_read_image(), ast_rtp_codecs_payload_code(), ast_rtp_engine_unload_format(), ast_rtp_lookup_mime_subtype2(), ast_rtp_lookup_sample_rate2(), ast_rtp_write(), ast_slinfactory_feed(), ast_write(), ast_writestream(), audiohook_list_translate_to_native(), audiohook_list_translate_to_slin(), audiohook_read_frame_helper(), bridge_channel_join(), cmp_cb(), filehelper(), find_exact_cb(), list_cmp_cb(), local_bridge_loop(), misdn_write(), moh_files_generator(), multiplexed_bridge_join(), pcm_write(), phone_setup(), phone_write(), rtp_payload_type_find_format(), set_format(), simple_bridge_join(), softmix_process_write_audio(), and wav_write().
{
if (format1->id != format2->id) {
return AST_FORMAT_CMP_NOT_EQUAL;
}
return format_cmp_helper(format1, format2);
}
| void ast_format_copy | ( | struct ast_format * | dst, |
| const struct ast_format * | src | ||
| ) |
copy format src into format dst.
Definition at line 86 of file format.c.
Referenced by __ast_play_and_record(), __ast_smoother_feed(), __get_from_jb(), __oh323_new(), add_static_payload(), adsi_transmit_message_full(), agent_new(), ast_async_goto(), ast_channel_start_silence_generator(), ast_codec_pref_append(), ast_codec_pref_convert(), ast_codec_pref_index(), ast_codec_pref_prepend(), ast_codec_pref_remove(), ast_do_masquerade(), ast_format_cap_add(), ast_format_cap_get_compatible_format(), ast_format_cap_iter_next(), ast_frdup(), ast_frisolate(), ast_getformatbyname(), ast_getformatname_multiple(), ast_iax2_new(), ast_openstream_full(), ast_prod(), ast_rtp_codecs_payloads_default(), ast_rtp_codecs_payloads_set_m_type(), ast_rtp_read(), ast_rtp_write(), ast_slinfactory_feed(), ast_slinfactory_init_with_format(), ast_smoother_read(), ast_speech_new(), ast_trans_frameout(), ast_translator_best_choice(), ast_writestream(), audiohook_list_translate_to_native(), audiohook_list_translate_to_slin(), audiohook_read_frame_helper(), background_detect_exec(), bridge_channel_join(), bridge_make_compatible(), bridge_request(), builtin_atxfer(), chanspy_exec(), check_goto_on_transfer(), create_jb(), dahdi_decoder_frameout(), dahdi_encoder_frameout(), dahdi_new(), dahdi_read(), dahdiscan_exec(), dictate_exec(), do_bridge_masquerade(), do_waiting(), eagi_exec(), extenspy_exec(), fax_detect_framehook(), fax_gateway_framehook(), find_best_byid_cb(), format_list_add_static(), free_translation(), generic_fax_exec(), gtalk_new(), handle_recordfile(), handle_show_translation_path(), handle_speechrecognize(), hook_event_cb(), iax2_request(), iax_frame_wrap(), iax_park(), ices_exec(), isAnsweringMachine(), jb_get_and_deliver(), jingle_new(), linear_alloc(), local_new(), masq_park_call(), measurenoise(), mgcp_new(), misdn_new(), moh_alloc(), moh_files_alloc(), moh_files_generator(), moh_files_write_format_change(), moh_release(), mohalloc(), mp3_exec(), multicast_rtp_request(), nbs_new(), NBScat_exec(), newpvt(), pcm_read(), phone_new(), phone_read(), phone_setup(), phone_write(), playtones_alloc(), rec_request(), record_exec(), register_translator(), send_waveform_to_channel(), set_format(), set_next_mime_type(), sip_new(), sip_park(), skinny_new(), softmix_process_write_audio(), softmix_translate_helper_entry_alloc(), speech_background(), start_rtp(), tonepair_alloc(), transmit_audio(), and unistim_new().
{
*dst = *src;
}
| struct ast_format* ast_format_from_old_bitfield | ( | struct ast_format * | dst, |
| uint64_t | src | ||
| ) | [read] |
convert old bitfield format to ast_format represenatation
| on | success, pointer to the dst format in the input parameters |
| on | failure, NULL |
G.723.1 compression
GSM compression
Raw mu-law data (G.711)
Raw A-law data (G.711)
ADPCM (G.726, 32kbps, AAL2 codeword packing)
ADPCM (IMA)
Raw 16-bit Signed Linear (8000 Hz) PCM
LPC10, 180 samples/frame
G.729A audio
SpeeX Free Compression
iLBC Free Compression
ADPCM (G.726, 32kbps, RFC3551 codeword packing)
G.722
G.722.1 (also known as Siren7, 32kbps assumed)
G.722.1 Annex C (also known as Siren14, 48kbps assumed)
Raw 16-bit Signed Linear (16000 Hz) PCM
G.719 (64 kbps assumed)
SpeeX Wideband (16kHz) Free Compression
Raw mu-law data (G.711)
H.261 Video
H.263 Video
H.263+ Video
H.264 Video
MPEG4 Video
JPEG Images
PNG Images
T.140 RED Text format RFC 4103
T.140 Text format - ITU T.140, RFC 4103
Definition at line 478 of file format.c.
References AST_FORMAT_ADPCM, AST_FORMAT_ALAW, ast_format_clear(), AST_FORMAT_G719, AST_FORMAT_G722, AST_FORMAT_G723_1, AST_FORMAT_G726, AST_FORMAT_G726_AAL2, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_H261, AST_FORMAT_H263, AST_FORMAT_H263_PLUS, AST_FORMAT_H264, AST_FORMAT_ILBC, AST_FORMAT_JPEG, AST_FORMAT_LPC10, AST_FORMAT_MP4_VIDEO, AST_FORMAT_PNG, ast_format_set(), AST_FORMAT_SIREN14, AST_FORMAT_SIREN7, AST_FORMAT_SLINEAR, AST_FORMAT_SLINEAR16, AST_FORMAT_SPEEX, AST_FORMAT_SPEEX16, AST_FORMAT_T140, AST_FORMAT_T140RED, AST_FORMAT_TESTLAW, and AST_FORMAT_ULAW.
Referenced by __get_from_jb(), ast_format_cap_from_old_bitfield(), ast_format_id_from_old_bitfield(), conf_run(), decode_frame(), iax2_getformatname(), register_translator(), socket_process_helper(), and socket_process_meta().
{
switch (src) {
/*! G.723.1 compression */
case (1ULL << 0):
return ast_format_set(dst, AST_FORMAT_G723_1, 0);
/*! GSM compression */
case (1ULL << 1):
return ast_format_set(dst, AST_FORMAT_GSM, 0);
/*! Raw mu-law data (G.711) */
case (1ULL << 2):
return ast_format_set(dst, AST_FORMAT_ULAW, 0);
/*! Raw A-law data (G.711) */
case (1ULL << 3):
return ast_format_set(dst, AST_FORMAT_ALAW, 0);
/*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */
case (1ULL << 4):
return ast_format_set(dst, AST_FORMAT_G726_AAL2, 0);
/*! ADPCM (IMA) */
case (1ULL << 5):
return ast_format_set(dst, AST_FORMAT_ADPCM, 0);
/*! Raw 16-bit Signed Linear (8000 Hz) PCM */
case (1ULL << 6):
return ast_format_set(dst, AST_FORMAT_SLINEAR, 0);
/*! LPC10, 180 samples/frame */
case (1ULL << 7):
return ast_format_set(dst, AST_FORMAT_LPC10, 0);
/*! G.729A audio */
case (1ULL << 8):
return ast_format_set(dst, AST_FORMAT_G729A, 0);
/*! SpeeX Free Compression */
case (1ULL << 9):
return ast_format_set(dst, AST_FORMAT_SPEEX, 0);
/*! iLBC Free Compression */
case (1ULL << 10):
return ast_format_set(dst, AST_FORMAT_ILBC, 0);
/*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */
case (1ULL << 11):
return ast_format_set(dst, AST_FORMAT_G726, 0);
/*! G.722 */
case (1ULL << 12):
return ast_format_set(dst, AST_FORMAT_G722, 0);
/*! G.722.1 (also known as Siren7, 32kbps assumed) */
case (1ULL << 13):
return ast_format_set(dst, AST_FORMAT_SIREN7, 0);
/*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */
case (1ULL << 14):
return ast_format_set(dst, AST_FORMAT_SIREN14, 0);
/*! Raw 16-bit Signed Linear (16000 Hz) PCM */
case (1ULL << 15):
return ast_format_set(dst, AST_FORMAT_SLINEAR16, 0);
/*! G.719 (64 kbps assumed) */
case (1ULL << 32):
return ast_format_set(dst, AST_FORMAT_G719, 0);
/*! SpeeX Wideband (16kHz) Free Compression */
case (1ULL << 33):
return ast_format_set(dst, AST_FORMAT_SPEEX16, 0);
/*! Raw mu-law data (G.711) */
case (1ULL << 47):
return ast_format_set(dst, AST_FORMAT_TESTLAW, 0);
/*! H.261 Video */
case (1ULL << 18):
return ast_format_set(dst, AST_FORMAT_H261, 0);
/*! H.263 Video */
case (1ULL << 19):
return ast_format_set(dst, AST_FORMAT_H263, 0);
/*! H.263+ Video */
case (1ULL << 20):
return ast_format_set(dst, AST_FORMAT_H263_PLUS, 0);
/*! H.264 Video */
case (1ULL << 21):
return ast_format_set(dst, AST_FORMAT_H264, 0);
/*! MPEG4 Video */
case (1ULL << 22):
return ast_format_set(dst, AST_FORMAT_MP4_VIDEO, 0);
/*! JPEG Images */
case (1ULL << 16):
return ast_format_set(dst, AST_FORMAT_JPEG, 0);
/*! PNG Images */
case (1ULL << 17):
return ast_format_set(dst, AST_FORMAT_PNG, 0);
/*! T.140 RED Text format RFC 4103 */
case (1ULL << 26):
return ast_format_set(dst, AST_FORMAT_T140RED, 0);
/*! T.140 Text format - ITU T.140, RFC 4103 */
case (1ULL << 27):
return ast_format_set(dst, AST_FORMAT_T140, 0);
}
ast_format_clear(dst);
return NULL;
}
| int ast_format_get_value | ( | const struct ast_format * | format, |
| int | key, | ||
| void * | value | ||
| ) |
Get a value from a format containing attributes.
| 0,success | |
| -1,failure |
Definition at line 281 of file format.c.
References ao2_rdlock, ao2_ref, ao2_unlock, ast_format::fattr, find_interface(), ast_format_attr_interface::format_attr_get_val, and interface_ao2_wrapper::interface.
Referenced by ast_format_rate().
{
int res = 0;
struct interface_ao2_wrapper *wrapper;
if (!(wrapper = find_interface(format))) {
return -1;
}
ao2_rdlock(wrapper);
if (!wrapper->interface ||
!wrapper->interface->format_attr_get_val) {
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
return -1;
}
res = wrapper->interface->format_attr_get_val(&format->fattr, key, value);
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
return res;
}
| int ast_format_get_video_mark | ( | const struct ast_format * | format | ) |
Determine of the marker bit is set or not on this format.
| 1,true | |
| 0,false |
Definition at line 96 of file format.c.
References ast_format::fattr, and ast_format_attr::rtp_marker_bit.
Referenced by ast_rtp_raw_write(), h263_write(), h264_write(), iax2_send(), and softmix_bridge_write().
{
return format->fattr.rtp_marker_bit;
}
| enum ast_format_id ast_format_id_from_old_bitfield | ( | uint64_t | src | ) |
convert old bitfield format to ast_format_id value
Definition at line 573 of file format.c.
References ast_format_from_old_bitfield(), and ast_format::id.
Referenced by dahdi_destroy(), dahdi_translate(), drop_translator(), iax2_send(), and socket_process_helper().
{
struct ast_format dst;
if (ast_format_from_old_bitfield(&dst, src)) {
return dst.id;
}
return 0;
}
| uint64_t ast_format_id_to_old_bitfield | ( | enum ast_format_id | id | ) |
ast_format_id to old bitfield format represenatation
G.723.1 compression
GSM compression
Raw mu-law data (G.711)
Raw A-law data (G.711)
ADPCM (G.726, 32kbps, AAL2 codeword packing)
ADPCM (IMA)
Raw 16-bit Signed Linear (8000 Hz) PCM
LPC10, 180 samples/frame
G.729A audio
SpeeX Free Compression
iLBC Free Compression
ADPCM (G.726, 32kbps, RFC3551 codeword packing)
G.722
G.722.1 (also known as Siren7, 32kbps assumed)
G.722.1 Annex C (also known as Siren14, 48kbps assumed)
Raw 16-bit Signed Linear (16000 Hz) PCM
G.719 (64 kbps assumed)
SpeeX Wideband (16kHz) Free Compression
Raw mu-law data (G.711)
H.261 Video
H.263 Video
H.263+ Video
H.264 Video
MPEG4 Video
JPEG Images
PNG Images
T.140 RED Text format RFC 4103
T.140 Text format - ITU T.140, RFC 4103
Definition at line 376 of file format.c.
References AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_G719, AST_FORMAT_G722, AST_FORMAT_G723_1, AST_FORMAT_G726, AST_FORMAT_G726_AAL2, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_H261, AST_FORMAT_H263, AST_FORMAT_H263_PLUS, AST_FORMAT_H264, AST_FORMAT_ILBC, AST_FORMAT_JPEG, AST_FORMAT_LPC10, AST_FORMAT_MP4_VIDEO, AST_FORMAT_PNG, AST_FORMAT_SIREN14, AST_FORMAT_SIREN7, AST_FORMAT_SLINEAR, AST_FORMAT_SLINEAR16, AST_FORMAT_SPEEX, AST_FORMAT_SPEEX16, AST_FORMAT_T140, AST_FORMAT_T140RED, AST_FORMAT_TESTLAW, and AST_FORMAT_ULAW.
Referenced by ast_format_to_old_bitfield(), and dahdi_translate().
{
switch (id) {
/*! G.723.1 compression */
case AST_FORMAT_G723_1:
return (1ULL << 0);
/*! GSM compression */
case AST_FORMAT_GSM:
return (1ULL << 1);
/*! Raw mu-law data (G.711) */
case AST_FORMAT_ULAW:
return (1ULL << 2);
/*! Raw A-law data (G.711) */
case AST_FORMAT_ALAW:
return (1ULL << 3);
/*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */
case AST_FORMAT_G726_AAL2:
return (1ULL << 4);
/*! ADPCM (IMA) */
case AST_FORMAT_ADPCM:
return (1ULL << 5);
/*! Raw 16-bit Signed Linear (8000 Hz) PCM */
case AST_FORMAT_SLINEAR:
return (1ULL << 6);
/*! LPC10, 180 samples/frame */
case AST_FORMAT_LPC10:
return (1ULL << 7);
/*! G.729A audio */
case AST_FORMAT_G729A:
return (1ULL << 8);
/*! SpeeX Free Compression */
case AST_FORMAT_SPEEX:
return (1ULL << 9);
/*! iLBC Free Compression */
case AST_FORMAT_ILBC:
return (1ULL << 10);
/*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */
case AST_FORMAT_G726:
return (1ULL << 11);
/*! G.722 */
case AST_FORMAT_G722:
return (1ULL << 12);
/*! G.722.1 (also known as Siren7, 32kbps assumed) */
case AST_FORMAT_SIREN7:
return (1ULL << 13);
/*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */
case AST_FORMAT_SIREN14:
return (1ULL << 14);
/*! Raw 16-bit Signed Linear (16000 Hz) PCM */
case AST_FORMAT_SLINEAR16:
return (1ULL << 15);
/*! G.719 (64 kbps assumed) */
case AST_FORMAT_G719:
return (1ULL << 32);
/*! SpeeX Wideband (16kHz) Free Compression */
case AST_FORMAT_SPEEX16:
return (1ULL << 33);
/*! Raw mu-law data (G.711) */
case AST_FORMAT_TESTLAW:
return (1ULL << 47);
/*! H.261 Video */
case AST_FORMAT_H261:
return (1ULL << 18);
/*! H.263 Video */
case AST_FORMAT_H263:
return (1ULL << 19);
/*! H.263+ Video */
case AST_FORMAT_H263_PLUS:
return (1ULL << 20);
/*! H.264 Video */
case AST_FORMAT_H264:
return (1ULL << 21);
/*! MPEG4 Video */
case AST_FORMAT_MP4_VIDEO:
return (1ULL << 22);
/*! JPEG Images */
case AST_FORMAT_JPEG:
return (1ULL << 16);
/*! PNG Images */
case AST_FORMAT_PNG:
return (1ULL << 17);
/*! T.140 RED Text format RFC 4103 */
case AST_FORMAT_T140RED:
return (1ULL << 26);
/*! T.140 Text format - ITU T.140, RFC 4103 */
case AST_FORMAT_T140:
return (1ULL << 27);
default:
return 0; /* not supported by old bitfield. */
}
return 0;
}
| int ast_format_is_slinear | ( | const struct ast_format * | format | ) |
Determine if a format is 16bit signed linear of any sample rate.
Definition at line 582 of file format.c.
References AST_FORMAT_SLINEAR, AST_FORMAT_SLINEAR12, AST_FORMAT_SLINEAR16, AST_FORMAT_SLINEAR192, AST_FORMAT_SLINEAR24, AST_FORMAT_SLINEAR32, AST_FORMAT_SLINEAR44, AST_FORMAT_SLINEAR48, AST_FORMAT_SLINEAR96, and ast_format::id.
Referenced by 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(), ast_slinfactory_init_with_format(), generate_table_cost(), pitchshift_cb(), and softmix_bridge_write().
{
if (format->id == AST_FORMAT_SLINEAR ||
format->id == AST_FORMAT_SLINEAR12 ||
format->id == AST_FORMAT_SLINEAR16 ||
format->id == AST_FORMAT_SLINEAR24 ||
format->id == AST_FORMAT_SLINEAR32 ||
format->id == AST_FORMAT_SLINEAR44 ||
format->id == AST_FORMAT_SLINEAR48 ||
format->id == AST_FORMAT_SLINEAR96 ||
format->id == AST_FORMAT_SLINEAR192) {
return 1;
}
return 0;
}
| int ast_format_isset | ( | const struct ast_format * | format, |
| ... | |||
| ) |
This function is used to set an ast_format object to represent a media format with optional capability attributes represented by format specific key value pairs.
Example usage. Is this SILK format capable of 8khz is_8khz = ast_format_isset(format, AST_FORMAT_SILK_CAP_RATE, 8000);
Definition at line 270 of file format.c.
References format_isset_helper().
Referenced by ast_codec_get_samples(), and ast_format_rate().
{
va_list ap;
int res;
va_start(ap, format);
res = format_isset_helper(format, ap);
va_end(ap);
return res;
}
| int ast_format_joint | ( | const struct ast_format * | format1, |
| const struct ast_format * | format2, | ||
| struct ast_format * | result | ||
| ) |
Find joint format attributes of two ast_format structures containing the same uid and return the intersection in the result structure.
retval 0, joint attribute capabilities exist. retval -1, no joint attribute capabilities exist.
Definition at line 366 of file format.c.
References format_joint_helper(), and ast_format::id.
Referenced by find_joint_cb().
{
if (format1->id != format2->id) {
return -1;
}
result->id = format1->id;
return format_joint_helper(format1, format2, result);
}
| struct ast_format_list* ast_format_list_destroy | ( | const struct ast_format_list * | list | ) | [read] |
Destroy an ast_format_list gotten from ast_format_list_get()
Definition at line 991 of file format.c.
References ao2_ref.
Referenced by ast_codec2str(), ast_codec_choose(), ast_codec_pref_append(), ast_codec_pref_convert(), ast_codec_pref_getsize(), ast_codec_pref_prepend(), ast_codec_pref_remove(), ast_codec_pref_setsize(), ast_data_add_codec(), ast_data_add_codecs(), ast_format_attr_reg_interface(), ast_format_attr_unreg_interface(), ast_format_cap_add_all(), ast_format_cap_add_all_by_type(), ast_getformatbyname(), ast_getformatname(), ast_getformatname_multiple(), ast_getformatname_multiple_byid(), complete_trans_path_choice(), handle_show_translation_path(), handle_show_translation_table(), show_codec_n(), and show_codecs().
{
ao2_ref((void *) list, -1);
return NULL;
}
| struct ast_format_list* ast_format_list_get | ( | size_t * | size | ) | [read] |
Retrieve the global format list in a read only array.
Definition at line 981 of file format.c.
References ao2_ref, ast_rwlock_rdlock, ast_rwlock_unlock, format_list_array, and format_list_array_len.
Referenced by ast_codec2str(), ast_codec_choose(), ast_codec_pref_append(), ast_codec_pref_convert(), ast_codec_pref_getsize(), ast_codec_pref_prepend(), ast_codec_pref_remove(), ast_codec_pref_setsize(), ast_data_add_codec(), ast_data_add_codecs(), ast_format_attr_reg_interface(), ast_format_attr_unreg_interface(), ast_format_cap_add_all(), ast_format_cap_add_all_by_type(), ast_getformatbyname(), ast_getformatname(), ast_getformatname_multiple(), ast_getformatname_multiple_byid(), complete_trans_path_choice(), handle_show_translation_path(), handle_show_translation_table(), show_codec_n(), and show_codecs().
{
struct ast_format_list *list;
ast_rwlock_rdlock(&format_list_array_lock);
ao2_ref(format_list_array, 1);
list = format_list_array;
*size = format_list_array_len;
ast_rwlock_unlock(&format_list_array_lock);
return list;
}
| int ast_format_list_init | ( | void | ) |
Init the Asterisk global format list after all format attribute modules have been loaded.
Definition at line 1092 of file format.c.
References ast_register_atexit(), ast_rwlock_init, build_format_list_array(), format_list_init(), and format_list_shutdown().
Referenced by main().
{
if (ast_rwlock_init(&format_list_array_lock)) {
return -1;
}
if (format_list_init()) {
goto init_list_cleanup;
}
if (build_format_list_array()) {
goto init_list_cleanup;
}
ast_register_atexit(format_list_shutdown);
return 0;
init_list_cleanup:
format_list_shutdown();
return -1;
}
| int ast_format_rate | ( | const struct ast_format * | format | ) |
Get the sample rate for a given format.
Definition at line 730 of file format.c.
References AST_FORMAT_ATTR_END, AST_FORMAT_CELT, AST_FORMAT_G719, AST_FORMAT_G722, ast_format_get_value(), ast_format_isset(), AST_FORMAT_SILK, AST_FORMAT_SIREN14, AST_FORMAT_SIREN7, AST_FORMAT_SLINEAR12, AST_FORMAT_SLINEAR16, AST_FORMAT_SLINEAR192, AST_FORMAT_SLINEAR24, AST_FORMAT_SLINEAR32, AST_FORMAT_SLINEAR44, AST_FORMAT_SLINEAR48, AST_FORMAT_SLINEAR96, AST_FORMAT_SPEEX16, AST_FORMAT_SPEEX32, CELT_ATTR_KEY_SAMP_RATE, ast_format::id, SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_12KHZ, SILK_ATTR_VAL_SAMP_16KHZ, and SILK_ATTR_VAL_SAMP_24KHZ.
Referenced by __ast_read(), __get_from_jb(), ast_channel_make_compatible_helper(), ast_codec_get_samples(), ast_read_generator_actions(), ast_readaudio_callback(), ast_readvideo_callback(), ast_rtp_engine_load_format(), ast_rtp_read(), ast_smoother_read(), ast_translate(), ast_translator_best_choice(), ast_write(), audiohook_list_translate_to_slin(), audiohook_read_frame_helper(), calc_timestamp(), find_best_byid_cb(), gather_softmix_stats(), generate_computational_cost(), generate_table_cost(), generator_force(), handle_show_translation_path(), hook_event_cb(), load_module(), mixmonitor_save_prep(), msg_create_from_file(), pitch_shift(), resamp_new(), rtp_get_rate(), schedule_delivery(), set_softmix_bridge_data(), speex_callback(), and waitstream_core().
{
switch (format->id) {
case AST_FORMAT_SLINEAR12:
return 12000;
case AST_FORMAT_SLINEAR24:
return 24000;
case AST_FORMAT_SLINEAR32:
return 32000;
case AST_FORMAT_SLINEAR44:
return 44100;
case AST_FORMAT_SLINEAR48:
return 48000;
case AST_FORMAT_SLINEAR96:
return 96000;
case AST_FORMAT_SLINEAR192:
return 192000;
case AST_FORMAT_G722:
case AST_FORMAT_SLINEAR16:
case AST_FORMAT_SIREN7:
case AST_FORMAT_SPEEX16:
return 16000;
case AST_FORMAT_SIREN14:
case AST_FORMAT_SPEEX32:
return 32000;
case AST_FORMAT_G719:
return 48000;
case AST_FORMAT_SILK:
if (!(ast_format_isset(format,
SILK_ATTR_KEY_SAMP_RATE,
SILK_ATTR_VAL_SAMP_24KHZ,
AST_FORMAT_ATTR_END))) {
return 24000;
} else if (!(ast_format_isset(format,
SILK_ATTR_KEY_SAMP_RATE,
SILK_ATTR_VAL_SAMP_16KHZ,
AST_FORMAT_ATTR_END))) {
return 16000;
} else if (!(ast_format_isset(format,
SILK_ATTR_KEY_SAMP_RATE,
SILK_ATTR_VAL_SAMP_12KHZ,
AST_FORMAT_ATTR_END))) {
return 12000;
} else {
return 8000;
}
case AST_FORMAT_CELT:
{
int samplerate;
if (!(ast_format_get_value(format,
CELT_ATTR_KEY_SAMP_RATE,
&samplerate))) {
return samplerate;
}
}
default:
return 8000;
}
}
| void ast_format_sdp_generate | ( | const struct ast_format * | format, |
| unsigned int | payload, | ||
| struct ast_str ** | str | ||
| ) |
This function is used to produce an fmtp SDP line for an Asterisk format. The attributes present on the Asterisk format are translated into the SDP equivalent.
| format | to generate an fmtp line for |
| payload | numerical payload for the fmtp line |
| str | structure that the fmtp line will be appended to |
Definition at line 146 of file format.c.
References ao2_rdlock, ao2_ref, ao2_unlock, ast_format::fattr, find_interface(), ast_format_attr_interface::format_attr_sdp_generate, and interface_ao2_wrapper::interface.
Referenced by add_codec_to_sdp(), and add_vcodec_to_sdp().
{
struct interface_ao2_wrapper *wrapper;
if (!(wrapper = find_interface(format))) {
return;
}
ao2_rdlock(wrapper);
if (!wrapper->interface || !wrapper->interface->format_attr_sdp_generate) {
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
return;
}
wrapper->interface->format_attr_sdp_generate(&format->fattr, payload, str);
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
}
| int ast_format_sdp_parse | ( | struct ast_format * | format, |
| const char * | attributes | ||
| ) |
This function is used to have a media format aware module parse and interpret SDP attribute information. Once interpreted this information is stored on the format itself using Asterisk format attributes.
| format | to set |
| attributes | string containing the fmtp line from the SDP |
| 0 | success, attribute values were valid |
| -1 | failure, values were not acceptable |
Definition at line 122 of file format.c.
References ao2_rdlock, ao2_ref, ao2_unlock, ast_format::fattr, find_interface(), ast_format_attr_interface::format_attr_sdp_parse, and interface_ao2_wrapper::interface.
Referenced by process_sdp_a_audio(), and process_sdp_a_video().
{
struct interface_ao2_wrapper *wrapper;
int res;
if (!(wrapper = find_interface(format))) {
return 0;
}
ao2_rdlock(wrapper);
if (!wrapper->interface || !wrapper->interface->format_attr_sdp_parse) {
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
return 0;
}
res = wrapper->interface->format_attr_sdp_parse(&format->fattr, attributes);
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
return res;
}
| struct ast_format* ast_format_set | ( | struct ast_format * | format, |
| enum ast_format_id | id, | ||
| int | set_attributes, | ||
| ... | |||
| ) | [read] |
This function is used to set an ast_format object to represent a media format with optional format attributes represented by format specific key value pairs.
| format | to set |
| id,format | id to set on format |
| set_attributes,are | there attributes to set on this format. 0 == false, 1 == True. |
| var | list of attribute key value pairs, must end with AST_FORMAT_ATTR_END; |
Example usage. ast_format_set(format, AST_FORMAT_ULAW, 0); // no capability attributes are needed for ULAW
ast_format_set(format, AST_FORMAT_SILK, 1, // SILK has capability attributes. AST_FORMAT_SILK_ATTR_RATE, 24000, AST_FORMAT_SILK_ATTR_RATE, 16000, AST_FORMAT_SILK_ATTR_RATE, 12000, AST_FORMAT_SILK_ATTR_RATE, 8000, AST_FORMAT_ATTR_END);
Definition at line 204 of file format.c.
References ast_format_clear(), format, format_set_helper(), ast_format::id, and id.
Referenced by __adsi_transmit_messages(), _moh_class_malloc(), action_originate(), add_tcodec_to_sdp(), adpcm_sample(), adsi_careful_send(), agent_new(), alaw_sample(), alloc_playback_chan(), alsa_new(), alsa_read(), alsa_request(), analog_ss_thread(), ast_channel_make_compatible_helper(), ast_format_from_old_bitfield(), ast_rtp_codecs_payloads_set_rtpmap_type_rate(), ast_rtp_engine_init(), ast_rtp_read(), ast_sendtext(), ast_set_read_format_by_id(), ast_set_write_format_by_id(), ast_slinfactory_init(), ast_speech_new(), ast_translate_available_formats(), ast_translator_build_path(), audiohook_list_translate_to_slin(), audiohook_read_frame_both(), audiohook_read_frame_helper(), audiohook_read_frame_single(), audiohook_set_internal_rate(), bridge_request(), build_conf(), cb_events(), codec_skinny2ast(), conf_run(), conf_start_record(), console_new(), custom_celt_format(), custom_silk_format(), dahdi_callwait(), dahdi_new(), dahdi_sendtext(), do_notify(), fax_gateway_framehook(), fax_generator_generate(), format_list_init(), g719read(), g722_sample(), g723_read(), g726_read(), g726_sample(), g729_read(), generic_fax_exec(), generic_read(), generic_recall(), gsm_read(), gsm_sample(), h263_read(), h264_read(), handle_jack_audio(), handle_speechcreate(), ilbc_read(), ilbc_sample(), jpeg_read_image(), linear_generator(), load_module(), load_moh_classes(), local_ast_moh_start(), lpc10_sample(), matrix_rebuild(), milliwatt_generate(), misdn_read(), mixmonitor_thread(), mp3_exec(), mwi_send_init(), mwi_thread(), my_callwait(), my_get_callerid(), my_send_callerid(), NBScat_exec(), new_outgoing(), ogg_vorbis_read(), orig_app(), orig_exten(), originate_exec(), oss_new(), oss_read(), oss_request(), parkandannounce_exec(), phone_new(), phone_setup(), phone_write(), playtones_generator(), process_sdp(), rec_request(), rtp_red_init(), send_cwcidspill(), send_tone_burst(), send_waveform_to_channel(), set_softmix_bridge_data(), silence_generator_generate(), sip_set_default_format_capabilities(), siren14read(), siren7read(), slin16_sample(), slin8_sample(), sms_generate(), softmix_bridge_thread(), softmix_translate_helper_change_rate(), softmix_translate_helper_init(), spandsp_fax_gw_t30_gen(), spandsp_fax_read(), speex16_sample(), speex_sample(), spy_generate(), stream_monitor(), tonepair_generator(), ulaw_sample(), vox_read(), and wav_read().
{
/* initialize the structure before setting it. */
ast_format_clear(format);
format->id = id;
if (set_attributes) {
va_list ap;
va_start(ap, set_attributes);
format_set_helper(format, ap);
va_end(ap);
}
return format;
}
| void ast_format_set_video_mark | ( | struct ast_format * | format | ) |
Set the rtp mark value on the format to indicate to the interface writing this format's payload that a new RTP marker is necessary.
Definition at line 91 of file format.c.
References ast_format::fattr, and ast_format_attr::rtp_marker_bit.
Referenced by ast_rtp_read(), h263_read(), h264_read(), and socket_process_helper().
{
format->fattr.rtp_marker_bit = 1;
}
| enum ast_format_id ast_format_slin_by_rate | ( | unsigned int | rate | ) |
Get the best slinear format id for a given sample rate.
Definition at line 598 of file format.c.
References AST_FORMAT_SLINEAR, AST_FORMAT_SLINEAR12, AST_FORMAT_SLINEAR16, AST_FORMAT_SLINEAR192, AST_FORMAT_SLINEAR24, AST_FORMAT_SLINEAR32, AST_FORMAT_SLINEAR44, AST_FORMAT_SLINEAR48, and AST_FORMAT_SLINEAR96.
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(), mixmonitor_thread(), set_softmix_bridge_data(), softmix_bridge_thread(), softmix_translate_helper_change_rate(), and softmix_translate_helper_init().
{
if (rate >= 192000) {
return AST_FORMAT_SLINEAR192;
} else if (rate >= 96000) {
return AST_FORMAT_SLINEAR96;
} else if (rate >= 48000) {
return AST_FORMAT_SLINEAR48;
} else if (rate >= 44100) {
return AST_FORMAT_SLINEAR44;
} else if (rate >= 32000) {
return AST_FORMAT_SLINEAR32;
} else if (rate >= 24000) {
return AST_FORMAT_SLINEAR24;
} else if (rate >= 16000) {
return AST_FORMAT_SLINEAR16;
} else if (rate >= 12000) {
return AST_FORMAT_SLINEAR12;
}
return AST_FORMAT_SLINEAR;
}
| uint64_t ast_format_to_old_bitfield | ( | const struct ast_format * | format | ) |
ast_format to old bitfield format represenatation
| iax2 | representation of ast_format |
| 0,if | no representation existis for iax2 |
Definition at line 473 of file format.c.
References ast_format_id_to_old_bitfield(), and ast_format::id.
Referenced by ast_format_cap_to_old_bitfield(), conf_run(), dahdi_translate(), iax2_best_codec(), iax2_codec_choose(), iax2_send(), iax_template_parse(), oh323_rtp_read(), setup_rtp_connection(), and socket_process_helper().
{
return ast_format_id_to_old_bitfield(format->id);
}
| struct ast_format* ast_getformatbyname | ( | const char * | name, |
| struct ast_format * | format | ||
| ) | [read] |
Gets a format from a name.
| name | string of format |
| format | structure to return the format in. |
Definition at line 693 of file format.c.
References ast_expand_codec_alias(), ast_format_copy(), ast_format_list_destroy(), ast_format_list_get(), and format.
Referenced by ast_parse_allow_disallow(), iax_template_parse(), load_moh_classes(), local_ast_moh_start(), msg_create_from_file(), reload_config(), and try_suggested_sip_codec().
{
int x;
size_t f_len;
const struct ast_format_list *f_list = ast_format_list_get(&f_len);
for (x = 0; x < f_len; x++) {
if (!strcasecmp(f_list[x].name, name) ||
!strcasecmp(f_list[x].name, ast_expand_codec_alias(name))) {
ast_format_copy(result, &f_list[x].format);
f_list = ast_format_list_destroy(f_list);
return result;
}
}
f_list = ast_format_list_destroy(f_list);
return NULL;
}
| const char* ast_getformatname | ( | const struct ast_format * | format | ) |
Get the name of a format.
| format | id of format |
Definition at line 620 of file format.c.
References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_list_destroy(), ast_format_list_get(), and ast_format_list::name.
Referenced by __ast_play_and_record(), __ast_read(), __ast_register_translator(), __ast_smoother_feed(), _sip_show_peer(), _skinny_show_line(), add_codec_to_answer(), add_codec_to_sdp(), add_sdp(), add_static_payload(), add_tcodec_to_sdp(), add_vcodec_to_sdp(), adsi_transmit_message_full(), agent_call(), ast_channel_make_compatible_helper(), ast_codec_get_len(), ast_codec_get_samples(), ast_codec_pref_getsize(), ast_codec_pref_string(), ast_do_masquerade(), ast_dsp_process(), ast_frame_subclass2str(), ast_openvstream(), ast_rtp_write(), ast_slinfactory_feed(), ast_stopstream(), ast_streamfile(), ast_translator_build_path(), ast_unregister_translator(), ast_write(), ast_writestream(), background_detect_exec(), bridge_channel_join(), bridge_make_compatible(), conf_run(), create_addr(), dahdi_read(), dahdi_translate(), dahdi_write(), do_waiting(), eagi_exec(), func_channel_read(), function_iaxpeer(), function_sippeer(), g719write(), g726_write(), g729_write(), generic_write(), gsm_write(), gtalk_rtp_read(), gtalk_show_channels(), gtalk_write(), h263_write(), h264_write(), handle_capabilities_res_message(), handle_cli_core_show_file_formats(), handle_cli_iax2_show_peer(), handle_cli_moh_show_classes(), handle_core_show_image_formats(), handle_open_receive_channel_ack_message(), handle_show_translation_table(), handle_showchan(), iax2_getformatname(), ilbc_write(), isAnsweringMachine(), jack_hook_callback(), jingle_read(), jingle_rtp_read(), jingle_show_channels(), jingle_write(), login_exec(), matrix_rebuild(), mgcp_rtp_read(), mgcp_write(), misdn_write(), moh_files_release(), moh_release(), nbs_xwrite(), ogg_vorbis_write(), oh323_rtp_read(), oh323_write(), pcm_write(), phone_setup(), phone_write(), print_codec_to_cli(), print_frame(), process_sdp_a_audio(), register_translator(), send_start_rtp(), serialize_showchan(), set_format(), set_local_capabilities(), set_peer_capabilities(), setup_rtp_connection(), sip_new(), sip_rtp_read(), sip_write(), siren14write(), siren7write(), skinny_new(), skinny_rtp_read(), skinny_set_rtp_peer(), skinny_write(), socket_process_helper(), start_rtp(), unistim_new(), unistim_rtp_read(), unistim_write(), vox_write(), and wav_write().
{
int x;
const char *ret = "unknown";
size_t f_len;
const struct ast_format_list *f_list = ast_format_list_get(&f_len);
for (x = 0; x < f_len; x++) {
if (ast_format_cmp(&f_list[x].format, format) == AST_FORMAT_CMP_EQUAL) {
ret = f_list[x].name;
break;
}
}
f_list = ast_format_list_destroy(f_list);
return ret;
}
| char* ast_getformatname_multiple_byid | ( | char * | buf, |
| size_t | size, | ||
| enum ast_format_id | id | ||
| ) |
Returns a string containing all formats pertaining to an format id.
| buf | a buffer for the output string |
| size | size of buf (bytes) |
| format | id. |
Definition at line 637 of file format.c.
References ast_copy_string(), ast_format_list_destroy(), ast_format_list_get(), format, len(), and name.
Referenced by ast_translate_path_to_str(), and handle_show_translation_path().
{
int x;
unsigned len;
char *start, *end = buf;
size_t f_len;
const struct ast_format_list *f_list = ast_format_list_get(&f_len);
if (!size) {
f_list = ast_format_list_destroy(f_list);
return buf;
}
snprintf(end, size, "(");
len = strlen(end);
end += len;
size -= len;
start = end;
for (x = 0; x < f_len; x++) {
if (f_list[x].format.id == id) {
snprintf(end, size, "%s|", f_list[x].name);
len = strlen(end);
end += len;
size -= len;
}
}
if (start == end) {
ast_copy_string(start, "nothing)", size);
} else if (size > 1) {
*(end - 1) = ')';
}
f_list = ast_format_list_destroy(f_list);
return buf;
}
| ASTERISK_FILE_VERSION | ( | __FILE__ | , |
| "$Revision: 411310 $" | |||
| ) |
| static int build_format_list_array | ( | void | ) | [static] |
Definition at line 997 of file format.c.
References ao2_alloc, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_rwlock_unlock, ast_rwlock_wrlock, format_list_array, and format_list_array_len.
Referenced by ast_format_list_init(), and load_format_config().
{
struct ast_format_list *tmp;
size_t arraysize = sizeof(struct ast_format_list) * ao2_container_count(format_list);
int i = 0;
struct ao2_iterator it;
ast_rwlock_wrlock(&format_list_array_lock);
tmp = format_list_array;
if (!(format_list_array = ao2_alloc(arraysize, NULL))) {
format_list_array = tmp;
ast_rwlock_unlock(&format_list_array_lock);
return -1;
}
format_list_array_len = ao2_container_count(format_list);
if (tmp) {
ao2_ref(tmp, -1);
}
/* walk through the container adding elements to the static array */
it = ao2_iterator_init(format_list, 0);
while ((tmp = ao2_iterator_next(&it)) && (i < format_list_array_len)) {
memcpy(&format_list_array[i], tmp, sizeof(struct ast_format_list));
ao2_ref(tmp, -1);
i++;
}
ao2_iterator_destroy(&it);
ast_rwlock_unlock(&format_list_array_lock);
return 0;
}
| static int conf_process_format_name | ( | const char * | name, |
| enum ast_format_id * | id | ||
| ) | [static] |
Definition at line 1216 of file format.c.
References AST_FORMAT_CELT, and AST_FORMAT_SILK.
Referenced by load_format_config().
{
if (!strcasecmp(name, "silk")) {
*id = AST_FORMAT_SILK;
} else if (!strcasecmp(name, "celt")) {
*id = AST_FORMAT_CELT;
} else {
*id = 0;
return -1;
}
return 0;
}
| static int conf_process_sample_rate | ( | const char * | rate, |
| unsigned int * | result | ||
| ) | [static] |
Definition at line 1229 of file format.c.
Referenced by load_format_config().
{
if (!strcasecmp(rate, "8000")) {
*result = 8000;
} else if (!strcasecmp(rate, "12000")) {
*result = 12000;
} else if (!strcasecmp(rate, "16000")) {
*result = 16000;
} else if (!strcasecmp(rate, "24000")) {
*result = 24000;
} else if (!strcasecmp(rate, "32000")) {
*result = 32000;
} else if (!strcasecmp(rate, "44100")) {
*result = 44100;
} else if (!strcasecmp(rate, "48000")) {
*result = 48000;
} else if (!strcasecmp(rate, "96000")) {
*result = 96000;
} else if (!strcasecmp(rate, "192000")) {
*result = 192000;
} else {
*result = 0;
return -1;
}
return 0;
}
| static int custom_celt_format | ( | struct ast_format_list * | entry, |
| unsigned int | maxbitrate, | ||
| unsigned int | framesize | ||
| ) | [static] |
Definition at line 1135 of file format.c.
References ast_format_append(), AST_FORMAT_ATTR_END, AST_FORMAT_CELT, ast_format_set(), ast_log(), CELT_ATTR_KEY_FRAME_SIZE, CELT_ATTR_KEY_MAX_BITRATE, CELT_ATTR_KEY_SAMP_RATE, ast_format_list::def_ms, ast_format_list::desc, ast_format_list::format, ast_format_list::fr_len, has_interface(), ast_format_list::inc_ms, LOG_WARNING, ast_format_list::max_ms, ast_format_list::min_ms, ast_format_list::name, and ast_format_list::samplespersecond.
Referenced by load_format_config().
{
if (!entry->samplespersecond) {
ast_log(LOG_WARNING, "Custom CELT format definition '%s' requires sample rate to be defined.\n", entry->name);
}
ast_format_set(&entry->format, AST_FORMAT_CELT, 0);
if (!has_interface(&entry->format)) {
return -1;
}
snprintf(entry->desc, sizeof(entry->desc), "CELT Custom Format %dkhz", entry->samplespersecond/1000);
ast_format_append(&entry->format,
CELT_ATTR_KEY_SAMP_RATE, entry->samplespersecond,
CELT_ATTR_KEY_MAX_BITRATE, maxbitrate,
CELT_ATTR_KEY_FRAME_SIZE, framesize,
AST_FORMAT_ATTR_END);
entry->fr_len = 80;
entry->min_ms = 20;
entry->max_ms = 20;
entry->inc_ms = 20;
entry->def_ms = 20;
return 0;
}
| static int custom_silk_format | ( | struct ast_format_list * | entry, |
| unsigned int | maxbitrate, | ||
| int | usedtx, | ||
| int | usefec, | ||
| int | packetloss_percentage | ||
| ) | [static] |
Definition at line 1161 of file format.c.
References ast_copy_string(), ast_format_append(), AST_FORMAT_ATTR_END, ast_format_set(), AST_FORMAT_SILK, ast_log(), ast_format_list::def_ms, ast_format_list::desc, ast_format_list::format, ast_format_list::fr_len, has_interface(), ast_format_list::inc_ms, LOG_WARNING, ast_format_list::max_ms, ast_format_list::min_ms, ast_format_list::name, ast_format_list::samplespersecond, SILK_ATTR_KEY_DTX, SILK_ATTR_KEY_FEC, SILK_ATTR_KEY_MAX_BITRATE, SILK_ATTR_KEY_PACKETLOSS_PERCENTAGE, SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_12KHZ, SILK_ATTR_VAL_SAMP_16KHZ, SILK_ATTR_VAL_SAMP_24KHZ, and SILK_ATTR_VAL_SAMP_8KHZ.
Referenced by load_format_config().
{
if (!entry->samplespersecond) {
ast_log(LOG_WARNING, "Custom SILK format definition '%s' requires sample rate to be defined.\n", entry->name);
}
ast_format_set(&entry->format, AST_FORMAT_SILK, 0);
if (!has_interface(&entry->format)) {
return -1;
}
switch (entry->samplespersecond) {
case 8000:
ast_copy_string(entry->desc, "SILK Custom Format 8khz", sizeof(entry->desc));
ast_format_append(&entry->format,
SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_8KHZ,
AST_FORMAT_ATTR_END);
break;
case 12000:
ast_copy_string(entry->desc, "SILK Custom Format 12khz", sizeof(entry->desc));
ast_format_append(&entry->format,
SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_12KHZ,
AST_FORMAT_ATTR_END);
break;
case 16000:
ast_copy_string(entry->desc, "SILK Custom Format 16khz", sizeof(entry->desc));
ast_format_append(&entry->format,
SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_16KHZ,
AST_FORMAT_ATTR_END);
break;
case 24000:
ast_copy_string(entry->desc, "SILK Custom Format 24khz", sizeof(entry->desc));
ast_format_append(&entry->format,
SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_24KHZ,
AST_FORMAT_ATTR_END);
break;
default:
ast_log(LOG_WARNING, "Custom SILK format definition '%s' can not support sample rate %d\n", entry->name, entry->samplespersecond);
return -1;
}
ast_format_append(&entry->format,
SILK_ATTR_KEY_MAX_BITRATE, maxbitrate,
SILK_ATTR_KEY_DTX, usedtx ? 1 : 0,
SILK_ATTR_KEY_FEC, usefec ? 1 : 0,
SILK_ATTR_KEY_PACKETLOSS_PERCENTAGE, packetloss_percentage,
AST_FORMAT_ATTR_END);
entry->fr_len = 80;
entry->min_ms = 20;
entry->max_ms = 20;
entry->inc_ms = 20;
entry->def_ms = 20;
return 0;
}
| static struct interface_ao2_wrapper* find_interface | ( | const struct ast_format * | format | ) | [static, read] |
Definition at line 101 of file format.c.
References ao2_find, interface_ao2_wrapper::id, ast_format::id, and OBJ_POINTER.
Referenced by ast_format_get_value(), ast_format_sdp_generate(), ast_format_sdp_parse(), format_cmp_helper(), format_isset_helper(), format_joint_helper(), format_set_helper(), and has_interface().
{
struct interface_ao2_wrapper tmp_wrapper = {
.id = format->id,
};
return ao2_find(interfaces, &tmp_wrapper, OBJ_POINTER);
}
| static void format_attr_shutdown | ( | void | ) | [static] |
Definition at line 1113 of file format.c.
References ao2_ref, ARRAY_LEN, and ast_cli_unregister_multiple().
Referenced by ast_format_attr_init().
{
ast_cli_unregister_multiple(my_clis, ARRAY_LEN(my_clis));
if (interfaces) {
ao2_ref(interfaces, -1);
interfaces = NULL;
}
}
| static enum ast_format_cmp_res format_cmp_helper | ( | const struct ast_format * | format1, |
| const struct ast_format * | format2 | ||
| ) | [static] |
Definition at line 309 of file format.c.
References ao2_rdlock, ao2_ref, ao2_unlock, AST_FORMAT_CMP_EQUAL, ast_format::fattr, find_interface(), ast_format_attr_interface::format_attr_cmp, and interface_ao2_wrapper::interface.
Referenced by ast_format_cmp().
{
enum ast_format_cmp_res res = AST_FORMAT_CMP_EQUAL;
struct interface_ao2_wrapper *wrapper;
if (!(wrapper = find_interface(format1))) {
return res;
}
ao2_rdlock(wrapper);
if (!wrapper->interface || !wrapper->interface->format_attr_cmp) {
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
return res;
}
res = wrapper->interface->format_attr_cmp(&format1->fattr, &format2->fattr);
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
return res;
}
| static int format_isset_helper | ( | const struct ast_format * | format, |
| va_list | ap | ||
| ) | [static] |
Definition at line 230 of file format.c.
References ao2_rdlock, ao2_ref, ao2_unlock, AST_FORMAT_CMP_NOT_EQUAL, ast_format::fattr, find_interface(), ast_format_attr_interface::format_attr_cmp, ast_format_attr_interface::format_attr_isset, ast_format_attr_interface::format_attr_set, ast_format::id, and interface_ao2_wrapper::interface.
Referenced by ast_format_isset().
{
int res;
struct interface_ao2_wrapper *wrapper;
struct ast_format tmp = {
.id = format->id,
.fattr = { { 0, }, },
};
if (!(wrapper = find_interface(format))) {
return -1;
}
ao2_rdlock(wrapper);
if (!wrapper->interface ||
!wrapper->interface->format_attr_set ||
!wrapper->interface->format_attr_cmp) {
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
return -1;
}
/* if isset is present, use that function, else just build a new
* format and use the cmp function */
if (wrapper->interface->format_attr_isset) {
res = wrapper->interface->format_attr_isset(&format->fattr, ap);
} else {
wrapper->interface->format_attr_set(&tmp.fattr, ap);
/* use our tmp structure to tell if the attributes are set or not */
res = wrapper->interface->format_attr_cmp(&tmp.fattr, &format->fattr);
res = (res == AST_FORMAT_CMP_NOT_EQUAL) ? -1 : 0;
}
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
return res;
}
| static int format_joint_helper | ( | const struct ast_format * | format1, |
| const struct ast_format * | format2, | ||
| struct ast_format * | result | ||
| ) | [static] |
Definition at line 345 of file format.c.
References ao2_rdlock, ao2_ref, ao2_unlock, ast_format::fattr, find_interface(), ast_format_attr_interface::format_attr_get_joint, and interface_ao2_wrapper::interface.
Referenced by ast_format_joint().
{
int res = 0;
struct interface_ao2_wrapper *wrapper;
if (!(wrapper = find_interface(format1))) {
/* if no interface is present, we assume formats are joint by id alone */
return res;
}
ao2_rdlock(wrapper);
if (wrapper->interface && wrapper->interface->format_attr_get_joint) {
res = wrapper->interface->format_attr_get_joint(&format1->fattr, &format2->fattr, &result->fattr);
}
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
return res;
}
| static int format_list_add_custom | ( | struct ast_format_list * | new | ) | [static] |
Definition at line 917 of file format.c.
References ao2_alloc, ao2_cleanup, and ao2_link.
Referenced by load_format_config().
{
RAII_VAR(struct ast_format_list *, entry, NULL, ao2_cleanup);
if (!(entry = ao2_alloc(sizeof(*entry), NULL))) {
return -1;
}
memcpy(entry, new, sizeof(struct ast_format_list));
entry->custom_entry = 1;
ao2_link(format_list, entry);
return 0;
}
| static int format_list_add_static | ( | const struct ast_format * | format, |
| const char * | name, | ||
| int | samplespersecond, | ||
| const char * | description, | ||
| int | fr_len, | ||
| int | min_ms, | ||
| int | max_ms, | ||
| int | inc_ms, | ||
| int | def_ms, | ||
| unsigned int | flags, | ||
| int | cur_ms | ||
| ) | [static] |
Definition at line 928 of file format.c.
References ao2_alloc, ao2_link, ao2_ref, ast_copy_string(), ast_format_copy(), ast_format_list::cur_ms, ast_format_list::custom_entry, ast_format_list::def_ms, ast_format_list::desc, ast_format_list::flags, ast_format_list::format, ast_format_list::fr_len, ast_format_list::inc_ms, ast_format_list::max_ms, ast_format_list::min_ms, ast_format_list::name, and ast_format_list::samplespersecond.
Referenced by format_list_init().
{
struct ast_format_list *entry;
if (!(entry = ao2_alloc(sizeof(*entry), NULL))) {
return -1;
}
ast_format_copy(&entry->format, format);
ast_copy_string(entry->name, name, sizeof(entry->name));
ast_copy_string(entry->desc, description, sizeof(entry->desc));
entry->samplespersecond = samplespersecond;
entry->fr_len = fr_len;
entry->min_ms = min_ms;
entry->max_ms = max_ms;
entry->inc_ms = inc_ms;
entry->def_ms = def_ms;
entry->flags = flags;
entry->cur_ms = cur_ms;
entry->custom_entry = 0;
ao2_link(format_list, entry);
ao2_ref(entry, -1);
return 0;
}
| static int format_list_init | ( | void | ) | [static] |
< G723.1
< Signed linear
< Binary commercial distribution
< Signed linear (16kHz)
< See format_jpeg.c
< PNG Image format
< H.261 Video Passthrough
< H.263 Passthrough support, see format_h263.c
< H.263plus passthrough support See format_h263.c
< Passthrough support, see format_h263.c
< Passthrough support for MPEG4
< Redundant T.140 Realtime Text
< Passthrough support for T.140 Realtime Text
< Binary commercial distribution
< Binary commercial distribution
< Signed linear (12kHz)
< Signed linear (24kHz)
< Signed linear (32kHz)
< Signed linear (44.1kHz)
< Signed linear (48kHz)
< Signed linear (96kHz)
< Signed linear (192kHz)
Definition at line 1029 of file format.c.
References ao2_container_alloc, AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_G719, AST_FORMAT_G722, AST_FORMAT_G723_1, AST_FORMAT_G726, AST_FORMAT_G726_AAL2, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_H261, AST_FORMAT_H263, AST_FORMAT_H263_PLUS, AST_FORMAT_H264, AST_FORMAT_ILBC, AST_FORMAT_JPEG, AST_FORMAT_LPC10, AST_FORMAT_MP4_VIDEO, AST_FORMAT_PNG, ast_format_set(), AST_FORMAT_SIREN14, AST_FORMAT_SIREN7, AST_FORMAT_SLINEAR, AST_FORMAT_SLINEAR12, AST_FORMAT_SLINEAR16, AST_FORMAT_SLINEAR192, AST_FORMAT_SLINEAR24, AST_FORMAT_SLINEAR32, AST_FORMAT_SLINEAR44, AST_FORMAT_SLINEAR48, AST_FORMAT_SLINEAR96, AST_FORMAT_SPEEX, AST_FORMAT_SPEEX16, AST_FORMAT_SPEEX32, AST_FORMAT_T140, AST_FORMAT_T140RED, AST_FORMAT_TESTLAW, AST_FORMAT_ULAW, AST_SMOOTHER_FLAG_BE, AST_SMOOTHER_FLAG_G729, format_list_add_static(), list_cmp_cb(), and list_hash_cb().
Referenced by ast_format_list_init().
{
struct ast_format tmpfmt;
if (!(format_list = ao2_container_alloc(283, list_hash_cb, list_cmp_cb))) {
return -1;
}
/* initiate static entries XXX DO NOT CHANGE THIS ORDER! */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G723_1, 0), "g723", 8000, "G.723.1", 20, 30, 300, 30, 30, 0, 0); /*!< G723.1 */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_GSM, 0), "gsm", 8000, "GSM", 33, 20, 300, 20, 20, 0, 0); /*!< codec_gsm.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0), "ulaw", 8000, "G.711 u-law", 80, 10, 150, 10, 20, 0, 0); /*!< codec_ulaw.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_ALAW, 0), "alaw", 8000, "G.711 A-law", 80, 10, 150, 10, 20, 0, 0); /*!< codec_alaw.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G726, 0), "g726", 8000, "G.726 RFC3551", 40, 10, 300, 10, 20, 0, 0); /*!< codec_g726.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_ADPCM, 0), "adpcm" , 8000, "ADPCM", 40, 10, 300, 10, 20, 0, 0); /*!< codec_adpcm.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0), "slin", 8000, "16 bit Signed Linear PCM", 160, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0); /*!< Signed linear */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_LPC10, 0), "lpc10", 8000, "LPC10", 7, 20, 20, 20, 20, 0, 0); /*!< codec_lpc10.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G729A, 0), "g729", 8000, "G.729A", 10, 10, 230, 10, 20, AST_SMOOTHER_FLAG_G729, 0); /*!< Binary commercial distribution */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SPEEX, 0), "speex", 8000, "SpeeX", 10, 10, 60, 10, 20, 0, 0); /*!< codec_speex.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SPEEX16, 0), "speex16", 16000, "SpeeX 16khz", 10, 10, 60, 10, 20, 0, 0); /*!< codec_speex.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_ILBC, 0), "ilbc", 8000, "iLBC", 50, 30, 30, 30, 30, 0, 0); /*!< codec_ilbc.c */ /* inc=30ms - workaround */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G726_AAL2, 0), "g726aal2", 8000, "G.726 AAL2", 40, 10, 300, 10, 20, 0, 0); /*!< codec_g726.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G722, 0), "g722", 16000, "G722", 80, 10, 150, 10, 20, 0, 0); /*!< codec_g722.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0), "slin16", 16000, "16 bit Signed Linear PCM (16kHz)", 320, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (16kHz) */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_JPEG, 0), "jpeg", 0, "JPEG image", 0, 0, 0, 0 ,0 ,0 ,0); /*!< See format_jpeg.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_PNG, 0), "png", 0, "PNG image", 0, 0, 0, 0 ,0 ,0 ,0); /*!< PNG Image format */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_H261, 0), "h261", 0, "H.261 Video", 0, 0, 0, 0 ,0 ,0 ,0); /*!< H.261 Video Passthrough */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_H263, 0), "h263", 0, "H.263 Video", 0, 0, 0, 0 ,0 ,0 ,0); /*!< H.263 Passthrough support, see format_h263.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_H263_PLUS, 0), "h263p", 0, "H.263+ Video", 0, 0, 0,0 ,0 ,0, 0); /*!< H.263plus passthrough support See format_h263.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_H264, 0), "h264", 0, "H.264 Video", 0, 0, 0, 0 ,0 ,0, 0); /*!< Passthrough support, see format_h263.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_MP4_VIDEO, 0), "mpeg4", 0, "MPEG4 Video", 0, 0, 0, 0, 0 ,0, 0); /*!< Passthrough support for MPEG4 */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_T140RED, 0), "red", 1, "T.140 Realtime Text with redundancy", 0, 0, 0,0 ,0 ,0, 0); /*!< Redundant T.140 Realtime Text */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_T140, 0), "t140", 0, "Passthrough T.140 Realtime Text", 0, 0, 0, 0 ,0 ,0, 0); /*!< Passthrough support for T.140 Realtime Text */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SIREN7, 0), "siren7", 16000, "ITU G.722.1 (Siren7, licensed from Polycom)", 80, 20, 80, 20, 20, 0, 0); /*!< Binary commercial distribution */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SIREN14, 0), "siren14", 32000, "ITU G.722.1 Annex C, (Siren14, licensed from Polycom)", 120, 20, 80, 20, 20, 0, 0); /*!< Binary commercial distribution */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_TESTLAW, 0), "testlaw", 8000, "G.711 test-law", 80, 10, 150, 10, 20, 0, 0); /*!< codec_ulaw.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G719, 0), "g719", 48000, "ITU G.719", 160, 20, 80, 20, 20, 0, 0);
/* ORDER MAY CHANGE AFTER THIS POINT IN THE LIST */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SPEEX32, 0), "speex32", 32000, "SpeeX 32khz", 10, 10, 60, 10, 20, 0, 0); /*!< codec_speex.c */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR12, 0), "slin12", 12000, "16 bit Signed Linear PCM (12kHz)", 240, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (12kHz) */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR24, 0), "slin24", 24000, "16 bit Signed Linear PCM (24kHz)", 480, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (24kHz) */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR32, 0), "slin32", 32000, "16 bit Signed Linear PCM (32kHz)", 640, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (32kHz) */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR44, 0), "slin44", 44100, "16 bit Signed Linear PCM (44kHz)", 882, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (44.1kHz) */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR48, 0), "slin48", 48000, "16 bit Signed Linear PCM (48kHz)", 960, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (48kHz) */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR96, 0), "slin96", 96000, "16 bit Signed Linear PCM (96kHz)", 1920, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (96kHz) */
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR192, 0), "slin192", 192000, "16 bit Signed Linear PCM (192kHz)", 3840, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (192kHz) */
return 0;
}
| static void format_list_shutdown | ( | void | ) | [static] |
Definition at line 1079 of file format.c.
References ao2_t_ref, and ast_rwlock_destroy.
Referenced by ast_format_list_init().
{
ast_rwlock_destroy(&format_list_array_lock);
if (format_list) {
ao2_t_ref(format_list, -1, "Unref format_list container in shutdown");
format_list = NULL;
}
if (format_list_array) {
ao2_t_ref(format_list_array, -1, "Unref format_list_array in shutdown");
format_list_array = NULL;
}
}
| static int format_set_helper | ( | struct ast_format * | format, |
| va_list | ap | ||
| ) | [static] |
Definition at line 170 of file format.c.
References ao2_rdlock, ao2_ref, ao2_unlock, ast_log(), ast_format::fattr, find_interface(), ast_format_attr_interface::format_attr_set, interface_ao2_wrapper::interface, and LOG_WARNING.
Referenced by ast_format_append(), and ast_format_set().
{
struct interface_ao2_wrapper *wrapper;
if (!(wrapper = find_interface(format))) {
ast_log(LOG_WARNING, "Could not find format interface to set.\n");
return -1;
}
ao2_rdlock(wrapper);
if (!wrapper->interface || !wrapper->interface->format_attr_set) {
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
return -1;
}
wrapper->interface->format_attr_set(&format->fattr, ap);
ao2_unlock(wrapper);
ao2_ref(wrapper, -1);
return 0;
}
| static int has_interface | ( | const struct ast_format * | format | ) | [static] |
Definition at line 110 of file format.c.
References ao2_ref, and find_interface().
Referenced by custom_celt_format(), and custom_silk_format().
{
struct interface_ao2_wrapper *wrapper;
wrapper = find_interface(format);
if (!wrapper) {
return 0;
}
ao2_ref(wrapper, -1);
return 1;
}
| int init_framer | ( | void | ) |
| static int interface_cmp_cb | ( | void * | obj, |
| void * | arg, | ||
| int | flags | ||
| ) | [static] |
Definition at line 72 of file format.c.
References CMP_MATCH, CMP_STOP, and interface_ao2_wrapper::id.
Referenced by ast_format_attr_init().
{
struct interface_ao2_wrapper *wrapper1 = obj;
struct interface_ao2_wrapper *wrapper2 = arg;
return (wrapper2->id == wrapper1->id) ? CMP_MATCH | CMP_STOP : 0;
}
| static int interface_hash_cb | ( | const void * | obj, |
| const int | flags | ||
| ) | [static] |
Definition at line 80 of file format.c.
References interface_ao2_wrapper::id.
Referenced by ast_format_attr_init().
{
const struct interface_ao2_wrapper *wrapper = obj;
return wrapper->id;
}
| static int list_all_custom | ( | void * | obj, |
| void * | arg, | ||
| int | flag | ||
| ) | [static] |
Definition at line 963 of file format.c.
References CMP_MATCH, and ast_format_list::custom_entry.
Referenced by load_format_config().
{
struct ast_format_list *entry = obj;
return entry->custom_entry ? CMP_MATCH : 0;
}
| static int list_cmp_cb | ( | void * | obj, |
| void * | arg, | ||
| int | flags | ||
| ) | [static] |
Definition at line 969 of file format.c.
References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, CMP_MATCH, CMP_STOP, and ast_format_list::format.
Referenced by format_list_init().
{
struct ast_format_list *entry1 = obj;
struct ast_format_list *entry2 = arg;
return (ast_format_cmp(&entry1->format, &entry2->format) == AST_FORMAT_CMP_EQUAL) ? CMP_MATCH | CMP_STOP : 0;
}
| static int list_hash_cb | ( | const void * | obj, |
| const int | flags | ||
| ) | [static] |
Definition at line 976 of file format.c.
References ao2_container_count().
Referenced by format_list_init().
{
return ao2_container_count(format_list);
}
| static int load_format_config | ( | void | ) | [static] |
Definition at line 1256 of file format.c.
References ao2_callback, ast_category_browse(), ast_config_destroy(), ast_config_load, ast_copy_string(), AST_FORMAT_CELT, AST_FORMAT_SILK, ast_log(), ast_true(), ast_variable_browse(), ast_variable_retrieve(), build_format_list_array(), conf_process_format_name(), conf_process_sample_rate(), CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, custom_celt_format(), custom_silk_format(), FORMAT_CONFIG, format_list_add_custom(), id, ast_variable::lineno, list_all_custom(), LOG_WARNING, ast_variable::name, ast_format_list::name, ast_variable::next, OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, ast_format_list::samplespersecond, settings, ast_variable::value, and var.
Referenced by ast_format_attr_reg_interface(), and ast_format_attr_unreg_interface().
{
struct ast_flags config_flags = { 0, };
struct ast_config *cfg = ast_config_load(FORMAT_CONFIG, config_flags);
struct ast_format_list entry;
struct ast_variable *var;
char *cat = NULL;
int add_it = 0;
struct {
enum ast_format_id id;
unsigned int maxbitrate;
unsigned int framesize;
unsigned int packetloss_percentage;
int usefec;
int usedtx;
} settings;
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
return 0;
}
/* remove all custom formats from the AO2 Container. Note, this has no affect on the
* global format list until the list is rebuild. That is why this is okay to do while
* reloading the config. */
ao2_callback(format_list, OBJ_NODATA | OBJ_UNLINK | OBJ_MULTIPLE, list_all_custom, NULL);
while ((cat = ast_category_browse(cfg, cat))) {
memset(&entry, 0, sizeof(entry));
memset(&settings, 0, sizeof(settings));
add_it = 0;
if (!(ast_variable_retrieve(cfg, cat, "type"))) {
continue;
}
ast_copy_string(entry.name, cat, sizeof(entry.name));
var = ast_variable_browse(cfg, cat);
for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
if (!strcasecmp(var->name, "type") && conf_process_format_name(var->value, &settings.id)) {
ast_log(LOG_WARNING, "Can not make custom format type for '%s' at line %d of %s\n",
var->value, var->lineno, FORMAT_CONFIG);
continue;
} else if (!strcasecmp(var->name, "samprate") && conf_process_sample_rate(var->value, &entry.samplespersecond)) {
ast_log(LOG_WARNING, "Sample rate '%s' at line %d of %s is not supported.\n",
var->value, var->lineno, FORMAT_CONFIG);
} else if (!strcasecmp(var->name, "maxbitrate")) {
if (sscanf(var->value, "%30u", &settings.maxbitrate) != 1) {
ast_log(LOG_WARNING, "maxbitrate '%s' at line %d of %s is not supported.\n",
var->value, var->lineno, FORMAT_CONFIG);
}
} else if (!strcasecmp(var->name, "framesize")) {
if (sscanf(var->value, "%30u", &settings.framesize) != 1) {
ast_log(LOG_WARNING, "framesize '%s' at line %d of %s is not supported.\n",
var->value, var->lineno, FORMAT_CONFIG);
}
} else if (!strcasecmp(var->name, "dtx")) {
settings.usedtx = ast_true(var->value) ? 1 : 0;
} else if (!strcasecmp(var->name, "fec")) {
settings.usefec = ast_true(var->value) ? 1 : 0;
} else if (!strcasecmp(var->name, "packetloss_percentage")) {
if ((sscanf(var->value, "%30u", &settings.packetloss_percentage) != 1) || (settings.packetloss_percentage > 100)) {
ast_log(LOG_WARNING, "packetloss_percentage '%s' at line %d of %s is not supported.\n",
var->value, var->lineno, FORMAT_CONFIG);
}
}
}
switch (settings.id) {
case AST_FORMAT_SILK:
if (!(custom_silk_format(&entry, settings.maxbitrate, settings.usedtx, settings.usefec, settings.packetloss_percentage))) {
add_it = 1;
}
break;
case AST_FORMAT_CELT:
if (!(custom_celt_format(&entry, settings.maxbitrate, settings.framesize))) {
add_it = 1;
}
break;
default:
ast_log(LOG_WARNING, "Can not create custom format %s\n", entry.name);
}
if (add_it) {
format_list_add_custom(&entry);
}
}
ast_config_destroy(cfg);
build_format_list_array();
return 0;
}
| static char* show_codec_n | ( | struct ast_cli_entry * | e, |
| int | cmd, | ||
| struct ast_cli_args * | a | ||
| ) | [static] |
Definition at line 863 of file format.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_format_list_destroy(), ast_format_list_get(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_format_list::desc, ast_cli_args::fd, format, and ast_cli_entry::usage.
{
enum ast_format_id format_id;
int x, found = 0;
int type_punned_codec;
size_t f_len;
const struct ast_format_list *f_list;
switch (cmd) {
case CLI_INIT:
e->command = "core show codec";
e->usage =
"Usage: core show codec <number>\n"
" Displays codec mapping\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
if (a->argc != 4) {
return CLI_SHOWUSAGE;
}
if (sscanf(a->argv[3], "%30d", &type_punned_codec) != 1) {
return CLI_SHOWUSAGE;
}
format_id = type_punned_codec;
f_list = ast_format_list_get(&f_len);
for (x = 0; x < f_len; x++) {
if (f_list[x].format.id == format_id) {
found = 1;
ast_cli(a->fd, "%11u %s\n", (unsigned int) format_id, f_list[x].desc);
}
}
if (!found) {
ast_cli(a->fd, "Codec %d not found\n", format_id);
}
f_list = ast_format_list_destroy(f_list);
return CLI_SUCCESS;
}
| static char* show_codecs | ( | struct ast_cli_entry * | e, |
| int | cmd, | ||
| struct ast_cli_args * | a | ||
| ) | [static] |
Definition at line 790 of file format.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), AST_FORMAT_GET_TYPE, ast_format_list_destroy(), ast_format_list_get(), AST_FORMAT_TYPE_AUDIO, AST_FORMAT_TYPE_IMAGE, AST_FORMAT_TYPE_TEXT, AST_FORMAT_TYPE_VIDEO, ast_opt_dont_warn, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_format_list::desc, ast_cli_args::fd, format, ast_format_list::format, ast_format::id, ast_format_list::name, and ast_cli_entry::usage.
{
int x, found=0;
size_t f_len;
const struct ast_format_list *f_list;
switch (cmd) {
case CLI_INIT:
e->command = "core show codecs [audio|video|image|text]";
e->usage =
"Usage: core show codecs [audio|video|image|text]\n"
" Displays codec mapping\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
if ((a->argc < 3) || (a->argc > 4)) {
return CLI_SHOWUSAGE;
}
f_list = ast_format_list_get(&f_len);
if (!ast_opt_dont_warn) {
ast_cli(a->fd, "Disclaimer: this command is for informational purposes only.\n"
"\tIt does not indicate anything about your configuration.\n");
}
ast_cli(a->fd, "%8s %5s %8s %s\n","ID","TYPE","NAME","DESCRIPTION");
ast_cli(a->fd, "-----------------------------------------------------------------------------------\n");
for (x = 0; x < f_len; x++) {
if (a->argc == 4) {
if (!strcasecmp(a->argv[3], "audio")) {
if (AST_FORMAT_GET_TYPE(f_list[x].format.id) != AST_FORMAT_TYPE_AUDIO) {
continue;
}
} else if (!strcasecmp(a->argv[3], "video")) {
if (AST_FORMAT_GET_TYPE(f_list[x].format.id) != AST_FORMAT_TYPE_VIDEO) {
continue;
}
} else if (!strcasecmp(a->argv[3], "image")) {
if (AST_FORMAT_GET_TYPE(f_list[x].format.id) != AST_FORMAT_TYPE_IMAGE) {
continue;
}
} else if (!strcasecmp(a->argv[3], "text")) {
if (AST_FORMAT_GET_TYPE(f_list[x].format.id) != AST_FORMAT_TYPE_TEXT) {
continue;
}
} else {
continue;
}
}
ast_cli(a->fd, "%8u %5s %8s (%s)\n",
f_list[x].format.id,
(AST_FORMAT_GET_TYPE(f_list[x].format.id) == AST_FORMAT_TYPE_AUDIO) ? "audio" :
(AST_FORMAT_GET_TYPE(f_list[x].format.id) == AST_FORMAT_TYPE_IMAGE) ? "image" :
(AST_FORMAT_GET_TYPE(f_list[x].format.id) == AST_FORMAT_TYPE_VIDEO) ? "video" :
(AST_FORMAT_GET_TYPE(f_list[x].format.id) == AST_FORMAT_TYPE_TEXT) ? "text" :
"(unk)",
f_list[x].name,
f_list[x].desc);
found = 1;
}
f_list = ast_format_list_destroy(f_list);
if (!found) {
return CLI_SHOWUSAGE;
} else {
return CLI_SUCCESS;
}
}
struct ast_codec_alias_table ast_codec_alias_table[] [static] |
struct ao2_container* format_list [static] |
Format List container, This container is never directly accessed outside of this file, and It only exists for building the format_list_array.
Definition at line 63 of file format.c.
Referenced by complete_trans_path_choice(), and handle_show_translation_path().
struct ast_format_list* format_list_array [static] |
Format List array is a read only array protected by a read write lock. This array may be used outside this file with the use of reference counting to guarantee safety for access by multiple threads.
Definition at line 67 of file format.c.
Referenced by ast_format_list_get(), and build_format_list_array().
size_t format_list_array_len = 0 [static] |
Definition at line 68 of file format.c.
Referenced by ast_format_list_get(), and build_format_list_array().
ast_rwlock_t format_list_array_lock [static] |
struct ao2_container* interfaces [static] |
Container for all the format attribute interfaces.
Definition at line 53 of file format.c.
Referenced by ast_cc_call_init(), and cc_interfaces_datastore_init().
struct ast_cli_entry my_clis[] [static] |
{
AST_CLI_DEFINE(show_codecs, "Displays a list of codecs"),
AST_CLI_DEFINE(show_codec_n, "Shows a specific codec"),
}