[libcamera-devel,v2,2/5] gstreamer: Update the obtained colorimetry in caps.
diff mbox series

Message ID 20220706080030.30929-2-rishikeshdonadkar@gmail.com
State Superseded
Headers show
Series
  • [libcamera-devel,v2,1/5] gstreamer: convert from libcamera colorspace to GStreamer colorimetry.
Related show

Commit Message

Rishikesh Donadkar July 6, 2022, 8 a.m. UTC
If the colorspace is set in the StreamConfiguration, get the colorimetry as
a result of conversion from the previous patch and update it into the caps.

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

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
index 60ac8c8e..c155dd0c 100644
--- a/src/gstreamer/gstlibcamera-utils.cpp
+++ b/src/gstreamer/gstlibcamera-utils.cpp
@@ -166,11 +166,23 @@  gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg
 {
 	GstCaps *caps = gst_caps_new_empty();
 	GstStructure *s = bare_structure_from_format(stream_cfg.pixelFormat);
+	gchar *colorimetry = nullptr;
+	std::optional<ColorSpace> colorspace = stream_cfg.colorSpace;
 
 	gst_structure_set(s,
 			  "width", G_TYPE_INT, stream_cfg.size.width,
 			  "height", G_TYPE_INT, stream_cfg.size.height,
 			  nullptr);
+
+	if (colorspace) {
+		colorimetry = colorimerty_from_colorspace(colorspace);
+		if (colorimetry)
+			gst_structure_set(s,
+			       "colorimetry", G_TYPE_STRING, colorimetry, nullptr);
+	} else {
+		g_free(colorimetry);
+	}
+
 	gst_caps_append_structure(caps, s);
 
 	return caps;