libcamera v0.6.0 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
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 * 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
20 class DeviceMatch
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
34 class DeviceEnumerator
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
46 Signal<> devicesAdded;
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 */
libcamera::DeviceEnumerator
Enumerate, store and search media devices.
Definition device_enumerator.h:35
libcamera::DeviceEnumerator::search
std::shared_ptr< MediaDevice > search(const DeviceMatch &dm)
Search available media devices for a pattern match.
Definition device_enumerator.cpp:311
libcamera::DeviceEnumerator::create
static std::unique_ptr< DeviceEnumerator > create()
Create a new device enumerator matching the systems capabilities.
Definition device_enumerator.cpp:147
libcamera::DeviceEnumerator::init
virtual int init()=0
Initialize the enumerator.
libcamera::DeviceEnumerator::addDevice
void addDevice(std::unique_ptr< MediaDevice > media)
Add a media device to the enumerator.
Definition device_enumerator.cpp:256
libcamera::DeviceEnumerator::enumerate
virtual int enumerate()=0
Enumerate all media devices in the system.
libcamera::DeviceEnumerator::removeDevice
void removeDevice(const std::string &deviceNode)
Remove a media device from the enumerator.
Definition device_enumerator.cpp:275
libcamera::DeviceEnumerator::devicesAdded
Signal devicesAdded
Notify of new media devices being found.
Definition device_enumerator.h:46
libcamera::DeviceEnumerator::createDevice
std::unique_ptr< MediaDevice > createDevice(const std::string &deviceNode)
Create a media device instance.
Definition device_enumerator.cpp:218
libcamera::DeviceMatch
Description of a media device search pattern.
Definition device_enumerator.h:21
libcamera::DeviceMatch::DeviceMatch
DeviceMatch(const std::string &driver)
Construct a media device search pattern.
Definition device_enumerator.cpp:70
libcamera::DeviceMatch::add
void add(const std::string &entity)
Add a media entity name to the search pattern.
Definition device_enumerator.cpp:79
libcamera::DeviceMatch::match
bool match(const MediaDevice *device) const
Compare a search pattern with a media device.
Definition device_enumerator.cpp:94
libcamera::MediaDevice
The MediaDevice represents a Media Controller device with its full graph of connected objects.
Definition media_device.h:27
libcamera::Signal
Generic signal and slot communication mechanism.
Definition signal.h:39
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
signal.h
Signal & slot implementation.