Emit a signal whenever new MediaDevices are added to the DeviceEnumerator. This will allow CameraManager to be notified about the new devices and it can re-emumerate all the devices currently present on the system. Device enumeration by the CameraManger is an expensive operation hence, we want one signal emission per 'x' milliseconds to notify multiple devices additions as a single batch, by the DeviceEnumerator. Add a \todo to investigate the support for that. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
61 lines
1.2 KiB
C++
61 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/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__ */
|