Check MS Media Foundation availability in G-API.

This commit is contained in:
Alexander Smorkalov 2025-05-24 09:38:37 +03:00 committed by Alexander Smorkalov
parent 250b5003ee
commit d3d477e4a0
4 changed files with 18 additions and 7 deletions

View File

@ -369,7 +369,7 @@ OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON
OCV_OPTION(WITH_DSHOW "Build VideoIO with DirectShow support" ON
VISIBLE_IF WIN32 AND NOT ARM AND NOT WINRT
VERIFY HAVE_DSHOW)
OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" NOT MINGW
OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" OFF # NOT MINGW
VISIBLE_IF WIN32
VERIFY HAVE_MSMF)
OCV_OPTION(WITH_MSMF_DXVA "Enable hardware acceleration in Media Foundation backend" WITH_MSMF

View File

@ -380,6 +380,15 @@ if(WIN32)
ocv_target_link_libraries(${the_module} PRIVATE wsock32 ws2_32)
endif()
ocv_option(OPENCV_GAPI_MSMF "Build G-API with MS Media Foundation support" HAVE_MSMF)
if(HAVE_MSMF AND OPENCV_GAPI_MSMF)
if(TARGET opencv_test_gapi)
ocv_target_compile_definitions(opencv_test_gapi PRIVATE -DHAVE_MSMF)
endif()
ocv_target_compile_definitions(${the_module} PRIVATE -DHAVE_MSMF)
ocv_target_link_libraries(${the_module} PRIVATE ocv.3rdparty.msmf)
endif()
if(HAVE_DIRECTML)
ocv_target_compile_definitions(${the_module} PRIVATE HAVE_DIRECTML=1)
endif()

View File

@ -14,7 +14,9 @@ namespace cv {
namespace gapi {
namespace wip {
namespace onevpl {
#ifdef _WIN32
#ifdef HAVE_MSMF
static HRESULT create_media_source(const std::string& url, IMFMediaSource **ppSource) {
wchar_t sURL[MAX_PATH];
GAPI_Assert(url.size() < MAX_PATH && "Windows MAX_PATH limit was reached");
@ -785,7 +787,7 @@ bool MFPAsyncDemuxDataProvider::empty() const {
(processing_locked_buffer_storage.size() == 0) &&
(get_locked_buffer_size() == 0);
}
#else // _WIN32
#else // HAVE_MSMF
MFPAsyncDemuxDataProvider::MFPAsyncDemuxDataProvider(const std::string&) {
GAPI_Error("Unsupported: Microsoft Media Foundation is not available");
@ -804,7 +806,7 @@ bool MFPAsyncDemuxDataProvider::empty() const {
GAPI_Error("Unsupported: Microsoft Media Foundation is not available");
return true;
}
#endif // _WIN32
#endif // HAVE_MSMF
} // namespace onevpl
} // namespace wip
} // namespace gapi

View File

@ -16,7 +16,7 @@
#include "streaming/onevpl/onevpl_export.hpp"
#include <opencv2/gapi/streaming/onevpl/data_provider_interface.hpp>
#ifdef _WIN32
#ifdef HAVE_MSMF
#define NOMINMAX
#include <mfapi.h>
#include <mfidl.h>
@ -104,7 +104,7 @@ private:
} // namespace gapi
} // namespace cv
#else // _WIN32
#else // HAVE_MSMF
namespace cv {
namespace gapi {
namespace wip {
@ -121,6 +121,6 @@ struct GAPI_EXPORTS MFPAsyncDemuxDataProvider : public IDataProvider {
} // namespace gapi
} // namespace cv
#endif // _WIN32
#endif // HAVE_MSMF
#endif // HAVE_ONEVPL
#endif // GAPI_STREAMING_ONEVPL_DEMUX_ASYNC_MFP_DEMUX_DATA_PROVIDER_HPP