1 gstgl_dep = dependency('', required : false)
2 gstglproto_dep = dependency('', required : false)
3 gstglx11_dep = dependency('', required : false)
4 gstglwayland_dep = dependency('', required : false)
5 gstglegl_dep = dependency('', required : false)
7 if get_option('gl').disabled()
8 message('GStreamer OpenGL integration disabled via options.')
18 'gstglcolorconvert.c',
22 'gstglcontextconfig.c',
23 'gstglcontextquirks.c',
32 'gstgloverlaycompositor.c',
34 'gstglrenderbuffer.c',
36 'gstglshaderstrings.c',
48 gir_gl_headers = files([
59 'gstglcolorconvert.h',
61 'gstglcontextconfig.h',
70 'gstgloverlaycompositor.h',
72 'gstglrenderbuffer.h',
74 'gstglshaderstrings.h',
84 gl_headers = gir_gl_headers + files([
88 gl_prototype_headers = files([
89 'glprototypes/all_functions.h',
90 'glprototypes/base.h',
91 'glprototypes/buffer_storage.h',
92 'glprototypes/blending.h',
93 'glprototypes/buffers.h',
94 'glprototypes/debug.h',
95 'glprototypes/eglimage.h',
97 'glprototypes/fixedfunction.h',
98 'glprototypes/gles.h',
99 'glprototypes/gstgl_compat.h',
100 'glprototypes/gstgl_gles2compat.h',
101 'glprototypes/opengl.h',
102 'glprototypes/query.h',
103 'glprototypes/shaders.h',
104 'glprototypes/sync.h',
105 'glprototypes/vao.h',
110 gl_wayland_sources = []
111 gl_wayland_headers = []
115 glconf = configuration_data()
117 'GST_GL_HAVE_OPENGL',
120 'GST_GL_HAVE_GLES3EXT3_H',
122 'GST_GL_HAVE_WINDOW_X11',
123 'GST_GL_HAVE_WINDOW_COCOA',
124 'GST_GL_HAVE_WINDOW_WIN32',
125 'GST_GL_HAVE_WINDOW_WINRT',
126 'GST_GL_HAVE_WINDOW_WAYLAND',
127 'GST_GL_HAVE_WINDOW_ANDROID',
128 'GST_GL_HAVE_WINDOW_DISPMANX',
129 'GST_GL_HAVE_WINDOW_EAGL',
130 'GST_GL_HAVE_WINDOW_VIV_FB',
131 'GST_GL_HAVE_WINDOW_GBM',
133 'GST_GL_HAVE_PLATFORM_EGL',
134 'GST_GL_HAVE_PLATFORM_GLX',
135 'GST_GL_HAVE_PLATFORM_WGL',
136 'GST_GL_HAVE_PLATFORM_CGL',
137 'GST_GL_HAVE_PLATFORM_EAGL',
139 'GST_GL_HAVE_DMABUF',
140 'GST_GL_HAVE_VIV_DIRECTVIV',
142 'GST_GL_HAVE_GLEGLIMAGEOES',
143 'GST_GL_HAVE_GLCHAR',
144 'GST_GL_HAVE_GLSIZEIPTR',
145 'GST_GL_HAVE_GLINTPTR',
146 'GST_GL_HAVE_GLSYNC',
147 'GST_GL_HAVE_GLUINT64',
148 'GST_GL_HAVE_GLINT64',
149 'GST_GL_HAVE_EGLATTRIB',
150 'GST_GL_HAVE_EGLUINT64KHR',
153 foreach option : glconf_options
154 glconf.set(option, 0)
157 unneeded_dep = dependency('', required : false)
158 if unneeded_dep.found()
159 error ('Found unfindable dependency')
162 # OpenGL/GLES2 libraries
164 # GL platform - EGL, GLX, CGL, WGL, etc
165 gl_platform_deps = []
166 # GL winsys - wayland, X11, Cocoa, win32, etc
168 # other things we need.
170 # Other preprocessor arguments
176 enabled_gl_platforms = []
177 enabled_gl_winsys = []
179 # parse provided options
180 libegl_module_name = get_option('egl_module_name')
181 if libegl_module_name != ''
182 gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)]
184 libgles2_module_name = get_option('gles2_module_name')
185 if libgles2_module_name != ''
186 gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)]
188 libgl_module_name = get_option('opengl_module_name')
189 if libgl_module_name != ''
190 gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)]
193 gl_apis = get_option('gl_api')
194 if gl_apis.contains('auto')
195 need_api_opengl = 'auto'
196 need_api_gles2 = 'auto'
198 need_api_opengl = 'no'
199 need_api_gles2 = 'no'
200 foreach api : gl_apis
202 need_api_opengl = 'yes'
204 need_api_gles2 = 'yes'
206 error('Unsupported GL api provided ' + api)
211 gl_platforms = get_option('gl_platform')
212 if gl_platforms.contains('auto')
213 need_platform_egl = 'auto'
214 need_platform_glx = 'auto'
215 need_platform_cgl = 'auto'
216 need_platform_wgl = 'auto'
217 need_platform_eagl = 'auto'
219 need_platform_egl = 'no'
220 need_platform_glx = 'no'
221 need_platform_cgl = 'no'
222 need_platform_wgl = 'no'
223 need_platform_eagl = 'no'
224 foreach platform : gl_platforms
226 need_platform_egl = 'yes'
227 elif platform == 'glx'
228 need_platform_glx = 'yes'
229 elif platform == 'cgl'
230 need_platform_cgl = 'yes'
231 elif platform == 'wgl'
232 need_platform_wgl = 'yes'
233 elif platform == 'eagl'
234 need_platform_eagl = 'yes'
236 error('Unsupported GL platform provided ' + platform)
241 gl_winsys = get_option('gl_winsys')
242 if gl_winsys.contains('auto')
243 need_win_x11 = 'auto'
244 need_win_wayland = 'auto'
245 need_win_win32 = 'auto'
246 need_win_winrt = 'auto'
247 need_win_cocoa = 'auto'
248 need_win_egl = 'auto'
249 need_win_eagl = 'auto'
250 need_win_dispmanx = 'auto'
251 need_win_viv_fb = 'auto'
252 need_win_gbm = 'auto'
253 need_win_android = 'auto'
256 need_win_wayland = 'no'
257 need_win_win32 = 'no'
258 need_win_winrt = 'no'
259 need_win_cocoa = 'no'
262 need_win_dispmanx = 'no'
263 need_win_viv_fb = 'no'
265 need_win_android = 'no'
266 foreach winsys : gl_winsys
269 elif winsys == 'wayland'
270 need_win_wayland = 'yes'
271 elif winsys == 'win32'
272 need_win_win32 = 'yes'
273 elif winsys == 'winrt'
274 need_win_winrt = 'yes'
275 elif winsys == 'cocoa'
276 need_win_cocoa = 'yes'
279 elif winsys == 'eagl'
280 need_win_eagl = 'yes'
281 elif winsys == 'dispmanx'
282 need_win_dispmanx = 'yes'
283 elif winsys == 'viv-fb'
284 need_win_viv_fb = 'yes'
287 elif winsys == 'android'
288 need_win_android = 'yes'
290 error('Unsupported GL winsys provided ' + winsys)
295 gl_include_header = '''
297 # pragma GCC diagnostic push
298 # pragma GCC diagnostic ignored "-Wredundant-decls"
300 #ifndef GL_GLEXT_PROTOTYPES
301 #define GL_GLEXT_PROTOTYPES 1
305 # convoluted way of getting at the subproject taking into account the wrap-mode
306 # so we don't download a subproject unless allowed
307 gl_header_dep = dependency('', fallback : ['gl-headers', 'gl_headers_dummy_dep'],
309 if gl_header_dep.type_name() == 'internal'
310 # this will only contain the includes of headers that are not found
311 compat_includes = subproject('gl-headers').get_variable('compatibility_includes')
316 # Desktop OpenGL checks
317 gl_dep = unneeded_dep
318 glx_dep = unneeded_dep
320 # (GLVND) OpenGL (without GLX) headers and interface
321 if need_api_opengl != 'no'
322 gl_dep = dependency('opengl', method: 'pkg-config', required : false)
325 # non-GLVND aka Legacy OpenGL
326 if need_api_opengl != 'no' and not gl_dep.found()
327 if host_system == 'darwin'
328 gl_dep = dependency('appleframeworks', modules : ['OpenGL'], required : false)
330 # override meson's braindead gl detection on osx/windows/etc by forcing pkg-config
331 gl_dep = dependency('gl', method: 'pkg-config', required : false)
334 if not gl_dep.found()
335 if host_system == 'windows'
336 gl_dep = cc.find_library('opengl32', required : false)
338 gl_dep = cc.find_library('GL', required : false)
341 if not cc.has_header('GL/gl.h', include_directories : compat_includes)
342 gl_dep = unneeded_dep
345 if not gl_dep.found() and need_api_opengl == 'yes'
346 error ('Could not find requested OpenGL library')
350 gl_includes += [compat_includes]
355 if need_platform_glx != 'no'
356 # (GLVND) GLX library and headers.
357 glx_dep = dependency('glx', method: 'pkg-config', required : false)
359 if not glx_dep.found()
360 if host_system == 'darwin'
361 glx_dep = cc.find_library('GL', required : false)
364 elif need_platform_glx == 'yes'
365 error ('Could not find requested GLX library')
370 if need_api_opengl != 'no'
372 if host_system == 'darwin'
373 opengl_includes += '''
374 #if !defined(MAC_OS_X_VERSION_MAX_ALLOWED) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1014
375 # define GL_SILENCE_DEPRECATION
377 #include <OpenGL/OpenGL.h>
378 #include <OpenGL/gl.h>
379 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
380 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
381 # include <OpenGL/gl3.h>
385 opengl_includes += '''
387 # include <windows.h>
390 #if __WIN32__ || _WIN32
391 # include <GL/glext.h>
397 bcm_host_dep = unneeded_dep
398 if need_win_dispmanx != 'no'
400 # Try pkg-config for bcm_host then fallback to find_library to also
401 # support older distribution
402 bcm_host_dep = dependency('bcm_host', required : false)
403 if not bcm_host_dep.found()
404 bcm_host_dep = cc.find_library('bcm_host', required : false)
409 gles2_dep = unneeded_dep
412 if need_api_gles2 != 'no'
413 if host_system == 'ios'
414 gles2_dep = dependency('appleframeworks', modules : ['OpenGLES'], required : false)
416 if bcm_host_dep.found()
417 gles2_dep = dependency('brcmglesv2', required : false)
419 if not gles2_dep.found()
420 gles2_dep = dependency('glesv2', required : false)
424 if not gles2_dep.found()
425 # if host_system == 'windows'
426 # elif host_system == ios
427 # gles2_dep = cc.find_library('GLESv2', required : false)
429 gles2_dep = cc.find_library('GLESv2', required : false)
432 if not cc.has_header('GLES2/gl2.h', include_directories : compat_includes)
433 gles2_dep = unneeded_dep
436 if not gles2_dep.found() and need_api_gles2 == 'yes'
437 error ('Could not find requested OpenGL ES library')
441 gl_includes += [compat_includes]
445 gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', dependencies : gles2_dep, include_directories : compat_includes)
448 if host_system == 'ios'
450 # include <OpenGLES/ES2/gl.h>
451 # include <OpenGLES/ES2/glext.h>
455 gl_includes += [compat_includes]
456 gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', dependencies : gles2_dep, include_directories : compat_includes)
458 # include <GLES3/gl3.h>
459 # include <GLES2/gl2ext.h>'''
462 # include <GLES3/gl3ext.h>'''
466 # include <GLES2/gl2.h>
467 # include <GLES2/gl2ext.h>'''
472 # can we include both gles2 and opengl headers?
473 if gles2_dep.found() and gl_dep.found()
474 gl_include_block = gl_include_header + gles_includes + opengl_includes
475 # TODO: Revert to passing gl_include_block via prefix: once
476 # https://github.com/mesonbuild/meson/issues/2364 is fixed
477 if not cc.compiles(gl_include_block + '\n' + 'void f (void) {}',dependencies : [gles2_dep, gl_dep], include_directories : compat_includes)
478 message ('Cannot include both OpenGL and OpenGL ES headers')
479 if need_api_gles2 != 'yes'
480 gles2_dep = unneeded_dep
481 elif need_api_opengl != 'yes'
482 gl_dep = unneeded_dep
484 error('Both OpenGL and OpenGL ES were requested but cannot be included together')
488 gl_include_block = gl_include_header
490 gl_include_block += gles_includes
493 gl_include_block += opengl_includes
497 gl_lib_deps += gles2_dep
498 glconf.set('GST_GL_HAVE_GLES2', 1)
500 glconf.set('GST_GL_HAVE_GLES3',1)
502 glconf.set('GST_GL_HAVE_GLES3EXT3_H', 1)
505 enabled_gl_apis += 'gles2'
509 gl_lib_deps += gl_dep
510 glconf.set('GST_GL_HAVE_OPENGL', 1)
511 enabled_gl_apis += 'gl'
515 egl_dep = unneeded_dep
516 if need_platform_egl != 'no'
517 if bcm_host_dep.found()
518 egl_dep = dependency('brcmegl', required : false)
520 if not egl_dep.found()
521 egl_dep = dependency('egl', required : false)
523 if not egl_dep.found()
524 egl_dep = cc.find_library('EGL', required : false)
527 if egl_dep.found() and not cc.has_header('EGL/egl.h',
528 dependencies : egl_dep,
529 include_directories : compat_includes)
530 egl_dep = unneeded_dep
532 if egl_dep.found() and not cc.has_header('EGL/eglext.h',
533 dependencies : egl_dep,
534 include_directories : compat_includes)
535 egl_dep = unneeded_dep
539 gl_egl_sources += files([
542 'egl/gstglcontext_egl.c',
543 'egl/gstgldisplay_egl.c',
544 'egl/gstglmemoryegl.c',
545 'egl/gstgldisplay_egl_device.c',
547 gl_egl_headers += files([
551 'egl/gstgldisplay_egl.h',
552 'egl/gstglmemoryegl.h',
553 'egl/gstgldisplay_egl_device.h',
555 gl_platform_deps += egl_dep
556 glconf.set('GST_GL_HAVE_PLATFORM_EGL', 1)
558 if cc.has_header('libdrm/drm_fourcc.h')
559 gl_misc_deps += allocators_dep
560 glconf.set('GST_GL_HAVE_DMABUF', 1)
565 #include <EGL/eglext.h>
567 enabled_gl_platforms += 'egl'
568 elif need_platform_egl == 'yes'
569 error ('Could not find requested EGL library')
574 if need_win_egl == 'yes'
575 if need_platform_egl == 'no'
576 error('Impossible situation requested: Cannot use Winsys egl without EGL support')
577 elif not egl_dep.found()
578 error ('Could not find EGL libraries for Winsys egl')
580 enabled_gl_winsys += 'egl'
585 wayland_client_dep = unneeded_dep
586 wayland_cursor_dep = unneeded_dep
587 wayland_egl_dep = unneeded_dep
588 if need_win_wayland != 'no'
589 if need_win_wayland == 'yes'
590 if need_platform_egl == 'no'
591 error('Impossible situation requested: Cannot use Wayland without EGL support')
594 if not egl_dep.found()
595 if need_win_wayland == 'yes'
596 error ('Could not find EGL libraries for wayland')
598 message ('Could not find EGL libraries for wayland')
601 wayland_client_dep = dependency('wayland-client', version : '>= 1.11', required : false)
602 wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
603 wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
604 wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.15', required : false)
605 wayland_scanner = find_program('wayland-scanner', required: false)
607 if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found() and wayland_protocols_dep.found() and wayland_scanner.found()
608 # Generate the XDG shell interface
609 wayland_protocols_basedir = wayland_protocols_dep.get_variable('pkgdatadir')
610 xdg_shell_xml_spec = join_paths(wayland_protocols_basedir, 'stable', 'xdg-shell', 'xdg-shell.xml')
611 xdg_shell_header = custom_target('xdg-shell-client-header',
612 command: [ wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@' ],
613 input: xdg_shell_xml_spec,
614 output: 'xdg-shell-client-protocol.h',
616 xdg_shell_code = custom_target('xdg-shell-client-code',
617 command: [ wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@' ],
618 input: xdg_shell_xml_spec,
619 output: 'xdg-shell-client-protocol.c',
622 gl_wayland_sources += files([
623 'wayland/gstgldisplay_wayland.c',
626 'wayland/gstglwindow_wayland_egl.c',
627 'wayland/wayland_event_source.c',
631 gl_wayland_headers += files([
633 'wayland/gstgldisplay_wayland.h'
635 glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
636 gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
637 enabled_gl_winsys += 'wayland'
639 if need_win_wayland == 'yes'
640 error ('Could not find requested Wayland libraries')
642 wayland_client_dep = unneeded_dep
643 wayland_cursor_dep = unneeded_dep
644 wayland_egl_dep = unneeded_dep
645 wayland_protocols_dep = unneeded_dep
651 if need_platform_glx == 'yes'
652 if need_win_x11 == 'no'
653 error('Impossible situation requested: Cannot use GLX without X11 support')
654 elif need_api_opengl == 'no'
655 error('Impossible situation requested: Cannot use GLX without the OpenGL library')
659 xcb_dep = unneeded_dep
660 if need_win_x11 != 'no'
661 xcb_dep = dependency('x11-xcb', required : false)
662 if x11_dep.found() and xcb_dep.found()
663 gl_x11_sources += files([
664 'x11/gstgldisplay_x11.c',
667 'x11/gstglwindow_x11.c',
668 'x11/xcb_event_source.c',
670 gl_x11_headers += files([
672 'x11/gstgldisplay_x11.h',
674 glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
675 gl_winsys_deps += [x11_dep, xcb_dep]
676 enabled_gl_winsys += 'x11'
678 if need_platform_glx != 'no' and glx_dep.found() and cc.has_function ('glXMakeCurrent', dependencies : glx_dep)
679 glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
681 'x11/gstglcontext_glx.c',
683 # GLX is in the opengl library on linux
684 gl_platform_deps += glx_dep
685 enabled_gl_platforms += 'glx'
687 elif need_win_x11 == 'yes'
688 error ('Could not find requested X11 libraries')
692 if need_win_dispmanx != 'no'
693 if bcm_host_dep.found()
694 if not egl_dep.found()
695 error('dispmanx requires the use of egl')
699 'dispmanx/gstglwindow_dispmanx_egl.c'
702 glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
703 gl_winsys_deps += bcm_host_dep
704 enabled_gl_winsys += 'dispmanx'
705 gl_cpp_args += ['-DUSE_EGL_RPI']
706 elif need_win_dispmanx == 'yes'
707 error('Could not find dispmanx libraries')
712 if need_platform_wgl == 'yes'
713 if need_win_win32 == 'no'
714 error('Impossible situation requested: Cannot use WGL without the win32 window system')
718 if host_system == 'windows' and need_win_win32 != 'no'
719 gdi_dep = cc.find_library('gdi32', required : false)
722 have_egl_win32 = false
723 if need_platform_wgl != 'no'
724 wglext_h = cc.has_header('GL/wglext.h',
725 prefix : '''#include <windows.h>
726 #include <GL/gl.h>''',
727 include_directories : compat_includes)
728 have_wgl = wglext_h and gl_dep.found()
731 have_egl_win32 = enabled_gl_platforms.contains('egl') and gles2_dep.found()
732 if have_wgl or have_egl_win32
733 gl_includes += [compat_includes]
734 gl_platform_deps += gdi_dep
736 'win32/gstglwindow_win32.c',
738 enabled_gl_winsys += 'win32'
739 gl_winsys_deps += gdi_dep
740 glconf.set('GST_GL_HAVE_WINDOW_WIN32', 1)
745 'wgl/gstglcontext_wgl.c',
747 enabled_gl_platforms += 'wgl'
748 glconf.set('GST_GL_HAVE_PLATFORM_WGL', 1)
754 if need_win_winrt != 'no' and host_system == 'windows'
755 if need_win_winrt == 'yes' and not enabled_gl_platforms.contains('egl')
756 error('Impossible situation requested: Cannot use WinRT ANGLE without EGL support')
760 windows_graphics_h = cc.has_header('windows.graphics.h')
761 windows_app_dep = cc.find_library('WindowsApp', required: false)
762 runtimeobject_lib = cc.find_library('runtimeobject', required: false)
764 if windows_graphics_h and windows_app_dep.found() and runtimeobject_lib.found()
765 enabled_gl_winsys += 'winrt'
766 glconf.set('GST_GL_HAVE_WINDOW_WINRT', 1)
768 'winrt/gstglwindow_winrt_egl.cpp'
770 gl_winsys_deps += runtimeobject_lib
771 elif need_win_winrt == 'yes'
772 error('WinRT is enabled, but headers/libraries were not found')
774 elif need_win_winrt == 'yes'
775 error('WinRT ANGLE is enabled, but EGL was not found')
777 message('WinRT ANGLE disabled because EGL was not found')
781 if ['darwin', 'ios'].contains(host_system)
783 error('No ObjC compiler found')
786 objc = meson.get_compiler('objc')
787 if not objc.has_argument('-fobjc-arc')
788 error('ARC is required for building')
791 gl_objc_args += ['-fobjc-arc']
795 if need_platform_cgl == 'yes'
796 if need_win_cocoa == 'no'
797 error('Impossible situation requested: Cannot use CGL without Cocoa support')
798 elif need_api_opengl == 'no'
799 error('Impossible situation requested: Cannot use CGL without the OpenGL library')
801 elif need_platform_cgl == 'no' and need_win_cocoa == 'yes'
802 error('Impossible situation requested: Cannot use Cocoa without CGL support')
805 if host_system == 'darwin'
806 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
807 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
808 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
810 if need_platform_cgl != 'no'
811 if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
812 gl_platform_deps += [quartzcore_dep, corefoundation_dep, foundation_dep]
813 enabled_gl_platforms += 'cgl'
814 glconf.set('GST_GL_HAVE_PLATFORM_CGL', 1)
816 if need_win_cocoa != 'no'
817 cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : false)
820 'cocoa/gstglcaopengllayer.m',
821 'cocoa/gstglcontext_cocoa.m',
822 'cocoa/gstgldisplay_cocoa.m',
823 'cocoa/gstglwindow_cocoa.m'
825 gl_winsys_deps += cocoa_dep
826 enabled_gl_winsys += 'cocoa'
827 glconf.set('GST_GL_HAVE_WINDOW_COCOA', 1)
828 elif need_win_cocoa == 'yes'
829 error('Could not find Cocoa')
832 elif need_platform_cgl == 'yes'
833 error('Could not find CGL dependencies')
838 if need_platform_eagl == 'yes'
839 if host_system != 'ios'
840 error('Can only use EAGL on iOS')
842 if need_win_eagl == 'no'
843 error('Impossible situation requested: Cannot use EAGL platform without the EAGL window system')
844 elif need_api_gles == 'no'
845 error('Impossible situation requested: Cannot use EAGL platform without the GLES library')
847 elif need_platform_eagl == 'no' and need_win_eagl == 'yes'
848 error('Impossible situation requested: Cannot use EAGL window system without the EAGL platform')
851 if host_system == 'ios' and need_platform_eagl != 'no' and need_win_eagl != 'no'
852 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
853 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
854 coregraphics_dep = dependency('appleframeworks', modules : ['CoreGraphics'], required : false)
855 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
856 uikit_dep = dependency('appleframeworks', modules : ['UIkit'], required : false)
858 if foundation_dep.found() and corefoundation_dep.found() and coregraphics_dep.found() and quartzcore_dep.found() and uikit_dep.found()
859 gl_platform_deps += [
867 'eagl/gstglcontext_eagl.m',
868 'eagl/gstglwindow_eagl.m',
870 enabled_gl_winsys += 'eagl'
871 enabled_gl_platforms += 'eagl'
872 glconf.set('GST_GL_HAVE_WINDOW_EAGL', 1)
873 glconf.set('GST_GL_HAVE_PLATFORM_EAGL', 1)
874 elif need_platform_eagl == 'yes' or need_win_eagl == 'yes'
875 error('Could not find dependencies for EAGL')
880 gbm_gudev_dep = unneeded_dep
881 gbm_libdrm_dep = unneeded_dep
882 gbm_dep = unneeded_dep
883 if need_win_gbm != 'no'
884 if need_win_gbm == 'yes'
885 if need_platform_egl == 'no'
886 error('Impossible situation requested: Cannot use GBM without EGL support')
890 gbm_gudev_dep = dependency('gudev-1.0', version : '>=147', required : false)
891 gbm_libdrm_dep = dependency('libdrm', version : '>= 2.4.55', required : false)
892 gbm_dep = dependency('gbm', required : false)
893 if egl_dep.found() and gbm_gudev_dep.found() and gbm_libdrm_dep.found() and gbm_dep.found()
895 'gbm/gstgldisplay_gbm.c',
896 'gbm/gstgl_gbm_utils.c',
897 'gbm/gstglwindow_gbm_egl.c',
899 enabled_gl_winsys += 'gbm'
900 gl_winsys_deps += [gbm_gudev_dep, gbm_libdrm_dep, gbm_dep]
901 glconf.set('GST_GL_HAVE_WINDOW_GBM', 1)
903 if need_win_gbm == 'yes'
904 error ('Could not find requested GBM libraries')
906 gbm_gudev_dep = unneeded_dep
907 gbm_libdrm_dep = unneeded_dep
908 gbm_dep = unneeded_dep
912 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
913 if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
914 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
915 enabled_gl_winsys += 'viv-fb'
916 glconf.set('GST_GL_HAVE_WINDOW_VIV_FB', 1)
917 glconf.set('GST_GL_HAVE_VIV_DIRECTVIV', 1)
919 'viv-fb/gstgldisplay_viv_fb.c',
920 'viv-fb/gstglwindow_viv_fb_egl.c',
922 gl_cpp_args += ['-DEGL_API_FB']
927 if need_win_android == 'yes'
928 if need_platform_egl == 'no'
929 error('Impossible situation requested: Cannot build for Android without EGL')
930 elif need_api_gles2 == 'no'
931 error('Impossible situation requested: Cannot build for Android without GLES2 support')
932 elif host_system != 'android'
933 error('Impossible situation requested: Cannot build for Android without an android system')
937 if host_system == 'android' and need_win_android != 'no' and need_platform_egl != 'no'
938 if gles2_dep.found() and egl_dep.found()
939 enabled_gl_winsys += ['android']
940 glconf.set('GST_GL_HAVE_WINDOW_ANDROID', 1)
942 'android/gstglwindow_android_egl.c'
948 nvbuf_utils_dep = unneeded_dep
950 # XXX: provide options for this?
951 # c_args and c_link_args can also cover this case just fine e.g.:
952 # -Dc_args='-I/usr/src/jetson_multimedia_api/include' -Dc_link_args='-L/usr/lib/aarch64-linux-gnu/tegra/'
953 nvbuf_utils_dep = cc.find_library('nvbuf_utils', required : false)
954 nvbuf_utils_h = cc.has_header('nvbuf_utils.h')
955 if nvbuf_utils_dep.found() and nvbuf_utils_h
956 gl_misc_deps += [nvbuf_utils_dep]
958 gl_cpp_args += ['-DHAVE_NVMM']
963 if enabled_gl_apis.length() == 0
964 message('No OpenGL API libraries found or requested')
967 if enabled_gl_platforms.length() == 0
968 message('No OpenGL Platforms found or requested')
971 if enabled_gl_winsys.length() == 0
972 message('No OpenGL Window systems found or requested')
977 # find some types that may or may not be defined
978 if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
979 glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
981 if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
982 glconf.set('GST_GL_HAVE_GLCHAR', 1)
984 if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
985 glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
987 if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
988 glconf.set('GST_GL_HAVE_GLINTPTR', 1)
990 if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
991 glconf.set('GST_GL_HAVE_GLSYNC', 1)
993 if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
994 glconf.set('GST_GL_HAVE_GLUINT64', 1)
996 if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
997 glconf.set('GST_GL_HAVE_GLINT64', 1)
999 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)
1000 glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
1002 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)
1003 glconf.set('GST_GL_HAVE_EGLUINT64KHR', 1)
1006 summary('GL api', enabled_gl_apis, list_sep: ', ')
1007 summary('GL platform', enabled_gl_platforms, list_sep: ', ')
1008 summary('GL winsys', enabled_gl_winsys, list_sep: ', ')
1010 install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
1011 install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
1013 configure_file(input : 'gstglconfig.h.meson',
1014 output : 'gstglconfig.h',
1015 install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
1016 install_tag : 'devel',
1017 configuration : glconf)
1019 glib_mkenums = find_program('glib-mkenums')
1020 mkenums = find_program('gl_mkenum.py')
1021 gl_enumtypes_h = custom_target('gstglenumtypes_h',
1022 output : 'gl-enumtypes.h',
1023 input : gir_gl_headers,
1025 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/gl/'),
1026 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1028 gl_enumtypes_c = custom_target('gstglenumtypes_c',
1029 output : 'gl-enumtypes.c',
1030 input : gir_gl_headers,
1031 depends : [gl_enumtypes_h],
1032 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1033 gen_sources = [gl_enumtypes_h]
1035 common_args = gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL', '-DG_LOG_DOMAIN="GStreamer-GL"']
1037 # We have custom_target() that generate headers in the current build dir,
1038 # but with implicit_include_directories: false, meson >= 0.58.0 won't include
1039 # it by default. We cannot use include_directories('.') here because it would
1040 # also include current source dir which is what we want to avoid because
1041 # case-insensitive FS would include gst-libs/gl/egl/egl.h as EGL/egl.h.
1042 common_args += '-I@0@'.format(meson.current_build_dir())
1044 gstgl = library('gstgl-' + api_version,
1045 gl_sources, gl_egl_sources, gl_x11_sources, gl_wayland_sources, gl_priv_sources, gl_enumtypes_c, gl_enumtypes_h,
1046 c_args : common_args,
1047 cpp_args : common_args,
1048 objc_args : common_args + gl_objc_args,
1049 include_directories : [configinc, libsinc, gl_includes],
1050 version : libversion,
1051 soversion : soversion,
1052 darwin_versions : osxversion,
1054 dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
1055 gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps],
1056 # don't confuse EGL/egl.h with gst-libs/gl/egl/egl.h on case-insensitive file systems
1057 implicit_include_directories : false)
1059 pkgconfig_gl_variables = [
1060 'gl_platforms=' + ' '.join(enabled_gl_platforms),
1061 'gl_winsys=' + ' '.join(enabled_gl_winsys),
1062 'gl_apis=' + ' '.join(enabled_gl_apis),
1065 library_def = {'lib': gstgl}
1066 pkg_name = 'gstreamer-gl-1.0'
1067 pkgconfig.generate(gstgl,
1068 libraries : [gstvideo, gst_base_dep, gst_dep],
1069 variables : pkgconfig_variables + pkgconfig_gl_variables,
1070 uninstalled_variables : pkgconfig_gl_variables,
1071 subdirs : pkgconfig_subdirs,
1072 extra_cflags : ['-I${libdir}/gstreamer-1.0/include'],
1074 description : 'Streaming media framework, OpenGL plugins libraries',
1077 # Desperate times, desperate measures... fix up escaping of our variables
1078 run_command(meson_pkg_config_file_fixup_script,
1079 'gstreamer-gl-1.0', 'gl_platforms', 'gl_winsys', 'gl_apis',
1083 libraries : [gstgl, gl_lib_deps],
1084 subdirs : pkgconfig_subdirs,
1085 name : 'gstreamer-gl-prototypes-1.0',
1086 description : 'Streaming media framework, OpenGL plugins libraries (OpenGL Prototypes)',
1091 'sources' : gl_sources + [gl_enumtypes_h] + [gl_enumtypes_c] + gir_gl_headers,
1092 'namespace' : 'GstGL',
1093 'nsversion' : api_version,
1094 'identifier_prefix' : 'Gst',
1095 'symbol_prefix' : 'gst',
1096 'export_packages' : pkg_name,
1097 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1099 'extra_args' : gir_init_section + ['--c-include=gst/gl/gl.h'],
1100 'dependencies' : [video_dep, gst_dep, gst_base_dep],
1102 library_def += {'gir': [gir]}
1104 gl_gir = gnome.generate_gir(gstgl, kwargs: gir)
1105 gen_sources += [gl_gir]
1108 gst_libraries += [[pkg_name, library_def]]
1109 gstgl_dep = declare_dependency(link_with : gstgl,
1110 include_directories : [libsinc, compat_includes],
1111 sources: gen_sources,
1112 dependencies : [video_dep, gst_base_dep])
1113 gstglproto_dep = declare_dependency(
1114 dependencies : [gstgl_dep] + gl_lib_deps,
1115 sources: gen_sources
1117 meson.override_dependency('gstreamer-gl-1.0', gstgl_dep)
1118 meson.override_dependency('gstreamer-gl-prototypes-1.0', gstglproto_dep)
1120 if gl_x11_headers.length() > 0
1121 install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
1122 pkg_name = 'gstreamer-gl-x11-1.0'
1124 libraries : [gstgl],
1125 requires: ['x11-xcb'],
1126 subdirs : pkgconfig_subdirs,
1128 description : 'Streaming media framework, OpenGL plugins libraries (X11 specifics)',
1133 'sources' : gl_x11_sources + gl_x11_headers,
1134 'namespace' : 'GstGLX11',
1135 'nsversion' : api_version,
1136 'identifier_prefix' : 'Gst',
1137 'symbol_prefix' : 'gst',
1138 'export_packages' : 'gstreamer-gl-x11-1.0',
1139 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1141 'extra_args' : gir_init_section + ['--c-include=gst/gl/x11/x11.h'],
1142 'dependencies' : [video_dep, gst_dep, gst_base_dep]
1144 gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1145 gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1147 gir += {'includes': gir['includes'] + [gl_gir[0]]}
1148 gl_x11_gir = gnome.generate_gir(gstgl, kwargs: gir)
1151 gstglx11_dep = declare_dependency(dependencies : [gstgl_dep, x11_dep, xcb_dep],
1152 sources : gl_x11_gir)
1153 meson.override_dependency('gstreamer-gl-x11-1.0', gstglx11_dep)
1156 if gl_wayland_headers.length() > 0
1157 install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
1158 pkg_name = 'gstreamer-gl-wayland-1.0'
1160 libraries : [gstgl],
1161 requires: ['wayland-egl', 'wayland-client'],
1162 subdirs : pkgconfig_subdirs,
1164 description : 'Streaming media framework, OpenGL plugins libraries (Wayland specifics)',
1169 'sources' : gl_wayland_sources + gl_wayland_headers,
1170 'namespace' : 'GstGLWayland',
1171 'nsversion' : api_version,
1172 'identifier_prefix' : 'Gst',
1173 'symbol_prefix' : 'gst',
1174 'export_packages' : 'gstreamer-gl-wayland-1.0',
1175 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1177 'extra_args' : gir_init_section + ['--c-include=gst/gl/wayland/wayland.h'],
1178 'dependencies' : [video_dep, gst_dep, gst_base_dep]
1181 gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1182 gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1184 gir += {'includes': gir['includes'] + [gl_gir[0]]}
1185 gl_wayland_gir = gnome.generate_gir(gstgl, kwargs: gir)
1188 gstglwayland_dep = declare_dependency(dependencies : [gstgl_dep],
1189 sources : gl_wayland_gir)
1190 meson.override_dependency(pkg_name, gstglwayland_dep)
1193 if gl_egl_headers.length() > 0
1194 install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
1195 pkg_name = 'gstreamer-gl-egl-1.0'
1197 libraries : [gstgl, egl_dep],
1198 subdirs : pkgconfig_subdirs,
1200 description : 'Streaming media framework, OpenGL plugins libraries (EGL specifics)',
1205 'sources' : gl_egl_sources + gl_egl_headers,
1206 'namespace' : 'GstGLEGL',
1207 'nsversion' : api_version,
1208 'identifier_prefix' : 'Gst',
1209 'symbol_prefix' : 'gst',
1210 'export_packages' : pkg_name,
1211 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1213 'extra_args' : gir_init_section + ['--c-include=gst/gl/egl/egl.h'],
1214 'dependencies' : [video_dep, gst_dep, gst_base_dep]
1216 gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1217 gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1219 gir += {'includes': gir['includes'] + [gl_gir[0]]}
1220 gl_egl_gir = gnome.generate_gir(gstgl, kwargs: gir)
1223 gstglegl_dep = declare_dependency(dependencies : [gstgl_dep],
1224 sources : gl_egl_gir)
1225 meson.override_dependency(pkg_name, gstglegl_dep)
1228 elif get_option('gl').enabled()
1229 error('GStreamer OpenGL integration required via options, but needed dependencies not found.')