1mf_sources = [ 2 'plugin.c', 3 'gstmfutils.cpp', 4 'gstmftransform.cpp', 5 'gstmfvideoenc.cpp', 6 'gstmfh264enc.cpp', 7 'gstmfh265enc.cpp', 8 'gstmfvp9enc.cpp', 9 'gstmfvideosrc.c', 10 'gstmfsourceobject.c', 11 'gstmfdevice.c', 12 'gstmfaudioenc.cpp', 13 'gstmfaacenc.cpp', 14 'gstmfmp3enc.cpp', 15 'gstmfvideobuffer.cpp', 16 'gstmfplatloader.c', 17] 18 19mf_desktop_sources = [ 20 'gstmfsourcereader.cpp', 21 'gstwin32devicewatcher.cpp', 22] 23 24mf_app_sources = [ 25 'gstmfcapturewinrt.cpp', 26 'mediacapturewrapper.cpp', 27] 28 29mf_header_deps = [ 30 'mfidl.h', 31 'mfapi.h', 32 'mfreadwrite.h', 33 'mferror.h', 34 'strmif.h', 35 'mfobjects.h', 36 'codecapi.h', 37] 38 39winapi_desktop = false 40winapi_app = false 41have_capture_engine = false 42have_mf_d3d11 = false 43mf_lib_deps = [] 44mf_config = configuration_data() 45extra_c_args = ['-DCOBJMACROS'] 46extra_cpp_args = [] 47 48mf_option = get_option('mediafoundation') 49if host_system != 'windows' or mf_option.disabled() 50 subdir_done() 51endif 52 53if cc.get_id() != 'msvc' 54 if mf_option.enabled() 55 error('mediafoundation plugin can only be built with MSVC') 56 endif 57 subdir_done() 58endif 59 60mf_lib = cc.find_library('mf', required : mf_option) 61mfplat_lib = cc.find_library('mfplat', required : mf_option) 62mfreadwrite_lib = cc.find_library('mfreadwrite', required : mf_option) 63mfuuid_lib = cc.find_library('mfuuid', required : mf_option) 64strmiids_lib = cc.find_library('strmiids', required : mf_option) 65ole32_dep = cc.find_library('ole32', required : mf_option) 66runtimeobject_lib = cc.find_library('runtimeobject', required : false) 67 68have_mf_lib = mf_lib.found() and mfplat_lib.found() and mfreadwrite_lib.found() and mfuuid_lib.found() and strmiids_lib.found() and ole32_dep.found() 69if not have_mf_lib 70 if mf_option.enabled() 71 error('The mediafoundation plugin was enabled explicitly, but required libraries were not found.') 72 endif 73 subdir_done() 74endif 75 76mf_lib_deps += [mf_lib, mfplat_lib, mfreadwrite_lib, mfuuid_lib, strmiids_lib, ole32_dep] 77 78have_mf_header = true 79foreach h: mf_header_deps 80 if have_mf_header 81 have_mf_header = cc.has_header(h) 82 endif 83endforeach 84 85if not have_mf_header 86 if mf_option.enabled() 87 error('The mediafoundation plugin was enabled explicitly, but required headers were not found.') 88 endif 89 subdir_done() 90endif 91 92winapi_desktop = cxx.compiles('''#include <winapifamily.h> 93 #include <wrl.h> 94 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 95 #error "not win32" 96 #endif''', 97 dependencies: mf_lib_deps, 98 name: 'building for Win32') 99 100if runtimeobject_lib.found() 101 winapi_app = cxx.compiles('''#include <winapifamily.h> 102 #include <windows.applicationmodel.core.h> 103 #include <wrl.h> 104 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 105 #error "not winrt" 106 #endif 107 #ifndef WINVER 108 #error "unknown minimum supported OS version" 109 #endif 110 #if (WINVER < 0x0A00) 111 #error "Windows 10 API is not guaranteed" 112 #endif''', 113 dependencies: [mf_lib_deps, runtimeobject_lib], 114 name: 'building for WinRT') 115endif 116 117if not winapi_desktop and not winapi_app 118 error('Neither Desktop partition nor App partition') 119endif 120 121if winapi_app 122 if not gstwinrt_dep.found() 123 if mf_option.enabled() 124 error('The mediafoundation plugin was enabled explicitly, but GstWinRt library is unavailable') 125 else 126 subdir_done() 127 endif 128 endif 129 130 mf_sources += mf_app_sources 131 mf_lib_deps += [runtimeobject_lib, gstwinrt_dep] 132endif 133 134if winapi_desktop 135 mf_sources += mf_desktop_sources 136 # We need d3d11_4.h header for querying "ExtendedNV12SharedTextureSupported" 137 # Since MFTEnum2 is desktop only we don't support d3d11 interop for UWP build 138 # And because MFTEnum2 is Windows 10 API, we will load MFTEnum2 symbol 139 # by using g_module_open() so that keep supporting old OS versions 140 if gstd3d11_dep.found() and cc.has_header('d3d11_4.h') and cc.has_header('d3d10.h') 141 have_mf_d3d11 = true 142 mf_lib_deps += [gstd3d11_dep] 143 extra_c_args += ['-DGST_USE_UNSTABLE_API'] 144 extra_cpp_args += ['-DGST_USE_UNSTABLE_API'] 145 message ('Enable D3D11 interop for MediaFoundation plugin') 146 endif 147endif 148 149mf_config.set10('GST_MF_WINAPI_APP', winapi_app) 150mf_config.set10('GST_MF_WINAPI_DESKTOP', winapi_desktop) 151mf_config.set10('GST_MF_HAVE_D3D11', have_mf_d3d11) 152 153configure_file( 154 output: 'gstmfconfig.h', 155 configuration: mf_config, 156) 157 158# Work around for Windows SDK header issue 159# https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-160#windows-header-issues 160extra_cpp_args += cxx.get_supported_arguments(['/Zc:twoPhase-']) 161 162gstmediafoundation = library('gstmediafoundation', 163 mf_sources, 164 c_args : gst_plugins_bad_args + extra_c_args, 165 cpp_args : gst_plugins_bad_args + extra_cpp_args, 166 include_directories : [configinc], 167 dependencies : [gstbase_dep, gstvideo_dep, gstaudio_dep, gstpbutils_dep, gmodule_dep] + mf_lib_deps, 168 install : true, 169 install_dir : plugins_install_dir, 170) 171pkgconfig.generate(gstmediafoundation, install_dir : plugins_pkgconfig_install_dir) 172plugins += [gstmediafoundation] 173