51 lines
1.4 KiB
C++
51 lines
1.4 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<Device> devices();
|
|
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__
|