vaapi: Disable Wayland if no libdrm
[platform/upstream/gstreamer.git] / subprojects / gstreamer-vaapi / meson.build
1 project('gstreamer-vaapi', 'c',
2   version : '1.19.90',
3   meson_version : '>= 0.59',
4   default_options : [ 'warning_level=1',
5                       'buildtype=debugoptimized' ])
6
7 if get_option('default_library') == 'static'
8   error('GStreamer-VAAPI plugin not supported with `static` builds yet.')
9 endif
10
11 gst_version = meson.project_version()
12 version_arr = gst_version.split('.')
13 gst_version_major = version_arr[0].to_int()
14 gst_version_minor = version_arr[1].to_int()
15 gst_version_micro = version_arr[2].to_int()
16
17 if version_arr.length() == 4
18   gst_version_nano = version_arr[3].to_int()
19 else
20   gst_version_nano = 0
21 endif
22
23 libva_req = ['>= 0.39.0', '!= 0.99.0']
24 glib_req = '>= 2.44.0'
25 libwayland_req = '>= 1.11.0'
26 libdrm_req = '>= 2.4.98'
27 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
28
29 cc = meson.get_compiler('c')
30
31 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
32   add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
33 endif
34
35 # Symbol visibility
36 if cc.has_argument('-fvisibility=hidden')
37   add_project_arguments('-fvisibility=hidden', language: 'c')
38 endif
39
40 # Disable strict aliasing
41 if cc.has_argument('-fno-strict-aliasing')
42   add_project_arguments('-fno-strict-aliasing', language: 'c')
43 endif
44
45 # Mandatory GST deps
46 libm = cc.find_library('m', required : false)
47 gst_dep = dependency('gstreamer-1.0', version : gst_req,
48   fallback : ['gstreamer', 'gst_dep'])
49 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
50   fallback : ['gstreamer', 'gst_base_dep'])
51 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
52     fallback : ['gst-plugins-base', 'pbutils_dep'])
53 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
54     fallback : ['gst-plugins-base', 'allocators_dep'])
55 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
56     fallback : ['gst-plugins-base', 'video_dep'])
57 gstcodecparsers_dep = dependency('gstreamer-codecparsers-1.0', version : gst_req,
58     fallback : ['gst-plugins-bad', 'gstcodecparsers_dep'])
59 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
60     fallback : ['gst-plugins-base', 'gstgl_dep'], required: false)
61 gstglproto_dep = dependency('', required : false)
62 gstglx11_dep = dependency('', required : false)
63 gstglwayland_dep = dependency('', required : false)
64 gstglegl_dep = dependency('', required : false)
65
66 # Disable compiler warnings for unused variables and args if gst debug system is disabled
67 if gst_dep.type_name() == 'internal'
68   gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
69 else
70   # We can't check that in the case of subprojects as we won't
71   # be able to build against an internal dependency (which is not built yet)
72   gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
73 endif
74
75 if gst_debug_disabled
76   message('GStreamer debug system is disabled')
77   add_project_arguments(cc.get_supported_arguments(['-Wno-unused']), language: 'c')
78 else
79   message('GStreamer debug system is enabled')
80 endif
81
82 # Other deps
83 gmodule_dep = dependency('gmodule-2.0', required: false)
84 libva_dep = dependency('libva', version: libva_req)
85
86 libva_drm_dep = dependency('libva-drm', version: libva_req, required: false)
87 libva_wayland_dep = dependency('libva-wayland', version: libva_req, required: false)
88 libva_x11_dep = dependency('libva-x11', version: libva_req, required: false)
89 libdrm_dep = dependency('libdrm', version: libdrm_req, required: false,
90   fallback: ['libdrm', 'ext_libdrm'])
91 libudev_dep = dependency('libudev', required: false)
92 egl_dep = dependency('egl', required: false)
93 gl_dep = dependency('gl', required: false)
94 glesv2_dep = dependency('glesv2', required: false)
95 gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
96   required : get_option('tests'),
97   fallback : ['gstreamer', 'gst_check_dep'])
98 libdl_dep = cc.find_library('dl', required: false)
99 wayland_client_dep = dependency('wayland-client', version: libwayland_req, required: false)
100 wayland_protocols_dep = dependency('wayland-protocols', version: '>= 1.15', required: false)
101 wayland_scanner_bin = find_program('wayland-scanner', required: false)
102 x11_dep = dependency('x11', required: false)
103 xrandr_dep = dependency('xrandr', required: false)
104
105 # some of the examples can use GTK+-3
106 gtk_dep = dependency('gtk+-3.0', version : '>= 3.10', required : get_option('examples'))
107
108 GLES_VERSION_MASK = gl_dep.found() ? 1 : 0
109 if glesv2_dep.found()
110   if (cc.has_header('GLES2/gl2.h', dependencies: glesv2_dep) and
111       cc.has_header('GLES2/gl2ext.h', dependencies: glesv2_dep))
112     GLES_VERSION_MASK += 4
113   endif
114   if (cc.has_header('GLES3/gl3.h', dependencies: glesv2_dep) and
115       cc.has_header('GLES3/gl3ext.h', dependencies: glesv2_dep) and
116       cc.has_header('GLES2/gl2ext.h', dependencies: glesv2_dep))
117     GLES_VERSION_MASK += 8
118   endif
119 endif
120
121 USE_ENCODERS = get_option('with_encoders') != 'no'
122 USE_VP9_ENCODER = USE_ENCODERS and cc.has_header('va/va_enc_vp9.h', dependencies: libva_dep, prefix: '#include <va/va.h>')
123 USE_AV1_DECODER = cc.has_header('va/va_dec_av1.h', dependencies: libva_dep, prefix: '#include <va/va.h>')
124
125 USE_DRM = libva_drm_dep.found() and libdrm_dep.found() and libudev_dep.found() and get_option('with_drm') != 'no'
126 USE_EGL = gmodule_dep.found() and egl_dep.found() and GLES_VERSION_MASK != 0 and get_option('with_egl') != 'no'
127 USE_WAYLAND = libva_wayland_dep.found() and wayland_client_dep.found() and wayland_protocols_dep.found() and wayland_scanner_bin.found() and get_option('with_wayland') != 'no' and USE_DRM
128 USE_X11 = libva_x11_dep.found() and x11_dep.found() and get_option('with_x11') != 'no'
129 USE_GLX = gl_dep.found() and libdl_dep.found() and get_option('with_glx') != 'no' and USE_X11
130
131 if get_option('with_wayland') == 'yes' and not USE_DRM
132    error('DRM support is required to enable Wayland support')
133 endif
134
135 if not (USE_DRM or USE_X11 or USE_WAYLAND)
136   error('No renderer API found (it is requried either DRM, X11 and/or WAYLAND)')
137 endif
138
139 if gstgl_dep.found()
140   gstglproto_dep = dependency('gstreamer-gl-prototypes-1.0', version : gst_req,
141     fallback : ['gst-plugins-base', 'gstglproto_dep'], required: true)
142   # Behind specific checks because meson fails at optional dependencies with a
143   # fallback to the same subproject.  On the first failure, meson will never
144   # check the system again even if the fallback never existed.
145   # Last checked with meson 0.54.3
146   if USE_X11
147     gstglx11_dep = dependency('gstreamer-gl-x11-1.0', version : gst_req,
148        fallback : ['gst-plugins-base', 'gstglx11_dep'], required: true)
149   endif
150   if USE_WAYLAND
151     gstglwayland_dep = dependency('gstreamer-gl-wayland-1.0', version : gst_req,
152         fallback : ['gst-plugins-base', 'gstglwayland_dep'], required: true)
153   endif
154   if USE_EGL
155     gstglegl_dep = dependency('gstreamer-gl-egl-1.0', version : gst_req,
156         fallback : ['gst-plugins-base', 'gstglegl_dep'], required: true)
157   endif
158 endif
159
160 driverdir = libva_dep.get_variable('driverdir')
161 if driverdir == ''
162   driverdir = join_paths(get_option('prefix'), get_option('libdir'), 'dri')
163 endif
164
165 cdata = configuration_data()
166 cdata.set_quoted('GST_API_VERSION_S', '@0@.@1@'.format(gst_version_major, gst_version_minor))
167 cdata.set_quoted('PACKAGE', 'gstreamer-vaapi')
168 cdata.set_quoted('VERSION', '@0@'.format(gst_version))
169 cdata.set_quoted('PACKAGE_VERSION', '@0@'.format(gst_version))
170 cdata.set_quoted('PACKAGE_NAME', 'GStreamer VA-API Plug-ins')
171 cdata.set_quoted('PACKAGE_STRING', 'GStreamer VA-API Plug-ins @0@'.format(gst_version))
172 cdata.set_quoted('PACKAGE_BUGREPORT', get_option('package-origin'))
173 cdata.set_quoted('VA_DRIVERS_PATH', '@0@'.format(driverdir))
174 cdata.set10('USE_DRM', USE_DRM)
175 cdata.set10('USE_EGL', USE_EGL)
176 cdata.set10('USE_ENCODERS', USE_ENCODERS)
177 cdata.set10('USE_GLX', USE_GLX)
178 cdata.set10('USE_VP9_ENCODER', USE_VP9_ENCODER)
179 cdata.set10('USE_AV1_DECODER', USE_AV1_DECODER)
180 cdata.set10('USE_WAYLAND', USE_WAYLAND)
181 cdata.set10('USE_X11', USE_X11)
182 cdata.set10('HAVE_XKBLIB', cc.has_header('X11/XKBlib.h', dependencies: x11_dep))
183 cdata.set10('HAVE_XRANDR', xrandr_dep.found())
184 cdata.set10('USE_GST_GL_HELPERS', gstgl_dep.found())
185 cdata.set('USE_GLES_VERSION_MASK', GLES_VERSION_MASK)
186
187 api_version = '1.0'
188 soversion = 0
189 # maintaining compatibility with the previous libtool versioning
190 # current = minor * 100 + micro
191 curversion = gst_version_minor * 100 + gst_version_micro
192 libversion = '@0@.@1@.0'.format(soversion, curversion)
193 osxversion = curversion + 1
194
195 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
196
197 gstreamer_vaapi_args = ['-DHAVE_CONFIG_H']
198 configinc = include_directories('.')
199 libsinc = include_directories('gst-libs')
200
201 plugins = []
202
203 subdir('gst-libs')
204 subdir('gst')
205 subdir('tests')
206 subdir('docs')
207
208 # Set release date
209 if gst_version_nano == 0
210   extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
211   run_result = run_command(extract_release_date, gst_version, files('gstreamer-vaapi.doap'), check: true)
212   release_date = run_result.stdout().strip()
213   cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
214   message('Package release date: ' + release_date)
215 endif
216
217 if gmodule_dep.version().version_compare('< 2.67.4')
218   cdata.set('g_memdup2(ptr,sz)', '(G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL)')
219 endif
220
221 configure_file(output: 'config.h', configuration: cdata)