stream: Add ast_stream_topology_del_stream() and unit test.

Change-Id: If07e3c716a2e3ff85ae905c17572ea6ec3cdc1f9
This commit is contained in:
Richard Mudgett
2017-06-09 19:03:05 -05:00
parent 15c04db3bd
commit 06265b8c8a
3 changed files with 184 additions and 0 deletions

View File

@@ -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)
{