From 1ef8981c3931f1df00e478b25d535306be1a2f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 10 Jul 2025 15:53:09 +0200 Subject: [PATCH] libcamera: pipeline: rpi: Do not set timestamps to 0 if unavailable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `SensorTimestamp` and `FrameWallClock` should always be available. However, if that ever changes or they are not available for some unforeseen reason, setting them to 0 is not ideal. That makes it more complicated for the application to detect these cases (since they have to check the existence either way), and if an application blindly assumes e.g. that `SensorTimestamp` is monotonically increasing, then receiving a timestamp of 0 will likely cause issues. So simply omit them from the request metadata if they are not available. Signed-off-by: Barnabás Pőcze Reviewed-by: Naushir Patuck Reviewed-by: Daniel Scally --- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index eafe9442..563df198 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -1487,10 +1487,10 @@ void CameraData::checkRequestCompleted() void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request *request) { - request->metadata().set(controls::SensorTimestamp, - bufferControls.get(controls::SensorTimestamp).value_or(0)); - request->metadata().set(controls::FrameWallClock, - bufferControls.get(controls::FrameWallClock).value_or(0)); + if (auto x = bufferControls.get(controls::SensorTimestamp)) + request->metadata().set(controls::SensorTimestamp, *x); + if (auto x = bufferControls.get(controls::FrameWallClock)) + request->metadata().set(controls::FrameWallClock, *x); if (cropParams_.size()) { std::vector crops;