From 32b8832e38e5311dcbed5badfad3d69e5981ed95 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 23 Jul 2021 02:57:44 +0300 Subject: libcamera: camera: Pass Private pointer to Camera constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 4 +++- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 4 +++- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 +++- src/libcamera/pipeline/simple/simple.cpp | 4 +++- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 5 ++++- src/libcamera/pipeline/vimc/vimc.cpp | 4 +++- 6 files changed, 19 insertions(+), 6 deletions(-) (limited to 'src/libcamera/pipeline') diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 6e26a7b7..6a015674 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -23,6 +23,7 @@ #include #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/delayed_controls.h" #include "libcamera/internal/device_enumerator.h" @@ -1164,7 +1165,8 @@ int PipelineHandlerIPU3::registerCameras() /* Create and register the Camera instance. */ std::string cameraId = cio2->sensor()->id(); std::shared_ptr camera = - Camera::create(this, cameraId, streams); + Camera::create(std::make_unique(this), + cameraId, streams); registerCamera(std::move(camera), std::move(data)); diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 2e8774ae..91e906ef 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -29,6 +29,7 @@ #include #include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/camera.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/delayed_controls.h" #include "libcamera/internal/device_enumerator.h" @@ -1105,7 +1106,8 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) /* Create and register the camera. */ std::shared_ptr camera = - Camera::create(this, data->sensor_->id(), streams); + Camera::create(std::make_unique(this), + data->sensor_->id(), streams); registerCamera(std::move(camera), std::move(data)); return true; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 710b9309..74c55620 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -27,6 +27,7 @@ #include #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/delayed_controls.h" #include "libcamera/internal/device_enumerator.h" @@ -971,7 +972,8 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) &data->selfPathStream_, }; std::shared_ptr camera = - Camera::create(this, data->sensor_->id(), streams); + Camera::create(std::make_unique(this), + data->sensor_->id(), streams); registerCamera(std::move(camera), std::move(data)); return 0; diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index b29fff98..ad581969 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -28,6 +28,7 @@ #include #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/media_device.h" @@ -1046,7 +1047,8 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) [](Stream &stream) { return &stream; }); std::shared_ptr camera = - Camera::create(this, data->sensor_->id(), streams); + Camera::create(std::make_unique(this), + data->sensor_->id(), streams); registerCamera(std::move(camera), std::move(data)); registered = true; } diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 573d8042..f2d2b670 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -22,6 +22,7 @@ #include #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/pipeline_handler.h" @@ -470,7 +471,9 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) } std::set streams{ &data->stream_ }; - std::shared_ptr camera = Camera::create(this, id, streams); + std::shared_ptr camera = + Camera::create(std::make_unique(this), id, + streams); registerCamera(std::move(camera), std::move(data)); /* Enable hot-unplug notifications. */ diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 1a6b8ae2..01b0b988 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -29,6 +29,7 @@ #include #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/ipa_manager.h" @@ -475,7 +476,8 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) /* Create and register the camera. */ std::set streams{ &data->stream_ }; std::shared_ptr camera = - Camera::create(this, data->sensor_->id(), streams); + Camera::create(std::make_unique(this), + data->sensor_->id(), streams); registerCamera(std::move(camera), std::move(data)); return true; -- cgit v1.2.1