From 55c72a8bb38bc12025de25fd0b3ee65b98078151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 8 Feb 2024 19:11:42 +0800 Subject: [PATCH] Camera (Windows): fix Windows Server Core compatibility --- CMakeLists.txt | 2 -- src/detection/camera/camera_windows.cpp | 9 ++++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33925ca3c..d29acd31c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -944,8 +944,6 @@ elseif(WIN32) PRIVATE "dwmapi" PRIVATE "gdi32" PRIVATE "iphlpapi" - PRIVATE "mf" - PRIVATE "mfplat" PRIVATE "ole32" PRIVATE "oleaut32" PRIVATE "ws2_32" diff --git a/src/detection/camera/camera_windows.cpp b/src/detection/camera/camera_windows.cpp index bcc3f2e3f..d84dd0c41 100644 --- a/src/detection/camera/camera_windows.cpp +++ b/src/detection/camera/camera_windows.cpp @@ -21,14 +21,17 @@ private: extern "C" const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result) { - // TODO: check if supported by Windows Server Core + FF_LIBRARY_LOAD(mfplat, NULL, "dlopen mfplat" FF_LIBRARY_EXTENSION " failed", "mfplat" FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(mfplat, MFCreateAttributes) + FF_LIBRARY_LOAD(mf, NULL, "dlopen mf" FF_LIBRARY_EXTENSION " failed", "mf" FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(mf, MFEnumDeviceSources) const char* error = ffInitCom(); if (error) return error; IMFAttributes* FF_AUTO_RELEASE_COM_OBJECT attrs = nullptr; - if (FAILED(MFCreateAttributes(&attrs, 1))) + if (FAILED(ffMFCreateAttributes(&attrs, 1))) return "MFCreateAttributes() failed"; if (FAILED(attrs->SetGUID( @@ -40,7 +43,7 @@ const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result) IMFActivate** devices = NULL; uint32_t count; - if (FAILED(MFEnumDeviceSources(attrs, &devices, &count))) + if (FAILED(ffMFEnumDeviceSources(attrs, &devices, &count))) return "MFEnumDeviceSources() failed"; for (uint32_t i = 0; i < count; i++)