From 7144fe6f9cdddb69caa33eb753bc173adcb2ad06 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Thu, 11 May 2023 22:21:02 +0100 Subject: libcamera: camera_manager: Move private implementation to internal The CameraManager makes use of the Extensible pattern to provide an internal private implementation that is not exposed in the public API. Move the Private declaration to an internal header to make it available from other internal components in preperation for reducing the surface area of the public interface of the CameraManager. Reviewed-by: Jacopo Mondi Tested-by: Ashok Sidipotu Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- include/libcamera/internal/camera_manager.h | 70 +++++++++++++++++++++++++++++ include/libcamera/internal/meson.build | 1 + 2 files changed, 71 insertions(+) create mode 100644 include/libcamera/internal/camera_manager.h (limited to 'include') diff --git a/include/libcamera/internal/camera_manager.h b/include/libcamera/internal/camera_manager.h new file mode 100644 index 00000000..8220a654 --- /dev/null +++ b/include/libcamera/internal/camera_manager.h @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Ideas on Board Oy. + * + * camera_manager.h - Camera manager private data + */ + +#pragma once + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "libcamera/internal/ipa_manager.h" +#include "libcamera/internal/process.h" + +namespace libcamera { + +class Camera; +class DeviceEnumerator; + +class CameraManager::Private : public Extensible::Private, public Thread +{ + LIBCAMERA_DECLARE_PUBLIC(CameraManager) + +public: + Private(); + + int start(); + void addCamera(std::shared_ptr camera, + const std::vector &devnums) LIBCAMERA_TSA_EXCLUDES(mutex_); + void removeCamera(Camera *camera) LIBCAMERA_TSA_EXCLUDES(mutex_); + +protected: + void run() override; + +private: + int init(); + void createPipelineHandlers(); + void cleanup() LIBCAMERA_TSA_EXCLUDES(mutex_); + + /* + * This mutex protects + * + * - initialized_ and status_ during initialization + * - cameras_ and camerasByDevnum_ after initialization + */ + mutable Mutex mutex_; + std::vector> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_); + std::map> camerasByDevnum_ LIBCAMERA_TSA_GUARDED_BY(mutex_); + + ConditionVariable cv_; + bool initialized_ LIBCAMERA_TSA_GUARDED_BY(mutex_); + int status_ LIBCAMERA_TSA_GUARDED_BY(mutex_); + + std::unique_ptr enumerator_; + + IPAManager ipaManager_; + ProcessManager processManager_; +}; + +} /* namespace libcamera */ diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index d7508805..4b2756a4 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -15,6 +15,7 @@ libcamera_internal_headers = files([ 'camera.h', 'camera_controls.h', 'camera_lens.h', + 'camera_manager.h', 'camera_sensor.h', 'camera_sensor_properties.h', 'control_serializer.h', -- cgit v1.2.1