#include "asterisk/astobj2.h"
#include "asterisk/silk.h"
#include "asterisk/celt.h"


Go to the source code of this file.
Data Structures | |
| struct | ast_format |
| Represents a media format within Asterisk. More... | |
| struct | ast_format_attr |
| This structure contains the buffer used for format attributes. More... | |
| struct | ast_format_attr_interface |
| A format must register an attribute interface if it requires the use of the format attributes void pointer. More... | |
| struct | ast_format_list |
| Definition of supported media formats (codecs). More... | |
Defines | |
| #define | AST_FORMAT_ATTR_END -1 |
| #define | AST_FORMAT_ATTR_SIZE 64 |
| #define | AST_FORMAT_GET_TYPE(id) (((int) (id / AST_FORMAT_INC)) * AST_FORMAT_INC) |
| #define | AST_FORMAT_INC 100000 |
Enumerations | |
| enum | ast_format_cmp_res { AST_FORMAT_CMP_EQUAL = 0, AST_FORMAT_CMP_NOT_EQUAL, AST_FORMAT_CMP_SUBSET } |
| enum | ast_format_id { AST_FORMAT_G723_1 = 1 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_GSM = 2 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_ULAW = 3 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_ALAW = 4 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_G726_AAL2 = 5 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_ADPCM = 6 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_LPC10 = 7 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_G729A = 8 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SPEEX = 9 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_ILBC = 10 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_G726 = 11 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_G722 = 12 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SIREN7 = 13 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SIREN14 = 14 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_G719 = 15 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SPEEX16 = 16 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_TESTLAW = 17 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SILK = 18 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SLINEAR = 19 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SLINEAR12 = 20 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SLINEAR16 = 21 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SLINEAR24 = 22 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SLINEAR32 = 23 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SLINEAR44 = 24 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SLINEAR48 = 25 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SLINEAR96 = 26 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SLINEAR192 = 27 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SPEEX32 = 28 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_CELT = 29 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_H261 = 1 + AST_FORMAT_TYPE_VIDEO, AST_FORMAT_H263 = 2 + AST_FORMAT_TYPE_VIDEO, AST_FORMAT_H263_PLUS = 3 + AST_FORMAT_TYPE_VIDEO, AST_FORMAT_H264 = 4 + AST_FORMAT_TYPE_VIDEO, AST_FORMAT_MP4_VIDEO = 5 + AST_FORMAT_TYPE_VIDEO, AST_FORMAT_JPEG = 1 + AST_FORMAT_TYPE_IMAGE, AST_FORMAT_PNG = 2 + AST_FORMAT_TYPE_IMAGE, AST_FORMAT_T140RED = 1 + AST_FORMAT_TYPE_TEXT, AST_FORMAT_T140 = 2 + AST_FORMAT_TYPE_TEXT } |
| enum | ast_format_type { AST_FORMAT_TYPE_AUDIO = 1 * AST_FORMAT_INC, AST_FORMAT_TYPE_VIDEO = 2 * AST_FORMAT_INC, AST_FORMAT_TYPE_IMAGE = 3 * AST_FORMAT_INC, AST_FORMAT_TYPE_TEXT = 4 * AST_FORMAT_INC } |
Functions | |
| const char * | ast_codec2str (struct ast_format *format) |
| Get a name from a format. | |
| 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_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_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 *format) |
| 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. | |
Definition in file format.h.
| #define AST_FORMAT_ATTR_END -1 |
This is the value that ends a var list of format attribute key value pairs.
Definition at line 37 of file format.h.
Referenced by ast_codec_get_samples(), ast_format_rate(), celt_isset(), celt_set(), custom_celt_format(), custom_silk_format(), silk_isset(), and silk_set().
Determine what type of media a ast_format_id is.
Definition at line 128 of file format.h.
Referenced by add_sdp(), ast_codec_choose(), ast_format_cap_add_all_by_type(), ast_format_cap_get_type(), ast_format_cap_has_type(), ast_openvstream(), ast_playstream(), ast_rtp_read(), ast_translate_available_formats(), ast_writestream(), complete_trans_path_choice(), filehelper(), filestream_close(), generate_table_cost(), gtalk_new(), handle_show_translation_path(), handle_show_translation_table(), jingle_add_payloads_to_description(), jingle_new(), multiple_by_type_cb(), phone_read(), show_codecs(), transmit_connect_with_sdp(), and transmit_modify_with_sdp().
| enum ast_format_cmp_res |
Definition at line 148 of file format.h.
00148 { 00149 /*! structure 1 is identical to structure 2. */ 00150 AST_FORMAT_CMP_EQUAL = 0, 00151 /*! structure 1 contains elements not in structure 2. */ 00152 AST_FORMAT_CMP_NOT_EQUAL, 00153 /*! structure 1 is a proper subset of the elements in structure 2.*/ 00154 AST_FORMAT_CMP_SUBSET, 00155 };
| enum ast_format_id |
Definition at line 47 of file format.h.
00047 { 00048 /*! G.723.1 compression */ 00049 AST_FORMAT_G723_1 = 1 + AST_FORMAT_TYPE_AUDIO, 00050 /*! GSM compression */ 00051 AST_FORMAT_GSM = 2 + AST_FORMAT_TYPE_AUDIO, 00052 /*! Raw mu-law data (G.711) */ 00053 AST_FORMAT_ULAW = 3 + AST_FORMAT_TYPE_AUDIO, 00054 /*! Raw A-law data (G.711) */ 00055 AST_FORMAT_ALAW = 4 + AST_FORMAT_TYPE_AUDIO, 00056 /*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */ 00057 AST_FORMAT_G726_AAL2 = 5 + AST_FORMAT_TYPE_AUDIO, 00058 /*! ADPCM (IMA) */ 00059 AST_FORMAT_ADPCM = 6 + AST_FORMAT_TYPE_AUDIO, 00060 /*! LPC10, 180 samples/frame */ 00061 AST_FORMAT_LPC10 = 7 + AST_FORMAT_TYPE_AUDIO, 00062 /*! G.729A audio */ 00063 AST_FORMAT_G729A = 8 + AST_FORMAT_TYPE_AUDIO, 00064 /*! SpeeX Free Compression */ 00065 AST_FORMAT_SPEEX = 9 + AST_FORMAT_TYPE_AUDIO, 00066 /*! iLBC Free Compression */ 00067 AST_FORMAT_ILBC = 10 + AST_FORMAT_TYPE_AUDIO, 00068 /*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */ 00069 AST_FORMAT_G726 = 11 + AST_FORMAT_TYPE_AUDIO, 00070 /*! G.722 */ 00071 AST_FORMAT_G722 = 12 + AST_FORMAT_TYPE_AUDIO, 00072 /*! G.722.1 (also known as Siren7, 32kbps assumed) */ 00073 AST_FORMAT_SIREN7 = 13 + AST_FORMAT_TYPE_AUDIO, 00074 /*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */ 00075 AST_FORMAT_SIREN14 = 14 + AST_FORMAT_TYPE_AUDIO, 00076 /*! G.719 (64 kbps assumed) */ 00077 AST_FORMAT_G719 = 15 + AST_FORMAT_TYPE_AUDIO, 00078 /*! SpeeX Wideband (16kHz) Free Compression */ 00079 AST_FORMAT_SPEEX16 = 16 + AST_FORMAT_TYPE_AUDIO, 00080 /*! Raw mu-law data (G.711) */ 00081 AST_FORMAT_TESTLAW = 17 + AST_FORMAT_TYPE_AUDIO, 00082 /*! SILK format */ 00083 AST_FORMAT_SILK = 18 + AST_FORMAT_TYPE_AUDIO, 00084 /*! Raw 16-bit Signed Linear (8000 Hz) PCM */ 00085 AST_FORMAT_SLINEAR = 19 + AST_FORMAT_TYPE_AUDIO, 00086 /*! Raw 16-bit Signed Linear (12000 Hz) PCM */ 00087 AST_FORMAT_SLINEAR12 = 20 + AST_FORMAT_TYPE_AUDIO, 00088 /*! Raw 16-bit Signed Linear (16000 Hz) PCM */ 00089 AST_FORMAT_SLINEAR16 = 21 + AST_FORMAT_TYPE_AUDIO, 00090 /*! Raw 16-bit Signed Linear (24000 Hz) PCM */ 00091 AST_FORMAT_SLINEAR24 = 22 + AST_FORMAT_TYPE_AUDIO, 00092 /*! Raw 16-bit Signed Linear (32000 Hz) PCM */ 00093 AST_FORMAT_SLINEAR32 = 23 + AST_FORMAT_TYPE_AUDIO, 00094 /*! Raw 16-bit Signed Linear (44100 Hz) PCM just because we can. */ 00095 AST_FORMAT_SLINEAR44 = 24 + AST_FORMAT_TYPE_AUDIO, 00096 /*! Raw 16-bit Signed Linear (48000 Hz) PCM */ 00097 AST_FORMAT_SLINEAR48 = 25 + AST_FORMAT_TYPE_AUDIO, 00098 /*! Raw 16-bit Signed Linear (96000 Hz) PCM */ 00099 AST_FORMAT_SLINEAR96 = 26 + AST_FORMAT_TYPE_AUDIO, 00100 /*! Raw 16-bit Signed Linear (192000 Hz) PCM. maybe we're taking this too far. */ 00101 AST_FORMAT_SLINEAR192 = 27 + AST_FORMAT_TYPE_AUDIO, 00102 AST_FORMAT_SPEEX32 = 28 + AST_FORMAT_TYPE_AUDIO, 00103 AST_FORMAT_CELT = 29 + AST_FORMAT_TYPE_AUDIO, 00104 00105 /*! H.261 Video */ 00106 AST_FORMAT_H261 = 1 + AST_FORMAT_TYPE_VIDEO, 00107 /*! H.263 Video */ 00108 AST_FORMAT_H263 = 2 + AST_FORMAT_TYPE_VIDEO, 00109 /*! H.263+ Video */ 00110 AST_FORMAT_H263_PLUS = 3 + AST_FORMAT_TYPE_VIDEO, 00111 /*! H.264 Video */ 00112 AST_FORMAT_H264 = 4 + AST_FORMAT_TYPE_VIDEO, 00113 /*! MPEG4 Video */ 00114 AST_FORMAT_MP4_VIDEO = 5 + AST_FORMAT_TYPE_VIDEO, 00115 00116 /*! JPEG Images */ 00117 AST_FORMAT_JPEG = 1 + AST_FORMAT_TYPE_IMAGE, 00118 /*! PNG Images */ 00119 AST_FORMAT_PNG = 2 + AST_FORMAT_TYPE_IMAGE, 00120 00121 /*! T.140 RED Text format RFC 4103 */ 00122 AST_FORMAT_T140RED = 1 + AST_FORMAT_TYPE_TEXT, 00123 /*! T.140 Text format - ITU T.140, RFC 4103 */ 00124 AST_FORMAT_T140 = 2 + AST_FORMAT_TYPE_TEXT, 00125 };
| enum ast_format_type |
Definition at line 40 of file format.h.
00040 { 00041 AST_FORMAT_TYPE_AUDIO = 1 * AST_FORMAT_INC, 00042 AST_FORMAT_TYPE_VIDEO = 2 * AST_FORMAT_INC, 00043 AST_FORMAT_TYPE_IMAGE = 3 * AST_FORMAT_INC, 00044 AST_FORMAT_TYPE_TEXT = 4 * AST_FORMAT_INC, 00045 };
| 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().
00714 { 00715 int x; 00716 const char *ret = "unknown"; 00717 size_t f_len; 00718 const struct ast_format_list *f_list = ast_format_list_get(&f_len); 00719 00720 for (x = 0; x < f_len; x++) { 00721 if (ast_format_cmp(&f_list[x].format, format) == AST_FORMAT_CMP_EQUAL) { 00722 ret = f_list[x].desc; 00723 break; 00724 } 00725 } 00726 f_list = ast_format_list_destroy(f_list); 00727 return ret; 00728 }
| 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; |
Definition at line 194 of file format.c.
References format_set_helper().
Referenced by custom_celt_format(), and custom_silk_format().
00195 { 00196 va_list ap; 00197 va_start(ap, format); 00198 format_set_helper(format, ap); 00199 va_end(ap); 00200 00201 return format; 00202 }
| 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, ast_format_attr_interface::id, interface_ao2_wrapper::id, interface_ao2_wrapper::interface, load_format_config(), LOG_WARNING, OBJ_NOLOCK, and OBJ_POINTER.
Referenced by load_module().
01348 { 01349 int x; 01350 size_t f_len; 01351 const struct ast_format_list *f_list; 01352 struct interface_ao2_wrapper *wrapper; 01353 struct interface_ao2_wrapper tmp_wrapper = { 01354 .id = interface->id, 01355 }; 01356 01357 /* 01358 * Grab the write lock before checking for duplicates in 01359 * anticipation of adding a new interface and to prevent a 01360 * duplicate from sneaking in between the check and add. 01361 */ 01362 ao2_wrlock(interfaces); 01363 01364 /* check for duplicates first*/ 01365 if ((wrapper = ao2_find(interfaces, &tmp_wrapper, (OBJ_POINTER | OBJ_NOLOCK)))) { 01366 ao2_unlock(interfaces); 01367 ast_log(LOG_WARNING, "Can not register attribute interface for format id %d, interface already exists.\n", interface->id); 01368 ao2_ref(wrapper, -1); 01369 return -1; 01370 } 01371 01372 wrapper = ao2_alloc_options(sizeof(*wrapper), NULL, AO2_ALLOC_OPT_LOCK_RWLOCK); 01373 if (!wrapper) { 01374 ao2_unlock(interfaces); 01375 return -1; 01376 } 01377 01378 wrapper->interface = interface; 01379 wrapper->id = interface->id; 01380 01381 /* The write lock is already held. */ 01382 ao2_link_flags(interfaces, wrapper, OBJ_NOLOCK); 01383 ao2_unlock(interfaces); 01384 01385 ao2_ref(wrapper, -1); 01386 01387 /* This will find all custom formats in codecs.conf for this new registered interface */ 01388 load_format_config(); 01389 01390 /* update the RTP engine to all custom formats created for this interface */ 01391 f_list = ast_format_list_get(&f_len); 01392 for (x = 0; x < f_len; x++) { 01393 if (f_list[x].format.id == tmp_wrapper.id) { 01394 ast_rtp_engine_load_format(&f_list[x].format); 01395 } 01396 } 01397 f_list = ast_format_list_destroy(f_list); 01398 return 0; 01399 }
| 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, ast_format_attr_interface::id, interface_ao2_wrapper::id, interface_ao2_wrapper::interface, load_format_config(), OBJ_POINTER, and OBJ_UNLINK.
Referenced by load_module(), and unload_module().
01402 { 01403 int x; 01404 size_t f_len; 01405 const struct ast_format_list *f_list; 01406 struct interface_ao2_wrapper *wrapper; 01407 struct interface_ao2_wrapper tmp_wrapper = { 01408 .id = interface->id, 01409 }; 01410 01411 if (!(wrapper = ao2_find(interfaces, &tmp_wrapper, (OBJ_POINTER | OBJ_UNLINK)))) { 01412 return -1; 01413 } 01414 01415 ao2_wrlock(wrapper); 01416 wrapper->interface = NULL; 01417 ao2_unlock(wrapper); 01418 01419 ao2_ref(wrapper, -1); 01420 01421 /* update the RTP engine to remove all custom formats created for this interface */ 01422 f_list = ast_format_list_get(&f_len); 01423 for (x = 0; x < f_len; x++) { 01424 if (f_list[x].format.id == tmp_wrapper.id) { 01425 ast_rtp_engine_unload_format(&f_list[x].format); 01426 } 01427 } 01428 01429 /* This will remove all custom formats previously created for this interface */ 01430 load_format_config(); 01431 f_list = ast_format_list_destroy(f_list); 01432 return 0; 01433 }
| 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().
00334 { 00335 if (format1->id != format2->id) { 00336 return AST_FORMAT_CMP_NOT_EQUAL; 00337 } 00338 00339 return format_cmp_helper(format1, format2); 00340 }
| 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().
| 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().
00479 { 00480 switch (src) { 00481 /*! G.723.1 compression */ 00482 case (1ULL << 0): 00483 return ast_format_set(dst, AST_FORMAT_G723_1, 0); 00484 /*! GSM compression */ 00485 case (1ULL << 1): 00486 return ast_format_set(dst, AST_FORMAT_GSM, 0); 00487 /*! Raw mu-law data (G.711) */ 00488 case (1ULL << 2): 00489 return ast_format_set(dst, AST_FORMAT_ULAW, 0); 00490 /*! Raw A-law data (G.711) */ 00491 case (1ULL << 3): 00492 return ast_format_set(dst, AST_FORMAT_ALAW, 0); 00493 /*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */ 00494 case (1ULL << 4): 00495 return ast_format_set(dst, AST_FORMAT_G726_AAL2, 0); 00496 /*! ADPCM (IMA) */ 00497 case (1ULL << 5): 00498 return ast_format_set(dst, AST_FORMAT_ADPCM, 0); 00499 /*! Raw 16-bit Signed Linear (8000 Hz) PCM */ 00500 case (1ULL << 6): 00501 return ast_format_set(dst, AST_FORMAT_SLINEAR, 0); 00502 /*! LPC10, 180 samples/frame */ 00503 case (1ULL << 7): 00504 return ast_format_set(dst, AST_FORMAT_LPC10, 0); 00505 /*! G.729A audio */ 00506 case (1ULL << 8): 00507 return ast_format_set(dst, AST_FORMAT_G729A, 0); 00508 /*! SpeeX Free Compression */ 00509 case (1ULL << 9): 00510 return ast_format_set(dst, AST_FORMAT_SPEEX, 0); 00511 /*! iLBC Free Compression */ 00512 case (1ULL << 10): 00513 return ast_format_set(dst, AST_FORMAT_ILBC, 0); 00514 /*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */ 00515 case (1ULL << 11): 00516 return ast_format_set(dst, AST_FORMAT_G726, 0); 00517 /*! G.722 */ 00518 case (1ULL << 12): 00519 return ast_format_set(dst, AST_FORMAT_G722, 0); 00520 /*! G.722.1 (also known as Siren7, 32kbps assumed) */ 00521 case (1ULL << 13): 00522 return ast_format_set(dst, AST_FORMAT_SIREN7, 0); 00523 /*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */ 00524 case (1ULL << 14): 00525 return ast_format_set(dst, AST_FORMAT_SIREN14, 0); 00526 /*! Raw 16-bit Signed Linear (16000 Hz) PCM */ 00527 case (1ULL << 15): 00528 return ast_format_set(dst, AST_FORMAT_SLINEAR16, 0); 00529 /*! G.719 (64 kbps assumed) */ 00530 case (1ULL << 32): 00531 return ast_format_set(dst, AST_FORMAT_G719, 0); 00532 /*! SpeeX Wideband (16kHz) Free Compression */ 00533 case (1ULL << 33): 00534 return ast_format_set(dst, AST_FORMAT_SPEEX16, 0); 00535 /*! Raw mu-law data (G.711) */ 00536 case (1ULL << 47): 00537 return ast_format_set(dst, AST_FORMAT_TESTLAW, 0); 00538 00539 /*! H.261 Video */ 00540 case (1ULL << 18): 00541 return ast_format_set(dst, AST_FORMAT_H261, 0); 00542 /*! H.263 Video */ 00543 case (1ULL << 19): 00544 return ast_format_set(dst, AST_FORMAT_H263, 0); 00545 /*! H.263+ Video */ 00546 case (1ULL << 20): 00547 return ast_format_set(dst, AST_FORMAT_H263_PLUS, 0); 00548 /*! H.264 Video */ 00549 case (1ULL << 21): 00550 return ast_format_set(dst, AST_FORMAT_H264, 0); 00551 /*! MPEG4 Video */ 00552 case (1ULL << 22): 00553 return ast_format_set(dst, AST_FORMAT_MP4_VIDEO, 0); 00554 00555 /*! JPEG Images */ 00556 case (1ULL << 16): 00557 return ast_format_set(dst, AST_FORMAT_JPEG, 0); 00558 /*! PNG Images */ 00559 case (1ULL << 17): 00560 return ast_format_set(dst, AST_FORMAT_PNG, 0); 00561 00562 /*! T.140 RED Text format RFC 4103 */ 00563 case (1ULL << 26): 00564 return ast_format_set(dst, AST_FORMAT_T140RED, 0); 00565 /*! T.140 Text format - ITU T.140, RFC 4103 */ 00566 case (1ULL << 27): 00567 return ast_format_set(dst, AST_FORMAT_T140, 0); 00568 } 00569 ast_format_clear(dst); 00570 return NULL; 00571 }
| 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().
00282 { 00283 int res = 0; 00284 struct interface_ao2_wrapper *wrapper; 00285 00286 if (!(wrapper = find_interface(format))) { 00287 return -1; 00288 } 00289 ao2_rdlock(wrapper); 00290 if (!wrapper->interface || 00291 !wrapper->interface->format_attr_get_val) { 00292 00293 ao2_unlock(wrapper); 00294 ao2_ref(wrapper, -1); 00295 return -1; 00296 } 00297 00298 res = wrapper->interface->format_attr_get_val(&format->fattr, key, value); 00299 00300 ao2_unlock(wrapper); 00301 ao2_ref(wrapper, -1); 00302 00303 return res; 00304 }
| 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().
00097 { 00098 return format->fattr.rtp_marker_bit; 00099 }
| 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_translate(), drop_translator(), iax2_send(), and socket_process_helper().
00574 { 00575 struct ast_format dst; 00576 if (ast_format_from_old_bitfield(&dst, src)) { 00577 return dst.id; 00578 } 00579 return 0; 00580 }
| 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().
00377 { 00378 switch (id) { 00379 /*! G.723.1 compression */ 00380 case AST_FORMAT_G723_1: 00381 return (1ULL << 0); 00382 /*! GSM compression */ 00383 case AST_FORMAT_GSM: 00384 return (1ULL << 1); 00385 /*! Raw mu-law data (G.711) */ 00386 case AST_FORMAT_ULAW: 00387 return (1ULL << 2); 00388 /*! Raw A-law data (G.711) */ 00389 case AST_FORMAT_ALAW: 00390 return (1ULL << 3); 00391 /*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */ 00392 case AST_FORMAT_G726_AAL2: 00393 return (1ULL << 4); 00394 /*! ADPCM (IMA) */ 00395 case AST_FORMAT_ADPCM: 00396 return (1ULL << 5); 00397 /*! Raw 16-bit Signed Linear (8000 Hz) PCM */ 00398 case AST_FORMAT_SLINEAR: 00399 return (1ULL << 6); 00400 /*! LPC10, 180 samples/frame */ 00401 case AST_FORMAT_LPC10: 00402 return (1ULL << 7); 00403 /*! G.729A audio */ 00404 case AST_FORMAT_G729A: 00405 return (1ULL << 8); 00406 /*! SpeeX Free Compression */ 00407 case AST_FORMAT_SPEEX: 00408 return (1ULL << 9); 00409 /*! iLBC Free Compression */ 00410 case AST_FORMAT_ILBC: 00411 return (1ULL << 10); 00412 /*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */ 00413 case AST_FORMAT_G726: 00414 return (1ULL << 11); 00415 /*! G.722 */ 00416 case AST_FORMAT_G722: 00417 return (1ULL << 12); 00418 /*! G.722.1 (also known as Siren7, 32kbps assumed) */ 00419 case AST_FORMAT_SIREN7: 00420 return (1ULL << 13); 00421 /*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */ 00422 case AST_FORMAT_SIREN14: 00423 return (1ULL << 14); 00424 /*! Raw 16-bit Signed Linear (16000 Hz) PCM */ 00425 case AST_FORMAT_SLINEAR16: 00426 return (1ULL << 15); 00427 /*! G.719 (64 kbps assumed) */ 00428 case AST_FORMAT_G719: 00429 return (1ULL << 32); 00430 /*! SpeeX Wideband (16kHz) Free Compression */ 00431 case AST_FORMAT_SPEEX16: 00432 return (1ULL << 33); 00433 /*! Raw mu-law data (G.711) */ 00434 case AST_FORMAT_TESTLAW: 00435 return (1ULL << 47); 00436 00437 /*! H.261 Video */ 00438 case AST_FORMAT_H261: 00439 return (1ULL << 18); 00440 /*! H.263 Video */ 00441 case AST_FORMAT_H263: 00442 return (1ULL << 19); 00443 /*! H.263+ Video */ 00444 case AST_FORMAT_H263_PLUS: 00445 return (1ULL << 20); 00446 /*! H.264 Video */ 00447 case AST_FORMAT_H264: 00448 return (1ULL << 21); 00449 /*! MPEG4 Video */ 00450 case AST_FORMAT_MP4_VIDEO: 00451 return (1ULL << 22); 00452 00453 /*! JPEG Images */ 00454 case AST_FORMAT_JPEG: 00455 return (1ULL << 16); 00456 /*! PNG Images */ 00457 case AST_FORMAT_PNG: 00458 return (1ULL << 17); 00459 00460 /*! T.140 RED Text format RFC 4103 */ 00461 case AST_FORMAT_T140RED: 00462 return (1ULL << 26); 00463 /*! T.140 Text format - ITU T.140, RFC 4103 */ 00464 case AST_FORMAT_T140: 00465 return (1ULL << 27); 00466 default: 00467 return 0; /* not supported by old bitfield. */ 00468 } 00469 00470 return 0; 00471 00472 }
| 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().
00583 { 00584 if (format->id == AST_FORMAT_SLINEAR || 00585 format->id == AST_FORMAT_SLINEAR12 || 00586 format->id == AST_FORMAT_SLINEAR16 || 00587 format->id == AST_FORMAT_SLINEAR24 || 00588 format->id == AST_FORMAT_SLINEAR32 || 00589 format->id == AST_FORMAT_SLINEAR44 || 00590 format->id == AST_FORMAT_SLINEAR48 || 00591 format->id == AST_FORMAT_SLINEAR96 || 00592 format->id == AST_FORMAT_SLINEAR192) { 00593 return 1; 00594 } 00595 return 0; 00596 }
| 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);
-1, The format key value pairs are _NOT_ within the capabilities of this structure.
Definition at line 270 of file format.c.
References format_isset_helper().
Referenced by ast_codec_get_samples(), and ast_format_rate().
00271 { 00272 va_list ap; 00273 int res; 00274 00275 va_start(ap, format); 00276 res = format_isset_helper(format, ap); 00277 va_end(ap); 00278 return res; 00279 }
| 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().
00367 { 00368 if (format1->id != format2->id) { 00369 return -1; 00370 } 00371 result->id = format1->id; 00372 return format_joint_helper(format1, format2, result); 00373 }
| 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 992 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().
00993 { 00994 ao2_ref((void *) list, -1); 00995 return NULL; 00996 }
| 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 982 of file format.c.
References ao2_ref, ast_rwlock_rdlock, ast_rwlock_unlock, 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().
00983 { 00984 struct ast_format_list *list; 00985 ast_rwlock_rdlock(&format_list_array_lock); 00986 ao2_ref(format_list_array, 1); 00987 list = format_list_array; 00988 *size = format_list_array_len; 00989 ast_rwlock_unlock(&format_list_array_lock); 00990 return list; 00991 }
| 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().
00731 { 00732 switch (format->id) { 00733 case AST_FORMAT_SLINEAR12: 00734 return 12000; 00735 case AST_FORMAT_SLINEAR24: 00736 return 24000; 00737 case AST_FORMAT_SLINEAR32: 00738 return 32000; 00739 case AST_FORMAT_SLINEAR44: 00740 return 44100; 00741 case AST_FORMAT_SLINEAR48: 00742 return 48000; 00743 case AST_FORMAT_SLINEAR96: 00744 return 96000; 00745 case AST_FORMAT_SLINEAR192: 00746 return 192000; 00747 case AST_FORMAT_G722: 00748 case AST_FORMAT_SLINEAR16: 00749 case AST_FORMAT_SIREN7: 00750 case AST_FORMAT_SPEEX16: 00751 return 16000; 00752 case AST_FORMAT_SIREN14: 00753 case AST_FORMAT_SPEEX32: 00754 return 32000; 00755 case AST_FORMAT_G719: 00756 return 48000; 00757 case AST_FORMAT_SILK: 00758 if (!(ast_format_isset(format, 00759 SILK_ATTR_KEY_SAMP_RATE, 00760 SILK_ATTR_VAL_SAMP_24KHZ, 00761 AST_FORMAT_ATTR_END))) { 00762 return 24000; 00763 } else if (!(ast_format_isset(format, 00764 SILK_ATTR_KEY_SAMP_RATE, 00765 SILK_ATTR_VAL_SAMP_16KHZ, 00766 AST_FORMAT_ATTR_END))) { 00767 return 16000; 00768 } else if (!(ast_format_isset(format, 00769 SILK_ATTR_KEY_SAMP_RATE, 00770 SILK_ATTR_VAL_SAMP_12KHZ, 00771 AST_FORMAT_ATTR_END))) { 00772 return 12000; 00773 } else { 00774 return 8000; 00775 } 00776 case AST_FORMAT_CELT: 00777 { 00778 int samplerate; 00779 if (!(ast_format_get_value(format, 00780 CELT_ATTR_KEY_SAMP_RATE, 00781 &samplerate))) { 00782 return samplerate; 00783 } 00784 } 00785 default: 00786 return 8000; 00787 } 00788 }
| 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().
00147 { 00148 struct interface_ao2_wrapper *wrapper; 00149 00150 if (!(wrapper = find_interface(format))) { 00151 return; 00152 } 00153 00154 ao2_rdlock(wrapper); 00155 if (!(wrapper->interface || !wrapper->interface->format_attr_sdp_generate)) { 00156 ao2_unlock(wrapper); 00157 ao2_ref(wrapper, -1); 00158 return; 00159 } 00160 00161 wrapper->interface->format_attr_sdp_generate(&format->fattr, payload, str); 00162 00163 ao2_unlock(wrapper); 00164 ao2_ref(wrapper, -1); 00165 }
| 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 |
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().
00123 { 00124 struct interface_ao2_wrapper *wrapper; 00125 int res; 00126 00127 if (!(wrapper = find_interface(format))) { 00128 return 0; 00129 } 00130 00131 ao2_rdlock(wrapper); 00132 if (!(wrapper->interface || !wrapper->interface->format_attr_sdp_parse)) { 00133 ao2_unlock(wrapper); 00134 ao2_ref(wrapper, -1); 00135 return 0; 00136 } 00137 00138 res = wrapper->interface->format_attr_sdp_parse(&format->fattr, attributes); 00139 00140 ao2_unlock(wrapper); 00141 ao2_ref(wrapper, -1); 00142 00143 return res; 00144 }
| 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; |
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_set_helper(), and ast_format::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_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().
00205 { 00206 /* initialize the structure before setting it. */ 00207 ast_format_clear(format); 00208 00209 format->id = id; 00210 00211 if (set_attributes) { 00212 va_list ap; 00213 va_start(ap, set_attributes); 00214 format_set_helper(format, ap); 00215 va_end(ap); 00216 } 00217 00218 return format; 00219 }
| 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().
00092 { 00093 format->fattr.rtp_marker_bit = 1; 00094 }
| 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().
00599 { 00600 if (rate >= 192000) { 00601 return AST_FORMAT_SLINEAR192; 00602 } else if (rate >= 96000) { 00603 return AST_FORMAT_SLINEAR96; 00604 } else if (rate >= 48000) { 00605 return AST_FORMAT_SLINEAR48; 00606 } else if (rate >= 44100) { 00607 return AST_FORMAT_SLINEAR44; 00608 } else if (rate >= 32000) { 00609 return AST_FORMAT_SLINEAR32; 00610 } else if (rate >= 24000) { 00611 return AST_FORMAT_SLINEAR24; 00612 } else if (rate >= 16000) { 00613 return AST_FORMAT_SLINEAR16; 00614 } else if (rate >= 12000) { 00615 return AST_FORMAT_SLINEAR12; 00616 } 00617 return AST_FORMAT_SLINEAR; 00618 }
| 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().
00474 { 00475 return ast_format_id_to_old_bitfield(format->id); 00476 }
| 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().
00694 { 00695 int x; 00696 size_t f_len; 00697 const struct ast_format_list *f_list = ast_format_list_get(&f_len); 00698 00699 for (x = 0; x < f_len; x++) { 00700 if (!strcasecmp(f_list[x].name, name) || 00701 !strcasecmp(f_list[x].name, ast_expand_codec_alias(name))) { 00702 00703 ast_format_copy(result, &f_list[x].format); 00704 f_list = ast_format_list_destroy(f_list); 00705 return result; 00706 } 00707 } 00708 f_list = ast_format_list_destroy(f_list); 00709 00710 return NULL; 00711 }
| 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().
00621 { 00622 int x; 00623 const char *ret = "unknown"; 00624 size_t f_len; 00625 const struct ast_format_list *f_list = ast_format_list_get(&f_len); 00626 for (x = 0; x < f_len; x++) { 00627 if (ast_format_cmp(&f_list[x].format, format) == AST_FORMAT_CMP_EQUAL) { 00628 ret = f_list[x].name; 00629 break; 00630 } 00631 } 00632 f_list = ast_format_list_destroy(f_list); 00633 return ret; 00634 }
| 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) | |
| id | 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().
00638 { 00639 int x; 00640 unsigned len; 00641 char *start, *end = buf; 00642 size_t f_len; 00643 const struct ast_format_list *f_list = ast_format_list_get(&f_len); 00644 00645 if (!size) { 00646 f_list = ast_format_list_destroy(f_list); 00647 return buf; 00648 } 00649 snprintf(end, size, "("); 00650 len = strlen(end); 00651 end += len; 00652 size -= len; 00653 start = end; 00654 for (x = 0; x < f_len; x++) { 00655 if (f_list[x].format.id == id) { 00656 snprintf(end, size, "%s|", f_list[x].name); 00657 len = strlen(end); 00658 end += len; 00659 size -= len; 00660 } 00661 } 00662 if (start == end) { 00663 ast_copy_string(start, "nothing)", size); 00664 } else if (size > 1) { 00665 *(end - 1) = ')'; 00666 } 00667 f_list = ast_format_list_destroy(f_list); 00668 return buf; 00669 }
1.5.6