diff options
author | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2019-01-22 16:31:39 +0100 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-01-24 22:24:11 +0200 |
commit | 5b02e03199b79165086135236d8fb9b2c673aae1 (patch) | |
tree | 84fe12868edf1c9a50d19a96455138975cb751af /src/libcamera/camera.cpp | |
parent | a29b7fc7d5b3cca3738728961cb2f5c9600cc960 (diff) |
libcamera: camera: Associate cameras with their pipeline handler
The PipelineHandler which creates a Camera is responsible for serving
any operation requested by the user. In order forward the public API
calls, the camera needs to store a reference to its pipeline handler.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes since v1:
- Create pipeline handlers is shared pointers, make them inherit from
std::enable_shared_from_this<> and stored them in shared pointers.
Diffstat (limited to 'src/libcamera/camera.cpp')
-rw-r--r-- | src/libcamera/camera.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index acf912be..3a531c7e 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -8,6 +8,7 @@ #include <libcamera/camera.h> #include "log.h" +#include "pipeline_handler.h" /** * \file camera.h @@ -52,17 +53,20 @@ namespace libcamera { /** * \brief Create a camera instance * \param[in] name The name of the camera device + * \param[in] pipe The pipeline handler responsible for the camera device * * The caller is responsible for guaranteeing unicity of the camera name. * * \return A shared pointer to the newly created camera object */ -std::shared_ptr<Camera> Camera::create(const std::string &name) +std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe, + const std::string &name) { struct Allocator : std::allocator<Camera> { - void construct(void *p, const std::string &name) + void construct(void *p, PipelineHandler *pipe, + const std::string &name) { - ::new(p) Camera(name); + ::new(p) Camera(pipe, name); } void destroy(Camera *p) { @@ -70,7 +74,7 @@ std::shared_ptr<Camera> Camera::create(const std::string &name) } }; - return std::allocate_shared<Camera>(Allocator(), name); + return std::allocate_shared<Camera>(Allocator(), pipe, name); } /** @@ -83,8 +87,8 @@ const std::string &Camera::name() const return name_; } -Camera::Camera(const std::string &name) - : name_(name) +Camera::Camera(PipelineHandler *pipe, const std::string &name) + : pipe_(pipe->shared_from_this()), name_(name) { } |