From b3f5169d55f4ad9acc022b4b3cca35d3b7eedea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 20 Aug 2021 12:03:24 +0300 Subject: [PATCH] Intersect caps with configured mode if not auto in ajasrc get_caps() to provide more constrained caps --- gstajasrc.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gstajasrc.cpp b/gstajasrc.cpp index 46b8ac4db1..8b1bb6be5f 100644 --- a/gstajasrc.cpp +++ b/gstajasrc.cpp @@ -1288,6 +1288,32 @@ static GstCaps *gst_aja_src_get_caps(GstBaseSrc *bsrc, GstCaps *filter) { caps = gst_pad_get_pad_template_caps(GST_BASE_SRC_PAD(self)); } + // Intersect with the configured video format if any to constrain the caps + // further. + if (self->video_format_setting != GST_AJA_VIDEO_FORMAT_AUTO) { + GstCaps *configured_caps = + gst_aja_video_format_to_caps(self->video_format_setting); + + if (configured_caps) { + GstCaps *tmp; + + // Remove pixel-aspect-ratio from the configured caps to allow for both + // widescreen and non-widescreen PAL/NTSC. It's added back by the + // template caps above when intersecting. + guint n = gst_caps_get_size(configured_caps); + for (guint i = 0; i < n; i++) { + GstStructure *s = gst_caps_get_structure(configured_caps, i); + + gst_structure_remove_fields(s, "pixel-aspect-ratio", NULL); + } + + tmp = gst_caps_intersect(caps, configured_caps); + gst_caps_unref(caps); + gst_caps_unref(configured_caps); + caps = tmp; + } + } + if (filter) { GstCaps *tmp = gst_caps_intersect_full(filter, caps, GST_CAPS_INTERSECT_FIRST);