1 if get_option('gl').disabled()
2 message('GStreamer OpenGL integration disabled via options.')
3 gstgl_dep = dependency('', required: false)
13 'gstglcolorconvert.c',
17 'gstglcontextconfig.c',
26 'gstgloverlaycompositor.c',
28 'gstglrenderbuffer.c',
30 'gstglshaderstrings.c',
53 'gstglcolorconvert.h',
55 'gstglcontextconfig.h',
64 'gstgloverlaycompositor.h',
66 'gstglrenderbuffer.h',
68 'gstglshaderstrings.h',
78 gl_headers = gir_gl_headers + [
82 gl_prototype_headers = [
83 'glprototypes/all_functions.h',
84 'glprototypes/base.h',
85 'glprototypes/buffer_storage.h',
86 'glprototypes/blending.h',
87 'glprototypes/buffers.h',
88 'glprototypes/debug.h',
89 'glprototypes/eglimage.h',
91 'glprototypes/fixedfunction.h',
92 'glprototypes/gles.h',
93 'glprototypes/gstgl_compat.h',
94 'glprototypes/gstgl_gles2compat.h',
95 'glprototypes/opengl.h',
96 'glprototypes/query.h',
97 'glprototypes/shaders.h',
98 'glprototypes/sync.h',
104 gl_wayland_sources = []
105 gl_wayland_headers = []
109 glconf = configuration_data()
111 'GST_GL_HAVE_OPENGL',
114 'GST_GL_HAVE_GLES3EXT3_H',
116 'GST_GL_HAVE_WINDOW_X11',
117 'GST_GL_HAVE_WINDOW_COCOA',
118 'GST_GL_HAVE_WINDOW_WIN32',
119 'GST_GL_HAVE_WINDOW_WINRT',
120 'GST_GL_HAVE_WINDOW_WAYLAND',
121 'GST_GL_HAVE_WINDOW_ANDROID',
122 'GST_GL_HAVE_WINDOW_DISPMANX',
123 'GST_GL_HAVE_WINDOW_EAGL',
124 'GST_GL_HAVE_WINDOW_VIV_FB',
125 'GST_GL_HAVE_WINDOW_GBM',
127 'GST_GL_HAVE_PLATFORM_EGL',
128 'GST_GL_HAVE_PLATFORM_GLX',
129 'GST_GL_HAVE_PLATFORM_WGL',
130 'GST_GL_HAVE_PLATFORM_CGL',
131 'GST_GL_HAVE_PLATFORM_EAGL',
133 'GST_GL_HAVE_DMABUF',
134 'GST_GL_HAVE_VIV_DIRECTVIV',
136 'GST_GL_HAVE_GLEGLIMAGEOES',
137 'GST_GL_HAVE_GLCHAR',
138 'GST_GL_HAVE_GLSIZEIPTR',
139 'GST_GL_HAVE_GLINTPTR',
140 'GST_GL_HAVE_GLSYNC',
141 'GST_GL_HAVE_GLUINT64',
142 'GST_GL_HAVE_GLINT64',
143 'GST_GL_HAVE_EGLATTRIB',
144 'GST_GL_HAVE_EGLUINT64KHR',
147 foreach option : glconf_options
148 glconf.set10(option, false)
151 unneeded_dep = dependency('', required : false)
152 if unneeded_dep.found()
153 error ('Found unfindable dependency')
156 # OpenGL/GLES2 libraries
158 # GL platform - EGL, GLX, CGL, WGL, etc
159 gl_platform_deps = []
160 # GL winsys - wayland, X11, Cocoa, win32, etc
162 # other things we need.
164 # Other preprocessor arguments
170 enabled_gl_platforms = []
171 enabled_gl_winsys = []
173 # parse provided options
174 libegl_module_name = get_option('egl_module_name')
175 if libegl_module_name != ''
176 gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)]
178 libgles2_module_name = get_option('gles2_module_name')
179 if libgles2_module_name != ''
180 gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)]
182 libgl_module_name = get_option('opengl_module_name')
183 if libgl_module_name != ''
184 gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)]
187 gl_apis = get_option('gl_api')
188 if gl_apis.contains('auto')
189 need_api_opengl = 'auto'
190 need_api_gles2 = 'auto'
192 need_api_opengl = 'no'
193 need_api_gles2 = 'no'
194 foreach api : gl_apis
196 need_api_opengl = 'yes'
198 need_api_gles2 = 'yes'
200 error('Unsupported GL api provided ' + api)
205 gl_platforms = get_option('gl_platform')
206 if gl_platforms.contains('auto')
207 need_platform_egl = 'auto'
208 need_platform_glx = 'auto'
209 need_platform_cgl = 'auto'
210 need_platform_wgl = 'auto'
211 need_platform_eagl = 'auto'
213 need_platform_egl = 'no'
214 need_platform_glx = 'no'
215 need_platform_cgl = 'no'
216 need_platform_wgl = 'no'
217 need_platform_eagl = 'no'
218 foreach platform : gl_platforms
220 need_platform_egl = 'yes'
221 elif platform == 'glx'
222 need_platform_glx = 'yes'
223 elif platform == 'cgl'
224 need_platform_cgl = 'yes'
225 elif platform == 'wgl'
226 need_platform_wgl = 'yes'
227 elif platform == 'eagl'
228 need_platform_eagl = 'yes'
230 error('Unsupported GL platform provided ' + platform)
235 gl_winsys = get_option('gl_winsys')
236 if gl_winsys.contains('auto')
237 need_win_x11 = 'auto'
238 need_win_wayland = 'auto'
239 need_win_win32 = 'auto'
240 need_win_winrt = 'auto'
241 need_win_cocoa = 'auto'
242 need_win_egl = 'auto'
243 need_win_eagl = 'auto'
244 need_win_dispmanx = 'auto'
245 need_win_viv_fb = 'auto'
246 need_win_gbm = 'auto'
247 need_win_android = 'auto'
250 need_win_wayland = 'no'
251 need_win_win32 = 'no'
252 need_win_winrt = 'no'
253 need_win_cocoa = 'no'
256 need_win_dispmanx = 'no'
257 need_win_viv_fb = 'no'
259 need_win_android = 'no'
260 foreach winsys : gl_winsys
263 elif winsys == 'wayland'
264 need_win_wayland = 'yes'
265 elif winsys == 'win32'
266 need_win_win32 = 'yes'
267 elif winsys == 'winrt'
268 need_win_winrt = 'yes'
269 elif winsys == 'cocoa'
270 need_win_cocoa = 'yes'
273 elif winsys == 'eagl'
274 need_win_eagl = 'yes'
275 elif winsys == 'dispmanx'
276 need_win_dispmanx = 'yes'
277 elif winsys == 'viv-fb'
278 need_win_viv_fb = 'yes'
281 elif winsys == 'android'
282 need_win_android = 'yes'
284 error('Unsupported GL winsys provided ' + winsys)
289 gl_include_header = '''
291 # pragma GCC diagnostic push
292 # pragma GCC diagnostic ignored "-Wredundant-decls"
294 #ifndef GL_GLEXT_PROTOTYPES
295 #define GL_GLEXT_PROTOTYPES 1
299 # convoluted way of getting at the subproject taking into account the wrap-mode
300 # so we don't download a subproject unless allowed
301 gl_header_dep = dependency('', fallback : ['gl-headers', 'gl_headers_dummy_dep'],
303 if gl_header_dep.type_name() == 'internal'
304 # this will only contain the includes of headers that are not found
305 compat_includes = subproject('gl-headers').get_variable('compatibility_includes')
310 # Desktop OpenGL checks
311 gl_dep = unneeded_dep
312 glx_dep = unneeded_dep
314 # (GLVND) OpenGL (without GLX) headers and interface
315 if need_api_opengl != 'no'
316 gl_dep = dependency('opengl', method: 'pkg-config', required : false)
319 # non-GLVND aka Legacy OpenGL
320 if need_api_opengl != 'no' and not gl_dep.found()
321 if host_system == 'darwin'
322 gl_dep = dependency('appleframeworks', modules : ['OpenGL'], required : false)
324 # override meson's braindead gl detection on osx/windows/etc by forcing pkg-config
325 gl_dep = dependency('gl', method: 'pkg-config', required : false)
328 if not gl_dep.found()
329 if host_system == 'windows'
330 gl_dep = cc.find_library('opengl32', required : false)
332 gl_dep = cc.find_library('GL', required : false)
335 if not cc.has_header('GL/gl.h', include_directories : compat_includes)
336 gl_dep = unneeded_dep
339 if not gl_dep.found() and need_api_opengl == 'yes'
340 error ('Could not find requested OpenGL library')
344 gl_includes += [compat_includes]
349 if need_platform_glx != 'no'
350 # (GLVND) GLX library and headers.
351 glx_dep = dependency('glx', method: 'pkg-config', required : false)
353 if not glx_dep.found()
354 if host_system == 'darwin'
355 glx_dep = cc.find_library('GL', required : false)
358 elif need_platform_glx == 'yes'
359 error ('Could not find requested GLX library')
364 if need_api_opengl != 'no'
366 if host_system == 'darwin'
367 opengl_includes += '''
368 #if !defined(MAC_OS_X_VERSION_MAX_ALLOWED) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1014
369 # define GL_SILENCE_DEPRECATION
371 #include <OpenGL/OpenGL.h>
372 #include <OpenGL/gl.h>
373 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
374 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
375 # include <OpenGL/gl3.h>
379 opengl_includes += '''
381 # include <windows.h>
384 #if __WIN32__ || _WIN32
385 # include <GL/glext.h>
391 bcm_host_dep = unneeded_dep
392 if need_win_dispmanx != 'no'
394 # Try pkg-config for bcm_host then fallback to find_library to also
395 # support older distribution
396 bcm_host_dep = dependency('bcm_host', required : false)
397 if not bcm_host_dep.found()
398 bcm_host_dep = cc.find_library('bcm_host', required : false)
403 gles2_dep = unneeded_dep
406 if need_api_gles2 != 'no'
407 if host_system == 'ios'
408 gles2_dep = dependency('appleframeworks', modules : ['OpenGLES'], required : false)
410 if bcm_host_dep.found()
411 gles2_dep = dependency('brcmglesv2', required : false)
413 if not gles2_dep.found()
414 gles2_dep = dependency('glesv2', required : false)
418 if not gles2_dep.found()
419 # if host_system == 'windows'
420 # elif host_system == ios
421 # gles2_dep = cc.find_library('GLESv2', required : false)
423 gles2_dep = cc.find_library('GLESv2', required : false)
426 if not cc.has_header('GLES2/gl2.h', include_directories : compat_includes)
427 gles2_dep = unneeded_dep
430 if not gles2_dep.found() and need_api_gles2 == 'yes'
431 error ('Could not find requested OpenGL ES library')
435 gl_includes += [compat_includes]
439 gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', dependencies : gles2_dep, include_directories : compat_includes)
442 if host_system == 'ios'
444 # include <OpenGLES/ES2/gl.h>
445 # include <OpenGLES/ES2/glext.h>
449 gl_includes += [compat_includes]
450 gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', dependencies : gles2_dep, include_directories : compat_includes)
452 # include <GLES3/gl3.h>
453 # include <GLES2/gl2ext.h>'''
456 # include <GLES3/gl3ext.h>'''
460 # include <GLES2/gl2.h>
461 # include <GLES2/gl2ext.h>'''
466 # can we include both gles2 and opengl headers?
467 if gles2_dep.found() and gl_dep.found()
468 gl_include_block = gl_include_header + gles_includes + opengl_includes
469 # TODO: Revert to passing gl_include_block via prefix: once
470 # https://github.com/mesonbuild/meson/issues/2364 is fixed
471 if not cc.compiles(gl_include_block + '\n' + 'void f (void) {}',dependencies : [gles2_dep, gl_dep], include_directories : compat_includes)
472 message ('Cannot include both OpenGL and OpenGL ES headers')
473 if need_api_gles2 != 'yes'
474 gles2_dep = unneeded_dep
475 elif need_api_opengl != 'yes'
476 gl_dep = unneeded_dep
478 error('Both OpenGL and OpenGL ES were requested but cannot be included together')
482 gl_include_block = gl_include_header
484 gl_include_block += gles_includes
487 gl_include_block += opengl_includes
491 gl_lib_deps += gles2_dep
492 glconf.set10('GST_GL_HAVE_GLES2', 1)
494 glconf.set10('GST_GL_HAVE_GLES3', 1)
496 glconf.set10('GST_GL_HAVE_GLES3EXT3_H', 1)
499 enabled_gl_apis += 'gles2'
503 gl_lib_deps += gl_dep
504 glconf.set10('GST_GL_HAVE_OPENGL', 1)
505 enabled_gl_apis += 'gl'
509 egl_dep = unneeded_dep
510 if need_platform_egl != 'no'
511 if bcm_host_dep.found()
512 egl_dep = dependency('brcmegl', required : false)
514 if not egl_dep.found()
515 egl_dep = dependency('egl', required : false)
517 if not egl_dep.found()
518 egl_dep = cc.find_library('EGL', required : false)
521 if egl_dep.found() and not cc.has_header('EGL/egl.h',
522 dependencies : egl_dep,
523 include_directories : compat_includes)
524 egl_dep = unneeded_dep
526 if egl_dep.found() and not cc.has_header('EGL/eglext.h',
527 dependencies : egl_dep,
528 include_directories : compat_includes)
529 egl_dep = unneeded_dep
536 'egl/gstglcontext_egl.c',
537 'egl/gstgldisplay_egl.c',
538 'egl/gstglmemoryegl.c',
539 'egl/gstgldisplay_egl_device.c',
545 'egl/gstgldisplay_egl.h',
546 'egl/gstglmemoryegl.h',
547 'egl/gstgldisplay_egl_device.h',
549 gl_platform_deps += egl_dep
550 glconf.set10('GST_GL_HAVE_PLATFORM_EGL', 1)
552 if cc.has_header('libdrm/drm_fourcc.h')
553 gl_misc_deps += allocators_dep
554 glconf.set10('GST_GL_HAVE_DMABUF', 1)
559 #include <EGL/eglext.h>
561 enabled_gl_platforms += 'egl'
562 elif need_platform_egl == 'yes'
563 error ('Could not find requested EGL library')
568 if need_win_egl == 'yes'
569 if need_platform_egl == 'no'
570 error('Impossible situation requested: Cannot use Winsys egl without EGL support')
571 elif not egl_dep.found()
572 error ('Could not find EGL libraries for Winsys egl')
574 enabled_gl_winsys += 'egl'
579 wayland_client_dep = unneeded_dep
580 wayland_cursor_dep = unneeded_dep
581 wayland_egl_dep = unneeded_dep
582 if need_win_wayland != 'no'
583 if need_win_wayland == 'yes'
584 if need_platform_egl == 'no'
585 error('Impossible situation requested: Cannot use Wayland without EGL support')
588 if not egl_dep.found()
589 if need_win_wayland == 'yes'
590 error ('Could not find EGL libraries for wayland')
592 message ('Could not find EGL libraries for wayland')
595 wayland_client_dep = dependency('wayland-client', version : '>= 1.11', required : false)
596 wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
597 wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
598 wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.15', required : false)
599 wayland_scanner = find_program('wayland-scanner', required: false)
601 if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found() and wayland_protocols_dep.found() and wayland_scanner.found()
602 # Generate the XDG shell interface
603 wayland_protocols_basedir = wayland_protocols_dep.get_pkgconfig_variable('pkgdatadir')
604 xdg_shell_xml_spec = join_paths(wayland_protocols_basedir, 'stable', 'xdg-shell', 'xdg-shell.xml')
605 xdg_shell_header = custom_target('xdg-shell-client-header',
606 command: [ wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@' ],
607 input: xdg_shell_xml_spec,
608 output: 'xdg-shell-client-protocol.h',
610 xdg_shell_code = custom_target('xdg-shell-client-code',
611 command: [ wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@' ],
612 input: xdg_shell_xml_spec,
613 output: 'xdg-shell-client-protocol.c',
616 gl_wayland_sources += [
617 'wayland/gstgldisplay_wayland.c',
620 'wayland/gstglwindow_wayland_egl.c',
621 'wayland/wayland_event_source.c',
625 gl_wayland_headers += [
627 'wayland/gstgldisplay_wayland.h'
629 glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
630 gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
631 enabled_gl_winsys += 'wayland'
633 if need_win_wayland == 'yes'
634 error ('Could not find requested Wayland libraries')
636 wayland_client_dep = unneeded_dep
637 wayland_cursor_dep = unneeded_dep
638 wayland_egl_dep = unneeded_dep
639 wayland_protocols_dep = unneeded_dep
645 if need_platform_glx == 'yes'
646 if need_win_x11 == 'no'
647 error('Impossible situation requested: Cannot use GLX without X11 support')
648 elif need_api_opengl == 'no'
649 error('Impossible situation requested: Cannot use GLX without the OpenGL library')
653 if need_win_x11 != 'no'
654 xcb_dep = dependency('x11-xcb', required : false)
655 if x11_dep.found() and xcb_dep.found()
657 'x11/gstgldisplay_x11.c',
660 'x11/gstglwindow_x11.c',
661 'x11/xcb_event_source.c',
665 'x11/gstgldisplay_x11.h',
667 glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
668 gl_winsys_deps += [x11_dep, xcb_dep]
669 enabled_gl_winsys += 'x11'
671 if need_platform_glx != 'no' and glx_dep.found() and cc.has_function ('glXMakeCurrent', dependencies : glx_dep)
672 glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
674 'x11/gstglcontext_glx.c',
676 # GLX is in the opengl library on linux
677 gl_platform_deps += glx_dep
678 enabled_gl_platforms += 'glx'
680 elif need_win_x11 == 'yes'
681 error ('Could not find requested X11 libraries')
685 if need_win_dispmanx != 'no'
686 if bcm_host_dep.found()
687 if not egl_dep.found()
688 error('dispmanx requires the use of egl')
692 'dispmanx/gstglwindow_dispmanx_egl.c'
695 glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
696 gl_winsys_deps += bcm_host_dep
697 enabled_gl_winsys += 'dispmanx'
698 gl_cpp_args += ['-DUSE_EGL_RPI']
699 elif need_win_dispmanx == 'yes'
700 error('Could not find dispmanx libraries')
705 if need_platform_wgl == 'yes'
706 if need_win_win32 == 'no'
707 error('Impossible situation requested: Cannot use WGL without the win32 window system')
711 if host_system == 'windows' and need_win_win32 != 'no'
712 gdi_dep = cc.find_library('gdi32', required : false)
715 have_egl_win32 = false
716 if need_platform_wgl != 'no'
717 wglext_h = cc.has_header('GL/wglext.h',
718 prefix : '''#include <windows.h>
719 #include <GL/gl.h>''',
720 include_directories : compat_includes)
721 have_wgl = wglext_h and gl_dep.found()
724 have_egl_win32 = enabled_gl_platforms.contains('egl') and gles2_dep.found()
725 if have_wgl or have_egl_win32
726 gl_includes += [compat_includes]
727 gl_platform_deps += gdi_dep
729 'win32/gstglwindow_win32.c',
731 enabled_gl_winsys += 'win32'
732 gl_winsys_deps += gdi_dep
733 glconf.set('GST_GL_HAVE_WINDOW_WIN32', 1)
738 'wgl/gstglcontext_wgl.c',
740 enabled_gl_platforms += 'wgl'
741 glconf.set('GST_GL_HAVE_PLATFORM_WGL', 1)
747 if need_win_winrt != 'no' and host_system == 'windows'
748 if need_win_winrt == 'yes' and not enabled_gl_platforms.contains('egl')
749 error('Impossible situation requested: Cannot use WinRT ANGLE without EGL support')
753 windows_graphics_h = cc.has_header('windows.graphics.h')
754 windows_app_dep = cc.find_library('WindowsApp', required: false)
755 runtimeobject_lib = cc.find_library('runtimeobject', required: false)
757 if windows_graphics_h and windows_app_dep.found() and runtimeobject_lib.found()
758 enabled_gl_winsys += 'winrt'
759 glconf.set10('GST_GL_HAVE_WINDOW_WINRT', 1)
761 'winrt/gstglwindow_winrt_egl.cpp'
763 gl_winsys_deps += runtimeobject_lib
764 elif need_win_winrt == 'yes'
765 error('WinRT is enabled, but headers/libraries were not found')
767 elif need_win_winrt == 'yes'
768 error('WinRT ANGLE is enabled, but EGL was not found')
770 message('WinRT ANGLE disabled because EGL was not found')
774 if ['darwin', 'ios'].contains(host_system)
776 error('No ObjC compiler found')
779 objc = meson.get_compiler('objc')
780 if not objc.has_argument('-fobjc-arc')
781 error('ARC is required for building')
784 gl_objc_args += ['-fobjc-arc']
788 if need_platform_cgl == 'yes'
789 if need_win_cocoa == 'no'
790 error('Impossible situation requested: Cannot use CGL without Cocoa support')
791 elif need_api_opengl == 'no'
792 error('Impossible situation requested: Cannot use CGL without the OpenGL library')
794 elif need_platform_cgl == 'no' and need_win_cocoa == 'yes'
795 error('Impossible situation requested: Cannot use Cocoa without CGL support')
798 if host_system == 'darwin'
799 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
800 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
801 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
803 if need_platform_cgl != 'no'
804 if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
805 gl_platform_deps += [quartzcore_dep, corefoundation_dep, foundation_dep]
806 enabled_gl_platforms += 'cgl'
807 glconf.set10('GST_GL_HAVE_PLATFORM_CGL', 1)
809 if need_win_cocoa != 'no'
810 cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : false)
813 'cocoa/gstglcaopengllayer.m',
814 'cocoa/gstglcontext_cocoa.m',
815 'cocoa/gstgldisplay_cocoa.m',
816 'cocoa/gstglwindow_cocoa.m'
818 gl_winsys_deps += cocoa_dep
819 enabled_gl_winsys += 'cocoa'
820 glconf.set10('GST_GL_HAVE_WINDOW_COCOA', 1)
821 elif need_win_cocoa == 'yes'
822 error('Could not find Cocoa')
825 elif need_platform_cgl == 'yes'
826 error('Could not find CGL dependencies')
831 if need_platform_eagl == 'yes'
832 if host_system != 'ios'
833 error('Can only use EAGL on iOS')
835 if need_win_eagl == 'no'
836 error('Impossible situation requested: Cannot use EAGL platform without the EAGL window system')
837 elif need_api_gles == 'no'
838 error('Impossible situation requested: Cannot use EAGL platform without the GLES library')
840 elif need_platform_eagl == 'no' and need_win_eagl == 'yes'
841 error('Impossible situation requested: Cannot use EAGL window system without the EAGL platform')
844 if host_system == 'ios' and need_platform_eagl != 'no' and need_win_eagl != 'no'
845 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
846 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
847 coregraphics_dep = dependency('appleframeworks', modules : ['CoreGraphics'], required : false)
848 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
849 uikit_dep = dependency('appleframeworks', modules : ['UIkit'], required : false)
851 if foundation_dep.found() and corefoundation_dep.found() and coregraphics_dep.found() and quartzcore_dep.found() and uikit_dep.found()
852 gl_platform_deps += [
860 'eagl/gstglcontext_eagl.m',
861 'eagl/gstglwindow_eagl.m',
863 enabled_gl_winsys += 'eagl'
864 enabled_gl_platforms += 'eagl'
865 glconf.set('GST_GL_HAVE_WINDOW_EAGL', 1)
866 glconf.set('GST_GL_HAVE_PLATFORM_EAGL', 1)
867 elif need_platform_eagl == 'yes' or need_win_eagl == 'yes'
868 error('Could not find dependencies for EAGL')
873 gbm_gudev_dep = unneeded_dep
874 gbm_libdrm_dep = unneeded_dep
875 gbm_dep = unneeded_dep
876 if need_win_gbm != 'no'
877 if need_win_gbm == 'yes'
878 if need_platform_egl == 'no'
879 error('Impossible situation requested: Cannot use GBM without EGL support')
883 gbm_gudev_dep = dependency('gudev-1.0', version : '>=147', required : false)
884 gbm_libdrm_dep = dependency('libdrm', version : '>= 2.4.55', required : false)
885 gbm_dep = dependency('gbm', required : false)
886 if egl_dep.found() and gbm_gudev_dep.found() and gbm_libdrm_dep.found() and gbm_dep.found()
888 'gbm/gstgldisplay_gbm.c',
889 'gbm/gstgl_gbm_utils.c',
890 'gbm/gstglwindow_gbm_egl.c',
892 enabled_gl_winsys += 'gbm'
893 gl_winsys_deps += [gbm_gudev_dep, gbm_libdrm_dep, gbm_dep]
894 glconf.set('GST_GL_HAVE_WINDOW_GBM', 1)
896 if need_win_gbm == 'yes'
897 error ('Could not find requested GBM libraries')
899 gbm_gudev_dep = unneeded_dep
900 gbm_libdrm_dep = unneeded_dep
901 gbm_dep = unneeded_dep
905 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
906 if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
907 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
908 enabled_gl_winsys += 'viv-fb'
909 glconf.set10('GST_GL_HAVE_WINDOW_VIV_FB', 1)
910 glconf.set10('GST_GL_HAVE_VIV_DIRECTVIV', 1)
912 'viv-fb/gstgldisplay_viv_fb.c',
913 'viv-fb/gstglwindow_viv_fb_egl.c',
915 gl_cpp_args += ['-DEGL_API_FB']
920 if need_win_android == 'yes'
921 if need_platform_egl == 'no'
922 error('Impossible situation requested: Cannot build for Android without EGL')
923 elif need_api_gles2 == 'no'
924 error('Impossible situation requested: Cannot build for Android without GLES2 support')
925 elif host_system != 'android'
926 error('Impossible situation requested: Cannot build for Android without an android system')
930 if host_system == 'android' and need_win_android != 'no' and need_platform_egl != 'no'
931 if gles2_dep.found() and egl_dep.found()
932 enabled_gl_winsys += ['android']
933 glconf.set10('GST_GL_HAVE_WINDOW_ANDROID', 1)
935 'android/gstglwindow_android_egl.c'
941 nvbuf_utils_dep = unneeded_dep
943 # XXX: provide options for this?
944 # c_args and c_link_args can also cover this case just fine e.g.:
945 # -Dc_args='-I/usr/src/jetson_multimedia_api/include' -Dc_link_args='-L/usr/lib/aarch64-linux-gnu/tegra/'
946 nvbuf_utils_dep = cc.find_library('nvbuf_utils', required : false)
947 nvbuf_utils_h = cc.has_header('nvbuf_utils.h')
948 if nvbuf_utils_dep.found() and nvbuf_utils_h
949 gl_misc_deps += [nvbuf_utils_dep]
951 gl_cpp_args += ['-DHAVE_NVMM']
956 if enabled_gl_apis.length() == 0
957 message('No OpenGL API libraries found or requested')
960 if enabled_gl_platforms.length() == 0
961 message('No OpenGL Platforms found or requested')
964 if enabled_gl_winsys.length() == 0
965 message('No OpenGL Window systems found or requested')
969 gstgl_dep = dependency('', required : false)
970 gstglproto_dep = dependency('', required : false)
971 gstglx11_dep = dependency('', required : false)
972 gstglwayland_dep = dependency('', required : false)
973 gstglegl_dep = dependency('', required : false)
976 # find some types that may or may not be defined
977 if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
978 glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
980 if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
981 glconf.set('GST_GL_HAVE_GLCHAR', 1)
983 if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
984 glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
986 if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
987 glconf.set('GST_GL_HAVE_GLINTPTR', 1)
989 if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
990 glconf.set('GST_GL_HAVE_GLSYNC', 1)
992 if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
993 glconf.set('GST_GL_HAVE_GLUINT64', 1)
995 if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
996 glconf.set('GST_GL_HAVE_GLINT64', 1)
998 if egl_dep.found() and cc.has_type('EGLAttrib', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep], include_directories : gl_includes)
999 glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
1001 if egl_dep.found() and cc.has_type('EGLuint64KHR', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep], include_directories : gl_includes)
1002 glconf.set('GST_GL_HAVE_EGLUINT64KHR', 1)
1005 summary('GL api', enabled_gl_apis, list_sep: ', ')
1006 summary('GL platform', enabled_gl_platforms, list_sep: ', ')
1007 summary('GL winsys', enabled_gl_winsys, list_sep: ', ')
1009 install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
1010 install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
1012 configure_file(input : 'gstglconfig.h.meson',
1013 output : 'gstglconfig.h',
1014 install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
1015 configuration : glconf)
1017 glib_mkenums = find_program('glib-mkenums')
1018 mkenums = find_program('gl_mkenum.py')
1019 gl_enumtypes_h = custom_target('gstglenumtypes_h',
1020 output : 'gl-enumtypes.h',
1021 input : gir_gl_headers,
1023 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/gl/'),
1024 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1026 gl_enumtypes_c = custom_target('gstglenumtypes_c',
1027 output : 'gl-enumtypes.c',
1028 input : gir_gl_headers,
1029 depends : [gl_enumtypes_h],
1030 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1031 gen_sources = [gl_enumtypes_h]
1033 common_args = gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL']
1035 # We have custom_target() that generate headers in the current build dir,
1036 # but with implicit_include_directories: false, meson >= 0.58.0 won't include
1037 # it by default. We cannot use include_directories('.') here because it would
1038 # also include current source dir which is what we want to avoid because
1039 # case-insensitive FS would include gst-libs/gl/egl/egl.h as EGL/egl.h.
1040 common_args += '-I@0@'.format(meson.current_build_dir())
1042 gstgl = library('gstgl-' + api_version,
1043 gl_sources, gl_egl_sources, gl_x11_sources, gl_wayland_sources, gl_priv_sources, gl_enumtypes_c, gl_enumtypes_h,
1044 c_args : common_args,
1045 cpp_args : common_args,
1046 objc_args : common_args + gl_objc_args,
1047 include_directories : [configinc, libsinc, gl_includes],
1048 version : libversion,
1049 soversion : soversion,
1050 darwin_versions : osxversion,
1052 dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
1053 gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps],
1054 # don't confuse EGL/egl.h with gst-libs/gl/egl/egl.h on case-insensitive file systems
1055 implicit_include_directories : false)
1057 pkgconfig_gl_variables = [
1058 'gl_platforms=' + ' '.join(enabled_gl_platforms),
1059 'gl_winsys=' + ' '.join(enabled_gl_winsys),
1060 'gl_apis=' + ' '.join(enabled_gl_apis),
1063 pkgconfig.generate(gstgl,
1064 libraries : [gstvideo, gst_base_dep, gst_dep],
1065 variables : pkgconfig_variables + pkgconfig_gl_variables,
1066 uninstalled_variables : pkgconfig_gl_variables,
1067 subdirs : pkgconfig_subdirs,
1068 extra_cflags : ['-I${libdir}/gstreamer-1.0/include'],
1069 name : 'gstreamer-gl-1.0',
1070 description : 'Streaming media framework, OpenGL plugins libraries',
1073 # Desperate times, desperate measures... fix up escaping of our variables
1074 run_command(meson_pkg_config_file_fixup_script,
1075 'gstreamer-gl-1.0', 'gl_platforms', 'gl_winsys', 'gl_apis',
1079 libraries : [gstgl, gl_lib_deps],
1080 subdirs : pkgconfig_subdirs,
1081 name : 'gstreamer-gl-prototypes-1.0',
1082 description : 'Streaming media framework, OpenGL plugins libraries (OpenGL Prototypes)',
1086 gl_gir = gnome.generate_gir(gstgl,
1087 sources : gl_sources + [gl_enumtypes_h] + [gl_enumtypes_c] + gir_gl_headers,
1088 namespace : 'GstGL',
1089 nsversion : api_version,
1090 identifier_prefix : 'Gst',
1091 symbol_prefix : 'gst',
1092 export_packages : 'gstreamer-gl-1.0',
1093 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1095 extra_args : gir_init_section + ['--c-include=gst/gl/gl.h'],
1096 dependencies : [video_dep, gst_dep, gst_base_dep]
1098 gen_sources += gl_gir
1101 gstgl_dep = declare_dependency(link_with : gstgl,
1102 include_directories : [libsinc, compat_includes],
1103 sources: gen_sources,
1104 dependencies : [video_dep, gst_base_dep])
1105 gstglproto_dep = declare_dependency(dependencies : [gstgl_dep] + gl_lib_deps)
1106 meson.override_dependency('gstreamer-gl-1.0', gstgl_dep)
1107 meson.override_dependency('gstreamer-gl-prototypes-1.0', gstglproto_dep)
1109 if gl_x11_headers.length() > 0
1110 install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
1112 libraries : [gstgl],
1113 requires: ['x11-xcb'],
1114 subdirs : pkgconfig_subdirs,
1115 name : 'gstreamer-gl-x11-1.0',
1116 description : 'Streaming media framework, OpenGL plugins libraries (X11 specifics)',
1120 gl_x11_gir = gnome.generate_gir(gstgl,
1121 sources : gl_x11_sources + gl_x11_headers,
1122 namespace : 'GstGLX11',
1123 nsversion : api_version,
1124 identifier_prefix : 'Gst',
1125 symbol_prefix : 'gst',
1126 export_packages : 'gstreamer-gl-x11-1.0',
1127 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', gl_gir[0]],
1129 extra_args : gir_init_section + ['--c-include=gst/gl/x11/x11.h'],
1130 dependencies : [video_dep, gst_dep, gst_base_dep]
1133 gstglx11_dep = declare_dependency(dependencies : [gstgl_dep],
1134 sources : gl_x11_gir)
1135 meson.override_dependency('gstreamer-gl-x11-1.0', gstglx11_dep)
1138 if gl_wayland_headers.length() > 0
1139 install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
1141 libraries : [gstgl],
1142 requires: ['wayland-egl', 'wayland-client'],
1143 subdirs : pkgconfig_subdirs,
1144 name : 'gstreamer-gl-wayland-1.0',
1145 description : 'Streaming media framework, OpenGL plugins libraries (Wayland specifics)',
1149 gl_wayland_gir = gnome.generate_gir(gstgl,
1150 sources : gl_wayland_sources + gl_wayland_headers,
1151 namespace : 'GstGLWayland',
1152 nsversion : api_version,
1153 identifier_prefix : 'Gst',
1154 symbol_prefix : 'gst',
1155 export_packages : 'gstreamer-gl-wayland-1.0',
1156 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', gl_gir[0]],
1158 extra_args : gir_init_section + ['--c-include=gst/gl/wayland/wayland.h'],
1159 dependencies : [video_dep, gst_dep, gst_base_dep]
1162 gstglwayland_dep = declare_dependency(dependencies : [gstgl_dep],
1163 sources : gl_wayland_gir)
1164 meson.override_dependency('gstreamer-gl-wayland-1.0', gstglwayland_dep)
1167 if gl_egl_headers.length() > 0
1168 install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
1170 libraries : [gstgl, egl_dep],
1171 subdirs : pkgconfig_subdirs,
1172 name : 'gstreamer-gl-egl-1.0',
1173 description : 'Streaming media framework, OpenGL plugins libraries (EGL specifics)',
1177 gl_egl_gir = gnome.generate_gir(gstgl,
1178 sources : gl_egl_sources + gl_egl_headers,
1179 namespace : 'GstGLEGL',
1180 nsversion : api_version,
1181 identifier_prefix : 'Gst',
1182 symbol_prefix : 'gst',
1183 export_packages : 'gstreamer-gl-egl-1.0',
1184 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', gl_gir[0]],
1186 extra_args : gir_init_section + ['--c-include=gst/gl/egl/egl.h'],
1187 dependencies : [video_dep, gst_dep, gst_base_dep]
1190 gstglegl_dep = declare_dependency(dependencies : [gstgl_dep],
1191 sources : gl_egl_gir)
1192 meson.override_dependency('gstreamer-gl-egl-1.0', gstglegl_dep)
1195 elif get_option('gl').enabled()
1196 error('GStreamer OpenGL integration required via options, but needed dependencies not found.')