[libcamera-devel] [PATCH] gstreamer: Provide interlace-mode as fixated caps

Umang Jain umang.jain at ideasonboard.com
Mon Aug 29 12:02:51 CEST 2022


The 'interlace-mode' for libcamerasrc will always be 'progressive'.
Provide it via fixated caps mechanism [1]

[1] https://gstreamer.freedesktop.org/documentation/plugin-development/advanced/negotiation.html?gi-language=c#fixed-negotiation

Signed-off-by: Umang Jain <umang.jain at ideasonboard.com>
---
Rishi, Can you please check this patch as well? I think it will closely
co-relate with the framerate being captured in caps, as fixate
negotitation mechanism.
---
 src/gstreamer/gstlibcamerasrc.cpp | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
index 16d70fea..24a2e33e 100644
--- a/src/gstreamer/gstlibcamerasrc.cpp
+++ b/src/gstreamer/gstlibcamerasrc.cpp
@@ -800,11 +800,37 @@ gst_libcamera_src_release_pad(GstElement *element, GstPad *pad)
 	gst_element_remove_pad(element, pad);
 }
 
+static GstCaps *gst_libcamera_src_src_fixate([[maybe_unused]] GstBaseSrc *bsrc,
+					     GstCaps *caps)
+{
+	GstStructure *structure;
+	GstCaps *fixated_caps;
+
+	fixated_caps = gst_caps_make_writable(caps);
+
+	for (guint i = 0; i < gst_caps_get_size(fixated_caps); ++i) {
+		structure = gst_caps_get_structure(fixated_caps, i);
+		if (gst_structure_has_field(structure, "interlace-mode"))
+			gst_structure_fixate_field_string(structure, "interlace-mode",
+							  "progressive");
+		else
+			gst_structure_set(structure, "interlace-mode", G_TYPE_STRING,
+					  "progressive", NULL);
+	}
+
+	fixated_caps = gst_caps_fixate(fixated_caps);
+
+	return fixated_caps;
+}
+
 static void
 gst_libcamera_src_class_init(GstLibcameraSrcClass *klass)
 {
 	GstElementClass *element_class = GST_ELEMENT_CLASS(klass);
 	GObjectClass *object_class = G_OBJECT_CLASS(klass);
+	GstBaseSrcClass *gstbasesrc_class = (GstBaseSrcClass *)klass;
+
+	gstbasesrc_class->fixate = gst_libcamera_src_src_fixate;
 
 	object_class->set_property = gst_libcamera_src_set_property;
 	object_class->get_property = gst_libcamera_src_get_property;
-- 
2.37.2



More information about the libcamera-devel mailing list