[libcamera-devel] [PATCH v2 3/7] qcam: Store CameraManager as class member
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Fri Feb 14 01:23:50 CET 2020
Hi Kieran,
Thank you for the patch.
On Fri, Feb 14, 2020 at 12:18:06AM +0000, Kieran Bingham wrote:
> Intialise a local copy of the CameraManager instance to ease
> access to the CameraManager which is frequently utilised.
>
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> src/qcam/main_window.cpp | 18 +++++++++---------
> src/qcam/main_window.h | 5 +++--
> 2 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index 38d7063363f0..2ed84cacf655 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -23,7 +23,7 @@
> using namespace libcamera;
>
> MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)
> - : options_(options), allocator_(nullptr), isCapturing_(false)
> + : options_(options), cm_(cm), allocator_(nullptr), isCapturing_(false)
> {
> int ret;
>
> @@ -35,7 +35,7 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)
> setCentralWidget(viewfinder_);
> adjustSize();
>
> - ret = openCamera(cm);
> + ret = openCamera();
> if (!ret)
> ret = startCapture();
>
> @@ -66,15 +66,15 @@ void MainWindow::updateTitle()
> setWindowTitle(title_ + " : " + QString::number(fps, 'f', 2) + " fps");
> }
>
> -std::string MainWindow::chooseCamera(CameraManager *cm)
> +std::string MainWindow::chooseCamera()
> {
> QStringList cameras;
> bool result;
>
> - if (cm->cameras().size() == 1)
> - return cm->cameras()[0]->name();
> + if (cm_->cameras().size() == 1)
> + return cm_->cameras()[0]->name();
>
> - for (const std::shared_ptr<Camera> &cam : cm->cameras())
> + for (const std::shared_ptr<Camera> &cam : cm_->cameras())
> cameras.append(QString::fromStdString(cam->name()));
>
> QString name = QInputDialog::getItem(this, "Select Camera",
> @@ -86,19 +86,19 @@ std::string MainWindow::chooseCamera(CameraManager *cm)
> return name.toStdString();
> }
>
> -int MainWindow::openCamera(CameraManager *cm)
> +int MainWindow::openCamera()
> {
> std::string cameraName;
>
> if (options_.isSet(OptCamera))
> cameraName = static_cast<std::string>(options_[OptCamera]);
> else
> - cameraName = chooseCamera(cm);
> + cameraName = chooseCamera();
>
> if (cameraName == "")
> return -EINVAL;
>
> - camera_ = cm->get(cameraName);
> + camera_ = cm_->get(cameraName);
> if (!camera_) {
> std::cout << "Camera " << cameraName << " not found"
> << std::endl;
> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
> index 04fb9e3ea869..d19cda16e36b 100644
> --- a/src/qcam/main_window.h
> +++ b/src/qcam/main_window.h
> @@ -44,8 +44,8 @@ private Q_SLOTS:
> void updateTitle();
>
> private:
> - std::string chooseCamera(CameraManager *cm);
> - int openCamera(CameraManager *cm);
> + std::string chooseCamera();
> + int openCamera();
>
> int startCapture();
> void stopCapture();
> @@ -58,6 +58,7 @@ private:
>
> const OptionsParser::Options &options_;
>
> + CameraManager *cm_;
> std::shared_ptr<Camera> camera_;
> FrameBufferAllocator *allocator_;
>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list