]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
format_cap: Don't append the 'none' format when appending all. 11/1611/3
authorJoshua Colp <jcolp@digium.com>
Thu, 12 Nov 2015 12:24:06 +0000 (08:24 -0400)
committerJoshua Colp <jcolp@digium.com>
Thu, 12 Nov 2015 13:46:54 +0000 (09:46 -0400)
When appending all formats of a type all the codecs are iterated
and added. This operation was incorrectly adding the ast_format_none
format which is special in that it is supposed to be used when no
format is present. It shouldn't be appended.

ASTERISK-25535

Change-Id: I7b00f3bdf4a5f3022e483d6ece602b1e8b12827c

main/format_cap.c
tests/test_format_cap.c

index 4739efa0a7296cddd1450709b5583ad184d88e4e..8d6046ab2a8cc90c6a64badaf844ed236a8419a0 100644 (file)
@@ -265,7 +265,15 @@ int ast_format_cap_append_by_type(struct ast_format_cap *cap, enum ast_media_typ
                }
 
                format = ast_format_cache_get(codec->name);
+
+               if (format == ast_format_none) {
+                       ao2_ref(format, -1);
+                       ao2_ref(codec, -1);
+                       continue;
+               }
+
                if (!format || (codec != ast_format_get_codec(format))) {
+                       ao2_cleanup(format);
                        format = ast_format_create(codec);
                }
                ao2_ref(codec, -1);
index e1ae553c7a2635b34e4e908dfb53d88540a7aac5..ed5427fa20c1ee9429ddd1fbbb31b08c116fae21 100644 (file)
@@ -245,7 +245,7 @@ AST_TEST_DEFINE(format_cap_append_all_unknown)
        } else if (!ast_format_cap_has_type(caps, AST_MEDIA_TYPE_VIDEO)) {
                ast_test_status_update(test, "Added all media formats but no video formats exist when they should\n");
                return AST_TEST_FAIL;
-       } else if ((ast_format_cap_count(caps) + 1) != ast_codec_get_max()) {
+       } else if ((ast_format_cap_count(caps) + 1) != (ast_codec_get_max() - 1)) {
                ast_test_status_update(test, "The number of formats in the capabilities structure does not match known number\n");
                return AST_TEST_FAIL;
        }