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 if not cc.compiles('void f (void) {}', prefix : gl_include_block, dependencies : [gles2_dep, gl_dep] )
370 message ('Cannot include both OpenGL and OpenGL ES headers')
371 if need_gles2 != 'yes'
372 gles2_dep = unneeded_dep
373 elif need_opengl != 'yes'
374 gl_dep = unneeded_dep
376 error('Both OpenGL and OpenGL ES were requested but cannot be included together')
380 gl_include_block = gl_include_header
382 gl_include_block += gles_includes
385 gl_include_block += opengl_includes
389 gl_lib_deps += gles2_dep
390 glconf.set10('GST_GL_HAVE_GLES2', 1)
392 glconf.set10('GST_GL_HAVE_GLES3', 1)
394 glconf.set10('GST_GL_HAVE_GLES3EXT3_H', 1)
397 enabled_gl_apis += 'gles2'
401 gl_lib_deps += gl_dep
402 glconf.set10('GST_GL_HAVE_OPENGL', 1)
403 enabled_gl_apis += 'opengl'
407 egl_dep = unneeded_dep
408 if need_platform_egl != 'no'
409 egl_dep = dependency('egl', required : false)
410 if not egl_dep.found()
411 egl_dep = cc.find_library('EGL', required : false)
413 if not egl_dep.found() and need_platform_egl == 'yes'
414 error ('Could not find requested EGL library')
422 'egl/gstglcontext_egl.c',
423 'egl/gstgldisplay_egl.c',
424 'egl/gstglmemoryegl.c',
429 'egl/gstgldisplay_egl.h',
430 'egl/gstglmemoryegl.h',
432 gl_platform_deps += egl_dep
433 glconf.set10('GST_GL_HAVE_PLATFORM_EGL', 1)
435 if cc.has_header('libdrm/drm_fourcc.h', required : false)
436 gl_misc_deps += allocators_dep
437 glconf.set10('GST_GL_HAVE_DMABUF', 1)
442 #include <EGL/eglext.h>
444 enabled_gl_platforms += 'egl'
450 wayland_client_dep = unneeded_dep
451 wayland_cursor_dep = unneeded_dep
452 wayland_egl_dep = unneeded_dep
453 if need_win_wayland != 'no'
454 if need_win_wayland == 'yes'
455 if need_platform_egl == 'no'
456 error('Impossible situation requested: Cannot use Wayland without EGL support')
459 if not egl_dep.found()
460 if need_win_wayland == 'yes'
461 error ('Could not find EGL libraries for wayland')
463 message ('Could not find EGL libraries for wayland')
466 wayland_client_dep = dependency('wayland-client', version : '>= 1.0', required : false)
467 wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
468 wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
470 if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found()
472 'wayland/gstgldisplay_wayland.c',
473 'wayland/gstglwindow_wayland_egl.c',
474 'wayland/wayland_event_source.c',
476 gl_wayland_headers += [
477 'wayland/gstgldisplay_wayland.h'
479 glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
480 gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
481 enabled_gl_winsys += 'wayland'
483 if need_win_wayland == 'yes'
484 error ('Could not find requested Wayland libraries')
486 wayland_client_dep = unneeded_dep
487 wayland_cursor_dep = unneeded_dep
488 wayland_egl_dep = unneeded_dep
494 if need_platform_glx == 'yes'
495 if need_win_x11 == 'no'
496 error('Impossible situation requested: Cannot use GLX without X11 support')
497 elif need_api_opengl == 'no'
498 error('Impossible situation requested: Cannot use GLX without the OpenGL library')
502 if need_win_x11 != 'no'
503 xcb_dep = dependency('x11-xcb', required : false)
504 if x11_dep.found() and xcb_dep.found()
506 'x11/gstgldisplay_x11.c',
507 'x11/gstglwindow_x11.c',
508 'x11/xcb_event_source.c',
511 'x11/gstgldisplay_x11.h',
513 glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
514 gl_winsys_deps += [x11_dep, xcb_dep]
515 enabled_gl_winsys += 'x11'
517 if need_platform_glx != 'no' and glx_dep.found()
518 glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
520 'x11/gstglcontext_glx.c',
522 # GLX is in the opengl library on linux
523 gl_platform_deps += glx_dep
524 enabled_gl_platforms += 'glx'
526 elif need_win_x11 == 'yes'
527 error ('Could not find requested X11 libraries')
531 bcm_host_dep = unneeded_dep
532 if need_win_dispmanx != 'no'
534 # Try pkg-config for bcm_host then fallback to find_library to also
535 # support older distribution
536 bcm_host_dep = dependency('bcm_host', required : false)
537 if not bcm_host_dep.found()
538 bcm_host_dep = cc.find_library('bcm_host', required : false)
541 if bcm_host_dep.found()
542 if not egl_dep.found()
543 error('dispmanx requires the use of egl')
547 'dispmanx/gstglwindow_dispmanx_egl.c'
550 glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
551 gl_winsys_deps += bcm_host_dep
552 enabled_gl_winsys += 'dispmanx'
553 gl_cpp_args += ['-DUSE_EGL_RPI']
554 elif need_win_dispmanx == 'yes'
555 error('Could not find dispmanx libraries')
560 if need_platform_wgl == 'yes'
561 if need_win_win32 == 'no'
562 error('Impossible situation requested: Cannot use WGL without the win32 window system')
567 if need_platform_wgl != 'no' and need_win_win32 != 'no'
568 gdi_dep = cc.find_library('gdi32', required : false)
569 # FIXME: Revert back to has_header once it gains prefix support
570 wglext_h = cc.has_header_symbol('GL/wglext.h', 'WGL_WGLEXT_VERSION',
571 prefix : '#include <windows.h>
574 if wglext_h and gdi_dep.found() and gl_dep.found()
575 gl_platform_deps += gdi_dep
577 'win32/win32_message_source.c',
578 'win32/gstglwindow_win32.c',
579 'win32/gstglwindow_win32.c',
581 enabled_gl_winsys += 'win32'
582 gl_winsys_deps += gdi_dep
583 enabled_gl_platforms += 'wgl'
587 if host_machine.system() == 'darwin'
588 # FIXME: how to know if we're on iOS or OS X?
589 # gl_cocoa_headers += [
590 # 'gstglcontext_cocoa.h',
591 # 'gstglcaopengllayer.h',
595 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
596 if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
597 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
598 enabled_gl_winsys += 'viv-fb'
599 glconf.set10('GST_GL_HAVE_WINDOW_VIV_FB', 1)
600 glconf.set10('GST_GL_HAVE_VIV_DIRECTVIV', 1)
602 'viv-fb/gstgldisplay_viv_fb.c',
603 'viv-fb/gstglwindow_viv_fb_egl.c',
605 gl_cpp_args += ['-DEGL_API_FB']
610 # TODO: Add rest of gl config here.
611 # iOS, OS X, win32 specific support
614 if enabled_gl_apis.length() == 0
615 message('No OpenGL API libraries found or requested')
618 if enabled_gl_platforms.length() == 0
619 message('No OpenGL Platforms found or requested')
622 if enabled_gl_winsys.length() == 0
623 message('No OpenGL Window systems found or requested')
628 # find some types that may or may not be defined
629 if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps)
630 glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
632 if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps)
633 glconf.set('GST_GL_HAVE_GLCHAR', 1)
635 if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps)
636 glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
638 if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps)
639 glconf.set('GST_GL_HAVE_GLINTPTR', 1)
641 if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps)
642 glconf.set('GST_GL_HAVE_GLSYNC', 1)
644 if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps)
645 glconf.set('GST_GL_HAVE_GLUINT64', 1)
647 if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps)
648 glconf.set('GST_GL_HAVE_GLINT64', 1)
650 if egl_dep.found() and cc.has_type('EGLAttrib', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep])
651 glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
654 message('Building libgstgl with GL api: ' + ' '.join(enabled_gl_apis))
655 message('Building libgstgl with GL platform: ' + ' '.join(enabled_gl_platforms))
656 message('Building libgstgl with GL winsys: ' + ' '.join(enabled_gl_winsys))
658 install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
659 install_headers(gl_cocoa_headers, subdir : 'gstreamer-1.0/gst/gl/cocoa')
660 install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
661 install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
662 install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
663 install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
665 configure_file(input : 'gstglconfig.h.meson',
666 output : 'gstglconfig.h',
667 install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
668 configuration : glconf)
670 gstgl = library('gstgl-' + api_version,
672 c_args : gst_plugins_base_args + gl_cpp_args,
673 include_directories : [configinc, libsinc],
674 version : libversion,
675 soversion : soversion,
677 dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
678 gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps])
681 gl_gir = gnome.generate_gir(gstgl,
682 sources : gl_sources + gl_headers,
684 nsversion : api_version,
685 identifier_prefix : 'Gst',
686 symbol_prefix : 'gst',
687 export_packages : 'gstreamer-gl-1.0',
688 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
690 extra_args : gir_init_section + ['--c-include=gst/gl/gl.h'],
691 dependencies : [video_dep, gst_dep, gst_base_dep]
693 gen_sources += gl_gir
697 gstgl_dep = declare_dependency(link_with : gstgl,
698 include_directories : [libsinc],
699 sources: gen_sources,
700 dependencies : [video_dep, gst_base_dep] + gl_winsys_deps)