• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1wasapi2_sources = [
2  'gstwasapi2src.c',
3  'gstwasapi2sink.c',
4  'gstwasapi2util.c',
5  'gstwasapi2client.cpp',
6  'gstwasapi2device.c',
7  'gstwasapi2ringbuffer.cpp',
8  'plugin.c',
9]
10
11mmdeviceapi_symbols = [
12  'ActivateAudioInterfaceAsync',
13  'DEVINTERFACE_AUDIO_RENDER',
14  'DEVINTERFACE_AUDIO_CAPTURE',
15]
16
17wasapi2_option = get_option('wasapi2')
18if 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
24endif
25
26ole32_dep = cc.find_library('ole32', required : get_option('wasapi2'))
27ksuser_dep = cc.find_library('ksuser', required : get_option('wasapi2'))
28runtimeobject_dep = cc.find_library('runtimeobject', required : get_option('wasapi2'))
29mmdeviceapi_dep = cc.find_library('mmdevapi', required : get_option('wasapi2'))
30mfplat_dep = cc.find_library('mfplat', required : get_option('wasapi2'))
31wasapi2_dep = [ole32_dep, ksuser_dep, runtimeobject_dep, mmdeviceapi_dep, mfplat_dep]
32extra_args = ['-DGST_USE_UNSTABLE_API']
33
34foreach 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
42endforeach
43
44if 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
50endif
51
52foreach 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
60endforeach
61
62winapi_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
78if 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
84endif
85
86winapi_desktop = cxx.compiles('''#include <winapifamily.h>
87    #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
88    #error "not win32"
89    #endif''',
90    name: 'building for WINAPI_PARTITION_DESKTOP')
91
92if winapi_app and not winapi_desktop
93  extra_args += ['-DGST_WASAPI2_WINAPI_ONLY_APP']
94endif
95
96win10_sdk = cxx.compiles('''#include <windows.h>
97    #ifndef WDK_NTDDI_VERSION
98    #error "unknown Windows SDK version"
99    #endif
100    #if (WDK_NTDDI_VERSION < 0x0A000000)
101    #error "Not a Windows 10 SDK"
102    #endif
103    ''',
104    name: 'building with Windows 10 SDK')
105
106if not win10_sdk
107  if wasapi2_option.enabled()
108    error('wasapi2 plugin was enabled explicitly, but Windows 10 SDK is unavailable')
109  else
110    subdir_done()
111  endif
112endif
113
114building_for_win10 = cxx.compiles('''#include <windows.h>
115    #ifndef WINVER
116    #error "unknown minimum supported OS version"
117    #endif
118    #if (WINVER < 0x0A00)
119    #error "Windows 10 API is not guaranteed"
120    #endif
121    ''',
122    name: 'building for Windows 10')
123
124if not building_for_win10
125  message('Bumping target Windows version to Windows 10 for building wasapi2 plugin')
126  extra_args += ['-DWINVER=0x0A00', '-D_WIN32_WINNT=0x0A00', '-DNTDDI_VERSION=WDK_NTDDI_VERSION']
127endif
128
129if not gstwinrt_dep.found()
130  if wasapi2_option.enabled()
131    error('wasapi2 plugin was enabled explicitly, but GstWinRt library is unavailable')
132  else
133    subdir_done()
134  endif
135endif
136
137# Work around for Windows SDK header issue
138# https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-160#windows-header-issues
139extra_cpp_args = cxx.get_supported_arguments(['/Zc:twoPhase-'])
140
141gstwasapi2 = library('gstwasapi2',
142  wasapi2_sources,
143  c_args : gst_plugins_bad_args + ['-DCOBJMACROS'] + extra_args,
144  cpp_args : gst_plugins_bad_args + extra_args + extra_cpp_args,
145  include_directories : [configinc],
146  dependencies : [gstaudio_dep, gstwinrt_dep] + wasapi2_dep,
147  install : true,
148  install_dir : plugins_install_dir)
149pkgconfig.generate(gstwasapi2, install_dir : plugins_pkgconfig_install_dir)
150plugins += [gstwasapi2]
151