libcamera: include/libcamera/internal/camera_manager.h Source File

libcamera v0.7.2 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
camera_manager.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2023, Ideas on Board Oy.
4 *
5 * Camera manager private data
6 */
7
8#pragma once
9
10#include <libcamera/camera_manager.h>
11
12#include <memory>
13#include <sys/types.h>
14#include <vector>
15
16#include <libcamera/base/class.h>
17#include <libcamera/base/mutex.h>
18#include <libcamera/base/thread.h>
19#include <libcamera/base/thread_annotations.h>
20
21#include "libcamera/internal/global_configuration.h"
22#include "libcamera/internal/process.h"
23
24namespace libcamera {
25
26class Camera;
27class DeviceEnumerator;
28class IPAManager;
29class PipelineHandlerFactoryBase;
30
31class CameraManager::Private : public Extensible::Private, public Thread
32{
33 LIBCAMERA_DECLARE_PUBLIC(CameraManager)
34
35public:
36 Private();
37
38 int start();
39 void addCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);
40 void removeCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);
41
42 const GlobalConfiguration &configuration() const
43 {
44 return configuration_;
45 }
46
47 IPAManager *ipaManager() const { return ipaManager_.get(); }
48
49protected:
50 void run() override;
51
52private:
53 int init();
54 void createPipelineHandlers();
55 void pipelineFactoryMatch(const PipelineHandlerFactoryBase *factory);
56 void cleanup() LIBCAMERA_TSA_EXCLUDES(mutex_);
57
58 /*
59 * This mutex protects
60 *
61 * - initialized_ and status_ during initialization
62 * - cameras_ after initialization
63 */
64 mutable Mutex mutex_;
65 std::vector<std::shared_ptr<Camera>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
66
67 ConditionVariable cv_;
68 bool initialized_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
69 int status_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
70
71 std::unique_ptr<DeviceEnumerator> enumerator_;
72
73 std::unique_ptr<IPAManager> ipaManager_;
74
75 const GlobalConfiguration configuration_;
76};
77
78} /* namespace libcamera */
camera_manager.h
The camera manager.
class.h
Utilities to help constructing class interfaces.
LIBCAMERA_DECLARE_PUBLIC
#define LIBCAMERA_DECLARE_PUBLIC(klass)
Declare public data for a private class.
Definition class.h:57
libcamera::Camera
Camera device.
Definition camera.h:116
libcamera::DeviceEnumerator
Enumerate, store and search media devices.
Definition device_enumerator.h:38
libcamera::Extensible::Private
Base class for private data managed through a d-pointer.
Definition class.h:65
libcamera::Extensible::Private::Private
Private()
Construct an instance of an Extensible class private data.
Definition class.cpp:194
libcamera::IPAManager
Manager for IPA modules.
Definition ipa_manager.h:31
libcamera::PipelineHandlerFactoryBase
Base class for pipeline handler factories.
Definition pipeline_handler.h:115
libcamera::Thread
A thread of execution.
Definition thread.h:32
mutex.h
Mutex classes with clang thread safety annotation.
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
process.h
Process object.
thread.h
Thread support.