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 have_dispmanx_window_t = cc.has_type(
694 'EGL_DISPMANX_WINDOW_T',
696 #include <bcm_host.h>
699 dependencies: [gl_lib_deps, egl_dep, bcm_host_dep],
700 include_directories: gl_includes)
702 if have_dispmanx_window_t and bcm_host_dep.found()
703 if not egl_dep.found()
704 error('dispmanx requires the use of egl')
708 'dispmanx/gstglwindow_dispmanx_egl.c'
711 glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
712 gl_winsys_deps += bcm_host_dep
713 enabled_gl_winsys += 'dispmanx'
714 gl_cpp_args += ['-DUSE_EGL_RPI']
715 elif need_win_dispmanx == 'yes'
716 error('Could not find dispmanx libraries')
721 if need_platform_wgl == 'yes'
722 if need_win_win32 == 'no'
723 error('Impossible situation requested: Cannot use WGL without the win32 window system')
727 if host_system == 'windows' and need_win_win32 != 'no'
728 gdi_dep = cc.find_library('gdi32', required : false)
731 have_egl_win32 = false
732 if need_platform_wgl != 'no'
733 wglext_h = cc.has_header('GL/wglext.h',
734 prefix : '''#include <windows.h>
735 #include <GL/gl.h>''',
736 include_directories : compat_includes)
737 have_wgl = wglext_h and gl_dep.found()
740 have_egl_win32 = enabled_gl_platforms.contains('egl') and gles2_dep.found()
741 if have_wgl or have_egl_win32
742 gl_includes += [compat_includes]
743 gl_platform_deps += gdi_dep
745 'win32/gstglwindow_win32.c',
747 enabled_gl_winsys += 'win32'
748 gl_winsys_deps += gdi_dep
749 glconf.set('GST_GL_HAVE_WINDOW_WIN32', 1)
754 'wgl/gstglcontext_wgl.c',
756 enabled_gl_platforms += 'wgl'
757 glconf.set('GST_GL_HAVE_PLATFORM_WGL', 1)
763 if need_win_winrt != 'no' and host_system == 'windows'
764 if need_win_winrt == 'yes' and not enabled_gl_platforms.contains('egl')
765 error('Impossible situation requested: Cannot use WinRT ANGLE without EGL support')
769 windows_graphics_h = cc.has_header('windows.graphics.h')
770 windows_app_dep = cc.find_library('WindowsApp', required: false)
771 runtimeobject_lib = cc.find_library('runtimeobject', required: false)
773 if windows_graphics_h and windows_app_dep.found() and runtimeobject_lib.found()
774 enabled_gl_winsys += 'winrt'
775 glconf.set('GST_GL_HAVE_WINDOW_WINRT', 1)
777 'winrt/gstglwindow_winrt_egl.cpp'
779 gl_winsys_deps += runtimeobject_lib
780 elif need_win_winrt == 'yes'
781 error('WinRT is enabled, but headers/libraries were not found')
783 elif need_win_winrt == 'yes'
784 error('WinRT ANGLE is enabled, but EGL was not found')
786 message('WinRT ANGLE disabled because EGL was not found')
790 if ['darwin', 'ios'].contains(host_system)
792 error('No ObjC compiler found')
795 objc = meson.get_compiler('objc')
796 if not objc.has_argument('-fobjc-arc')
797 error('ARC is required for building')
800 gl_objc_args += ['-fobjc-arc']
804 if need_platform_cgl == 'yes'
805 if need_win_cocoa == 'no'
806 error('Impossible situation requested: Cannot use CGL without Cocoa support')
807 elif need_api_opengl == 'no'
808 error('Impossible situation requested: Cannot use CGL without the OpenGL library')
810 elif need_platform_cgl == 'no' and need_win_cocoa == 'yes'
811 error('Impossible situation requested: Cannot use Cocoa without CGL support')
814 if host_system == 'darwin'
815 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
816 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
817 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
819 if need_platform_cgl != 'no'
820 if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
821 gl_platform_deps += [quartzcore_dep, corefoundation_dep, foundation_dep]
822 enabled_gl_platforms += 'cgl'
823 glconf.set('GST_GL_HAVE_PLATFORM_CGL', 1)
825 if need_win_cocoa != 'no'
826 cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : false)
829 'cocoa/gstglcaopengllayer.m',
830 'cocoa/gstglcontext_cocoa.m',
831 'cocoa/gstgldisplay_cocoa.m',
832 'cocoa/gstglwindow_cocoa.m'
834 gl_winsys_deps += cocoa_dep
835 enabled_gl_winsys += 'cocoa'
836 glconf.set('GST_GL_HAVE_WINDOW_COCOA', 1)
837 elif need_win_cocoa == 'yes'
838 error('Could not find Cocoa')
841 elif need_platform_cgl == 'yes'
842 error('Could not find CGL dependencies')
847 if need_platform_eagl == 'yes'
848 if host_system != 'ios'
849 error('Can only use EAGL on iOS')
851 if need_win_eagl == 'no'
852 error('Impossible situation requested: Cannot use EAGL platform without the EAGL window system')
853 elif need_api_gles == 'no'
854 error('Impossible situation requested: Cannot use EAGL platform without the GLES library')
856 elif need_platform_eagl == 'no' and need_win_eagl == 'yes'
857 error('Impossible situation requested: Cannot use EAGL window system without the EAGL platform')
860 if host_system == 'ios' and need_platform_eagl != 'no' and need_win_eagl != 'no'
861 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
862 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
863 coregraphics_dep = dependency('appleframeworks', modules : ['CoreGraphics'], required : false)
864 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
865 uikit_dep = dependency('appleframeworks', modules : ['UIkit'], required : false)
867 if foundation_dep.found() and corefoundation_dep.found() and coregraphics_dep.found() and quartzcore_dep.found() and uikit_dep.found()
868 gl_platform_deps += [
876 'eagl/gstglcontext_eagl.m',
877 'eagl/gstglwindow_eagl.m',
879 enabled_gl_winsys += 'eagl'
880 enabled_gl_platforms += 'eagl'
881 glconf.set('GST_GL_HAVE_WINDOW_EAGL', 1)
882 glconf.set('GST_GL_HAVE_PLATFORM_EAGL', 1)
883 elif need_platform_eagl == 'yes' or need_win_eagl == 'yes'
884 error('Could not find dependencies for EAGL')
889 gbm_gudev_dep = unneeded_dep
890 gbm_libdrm_dep = unneeded_dep
891 gbm_dep = unneeded_dep
892 if need_win_gbm != 'no'
893 if need_win_gbm == 'yes'
894 if need_platform_egl == 'no'
895 error('Impossible situation requested: Cannot use GBM without EGL support')
899 gbm_gudev_dep = dependency('gudev-1.0', version : '>=147', required : false)
900 gbm_libdrm_dep = dependency('libdrm', version : '>= 2.4.55', required : false)
901 gbm_dep = dependency('gbm', required : false)
902 if egl_dep.found() and gbm_gudev_dep.found() and gbm_libdrm_dep.found() and gbm_dep.found()
904 'gbm/gstgldisplay_gbm.c',
905 'gbm/gstgl_gbm_utils.c',
906 'gbm/gstglwindow_gbm_egl.c',
908 enabled_gl_winsys += 'gbm'
909 gl_winsys_deps += [gbm_gudev_dep, gbm_libdrm_dep, gbm_dep]
910 glconf.set('GST_GL_HAVE_WINDOW_GBM', 1)
912 if need_win_gbm == 'yes'
913 error ('Could not find requested GBM libraries')
915 gbm_gudev_dep = unneeded_dep
916 gbm_libdrm_dep = unneeded_dep
917 gbm_dep = unneeded_dep
921 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
922 if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
923 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
924 enabled_gl_winsys += 'viv-fb'
925 glconf.set('GST_GL_HAVE_WINDOW_VIV_FB', 1)
926 glconf.set('GST_GL_HAVE_VIV_DIRECTVIV', 1)
928 'viv-fb/gstgldisplay_viv_fb.c',
929 'viv-fb/gstglwindow_viv_fb_egl.c',
931 gl_cpp_args += ['-DEGL_API_FB']
932 gl_viv_fb_headers = [
933 'viv-fb/gstgldisplay_viv_fb.h',
934 'viv-fb/gstglwindow_viv_fb_egl.h',
936 install_headers(gl_viv_fb_headers, subdir : 'gstreamer-1.0/gst/gl/viv-fb')
941 if need_win_android == 'yes'
942 if need_platform_egl == 'no'
943 error('Impossible situation requested: Cannot build for Android without EGL')
944 elif need_api_gles2 == 'no'
945 error('Impossible situation requested: Cannot build for Android without GLES2 support')
946 elif host_system != 'android'
947 error('Impossible situation requested: Cannot build for Android without an android system')
951 if host_system == 'android' and need_win_android != 'no' and need_platform_egl != 'no'
952 if gles2_dep.found() and egl_dep.found()
953 enabled_gl_winsys += ['android']
954 glconf.set('GST_GL_HAVE_WINDOW_ANDROID', 1)
956 'android/gstglwindow_android_egl.c'
962 nvbuf_utils_dep = unneeded_dep
964 # XXX: provide options for this?
965 # c_args and c_link_args can also cover this case just fine e.g.:
966 # -Dc_args='-I/usr/src/jetson_multimedia_api/include' -Dc_link_args='-L/usr/lib/aarch64-linux-gnu/tegra/'
967 nvbuf_utils_dep = cc.find_library('nvbuf_utils', required : false)
968 nvbuf_utils_h = cc.has_header('nvbuf_utils.h')
969 if nvbuf_utils_dep.found() and nvbuf_utils_h
970 gl_misc_deps += [nvbuf_utils_dep]
972 gl_cpp_args += ['-DHAVE_NVMM']
977 if enabled_gl_apis.length() == 0
978 message('No OpenGL API libraries found or requested')
981 if enabled_gl_platforms.length() == 0
982 message('No OpenGL Platforms found or requested')
985 if enabled_gl_winsys.length() == 0
986 message('No OpenGL Window systems found or requested')
991 # find some types that may or may not be defined
992 if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
993 glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
995 if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
996 glconf.set('GST_GL_HAVE_GLCHAR', 1)
998 if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
999 glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
1001 if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1002 glconf.set('GST_GL_HAVE_GLINTPTR', 1)
1004 if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1005 glconf.set('GST_GL_HAVE_GLSYNC', 1)
1007 if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1008 glconf.set('GST_GL_HAVE_GLUINT64', 1)
1010 if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1011 glconf.set('GST_GL_HAVE_GLINT64', 1)
1013 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)
1014 glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
1016 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)
1017 glconf.set('GST_GL_HAVE_EGLUINT64KHR', 1)
1020 summary('GL api', enabled_gl_apis, list_sep: ', ')
1021 summary('GL platform', enabled_gl_platforms, list_sep: ', ')
1022 summary('GL winsys', enabled_gl_winsys, list_sep: ', ')
1024 install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
1025 install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
1027 configure_file(input : 'gstglconfig.h.meson',
1028 output : 'gstglconfig.h',
1029 install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
1030 install_tag : 'devel',
1031 configuration : glconf)
1033 glib_mkenums = find_program('glib-mkenums')
1034 mkenums = find_program('gl_mkenum.py')
1035 gl_enumtypes_h = custom_target('gstglenumtypes_h',
1036 output : 'gl-enumtypes.h',
1037 input : gir_gl_headers,
1039 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/gl/'),
1040 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1042 gl_enumtypes_c = custom_target('gstglenumtypes_c',
1043 output : 'gl-enumtypes.c',
1044 input : gir_gl_headers,
1045 depends : [gl_enumtypes_h],
1046 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1047 gen_sources = [gl_enumtypes_h]
1049 common_args = gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL', '-DG_LOG_DOMAIN="GStreamer-GL"']
1051 # We have custom_target() that generate headers in the current build dir,
1052 # but with implicit_include_directories: false, meson >= 0.58.0 won't include
1053 # it by default. We cannot use include_directories('.') here because it would
1054 # also include current source dir which is what we want to avoid because
1055 # case-insensitive FS would include gst-libs/gl/egl/egl.h as EGL/egl.h.
1056 common_args += '-I@0@'.format(meson.current_build_dir())
1058 gstgl = library('gstgl-' + api_version,
1059 gl_sources, gl_egl_sources, gl_x11_sources, gl_wayland_sources, gl_priv_sources, gl_enumtypes_c, gl_enumtypes_h,
1060 c_args : common_args,
1061 cpp_args : common_args,
1062 objc_args : common_args + gl_objc_args,
1063 include_directories : [configinc, libsinc, gl_includes],
1064 version : libversion,
1065 soversion : soversion,
1066 darwin_versions : osxversion,
1068 dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
1069 gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps],
1070 # don't confuse EGL/egl.h with gst-libs/gl/egl/egl.h on case-insensitive file systems
1071 implicit_include_directories : false)
1073 pkgconfig_gl_variables = [
1074 'gl_platforms=' + ' '.join(enabled_gl_platforms),
1075 'gl_winsys=' + ' '.join(enabled_gl_winsys),
1076 'gl_apis=' + ' '.join(enabled_gl_apis),
1079 library_def = {'lib': gstgl}
1080 pkg_name = 'gstreamer-gl-1.0'
1081 pkgconfig.generate(gstgl,
1082 libraries : [gstvideo, gst_base_dep, gst_dep],
1083 variables : pkgconfig_variables + pkgconfig_gl_variables,
1084 uninstalled_variables : pkgconfig_gl_variables,
1085 subdirs : pkgconfig_subdirs,
1086 extra_cflags : ['-I${libdir}/gstreamer-1.0/include'],
1088 description : 'Streaming media framework, OpenGL plugins libraries',
1091 # Desperate times, desperate measures... fix up escaping of our variables
1092 run_command(meson_pkg_config_file_fixup_script,
1093 'gstreamer-gl-1.0', 'gl_platforms', 'gl_winsys', 'gl_apis',
1097 libraries : [gstgl, gl_lib_deps],
1098 subdirs : pkgconfig_subdirs,
1099 name : 'gstreamer-gl-prototypes-1.0',
1100 description : 'Streaming media framework, OpenGL plugins libraries (OpenGL Prototypes)',
1105 'sources' : gl_sources + [gl_enumtypes_h] + [gl_enumtypes_c] + gir_gl_headers,
1106 'namespace' : 'GstGL',
1107 'nsversion' : api_version,
1108 'identifier_prefix' : 'Gst',
1109 'symbol_prefix' : 'gst',
1110 'export_packages' : pkg_name,
1111 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1113 'extra_args' : gir_init_section + ['--c-include=gst/gl/gl.h'],
1114 'dependencies' : [video_dep, gst_dep, gst_base_dep],
1116 library_def += {'gir': [gir]}
1118 gl_gir = gnome.generate_gir(gstgl, kwargs: gir)
1119 gen_sources += [gl_gir]
1122 gst_libraries += [[pkg_name, library_def]]
1123 gstgl_dep = declare_dependency(link_with : gstgl,
1124 include_directories : [libsinc, compat_includes],
1125 sources: gen_sources,
1126 dependencies : [video_dep, gst_base_dep, gl_winsys_deps],
1127 variables: pkgconfig_gl_variables)
1128 gstglproto_dep = declare_dependency(
1129 dependencies : [gstgl_dep] + gl_lib_deps,
1130 sources: gen_sources
1132 meson.override_dependency('gstreamer-gl-1.0', gstgl_dep)
1133 meson.override_dependency('gstreamer-gl-prototypes-1.0', gstglproto_dep)
1135 if gl_x11_headers.length() > 0
1136 install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
1137 pkg_name = 'gstreamer-gl-x11-1.0'
1139 libraries : [gstgl],
1140 requires: ['x11-xcb'],
1141 subdirs : pkgconfig_subdirs,
1143 description : 'Streaming media framework, OpenGL plugins libraries (X11 specifics)',
1148 'sources' : gl_x11_sources + gl_x11_headers,
1149 'namespace' : 'GstGLX11',
1150 'nsversion' : api_version,
1151 'identifier_prefix' : 'Gst',
1152 'symbol_prefix' : 'gst',
1153 'export_packages' : 'gstreamer-gl-x11-1.0',
1154 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1156 'extra_args' : gir_init_section + ['--c-include=gst/gl/x11/x11.h'],
1157 'dependencies' : [video_dep, gst_dep, gst_base_dep]
1159 gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1160 gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1162 gir += {'includes': gir['includes'] + [gl_gir[0]]}
1163 gl_x11_gir = gnome.generate_gir(gstgl, kwargs: gir)
1166 gstglx11_dep = declare_dependency(dependencies : [gstgl_dep, x11_dep, xcb_dep],
1167 sources : gl_x11_gir)
1168 meson.override_dependency('gstreamer-gl-x11-1.0', gstglx11_dep)
1171 if gl_wayland_headers.length() > 0
1172 install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
1173 pkg_name = 'gstreamer-gl-wayland-1.0'
1175 libraries : [gstgl],
1176 requires: ['wayland-egl', 'wayland-client'],
1177 subdirs : pkgconfig_subdirs,
1179 description : 'Streaming media framework, OpenGL plugins libraries (Wayland specifics)',
1184 'sources' : gl_wayland_sources + gl_wayland_headers,
1185 'namespace' : 'GstGLWayland',
1186 'nsversion' : api_version,
1187 'identifier_prefix' : 'Gst',
1188 'symbol_prefix' : 'gst',
1189 'export_packages' : 'gstreamer-gl-wayland-1.0',
1190 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1192 'extra_args' : gir_init_section + ['--c-include=gst/gl/wayland/wayland.h'],
1193 'dependencies' : [video_dep, gst_dep, gst_base_dep]
1196 gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1197 gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1199 gir += {'includes': gir['includes'] + [gl_gir[0]]}
1200 gl_wayland_gir = gnome.generate_gir(gstgl, kwargs: gir)
1203 gstglwayland_dep = declare_dependency(dependencies : [gstgl_dep],
1204 sources : gl_wayland_gir)
1205 meson.override_dependency(pkg_name, gstglwayland_dep)
1208 if gl_egl_headers.length() > 0
1209 install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
1210 pkg_name = 'gstreamer-gl-egl-1.0'
1212 libraries : [gstgl, egl_dep],
1213 subdirs : pkgconfig_subdirs,
1215 description : 'Streaming media framework, OpenGL plugins libraries (EGL specifics)',
1220 'sources' : gl_egl_sources + gl_egl_headers,
1221 'namespace' : 'GstGLEGL',
1222 'nsversion' : api_version,
1223 'identifier_prefix' : 'Gst',
1224 'symbol_prefix' : 'gst',
1225 'export_packages' : pkg_name,
1226 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1228 'extra_args' : gir_init_section + ['--c-include=gst/gl/egl/egl.h'],
1229 'dependencies' : [video_dep, gst_dep, gst_base_dep]
1231 gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1232 gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1234 gir += {'includes': gir['includes'] + [gl_gir[0]]}
1235 gl_egl_gir = gnome.generate_gir(gstgl, kwargs: gir)
1238 gstglegl_dep = declare_dependency(dependencies : [gstgl_dep],
1239 sources : gl_egl_gir)
1240 meson.override_dependency(pkg_name, gstglegl_dep)
1243 elif get_option('gl').enabled()
1244 error('GStreamer OpenGL integration required via options, but needed dependencies not found.')