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