summaryrefslogtreecommitdiff
path: root/include/libcamera/internal/device_enumerator.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libcamera/internal/device_enumerator.h')
-rw-r--r--include/libcamera/internal/device_enumerator.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h
new file mode 100644
index 00000000..433e357a
--- /dev/null
+++ b/include/libcamera/internal/device_enumerator.h
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2018, Google Inc.
+ *
+ * device_enumerator.h - API to enumerate and find media devices
+ */
+#ifndef __LIBCAMERA_DEVICE_ENUMERATOR_H__
+#define __LIBCAMERA_DEVICE_ENUMERATOR_H__
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include <linux/media.h>
+
+namespace libcamera {
+
+class MediaDevice;
+
+class DeviceMatch
+{
+public:
+ DeviceMatch(const std::string &driver);
+
+ void add(const std::string &entity);
+
+ bool match(const MediaDevice *device) const;
+
+private:
+ std::string driver_;
+ std::vector<std::string> entities_;
+};
+
+class DeviceEnumerator
+{
+public:
+ static std::unique_ptr<DeviceEnumerator> create();
+
+ virtual ~DeviceEnumerator();
+
+ virtual int init() = 0;
+ virtual int enumerate() = 0;
+
+ std::shared_ptr<MediaDevice> search(const DeviceMatch &dm);
+
+protected:
+ std::unique_ptr<MediaDevice> createDevice(const std::string &deviceNode);
+ void addDevice(std::unique_ptr<MediaDevice> &&media);
+ void removeDevice(const std::string &deviceNode);
+
+private:
+ std::vector<std::shared_ptr<MediaDevice>> devices_;
+};
+
+} /* namespace libcamera */
+
+#endif /* __LIBCAMERA_DEVICE_ENUMERATOR_H__ */