From 2f3565efb5377768e3c2e1ef85eec99668f485de Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Mon, 7 Aug 2023 10:13:16 +0200 Subject: libcamera: Define and use MediaDeviceMatch The xistingdevice search and match criteria implemented by libcamera only supports 'media device' based cameras, which are supported in the Linux kernel by the usage of the V4L2/MC API. Define a MediaDeviceMatch class derived from DeviceMatch and use it wherever DeviceMatch was used in order to later introduce new derived classes to support searching and matching devices of a different type. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/device_enumerator.h | 2 +- include/libcamera/internal/device_match.h | 9 +++++++-- include/libcamera/internal/pipeline_handler.h | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h index 259a9e46..2afb9fa0 100644 --- a/include/libcamera/internal/device_enumerator.h +++ b/include/libcamera/internal/device_enumerator.h @@ -29,7 +29,7 @@ public: virtual int init() = 0; virtual int enumerate() = 0; - std::shared_ptr search(const DeviceMatch &dm); + std::shared_ptr search(const MediaDeviceMatch &dm); Signal<> devicesAdded; diff --git a/include/libcamera/internal/device_match.h b/include/libcamera/internal/device_match.h index 9f190f0c..6df7dece 100644 --- a/include/libcamera/internal/device_match.h +++ b/include/libcamera/internal/device_match.h @@ -17,11 +17,16 @@ class MediaDevice; class DeviceMatch { public: - DeviceMatch(const std::string &driver); + virtual bool match(const MediaDevice *device) const = 0; +}; +class MediaDeviceMatch : public DeviceMatch +{ +public: void add(const std::string &entity); + MediaDeviceMatch(const std::string &driver); - bool match(const MediaDevice *device) const; + bool match(const MediaDevice *device) const override; private: std::string driver_; diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index c96944f4..02b2f337 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -28,7 +28,7 @@ class Camera; class CameraConfiguration; class CameraManager; class DeviceEnumerator; -class DeviceMatch; +class MediaDeviceMatch; class FrameBuffer; class MediaDevice; class PipelineHandler; @@ -43,7 +43,7 @@ public: virtual bool match(DeviceEnumerator *enumerator) = 0; MediaDevice *acquireMediaDevice(DeviceEnumerator *enumerator, - const DeviceMatch &dm); + const MediaDeviceMatch &dm); bool acquire(); void release(Camera *camera); -- cgit v1.2.1