libcamera  v0.3.1+1-c9152bad
Supporting cameras in Linux since 2019
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 
11 
12 #include <map>
13 #include <memory>
14 #include <sys/types.h>
15 #include <vector>
16 
17 #include <libcamera/base/class.h>
18 #include <libcamera/base/mutex.h>
19 #include <libcamera/base/thread.h>
20 #include <libcamera/base/thread_annotations.h>
21 
24 
25 namespace libcamera {
26 
27 class Camera;
28 class DeviceEnumerator;
29 
30 class CameraManager::Private : public Extensible::Private, public Thread
31 {
32  LIBCAMERA_DECLARE_PUBLIC(CameraManager)
33 
34 public:
35  Private();
36 
37  int start();
38  void addCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);
39  void removeCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);
40 
41 protected:
42  void run() override;
43 
44 private:
45  int init();
46  void createPipelineHandlers();
47  void pipelineFactoryMatch(const PipelineHandlerFactoryBase *factory);
48  void cleanup() LIBCAMERA_TSA_EXCLUDES(mutex_);
49 
50  /*
51  * This mutex protects
52  *
53  * - initialized_ and status_ during initialization
54  * - cameras_ after initialization
55  */
56  mutable Mutex mutex_;
57  std::vector<std::shared_ptr<Camera>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
58 
59  ConditionVariable cv_;
60  bool initialized_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
61  int status_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
62 
63  std::unique_ptr<DeviceEnumerator> enumerator_;
64 
65  IPAManager ipaManager_;
66  ProcessManager processManager_;
67 };
68 
69 } /* namespace libcamera */
Utilities to help constructing class interfaces.
Image Processing Algorithm module manager.
Top-level libcamera namespace.
Definition: backtrace.h:17
The camera manager.
Definition: v4l2_pixelformat.h:60
#define LIBCAMERA_DECLARE_PUBLIC(klass)
Declare public data for a private class.
Thread support.
Private()
Construct an instance of an Extensible class private data.
Definition: class.cpp:194
virtual void run()
Main function of the thread.
Definition: thread.cpp:367
int start()
Start the camera manager.
Definition: camera_manager.cpp:311
Process object.
Mutex classes with clang thread safety annotation.