1 gstgl_dep = dependency('', required : false)
2 gstglproto_dep = dependency('', required : false)
3 gstglx11_dep = dependency('', required : false)
4 gstglwayland_dep = dependency('', required : false)
5 gstglegl_dep = dependency('', required : false)
6 gstglviv_fb_dep = dependency('', required : false)
8 if get_option('gl').disabled()
9 message('GStreamer OpenGL integration disabled via options.')
19 'gstglcolorconvert.c',
23 'gstglcontextconfig.c',
24 'gstglcontextquirks.c',
33 'gstgloverlaycompositor.c',
35 'gstglrenderbuffer.c',
37 'gstglshaderstrings.c',
49 gir_gl_headers = files([
60 'gstglcolorconvert.h',
62 'gstglcontextconfig.h',
71 'gstgloverlaycompositor.h',
73 'gstglrenderbuffer.h',
75 'gstglshaderstrings.h',
85 gl_headers = gir_gl_headers + files([
89 gl_prototype_headers = files([
90 'glprototypes/all_functions.h',
91 'glprototypes/base.h',
92 'glprototypes/buffer_storage.h',
93 'glprototypes/blending.h',
94 'glprototypes/buffers.h',
95 'glprototypes/debug.h',
96 'glprototypes/eglimage.h',
98 'glprototypes/fixedfunction.h',
99 'glprototypes/gles.h',
100 'glprototypes/gstgl_compat.h',
101 'glprototypes/gstgl_gles2compat.h',
102 'glprototypes/opengl.h',
103 'glprototypes/query.h',
104 'glprototypes/shaders.h',
105 'glprototypes/sync.h',
106 'glprototypes/vao.h',
111 gl_wayland_sources = []
112 gl_wayland_headers = []
115 gl_viv_fb_sources = []
116 gl_viv_fb_headers = []
118 glconf = configuration_data()
120 'GST_GL_HAVE_OPENGL',
123 'GST_GL_HAVE_GLES3EXT3_H',
125 'GST_GL_HAVE_WINDOW_X11',
126 'GST_GL_HAVE_WINDOW_COCOA',
127 'GST_GL_HAVE_WINDOW_WIN32',
128 'GST_GL_HAVE_WINDOW_WINRT',
129 'GST_GL_HAVE_WINDOW_WAYLAND',
130 'GST_GL_HAVE_WINDOW_ANDROID',
131 'GST_GL_HAVE_WINDOW_DISPMANX',
132 'GST_GL_HAVE_WINDOW_EAGL',
133 'GST_GL_HAVE_WINDOW_VIV_FB',
134 'GST_GL_HAVE_WINDOW_GBM',
136 'GST_GL_HAVE_PLATFORM_EGL',
137 'GST_GL_HAVE_PLATFORM_GLX',
138 'GST_GL_HAVE_PLATFORM_WGL',
139 'GST_GL_HAVE_PLATFORM_CGL',
140 'GST_GL_HAVE_PLATFORM_EAGL',
142 'GST_GL_HAVE_DMABUF',
143 'GST_GL_HAVE_VIV_DIRECTVIV',
145 'GST_GL_HAVE_GLEGLIMAGEOES',
146 'GST_GL_HAVE_GLCHAR',
147 'GST_GL_HAVE_GLSIZEIPTR',
148 'GST_GL_HAVE_GLINTPTR',
149 'GST_GL_HAVE_GLSYNC',
150 'GST_GL_HAVE_GLUINT64',
151 'GST_GL_HAVE_GLINT64',
152 'GST_GL_HAVE_EGLATTRIB',
153 'GST_GL_HAVE_EGLUINT64KHR',
156 foreach option : glconf_options
157 glconf.set(option, 0)
160 unneeded_dep = dependency('', required : false)
161 if unneeded_dep.found()
162 error ('Found unfindable dependency')
165 # OpenGL/GLES2 libraries
167 # GL platform - EGL, GLX, CGL, WGL, etc
168 gl_platform_deps = []
169 # GL winsys - wayland, X11, Cocoa, win32, etc
171 # other things we need.
173 # Other preprocessor arguments
179 enabled_gl_platforms = []
180 enabled_gl_winsys = []
182 # parse provided options
183 libegl_module_name = get_option('egl_module_name')
184 if libegl_module_name != ''
185 gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)]
187 libgles2_module_name = get_option('gles2_module_name')
188 if libgles2_module_name != ''
189 gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)]
191 libgl_module_name = get_option('opengl_module_name')
192 if libgl_module_name != ''
193 gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)]
196 gl_apis = get_option('gl_api')
197 if gl_apis.contains('auto')
198 need_api_opengl = 'auto'
199 need_api_gles2 = 'auto'
201 need_api_opengl = 'no'
202 need_api_gles2 = 'no'
203 foreach api : gl_apis
205 need_api_opengl = 'yes'
207 need_api_gles2 = 'yes'
209 error('Unsupported GL api provided ' + api)
214 gl_platforms = get_option('gl_platform')
215 if gl_platforms.contains('auto')
216 need_platform_egl = 'auto'
217 need_platform_glx = 'auto'
218 need_platform_cgl = 'auto'
219 need_platform_wgl = 'auto'
220 need_platform_eagl = 'auto'
222 need_platform_egl = 'no'
223 need_platform_glx = 'no'
224 need_platform_cgl = 'no'
225 need_platform_wgl = 'no'
226 need_platform_eagl = 'no'
227 foreach platform : gl_platforms
229 need_platform_egl = 'yes'
230 elif platform == 'glx'
231 need_platform_glx = 'yes'
232 elif platform == 'cgl'
233 need_platform_cgl = 'yes'
234 elif platform == 'wgl'
235 need_platform_wgl = 'yes'
236 elif platform == 'eagl'
237 need_platform_eagl = 'yes'
239 error('Unsupported GL platform provided ' + platform)
244 gl_winsys = get_option('gl_winsys')
245 if gl_winsys.contains('auto')
246 need_win_x11 = 'auto'
247 need_win_wayland = 'auto'
248 need_win_win32 = 'auto'
249 need_win_winrt = 'auto'
250 need_win_cocoa = 'auto'
251 need_win_egl = 'auto'
252 need_win_eagl = 'auto'
253 need_win_dispmanx = 'auto'
254 need_win_viv_fb = 'auto'
255 need_win_gbm = 'auto'
256 need_win_android = 'auto'
259 need_win_wayland = 'no'
260 need_win_win32 = 'no'
261 need_win_winrt = 'no'
262 need_win_cocoa = 'no'
265 need_win_dispmanx = 'no'
266 need_win_viv_fb = 'no'
268 need_win_android = 'no'
269 foreach winsys : gl_winsys
272 elif winsys == 'wayland'
273 need_win_wayland = 'yes'
274 elif winsys == 'win32'
275 need_win_win32 = 'yes'
276 elif winsys == 'winrt'
277 need_win_winrt = 'yes'
278 elif winsys == 'cocoa'
279 need_win_cocoa = 'yes'
282 elif winsys == 'eagl'
283 need_win_eagl = 'yes'
284 elif winsys == 'dispmanx'
285 need_win_dispmanx = 'yes'
286 elif winsys == 'viv-fb'
287 need_win_viv_fb = 'yes'
290 elif winsys == 'android'
291 need_win_android = 'yes'
293 error('Unsupported GL winsys provided ' + winsys)
298 gl_include_header = '''
300 # pragma GCC diagnostic push
301 # pragma GCC diagnostic ignored "-Wredundant-decls"
303 #ifndef GL_GLEXT_PROTOTYPES
304 #define GL_GLEXT_PROTOTYPES 1
308 # convoluted way of getting at the subproject taking into account the wrap-mode
309 # so we don't download a subproject unless allowed
310 gl_header_dep = dependency('', fallback : ['gl-headers', 'gl_headers_dummy_dep'],
312 if gl_header_dep.type_name() == 'internal'
313 # this will only contain the includes of headers that are not found
314 compat_includes = subproject('gl-headers').get_variable('compatibility_includes')
319 # Desktop OpenGL checks
320 gl_dep = unneeded_dep
321 glx_dep = unneeded_dep
323 # (GLVND) OpenGL (without GLX) headers and interface
324 if need_api_opengl != 'no'
325 gl_dep = dependency('opengl', method: 'pkg-config', required : false)
328 # non-GLVND aka Legacy OpenGL
329 if need_api_opengl != 'no' and not gl_dep.found()
330 if host_system == 'darwin'
331 gl_dep = dependency('appleframeworks', modules : ['OpenGL'], required : false)
333 # override meson's braindead gl detection on osx/windows/etc by forcing pkg-config
334 gl_dep = dependency('gl', method: 'pkg-config', required : false)
337 if not gl_dep.found()
338 if host_system == 'windows'
339 gl_dep = cc.find_library('opengl32', required : false)
341 gl_dep = cc.find_library('GL', required : false)
344 if not cc.has_header('GL/gl.h', include_directories : compat_includes)
345 gl_dep = unneeded_dep
348 if not gl_dep.found() and need_api_opengl == 'yes'
349 error ('Could not find requested OpenGL library')
353 gl_includes += [compat_includes]
358 if need_platform_glx != 'no'
359 # (GLVND) GLX library and headers.
360 glx_dep = dependency('glx', method: 'pkg-config', required : false)
362 if not glx_dep.found()
363 if host_system == 'darwin'
364 glx_dep = cc.find_library('GL', required : false)
367 elif need_platform_glx == 'yes'
368 error ('Could not find requested GLX library')
373 if need_api_opengl != 'no'
375 if host_system == 'darwin'
376 opengl_includes += '''
377 #if !defined(MAC_OS_X_VERSION_MAX_ALLOWED) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1014
378 # define GL_SILENCE_DEPRECATION
380 #include <OpenGL/OpenGL.h>
381 #include <OpenGL/gl.h>
382 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
383 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
384 # include <OpenGL/gl3.h>
388 opengl_includes += '''
390 # include <windows.h>
393 #if __WIN32__ || _WIN32
394 # include <GL/glext.h>
400 bcm_host_dep = unneeded_dep
401 if need_win_dispmanx != 'no'
403 # Try pkg-config for bcm_host then fallback to find_library to also
404 # support older distribution
405 bcm_host_dep = dependency('bcm_host', required : false)
406 if not bcm_host_dep.found()
407 bcm_host_dep = cc.find_library('bcm_host', required : false)
412 gles2_dep = unneeded_dep
415 if need_api_gles2 != 'no'
416 if host_system == 'ios'
417 gles2_dep = dependency('appleframeworks', modules : ['OpenGLES'], required : false)
419 if bcm_host_dep.found()
420 gles2_dep = dependency('brcmglesv2', required : false)
422 if not gles2_dep.found()
423 gles2_dep = dependency('glesv2', required : false)
427 if not gles2_dep.found()
428 # if host_system == 'windows'
429 # elif host_system == ios
430 # gles2_dep = cc.find_library('GLESv2', required : false)
432 gles2_dep = cc.find_library('GLESv2', required : false)
435 if not cc.has_header('GLES2/gl2.h', include_directories : compat_includes)
436 gles2_dep = unneeded_dep
439 if not gles2_dep.found() and need_api_gles2 == 'yes'
440 error ('Could not find requested OpenGL ES library')
444 gl_includes += [compat_includes]
448 gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', dependencies : gles2_dep, include_directories : compat_includes)
451 if host_system == 'ios'
453 # include <OpenGLES/ES2/gl.h>
454 # include <OpenGLES/ES2/glext.h>
458 gl_includes += [compat_includes]
459 gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', dependencies : gles2_dep, include_directories : compat_includes)
461 # include <GLES3/gl3.h>
462 # include <GLES2/gl2ext.h>'''
465 # include <GLES3/gl3ext.h>'''
469 # include <GLES2/gl2.h>
470 # include <GLES2/gl2ext.h>'''
475 # can we include both gles2 and opengl headers?
476 if gles2_dep.found() and gl_dep.found()
477 gl_include_block = gl_include_header + gles_includes + opengl_includes
478 # TODO: Revert to passing gl_include_block via prefix: once
479 # https://github.com/mesonbuild/meson/issues/2364 is fixed
480 if not cc.compiles(gl_include_block + '\n' + 'void f (void) {}',dependencies : [gles2_dep, gl_dep], include_directories : compat_includes)
481 message ('Cannot include both OpenGL and OpenGL ES headers')
482 if need_api_gles2 != 'yes'
483 gles2_dep = unneeded_dep
484 elif need_api_opengl != 'yes'
485 gl_dep = unneeded_dep
487 error('Both OpenGL and OpenGL ES were requested but cannot be included together')
491 gl_include_block = gl_include_header
493 gl_include_block += gles_includes
496 gl_include_block += opengl_includes
500 gl_lib_deps += gles2_dep
501 glconf.set('GST_GL_HAVE_GLES2', 1)
503 glconf.set('GST_GL_HAVE_GLES3',1)
505 glconf.set('GST_GL_HAVE_GLES3EXT3_H', 1)
508 enabled_gl_apis += 'gles2'
512 gl_lib_deps += gl_dep
513 glconf.set('GST_GL_HAVE_OPENGL', 1)
514 enabled_gl_apis += 'gl'
518 egl_dep = unneeded_dep
519 if need_platform_egl != 'no'
520 if bcm_host_dep.found()
521 egl_dep = dependency('brcmegl', required : false)
523 if not egl_dep.found()
524 egl_dep = dependency('egl', required : false)
526 if not egl_dep.found()
527 egl_dep = cc.find_library('EGL', required : false)
530 if egl_dep.found() and not cc.has_header('EGL/egl.h',
531 dependencies : egl_dep,
532 include_directories : compat_includes)
533 egl_dep = unneeded_dep
535 if egl_dep.found() and not cc.has_header('EGL/eglext.h',
536 dependencies : egl_dep,
537 include_directories : compat_includes)
538 egl_dep = unneeded_dep
542 gl_egl_sources += files([
545 'egl/gstglcontext_egl.c',
546 'egl/gstgldisplay_egl.c',
547 'egl/gstglmemoryegl.c',
548 'egl/gstgldisplay_egl_device.c',
550 gl_egl_headers += files([
554 'egl/gstgldisplay_egl.h',
555 'egl/gstglmemoryegl.h',
556 'egl/gstgldisplay_egl_device.h',
558 gl_platform_deps += egl_dep
559 glconf.set('GST_GL_HAVE_PLATFORM_EGL', 1)
561 if cc.has_header('libdrm/drm_fourcc.h')
562 gl_misc_deps += allocators_dep
563 glconf.set('GST_GL_HAVE_DMABUF', 1)
568 #include <EGL/eglext.h>
570 enabled_gl_platforms += 'egl'
571 elif need_platform_egl == 'yes'
572 error ('Could not find requested EGL library')
577 if need_win_egl == 'yes'
578 if need_platform_egl == 'no'
579 error('Impossible situation requested: Cannot use Winsys egl without EGL support')
580 elif not egl_dep.found()
581 error ('Could not find EGL libraries for Winsys egl')
583 enabled_gl_winsys += 'egl'
588 wayland_client_dep = unneeded_dep
589 wayland_cursor_dep = unneeded_dep
590 wayland_egl_dep = unneeded_dep
591 if need_win_wayland != 'no'
592 if need_win_wayland == 'yes'
593 if need_platform_egl == 'no'
594 error('Impossible situation requested: Cannot use Wayland without EGL support')
597 if not egl_dep.found()
598 if need_win_wayland == 'yes'
599 error ('Could not find EGL libraries for wayland')
601 message ('Could not find EGL libraries for wayland')
604 wayland_client_dep = dependency('wayland-client', version : '>= 1.11', required : false)
605 wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
606 wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
607 wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.15', required : false)
608 wayland_scanner = find_program('wayland-scanner', required: false)
610 if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found() and wayland_protocols_dep.found() and wayland_scanner.found()
611 # Generate the XDG shell interface
612 wayland_protocols_basedir = wayland_protocols_dep.get_variable('pkgdatadir')
613 xdg_shell_xml_spec = join_paths(wayland_protocols_basedir, 'stable', 'xdg-shell', 'xdg-shell.xml')
614 xdg_shell_header = custom_target('xdg-shell-client-header',
615 command: [ wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@' ],
616 input: xdg_shell_xml_spec,
617 output: 'xdg-shell-client-protocol.h',
619 xdg_shell_code = custom_target('xdg-shell-client-code',
620 command: [ wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@' ],
621 input: xdg_shell_xml_spec,
622 output: 'xdg-shell-client-protocol.c',
625 gl_wayland_sources += files([
626 'wayland/gstgldisplay_wayland.c',
629 'wayland/gstglwindow_wayland_egl.c',
630 'wayland/wayland_event_source.c',
634 gl_wayland_headers += files([
636 'wayland/gstgldisplay_wayland.h'
638 glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
639 gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
640 enabled_gl_winsys += 'wayland'
642 if need_win_wayland == 'yes'
643 error ('Could not find requested Wayland libraries')
645 wayland_client_dep = unneeded_dep
646 wayland_cursor_dep = unneeded_dep
647 wayland_egl_dep = unneeded_dep
648 wayland_protocols_dep = unneeded_dep
654 if need_platform_glx == 'yes'
655 if need_win_x11 == 'no'
656 error('Impossible situation requested: Cannot use GLX without X11 support')
657 elif need_api_opengl == 'no'
658 error('Impossible situation requested: Cannot use GLX without the OpenGL library')
662 xcb_dep = unneeded_dep
663 if need_win_x11 != 'no'
664 xcb_dep = dependency('x11-xcb', required : false)
665 if x11_dep.found() and xcb_dep.found()
666 gl_x11_sources += files([
667 'x11/gstgldisplay_x11.c',
670 'x11/gstglwindow_x11.c',
671 'x11/xcb_event_source.c',
673 gl_x11_headers += files([
675 'x11/gstgldisplay_x11.h',
677 glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
678 gl_winsys_deps += [x11_dep, xcb_dep]
679 enabled_gl_winsys += 'x11'
681 if need_platform_glx != 'no' and glx_dep.found() and cc.has_function ('glXMakeCurrent', dependencies : glx_dep)
682 glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
684 'x11/gstglcontext_glx.c',
686 # GLX is in the opengl library on linux
687 gl_platform_deps += glx_dep
688 enabled_gl_platforms += 'glx'
690 elif need_win_x11 == 'yes'
691 error ('Could not find requested X11 libraries')
695 if need_win_dispmanx != 'no'
696 have_dispmanx_window_t = cc.has_type(
697 'EGL_DISPMANX_WINDOW_T',
699 #include <bcm_host.h>
702 dependencies: [gl_lib_deps, egl_dep, bcm_host_dep],
703 include_directories: gl_includes)
705 if have_dispmanx_window_t and bcm_host_dep.found()
706 if not egl_dep.found()
707 error('dispmanx requires the use of egl')
711 'dispmanx/gstglwindow_dispmanx_egl.c'
714 glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
715 gl_winsys_deps += bcm_host_dep
716 enabled_gl_winsys += 'dispmanx'
717 gl_cpp_args += ['-DUSE_EGL_RPI']
718 elif need_win_dispmanx == 'yes'
719 error('Could not find dispmanx libraries')
724 if need_platform_wgl == 'yes'
725 if need_win_win32 == 'no'
726 error('Impossible situation requested: Cannot use WGL without the win32 window system')
730 if host_system == 'windows' and need_win_win32 != 'no'
731 gdi_dep = cc.find_library('gdi32', required : false)
734 have_egl_win32 = false
735 if need_platform_wgl != 'no'
736 wglext_h = cc.has_header('GL/wglext.h',
737 prefix : '''#include <windows.h>
738 #include <GL/gl.h>''',
739 include_directories : compat_includes)
740 have_wgl = wglext_h and gl_dep.found()
743 have_egl_win32 = enabled_gl_platforms.contains('egl') and gles2_dep.found()
744 if have_wgl or have_egl_win32
745 gl_includes += [compat_includes]
746 gl_platform_deps += gdi_dep
748 'win32/gstglwindow_win32.c',
750 enabled_gl_winsys += 'win32'
751 gl_winsys_deps += gdi_dep
752 glconf.set('GST_GL_HAVE_WINDOW_WIN32', 1)
757 'wgl/gstglcontext_wgl.c',
759 enabled_gl_platforms += 'wgl'
760 glconf.set('GST_GL_HAVE_PLATFORM_WGL', 1)
766 if need_win_winrt != 'no' and host_system == 'windows'
767 if need_win_winrt == 'yes' and not enabled_gl_platforms.contains('egl')
768 error('Impossible situation requested: Cannot use WinRT ANGLE without EGL support')
772 windows_graphics_h = cc.has_header('windows.graphics.h')
773 windows_app_dep = cc.find_library('WindowsApp', required: false)
774 runtimeobject_lib = cc.find_library('runtimeobject', required: false)
776 if windows_graphics_h and windows_app_dep.found() and runtimeobject_lib.found()
777 enabled_gl_winsys += 'winrt'
778 glconf.set('GST_GL_HAVE_WINDOW_WINRT', 1)
780 'winrt/gstglwindow_winrt_egl.cpp'
782 gl_winsys_deps += runtimeobject_lib
783 elif need_win_winrt == 'yes'
784 error('WinRT is enabled, but headers/libraries were not found')
786 elif need_win_winrt == 'yes'
787 error('WinRT ANGLE is enabled, but EGL was not found')
789 message('WinRT ANGLE disabled because EGL was not found')
793 if ['darwin', 'ios'].contains(host_system)
795 error('No ObjC compiler found')
798 objc = meson.get_compiler('objc')
799 if not objc.has_argument('-fobjc-arc')
800 error('ARC is required for building')
803 gl_objc_args += ['-fobjc-arc']
807 if need_platform_cgl == 'yes'
808 if need_win_cocoa == 'no'
809 error('Impossible situation requested: Cannot use CGL without Cocoa support')
810 elif need_api_opengl == 'no'
811 error('Impossible situation requested: Cannot use CGL without the OpenGL library')
813 elif need_platform_cgl == 'no' and need_win_cocoa == 'yes'
814 error('Impossible situation requested: Cannot use Cocoa without CGL support')
817 if host_system == 'darwin'
818 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
819 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
820 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
822 if need_platform_cgl != 'no'
823 if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
824 gl_platform_deps += [quartzcore_dep, corefoundation_dep, foundation_dep]
825 enabled_gl_platforms += 'cgl'
826 glconf.set('GST_GL_HAVE_PLATFORM_CGL', 1)
828 if need_win_cocoa != 'no'
829 cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : false)
832 'cocoa/gstglcaopengllayer.m',
833 'cocoa/gstglcontext_cocoa.m',
834 'cocoa/gstgldisplay_cocoa.m',
835 'cocoa/gstglwindow_cocoa.m'
837 gl_winsys_deps += cocoa_dep
838 enabled_gl_winsys += 'cocoa'
839 glconf.set('GST_GL_HAVE_WINDOW_COCOA', 1)
840 elif need_win_cocoa == 'yes'
841 error('Could not find Cocoa')
844 elif need_platform_cgl == 'yes'
845 error('Could not find CGL dependencies')
850 if need_platform_eagl == 'yes'
851 if host_system != 'ios'
852 error('Can only use EAGL on iOS')
854 if need_win_eagl == 'no'
855 error('Impossible situation requested: Cannot use EAGL platform without the EAGL window system')
856 elif need_api_gles == 'no'
857 error('Impossible situation requested: Cannot use EAGL platform without the GLES library')
859 elif need_platform_eagl == 'no' and need_win_eagl == 'yes'
860 error('Impossible situation requested: Cannot use EAGL window system without the EAGL platform')
863 if host_system == 'ios' and need_platform_eagl != 'no' and need_win_eagl != 'no'
864 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
865 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
866 coregraphics_dep = dependency('appleframeworks', modules : ['CoreGraphics'], required : false)
867 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
868 uikit_dep = dependency('appleframeworks', modules : ['UIkit'], required : false)
870 if foundation_dep.found() and corefoundation_dep.found() and coregraphics_dep.found() and quartzcore_dep.found() and uikit_dep.found()
871 gl_platform_deps += [
879 'eagl/gstglcontext_eagl.m',
880 'eagl/gstglwindow_eagl.m',
882 enabled_gl_winsys += 'eagl'
883 enabled_gl_platforms += 'eagl'
884 glconf.set('GST_GL_HAVE_WINDOW_EAGL', 1)
885 glconf.set('GST_GL_HAVE_PLATFORM_EAGL', 1)
886 elif need_platform_eagl == 'yes' or need_win_eagl == 'yes'
887 error('Could not find dependencies for EAGL')
892 gbm_gudev_dep = unneeded_dep
893 gbm_libdrm_dep = unneeded_dep
894 gbm_dep = unneeded_dep
895 if need_win_gbm != 'no'
896 if need_win_gbm == 'yes'
897 if need_platform_egl == 'no'
898 error('Impossible situation requested: Cannot use GBM without EGL support')
902 gbm_gudev_dep = dependency('gudev-1.0', version : '>=147', required : false)
903 gbm_libdrm_dep = dependency('libdrm', version : '>= 2.4.55', required : false)
904 gbm_dep = dependency('gbm', required : false)
905 if egl_dep.found() and gbm_gudev_dep.found() and gbm_libdrm_dep.found() and gbm_dep.found()
907 'gbm/gstgldisplay_gbm.c',
908 'gbm/gstgl_gbm_utils.c',
909 'gbm/gstglwindow_gbm_egl.c',
911 enabled_gl_winsys += 'gbm'
912 gl_winsys_deps += [gbm_gudev_dep, gbm_libdrm_dep, gbm_dep]
913 glconf.set('GST_GL_HAVE_WINDOW_GBM', 1)
915 if need_win_gbm == 'yes'
916 error ('Could not find requested GBM libraries')
918 gbm_gudev_dep = unneeded_dep
919 gbm_libdrm_dep = unneeded_dep
920 gbm_dep = unneeded_dep
924 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
925 glconf.set('GST_GL_HAVE_VIV_DIRECTVIV', 1)
928 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
929 if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
930 enabled_gl_winsys += 'viv-fb'
931 glconf.set('GST_GL_HAVE_WINDOW_VIV_FB', 1)
932 gl_priv_sources += files([
933 'viv-fb/gstgldisplay_viv_fb.c',
934 'viv-fb/gstglwindow_viv_fb_egl.c',
936 gl_viv_fb_sources += files([
937 'viv-fb/gstgldisplay_viv_fb.c',
940 gl_cpp_args += ['-DEGL_API_FB']
941 gl_viv_fb_headers = files([
942 'viv-fb/gstglviv-fb.h',
943 'viv-fb/gstgldisplay_viv_fb.h',
948 if need_win_android == 'yes'
949 if need_platform_egl == 'no'
950 error('Impossible situation requested: Cannot build for Android without EGL')
951 elif need_api_gles2 == 'no'
952 error('Impossible situation requested: Cannot build for Android without GLES2 support')
953 elif host_system != 'android'
954 error('Impossible situation requested: Cannot build for Android without an android system')
958 if host_system == 'android' and need_win_android != 'no' and need_platform_egl != 'no'
959 if gles2_dep.found() and egl_dep.found()
960 enabled_gl_winsys += ['android']
961 glconf.set('GST_GL_HAVE_WINDOW_ANDROID', 1)
963 'android/gstglwindow_android_egl.c'
969 nvbuf_utils_dep = unneeded_dep
971 # XXX: provide options for this?
972 # c_args and c_link_args can also cover this case just fine e.g.:
973 # -Dc_args='-I/usr/src/jetson_multimedia_api/include' -Dc_link_args='-L/usr/lib/aarch64-linux-gnu/tegra/'
974 nvbuf_utils_dep = cc.find_library('nvbuf_utils', required : false)
975 nvbuf_utils_h = cc.has_header('nvbuf_utils.h')
976 if nvbuf_utils_dep.found() and nvbuf_utils_h
977 gl_misc_deps += [nvbuf_utils_dep]
979 gl_cpp_args += ['-DHAVE_NVMM']
984 if enabled_gl_apis.length() == 0
985 message('No OpenGL API libraries found or requested')
988 if enabled_gl_platforms.length() == 0
989 message('No OpenGL Platforms found or requested')
992 if enabled_gl_winsys.length() == 0
993 message('No OpenGL Window systems found or requested')
998 # find some types that may or may not be defined
999 if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1000 glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
1002 if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1003 glconf.set('GST_GL_HAVE_GLCHAR', 1)
1005 if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1006 glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
1008 if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1009 glconf.set('GST_GL_HAVE_GLINTPTR', 1)
1011 if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1012 glconf.set('GST_GL_HAVE_GLSYNC', 1)
1014 if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1015 glconf.set('GST_GL_HAVE_GLUINT64', 1)
1017 if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1018 glconf.set('GST_GL_HAVE_GLINT64', 1)
1020 if egl_dep.found() and cc.has_type('EGLAttrib', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep], include_directories : gl_includes)
1021 glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
1023 if egl_dep.found() and cc.has_type('EGLuint64KHR', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep], include_directories : gl_includes)
1024 glconf.set('GST_GL_HAVE_EGLUINT64KHR', 1)
1027 summary('GL api', enabled_gl_apis, list_sep: ', ')
1028 summary('GL platform', enabled_gl_platforms, list_sep: ', ')
1029 summary('GL winsys', enabled_gl_winsys, list_sep: ', ')
1031 install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
1032 install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
1034 configure_file(input : 'gstglconfig.h.meson',
1035 output : 'gstglconfig.h',
1036 install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
1037 install_tag : 'devel',
1038 configuration : glconf)
1040 glib_mkenums = find_program('glib-mkenums')
1041 mkenums = find_program('gl_mkenum.py')
1042 gl_enumtypes_h = custom_target('gstglenumtypes_h',
1043 output : 'gl-enumtypes.h',
1044 input : gir_gl_headers,
1046 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/gl/'),
1047 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1049 gl_enumtypes_c = custom_target('gstglenumtypes_c',
1050 output : 'gl-enumtypes.c',
1051 input : gir_gl_headers,
1052 depends : [gl_enumtypes_h],
1053 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1054 gen_sources = [gl_enumtypes_h]
1056 common_args = gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL', '-DG_LOG_DOMAIN="GStreamer-GL"']
1058 # We have custom_target() that generate headers in the current build dir,
1059 # but with implicit_include_directories: false, meson >= 0.58.0 won't include
1060 # it by default. We cannot use include_directories('.') here because it would
1061 # also include current source dir which is what we want to avoid because
1062 # case-insensitive FS would include gst-libs/gl/egl/egl.h as EGL/egl.h.
1063 common_args += '-I@0@'.format(meson.current_build_dir())
1065 gstgl = library('gstgl-' + api_version,
1066 gl_sources, gl_egl_sources, gl_x11_sources, gl_wayland_sources, gl_viv_fb_sources, gl_priv_sources, gl_enumtypes_c, gl_enumtypes_h,
1067 c_args : common_args,
1068 cpp_args : common_args,
1069 objc_args : common_args + gl_objc_args,
1070 include_directories : [configinc, libsinc, gl_includes],
1071 version : libversion,
1072 soversion : soversion,
1073 darwin_versions : osxversion,
1075 dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
1076 gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps],
1077 # don't confuse EGL/egl.h with gst-libs/gl/egl/egl.h on case-insensitive file systems
1078 implicit_include_directories : false)
1080 pkgconfig_gl_variables = [
1081 'gl_platforms=' + ' '.join(enabled_gl_platforms),
1082 'gl_winsys=' + ' '.join(enabled_gl_winsys),
1083 'gl_apis=' + ' '.join(enabled_gl_apis),
1086 library_def = {'lib': gstgl}
1087 pkg_name = 'gstreamer-gl-1.0'
1088 pkgconfig.generate(gstgl,
1089 libraries : [gstvideo, gst_base_dep, gst_dep],
1090 variables : pkgconfig_variables + pkgconfig_gl_variables,
1091 uninstalled_variables : pkgconfig_gl_variables,
1092 subdirs : pkgconfig_subdirs,
1093 extra_cflags : ['-I${libdir}/gstreamer-1.0/include'],
1095 description : 'Streaming media framework, OpenGL plugins libraries',
1098 # Desperate times, desperate measures... fix up escaping of our variables
1099 run_command(meson_pkg_config_file_fixup_script,
1100 'gstreamer-gl-1.0', 'gl_platforms', 'gl_winsys', 'gl_apis',
1104 libraries : [gstgl, gl_lib_deps],
1105 subdirs : pkgconfig_subdirs,
1106 name : 'gstreamer-gl-prototypes-1.0',
1107 description : 'Streaming media framework, OpenGL plugins libraries (OpenGL Prototypes)',
1112 'sources' : gl_sources + [gl_enumtypes_h] + [gl_enumtypes_c] + gir_gl_headers,
1113 'namespace' : 'GstGL',
1114 'nsversion' : api_version,
1115 'identifier_prefix' : 'Gst',
1116 'symbol_prefix' : 'gst',
1117 'export_packages' : pkg_name,
1118 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1120 'extra_args' : gir_init_section + ['--c-include=gst/gl/gl.h'],
1121 'dependencies' : [video_dep, gst_dep, gst_base_dep],
1123 library_def += {'gir': [gir]}
1125 gl_gir = gnome.generate_gir(gstgl, kwargs: gir)
1126 gen_sources += [gl_gir]
1129 gst_libraries += [[pkg_name, library_def]]
1130 gstgl_dep = declare_dependency(link_with : gstgl,
1131 include_directories : [libsinc, compat_includes],
1132 sources: gen_sources,
1133 dependencies : [video_dep, gst_base_dep, gl_winsys_deps],
1134 variables: pkgconfig_gl_variables)
1135 gstglproto_dep = declare_dependency(
1136 dependencies : [gstgl_dep] + gl_lib_deps,
1137 sources: gen_sources
1139 meson.override_dependency('gstreamer-gl-1.0', gstgl_dep)
1140 meson.override_dependency('gstreamer-gl-prototypes-1.0', gstglproto_dep)
1142 if gl_x11_headers.length() > 0
1143 install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
1144 pkg_name = 'gstreamer-gl-x11-1.0'
1146 libraries : [gstgl],
1147 requires: ['x11-xcb'],
1148 subdirs : pkgconfig_subdirs,
1150 description : 'Streaming media framework, OpenGL plugins libraries (X11 specifics)',
1155 'sources' : gl_x11_sources + gl_x11_headers,
1156 'namespace' : 'GstGLX11',
1157 'nsversion' : api_version,
1158 'identifier_prefix' : 'Gst',
1159 'symbol_prefix' : 'gst',
1160 'export_packages' : 'gstreamer-gl-x11-1.0',
1161 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1163 'extra_args' : gir_init_section + ['--c-include=gst/gl/x11/x11.h'],
1164 'dependencies' : [video_dep, gst_dep, gst_base_dep]
1166 gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1167 gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1169 gir += {'includes': gir['includes'] + [gl_gir[0]]}
1170 gl_x11_gir = gnome.generate_gir(gstgl, kwargs: gir)
1173 gstglx11_dep = declare_dependency(dependencies : [gstgl_dep, x11_dep, xcb_dep],
1174 sources : gl_x11_gir)
1175 meson.override_dependency('gstreamer-gl-x11-1.0', gstglx11_dep)
1178 if gl_wayland_headers.length() > 0
1179 install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
1180 pkg_name = 'gstreamer-gl-wayland-1.0'
1182 libraries : [gstgl],
1183 requires: ['wayland-egl', 'wayland-client'],
1184 subdirs : pkgconfig_subdirs,
1186 description : 'Streaming media framework, OpenGL plugins libraries (Wayland specifics)',
1191 'sources' : gl_wayland_sources + gl_wayland_headers,
1192 'namespace' : 'GstGLWayland',
1193 'nsversion' : api_version,
1194 'identifier_prefix' : 'Gst',
1195 'symbol_prefix' : 'gst',
1196 'export_packages' : 'gstreamer-gl-wayland-1.0',
1197 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1199 'extra_args' : gir_init_section + ['--c-include=gst/gl/wayland/wayland.h'],
1200 'dependencies' : [video_dep, gst_dep, gst_base_dep]
1203 gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1204 gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1206 gir += {'includes': gir['includes'] + [gl_gir[0]]}
1207 gl_wayland_gir = gnome.generate_gir(gstgl, kwargs: gir)
1210 gstglwayland_dep = declare_dependency(dependencies : [gstgl_dep],
1211 sources : gl_wayland_gir)
1212 meson.override_dependency(pkg_name, gstglwayland_dep)
1215 if gl_egl_headers.length() > 0
1216 install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
1217 pkg_name = 'gstreamer-gl-egl-1.0'
1219 libraries : [gstgl, egl_dep],
1220 subdirs : pkgconfig_subdirs,
1222 description : 'Streaming media framework, OpenGL plugins libraries (EGL specifics)',
1227 'sources' : gl_egl_sources + gl_egl_headers,
1228 'namespace' : 'GstGLEGL',
1229 'nsversion' : api_version,
1230 'identifier_prefix' : 'Gst',
1231 'symbol_prefix' : 'gst',
1232 'export_packages' : pkg_name,
1233 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1235 'extra_args' : gir_init_section + ['--c-include=gst/gl/egl/egl.h'],
1236 'dependencies' : [video_dep, gst_dep, gst_base_dep]
1238 gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1239 gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1241 gir += {'includes': gir['includes'] + [gl_gir[0]]}
1242 gl_egl_gir = gnome.generate_gir(gstgl, kwargs: gir)
1245 gstglegl_dep = declare_dependency(dependencies : [gstgl_dep],
1246 sources : gl_egl_gir)
1247 meson.override_dependency(pkg_name, gstglegl_dep)
1250 if gl_viv_fb_headers.length() > 0
1251 install_headers(gl_viv_fb_headers, subdir : 'gstreamer-1.0/gst/gl/viv-fb')
1252 pkg_name = 'gstreamer-gl-viv-fb-1.0'
1254 libraries : [gstgl],
1255 subdirs : pkgconfig_subdirs,
1257 description : 'Streaming media framework, OpenGL plugins libraries (Vivante Framebuffer specifics)',
1262 'sources' : gl_viv_fb_sources + gl_viv_fb_headers,
1263 'namespace' : 'GstGLVivFB',
1264 'nsversion' : api_version,
1265 'identifier_prefix' : 'Gst',
1266 'symbol_prefix' : 'gst',
1267 'export_packages' : pkg_name,
1268 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1270 'extra_args' : gir_init_section + ['--c-include=gst/gl/viv-fb/gstglviv-fb.h'],
1271 'dependencies' : [video_dep, gst_dep, gst_base_dep]
1273 gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1274 gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1276 gir += {'includes': gir['includes'] + [gl_gir[0]]}
1277 gl_viv_fb_gir = gnome.generate_gir(gstgl, kwargs: gir)
1278 library_def += {'gir_targets': library_def.get('gir_targets', []) + [gl_viv_fb_gir]}
1281 gstglviv_fb_dep = declare_dependency(dependencies : [gstgl_dep],
1282 sources : gl_viv_fb_gir)
1283 meson.override_dependency(pkg_name, gstglviv_fb_dep)
1286 elif get_option('gl').enabled()
1287 error('GStreamer OpenGL integration required via options, but needed dependencies not found.')