diff options
author | Richard Mudgett <rmudgett@digium.com> | 2017-06-09 19:03:05 -0500 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2017-06-15 09:42:15 -0500 |
commit | 06265b8c8a7e38707c76b5ca257882223797e612 (patch) | |
tree | ff5ccc412f863357fbff7e7d306a6f59e4410534 /main/stream.c | |
parent | 15c04db3bd976edc60393f6261c60ca779a1f8d2 (diff) |
stream: Add ast_stream_topology_del_stream() and unit test.
Change-Id: If07e3c716a2e3ff85ae905c17572ea6ec3cdc1f9
Diffstat (limited to 'main/stream.c')
-rw-r--r-- | main/stream.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/main/stream.c b/main/stream.c index fb146931d..b61774474 100644 --- a/main/stream.c +++ b/main/stream.c @@ -349,6 +349,29 @@ int ast_stream_topology_set_stream(struct ast_stream_topology *topology, return AST_VECTOR_REPLACE(&topology->streams, position, stream); } +int ast_stream_topology_del_stream(struct ast_stream_topology *topology, + unsigned int position) +{ + struct ast_stream *stream; + + ast_assert(topology != NULL); + + if (AST_VECTOR_SIZE(&topology->streams) <= position) { + return -1; + } + + stream = AST_VECTOR_REMOVE_ORDERED(&topology->streams, position); + ast_stream_free(stream); + + /* Fix up higher stream position indices */ + for (; position < AST_VECTOR_SIZE(&topology->streams); ++position) { + stream = AST_VECTOR_GET(&topology->streams, position); + stream->position = position; + } + + return 0; +} + struct ast_stream_topology *ast_stream_topology_create_from_format_cap( struct ast_format_cap *cap) { |