libcamera  v0.2.0+31-5e4dc46a
Supporting cameras in Linux since 2019
device_enumerator.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  * device_enumerator.h - API to enumerate and find media devices
6  */
7 
8 #pragma once
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 #include <libcamera/base/signal.h>
15 
16 namespace libcamera {
17 
18 class MediaDevice;
19 
21 {
22 public:
23  DeviceMatch(const std::string &driver);
24 
25  void add(const std::string &entity);
26 
27  bool match(const MediaDevice *device) const;
28 
29 private:
30  std::string driver_;
31  std::vector<std::string> entities_;
32 };
33 
35 {
36 public:
37  static std::unique_ptr<DeviceEnumerator> create();
38 
39  virtual ~DeviceEnumerator();
40 
41  virtual int init() = 0;
42  virtual int enumerate() = 0;
43 
44  std::shared_ptr<MediaDevice> search(const DeviceMatch &dm);
45 
47 
48 protected:
49  std::unique_ptr<MediaDevice> createDevice(const std::string &deviceNode);
50  void addDevice(std::unique_ptr<MediaDevice> media);
51  void removeDevice(const std::string &deviceNode);
52 
53 private:
54  std::vector<std::shared_ptr<MediaDevice>> devices_;
55 };
56 
57 } /* namespace libcamera */
The MediaDevice represents a Media Controller device with its full graph of connected objects...
Definition: media_device.h:25
Top-level libcamera namespace.
Definition: backtrace.h:17
bool match(const MediaDevice *device) const
Compare a search pattern with a media device.
Definition: device_enumerator.cpp:94
Signal & slot implementation.
Description of a media device search pattern.
Definition: device_enumerator.h:20
Enumerate, store and search media devices.
Definition: device_enumerator.h:34
Generic signal and slot communication mechanism.
Definition: object.h:20
DeviceMatch(const std::string &driver)
Construct a media device search pattern.
Definition: device_enumerator.cpp:70
void add(const std::string &entity)
Add a media entity name to the search pattern.
Definition: device_enumerator.cpp:79
Signal devicesAdded
Notify of new media devices being found.
Definition: device_enumerator.h:46