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

Message ID 20220703073358.76643-2-rishikeshdonadkar@gmail.com
State Superseded
Headers show
Series
  • [libcamera-devel,v1,1/5] gstreamer: Convert form colorspace to colorimetry.
Related show

Commit Message

Rishikesh Donadkar July 3, 2022, 7:33 a.m. UTC
Get the colorimetry as a result conversion in the previous patch and
update the colorimetry in the gstreamer caps.

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

Comments

Nicolas Dufresne July 4, 2022, 6:10 p.m. UTC | #1
Le dimanche 03 juillet 2022 à 13:03 +0530, Rishikesh Donadkar a écrit :
> Get the colorimetry as a result conversion in the previous patch and
> update the colorimetry in the gstreamer caps.
> 
> Signed-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>
> ---
>  src/gstreamer/gstlibcamera-utils.cpp | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
> index 20c39919..690a9f43 100644
> --- a/src/gstreamer/gstlibcamera-utils.cpp
> +++ b/src/gstreamer/gstlibcamera-utils.cpp
> @@ -205,10 +205,17 @@ 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);
> +	const gchar *colorimetry;
> +	std::optional<ColorSpace> colorspace = stream_cfg.colorSpace;
> +	if (colorspace)
> +		colorimetry = colorimerty_from_colorspace(colorspace);
> +	else
> +		colorimetry = g_strdup("Unset");

As currently implemented, colorimerty_from_colorspace() never turns null. Also,
"Unset" is an invalid colorimetry value that will break the streaming. If you
add a way for colorspace to fail, first don't leave that silent, its likely due
to a missing mapping, and second, simply don't set the field or set it to a
valid fallback.

>  
>  	gst_structure_set(s,
>  			  "width", G_TYPE_INT, stream_cfg.size.width,
>  			  "height", G_TYPE_INT, stream_cfg.size.height,
> +			  "colorimetry", G_TYPE_STRING, colorimetry,
>  			  nullptr);
>  	gst_caps_append_structure(caps, s);
>

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
index 20c39919..690a9f43 100644
--- a/src/gstreamer/gstlibcamera-utils.cpp
+++ b/src/gstreamer/gstlibcamera-utils.cpp
@@ -205,10 +205,17 @@  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);
+	const gchar *colorimetry;
+	std::optional<ColorSpace> colorspace = stream_cfg.colorSpace;
+	if (colorspace)
+		colorimetry = colorimerty_from_colorspace(colorspace);
+	else
+		colorimetry = g_strdup("Unset");
 
 	gst_structure_set(s,
 			  "width", G_TYPE_INT, stream_cfg.size.width,
 			  "height", G_TYPE_INT, stream_cfg.size.height,
+			  "colorimetry", G_TYPE_STRING, colorimetry,
 			  nullptr);
 	gst_caps_append_structure(caps, s);