rtsp-server: fix memory leak
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-base / gst-libs / gst / gl / meson.build
1 gstgl_dep = dependency('', required : false)
2 gstglproto_dep = dependency('', required : false)
3 gstglx11_dep = dependency('', required : false)
4 gstglwayland_dep = dependency('', required : false)
5 gstglegl_dep = dependency('', required : false)
6 gstglviv_fb_dep = dependency('', required : false)
7
8 if get_option('gl').disabled()
9   message('GStreamer OpenGL integration disabled via options.')
10   build_gstgl = false
11   subdir_done()
12 endif
13
14 gl_sources = files([
15   'gstglapi.c',
16   'gstglbasefilter.c',
17   'gstglbasememory.c',
18   'gstglbasesrc.c',
19   'gstglcolorconvert.c',
20   'gstglbuffer.c',
21   'gstglbufferpool.c',
22   'gstglcontext.c',
23   'gstglcontextconfig.c',
24   'gstglcontextquirks.c',
25   'gstgldebug.c',
26   'gstgldisplay.c',
27   'gstglfeature.c',
28   'gstglfilter.c',
29   'gstglformat.c',
30   'gstglframebuffer.c',
31   'gstglmemory.c',
32   'gstglmemorypbo.c',
33   'gstgloverlaycompositor.c',
34   'gstglquery.c',
35   'gstglrenderbuffer.c',
36   'gstglshader.c',
37   'gstglshaderstrings.c',
38   'gstglsl.c',
39   'gstglslstage.c',
40   'gstglsyncmeta.c',
41   'gstglupload.c',
42   'gstglutils.c',
43   'gstglviewconvert.c',
44   'gstglwindow.c',
45 ])
46
47 gl_priv_sources = []
48
49 gir_gl_headers = files([
50   'gl.h',
51   'gl-prelude.h',
52   'gstgl_enums.h',
53   'gstgl_fwd.h',
54   'gstglapi.h',
55   'gstglbasefilter.h',
56   'gstglbasememory.h',
57   'gstglbasesrc.h',
58   'gstglbuffer.h',
59   'gstglbufferpool.h',
60   'gstglcolorconvert.h',
61   'gstglcontext.h',
62   'gstglcontextconfig.h',
63   'gstgldebug.h',
64   'gstgldisplay.h',
65   'gstglfeature.h',
66   'gstglfilter.h',
67   'gstglformat.h',
68   'gstglframebuffer.h',
69   'gstglmemory.h',
70   'gstglmemorypbo.h',
71   'gstgloverlaycompositor.h',
72   'gstglquery.h',
73   'gstglrenderbuffer.h',
74   'gstglshader.h',
75   'gstglshaderstrings.h',
76   'gstglsl.h',
77   'gstglslstage.h',
78   'gstglsyncmeta.h',
79   'gstglupload.h',
80   'gstglutils.h',
81   'gstglviewconvert.h',
82   'gstglwindow.h',
83 ])
84
85 gl_headers = gir_gl_headers + files([
86   'gstglfuncs.h',
87 ])
88
89 gl_prototype_headers = files([
90   'glprototypes/all_functions.h',
91   'glprototypes/base.h',
92   'glprototypes/buffer_storage.h',
93   'glprototypes/blending.h',
94   'glprototypes/buffers.h',
95   'glprototypes/debug.h',
96   'glprototypes/eglimage.h',
97   'glprototypes/fbo.h',
98   'glprototypes/fixedfunction.h',
99   'glprototypes/gles.h',
100   'glprototypes/gstgl_compat.h',
101   'glprototypes/gstgl_gles2compat.h',
102   'glprototypes/opengl.h',
103   'glprototypes/query.h',
104   'glprototypes/shaders.h',
105   'glprototypes/sync.h',
106   'glprototypes/vao.h',
107 ])
108
109 gl_x11_sources = []
110 gl_x11_headers = []
111 gl_wayland_sources = []
112 gl_wayland_headers = []
113 gl_egl_sources = []
114 gl_egl_headers = []
115 gl_viv_fb_sources = []
116 gl_viv_fb_headers = []
117
118 glconf = configuration_data()
119 glconf_options = [
120     'GST_GL_HAVE_OPENGL',
121     'GST_GL_HAVE_GLES2',
122     'GST_GL_HAVE_GLES3',
123     'GST_GL_HAVE_GLES3EXT3_H',
124
125     'GST_GL_HAVE_WINDOW_X11',
126     'GST_GL_HAVE_WINDOW_COCOA',
127     'GST_GL_HAVE_WINDOW_WIN32',
128     'GST_GL_HAVE_WINDOW_WINRT',
129     'GST_GL_HAVE_WINDOW_WAYLAND',
130     'GST_GL_HAVE_WINDOW_ANDROID',
131     'GST_GL_HAVE_WINDOW_DISPMANX',
132     'GST_GL_HAVE_WINDOW_EAGL',
133     'GST_GL_HAVE_WINDOW_VIV_FB',
134     'GST_GL_HAVE_WINDOW_GBM',
135
136     'GST_GL_HAVE_PLATFORM_EGL',
137     'GST_GL_HAVE_PLATFORM_GLX',
138     'GST_GL_HAVE_PLATFORM_WGL',
139     'GST_GL_HAVE_PLATFORM_CGL',
140     'GST_GL_HAVE_PLATFORM_EAGL',
141
142     'GST_GL_HAVE_DMABUF',
143     'GST_GL_HAVE_VIV_DIRECTVIV',
144
145     'GST_GL_HAVE_GLEGLIMAGEOES',
146     'GST_GL_HAVE_GLCHAR',
147     'GST_GL_HAVE_GLSIZEIPTR',
148     'GST_GL_HAVE_GLINTPTR',
149     'GST_GL_HAVE_GLSYNC',
150     'GST_GL_HAVE_GLUINT64',
151     'GST_GL_HAVE_GLINT64',
152     'GST_GL_HAVE_EGLATTRIB',
153     'GST_GL_HAVE_EGLUINT64KHR',
154 ]
155
156 foreach option : glconf_options
157   glconf.set(option, 0)
158 endforeach
159
160 unneeded_dep = dependency('', required : false)
161 if unneeded_dep.found()
162   error ('Found unfindable dependency')
163 endif
164
165 # OpenGL/GLES2 libraries
166 gl_lib_deps = []
167 # GL platform - EGL, GLX, CGL, WGL, etc
168 gl_platform_deps = []
169 # GL winsys - wayland, X11, Cocoa, win32, etc
170 gl_winsys_deps = []
171 # other things we need.
172 gl_misc_deps = []
173 # Other preprocessor arguments
174 gl_cpp_args = []
175 gl_includes = []
176 gl_objc_args = []
177
178 enabled_gl_apis = []
179 enabled_gl_platforms = []
180 enabled_gl_winsys = []
181
182 # parse provided options
183 libegl_module_name = get_option('egl_module_name')
184 if libegl_module_name != ''
185   gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)]
186 endif
187 libgles2_module_name = get_option('gles2_module_name')
188 if libgles2_module_name != ''
189   gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)]
190 endif
191 libgl_module_name = get_option('opengl_module_name')
192 if libgl_module_name != ''
193   gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)]
194 endif
195
196 gl_apis = get_option('gl_api')
197 if gl_apis.contains('auto')
198   need_api_opengl = 'auto'
199   need_api_gles2 = 'auto'
200 else
201   need_api_opengl = 'no'
202   need_api_gles2 = 'no'
203   foreach api : gl_apis
204     if api == 'opengl'
205       need_api_opengl = 'yes'
206     elif api == 'gles2'
207       need_api_gles2 = 'yes'
208     else
209       error('Unsupported GL api provided ' + api)
210     endif
211   endforeach
212 endif
213
214 gl_platforms = get_option('gl_platform')
215 if gl_platforms.contains('auto')
216   need_platform_egl = 'auto'
217   need_platform_glx = 'auto'
218   need_platform_cgl = 'auto'
219   need_platform_wgl = 'auto'
220   need_platform_eagl = 'auto'
221 else
222   need_platform_egl = 'no'
223   need_platform_glx = 'no'
224   need_platform_cgl = 'no'
225   need_platform_wgl = 'no'
226   need_platform_eagl = 'no'
227   foreach platform : gl_platforms
228     if platform == 'egl'
229       need_platform_egl = 'yes'
230     elif platform == 'glx'
231       need_platform_glx = 'yes'
232     elif platform == 'cgl'
233       need_platform_cgl = 'yes'
234     elif platform == 'wgl'
235       need_platform_wgl = 'yes'
236     elif platform == 'eagl'
237       need_platform_eagl = 'yes'
238     else
239       error('Unsupported GL platform provided ' + platform)
240     endif
241   endforeach
242 endif
243
244 gl_winsys = get_option('gl_winsys')
245 if gl_winsys.contains('auto')
246   need_win_x11 = 'auto'
247   need_win_wayland = 'auto'
248   need_win_win32 = 'auto'
249   need_win_winrt = 'auto'
250   need_win_cocoa = 'auto'
251   need_win_egl = 'auto'
252   need_win_eagl = 'auto'
253   need_win_dispmanx = 'auto'
254   need_win_viv_fb = 'auto'
255   need_win_gbm = 'auto'
256   need_win_android = 'auto'
257 else
258   need_win_x11 = 'no'
259   need_win_wayland = 'no'
260   need_win_win32 = 'no'
261   need_win_winrt = 'no'
262   need_win_cocoa = 'no'
263   need_win_egl = 'no'
264   need_win_eagl = 'no'
265   need_win_dispmanx = 'no'
266   need_win_viv_fb = 'no'
267   need_win_gbm = 'no'
268   need_win_android = 'no'
269   foreach winsys : gl_winsys
270     if winsys == 'x11'
271       need_win_x11 = 'yes'
272     elif winsys == 'wayland'
273       need_win_wayland = 'yes'
274     elif winsys == 'win32'
275       need_win_win32 = 'yes'
276     elif winsys == 'winrt'
277       need_win_winrt = 'yes'
278     elif winsys == 'cocoa'
279       need_win_cocoa = 'yes'
280     elif winsys == 'egl'
281       need_win_egl = 'yes'
282     elif winsys == 'eagl'
283       need_win_eagl = 'yes'
284     elif winsys == 'dispmanx'
285       need_win_dispmanx = 'yes'
286     elif winsys == 'viv-fb'
287       need_win_viv_fb = 'yes'
288     elif winsys == 'gbm'
289       need_win_gbm = 'yes'
290     elif winsys == 'android'
291       need_win_android = 'yes'
292     else
293       error('Unsupported GL winsys provided ' + winsys)
294     endif
295   endforeach
296 endif
297
298 gl_include_header = '''
299 #ifdef __GNUC__
300 #  pragma GCC diagnostic push
301 #  pragma GCC diagnostic ignored "-Wredundant-decls"
302 #endif
303 #ifndef GL_GLEXT_PROTOTYPES
304 #define GL_GLEXT_PROTOTYPES 1
305 #endif
306 '''
307
308 # convoluted way of getting at the subproject taking into account the wrap-mode
309 # so we don't download a subproject unless allowed
310 gl_header_dep = dependency('', fallback : ['gl-headers', 'gl_headers_dummy_dep'],
311     required : false)
312 if gl_header_dep.type_name() == 'internal'
313   # this will only contain the includes of headers that are not found
314   compat_includes = subproject('gl-headers').get_variable('compatibility_includes')
315 else
316   compat_includes = []
317 endif
318
319 # Desktop OpenGL checks
320 gl_dep = unneeded_dep
321 glx_dep = unneeded_dep
322
323 # (GLVND) OpenGL (without GLX) headers and interface
324 if need_api_opengl != 'no'
325   gl_dep = dependency('opengl', method: 'pkg-config', required : false)
326 endif
327
328 # non-GLVND aka Legacy OpenGL
329 if need_api_opengl != 'no' and not gl_dep.found()
330   if host_system == 'darwin'
331     gl_dep = dependency('appleframeworks', modules : ['OpenGL'], required : false)
332   else
333     # override meson's braindead gl detection on osx/windows/etc by forcing pkg-config
334     gl_dep = dependency('gl', method: 'pkg-config', required : false)
335   endif
336
337   if not gl_dep.found()
338     if host_system == 'windows'
339       gl_dep = cc.find_library('opengl32', required : false)
340     else
341       gl_dep = cc.find_library('GL', required : false)
342     endif
343
344     if not cc.has_header('GL/gl.h', include_directories : compat_includes)
345       gl_dep = unneeded_dep
346     endif
347
348     if not gl_dep.found() and need_api_opengl == 'yes'
349       error ('Could not find requested OpenGL library')
350     endif
351
352     if gl_dep.found()
353       gl_includes += [compat_includes]
354     endif
355   endif
356 endif
357
358 if need_platform_glx != 'no'
359   # (GLVND) GLX library and headers.
360   glx_dep = dependency('glx', method: 'pkg-config', required : false)
361
362   if not glx_dep.found()
363     if host_system == 'darwin'
364       glx_dep = cc.find_library('GL', required : false)
365     elif gl_dep.found()
366       glx_dep = gl_dep
367     elif need_platform_glx == 'yes'
368       error ('Could not find requested GLX library')
369     endif
370   endif
371 endif
372
373 if need_api_opengl != 'no'
374   opengl_includes = ''
375   if host_system == 'darwin'
376     opengl_includes += '''
377 #if !defined(MAC_OS_X_VERSION_MAX_ALLOWED) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1014
378 # define GL_SILENCE_DEPRECATION
379 #endif
380 #include <OpenGL/OpenGL.h>
381 #include <OpenGL/gl.h>
382 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
383 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
384 # include <OpenGL/gl3.h>
385 #endif
386 '''
387   else
388     opengl_includes += '''
389 #if _MSC_VER
390 # include <windows.h>
391 #endif
392 #include <GL/gl.h>
393 #if __WIN32__ || _WIN32
394 # include <GL/glext.h>
395 #endif
396 '''
397   endif
398 endif
399
400 bcm_host_dep = unneeded_dep
401 if need_win_dispmanx != 'no'
402
403   # Try pkg-config for bcm_host then fallback to find_library to also
404   # support older distribution
405   bcm_host_dep = dependency('bcm_host', required : false)
406   if not bcm_host_dep.found()
407     bcm_host_dep = cc.find_library('bcm_host', required : false)
408   endif
409 endif
410
411 # GLES2 checks
412 gles2_dep = unneeded_dep
413 gles3_h = false
414 gles3ext3_h = false
415 if need_api_gles2 != 'no'
416   if host_system == 'ios'
417     gles2_dep = dependency('appleframeworks', modules : ['OpenGLES'], required : false)
418   else
419     if bcm_host_dep.found()
420       gles2_dep = dependency('brcmglesv2', required : false)
421     endif
422     if not gles2_dep.found()
423       gles2_dep = dependency('glesv2', required : false)
424     endif
425   endif
426
427   if not gles2_dep.found()
428 #    if host_system == 'windows'
429 #    elif host_system == ios
430 #      gles2_dep = cc.find_library('GLESv2', required : false)
431 #    else
432       gles2_dep = cc.find_library('GLESv2', required : false)
433 #    endif
434
435     if not cc.has_header('GLES2/gl2.h', include_directories : compat_includes)
436       gles2_dep = unneeded_dep
437     endif
438
439     if not gles2_dep.found() and need_api_gles2 == 'yes'
440       error ('Could not find requested OpenGL ES library')
441     endif
442
443     if gles2_dep.found()
444       gl_includes += [compat_includes]
445     endif
446   endif
447
448   gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', dependencies : gles2_dep, include_directories : compat_includes)
449
450   gles_includes = ''
451   if host_system == 'ios'
452     gles_includes += '''
453 # include <OpenGLES/ES2/gl.h>
454 # include <OpenGLES/ES2/glext.h>
455 '''
456   else
457     if gles3_h
458       gl_includes += [compat_includes]
459       gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', dependencies : gles2_dep, include_directories : compat_includes)
460       gles_includes += '''
461 # include <GLES3/gl3.h>
462 # include <GLES2/gl2ext.h>'''
463       if gles3ext3_h
464         gles_includes += '''
465 # include <GLES3/gl3ext.h>'''
466       endif
467     else
468       gles_includes += '''
469 # include <GLES2/gl2.h>
470 # include <GLES2/gl2ext.h>'''
471     endif
472   endif
473 endif
474
475 # can we include both gles2 and opengl headers?
476 if gles2_dep.found() and gl_dep.found()
477   gl_include_block = gl_include_header + gles_includes + opengl_includes
478   # TODO: Revert to passing gl_include_block via prefix: once
479   # https://github.com/mesonbuild/meson/issues/2364 is fixed
480   if not cc.compiles(gl_include_block + '\n' + 'void f (void) {}',dependencies : [gles2_dep, gl_dep], include_directories : compat_includes)
481     message ('Cannot include both OpenGL and OpenGL ES headers')
482     if need_api_gles2 != 'yes'
483       gles2_dep = unneeded_dep
484     elif need_api_opengl != 'yes'
485       gl_dep = unneeded_dep
486     else
487       error('Both OpenGL and OpenGL ES were requested but cannot be included together')
488     endif
489   endif
490 endif
491 gl_include_block = gl_include_header
492 if gles2_dep.found()
493   gl_include_block += gles_includes
494 endif
495 if gl_dep.found()
496   gl_include_block += opengl_includes
497 endif
498
499 if gles2_dep.found()
500   gl_lib_deps += gles2_dep
501   glconf.set('GST_GL_HAVE_GLES2', 1)
502   if gles3_h
503     glconf.set('GST_GL_HAVE_GLES3',1)
504     if gles3ext3_h
505       glconf.set('GST_GL_HAVE_GLES3EXT3_H', 1)
506     endif
507   endif
508   enabled_gl_apis += 'gles2'
509 endif
510
511 if gl_dep.found()
512   gl_lib_deps += gl_dep
513   glconf.set('GST_GL_HAVE_OPENGL', 1)
514   enabled_gl_apis += 'gl'
515 endif
516
517 # EGL checks
518 egl_dep = unneeded_dep
519 if need_platform_egl != 'no'
520   if bcm_host_dep.found()
521     egl_dep = dependency('brcmegl', required : false)
522   endif
523   if not egl_dep.found()
524     egl_dep = dependency('egl', required : false)
525   endif
526   if not egl_dep.found()
527     egl_dep = cc.find_library('EGL', required : false)
528   endif
529
530   if egl_dep.found() and not cc.has_header('EGL/egl.h',
531                                            dependencies : egl_dep,
532                                            include_directories : compat_includes)
533     egl_dep = unneeded_dep
534   endif
535   if egl_dep.found() and not cc.has_header('EGL/eglext.h',
536                                            dependencies : egl_dep,
537                                            include_directories : compat_includes)
538     egl_dep = unneeded_dep
539   endif
540
541   if egl_dep.found()
542     gl_egl_sources += files([
543       'egl/gstegl.c',
544       'egl/gsteglimage.c',
545       'egl/gstglcontext_egl.c',
546       'egl/gstgldisplay_egl.c',
547       'egl/gstglmemoryegl.c',
548       'egl/gstgldisplay_egl_device.c',
549     ])
550     gl_egl_headers += files([
551       'egl/egl.h',
552       'egl/gstegl.h',
553       'egl/gsteglimage.h',
554       'egl/gstgldisplay_egl.h',
555       'egl/gstglmemoryegl.h',
556       'egl/gstgldisplay_egl_device.h',
557     ])
558     gl_platform_deps += egl_dep
559     glconf.set('GST_GL_HAVE_PLATFORM_EGL', 1)
560
561     if cc.has_header('libdrm/drm_fourcc.h')
562       gl_misc_deps += allocators_dep
563       glconf.set('GST_GL_HAVE_DMABUF', 1)
564     endif
565
566     egl_includes = '''
567 #include <EGL/egl.h>
568 #include <EGL/eglext.h>
569 '''
570     enabled_gl_platforms += 'egl'
571   elif need_platform_egl == 'yes'
572     error ('Could not find requested EGL library')
573   endif
574 endif
575
576 # winsys_egl checks
577 if need_win_egl == 'yes'
578   if need_platform_egl == 'no'
579     error('Impossible situation requested: Cannot use Winsys egl without EGL support')
580   elif not egl_dep.found()
581     error ('Could not find EGL libraries for Winsys egl')
582   else
583     enabled_gl_winsys += 'egl'
584   endif
585 endif
586
587 # wayland checks
588 wayland_client_dep = unneeded_dep
589 wayland_cursor_dep = unneeded_dep
590 wayland_egl_dep = unneeded_dep
591 if need_win_wayland != 'no'
592   if need_win_wayland == 'yes'
593     if need_platform_egl == 'no'
594       error('Impossible situation requested: Cannot use Wayland without EGL support')
595     endif
596   endif
597   if not egl_dep.found()
598     if need_win_wayland == 'yes'
599       error ('Could not find EGL libraries for wayland')
600     else
601       message ('Could not find EGL libraries for wayland')
602     endif
603   else
604     wayland_client_dep = dependency('wayland-client', version : '>= 1.11', required : false)
605     wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
606     wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
607     wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.15', required : false)
608     wayland_scanner = find_program('wayland-scanner', required: false)
609
610     if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found() and wayland_protocols_dep.found() and wayland_scanner.found()
611       # Generate the XDG shell interface
612       wayland_protocols_basedir = wayland_protocols_dep.get_variable('pkgdatadir')
613       xdg_shell_xml_spec = join_paths(wayland_protocols_basedir, 'stable', 'xdg-shell', 'xdg-shell.xml')
614       xdg_shell_header = custom_target('xdg-shell-client-header',
615         command: [ wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@' ],
616         input: xdg_shell_xml_spec,
617         output: 'xdg-shell-client-protocol.h',
618       )
619       xdg_shell_code = custom_target('xdg-shell-client-code',
620         command: [ wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@' ],
621         input: xdg_shell_xml_spec,
622         output: 'xdg-shell-client-protocol.c',
623       )
624
625       gl_wayland_sources += files([
626         'wayland/gstgldisplay_wayland.c',
627       ])
628       gl_priv_sources += [
629         'wayland/gstglwindow_wayland_egl.c',
630         'wayland/wayland_event_source.c',
631         xdg_shell_header,
632         xdg_shell_code,
633       ]
634       gl_wayland_headers += files([
635         'wayland/wayland.h',
636         'wayland/gstgldisplay_wayland.h'
637       ])
638       glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
639       gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
640       enabled_gl_winsys += 'wayland'
641     else
642       if need_win_wayland == 'yes'
643         error ('Could not find requested Wayland libraries')
644       endif
645       wayland_client_dep = unneeded_dep
646       wayland_cursor_dep = unneeded_dep
647       wayland_egl_dep = unneeded_dep
648       wayland_protocols_dep = unneeded_dep
649     endif
650   endif
651 endif
652
653 # X11 checks
654 if need_platform_glx == 'yes'
655   if need_win_x11 == 'no'
656     error('Impossible situation requested: Cannot use GLX without X11 support')
657   elif need_api_opengl == 'no'
658     error('Impossible situation requested: Cannot use GLX without the OpenGL library')
659   endif
660 endif
661
662 xcb_dep = unneeded_dep
663 if need_win_x11 != 'no'
664   xcb_dep = dependency('x11-xcb', required : false)
665   if x11_dep.found() and xcb_dep.found()
666     gl_x11_sources += files([
667       'x11/gstgldisplay_x11.c',
668     ])
669     gl_priv_sources += [
670       'x11/gstglwindow_x11.c',
671       'x11/xcb_event_source.c',
672     ]
673     gl_x11_headers += files([
674       'x11/x11.h',
675       'x11/gstgldisplay_x11.h',
676     ])
677     glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
678     gl_winsys_deps += [x11_dep, xcb_dep]
679     enabled_gl_winsys += 'x11'
680
681     if need_platform_glx != 'no' and glx_dep.found() and cc.has_function ('glXMakeCurrent', dependencies : glx_dep)
682       glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
683       gl_priv_sources += [
684         'x11/gstglcontext_glx.c',
685       ]
686       # GLX is in the opengl library on linux
687       gl_platform_deps += glx_dep
688       enabled_gl_platforms += 'glx'
689     endif
690   elif need_win_x11 == 'yes'
691     error ('Could not find requested X11 libraries')
692   endif
693 endif
694
695 if need_win_dispmanx != 'no'
696   have_dispmanx_window_t = cc.has_type(
697       'EGL_DISPMANX_WINDOW_T',
698       prefix: '''
699 #include <bcm_host.h>
700 #include <EGL/egl.h>
701 ''',
702       dependencies: [gl_lib_deps, egl_dep, bcm_host_dep],
703       include_directories: gl_includes)
704
705   if have_dispmanx_window_t and bcm_host_dep.found()
706     if not egl_dep.found()
707       error('dispmanx requires the use of egl')
708     endif
709
710     gl_priv_sources += [
711       'dispmanx/gstglwindow_dispmanx_egl.c'
712     ]
713
714     glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
715     gl_winsys_deps += bcm_host_dep
716     enabled_gl_winsys += 'dispmanx'
717     gl_cpp_args += ['-DUSE_EGL_RPI']
718   elif need_win_dispmanx == 'yes'
719     error('Could not find dispmanx libraries')
720   endif
721 endif
722
723 # win32 checks
724 if need_platform_wgl == 'yes'
725   if need_win_win32 == 'no'
726     error('Impossible situation requested: Cannot use WGL without the win32 window system')
727   endif
728 endif
729
730 if host_system == 'windows' and need_win_win32 != 'no'
731   gdi_dep = cc.find_library('gdi32', required : false)
732   if gdi_dep.found()
733     have_wgl = false
734     have_egl_win32 = false
735     if need_platform_wgl != 'no'
736       wglext_h = cc.has_header('GL/wglext.h',
737                                prefix : '''#include <windows.h>
738                                            #include <GL/gl.h>''',
739                                include_directories : compat_includes)
740       have_wgl = wglext_h and gl_dep.found()
741     endif
742
743     have_egl_win32 = enabled_gl_platforms.contains('egl') and gles2_dep.found()
744     if have_wgl or have_egl_win32
745       gl_includes += [compat_includes]
746       gl_platform_deps += gdi_dep
747       gl_priv_sources += [
748         'win32/gstglwindow_win32.c',
749       ]
750       enabled_gl_winsys += 'win32'
751       gl_winsys_deps += gdi_dep
752       glconf.set('GST_GL_HAVE_WINDOW_WIN32', 1)
753     endif
754
755     if have_wgl
756       gl_priv_sources += [
757         'wgl/gstglcontext_wgl.c',
758       ]
759       enabled_gl_platforms += 'wgl'
760       glconf.set('GST_GL_HAVE_PLATFORM_WGL', 1)
761     endif
762   endif
763 endif
764
765 # WinRT ANGLE checks
766 if need_win_winrt != 'no' and host_system == 'windows'
767   if need_win_winrt == 'yes' and not enabled_gl_platforms.contains('egl')
768     error('Impossible situation requested: Cannot use WinRT ANGLE without EGL support')
769   endif
770
771   if egl_dep.found()
772     windows_graphics_h = cc.has_header('windows.graphics.h')
773     windows_app_dep = cc.find_library('WindowsApp', required: false)
774     runtimeobject_lib = cc.find_library('runtimeobject', required: false)
775
776     if windows_graphics_h and windows_app_dep.found() and runtimeobject_lib.found()
777       enabled_gl_winsys += 'winrt'
778       glconf.set('GST_GL_HAVE_WINDOW_WINRT', 1)
779       gl_priv_sources += [
780         'winrt/gstglwindow_winrt_egl.cpp'
781       ]
782       gl_winsys_deps += runtimeobject_lib
783     elif need_win_winrt == 'yes'
784       error('WinRT is enabled, but headers/libraries were not found')
785     endif
786   elif need_win_winrt == 'yes'
787     error('WinRT ANGLE is enabled, but EGL was not found')
788   else
789     message('WinRT ANGLE disabled because EGL was not found')
790   endif
791 endif
792
793 if ['darwin', 'ios'].contains(host_system)
794   if not have_objc
795     error('No ObjC compiler found')
796   endif
797
798   objc = meson.get_compiler('objc')
799   if not objc.has_argument('-fobjc-arc')
800     error('ARC is required for building')
801   endif
802
803   gl_objc_args += ['-fobjc-arc']
804 endif
805
806 # OSX check
807 if need_platform_cgl == 'yes'
808   if need_win_cocoa == 'no'
809     error('Impossible situation requested: Cannot use CGL without Cocoa support')
810   elif need_api_opengl == 'no'
811     error('Impossible situation requested: Cannot use CGL without the OpenGL library')
812   endif
813 elif need_platform_cgl == 'no' and need_win_cocoa == 'yes'
814   error('Impossible situation requested: Cannot use Cocoa without CGL support')
815 endif
816
817 if host_system == 'darwin'
818   foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
819   quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
820   corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
821
822   if need_platform_cgl != 'no'
823     if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
824       gl_platform_deps += [quartzcore_dep, corefoundation_dep, foundation_dep]
825       enabled_gl_platforms += 'cgl'
826       glconf.set('GST_GL_HAVE_PLATFORM_CGL', 1)
827
828       if need_win_cocoa != 'no'
829         cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : false)
830         if cocoa_dep.found()
831           gl_priv_sources += [
832             'cocoa/gstglcaopengllayer.m',
833             'cocoa/gstglcontext_cocoa.m',
834             'cocoa/gstgldisplay_cocoa.m',
835             'cocoa/gstglwindow_cocoa.m'
836           ]
837           gl_winsys_deps += cocoa_dep
838           enabled_gl_winsys += 'cocoa'
839           glconf.set('GST_GL_HAVE_WINDOW_COCOA', 1)
840         elif need_win_cocoa == 'yes'
841           error('Could not find Cocoa')
842         endif
843       endif
844     elif need_platform_cgl == 'yes'
845       error('Could not find CGL dependencies')
846     endif
847   endif
848 endif
849
850 if need_platform_eagl == 'yes'
851   if host_system != 'ios'
852     error('Can only use EAGL on iOS')
853   endif
854   if need_win_eagl == 'no'
855     error('Impossible situation requested: Cannot use EAGL platform without the EAGL window system')
856   elif need_api_gles == 'no'
857     error('Impossible situation requested: Cannot use EAGL platform without the GLES library')
858   endif
859 elif need_platform_eagl == 'no' and need_win_eagl == 'yes'
860   error('Impossible situation requested: Cannot use EAGL window system without the EAGL platform')
861 endif
862
863 if host_system == 'ios' and need_platform_eagl != 'no' and need_win_eagl != 'no'
864   foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
865   corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
866   coregraphics_dep = dependency('appleframeworks', modules : ['CoreGraphics'], required : false)
867   quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
868   uikit_dep = dependency('appleframeworks', modules : ['UIkit'], required : false)
869
870   if foundation_dep.found() and corefoundation_dep.found() and coregraphics_dep.found() and quartzcore_dep.found() and uikit_dep.found()
871     gl_platform_deps += [
872       corefoundation_dep,
873       foundation_dep,
874       coregraphics_dep,
875       quartzcore_dep,
876       uikit_dep,
877     ]
878     gl_priv_sources += [
879       'eagl/gstglcontext_eagl.m',
880       'eagl/gstglwindow_eagl.m',
881     ]
882     enabled_gl_winsys += 'eagl'
883     enabled_gl_platforms += 'eagl'
884     glconf.set('GST_GL_HAVE_WINDOW_EAGL', 1)
885     glconf.set('GST_GL_HAVE_PLATFORM_EAGL', 1)
886   elif need_platform_eagl == 'yes' or need_win_eagl == 'yes'
887     error('Could not find dependencies for EAGL')
888   endif
889 endif
890
891 # GBM Checks
892 gbm_gudev_dep = unneeded_dep
893 gbm_libdrm_dep = unneeded_dep
894 gbm_dep = unneeded_dep
895 if need_win_gbm != 'no'
896   if need_win_gbm == 'yes'
897     if need_platform_egl == 'no'
898       error('Impossible situation requested: Cannot use GBM without EGL support')
899     endif
900   endif
901
902   gbm_gudev_dep = dependency('gudev-1.0', version : '>=147', required : false)
903   gbm_libdrm_dep = dependency('libdrm', version : '>= 2.4.55', required : false)
904   gbm_dep = dependency('gbm', required : false)
905   if egl_dep.found() and gbm_gudev_dep.found() and gbm_libdrm_dep.found() and gbm_dep.found()
906     gl_priv_sources += [
907       'gbm/gstgldisplay_gbm.c',
908       'gbm/gstgl_gbm_utils.c',
909       'gbm/gstglwindow_gbm_egl.c',
910     ]
911     enabled_gl_winsys += 'gbm'
912     gl_winsys_deps += [gbm_gudev_dep, gbm_libdrm_dep, gbm_dep]
913     glconf.set('GST_GL_HAVE_WINDOW_GBM', 1)
914   else
915     if need_win_gbm == 'yes'
916       error ('Could not find requested GBM libraries')
917     endif
918     gbm_gudev_dep = unneeded_dep
919     gbm_libdrm_dep = unneeded_dep
920     gbm_dep = unneeded_dep
921   endif
922 endif
923
924 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
925   glconf.set('GST_GL_HAVE_VIV_DIRECTVIV', 1)
926 endif
927
928 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
929   if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
930     enabled_gl_winsys += 'viv-fb'
931     glconf.set('GST_GL_HAVE_WINDOW_VIV_FB', 1)
932     gl_priv_sources += files([
933       'viv-fb/gstgldisplay_viv_fb.c',
934       'viv-fb/gstglwindow_viv_fb_egl.c',
935     ])
936     gl_viv_fb_sources += files([
937       'viv-fb/gstgldisplay_viv_fb.c',
938     ])
939
940     gl_cpp_args += ['-DEGL_API_FB']
941     gl_viv_fb_headers = files([
942       'viv-fb/gstglviv-fb.h',
943       'viv-fb/gstgldisplay_viv_fb.h',
944     ])
945   endif
946 endif
947
948 if need_win_android == 'yes'
949   if need_platform_egl == 'no'
950     error('Impossible situation requested: Cannot build for Android without EGL')
951   elif need_api_gles2 == 'no'
952     error('Impossible situation requested: Cannot build for Android without GLES2 support')
953   elif host_system != 'android'
954     error('Impossible situation requested: Cannot build for Android without an android system')
955   endif
956 endif
957
958 if host_system == 'android' and need_win_android != 'no' and need_platform_egl != 'no'
959   if gles2_dep.found() and egl_dep.found()
960     enabled_gl_winsys += ['android']
961     glconf.set('GST_GL_HAVE_WINDOW_ANDROID', 1)
962     gl_priv_sources += [
963       'android/gstglwindow_android_egl.c'
964     ]
965   endif
966 endif
967
968 gl_nvmm = false
969 nvbuf_utils_dep = unneeded_dep
970 if egl_dep.found()
971   # XXX: provide options for this?
972   # c_args and c_link_args can also cover this case just fine e.g.:
973   # -Dc_args='-I/usr/src/jetson_multimedia_api/include' -Dc_link_args='-L/usr/lib/aarch64-linux-gnu/tegra/'
974   nvbuf_utils_dep = cc.find_library('nvbuf_utils', required : false)
975   nvbuf_utils_h = cc.has_header('nvbuf_utils.h')
976   if nvbuf_utils_dep.found() and nvbuf_utils_h
977     gl_misc_deps += [nvbuf_utils_dep]
978     gl_nvmm = true
979     gl_cpp_args += ['-DHAVE_NVMM']
980   endif
981 endif
982
983 build_gstgl = true
984 if enabled_gl_apis.length() == 0
985   message('No OpenGL API libraries found or requested')
986   build_gstgl = false
987 endif
988 if enabled_gl_platforms.length() == 0
989   message('No OpenGL Platforms found or requested')
990   build_gstgl = false
991 endif
992 if enabled_gl_winsys.length() == 0
993   message('No OpenGL Window systems found or requested')
994   build_gstgl = false
995 endif
996
997 if build_gstgl
998   # find some types that may or may not be defined
999   if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1000     glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
1001   endif
1002   if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1003     glconf.set('GST_GL_HAVE_GLCHAR', 1)
1004   endif
1005   if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1006     glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
1007   endif
1008   if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1009     glconf.set('GST_GL_HAVE_GLINTPTR', 1)
1010   endif
1011   if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1012     glconf.set('GST_GL_HAVE_GLSYNC', 1)
1013   endif
1014   if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1015     glconf.set('GST_GL_HAVE_GLUINT64', 1)
1016   endif
1017   if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1018     glconf.set('GST_GL_HAVE_GLINT64', 1)
1019   endif
1020   if egl_dep.found() and cc.has_type('EGLAttrib', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep], include_directories : gl_includes)
1021     glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
1022   endif
1023   if egl_dep.found() and cc.has_type('EGLuint64KHR', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep], include_directories : gl_includes)
1024     glconf.set('GST_GL_HAVE_EGLUINT64KHR', 1)
1025   endif
1026
1027   summary('GL api', enabled_gl_apis, list_sep: ', ')
1028   summary('GL platform', enabled_gl_platforms, list_sep: ', ')
1029   summary('GL winsys', enabled_gl_winsys, list_sep: ', ')
1030
1031   install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
1032   install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
1033
1034   configure_file(input : 'gstglconfig.h.meson',
1035     output : 'gstglconfig.h',
1036     install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
1037     install_tag : 'devel',
1038     configuration : glconf)
1039
1040   glib_mkenums = find_program('glib-mkenums')
1041   mkenums = find_program('gl_mkenum.py')
1042   gl_enumtypes_h = custom_target('gstglenumtypes_h',
1043     output : 'gl-enumtypes.h',
1044     input : gir_gl_headers,
1045     install : true,
1046     install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/gl/'),
1047     command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1048
1049   gl_enumtypes_c = custom_target('gstglenumtypes_c',
1050     output : 'gl-enumtypes.c',
1051     input : gir_gl_headers,
1052     depends : [gl_enumtypes_h],
1053     command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1054   gen_sources = [gl_enumtypes_h]
1055
1056   common_args = gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL', '-DG_LOG_DOMAIN="GStreamer-GL"']
1057
1058   # We have custom_target() that generate headers in the current build dir,
1059   # but with implicit_include_directories: false, meson >= 0.58.0 won't include
1060   # it by default. We cannot use include_directories('.') here because it would
1061   # also include current source dir which is what we want to avoid because
1062   # case-insensitive FS would include gst-libs/gl/egl/egl.h as EGL/egl.h.
1063   common_args += '-I@0@'.format(meson.current_build_dir())
1064
1065   gstgl = library('gstgl-' + api_version,
1066     gl_sources, gl_egl_sources, gl_x11_sources, gl_wayland_sources, gl_viv_fb_sources, gl_priv_sources, gl_enumtypes_c, gl_enumtypes_h,
1067     c_args : common_args,
1068     cpp_args : common_args,
1069     objc_args : common_args + gl_objc_args,
1070     include_directories : [configinc, libsinc, gl_includes],
1071     version : libversion,
1072     soversion : soversion,
1073     darwin_versions : osxversion,
1074     install : true,
1075     dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
1076                     gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps],
1077     # don't confuse EGL/egl.h with gst-libs/gl/egl/egl.h on case-insensitive file systems
1078     implicit_include_directories : false)
1079
1080   pkgconfig_gl_variables = [
1081     'gl_platforms=' + ' '.join(enabled_gl_platforms),
1082     'gl_winsys=' + ' '.join(enabled_gl_winsys),
1083     'gl_apis=' + ' '.join(enabled_gl_apis),
1084   ]
1085
1086   library_def = {'lib': gstgl}
1087   pkg_name = 'gstreamer-gl-1.0'
1088   pkgconfig.generate(gstgl,
1089     libraries : [gstvideo, gst_base_dep, gst_dep],
1090     variables : pkgconfig_variables + pkgconfig_gl_variables,
1091     uninstalled_variables : pkgconfig_gl_variables,
1092     subdirs : pkgconfig_subdirs,
1093     extra_cflags : ['-I${libdir}/gstreamer-1.0/include'],
1094     name : pkg_name,
1095     description : 'Streaming media framework, OpenGL plugins libraries',
1096   )
1097
1098   # Desperate times, desperate measures... fix up escaping of our variables
1099   run_command(meson_pkg_config_file_fixup_script,
1100     'gstreamer-gl-1.0', 'gl_platforms', 'gl_winsys', 'gl_apis',
1101     check: true)
1102
1103   pkgconfig.generate(
1104     libraries : [gstgl, gl_lib_deps],
1105     subdirs : pkgconfig_subdirs,
1106     name : 'gstreamer-gl-prototypes-1.0',
1107     description : 'Streaming media framework, OpenGL plugins libraries (OpenGL Prototypes)',
1108   )
1109
1110   if build_gir
1111     gir = {
1112         'sources' : gl_sources + [gl_enumtypes_h] + [gl_enumtypes_c] + gir_gl_headers,
1113         'namespace' : 'GstGL',
1114         'nsversion' : api_version,
1115         'identifier_prefix' : 'Gst',
1116         'symbol_prefix' : 'gst',
1117         'export_packages' : pkg_name,
1118         'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1119         'install' : true,
1120         'extra_args' : gir_init_section + ['--c-include=gst/gl/gl.h'],
1121         'dependencies' : [video_dep, gst_dep, gst_base_dep],
1122     }
1123     library_def += {'gir': [gir]}
1124     if not static_build
1125       gl_gir = gnome.generate_gir(gstgl, kwargs: gir)
1126       gen_sources += [gl_gir]
1127     endif
1128   endif
1129   gst_libraries += [[pkg_name, library_def]]
1130   gstgl_dep = declare_dependency(link_with : gstgl,
1131     include_directories : [libsinc, compat_includes],
1132     sources: gen_sources,
1133     dependencies : [video_dep, gst_base_dep, gl_winsys_deps],
1134     variables: pkgconfig_gl_variables)
1135   gstglproto_dep = declare_dependency(
1136     dependencies : [gstgl_dep] + gl_lib_deps,
1137     sources: gen_sources
1138   )
1139   meson.override_dependency('gstreamer-gl-1.0', gstgl_dep)
1140   meson.override_dependency('gstreamer-gl-prototypes-1.0', gstglproto_dep)
1141
1142   if gl_x11_headers.length() > 0
1143     install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
1144     pkg_name = 'gstreamer-gl-x11-1.0'
1145     pkgconfig.generate(
1146       libraries : [gstgl],
1147       requires: ['x11-xcb'],
1148       subdirs : pkgconfig_subdirs,
1149       name : pkg_name,
1150       description : 'Streaming media framework, OpenGL plugins libraries (X11 specifics)',
1151     )
1152     gl_x11_gir = []
1153     if build_gir
1154       gir = {
1155         'sources' : gl_x11_sources + gl_x11_headers,
1156         'namespace' : 'GstGLX11',
1157         'nsversion' : api_version,
1158         'identifier_prefix' : 'Gst',
1159         'symbol_prefix' : 'gst',
1160         'export_packages' : 'gstreamer-gl-x11-1.0',
1161         'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1162         'install' : true,
1163         'extra_args' : gir_init_section + ['--c-include=gst/gl/x11/x11.h'],
1164         'dependencies' : [video_dep, gst_dep, gst_base_dep]
1165       }
1166       gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1167       gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1168       if not static_build
1169         gir += {'includes': gir['includes'] + [gl_gir[0]]}
1170         gl_x11_gir = gnome.generate_gir(gstgl, kwargs: gir)
1171       endif
1172     endif
1173     gstglx11_dep = declare_dependency(dependencies : [gstgl_dep, x11_dep, xcb_dep],
1174       sources : gl_x11_gir)
1175     meson.override_dependency('gstreamer-gl-x11-1.0', gstglx11_dep)
1176   endif
1177
1178   if gl_wayland_headers.length() > 0
1179     install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
1180     pkg_name = 'gstreamer-gl-wayland-1.0'
1181     pkgconfig.generate(
1182       libraries : [gstgl],
1183       requires: ['wayland-egl', 'wayland-client'],
1184       subdirs : pkgconfig_subdirs,
1185       name : pkg_name,
1186       description : 'Streaming media framework, OpenGL plugins libraries (Wayland specifics)',
1187     )
1188     gl_wayland_gir = []
1189     if build_gir
1190       gir = {
1191         'sources' : gl_wayland_sources + gl_wayland_headers,
1192         'namespace' : 'GstGLWayland',
1193         'nsversion' : api_version,
1194         'identifier_prefix' : 'Gst',
1195         'symbol_prefix' : 'gst',
1196         'export_packages' : 'gstreamer-gl-wayland-1.0',
1197         'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1198         'install' : true,
1199         'extra_args' : gir_init_section + ['--c-include=gst/gl/wayland/wayland.h'],
1200         'dependencies' : [video_dep, gst_dep, gst_base_dep]
1201       }
1202
1203       gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1204       gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1205       if not static_build
1206         gir += {'includes': gir['includes'] + [gl_gir[0]]}
1207         gl_wayland_gir = gnome.generate_gir(gstgl, kwargs: gir)
1208       endif
1209     endif
1210     gstglwayland_dep = declare_dependency(dependencies : [gstgl_dep],
1211       sources : gl_wayland_gir)
1212     meson.override_dependency(pkg_name, gstglwayland_dep)
1213   endif
1214
1215   if gl_egl_headers.length() > 0
1216     install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
1217     pkg_name = 'gstreamer-gl-egl-1.0'
1218     pkgconfig.generate(
1219       libraries : [gstgl, egl_dep],
1220       subdirs : pkgconfig_subdirs,
1221       name : pkg_name,
1222       description : 'Streaming media framework, OpenGL plugins libraries (EGL specifics)',
1223     )
1224     gl_egl_gir = []
1225     if build_gir
1226       gir = {
1227         'sources' : gl_egl_sources + gl_egl_headers,
1228         'namespace' : 'GstGLEGL',
1229         'nsversion' : api_version,
1230         'identifier_prefix' : 'Gst',
1231         'symbol_prefix' : 'gst',
1232         'export_packages' : pkg_name,
1233         'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1234         'install' : true,
1235         'extra_args' : gir_init_section + ['--c-include=gst/gl/egl/egl.h'],
1236         'dependencies' : [video_dep, gst_dep, gst_base_dep]
1237       }
1238       gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1239       gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1240       if not static_build
1241         gir += {'includes': gir['includes'] + [gl_gir[0]]}
1242         gl_egl_gir = gnome.generate_gir(gstgl, kwargs: gir)
1243       endif
1244     endif
1245     gstglegl_dep = declare_dependency(dependencies : [gstgl_dep],
1246       sources : gl_egl_gir)
1247     meson.override_dependency(pkg_name, gstglegl_dep)
1248   endif
1249
1250   if gl_viv_fb_headers.length() > 0
1251     install_headers(gl_viv_fb_headers, subdir : 'gstreamer-1.0/gst/gl/viv-fb')
1252     pkg_name = 'gstreamer-gl-viv-fb-1.0'
1253     pkgconfig.generate(
1254       libraries : [gstgl],
1255       subdirs : pkgconfig_subdirs,
1256       name : pkg_name,
1257       description : 'Streaming media framework, OpenGL plugins libraries (Vivante Framebuffer specifics)',
1258     )
1259     gl_viv_fb_gir = []
1260     if build_gir
1261       gir = {
1262         'sources' : gl_viv_fb_sources + gl_viv_fb_headers,
1263         'namespace' : 'GstGLVivFB',
1264         'nsversion' : api_version,
1265         'identifier_prefix' : 'Gst',
1266         'symbol_prefix' : 'gst',
1267         'export_packages' : pkg_name,
1268         'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1269         'install' : true,
1270         'extra_args' : gir_init_section + ['--c-include=gst/gl/viv-fb/gstglviv-fb.h'],
1271         'dependencies' : [video_dep, gst_dep, gst_base_dep]
1272       }
1273       gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1274       gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1275       if not static_build
1276         gir += {'includes': gir['includes'] + [gl_gir[0]]}
1277         gl_viv_fb_gir = gnome.generate_gir(gstgl, kwargs: gir)
1278         library_def += {'gir_targets':  library_def.get('gir_targets', []) + [gl_viv_fb_gir]}
1279       endif
1280     endif
1281     gstglviv_fb_dep = declare_dependency(dependencies : [gstgl_dep],
1282       sources : gl_viv_fb_gir)
1283     meson.override_dependency(pkg_name, gstglviv_fb_dep)
1284   endif
1285
1286 elif get_option('gl').enabled()
1287   error('GStreamer OpenGL integration required via options, but needed dependencies not found.')
1288 endif