[7/8] libcamera: request: Make access to metadata() const
diff mbox series

Message ID 20241206160747.97176-8-jacopo.mondi@ideasonboard.com
State New
Headers show
Series
  • libcamera: Support partial metadata completion
Related show

Commit Message

Jacopo Mondi Dec. 6, 2024, 4:07 p.m. UTC
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 <jacopo.mondi@ideasonboard.com>
---
 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(-)

Patch
diff mbox series

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<const ControlId *> ids;
 		ids.insert(&ctrl);
 
-		request->metadata().set<T, T>(ctrl, value);
+		request->_d()->metadata().set<T, T>(ctrl, value);
 
 		Camera *camera = request->_d()->camera();
 		camera->metadataAvailable.emit(request, ids);
@@ -92,7 +92,7 @@  public:
 		std::unordered_set<const ControlId *> 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<Request>()->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<Request>()->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> 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);