Asterisk - The Open Source Telephony Project
18.5.0
|
Media Stream API. More...
#include "asterisk.h"
#include "asterisk/logger.h"
#include "asterisk/stream.h"
#include "asterisk/strings.h"
#include "asterisk/format.h"
#include "asterisk/format_cap.h"
#include "asterisk/vector.h"
#include "asterisk/config.h"
#include "asterisk/rtp_engine.h"
Go to the source code of this file.
Data Structures | |
struct | ast_stream |
struct | ast_stream_metadata_entry |
struct | ast_stream_topology |
Macros | |
#define | MIN_STREAM_NAME_LEN 16 |
#define | set_pref_value(_name, _value, _prefs, _UC, _lc, _error_message) |
#define | TOPOLOGY_INITIAL_STREAM_COUNT 2 |
Functions | |
struct ast_stream * | ast_stream_alloc (const char *name, enum ast_media_type type) |
Create a new media stream representation. More... | |
struct ast_stream * | ast_stream_clone (const struct ast_stream *stream, const char *name) |
Create a deep clone of an existing stream. More... | |
int | ast_stream_codec_prefs_parse (const char *pref_string, struct ast_stream_codec_negotiation_prefs *prefs, struct ast_str **error_message) |
Parses a string representing the codec prefs into a ast_stream_codec_negotiation_pref structure. More... | |
const char * | ast_stream_codec_prefs_to_str (const struct ast_stream_codec_negotiation_prefs *prefs, struct ast_str **buf) |
Return a string representing the codec preferences. More... | |
struct ast_stream * | ast_stream_create_resolved (struct ast_stream *pending_stream, struct ast_stream *validation_stream, struct ast_stream_codec_negotiation_prefs *prefs, struct ast_str **error_message) |
Create a resolved stream from 2 streams. More... | |
void | ast_stream_free (struct ast_stream *stream) |
Destroy a media stream representation. More... | |
int | ast_stream_get_format_count (const struct ast_stream *stream) |
Get the count of the current negotiated formats of a stream. More... | |
const struct ast_format_cap * | ast_stream_get_formats (const struct ast_stream *stream) |
Get the current negotiated formats of a stream. More... | |
int | ast_stream_get_group (const struct ast_stream *stream) |
Get the stream group that a stream is part of. More... | |
const char * | ast_stream_get_metadata (const struct ast_stream *stream, const char *m_key) |
Get a stream metadata value. More... | |
struct ast_variable * | ast_stream_get_metadata_list (const struct ast_stream *stream) |
Get all stream metadata keys. More... | |
const char * | ast_stream_get_name (const struct ast_stream *stream) |
Get the name of a stream. More... | |
int | ast_stream_get_position (const struct ast_stream *stream) |
Get the position of the stream in the topology. More... | |
struct ast_rtp_codecs * | ast_stream_get_rtp_codecs (const struct ast_stream *stream) |
Get rtp_codecs associated with the stream. More... | |
enum ast_stream_state | ast_stream_get_state (const struct ast_stream *stream) |
Get the current state of a stream. More... | |
enum ast_media_type | ast_stream_get_type (const struct ast_stream *stream) |
Get the media type of a stream. More... | |
void | ast_stream_set_formats (struct ast_stream *stream, struct ast_format_cap *caps) |
Set the current negotiated formats of a stream. More... | |
void | ast_stream_set_group (struct ast_stream *stream, int group) |
Set the stream group for a stream. More... | |
int | ast_stream_set_metadata (struct ast_stream *stream, const char *m_key, const char *value) |
Set a stream metadata value. More... | |
void | ast_stream_set_rtp_codecs (struct ast_stream *stream, struct ast_rtp_codecs *rtp_codecs) |
Set rtp_codecs associated with the stream. More... | |
void | ast_stream_set_state (struct ast_stream *stream, enum ast_stream_state state) |
Set the state of a stream. More... | |
void | ast_stream_set_type (struct ast_stream *stream, enum ast_media_type type) |
Change the media type of a stream. More... | |
const char * | ast_stream_state2str (enum ast_stream_state state) |
Convert the state of a stream into a string. More... | |
enum ast_stream_state | ast_stream_str2state (const char *str) |
Convert a string to a stream state. More... | |
const char * | ast_stream_to_str (const struct ast_stream *stream, struct ast_str **buf) |
Get a string representing the stream for debugging/display purposes. More... | |
struct ast_stream_topology * | ast_stream_topology_alloc (void) |
Create a stream topology. More... | |
int | ast_stream_topology_append_stream (struct ast_stream_topology *topology, struct ast_stream *stream) |
Append a stream to the topology. More... | |
struct ast_stream_topology * | ast_stream_topology_clone (const struct ast_stream_topology *topology) |
Create a deep clone of an existing stream topology. More... | |
struct ast_stream_topology * | ast_stream_topology_create_from_format_cap (struct ast_format_cap *cap) |
A helper function that, given a format capabilities structure, creates a topology and separates the media types in format_cap into separate streams. More... | |
struct ast_stream_topology * | ast_stream_topology_create_resolved (struct ast_stream_topology *pending_topology, struct ast_stream_topology *configured_topology, struct ast_stream_codec_negotiation_prefs *prefs, struct ast_str **error_message) |
Create a resolved stream topology from 2 topologies. More... | |
int | ast_stream_topology_del_stream (struct ast_stream_topology *topology, unsigned int position) |
Delete a specified stream from the given topology. More... | |
int | ast_stream_topology_equal (const struct ast_stream_topology *left, const struct ast_stream_topology *right) |
Compare two stream topologies to see if they are equal. More... | |
void | ast_stream_topology_free (struct ast_stream_topology *topology) |
Unreference and destroy a stream topology. More... | |
int | ast_stream_topology_get_active_count (const struct ast_stream_topology *topology) |
Get the number of active (non-REMOVED) streams in a topology. More... | |
int | ast_stream_topology_get_count (const struct ast_stream_topology *topology) |
Get the number of streams in a topology. More... | |
struct ast_stream * | ast_stream_topology_get_first_stream_by_type (const struct ast_stream_topology *topology, enum ast_media_type type) |
Gets the first active stream of a specific type from the topology. More... | |
struct ast_format_cap * | ast_stream_topology_get_formats (struct ast_stream_topology *topology) |
Create a format capabilities structure representing the topology. More... | |
struct ast_format_cap * | ast_stream_topology_get_formats_by_type (struct ast_stream_topology *topology, enum ast_media_type type) |
Create a format capabilities structure containing all the formats from all the streams of a particular type in the topology. More... | |
struct ast_stream * | ast_stream_topology_get_stream (const struct ast_stream_topology *topology, unsigned int stream_num) |
Get a specific stream from the topology. More... | |
void | ast_stream_topology_map (const struct ast_stream_topology *topology, struct ast_vector_int *types, struct ast_vector_int *v0, struct ast_vector_int *v1) |
Map a given topology's streams to the given types. More... | |
int | ast_stream_topology_set_stream (struct ast_stream_topology *topology, unsigned int position, struct ast_stream *stream) |
Set a specific position in a topology. More... | |
const char * | ast_stream_topology_to_str (const struct ast_stream_topology *topology, struct ast_str **buf) |
Get a string representing the topology for debugging/display purposes. More... | |
static void | stream_topology_destroy (void *data) |
Variables | |
const char * | ast_stream_codec_negotiation_keep_map [] |
"keep" enum to string map More... | |
const char * | ast_stream_codec_negotiation_operation_map [] |
"operation" enum to string map More... | |
const char * | ast_stream_codec_negotiation_params_map [] |
Preference enum to string map. More... | |
const char * | ast_stream_codec_negotiation_prefer_map [] |
"prefer" enum to string map More... | |
const char * | ast_stream_codec_negotiation_transcode_map [] |
"transcode" state enum to string map More... | |
const char * | ast_stream_state_map [] |
Stream state enum to string map. More... | |
Media Stream API.
Definition in file stream.c.
#define MIN_STREAM_NAME_LEN 16 |
Definition at line 231 of file stream.c.
Referenced by ast_stream_alloc(), ast_stream_clone(), ast_stream_topology_append_stream(), ast_stream_topology_create_from_format_cap(), and ast_stream_topology_set_stream().
#define set_pref_value | ( | _name, | |
_value, | |||
_prefs, | |||
_UC, | |||
_lc, | |||
_error_message | |||
) |
Definition at line 159 of file stream.c.
Referenced by ast_stream_codec_prefs_parse().
#define TOPOLOGY_INITIAL_STREAM_COUNT 2 |
Definition at line 649 of file stream.c.
Referenced by ast_stream_topology_alloc().
struct ast_stream* ast_stream_alloc | ( | const char * | name, |
enum ast_media_type | type | ||
) |
Create a new media stream representation.
name | A name for the stream |
type | The media type the stream is handling |
non-NULL | success |
NULL | failure |
Definition at line 233 of file stream.c.
References ast_calloc, ast_format_cap_alloc, AST_FORMAT_CAP_FLAG_DEFAULT, ast_free, AST_STREAM_STATE_INACTIVE, ast_stream::formats, ast_stream::group, MAX, MIN_STREAM_NAME_LEN, ast_stream::name, NULL, S_OR, ast_stream::state, ast_stream::type, and type.
Referenced by ast_stream_topology_create_from_format_cap(), AST_TEST_DEFINE(), ast_unreal_indicate(), build_topology(), handle_incoming_sdp(), make_channel(), sdp_requires_deferral(), t38_create_media_state(), and test_stream_alloc().
struct ast_stream* ast_stream_clone | ( | const struct ast_stream * | stream, |
const char * | name | ||
) |
Create a deep clone of an existing stream.
stream | The existing stream |
Optional | name for cloned stream. If NULL, then existing stream's name is copied. |
non-NULL | success |
NULL | failure |
Definition at line 257 of file stream.c.
References ast_calloc, ast_format_cap_alloc, ast_format_cap_append_from_cap(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_free, AST_MEDIA_TYPE_UNKNOWN, ast_stream_get_metadata_list(), ast_stream::formats, ast_stream::group, MAX, ast_stream::metadata, MIN_STREAM_NAME_LEN, ast_stream::name, NULL, and S_OR.
Referenced by append_all_streams(), append_source_stream(), ast_sip_session_create_joint_call_stream(), ast_stream_create_resolved(), ast_stream_topology_clone(), ast_stream_topology_create_resolved(), remove_all_original_streams(), resolve_refresh_media_states(), sip_session_refresh(), and stream_echo_topology_alloc().
int ast_stream_codec_prefs_parse | ( | const char * | pref_string, |
struct ast_stream_codec_negotiation_prefs * | prefs, | ||
struct ast_str ** | error_message | ||
) |
Parses a string representing the codec prefs into a ast_stream_codec_negotiation_pref structure.
This function is mainly used by pjsip_configuration as a sorcery parameter handler.
pref_string | A string in the format described by ast_stream_codec_prefs_to_str(). |
prefs | Pointer to a ast_stream_codec_negotiation_prefs structure to receive the parsed values. |
error_message | An optional ast_str** into which parsing errors will be placed. |
0 | if success |
-1 | if failed |
Whitespace around the ':' and ',' separators is ignored and the parameters can be specified in any order. Parameters missing in the input string will have their values set to the appropriate *_UNSPECIFIED value and will not be considered an error. It's up to the caller to decide whether set a default value, return an error, etc.
Sample input: "prefer : configured , operation: union,keep:all, transcode:prevent"
Definition at line 181 of file stream.c.
References ast_str_append(), ast_strdupa, CODEC_NEGOTIATION_KEEP_UNSPECIFIED, CODEC_NEGOTIATION_OPERATION_UNSPECIFIED, CODEC_NEGOTIATION_PREFER_UNSPECIFIED, CODEC_NEGOTIATION_TRANSCODE_UNSPECIFIED, ast_stream_codec_negotiation_prefs::keep, name, NULL, ast_stream_codec_negotiation_prefs::operation, ast_stream_codec_negotiation_prefs::prefer, set_pref_value, ast_stream_codec_negotiation_prefs::transcode, and value.
Referenced by codec_prefs_handler().
const char* ast_stream_codec_prefs_to_str | ( | const struct ast_stream_codec_negotiation_prefs * | prefs, |
struct ast_str ** | buf | ||
) |
Return a string representing the codec preferences.
This function can be used for debugging purposes but is also used in pjsip_configuration as a sorcery parameter handler
prefs | A pointer to a ast_stream_codec_negotiation_prefs structure |
buf | A pointer to an ast_str* used for the output. See note below. |
Sample output: "prefer: configured, operation: union, keep:all, transcode:prevent"
Definition at line 132 of file stream.c.
References ast_str_append(), ast_str_buffer(), ast_stream_codec_keep_to_str, ast_stream_codec_operation_to_str, ast_stream_codec_param_to_str, ast_stream_codec_prefer_to_str, ast_stream_codec_transcode_to_str, CODEC_NEGOTIATION_PARAM_KEEP, CODEC_NEGOTIATION_PARAM_OPERATION, CODEC_NEGOTIATION_PARAM_PREFER, CODEC_NEGOTIATION_PARAM_TRANSCODE, ast_stream_codec_negotiation_prefs::keep, ast_stream_codec_negotiation_prefs::operation, ast_stream_codec_negotiation_prefs::prefer, and ast_stream_codec_negotiation_prefs::transcode.
Referenced by ast_stream_create_resolved(), and codec_prefs_to_str().
struct ast_stream* ast_stream_create_resolved | ( | struct ast_stream * | pending_stream, |
struct ast_stream * | configured_stream, | ||
struct ast_stream_codec_negotiation_prefs * | prefs, | ||
struct ast_str ** | error_message | ||
) |
Create a resolved stream from 2 streams.
pending_stream | The "live" stream created from an SDP, passed through the core, or used to create an SDP. |
configured_stream | The static stream used to validate the pending stream. |
prefs | A pointer to an ast_stream_codec_negotiation_prefs structure. |
error_message | If supplied, error messages will be appended. |
The resulting stream will contain all of the attributes and metadata of the pending stream but will contain only the formats that passed the validation specified by the ast_stream_codec_negotiation_prefs structure. This may mean that the stream's format_caps will be empty. It's up to the caller to determine what to do with the stream in that case. I.E. Free it, set it to the REMOVED state, etc. A stream will always be returned unless there was some catastrophic allocation failure.
NULL | if there was some allocation failure. |
A | new, resolved stream. |
Definition at line 525 of file stream.c.
References ao2_cleanup, ao2_ref, ast_codec_media_type2str(), ast_format_cap_alloc, ast_format_cap_append, ast_format_cap_append_from_cap(), ast_format_cap_append_names(), ast_format_cap_empty(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_get_compatible(), ast_format_cap_get_format(), ast_format_cap_get_framing(), AST_FORMAT_CAP_NAMES_LEN, ast_format_cap_remove_by_type(), ast_format_cap_set_framing(), ast_free, AST_MEDIA_TYPE_UNKNOWN, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_set(), ast_str_tmp, ast_stream_clone(), ast_stream_codec_prefs_to_str(), AST_STREAM_MAX_CODEC_PREFS_LENGTH, ast_stream_set_formats(), ast_stream_to_str(), ast_trace, buf, CODEC_NEGOTIATION_KEEP_FIRST, CODEC_NEGOTIATION_OPERATION_INTERSECT, CODEC_NEGOTIATION_OPERATION_ONLY_NONPREFERRED, CODEC_NEGOTIATION_OPERATION_ONLY_PREFERRED, CODEC_NEGOTIATION_OPERATION_UNION, CODEC_NEGOTIATION_PREFER_PENDING, ast_stream::formats, ast_stream_codec_negotiation_prefs::keep, NULL, ast_stream_codec_negotiation_prefs::operation, ast_stream_codec_negotiation_prefs::prefer, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, TRACE_ATLEAST, and ast_stream::type.
Referenced by ast_stream_topology_create_resolved().
void ast_stream_free | ( | struct ast_stream * | stream | ) |
Destroy a media stream representation.
stream | The media stream |
Definition at line 292 of file stream.c.
References ao2_cleanup, ast_free, ast_rtp_codecs_payloads_destroy(), ast_variables_destroy(), ast_stream::formats, ast_stream::metadata, and ast_stream::rtp_codecs.
Referenced by append_all_streams(), append_source_stream(), ast_sip_session_create_outgoing(), ast_stream_topology_clone(), ast_stream_topology_create_from_format_cap(), ast_stream_topology_create_resolved(), ast_stream_topology_del_stream(), ast_stream_topology_set_stream(), AST_TEST_DEFINE(), build_topology(), handle_incoming_sdp(), remove_all_original_streams(), sdp_requires_deferral(), sip_session_refresh(), stream_echo_topology_alloc(), stream_topology_destroy(), and t38_create_media_state().
int ast_stream_get_format_count | ( | const struct ast_stream * | stream | ) |
Get the count of the current negotiated formats of a stream.
stream | The media stream |
Definition at line 358 of file stream.c.
References ast_assert, ast_format_cap_count(), ast_stream::formats, and NULL.
Referenced by ast_sip_session_create_outgoing(), and ast_stream_topology_create_resolved().
const struct ast_format_cap* ast_stream_get_formats | ( | const struct ast_stream * | stream | ) |
Get the current negotiated formats of a stream.
stream | The media stream |
non-NULL | success |
NULL | failure |
Definition at line 330 of file stream.c.
References ast_assert, ast_stream::formats, and NULL.
Referenced by ast_sip_session_create_joint_call_stream(), ast_stream_topology_equal(), AST_TEST_DEFINE(), create_outgoing_sdp_stream(), handle_showchan(), is_compatible_format(), local_request_with_stream_topology(), media_offer_read_av(), media_offer_write_av(), native_rtp_request_stream_topology_update(), simple_bridge_request_stream_topology_update(), sip_session_refresh(), and validate_stream().
int ast_stream_get_group | ( | const struct ast_stream * | stream | ) |
Get the stream group that a stream is part of.
stream | The stream |
Definition at line 1077 of file stream.c.
References ast_assert, ast_stream::group, and NULL.
Referenced by add_msid_to_stream(), ast_stream_topology_clone(), and handle_showchan().
const char* ast_stream_get_metadata | ( | const struct ast_stream * | stream, |
const char * | m_key | ||
) |
Get a stream metadata value.
stream | The media stream |
m_key | An arbitrary metadata key |
non-NULL | metadata value |
NULL | failure or not found |
Definition at line 423 of file stream.c.
References ast_assert_return, ast_stream::metadata, ast_variable::name, ast_variable::next, NULL, and ast_variable::value.
Referenced by add_msid_to_stream(), AST_TEST_DEFINE(), handle_incoming_sdp(), sdp_requires_deferral(), and sip_session_refresh().
struct ast_variable* ast_stream_get_metadata_list | ( | const struct ast_stream * | stream | ) |
Get all stream metadata keys.
stream | The media stream |
An | ast_variable list of the metadata key/value pairs. |
NULL | if error or no variables are set. |
When you're finished with the list, you must call ast_variables_destroy(list);
Definition at line 439 of file stream.c.
References ast_assert_return, ast_variable_list_append, ast_variable_new, ast_variables_destroy(), ast_stream::metadata, ast_variable::name, ast_variable::next, NULL, and ast_variable::value.
Referenced by ast_stream_clone(), and handle_showchan().
const char* ast_stream_get_name | ( | const struct ast_stream * | stream | ) |
Get the name of a stream.
stream | The media stream |
non-NULL | success |
NULL | failure |
Definition at line 309 of file stream.c.
References ast_assert, ast_stream::name, and NULL.
Referenced by ast_sip_session_media_state_add(), ast_stream_topology_equal(), AST_TEST_DEFINE(), handle_incoming_sdp(), handle_showchan(), is_media_state_valid(), is_video_dest(), is_video_source(), remove_all_original_streams(), resolve_refresh_media_states(), sdp_requires_deferral(), sip_session_refresh(), softmix_bridge_stream_sources_update(), and validate_stream().
int ast_stream_get_position | ( | const struct ast_stream * | stream | ) |
Get the position of the stream in the topology.
stream | The media stream |
Definition at line 500 of file stream.c.
References ast_assert, NULL, and ast_stream::position.
Referenced by __ast_read(), apply_negotiated_sdp_stream(), AST_TEST_DEFINE(), ast_write_stream(), check_stream_positions(), create_outgoing_sdp_stream(), stream_echo_write_error(), and tech_write().
struct ast_rtp_codecs* ast_stream_get_rtp_codecs | ( | const struct ast_stream * | stream | ) |
Get rtp_codecs associated with the stream.
stream | The media stream |
Definition at line 507 of file stream.c.
References ast_assert, NULL, and ast_stream::rtp_codecs.
enum ast_stream_state ast_stream_get_state | ( | const struct ast_stream * | stream | ) |
Get the current state of a stream.
stream | The media stream |
Definition at line 373 of file stream.c.
References ast_assert, NULL, and ast_stream::state.
Referenced by append_all_streams(), ast_sip_session_create_outgoing(), ast_sip_session_is_pending_stream_default(), ast_sip_session_media_state_add(), ast_sip_session_media_state_clone(), ast_stream_topology_equal(), AST_TEST_DEFINE(), create_outgoing_sdp_stream(), handle_incoming_sdp(), handle_negotiated_sdp(), handle_showchan(), is_video_dest(), is_video_source(), local_request_with_stream_topology(), media_offer_read_av(), native_rtp_request_stream_topology_update(), resolve_refresh_media_states(), simple_bridge_request_stream_topology_update(), sip_session_refresh(), softmix_bridge_stream_sources_update(), softmix_bridge_stream_topology_changed(), stream_echo_topology_alloc(), test_media_add(), and unreal_colp_stream_topology_request_change().
enum ast_media_type ast_stream_get_type | ( | const struct ast_stream * | stream | ) |
Get the media type of a stream.
stream | The media stream |
Definition at line 316 of file stream.c.
References ast_assert, NULL, and ast_stream::type.
Referenced by add_msid_to_stream(), ast_sip_session_create_joint_call_stream(), ast_sip_session_is_pending_stream_default(), ast_sip_session_media_state_clone(), ast_stream_topology_equal(), ast_stream_topology_map(), AST_TEST_DEFINE(), ast_write_stream(), check_stream_positions(), create_local_sdp(), handle_showchan(), is_media_state_valid(), is_video_dest(), is_video_source(), local_request_with_stream_topology(), media_offer_read_av(), native_rtp_request_stream_topology_update(), simple_bridge_request_stream_topology_update(), sip_session_refresh(), softmix_bridge_stream_sources_update(), softmix_bridge_stream_topology_changed(), stream_echo_topology_alloc(), stream_echo_write(), stream_echo_write_error(), and validate_stream().
void ast_stream_set_formats | ( | struct ast_stream * | stream, |
struct ast_format_cap * | caps | ||
) |
Set the current negotiated formats of a stream.
stream | The media stream |
caps | The current negotiated formats |
Definition at line 365 of file stream.c.
References ao2_bump, ao2_cleanup, ast_assert, ast_stream::formats, and NULL.
Referenced by apply_cap_to_bundled(), ast_sip_session_create_joint_call_stream(), ast_stream_create_resolved(), ast_stream_topology_create_from_format_cap(), AST_TEST_DEFINE(), build_topology(), local_request_with_stream_topology(), media_offer_write_av(), native_rtp_request_stream_topology_update(), simple_bridge_request_stream_topology_update(), sip_session_refresh(), and t38_create_media_state().
void ast_stream_set_group | ( | struct ast_stream * | stream, |
int | group | ||
) |
Set the stream group for a stream.
stream | The stream |
group | The group the stream is part of |
Definition at line 1084 of file stream.c.
References ast_assert, ast_stream::group, and NULL.
Referenced by ast_stream_topology_clone(), and set_remote_mslabel_and_stream_group().
int ast_stream_set_metadata | ( | struct ast_stream * | stream, |
const char * | m_key, | ||
const char * | value | ||
) |
Set a stream metadata value.
stream | The media stream |
m_key | An arbitrary metadata key |
value | String metadata value or NULL to remove existing value |
-1 | failure |
0 | success |
Definition at line 460 of file stream.c.
References ast_assert_return, ast_free, ast_variable_list_append, ast_variable_new, ast_stream::metadata, ast_variable::name, ast_variable::next, and NULL.
Referenced by add_msid_to_stream(), append_source_stream(), AST_TEST_DEFINE(), handle_incoming_sdp(), media_offer_write_av(), and sdp_requires_deferral().
void ast_stream_set_rtp_codecs | ( | struct ast_stream * | stream, |
struct ast_rtp_codecs * | rtp_codecs | ||
) |
Set rtp_codecs associated with the stream.
stream | The media stream |
rtp_codecs | The rtp_codecs |
Definition at line 514 of file stream.c.
References ast_assert, ast_rtp_codecs_payloads_destroy(), NULL, and ast_stream::rtp_codecs.
void ast_stream_set_state | ( | struct ast_stream * | stream, |
enum ast_stream_state | state | ||
) |
Set the state of a stream.
stream | The media stream |
state | The new state that the stream is in |
Definition at line 380 of file stream.c.
References ast_assert, NULL, ast_stream::state, and state.
Referenced by append_source_stream(), ast_stream_topology_create_resolved(), AST_TEST_DEFINE(), create_outgoing_sdp_stream(), handle_incoming_sdp(), handle_negotiated_sdp(), handle_negotiated_sdp_session_media(), native_rtp_request_stream_topology_update(), remove_all_original_streams(), remove_destination_streams(), remove_stream_from_bundle(), resolve_refresh_media_states(), sdp_requires_deferral(), simple_bridge_request_stream_topology_update(), sip_session_refresh(), softmix_bridge_stream_sources_update(), stream_echo_topology_alloc(), t38_create_media_state(), test_stream_alloc(), and unreal_colp_stream_topology_request_change().
void ast_stream_set_type | ( | struct ast_stream * | stream, |
enum ast_media_type | type | ||
) |
Change the media type of a stream.
stream | The media stream |
type | The new media type |
Definition at line 323 of file stream.c.
References ast_assert, NULL, ast_stream::type, and type.
Referenced by AST_TEST_DEFINE().
const char* ast_stream_state2str | ( | enum ast_stream_state | state | ) |
Convert the state of a stream into a string.
state | The stream state |
Definition at line 388 of file stream.c.
References AST_STREAM_STATE_INACTIVE, AST_STREAM_STATE_RECVONLY, AST_STREAM_STATE_REMOVED, AST_STREAM_STATE_SENDONLY, and AST_STREAM_STATE_SENDRECV.
Referenced by handle_showchan(), resolve_refresh_media_states(), and softmix_bridge_stream_sources_update().
enum ast_stream_state ast_stream_str2state | ( | const char * | str | ) |
Convert a string to a stream state.
str | The string to convert |
Definition at line 406 of file stream.c.
References AST_STREAM_STATE_INACTIVE, AST_STREAM_STATE_RECVONLY, AST_STREAM_STATE_REMOVED, AST_STREAM_STATE_SENDONLY, and AST_STREAM_STATE_SENDRECV.
const char* ast_stream_to_str | ( | const struct ast_stream * | stream, |
struct ast_str ** | buf | ||
) |
Get a string representing the stream for debugging/display purposes.
stream | A stream |
buf | A pointer to an ast_str* used for the output. |
"" | (empty string) if either buf or *buf are NULL |
(null stream) | if *stream was NULL |
<stream_representation> | otherwise |
Return format: <name>:<media_type>:<stream_state> (formats)
Sample return: "audio:audio:sendrecv (ulaw,g722)"
Definition at line 337 of file stream.c.
References ast_codec_media_type2str(), ast_format_cap_append_names(), ast_str_append(), ast_str_buffer(), ast_stream_state_map, ast_stream::formats, ast_stream::name, ast_stream::position, S_OR, ast_stream::state, and ast_stream::type.
Referenced by add_sdp_streams(), apply_negotiated_sdp_stream(), ast_stream_create_resolved(), ast_stream_topology_to_str(), create_local_sdp(), create_outgoing_sdp_stream(), handle_incoming_sdp(), is_media_state_valid(), resolve_refresh_media_states(), and softmix_bridge_stream_sources_update().
struct ast_stream_topology* ast_stream_topology_alloc | ( | void | ) |
Create a stream topology.
non-NULL | success |
NULL | failure |
Definition at line 650 of file stream.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, AST_VECTOR_INIT, NULL, stream_topology_destroy(), and TOPOLOGY_INITIAL_STREAM_COUNT.
Referenced by __ast_channel_alloc_ap(), ast_channel_set_stream_topology(), ast_sip_session_create_outgoing(), ast_stream_topology_clone(), ast_stream_topology_create_from_format_cap(), ast_stream_topology_create_resolved(), AST_TEST_DEFINE(), ast_unreal_indicate(), build_topology(), handle_incoming_sdp(), make_channel(), sdp_requires_deferral(), sfu_topologies_on_join(), sfu_topologies_on_source_change(), softmix_bridge_stream_sources_update(), stream_echo_topology_alloc(), and t38_create_media_state().
int ast_stream_topology_append_stream | ( | struct ast_stream_topology * | topology, |
struct ast_stream * | stream | ||
) |
Append a stream to the topology.
topology | The topology of streams |
stream | The stream to append |
Definition at line 748 of file stream.c.
References ast_assert, ast_codec_media_type2str(), ast_strlen_zero, AST_VECTOR_APPEND, AST_VECTOR_SIZE, MIN_STREAM_NAME_LEN, ast_stream::name, ast_stream::position, and ast_stream::type.
Referenced by append_all_streams(), append_source_stream(), ast_sip_session_create_outgoing(), ast_stream_topology_create_from_format_cap(), ast_stream_topology_create_resolved(), AST_TEST_DEFINE(), ast_unreal_indicate(), build_topology(), make_channel(), resolve_refresh_media_states(), sip_session_refresh(), stream_echo_topology_alloc(), and test_media_add().
struct ast_stream_topology* ast_stream_topology_clone | ( | const struct ast_stream_topology * | topology | ) |
Create a deep clone of an existing stream topology.
topology | The existing topology of streams |
non-NULL | success |
NULL | failure |
Definition at line 667 of file stream.c.
References ast_assert, ast_stream_clone(), ast_stream_free(), ast_stream_get_group(), ast_stream_set_group(), ast_stream_topology_alloc(), ast_stream_topology_free(), AST_VECTOR_APPEND, AST_VECTOR_GET, AST_VECTOR_SIZE, and NULL.
Referenced by ast_sip_session_create_outgoing(), ast_sip_session_media_state_clone(), AST_TEST_DEFINE(), ast_unreal_alloc_stream_topology(), ast_unreal_new_channels(), chan_pjsip_new(), create_local_sdp(), dial_exec_full(), do_forward(), handle_negotiated_sdp(), local_request_with_stream_topology(), media_offer_read_av(), media_offer_write_av(), native_rtp_request_stream_topology_update(), session_refresh_state_get_or_alloc(), sfu_topologies_on_join(), sfu_topologies_on_source_change(), simple_bridge_request_stream_topology_update(), softmix_bridge_stream_sources_update(), topology_change_refresh_data_alloc(), and unreal_colp_stream_topology_request_change().
struct ast_stream_topology* ast_stream_topology_create_from_format_cap | ( | struct ast_format_cap * | cap | ) |
A helper function that, given a format capabilities structure, creates a topology and separates the media types in format_cap into separate streams.
caps | The format capabilities structure (NULL creates an empty topology) |
non-NULL | success |
NULL | failure |
Definition at line 848 of file stream.c.
References ao2_cleanup, ao2_ref, ast_codec_media_type2str(), ast_format_cap_alloc, ast_format_cap_append_from_cap(), ast_format_cap_count(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_get_framing(), ast_format_cap_has_type(), ast_format_cap_set_framing(), AST_MEDIA_TYPE_END, AST_MEDIA_TYPE_UNKNOWN, ast_stream_alloc(), ast_stream_free(), ast_stream_set_formats(), AST_STREAM_STATE_SENDRECV, ast_stream_topology_alloc(), ast_stream_topology_append_stream(), ast_stream_topology_free(), MIN_STREAM_NAME_LEN, ast_stream::name, NULL, ast_stream::position, ast_stream::state, ast_stream::type, and type.
Referenced by ast_channel_nativeformats_set(), AST_TEST_DEFINE(), ast_unreal_alloc(), chan_pjsip_request(), local_request(), request_channel(), and sip_endpoint_apply_handler().
struct ast_stream_topology* ast_stream_topology_create_resolved | ( | struct ast_stream_topology * | pending_topology, |
struct ast_stream_topology * | validation_topology, | ||
struct ast_stream_codec_negotiation_prefs * | prefs, | ||
struct ast_str ** | error_message | ||
) |
Create a resolved stream topology from 2 topologies.
pending_topology | The "live" topology created from an SDP, passed through the core, or used to create an SDP. |
configured_topology | The static topology used to validate the pending topology. It MUST have only 1 stream per media type. |
prefs | A pointer to an ast_stream_codec_negotiation_prefs structure. |
error_message | If supplied, error messages will be appended. |
The streams in the resolved topology will contain all of the attributes of the corresponding stream from the pending topology. It's format_caps however will contain only the formats that passed the validation specified by the ast_stream_codec_negotiation_prefs structure. This may mean that some of the streams format_caps will be empty. If that's the case, the stream will be in a REMOVED state. With those rules in mind, a resolved topology will always be returned (unless there's some catastrophic allocation failure) and the resolved topology is guaranteed to have the same number of streams, in the same order, as the pending topology.
NULL | if there was some allocation failure. |
The | joint topology. |
Definition at line 1030 of file stream.c.
References ao2_cleanup, ast_stream_clone(), ast_stream_create_resolved(), ast_stream_free(), ast_stream_get_format_count(), ast_stream_set_state(), AST_STREAM_STATE_REMOVED, ast_stream_topology_alloc(), ast_stream_topology_append_stream(), ast_stream_topology_get_first_stream_by_type(), AST_VECTOR_GET, AST_VECTOR_SIZE, NULL, and ast_stream::type.
int ast_stream_topology_del_stream | ( | struct ast_stream_topology * | topology, |
unsigned int | position | ||
) |
Delete a specified stream from the given topology.
topology | The topology of streams. |
position | The topology position to delete. |
0 | on success. |
-1 | on failure. |
Definition at line 825 of file stream.c.
References ast_assert, ast_stream_free(), AST_VECTOR_GET, AST_VECTOR_REMOVE_ORDERED, AST_VECTOR_SIZE, NULL, and ast_stream::position.
Referenced by AST_TEST_DEFINE(), and sip_session_refresh().
int ast_stream_topology_equal | ( | const struct ast_stream_topology * | left, |
const struct ast_stream_topology * | right | ||
) |
Compare two stream topologies to see if they are equal.
left | The left topology |
right | The right topology |
1 | topologies are equivalent |
0 | topologies differ |
Definition at line 696 of file stream.c.
References ast_assert, ast_format_cap_count(), ast_format_cap_identical(), ast_stream_get_formats(), ast_stream_get_name(), ast_stream_get_state(), ast_stream_get_type(), ast_stream_topology_get_count(), ast_stream_topology_get_stream(), and NULL.
Referenced by ast_channel_request_stream_topology_change(), handle_negotiated_sdp(), reschedule_reinvite(), sip_session_refresh(), and test_is_media_state_equal().
void ast_stream_topology_free | ( | struct ast_stream_topology * | topology | ) |
Unreference and destroy a stream topology.
topology | The topology of streams |
Definition at line 743 of file stream.c.
References ao2_cleanup.
Referenced by ast_channel_internal_set_stream_topology(), ast_sip_session_media_state_reset(), ast_stream_topology_clone(), ast_stream_topology_create_from_format_cap(), AST_TEST_DEFINE(), ast_unreal_alloc(), ast_unreal_destructor(), ast_unreal_new_channels(), build_topology(), chan_pjsip_new(), chan_pjsip_request(), create_local_sdp(), dial_exec_full(), do_forward(), endpoint_destructor(), local_request(), make_channel(), native_rtp_bridge_join(), native_rtp_stream_topology_changed(), request_channel(), sfu_topologies_on_join(), sfu_topologies_on_source_change(), simple_bridge_join(), simple_bridge_stream_topology_changed(), softmix_bridge_leave(), softmix_bridge_stream_sources_update(), softmix_bridge_stream_topology_changed(), stream_echo_exec(), stream_echo_topology_alloc(), and unreal_colp_stream_topology_request_change().
int ast_stream_topology_get_active_count | ( | const struct ast_stream_topology * | topology | ) |
Get the number of active (non-REMOVED) streams in a topology.
topology | The topology of streams |
Definition at line 772 of file stream.c.
References ast_assert, AST_STREAM_STATE_REMOVED, AST_VECTOR_GET, AST_VECTOR_SIZE, NULL, and ast_stream::state.
int ast_stream_topology_get_count | ( | const struct ast_stream_topology * | topology | ) |
Get the number of streams in a topology.
topology | The topology of streams |
Definition at line 765 of file stream.c.
References ast_assert, AST_VECTOR_SIZE, and NULL.
Referenced by append_all_streams(), append_source_streams(), ast_sip_session_create_outgoing(), ast_sip_session_is_pending_stream_default(), ast_stream_topology_equal(), ast_stream_topology_map(), AST_TEST_DEFINE(), ast_write_stream(), chan_pjsip_new(), check_stream_positions(), create_local_sdp(), handle_incoming_sdp(), handle_negotiated_sdp(), handle_showchan(), is_media_state_valid(), local_request_with_stream_topology(), make_channel(), map_source_to_destinations(), media_offer_read_av(), native_rtp_bridge_join(), native_rtp_request_stream_topology_update(), remove_all_original_streams(), remove_destination_streams(), resolve_refresh_media_states(), sdp_requires_deferral(), simple_bridge_join(), simple_bridge_request_stream_topology_update(), sip_session_refresh(), softmix_bridge_stream_sources_update(), softmix_bridge_stream_topology_changed(), stream_echo_topology_alloc(), stream_echo_write(), test_media_add(), unreal_colp_stream_topology_request_change(), and validate_original_streams().
struct ast_stream* ast_stream_topology_get_first_stream_by_type | ( | const struct ast_stream_topology * | topology, |
enum ast_media_type | type | ||
) |
Gets the first active stream of a specific type from the topology.
topology | The topology of streams |
type | The media type |
non-NULL | success |
NULL | failure |
Definition at line 964 of file stream.c.
References ast_assert, AST_STREAM_STATE_REMOVED, AST_VECTOR_GET, AST_VECTOR_SIZE, NULL, ast_stream::state, and ast_stream::type.
Referenced by ast_stream_topology_create_resolved(), AST_TEST_DEFINE(), channel_set_default_streams(), and media_offer_write_av().
struct ast_format_cap* ast_stream_topology_get_formats | ( | struct ast_stream_topology * | topology | ) |
Create a format capabilities structure representing the topology.
A helper function that, given a stream topology, creates a format capabilities structure containing all formats from all active streams.
topology | The topology of streams |
non-NULL | success (the resulting format caps must be unreffed by the caller) |
NULL | failure |
Definition at line 930 of file stream.c.
References AST_MEDIA_TYPE_UNKNOWN, and ast_stream_topology_get_formats_by_type().
Referenced by AST_TEST_DEFINE(), ast_unreal_alloc_stream_topology(), chan_pjsip_new(), compatible_formats_exist(), and request_channel().
struct ast_format_cap* ast_stream_topology_get_formats_by_type | ( | struct ast_stream_topology * | topology, |
enum ast_media_type | type | ||
) |
Create a format capabilities structure containing all the formats from all the streams of a particular type in the topology.
A helper function that, given a stream topology and a media type, creates a format capabilities structure containing all formats from all active streams with the particular type.
topology | The topology of streams |
type | The media type |
non-NULL | success (the resulting format caps must be unreffed by the caller) |
NULL | failure |
Definition at line 902 of file stream.c.
References ast_assert, ast_format_cap_alloc, ast_format_cap_append_from_cap(), AST_FORMAT_CAP_FLAG_DEFAULT, AST_MEDIA_TYPE_UNKNOWN, AST_STREAM_STATE_REMOVED, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_stream::formats, NULL, ast_stream::state, and ast_stream::type.
Referenced by ast_stream_topology_get_formats().
struct ast_stream* ast_stream_topology_get_stream | ( | const struct ast_stream_topology * | topology, |
unsigned int | position | ||
) |
Get a specific stream from the topology.
topology | The topology of streams |
position | The topology position to get |
non-NULL | success |
NULL | failure |
Definition at line 788 of file stream.c.
References ast_assert, AST_VECTOR_GET, and NULL.
Referenced by __ast_read(), append_all_streams(), append_source_streams(), ast_sip_session_create_outgoing(), ast_sip_session_is_pending_stream_default(), ast_sip_session_media_state_add(), ast_sip_session_media_state_clone(), ast_stream_topology_equal(), ast_stream_topology_map(), AST_TEST_DEFINE(), ast_write_stream(), check_stream_positions(), create_local_sdp(), handle_incoming_sdp(), handle_negotiated_sdp(), handle_showchan(), is_compatible_format(), is_media_state_valid(), local_request_with_stream_topology(), map_source_to_destinations(), media_offer_read_av(), native_rtp_request_stream_topology_update(), remove_all_original_streams(), remove_destination_streams(), resolve_refresh_media_states(), sdp_requires_deferral(), simple_bridge_request_stream_topology_update(), sip_session_refresh(), softmix_bridge_stream_sources_update(), softmix_bridge_stream_topology_changed(), stream_echo_topology_alloc(), stream_echo_write(), stream_echo_write_error(), test_media_add(), unreal_colp_stream_topology_request_change(), and validate_original_streams().
void ast_stream_topology_map | ( | const struct ast_stream_topology * | topology, |
struct ast_vector_int * | types, | ||
struct ast_vector_int * | v0, | ||
struct ast_vector_int * | v1 | ||
) |
Map a given topology's streams to the given types.
topology | The topology to map |
types | The media types to be mapped |
v0 | Index mapping of topology to types |
v1 | Index mapping of types to topology |
Definition at line 985 of file stream.c.
References AST_MEDIA_TYPE_END, ast_stream_get_type(), ast_stream_topology_get_count(), ast_stream_topology_get_stream(), AST_VECTOR_APPEND, AST_VECTOR_ELEM_DEFAULT_CMP, AST_VECTOR_FREE, AST_VECTOR_GET_INDEX_NTH, AST_VECTOR_INIT, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, and type.
Referenced by ast_bridge_channel_stream_map(), and AST_TEST_DEFINE().
int ast_stream_topology_set_stream | ( | struct ast_stream_topology * | topology, |
unsigned int | position, | ||
struct ast_stream * | stream | ||
) |
Set a specific position in a topology.
topology | The topology of streams |
position | The topology position to set |
stream | The stream to put in its place |
0 | success |
-1 | failure |
Definition at line 796 of file stream.c.
References ast_assert, ast_codec_media_type2str(), ast_stream_free(), ast_strlen_zero, AST_VECTOR_APPEND, AST_VECTOR_GET, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, MIN_STREAM_NAME_LEN, ast_stream::name, ast_stream::position, and ast_stream::type.
Referenced by append_all_streams(), AST_TEST_DEFINE(), handle_incoming_sdp(), remove_all_original_streams(), resolve_refresh_media_states(), sdp_requires_deferral(), t38_create_media_state(), and test_media_add().
const char* ast_stream_topology_to_str | ( | const struct ast_stream_topology * | topology, |
struct ast_str ** | buf | ||
) |
Get a string representing the topology for debugging/display purposes.
topology | A stream topology |
buf | A pointer to an ast_str* used for the output. |
"" | (empty string) if either buf or *buf are NULL |
(null topology) | if *topology was NULL |
<topology_representation> | otherwise |
Return format: <final>? <stream> ...
Sample return: "final <audio:audio:sendrecv (ulaw,g722)> <video:video:sendonly (h264)>"
Definition at line 936 of file stream.c.
References ast_str_append(), ast_str_buffer(), ast_stream_to_str(), AST_VECTOR_GET, AST_VECTOR_SIZE, and S_COR.
Referenced by ast_channel_request_stream_topology_change(), ast_channel_set_stream_topology(), ast_sip_session_create_outgoing(), call(), chan_pjsip_call(), chan_pjsip_indicate(), chan_pjsip_request_with_stream_topology(), compatible_formats_exist(), dial_exec_full(), is_media_state_valid(), on_topology_change_response(), resolve_refresh_media_states(), send_topology_change_refresh(), session_on_tsx_state(), sip_session_refresh(), softmix_bridge_stream_sources_update(), and wait_for_answer().
|
static |
Definition at line 641 of file stream.c.
References ast_stream_free(), AST_VECTOR_CALLBACK_VOID, and AST_VECTOR_FREE.
Referenced by ast_stream_topology_alloc().
const char* ast_stream_codec_negotiation_keep_map[] |
"keep" enum to string map
const char* ast_stream_codec_negotiation_operation_map[] |
const char* ast_stream_codec_negotiation_params_map[] |
const char* ast_stream_codec_negotiation_prefer_map[] |
"prefer" enum to string map
const char* ast_stream_codec_negotiation_transcode_map[] |
"transcode" state enum to string map
const char* ast_stream_state_map[] |
Stream state enum to string map.
Definition at line 223 of file stream.c.
Referenced by ast_stream_to_str().