From 328b6bc55d95d40936743ec1ef390026644e1a4c Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 21 May 2025 10:54:48 +0200 Subject: [PATCH] core: gstvalue: fix ANY/EMPTY caps (features) hash They should be special cases as both do not have any actual caps/features. Part-of: --- subprojects/gstreamer/gst/gstvalue.c | 16 ++++++++++++++++ subprojects/gstreamer/tests/check/gst/gstvalue.c | 2 ++ 2 files changed, 18 insertions(+) diff --git a/subprojects/gstreamer/gst/gstvalue.c b/subprojects/gstreamer/gst/gstvalue.c index d8e94a72ec..dce0d27f0f 100644 --- a/subprojects/gstreamer/gst/gstvalue.c +++ b/subprojects/gstreamer/gst/gstvalue.c @@ -8365,6 +8365,14 @@ gst_hash_caps_features (const GstCapsFeatures * features, guint * res) { guint i; + if (gst_caps_features_is_any (features)) { + *res = g_str_hash ("ANY"); + return TRUE; + } else if (gst_caps_features_get_size (features) == 0) { + *res = g_str_hash ("EMPTY"); + return TRUE; + } + *res = 0; for (i = 0; i < gst_caps_features_get_size (features); i++) { @@ -8389,6 +8397,14 @@ gst_value_hash_caps (const GValue * v, guint * res) guint i; guint n = gst_caps_get_size (caps); + if (gst_caps_is_any (caps)) { + *res = g_str_hash ("ANY"); + return TRUE; + } else if (n == 0) { + *res = g_str_hash ("EMPTY"); + return TRUE; + } + *res = 0; for (i = 0; i < n; i++) { GstCapsFeatures *features = gst_caps_get_features (caps, i); diff --git a/subprojects/gstreamer/tests/check/gst/gstvalue.c b/subprojects/gstreamer/tests/check/gst/gstvalue.c index 9e6e8d0abf..58546222ee 100644 --- a/subprojects/gstreamer/tests/check/gst/gstvalue.c +++ b/subprojects/gstreamer/tests/check/gst/gstvalue.c @@ -4168,6 +4168,7 @@ GST_START_TEST (test_hash) {GST_TYPE_CAPS, "video/x-raw", "audio/x-raw", TRUE}, {GST_TYPE_CAPS, "video/x-raw,width=1920", "video/x-raw,width=800", TRUE}, {GST_TYPE_CAPS, "video/x-raw", "video/x-raw(memory:DMABuf)", TRUE}, + {GST_TYPE_CAPS, "ANY", "EMPTY", TRUE}, {GST_TYPE_TAG_LIST, "taglist, title=(string)Title, artist=(string)Artist", "taglist, title=(string)Title2, artist=(string)Artist", TRUE}, {G_TYPE_DATE, "1984-11-30", "1985-11-30", TRUE}, @@ -4180,6 +4181,7 @@ GST_START_TEST (test_hash) TRUE}, {GST_TYPE_LIST, "{1, 2}", "{1, 3}", TRUE}, {GST_TYPE_CAPS_FEATURES, "memory:DMABuf", "memory:GLMemory", FALSE}, + {GST_TYPE_CAPS_FEATURES, "ANY", "", FALSE}, }; /* check that a and b are equal */