format.h File Reference

Media Format API. More...

#include "asterisk/codec.h"

Include dependency graph for format.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_format_interface
 Optional format interface to extend format operations. More...

Defines

#define ast_format_interface_register(codec, interface)   __ast_format_interface_register(codec, interface, ast_module_info->self)
 Register a format interface for use with the provided codec.

Enumerations

enum  ast_format_cmp_res { AST_FORMAT_CMP_EQUAL = 0, AST_FORMAT_CMP_NOT_EQUAL, AST_FORMAT_CMP_SUBSET }
 Format comparison results. More...

Functions

int __ast_format_interface_register (const char *codec, const struct ast_format_interface *interface, struct ast_module *mod)
 Register a format interface for use with the provided codec.
struct ast_formatast_format_attribute_set (const struct ast_format *format, const char *name, const char *value)
 Set an attribute on a format to a specific value.
int ast_format_can_be_smoothed (const struct ast_format *format)
 Get whether or not the format can be smoothed.
struct ast_formatast_format_clone (const struct ast_format *format)
 Clone an existing media format so it can be modified.
enum ast_format_cmp_res ast_format_cmp (const struct ast_format *format1, const struct ast_format *format2)
 Compare two formats.
struct ast_formatast_format_create (struct ast_codec *codec)
 Create a new media format.
struct ast_formatast_format_create_named (const char *format_name, struct ast_codec *codec)
 Create a new media format with a specific name.
unsigned int ast_format_determine_length (const struct ast_format *format, unsigned int samples)
 Get the length (in milliseconds) for the format with a given number of samples.
void ast_format_generate_sdp_fmtp (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.
void * ast_format_get_attribute_data (const struct ast_format *format)
 Get the attribute data on a format.
struct ast_codecast_format_get_codec (const struct ast_format *format)
 Get the codec associated with a format.
unsigned int ast_format_get_codec_id (const struct ast_format *format)
 Get the codec identifier associated with a format.
const char * ast_format_get_codec_name (const struct ast_format *format)
 Get the codec name associated with a format.
unsigned int ast_format_get_default_ms (const struct ast_format *format)
 Get the default framing size (in milliseconds) for a format.
unsigned int ast_format_get_maximum_ms (const struct ast_format *format)
 Get the maximum amount of media carried in this format.
unsigned int ast_format_get_minimum_bytes (const struct ast_format *format)
 Get the minimum number of bytes expected in a frame for this format.
unsigned int ast_format_get_minimum_ms (const struct ast_format *format)
 Get the minimum amount of media carried in this format.
const char * ast_format_get_name (const struct ast_format *format)
 Get the name associated with a format.
unsigned int ast_format_get_sample_rate (const struct ast_format *format)
 Get the sample rate of a media format.
enum ast_media_type ast_format_get_type (const struct ast_format *format)
 Get the media type of a format.
int ast_format_init (void)
 Initialize media format support.
struct ast_formatast_format_joint (const struct ast_format *format1, const struct ast_format *format2)
 Get a common joint capability between two formats.
struct ast_formatast_format_parse_sdp_fmtp (const 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 stasis_message_typeast_format_register_type (void)
 Get the message type used for signaling a format registration.
void ast_format_set_attribute_data (struct ast_format *format, void *attribute_data)
 Set the attribute data on a format.
struct stasis_message_typeast_format_unregister_type (void)
 Get the message type used for signaling a format unregistration.


Detailed Description

Media Format API.

Author:
Joshua Colp <jcolp@digium.com>

Definition in file format.h.


Define Documentation

#define ast_format_interface_register ( codec,
interface   )     __ast_format_interface_register(codec, interface, ast_module_info->self)

Register a format interface for use with the provided codec.

Parameters:
codec The name of codec the interface is applicable to
interface A pointer to the interface implementation
Return values:
0 success
-1 failure

Definition at line 250 of file format.h.

Referenced by load_module().


Enumeration Type Documentation

Format comparison results.

Enumerator:
AST_FORMAT_CMP_EQUAL  Both formats are equivalent to eachother
AST_FORMAT_CMP_NOT_EQUAL  Both formats are completely different and not the same in any way
AST_FORMAT_CMP_SUBSET  Both formats are similar but not equivalent

Definition at line 34 of file format.h.

00034                         {
00035    /*! Both formats are equivalent to eachother */
00036    AST_FORMAT_CMP_EQUAL = 0,
00037    /*! Both formats are completely different and not the same in any way */
00038    AST_FORMAT_CMP_NOT_EQUAL,
00039    /*! Both formats are similar but not equivalent */
00040    AST_FORMAT_CMP_SUBSET,
00041 };


Function Documentation

int __ast_format_interface_register ( const char *  codec,
const struct ast_format_interface interface,
struct ast_module mod 
)

Register a format interface for use with the provided codec.

Parameters:
codec The name of codec the interface is applicable to
interface A pointer to the interface implementation
mod The module this format interface is provided by
Return values:
0 success
-1 failure

Definition at line 134 of file format.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_find, ao2_link_flags, ao2_ref, ast_log, ast_verb, format_interface::codec, ast_format_interface::format_clone, ast_format_interface::format_destroy, format_interface::interface, lock, LOG_ERROR, NULL, OBJ_NOLOCK, OBJ_SEARCH_KEY, and SCOPED_AO2WRLOCK.

00135 {
00136    SCOPED_AO2WRLOCK(lock, interfaces);
00137    struct format_interface *format_interface;
00138 
00139    if (!interface->format_clone || !interface->format_destroy) {
00140       ast_log(LOG_ERROR, "Format interface for codec '%s' does not implement required callbacks\n", codec);
00141       return -1;
00142    }
00143 
00144    format_interface = ao2_find(interfaces, codec, OBJ_SEARCH_KEY | OBJ_NOLOCK);
00145    if (format_interface) {
00146       ast_log(LOG_ERROR, "A format interface is already present for codec '%s'\n", codec);
00147       ao2_ref(format_interface, -1);
00148       return -1;
00149    }
00150 
00151    format_interface = ao2_alloc_options(sizeof(*format_interface) + strlen(codec) + 1,
00152       NULL, AO2_ALLOC_OPT_LOCK_NOLOCK);
00153    if (!format_interface) {
00154       return -1;
00155    }
00156    format_interface->interface = interface;
00157    strcpy(format_interface->codec, codec); /* Safe */
00158 
00159    ao2_link_flags(interfaces, format_interface, OBJ_NOLOCK);
00160    ao2_ref(format_interface, -1);
00161 
00162    ast_verb(2, "Registered format interface for codec '%s'\n", codec);
00163 
00164    return 0;
00165 }

struct ast_format* ast_format_attribute_set ( const struct ast_format format,
const char *  name,
const char *  value 
) [read]

Set an attribute on a format to a specific value.

Parameters:
format The format to set the attribute on
name Attribute name
value Attribute value
Return values:
non-NULL success
NULL failure

Definition at line 279 of file format.c.

References ao2_bump, ao2_find, ao2_ref, ast_format::codec, ast_format_interface::format_attribute_set, format_interface::interface, ast_format::interface, ast_codec::name, and OBJ_SEARCH_KEY.

Referenced by AST_TEST_DEFINE().

00280 {
00281    const struct ast_format_interface *interface = format->interface;
00282 
00283    if (!interface) {
00284       struct format_interface *format_interface = ao2_find(interfaces, format->codec->name, OBJ_SEARCH_KEY);
00285       if (format_interface) {
00286          interface = format_interface->interface;
00287          ao2_ref(format_interface, -1);
00288       }
00289    }
00290 
00291    if (!interface || !interface->format_attribute_set) {
00292       return ao2_bump((struct ast_format*)format);
00293    }
00294 
00295    return interface->format_attribute_set(format, name, value);
00296 }

int ast_format_can_be_smoothed ( const struct ast_format format  ) 

Get whether or not the format can be smoothed.

Parameters:
format The media format
Return values:
0 the format cannot be smoothed
1 the format can be smoothed

Definition at line 346 of file format.c.

References ast_format::codec, and ast_codec::smooth.

Referenced by ast_rtp_write().

00347 {
00348    return format->codec->smooth;
00349 }

struct ast_format* ast_format_clone ( const struct ast_format format  )  [read]

Clone an existing media format so it can be modified.

Parameters:
format The existing media format
Note:
The returned format is a new ao2 object. It must be released using ao2_cleanup.
Return values:
non-NULL success
NULL failure

Definition at line 211 of file format.c.

References ao2_ref, ast_format_create_named(), ast_format::codec, ast_format_interface::format_clone, ast_format::interface, ast_format::name, and NULL.

Referenced by AST_TEST_DEFINE(), celt_getjoint(), celt_parse_sdp_fmtp(), celt_set(), h263_getjoint(), h263_parse_sdp_fmtp(), h264_getjoint(), h264_parse_sdp_fmtp(), opus_getjoint(), opus_parse_sdp_fmtp(), opus_set(), silk_getjoint(), silk_parse_sdp_fmtp(), silk_set(), test_core_format_attribute_set(), test_core_format_get_joint(), and test_core_format_parse_sdp_fmtp().

00212 {
00213    struct ast_format *cloned = ast_format_create_named(format->name, format->codec);
00214 
00215    if (!cloned) {
00216       return NULL;
00217    }
00218 
00219    if (cloned->interface && cloned->interface->format_clone(format, cloned)) {
00220       ao2_ref(cloned, -1);
00221       return NULL;
00222    }
00223 
00224    return cloned;
00225 }

enum ast_format_cmp_res ast_format_cmp ( const struct ast_format format1,
const struct ast_format format2 
)

Compare two formats.

Return values:
ast_format_cmp_res representing the result of comparing format1 and format2.
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 232 of file format.c.

References AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, ast_format::codec, ast_format_interface::format_cmp, ast_format::interface, and NULL.

Referenced by __ast_read(), __ast_smoother_feed(), add_codec_to_sdp(), add_tcodec_to_sdp(), add_vcodec_to_sdp(), adsi_careful_send(), alarmreceiver_exec(), ast_bridge_channel_restore_formats(), ast_channel_make_compatible_helper(), ast_dsp_process(), ast_dsp_silence_noise_with_energy(), ast_format_cache_is_slinear(), ast_format_cap_get_compatible_format(), ast_format_cap_get_format_framing(), ast_format_cap_iscompatible_format(), ast_format_compatibility_format2bitfield(), ast_format_joint(), ast_frame_slinear_sum(), ast_read_generator_actions(), ast_read_image(), ast_rtp_codecs_payload_code(), ast_rtp_codecs_payloads_set_rtpmap_type_rate(), ast_rtp_engine_unload_format(), ast_rtp_lookup_mime_subtype2(), ast_rtp_lookup_sample_rate2(), ast_rtp_raw_write(), ast_rtp_read(), ast_rtp_write(), ast_set_read_format_path(), ast_slinfactory_feed(), AST_TEST_DEFINE(), ast_write(), ast_writestream(), au_seek(), audiohook_list_translate_to_native(), audiohook_list_translate_to_slin(), audiohook_read_frame_helper(), background_detect_exec(), codec_ast2skinny(), conf_run(), dahdi_read(), dahdi_write(), fax_detect_framehook(), fax_gateway_framehook(), filehelper(), generic_fax_exec(), iax2_send(), iax_frame_wrap(), jack_hook_callback(), jingle_add_payloads_to_description(), make_silence(), measurenoise(), misdn_write(), moh_files_generator(), ooh323_convertAsteriskCapToH323Cap(), ooh323_rtp_read(), ooh323c_set_capability(), ooh323c_set_capability_for_call(), ooh323c_start_transmit_channel(), pcm_read(), pcm_seek(), pcm_write(), phone_read(), phone_setup(), phone_write(), process_sdp_a_audio(), rtp_get_rate(), send_start_rtp(), set_format(), setup_rtp_connection(), socket_process_helper(), softmix_bridge_write_voice(), softmix_process_write_audio(), spandsp_fax_gateway_process(), spandsp_v21_detect(), and transmit_audio().

00233 {
00234    const struct ast_format_interface *interface;
00235 
00236    if (format1 == NULL || format2 == NULL) {
00237       return AST_FORMAT_CMP_NOT_EQUAL;
00238    }
00239 
00240    if (format1 == format2) {
00241       return AST_FORMAT_CMP_EQUAL;
00242    }
00243 
00244    if (format1->codec != format2->codec) {
00245       return AST_FORMAT_CMP_NOT_EQUAL;
00246    }
00247 
00248    interface = format1->interface ? format1->interface : format2->interface;
00249 
00250    if (interface && interface->format_cmp) {
00251       return interface->format_cmp(format1, format2);
00252    }
00253 
00254    return AST_FORMAT_CMP_EQUAL;
00255 }

struct ast_format* ast_format_create ( struct ast_codec codec  )  [read]

Create a new media format.

Parameters:
codec The codec to use
Return values:
non-NULL success
NULL failure
Note:
The format is returned with reference count incremented. It must be released using ao2_ref or ao2_cleanup.

Definition at line 227 of file format.c.

References ast_format_create_named(), and ast_codec::name.

Referenced by ast_format_cap_append_by_type(), AST_TEST_DEFINE(), check_translation_path(), and newpvt().

00228 {
00229    return ast_format_create_named(codec->name, codec);
00230 }

struct ast_format* ast_format_create_named ( const char *  format_name,
struct ast_codec codec 
) [read]

Create a new media format with a specific name.

Parameters:
format_name The name to use for the format
codec The codec to use
Note:
This creation function should be used when the name of the codec cannot be explicitly used for the name of the format. This is the case for codecs with multiple sample rates

The format is returned with reference count incremented. It must be released using ao2_ref or ao2_cleanup.

Return values:
non-NULL success
NULL failure

Definition at line 189 of file format.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_bump, ao2_find, ao2_ref, ao2_t_alloc_options, ast_format::codec, ast_codec::description, format, format_destroy(), format_interface::interface, ast_format::interface, ast_codec::name, ast_format::name, NULL, OBJ_SEARCH_KEY, and S_OR.

Referenced by ast_format_clone(), ast_format_create(), and AST_TEST_DEFINE().

00190 {
00191    struct ast_format *format;
00192    struct format_interface *format_interface;
00193 
00194    format = ao2_t_alloc_options(sizeof(*format), format_destroy,
00195       AO2_ALLOC_OPT_LOCK_NOLOCK, S_OR(codec->description, ""));
00196    if (!format) {
00197       return NULL;
00198    }
00199    format->name = format_name;
00200    format->codec = ao2_bump(codec);
00201 
00202    format_interface = ao2_find(interfaces, codec->name, OBJ_SEARCH_KEY);
00203    if (format_interface) {
00204       format->interface = format_interface->interface;
00205       ao2_ref(format_interface, -1);
00206    }
00207 
00208    return format;
00209 }

unsigned int ast_format_determine_length ( const struct ast_format format,
unsigned int  samples 
)

Get the length (in milliseconds) for the format with a given number of samples.

Parameters:
format The media format
samples The number of samples
Returns:
length of media (in milliseconds)

Definition at line 381 of file format.c.

References ast_codec_determine_length(), and ast_format::codec.

Referenced by moh_generate(), and monmp3thread().

00382 {
00383    return ast_codec_determine_length(format->codec, samples);
00384 }

void ast_format_generate_sdp_fmtp ( 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.

Parameters:
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 317 of file format.c.

References ast_format_interface::format_generate_sdp_fmtp, and ast_format::interface.

Referenced by add_codec_to_sdp(), add_vcodec_to_sdp(), AST_TEST_DEFINE(), and generate_fmtp_attr().

00318 {
00319    if (!format->interface || !format->interface->format_generate_sdp_fmtp) {
00320       return;
00321    }
00322 
00323    format->interface->format_generate_sdp_fmtp(format, payload, str);
00324 }

void* ast_format_get_attribute_data ( const struct ast_format format  ) 

struct ast_codec* ast_format_get_codec ( const struct ast_format format  )  [read]

Get the codec associated with a format.

Parameters:
format The media format
Returns:
The codec
Note:
The reference count of the returned codec is increased by 1 and must be decremented

Definition at line 326 of file format.c.

References ao2_bump, and ast_format::codec.

Referenced by ast_codec_samples_count().

00327 {
00328    return ao2_bump(format->codec);
00329 }

unsigned int ast_format_get_codec_id ( const struct ast_format format  ) 

Get the codec identifier associated with a format.

Parameters:
format The media format
Returns:
codec identifier

Definition at line 331 of file format.c.

References ast_format::codec, and ast_codec::id.

Referenced by ast_format_cap_get_compatible_format(), ast_format_cap_get_format_framing(), ast_format_cap_iscompatible_format(), ast_format_cap_remove(), ast_format_compatibility_codec2bitfield(), ast_slinfactory_feed(), AST_TEST_DEFINE(), data_add_codec(), format2index(), format_cap_framed_init(), format_cap_replace(), and format_in_format_cap().

00332 {
00333    return format->codec->id;
00334 }

const char* ast_format_get_codec_name ( const struct ast_format format  ) 

Get the codec name associated with a format.

Parameters:
format The media format
Returns:
The codec name

Definition at line 341 of file format.c.

References ast_format::codec, and ast_codec::name.

00342 {
00343    return format->codec->name;
00344 }

unsigned int ast_format_get_default_ms ( const struct ast_format format  ) 

Get the default framing size (in milliseconds) for a format.

Parameters:
format The media format
Returns:
default framing size in milliseconds

Definition at line 356 of file format.c.

References ast_format::codec, and ast_codec::default_ms.

Referenced by __get_from_jb(), ast_format_cap_get_format_framing(), AST_TEST_DEFINE(), format_cap_framed_init(), and jb_get_and_deliver().

00357 {
00358    return format->codec->default_ms;
00359 }

unsigned int ast_format_get_maximum_ms ( const struct ast_format format  ) 

Get the maximum amount of media carried in this format.

Parameters:
format The media format
Returns:
maximum framing size in milliseconds

Definition at line 366 of file format.c.

References ast_format::codec, and ast_codec::maximum_ms.

Referenced by add_codec_to_sdp(), and create_outgoing_sdp_stream().

00367 {
00368    return format->codec->maximum_ms;
00369 }

unsigned int ast_format_get_minimum_bytes ( const struct ast_format format  ) 

Get the minimum number of bytes expected in a frame for this format.

Parameters:
format The media format
Returns:
minimum expected bytes in a frame for this format

Definition at line 371 of file format.c.

References ast_format::codec, and ast_codec::minimum_bytes.

Referenced by ast_rtp_write().

00372 {
00373    return format->codec->minimum_bytes;
00374 }

unsigned int ast_format_get_minimum_ms ( const struct ast_format format  ) 

Get the minimum amount of media carried in this format.

Parameters:
format The media format
Returns:
minimum framing size in milliseconds

Definition at line 361 of file format.c.

References ast_format::codec, and ast_codec::minimum_ms.

Referenced by ast_rtp_write().

00362 {
00363    return format->codec->minimum_ms;
00364 }

const char* ast_format_get_name ( const struct ast_format format  ) 

Get the name associated with a format.

Parameters:
format The media format
Returns:
The name of the format
Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 336 of file format.c.

References ast_format::name.

Referenced by __ast_play_and_record(), __ast_smoother_feed(), add_codec_to_sdp(), add_format_information_cb(), add_sdp(), add_static_payload(), add_tcodec_to_sdp(), add_vcodec_to_sdp(), adsi_transmit_message_full(), agent_login_exec(), ast_bridge_channel_restore_formats(), ast_channel_make_compatible_helper(), ast_codec_samples_count(), ast_dsp_process(), ast_format_cache_set(), ast_format_cap_get_names(), ast_frame_subclass2str(), ast_openvstream(), ast_rtp_engine_load_format(), ast_rtp_write(), ast_set_read_format_path(), ast_slinfactory_feed(), ast_stopstream(), ast_streamfile(), ast_translator_build_path(), ast_write(), ast_writestream(), background_detect_exec(), chan_pjsip_write(), channel_do_masquerade(), create_outgoing_sdp_stream(), dahdi_write(), do_waiting(), eagi_exec(), format_cmp_cb(), format_hash_cb(), func_channel_read(), function_iaxpeer(), function_sippeer(), generate_status(), handle_capabilities_res_message(), handle_cli_core_show_file_formats(), handle_cli_moh_show_classes(), handle_core_show_image_formats(), handle_open_receive_channel_ack_message(), handle_showchan(), handle_streamfile(), iax2_codec_pref_string(), iax2_getformatname(), init_jack_data(), isAnsweringMachine(), jack_hook_callback(), jingle_read(), jingle_write(), linear_release(), media_offer_read_av(), mgcp_rtp_read(), mgcp_write(), misdn_write(), moh_alloc(), moh_files_release(), moh_release(), ooh323_convertAsteriskCapToH323Cap(), ooh323_rtp_read(), ooh323_set_read_format(), ooh323_set_write_format(), ooh323_write(), phone_setup(), phone_write(), print_frame(), process_cn_rfc3389(), send_start_rtp(), serialize_showchan(), set_format(), show_sound_info_cb(), sip_new(), sip_rtp_read(), sip_write(), skinny_new(), skinny_rtp_read(), skinny_set_rtp_peer(), skinny_write(), socket_process_helper(), softmix_bridge_write_voice(), spandsp_v21_detect(), start_rtp(), transmit_audio(), unistim_new(), unistim_rtp_read(), and unistim_write().

00337 {
00338    return format->name;
00339 }

unsigned int ast_format_get_sample_rate ( const struct ast_format format  ) 

enum ast_media_type ast_format_get_type ( const struct ast_format format  ) 

int ast_format_init ( void   ) 

Initialize media format support.

Return values:
0 success
-1 failure

Definition at line 121 of file format.c.

References AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_container_alloc_options, ast_register_cleanup(), FORMAT_INTERFACE_BUCKETS, format_interface_cmp(), format_interface_hash(), and format_shutdown().

Referenced by main().

00122 {
00123    interfaces = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, FORMAT_INTERFACE_BUCKETS, format_interface_hash,
00124       format_interface_cmp);
00125    if (!interfaces) {
00126       return -1;
00127    }
00128 
00129    ast_register_cleanup(format_shutdown);
00130 
00131    return 0;
00132 }

struct ast_format* ast_format_joint ( const struct ast_format format1,
const struct ast_format format2 
) [read]

Get a common joint capability between two formats.

Return values:
non-NULL if joint capability exists
NULL if no joint capability exists
Note:
The returned format must be treated as immutable.

Definition at line 257 of file format.c.

References ao2_bump, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format::attribute_data, ast_format::codec, ast_format_interface::format_get_joint, ast_format::interface, and NULL.

Referenced by ast_format_cap_get_compatible_format(), and AST_TEST_DEFINE().

00258 {
00259    const struct ast_format_interface *interface;
00260 
00261    if (format1->codec != format2->codec) {
00262       return NULL;
00263    }
00264 
00265    /* If the two formats are the same structure OR if the codec is the same and no attributes
00266     * exist we can immediately return a format with reference count bumped up, since they are
00267     * the same.
00268     */
00269    if ((ast_format_cmp(format1, format2) == AST_FORMAT_CMP_EQUAL && !format1->attribute_data && !format2->attribute_data)) {
00270       return ao2_bump((struct ast_format*)format1);
00271    }
00272 
00273    interface = format1->interface ? format1->interface : format2->interface;
00274 
00275    /* If there is attribute data on either there has to be an interface */
00276    return interface->format_get_joint(format1, format2);
00277 }

struct ast_format* ast_format_parse_sdp_fmtp ( const struct ast_format format,
const char *  attributes 
) [read]

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.

Parameters:
format to set
attributes string containing the fmtp line from the SDP
Return values:
non-NULL success, attribute values were valid
NULL failure, values were not acceptable

Definition at line 298 of file format.c.

References ao2_bump, ao2_find, ao2_ref, ast_format::codec, ast_format_interface::format_parse_sdp_fmtp, format_interface::interface, ast_format::interface, ast_codec::name, and OBJ_SEARCH_KEY.

Referenced by AST_TEST_DEFINE(), get_codecs(), process_sdp_a_audio(), and process_sdp_a_video().

00299 {
00300    const struct ast_format_interface *interface = format->interface;
00301 
00302    if (!interface) {
00303       struct format_interface *format_interface = ao2_find(interfaces, format->codec->name, OBJ_SEARCH_KEY);
00304       if (format_interface) {
00305          interface = format_interface->interface;
00306          ao2_ref(format_interface, -1);
00307       }
00308    }
00309 
00310    if (!interface || !interface->format_parse_sdp_fmtp) {
00311       return ao2_bump((struct ast_format*)format);
00312    }
00313 
00314    return interface->format_parse_sdp_fmtp(format, attributes);
00315 }

struct stasis_message_type* ast_format_register_type ( void   )  [read]

Get the message type used for signaling a format registration.

Since:
12
Return values:
Stasis message type for format registration
NULL on error

Referenced by __ast_format_def_register(), ast_file_init(), ast_sounds_index_init(), and file_shutdown().

void ast_format_set_attribute_data ( struct ast_format format,
void *  attribute_data 
)

Set the attribute data on a format.

Parameters:
format The media format
attribute_data The attribute data

Definition at line 172 of file format.c.

References ast_format::attribute_data.

Referenced by celt_clone(), h263_clone(), h264_clone(), opus_clone(), silk_clone(), and test_core_format_clone().

00173 {
00174    format->attribute_data = attribute_data;
00175 }

struct stasis_message_type* ast_format_unregister_type ( void   )  [read]

Get the message type used for signaling a format unregistration.

Since:
12
Return values:
Stasis message type for format unregistration
NULL on error

Referenced by ast_file_init(), ast_format_def_unregister(), ast_sounds_index_init(), and file_shutdown().


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