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

libcamera v0.3.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/process.h"
22
23namespace libcamera {
24
25class Camera;
26class DeviceEnumerator;
27class IPAManager;
28class PipelineHandlerFactoryBase;
29
30class CameraManager::Private : public Extensible::Private, public Thread
31{
32 LIBCAMERA_DECLARE_PUBLIC(CameraManager)
33
34public:
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 IPAManager *ipaManager() const { return ipaManager_.get(); }
42
43protected:
44 void run() override;
45
46private:
47 int init();
48 void createPipelineHandlers();
49 void pipelineFactoryMatch(const PipelineHandlerFactoryBase *factory);
50 void cleanup() LIBCAMERA_TSA_EXCLUDES(mutex_);
51
52 /*
53 * This mutex protects
54 *
55 * - initialized_ and status_ during initialization
56 * - cameras_ after initialization
57 */
58 mutable Mutex mutex_;
59 std::vector<std::shared_ptr<Camera>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
60
61 ConditionVariable cv_;
62 bool initialized_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
63 int status_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
64
65 std::unique_ptr<DeviceEnumerator> enumerator_;
66
67 std::unique_ptr<IPAManager> ipaManager_;
68 ProcessManager processManager_;
69};
70
71} /* 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::Extensible::Private::Private
Private()
Construct an instance of an Extensible class private data.
Definition class.cpp:194
libcamera::Thread::start
void start()
Start the thread.
Definition thread.cpp:245
libcamera::Thread::run
virtual void run()
Main function of the thread.
Definition thread.cpp:331
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.