diff --git a/girs/GstVideo-1.0.gir b/girs/GstVideo-1.0.gir
index f8d0da4987..8ec3a8eef6 100644
--- a/girs/GstVideo-1.0.gir
+++ b/girs/GstVideo-1.0.gir
@@ -2977,6 +2977,20 @@ Formats are sorted by decreasing "quality", using these criteria by priority:
+
+ This is similar to %GST_VIDEO_FORMATS_ALL but includes formats like DMA_DRM
+that do not have a software converter. This should be used for passthrough
+template caps.
+
+
+
+
+ This is similar to %GST_VIDEO_FORMATS_ALL_STR but includes formats like
+DMA_DRM for which no software converter exists. This should be used for
+passthrough template caps.
+
+
+
@@ -18499,6 +18513,25 @@ the #GstVideoFormat if there is one, or NULL otherwise.
+
+ Return all the raw video formats supported by GStreamer including
+special opaque formats such as %GST_VIDEO_FORMAT_DMA_DRM for which
+no software conversion exists. This should be use for passthrough
+template cpas.
+
+
+ an array of #GstVideoFormat
+
+
+
+
+
+
+ the number of elements in the returned array
+
+
+
+
Return all the raw video formats supported by GStreamer.
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/video/video-format.c b/subprojects/gst-plugins-base/gst-libs/gst/video/video-format.c
index 3a2955fbfe..f636d98239 100644
--- a/subprojects/gst-plugins-base/gst-libs/gst/video/video-format.c
+++ b/subprojects/gst-plugins-base/gst-libs/gst/video/video-format.c
@@ -8041,6 +8041,7 @@ gst_video_format_from_string (const gchar * format)
if (strcmp (GST_VIDEO_FORMAT_INFO_NAME (&formats[i].info), format) == 0)
return GST_VIDEO_FORMAT_INFO_FORMAT (&formats[i].info);
}
+
return GST_VIDEO_FORMAT_UNKNOWN;
}
@@ -8204,8 +8205,8 @@ struct RawVideoFormats
guint n;
};
-static gpointer
-generate_raw_video_formats (gpointer data)
+static struct RawVideoFormats *
+generate_video_formats (const gchar * formats)
{
GValue list = G_VALUE_INIT;
struct RawVideoFormats *all = g_new (struct RawVideoFormats, 1);
@@ -8217,7 +8218,7 @@ generate_raw_video_formats (gpointer data)
/* Workaround a bug in our parser that would lead to segfaults
* when deserializing container types using static strings,
* see https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/446 */
- tmp = g_strdup (GST_VIDEO_FORMATS_ALL);
+ tmp = g_strdup (formats);
res = gst_value_deserialize (&list, tmp);
g_assert (res);
g_free (tmp);
@@ -8230,8 +8231,7 @@ generate_raw_video_formats (gpointer data)
all->formats[i] = gst_video_format_from_string (g_value_get_string (v));
g_assert (all->formats[i] != GST_VIDEO_FORMAT_UNKNOWN
- && all->formats[i] != GST_VIDEO_FORMAT_ENCODED
- && all->formats[i] != GST_VIDEO_FORMAT_DMA_DRM);
+ && all->formats[i] != GST_VIDEO_FORMAT_ENCODED);
}
g_value_unset (&list);
@@ -8239,6 +8239,18 @@ generate_raw_video_formats (gpointer data)
return all;
}
+static gpointer
+generate_raw_video_formats (gpointer data)
+{
+ return generate_video_formats (GST_VIDEO_FORMATS_ALL);
+}
+
+static gpointer
+generate_any_video_formats (gpointer data)
+{
+ return generate_video_formats (GST_VIDEO_FORMATS_ANY);
+}
+
/**
* gst_video_formats_raw:
* @len: (out): the number of elements in the returned array
@@ -8263,6 +8275,33 @@ gst_video_formats_raw (guint * len)
return all->formats;
}
+/**
+ * gst_video_formats_any:
+ * @len: (out): the number of elements in the returned array
+ *
+ * Return all the raw video formats supported by GStreamer including
+ * special opaque formats such as %GST_VIDEO_FORMAT_DMA_DRM for which
+ * no software conversion exists. This should be use for passthrough
+ * template cpas.
+ *
+ * Returns: (transfer none) (array length=len): an array of #GstVideoFormat
+ * Since: 1.24
+ */
+const GstVideoFormat *
+gst_video_formats_any (guint * len)
+{
+ static GOnce any_video_formats_once = G_ONCE_INIT;
+ struct RawVideoFormats *all;
+
+ g_return_val_if_fail (len, NULL);
+
+ g_once (&any_video_formats_once, generate_any_video_formats, NULL);
+
+ all = any_video_formats_once.retval;
+ *len = all->n;
+ return all->formats;
+}
+
/**
* gst_video_make_raw_caps:
* @formats: (array length=len) (nullable): an array of raw #GstVideoFormat, or %NULL
@@ -8318,8 +8357,7 @@ gst_video_make_raw_caps_with_features (const GstVideoFormat formats[],
GValue v = G_VALUE_INIT;
g_return_val_if_fail (formats[i] != GST_VIDEO_FORMAT_UNKNOWN
- && formats[i] != GST_VIDEO_FORMAT_ENCODED
- && formats[i] != GST_VIDEO_FORMAT_DMA_DRM, NULL);
+ && formats[i] != GST_VIDEO_FORMAT_ENCODED, NULL);
g_value_init (&v, G_TYPE_STRING);
g_value_set_static_string (&v, gst_video_format_to_string (formats[i]));
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h b/subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h
index 4088d5e322..262cc1bb77 100644
--- a/subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h
+++ b/subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h
@@ -1116,6 +1116,17 @@ gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsi
"GRAY10_LE32, GRAY8"
#endif
+/**
+ * GST_VIDEO_FORMATS_ANY_STR:
+ *
+ * This is similar to %GST_VIDEO_FORMATS_ALL_STR but includes formats like
+ * DMA_DRM for which no software converter exists. This should be used for
+ * passthrough template caps.
+ *
+ * Since: 1.24
+ */
+#define GST_VIDEO_FORMATS_ANY_STR "DMA_DRM, " GST_VIDEO_FORMATS_ALL_STR
+
/**
* GST_VIDEO_FORMATS_ALL:
*
@@ -1137,9 +1148,23 @@ gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsi
*/
#define GST_VIDEO_FORMATS_ALL "{ " GST_VIDEO_FORMATS_ALL_STR " }"
+/**
+ * GST_VIDEO_FORMATS_ANY:
+ *
+ * This is similar to %GST_VIDEO_FORMATS_ALL but includes formats like DMA_DRM
+ * that do not have a software converter. This should be used for passthrough
+ * template caps.
+ *
+ * Since: 1.24
+ */
+#define GST_VIDEO_FORMATS_ANY "{ " GST_VIDEO_FORMATS_ANY_STR " }"
+
GST_VIDEO_API
const GstVideoFormat * gst_video_formats_raw (guint * len);
+GST_VIDEO_API
+const GstVideoFormat * gst_video_formats_any (guint * len);
+
/**
* GST_VIDEO_CAPS_MAKE:
* @format: string format that describes the pixel layout, as string
diff --git a/subprojects/gst-plugins-base/tests/check/libs/video.c b/subprojects/gst-plugins-base/tests/check/libs/video.c
index 29d2036c65..32306dd5b1 100644
--- a/subprojects/gst-plugins-base/tests/check/libs/video.c
+++ b/subprojects/gst-plugins-base/tests/check/libs/video.c
@@ -4027,6 +4027,18 @@ GST_START_TEST (test_video_make_raw_caps)
fail_unless (gst_caps_is_equal (caps, expected));
gst_caps_unref (caps);
gst_caps_unref (expected);
+
+ guint len;
+ const GstVideoFormat *formats = gst_video_formats_any (&len);
+ caps =
+ gst_video_make_raw_caps_with_features (formats, len,
+ gst_caps_features_new_any ());
+ expected =
+ gst_caps_from_string (GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("ANY",
+ GST_VIDEO_FORMATS_ANY));
+ fail_unless (gst_caps_is_equal (caps, expected));
+ gst_caps_unref (caps);
+ gst_caps_unref (expected);
}
GST_END_TEST;