Release 1.22.2
[platform/upstream/gstreamer.git] / subprojects / gstreamer-vaapi / meson.build
1 project('gstreamer-vaapi', 'c',
2   version : '1.22.2',
3   meson_version : '>= 0.62',
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 libwayland_req = '>= 1.11.0'
25 libdrm_req = '>= 2.4.98'
26 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
27
28 cc = meson.get_compiler('c')
29 static_build = get_option('default_library') == 'static'
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 libva_dep = dependency('libva', version: libva_req,
83   fallback : ['libva', 'libva_dep'])
84 libva_drm_dep = dependency('libva-drm', version: libva_req,
85   required: get_option('drm'), fallback : ['libva', 'libva_drm_dep'])
86 libva_wayland_dep = dependency('libva-wayland', version: libva_req,
87   required: get_option('wayland'), fallback : ['libva', 'libva_wayland_dep'])
88 libva_x11_dep = dependency('libva-x11', version: libva_req,
89   required: get_option('x11'), fallback : ['libva', 'libva_x11_dep'])
90
91 libdrm_dep = dependency('libdrm', version: libdrm_req,
92   required: get_option('drm'), fallback: ['libdrm', 'ext_libdrm'])
93 libudev_dep = dependency('libudev', required: get_option('drm'))
94
95 x11_dep = dependency('x11', required: get_option('x11'))
96 xrandr_dep = dependency('xrandr', required: get_option('x11'))
97
98 gmodule_dep = dependency('gmodule-no-export-2.0')
99 egl_dep = dependency('egl', required: get_option('egl'))
100 glesv2_dep = dependency('glesv2', required: false)
101
102 glx_option = get_option('glx').require(libva_x11_dep.found() and x11_dep.found(),
103     error_message: 'glx requires libva-x11 and x11 dependency')
104 gl_dep = dependency('gl', required: glx_option)
105 libdl_dep = cc.find_library('dl', required: glx_option)
106
107 wayland_option = get_option('wayland').require(libdrm_dep.found(),
108     error_message: 'wayland requires libdrm dependency')
109 wayland_client_dep = dependency('wayland-client', version: libwayland_req,
110   required: wayland_option)
111 wayland_protocols_dep = dependency('wayland-protocols', version: '>= 1.15',
112   required: wayland_option)
113 wayland_scanner_bin = find_program('wayland-scanner', required: wayland_option)
114
115 gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
116   required : get_option('tests'),
117   fallback : ['gstreamer', 'gst_check_dep'])
118
119 # some of the examples can use GTK+-3
120 gtk_dep = dependency('gtk+-3.0', version : '>= 3.10', required : get_option('examples'))
121
122 GLES_VERSION_MASK = gl_dep.found() ? 1 : 0
123 if glesv2_dep.found()
124   if (cc.has_header('GLES2/gl2.h', dependencies: glesv2_dep) and
125       cc.has_header('GLES2/gl2ext.h', dependencies: glesv2_dep))
126     GLES_VERSION_MASK += 4
127   endif
128   if (cc.has_header('GLES3/gl3.h', dependencies: glesv2_dep) and
129       cc.has_header('GLES3/gl3ext.h', dependencies: glesv2_dep) and
130       cc.has_header('GLES2/gl2ext.h', dependencies: glesv2_dep))
131     GLES_VERSION_MASK += 8
132   endif
133 endif
134
135 USE_ENCODERS = get_option('encoders').allowed()
136 USE_VP9_ENCODER = USE_ENCODERS and libva_dep.version().version_compare('>= 0.40.0')
137 USE_AV1_DECODER = libva_dep.version().version_compare('>= 1.10')
138
139 USE_DRM = (libva_drm_dep.found()
140     and libdrm_dep.found()
141     and libudev_dep.found())
142 USE_EGL = (egl_dep.found()
143     and GLES_VERSION_MASK != 0)
144 USE_WAYLAND = (libva_wayland_dep.found()
145     and wayland_client_dep.found()
146     and wayland_protocols_dep.found()
147     and wayland_scanner_bin.found()
148     and libdrm_dep.found())
149 USE_X11 = (libva_x11_dep.found() and x11_dep.found())
150 USE_GLX = (USE_X11 and gl_dep.found() and libdl_dep.found())
151
152 if not (USE_DRM or USE_X11 or USE_WAYLAND)
153   error('No renderer API found (it is requried either DRM, X11 and/or WAYLAND)')
154 endif
155
156 if gstgl_dep.found()
157   gstglproto_dep = dependency('gstreamer-gl-prototypes-1.0', version : gst_req,
158     fallback : ['gst-plugins-base', 'gstglproto_dep'], required: true)
159   # Behind specific checks because meson fails at optional dependencies with a
160   # fallback to the same subproject.  On the first failure, meson will never
161   # check the system again even if the fallback never existed.
162   # Last checked with meson 0.54.3
163   if USE_X11
164     gstglx11_dep = dependency('gstreamer-gl-x11-1.0', version : gst_req,
165        fallback : ['gst-plugins-base', 'gstglx11_dep'], required: true)
166   endif
167   if USE_WAYLAND
168     gstglwayland_dep = dependency('gstreamer-gl-wayland-1.0', version : gst_req,
169         fallback : ['gst-plugins-base', 'gstglwayland_dep'], required: true)
170   endif
171   if USE_EGL
172     gstglegl_dep = dependency('gstreamer-gl-egl-1.0', version : gst_req,
173         fallback : ['gst-plugins-base', 'gstglegl_dep'], required: true)
174   endif
175 endif
176
177 driverdir = libva_dep.get_variable('driverdir', default_value: '')
178 if driverdir == ''
179   driverdir = join_paths(get_option('prefix'), get_option('libdir'), 'dri')
180 endif
181
182 cdata = configuration_data()
183 cdata.set_quoted('GST_API_VERSION_S', '@0@.@1@'.format(gst_version_major, gst_version_minor))
184 cdata.set_quoted('PACKAGE', 'gstreamer-vaapi')
185 cdata.set_quoted('VERSION', '@0@'.format(gst_version))
186 cdata.set_quoted('PACKAGE_VERSION', '@0@'.format(gst_version))
187 cdata.set_quoted('PACKAGE_NAME', 'GStreamer VA-API Plug-ins')
188 cdata.set_quoted('PACKAGE_STRING', 'GStreamer VA-API Plug-ins @0@'.format(gst_version))
189 cdata.set_quoted('PACKAGE_BUGREPORT', get_option('package-origin'))
190 cdata.set_quoted('VA_DRIVERS_PATH', '@0@'.format(driverdir))
191 cdata.set10('GST_VAAPI_USE_DRM', USE_DRM)
192 cdata.set10('GST_VAAPI_USE_EGL', USE_EGL)
193 cdata.set10('GST_VAAPI_USE_ENCODERS', USE_ENCODERS)
194 cdata.set10('GST_VAAPI_USE_GLX', USE_GLX)
195 cdata.set10('GST_VAAPI_USE_VP9_ENCODER', USE_VP9_ENCODER)
196 cdata.set10('GST_VAAPI_USE_AV1_DECODER', USE_AV1_DECODER)
197 cdata.set10('GST_VAAPI_USE_WAYLAND', USE_WAYLAND)
198 cdata.set10('GST_VAAPI_USE_X11', USE_X11)
199 cdata.set10('HAVE_XKBLIB', cc.has_header('X11/XKBlib.h', dependencies: x11_dep))
200 cdata.set10('HAVE_XRANDR', xrandr_dep.found())
201 cdata.set10('USE_GST_GL_HELPERS', gstgl_dep.found())
202 cdata.set('USE_GLES_VERSION_MASK', GLES_VERSION_MASK)
203
204 api_version = '1.0'
205 soversion = 0
206 # maintaining compatibility with the previous libtool versioning
207 # current = minor * 100 + micro
208 curversion = gst_version_minor * 100 + gst_version_micro
209 libversion = '@0@.@1@.0'.format(soversion, curversion)
210 osxversion = curversion + 1
211
212 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
213
214 gstreamer_vaapi_args = ['-DHAVE_CONFIG_H']
215 configinc = include_directories('.')
216 libsinc = include_directories('gst-libs')
217
218 plugins = []
219
220 subdir('gst-libs')
221 subdir('gst')
222 subdir('tests')
223 subdir('docs')
224
225 # Set release date
226 if gst_version_nano == 0
227   extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
228   run_result = run_command(extract_release_date, gst_version, files('gstreamer-vaapi.doap'), check: true)
229   release_date = run_result.stdout().strip()
230   cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
231   message('Package release date: ' + release_date)
232 endif
233
234 if gmodule_dep.version().version_compare('< 2.67.4')
235   cdata.set('g_memdup2(ptr,sz)', '(G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL)')
236 endif
237
238 configure_file(output: 'config.h', configuration: cdata)
239
240 meson.add_dist_script('scripts/gen-changelog.py', meson.project_name(), '1.20.0', meson.project_version())
241
242 pkgconfig = import('pkgconfig')
243 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
244 if get_option('default_library') == 'shared'
245   # If we don't build static plugins there is no need to generate pc files
246   plugins_pkgconfig_install_dir = disabler()
247 endif
248
249 plugin_names = []
250 gst_plugins = []
251 foreach plugin: plugins
252   pkgconfig.generate(plugin, install_dir: plugins_pkgconfig_install_dir)
253   dep = declare_dependency(link_with: plugin, variables: {'full_path': plugin.full_path()})
254   meson.override_dependency(plugin.name(), dep)
255   gst_plugins += [dep]
256   if plugin.name().startswith('gst')
257     plugin_names += [plugin.name().substring(3)]
258   else
259     plugin_names += [plugin.name()]
260   endif
261 endforeach
262
263 summary({
264     'Plugins': plugin_names,
265 }, list_sep: ', ')