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',
101 gl_wayland_sources = []
102 gl_wayland_headers = []
106 glconf = configuration_data()
108 'GST_GL_HAVE_OPENGL',
111 'GST_GL_HAVE_GLES3EXT3_H',
113 'GST_GL_HAVE_WINDOW_X11',
114 'GST_GL_HAVE_WINDOW_COCOA',
115 'GST_GL_HAVE_WINDOW_WIN32',
116 'GST_GL_HAVE_WINDOW_WINRT',
117 'GST_GL_HAVE_WINDOW_WAYLAND',
118 'GST_GL_HAVE_WINDOW_ANDROID',
119 'GST_GL_HAVE_WINDOW_DISPMANX',
120 'GST_GL_HAVE_WINDOW_EAGL',
121 'GST_GL_HAVE_WINDOW_VIV_FB',
122 'GST_GL_HAVE_WINDOW_GBM',
124 'GST_GL_HAVE_PLATFORM_EGL',
125 'GST_GL_HAVE_PLATFORM_GLX',
126 'GST_GL_HAVE_PLATFORM_WGL',
127 'GST_GL_HAVE_PLATFORM_CGL',
128 'GST_GL_HAVE_PLATFORM_EAGL',
130 'GST_GL_HAVE_DMABUF',
131 'GST_GL_HAVE_VIV_DIRECTVIV',
133 'GST_GL_HAVE_GLEGLIMAGEOES',
134 'GST_GL_HAVE_GLCHAR',
135 'GST_GL_HAVE_GLSIZEIPTR',
136 'GST_GL_HAVE_GLINTPTR',
137 'GST_GL_HAVE_GLSYNC',
138 'GST_GL_HAVE_GLUINT64',
139 'GST_GL_HAVE_GLINT64',
140 'GST_GL_HAVE_EGLATTRIB',
141 'GST_GL_HAVE_EGLUINT64KHR',
144 foreach option : glconf_options
145 glconf.set10(option, false)
148 unneeded_dep = dependency('', required : false)
149 if unneeded_dep.found()
150 error ('Found unfindable dependency')
153 # OpenGL/GLES2 libraries
155 # GL platform - EGL, GLX, CGL, WGL, etc
156 gl_platform_deps = []
157 # GL winsys - wayland, X11, Cocoa, win32, etc
159 # other things we need.
161 # Other preprocessor arguments
167 enabled_gl_platforms = []
168 enabled_gl_winsys = []
170 # parse provided options
171 libegl_module_name = get_option('egl_module_name')
172 if libegl_module_name != ''
173 gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)]
175 libgles2_module_name = get_option('gles2_module_name')
176 if libgles2_module_name != ''
177 gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)]
179 libgl_module_name = get_option('opengl_module_name')
180 if libgl_module_name != ''
181 gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)]
184 gl_apis = get_option('gl_api')
185 if gl_apis.contains('auto')
186 need_api_opengl = 'auto'
187 need_api_gles2 = 'auto'
189 need_api_opengl = 'no'
190 need_api_gles2 = 'no'
191 foreach api : gl_apis
193 need_api_opengl = 'yes'
195 need_api_gles2 = 'yes'
197 error('Unsupported GL api provided ' + api)
202 gl_platforms = get_option('gl_platform')
203 if gl_platforms.contains('auto')
204 need_platform_egl = 'auto'
205 need_platform_glx = 'auto'
206 need_platform_cgl = 'auto'
207 need_platform_wgl = 'auto'
208 need_platform_eagl = 'auto'
210 need_platform_egl = 'no'
211 need_platform_glx = 'no'
212 need_platform_cgl = 'no'
213 need_platform_wgl = 'no'
214 need_platform_eagl = 'no'
215 foreach platform : gl_platforms
217 need_platform_egl = 'yes'
218 elif platform == 'glx'
219 need_platform_glx = 'yes'
220 elif platform == 'cgl'
221 need_platform_cgl = 'yes'
222 elif platform == 'wgl'
223 need_platform_wgl = 'yes'
224 elif platform == 'eagl'
225 need_platform_eagl = 'yes'
227 error('Unsupported GL platform provided ' + platform)
232 gl_winsys = get_option('gl_winsys')
233 if gl_winsys.contains('auto')
234 need_win_x11 = 'auto'
235 need_win_wayland = 'auto'
236 need_win_win32 = 'auto'
237 need_win_winrt = 'auto'
238 need_win_cocoa = 'auto'
239 need_win_egl = 'auto'
240 need_win_eagl = 'auto'
241 need_win_dispmanx = 'auto'
242 need_win_viv_fb = 'auto'
243 need_win_gbm = 'auto'
244 need_win_android = 'auto'
247 need_win_wayland = 'no'
248 need_win_win32 = 'no'
249 need_win_winrt = 'no'
250 need_win_cocoa = 'no'
253 need_win_dispmanx = 'no'
254 need_win_viv_fb = 'no'
256 need_win_android = 'no'
257 foreach winsys : gl_winsys
260 elif winsys == 'wayland'
261 need_win_wayland = 'yes'
262 elif winsys == 'win32'
263 need_win_win32 = 'yes'
264 elif winsys == 'winrt'
265 need_win_winrt = 'yes'
266 elif winsys == 'cocoa'
267 need_win_cocoa = 'yes'
270 elif winsys == 'eagl'
271 need_win_eagl = 'yes'
272 elif winsys == 'dispmanx'
273 need_win_dispmanx = 'yes'
274 elif winsys == 'viv-fb'
275 need_win_viv_fb = 'yes'
278 elif winsys == 'android'
279 need_win_android = 'yes'
281 error('Unsupported GL winsys provided ' + winsys)
286 gl_include_header = '''
288 # pragma GCC diagnostic push
289 # pragma GCC diagnostic ignored "-Wredundant-decls"
291 #ifndef GL_GLEXT_PROTOTYPES
292 #define GL_GLEXT_PROTOTYPES 1
296 # convoluted way of getting at the subproject taking into account the wrap-mode
297 # so we don't download a subproject unless allowed
298 gl_header_dep = dependency('', fallback : ['gl-headers', 'gl_headers_dummy_dep'],
300 if gl_header_dep.type_name() == 'internal'
301 # this will only contain the includes of headers that are not found
302 compat_includes = subproject('gl-headers').get_variable('compatibility_includes')
307 # Desktop OpenGL checks
308 gl_dep = unneeded_dep
309 glx_dep = unneeded_dep
310 if need_api_opengl != 'no' or need_platform_glx != 'no'
311 if host_system == 'darwin'
312 gl_dep = dependency('appleframeworks', modules : ['OpenGL'], required : false)
314 # override meson's braindead gl detection on osx/windows/etc by forcing pkg-config
315 gl_dep = dependency('gl', method: 'pkg-config', required : false)
318 if not gl_dep.found()
319 if host_system == 'windows'
320 gl_dep = cc.find_library('opengl32', required : false)
322 gl_dep = cc.find_library('GL', required : false)
325 if not cc.has_header('GL/gl.h', include_directories : compat_includes)
326 gl_dep = unneeded_dep
329 if not gl_dep.found() and need_api_opengl == 'yes'
330 error ('Could not find requested OpenGL library')
334 gl_includes += [compat_includes]
338 if host_system == 'darwin'
339 glx_dep = cc.find_library('GL', required : false)
344 if need_api_opengl == 'no'
345 gl_dep = unneeded_dep
347 if need_platform_glx == 'no'
348 glx_dep = unneeded_dep
352 if host_system == 'darwin'
353 opengl_includes += '''
354 #include <OpenGL/OpenGL.h>
355 #include <OpenGL/gl.h>
356 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
357 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
358 # include <OpenGL/gl3.h>
362 opengl_includes += '''
364 # include <windows.h>
367 #if __WIN32__ || _WIN32
368 # include <GL/glext.h>
374 bcm_host_dep = unneeded_dep
375 if need_win_dispmanx != 'no'
377 # Try pkg-config for bcm_host then fallback to find_library to also
378 # support older distribution
379 bcm_host_dep = dependency('bcm_host', required : false)
380 if not bcm_host_dep.found()
381 bcm_host_dep = cc.find_library('bcm_host', required : false)
386 gles2_dep = unneeded_dep
389 if need_api_gles2 != 'no'
390 if host_system == 'ios'
391 gles2_dep = dependency('appleframeworks', modules : ['OpenGLES'], required : false)
393 if bcm_host_dep.found()
394 gles2_dep = dependency('brcmglesv2', required : false)
396 if not gles2_dep.found()
397 gles2_dep = dependency('glesv2', required : false)
401 if not gles2_dep.found()
402 # if host_system == 'windows'
403 # elif host_system == ios
404 # gles2_dep = cc.find_library('GLESv2', required : false)
406 gles2_dep = cc.find_library('GLESv2', required : false)
409 if not cc.has_header('GLES2/gl2.h', include_directories : compat_includes)
410 gles2_dep = unneeded_dep
413 if not gles2_dep.found() and need_api_gles2 == 'yes'
414 error ('Could not find requested OpenGL ES library')
418 gl_includes += [compat_includes]
422 gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', dependencies : gles2_dep, include_directories : compat_includes)
425 if host_system == 'ios'
427 # include <OpenGLES/ES2/gl.h>
428 # include <OpenGLES/ES2/glext.h>
432 gl_includes += [compat_includes]
433 gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', dependencies : gles2_dep, include_directories : compat_includes)
435 # include <GLES3/gl3.h>
436 # include <GLES2/gl2ext.h>'''
439 # include <GLES3/gl3ext.h>'''
443 # include <GLES2/gl2.h>
444 # include <GLES2/gl2ext.h>'''
449 # can we include both gles2 and opengl headers?
450 if gles2_dep.found() and gl_dep.found()
451 gl_include_block = gl_include_header + gles_includes + opengl_includes
452 # TODO: Revert to passing gl_include_block via prefix: once
453 # https://github.com/mesonbuild/meson/issues/2364 is fixed
454 if not cc.compiles(gl_include_block + '\n' + 'void f (void) {}',dependencies : [gles2_dep, gl_dep], include_directories : compat_includes)
455 message ('Cannot include both OpenGL and OpenGL ES headers')
456 if need_api_gles2 != 'yes'
457 gles2_dep = unneeded_dep
458 elif need_api_opengl != 'yes'
459 gl_dep = unneeded_dep
461 error('Both OpenGL and OpenGL ES were requested but cannot be included together')
465 gl_include_block = gl_include_header
467 gl_include_block += gles_includes
470 gl_include_block += opengl_includes
474 gl_lib_deps += gles2_dep
475 glconf.set10('GST_GL_HAVE_GLES2', 1)
477 glconf.set10('GST_GL_HAVE_GLES3', 1)
479 glconf.set10('GST_GL_HAVE_GLES3EXT3_H', 1)
482 enabled_gl_apis += 'gles2'
486 gl_lib_deps += gl_dep
487 glconf.set10('GST_GL_HAVE_OPENGL', 1)
488 enabled_gl_apis += 'gl'
492 egl_dep = unneeded_dep
493 if need_platform_egl != 'no'
494 if bcm_host_dep.found()
495 egl_dep = dependency('brcmegl', required : false)
497 if not egl_dep.found()
498 egl_dep = dependency('egl', required : false)
500 if not egl_dep.found()
501 egl_dep = cc.find_library('EGL', required : false)
504 if egl_dep.found() and not cc.has_header('EGL/egl.h',
505 dependencies : egl_dep,
506 include_directories : compat_includes)
507 egl_dep = unneeded_dep
509 if egl_dep.found() and not cc.has_header('EGL/eglext.h',
510 dependencies : egl_dep,
511 include_directories : compat_includes)
512 egl_dep = unneeded_dep
519 'egl/gstglcontext_egl.c',
520 'egl/gstgldisplay_egl.c',
521 'egl/gstglmemoryegl.c',
522 'egl/gstgldisplay_egl_device.c',
528 'egl/gstgldisplay_egl.h',
529 'egl/gstglmemoryegl.h',
530 'egl/gstgldisplay_egl_device.h',
532 gl_platform_deps += egl_dep
533 glconf.set10('GST_GL_HAVE_PLATFORM_EGL', 1)
535 if cc.has_header('libdrm/drm_fourcc.h')
536 gl_misc_deps += allocators_dep
537 glconf.set10('GST_GL_HAVE_DMABUF', 1)
542 #include <EGL/eglext.h>
544 enabled_gl_platforms += 'egl'
545 elif need_platform_egl == 'yes'
546 error ('Could not find requested EGL library')
551 if need_win_egl == 'yes'
552 if need_platform_egl == 'no'
553 error('Impossible situation requested: Cannot use Winsys egl without EGL support')
554 elif not egl_dep.found()
555 error ('Could not find EGL libraries for Winsys egl')
557 enabled_gl_winsys += 'egl'
562 wayland_client_dep = unneeded_dep
563 wayland_cursor_dep = unneeded_dep
564 wayland_egl_dep = unneeded_dep
565 if need_win_wayland != 'no'
566 if need_win_wayland == 'yes'
567 if need_platform_egl == 'no'
568 error('Impossible situation requested: Cannot use Wayland without EGL support')
571 if not egl_dep.found()
572 if need_win_wayland == 'yes'
573 error ('Could not find EGL libraries for wayland')
575 message ('Could not find EGL libraries for wayland')
578 wayland_client_dep = dependency('wayland-client', version : '>= 1.11', required : false)
579 wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
580 wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
581 wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.15', required : false)
582 wayland_scanner = find_program('wayland-scanner', required: false)
584 if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found() and wayland_protocols_dep.found() and wayland_scanner.found()
585 # Generate the XDG shell interface
586 wayland_protocols_basedir = wayland_protocols_dep.get_pkgconfig_variable('pkgdatadir')
587 xdg_shell_xml_spec = join_paths(wayland_protocols_basedir, 'stable', 'xdg-shell', 'xdg-shell.xml')
588 xdg_shell_header = custom_target('xdg-shell-client-header',
589 command: [ wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@' ],
590 input: xdg_shell_xml_spec,
591 output: 'xdg-shell-client-protocol.h',
593 xdg_shell_code = custom_target('xdg-shell-client-code',
594 command: [ wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@' ],
595 input: xdg_shell_xml_spec,
596 output: 'xdg-shell-client-protocol.c',
599 gl_wayland_sources += [
600 'wayland/gstgldisplay_wayland.c',
603 'wayland/gstglwindow_wayland_egl.c',
604 'wayland/wayland_event_source.c',
608 gl_wayland_headers += [
610 'wayland/gstgldisplay_wayland.h'
612 glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
613 gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
614 enabled_gl_winsys += 'wayland'
616 if need_win_wayland == 'yes'
617 error ('Could not find requested Wayland libraries')
619 wayland_client_dep = unneeded_dep
620 wayland_cursor_dep = unneeded_dep
621 wayland_egl_dep = unneeded_dep
622 wayland_protocols_dep = unneeded_dep
628 if need_platform_glx == 'yes'
629 if need_win_x11 == 'no'
630 error('Impossible situation requested: Cannot use GLX without X11 support')
631 elif need_api_opengl == 'no'
632 error('Impossible situation requested: Cannot use GLX without the OpenGL library')
636 if need_win_x11 != 'no'
637 xcb_dep = dependency('x11-xcb', required : false)
638 if x11_dep.found() and xcb_dep.found()
640 'x11/gstgldisplay_x11.c',
643 'x11/gstglwindow_x11.c',
644 'x11/xcb_event_source.c',
648 'x11/gstgldisplay_x11.h',
650 glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
651 gl_winsys_deps += [x11_dep, xcb_dep]
652 enabled_gl_winsys += 'x11'
654 if need_platform_glx != 'no' and glx_dep.found() and cc.has_function ('glXMakeCurrent', dependencies : glx_dep)
655 glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
657 'x11/gstglcontext_glx.c',
659 # GLX is in the opengl library on linux
660 gl_platform_deps += glx_dep
661 enabled_gl_platforms += 'glx'
663 elif need_win_x11 == 'yes'
664 error ('Could not find requested X11 libraries')
668 if need_win_dispmanx != 'no'
669 if bcm_host_dep.found()
670 if not egl_dep.found()
671 error('dispmanx requires the use of egl')
675 'dispmanx/gstglwindow_dispmanx_egl.c'
678 glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
679 gl_winsys_deps += bcm_host_dep
680 enabled_gl_winsys += 'dispmanx'
681 gl_cpp_args += ['-DUSE_EGL_RPI']
682 elif need_win_dispmanx == 'yes'
683 error('Could not find dispmanx libraries')
688 if need_platform_wgl == 'yes'
689 if need_win_win32 == 'no'
690 error('Impossible situation requested: Cannot use WGL without the win32 window system')
694 if host_system == 'windows' and need_win_win32 != 'no'
695 gdi_dep = cc.find_library('gdi32', required : false)
698 have_egl_win32 = false
699 if need_platform_wgl != 'no'
700 wglext_h = cc.has_header('GL/wglext.h',
701 prefix : '''#include <windows.h>
702 #include <GL/gl.h>''',
703 include_directories : compat_includes)
704 have_wgl = wglext_h and gl_dep.found()
707 have_egl_win32 = enabled_gl_platforms.contains('egl') and gles2_dep.found()
708 if have_wgl or have_egl_win32
709 gl_includes += [compat_includes]
710 gl_platform_deps += gdi_dep
712 'win32/gstglwindow_win32.c',
714 enabled_gl_winsys += 'win32'
715 gl_winsys_deps += gdi_dep
716 glconf.set('GST_GL_HAVE_WINDOW_WIN32', 1)
721 'wgl/gstglcontext_wgl.c',
723 enabled_gl_platforms += 'wgl'
724 glconf.set('GST_GL_HAVE_PLATFORM_WGL', 1)
730 if need_win_winrt != 'no' and host_system == 'windows'
731 if need_win_winrt == 'yes' and not enabled_gl_platforms.contains('egl')
732 error('Impossible situation requested: Cannot use WinRT ANGLE without EGL support')
736 windows_graphics_h = cc.has_header('windows.graphics.h')
737 windows_app_dep = cc.find_library('WindowsApp', required: false)
738 runtimeobject_lib = cc.find_library('runtimeobject', required: false)
740 if windows_graphics_h and windows_app_dep.found() and runtimeobject_lib.found()
741 enabled_gl_winsys += 'winrt'
742 glconf.set10('GST_GL_HAVE_WINDOW_WINRT', 1)
744 'winrt/gstglwindow_winrt_egl.cpp'
746 gl_winsys_deps += runtimeobject_lib
747 elif need_win_winrt == 'yes'
748 error('WinRT is enabled, but headers/libraries were not found')
750 elif need_win_winrt == 'yes'
751 error('WinRT ANGLE is enabled, but EGL was not found')
753 message('WinRT ANGLE disabled because EGL was not found')
757 if ['darwin', 'ios'].contains(host_system)
759 error('No ObjC compiler found')
762 objc = meson.get_compiler('objc')
763 if not objc.has_argument('-fobjc-arc')
764 error('ARC is required for building')
767 gl_objc_args += ['-fobjc-arc']
771 if need_platform_cgl == 'yes'
772 if need_win_cocoa == 'no'
773 error('Impossible situation requested: Cannot use CGL without Cocoa support')
774 elif need_api_opengl == 'no'
775 error('Impossible situation requested: Cannot use CGL without the OpenGL library')
777 elif need_platform_cgl == 'no' and need_win_cocoa == 'yes'
778 error('Impossible situation requested: Cannot use Cocoa without CGL support')
781 if host_system == 'darwin'
782 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
783 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
784 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
786 if need_platform_cgl != 'no'
787 if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
788 gl_platform_deps += [quartzcore_dep, corefoundation_dep, foundation_dep]
789 enabled_gl_platforms += 'cgl'
790 glconf.set10('GST_GL_HAVE_PLATFORM_CGL', 1)
792 if need_win_cocoa != 'no'
793 cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : false)
796 'cocoa/gstglcaopengllayer.m',
797 'cocoa/gstglcontext_cocoa.m',
798 'cocoa/gstgldisplay_cocoa.m',
799 'cocoa/gstglwindow_cocoa.m'
801 gl_winsys_deps += cocoa_dep
802 enabled_gl_winsys += 'cocoa'
803 glconf.set10('GST_GL_HAVE_WINDOW_COCOA', 1)
804 elif need_win_cocoa == 'yes'
805 error('Could not find Cocoa')
808 elif need_platform_cgl == 'yes'
809 error('Could not find CGL dependencies')
814 if need_platform_eagl == 'yes'
815 if host_system != 'ios'
816 error('Can only use EAGL on iOS')
818 if need_win_eagl == 'no'
819 error('Impossible situation requested: Cannot use EAGL platform without the EAGL window system')
820 elif need_api_gles == 'no'
821 error('Impossible situation requested: Cannot use EAGL platform without the GLES library')
823 elif need_platform_eagl == 'no' and need_win_eagl == 'yes'
824 error('Impossible situation requested: Cannot use EAGL window system without the EAGL platform')
827 if host_system == 'ios' and need_platform_eagl != 'no' and need_win_eagl != 'no'
828 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
829 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
830 coregraphics_dep = dependency('appleframeworks', modules : ['CoreGraphics'], required : false)
831 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
832 uikit_dep = dependency('appleframeworks', modules : ['UIkit'], required : false)
834 if foundation_dep.found() and corefoundation_dep.found() and coregraphics_dep.found() and quartzcore_dep.found() and uikit_dep.found()
835 gl_platform_deps += [
843 'eagl/gstglcontext_eagl.m',
844 'eagl/gstglwindow_eagl.m',
846 enabled_gl_winsys += 'eagl'
847 enabled_gl_platforms += 'eagl'
848 glconf.set('GST_GL_HAVE_WINDOW_EAGL', 1)
849 glconf.set('GST_GL_HAVE_PLATFORM_EAGL', 1)
850 elif need_platform_eagl == 'yes' or need_win_eagl == 'yes'
851 error('Could not find dependencies for EAGL')
856 gbm_gudev_dep = unneeded_dep
857 gbm_libdrm_dep = unneeded_dep
858 gbm_dep = unneeded_dep
859 if need_win_gbm != 'no'
860 if need_win_gbm == 'yes'
861 if need_platform_egl == 'no'
862 error('Impossible situation requested: Cannot use GBM without EGL support')
866 gbm_gudev_dep = dependency('gudev-1.0', version : '>=147', required : false)
867 gbm_libdrm_dep = dependency('libdrm', version : '>= 2.4.55', required : false)
868 gbm_dep = dependency('gbm', required : false)
869 if egl_dep.found() and gbm_gudev_dep.found() and gbm_libdrm_dep.found() and gbm_dep.found()
871 'gbm/gstgldisplay_gbm.c',
872 'gbm/gstgl_gbm_utils.c',
873 'gbm/gstglwindow_gbm_egl.c',
875 enabled_gl_winsys += 'gbm'
876 gl_winsys_deps += [gbm_gudev_dep, gbm_libdrm_dep, gbm_dep]
877 glconf.set('GST_GL_HAVE_WINDOW_GBM', 1)
879 if need_win_gbm == 'yes'
880 error ('Could not find requested GBM libraries')
882 gbm_gudev_dep = unneeded_dep
883 gbm_libdrm_dep = unneeded_dep
884 gbm_dep = unneeded_dep
888 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
889 if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
890 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
891 enabled_gl_winsys += 'viv-fb'
892 glconf.set10('GST_GL_HAVE_WINDOW_VIV_FB', 1)
893 glconf.set10('GST_GL_HAVE_VIV_DIRECTVIV', 1)
895 'viv-fb/gstgldisplay_viv_fb.c',
896 'viv-fb/gstglwindow_viv_fb_egl.c',
898 gl_cpp_args += ['-DEGL_API_FB']
903 if need_win_android == 'yes'
904 if need_platform_egl == 'no'
905 error('Impossible situation requested: Cannot build for Android without EGL')
906 elif need_api_gles2 == 'no'
907 error('Impossible situation requested: Cannot build for Android without GLES2 support')
908 elif host_system != 'android'
909 error('Impossible situation requested: Cannot build for Android without an android system')
913 if host_system == 'android' and need_win_android != 'no' and need_platform_egl != 'no'
914 if gles2_dep.found() and egl_dep.found()
915 enabled_gl_winsys += ['android']
916 glconf.set10('GST_GL_HAVE_WINDOW_ANDROID', 1)
918 'android/gstglwindow_android_egl.c'
923 # TODO: Add rest of gl config here.
924 # iOS, specific support
927 if enabled_gl_apis.length() == 0
928 message('No OpenGL API libraries found or requested')
931 if enabled_gl_platforms.length() == 0
932 message('No OpenGL Platforms found or requested')
935 if enabled_gl_winsys.length() == 0
936 message('No OpenGL Window systems found or requested')
940 gstgl_dep = dependency('', required : false)
941 gstglproto_dep = dependency('', required : false)
942 gstglx11_dep = dependency('', required : false)
943 gstglwayland_dep = dependency('', required : false)
944 gstglegl_dep = dependency('', required : false)
947 # find some types that may or may not be defined
948 if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
949 glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
951 if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
952 glconf.set('GST_GL_HAVE_GLCHAR', 1)
954 if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
955 glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
957 if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
958 glconf.set('GST_GL_HAVE_GLINTPTR', 1)
960 if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
961 glconf.set('GST_GL_HAVE_GLSYNC', 1)
963 if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
964 glconf.set('GST_GL_HAVE_GLUINT64', 1)
966 if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
967 glconf.set('GST_GL_HAVE_GLINT64', 1)
969 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)
970 glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
972 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)
973 glconf.set('GST_GL_HAVE_EGLUINT64KHR', 1)
976 summary('GL api', enabled_gl_apis, list_sep: ', ')
977 summary('GL platform', enabled_gl_platforms, list_sep: ', ')
978 summary('GL winsys', enabled_gl_winsys, list_sep: ', ')
980 install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
981 install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
983 configure_file(input : 'gstglconfig.h.meson',
984 output : 'gstglconfig.h',
985 install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
986 configuration : glconf)
988 glib_mkenums = find_program('glib-mkenums')
989 mkenums = find_program('gl_mkenum.py')
990 gl_enumtypes_h = custom_target('gstglenumtypes_h',
991 output : 'gl-enumtypes.h',
992 input : gir_gl_headers,
994 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/gl/'),
995 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
997 gl_enumtypes_c = custom_target('gstglenumtypes_c',
998 output : 'gl-enumtypes.c',
999 input : gir_gl_headers,
1000 depends : [gl_enumtypes_h],
1001 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1002 gen_sources = [gl_enumtypes_h]
1004 gstgl = library('gstgl-' + api_version,
1005 gl_sources, gl_egl_sources, gl_x11_sources, gl_wayland_sources, gl_priv_sources, gl_enumtypes_c, gl_enumtypes_h,
1006 c_args : gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL'],
1007 cpp_args : gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL'],
1008 objc_args : gst_plugins_base_args + gl_cpp_args + gl_objc_args + ['-DBUILDING_GST_GL'],
1009 include_directories : [configinc, libsinc, gl_includes],
1010 version : libversion,
1011 soversion : soversion,
1012 darwin_versions : osxversion,
1014 dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
1015 gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps],
1016 # don't confuse EGL/egl.h with gst-libs/gl/egl/egl.h on case-insensitive file systems
1017 implicit_include_directories : false)
1019 pkgconfig.generate(gstgl,
1020 libraries : [gstvideo, gst_base_dep, gst_dep],
1021 variables : pkgconfig_variables + [
1022 'gl_platforms=' + ' '.join(enabled_gl_platforms),
1023 'gl_winsys=' + ' '.join(enabled_gl_winsys),
1024 'gl_apis=' + ' '.join(enabled_gl_apis),
1026 subdirs : pkgconfig_subdirs,
1027 extra_cflags : ['-I${libdir}/gstreamer-1.0/include'],
1028 name : 'gstreamer-gl-1.0',
1029 description : 'Streaming media framework, OpenGL plugins libraries',
1033 libraries : [gstgl, gl_lib_deps],
1034 subdirs : pkgconfig_subdirs,
1035 name : 'gstreamer-gl-prototypes-1.0',
1036 description : 'Streaming media framework, OpenGL plugins libraries (OpenGL Prototypes)',
1040 gl_gir = gnome.generate_gir(gstgl,
1041 sources : gl_sources + [gl_enumtypes_h] + [gl_enumtypes_c] + gir_gl_headers,
1042 namespace : 'GstGL',
1043 nsversion : api_version,
1044 identifier_prefix : 'Gst',
1045 symbol_prefix : 'gst',
1046 export_packages : 'gstreamer-gl-1.0',
1047 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1049 extra_args : gir_init_section + ['--c-include=gst/gl/gl.h'],
1050 dependencies : [video_dep, gst_dep, gst_base_dep]
1052 gen_sources += gl_gir
1055 gstgl_dep = declare_dependency(link_with : gstgl,
1056 include_directories : [libsinc, compat_includes],
1057 sources: gen_sources,
1058 dependencies : [video_dep, gst_base_dep])
1059 gstglproto_dep = declare_dependency(dependencies : [gstgl_dep] + gl_lib_deps)
1060 meson.override_dependency('gstreamer-gl-1.0', gstgl_dep)
1061 meson.override_dependency('gstreamer-gl-prototypes-1.0', gstglproto_dep)
1063 if gl_x11_headers.length() > 0
1064 install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
1066 libraries : [gstgl],
1067 requires: ['x11-xcb'],
1068 subdirs : pkgconfig_subdirs,
1069 name : 'gstreamer-gl-x11-1.0',
1070 description : 'Streaming media framework, OpenGL plugins libraries (X11 specifics)',
1074 gl_x11_gir = gnome.generate_gir(gstgl,
1075 sources : gl_x11_sources + gl_x11_headers,
1076 namespace : 'GstGLX11',
1077 nsversion : api_version,
1078 identifier_prefix : 'Gst',
1079 symbol_prefix : 'gst',
1080 export_packages : 'gstreamer-gl-x11-1.0',
1081 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', gl_gir[0]],
1083 extra_args : gir_init_section + ['--c-include=gst/gl/x11/x11.h'],
1084 dependencies : [video_dep, gst_dep, gst_base_dep]
1087 gstglx11_dep = declare_dependency(dependencies : [gstgl_dep],
1088 sources : gl_x11_gir)
1089 meson.override_dependency('gstreamer-gl-x11-1.0', gstglx11_dep)
1092 if gl_wayland_headers.length() > 0
1093 install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
1095 libraries : [gstgl],
1096 requires: ['wayland-egl', 'wayland-client'],
1097 subdirs : pkgconfig_subdirs,
1098 name : 'gstreamer-gl-wayland-1.0',
1099 description : 'Streaming media framework, OpenGL plugins libraries (Wayland specifics)',
1103 gl_wayland_gir = gnome.generate_gir(gstgl,
1104 sources : gl_wayland_sources + gl_wayland_headers,
1105 namespace : 'GstGLWayland',
1106 nsversion : api_version,
1107 identifier_prefix : 'Gst',
1108 symbol_prefix : 'gst',
1109 export_packages : 'gstreamer-gl-wayland-1.0',
1110 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', gl_gir[0]],
1112 extra_args : gir_init_section + ['--c-include=gst/gl/wayland/wayland.h'],
1113 dependencies : [video_dep, gst_dep, gst_base_dep]
1116 gstglwayland_dep = declare_dependency(dependencies : [gstgl_dep],
1117 sources : gl_wayland_gir)
1118 meson.override_dependency('gstreamer-gl-wayland-1.0', gstglwayland_dep)
1121 if gl_egl_headers.length() > 0
1122 install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
1124 libraries : [gstgl, egl_dep],
1125 subdirs : pkgconfig_subdirs,
1126 name : 'gstreamer-gl-egl-1.0',
1127 description : 'Streaming media framework, OpenGL plugins libraries (EGL specifics)',
1131 gl_egl_gir = gnome.generate_gir(gstgl,
1132 sources : gl_egl_sources + gl_egl_headers,
1133 namespace : 'GstGLEGL',
1134 nsversion : api_version,
1135 identifier_prefix : 'Gst',
1136 symbol_prefix : 'gst',
1137 export_packages : 'gstreamer-gl-egl-1.0',
1138 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', gl_gir[0]],
1140 extra_args : gir_init_section + ['--c-include=gst/gl/egl/egl.h'],
1141 dependencies : [video_dep, gst_dep, gst_base_dep]
1144 gstglegl_dep = declare_dependency(dependencies : [gstgl_dep],
1145 sources : gl_egl_gir)
1146 meson.override_dependency('gstreamer-gl-egl-1.0', gstglegl_dep)
1149 elif get_option('gl').enabled()
1150 error('GStreamer OpenGL integration required via options, but needed dependencies not found.')