meson.build 3.67 KB
Newer Older
1 2 3
mf_sources = [
  'plugin.c',
  'gstmfutils.cpp',
4 5 6
  'gstmftransform.cpp',
  'gstmfvideoenc.cpp',
  'gstmfh264enc.cpp',
7
  'gstmfh265enc.cpp',
8
  'gstmfvp9enc.cpp',
9 10 11
  'gstmfvideosrc.c',
  'gstmfsourceobject.c',
  'gstmfdevice.c',
12 13
  'gstmfaudioenc.cpp',
  'gstmfaacenc.cpp',
14
  'gstmfmp3enc.cpp',
15 16 17
]

mf_desktop_sources = [
18
  'gstmfsourcereader.cpp',
19 20 21 22 23
]

mf_app_sources = [
  'gstmfcapturewinrt.cpp',
  'mediacapturewrapper.cpp',
24 25 26 27 28 29 30 31 32
]

mf_header_deps = [
  'mfidl.h',
  'mfapi.h',
  'mfreadwrite.h',
  'mferror.h',
  'strmif.h',
  'mfobjects.h',
33
  'codecapi.h',
34 35 36
]

winapi_desktop = false
37
winapi_app = false
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
have_capture_engine = false
mf_lib_deps = []
mf_config = configuration_data()

mf_option = get_option('mediafoundation')
if host_system != 'windows' or mf_option.disabled()
  subdir_done()
endif

if cc.get_id() != 'msvc'
  if mf_option.enabled()
    error('mediafoundation plugin can only be built with MSVC')
  endif
  subdir_done()
endif

mf_lib = cc.find_library('mf', required : mf_option)
mfplat_lib = cc.find_library('mfplat', required : mf_option)
mfreadwrite_lib = cc.find_library('mfreadwrite', required : mf_option)
mfuuid_lib = cc.find_library('mfuuid', required : mf_option)
strmiids_lib = cc.find_library('strmiids', required : mf_option)
59
ole32_dep = cc.find_library('ole32', required : mf_option)
60
runtimeobject_lib = cc.find_library('runtimeobject', required : false)
61

62
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()
63 64 65 66 67 68 69
if not have_mf_lib
  if mf_option.enabled()
    error('The mediafoundation plugin was enabled explicitly, but required libraries were not found.')
  endif
  subdir_done()
endif

70
mf_lib_deps += [mf_lib, mfplat_lib, mfreadwrite_lib, mfuuid_lib, strmiids_lib, ole32_dep]
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91

have_mf_header = true
foreach h: mf_header_deps
  if have_mf_header
    have_mf_header = cc.has_header(h)
  endif
endforeach

if not have_mf_header
  if mf_option.enabled()
    error('The mediafoundation plugin was enabled explicitly, but required headers were not found.')
  endif
  subdir_done()
endif

winapi_desktop = cxx.compiles('''#include <winapifamily.h>
    #include <wrl.h>
    #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
    #error "not win32"
    #endif''',
    dependencies: mf_lib_deps,
92
    name: 'building for Win32')
93

94 95 96 97 98 99
if runtimeobject_lib.found()
  winapi_app = cxx.compiles('''#include <winapifamily.h>
      #include <windows.applicationmodel.core.h>
      #include <wrl.h>
      #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
      #error "not winrt"
100 101 102 103 104 105
      #endif
      #ifndef WINVER
      #error "unknown minimum supported OS version"
      #endif
      #if (WINVER < 0x0A00)
      #error "Windows 10 API is not guaranteed"
106 107
      #endif''',
      dependencies: [mf_lib_deps, runtimeobject_lib],
108
      name: 'building for WinRT')
109 110 111 112 113 114
endif

if not winapi_desktop and not winapi_app
  error('Neither Desktop partition nor App partition')
endif

115
if winapi_app
116 117
  mf_sources += mf_app_sources
  mf_lib_deps += [runtimeobject_lib]
118 119 120
endif

if winapi_desktop
121
  mf_sources += mf_desktop_sources
122 123
endif

124 125
mf_config.set10('GST_MF_WINAPI_APP', winapi_app)
mf_config.set10('GST_MF_WINAPI_DESKTOP', winapi_desktop)
126 127 128 129 130 131 132 133

configure_file(
  output: 'gstmfconfig.h',
  configuration: mf_config,
)

gstmediafoundation = library('gstmediafoundation',
  mf_sources,
134
  c_args : gst_plugins_bad_args + ['-DCOBJMACROS'],
135 136
  cpp_args : gst_plugins_bad_args,
  include_directories : [configinc],
137
  dependencies : [gstbase_dep, gstvideo_dep, gstaudio_dep, gstpbutils_dep] + mf_lib_deps,
138 139 140 141 142
  install : true,
  install_dir : plugins_install_dir,
)
pkgconfig.generate(gstmediafoundation, install_dir : plugins_pkgconfig_install_dir)
plugins += [gstmediafoundation]