134 if (!prefs || !
buf || !*
buf) {
159#define set_pref_value(_name, _value, _prefs, _UC, _lc, _error_message) \
162 if (strcmp(_name, ast_stream_codec_negotiation_params_map[CODEC_NEGOTIATION_PARAM_ ## _UC]) == 0) { \
164 for (i = CODEC_NEGOTIATION_ ## _UC ## _UNSPECIFIED + 1; i < CODEC_NEGOTIATION_ ## _UC ## _END; i++) { \
165 if (strcmp(value, ast_stream_codec_negotiation_ ## _lc ## _map[i]) == 0) { \
169 if ( prefs->_lc == CODEC_NEGOTIATION_ ## _UC ## _UNSPECIFIED) { \
171 if (_error_message) { \
172 ast_str_append(_error_message, 0, "Codec preference '%s' has invalid value '%s'", name, value); \
182 struct ast_str **error_message)
201 for (current_value = initial_value; (pref = strtok_r(current_value,
",", &saveptr1)) !=
NULL; ) {
202 name = strtok_r(pref,
": ", &saveptr2);
207 ast_str_append(error_message, 0,
"Codec preference '%s' is invalid", pref);
217 current_value =
NULL;
231#define MIN_STREAM_NAME_LEN 16
238 stream =
ast_calloc(1,
sizeof(*stream) + name_len + 1);
260 const char *stream_name;
269 new_stream =
ast_calloc(1,
sizeof(*stream) + name_len + 1);
274 memcpy(new_stream, stream,
sizeof(*new_stream));
275 strcpy(new_stream->
name, stream_name);
276 new_stream->
group = -1;
377 return stream->
state;
408 if (!strcmp(
"sendrecv",
str)) {
411 if (!strcmp(
"sendonly",
str)) {
414 if (!strcmp(
"recvonly",
str)) {
417 if (!strcmp(
"inactive",
str)) {
431 if (strcmp(v->
name, m_key) == 0) {
472 if (strcmp(v->
name, m_key) == 0) {
527 struct ast_str **error_message)
535 SCOPE_ENTER(4,
"Pending: %s Validation: %s Prefs: %s\n",
540 if (!pending_stream || !validation_stream || !prefs || !joint_caps
550 preferred_caps = pending_stream->
formats;
551 nonpreferred_caps = validation_stream->
formats;
553 preferred_caps = validation_stream->
formats;
554 nonpreferred_caps = pending_stream->
formats;
580 ast_str_append(error_message, 0,
"No common formats available for media type '%s' ",
602 ast_str_append(error_message, 0,
"No common formats available for media type '%s' ",
649#define TOPOLOGY_INITIAL_STREAM_COUNT 2
1005 for (i = 0; i < size; ++i) {
1038 if (!pending_topology || !configured_topology || !joint_topology) {
1049 if (!configured_stream) {
1051 if (!joint_stream) {
1058 if (!joint_stream) {
1074 return joint_topology;
1081 return stream->
group;
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
@ AO2_ALLOC_OPT_LOCK_NOLOCK
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
ast_media_type
Types of media.
const char * ast_codec_media_type2str(enum ast_media_type type)
Conversion function to take a media type and turn it into a string.
#define TRACE_ATLEAST(level)
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define SCOPE_ENTER(level,...)
#define ast_trace(level,...)
Configuration File Parser.
#define ast_variable_new(name, value, filename)
#define ast_variable_list_append(head, new_var)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Support for logging to various files, console and syslog Configuration in file logger....
Pluggable RTP Architecture.
void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs)
Destroy the contents of an RTP codecs structure (but not the structure itself)
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
struct ast_rtp_codecs * ast_stream_get_rtp_codecs(const struct ast_stream *stream)
Get rtp_codecs associated with the stream.
void ast_stream_set_rtp_codecs(struct ast_stream *stream, struct ast_rtp_codecs *rtp_codecs)
Set rtp_codecs associated with the stream.
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.
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.
struct ast_stream * ast_stream_alloc(const char *name, enum ast_media_type type)
Create a new media stream representation.
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.
const char * ast_stream_get_metadata(const struct ast_stream *stream, const char *m_key)
Get a stream metadata value.
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 particula...
const char * ast_stream_get_name(const struct ast_stream *stream)
Get the name of a stream.
int ast_stream_set_metadata(struct ast_stream *stream, const char *m_key, const char *value)
Set a stream metadata value.
int ast_stream_get_position(const struct ast_stream *stream)
Get the position of the stream in the topology.
static void stream_topology_destroy(void *data)
const char * ast_stream_state2str(enum ast_stream_state state)
Convert the state of a stream into a string.
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state)
Set the state of a stream.
int ast_stream_topology_append_stream(struct ast_stream_topology *topology, struct ast_stream *stream)
Append a stream to the topology.
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.
struct ast_stream * ast_stream_clone(const struct ast_stream *stream, const char *name)
Create a deep clone of an existing stream.
enum ast_stream_state ast_stream_str2state(const char *str)
Convert a string to a stream state.
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.
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
int ast_stream_get_format_count(const struct ast_stream *stream)
Get the count of the current negotiated formats of a stream.
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
int ast_stream_topology_del_stream(struct ast_stream_topology *topology, unsigned int position)
Delete a specified stream from the given topology.
int ast_stream_get_group(const struct ast_stream *stream)
Get the stream group that a stream is part of.
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
void ast_stream_set_formats(struct ast_stream *stream, struct ast_format_cap *caps)
Set the current negotiated formats of a stream.
const char * ast_stream_codec_negotiation_transcode_map[]
"transcode" state enum to string map
int ast_stream_topology_get_active_count(const struct ast_stream_topology *topology)
Get the number of active (non-REMOVED) streams in a topology.
void ast_stream_set_type(struct ast_stream *stream, enum ast_media_type type)
Change the media type of a stream.
const char * ast_stream_codec_negotiation_params_map[]
Preference enum to string map.
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.
const char * ast_stream_codec_negotiation_keep_map[]
"keep" enum to string map
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 m...
struct ast_variable * ast_stream_get_metadata_list(const struct ast_stream *stream)
Get all stream metadata keys.
#define TOPOLOGY_INITIAL_STREAM_COUNT
#define MIN_STREAM_NAME_LEN
struct ast_format_cap * ast_stream_topology_get_formats(struct ast_stream_topology *topology)
Create a format capabilities structure representing the topology.
const char * ast_stream_state_map[]
Stream state enum to string map.
void ast_stream_free(struct ast_stream *stream)
Destroy a media stream representation.
const char * ast_stream_codec_negotiation_prefer_map[]
"prefer" enum to string map
#define set_pref_value(_name, _value, _prefs, _UC, _lc, _error_message)
void ast_stream_set_group(struct ast_stream *stream, int group)
Set the stream group for a stream.
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.
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.
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
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.
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.
struct ast_stream_topology * ast_stream_topology_clone(const struct ast_stream_topology *topology)
Create a deep clone of an existing stream topology.
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.
const char * ast_stream_codec_negotiation_operation_map[]
"operation" enum to string map
#define AST_STREAM_MAX_CODEC_PREFS_LENGTH
Define for allocating buffer space for to_str() functions.
@ CODEC_NEGOTIATION_OPERATION_ONLY_PREFERRED
@ CODEC_NEGOTIATION_OPERATION_UNSPECIFIED
@ CODEC_NEGOTIATION_OPERATION_ONLY_NONPREFERRED
@ CODEC_NEGOTIATION_OPERATION_UNION
@ CODEC_NEGOTIATION_OPERATION_INTERSECT
ast_stream_state
States that a stream may be in.
@ AST_STREAM_STATE_RECVONLY
Set when the stream is receiving media only.
@ AST_STREAM_STATE_INACTIVE
Set when the stream is not sending OR receiving media.
@ AST_STREAM_STATE_REMOVED
Set when the stream has been removed/declined.
@ AST_STREAM_STATE_SENDRECV
Set when the stream is sending and receiving media.
@ AST_STREAM_STATE_SENDONLY
Set when the stream is sending media only.
@ CODEC_NEGOTIATION_KEEP_FIRST
@ CODEC_NEGOTIATION_KEEP_UNSPECIFIED
@ CODEC_NEGOTIATION_KEEP_ALL
#define ast_stream_codec_operation_to_str(value)
Safely get the name of an "operation" parameter value.
#define ast_stream_codec_transcode_to_str(value)
Safely get the name of a "transcode" parameter value.
@ CODEC_NEGOTIATION_TRANSCODE_UNSPECIFIED
@ CODEC_NEGOTIATION_TRANSCODE_PREVENT
@ CODEC_NEGOTIATION_TRANSCODE_ALLOW
@ CODEC_NEGOTIATION_PARAM_PREFER
@ CODEC_NEGOTIATION_PARAM_TRANSCODE
@ CODEC_NEGOTIATION_PARAM_KEEP
@ CODEC_NEGOTIATION_PARAM_OPERATION
@ CODEC_NEGOTIATION_PARAM_UNSPECIFIED
@ CODEC_NEGOTIATION_PREFER_CONFIGURED
@ CODEC_NEGOTIATION_PREFER_UNSPECIFIED
@ CODEC_NEGOTIATION_PREFER_PENDING
#define ast_stream_codec_param_to_str(value)
Safely get the name of a preference parameter.
#define ast_stream_codec_prefer_to_str(value)
Safely get the name of a "prefer" parameter value.
#define ast_stream_codec_keep_to_str(value)
Safely get the name of a "keep" parameter value.
String manipulation functions.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Support for dynamic strings.
enum ast_stream_codec_negotiation_prefs_transcode_values transcode
enum ast_stream_codec_negotiation_prefs_operation_values operation
enum ast_stream_codec_negotiation_prefs_keep_values keep
enum ast_stream_codec_negotiation_prefs_prefer_values prefer
struct ast_stream_topology::@402 streams
A vector of all the streams in this topology.
int group
The group that the stream is part of.
struct ast_format_cap * formats
Current formats negotiated on the stream.
unsigned int position
The position of the stream in the topology.
struct ast_rtp_codecs * rtp_codecs
The rtp_codecs used by the stream.
enum ast_media_type type
The type of media the stream is handling.
struct ast_variable * metadata
Stream metadata vector.
enum ast_stream_state state
The current state of the stream.
char name[0]
Name for the stream within the context of the channel it is on.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Integer vector definition.
#define ast_assert_return(a,...)
Vector container support.
#define AST_VECTOR_REMOVE_ORDERED(vec, idx)
Remove an element from a vector by index while maintaining order.
#define AST_VECTOR_REPLACE(vec, idx, elem)
Replace an element at a specific position in a vector, growing the vector if needed.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_GET_INDEX_NTH(vec, nth, value, cmp)
Get the nth index from a vector that matches the given comparison.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_ELEM_DEFAULT_CMP(elem, value)
Default comparator for AST_VECTOR_REMOVE_ELEM_UNORDERED()
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
#define AST_VECTOR(name, type)
Define a vector structure.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.