SmartLockerTools/Peripheral/DeviceDiscovery.h
luocai ce673bf330
Some checks failed
Build Applications / Build (push) Failing after 1m17s
Windows CI / build (push) Successful in 3m4s
add dshow api.
2024-11-21 19:34:13 +08:00

52 lines
1.5 KiB
C++

#ifndef __DEVICEDISCOVERY_H__
#define __DEVICEDISCOVERY_H__
#include <memory>
#include <string>
#include <system_error>
#include <vector>
#ifdef WIN32
#include <mfidl.h>
#include <mfreadwrite.h>
class IPin;
class IBaseFilter;
#endif
class DeviceDiscovery {
constexpr static int32_t OtaSpecificWidth = 96;
public:
constexpr static auto DeviceName = "UVC Camera";
using Resolution = std::pair<int32_t, int32_t>;
using Resolutions = std::vector<Resolution>;
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<Device> find(const std::string &deviceName, std::error_code &error);
void enterOtaMode(const std::shared_ptr<Device> &device, std::error_code &error);
std::vector<std::string> devices();
std::vector<Device> getDevices();
bool SetResolution(const std::string &deviceName, int width, int height);
protected:
Resolutions deviceResolutions(const std::shared_ptr<Device> &source);
#ifdef WIN32
void GetDeviceNames(IMoniker *pMoniker, Device &info);
void GetSupportedResolutions(IPin *pPin, std::vector<std::pair<int, int>> &resolutions);
bool SetPinResolution(IBaseFilter *pFilter, int width, int height);
#endif
};
#endif // __DEVICEDISCOVERY_H__