gstreamer: Log and check adjusted camera configuration

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@ziska.de>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <uajain@igalia.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Jaslo Ziska
2025-07-22 12:39:29 +02:00
committed by Laurent Pinchart
parent 36bec972d3
commit 84c0b9dd0a

View File

@@ -617,8 +617,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"));
int ret = state->cam_->configure(state->config_.get());
if (ret) {
@@ -643,6 +648,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;
if (!gst_pad_push_event(srcpad, gst_event_new_caps(caps)))
return false;
}