libcamera: device_enumerator: Add hotplug support

Create a udev_monitor in the udev device enumerator to listen to media
device disconnection, and emit the corresponding media device's
disconnect signal in response.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Laurent Pinchart
2019-01-06 12:19:24 +02:00
parent 4d84fa4fee
commit 0052aaa40e
2 changed files with 88 additions and 1 deletions

View File

@@ -16,6 +16,7 @@
namespace libcamera {
class EventNotifier;
class MediaDevice;
class DeviceMatch
@@ -46,6 +47,7 @@ public:
protected:
int addDevice(const std::string &deviceNode);
void removeDevice(const std::string &deviceNode);
private:
std::vector<std::shared_ptr<MediaDevice>> devices_;
@@ -64,8 +66,12 @@ public:
private:
struct udev *udev_;
struct udev_monitor *monitor_;
EventNotifier *notifier_;
std::string lookupDeviceNode(int major, int minor) final;
void udevNotify(EventNotifier *notifier);
};
} /* namespace libcamera */