1if get_option('gl').disabled() 2 message('GStreamer OpenGL integration disabled via options.') 3 gstgl_dep = dependency('', required: false) 4 build_gstgl = false 5 subdir_done() 6endif 7 8gl_sources = [ 9 'gstglapi.c', 10 'gstglbasefilter.c', 11 'gstglbasememory.c', 12 'gstglcolorconvert.c', 13 'gstglbuffer.c', 14 'gstglbufferpool.c', 15 'gstglcontext.c', 16 'gstgldebug.c', 17 'gstgldisplay.c', 18 'gstglfeature.c', 19 'gstglfilter.c', 20 'gstglformat.c', 21 'gstglframebuffer.c', 22 'gstglmemory.c', 23 'gstglmemorypbo.c', 24 'gstgloverlaycompositor.c', 25 'gstglquery.c', 26 'gstglrenderbuffer.c', 27 'gstglshader.c', 28 'gstglshaderstrings.c', 29 'gstglsl.c', 30 'gstglslstage.c', 31 'gstglsyncmeta.c', 32 'gstglupload.c', 33 'gstglutils.c', 34 'gstglviewconvert.c', 35 'gstglwindow.c', 36] 37 38gl_priv_sources = [] 39 40gir_gl_headers = [ 41 'gl.h', 42 'gl-prelude.h', 43 'gstgl_enums.h', 44 'gstgl_fwd.h', 45 'gstglapi.h', 46 'gstglbasefilter.h', 47 'gstglbasememory.h', 48 'gstglbuffer.h', 49 'gstglbufferpool.h', 50 'gstglcolorconvert.h', 51 'gstglcontext.h', 52 'gstgldebug.h', 53 'gstgldisplay.h', 54 'gstglfeature.h', 55 'gstglfilter.h', 56 'gstglformat.h', 57 'gstglframebuffer.h', 58 'gstglmemory.h', 59 'gstglmemorypbo.h', 60 'gstgloverlaycompositor.h', 61 'gstglquery.h', 62 'gstglrenderbuffer.h', 63 'gstglshader.h', 64 'gstglshaderstrings.h', 65 'gstglsl.h', 66 'gstglslstage.h', 67 'gstglsyncmeta.h', 68 'gstglupload.h', 69 'gstglutils.h', 70 'gstglviewconvert.h', 71 'gstglwindow.h', 72] 73 74gl_headers = gir_gl_headers + [ 75 'gstglfuncs.h', 76] 77 78gl_prototype_headers = [ 79 'glprototypes/all_functions.h', 80 'glprototypes/base.h', 81 'glprototypes/blending.h', 82 'glprototypes/buffers.h', 83 'glprototypes/debug.h', 84 'glprototypes/eglimage.h', 85 'glprototypes/fbo.h', 86 'glprototypes/fixedfunction.h', 87 'glprototypes/gles.h', 88 'glprototypes/gstgl_compat.h', 89 'glprototypes/gstgl_gles2compat.h', 90 'glprototypes/opengl.h', 91 'glprototypes/query.h', 92 'glprototypes/shaders.h', 93 'glprototypes/sync.h', 94 'glprototypes/vao.h', 95] 96 97gl_x11_headers = [] 98gl_wayland_headers = [] 99gl_win32_headers = [] 100gl_cocoa_headers = [] 101gl_egl_headers = [] 102 103glconf = configuration_data() 104glconf_options = [ 105 'GST_GL_HAVE_OPENGL', 106 'GST_GL_HAVE_GLES2', 107 'GST_GL_HAVE_GLES3', 108 'GST_GL_HAVE_GLES3EXT3_H', 109 110 'GST_GL_HAVE_WINDOW_X11', 111 'GST_GL_HAVE_WINDOW_COCOA', 112 'GST_GL_HAVE_WINDOW_WIN32', 113 'GST_GL_HAVE_WINDOW_WAYLAND', 114 'GST_GL_HAVE_WINDOW_ANDROID', 115 'GST_GL_HAVE_WINDOW_DISPMANX', 116 'GST_GL_HAVE_WINDOW_EAGL', 117 'GST_GL_HAVE_WINDOW_VIV_FB', 118 'GST_GL_HAVE_WINDOW_GBM', 119 120 'GST_GL_HAVE_PLATFORM_EGL', 121 'GST_GL_HAVE_PLATFORM_GLX', 122 'GST_GL_HAVE_PLATFORM_WGL', 123 'GST_GL_HAVE_PLATFORM_CGL', 124 'GST_GL_HAVE_PLATFORM_EAGL', 125 126 'GST_GL_HAVE_DMABUF', 127 'GST_GL_HAVE_VIV_DIRECTVIV', 128 129 'GST_GL_HAVE_GLEGLIMAGEOES', 130 'GST_GL_HAVE_GLCHAR', 131 'GST_GL_HAVE_GLSIZEIPTR', 132 'GST_GL_HAVE_GLINTPTR', 133 'GST_GL_HAVE_GLSYNC', 134 'GST_GL_HAVE_GLUINT64', 135 'GST_GL_HAVE_GLINT64', 136 'GST_GL_HAVE_EGLATTRIB', 137 'GST_GL_HAVE_EGLUINT64KHR', 138] 139 140foreach option : glconf_options 141 glconf.set10(option, false) 142endforeach 143 144unneeded_dep = dependency('', required : false) 145if unneeded_dep.found() 146 error ('Found unfindable dependency') 147endif 148 149# OpenGL/GLES2 libraries 150gl_lib_deps = [] 151# GL platform - EGL, GLX, CGL, WGL, etc 152gl_platform_deps = [] 153# GL winsys - wayland, X11, Cocoa, win32, etc 154gl_winsys_deps = [] 155# other things we need. 156gl_misc_deps = [] 157# Other preprocessor arguments 158gl_cpp_args = [] 159gl_includes = [] 160gl_objc_args = [] 161 162enabled_gl_apis = [] 163enabled_gl_platforms = [] 164enabled_gl_winsys = [] 165 166# parse provided options 167libegl_module_name = get_option('egl_module_name') 168if libegl_module_name != '' 169 gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)] 170endif 171libgles2_module_name = get_option('gles2_module_name') 172if libgles2_module_name != '' 173 gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)] 174endif 175libgl_module_name = get_option('opengl_module_name') 176if libgl_module_name != '' 177 gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)] 178endif 179 180gl_apis = get_option('gl_api') 181if gl_apis.contains('auto') 182 need_api_opengl = 'auto' 183 need_api_gles2 = 'auto' 184else 185 need_api_opengl = 'no' 186 need_api_gles2 = 'no' 187 foreach api : gl_apis 188 if api == 'opengl' 189 need_api_opengl = 'yes' 190 elif api == 'gles2' 191 need_api_gles2 = 'yes' 192 else 193 error('Unsupported GL api provided ' + api) 194 endif 195 endforeach 196endif 197 198gl_platforms = get_option('gl_platform') 199if gl_platforms.contains('auto') 200 need_platform_egl = 'auto' 201 need_platform_glx = 'auto' 202 need_platform_cgl = 'auto' 203 need_platform_wgl = 'auto' 204 need_platform_eagl = 'auto' 205else 206 need_platform_egl = 'no' 207 need_platform_glx = 'no' 208 need_platform_cgl = 'no' 209 need_platform_wgl = 'no' 210 need_platform_eagl = 'no' 211 foreach platform : gl_platforms 212 if platform == 'egl' 213 need_platform_egl = 'yes' 214 elif platform == 'glx' 215 need_platform_glx = 'yes' 216 elif platform == 'cgl' 217 need_platform_cgl = 'yes' 218 elif platform == 'wgl' 219 need_platform_wgl = 'yes' 220 elif platform == 'eagl' 221 need_platform_eagl = 'yes' 222 else 223 error('Unsupported GL platform provided ' + platform) 224 endif 225 endforeach 226endif 227 228gl_winsys = get_option('gl_winsys') 229if gl_winsys.contains('auto') 230 need_win_x11 = 'auto' 231 need_win_wayland = 'auto' 232 need_win_win32 = 'auto' 233 need_win_cocoa = 'auto' 234 need_win_eagl = 'auto' 235 need_win_dispmanx = 'auto' 236 need_win_viv_fb = 'auto' 237 need_win_gbm = 'auto' 238 need_win_android = 'auto' 239else 240 need_win_x11 = 'no' 241 need_win_wayland = 'no' 242 need_win_win32 = 'no' 243 need_win_cocoa = 'no' 244 need_win_eagl = 'no' 245 need_win_dispmanx = 'no' 246 need_win_viv_fb = 'no' 247 need_win_gbm = 'no' 248 need_win_android = 'no' 249 foreach winsys : gl_winsys 250 if winsys == 'x11' 251 need_win_x11 = 'yes' 252 elif winsys == 'wayland' 253 need_win_wayland = 'yes' 254 elif winsys == 'win32' 255 need_win_win32 = 'yes' 256 elif winsys == 'cocoa' 257 need_win_cocoa = 'yes' 258 elif winsys == 'eagl' 259 need_win_eagl = 'yes' 260 elif winsys == 'dispmanx' 261 need_win_dispmanx = 'yes' 262 elif winsys == 'viv-fb' 263 need_win_viv_fb = 'yes' 264 elif winsys == 'gbm' 265 need_win_gbm = 'yes' 266 elif winsys == 'android' 267 need_win_android = 'yes' 268 else 269 error('Unsupported GL winsys provided ' + winsys) 270 endif 271 endforeach 272endif 273 274gl_include_header = ''' 275#ifdef __GNUC__ 276# pragma GCC diagnostic push 277# pragma GCC diagnostic ignored "-Wredundant-decls" 278#endif 279#ifndef GL_GLEXT_PROTOTYPES 280#define GL_GLEXT_PROTOTYPES 1 281#endif 282''' 283 284# convoluted way of getting at the subproject taking into account the wrap-mode 285# so we don't download a subproject unless allowed 286gl_header_dep = dependency('', fallback : ['gl-headers', 'gl_headers_dummy_dep'], 287 required : false) 288if gl_header_dep.type_name() == 'internal' 289 # this will only contain the includes of headers that are not found 290 compat_includes = subproject('gl-headers').get_variable('compatibility_includes') 291else 292 compat_includes = [] 293endif 294 295# Desktop OpenGL checks 296gl_dep = unneeded_dep 297glx_dep = unneeded_dep 298if need_api_opengl != 'no' or need_platform_glx != 'no' 299 if host_system == 'darwin' 300 gl_dep = dependency('appleframeworks', modules : ['OpenGL'], required : false) 301 else 302 # override meson's braindead gl detection on osx/windows/etc by forcing pkg-config 303 gl_dep = dependency('gl', method: 'pkg-config', required : false) 304 endif 305 306 if not gl_dep.found() 307 if host_system == 'windows' 308 gl_dep = cc.find_library('opengl32', required : false) 309 else 310 gl_dep = cc.find_library('GL', required : false) 311 endif 312 313 if not cc.has_header('GL/gl.h', include_directories : compat_includes) 314 gl_dep = unneeded_dep 315 endif 316 317 if not gl_dep.found() and need_api_opengl == 'yes' 318 error ('Could not find requested OpenGL library') 319 endif 320 321 if gl_dep.found() 322 gl_includes += [compat_includes] 323 endif 324 endif 325 326 if host_system == 'darwin' 327 glx_dep = cc.find_library('GL', required : false) 328 else 329 glx_dep = gl_dep 330 endif 331 332 if need_api_opengl == 'no' 333 gl_dep = unneeded_dep 334 endif 335 if need_platform_glx == 'no' 336 glx_dep = unneeded_dep 337 endif 338 339 opengl_includes = '' 340 if host_system == 'darwin' 341 opengl_includes += ''' 342#include <OpenGL/OpenGL.h> 343#include <OpenGL/gl.h> 344#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 345# define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED 346# include <OpenGL/gl3.h> 347#endif 348''' 349 else 350 opengl_includes += ''' 351#if _MSC_VER 352# include <windows.h> 353#endif 354#include <GL/gl.h> 355#if __WIN32__ || _WIN32 356# include <GL/glext.h> 357#endif 358''' 359 endif 360endif 361 362# GLES2 checks 363gles2_dep = unneeded_dep 364gles3_h = false 365gles3ext3_h = false 366if need_api_gles2 != 'no' 367 if host_system == 'ios' 368 gles2_dep = dependency('appleframeworks', modules : ['OpenGLES'], required : false) 369 else 370 gles2_dep = dependency('glesv2', required : false) 371 endif 372 373 if not gles2_dep.found() 374# if host_system == 'windows' 375# elif host_system == ios 376# gles2_dep = cc.find_library('GLESv2', required : false) 377# else 378 gles2_dep = cc.find_library('GLESv2', required : false) 379# endif 380 381 if not cc.has_header('GLES2/gl2.h', include_directories : compat_includes) 382 gles2_dep = unneeded_dep 383 endif 384 385 if not gles2_dep.found() and need_api_gles2 == 'yes' 386 error ('Could not find requested OpenGL ES library') 387 endif 388 389 if gles2_dep.found() 390 gl_includes += [compat_includes] 391 endif 392 endif 393 394 gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', dependencies : gles2_dep, include_directories : compat_includes) 395 396 gles_includes = '' 397 if host_system == 'ios' 398 gles_includes += ''' 399# include <OpenGLES/ES2/gl.h> 400# include <OpenGLES/ES2/glext.h> 401''' 402 else 403 if gles3_h 404 gl_includes += [compat_includes] 405 gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', dependencies : gles2_dep, include_directories : compat_includes) 406 gles_includes += ''' 407# include <GLES3/gl3.h> 408# include <GLES2/gl2ext.h>''' 409 if gles3ext3_h 410 gles_includes += ''' 411# include <GLES3/gl3ext.h>''' 412 endif 413 else 414 gles_includes += ''' 415# include <GLES2/gl2.h> 416# include <GLES2/gl2ext.h>''' 417 endif 418 endif 419endif 420 421# can we include both gles2 and opengl headers? 422if gles2_dep.found() and gl_dep.found() 423 gl_include_block = gl_include_header + gles_includes + opengl_includes 424 # TODO: Revert to passing gl_include_block via prefix: once 425 # https://github.com/mesonbuild/meson/issues/2364 is fixed 426 if not cc.compiles(gl_include_block + '\n' + 'void f (void) {}',dependencies : [gles2_dep, gl_dep], include_directories : compat_includes) 427 message ('Cannot include both OpenGL and OpenGL ES headers') 428 if need_api_gles2 != 'yes' 429 gles2_dep = unneeded_dep 430 elif need_api_opengl != 'yes' 431 gl_dep = unneeded_dep 432 else 433 error('Both OpenGL and OpenGL ES were requested but cannot be included together') 434 endif 435 endif 436endif 437gl_include_block = gl_include_header 438if gles2_dep.found() 439 gl_include_block += gles_includes 440endif 441if gl_dep.found() 442 gl_include_block += opengl_includes 443endif 444 445if gles2_dep.found() 446 gl_lib_deps += gles2_dep 447 glconf.set10('GST_GL_HAVE_GLES2', 1) 448 if gles3_h 449 glconf.set10('GST_GL_HAVE_GLES3', 1) 450 if gles3ext3_h 451 glconf.set10('GST_GL_HAVE_GLES3EXT3_H', 1) 452 endif 453 endif 454 enabled_gl_apis += 'gles2' 455endif 456 457if gl_dep.found() 458 gl_lib_deps += gl_dep 459 glconf.set10('GST_GL_HAVE_OPENGL', 1) 460 enabled_gl_apis += 'gl' 461endif 462 463# EGL checks 464egl_dep = unneeded_dep 465if need_platform_egl != 'no' 466 egl_dep = dependency('egl', required : false) 467 if not egl_dep.found() 468 egl_dep = cc.find_library('EGL', required : false) 469 endif 470 471 if egl_dep.found() and not cc.has_header('EGL/egl.h', 472 dependencies : egl_dep, 473 include_directories : compat_includes) 474 egl_dep = unneeded_dep 475 endif 476 if egl_dep.found() and not cc.has_header('EGL/eglext.h', 477 dependencies : egl_dep, 478 include_directories : compat_includes) 479 egl_dep = unneeded_dep 480 endif 481 482 if egl_dep.found() 483 gl_sources += [ 484 'egl/gstegl.c', 485 'egl/gsteglimage.c', 486 'egl/gstglcontext_egl.c', 487 'egl/gstgldisplay_egl.c', 488 'egl/gstglmemoryegl.c', 489 ] 490 gl_egl_headers += [ 491 'egl/gstegl.h', 492 'egl/gsteglimage.h', 493 'egl/gstgldisplay_egl.h', 494 'egl/gstglmemoryegl.h', 495 ] 496 gl_platform_deps += egl_dep 497 glconf.set10('GST_GL_HAVE_PLATFORM_EGL', 1) 498 499 if cc.has_header('libdrm/drm_fourcc.h') 500 gl_misc_deps += allocators_dep 501 glconf.set10('GST_GL_HAVE_DMABUF', 1) 502 endif 503 504 egl_includes = ''' 505#include <EGL/egl.h> 506#include <EGL/eglext.h> 507''' 508 enabled_gl_platforms += 'egl' 509 elif need_platform_egl == 'yes' 510 error ('Could not find requested EGL library') 511 endif 512endif 513 514# wayland checks 515wayland_client_dep = unneeded_dep 516wayland_cursor_dep = unneeded_dep 517wayland_egl_dep = unneeded_dep 518if need_win_wayland != 'no' 519 if need_win_wayland == 'yes' 520 if need_platform_egl == 'no' 521 error('Impossible situation requested: Cannot use Wayland without EGL support') 522 endif 523 endif 524 if not egl_dep.found() 525 if need_win_wayland == 'yes' 526 error ('Could not find EGL libraries for wayland') 527 else 528 message ('Could not find EGL libraries for wayland') 529 endif 530 else 531 wayland_client_dep = dependency('wayland-client', version : '>= 1.0', required : false) 532 wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false) 533 wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false) 534 wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.15', required : false) 535 wayland_scanner = find_program('wayland-scanner', required: false) 536 537 if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found() and wayland_protocols_dep.found() and wayland_scanner.found() 538 # Generate the XDG shell interface 539 wayland_protocols_basedir = wayland_protocols_dep.get_pkgconfig_variable('pkgdatadir') 540 xdg_shell_xml_spec = join_paths(wayland_protocols_basedir, 'stable', 'xdg-shell', 'xdg-shell.xml') 541 xdg_shell_header = custom_target('xdg-shell-client-header', 542 command: [ wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@' ], 543 input: xdg_shell_xml_spec, 544 output: 'xdg-shell-client-protocol.h', 545 ) 546 xdg_shell_code = custom_target('xdg-shell-client-code', 547 command: [ wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@' ], 548 input: xdg_shell_xml_spec, 549 output: 'xdg-shell-client-protocol.c', 550 ) 551 552 gl_sources += [ 553 'wayland/gstgldisplay_wayland.c', 554 'wayland/gstglwindow_wayland_egl.c', 555 'wayland/wayland_event_source.c', 556 ] 557 gl_priv_sources += [ 558 xdg_shell_header, 559 xdg_shell_code, 560 ] 561 gl_wayland_headers += [ 562 'wayland/gstgldisplay_wayland.h' 563 ] 564 glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1) 565 gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep] 566 enabled_gl_winsys += 'wayland' 567 else 568 if need_win_wayland == 'yes' 569 error ('Could not find requested Wayland libraries') 570 endif 571 wayland_client_dep = unneeded_dep 572 wayland_cursor_dep = unneeded_dep 573 wayland_egl_dep = unneeded_dep 574 wayland_protocols_dep = unneeded_dep 575 endif 576 endif 577endif 578 579# X11 checks 580if need_platform_glx == 'yes' 581 if need_win_x11 == 'no' 582 error('Impossible situation requested: Cannot use GLX without X11 support') 583 elif need_api_opengl == 'no' 584 error('Impossible situation requested: Cannot use GLX without the OpenGL library') 585 endif 586endif 587 588if need_win_x11 != 'no' 589 xcb_dep = dependency('x11-xcb', required : false) 590 if x11_dep.found() and xcb_dep.found() 591 gl_sources += [ 592 'x11/gstgldisplay_x11.c', 593 'x11/gstglwindow_x11.c', 594 'x11/xcb_event_source.c', 595 ] 596 gl_x11_headers += [ 597 'x11/gstgldisplay_x11.h', 598 ] 599 glconf.set('GST_GL_HAVE_WINDOW_X11', 1) 600 gl_winsys_deps += [x11_dep, xcb_dep] 601 enabled_gl_winsys += 'x11' 602 603 if need_platform_glx != 'no' and glx_dep.found() and cc.has_function ('glXMakeCurrent', dependencies : glx_dep) 604 glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1) 605 gl_sources += [ 606 'x11/gstglcontext_glx.c', 607 ] 608 # GLX is in the opengl library on linux 609 gl_platform_deps += glx_dep 610 enabled_gl_platforms += 'glx' 611 endif 612 elif need_win_x11 == 'yes' 613 error ('Could not find requested X11 libraries') 614 endif 615endif 616 617bcm_host_dep = unneeded_dep 618if need_win_dispmanx != 'no' 619 620 # Try pkg-config for bcm_host then fallback to find_library to also 621 # support older distribution 622 bcm_host_dep = dependency('bcm_host', required : false) 623 if not bcm_host_dep.found() 624 bcm_host_dep = cc.find_library('bcm_host', required : false) 625 endif 626 627 if bcm_host_dep.found() 628 if not egl_dep.found() 629 error('dispmanx requires the use of egl') 630 endif 631 632 gl_sources += [ 633 'dispmanx/gstglwindow_dispmanx_egl.c' 634 ] 635 636 glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1) 637 gl_winsys_deps += bcm_host_dep 638 enabled_gl_winsys += 'dispmanx' 639 gl_cpp_args += ['-DUSE_EGL_RPI'] 640 elif need_win_dispmanx == 'yes' 641 error('Could not find dispmanx libraries') 642 endif 643endif 644 645# win32 checks 646if need_platform_wgl == 'yes' 647 if need_win_win32 == 'no' 648 error('Impossible situation requested: Cannot use WGL without the win32 window system') 649 endif 650endif 651 652if need_platform_wgl != 'no' and need_win_win32 != 'no' 653 gdi_dep = cc.find_library('gdi32', required : false) 654 # FIXME: Revert back to has_header once it gains prefix support 655 wglext_h = cc.has_header('GL/wglext.h', 656 prefix : '''#include <windows.h> 657 #include <GL/gl.h>''', 658 include_directories : compat_includes) 659 660 if wglext_h and gdi_dep.found() and gl_dep.found() 661 gl_includes += [compat_includes] 662 gl_platform_deps += gdi_dep 663 gl_sources += [ 664 'win32/gstglwindow_win32.c', 665 'win32/gstglwindow_win32.c', 666 'win32/gstglcontext_wgl.c', 667 ] 668 enabled_gl_winsys += 'win32' 669 gl_winsys_deps += gdi_dep 670 enabled_gl_platforms += 'wgl' 671 glconf.set('GST_GL_HAVE_WINDOW_WIN32', 1) 672 glconf.set('GST_GL_HAVE_PLATFORM_WGL', 1) 673 endif 674endif 675 676if ['darwin', 'ios'].contains(host_system) 677 if not have_objc 678 error('No ObjC compiler found') 679 endif 680 681 objc = meson.get_compiler('objc') 682 if not objc.has_argument('-fobjc-arc') 683 error('ARC is required for building') 684 endif 685 686 gl_objc_args += ['-fobjc-arc'] 687endif 688 689# OSX check 690if need_platform_cgl == 'yes' 691 if need_win_cocoa == 'no' 692 error('Impossible situation requested: Cannot use CGL without Cocoa support') 693 elif need_api_opengl == 'no' 694 error('Impossible situation requested: Cannot use CGL without the OpenGL library') 695 endif 696elif need_platform_cgl == 'no' and need_win_cocoa == 'yes' 697 error('Impossible situation requested: Cannot use Cocoa without CGL support') 698endif 699 700if host_system == 'darwin' 701 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false) 702 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false) 703 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false) 704 705 if need_platform_cgl != 'no' 706 if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found() 707 gl_platform_deps += [quartzcore_dep, corefoundation_dep, foundation_dep] 708 enabled_gl_platforms += 'cgl' 709 glconf.set10('GST_GL_HAVE_PLATFORM_CGL', 1) 710 711 if need_win_cocoa != 'no' 712 cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : false) 713 if cocoa_dep.found() 714 gl_sources += [ 715 'cocoa/gstglcaopengllayer.m', 716 'cocoa/gstglcontext_cocoa.m', 717 'cocoa/gstgldisplay_cocoa.m', 718 'cocoa/gstglwindow_cocoa.m' 719 ] 720 gl_winsys_deps += cocoa_dep 721 enabled_gl_winsys += 'cocoa' 722 glconf.set10('GST_GL_HAVE_WINDOW_COCOA', 1) 723 elif need_win_cocoa == 'yes' 724 error('Could not find Cocoa') 725 endif 726 endif 727 elif need_platform_cgl == 'yes' 728 error('Could not find CGL dependencies') 729 endif 730 endif 731endif 732 733if need_platform_eagl == 'yes' 734 if host_system != 'ios' 735 error('Can only use EAGL on iOS') 736 endif 737 if need_win_eagl == 'no' 738 error('Impossible situation requested: Cannot use EAGL platform without the EAGL window system') 739 elif need_api_gles == 'no' 740 error('Impossible situation requested: Cannot use EAGL platform without the GLES library') 741 endif 742elif need_platform_eagl == 'no' and need_win_eagl == 'yes' 743 error('Impossible situation requested: Cannot use EAGL window system without the EAGL platform') 744endif 745 746if host_system == 'ios' and need_platform_eagl != 'no' and need_win_eagl != 'no' 747 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false) 748 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false) 749 coregraphics_dep = dependency('appleframeworks', modules : ['CoreGraphics'], required : false) 750 uikit_dep = dependency('appleframeworks', modules : ['UIkit'], required : false) 751 752 if foundation_dep.found() and corefoundation_dep.found() and coregraphics_dep.found() and uikit_dep.found() 753 gl_platform_deps += [ 754 corefoundation_dep, 755 foundation_dep, 756 coregraphics_dep, 757 uikit_dep, 758 ] 759 gl_sources += [ 760 'eagl/gstglcontext_eagl.m', 761 'eagl/gstglwindow_eagl.m', 762 ] 763 enabled_gl_winsys += 'eagl' 764 enabled_gl_platforms += 'eagl' 765 glconf.set('GST_GL_HAVE_WINDOW_EAGL', 1) 766 glconf.set('GST_GL_HAVE_PLATFORM_EAGL', 1) 767 elif need_platform_eagl == 'yes' or need_win_eagl == 'yes' 768 error('Could not find dependencies for EAGL') 769 endif 770endif 771 772# GBM Checks 773gbm_gudev_dep = unneeded_dep 774gbm_libdrm_dep = unneeded_dep 775gbm_dep = unneeded_dep 776if need_win_gbm != 'no' 777 if need_win_gbm == 'yes' 778 if need_platform_egl == 'no' 779 error('Impossible situation requested: Cannot use GBM without EGL support') 780 endif 781 endif 782 783 gbm_gudev_dep = dependency('gudev-1.0', version : '>=147', required : false) 784 gbm_libdrm_dep = dependency('libdrm', version : '>= 2.4.55', required : false) 785 gbm_dep = dependency('gbm', required : false) 786 if egl_dep.found() and gbm_gudev_dep.found() and gbm_libdrm_dep.found() and gbm_dep.found() 787 gl_sources += [ 788 'gbm/gstgldisplay_gbm.c', 789 'gbm/gstgl_gbm_utils.c', 790 'gbm/gstglwindow_gbm_egl.c', 791 ] 792 enabled_gl_winsys += 'gbm' 793 gl_winsys_deps += [gbm_gudev_dep, gbm_libdrm_dep, gbm_dep] 794 glconf.set('GST_GL_HAVE_WINDOW_GBM', 1) 795 else 796 if need_win_gbm == 'yes' 797 error ('Could not find requested GBM libraries') 798 endif 799 gbm_gudev_dep = unneeded_dep 800 gbm_libdrm_dep = unneeded_dep 801 gbm_dep = unneeded_dep 802 endif 803endif 804 805if need_platform_egl != 'no' and need_win_viv_fb != 'no' 806 if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep) 807 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep) 808 enabled_gl_winsys += 'viv-fb' 809 glconf.set10('GST_GL_HAVE_WINDOW_VIV_FB', 1) 810 glconf.set10('GST_GL_HAVE_VIV_DIRECTVIV', 1) 811 gl_sources += [ 812 'viv-fb/gstgldisplay_viv_fb.c', 813 'viv-fb/gstglwindow_viv_fb_egl.c', 814 ] 815 gl_cpp_args += ['-DEGL_API_FB'] 816 endif 817 endif 818endif 819 820if need_win_android == 'yes' 821 if need_platform_egl == 'no' 822 error('Impossible situation requested: Cannot build for Android without EGL') 823 elif need_api_gles2 == 'no' 824 error('Impossible situation requested: Cannot build for Android without GLES2 support') 825 elif host_system != 'android' 826 error('Impossible situation requested: Cannot build for Android without an android system') 827 endif 828endif 829 830if host_system == 'android' and need_win_android != 'no' and need_platform_egl != 'no' 831 if gles2_dep.found() and egl_dep.found() 832 enabled_gl_winsys += ['android'] 833 glconf.set10('GST_GL_HAVE_WINDOW_ANDROID', 1) 834 gl_sources += [ 835 'android/gstglwindow_android_egl.c' 836 ] 837 endif 838endif 839 840# TODO: Add rest of gl config here. 841# iOS, specific support 842 843build_gstgl = true 844if enabled_gl_apis.length() == 0 845 message('No OpenGL API libraries found or requested') 846 build_gstgl = false 847endif 848if enabled_gl_platforms.length() == 0 849 message('No OpenGL Platforms found or requested') 850 build_gstgl = false 851endif 852if enabled_gl_winsys.length() == 0 853 message('No OpenGL Window systems found or requested') 854 build_gstgl = false 855endif 856 857if build_gstgl 858 # find some types that may or may not be defined 859 if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes) 860 glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1) 861 endif 862 if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes) 863 glconf.set('GST_GL_HAVE_GLCHAR', 1) 864 endif 865 if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes) 866 glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1) 867 endif 868 if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes) 869 glconf.set('GST_GL_HAVE_GLINTPTR', 1) 870 endif 871 if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes) 872 glconf.set('GST_GL_HAVE_GLSYNC', 1) 873 endif 874 if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes) 875 glconf.set('GST_GL_HAVE_GLUINT64', 1) 876 endif 877 if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes) 878 glconf.set('GST_GL_HAVE_GLINT64', 1) 879 endif 880 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) 881 glconf.set('GST_GL_HAVE_EGLATTRIB', 1) 882 endif 883 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) 884 glconf.set('GST_GL_HAVE_EGLUINT64KHR', 1) 885 endif 886 887 message('Building libgstgl with GL api: ' + ' '.join(enabled_gl_apis)) 888 message('Building libgstgl with GL platform: ' + ' '.join(enabled_gl_platforms)) 889 message('Building libgstgl with GL winsys: ' + ' '.join(enabled_gl_winsys)) 890 891 install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl') 892 install_headers(gl_cocoa_headers, subdir : 'gstreamer-1.0/gst/gl/cocoa') 893 install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl') 894 install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes') 895 install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11') 896 install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland') 897 898 configure_file(input : 'gstglconfig.h.meson', 899 output : 'gstglconfig.h', 900 install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl', 901 configuration : glconf) 902 903 gl_enums = gnome.mkenums_simple('gl-enumtypes', 904 sources : gir_gl_headers, 905 body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif', 906 header_prefix : '#include <gst/gl/gl-prelude.h>', 907 decorator : 'GST_GL_API', 908 install_header: true, 909 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/gl')) 910 gl_enumtypes_c = gl_enums[0] 911 gl_enumtypes_h = gl_enums[1] 912 gen_sources = [gl_enumtypes_h] 913 914 gstgl = library('gstgl-' + api_version, 915 gl_sources, gl_priv_sources, gl_enumtypes_c, gl_enumtypes_h, 916 c_args : gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL'], 917 objc_args : gst_plugins_base_args + gl_cpp_args + gl_objc_args + ['-DBUILDING_GST_GL'], 918 include_directories : [configinc, libsinc, gl_includes], 919 version : libversion, 920 soversion : soversion, 921 darwin_versions : osxversion, 922 install : true, 923 dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep, 924 gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps]) 925 if build_gir 926 gl_gir = gnome.generate_gir(gstgl, 927 sources : gl_sources + [gl_enumtypes_h] + [gl_enumtypes_c] + gir_gl_headers + gl_x11_headers + gl_wayland_headers + gl_win32_headers + gl_cocoa_headers + gl_egl_headers, 928 namespace : 'GstGL', 929 nsversion : api_version, 930 identifier_prefix : 'Gst', 931 symbol_prefix : 'gst', 932 export_packages : 'gstreamer-gl-1.0', 933 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'], 934 install : true, 935 extra_args : gir_init_section + ['--c-include=gst/gl/gl.h'], 936 dependencies : [video_dep, gst_dep, gst_base_dep] 937 ) 938 gen_sources += gl_gir 939 endif 940 941 942 gstgl_dep = declare_dependency(link_with : gstgl, 943 include_directories : [libsinc, compat_includes], 944 sources: gen_sources, 945 dependencies : [video_dep, gst_base_dep] + gl_winsys_deps) 946 947elif get_option('gl').enabled() 948 error('GStreamer OpenGL integration required via options, but needed dependencies not found.') 949else 950 gstgl_dep = dependency('', required : false) 951endif 952