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