From patchwork Fri Dec 6 16:07:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22233 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 E32C0BE173 for ; Fri, 6 Dec 2024 16:08:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9635867E39; Fri, 6 Dec 2024 17:08:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BRtquDjr"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A305E67E28 for ; Fri, 6 Dec 2024 17:07:57 +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 EFDDF9FC; Fri, 6 Dec 2024 17:07:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733501248; bh=hcQCGlN1mpUvkybpuZx7ht1VfpPoOAeR0rAg/6KGvW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BRtquDjrSx2t0Jzj8d47i7i23/UUNO/C+m5AU6IVLC1BuPaKFPgSCtQlcEtwOfpLp WOAzNlUZpRC+731jpW2CXyGZ315pDCU2v0HGi5MEdeqFyQ/OBRwIijKcne6xUJlYXh DA9fO963s8eDRZqm8VbyeMtKb/UCTA8BKSq02jp8= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Harvey Yang , Han-Lin Chen Subject: [PATCH 7/8] libcamera: request: Make access to metadata() const Date: Fri, 6 Dec 2024 17:07:45 +0100 Message-ID: <20241206160747.97176-8-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" Restict access to the metadata list to return a const reference. Provide a Request::Private::metadata() function for the pipeline handler base class to access the metadata list in RW mode. All other users, of the public and internal API alike, can only access metadata through a const reference. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/pipeline_handler.h | 4 ++-- include/libcamera/internal/request.h | 5 ++++- include/libcamera/request.h | 4 +++- src/libcamera/pipeline_handler.cpp | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 3ca6a0290b2b..b84e5a06d77b 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -74,7 +74,7 @@ public: std::unordered_set ids; ids.insert(&ctrl); - request->metadata().set(ctrl, value); + request->_d()->metadata().set(ctrl, value); Camera *camera = request->_d()->camera(); camera->metadataAvailable.emit(request, ids); @@ -92,7 +92,7 @@ public: std::unordered_set ids; ids.insert(&ctrl); - request->metadata().set(ctrl, value); + request->_d()->metadata().set(ctrl, value); Camera *camera = request->_d()->camera(); camera->metadataAvailable.emit(request, ids); diff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h index 98b7c6d6dfdf..1a7128b4259a 100644 --- a/include/libcamera/internal/request.h +++ b/include/libcamera/internal/request.h @@ -42,7 +42,8 @@ public: void resetMetadata() { - _o()->metadata().clear(); + ControlList &data = metadata(); + data.clear(); } void prepare(std::chrono::milliseconds timeout = 0ms); @@ -52,6 +53,8 @@ private: friend class PipelineHandler; friend std::ostream &operator<<(std::ostream &out, const Request &r); + ControlList &metadata() { return _o()->metadataRW(); } + void doCancelRequest(); void emitPrepareCompleted(); void notifierActivated(FrameBuffer *buffer); diff --git a/include/libcamera/request.h b/include/libcamera/request.h index e214a9d13c37..7791080976c2 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -50,7 +50,7 @@ public: void reuse(ReuseFlag flags = Default); ControlList &controls() { return *controls_; } - ControlList &metadata() { return *metadata_; } + const ControlList &metadata() { return *metadata_; } const BufferMap &buffers() const { return bufferMap_; } int addBuffer(const Stream *stream, FrameBuffer *buffer, std::unique_ptr fence = nullptr); @@ -67,6 +67,8 @@ public: private: LIBCAMERA_DISABLE_COPY(Request) + ControlList &metadataRW() { return *metadata_; } + ControlList *controls_; ControlList *metadata_; BufferMap bufferMap_; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index a69d789116ad..831ac6c87463 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -548,7 +548,7 @@ void PipelineHandler::metadataAvailable(Request *request, const ControlList &met if (ids.empty()) return; - request->metadata().merge(metadata); + request->_d()->metadata().merge(metadata); Camera *camera = request->_d()->camera(); camera->metadataAvailable.emit(request, ids);