summaryrefslogtreecommitdiff
path: root/src/libcamera/camera.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-07-23 02:57:44 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-08-16 23:57:28 +0300
commit32b8832e38e5311dcbed5badfad3d69e5981ed95 (patch)
treed78355ef8ebb1a75248f11464723fd73fb52fe67 /src/libcamera/camera.cpp
parente77c8951e9ff91bf2bacf81791a882ccb3cee30b (diff)
libcamera: camera: Pass Private pointer to Camera constructor
In order to allow subclassing Camera::Private in pipeline handlers, pass the pointer to the private data to the Camera constructor, and to the Camera::createCamera() function. The Camera::Private id_ and streams_ members now need to be initialized by the Camera constructor instead of the Camera::Private constructor, to allow storage of the streams in a pipeline handler-specific subclass of Camera::Private. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/libcamera/camera.cpp')
-rw-r--r--src/libcamera/camera.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 8e99e2a9..d9f6b784 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -332,11 +332,13 @@ std::size_t CameraConfiguration::size() const
* \brief The vector of stream configurations
*/
-Camera::Private::Private(PipelineHandler *pipe,
- const std::string &id,
- const std::set<Stream *> &streams)
- : pipe_(pipe->shared_from_this()), id_(id), streams_(streams),
- disconnected_(false), state_(CameraAvailable)
+/**
+ * \brief Construct a Camera::Private instance
+ * \param[in] pipe The pipeline handler responsible for the camera device
+ */
+Camera::Private::Private(PipelineHandler *pipe)
+ : pipe_(pipe->shared_from_this()), disconnected_(false),
+ state_(CameraAvailable)
{
}
@@ -513,7 +515,7 @@ void Camera::Private::setState(State state)
/**
* \brief Create a camera instance
- * \param[in] pipe The pipeline handler responsible for the camera device
+ * \param[in] d Camera private data
* \param[in] id The ID of the camera device
* \param[in] streams Array of streams the camera provides
*
@@ -527,10 +529,12 @@ void Camera::Private::setState(State state)
*
* \return A shared pointer to the newly created camera object
*/
-std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,
+std::shared_ptr<Camera> Camera::create(std::unique_ptr<Private> d,
const std::string &id,
const std::set<Stream *> &streams)
{
+ ASSERT(d);
+
struct Deleter : std::default_delete<Camera> {
void operator()(Camera *camera)
{
@@ -541,7 +545,7 @@ std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,
}
};
- Camera *camera = new Camera(pipe, id, streams);
+ Camera *camera = new Camera(std::move(d), id, streams);
return std::shared_ptr<Camera>(camera, Deleter());
}
@@ -594,10 +598,12 @@ const std::string &Camera::id() const
* application API calls by returning errors immediately.
*/
-Camera::Camera(PipelineHandler *pipe, const std::string &id,
+Camera::Camera(std::unique_ptr<Private> d, const std::string &id,
const std::set<Stream *> &streams)
- : Extensible(std::make_unique<Private>(pipe, id, streams))
+ : Extensible(std::move(d))
{
+ _d()->id_ = id;
+ _d()->streams_ = streams;
}
Camera::~Camera()