Asterisk - The Open Source Telephony Project
21.4.1
|
Format Capabilities API. More...
#include "asterisk/codec.h"
Go to the source code of this file.
Macros | |
#define | ast_format_cap_alloc(flags) |
Allocate a new ast_format_cap structure. More... | |
#define | ast_format_cap_append(cap, format, framing) |
Add format capability to capabilities structure. More... | |
#define | AST_FORMAT_CAP_NAMES_LEN 384 |
#define | ast_t_format_cap_alloc(flags, tag) __ast_format_cap_alloc((flags), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define | ast_t_format_cap_append(cap, format, framing, tag) |
Enumerations | |
enum | ast_format_cap_flags { AST_FORMAT_CAP_FLAG_DEFAULT = 0 } |
Functions | |
struct ast_format_cap * | __ast_format_cap_alloc (enum ast_format_cap_flags flags, const char *tag, const char *file, int line, const char *func) |
int | __ast_format_cap_append (struct ast_format_cap *cap, struct ast_format *format, unsigned int framing, const char *tag, const char *file, int line, const char *func) |
int | ast_format_cap_append_by_type (struct ast_format_cap *cap, enum ast_media_type type) |
Add all codecs Asterisk knows about for a specific type to the capabilities structure. More... | |
int | ast_format_cap_append_from_cap (struct ast_format_cap *dst, const struct ast_format_cap *src, enum ast_media_type type) |
Append the formats of provided type in src to dst. More... | |
const char * | ast_format_cap_append_names (const struct ast_format_cap *cap, struct ast_str **buf) |
Append the names of codecs of a set of formats to an ast_str buffer. More... | |
size_t | ast_format_cap_count (const struct ast_format_cap *cap) |
Get the number of formats present within the capabilities structure. More... | |
int | ast_format_cap_empty (const struct ast_format_cap *cap) |
Determine if a format cap has no formats in it. More... | |
struct ast_format * | ast_format_cap_get_best_by_type (const struct ast_format_cap *cap, enum ast_media_type type) |
Get the most preferred format for a particular media type. More... | |
int | ast_format_cap_get_compatible (const struct ast_format_cap *cap1, const struct ast_format_cap *cap2, struct ast_format_cap *result) |
Find the compatible formats between two capabilities structures. More... | |
struct ast_format * | ast_format_cap_get_compatible_format (const struct ast_format_cap *cap, const struct ast_format *format) |
Find if input ast_format is within the capabilities of the ast_format_cap object then return the compatible format from the capabilities structure in the result. More... | |
struct ast_format * | ast_format_cap_get_format (const struct ast_format_cap *cap, int position) |
Get the format at a specific index. More... | |
unsigned int | ast_format_cap_get_format_framing (const struct ast_format_cap *cap, const struct ast_format *format) |
Get the framing for a format. More... | |
unsigned int | ast_format_cap_get_framing (const struct ast_format_cap *cap) |
Get the global framing. More... | |
const char * | ast_format_cap_get_names (const struct ast_format_cap *cap, struct ast_str **buf) |
Get the names of codecs of a set of formats. More... | |
int | ast_format_cap_has_type (const struct ast_format_cap *cap, enum ast_media_type type) |
Find out if the capabilities structure has any formats of a specific type. More... | |
int | ast_format_cap_identical (const struct ast_format_cap *cap1, const struct ast_format_cap *cap2) |
Determine if two capabilities structures are identical. More... | |
int | ast_format_cap_iscompatible (const struct ast_format_cap *cap1, const struct ast_format_cap *cap2) |
Determine if any joint capabilities exist between two capabilities structures. More... | |
enum ast_format_cmp_res | ast_format_cap_iscompatible_format (const struct ast_format_cap *cap, const struct ast_format *format) |
Find if ast_format is within the capabilities of the ast_format_cap object. More... | |
int | ast_format_cap_remove (struct ast_format_cap *cap, struct ast_format *format) |
Remove format capability from capability structure. More... | |
void | ast_format_cap_remove_by_type (struct ast_format_cap *cap, enum ast_media_type type) |
Remove all formats matching a specific format type. More... | |
void | ast_format_cap_replace_from_cap (struct ast_format_cap *dst, const struct ast_format_cap *src, enum ast_media_type type) |
Replace the formats of provided type in dst with equivalent formats from src. More... | |
void | ast_format_cap_set_framing (struct ast_format_cap *cap, unsigned int framing) |
Set the global framing. More... | |
int | ast_format_cap_update_by_allow_disallow (struct ast_format_cap *cap, const char *list, int allowing) |
Parse an "allow" or "deny" list and modify a format capabilities structure accordingly. More... | |
Format Capabilities API.
Definition in file format_cap.h.
#define ast_format_cap_alloc | ( | flags | ) |
Allocate a new ast_format_cap structure.
flags | Modifiers of struct behavior. |
NULL | on failure. |
Definition at line 49 of file format_cap.h.
Referenced by __ast_channel_alloc_ap(), ast_ari_channels_create(), ast_iax2_new(), ast_local_init(), ast_media_get_format_cap(), ast_openstream_full(), ast_openvstream(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), ast_set_read_format(), ast_set_write_format(), ast_set_write_format_interleaved_stereo(), ast_speech_new(), ast_stream_alloc(), ast_stream_clone(), ast_stream_create_resolved(), ast_stream_topology_create_from_format_cap(), ast_stream_topology_get_formats_by_type(), ast_translator_best_choice(), audiosocket_request(), begin_dial_prerun(), build_conf(), chan_pjsip_new(), chan_pjsip_read_stream(), channel_do_masquerade(), console_new(), create_outgoing_sdp_stream(), handle_exec(), iax2_codec_pref_string(), jingle_alloc(), jingle_endpoint_alloc(), jingle_interpret_content(), jingle_new(), jingle_read(), load_module(), local_request_with_stream_topology(), multicast_rtp_request(), orig_app(), orig_exten(), prepare_bridge_moh_channel(), stasis_app_control_snoop(), t38_create_media_state(), unicast_rtp_request(), and unistim_new().
#define ast_format_cap_append | ( | cap, | |
format, | |||
framing | |||
) |
Add format capability to capabilities structure.
cap | The capabilities structure to add to. |
format | The format to add. |
framing | The framing for the format (in milliseconds). |
0 | success |
-1 | failure |
Definition at line 99 of file format_cap.h.
Referenced by __ast_channel_alloc_ap(), ast_ari_channels_create(), ast_format_cap_append_by_type(), ast_format_cap_append_from_cap(), ast_format_cap_get_compatible(), ast_format_cap_update_by_allow_disallow(), ast_rtp_codecs_payload_formats(), ast_set_read_format(), ast_set_write_format(), ast_set_write_format_interleaved_stereo(), ast_stream_create_resolved(), ast_translate_available_formats(), audiosocket_request(), build_conf(), chan_pjsip_read_stream(), console_new(), handle_exec(), iax2_codec_pref_best_bitfield2cap(), iax2_codec_pref_to_cap(), iax2_format_compatibility_bitfield2cap(), jingle_read(), load_module(), local_request_with_stream_topology(), multicast_rtp_request(), orig_app(), orig_exten(), prepare_bridge_moh_channel(), stasis_app_control_snoop(), t38_create_media_state(), unicast_rtp_request(), and update_file_format_info().
#define AST_FORMAT_CAP_NAMES_LEN 384 |
Buffer size for callers of ast_format_cap_get_names to allocate.
Definition at line 324 of file format_cap.h.
Referenced by ast_stream_create_resolved(), ast_streamfile(), ast_write_stream(), chan_pjsip_get_codec(), chan_pjsip_set_rtp_peer(), chan_rtp_get_codec(), compatible_formats_exist(), console_request(), handle_cli_core_show_channeltype(), handle_cli_iax2_show_peer(), handle_showchan(), jingle_write(), local_request_with_stream_topology(), and unistim_new().
#define ast_t_format_cap_append | ( | cap, | |
format, | |||
framing, | |||
tag | |||
) |
Definition at line 102 of file format_cap.h.
enum ast_format_cap_flags |
Enumerator | |
---|---|
AST_FORMAT_CAP_FLAG_DEFAULT |
Default format capabilities settings |
Definition at line 34 of file format_cap.h.
int ast_format_cap_append_by_type | ( | struct ast_format_cap * | cap, |
enum ast_media_type | type | ||
) |
Add all codecs Asterisk knows about for a specific type to the capabilities structure.
cap | The capabilities structure to add to. |
type | The type of formats to add. |
0 | success |
-1 | failure |
Definition at line 216 of file format_cap.c.
References ao2_ref, ast_codec_get_by_id(), ast_codec_get_max(), ast_format_cache_get_by_codec(), ast_format_cap_append, ast_format_create(), ast_format_get_codec(), ast_format_none, format_cap_framed::format, and ast_codec::type.
Referenced by ast_ari_channels_create(), ast_format_cap_update_by_allow_disallow(), ast_local_init(), begin_dial_prerun(), and load_module().
int ast_format_cap_append_from_cap | ( | struct ast_format_cap * | dst, |
const struct ast_format_cap * | src, | ||
enum ast_media_type | type | ||
) |
Append the formats of provided type in src to dst.
dst | The destination capabilities structure |
src | The source capabilities structure |
type | The type of formats to append. |
0 | success |
-1 | failure |
Definition at line 269 of file format_cap.c.
References ast_format_cap_append, ast_format_get_type(), AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, format_cap_framed::framing, and ast_format_cap::preference_order.
Referenced by ast_media_get_format_cap(), ast_stream_clone(), ast_stream_create_resolved(), ast_stream_topology_create_from_format_cap(), ast_stream_topology_get_formats_by_type(), chan_pjsip_get_codec(), chan_pjsip_new(), chan_pjsip_read_stream(), chan_rtp_get_codec(), channel_do_masquerade(), create_outgoing_sdp_stream(), jingle_alloc(), jingle_call(), jingle_interpret_content(), jingle_new(), load_module(), and unistim_new().
const char* ast_format_cap_append_names | ( | const struct ast_format_cap * | cap, |
struct ast_str ** | buf | ||
) |
Append the names of codecs of a set of formats to an ast_str buffer.
cap | The capabilities structure containing the formats |
buf | A ast_str buffer to append the names of the formats to |
buf
Definition at line 739 of file format_cap.c.
Referenced by ast_stream_create_resolved(), and ast_stream_to_str().
size_t ast_format_cap_count | ( | const struct ast_format_cap * | cap | ) |
Get the number of formats present within the capabilities structure.
cap | The capabilities structure |
Definition at line 395 of file format_cap.c.
References AST_VECTOR_SIZE, and ast_format_cap::preference_order.
Referenced by add_format_information_cb(), ast_format_cap_empty(), ast_iax2_new(), ast_openvstream(), ast_rtp_instance_available_formats(), ast_rtp_lookup_mime_multiple2(), ast_stream_get_format_count(), ast_stream_topology_create_from_format_cap(), ast_stream_topology_equal(), ast_translate_available_formats(), ast_translator_best_choice(), begin_dial_prerun(), create_outgoing_sdp_stream(), iax2_codec_pref_string(), iax2_format_compatibility_cap2bitfield(), jingle_add_payloads_to_description(), jingle_interpret_description(), jingle_new(), and unistim_new().
int ast_format_cap_empty | ( | const struct ast_format_cap * | cap | ) |
Determine if a format cap has no formats in it.
cap | The format cap to check for emptiness |
1 | The format cap has zero formats or only ast_format_none |
0 | The format cap has at least one format |
Definition at line 744 of file format_cap.c.
References ast_format_cap_count(), ast_format_none, AST_VECTOR_GET, and ast_format_cap::preference_order.
Referenced by ast_stream_create_resolved(), ast_translator_best_choice(), and chan_pjsip_new().
struct ast_format* ast_format_cap_get_best_by_type | ( | const struct ast_format_cap * | cap, |
enum ast_media_type | type | ||
) |
Get the most preferred format for a particular media type.
cap | The capabilities structure |
type | The type of media to get |
non-NULL | the preferred format |
NULL | no media of type present |
Definition at line 417 of file format_cap.c.
References ao2_ref, ast_format_cap_get_format(), ast_format_get_type(), ast_format_none, AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, and ast_format_cap::preference_order.
Referenced by chan_pjsip_new().
int ast_format_cap_get_compatible | ( | const struct ast_format_cap * | cap1, |
const struct ast_format_cap * | cap2, | ||
struct ast_format_cap * | result | ||
) |
Find the compatible formats between two capabilities structures.
cap1 | The first capabilities structure | |
cap2 | The second capabilities structure | |
[out] | result | The capabilities structure to place the results into |
0 | success |
-1 | failure |
Definition at line 628 of file format_cap.c.
References ao2_ref, ast_format_cap_append, ast_format_cap_get_compatible_format(), AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, format_cap_framed::framing, and ast_format_cap::preference_order.
Referenced by ast_speech_new(), ast_stream_create_resolved(), ast_translator_best_choice(), create_outgoing_sdp_stream(), and jingle_interpret_description().
struct ast_format* ast_format_cap_get_compatible_format | ( | const struct ast_format_cap * | cap, |
const struct ast_format * | format | ||
) |
Find if input ast_format is within the capabilities of the ast_format_cap object then return the compatible format from the capabilities structure in the result.
non-NULL | if format is compatible |
NULL | if not compatible |
Definition at line 546 of file format_cap.c.
References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_codec_id(), ast_format_joint(), AST_LIST_TRAVERSE, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, format_cap_framed::format, and ast_format_cap::formats.
Referenced by ast_format_cap_get_compatible(), and ast_translate_available_formats().
struct ast_format* ast_format_cap_get_format | ( | const struct ast_format_cap * | cap, |
int | position | ||
) |
Get the format at a specific index.
cap | The capabilities structure |
position | The position to get |
non-NULL | success |
NULL | failure |
Definition at line 400 of file format_cap.c.
References ao2_ref, ast_format_none, AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, and ast_format_cap::preference_order.
Referenced by add_format_information_cb(), ast_format_cap_get_best_by_type(), ast_iax2_new(), ast_openvstream(), ast_rtp_lookup_mime_multiple2(), ast_speech_new(), ast_stream_create_resolved(), ast_translate_available_formats(), ast_translator_best_choice(), ast_unreal_new_channels(), audiosocket_request(), chan_pjsip_new(), create_outgoing_sdp_stream(), iax2_codec_pref_string(), iax2_format_compatibility_cap2bitfield(), jingle_add_payloads_to_description(), jingle_interpret_content(), jingle_new(), and unistim_new().
unsigned int ast_format_cap_get_format_framing | ( | const struct ast_format_cap * | cap, |
const struct ast_format * | format | ||
) |
Get the framing for a format.
cap | The capabilities structure |
format | The format to retrieve |
Definition at line 443 of file format_cap.c.
References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_codec_id(), ast_format_get_default_ms(), AST_LIST_TRAVERSE, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, format_cap_framed::format, ast_format_cap::formats, format_cap_framed::framing, and ast_format_cap::framing.
unsigned int ast_format_cap_get_framing | ( | const struct ast_format_cap * | cap | ) |
Get the global framing.
cap | The capabilities structure. |
0 | if no formats are in the structure and no framing has been provided |
Definition at line 438 of file format_cap.c.
References ast_format_cap::framing.
Referenced by ast_stream_create_resolved(), ast_stream_topology_create_from_format_cap(), create_outgoing_sdp_stream(), jingle_enable_video(), and jingle_new().
const char* ast_format_cap_get_names | ( | const struct ast_format_cap * | cap, |
struct ast_str ** | buf | ||
) |
Get the names of codecs of a set of formats.
cap | The capabilities structure containing the formats |
buf | A ast_str buffer to populate with the names of the formats |
buf
Definition at line 734 of file format_cap.c.
Referenced by ast_streamfile(), ast_write_stream(), chan_pjsip_get_codec(), chan_pjsip_set_rtp_peer(), chan_rtp_get_codec(), compatible_formats_exist(), console_request(), handle_cli_core_show_channeltype(), handle_showchan(), jingle_write(), local_request_with_stream_topology(), and unistim_new().
int ast_format_cap_has_type | ( | const struct ast_format_cap * | cap, |
enum ast_media_type | type | ||
) |
Find out if the capabilities structure has any formats of a specific type.
1 | true |
0 | false, no formats of specific type. |
Definition at line 613 of file format_cap.c.
References ast_format_get_type(), AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, and ast_format_cap::preference_order.
Referenced by ast_bridge_update_talker_src_video_mode(), ast_channel_make_compatible_helper(), ast_openstream_full(), ast_openvstream(), ast_sendtext_data(), ast_stream_topology_create_from_format_cap(), jingle_enable_video(), jingle_request(), and negotiate_incoming_sdp_stream().
int ast_format_cap_identical | ( | const struct ast_format_cap * | cap1, |
const struct ast_format_cap * | cap2 | ||
) |
Determine if two capabilities structures are identical.
cap1 | The first capabilities structure |
cap2 | The second capabilities structure |
0 | capabilities are not identical |
1 | capabilities are identical |
Definition at line 687 of file format_cap.c.
References AST_VECTOR_SIZE, and ast_format_cap::preference_order.
Referenced by ast_stream_topology_equal().
int ast_format_cap_iscompatible | ( | const struct ast_format_cap * | cap1, |
const struct ast_format_cap * | cap2 | ||
) |
Determine if any joint capabilities exist between two capabilities structures.
cap1 | The first capabilities structure |
cap2 | The second capabilities structure |
0 | no joint capabilities exist |
1 | joint capabilities exist |
Definition at line 653 of file format_cap.c.
References ast_format_cap_iscompatible_format(), AST_FORMAT_CMP_NOT_EQUAL, AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, and ast_format_cap::preference_order.
Referenced by ast_openvstream(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), compatible_formats_exist(), and console_request().
enum ast_format_cmp_res ast_format_cap_iscompatible_format | ( | const struct ast_format_cap * | cap, |
const struct ast_format * | format | ||
) |
Find if ast_format is within the capabilities of the ast_format_cap object.
Definition at line 581 of file format_cap.c.
References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_codec_id(), AST_LIST_TRAVERSE, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, format_cap_framed::format, and ast_format_cap::formats.
Referenced by ast_format_cap_iscompatible(), ast_speech_new(), chan_pjsip_indicate(), chan_pjsip_read_stream(), is_compatible_format(), jingle_read(), and jingle_write().
int ast_format_cap_remove | ( | struct ast_format_cap * | cap, |
struct ast_format * | format | ||
) |
Remove format capability from capability structure.
0 | remove was successful |
-1 | remove failed. Could not find format to remove |
Definition at line 495 of file format_cap.c.
References ast_format_get_codec_id(), AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_VECTOR_GET_ADDR, AST_VECTOR_REMOVE_CMP_ORDERED, AST_VECTOR_SIZE, FORMAT_CAP_FRAMED_ELEM_CLEANUP, FORMAT_CAP_FRAMED_ELEM_CMP, ast_format_cap::formats, and ast_format_cap::preference_order.
Referenced by ast_format_cap_update_by_allow_disallow().
void ast_format_cap_remove_by_type | ( | struct ast_format_cap * | cap, |
enum ast_media_type | type | ||
) |
Remove all formats matching a specific format type.
cap | The capabilities structure |
type | The media type to remove formats of |
Definition at line 523 of file format_cap.c.
References ao2_ref, ast_format_get_type(), AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_VECTOR_GET_ADDR, AST_VECTOR_REMOVE_CMP_ORDERED, AST_VECTOR_SIZE, format_cap_framed::format, FORMAT_CAP_FRAMED_ELEM_CLEANUP, FORMAT_CAP_FRAMED_ELEM_CMP, ast_format_cap::formats, and ast_format_cap::preference_order.
Referenced by ast_format_cap_update_by_allow_disallow(), ast_rtp_codecs_payload_formats(), ast_stream_create_resolved(), chan_pjsip_read_stream(), and jingle_interpret_description().
void ast_format_cap_replace_from_cap | ( | struct ast_format_cap * | dst, |
const struct ast_format_cap * | src, | ||
enum ast_media_type | type | ||
) |
Replace the formats of provided type in dst with equivalent formats from src.
dst | The destination capabilities structure |
src | The source capabilities structure |
type | The type of formats to replace. |
Definition at line 306 of file format_cap.c.
References ast_format_get_type(), AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, format_cap_framed::framing, and ast_format_cap::preference_order.
void ast_format_cap_set_framing | ( | struct ast_format_cap * | cap, |
unsigned int | framing | ||
) |
Set the global framing.
cap | The capabilities structure. |
framing | The framing value (in milliseconds). |
ast_format_cap
structure may override this value, if the framing they require is less than the value set by this function. Definition at line 136 of file format_cap.c.
References format_cap_framed::framing, and ast_format_cap::framing.
Referenced by ast_rtp_codecs_payload_formats(), ast_stream_create_resolved(), and ast_stream_topology_create_from_format_cap().
int ast_format_cap_update_by_allow_disallow | ( | struct ast_format_cap * | cap, |
const char * | list, | ||
int | allowing | ||
) |
Parse an "allow" or "deny" list and modify a format capabilities structure accordingly.
cap | The capabilities structure to modify |
list | The list containing formats to append or remove |
allowing | If zero, start removing formats specified in the list. If non-zero, start appending formats specified in the list. |
0 | on success |
-1 | on failure |
Definition at line 320 of file format_cap.c.
References ast_debug, ast_format_cache_get, ast_format_cap_append, ast_format_cap_append_by_type(), ast_format_cap_remove(), ast_format_cap_remove_by_type(), ast_strdupa, and ast_strip().
Referenced by codec_handler_fn().