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