1 project('gstreamer-vaapi', 'c',
3 meson_version : '>= 0.60',
4 default_options : [ 'warning_level=1',
5 'buildtype=debugoptimized' ])
7 if get_option('default_library') == 'static'
8 error('GStreamer-VAAPI plugin not supported with `static` builds yet.')
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()
17 if version_arr.length() == 4
18 gst_version_nano = version_arr[3].to_int()
23 libva_req = ['>= 0.39.0', '!= 0.99.0']
24 libwayland_req = '>= 1.11.0'
25 libdrm_req = '>= 2.4.98'
26 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
28 cc = meson.get_compiler('c')
30 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
31 add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
35 if cc.has_argument('-fvisibility=hidden')
36 add_project_arguments('-fvisibility=hidden', language: 'c')
39 # Disable strict aliasing
40 if cc.has_argument('-fno-strict-aliasing')
41 add_project_arguments('-fno-strict-aliasing', language: 'c')
45 libm = cc.find_library('m', required : false)
46 gst_dep = dependency('gstreamer-1.0', version : gst_req,
47 fallback : ['gstreamer', 'gst_dep'])
48 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
49 fallback : ['gstreamer', 'gst_base_dep'])
50 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
51 fallback : ['gst-plugins-base', 'pbutils_dep'])
52 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
53 fallback : ['gst-plugins-base', 'allocators_dep'])
54 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
55 fallback : ['gst-plugins-base', 'video_dep'])
56 gstcodecparsers_dep = dependency('gstreamer-codecparsers-1.0', version : gst_req,
57 fallback : ['gst-plugins-bad', 'gstcodecparsers_dep'])
58 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
59 fallback : ['gst-plugins-base', 'gstgl_dep'], required: false)
60 gstglproto_dep = dependency('', required : false)
61 gstglx11_dep = dependency('', required : false)
62 gstglwayland_dep = dependency('', required : false)
63 gstglegl_dep = dependency('', required : false)
65 # Disable compiler warnings for unused variables and args if gst debug system is disabled
66 if gst_dep.type_name() == 'internal'
67 gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
69 # We can't check that in the case of subprojects as we won't
70 # be able to build against an internal dependency (which is not built yet)
71 gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
75 message('GStreamer debug system is disabled')
76 add_project_arguments(cc.get_supported_arguments(['-Wno-unused']), language: 'c')
78 message('GStreamer debug system is enabled')
81 libva_dep = dependency('libva', version: libva_req,
82 fallback : ['libva', 'libva_dep'])
83 libva_drm_dep = dependency('libva-drm', version: libva_req,
84 required: get_option('drm'), fallback : ['libva', 'libva_drm_dep'])
85 libva_wayland_dep = dependency('libva-wayland', version: libva_req,
86 required: get_option('wayland'), fallback : ['libva', 'libva_wayland_dep'])
87 libva_x11_dep = dependency('libva-x11', version: libva_req,
88 required: get_option('x11'), fallback : ['libva', 'libva_x11_dep'])
90 libdrm_dep = dependency('libdrm', version: libdrm_req,
91 required: get_option('drm'), fallback: ['libdrm', 'ext_libdrm'])
92 libudev_dep = dependency('libudev', required: get_option('drm'))
94 x11_dep = dependency('x11', required: get_option('x11'))
95 xrandr_dep = dependency('xrandr', required: get_option('x11'))
97 gmodule_dep = dependency('gmodule-2.0')
98 egl_dep = dependency('egl', required: get_option('egl'))
99 glesv2_dep = dependency('glesv2', required: false)
101 glx_option = get_option('glx').require(libva_x11_dep.found() and x11_dep.found(),
102 error_message: 'glx requires libva-x11 and x11 dependency')
103 gl_dep = dependency('gl', required: glx_option)
104 libdl_dep = cc.find_library('dl', required: glx_option)
106 wayland_option = get_option('wayland').require(libdrm_dep.found(),
107 error_message: 'wayland requires libdrm dependency')
108 wayland_client_dep = dependency('wayland-client', version: libwayland_req,
109 required: wayland_option)
110 wayland_protocols_dep = dependency('wayland-protocols', version: '>= 1.15',
111 required: wayland_option)
112 wayland_scanner_bin = find_program('wayland-scanner', required: wayland_option)
114 gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
115 required : get_option('tests'),
116 fallback : ['gstreamer', 'gst_check_dep'])
118 # some of the examples can use GTK+-3
119 gtk_dep = dependency('gtk+-3.0', version : '>= 3.10', required : get_option('examples'))
121 GLES_VERSION_MASK = gl_dep.found() ? 1 : 0
122 if glesv2_dep.found()
123 if (cc.has_header('GLES2/gl2.h', dependencies: glesv2_dep) and
124 cc.has_header('GLES2/gl2ext.h', dependencies: glesv2_dep))
125 GLES_VERSION_MASK += 4
127 if (cc.has_header('GLES3/gl3.h', dependencies: glesv2_dep) and
128 cc.has_header('GLES3/gl3ext.h', dependencies: glesv2_dep) and
129 cc.has_header('GLES2/gl2ext.h', dependencies: glesv2_dep))
130 GLES_VERSION_MASK += 8
134 USE_ENCODERS = get_option('encoders').allowed()
135 USE_VP9_ENCODER = USE_ENCODERS and libva_dep.version().version_compare('>= 0.40.0')
136 USE_AV1_DECODER = libva_dep.version().version_compare('>= 1.10')
138 USE_DRM = (libva_drm_dep.found()
139 and libdrm_dep.found()
140 and libudev_dep.found())
141 USE_EGL = (egl_dep.found()
142 and GLES_VERSION_MASK != 0)
143 USE_WAYLAND = (libva_wayland_dep.found()
144 and wayland_client_dep.found()
145 and wayland_protocols_dep.found()
146 and wayland_scanner_bin.found()
147 and libdrm_dep.found())
148 USE_X11 = (libva_x11_dep.found() and x11_dep.found())
149 USE_GLX = (USE_X11 and gl_dep.found() and libdl_dep.found())
151 if not (USE_DRM or USE_X11 or USE_WAYLAND)
152 error('No renderer API found (it is requried either DRM, X11 and/or WAYLAND)')
156 gstglproto_dep = dependency('gstreamer-gl-prototypes-1.0', version : gst_req,
157 fallback : ['gst-plugins-base', 'gstglproto_dep'], required: true)
158 # Behind specific checks because meson fails at optional dependencies with a
159 # fallback to the same subproject. On the first failure, meson will never
160 # check the system again even if the fallback never existed.
161 # Last checked with meson 0.54.3
163 gstglx11_dep = dependency('gstreamer-gl-x11-1.0', version : gst_req,
164 fallback : ['gst-plugins-base', 'gstglx11_dep'], required: true)
167 gstglwayland_dep = dependency('gstreamer-gl-wayland-1.0', version : gst_req,
168 fallback : ['gst-plugins-base', 'gstglwayland_dep'], required: true)
171 gstglegl_dep = dependency('gstreamer-gl-egl-1.0', version : gst_req,
172 fallback : ['gst-plugins-base', 'gstglegl_dep'], required: true)
176 driverdir = libva_dep.get_variable('driverdir', default_value: '')
178 driverdir = join_paths(get_option('prefix'), get_option('libdir'), 'dri')
181 cdata = configuration_data()
182 cdata.set_quoted('GST_API_VERSION_S', '@0@.@1@'.format(gst_version_major, gst_version_minor))
183 cdata.set_quoted('PACKAGE', 'gstreamer-vaapi')
184 cdata.set_quoted('VERSION', '@0@'.format(gst_version))
185 cdata.set_quoted('PACKAGE_VERSION', '@0@'.format(gst_version))
186 cdata.set_quoted('PACKAGE_NAME', 'GStreamer VA-API Plug-ins')
187 cdata.set_quoted('PACKAGE_STRING', 'GStreamer VA-API Plug-ins @0@'.format(gst_version))
188 cdata.set_quoted('PACKAGE_BUGREPORT', get_option('package-origin'))
189 cdata.set_quoted('VA_DRIVERS_PATH', '@0@'.format(driverdir))
190 cdata.set10('USE_DRM', USE_DRM)
191 cdata.set10('USE_EGL', USE_EGL)
192 cdata.set10('USE_ENCODERS', USE_ENCODERS)
193 cdata.set10('USE_GLX', USE_GLX)
194 cdata.set10('USE_VP9_ENCODER', USE_VP9_ENCODER)
195 cdata.set10('USE_AV1_DECODER', USE_AV1_DECODER)
196 cdata.set10('USE_WAYLAND', USE_WAYLAND)
197 cdata.set10('USE_X11', USE_X11)
198 cdata.set10('HAVE_XKBLIB', cc.has_header('X11/XKBlib.h', dependencies: x11_dep))
199 cdata.set10('HAVE_XRANDR', xrandr_dep.found())
200 cdata.set10('USE_GST_GL_HELPERS', gstgl_dep.found())
201 cdata.set('USE_GLES_VERSION_MASK', GLES_VERSION_MASK)
205 # maintaining compatibility with the previous libtool versioning
206 # current = minor * 100 + micro
207 curversion = gst_version_minor * 100 + gst_version_micro
208 libversion = '@0@.@1@.0'.format(soversion, curversion)
209 osxversion = curversion + 1
211 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
213 gstreamer_vaapi_args = ['-DHAVE_CONFIG_H']
214 configinc = include_directories('.')
215 libsinc = include_directories('gst-libs')
225 if gst_version_nano == 0
226 extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
227 run_result = run_command(extract_release_date, gst_version, files('gstreamer-vaapi.doap'), check: true)
228 release_date = run_result.stdout().strip()
229 cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
230 message('Package release date: ' + release_date)
233 if gmodule_dep.version().version_compare('< 2.67.4')
234 cdata.set('g_memdup2(ptr,sz)', '(G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL)')
237 configure_file(output: 'config.h', configuration: cdata)