1 if get_option('gl').disabled()
2 message('GStreamer OpenGL integration disabled via options.')
3 gstgl_dep = dependency('', required: false)
13 'gstglcolorconvert.c',
25 'gstgloverlaycompositor.c',
27 'gstglrenderbuffer.c',
29 'gstglshaderstrings.c',
52 'gstglcolorconvert.h',
62 'gstgloverlaycompositor.h',
64 'gstglrenderbuffer.h',
66 'gstglshaderstrings.h',
76 gl_headers = gir_gl_headers + [
80 gl_prototype_headers = [
81 'glprototypes/all_functions.h',
82 'glprototypes/base.h',
83 'glprototypes/blending.h',
84 'glprototypes/buffers.h',
85 'glprototypes/debug.h',
86 'glprototypes/eglimage.h',
88 'glprototypes/fixedfunction.h',
89 'glprototypes/gles.h',
90 'glprototypes/gstgl_compat.h',
91 'glprototypes/gstgl_gles2compat.h',
92 'glprototypes/opengl.h',
93 'glprototypes/query.h',
94 'glprototypes/shaders.h',
95 'glprototypes/sync.h',
100 gl_wayland_headers = []
103 glconf = configuration_data()
105 'GST_GL_HAVE_OPENGL',
108 'GST_GL_HAVE_GLES3EXT3_H',
110 'GST_GL_HAVE_WINDOW_X11',
111 'GST_GL_HAVE_WINDOW_COCOA',
112 'GST_GL_HAVE_WINDOW_WIN32',
113 'GST_GL_HAVE_WINDOW_WINRT',
114 'GST_GL_HAVE_WINDOW_WAYLAND',
115 'GST_GL_HAVE_WINDOW_ANDROID',
116 'GST_GL_HAVE_WINDOW_DISPMANX',
117 'GST_GL_HAVE_WINDOW_EAGL',
118 'GST_GL_HAVE_WINDOW_VIV_FB',
119 'GST_GL_HAVE_WINDOW_GBM',
121 'GST_GL_HAVE_PLATFORM_EGL',
122 'GST_GL_HAVE_PLATFORM_GLX',
123 'GST_GL_HAVE_PLATFORM_WGL',
124 'GST_GL_HAVE_PLATFORM_CGL',
125 'GST_GL_HAVE_PLATFORM_EAGL',
127 'GST_GL_HAVE_DMABUF',
128 'GST_GL_HAVE_VIV_DIRECTVIV',
130 'GST_GL_HAVE_GLEGLIMAGEOES',
131 'GST_GL_HAVE_GLCHAR',
132 'GST_GL_HAVE_GLSIZEIPTR',
133 'GST_GL_HAVE_GLINTPTR',
134 'GST_GL_HAVE_GLSYNC',
135 'GST_GL_HAVE_GLUINT64',
136 'GST_GL_HAVE_GLINT64',
137 'GST_GL_HAVE_EGLATTRIB',
138 'GST_GL_HAVE_EGLUINT64KHR',
141 foreach option : glconf_options
142 glconf.set10(option, false)
145 unneeded_dep = dependency('', required : false)
146 if unneeded_dep.found()
147 error ('Found unfindable dependency')
150 # OpenGL/GLES2 libraries
152 # GL platform - EGL, GLX, CGL, WGL, etc
153 gl_platform_deps = []
154 # GL winsys - wayland, X11, Cocoa, win32, etc
156 # other things we need.
158 # Other preprocessor arguments
164 enabled_gl_platforms = []
165 enabled_gl_winsys = []
167 # parse provided options
168 libegl_module_name = get_option('egl_module_name')
169 if libegl_module_name != ''
170 gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)]
172 libgles2_module_name = get_option('gles2_module_name')
173 if libgles2_module_name != ''
174 gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)]
176 libgl_module_name = get_option('opengl_module_name')
177 if libgl_module_name != ''
178 gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)]
181 gl_apis = get_option('gl_api')
182 if gl_apis.contains('auto')
183 need_api_opengl = 'auto'
184 need_api_gles2 = 'auto'
186 need_api_opengl = 'no'
187 need_api_gles2 = 'no'
188 foreach api : gl_apis
190 need_api_opengl = 'yes'
192 need_api_gles2 = 'yes'
194 error('Unsupported GL api provided ' + api)
199 gl_platforms = get_option('gl_platform')
200 if gl_platforms.contains('auto')
201 need_platform_egl = 'auto'
202 need_platform_glx = 'auto'
203 need_platform_cgl = 'auto'
204 need_platform_wgl = 'auto'
205 need_platform_eagl = 'auto'
207 need_platform_egl = 'no'
208 need_platform_glx = 'no'
209 need_platform_cgl = 'no'
210 need_platform_wgl = 'no'
211 need_platform_eagl = 'no'
212 foreach platform : gl_platforms
214 need_platform_egl = 'yes'
215 elif platform == 'glx'
216 need_platform_glx = 'yes'
217 elif platform == 'cgl'
218 need_platform_cgl = 'yes'
219 elif platform == 'wgl'
220 need_platform_wgl = 'yes'
221 elif platform == 'eagl'
222 need_platform_eagl = 'yes'
224 error('Unsupported GL platform provided ' + platform)
229 gl_winsys = get_option('gl_winsys')
230 if gl_winsys.contains('auto')
231 need_win_x11 = 'auto'
232 need_win_wayland = 'auto'
233 need_win_win32 = 'auto'
234 need_win_winrt = 'auto'
235 need_win_cocoa = 'auto'
236 need_win_egl = 'auto'
237 need_win_eagl = 'auto'
238 need_win_dispmanx = 'auto'
239 need_win_viv_fb = 'auto'
240 need_win_gbm = 'auto'
241 need_win_android = 'auto'
244 need_win_wayland = 'no'
245 need_win_win32 = 'no'
246 need_win_winrt = 'no'
247 need_win_cocoa = 'no'
250 need_win_dispmanx = 'no'
251 need_win_viv_fb = 'no'
253 need_win_android = 'no'
254 foreach winsys : gl_winsys
257 elif winsys == 'wayland'
258 need_win_wayland = 'yes'
259 elif winsys == 'win32'
260 need_win_win32 = 'yes'
261 elif winsys == 'winrt'
262 need_win_winrt = 'yes'
263 elif winsys == 'cocoa'
264 need_win_cocoa = 'yes'
267 elif winsys == 'eagl'
268 need_win_eagl = 'yes'
269 elif winsys == 'dispmanx'
270 need_win_dispmanx = 'yes'
271 elif winsys == 'viv-fb'
272 need_win_viv_fb = 'yes'
275 elif winsys == 'android'
276 need_win_android = 'yes'
278 error('Unsupported GL winsys provided ' + winsys)
283 gl_include_header = '''
285 # pragma GCC diagnostic push
286 # pragma GCC diagnostic ignored "-Wredundant-decls"
288 #ifndef GL_GLEXT_PROTOTYPES
289 #define GL_GLEXT_PROTOTYPES 1
293 # convoluted way of getting at the subproject taking into account the wrap-mode
294 # so we don't download a subproject unless allowed
295 gl_header_dep = dependency('', fallback : ['gl-headers', 'gl_headers_dummy_dep'],
297 if gl_header_dep.type_name() == 'internal'
298 # this will only contain the includes of headers that are not found
299 compat_includes = subproject('gl-headers').get_variable('compatibility_includes')
304 # Desktop OpenGL checks
305 gl_dep = unneeded_dep
306 glx_dep = unneeded_dep
307 if need_api_opengl != 'no' or need_platform_glx != 'no'
308 if host_system == 'darwin'
309 gl_dep = dependency('appleframeworks', modules : ['OpenGL'], required : false)
311 # override meson's braindead gl detection on osx/windows/etc by forcing pkg-config
312 gl_dep = dependency('gl', method: 'pkg-config', required : false)
315 if not gl_dep.found()
316 if host_system == 'windows'
317 gl_dep = cc.find_library('opengl32', required : false)
319 gl_dep = cc.find_library('GL', required : false)
322 if not cc.has_header('GL/gl.h', include_directories : compat_includes)
323 gl_dep = unneeded_dep
326 if not gl_dep.found() and need_api_opengl == 'yes'
327 error ('Could not find requested OpenGL library')
331 gl_includes += [compat_includes]
335 if host_system == 'darwin'
336 glx_dep = cc.find_library('GL', required : false)
341 if need_api_opengl == 'no'
342 gl_dep = unneeded_dep
344 if need_platform_glx == 'no'
345 glx_dep = unneeded_dep
349 if host_system == 'darwin'
350 opengl_includes += '''
351 #include <OpenGL/OpenGL.h>
352 #include <OpenGL/gl.h>
353 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
354 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
355 # include <OpenGL/gl3.h>
359 opengl_includes += '''
361 # include <windows.h>
364 #if __WIN32__ || _WIN32
365 # include <GL/glext.h>
372 gles2_dep = unneeded_dep
375 if need_api_gles2 != 'no'
376 if host_system == 'ios'
377 gles2_dep = dependency('appleframeworks', modules : ['OpenGLES'], required : false)
379 gles2_dep = dependency('glesv2', required : false)
382 if not gles2_dep.found()
383 # if host_system == 'windows'
384 # elif host_system == ios
385 # gles2_dep = cc.find_library('GLESv2', required : false)
387 gles2_dep = cc.find_library('GLESv2', required : false)
390 if not cc.has_header('GLES2/gl2.h', include_directories : compat_includes)
391 gles2_dep = unneeded_dep
394 if not gles2_dep.found() and need_api_gles2 == 'yes'
395 error ('Could not find requested OpenGL ES library')
399 gl_includes += [compat_includes]
403 gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', dependencies : gles2_dep, include_directories : compat_includes)
406 if host_system == 'ios'
408 # include <OpenGLES/ES2/gl.h>
409 # include <OpenGLES/ES2/glext.h>
413 gl_includes += [compat_includes]
414 gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', dependencies : gles2_dep, include_directories : compat_includes)
416 # include <GLES3/gl3.h>
417 # include <GLES2/gl2ext.h>'''
420 # include <GLES3/gl3ext.h>'''
424 # include <GLES2/gl2.h>
425 # include <GLES2/gl2ext.h>'''
430 # can we include both gles2 and opengl headers?
431 if gles2_dep.found() and gl_dep.found()
432 gl_include_block = gl_include_header + gles_includes + opengl_includes
433 # TODO: Revert to passing gl_include_block via prefix: once
434 # https://github.com/mesonbuild/meson/issues/2364 is fixed
435 if not cc.compiles(gl_include_block + '\n' + 'void f (void) {}',dependencies : [gles2_dep, gl_dep], include_directories : compat_includes)
436 message ('Cannot include both OpenGL and OpenGL ES headers')
437 if need_api_gles2 != 'yes'
438 gles2_dep = unneeded_dep
439 elif need_api_opengl != 'yes'
440 gl_dep = unneeded_dep
442 error('Both OpenGL and OpenGL ES were requested but cannot be included together')
446 gl_include_block = gl_include_header
448 gl_include_block += gles_includes
451 gl_include_block += opengl_includes
455 gl_lib_deps += gles2_dep
456 glconf.set10('GST_GL_HAVE_GLES2', 1)
458 glconf.set10('GST_GL_HAVE_GLES3', 1)
460 glconf.set10('GST_GL_HAVE_GLES3EXT3_H', 1)
463 enabled_gl_apis += 'gles2'
467 gl_lib_deps += gl_dep
468 glconf.set10('GST_GL_HAVE_OPENGL', 1)
469 enabled_gl_apis += 'gl'
473 egl_dep = unneeded_dep
474 if need_platform_egl != 'no'
475 egl_dep = dependency('egl', required : false)
476 if not egl_dep.found()
477 egl_dep = cc.find_library('EGL', required : false)
480 if egl_dep.found() and not cc.has_header('EGL/egl.h',
481 dependencies : egl_dep,
482 include_directories : compat_includes)
483 egl_dep = unneeded_dep
485 if egl_dep.found() and not cc.has_header('EGL/eglext.h',
486 dependencies : egl_dep,
487 include_directories : compat_includes)
488 egl_dep = unneeded_dep
495 'egl/gstglcontext_egl.c',
496 'egl/gstgldisplay_egl.c',
497 'egl/gstglmemoryegl.c',
498 'egl/gstgldisplay_egl_device.c',
503 'egl/gstgldisplay_egl.h',
504 'egl/gstglmemoryegl.h',
505 'egl/gstgldisplay_egl_device.h',
507 gl_platform_deps += egl_dep
508 glconf.set10('GST_GL_HAVE_PLATFORM_EGL', 1)
510 if cc.has_header('libdrm/drm_fourcc.h')
511 gl_misc_deps += allocators_dep
512 glconf.set10('GST_GL_HAVE_DMABUF', 1)
517 #include <EGL/eglext.h>
519 enabled_gl_platforms += 'egl'
520 elif need_platform_egl == 'yes'
521 error ('Could not find requested EGL library')
526 if need_win_egl == 'yes'
527 if need_platform_egl == 'no'
528 error('Impossible situation requested: Cannot use Winsys egl without EGL support')
529 elif not egl_dep.found()
530 error ('Could not find EGL libraries for Winsys egl')
532 enabled_gl_winsys += 'egl'
537 wayland_client_dep = unneeded_dep
538 wayland_cursor_dep = unneeded_dep
539 wayland_egl_dep = unneeded_dep
540 if need_win_wayland != 'no'
541 if need_win_wayland == 'yes'
542 if need_platform_egl == 'no'
543 error('Impossible situation requested: Cannot use Wayland without EGL support')
546 if not egl_dep.found()
547 if need_win_wayland == 'yes'
548 error ('Could not find EGL libraries for wayland')
550 message ('Could not find EGL libraries for wayland')
553 wayland_client_dep = dependency('wayland-client', version : '>= 1.11', required : false)
554 wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
555 wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
556 wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.15', required : false)
557 wayland_scanner = find_program('wayland-scanner', required: false)
559 if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found() and wayland_protocols_dep.found() and wayland_scanner.found()
560 # Generate the XDG shell interface
561 wayland_protocols_basedir = wayland_protocols_dep.get_pkgconfig_variable('pkgdatadir')
562 xdg_shell_xml_spec = join_paths(wayland_protocols_basedir, 'stable', 'xdg-shell', 'xdg-shell.xml')
563 xdg_shell_header = custom_target('xdg-shell-client-header',
564 command: [ wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@' ],
565 input: xdg_shell_xml_spec,
566 output: 'xdg-shell-client-protocol.h',
568 xdg_shell_code = custom_target('xdg-shell-client-code',
569 command: [ wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@' ],
570 input: xdg_shell_xml_spec,
571 output: 'xdg-shell-client-protocol.c',
575 'wayland/gstgldisplay_wayland.c',
576 'wayland/gstglwindow_wayland_egl.c',
577 'wayland/wayland_event_source.c',
583 gl_wayland_headers += [
584 'wayland/gstgldisplay_wayland.h'
586 glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
587 gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
588 enabled_gl_winsys += 'wayland'
590 if need_win_wayland == 'yes'
591 error ('Could not find requested Wayland libraries')
593 wayland_client_dep = unneeded_dep
594 wayland_cursor_dep = unneeded_dep
595 wayland_egl_dep = unneeded_dep
596 wayland_protocols_dep = unneeded_dep
602 if need_platform_glx == 'yes'
603 if need_win_x11 == 'no'
604 error('Impossible situation requested: Cannot use GLX without X11 support')
605 elif need_api_opengl == 'no'
606 error('Impossible situation requested: Cannot use GLX without the OpenGL library')
610 if need_win_x11 != 'no'
611 xcb_dep = dependency('x11-xcb', required : false)
612 if x11_dep.found() and xcb_dep.found()
614 'x11/gstgldisplay_x11.c',
615 'x11/gstglwindow_x11.c',
616 'x11/xcb_event_source.c',
619 'x11/gstgldisplay_x11.h',
621 glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
622 gl_winsys_deps += [x11_dep, xcb_dep]
623 enabled_gl_winsys += 'x11'
625 if need_platform_glx != 'no' and glx_dep.found() and cc.has_function ('glXMakeCurrent', dependencies : glx_dep)
626 glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
628 'x11/gstglcontext_glx.c',
630 # GLX is in the opengl library on linux
631 gl_platform_deps += glx_dep
632 enabled_gl_platforms += 'glx'
634 elif need_win_x11 == 'yes'
635 error ('Could not find requested X11 libraries')
639 bcm_host_dep = unneeded_dep
640 if need_win_dispmanx != 'no'
642 # Try pkg-config for bcm_host then fallback to find_library to also
643 # support older distribution
644 bcm_host_dep = dependency('bcm_host', required : false)
645 if not bcm_host_dep.found()
646 bcm_host_dep = cc.find_library('bcm_host', required : false)
649 if bcm_host_dep.found()
650 if not egl_dep.found()
651 error('dispmanx requires the use of egl')
655 'dispmanx/gstglwindow_dispmanx_egl.c'
658 glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
659 gl_winsys_deps += bcm_host_dep
660 enabled_gl_winsys += 'dispmanx'
661 gl_cpp_args += ['-DUSE_EGL_RPI']
662 elif need_win_dispmanx == 'yes'
663 error('Could not find dispmanx libraries')
668 if need_platform_wgl == 'yes'
669 if need_win_win32 == 'no'
670 error('Impossible situation requested: Cannot use WGL without the win32 window system')
674 if host_system == 'windows' and need_win_win32 != 'no'
675 gdi_dep = cc.find_library('gdi32', required : false)
678 have_egl_win32 = false
679 if need_platform_wgl != 'no'
680 wglext_h = cc.has_header('GL/wglext.h',
681 prefix : '''#include <windows.h>
682 #include <GL/gl.h>''',
683 include_directories : compat_includes)
684 have_wgl = wglext_h and gl_dep.found()
687 have_egl_win32 = enabled_gl_platforms.contains('egl') and gles2_dep.found()
688 if have_wgl or have_egl_win32
689 gl_includes += [compat_includes]
690 gl_platform_deps += gdi_dep
692 'win32/gstglwindow_win32.c',
693 'win32/gstglwindow_win32.c',
695 enabled_gl_winsys += 'win32'
696 gl_winsys_deps += gdi_dep
697 glconf.set('GST_GL_HAVE_WINDOW_WIN32', 1)
702 'wgl/gstglcontext_wgl.c',
704 enabled_gl_platforms += 'wgl'
705 glconf.set('GST_GL_HAVE_PLATFORM_WGL', 1)
711 if need_win_winrt != 'no' and host_system == 'windows'
712 if need_win_winrt == 'yes' and not enabled_gl_platforms.contains('egl')
713 error('Impossible situation requested: Cannot use WinRT ANGLE without EGL support')
717 windows_graphics_h = cc.has_header('windows.graphics.h')
718 windows_app_dep = cc.find_library('WindowsApp', required: false)
719 runtimeobject_lib = cc.find_library('runtimeobject', required: false)
721 if windows_graphics_h and windows_app_dep.found() and runtimeobject_lib.found()
722 enabled_gl_winsys += 'winrt'
723 glconf.set10('GST_GL_HAVE_WINDOW_WINRT', 1)
725 'winrt/gstglwindow_winrt_egl.cpp'
727 gl_winsys_deps += runtimeobject_lib
728 elif need_win_winrt == 'yes'
729 error('WinRT is enabled, but headers/libraries were not found')
731 elif need_win_winrt == 'yes'
732 error('WinRT ANGLE is enabled, but EGL was not found')
734 message('WinRT ANGLE disabled because EGL was not found')
738 if ['darwin', 'ios'].contains(host_system)
740 error('No ObjC compiler found')
743 objc = meson.get_compiler('objc')
744 if not objc.has_argument('-fobjc-arc')
745 error('ARC is required for building')
748 gl_objc_args += ['-fobjc-arc']
752 if need_platform_cgl == 'yes'
753 if need_win_cocoa == 'no'
754 error('Impossible situation requested: Cannot use CGL without Cocoa support')
755 elif need_api_opengl == 'no'
756 error('Impossible situation requested: Cannot use CGL without the OpenGL library')
758 elif need_platform_cgl == 'no' and need_win_cocoa == 'yes'
759 error('Impossible situation requested: Cannot use Cocoa without CGL support')
762 if host_system == 'darwin'
763 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
764 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
765 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
767 if need_platform_cgl != 'no'
768 if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
769 gl_platform_deps += [quartzcore_dep, corefoundation_dep, foundation_dep]
770 enabled_gl_platforms += 'cgl'
771 glconf.set10('GST_GL_HAVE_PLATFORM_CGL', 1)
773 if need_win_cocoa != 'no'
774 cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : false)
777 'cocoa/gstglcaopengllayer.m',
778 'cocoa/gstglcontext_cocoa.m',
779 'cocoa/gstgldisplay_cocoa.m',
780 'cocoa/gstglwindow_cocoa.m'
782 gl_winsys_deps += cocoa_dep
783 enabled_gl_winsys += 'cocoa'
784 glconf.set10('GST_GL_HAVE_WINDOW_COCOA', 1)
785 elif need_win_cocoa == 'yes'
786 error('Could not find Cocoa')
789 elif need_platform_cgl == 'yes'
790 error('Could not find CGL dependencies')
795 if need_platform_eagl == 'yes'
796 if host_system != 'ios'
797 error('Can only use EAGL on iOS')
799 if need_win_eagl == 'no'
800 error('Impossible situation requested: Cannot use EAGL platform without the EAGL window system')
801 elif need_api_gles == 'no'
802 error('Impossible situation requested: Cannot use EAGL platform without the GLES library')
804 elif need_platform_eagl == 'no' and need_win_eagl == 'yes'
805 error('Impossible situation requested: Cannot use EAGL window system without the EAGL platform')
808 if host_system == 'ios' and need_platform_eagl != 'no' and need_win_eagl != 'no'
809 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
810 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
811 coregraphics_dep = dependency('appleframeworks', modules : ['CoreGraphics'], required : false)
812 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
813 uikit_dep = dependency('appleframeworks', modules : ['UIkit'], required : false)
815 if foundation_dep.found() and corefoundation_dep.found() and coregraphics_dep.found() and quartzcore_dep.found() and uikit_dep.found()
816 gl_platform_deps += [
824 'eagl/gstglcontext_eagl.m',
825 'eagl/gstglwindow_eagl.m',
827 enabled_gl_winsys += 'eagl'
828 enabled_gl_platforms += 'eagl'
829 glconf.set('GST_GL_HAVE_WINDOW_EAGL', 1)
830 glconf.set('GST_GL_HAVE_PLATFORM_EAGL', 1)
831 elif need_platform_eagl == 'yes' or need_win_eagl == 'yes'
832 error('Could not find dependencies for EAGL')
837 gbm_gudev_dep = unneeded_dep
838 gbm_libdrm_dep = unneeded_dep
839 gbm_dep = unneeded_dep
840 if need_win_gbm != 'no'
841 if need_win_gbm == 'yes'
842 if need_platform_egl == 'no'
843 error('Impossible situation requested: Cannot use GBM without EGL support')
847 gbm_gudev_dep = dependency('gudev-1.0', version : '>=147', required : false)
848 gbm_libdrm_dep = dependency('libdrm', version : '>= 2.4.55', required : false)
849 gbm_dep = dependency('gbm', required : false)
850 if egl_dep.found() and gbm_gudev_dep.found() and gbm_libdrm_dep.found() and gbm_dep.found()
852 'gbm/gstgldisplay_gbm.c',
853 'gbm/gstgl_gbm_utils.c',
854 'gbm/gstglwindow_gbm_egl.c',
856 enabled_gl_winsys += 'gbm'
857 gl_winsys_deps += [gbm_gudev_dep, gbm_libdrm_dep, gbm_dep]
858 glconf.set('GST_GL_HAVE_WINDOW_GBM', 1)
860 if need_win_gbm == 'yes'
861 error ('Could not find requested GBM libraries')
863 gbm_gudev_dep = unneeded_dep
864 gbm_libdrm_dep = unneeded_dep
865 gbm_dep = unneeded_dep
869 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
870 if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
871 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
872 enabled_gl_winsys += 'viv-fb'
873 glconf.set10('GST_GL_HAVE_WINDOW_VIV_FB', 1)
874 glconf.set10('GST_GL_HAVE_VIV_DIRECTVIV', 1)
876 'viv-fb/gstgldisplay_viv_fb.c',
877 'viv-fb/gstglwindow_viv_fb_egl.c',
879 gl_cpp_args += ['-DEGL_API_FB']
884 if need_win_android == 'yes'
885 if need_platform_egl == 'no'
886 error('Impossible situation requested: Cannot build for Android without EGL')
887 elif need_api_gles2 == 'no'
888 error('Impossible situation requested: Cannot build for Android without GLES2 support')
889 elif host_system != 'android'
890 error('Impossible situation requested: Cannot build for Android without an android system')
894 if host_system == 'android' and need_win_android != 'no' and need_platform_egl != 'no'
895 if gles2_dep.found() and egl_dep.found()
896 enabled_gl_winsys += ['android']
897 glconf.set10('GST_GL_HAVE_WINDOW_ANDROID', 1)
899 'android/gstglwindow_android_egl.c'
904 # TODO: Add rest of gl config here.
905 # iOS, specific support
908 if enabled_gl_apis.length() == 0
909 message('No OpenGL API libraries found or requested')
912 if enabled_gl_platforms.length() == 0
913 message('No OpenGL Platforms found or requested')
916 if enabled_gl_winsys.length() == 0
917 message('No OpenGL Window systems found or requested')
922 # find some types that may or may not be defined
923 if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
924 glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
926 if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
927 glconf.set('GST_GL_HAVE_GLCHAR', 1)
929 if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
930 glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
932 if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
933 glconf.set('GST_GL_HAVE_GLINTPTR', 1)
935 if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
936 glconf.set('GST_GL_HAVE_GLSYNC', 1)
938 if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
939 glconf.set('GST_GL_HAVE_GLUINT64', 1)
941 if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
942 glconf.set('GST_GL_HAVE_GLINT64', 1)
944 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)
945 glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
947 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)
948 glconf.set('GST_GL_HAVE_EGLUINT64KHR', 1)
951 message('Building libgstgl with GL api: ' + ' '.join(enabled_gl_apis))
952 message('Building libgstgl with GL platform: ' + ' '.join(enabled_gl_platforms))
953 message('Building libgstgl with GL winsys: ' + ' '.join(enabled_gl_winsys))
955 install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
956 install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
957 install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
958 install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
959 install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
961 configure_file(input : 'gstglconfig.h.meson',
962 output : 'gstglconfig.h',
963 install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
964 configuration : glconf)
966 gl_enums = gnome.mkenums_simple('gl-enumtypes',
967 sources : gir_gl_headers,
968 body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif',
969 header_prefix : '#include <gst/gl/gl-prelude.h>',
970 decorator : 'GST_GL_API',
971 install_header: true,
972 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/gl'))
973 gl_enumtypes_c = gl_enums[0]
974 gl_enumtypes_h = gl_enums[1]
975 gen_sources = [gl_enumtypes_h]
977 gstgl = library('gstgl-' + api_version,
978 gl_sources, gl_priv_sources, gl_enumtypes_c, gl_enumtypes_h,
979 c_args : gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL'],
980 cpp_args : gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL'],
981 objc_args : gst_plugins_base_args + gl_cpp_args + gl_objc_args + ['-DBUILDING_GST_GL'],
982 include_directories : [configinc, libsinc, gl_includes],
983 version : libversion,
984 soversion : soversion,
985 darwin_versions : osxversion,
987 dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
988 gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps])
990 gl_gir = gnome.generate_gir(gstgl,
991 sources : gl_sources + [gl_enumtypes_h] + [gl_enumtypes_c] + gir_gl_headers + gl_x11_headers + gl_wayland_headers + gl_egl_headers,
993 nsversion : api_version,
994 identifier_prefix : 'Gst',
995 symbol_prefix : 'gst',
996 export_packages : 'gstreamer-gl-1.0',
997 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
999 extra_args : gir_init_section + ['--c-include=gst/gl/gl.h'],
1000 dependencies : [video_dep, gst_dep, gst_base_dep]
1002 gen_sources += gl_gir
1006 gstgl_dep = declare_dependency(link_with : gstgl,
1007 include_directories : [libsinc, compat_includes],
1008 sources: gen_sources,
1009 dependencies : [video_dep, gst_base_dep] + gl_lib_deps + gl_winsys_deps)
1011 elif get_option('gl').enabled()
1012 error('GStreamer OpenGL integration required via options, but needed dependencies not found.')
1014 gstgl_dep = dependency('', required : false)