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/blending.h',
86 'glprototypes/buffers.h',
87 'glprototypes/debug.h',
88 'glprototypes/eglimage.h',
90 'glprototypes/fixedfunction.h',
91 'glprototypes/gles.h',
92 'glprototypes/gstgl_compat.h',
93 'glprototypes/gstgl_gles2compat.h',
94 'glprototypes/opengl.h',
95 'glprototypes/query.h',
96 'glprototypes/shaders.h',
97 'glprototypes/sync.h',
103 gl_wayland_sources = []
104 gl_wayland_headers = []
108 glconf = configuration_data()
110 'GST_GL_HAVE_OPENGL',
113 'GST_GL_HAVE_GLES3EXT3_H',
115 'GST_GL_HAVE_WINDOW_X11',
116 'GST_GL_HAVE_WINDOW_COCOA',
117 'GST_GL_HAVE_WINDOW_WIN32',
118 'GST_GL_HAVE_WINDOW_WINRT',
119 'GST_GL_HAVE_WINDOW_WAYLAND',
120 'GST_GL_HAVE_WINDOW_ANDROID',
121 'GST_GL_HAVE_WINDOW_DISPMANX',
122 'GST_GL_HAVE_WINDOW_EAGL',
123 'GST_GL_HAVE_WINDOW_VIV_FB',
124 'GST_GL_HAVE_WINDOW_GBM',
126 'GST_GL_HAVE_PLATFORM_EGL',
127 'GST_GL_HAVE_PLATFORM_GLX',
128 'GST_GL_HAVE_PLATFORM_WGL',
129 'GST_GL_HAVE_PLATFORM_CGL',
130 'GST_GL_HAVE_PLATFORM_EAGL',
132 'GST_GL_HAVE_DMABUF',
133 'GST_GL_HAVE_VIV_DIRECTVIV',
135 'GST_GL_HAVE_GLEGLIMAGEOES',
136 'GST_GL_HAVE_GLCHAR',
137 'GST_GL_HAVE_GLSIZEIPTR',
138 'GST_GL_HAVE_GLINTPTR',
139 'GST_GL_HAVE_GLSYNC',
140 'GST_GL_HAVE_GLUINT64',
141 'GST_GL_HAVE_GLINT64',
142 'GST_GL_HAVE_EGLATTRIB',
143 'GST_GL_HAVE_EGLUINT64KHR',
146 foreach option : glconf_options
147 glconf.set10(option, false)
150 unneeded_dep = dependency('', required : false)
151 if unneeded_dep.found()
152 error ('Found unfindable dependency')
155 # OpenGL/GLES2 libraries
157 # GL platform - EGL, GLX, CGL, WGL, etc
158 gl_platform_deps = []
159 # GL winsys - wayland, X11, Cocoa, win32, etc
161 # other things we need.
163 # Other preprocessor arguments
169 enabled_gl_platforms = []
170 enabled_gl_winsys = []
172 # parse provided options
173 libegl_module_name = get_option('egl_module_name')
174 if libegl_module_name != ''
175 gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)]
177 libgles2_module_name = get_option('gles2_module_name')
178 if libgles2_module_name != ''
179 gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)]
181 libgl_module_name = get_option('opengl_module_name')
182 if libgl_module_name != ''
183 gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)]
186 gl_apis = get_option('gl_api')
187 if gl_apis.contains('auto')
188 need_api_opengl = 'auto'
189 need_api_gles2 = 'auto'
191 need_api_opengl = 'no'
192 need_api_gles2 = 'no'
193 foreach api : gl_apis
195 need_api_opengl = 'yes'
197 need_api_gles2 = 'yes'
199 error('Unsupported GL api provided ' + api)
204 gl_platforms = get_option('gl_platform')
205 if gl_platforms.contains('auto')
206 need_platform_egl = 'auto'
207 need_platform_glx = 'auto'
208 need_platform_cgl = 'auto'
209 need_platform_wgl = 'auto'
210 need_platform_eagl = 'auto'
212 need_platform_egl = 'no'
213 need_platform_glx = 'no'
214 need_platform_cgl = 'no'
215 need_platform_wgl = 'no'
216 need_platform_eagl = 'no'
217 foreach platform : gl_platforms
219 need_platform_egl = 'yes'
220 elif platform == 'glx'
221 need_platform_glx = 'yes'
222 elif platform == 'cgl'
223 need_platform_cgl = 'yes'
224 elif platform == 'wgl'
225 need_platform_wgl = 'yes'
226 elif platform == 'eagl'
227 need_platform_eagl = 'yes'
229 error('Unsupported GL platform provided ' + platform)
234 gl_winsys = get_option('gl_winsys')
235 if gl_winsys.contains('auto')
236 need_win_x11 = 'auto'
237 need_win_wayland = 'auto'
238 need_win_win32 = 'auto'
239 need_win_winrt = 'auto'
240 need_win_cocoa = 'auto'
241 need_win_egl = 'auto'
242 need_win_eagl = 'auto'
243 need_win_dispmanx = 'auto'
244 need_win_viv_fb = 'auto'
245 need_win_gbm = 'auto'
246 need_win_android = 'auto'
249 need_win_wayland = 'no'
250 need_win_win32 = 'no'
251 need_win_winrt = 'no'
252 need_win_cocoa = 'no'
255 need_win_dispmanx = 'no'
256 need_win_viv_fb = 'no'
258 need_win_android = 'no'
259 foreach winsys : gl_winsys
262 elif winsys == 'wayland'
263 need_win_wayland = 'yes'
264 elif winsys == 'win32'
265 need_win_win32 = 'yes'
266 elif winsys == 'winrt'
267 need_win_winrt = 'yes'
268 elif winsys == 'cocoa'
269 need_win_cocoa = 'yes'
272 elif winsys == 'eagl'
273 need_win_eagl = 'yes'
274 elif winsys == 'dispmanx'
275 need_win_dispmanx = 'yes'
276 elif winsys == 'viv-fb'
277 need_win_viv_fb = 'yes'
280 elif winsys == 'android'
281 need_win_android = 'yes'
283 error('Unsupported GL winsys provided ' + winsys)
288 gl_include_header = '''
290 # pragma GCC diagnostic push
291 # pragma GCC diagnostic ignored "-Wredundant-decls"
293 #ifndef GL_GLEXT_PROTOTYPES
294 #define GL_GLEXT_PROTOTYPES 1
298 # convoluted way of getting at the subproject taking into account the wrap-mode
299 # so we don't download a subproject unless allowed
300 gl_header_dep = dependency('', fallback : ['gl-headers', 'gl_headers_dummy_dep'],
302 if gl_header_dep.type_name() == 'internal'
303 # this will only contain the includes of headers that are not found
304 compat_includes = subproject('gl-headers').get_variable('compatibility_includes')
309 # Desktop OpenGL checks
310 gl_dep = unneeded_dep
311 glx_dep = unneeded_dep
313 # (GLVND) OpenGL (without GLX) headers and interface
314 if need_api_opengl != 'no'
315 gl_dep = dependency('opengl', method: 'pkg-config', required : false)
318 # non-GLVND aka Legacy OpenGL
319 if need_api_opengl != 'no' and not gl_dep.found()
320 if host_system == 'darwin'
321 gl_dep = dependency('appleframeworks', modules : ['OpenGL'], required : false)
323 # override meson's braindead gl detection on osx/windows/etc by forcing pkg-config
324 gl_dep = dependency('gl', method: 'pkg-config', required : false)
327 if not gl_dep.found()
328 if host_system == 'windows'
329 gl_dep = cc.find_library('opengl32', required : false)
331 gl_dep = cc.find_library('GL', required : false)
334 if not cc.has_header('GL/gl.h', include_directories : compat_includes)
335 gl_dep = unneeded_dep
338 if not gl_dep.found() and need_api_opengl == 'yes'
339 error ('Could not find requested OpenGL library')
343 gl_includes += [compat_includes]
348 if need_platform_glx != 'no'
349 # (GLVND) GLX library and headers.
350 glx_dep = dependency('glx', method: 'pkg-config', required : false)
352 if not glx_dep.found()
353 if host_system == 'darwin'
354 glx_dep = cc.find_library('GL', required : false)
357 elif need_platform_glx == 'yes'
358 error ('Could not find requested GLX library')
363 if need_api_opengl != 'no'
365 if host_system == 'darwin'
366 opengl_includes += '''
367 #if !defined(MAC_OS_X_VERSION_MAX_ALLOWED) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1014
368 # define GL_SILENCE_DEPRECATION
370 #include <OpenGL/OpenGL.h>
371 #include <OpenGL/gl.h>
372 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
373 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
374 # include <OpenGL/gl3.h>
378 opengl_includes += '''
380 # include <windows.h>
383 #if __WIN32__ || _WIN32
384 # include <GL/glext.h>
390 bcm_host_dep = unneeded_dep
391 if need_win_dispmanx != 'no'
393 # Try pkg-config for bcm_host then fallback to find_library to also
394 # support older distribution
395 bcm_host_dep = dependency('bcm_host', required : false)
396 if not bcm_host_dep.found()
397 bcm_host_dep = cc.find_library('bcm_host', required : false)
402 gles2_dep = unneeded_dep
405 if need_api_gles2 != 'no'
406 if host_system == 'ios'
407 gles2_dep = dependency('appleframeworks', modules : ['OpenGLES'], required : false)
409 if bcm_host_dep.found()
410 gles2_dep = dependency('brcmglesv2', required : false)
412 if not gles2_dep.found()
413 gles2_dep = dependency('glesv2', required : false)
417 if not gles2_dep.found()
418 # if host_system == 'windows'
419 # elif host_system == ios
420 # gles2_dep = cc.find_library('GLESv2', required : false)
422 gles2_dep = cc.find_library('GLESv2', required : false)
425 if not cc.has_header('GLES2/gl2.h', include_directories : compat_includes)
426 gles2_dep = unneeded_dep
429 if not gles2_dep.found() and need_api_gles2 == 'yes'
430 error ('Could not find requested OpenGL ES library')
434 gl_includes += [compat_includes]
438 gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', dependencies : gles2_dep, include_directories : compat_includes)
441 if host_system == 'ios'
443 # include <OpenGLES/ES2/gl.h>
444 # include <OpenGLES/ES2/glext.h>
448 gl_includes += [compat_includes]
449 gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', dependencies : gles2_dep, include_directories : compat_includes)
451 # include <GLES3/gl3.h>
452 # include <GLES2/gl2ext.h>'''
455 # include <GLES3/gl3ext.h>'''
459 # include <GLES2/gl2.h>
460 # include <GLES2/gl2ext.h>'''
465 # can we include both gles2 and opengl headers?
466 if gles2_dep.found() and gl_dep.found()
467 gl_include_block = gl_include_header + gles_includes + opengl_includes
468 # TODO: Revert to passing gl_include_block via prefix: once
469 # https://github.com/mesonbuild/meson/issues/2364 is fixed
470 if not cc.compiles(gl_include_block + '\n' + 'void f (void) {}',dependencies : [gles2_dep, gl_dep], include_directories : compat_includes)
471 message ('Cannot include both OpenGL and OpenGL ES headers')
472 if need_api_gles2 != 'yes'
473 gles2_dep = unneeded_dep
474 elif need_api_opengl != 'yes'
475 gl_dep = unneeded_dep
477 error('Both OpenGL and OpenGL ES were requested but cannot be included together')
481 gl_include_block = gl_include_header
483 gl_include_block += gles_includes
486 gl_include_block += opengl_includes
490 gl_lib_deps += gles2_dep
491 glconf.set10('GST_GL_HAVE_GLES2', 1)
493 glconf.set10('GST_GL_HAVE_GLES3', 1)
495 glconf.set10('GST_GL_HAVE_GLES3EXT3_H', 1)
498 enabled_gl_apis += 'gles2'
502 gl_lib_deps += gl_dep
503 glconf.set10('GST_GL_HAVE_OPENGL', 1)
504 enabled_gl_apis += 'gl'
508 egl_dep = unneeded_dep
509 if need_platform_egl != 'no'
510 if bcm_host_dep.found()
511 egl_dep = dependency('brcmegl', required : false)
513 if not egl_dep.found()
514 egl_dep = dependency('egl', required : false)
516 if not egl_dep.found()
517 egl_dep = cc.find_library('EGL', required : false)
520 if egl_dep.found() and not cc.has_header('EGL/egl.h',
521 dependencies : egl_dep,
522 include_directories : compat_includes)
523 egl_dep = unneeded_dep
525 if egl_dep.found() and not cc.has_header('EGL/eglext.h',
526 dependencies : egl_dep,
527 include_directories : compat_includes)
528 egl_dep = unneeded_dep
535 'egl/gstglcontext_egl.c',
536 'egl/gstgldisplay_egl.c',
537 'egl/gstglmemoryegl.c',
538 'egl/gstgldisplay_egl_device.c',
544 'egl/gstgldisplay_egl.h',
545 'egl/gstglmemoryegl.h',
546 'egl/gstgldisplay_egl_device.h',
548 gl_platform_deps += egl_dep
549 glconf.set10('GST_GL_HAVE_PLATFORM_EGL', 1)
551 if cc.has_header('libdrm/drm_fourcc.h')
552 gl_misc_deps += allocators_dep
553 glconf.set10('GST_GL_HAVE_DMABUF', 1)
558 #include <EGL/eglext.h>
560 enabled_gl_platforms += 'egl'
561 elif need_platform_egl == 'yes'
562 error ('Could not find requested EGL library')
567 if need_win_egl == 'yes'
568 if need_platform_egl == 'no'
569 error('Impossible situation requested: Cannot use Winsys egl without EGL support')
570 elif not egl_dep.found()
571 error ('Could not find EGL libraries for Winsys egl')
573 enabled_gl_winsys += 'egl'
578 wayland_client_dep = unneeded_dep
579 wayland_cursor_dep = unneeded_dep
580 wayland_egl_dep = unneeded_dep
581 if need_win_wayland != 'no'
582 if need_win_wayland == 'yes'
583 if need_platform_egl == 'no'
584 error('Impossible situation requested: Cannot use Wayland without EGL support')
587 if not egl_dep.found()
588 if need_win_wayland == 'yes'
589 error ('Could not find EGL libraries for wayland')
591 message ('Could not find EGL libraries for wayland')
594 wayland_client_dep = dependency('wayland-client', version : '>= 1.11', required : false)
595 wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
596 wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
597 wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.15', required : false)
598 wayland_scanner = find_program('wayland-scanner', required: false)
600 if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found() and wayland_protocols_dep.found() and wayland_scanner.found()
601 # Generate the XDG shell interface
602 wayland_protocols_basedir = wayland_protocols_dep.get_pkgconfig_variable('pkgdatadir')
603 xdg_shell_xml_spec = join_paths(wayland_protocols_basedir, 'stable', 'xdg-shell', 'xdg-shell.xml')
604 xdg_shell_header = custom_target('xdg-shell-client-header',
605 command: [ wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@' ],
606 input: xdg_shell_xml_spec,
607 output: 'xdg-shell-client-protocol.h',
609 xdg_shell_code = custom_target('xdg-shell-client-code',
610 command: [ wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@' ],
611 input: xdg_shell_xml_spec,
612 output: 'xdg-shell-client-protocol.c',
615 gl_wayland_sources += [
616 'wayland/gstgldisplay_wayland.c',
619 'wayland/gstglwindow_wayland_egl.c',
620 'wayland/wayland_event_source.c',
624 gl_wayland_headers += [
626 'wayland/gstgldisplay_wayland.h'
628 glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
629 gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
630 enabled_gl_winsys += 'wayland'
632 if need_win_wayland == 'yes'
633 error ('Could not find requested Wayland libraries')
635 wayland_client_dep = unneeded_dep
636 wayland_cursor_dep = unneeded_dep
637 wayland_egl_dep = unneeded_dep
638 wayland_protocols_dep = unneeded_dep
644 if need_platform_glx == 'yes'
645 if need_win_x11 == 'no'
646 error('Impossible situation requested: Cannot use GLX without X11 support')
647 elif need_api_opengl == 'no'
648 error('Impossible situation requested: Cannot use GLX without the OpenGL library')
652 if need_win_x11 != 'no'
653 xcb_dep = dependency('x11-xcb', required : false)
654 if x11_dep.found() and xcb_dep.found()
656 'x11/gstgldisplay_x11.c',
659 'x11/gstglwindow_x11.c',
660 'x11/xcb_event_source.c',
664 'x11/gstgldisplay_x11.h',
666 glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
667 gl_winsys_deps += [x11_dep, xcb_dep]
668 enabled_gl_winsys += 'x11'
670 if need_platform_glx != 'no' and glx_dep.found() and cc.has_function ('glXMakeCurrent', dependencies : glx_dep)
671 glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
673 'x11/gstglcontext_glx.c',
675 # GLX is in the opengl library on linux
676 gl_platform_deps += glx_dep
677 enabled_gl_platforms += 'glx'
679 elif need_win_x11 == 'yes'
680 error ('Could not find requested X11 libraries')
684 if need_win_dispmanx != 'no'
685 if bcm_host_dep.found()
686 if not egl_dep.found()
687 error('dispmanx requires the use of egl')
691 'dispmanx/gstglwindow_dispmanx_egl.c'
694 glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
695 gl_winsys_deps += bcm_host_dep
696 enabled_gl_winsys += 'dispmanx'
697 gl_cpp_args += ['-DUSE_EGL_RPI']
698 elif need_win_dispmanx == 'yes'
699 error('Could not find dispmanx libraries')
704 if need_platform_wgl == 'yes'
705 if need_win_win32 == 'no'
706 error('Impossible situation requested: Cannot use WGL without the win32 window system')
710 if host_system == 'windows' and need_win_win32 != 'no'
711 gdi_dep = cc.find_library('gdi32', required : false)
714 have_egl_win32 = false
715 if need_platform_wgl != 'no'
716 wglext_h = cc.has_header('GL/wglext.h',
717 prefix : '''#include <windows.h>
718 #include <GL/gl.h>''',
719 include_directories : compat_includes)
720 have_wgl = wglext_h and gl_dep.found()
723 have_egl_win32 = enabled_gl_platforms.contains('egl') and gles2_dep.found()
724 if have_wgl or have_egl_win32
725 gl_includes += [compat_includes]
726 gl_platform_deps += gdi_dep
728 'win32/gstglwindow_win32.c',
730 enabled_gl_winsys += 'win32'
731 gl_winsys_deps += gdi_dep
732 glconf.set('GST_GL_HAVE_WINDOW_WIN32', 1)
737 'wgl/gstglcontext_wgl.c',
739 enabled_gl_platforms += 'wgl'
740 glconf.set('GST_GL_HAVE_PLATFORM_WGL', 1)
746 if need_win_winrt != 'no' and host_system == 'windows'
747 if need_win_winrt == 'yes' and not enabled_gl_platforms.contains('egl')
748 error('Impossible situation requested: Cannot use WinRT ANGLE without EGL support')
752 windows_graphics_h = cc.has_header('windows.graphics.h')
753 windows_app_dep = cc.find_library('WindowsApp', required: false)
754 runtimeobject_lib = cc.find_library('runtimeobject', required: false)
756 if windows_graphics_h and windows_app_dep.found() and runtimeobject_lib.found()
757 enabled_gl_winsys += 'winrt'
758 glconf.set10('GST_GL_HAVE_WINDOW_WINRT', 1)
760 'winrt/gstglwindow_winrt_egl.cpp'
762 gl_winsys_deps += runtimeobject_lib
763 elif need_win_winrt == 'yes'
764 error('WinRT is enabled, but headers/libraries were not found')
766 elif need_win_winrt == 'yes'
767 error('WinRT ANGLE is enabled, but EGL was not found')
769 message('WinRT ANGLE disabled because EGL was not found')
773 if ['darwin', 'ios'].contains(host_system)
775 error('No ObjC compiler found')
778 objc = meson.get_compiler('objc')
779 if not objc.has_argument('-fobjc-arc')
780 error('ARC is required for building')
783 gl_objc_args += ['-fobjc-arc']
787 if need_platform_cgl == 'yes'
788 if need_win_cocoa == 'no'
789 error('Impossible situation requested: Cannot use CGL without Cocoa support')
790 elif need_api_opengl == 'no'
791 error('Impossible situation requested: Cannot use CGL without the OpenGL library')
793 elif need_platform_cgl == 'no' and need_win_cocoa == 'yes'
794 error('Impossible situation requested: Cannot use Cocoa without CGL support')
797 if host_system == 'darwin'
798 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
799 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
800 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
802 if need_platform_cgl != 'no'
803 if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
804 gl_platform_deps += [quartzcore_dep, corefoundation_dep, foundation_dep]
805 enabled_gl_platforms += 'cgl'
806 glconf.set10('GST_GL_HAVE_PLATFORM_CGL', 1)
808 if need_win_cocoa != 'no'
809 cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : false)
812 'cocoa/gstglcaopengllayer.m',
813 'cocoa/gstglcontext_cocoa.m',
814 'cocoa/gstgldisplay_cocoa.m',
815 'cocoa/gstglwindow_cocoa.m'
817 gl_winsys_deps += cocoa_dep
818 enabled_gl_winsys += 'cocoa'
819 glconf.set10('GST_GL_HAVE_WINDOW_COCOA', 1)
820 elif need_win_cocoa == 'yes'
821 error('Could not find Cocoa')
824 elif need_platform_cgl == 'yes'
825 error('Could not find CGL dependencies')
830 if need_platform_eagl == 'yes'
831 if host_system != 'ios'
832 error('Can only use EAGL on iOS')
834 if need_win_eagl == 'no'
835 error('Impossible situation requested: Cannot use EAGL platform without the EAGL window system')
836 elif need_api_gles == 'no'
837 error('Impossible situation requested: Cannot use EAGL platform without the GLES library')
839 elif need_platform_eagl == 'no' and need_win_eagl == 'yes'
840 error('Impossible situation requested: Cannot use EAGL window system without the EAGL platform')
843 if host_system == 'ios' and need_platform_eagl != 'no' and need_win_eagl != 'no'
844 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
845 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
846 coregraphics_dep = dependency('appleframeworks', modules : ['CoreGraphics'], required : false)
847 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
848 uikit_dep = dependency('appleframeworks', modules : ['UIkit'], required : false)
850 if foundation_dep.found() and corefoundation_dep.found() and coregraphics_dep.found() and quartzcore_dep.found() and uikit_dep.found()
851 gl_platform_deps += [
859 'eagl/gstglcontext_eagl.m',
860 'eagl/gstglwindow_eagl.m',
862 enabled_gl_winsys += 'eagl'
863 enabled_gl_platforms += 'eagl'
864 glconf.set('GST_GL_HAVE_WINDOW_EAGL', 1)
865 glconf.set('GST_GL_HAVE_PLATFORM_EAGL', 1)
866 elif need_platform_eagl == 'yes' or need_win_eagl == 'yes'
867 error('Could not find dependencies for EAGL')
872 gbm_gudev_dep = unneeded_dep
873 gbm_libdrm_dep = unneeded_dep
874 gbm_dep = unneeded_dep
875 if need_win_gbm != 'no'
876 if need_win_gbm == 'yes'
877 if need_platform_egl == 'no'
878 error('Impossible situation requested: Cannot use GBM without EGL support')
882 gbm_gudev_dep = dependency('gudev-1.0', version : '>=147', required : false)
883 gbm_libdrm_dep = dependency('libdrm', version : '>= 2.4.55', required : false)
884 gbm_dep = dependency('gbm', required : false)
885 if egl_dep.found() and gbm_gudev_dep.found() and gbm_libdrm_dep.found() and gbm_dep.found()
887 'gbm/gstgldisplay_gbm.c',
888 'gbm/gstgl_gbm_utils.c',
889 'gbm/gstglwindow_gbm_egl.c',
891 enabled_gl_winsys += 'gbm'
892 gl_winsys_deps += [gbm_gudev_dep, gbm_libdrm_dep, gbm_dep]
893 glconf.set('GST_GL_HAVE_WINDOW_GBM', 1)
895 if need_win_gbm == 'yes'
896 error ('Could not find requested GBM libraries')
898 gbm_gudev_dep = unneeded_dep
899 gbm_libdrm_dep = unneeded_dep
900 gbm_dep = unneeded_dep
904 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
905 if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
906 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
907 enabled_gl_winsys += 'viv-fb'
908 glconf.set10('GST_GL_HAVE_WINDOW_VIV_FB', 1)
909 glconf.set10('GST_GL_HAVE_VIV_DIRECTVIV', 1)
911 'viv-fb/gstgldisplay_viv_fb.c',
912 'viv-fb/gstglwindow_viv_fb_egl.c',
914 gl_cpp_args += ['-DEGL_API_FB']
919 if need_win_android == 'yes'
920 if need_platform_egl == 'no'
921 error('Impossible situation requested: Cannot build for Android without EGL')
922 elif need_api_gles2 == 'no'
923 error('Impossible situation requested: Cannot build for Android without GLES2 support')
924 elif host_system != 'android'
925 error('Impossible situation requested: Cannot build for Android without an android system')
929 if host_system == 'android' and need_win_android != 'no' and need_platform_egl != 'no'
930 if gles2_dep.found() and egl_dep.found()
931 enabled_gl_winsys += ['android']
932 glconf.set10('GST_GL_HAVE_WINDOW_ANDROID', 1)
934 'android/gstglwindow_android_egl.c'
940 nvbuf_utils_dep = unneeded_dep
942 # XXX: provide options for this?
943 # c_args and c_link_args can also cover this case just fine e.g.:
944 # -Dc_args='-I/usr/src/jetson_multimedia_api/include' -Dc_link_args='-L/usr/lib/aarch64-linux-gnu/tegra/'
945 nvbuf_utils_dep = cc.find_library('nvbuf_utils', required : false)
946 nvbuf_utils_h = cc.has_header('nvbuf_utils.h')
947 if nvbuf_utils_dep.found() and nvbuf_utils_h
948 gl_misc_deps += [nvbuf_utils_dep]
950 gl_cpp_args += ['-DHAVE_NVMM']
955 if enabled_gl_apis.length() == 0
956 message('No OpenGL API libraries found or requested')
959 if enabled_gl_platforms.length() == 0
960 message('No OpenGL Platforms found or requested')
963 if enabled_gl_winsys.length() == 0
964 message('No OpenGL Window systems found or requested')
968 gstgl_dep = dependency('', required : false)
969 gstglproto_dep = dependency('', required : false)
970 gstglx11_dep = dependency('', required : false)
971 gstglwayland_dep = dependency('', required : false)
972 gstglegl_dep = dependency('', required : false)
975 # find some types that may or may not be defined
976 if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
977 glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
979 if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
980 glconf.set('GST_GL_HAVE_GLCHAR', 1)
982 if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
983 glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
985 if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
986 glconf.set('GST_GL_HAVE_GLINTPTR', 1)
988 if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
989 glconf.set('GST_GL_HAVE_GLSYNC', 1)
991 if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
992 glconf.set('GST_GL_HAVE_GLUINT64', 1)
994 if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
995 glconf.set('GST_GL_HAVE_GLINT64', 1)
997 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)
998 glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
1000 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)
1001 glconf.set('GST_GL_HAVE_EGLUINT64KHR', 1)
1004 summary('GL api', enabled_gl_apis, list_sep: ', ')
1005 summary('GL platform', enabled_gl_platforms, list_sep: ', ')
1006 summary('GL winsys', enabled_gl_winsys, list_sep: ', ')
1008 install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
1009 install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
1011 configure_file(input : 'gstglconfig.h.meson',
1012 output : 'gstglconfig.h',
1013 install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
1014 configuration : glconf)
1016 glib_mkenums = find_program('glib-mkenums')
1017 mkenums = find_program('gl_mkenum.py')
1018 gl_enumtypes_h = custom_target('gstglenumtypes_h',
1019 output : 'gl-enumtypes.h',
1020 input : gir_gl_headers,
1022 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/gl/'),
1023 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1025 gl_enumtypes_c = custom_target('gstglenumtypes_c',
1026 output : 'gl-enumtypes.c',
1027 input : gir_gl_headers,
1028 depends : [gl_enumtypes_h],
1029 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1030 gen_sources = [gl_enumtypes_h]
1032 common_args = gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL']
1034 # We have custom_target() that generate headers in the current build dir,
1035 # but with implicit_include_directories: false, meson >= 0.58.0 won't include
1036 # it by default. We cannot use include_directories('.') here because it would
1037 # also include current source dir which is what we want to avoid because
1038 # case-insensitive FS would include gst-libs/gl/egl/egl.h as EGL/egl.h.
1039 common_args += '-I@0@'.format(meson.current_build_dir())
1041 gstgl = library('gstgl-' + api_version,
1042 gl_sources, gl_egl_sources, gl_x11_sources, gl_wayland_sources, gl_priv_sources, gl_enumtypes_c, gl_enumtypes_h,
1043 c_args : common_args,
1044 cpp_args : common_args,
1045 objc_args : common_args + gl_objc_args,
1046 include_directories : [configinc, libsinc, gl_includes],
1047 version : libversion,
1048 soversion : soversion,
1049 darwin_versions : osxversion,
1051 dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
1052 gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps],
1053 # don't confuse EGL/egl.h with gst-libs/gl/egl/egl.h on case-insensitive file systems
1054 implicit_include_directories : false)
1056 pkgconfig_gl_variables = [
1057 'gl_platforms=' + ' '.join(enabled_gl_platforms),
1058 'gl_winsys=' + ' '.join(enabled_gl_winsys),
1059 'gl_apis=' + ' '.join(enabled_gl_apis),
1062 pkgconfig.generate(gstgl,
1063 libraries : [gstvideo, gst_base_dep, gst_dep],
1064 variables : pkgconfig_variables + pkgconfig_gl_variables,
1065 uninstalled_variables : pkgconfig_gl_variables,
1066 subdirs : pkgconfig_subdirs,
1067 extra_cflags : ['-I${libdir}/gstreamer-1.0/include'],
1068 name : 'gstreamer-gl-1.0',
1069 description : 'Streaming media framework, OpenGL plugins libraries',
1072 # Desperate times, desperate measures... fix up escaping of our variables
1073 run_command(meson_pkg_config_file_fixup_script,
1074 'gstreamer-gl-1.0', 'gl_platforms', 'gl_winsys', 'gl_apis',
1078 libraries : [gstgl, gl_lib_deps],
1079 subdirs : pkgconfig_subdirs,
1080 name : 'gstreamer-gl-prototypes-1.0',
1081 description : 'Streaming media framework, OpenGL plugins libraries (OpenGL Prototypes)',
1085 gl_gir = gnome.generate_gir(gstgl,
1086 sources : gl_sources + [gl_enumtypes_h] + [gl_enumtypes_c] + gir_gl_headers,
1087 namespace : 'GstGL',
1088 nsversion : api_version,
1089 identifier_prefix : 'Gst',
1090 symbol_prefix : 'gst',
1091 export_packages : 'gstreamer-gl-1.0',
1092 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1094 extra_args : gir_init_section + ['--c-include=gst/gl/gl.h'],
1095 dependencies : [video_dep, gst_dep, gst_base_dep]
1097 gen_sources += gl_gir
1100 gstgl_dep = declare_dependency(link_with : gstgl,
1101 include_directories : [libsinc, compat_includes],
1102 sources: gen_sources,
1103 dependencies : [video_dep, gst_base_dep])
1104 gstglproto_dep = declare_dependency(dependencies : [gstgl_dep] + gl_lib_deps)
1105 meson.override_dependency('gstreamer-gl-1.0', gstgl_dep)
1106 meson.override_dependency('gstreamer-gl-prototypes-1.0', gstglproto_dep)
1108 if gl_x11_headers.length() > 0
1109 install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
1111 libraries : [gstgl],
1112 requires: ['x11-xcb'],
1113 subdirs : pkgconfig_subdirs,
1114 name : 'gstreamer-gl-x11-1.0',
1115 description : 'Streaming media framework, OpenGL plugins libraries (X11 specifics)',
1119 gl_x11_gir = gnome.generate_gir(gstgl,
1120 sources : gl_x11_sources + gl_x11_headers,
1121 namespace : 'GstGLX11',
1122 nsversion : api_version,
1123 identifier_prefix : 'Gst',
1124 symbol_prefix : 'gst',
1125 export_packages : 'gstreamer-gl-x11-1.0',
1126 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', gl_gir[0]],
1128 extra_args : gir_init_section + ['--c-include=gst/gl/x11/x11.h'],
1129 dependencies : [video_dep, gst_dep, gst_base_dep]
1132 gstglx11_dep = declare_dependency(dependencies : [gstgl_dep],
1133 sources : gl_x11_gir)
1134 meson.override_dependency('gstreamer-gl-x11-1.0', gstglx11_dep)
1137 if gl_wayland_headers.length() > 0
1138 install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
1140 libraries : [gstgl],
1141 requires: ['wayland-egl', 'wayland-client'],
1142 subdirs : pkgconfig_subdirs,
1143 name : 'gstreamer-gl-wayland-1.0',
1144 description : 'Streaming media framework, OpenGL plugins libraries (Wayland specifics)',
1148 gl_wayland_gir = gnome.generate_gir(gstgl,
1149 sources : gl_wayland_sources + gl_wayland_headers,
1150 namespace : 'GstGLWayland',
1151 nsversion : api_version,
1152 identifier_prefix : 'Gst',
1153 symbol_prefix : 'gst',
1154 export_packages : 'gstreamer-gl-wayland-1.0',
1155 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', gl_gir[0]],
1157 extra_args : gir_init_section + ['--c-include=gst/gl/wayland/wayland.h'],
1158 dependencies : [video_dep, gst_dep, gst_base_dep]
1161 gstglwayland_dep = declare_dependency(dependencies : [gstgl_dep],
1162 sources : gl_wayland_gir)
1163 meson.override_dependency('gstreamer-gl-wayland-1.0', gstglwayland_dep)
1166 if gl_egl_headers.length() > 0
1167 install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
1169 libraries : [gstgl, egl_dep],
1170 subdirs : pkgconfig_subdirs,
1171 name : 'gstreamer-gl-egl-1.0',
1172 description : 'Streaming media framework, OpenGL plugins libraries (EGL specifics)',
1176 gl_egl_gir = gnome.generate_gir(gstgl,
1177 sources : gl_egl_sources + gl_egl_headers,
1178 namespace : 'GstGLEGL',
1179 nsversion : api_version,
1180 identifier_prefix : 'Gst',
1181 symbol_prefix : 'gst',
1182 export_packages : 'gstreamer-gl-egl-1.0',
1183 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', gl_gir[0]],
1185 extra_args : gir_init_section + ['--c-include=gst/gl/egl/egl.h'],
1186 dependencies : [video_dep, gst_dep, gst_base_dep]
1189 gstglegl_dep = declare_dependency(dependencies : [gstgl_dep],
1190 sources : gl_egl_gir)
1191 meson.override_dependency('gstreamer-gl-egl-1.0', gstglegl_dep)
1194 elif get_option('gl').enabled()
1195 error('GStreamer OpenGL integration required via options, but needed dependencies not found.')