From 32f2c0da064a0f53a04056dc9869c331b7df4d25 Mon Sep 17 00:00:00 2001 From: Anjo Krank Date: Wed, 5 Jul 2023 17:53:57 +0200 Subject: [PATCH] core: adding method to access CameraManager Added the ability to get at the CameraManager to allow for access to the Camera list. Signed-off-by: naushir --- core/libcamera_app.cpp | 7 ++++++- core/libcamera_app.hpp | 8 +++++++- core/options.cpp | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/libcamera_app.cpp b/core/libcamera_app.cpp index 233c9647..776b1431 100644 --- a/core/libcamera_app.cpp +++ b/core/libcamera_app.cpp @@ -136,7 +136,7 @@ void LibcameraApp::OpenCamera() if (ret) throw std::runtime_error("camera manager failed to start, code " + std::to_string(-ret)); - std::vector> cameras = LibcameraApp::GetCameras(camera_manager_); + std::vector> cameras = GetCameras(); if (cameras.size() == 0) throw std::runtime_error("no cameras available"); if (options_->camera >= cameras.size()) @@ -773,6 +773,11 @@ libcamera::Stream *LibcameraApp::GetMainStream() const return nullptr; } +const libcamera::CameraManager *LibcameraApp::GetCameraManager() const +{ + return camera_manager_.get(); +} + std::vector> LibcameraApp::Mmap(FrameBuffer *buffer) const { auto item = mapped_buffers_.find(buffer); diff --git a/core/libcamera_app.hpp b/core/libcamera_app.hpp index 965fb391..bd040079 100644 --- a/core/libcamera_app.hpp +++ b/core/libcamera_app.hpp @@ -119,6 +119,12 @@ class LibcameraApp Stream *LoresStream(StreamInfo *info = nullptr) const; Stream *GetMainStream() const; + const CameraManager *GetCameraManager() const; + std::vector> GetCameras() + { + return GetCameras(camera_manager_.get()); + } + std::vector> Mmap(FrameBuffer *buffer) const; void ShowPreview(CompletedRequestPtr &completed_request, Stream *stream); @@ -129,7 +135,7 @@ class LibcameraApp static unsigned int verbosity; static unsigned int GetVerbosity() { return verbosity; } - static std::vector> GetCameras(const std::unique_ptr &cm) + static std::vector> GetCameras(const CameraManager *cm) { std::vector> cameras = cm->cameras(); // Do not show USB webcams as these are not supported in libcamera-apps! diff --git a/core/options.cpp b/core/options.cpp index e42678ae..13d12b11 100644 --- a/core/options.cpp +++ b/core/options.cpp @@ -154,7 +154,7 @@ bool Options::Parse(int argc, char *argv[]) if (ret) throw std::runtime_error("camera manager failed to start, code " + std::to_string(-ret)); - std::vector> cameras = LibcameraApp::GetCameras(cm); + std::vector> cameras = LibcameraApp::GetCameras(cm.get()); if (cameras.size() != 0) { unsigned int idx = 0;