[PATCH 2/4] gstreamer: Log and check adjusted camera configuration

Nicolas Dufresne nicolas at ndufresne.ca
Tue Apr 22 16:34:14 CEST 2025


Hi,

Le mardi 22 avril 2025 à 16:10 +0200, Jaslo Ziska a écrit :
> As CameraConfiguration::validate() might alter the configuration
> previously negotiated with downstream, log an info when this happens as
> GStreamer source elements are not supposed to do that.
> 
> Also check if downstream can accept this new stream configuration and if
> not, return a not-negotiated error.
> 
> Signed-off-by: Jaslo Ziska <jaslo at ziska.de>
> ---
>  src/gstreamer/gstlibcamerasrc.cpp | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
> index 12bf8de0..2d9db342 100644
> --- a/src/gstreamer/gstlibcamerasrc.cpp
> +++ b/src/gstreamer/gstlibcamerasrc.cpp
> @@ -455,8 +455,13 @@ gst_libcamera_src_negotiate(GstLibcameraSrc *self)
>  	}
>  
>  	/* Validate the configuration. */
> -	if (state->config_->validate() == CameraConfiguration::Invalid)
> +	CameraConfiguration::Status status = state->config_->validate();
> +	if (status == CameraConfiguration::Invalid)
>  		return false;
> +	else if (status == CameraConfiguration::Adjusted)
> +		GST_ELEMENT_INFO(self, RESOURCE, SETTINGS,
> +				 ("Configuration was adjusted"),
> +				 ("CameraConfiguration::validate() returned CameraConfiguration::Adjusted"));

Not sure if others would prefer a switch, I don't have a strong
preference here.

>  
>  	int ret = state->cam_->configure(state->config_.get());
>  	if (ret) {
> @@ -481,6 +486,10 @@ gst_libcamera_src_negotiate(GstLibcameraSrc *self)
>  		g_autoptr(GstCaps) caps = gst_libcamera_stream_configuration_to_caps(stream_cfg, transfer[i]);
>  		gst_libcamera_framerate_to_caps(caps, element_caps);
>  
> +		if (status == CameraConfiguration::Adjusted &&
> +		    !gst_pad_peer_query_accept_caps(srcpad, caps))
> +			return false;
> +

Seems fair to me.

Reviewed-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>

>  		if (!gst_pad_push_event(srcpad, gst_event_new_caps(caps)))
>  			return false;
>  	}


More information about the libcamera-devel mailing list