From patchwork Fri Dec 6 16:07:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22227 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 23B9FBE173 for ; Fri, 6 Dec 2024 16:08:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 665F467E27; Fri, 6 Dec 2024 17:07:57 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Ts324LDQ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 38FA566176 for ; Fri, 6 Dec 2024 17:07:55 +0100 (CET) Received: from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6D3AA9FC; Fri, 6 Dec 2024 17:07:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733501245; bh=Scbv05dXlHumWo/CTfJGqq5LN8ueXb/PBHOBlNjYnw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ts324LDQbr52G/xMJ1LnBkPPyIsxyk3pz00jixFTaaFtwNE6dtQA308+bFN3xM4EP ptc+g5p6Ixw61pdgs5rSrBjoP7BhwUKymH4EPTGwAqpfz9STCnPCmMZSXciAOoqg8p ZgRL4gM3/vV3jnbpj8728phNum0UyJakmI3+9dQE= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Harvey Yang , Han-Lin Chen Subject: [PATCH 1/8] libcamera: camera: Introduce metadataAvailable signal Date: Fri, 6 Dec 2024 17:07:39 +0100 Message-ID: <20241206160747.97176-2-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> References: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a new signal to the Camera class that allows applications to receive notifications for early completion of metadata results. To avoid expensive copies of the metadata results the signal transports the ids of the metadata keys that are ready. Applications can use these ids to access the metadata results from Request::metadata(). The signal is an opt-in feature for applications and the sum of all metadata results notified through this signal is available in Request::metadata() at request completion time. Signed-off-by: Jacopo Mondi --- include/libcamera/camera.h | 2 ++ src/libcamera/camera.cpp | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 94cee7bd86bb..20d51c191ecd 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -122,6 +123,7 @@ public: const std::string &id() const; + Signal> metadataAvailable; Signal bufferCompleted; Signal requestCompleted; Signal<> disconnected; diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 4c865a46af53..63e78b24e271 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -886,6 +886,48 @@ const std::string &Camera::id() const return _d()->id_; } +/** + * \var Camera::metadataAvailable + * \brief Signal emitted when metadata for a request are available + * + * The metadataAvailable signal notifies applications about the availability + * of metadata for a request before the request completes. + * + * As metadata results could be large in size, the signal transports the ids + * of the metadata that have just been made available, but the actual control + * values are stored in the Camera::metadata() list. + * + * Applications can access the value of the newly available metadata results + * with: + * + * \code + + void metadataAvailableHandler(Request *request, + std::unordered_set ids) + { + const ControlList &metadata = request->metadata(); + + for (const auto id : ids) { + ControlValue &value = metadata.get(id->id()); + + .... + } + } + \endcode + * + * This signal is emitted multiple times for the same request, it is in facts + * emitted by the framework every time a new metadata list is made available + * by the Camera to the application. + * + * The sum of all metadata lists reported through this signal is equal to + * Request::metadata() list when the Request completes. + * + * Application can opt-in to handle this signal to receive fast notifications + * of metadata availability or can equally access the full metadata list + * at Request complete time through Request::metadata() if they have no interest + * in early metadata notification. + */ + /** * \var Camera::bufferCompleted * \brief Signal emitted when a buffer for a request queued to the camera has