[libcamera-devel,v3,4/5] gstreamer: Configure the colorSpace in the Stream configuration.
diff mbox series

Message ID 20220711153711.36679-5-rishikeshdonadkar@gmail.com
State Superseded
Headers show
Series
  • Add colorimetry support to libcamera gstreamer element.
Related show

Commit Message

Rishikesh Donadkar July 11, 2022, 3:37 p.m. UTC
Get the colorimetry if requested in the gstreamer pipeline and
convert it to colorspace using the function colorspace_from_colorimetry()
Set the colorspace as a result of conversion in the StreamConfiguration.

Signed-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>
---
 src/gstreamer/gstlibcamera-utils.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
index 5b3bfd70..b3fc9ff4 100644
--- a/src/gstreamer/gstlibcamera-utils.cpp
+++ b/src/gstreamer/gstlibcamera-utils.cpp
@@ -278,6 +278,14 @@  gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg,
 		g_critical("Unsupported media type: %s", gst_structure_get_name(s));
 	}
 
+	/* Configure colorSpace */
+	if (gst_structure_has_field(s, "colorimetry")) {
+		const gchar *colorimetry_in_caps = gst_structure_get_string(s, "colorimetry");
+		std::optional<ColorSpace> colorSpace = colorspace_from_colorimetry(colorimetry_in_caps);
+		if (colorSpace)
+			stream_cfg.colorSpace = colorSpace;
+	}
+
 	gint width, height;
 	gst_structure_get_int(s, "width", &width);
 	gst_structure_get_int(s, "height", &height);