diff --git a/CMakeLists.txt b/CMakeLists.txt index b99e7bc..9cb4a13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ set(OPENSSL_INCLUDE_DIR ${OpenSSL_ROOT}/include) set(OpenSSL_LIBRARY_DIRS ${OpenSSL_ROOT}/lib) set(OpenSSL_LIBRARIES libssl libcrypto) -set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-7.0.1-full_build-shared) +set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-7.0.2-full_build-shared) set(FFmpeg_INCLUDE_DIR ${FFmpeg_ROOT}/include) set(FFmpeg_LIB_DIR ${FFmpeg_ROOT}/lib) diff --git a/Peripheral/DeviceDiscovery.cpp b/Peripheral/DeviceDiscovery.cpp index 10a2035..8ffee6e 100644 --- a/Peripheral/DeviceDiscovery.cpp +++ b/Peripheral/DeviceDiscovery.cpp @@ -6,6 +6,13 @@ #include #include +struct DeviceDiscovery::Device { + Device(IMFMediaSource *source); + ~Device(); + IMFMediaSource *source = nullptr; + IMFSourceReader *reader = nullptr; +}; + template void SafeRelease(T **ppT) { if (*ppT) { @@ -17,6 +24,21 @@ void SafeRelease(T **ppT) { DeviceDiscovery::DeviceDiscovery() { } +static std::string deviceName(IMFActivate *device) { + std::string ret; + WCHAR *friendlyName = nullptr; + uint32_t nameLength = 0; + auto result = device->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, &friendlyName, &nameLength); + + if (SUCCEEDED(result)) { + ret = Amass::StringUtility::wstringToString(std::wstring(friendlyName, nameLength)); + } + if (friendlyName != nullptr) { + CoTaskMemFree(friendlyName); + } + return ret; +} + std::shared_ptr DeviceDiscovery::find(const std::string &deviceName, std::error_code &error) { std::shared_ptr ret; @@ -45,7 +67,7 @@ std::shared_ptr DeviceDiscovery::find(const std::string int index = -1; for (int i = 0; i < count; i++) { - auto name = this->deviceName(devices[i]); + auto name = ::deviceName(devices[i]); LOG(info) << "device[" << i << "]: " << name; if (name == deviceName) { index = i; @@ -63,21 +85,6 @@ std::shared_ptr DeviceDiscovery::find(const std::string return ret; } -std::string DeviceDiscovery::deviceName(IMFActivate *device) { - std::string ret; - WCHAR *friendlyName = nullptr; - uint32_t nameLength = 0; - auto result = device->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, &friendlyName, &nameLength); - - if (SUCCEEDED(result)) { - ret = Amass::StringUtility::wstringToString(std::wstring(friendlyName, nameLength)); - } - if (friendlyName != nullptr) { - CoTaskMemFree(friendlyName); - } - return ret; -} - void DeviceDiscovery::enterOtaMode(const std::shared_ptr &device, std::error_code &error) { auto resolutions = deviceResolutions(device); LOG(info) << "device resolutions:"; @@ -144,7 +151,7 @@ std::vector DeviceDiscovery::devices() { } for (int i = 0; i < count; i++) { - auto name = this->deviceName(devices[i]); + auto name = ::deviceName(devices[i]); ret.push_back(name); } return ret; diff --git a/Peripheral/DeviceDiscovery.h b/Peripheral/DeviceDiscovery.h index ecdb01f..4f16963 100644 --- a/Peripheral/DeviceDiscovery.h +++ b/Peripheral/DeviceDiscovery.h @@ -12,12 +12,7 @@ class DeviceDiscovery { constexpr static int32_t OtaSpecificWidth = 96; public: - struct Device { - Device(IMFMediaSource *source); - ~Device(); - IMFMediaSource *source = nullptr; - IMFSourceReader *reader = nullptr; - }; + struct Device; using Resolution = std::pair; using Resolutions = std::vector; @@ -27,7 +22,6 @@ public: std::vector devices(); protected: - std::string deviceName(IMFActivate *device); Resolutions deviceResolutions(const std::shared_ptr &source); }; #endif // __DEVICEDISCOVERY_H__