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);
203 value = strtok_r(
NULL,
": ", &saveptr2);
205 if (!name || !value) {
207 ast_str_append(error_message, 0,
"Codec preference '%s' is invalid", pref);
212 set_pref_value(name, value, prefs, OPERATION, operation, error_message);
213 set_pref_value(name, value, prefs, PREFER, prefer, error_message);
215 set_pref_value(name, value, prefs, TRANSCODE, transcode, error_message);
217 current_value =
NULL;
231 #define MIN_STREAM_NAME_LEN 16 238 stream =
ast_calloc(1,
sizeof(*stream) + name_len + 1);
246 strcpy(stream->
name,
S_OR(name,
""));
260 const char *stream_name;
267 stream_name = name ?: 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 976 if (stream->
type == type
986 struct ast_vector_int *types,
struct ast_vector_int *v0,
struct ast_vector_int *v1)
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;
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
struct ast_variable * next
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
enum sip_cc_notify_state state
struct ast_rtp_codecs * rtp_codecs
The rtp_codecs used by the stream.
const char * ast_stream_codec_negotiation_prefer_map[]
"prefer" enum to string map
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.
#define AST_VECTOR_GET_INDEX_NTH(vec, nth, value, cmp)
Get the nth index from a vector that matches the given comparison.
Asterisk main include file. File version handling, generic pbx functions.
struct ast_format_cap * ast_stream_topology_get_formats(struct ast_stream_topology *topology)
Create a format capabilities structure representing the topology.
enum ast_stream_state ast_stream_str2state(const char *str)
Convert a string to a stream state.
String manipulation functions.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
media_type
Media types generate different "dummy answers" for not accepting the offer of a media stream...
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 char * ast_stream_codec_negotiation_keep_map[]
"keep" enum to string map
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
#define AST_VECTOR_ELEM_DEFAULT_CMP(elem, value)
Default comparator for AST_VECTOR_REMOVE_ELEM_UNORDERED()
#define AST_STREAM_MAX_CODEC_PREFS_LENGTH
Define for allocating buffer space for to_str() functions.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
const char * ast_stream_state_map[]
Stream state enum to string map.
enum ast_stream_codec_negotiation_prefs_operation_values operation
const char * ast_codec_media_type2str(enum ast_media_type type)
Conversion function to take a media type and turn it into a string.
struct ast_format_cap * formats
Current formats negotiated on the stream.
Structure for variables, used for configurations and for channel variables.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Set when the stream has been removed/declined.
int ast_stream_get_format_count(const struct ast_stream *stream)
Get the count of the current negotiated formats of a stream.
#define ast_trace(level,...)
Print a basic trace message.
static void stream_topology_destroy(void *data)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
enum ast_stream_codec_negotiation_prefs_prefer_values prefer
#define MIN_STREAM_NAME_LEN
#define ao2_alloc_options(data_size, destructor_fn, options)
Set when the stream is not sending OR receiving media.
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.
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
ast_stream_state
States that a stream may be in.
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_params_map[]
Preference enum to string map.
enum ast_stream_state state
The current state of the stream.
void ast_stream_set_type(struct ast_stream *stream, enum ast_media_type type)
Change the media type of a stream.
void ast_stream_free(struct ast_stream *stream)
Destroy a media stream representation.
#define ast_strlen_zero(foo)
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
char name[0]
Name for the stream within the context of the channel it is on.
struct ast_stream * ast_stream_alloc(const char *name, enum ast_media_type type)
Create a new media stream representation.
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.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Configuration File Parser.
int group
The group that the stream is part of.
#define ast_str_tmp(init_len, __expr)
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...
#define ast_stream_codec_operation_to_str(value)
Safely get the name of an "operation" parameter 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...
void ast_stream_set_group(struct ast_stream *stream, int group)
Set the stream group for a stream.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
enum ast_media_type type
The type of media the stream is handling.
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.
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.
#define ao2_ref(o, delta)
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
const char * ast_stream_codec_negotiation_operation_map[]
"operation" enum to string map
#define AST_VECTOR_REMOVE_ORDERED(vec, idx)
Remove an element from a vector by index while maintaining order.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define AST_VECTOR(name, type)
Define a vector structure.
#define ast_variable_new(name, value, filename)
#define TOPOLOGY_INITIAL_STREAM_COUNT
int ast_stream_topology_append_stream(struct ast_stream_topology *topology, struct ast_stream *stream)
Append a stream to the topology.
struct ast_stream_topology * ast_stream_topology_clone(const struct ast_stream_topology *topology)
Create a deep clone of an existing stream topology.
enum ast_stream_codec_negotiation_prefs_keep_values keep
void ast_stream_set_formats(struct ast_stream *stream, struct ast_format_cap *caps)
Set 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.
const char * ast_stream_codec_negotiation_transcode_map[]
"transcode" state enum to string map
Set when the stream is sending and receiving media.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
struct ast_variable * ast_stream_get_metadata_list(const struct ast_stream *stream)
Get all stream metadata keys.
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...
#define ast_stream_codec_keep_to_str(value)
Safely get the name of a "keep" parameter value.
#define ast_stream_codec_transcode_to_str(value)
Safely get the name of a "transcode" parameter value.
Set when the stream is sending media only.
#define ast_calloc(num, len)
A wrapper for calloc()
int ast_stream_set_metadata(struct ast_stream *stream, const char *m_key, const char *value)
Set a stream metadata value.
#define SCOPE_ENTER(level,...)
Non RAII_VAR Scope Trace macros The advantage of these macros is that the EXITs will have the actual ...
Vector container support.
#define TRACE_ATLEAST(level)
int ast_stream_topology_del_stream(struct ast_stream_topology *topology, unsigned int position)
Delete a specified stream from the given topology.
void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs)
Destroy the contents of an RTP codecs structure (but not the structure itself)
Support for logging to various files, console and syslog Configuration in file logger.conf.
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
Scope Exit with return value.
int ast_stream_get_position(const struct ast_stream *stream)
Get the position of the stream in the topology.
const char * ast_stream_state2str(enum ast_stream_state state)
Convert the state of a stream into a string.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
struct ast_rtp_codecs * ast_stream_get_rtp_codecs(const struct ast_stream *stream)
Get 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.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
enum ast_stream_codec_negotiation_prefs_transcode_values transcode
#define AST_VECTOR_REPLACE(vec, idx, elem)
Replace an element at a specific position in a vector, growing the vector if needed.
#define ast_assert_return(a,...)
struct ast_stream * ast_stream_clone(const struct ast_stream *stream, const char *name)
Create a deep clone of an existing stream.
#define ast_stream_codec_prefer_to_str(value)
Safely get the name of a "prefer" parameter value.
#define ast_stream_codec_param_to_str(value)
Safely get the name of a preference parameter.
const char * ast_stream_get_name(const struct ast_stream *stream)
Get the name of a stream.
ast_media_type
Types of media.
int ast_stream_topology_get_active_count(const struct ast_stream_topology *topology)
Get the number of active (non-REMOVED) streams in a topology.
Pluggable RTP Architecture.
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.
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state)
Set the state of a stream.
#define set_pref_value(_name, _value, _prefs, _UC, _lc, _error_message)
void ast_stream_set_rtp_codecs(struct ast_stream *stream, struct ast_rtp_codecs *rtp_codecs)
Set rtp_codecs associated with the stream.
Set when the stream is receiving media only.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
struct ast_variable * metadata
Stream metadata vector.
unsigned int position
The position of the stream in the topology.
#define ast_variable_list_append(head, new_var)
const char * ast_stream_get_metadata(const struct ast_stream *stream, const char *m_key)
Get a stream metadata value.
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
int ast_stream_get_group(const struct ast_stream *stream)
Get the stream group that a stream is part of.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.