SmartLockerTools/Peripheral/DeviceDiscovery.h

52 lines
1.5 KiB
C
Raw Normal View History

2024-05-17 10:36:23 +08:00
#ifndef __DEVICEDISCOVERY_H__
#define __DEVICEDISCOVERY_H__
#include <memory>
#include <string>
#include <system_error>
#include <vector>
2024-10-02 03:13:15 +08:00
#ifdef WIN32
#include <mfidl.h>
#include <mfreadwrite.h>
2024-11-21 19:34:13 +08:00
class IPin;
class IBaseFilter;
2024-10-02 03:13:15 +08:00
#endif
2024-05-17 10:36:23 +08:00
class DeviceDiscovery {
constexpr static int32_t OtaSpecificWidth = 96;
public:
2024-10-02 03:01:37 +08:00
constexpr static auto DeviceName = "UVC Camera";
2024-11-21 19:34:13 +08:00
using Resolution = std::pair<int32_t, int32_t>;
using Resolutions = std::vector<Resolution>;
2024-10-02 03:01:37 +08:00
struct Device {
2024-11-21 19:34:13 +08:00
Device() = default;
std::string friendlyName;
std::string alternativeName;
Resolutions resolutions;
2024-10-02 03:01:37 +08:00
~Device();
2024-10-02 03:13:15 +08:00
#ifdef WIN32
2024-10-02 03:01:37 +08:00
Device(IMFMediaSource *source);
IMFMediaSource *source = nullptr;
IMFSourceReader *reader = nullptr;
#endif
};
2024-05-17 10:36:23 +08:00
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);
2024-06-13 15:41:40 +08:00
std::vector<std::string> devices();
2024-11-21 19:34:13 +08:00
std::vector<Device> getDevices();
bool SetResolution(const std::string &deviceName, int width, int height);
2024-05-17 10:36:23 +08:00
protected:
Resolutions deviceResolutions(const std::shared_ptr<Device> &source);
2024-11-21 19:34:13 +08:00
#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
2024-05-17 10:36:23 +08:00
};
#endif // __DEVICEDISCOVERY_H__