acffe919cca12be337eae90800dfe1ac3259d680
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / sys / wasapi2 / meson.build
1 wasapi2_sources = [
2   'gstwasapi2src.c',
3   'gstwasapi2sink.c',
4   'gstwasapi2util.c',
5   'gstwasapi2client.cpp',
6   'gstwasapi2device.c',
7   'gstwasapi2ringbuffer.cpp',
8   'plugin.c',
9 ]
10
11 mmdeviceapi_symbols = [
12   'ActivateAudioInterfaceAsync',
13   'DEVINTERFACE_AUDIO_RENDER',
14   'DEVINTERFACE_AUDIO_CAPTURE',
15 ]
16
17 wasapi2_option = get_option('wasapi2')
18 if host_system != 'windows'
19   if wasapi2_option.disabled()
20     subdir_done()
21   elif wasapi2_option.enabled()
22     error('Cannot build wasapi2 plugin when not building for Windows')
23   endif
24 endif
25
26 ole32_dep = cc.find_library('ole32', required : get_option('wasapi2'))
27 ksuser_dep = cc.find_library('ksuser', required : get_option('wasapi2'))
28 runtimeobject_dep = cc.find_library('runtimeobject', required : get_option('wasapi2'))
29 mmdeviceapi_dep = cc.find_library('mmdevapi', required : get_option('wasapi2'))
30 mfplat_dep = cc.find_library('mfplat', required : get_option('wasapi2'))
31 wasapi2_dep = [ole32_dep, ksuser_dep, runtimeobject_dep, mmdeviceapi_dep, mfplat_dep]
32 extra_args = ['-DGST_USE_UNSTABLE_API']
33
34 foreach dep: wasapi2_dep
35   if not dep.found()
36     if wasapi2_option.enabled()
37       error('wasapi2 plugin was enabled explicitly, but required dependencies were not found')
38     else
39       subdir_done()
40     endif
41   endif
42 endforeach
43
44 if not cxx.has_header_symbol ('audioclient.h', 'IAudioClient3', dependencies : wasapi2_dep)
45   if wasapi2_option.enabled()
46     error('wasapi2 plugin was enabled explicitly, but IAudioClient3 is unavailable')
47   else
48     subdir_done()
49   endif
50 endif
51
52 foreach symbol: mmdeviceapi_symbols
53   if not cxx.has_header_symbol ('mmdeviceapi.h', symbol, dependencies : wasapi2_dep)
54     if wasapi2_option.enabled()
55       error('wasapi2 plugin was enabled explicitly, but @1@ is unavailable'.format(symbol))
56     else
57       subdir_done()
58     endif
59   endif
60 endforeach
61
62 winapi_app = cxx.compiles('''#include <winapifamily.h>
63   #include <windows.applicationmodel.core.h>
64   #include <wrl.h>
65   #include <wrl/wrappers/corewrappers.h>
66   #include <audioclient.h>
67   #include <mmdeviceapi.h>
68   #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
69   #error "not winrt"
70   #endif
71   int main (int argc, char ** argv) {
72     IAudioClient3 *client = NULL;
73     return 0;
74   } ''',
75   dependencies: wasapi2_dep,
76   name: 'building for WINAPI_PARTITION_APP')
77
78 if not winapi_app
79   if wasapi2_option.enabled()
80     error('wasapi2 plugin was enabled explicitly, but build target is not include WINAPI_PARTITION_APP')
81   else
82     subdir_done()
83   endif
84 endif
85
86 win10_sdk = cxx.compiles('''#include <windows.h>
87     #ifndef WDK_NTDDI_VERSION
88     #error "unknown Windows SDK version"
89     #endif
90     #if (WDK_NTDDI_VERSION < 0x0A000000)
91     #error "Not a Windows 10 SDK"
92     #endif
93     ''',
94     name: 'building with Windows 10 SDK')
95
96 if not win10_sdk
97   if wasapi2_option.enabled()
98     error('wasapi2 plugin was enabled explicitly, but Windows 10 SDK is unavailable')
99   else
100     subdir_done()
101   endif
102 endif
103
104 building_for_win10 = cxx.compiles('''#include <windows.h>
105     #ifndef WINVER
106     #error "unknown minimum supported OS version"
107     #endif
108     #if (WINVER < 0x0A00)
109     #error "Windows 10 API is not guaranteed"
110     #endif
111     ''',
112     name: 'building for Windows 10')
113
114 if not building_for_win10
115   message('Bumping target Windows version to Windows 10 for building wasapi2 plugin')
116   extra_args += ['-DWINVER=0x0A00', '-D_WIN32_WINNT=0x0A00', '-DNTDDI_VERSION=WDK_NTDDI_VERSION']
117 endif
118
119 if not gstwinrt_dep.found()
120   if wasapi2_option.enabled()
121     error('wasapi2 plugin was enabled explicitly, but GstWinRt library is unavailable')
122   else
123     subdir_done()
124   endif
125 endif
126
127 gstwasapi2 = library('gstwasapi2',
128   wasapi2_sources,
129   c_args : gst_plugins_bad_args + ['-DCOBJMACROS'] + extra_args,
130   cpp_args : gst_plugins_bad_args + extra_args,
131   include_directories : [configinc],
132   dependencies : [gstaudio_dep, gstwinrt_dep] + wasapi2_dep,
133   install : true,
134   install_dir : plugins_install_dir)
135 pkgconfig.generate(gstwasapi2, install_dir : plugins_pkgconfig_install_dir)
136 plugins += [gstwasapi2]