]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
stream: Make ast_stream_topology_create_from_format_cap() allow NULL cap.
authorRichard Mudgett <rmudgett@digium.com>
Fri, 21 Apr 2017 00:25:10 +0000 (19:25 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Fri, 28 Apr 2017 00:08:05 +0000 (19:08 -0500)
Change-Id: Ie29760c49c25d7022ba2124698283181a0dd5d08

include/asterisk/stream.h
main/channel_internal_api.c
main/stream.c

index 924bfb65cdf408e79866fc1bc6261f283634bee7..1e07407a9f834625633800c393821d70f44a2a87 100644 (file)
@@ -356,7 +356,7 @@ int ast_stream_topology_set_stream(struct ast_stream_topology *topology,
  * creates a topology and separates the media types in format_cap into
  * separate streams.
  *
- * \param caps The format capabilities structure
+ * \param caps The format capabilities structure (NULL creates an empty topology)
  *
  * \retval non-NULL success
  * \retval NULL failure
index d838ea80cfb6d3d1cf11a9802f745b96462cf492..7f32b219665ab75f8d17e0eca0f9f16b6ef6b6b8 100644 (file)
@@ -852,14 +852,10 @@ void ast_channel_nativeformats_set(struct ast_channel *chan,
                return;
        }
 
-       if ((!ast_channel_is_multistream(chan)) || !value) {
+       if (!ast_channel_is_multistream(chan) || !value) {
                struct ast_stream_topology *new_topology;
 
-               if (!value) {
-                       new_topology = ast_stream_topology_alloc();
-               } else {
-                       new_topology = ast_stream_topology_create_from_format_cap(value);
-               }
+               new_topology = ast_stream_topology_create_from_format_cap(value);
                ast_channel_internal_set_stream_topology(chan, new_topology);
        }
 }
index cf2633e1b76a7c6effa41196fc635295f8e06554..39b6b1b13f63db2fc2effe6d96014d13ee33b2a8 100644 (file)
@@ -345,11 +345,9 @@ struct ast_stream_topology *ast_stream_topology_create_from_format_cap(
        struct ast_stream_topology *topology;
        enum ast_media_type type;
 
-       ast_assert(cap != NULL);
-
        topology = ast_stream_topology_alloc();
-       if (!topology) {
-               return NULL;
+       if (!topology || !cap || !ast_format_cap_count(cap)) {
+               return topology;
        }
 
        for (type = AST_MEDIA_TYPE_UNKNOWN + 1; type < AST_MEDIA_TYPE_END; type++) {