SmartLockerTools/Peripheral/DeviceDiscovery.h
2024-06-13 15:41:40 +08:00

34 lines
950 B
C++

#ifndef __DEVICEDISCOVERY_H__
#define __DEVICEDISCOVERY_H__
#include <memory>
#include <mfidl.h>
#include <mfreadwrite.h>
#include <string>
#include <system_error>
#include <vector>
class DeviceDiscovery {
constexpr static int32_t OtaSpecificWidth = 96;
public:
struct Device {
Device(IMFMediaSource *source);
~Device();
IMFMediaSource *source = nullptr;
IMFSourceReader *reader = nullptr;
};
using Resolution = std::pair<int32_t, int32_t>;
using Resolutions = std::vector<Resolution>;
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();
protected:
std::string deviceName(IMFActivate *device);
Resolutions deviceResolutions(const std::shared_ptr<Device> &source);
};
#endif // __DEVICEDISCOVERY_H__