17 'gstgloverlaycompositor.c',
19 'gstglrenderbuffer.c',
21 'gstglshaderstrings.c',
40 'gstglcolorconvert.h',
51 'gstgloverlaycompositor.h',
53 'gstglrenderbuffer.h',
55 'gstglshaderstrings.h',
65 gl_prototype_headers = [
66 'glprototypes/all_functions.h',
67 'glprototypes/base.h',
68 'glprototypes/blending.h',
69 'glprototypes/buffers.h',
70 'glprototypes/debug.h',
71 'glprototypes/eglimage.h',
73 'glprototypes/fixedfunction.h',
74 'glprototypes/gles.h',
75 'glprototypes/gstgl_compat.h',
76 'glprototypes/gstgl_gles2compat.h',
77 'glprototypes/Makefile.am',
78 'glprototypes/opengl.h',
79 'glprototypes/query.h',
80 'glprototypes/README',
81 'glprototypes/shaders.h',
82 'glprototypes/sync.h',
87 gl_wayland_headers = []
92 glconf = configuration_data()
97 'GST_GL_HAVE_GLES3EXT3_H',
99 'GST_GL_HAVE_WINDOW_X11',
100 'GST_GL_HAVE_WINDOW_COCOA',
101 'GST_GL_HAVE_WINDOW_WIN32',
102 'GST_GL_HAVE_WINDOW_WAYLAND',
103 'GST_GL_HAVE_WINDOW_ANDROID',
104 'GST_GL_HAVE_WINDOW_DISPMANX',
105 'GST_GL_HAVE_WINDOW_EAGL',
106 'GST_GL_HAVE_WINDOW_VIV_FB',
108 'GST_GL_HAVE_PLATFORM_EGL',
109 'GST_GL_HAVE_PLATFORM_GLX',
110 'GST_GL_HAVE_PLATFORM_WGL',
111 'GST_GL_HAVE_PLATFORM_CGL',
112 'GST_GL_HAVE_PLATFORM_EAGL',
114 'GST_GL_HAVE_DMABUF',
115 'GST_GL_HAVE_VIV_DIRECTVIV',
117 'GST_GL_HAVE_GLEGLIMAGEOES',
118 'GST_GL_HAVE_GLCHAR',
119 'GST_GL_HAVE_GLSIZEIPTR',
120 'GST_GL_HAVE_GLINTPTR',
121 'GST_GL_HAVE_GLSYNC',
122 'GST_GL_HAVE_GLUINT64',
123 'GST_GL_HAVE_GLINT64',
124 'GST_GL_HAVE_EGLATTRIB',
127 foreach option : glconf_options
128 glconf.set10(option, false)
131 gmodule_dep = dependency('gmodule-no-export-2.0',
132 fallback: ['glib', 'libgmodule_dep'])
133 unneeded_dep = dependency('', required : false)
134 if unneeded_dep.found()
135 error ('Found unfindable dependency')
138 # OpenGL/GLES2 libraries
140 # GL platform - EGL, GLX, CGL, WGL, etc
141 gl_platform_deps = []
142 # GL winsys - wayland, X11, Cocoa, win32, etc
144 # other things we need.
146 # Other preprocessor arguments
147 gl_cpp_args = ['-DGST_EXPORTS']
150 enabled_gl_platforms = []
151 enabled_gl_winsys = []
153 # parse provided options
154 libegl_module_name = get_option('with_egl_module_name')
155 if libegl_module_name != ''
156 gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)]
158 libgles2_module_name = get_option('with_gles2_module_name')
159 if libgles2_module_name != ''
160 gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)]
162 libgl_module_name = get_option('with_opengl_module_name')
163 if libgl_module_name != ''
164 gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)]
167 gl_apis_s = get_option ('with_gl_api')
168 if gl_apis_s == 'auto'
169 need_api_opengl = 'auto'
170 need_api_gles2 = 'auto'
172 need_api_opengl = 'no'
173 need_api_gles2 = 'no'
174 gl_apis = gl_apis_s.split(',')
175 foreach api : gl_apis
177 need_api_opengl = 'yes'
179 need_api_gles2 = 'yes'
181 error('Unsupported GL api provided ' + api)
186 gl_platforms_s = get_option ('with_gl_platform')
187 if gl_platforms_s == 'auto'
188 need_platform_egl = 'auto'
189 need_platform_glx = 'auto'
190 need_platform_cgl = 'auto'
191 need_platform_wgl = 'auto'
192 need_platform_eagl = 'auto'
194 need_platform_egl = 'no'
195 need_platform_glx = 'no'
196 need_platform_cgl = 'no'
197 need_platform_wgl = 'no'
198 need_platform_eagl = 'no'
199 gl_platforms = gl_platforms_s.split(',')
200 foreach platform : gl_platforms
202 need_platform_egl = 'yes'
203 elif platform == 'glx'
204 need_platform_glx = 'yes'
205 # elif platform == 'cgl'
206 # need_platform_cgl = 'yes'
207 elif platform == 'wgl'
208 need_platform_wgl = 'yes'
209 # elif platform == 'eagl'
210 # need_platform_eagl = 'yes'
212 error('Unsupported GL platform provided ' + platform)
217 gl_winsys_s = get_option ('with_gl_winsys')
218 if gl_winsys_s == 'auto'
219 need_win_x11 = 'auto'
220 need_win_wayland = 'auto'
221 need_win_win32 = 'auto'
222 need_win_cocoa = 'auto'
223 need_win_eagl = 'auto'
224 need_win_dispmanx = 'auto'
225 need_win_viv_fb = 'auto'
228 need_win_wayland = 'no'
229 need_win_win32 = 'no'
230 need_win_cocoa = 'no'
232 need_win_dispmanx = 'no'
233 need_win_viv_fb = 'no'
234 gl_winsys = gl_winsys_s.split(',')
235 foreach winsys : gl_winsys
238 elif winsys == 'wayland'
239 need_win_wayland = 'yes'
240 elif winsys == 'win32'
241 need_win_win32 = 'yes'
242 # elif winsys == 'cocoa'
243 # need_win_cocoa = 'yes'
244 # elif winsys == 'eagl'
245 # need_win_eagl = 'yes'
246 elif winsys == 'dispmanx'
247 need_win_dispmanx = 'yes'
248 elif winsys == 'viv-fb'
249 need_win_viv_fb = 'yes'
251 error('Unsupported GL winsys provided ' + winsys)
256 gl_include_header = '''
258 # pragma GCC diagnostic push
259 # pragma GCC diagnostic ignored "-Wredundant-decls"
261 #ifndef GL_GLEXT_PROTOTYPES
262 #define GL_GLEXT_PROTOTYPES 1
266 # Desktop OpenGL checks
267 gl_dep = unneeded_dep
268 glx_dep = unneeded_dep
269 if need_api_opengl != 'no' or need_platform_glx != 'no'
270 gl_dep = dependency('gl', required : false)
271 if not gl_dep.found()
272 if host_machine.system() == 'windows'
273 gl_dep = cc.find_library('opengl32', required : false)
274 # elif host_machine.system() == 'darwin'
275 # gl_dep = cc.find_library('OpenGL', required : false)
277 gl_dep = cc.find_library('GL', required : false)
280 if not cc.has_header('GL/gl.h', required : false)
281 gl_dep = unneeded_dep
284 if not gl_dep.found() and need_api_opengl == 'yes'
285 error ('Could not find requested OpenGL library')
290 if need_api_opengl == 'no'
291 gl_dep = unneeded_dep
293 if need_platform_glx == 'no'
294 glx_dep = unneeded_dep
297 opengl_includes = '''
299 # include <OpenGL/OpenGL.h>
300 # include <OpenGL/gl.h>
301 # if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
302 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
303 # include <OpenGL/gl3.h>
307 # include <windows.h>
310 # if __WIN32__ || _WIN32
311 # include <GL/glext.h>
318 gles2_dep = unneeded_dep
321 if need_api_gles2 != 'no'
322 gles2_dep = dependency('glesv2', required : false)
323 if not gles2_dep.found()
324 # if host_machine.system() == 'windows'
325 # elif host_machine.system() == 'darwin'
326 # gles2_dep = cc.find_library('GLESv2', required : false)
328 gles2_dep = cc.find_library('GLESv2', required : false)
331 if not cc.has_header('GLES2/gl2.h', required : false)
332 gles2_dep = unneeded_dep
335 if not gles2_dep.found() and need_api_gles2 == 'yes'
336 error ('Could not find requested OpenGL ES library')
340 gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', required : false, dependencies : gles2_dep)
343 #ifdef HAVE_IOS /* FIXME */
344 # include <OpenGLES/ES2/gl.h>
345 # include <OpenGLES/ES2/glext.h>
348 gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', required : false, dependencies : gles2_dep)
350 # include <GLES3/gl3.h>
351 # include <GLES2/gl2ext.h>'''
354 # include <GLES3/gl3ext.h>'''
358 # include <GLES2/gl2.h>
359 # include <GLES2/gl2ext.h>'''
366 # can we include both gles2 and opengl headers?
367 if gles2_dep.found() and gl_dep.found()
368 gl_include_block = gl_include_header + gles_includes + opengl_includes
369 # TODO: Revert to passing gl_include_block via prefix: once
370 # https://github.com/mesonbuild/meson/issues/2364 is fixed
371 if not cc.compiles(gl_include_block + '\n' + 'void f (void) {}',dependencies : [gles2_dep, gl_dep])
372 message ('Cannot include both OpenGL and OpenGL ES headers')
373 if need_gles2 != 'yes'
374 gles2_dep = unneeded_dep
375 elif need_opengl != 'yes'
376 gl_dep = unneeded_dep
378 error('Both OpenGL and OpenGL ES were requested but cannot be included together')
382 gl_include_block = gl_include_header
384 gl_include_block += gles_includes
387 gl_include_block += opengl_includes
391 gl_lib_deps += gles2_dep
392 glconf.set10('GST_GL_HAVE_GLES2', 1)
394 glconf.set10('GST_GL_HAVE_GLES3', 1)
396 glconf.set10('GST_GL_HAVE_GLES3EXT3_H', 1)
399 enabled_gl_apis += 'gles2'
403 gl_lib_deps += gl_dep
404 glconf.set10('GST_GL_HAVE_OPENGL', 1)
405 enabled_gl_apis += 'opengl'
409 egl_dep = unneeded_dep
410 if need_platform_egl != 'no'
411 egl_dep = dependency('egl', required : false)
412 if not egl_dep.found()
413 egl_dep = cc.find_library('EGL', required : false)
415 if not egl_dep.found() and need_platform_egl == 'yes'
416 error ('Could not find requested EGL library')
424 'egl/gstglcontext_egl.c',
425 'egl/gstgldisplay_egl.c',
426 'egl/gstglmemoryegl.c',
431 'egl/gstgldisplay_egl.h',
432 'egl/gstglmemoryegl.h',
434 gl_platform_deps += egl_dep
435 glconf.set10('GST_GL_HAVE_PLATFORM_EGL', 1)
437 if cc.has_header('libdrm/drm_fourcc.h', required : false)
438 gl_misc_deps += allocators_dep
439 glconf.set10('GST_GL_HAVE_DMABUF', 1)
444 #include <EGL/eglext.h>
446 enabled_gl_platforms += 'egl'
452 wayland_client_dep = unneeded_dep
453 wayland_cursor_dep = unneeded_dep
454 wayland_egl_dep = unneeded_dep
455 if need_win_wayland != 'no'
456 if need_win_wayland == 'yes'
457 if need_platform_egl == 'no'
458 error('Impossible situation requested: Cannot use Wayland without EGL support')
461 if not egl_dep.found()
462 if need_win_wayland == 'yes'
463 error ('Could not find EGL libraries for wayland')
465 message ('Could not find EGL libraries for wayland')
468 wayland_client_dep = dependency('wayland-client', version : '>= 1.0', required : false)
469 wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
470 wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
472 if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found()
474 'wayland/gstgldisplay_wayland.c',
475 'wayland/gstglwindow_wayland_egl.c',
476 'wayland/wayland_event_source.c',
478 gl_wayland_headers += [
479 'wayland/gstgldisplay_wayland.h'
481 glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
482 gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
483 enabled_gl_winsys += 'wayland'
485 if need_win_wayland == 'yes'
486 error ('Could not find requested Wayland libraries')
488 wayland_client_dep = unneeded_dep
489 wayland_cursor_dep = unneeded_dep
490 wayland_egl_dep = unneeded_dep
496 if need_platform_glx == 'yes'
497 if need_win_x11 == 'no'
498 error('Impossible situation requested: Cannot use GLX without X11 support')
499 elif need_api_opengl == 'no'
500 error('Impossible situation requested: Cannot use GLX without the OpenGL library')
504 if need_win_x11 != 'no'
505 xcb_dep = dependency('x11-xcb', required : false)
506 if x11_dep.found() and xcb_dep.found()
508 'x11/gstgldisplay_x11.c',
509 'x11/gstglwindow_x11.c',
510 'x11/xcb_event_source.c',
513 'x11/gstgldisplay_x11.h',
515 glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
516 gl_winsys_deps += [x11_dep, xcb_dep]
517 enabled_gl_winsys += 'x11'
519 if need_platform_glx != 'no' and glx_dep.found()
520 glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
522 'x11/gstglcontext_glx.c',
524 # GLX is in the opengl library on linux
525 gl_platform_deps += glx_dep
526 enabled_gl_platforms += 'glx'
528 elif need_win_x11 == 'yes'
529 error ('Could not find requested X11 libraries')
533 bcm_host_dep = unneeded_dep
534 if need_win_dispmanx != 'no'
536 # Try pkg-config for bcm_host then fallback to find_library to also
537 # support older distribution
538 bcm_host_dep = dependency('bcm_host', required : false)
539 if not bcm_host_dep.found()
540 bcm_host_dep = cc.find_library('bcm_host', required : false)
543 if bcm_host_dep.found()
544 if not egl_dep.found()
545 error('dispmanx requires the use of egl')
549 'dispmanx/gstglwindow_dispmanx_egl.c'
552 glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
553 gl_winsys_deps += bcm_host_dep
554 enabled_gl_winsys += 'dispmanx'
555 gl_cpp_args += ['-DUSE_EGL_RPI']
556 elif need_win_dispmanx == 'yes'
557 error('Could not find dispmanx libraries')
562 if need_platform_wgl == 'yes'
563 if need_win_win32 == 'no'
564 error('Impossible situation requested: Cannot use WGL without the win32 window system')
569 if need_platform_wgl != 'no' and need_win_win32 != 'no'
570 gdi_dep = cc.find_library('gdi32', required : false)
571 # FIXME: Revert back to has_header once it gains prefix support
572 wglext_h = cc.has_header_symbol('GL/wglext.h', 'WGL_WGLEXT_VERSION',
573 prefix : '#include <windows.h>
576 if wglext_h and gdi_dep.found() and gl_dep.found()
577 gl_platform_deps += gdi_dep
579 'win32/win32_message_source.c',
580 'win32/gstglwindow_win32.c',
581 'win32/gstglwindow_win32.c',
583 enabled_gl_winsys += 'win32'
584 gl_winsys_deps += gdi_dep
585 enabled_gl_platforms += 'wgl'
589 if host_machine.system() == 'darwin'
590 # FIXME: how to know if we're on iOS or OS X?
591 # gl_cocoa_headers += [
592 # 'gstglcontext_cocoa.h',
593 # 'gstglcaopengllayer.h',
597 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
598 if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
599 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
600 enabled_gl_winsys += 'viv-fb'
601 glconf.set10('GST_GL_HAVE_WINDOW_VIV_FB', 1)
602 glconf.set10('GST_GL_HAVE_VIV_DIRECTVIV', 1)
604 'viv-fb/gstgldisplay_viv_fb.c',
605 'viv-fb/gstglwindow_viv_fb_egl.c',
607 gl_cpp_args += ['-DEGL_API_FB']
612 # TODO: Add rest of gl config here.
613 # iOS, OS X, win32 specific support
616 if enabled_gl_apis.length() == 0
617 message('No OpenGL API libraries found or requested')
620 if enabled_gl_platforms.length() == 0
621 message('No OpenGL Platforms found or requested')
624 if enabled_gl_winsys.length() == 0
625 message('No OpenGL Window systems found or requested')
630 # find some types that may or may not be defined
631 if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps)
632 glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
634 if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps)
635 glconf.set('GST_GL_HAVE_GLCHAR', 1)
637 if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps)
638 glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
640 if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps)
641 glconf.set('GST_GL_HAVE_GLINTPTR', 1)
643 if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps)
644 glconf.set('GST_GL_HAVE_GLSYNC', 1)
646 if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps)
647 glconf.set('GST_GL_HAVE_GLUINT64', 1)
649 if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps)
650 glconf.set('GST_GL_HAVE_GLINT64', 1)
652 if egl_dep.found() and cc.has_type('EGLAttrib', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep])
653 glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
656 message('Building libgstgl with GL api: ' + ' '.join(enabled_gl_apis))
657 message('Building libgstgl with GL platform: ' + ' '.join(enabled_gl_platforms))
658 message('Building libgstgl with GL winsys: ' + ' '.join(enabled_gl_winsys))
660 install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
661 install_headers(gl_cocoa_headers, subdir : 'gstreamer-1.0/gst/gl/cocoa')
662 install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
663 install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
664 install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
665 install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
667 configure_file(input : 'gstglconfig.h.meson',
668 output : 'gstglconfig.h',
669 install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
670 configuration : glconf)
672 gstgl = library('gstgl-' + api_version,
674 c_args : gst_plugins_base_args + gl_cpp_args,
675 include_directories : [configinc, libsinc],
676 version : libversion,
677 soversion : soversion,
679 dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
680 gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps])
683 gl_gir = gnome.generate_gir(gstgl,
684 sources : gl_sources + gl_headers,
686 nsversion : api_version,
687 identifier_prefix : 'Gst',
688 symbol_prefix : 'gst',
689 export_packages : 'gstreamer-gl-1.0',
690 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
692 extra_args : gir_init_section + ['--c-include=gst/gl/gl.h'],
693 dependencies : [video_dep, gst_dep, gst_base_dep]
695 gen_sources += gl_gir
699 gstgl_dep = declare_dependency(link_with : gstgl,
700 include_directories : [libsinc],
701 sources: gen_sources,
702 dependencies : [video_dep, gst_base_dep] + gl_winsys_deps)