Files
external_libcamera/include/libcamera/internal/device_enumerator.h
Kieran Bingham 27aff949fb libcamera/base: Move extended base functionality
Move the functionality for the following components to the new
base support library:

 - BoundMethod
 - EventDispatcher
 - EventDispatcherPoll
 - Log
 - Message
 - Object
 - Signal
 - Semaphore
 - Thread
 - Timer

While it would be preferable to see these split to move one component
per commit, these components are all interdependent upon each other,
which leaves us with one big change performing the move for all of them.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-25 16:11:08 +01:00

62 lines
1.2 KiB
C++

/* 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_INTERNAL_DEVICE_ENUMERATOR_H__
#define __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_H__
#include <memory>
#include <string>
#include <vector>
#include <linux/media.h>
#include <libcamera/base/signal.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);
Signal<> devicesAdded;
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_INTERNAL_DEVICE_ENUMERATOR_H__ */