videoaggregator: Avoid creating caps that are not in the template

By using the gst_caps_set_simple() to set the format on all structures, the
compositor may create invalid combinations as the caps may contain passthrough
caps. Avoid this issue by intersecting the resul with its original.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5386>
This commit is contained in:
Nicolas Dufresne 2023-09-29 14:46:35 +02:00 committed by GStreamer Marge Bot
parent dcd911f5dc
commit 0eee03d688

View file

@ -1254,6 +1254,15 @@ gst_video_aggregator_default_update_caps (GstVideoAggregator * vagg,
best_format_caps = gst_caps_copy (caps);
gst_caps_set_simple (best_format_caps, "format", G_TYPE_STRING,
gst_video_format_to_string (best_format), NULL);
/*
* set_simple() will likely create some invalid combination, as it may as an
* example set format to NV12 with memory:DMABuf caps feature where DMA_DRM
* format might be the only supported formats. Simply intersect with the
* original to fix this.
*/
ret = gst_caps_intersect (best_format_caps, caps);
gst_caps_replace (&best_format_caps, ret);
gst_clear_caps (&ret);
if (chroma_site != NULL)
gst_caps_set_simple (best_format_caps, "chroma-site", G_TYPE_STRING,