mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
stream: Enforce formats immutability and ensure formats exist.
Some places in Asterisk did not treat the formats on a stream as immutable when they are. The ast_stream_get_formats function is now const to enforce this and parts of Asterisk have been updated to take this into account. Some violations of this were also fixed along the way. An additional minor tweak is that streams are now allocated with an empty format capabilities structure removing the need in various places to check that one is present on the stream. ASTERISK-28846 Change-Id: I32f29715330db4ff48edd6f1f359090458a9bfbe
This commit is contained in:
committed by
Kevin Harwell
parent
9ad3d2829c
commit
1c5e68580a
@@ -108,6 +108,12 @@ struct ast_stream *ast_stream_alloc(const char *name, enum ast_media_type type)
|
||||
stream->group = -1;
|
||||
strcpy(stream->name, S_OR(name, "")); /* Safe */
|
||||
|
||||
stream->formats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
|
||||
if (!stream->formats) {
|
||||
ast_free(stream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
@@ -179,7 +185,7 @@ void ast_stream_set_type(struct ast_stream *stream, enum ast_media_type type)
|
||||
stream->type = type;
|
||||
}
|
||||
|
||||
struct ast_format_cap *ast_stream_get_formats(const struct ast_stream *stream)
|
||||
const struct ast_format_cap *ast_stream_get_formats(const struct ast_stream *stream)
|
||||
{
|
||||
ast_assert(stream != NULL);
|
||||
|
||||
|
Reference in New Issue
Block a user