17 'gstgloverlaycompositor.c',
19 'gstglrenderbuffer.c',
21 'gstglshaderstrings.c',
41 'gstglcolorconvert.h',
52 'gstgloverlaycompositor.h',
54 'gstglrenderbuffer.h',
56 'gstglshaderstrings.h',
66 gl_prototype_headers = [
67 'glprototypes/all_functions.h',
68 'glprototypes/base.h',
69 'glprototypes/blending.h',
70 'glprototypes/buffers.h',
71 'glprototypes/debug.h',
72 'glprototypes/eglimage.h',
74 'glprototypes/fixedfunction.h',
75 'glprototypes/gles.h',
76 'glprototypes/gstgl_compat.h',
77 'glprototypes/gstgl_gles2compat.h',
78 'glprototypes/Makefile.am',
79 'glprototypes/opengl.h',
80 'glprototypes/query.h',
81 'glprototypes/README',
82 'glprototypes/shaders.h',
83 'glprototypes/sync.h',
88 gl_wayland_headers = []
93 glconf = configuration_data()
98 'GST_GL_HAVE_GLES3EXT3_H',
100 'GST_GL_HAVE_WINDOW_X11',
101 'GST_GL_HAVE_WINDOW_COCOA',
102 'GST_GL_HAVE_WINDOW_WIN32',
103 'GST_GL_HAVE_WINDOW_WAYLAND',
104 'GST_GL_HAVE_WINDOW_ANDROID',
105 'GST_GL_HAVE_WINDOW_DISPMANX',
106 'GST_GL_HAVE_WINDOW_EAGL',
107 'GST_GL_HAVE_WINDOW_VIV_FB',
108 'GST_GL_HAVE_WINDOW_GBM',
110 'GST_GL_HAVE_PLATFORM_EGL',
111 'GST_GL_HAVE_PLATFORM_GLX',
112 'GST_GL_HAVE_PLATFORM_WGL',
113 'GST_GL_HAVE_PLATFORM_CGL',
114 'GST_GL_HAVE_PLATFORM_EAGL',
116 'GST_GL_HAVE_DMABUF',
117 'GST_GL_HAVE_VIV_DIRECTVIV',
119 'GST_GL_HAVE_GLEGLIMAGEOES',
120 'GST_GL_HAVE_GLCHAR',
121 'GST_GL_HAVE_GLSIZEIPTR',
122 'GST_GL_HAVE_GLINTPTR',
123 'GST_GL_HAVE_GLSYNC',
124 'GST_GL_HAVE_GLUINT64',
125 'GST_GL_HAVE_GLINT64',
126 'GST_GL_HAVE_EGLATTRIB',
129 foreach option : glconf_options
130 glconf.set10(option, false)
133 gmodule_dep = dependency('gmodule-no-export-2.0',
134 fallback: ['glib', 'libgmodule_dep'])
135 unneeded_dep = dependency('', required : false)
136 if unneeded_dep.found()
137 error ('Found unfindable dependency')
140 # OpenGL/GLES2 libraries
142 # GL platform - EGL, GLX, CGL, WGL, etc
143 gl_platform_deps = []
144 # GL winsys - wayland, X11, Cocoa, win32, etc
146 # other things we need.
148 # Other preprocessor arguments
149 gl_cpp_args = ['-DGST_EXPORTS']
152 enabled_gl_platforms = []
153 enabled_gl_winsys = []
155 # parse provided options
156 libegl_module_name = get_option('with_egl_module_name')
157 if libegl_module_name != ''
158 gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)]
160 libgles2_module_name = get_option('with_gles2_module_name')
161 if libgles2_module_name != ''
162 gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)]
164 libgl_module_name = get_option('with_opengl_module_name')
165 if libgl_module_name != ''
166 gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)]
169 gl_apis_s = get_option ('with_gl_api')
170 if gl_apis_s == 'auto'
171 need_api_opengl = 'auto'
172 need_api_gles2 = 'auto'
174 need_api_opengl = 'no'
175 need_api_gles2 = 'no'
176 gl_apis = gl_apis_s.split(',')
177 foreach api : gl_apis
179 need_api_opengl = 'yes'
181 need_api_gles2 = 'yes'
183 error('Unsupported GL api provided ' + api)
188 gl_platforms_s = get_option ('with_gl_platform')
189 if gl_platforms_s == 'auto'
190 need_platform_egl = 'auto'
191 need_platform_glx = 'auto'
192 need_platform_cgl = 'auto'
193 need_platform_wgl = 'auto'
194 need_platform_eagl = 'auto'
196 need_platform_egl = 'no'
197 need_platform_glx = 'no'
198 need_platform_cgl = 'no'
199 need_platform_wgl = 'no'
200 need_platform_eagl = 'no'
201 gl_platforms = gl_platforms_s.split(',')
202 foreach platform : gl_platforms
204 need_platform_egl = 'yes'
205 elif platform == 'glx'
206 need_platform_glx = 'yes'
207 # elif platform == 'cgl'
208 # need_platform_cgl = 'yes'
209 elif platform == 'wgl'
210 need_platform_wgl = 'yes'
211 # elif platform == 'eagl'
212 # need_platform_eagl = 'yes'
214 error('Unsupported GL platform provided ' + platform)
219 gl_winsys_s = get_option ('with_gl_winsys')
220 if gl_winsys_s == 'auto'
221 need_win_x11 = 'auto'
222 need_win_wayland = 'auto'
223 need_win_win32 = 'auto'
224 need_win_cocoa = 'auto'
225 need_win_eagl = 'auto'
226 need_win_dispmanx = 'auto'
227 need_win_viv_fb = 'auto'
228 need_win_gbm = 'auto'
231 need_win_wayland = 'no'
232 need_win_win32 = 'no'
233 need_win_cocoa = 'no'
235 need_win_dispmanx = 'no'
236 need_win_viv_fb = 'no'
238 gl_winsys = gl_winsys_s.split(',')
239 foreach winsys : gl_winsys
242 elif winsys == 'wayland'
243 need_win_wayland = 'yes'
244 elif winsys == 'win32'
245 need_win_win32 = 'yes'
246 # elif winsys == 'cocoa'
247 # need_win_cocoa = 'yes'
248 # elif winsys == 'eagl'
249 # need_win_eagl = 'yes'
250 elif winsys == 'dispmanx'
251 need_win_dispmanx = 'yes'
252 elif winsys == 'viv-fb'
253 need_win_viv_fb = 'yes'
257 error('Unsupported GL winsys provided ' + winsys)
262 gl_include_header = '''
264 # pragma GCC diagnostic push
265 # pragma GCC diagnostic ignored "-Wredundant-decls"
267 #ifndef GL_GLEXT_PROTOTYPES
268 #define GL_GLEXT_PROTOTYPES 1
272 # Desktop OpenGL checks
273 gl_dep = unneeded_dep
274 glx_dep = unneeded_dep
275 if need_api_opengl != 'no' or need_platform_glx != 'no'
276 gl_dep = dependency('gl', required : false)
277 if not gl_dep.found()
278 if host_machine.system() == 'windows'
279 gl_dep = cc.find_library('opengl32', required : false)
280 # elif host_machine.system() == 'darwin'
281 # gl_dep = cc.find_library('OpenGL', required : false)
283 gl_dep = cc.find_library('GL', required : false)
286 if not cc.has_header('GL/gl.h')
287 gl_dep = unneeded_dep
290 if not gl_dep.found() and need_api_opengl == 'yes'
291 error ('Could not find requested OpenGL library')
296 if need_api_opengl == 'no'
297 gl_dep = unneeded_dep
299 if need_platform_glx == 'no'
300 glx_dep = unneeded_dep
303 opengl_includes = '''
305 # include <OpenGL/OpenGL.h>
306 # include <OpenGL/gl.h>
307 # if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
308 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
309 # include <OpenGL/gl3.h>
313 # include <windows.h>
316 # if __WIN32__ || _WIN32
317 # include <GL/glext.h>
324 gles2_dep = unneeded_dep
327 if need_api_gles2 != 'no'
328 gles2_dep = dependency('glesv2', required : false)
329 if not gles2_dep.found()
330 # if host_machine.system() == 'windows'
331 # elif host_machine.system() == 'darwin'
332 # gles2_dep = cc.find_library('GLESv2', required : false)
334 gles2_dep = cc.find_library('GLESv2', required : false)
337 if not cc.has_header('GLES2/gl2.h')
338 gles2_dep = unneeded_dep
341 if not gles2_dep.found() and need_api_gles2 == 'yes'
342 error ('Could not find requested OpenGL ES library')
346 gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', dependencies : gles2_dep)
349 #ifdef HAVE_IOS /* FIXME */
350 # include <OpenGLES/ES2/gl.h>
351 # include <OpenGLES/ES2/glext.h>
354 gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', dependencies : gles2_dep)
356 # include <GLES3/gl3.h>
357 # include <GLES2/gl2ext.h>'''
360 # include <GLES3/gl3ext.h>'''
364 # include <GLES2/gl2.h>
365 # include <GLES2/gl2ext.h>'''
372 # can we include both gles2 and opengl headers?
373 if gles2_dep.found() and gl_dep.found()
374 gl_include_block = gl_include_header + gles_includes + opengl_includes
375 # TODO: Revert to passing gl_include_block via prefix: once
376 # https://github.com/mesonbuild/meson/issues/2364 is fixed
377 if not cc.compiles(gl_include_block + '\n' + 'void f (void) {}',dependencies : [gles2_dep, gl_dep])
378 message ('Cannot include both OpenGL and OpenGL ES headers')
379 if need_api_gles2 != 'yes'
380 gles2_dep = unneeded_dep
381 elif need_api_opengl != 'yes'
382 gl_dep = unneeded_dep
384 error('Both OpenGL and OpenGL ES were requested but cannot be included together')
388 gl_include_block = gl_include_header
390 gl_include_block += gles_includes
393 gl_include_block += opengl_includes
397 gl_lib_deps += gles2_dep
398 glconf.set10('GST_GL_HAVE_GLES2', 1)
400 glconf.set10('GST_GL_HAVE_GLES3', 1)
402 glconf.set10('GST_GL_HAVE_GLES3EXT3_H', 1)
405 enabled_gl_apis += 'gles2'
409 gl_lib_deps += gl_dep
410 glconf.set10('GST_GL_HAVE_OPENGL', 1)
411 enabled_gl_apis += 'opengl'
415 egl_dep = unneeded_dep
416 if need_platform_egl != 'no'
417 egl_dep = dependency('egl', required : false)
418 if not egl_dep.found()
419 egl_dep = cc.find_library('EGL', required : false)
421 if not egl_dep.found() and need_platform_egl == 'yes'
422 error ('Could not find requested EGL library')
430 'egl/gstglcontext_egl.c',
431 'egl/gstgldisplay_egl.c',
432 'egl/gstglmemoryegl.c',
437 'egl/gstgldisplay_egl.h',
438 'egl/gstglmemoryegl.h',
440 gl_platform_deps += egl_dep
441 glconf.set10('GST_GL_HAVE_PLATFORM_EGL', 1)
443 if cc.has_header('libdrm/drm_fourcc.h')
444 gl_misc_deps += allocators_dep
445 glconf.set10('GST_GL_HAVE_DMABUF', 1)
450 #include <EGL/eglext.h>
452 enabled_gl_platforms += 'egl'
458 wayland_client_dep = unneeded_dep
459 wayland_cursor_dep = unneeded_dep
460 wayland_egl_dep = unneeded_dep
461 if need_win_wayland != 'no'
462 if need_win_wayland == 'yes'
463 if need_platform_egl == 'no'
464 error('Impossible situation requested: Cannot use Wayland without EGL support')
467 if not egl_dep.found()
468 if need_win_wayland == 'yes'
469 error ('Could not find EGL libraries for wayland')
471 message ('Could not find EGL libraries for wayland')
474 wayland_client_dep = dependency('wayland-client', version : '>= 1.0', required : false)
475 wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
476 wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
478 if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found()
480 'wayland/gstgldisplay_wayland.c',
481 'wayland/gstglwindow_wayland_egl.c',
482 'wayland/wayland_event_source.c',
484 gl_wayland_headers += [
485 'wayland/gstgldisplay_wayland.h'
487 glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
488 gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
489 enabled_gl_winsys += 'wayland'
491 if need_win_wayland == 'yes'
492 error ('Could not find requested Wayland libraries')
494 wayland_client_dep = unneeded_dep
495 wayland_cursor_dep = unneeded_dep
496 wayland_egl_dep = unneeded_dep
502 if need_platform_glx == 'yes'
503 if need_win_x11 == 'no'
504 error('Impossible situation requested: Cannot use GLX without X11 support')
505 elif need_api_opengl == 'no'
506 error('Impossible situation requested: Cannot use GLX without the OpenGL library')
510 if need_win_x11 != 'no'
511 xcb_dep = dependency('x11-xcb', required : false)
512 if x11_dep.found() and xcb_dep.found()
514 'x11/gstgldisplay_x11.c',
515 'x11/gstglwindow_x11.c',
516 'x11/xcb_event_source.c',
519 'x11/gstgldisplay_x11.h',
521 glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
522 gl_winsys_deps += [x11_dep, xcb_dep]
523 enabled_gl_winsys += 'x11'
525 if need_platform_glx != 'no' and glx_dep.found()
526 glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
528 'x11/gstglcontext_glx.c',
530 # GLX is in the opengl library on linux
531 gl_platform_deps += glx_dep
532 enabled_gl_platforms += 'glx'
534 elif need_win_x11 == 'yes'
535 error ('Could not find requested X11 libraries')
539 bcm_host_dep = unneeded_dep
540 if need_win_dispmanx != 'no'
542 # Try pkg-config for bcm_host then fallback to find_library to also
543 # support older distribution
544 bcm_host_dep = dependency('bcm_host', required : false)
545 if not bcm_host_dep.found()
546 bcm_host_dep = cc.find_library('bcm_host', required : false)
549 if bcm_host_dep.found()
550 if not egl_dep.found()
551 error('dispmanx requires the use of egl')
555 'dispmanx/gstglwindow_dispmanx_egl.c'
558 glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
559 gl_winsys_deps += bcm_host_dep
560 enabled_gl_winsys += 'dispmanx'
561 gl_cpp_args += ['-DUSE_EGL_RPI']
562 elif need_win_dispmanx == 'yes'
563 error('Could not find dispmanx libraries')
568 if need_platform_wgl == 'yes'
569 if need_win_win32 == 'no'
570 error('Impossible situation requested: Cannot use WGL without the win32 window system')
575 if need_platform_wgl != 'no' and need_win_win32 != 'no'
576 gdi_dep = cc.find_library('gdi32', required : false)
577 # FIXME: Revert back to has_header once it gains prefix support
578 wglext_h = cc.has_header_symbol('GL/wglext.h', 'WGL_WGLEXT_VERSION',
579 prefix : '''#include <windows.h>
580 #include <GL/gl.h>''')
582 if wglext_h and gdi_dep.found() and gl_dep.found()
583 gl_platform_deps += gdi_dep
585 'win32/win32_message_source.c',
586 'win32/gstglwindow_win32.c',
587 'win32/gstglwindow_win32.c',
588 'win32/gstglcontext_wgl.c',
590 enabled_gl_winsys += 'win32'
591 gl_winsys_deps += gdi_dep
592 enabled_gl_platforms += 'wgl'
593 glconf.set('GST_GL_HAVE_WINDOW_WIN32', 1)
594 glconf.set('GST_GL_HAVE_PLATFORM_WGL', 1)
598 if host_machine.system() == 'darwin'
599 # FIXME: how to know if we're on iOS or OS X?
600 # gl_cocoa_headers += [
601 # 'gstglcontext_cocoa.h',
602 # 'gstglcaopengllayer.h',
607 gbm_gudev_dep = unneeded_dep
608 gbm_libdrm_dep = unneeded_dep
609 gbm_dep = unneeded_dep
610 if need_win_gbm != 'no'
611 if need_win_gbm == 'yes'
612 if need_platform_egl == 'no'
613 error('Impossible situation requested: Cannot use GBM without EGL support')
617 gbm_gudev_dep = dependency('gudev-1.0', version : '>=147', required : false)
618 gbm_libdrm_dep = dependency('libdrm', version : '>= 2.4.55', required : false)
619 gbm_dep = dependency('gbm', required : false)
620 if egl_dep.found() and gbm_gudev_dep.found() and gbm_libdrm_dep.found() and gbm_dep.found()
622 'gbm/gstgldisplay_gbm.c',
623 'gbm/gstgl_gbm_utils.c',
624 'gbm/gstglwindow_gbm_egl.c',
626 enabled_gl_winsys += 'gbm'
627 gl_winsys_deps += [gbm_gudev_dep, gbm_libdrm_dep, gbm_dep]
628 glconf.set('GST_GL_HAVE_WINDOW_GBM', 1)
630 if need_win_gbm == 'yes'
631 error ('Could not find requested GBM libraries')
633 gbm_gudev_dep = unneeded_dep
634 gbm_libdrm_dep = unneeded_dep
635 gbm_dep = unneeded_dep
639 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
640 if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
641 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
642 enabled_gl_winsys += 'viv-fb'
643 glconf.set10('GST_GL_HAVE_WINDOW_VIV_FB', 1)
644 glconf.set10('GST_GL_HAVE_VIV_DIRECTVIV', 1)
646 'viv-fb/gstgldisplay_viv_fb.c',
647 'viv-fb/gstglwindow_viv_fb_egl.c',
649 gl_cpp_args += ['-DEGL_API_FB']
654 # TODO: Add rest of gl config here.
655 # iOS, OS X, win32 specific support
658 if enabled_gl_apis.length() == 0
659 message('No OpenGL API libraries found or requested')
662 if enabled_gl_platforms.length() == 0
663 message('No OpenGL Platforms found or requested')
666 if enabled_gl_winsys.length() == 0
667 message('No OpenGL Window systems found or requested')
672 # find some types that may or may not be defined
673 if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps)
674 glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
676 if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps)
677 glconf.set('GST_GL_HAVE_GLCHAR', 1)
679 if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps)
680 glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
682 if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps)
683 glconf.set('GST_GL_HAVE_GLINTPTR', 1)
685 if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps)
686 glconf.set('GST_GL_HAVE_GLSYNC', 1)
688 if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps)
689 glconf.set('GST_GL_HAVE_GLUINT64', 1)
691 if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps)
692 glconf.set('GST_GL_HAVE_GLINT64', 1)
694 if egl_dep.found() and cc.has_type('EGLAttrib', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep])
695 glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
698 message('Building libgstgl with GL api: ' + ' '.join(enabled_gl_apis))
699 message('Building libgstgl with GL platform: ' + ' '.join(enabled_gl_platforms))
700 message('Building libgstgl with GL winsys: ' + ' '.join(enabled_gl_winsys))
702 install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
703 install_headers(gl_cocoa_headers, subdir : 'gstreamer-1.0/gst/gl/cocoa')
704 install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
705 install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
706 install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
707 install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
709 configure_file(input : 'gstglconfig.h.meson',
710 output : 'gstglconfig.h',
711 install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
712 configuration : glconf)
714 gstgl = library('gstgl-' + api_version,
716 c_args : gst_plugins_base_args + gl_cpp_args,
717 include_directories : [configinc, libsinc],
718 version : libversion,
719 soversion : soversion,
721 dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
722 gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps])
725 gl_gir = gnome.generate_gir(gstgl,
726 sources : gl_sources + gl_headers,
728 nsversion : api_version,
729 identifier_prefix : 'Gst',
730 symbol_prefix : 'gst',
731 export_packages : 'gstreamer-gl-1.0',
732 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
734 extra_args : gir_init_section + ['--c-include=gst/gl/gl.h'],
735 dependencies : [video_dep, gst_dep, gst_base_dep]
737 gen_sources += gl_gir
741 gstgl_dep = declare_dependency(link_with : gstgl,
742 include_directories : [libsinc],
743 sources: gen_sources,
744 dependencies : [video_dep, gst_base_dep] + gl_winsys_deps)