libcamera  v0.0.0
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) 2018, Google Inc.
4  *
5  * camera_manager.h - Camera management
6  */
7 #ifndef __LIBCAMERA_CAMERA_MANAGER_H__
8 #define __LIBCAMERA_CAMERA_MANAGER_H__
9 
10 #include <memory>
11 #include <string>
12 #include <sys/types.h>
13 #include <vector>
14 
15 #include <libcamera/object.h>
16 #include <libcamera/signal.h>
17 
18 namespace libcamera {
19 
20 class Camera;
21 class EventDispatcher;
22 
23 class CameraManager : public Object
24 {
25 public:
26  CameraManager();
27  CameraManager(const CameraManager &) = delete;
28  CameraManager &operator=(const CameraManager &) = delete;
29  ~CameraManager();
30 
31  int start();
32  void stop();
33 
34  std::vector<std::shared_ptr<Camera>> cameras() const;
35  std::shared_ptr<Camera> get(const std::string &name);
36  std::shared_ptr<Camera> get(dev_t devnum);
37 
38  void addCamera(std::shared_ptr<Camera> camera,
39  const std::vector<dev_t> &devnums);
40  void removeCamera(std::shared_ptr<Camera> camera);
41 
42  static const std::string &version() { return version_; }
43 
44  void setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher);
46 
49 
50 private:
51  static const std::string version_;
52  static CameraManager *self_;
53 
54  class Private;
55  std::unique_ptr<Private> p_;
56 };
57 
58 } /* namespace libcamera */
59 
60 #endif /* __LIBCAMERA_CAMERA_MANAGER_H__ */
Provide access and manage all cameras in the system.
Definition: camera_manager.h:24
std::vector< std::shared_ptr< Camera > > cameras() const
Retrieve all available cameras.
Definition: camera_manager.cpp:320
static const std::string & version()
Retrieve the libcamera version string.
Definition: camera_manager.h:42
int start()
Start the camera manager.
Definition: camera_manager.cpp:281
void removeCamera(std::shared_ptr< Camera > camera)
Remove a camera from the camera manager.
Definition: camera_manager.cpp:438
void addCamera(std::shared_ptr< Camera > camera, const std::vector< dev_t > &devnums)
Add a camera to the camera manager.
Definition: camera_manager.cpp:419
Signal< std::shared_ptr< Camera > > cameraAdded
Notify of a new camera added to the system.
Definition: camera_manager.h:47
Signal< std::shared_ptr< Camera > > cameraRemoved
Notify of a new camera removed from the system.
Definition: camera_manager.h:48
std::shared_ptr< Camera > get(const std::string &name)
Get a camera based on name.
Definition: camera_manager.cpp:338
void stop()
Stop the camera manager.
Definition: camera_manager.cpp:303
EventDispatcher * eventDispatcher()
Retrieve the event dispatcher.
Definition: camera_manager.cpp:482
void setEventDispatcher(std::unique_ptr< EventDispatcher > dispatcher)
Set the event dispatcher.
Definition: camera_manager.cpp:466
Interface to manage the libcamera events and timers.
Definition: event_dispatcher.h:18
Base object to support automatic signal disconnection.
Definition: object.h:25
Generic signal and slot communication mechanism.
Definition: signal.h:39
Base object to support automatic signal disconnection.
Signal & slot implementation.