[libcamera-devel] [RFC v2 2/4] HACK: expose Camera* from Request

Tomi Valkeinen tomi.valkeinen at iki.fi
Fri Nov 27 14:37:36 CET 2020


Py bindings need to find out which camera is the source of the completed
Request. Request already has a private field for the Camera, so we can
just expose it via a getter.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ti.com>
---
 include/libcamera/request.h | 1 +
 src/libcamera/request.cpp   | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/include/libcamera/request.h b/include/libcamera/request.h
index 655b1324..f98ef767 100644
--- a/include/libcamera/request.h
+++ b/include/libcamera/request.h
@@ -56,6 +56,7 @@ public:
 
 	bool hasPendingBuffers() const { return !pending_.empty(); }
 
+        std::shared_ptr<Camera> camera() const;
 private:
 	friend class PipelineHandler;
 
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index a68684ef..5a50ec6b 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -216,6 +216,11 @@ FrameBuffer *Request::findBuffer(const Stream *stream) const
 	return it->second;
 }
 
+std::shared_ptr<Camera> Request::camera() const
+{
+	return camera_->shared_from_this();
+}
+
 /**
  * \fn Request::metadata()
  * \brief Retrieve the request's metadata
-- 
2.25.1



More information about the libcamera-devel mailing list