[v2] gstreamer: Read correct colorimetry from caps into the stream configuration
diff mbox series

Message ID 20241113102043.1900034-1-qi.hou@nxp.com
State New
Headers show
Series
  • [v2] gstreamer: Read correct colorimetry from caps into the stream configuration
Related show

Commit Message

Qi Hou Nov. 13, 2024, 10:20 a.m. UTC
When libcamerasrc is negotiating with downstream element, it first
extracts colorimetry field from downstream supported caps, then set
this colorimetry to its stream configuration and propagates the
colorimetry downstream.

Currently libamerasrc only considers the case there is one colorimetry
in colorimetry field of downstream caps. But the issue is that
downstream caps may report a list of supported colorimetry, which
causes libcamerasrc to set unknown colorimetry to stream configuration
and negotiate fail with downstream element.

In order to fix the issue, get the first string if colorimetry field
holds string list to set it to stream configuration.

Signed-off-by: Hou Qi <qi.hou@nxp.com>
---
 src/gstreamer/gstlibcamera-utils.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
index 732987ef..340a43a8 100644
--- a/src/gstreamer/gstlibcamera-utils.cpp
+++ b/src/gstreamer/gstlibcamera-utils.cpp
@@ -489,9 +489,17 @@  gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg,
 
 	/* Configure colorimetry */
 	if (gst_structure_has_field(s, "colorimetry")) {
-		const gchar *colorimetry_str = gst_structure_get_string(s, "colorimetry");
+		const GValue *value;
+		const gchar *colorimetry_str = NULL;
 		GstVideoColorimetry colorimetry;
 
+		value = gst_structure_get_value(s, "colorimetry");
+
+		if (GST_VALUE_HOLDS_LIST(value))
+			value = gst_value_list_get_value(value, 0);
+		if (G_VALUE_HOLDS_STRING(value))
+			colorimetry_str = g_value_get_string(value);
+
 		if (!gst_video_colorimetry_from_string(&colorimetry, colorimetry_str))
 			g_critical("Invalid colorimetry %s", colorimetry_str);