#ifndef __DEVICEDISCOVERY_H__ #define __DEVICEDISCOVERY_H__ #include #include #include #include #ifdef WIN32 #include #include class IPin; class IBaseFilter; #endif class DeviceDiscovery { constexpr static int32_t OtaSpecificWidth = 96; public: constexpr static auto DeviceName = "UVC Camera"; using Resolution = std::pair; using Resolutions = std::vector; struct Device { Device() = default; std::string friendlyName; std::string alternativeName; Resolutions resolutions; ~Device(); #ifdef WIN32 Device(IMFMediaSource *source); IMFMediaSource *source = nullptr; IMFSourceReader *reader = nullptr; #endif }; DeviceDiscovery(); std::shared_ptr find(const std::string &deviceName, std::error_code &error); void enterOtaMode(const std::shared_ptr &device, std::error_code &error); std::vector devices(); std::vector getDevices(); bool SetResolution(const std::string &deviceName, int width, int height); protected: Resolutions deviceResolutions(const std::shared_ptr &source); #ifdef WIN32 void GetDeviceNames(IMoniker *pMoniker, Device &info); void GetSupportedResolutions(IPin *pPin, std::vector> &resolutions); bool SetPinResolution(IBaseFilter *pFilter, int width, int height); #endif }; #endif // __DEVICEDISCOVERY_H__