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