summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2017-12-11 12:59:09 +0000
committerTim-Philipp Müller <tim@centricular.com>2017-12-19 12:02:31 +0000
commit769a21d0bb310906b880c07da0e1e2376e11c187 (patch)
tree02b93bbe659389c940abd69b3a214cfa05f6c501 /gst-libs
parent43631c63ea76c524f96488dbdf4f4e20fa764626 (diff)
gl: remove GStreamer OpenGL integration library and move to -base
https://bugzilla.gnome.org/show_bug.cgi?id=754094
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/Makefile.am17
-rw-r--r--gst-libs/gst/gl/.gitignore2
-rw-r--r--gst-libs/gst/gl/Makefile.am215
-rw-r--r--gst-libs/gst/gl/android/Makefile.am21
-rw-r--r--gst-libs/gst/gl/android/gstglwindow_android_egl.c146
-rw-r--r--gst-libs/gst/gl/android/gstglwindow_android_egl.h65
-rw-r--r--gst-libs/gst/gl/cocoa/Makefile.am42
-rw-r--r--gst-libs/gst/gl/cocoa/gstgl_cocoa_private.h67
-rw-r--r--gst-libs/gst/gl/cocoa/gstglcaopengllayer.h59
-rw-r--r--gst-libs/gst/gl/cocoa/gstglcaopengllayer.m252
-rw-r--r--gst-libs/gst/gl/cocoa/gstglcontext_cocoa.h75
-rw-r--r--gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m339
-rw-r--r--gst-libs/gst/gl/cocoa/gstgldisplay_cocoa.h62
-rw-r--r--gst-libs/gst/gl/cocoa/gstgldisplay_cocoa.m250
-rw-r--r--gst-libs/gst/gl/cocoa/gstglwindow_cocoa.h67
-rw-r--r--gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m604
-rw-r--r--gst-libs/gst/gl/dispmanx/Makefile.am21
-rw-r--r--gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.c325
-rw-r--r--gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.h93
-rw-r--r--gst-libs/gst/gl/eagl/Makefile.am35
-rw-r--r--gst-libs/gst/gl/eagl/gstglcontext_eagl.h75
-rw-r--r--gst-libs/gst/gl/eagl/gstglcontext_eagl.m397
-rw-r--r--gst-libs/gst/gl/eagl/gstglwindow_eagl.h69
-rw-r--r--gst-libs/gst/gl/eagl/gstglwindow_eagl.m223
-rw-r--r--gst-libs/gst/gl/egl/Makefile.am32
-rw-r--r--gst-libs/gst/gl/egl/gstegl.c64
-rw-r--r--gst-libs/gst/gl/egl/gstegl.h57
-rw-r--r--gst-libs/gst/gl/egl/gsteglimage.c531
-rw-r--r--gst-libs/gst/gl/egl/gsteglimage.h124
-rw-r--r--gst-libs/gst/gl/egl/gstglcontext_egl.c798
-rw-r--r--gst-libs/gst/gl/egl/gstglcontext_egl.h95
-rw-r--r--gst-libs/gst/gl/egl/gstgldisplay_egl.c299
-rw-r--r--gst-libs/gst/gl/egl/gstgldisplay_egl.h82
-rw-r--r--gst-libs/gst/gl/egl/gstglmemoryegl.c275
-rw-r--r--gst-libs/gst/gl/egl/gstglmemoryegl.h105
-rw-r--r--gst-libs/gst/gl/gl.h58
-rw-r--r--gst-libs/gst/gl/glprototypes/Makefile.am20
-rw-r--r--gst-libs/gst/gl/glprototypes/README54
-rw-r--r--gst-libs/gst/gl/glprototypes/all_functions.h33
-rw-r--r--gst-libs/gst/gl/glprototypes/base.h328
-rw-r--r--gst-libs/gst/gl/glprototypes/blending.h99
-rw-r--r--gst-libs/gst/gl/glprototypes/buffers.h48
-rw-r--r--gst-libs/gst/gl/glprototypes/debug.h117
-rw-r--r--gst-libs/gst/gl/glprototypes/eglimage.h53
-rw-r--r--gst-libs/gst/gl/glprototypes/fbo.h157
-rw-r--r--gst-libs/gst/gl/glprototypes/fixedfunction.h144
-rw-r--r--gst-libs/gst/gl/glprototypes/gles.h102
-rw-r--r--gst-libs/gst/gl/glprototypes/gstgl_compat.h67
-rw-r--r--gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h57
-rw-r--r--gst-libs/gst/gl/glprototypes/opengl.h72
-rw-r--r--gst-libs/gst/gl/glprototypes/query.h63
-rw-r--r--gst-libs/gst/gl/glprototypes/shaders.h374
-rw-r--r--gst-libs/gst/gl/glprototypes/sync.h46
-rw-r--r--gst-libs/gst/gl/glprototypes/vao.h37
-rw-r--r--gst-libs/gst/gl/gstgl_enums.h41
-rw-r--r--gst-libs/gst/gl/gstgl_fwd.h177
-rw-r--r--gst-libs/gst/gl/gstglapi.c214
-rw-r--r--gst-libs/gst/gl/gstglapi.h113
-rw-r--r--gst-libs/gst/gl/gstglbasefilter.c465
-rw-r--r--gst-libs/gst/gl/gstglbasefilter.h88
-rw-r--r--gst-libs/gst/gl/gstglbasememory.c759
-rw-r--r--gst-libs/gst/gl/gstglbasememory.h421
-rw-r--r--gst-libs/gst/gl/gstglbuffer.c492
-rw-r--r--gst-libs/gst/gl/gstglbuffer.h141
-rw-r--r--gst-libs/gst/gl/gstglbufferpool.c417
-rw-r--r--gst-libs/gst/gl/gstglbufferpool.h80
-rw-r--r--gst-libs/gst/gl/gstglcolorconvert.c2524
-rw-r--r--gst-libs/gst/gl/gstglcolorconvert.h142
-rw-r--r--gst-libs/gst/gl/gstglconfig.h.meson48
-rw-r--r--gst-libs/gst/gl/gstglcontext.c1857
-rw-r--r--gst-libs/gst/gl/gstglcontext.h221
-rw-r--r--gst-libs/gst/gl/gstglcontext_private.h31
-rw-r--r--gst-libs/gst/gl/gstgldebug.c521
-rw-r--r--gst-libs/gst/gl/gstgldebug.h184
-rw-r--r--gst-libs/gst/gl/gstgldisplay.c792
-rw-r--r--gst-libs/gst/gl/gstgldisplay.h149
-rw-r--r--gst-libs/gst/gl/gstglfeature.c285
-rw-r--r--gst-libs/gst/gl/gstglfeature.h62
-rw-r--r--gst-libs/gst/gl/gstglfeature_private.h108
-rw-r--r--gst-libs/gst/gl/gstglfilter.c1223
-rw-r--r--gst-libs/gst/gl/gstglfilter.h145
-rw-r--r--gst-libs/gst/gl/gstglformat.c387
-rw-r--r--gst-libs/gst/gl/gstglformat.h148
-rw-r--r--gst-libs/gst/gl/gstglframebuffer.c579
-rw-r--r--gst-libs/gst/gl/gstglframebuffer.h121
-rw-r--r--gst-libs/gst/gl/gstglfuncs.h108
-rw-r--r--gst-libs/gst/gl/gstglmemory.c1526
-rw-r--r--gst-libs/gst/gl/gstglmemory.h306
-rw-r--r--gst-libs/gst/gl/gstglmemorypbo.c867
-rw-r--r--gst-libs/gst/gl/gstglmemorypbo.h110
-rw-r--r--gst-libs/gst/gl/gstgloverlaycompositor.c649
-rw-r--r--gst-libs/gst/gl/gstgloverlaycompositor.h92
-rw-r--r--gst-libs/gst/gl/gstglpixelformat.c23
-rw-r--r--gst-libs/gst/gl/gstglquery.c354
-rw-r--r--gst-libs/gst/gl/gstglquery.h163
-rw-r--r--gst-libs/gst/gl/gstglrenderbuffer.c476
-rw-r--r--gst-libs/gst/gl/gstglrenderbuffer.h154
-rw-r--r--gst-libs/gst/gl/gstglshader.c1589
-rw-r--r--gst-libs/gst/gl/gstglshader.h160
-rw-r--r--gst-libs/gst/gl/gstglshaderstrings.c82
-rw-r--r--gst-libs/gst/gl/gstglshaderstrings.h42
-rw-r--r--gst-libs/gst/gl/gstglsl.c931
-rw-r--r--gst-libs/gst/gl/gstglsl.h157
-rw-r--r--gst-libs/gst/gl/gstglsl_private.h68
-rw-r--r--gst-libs/gst/gl/gstglslstage.c549
-rw-r--r--gst-libs/gst/gl/gstglslstage.h108
-rw-r--r--gst-libs/gst/gl/gstglsyncmeta.c388
-rw-r--r--gst-libs/gst/gl/gstglsyncmeta.h95
-rw-r--r--gst-libs/gst/gl/gstglupload.c1856
-rw-r--r--gst-libs/gst/gl/gstglupload.h123
-rw-r--r--gst-libs/gst/gl/gstglutils.c874
-rw-r--r--gst-libs/gst/gl/gstglutils.h64
-rw-r--r--gst-libs/gst/gl/gstglutils_private.h34
-rw-r--r--gst-libs/gst/gl/gstglviewconvert.c2381
-rw-r--r--gst-libs/gst/gl/gstglviewconvert.h137
-rw-r--r--gst-libs/gst/gl/gstglwindow.c1022
-rw-r--r--gst-libs/gst/gl/gstglwindow.h269
-rw-r--r--gst-libs/gst/gl/gstglwindow_private.h31
-rw-r--r--gst-libs/gst/gl/meson.build702
-rw-r--r--gst-libs/gst/gl/utils/gles_versions.h38
-rw-r--r--gst-libs/gst/gl/utils/opengl_versions.h54
-rw-r--r--gst-libs/gst/gl/viv-fb/Makefile.am25
-rw-r--r--gst-libs/gst/gl/viv-fb/gstgldisplay_viv_fb.c103
-rw-r--r--gst-libs/gst/gl/viv-fb/gstgldisplay_viv_fb.h67
-rw-r--r--gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.c264
-rw-r--r--gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.h66
-rw-r--r--gst-libs/gst/gl/wayland/Makefile.am29
-rw-r--r--gst-libs/gst/gl/wayland/gstgldisplay_wayland.c173
-rw-r--r--gst-libs/gst/gl/wayland/gstgldisplay_wayland.h82
-rw-r--r--gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c583
-rw-r--r--gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.h109
-rw-r--r--gst-libs/gst/gl/wayland/wayland_event_source.c204
-rw-r--r--gst-libs/gst/gl/wayland/wayland_event_source.h42
-rw-r--r--gst-libs/gst/gl/win32/Makefile.am29
-rw-r--r--gst-libs/gst/gl/win32/gstglcontext_wgl.c417
-rw-r--r--gst-libs/gst/gl/win32/gstglcontext_wgl.h67
-rw-r--r--gst-libs/gst/gl/win32/gstglwindow_win32.c496
-rw-r--r--gst-libs/gst/gl/win32/gstglwindow_win32.h86
-rw-r--r--gst-libs/gst/gl/win32/win32_message_source.c83
-rw-r--r--gst-libs/gst/gl/win32/win32_message_source.h34
-rw-r--r--gst-libs/gst/gl/x11/Makefile.am33
-rw-r--r--gst-libs/gst/gl/x11/gstglcontext_glx.c522
-rw-r--r--gst-libs/gst/gl/x11/gstglcontext_glx.h77
-rw-r--r--gst-libs/gst/gl/x11/gstgldisplay_x11.c240
-rw-r--r--gst-libs/gst/gl/x11/gstgldisplay_x11.h79
-rw-r--r--gst-libs/gst/gl/x11/gstglwindow_x11.c670
-rw-r--r--gst-libs/gst/gl/x11/gstglwindow_x11.h114
-rw-r--r--gst-libs/gst/gl/x11/xcb_event_source.c105
-rw-r--r--gst-libs/gst/gl/x11/xcb_event_source.h29
-rw-r--r--gst-libs/gst/meson.build1
150 files changed, 3 insertions, 42255 deletions
diff --git a/gst-libs/gst/Makefile.am b/gst-libs/gst/Makefile.am
index 1939611a2..62dd9fdfa 100644
--- a/gst-libs/gst/Makefile.am
+++ b/gst-libs/gst/Makefile.am
@@ -1,11 +1,3 @@
-
-if USE_OPENGL
-GL_DIR = gl
-endif
-if USE_GLES2
-GL_DIR = gl
-endif
-
if USE_WAYLAND
WAYLAND_DIR=wayland
endif
@@ -15,21 +7,18 @@ OPENCV_DIR=opencv
endif
SUBDIRS = uridownloader adaptivedemux interfaces basecamerabinsrc codecparsers \
- insertbin mpegts video audio player allocators isoff $(GL_DIR) $(WAYLAND_DIR) \
+ insertbin mpegts video audio player allocators isoff $(WAYLAND_DIR) \
$(OPENCV_DIR)
noinst_HEADERS = gst-i18n-plugin.h gettext.h glib-compat-private.h
-DIST_SUBDIRS = uridownloader adaptivedemux interfaces gl basecamerabinsrc \
+DIST_SUBDIRS = uridownloader adaptivedemux interfaces basecamerabinsrc \
codecparsers insertbin mpegts wayland opencv video audio player allocators isoff
-#dependencies
-gl: allocators
-
adaptivedemux: uridownloader
INDEPENDENT_SUBDIRS = \
interfaces basecamerabinsrc codecparsers insertbin uridownloader \
- mpegts player allocators isoff $(GL_DIR) $(WAYLAND_DIR) $(OPENCV_DIR)
+ mpegts player allocators isoff $(WAYLAND_DIR) $(OPENCV_DIR)
.PHONY: independent-subdirs $(INDEPENDENT_SUBDIRS)
diff --git a/gst-libs/gst/gl/.gitignore b/gst-libs/gst/gl/.gitignore
deleted file mode 100644
index a663943b8..000000000
--- a/gst-libs/gst/gl/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-gstglconfig.h
-stamp-gc-h
diff --git a/gst-libs/gst/gl/Makefile.am b/gst-libs/gst/gl/Makefile.am
deleted file mode 100644
index 269fdb6a4..000000000
--- a/gst-libs/gst/gl/Makefile.am
+++ /dev/null
@@ -1,215 +0,0 @@
-
-lib_LTLIBRARIES = libgstgl-@GST_API_VERSION@.la
-
-SUBDIRS = glprototypes
-DIST_SUBDIRS = glprototypes android x11 win32 cocoa wayland dispmanx egl eagl viv-fb
-
-built_sys_header_configure = gstglconfig.h
-
-libgstgl_@GST_API_VERSION@_la_SOURCES = \
- gstgldisplay.c \
- gstglcontext.c \
- gstgldebug.c \
- gstglbasememory.c \
- gstglbuffer.c \
- gstglmemory.c \
- gstglmemorypbo.c \
- gstglrenderbuffer.c \
- gstglbufferpool.c \
- gstglfilter.c \
- gstglformat.c \
- gstglbasefilter.c \
- gstglshader.c \
- gstglshaderstrings.c \
- gstglsl.c \
- gstglslstage.c \
- gstglcolorconvert.c \
- gstglupload.c \
- gstglwindow.c \
- gstglapi.c \
- gstglfeature.c \
- gstglutils.c \
- gstglframebuffer.c \
- gstglsyncmeta.c \
- gstglviewconvert.c \
- gstgloverlaycompositor.c \
- gstglquery.c
-
-libgstgl_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl
-libgstgl_@GST_API_VERSION@include_HEADERS = \
- gstglwindow.h \
- gstgldisplay.h \
- gstglcontext.h \
- gstgldebug.h \
- gstglbasememory.h \
- gstglbuffer.h \
- gstglmemory.h \
- gstglmemorypbo.h \
- gstglrenderbuffer.h \
- gstglbufferpool.h \
- gstglfilter.h \
- gstglformat.h \
- gstglfuncs.h \
- gstglbasefilter.h \
- gstglshader.h \
- gstglshaderstrings.h \
- gstglsl.h \
- gstglslstage.h \
- gstglcolorconvert.h \
- gstglupload.h \
- gstglapi.h \
- gstglfeature.h \
- gstglutils.h \
- gstglframebuffer.h \
- gstglsyncmeta.h \
- gstglviewconvert.h \
- gstgloverlaycompositor.h \
- gstglquery.h \
- gstgl_fwd.h \
- gstgl_enums.h \
- gl.h
-
-noinst_HEADERS = \
- gstglcontext_private.h \
- gstglfeature_private.h \
- gstglsl_private.h \
- gstglwindow_private.h \
- gstglutils_private.h \
- utils/opengl_versions.h \
- utils/gles_versions.h
-
-
-libgstgl_@GST_API_VERSION@_la_LIBADD = \
- $(GMODULE_NO_EXPORT_LIBS) \
- $(GST_PLUGINS_BASE_LIBS) \
- -lgstvideo-$(GST_API_VERSION) \
- $(GST_BASE_LIBS) \
- $(GST_LIBS) \
- $(GL_LIBS) \
- $(top_builddir)/gst-libs/gst/allocators/libgstbadallocators-@GST_API_VERSION@.la
-
-if HAVE_WINDOW_WIN32
-SUBDIRS += win32
-libgstgl_@GST_API_VERSION@_la_LIBADD += win32/libgstgl-win32.la
-endif
-
-if HAVE_WINDOW_COCOA
-SUBDIRS += cocoa
-libgstgl_@GST_API_VERSION@_la_LIBADD += cocoa/libgstgl-cocoa.la
-endif
-
-if HAVE_WINDOW_X11
-SUBDIRS += x11
-libgstgl_@GST_API_VERSION@_la_LIBADD += x11/libgstgl-x11.la
-endif
-
-if HAVE_WINDOW_WAYLAND
-SUBDIRS += wayland
-libgstgl_@GST_API_VERSION@_la_LIBADD += wayland/libgstgl-wayland.la
-endif
-
-if HAVE_WINDOW_DISPMANX
-SUBDIRS += dispmanx
-libgstgl_@GST_API_VERSION@_la_LIBADD += dispmanx/libgstgl-dispmanx.la
-endif
-
-if HAVE_WINDOW_ANDROID
-SUBDIRS += android
-libgstgl_@GST_API_VERSION@_la_LIBADD += android/libgstgl-android.la
-endif
-
-if HAVE_WINDOW_EAGL
-SUBDIRS += eagl
-libgstgl_@GST_API_VERSION@_la_LIBADD += eagl/libgstgl-eagl.la
-endif
-
-if HAVE_WINDOW_VIV_FB
-SUBDIRS += viv-fb
-libgstgl_@GST_API_VERSION@_la_LIBADD += viv-fb/libgstgl-viv-fb.la
-endif
-
-if USE_EGL
-SUBDIRS += egl
-libgstgl_@GST_API_VERSION@_la_LIBADD += egl/libgstgl-egl.la
-libgstgl_@GST_API_VERSION@_la_LIBADD += -lgstallocators-$(GST_API_VERSION)
-endif
-
-configexecincludedir = $(libdir)/gstreamer-@GST_API_VERSION@/include/gst/gl
-nodist_configexecinclude_HEADERS = $(built_sys_header_configure)
-
-libgstgl_@GST_API_VERSION@_la_CFLAGS = \
- -DGST_EXPORTS \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) \
- $(GST_CFLAGS) \
- $(GL_CFLAGS)
-
-libgstgl_@GST_API_VERSION@_la_LDFLAGS = \
- $(GST_LIB_LDFLAGS) \
- $(GST_ALL_LDFLAGS) \
- $(GST_LT_LDFLAGS)
-
-# DISTCLEANFILES is for files generated by configure
-DISTCLEANFILES = $(built_sys_header_configure)
-
-if HAVE_INTROSPECTION
-BUILT_GIRSOURCES = GstGL-@GST_API_VERSION@.gir
-
-gir_headers=$(patsubst %,$(srcdir)/%, $(libgstgl_@GST_API_VERSION@include_HEADERS))
-gir_sources=$(patsubst %,$(srcdir)/%, $(libgstgl_@GST_API_VERSION@_la_SOURCES))
-
-GstGL-@GST_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libgstgl-@GST_API_VERSION@.la
- $(AM_V_GEN)PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" GI_SCANNER_DISABLE_CACHE=yes\
- GST_PLUGIN_SYSTEM_PATH_1_0="" GST_PLUGIN_PATH_1_0="" GST_REGISTRY_UPDATE=no \
- CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" CC="$(CC)" PKG_CONFIG="$(PKG_CONFIG)" DLLTOOL="$(DLLTOOL)" \
- $(INTROSPECTION_SCANNER) -v --namespace GstGL \
- --nsversion=@GST_API_VERSION@ \
- --identifier-prefix=Gst \
- --symbol-prefix=gst \
- --warn-all \
- --c-include "gst/gl/gl.h" \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GL_CFLAGS) \
- --add-include-path=`PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" $(PKG_CONFIG) --variable=girdir gstreamer-@GST_API_VERSION@` \
- --add-include-path=`PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" $(PKG_CONFIG) --variable=girdir gstreamer-base-@GST_API_VERSION@` \
- --add-include-path=`PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" $(PKG_CONFIG) --variable=girdir gstreamer-video-@GST_API_VERSION@` \
- --library=libgstgl-@GST_API_VERSION@.la \
- --include=Gst-@GST_API_VERSION@ \
- --include=GstBase-@GST_API_VERSION@ \
- --include=GstVideo-@GST_API_VERSION@ \
- --libtool="$(top_builddir)/libtool" \
- --pkg gstreamer-@GST_API_VERSION@ \
- --pkg gstreamer-base-@GST_API_VERSION@ \
- --pkg gstreamer-video-@GST_API_VERSION@ \
- --pkg-export gstreamer-gl-@GST_API_VERSION@ \
- --add-init-section="$(INTROSPECTION_INIT)" \
- -DGST_USE_UNSTABLE_API \
- --output $@ \
- $(gir_headers) \
- $(gir_sources)
-
-# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to
-# install anything - we need to install inside our prefix.
-girdir = $(datadir)/gir-1.0
-gir_DATA = $(BUILT_GIRSOURCES)
-
-typelibsdir = $(libdir)/girepository-1.0/
-
-typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
-
-%.typelib: %.gir $(INTROSPECTION_COMPILER)
- $(AM_V_GEN)PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" \
- $(INTROSPECTION_COMPILER) \
- --includedir=$(srcdir) \
- --includedir=$(builddir) \
- --includedir=`PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" $(PKG_CONFIG) --variable=girdir gstreamer-@GST_API_VERSION@` \
- --includedir=`PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" $(PKG_CONFIG) --variable=girdir gstreamer-base-@GST_API_VERSION@` \
- --includedir=`PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" $(PKG_CONFIG) --variable=girdir gstreamer-video-@GST_API_VERSION@` \
- $(INTROSPECTION_COMPILER_OPTS) $< -o $(@F)
-
-CLEANFILES = $(BUILT_GIRSOURCES) $(typelibs_DATA)
-endif
diff --git a/gst-libs/gst/gl/android/Makefile.am b/gst-libs/gst/gl/android/Makefile.am
deleted file mode 100644
index c21097bc9..000000000
--- a/gst-libs/gst/gl/android/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-noinst_LTLIBRARIES = libgstgl-android.la
-
-libgstgl_android_la_SOURCES = \
- gstglwindow_android_egl.c
-
-noinst_HEADERS = \
- gstglwindow_android_egl.h
-
-libgstgl_android_la_CFLAGS = \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- $(GL_CFLAGS) \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) \
- $(GST_CFLAGS)
-
-libgstgl_android_la_LDFLAGS = \
- $(GST_LIB_LDFLAGS) \
- $(GST_ALL_LDFLAGS)
diff --git a/gst-libs/gst/gl/android/gstglwindow_android_egl.c b/gst-libs/gst/gl/android/gstglwindow_android_egl.c
deleted file mode 100644
index 68c1c9403..000000000
--- a/gst-libs/gst/gl/android/gstglwindow_android_egl.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- * Copyright (C) 2013 Sebastian Dröge <slomo@circular-chaos.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/* TODO: - Window resize handling
- * - Event handling input event handling
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-#include <gst/gl/egl/gstglcontext_egl.h>
-#include "gstglwindow_android_egl.h"
-#include "../gstglwindow_private.h"
-
-#define GST_CAT_DEFAULT gst_gl_window_debug
-
-#define gst_gl_window_android_egl_parent_class parent_class
-G_DEFINE_TYPE (GstGLWindowAndroidEGL, gst_gl_window_android_egl,
- GST_TYPE_GL_WINDOW);
-
-static guintptr gst_gl_window_android_egl_get_display (GstGLWindow * window);
-static guintptr gst_gl_window_android_egl_get_window_handle (GstGLWindow *
- window);
-static void gst_gl_window_android_egl_set_window_handle (GstGLWindow * window,
- guintptr handle);
-static void gst_gl_window_android_egl_draw (GstGLWindow * window);
-
-static void
-gst_gl_window_android_egl_class_init (GstGLWindowAndroidEGLClass * klass)
-{
- GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
-
- window_class->get_display =
- GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_get_display);
- window_class->get_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_get_window_handle);
- window_class->set_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_set_window_handle);
- window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_draw);
-}
-
-static void
-gst_gl_window_android_egl_init (GstGLWindowAndroidEGL * window)
-{
-}
-
-/* Must be called in the gl thread */
-GstGLWindowAndroidEGL *
-gst_gl_window_android_egl_new (GstGLDisplay * display)
-{
- GstGLWindowAndroidEGL *window;
-
- if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_EGL) == 0)
- /* we require an egl display to create android windows */
- return NULL;
-
- GST_DEBUG ("creating Android EGL window");
-
- window = g_object_new (GST_TYPE_GL_WINDOW_ANDROID_EGL, NULL);
- gst_object_ref_sink (window);
-
- return window;
-}
-
-static void
-gst_gl_window_android_egl_set_window_handle (GstGLWindow * window,
- guintptr handle)
-{
- GstGLWindowAndroidEGL *window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
-
- window_egl->native_window = (EGLNativeWindowType) handle;
-}
-
-static guintptr
-gst_gl_window_android_egl_get_window_handle (GstGLWindow * window)
-{
- GstGLWindowAndroidEGL *window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
-
- return (guintptr) window_egl->native_window;
-}
-
-static void
-draw_cb (gpointer data)
-{
- GstGLWindowAndroidEGL *window_egl = data;
- GstGLWindow *window = GST_GL_WINDOW (window_egl);
- GstGLContext *context = gst_gl_window_get_context (window);
- GstGLContextEGL *context_egl = GST_GL_CONTEXT_EGL (context);
-
- if (context_egl->egl_surface) {
- gint width, height;
- guint window_width, window_height;
-
- gst_gl_window_get_surface_dimensions (window, &window_width,
- &window_height);
- if (eglQuerySurface (context_egl->egl_display, context_egl->egl_surface,
- EGL_WIDTH, &width)
- && eglQuerySurface (context_egl->egl_display, context_egl->egl_surface,
- EGL_HEIGHT, &height)
- && (window->queue_resize || width != window_egl->window_width
- || height != window_egl->window_height)) {
- gst_gl_window_resize (window, width, height);
- }
- }
-
- if (window->draw)
- window->draw (window->draw_data);
-
- gst_gl_context_swap_buffers (context);
-
- gst_object_unref (context);
-}
-
-static void
-gst_gl_window_android_egl_draw (GstGLWindow * window)
-{
- gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
-}
-
-static guintptr
-gst_gl_window_android_egl_get_display (GstGLWindow * window)
-{
- return 0;
-}
diff --git a/gst-libs/gst/gl/android/gstglwindow_android_egl.h b/gst-libs/gst/gl/android/gstglwindow_android_egl.h
deleted file mode 100644
index b467b6dbd..000000000
--- a/gst-libs/gst/gl/android/gstglwindow_android_egl.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- * Copyright (C) 2013 Sebastian Dröge <slomo@circular-chaos.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_WINDOW_ANDROID_EGL_H__
-#define __GST_GL_WINDOW_ANDROID_EGL_H__
-
-#include <gst/gl/gl.h>
-#include <gst/gl/egl/gstegl.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_WINDOW_ANDROID_EGL (gst_gl_window_android_egl_get_type())
-#define GST_GL_WINDOW_ANDROID_EGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW_ANDROID_EGL, GstGLWindowAndroidEGL))
-#define GST_GL_WINDOW_ANDROID_EGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_WINDOW_ANDROID_EGL, GstGLWindowAndroidEGLClass))
-#define GST_IS_GL_WINDOW_ANDROID_EGL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW_ANDROID_EGL))
-#define GST_IS_GL_WINDOW_ANDROID_EGL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW_ANDROID_EGL))
-#define GST_GL_WINDOW_ANDROID_EGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW_ANDROID_EGL, GstGLWindowAndroidEGL_Class))
-
-typedef struct _GstGLWindowAndroidEGL GstGLWindowAndroidEGL;
-typedef struct _GstGLWindowAndroidEGLClass GstGLWindowAndroidEGLClass;
-
-struct _GstGLWindowAndroidEGL {
- /*< private >*/
- GstGLWindow parent;
-
- /* This is actually an ANativeWindow */
- EGLNativeWindowType native_window;
- gint window_width, window_height;
-
- gpointer _reserved[GST_PADDING];
-};
-
-struct _GstGLWindowAndroidEGLClass {
- /*< private >*/
- GstGLWindowClass parent_class;
-
- /*< private >*/
- gpointer _reserved[GST_PADDING];
-};
-
-GType gst_gl_window_android_egl_get_type (void);
-
-GstGLWindowAndroidEGL * gst_gl_window_android_egl_new (GstGLDisplay * display);
-
-G_END_DECLS
-
-#endif /* __GST_GL_WINDOW_ANDROID_H__ */
diff --git a/gst-libs/gst/gl/cocoa/Makefile.am b/gst-libs/gst/gl/cocoa/Makefile.am
deleted file mode 100644
index 018d280b3..000000000
--- a/gst-libs/gst/gl/cocoa/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-noinst_LTLIBRARIES = libgstgl-cocoa.la
-
-libgstgl_cocoa_la_SOURCES = \
- gstglwindow_cocoa.m \
- gstglcontext_cocoa.m \
- gstgldisplay_cocoa.m \
- gstglcaopengllayer.m
-
-noinst_HEADERS = \
- gstglcontext_cocoa.h \
- gstglwindow_cocoa.h \
- gstgl_cocoa_private.h
-
-libgstgl_cocoaincludedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl/cocoa
-libgstgl_cocoainclude_HEADERS = \
- gstglcaopengllayer.h \
- gstgldisplay_cocoa.h
-
-libgstgl_cocoa_la_CFLAGS = \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- $(GL_CFLAGS) \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) \
- $(GST_CFLAGS)
-
-libgstgl_cocoa_la_OBJCFLAGS = \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- -fobjc-arc \
- $(GL_OBJCFLAGS) \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) \
- $(GST_OBJCFLAGS)
-
-libgstgl_cocoa_la_LDFLAGS = \
- $(GST_LIB_LDFLAGS) \
- $(GST_ALL_LDFLAGS)
-
-libgstgl_cocoa_la_LIBTOOLFLAGS = --tag=CC
diff --git a/gst-libs/gst/gl/cocoa/gstgl_cocoa_private.h b/gst-libs/gst/gl/cocoa/gstgl_cocoa_private.h
deleted file mode 100644
index 380d6f704..000000000
--- a/gst-libs/gst/gl/cocoa/gstgl_cocoa_private.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_COCOA_PRIVATE_H__
-#define __GST_GL_COCOA_PRIVATE_H__
-
-#include <gst/gst.h>
-#include <gst/gl/gstglfuncs.h>
-
-#include <Cocoa/Cocoa.h>
-
-#include "gstglwindow_cocoa.h"
-#include "gstglcontext_cocoa.h"
-#include "gstglcaopengllayer.h"
-
-G_BEGIN_DECLS
-
-struct _GstGLContextCocoaPrivate
-{
- CGLPixelFormatObj pixel_format;
- CGLContextObj gl_context;
- CGLContextObj external_gl_context;
-
- GstGLAPI context_api;
-
- gint source_id;
-};
-
-
-/* =============================================================*/
-/* */
-/* GstGLNSView declaration */
-/* */
-/* =============================================================*/
-
-@interface GstGLNSView: NSView {
-@public
- GstGLWindowCocoa *window_cocoa;
- GstGLCAOpenGLLayer *layer;
-}
-- (id) initWithFrameLayer:(GstGLWindowCocoa *)window rect:(NSRect)contentRect layer:(CALayer *)layerContent;
-@end
-
-gboolean gst_gl_window_cocoa_create_window (GstGLWindowCocoa *window_cocoa);
-
-void _invoke_on_main (GstGLWindowCB func, gpointer data, GDestroyNotify notify);
-
-G_END_DECLS
-
-#endif /* __GST_GL_COCOA_PRIVATE_H__ */
diff --git a/gst-libs/gst/gl/cocoa/gstglcaopengllayer.h b/gst-libs/gst/gl/cocoa/gstglcaopengllayer.h
deleted file mode 100644
index 808604d27..000000000
--- a/gst-libs/gst/gl/cocoa/gstglcaopengllayer.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_CA_OPENGL_LAYER__
-#define __GST_GL_CA_OPENGL_LAYER__
-
-#include <gst/gst.h>
-#include <gst/gl/gl.h>
-#include <Cocoa/Cocoa.h>
-
-G_BEGIN_DECLS
-
-@interface GstGLCAOpenGLLayer : CAOpenGLLayer {
-@public
- GstGLContext *gst_gl_context;
- CGLContextObj gl_context;
-
-@private
- GstGLContext *draw_context;
- CGRect last_bounds;
- gint expected_dims[4];
-
- GstGLWindowCB draw_cb;
- gpointer draw_data;
- GDestroyNotify draw_notify;
-
- GstGLWindowResizeCB resize_cb;
- gpointer resize_data;
- GDestroyNotify resize_notify;
-
- gint can_draw;
- gboolean queue_resize;
-}
-- (void) setDrawCallback:(GstGLWindowCB)cb data:(gpointer)a notify:(GDestroyNotify)notify;
-- (void) setResizeCallback:(GstGLWindowResizeCB)cb data:(gpointer)a notify:(GDestroyNotify)notify;
-- (void) queueResize;
-- (id) initWithGstGLContext: (GstGLContext *)context;
-@end
-
-G_END_DECLS
-
-#endif /* __GST_GL_CA_OPENGL_LAYER__ */
diff --git a/gst-libs/gst/gl/cocoa/gstglcaopengllayer.m b/gst-libs/gst/gl/cocoa/gstglcaopengllayer.m
deleted file mode 100644
index 065d596de..000000000
--- a/gst-libs/gst/gl/cocoa/gstglcaopengllayer.m
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <Cocoa/Cocoa.h>
-
-#include "gstglcaopengllayer.h"
-#include "gstgl_cocoa_private.h"
-
-#define GST_CAT_DEFAULT gst_gl_ca_opengl_layer_debug
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-
-static void
-_init_debug (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- GST_DEBUG_CATEGORY_INIT(gst_gl_ca_opengl_layer_debug, "glcaopengllayer",
- 0, "CAOpenGLLayer");
-
- g_once_init_leave (&_init, 1);
- }
-}
-
-@implementation GstGLCAOpenGLLayer
-- (void)dealloc {
- if (self->draw_notify)
- self->draw_notify (self->draw_data);
-
- if (self->draw_context)
- gst_object_unref (self->draw_context);
-
- GST_TRACE ("dealloc GstGLCAOpenGLLayer %p context %p", self, self->gst_gl_context);
-}
-
-static void
-_context_ready (gpointer data)
-{
- GstGLCAOpenGLLayer *ca_layer = (__bridge GstGLCAOpenGLLayer *) data;
-
- g_atomic_int_set (&ca_layer->can_draw, 1);
-}
-
-- (id)initWithGstGLContext:(GstGLContext *)parent_gl_context {
- g_return_val_if_fail (GST_IS_GL_CONTEXT_COCOA (parent_gl_context), nil);
-
- self = [super init];
-
- _init_debug();
-
- GST_LOG ("init CAOpenGLLayer");
-
- self->gst_gl_context = parent_gl_context;
- self.needsDisplayOnBoundsChange = YES;
-
- gst_gl_window_send_message_async (parent_gl_context->window,
- (GstGLWindowCB) _context_ready, (__bridge_retained gpointer)self, (GDestroyNotify)CFRelease);
-
- return self;
-}
-
-- (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask {
- CGLPixelFormatObj fmt = NULL;
-
- if (self->gst_gl_context)
- fmt = gst_gl_context_cocoa_get_pixel_format (GST_GL_CONTEXT_COCOA (self->gst_gl_context));
-
- if (!fmt) {
- CGLPixelFormatAttribute attribs[] = {
- kCGLPFADoubleBuffer,
- kCGLPFAAccumSize, 32,
- 0
- };
- CGLError ret;
- gint npix = 0;
-
- GST_DEBUG ("creating new pixel format for CAOpenGLLayer %p", self);
-
- ret = CGLChoosePixelFormat (attribs, &fmt, &npix);
- if (ret != kCGLNoError) {
- GST_ERROR ("CAOpenGLLayer cannot choose a pixel format: %s", CGLErrorString (ret));
- }
- }
-
- return fmt;
-}
-
-- (CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat {
- GstGLDisplay *display;
- CGLContextObj external_context = NULL;
- CGLError ret;
- GError *error = NULL;
-
- if (self->gst_gl_context)
- external_context = (CGLContextObj) gst_gl_context_get_gl_context (self->gst_gl_context);
-
- GST_INFO ("attempting to create CGLContext for CAOpenGLLayer with "
- "share context %p", external_context);
-
- ret = CGLCreateContext (pixelFormat, external_context, &self->gl_context);
- if (ret != kCGLNoError) {
- GST_ERROR ("failed to create CGL context in CAOpenGLLayer with share context %p: %s", external_context, CGLErrorString(ret));
- return NULL;
- }
-
- if (self->draw_context)
- gst_object_unref (self->draw_context);
-
- if (kCGLNoError != CGLSetCurrentContext (self->gl_context)) {
- GST_ERROR ("failed set cgl context %p current", self->gl_context);
- return NULL;
- }
-
- display = gst_gl_context_get_display (self->gst_gl_context);
- self->draw_context = gst_gl_context_new_wrapped (display,
- (guintptr) self->gl_context, GST_GL_PLATFORM_CGL,
- gst_gl_context_get_current_gl_api (GST_GL_PLATFORM_CGL, NULL, NULL));
- gst_object_unref (display);
-
- if (!self->draw_context) {
- GST_ERROR ("failed to create wrapped context");
- return NULL;
- }
-
- gst_gl_context_activate (self->draw_context, TRUE);
- gst_gl_context_set_shared_with (self->draw_context, self->gst_gl_context);
- if (!gst_gl_context_fill_info (self->draw_context, &error)) {
- GST_ERROR ("failed to fill wrapped context information: %s", error->message);
- return NULL;
- }
- gst_gl_context_activate (self->draw_context, FALSE);
-
- return self->gl_context;
-}
-
-- (void)queueResize {
- self->queue_resize = TRUE;
-}
-
-- (void)releaseCGLContext:(CGLContextObj)glContext {
- CGLReleaseContext (glContext);
-}
-
-- (void)setDrawCallback:(GstGLWindowCB)cb data:(gpointer)data
- notify:(GDestroyNotify)notify {
- g_return_if_fail (cb);
-
- if (self->draw_notify)
- self->draw_notify (self->draw_data);
-
- self->draw_cb = cb;
- self->draw_data = data;
- self->draw_notify = notify;
-}
-
-- (void)setResizeCallback:(GstGLWindowResizeCB)cb data:(gpointer)data
- notify:(GDestroyNotify)notify {
- if (self->resize_notify)
- self->resize_notify (self->resize_data);
-
- self->resize_cb = cb;
- self->resize_data = data;
- self->resize_notify = notify;
-}
-
-- (BOOL)canDrawInCGLContext:(CGLContextObj)glContext
- pixelFormat:(CGLPixelFormatObj)pixelFormat
- forLayerTime:(CFTimeInterval)interval
- displayTime:(const CVTimeStamp *)timeStamp {
- return g_atomic_int_get (&self->can_draw);
-}
-
-- (void)drawInCGLContext:(CGLContextObj)glContext
- pixelFormat:(CGLPixelFormatObj)pixelFormat
- forLayerTime:(CFTimeInterval)interval
- displayTime:(const CVTimeStamp *)timeStamp {
- const GstGLFuncs *gl = ((GstGLContext *)self->gst_gl_context)->gl_vtable;
- GstVideoRectangle src, dst, result;
- gint ca_viewport[4];
-
- GST_LOG ("CAOpenGLLayer drawing with cgl context %p", glContext);
-
- /* attempt to get the correct viewport back due to CA being too smart
- * and messing around with it so center the expected viewport into
- * the CA viewport set up on entry to this function */
- gl->GetIntegerv (GL_VIEWPORT, ca_viewport);
-
- gst_gl_context_activate (self->draw_context, TRUE);
- if (self->queue_resize || self->last_bounds.size.width != self.bounds.size.width
- || self->last_bounds.size.height != self.bounds.size.height) {
- if (self->resize_cb) {
- self->resize_cb (self->resize_data,
- self.bounds.size.width*self.contentsScale,
- self.bounds.size.height*self.contentsScale);
-
- gl->GetIntegerv (GL_VIEWPORT, self->expected_dims);
- } else {
- /* default to whatever ca gives us */
- self->expected_dims[0] = ca_viewport[0];
- self->expected_dims[1] = ca_viewport[1];
- self->expected_dims[2] = ca_viewport[2];
- self->expected_dims[3] = ca_viewport[3];
- }
-
- self->last_bounds = self.bounds;
- self->queue_resize = FALSE;
- }
-
- src.x = self->expected_dims[0];
- src.y = self->expected_dims[1];
- src.w = self->expected_dims[2];
- src.h = self->expected_dims[3];
-
- dst.x = ca_viewport[0];
- dst.y = ca_viewport[1];
- dst.w = ca_viewport[2];
- dst.h = ca_viewport[3];
-
- gst_video_sink_center_rect (src, dst, &result, TRUE);
-
- gl->Viewport (result.x, result.y, result.w, result.h);
-
- if (self->draw_cb)
- self->draw_cb (self->draw_data);
- gst_gl_context_activate (self->draw_context, FALSE);
-
- /* flushes the buffer */
- [super drawInCGLContext:glContext pixelFormat:pixelFormat forLayerTime:interval displayTime:timeStamp];
-}
-
-@end
diff --git a/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.h b/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.h
deleted file mode 100644
index b767bb3ba..000000000
--- a/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_CONTEXT_COCOA_H__
-#define __GST_GL_CONTEXT_COCOA_H__
-
-#include <gst/gst.h>
-
-#include <gst/gl/gl.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_CONTEXT_COCOA (gst_gl_context_cocoa_get_type())
-GType gst_gl_context_cocoa_get_type (void);
-
-/* FIXME: remove this when moving to -base */
-#ifndef GST_DISABLE_DEPRECATED
-#define GST_GL_TYPE_CONTEXT_COCOA GST_TYPE_GL_CONTEXT_COCOA
-#endif
-#define GST_GL_CONTEXT_COCOA(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_CONTEXT_COCOA, GstGLContextCocoa))
-#define GST_GL_CONTEXT_COCOA_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_CONTEXT_COCOA, GstGLContextCocoaClass))
-#define GST_IS_GL_CONTEXT_COCOA(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_CONTEXT_COCOA))
-#define GST_IS_GL_CONTEXT_COCOA_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_CONTEXT_COCOA))
-#define GST_GL_CONTEXT_COCOA_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_CONTEXT_COCOA, GstGLContextCocoaClass))
-
-typedef struct _GstGLContextCocoa GstGLContextCocoa;
-typedef struct _GstGLContextCocoaPrivate GstGLContextCocoaPrivate;
-typedef struct _GstGLContextCocoaClass GstGLContextCocoaClass;
-
-struct _GstGLContextCocoa {
- /*< private >*/
- GstGLContext parent;
-
- /*< private >*/
- GstGLContextCocoaPrivate *priv;
-
- gpointer _reserved[GST_PADDING];
-};
-
-struct _GstGLContextCocoaClass {
- /*< private >*/
- GstGLContextClass parent_class;
-
- /*< private >*/
- gpointer _reserved[GST_PADDING_LARGE];
-
- GstGLContextCocoaPrivate *priv;
-};
-
-GstGLContextCocoa * gst_gl_context_cocoa_new (GstGLDisplay * display);
-guintptr gst_gl_context_cocoa_get_current_context (void);
-CGLPixelFormatObj gst_gl_context_cocoa_get_pixel_format (GstGLContextCocoa *context);
-void gst_gl_context_cocoa_dump_pixel_format (CGLPixelFormatObj fmt);
-
-
-G_END_DECLS
-
-#endif /* __GST_GL_CONTEXT_COCOA_H__ */
diff --git a/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m b/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m
deleted file mode 100644
index b3ba59e9c..000000000
--- a/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <Cocoa/Cocoa.h>
-
-#include "gstglcontext_cocoa.h"
-#include "gstgl_cocoa_private.h"
-
-static gboolean gst_gl_context_cocoa_create_context (GstGLContext *context, GstGLAPI gl_api,
- GstGLContext * other_context, GError **error);
-static void gst_gl_context_cocoa_destroy_context (GstGLContext *context);
-static guintptr gst_gl_context_cocoa_get_gl_context (GstGLContext * window);
-static gboolean gst_gl_context_cocoa_activate (GstGLContext * context, gboolean activate);
-static GstGLAPI gst_gl_context_cocoa_get_gl_api (GstGLContext * context);
-static GstGLPlatform gst_gl_context_cocoa_get_gl_platform (GstGLContext * context);
-static void gst_gl_context_cocoa_swap_buffers (GstGLContext * context);
-
-#define GST_GL_CONTEXT_COCOA_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_CONTEXT_COCOA, GstGLContextCocoaPrivate))
-
-GST_DEBUG_CATEGORY_STATIC (gst_gl_context_cocoa_debug);
-#define GST_CAT_DEFAULT gst_gl_context_cocoa_debug
-
-G_DEFINE_TYPE_WITH_CODE (GstGLContextCocoa, gst_gl_context_cocoa,
- GST_TYPE_GL_CONTEXT, GST_DEBUG_CATEGORY_INIT (gst_gl_context_cocoa_debug, "glcontext_cocoa", 0, "Cocoa GL Context"); );
-
-static void
-gst_gl_context_cocoa_class_init (GstGLContextCocoaClass * klass)
-{
- GstGLContextClass *context_class = (GstGLContextClass *) klass;
-
- g_type_class_add_private (klass, sizeof (GstGLContextCocoaPrivate));
-
- context_class->swap_buffers =
- GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_swap_buffers);
- context_class->destroy_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_destroy_context);
- context_class->create_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_create_context);
- context_class->get_gl_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_get_gl_context);
- context_class->activate = GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_activate);
- context_class->get_gl_api =
- GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_get_gl_api);
- context_class->get_gl_platform =
- GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_get_gl_platform);
-}
-
-static void
-gst_gl_context_cocoa_init (GstGLContextCocoa * context)
-{
- context->priv = GST_GL_CONTEXT_COCOA_GET_PRIVATE (context);
-}
-
-/* Must be called in the gl thread */
-GstGLContextCocoa *
-gst_gl_context_cocoa_new (GstGLDisplay * display)
-{
- GstGLContextCocoa *context;
-
- if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_COCOA) == 0)
- /* we require an cocoa display to create CGL contexts */
- return NULL;
-
- context = g_object_new (GST_TYPE_GL_CONTEXT_COCOA, NULL);
- gst_object_ref_sink (context);
-
- return context;
-}
-
-struct pixel_attr
-{
- CGLPixelFormatAttribute attr;
- const gchar *attr_name;
-};
-
-static struct pixel_attr pixel_attrs[] = {
- {kCGLPFAAllRenderers, "All Renderers"},
- {kCGLPFADoubleBuffer, "Double Buffered"},
- {kCGLPFAAuxBuffers, "Aux Buffers"},
- {kCGLPFAColorSize, "Color Size"},
- {kCGLPFAAlphaSize, "Alpha Size"},
- {kCGLPFADepthSize, "Depth Size"},
- {kCGLPFAStencilSize, "Stencil Size"},
- {kCGLPFAAccumSize, "Accum Size"},
- {kCGLPFAMinimumPolicy, "Minimum Policy"},
- {kCGLPFAMaximumPolicy, "Maximum Policy"},
- {kCGLPFASampleBuffers, "Sample Buffers"},
- {kCGLPFASamples, "Samples"},
- {kCGLPFAAuxDepthStencil, "Aux Depth Stencil"},
- {kCGLPFAColorFloat, "Color Float"},
- {kCGLPFAMultisample, "Multisample"},
- {kCGLPFASupersample, "Supersample"},
- {kCGLPFARendererID, "Renderer ID"},
- {kCGLPFANoRecovery, "No Recovery"},
- {kCGLPFAAccelerated, "Accelerated"},
- {kCGLPFAClosestPolicy, "Closest Policy"},
- {kCGLPFABackingStore, "Backing Store"},
- {kCGLPFADisplayMask, "Display Mask"},
- {kCGLPFAAllowOfflineRenderers, "Allow Offline Renderers"},
- {kCGLPFAAcceleratedCompute, "Accelerated Compute"},
- {kCGLPFAOpenGLProfile, "OpenGL Profile"},
- {kCGLPFAVirtualScreenCount, "Virtual Screen Count"},
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11
- {kCGLPFAStereo, "Stereo"},
-#endif
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
- {kCGLPFACompliant, "Compliant"},
- {kCGLPFARemotePBuffer, "Remote PBuffer"},
- {kCGLPFASingleRenderer, "Single Renderer"},
- {kCGLPFAWindow, "Window"},
-#endif
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
-// {kCGLPFAOffScreen, "Off Screen"},
-// {kCGLPFAPBuffer, "PBuffer"},
-#endif
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
-// {kCGLPFAFullScreen, "Full Screen"},
-#endif
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
-// {kCGLPFAMPSafe, "MP Safe"},
-// {kCGLPFAMultiScreen, "Multi Screen"},
-// {kCGLPFARobust, "Robust"},
-#endif
-};
-
-void
-gst_gl_context_cocoa_dump_pixel_format (CGLPixelFormatObj fmt)
-{
- int i;
-
- for (i = 0; i < G_N_ELEMENTS (pixel_attrs); i++) {
- gint val;
- CGLError ret = CGLDescribePixelFormat (fmt, 0, pixel_attrs[i].attr, &val);
-
- if (ret != kCGLNoError) {
- GST_WARNING ("failed to get pixel format %p attribute %s", fmt, pixel_attrs[i].attr_name);
- } else {
- GST_DEBUG ("Pixel format %p attr %s = %i", fmt, pixel_attrs[i].attr_name,
- val);
- }
- }
-}
-
-CGLPixelFormatObj
-gst_gl_context_cocoa_get_pixel_format (GstGLContextCocoa *context)
-{
- return context->priv->pixel_format;
-}
-
-static gboolean
-gst_gl_context_cocoa_create_context (GstGLContext *context, GstGLAPI gl_api,
- GstGLContext *other_context, GError **error)
-{
- GstGLContextCocoa *context_cocoa = GST_GL_CONTEXT_COCOA (context);
- GstGLContextCocoaPrivate *priv = context_cocoa->priv;
- GstGLWindow *window = gst_gl_context_get_window (context);
- GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
- GstGLAPI context_api = GST_GL_API_NONE;
- const GLint swapInterval = 1;
- CGLPixelFormatObj fmt = NULL;
- CGLContextObj glContext;
- CGLPixelFormatAttribute attribs[] = {
- kCGLPFADoubleBuffer,
- kCGLPFAAccumSize, 32,
- 0
- };
- CGLError ret;
- gint pix_fmt_i = 0;
- gint npix;
-
- if ((gl_api & (GST_GL_API_OPENGL | GST_GL_API_OPENGL3)) == GST_GL_API_NONE) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
- "The CGL backend only supports GL and GL3");
- goto error;
- }
-
- priv->gl_context = nil;
- if (other_context)
- priv->external_gl_context = (CGLContextObj) gst_gl_context_get_gl_context (other_context);
- else
- priv->external_gl_context = NULL;
-
- if (priv->external_gl_context) {
- gint profile;
-
- fmt = CGLGetPixelFormat (priv->external_gl_context);
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
- /* core profile is only available in >= 10.7 */
- if (kCGLNoError == CGLDescribePixelFormat (fmt, 0, kCGLPFAOpenGLProfile,
- &profile)) {
- if (profile == kCGLOGLPVersion_3_2_Core) {
- context_api = GST_GL_API_OPENGL3;
- } else {
- context_api =GST_GL_API_OPENGL;
- }
- }
-#else
- context_api = GST_GL_API_OPENGL;
-#endif
- }
-
- if (!fmt) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
- if (gl_api & GST_GL_API_OPENGL3) {
- attribs[pix_fmt_i++] = kCGLPFAOpenGLProfile;
- attribs[pix_fmt_i++] = (int) kCGLOGLPVersion_3_2_Core;
- context_api = GST_GL_API_OPENGL3;
- } else {
- context_api = GST_GL_API_OPENGL;
- }
-#else
- context_api = GST_GL_API_OPENGL;
-#endif
-
- attribs[pix_fmt_i++] = 0;
-
- ret = CGLChoosePixelFormat (attribs, &fmt, &npix);
- if (ret != kCGLNoError) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_WRONG_CONFIG, "cannot choose a pixel format: %s", CGLErrorString (ret));
- goto error;
- }
- }
-
- gst_gl_context_cocoa_dump_pixel_format (fmt);
-
- ret = CGLCreateContext (fmt, priv->external_gl_context, &glContext);
- if (ret != kCGLNoError) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
- "failed to create context: %s", CGLErrorString (ret));
- goto error;
- }
-
- context_cocoa->priv->pixel_format = fmt;
- context_cocoa->priv->gl_context = glContext;
-
- _invoke_on_main ((GstGLWindowCB) gst_gl_window_cocoa_create_window,
- gst_object_ref (window_cocoa), (GDestroyNotify) gst_object_unref);
-
- if (!context_cocoa->priv->gl_context) {
- goto error;
- }
-
- GST_INFO_OBJECT (context, "GL context created: %p", context_cocoa->priv->gl_context);
-
- CGLSetCurrentContext (context_cocoa->priv->gl_context);
-
- /* Back and front buffers are swapped only during the vertical retrace of the monitor.
- * Discarded if you configured your driver to Never-use-V-Sync.
- */
- CGLSetParameter (context_cocoa->priv->gl_context, kCGLCPSwapInterval, &swapInterval);
-
- context_cocoa->priv->context_api = context_api;
-
- if (window)
- gst_object_unref (window);
-
- return TRUE;
-
-error:
- {
- if (window)
- gst_object_unref (window);
- return FALSE;
- }
-}
-
-static void
-gst_gl_context_cocoa_swap_buffers (GstGLContext * context)
-{
-}
-
-static void
-gst_gl_context_cocoa_destroy_context (GstGLContext *context)
-{
- /* FIXME: Need to release context and other things? */
-}
-
-static guintptr
-gst_gl_context_cocoa_get_gl_context (GstGLContext * context)
-{
- return (guintptr) GST_GL_CONTEXT_COCOA (context)->priv->gl_context;
-}
-
-static gboolean
-gst_gl_context_cocoa_activate (GstGLContext * context, gboolean activate)
-{
- GstGLContextCocoa *context_cocoa = GST_GL_CONTEXT_COCOA (context);
- gpointer context_handle = activate ? context_cocoa->priv->gl_context : NULL;
-
- return kCGLNoError == CGLSetCurrentContext (context_handle);
-}
-
-static GstGLAPI
-gst_gl_context_cocoa_get_gl_api (GstGLContext * context)
-{
- GstGLContextCocoa *context_cocoa = GST_GL_CONTEXT_COCOA (context);
-
- if (context_cocoa->priv->gl_context)
- return context_cocoa->priv->context_api;
-
- return GST_GL_API_OPENGL | GST_GL_API_OPENGL3;
-}
-
-static GstGLPlatform
-gst_gl_context_cocoa_get_gl_platform (GstGLContext * context)
-{
- return GST_GL_PLATFORM_CGL;
-}
-
-guintptr
-gst_gl_context_cocoa_get_current_context (void)
-{
- return (guintptr) CGLGetCurrentContext ();
-}
diff --git a/gst-libs/gst/gl/cocoa/gstgldisplay_cocoa.h b/gst-libs/gst/gl/cocoa/gstgldisplay_cocoa.h
deleted file mode 100644
index 5551f0f29..000000000
--- a/gst-libs/gst/gl/cocoa/gstgldisplay_cocoa.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Julien Isorce <julien.isorce@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_DISPLAY_COCOA_H__
-#define __GST_GL_DISPLAY_COCOA_H__
-
-#include <gst/gst.h>
-
-#include <gst/gl/gstgl_fwd.h>
-#include <gst/gl/gstgldisplay.h>
-
-G_BEGIN_DECLS
-
-GType gst_gl_display_cocoa_get_type (void);
-
-#define GST_TYPE_GL_DISPLAY_COCOA (gst_gl_display_cocoa_get_type())
-#define GST_GL_DISPLAY_COCOA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_DISPLAY_COCOA,GstGLDisplayCocoa))
-#define GST_GL_DISPLAY_COCOA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_GL_DISPLAY_COCOA,GstGLDisplayCocoaClass))
-#define GST_IS_GL_DISPLAY_COCOA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_DISPLAY_COCOA))
-#define GST_IS_GL_DISPLAY_COCOA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GL_DISPLAY_COCOA))
-#define GST_GL_DISPLAY_COCOA_CAST(obj) ((GstGLDisplayCocoa*)(obj))
-
-typedef struct _GstGLDisplayCocoa GstGLDisplayCocoa;
-typedef struct _GstGLDisplayCocoaClass GstGLDisplayCocoaClass;
-
-/**
- * GstGLDisplayCocoa:
- *
- * Initialized NSApp if the application has not done it.
- */
-struct _GstGLDisplayCocoa
-{
- GstGLDisplay parent;
-};
-
-struct _GstGLDisplayCocoaClass
-{
- GstGLDisplayClass object_class;
-};
-
-GstGLDisplayCocoa *gst_gl_display_cocoa_new (void);
-
-G_END_DECLS
-
-#endif /* __GST_GL_DISPLAY_COCOA_H__ */
diff --git a/gst-libs/gst/gl/cocoa/gstgldisplay_cocoa.m b/gst-libs/gst/gl/cocoa/gstgldisplay_cocoa.m
deleted file mode 100644
index 5b9205b45..000000000
--- a/gst-libs/gst/gl/cocoa/gstgldisplay_cocoa.m
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Julien Isorce <julien.isorce@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <Cocoa/Cocoa.h>
-
-#include <gst/gl/cocoa/gstgldisplay_cocoa.h>
-
-GST_DEBUG_CATEGORY_STATIC (gst_gl_display_debug);
-#define GST_CAT_DEFAULT gst_gl_display_debug
-
-G_DEFINE_TYPE (GstGLDisplayCocoa, gst_gl_display_cocoa, GST_TYPE_GL_DISPLAY);
-
-static void gst_gl_display_cocoa_finalize (GObject * object);
-static guintptr gst_gl_display_cocoa_get_handle (GstGLDisplay * display);
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
-#define NSEventMaskAny NSAnyEventMask
-#endif
-
-/* Define this if the GLib patch from
- * https://bugzilla.gnome.org/show_bug.cgi?id=741450
- * is used
- */
-#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
-
-static GstGLDisplayCocoa *singleton = NULL;
-static gint nsapp_source_id = 0;
-static GMutex nsapp_lock;
-static GCond nsapp_cond;
-
-static gboolean
-gst_gl_display_cocoa_nsapp_iteration (gpointer data)
-{
- NSEvent *event = nil;
-
- if (![NSThread isMainThread]) {
- GST_WARNING ("NSApp iteration not running in the main thread");
- return FALSE;
- }
-
-
- while ((event = ([NSApp nextEventMatchingMask:NSEventMaskAny
- untilDate:[NSDate dateWithTimeIntervalSinceNow:0.05]
- inMode:NSDefaultRunLoopMode dequeue:YES])) != nil) {
- [NSApp sendEvent:event];
- }
-
- return TRUE;
-}
-
-static void
-gst_gl_display_cocoa_open_and_attach_source (gpointer data)
-{
- if ([NSThread isMainThread]) {
- /* The sharedApplication class method initializes
- * the display environment and connects your program
- * to the window server and the display server.
- * It has to be done in the main thread.
- */
- [NSApplication sharedApplication];
-
- GST_DEBUG ("Custom NSApp initialization done");
-
- nsapp_source_id = g_timeout_add (60, gst_gl_display_cocoa_nsapp_iteration,
- NULL);
-
- GST_DEBUG ("NSApp iteration loop attached, id %d", nsapp_source_id);
- }
-}
-
-static gboolean
-gst_gl_display_cocoa_init_nsapp (gpointer data)
-{
- g_mutex_lock (&nsapp_lock);
-
- gst_gl_display_cocoa_open_and_attach_source (data);
-
- g_cond_signal (&nsapp_cond);
- g_mutex_unlock (&nsapp_lock);
-
- return FALSE;
-}
-
-static GstGLDisplayCocoa *
-gst_gl_display_cocoa_setup_nsapp (gpointer data)
-{
- GMainContext *context = g_main_context_default ();
- gint delta_ms = 0;
-
- g_mutex_lock (&nsapp_lock);
-
- if (singleton) {
- GST_DEBUG ("Get existing display");
- singleton = gst_object_ref (singleton);
- g_mutex_unlock (&nsapp_lock);
- return singleton;
- }
-
- if (NSApp != nil && !singleton) {
- GstGLDisplayCocoa *ret = g_object_new (GST_TYPE_GL_DISPLAY_COCOA, NULL);
- gst_object_ref_sink (ret);
- g_mutex_unlock (&nsapp_lock);
- return ret;
- }
-
- /* All application have to start with [NSApplication sharedApplication]
- * so if NSApp is nil here let's assume this is a debugging application
- * that runs a glib main loop. */
- g_assert (NSApp == nil);
-
- GST_DEBUG ("The application has not initialized NSApp");
-
- if ([NSThread isMainThread]) {
-
- GST_DEBUG ("Setting up NSApp from the main thread");
- if (g_main_context_is_owner (context)) {
- GST_DEBUG ("The main thread own the context");
- gst_gl_display_cocoa_open_and_attach_source (data);
- } else if (g_main_context_acquire (context)) {
- GST_DEBUG ("The main loop should be shortly running in the main thread");
- gst_gl_display_cocoa_open_and_attach_source (data);
- g_main_context_release (context);
- } else {
- GST_WARNING ("Main loop running in another thread");
- }
- } else {
-
- GST_DEBUG ("Setting up NSApp not from the main thread");
-
- if (g_main_context_is_owner (context)) {
- GST_WARNING ("Default context not own by the main thread");
- delta_ms = -1;
- } else if (g_main_context_acquire (context)) {
- GST_DEBUG ("The main loop should be shortly running in the main thread");
- delta_ms = 1000;
- g_main_context_release (context);
- } else {
- GST_DEBUG ("Main loop running in main thread");
- delta_ms = 500;
- }
-
- if (delta_ms > 0) {
- gint64 end_time = g_get_monotonic_time () + delta_ms * 1000;;
- g_idle_add_full (G_PRIORITY_HIGH, gst_gl_display_cocoa_init_nsapp, data, NULL);
- g_cond_wait_until (&nsapp_cond, &nsapp_lock, end_time);
- }
- }
-
- if (NSApp == nil) {
- GST_ERROR ("Custom NSApp initialization failed");
- } else {
- GST_DEBUG ("Create display");
- singleton = g_object_new (GST_TYPE_GL_DISPLAY_COCOA, NULL);
- gst_object_ref_sink (singleton);
- }
-
- g_mutex_unlock (&nsapp_lock);
-
- return singleton;
-}
-
-#endif
-
-static void
-gst_gl_display_cocoa_class_init (GstGLDisplayCocoaClass * klass)
-{
- GST_GL_DISPLAY_CLASS (klass)->get_handle =
- GST_DEBUG_FUNCPTR (gst_gl_display_cocoa_get_handle);
-
- G_OBJECT_CLASS (klass)->finalize = gst_gl_display_cocoa_finalize;
-}
-
-static void
-gst_gl_display_cocoa_init (GstGLDisplayCocoa * display_cocoa)
-{
- GstGLDisplay *display = (GstGLDisplay *) display_cocoa;
- display->type = GST_GL_DISPLAY_TYPE_COCOA;
-}
-
-static void
-gst_gl_display_cocoa_finalize (GObject * object)
-{
-#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
- g_mutex_lock (&nsapp_lock);
- if (singleton) {
- GST_DEBUG ("Destroy display");
- singleton = NULL;
- if (nsapp_source_id) {
- GST_DEBUG ("Remove NSApp loop iteration, id %d", nsapp_source_id);
- g_source_remove (nsapp_source_id);
- }
- nsapp_source_id = 0;
- g_mutex_unlock (&nsapp_lock);
- }
- g_mutex_unlock (&nsapp_lock);
-#endif
-
- G_OBJECT_CLASS (gst_gl_display_cocoa_parent_class)->finalize (object);
-}
-
-/**
- * gst_gl_display_cocoa_new:
- *
- * Create a new #GstGLDisplayCocoa.
- *
- * Returns: (transfer full): a new #GstGLDisplayCocoa or %NULL
- */
-GstGLDisplayCocoa *
-gst_gl_display_cocoa_new (void)
-{
- GstGLDisplayCocoa *display;
-
- GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");
-
-#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
- display = gst_gl_display_cocoa_setup_nsapp (NULL);
-#else
- display = g_object_new (GST_TYPE_GL_DISPLAY_COCOA, NULL);
- gst_object_ref_sink (display);
-#endif
-
- return display;
-}
-
-static guintptr
-gst_gl_display_cocoa_get_handle (GstGLDisplay * display)
-{
- return (guintptr) NSApp;
-}
diff --git a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.h b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.h
deleted file mode 100644
index 4c0bf4fc3..000000000
--- a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_WINDOW_COCOA_H__
-#define __GST_GL_WINDOW_COCOA_H__
-
-#include <gst/gst.h>
-
-#include <gst/gl/gl.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_WINDOW_COCOA (gst_gl_window_cocoa_get_type())
-#define GST_GL_WINDOW_COCOA(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW_COCOA, GstGLWindowCocoa))
-#define GST_GL_WINDOW_COCOA_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_WINDOW_COCOA, GstGLWindowCocoaClass))
-#define GST_IS_GL_WINDOW_COCOA(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW_COCOA))
-#define GST_IS_GL_WINDOW_COCOA_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW_COCOA))
-#define GST_GL_WINDOW_COCOA_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW_COCOA, GstGLWindowCocoaClass))
-
-typedef struct _GstGLWindowCocoa GstGLWindowCocoa;
-typedef struct _GstGLWindowCocoaPrivate GstGLWindowCocoaPrivate;
-typedef struct _GstGLWindowCocoaClass GstGLWindowCocoaClass;
-
-struct _GstGLWindowCocoa {
- /*< private >*/
- GstGLWindow parent;
-
- /*< private >*/
- GstGLWindowCocoaPrivate *priv;
-
- gpointer _reserved[GST_PADDING];
-};
-
-struct _GstGLWindowCocoaClass {
- /*< private >*/
- GstGLWindowClass parent_class;
-
- /*< private >*/
- gpointer _reserved[GST_PADDING_LARGE];
-};
-
-GType gst_gl_window_cocoa_get_type (void);
-
-GstGLWindowCocoa * gst_gl_window_cocoa_new (GstGLDisplay * display);
-
-void gst_gl_window_cocoa_draw_thread (GstGLWindowCocoa *window_cocoa);
-
-G_END_DECLS
-
-#endif /* __GST_GL_WINDOW_COCOA_H__ */
diff --git a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
deleted file mode 100644
index 4533b83c9..000000000
--- a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it un der the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <Cocoa/Cocoa.h>
-#include <QuartzCore/QuartzCore.h>
-
-#include "gstgl_cocoa_private.h"
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
-#define NSWindowStyleMaskTitled NSTitledWindowMask
-#define NSWindowStyleMaskClosable NSClosableWindowMask
-#define NSWindowStyleMaskResizable NSResizableWindowMask
-#define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
-#endif
-
-/* =============================================================*/
-/* */
-/* GstGLNSWindow declaration */
-/* */
-/* =============================================================*/
-
-@interface GstGLNSWindow: NSWindow {
- BOOL m_isClosed;
- GstGLWindowCocoa *window_cocoa;
-}
-- (id)initWithContentRect:(NSRect)contentRect
- styleMask: (unsigned int) styleMask
- backing: (NSBackingStoreType) bufferingType
- defer: (BOOL) flag screen: (NSScreen *) aScreen
- gstWin: (GstGLWindowCocoa *) window;
-- (void) setClosed;
-- (BOOL) isClosed;
-- (BOOL) canBecomeMainWindow;
-- (BOOL) canBecomeKeyWindow;
-@end
-
-/* =============================================================*/
-/* */
-/* GstGLWindow */
-/* */
-/* =============================================================*/
-
-#define GST_GL_WINDOW_COCOA_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_WINDOW_COCOA, GstGLWindowCocoaPrivate))
-
-#define GST_CAT_DEFAULT gst_gl_window_cocoa_debug
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-
-#define DEBUG_INIT \
- GST_DEBUG_CATEGORY_GET (GST_CAT_DEFAULT, "glwindow");
-#define gst_gl_window_cocoa_parent_class parent_class
-G_DEFINE_TYPE_WITH_CODE (GstGLWindowCocoa, gst_gl_window_cocoa, GST_TYPE_GL_WINDOW, DEBUG_INIT);
-static void gst_gl_window_cocoa_finalize (GObject * object);
-
-static gboolean gst_gl_window_cocoa_open (GstGLWindow *window, GError **err);
-static void gst_gl_window_cocoa_close (GstGLWindow *window);
-static guintptr gst_gl_window_cocoa_get_window_handle (GstGLWindow * window);
-static void gst_gl_window_cocoa_set_window_handle (GstGLWindow * window,
- guintptr handle);
-static void gst_gl_window_cocoa_draw (GstGLWindow * window);
-static void gst_gl_window_cocoa_set_preferred_size (GstGLWindow * window,
- gint width, gint height);
-static void gst_gl_window_cocoa_show (GstGLWindow * window);
-static void gst_gl_window_cocoa_queue_resize (GstGLWindow * window);
-static void gst_gl_window_cocoa_send_message_async (GstGLWindow * window,
- GstGLWindowCB callback, gpointer data, GDestroyNotify destroy);
-
-struct _GstGLWindowCocoaPrivate
-{
- gpointer internal_win_id;
- gpointer external_view;
- gboolean visible;
- gint preferred_width;
- gint preferred_height;
-
- GLint viewport_dim[4];
-
- /* atomic set when the internal NSView has been created */
- int view_ready;
-
- gpointer gl_queue;
-};
-
-static void
-gst_gl_window_cocoa_class_init (GstGLWindowCocoaClass * klass)
-{
- GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
- GObjectClass *gobject_class = (GObjectClass *) klass;
-
- g_type_class_add_private (klass, sizeof (GstGLWindowCocoaPrivate));
-
- window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_open);
- window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_close);
- window_class->get_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_get_window_handle);
- window_class->set_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_set_window_handle);
- window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_draw);
- window_class->set_preferred_size =
- GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_set_preferred_size);
- window_class->show = GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_show);
- window_class->queue_resize = GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_queue_resize);
- window_class->send_message_async =
- GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_send_message_async);
-
- gobject_class->finalize = gst_gl_window_cocoa_finalize;
-}
-
-static void
-gst_gl_window_cocoa_init (GstGLWindowCocoa * window)
-{
- window->priv = GST_GL_WINDOW_COCOA_GET_PRIVATE (window);
-
- window->priv->preferred_width = 320;
- window->priv->preferred_height = 240;
- window->priv->gl_queue = (__bridge_retained gpointer)
- (dispatch_queue_create ("org.freedesktop.gstreamer.glwindow", NULL));
-}
-
-static void
-gst_gl_window_cocoa_finalize (GObject * object)
-{
- GstGLWindowCocoa *window = GST_GL_WINDOW_COCOA (object);
- window->priv->gl_queue = NULL;
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-GstGLWindowCocoa *
-gst_gl_window_cocoa_new (GstGLDisplay * display)
-{
- GstGLWindowCocoa *window;
-
- if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_COCOA) == 0)
- /* we require an cocoa display to create CGL windows */
- return NULL;
-
- window = g_object_new (GST_TYPE_GL_WINDOW_COCOA, NULL);
- gst_object_ref_sink (window);
-
- return window;
-}
-
-/* Must be called from the main thread */
-gboolean
-gst_gl_window_cocoa_create_window (GstGLWindowCocoa *window_cocoa)
-{
- GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
- GstGLWindow *window = GST_GL_WINDOW (window_cocoa);
- GstGLNSWindow *internal_win_id;
- NSRect mainRect = [[NSScreen mainScreen] visibleFrame];
- gint h = priv->preferred_height;
- gint y = mainRect.size.height > h ? (mainRect.size.height - h) * 0.5 : 0;
- NSRect rect = NSMakeRect (0, y, priv->preferred_width, priv->preferred_height);
- NSRect windowRect = NSMakeRect (0, y, priv->preferred_width, priv->preferred_height);
- GstGLContext *context = gst_gl_window_get_context (window);
- GstGLContextCocoa *context_cocoa;
- GstGLCAOpenGLLayer *layer;
- GstGLNSView *glView;
-
- if (!context)
- return FALSE;
-
- context_cocoa = GST_GL_CONTEXT_COCOA (context);
- layer = [[GstGLCAOpenGLLayer alloc] initWithGstGLContext:context];
- glView = [[GstGLNSView alloc] initWithFrameLayer:window_cocoa rect:windowRect layer:layer];
-
- gst_object_unref (context);
-
- internal_win_id = [[GstGLNSWindow alloc] initWithContentRect:rect styleMask:
- (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
- NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable)
- backing: NSBackingStoreBuffered defer: NO screen: nil gstWin: window_cocoa];
-
- priv->internal_win_id = (__bridge_retained gpointer)internal_win_id;
-
- GST_DEBUG ("NSWindow id: %"G_GUINTPTR_FORMAT, (guintptr) priv->internal_win_id);
-
- [internal_win_id setContentView:glView];
-
- g_atomic_int_set (&window_cocoa->priv->view_ready, 1);
-
- /* Set the window handle for real now that the NSWindow has been created. */
- if (priv->external_view)
- gst_gl_window_cocoa_set_window_handle (window,
- (guintptr) priv->external_view);
-
- return TRUE;
-}
-
-static gboolean
-gst_gl_window_cocoa_open (GstGLWindow *window, GError **err)
-{
- GstGLWindowCocoa *window_cocoa;
-
- window_cocoa = GST_GL_WINDOW_COCOA (window);
-
- return TRUE;
-}
-
-static void
-gst_gl_window_cocoa_close (GstGLWindow *window)
-{
- GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
- GstGLNSWindow *internal_win_id = (__bridge GstGLNSWindow *)window_cocoa->priv->internal_win_id;
-
- [[internal_win_id contentView] removeFromSuperview];
- CFBridgingRelease(window_cocoa->priv->internal_win_id);
- window_cocoa->priv->internal_win_id = NULL;
-}
-
-static guintptr
-gst_gl_window_cocoa_get_window_handle (GstGLWindow *window)
-{
- return (guintptr) GST_GL_WINDOW_COCOA (window)->priv->internal_win_id;
-}
-
-static void
-gst_gl_window_cocoa_set_window_handle (GstGLWindow * window, guintptr handle)
-{
- GstGLWindowCocoa *window_cocoa;
- GstGLWindowCocoaPrivate *priv;
-
- window_cocoa = GST_GL_WINDOW_COCOA (window);
- priv = window_cocoa->priv;
-
- if (priv->internal_win_id) {
- if (handle) {
- priv->external_view = (gpointer)handle;
- priv->visible = TRUE;
- } else {
- /* bring back our internal window */
- priv->external_view = 0;
- priv->visible = FALSE;
- }
-
-
- dispatch_async (dispatch_get_main_queue (), ^{
- GstGLNSWindow *internal_win_id =
- (__bridge GstGLNSWindow *)window_cocoa->priv->internal_win_id;
- NSView *external_view =
- (__bridge NSView *)window_cocoa->priv->external_view;
-
- NSView *view = [internal_win_id contentView];
- [internal_win_id orderOut:internal_win_id];
-
- [external_view addSubview: view];
-
- [view setFrame: [external_view bounds]];
- [view setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
- });
- } else {
- /* no internal window yet so delay it to the next drawing */
- priv->external_view = (gpointer)handle;
- priv->visible = FALSE;
- }
-}
-
-static void
-_show_window (gpointer data)
-{
- GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (data);
- GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
- GstGLNSWindow *internal_win_id = (__bridge GstGLNSWindow *)priv->internal_win_id;
-
- GST_DEBUG_OBJECT (window_cocoa, "make the window available\n");
- [internal_win_id makeMainWindow];
- [internal_win_id orderFrontRegardless];
- [internal_win_id setViewsNeedDisplay:YES];
-
- priv->visible = TRUE;
-}
-
-static void
-gst_gl_window_cocoa_show (GstGLWindow * window)
-{
- GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
- GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
-
- if (!priv->visible) {
- /* useful when set_window_handle is called before
- * the internal NSWindow */
- if (priv->external_view) {
- gst_gl_window_cocoa_set_window_handle (window, (guintptr) priv->external_view);
- priv->visible = TRUE;
- return;
- }
-
- if (!priv->external_view && !priv->visible)
- _invoke_on_main ((GstGLWindowCB) _show_window, gst_object_ref (window),
- (GDestroyNotify) gst_object_unref);
- }
-}
-
-static void
-gst_gl_window_cocoa_queue_resize (GstGLWindow * window)
-{
- GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
- GstGLNSView *view;
- GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
- GstGLNSWindow *internal_win_id = (__bridge GstGLNSWindow *)priv->internal_win_id;
-
- if (!g_atomic_int_get (&window_cocoa->priv->view_ready))
- return;
-
- view = (GstGLNSView *)[internal_win_id contentView];
-
- [view->layer queueResize];
-}
-
-static void
-gst_gl_window_cocoa_draw (GstGLWindow * window)
-{
- GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
- GstGLNSView *view;
- GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
- GstGLNSWindow *internal_win_id = (__bridge GstGLNSWindow *)priv->internal_win_id;
-
- /* As the view is created asynchronously in the main thread we cannot know
- * exactly when it will be ready to draw to */
- if (!g_atomic_int_get (&window_cocoa->priv->view_ready))
- return;
-
- view = (GstGLNSView *)[internal_win_id contentView];
-
- /* this redraws the GstGLCAOpenGLLayer which calls
- * gst_gl_window_cocoa_draw_thread(). Use an explicit CATransaction since we
- * don't know how often the main runloop is running.
- */
- [CATransaction begin];
- [view setNeedsDisplay:YES];
- [CATransaction commit];
-}
-
-static void
-gst_gl_window_cocoa_set_preferred_size (GstGLWindow * window, gint width,
- gint height)
-{
- GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
-
- window_cocoa->priv->preferred_width = width;
- window_cocoa->priv->preferred_height = height;
-}
-
-static void
-gst_gl_cocoa_draw_cb (GstGLWindowCocoa *window_cocoa)
-{
- GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
- GstGLNSWindow *internal_win_id = (__bridge GstGLNSWindow *)priv->internal_win_id;
-
- if (internal_win_id && ![internal_win_id isClosed]) {
- GstGLWindow *window = GST_GL_WINDOW (window_cocoa);
-
- /* draw opengl scene in the back buffer */
- if (window->draw)
- window->draw (window->draw_data);
- }
-}
-
-static void
-gst_gl_cocoa_resize_cb (GstGLNSView * view, guint width, guint height)
-{
- GstGLWindowCocoa *window_cocoa = view->window_cocoa;
- GstGLWindow *window = GST_GL_WINDOW (window_cocoa);
- GstGLContext *context = gst_gl_window_get_context (window);
- GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
- GstGLNSWindow *internal_win_id = (__bridge GstGLNSWindow *)priv->internal_win_id;
-
- if (internal_win_id && ![internal_win_id isClosed]) {
- const GstGLFuncs *gl;
- NSRect bounds = [view bounds];
- NSRect visibleRect = [view visibleRect];
- gint viewport_dim[4];
-
- gl = context->gl_vtable;
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- bounds = [view convertRectToBacking:bounds];
- visibleRect = [view convertRectToBacking:visibleRect];
-#endif
-
- GST_DEBUG_OBJECT (window, "Window resized: bounds %lf %lf %lf %lf "
- "visibleRect %lf %lf %lf %lf",
- bounds.origin.x, bounds.origin.y,
- bounds.size.width, bounds.size.height,
- visibleRect.origin.x, visibleRect.origin.y,
- visibleRect.size.width, visibleRect.size.height);
-
- gst_gl_window_resize (window, width, height);
- gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
-
- gl->Viewport (viewport_dim[0] - visibleRect.origin.x,
- viewport_dim[1] - visibleRect.origin.y,
- viewport_dim[2], viewport_dim[3]);
- }
-
- gst_object_unref (context);
-}
-
-static void
-gst_gl_window_cocoa_send_message_async (GstGLWindow * window,
- GstGLWindowCB callback, gpointer data, GDestroyNotify destroy)
-{
- GstGLWindowCocoa *window_cocoa = (GstGLWindowCocoa *) window;
- GstGLContext *context = gst_gl_window_get_context (window);
- GThread *thread = gst_gl_context_get_thread (context);
- GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
- dispatch_queue_t gl_queue = (__bridge dispatch_queue_t)priv->gl_queue;
-
- if (thread == g_thread_self()) {
- /* this case happens for nested calls happening from inside the GCD queue */
- callback (data);
- if (destroy)
- destroy (data);
- gst_object_unref (context);
- } else {
- dispatch_async (gl_queue, ^{
- gst_gl_context_activate (context, TRUE);
- gst_object_unref (context);
- callback (data);
- if (destroy)
- destroy (data);
- });
- }
- if (thread)
- g_thread_unref (thread);
-}
-
-/* =============================================================*/
-/* */
-/* GstGLNSWindow implementation */
-/* */
-/* =============================================================*/
-
-/* Must be called from the main thread */
-@implementation GstGLNSWindow
-
-- (id) initWithContentRect: (NSRect) contentRect
- styleMask: (unsigned int) styleMask
- backing: (NSBackingStoreType) bufferingType
- defer: (BOOL) flag screen: (NSScreen *) aScreen
- gstWin: (GstGLWindowCocoa *) cocoa {
-
- m_isClosed = NO;
- window_cocoa = cocoa;
- GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
- GstGLNSWindow *internal_win_id = (__bridge GstGLNSWindow *)priv->internal_win_id;
-
- self = [super initWithContentRect: contentRect
- styleMask: styleMask backing: bufferingType
- defer: flag screen:aScreen];
-
- [self setReleasedWhenClosed:NO];
-
- GST_DEBUG ("initializing GstGLNSWindow\n");
-
- [self setTitle:@"OpenGL renderer"];
-
- [self setBackgroundColor:[NSColor blackColor]];
-
- [self orderOut:internal_win_id];
-
- return self;
-}
-
-- (void) setClosed {
- m_isClosed = YES;
-}
-
-- (BOOL) isClosed {
- return m_isClosed;
-}
-
-- (BOOL) canBecomeMainWindow {
- return YES;
-}
-
-- (BOOL) canBecomeKeyWindow {
- return YES;
-}
-
-static void
-close_window_cb (gpointer data)
-{
- GstGLWindowCocoa *window_cocoa = data;
- GstGLWindow *window;
-
- window = GST_GL_WINDOW (window_cocoa);
-
- if (window->close) {
- window->close (window->close_data);
- }
-}
-
-/* Called in the main thread which is never the gl thread */
-- (BOOL) windowShouldClose:(id)sender {
-
- GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
- GstGLNSWindow *internal_win_id = (__bridge GstGLNSWindow *)priv->internal_win_id;
- GST_DEBUG ("user clicked the close button\n");
- [internal_win_id setClosed];
- gst_gl_window_send_message_async (GST_GL_WINDOW (window_cocoa),
- (GstGLWindowCB) close_window_cb, gst_object_ref (window_cocoa),
- (GDestroyNotify) gst_object_unref);
- return YES;
-}
-
-@end
-
-/* =============================================================*/
-/* */
-/* GstGLNSView implementation */
-/* */
-/* =============================================================*/
-
-@implementation GstGLNSView
-
-/* Must be called from the application main thread */
-- (id)initWithFrameLayer:(GstGLWindowCocoa *)window rect:(NSRect)contentRect layer:(CALayer *)layerContent {
-
- self = [super initWithFrame: contentRect];
-
- window_cocoa = window;
-
- /* The order of the next two calls matters. This creates a layer-hosted
- * NSView. Calling setWantsLayer before setLayer will create a
- * layer-backed NSView. See the apple developer documentation on the
- * difference.
- */
- [self setLayer:layerContent];
- [self setWantsLayer:YES];
- self->layer = (GstGLCAOpenGLLayer *)layerContent;
- [self->layer setDrawCallback:(GstGLWindowCB)gst_gl_cocoa_draw_cb
- data:window notify:NULL];
- [self->layer setResizeCallback:(GstGLWindowResizeCB)gst_gl_cocoa_resize_cb
- data:(__bridge_retained gpointer)self notify:(GDestroyNotify)CFRelease];
-
- [self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay];
-
- [self setWantsBestResolutionOpenGLSurface:YES];
-
- return self;
-}
-
-- (void) dealloc {
- self->layer = nil;
-}
-
-- (void)renewGState {
- /* Don't update the screen until we redraw, this
- * prevents flickering during scrolling, clipping,
- * resizing, etc
- */
- [[self window] disableScreenUpdatesUntilFlush];
-
- [super renewGState];
-}
-
-- (BOOL) isOpaque {
- return YES;
-}
-
-- (BOOL) isFlipped {
- return NO;
-}
-
-@end
-
-void
-_invoke_on_main (GstGLWindowCB func, gpointer data, GDestroyNotify notify)
-{
- if ([NSThread isMainThread]) {
- func (data);
- if (notify)
- notify (data);
- } else {
- dispatch_async (dispatch_get_main_queue (), ^{
- func (data);
- if (notify)
- notify (data);
- });
- }
-}
diff --git a/gst-libs/gst/gl/dispmanx/Makefile.am b/gst-libs/gst/gl/dispmanx/Makefile.am
deleted file mode 100644
index 28f4430b6..000000000
--- a/gst-libs/gst/gl/dispmanx/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-noinst_LTLIBRARIES = libgstgl-dispmanx.la
-
-libgstgl_dispmanx_la_SOURCES = \
- gstglwindow_dispmanx_egl.c
-
-noinst_HEADERS = \
- gstglwindow_dispmanx_egl.h
-
-libgstgl_dispmanx_la_CFLAGS = \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- $(GL_CFLAGS) \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) \
- $(GST_CFLAGS)
-
-libgstgl_dispmanx_la_LDFLAGS = \
- $(GST_LIB_LDFLAGS) \
- $(GST_ALL_LDFLAGS)
diff --git a/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.c b/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.c
deleted file mode 100644
index 7b10b4d01..000000000
--- a/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.c
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Julien Isorce <julien.isorce@collabora.co.uk>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#define GLIB_DISABLE_DEPRECATION_WARNINGS
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "../gstgl_fwd.h"
-#include <gst/gl/gstglcontext.h>
-
-#include "gstglwindow_dispmanx_egl.h"
-#include "../gstglwindow_private.h"
-
-
-#ifndef ELEMENT_CHANGE_LAYER
-/* copied from interface/vmcs_host/vc_vchi_dispmanx.h of userland.git */
-#define ELEMENT_CHANGE_LAYER (1<<0)
-#define ELEMENT_CHANGE_OPACITY (1<<1)
-#define ELEMENT_CHANGE_DEST_RECT (1<<2)
-#define ELEMENT_CHANGE_SRC_RECT (1<<3)
-#define ELEMENT_CHANGE_MASK_RESOURCE (1<<4)
-#define ELEMENT_CHANGE_TRANSFORM (1<<5)
-#endif
-
-#define GST_CAT_DEFAULT gst_gl_window_debug
-
-#define gst_gl_window_dispmanx_egl_parent_class parent_class
-G_DEFINE_TYPE (GstGLWindowDispmanxEGL, gst_gl_window_dispmanx_egl,
- GST_TYPE_GL_WINDOW);
-
-static guintptr gst_gl_window_dispmanx_egl_get_window_handle (GstGLWindow *
- window);
-static void gst_gl_window_dispmanx_egl_set_window_handle (GstGLWindow * window,
- guintptr handle);
-static void gst_gl_window_dispmanx_egl_set_preferred_size (GstGLWindow * window,
- gint width, gint height);
-static void gst_gl_window_dispmanx_egl_show (GstGLWindow * window);
-static void gst_gl_window_dispmanx_egl_close (GstGLWindow * window);
-static gboolean gst_gl_window_dispmanx_egl_open (GstGLWindow * window,
- GError ** error);
-static guintptr gst_gl_window_dispmanx_egl_get_display (GstGLWindow * window);
-static gboolean gst_gl_window_dispmanx_egl_set_render_rectangle (GstGLWindow *
- window, gint x, gint y, gint width, gint height);
-
-static void window_resize (GstGLWindowDispmanxEGL * window_egl, guint width,
- guint height, gboolean visible);
-
-static void
-gst_gl_window_dispmanx_egl_class_init (GstGLWindowDispmanxEGLClass * klass)
-{
- GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
-
- window_class->get_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_get_window_handle);
- window_class->set_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_set_window_handle);
- window_class->show = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_show);
- window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_close);
- window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_open);
- window_class->get_display =
- GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_get_display);
- window_class->set_preferred_size =
- GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_set_preferred_size);
- window_class->set_render_rectangle =
- GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_set_render_rectangle);
-}
-
-static void
-gst_gl_window_dispmanx_egl_init (GstGLWindowDispmanxEGL * window_egl)
-{
- window_egl->egldisplay = EGL_DEFAULT_DISPLAY;
-
- window_egl->visible = FALSE;
- window_egl->display = 0;
- window_egl->dp_width = 0;
- window_egl->dp_height = 0;
- window_egl->native.element = 0;
- window_egl->native.width = 0;
- window_egl->native.height = 0;
- window_egl->foreign.element = 0;
- window_egl->foreign.width = 0;
- window_egl->foreign.height = 0;
- window_egl->render_rect.x = 0;
- window_egl->render_rect.y = 0;
- window_egl->render_rect.w = 0;
- window_egl->render_rect.h = 0;
-}
-
-/* Must be called in the gl thread */
-GstGLWindowDispmanxEGL *
-gst_gl_window_dispmanx_egl_new (GstGLDisplay * display)
-{
- GstGLWindowDispmanxEGL *window;
-
- if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_EGL) == 0)
- /* we require an egl display to create dispmanx windows */
- return NULL;
-
- GST_DEBUG ("creating Dispmanx EGL window");
-
- window = g_object_new (GST_TYPE_GL_WINDOW_DISPMANX_EGL, NULL);
- gst_object_ref_sink (window);
-
- return window;
-}
-
-static void
-gst_gl_window_dispmanx_egl_close (GstGLWindow * window)
-{
- GstGLWindowDispmanxEGL *window_egl;
- DISPMANX_UPDATE_HANDLE_T dispman_update;
-
- window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
-
- if (window_egl->native.element
- && window_egl->native.element != window_egl->foreign.element) {
- dispman_update = vc_dispmanx_update_start (0);
- vc_dispmanx_element_remove (dispman_update, window_egl->native.element);
- vc_dispmanx_update_submit_sync (dispman_update);
- }
- vc_dispmanx_display_close (window_egl->display);
-
- GST_GL_WINDOW_CLASS (parent_class)->close (window);
-}
-
-static gboolean
-gst_gl_window_dispmanx_egl_open (GstGLWindow * window, GError ** error)
-{
- GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
- gint ret = graphics_get_display_size (0, &window_egl->dp_width,
- &window_egl->dp_height);
- if (ret < 0) {
- g_set_error (error, GST_GL_WINDOW_ERROR,
- GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE, "Can't open display");
- return FALSE;
- }
- GST_DEBUG ("Got display size: %dx%d\n", window_egl->dp_width,
- window_egl->dp_height);
-
- window_egl->native.element = 0;
-
- return GST_GL_WINDOW_CLASS (parent_class)->open (window, error);
-}
-
-gboolean
-gst_gl_window_dispmanx_egl_create_window (GstGLWindowDispmanxEGL * window_egl)
-{
- window_egl->native.width = 0;
- window_egl->native.height = 0;
- window_egl->display = vc_dispmanx_display_open (0);
- window_resize (window_egl, 16, 16, FALSE);
- return TRUE;
-}
-
-static guintptr
-gst_gl_window_dispmanx_egl_get_window_handle (GstGLWindow * window)
-{
- GstGLWindowDispmanxEGL *window_egl;
- window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
- if (window_egl->native.element)
- return (guintptr) & window_egl->native;
- return 0;
-}
-
-static void
-gst_gl_window_dispmanx_egl_set_window_handle (GstGLWindow * window,
- guintptr handle)
-{
- GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
- EGL_DISPMANX_WINDOW_T *foreign_window = (EGL_DISPMANX_WINDOW_T *) handle;
- DISPMANX_UPDATE_HANDLE_T dispman_update;
-
- GST_DEBUG_OBJECT (window, "set window handle with size %dx%d",
- foreign_window->width, foreign_window->height);
-
- if (window_egl->native.element) {
- dispman_update = vc_dispmanx_update_start (0);
- vc_dispmanx_element_remove (dispman_update, window_egl->native.element);
- vc_dispmanx_update_submit_sync (dispman_update);
- }
-
- window_egl->native.element = window_egl->foreign.element =
- foreign_window->element;
- window_egl->native.width = window_egl->foreign.width = foreign_window->width;
- window_egl->native.height = window_egl->foreign.height =
- foreign_window->height;
-}
-
-static void
-gst_gl_window_dispmanx_egl_set_preferred_size (GstGLWindow * window, gint width,
- gint height)
-{
- GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
-
- GST_DEBUG_OBJECT (window, "set preferred size to %dx%d", width, height);
- window_egl->preferred_width = width;
- window_egl->preferred_height = height;
-}
-
-static void
-window_resize (GstGLWindowDispmanxEGL * window_egl, guint width, guint height,
- gboolean visible)
-{
- GstGLWindow *window = GST_GL_WINDOW (window_egl);
-
- GST_DEBUG ("resizing %s window from %ux%u to %ux%u",
- visible ? "visible" : "invisible", window_egl->native.width,
- window_egl->native.height, width, height);
-
- if (window_egl->display) {
- VC_RECT_T dst_rect;
- VC_RECT_T src_rect;
- GstVideoRectangle src, res;
- DISPMANX_UPDATE_HANDLE_T dispman_update;
- uint32_t opacity = visible ? 255 : 0;
- VC_DISPMANX_ALPHA_T alpha =
- { DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS, opacity, 0 };
-
- src.w = width;
- src.h = height;
- src.x = src.y = 0;
-
- /* If there is no render rectangle, center the width*height frame
- * inside dp_width*dp_height */
- if (window_egl->render_rect.w <= 0 || window_egl->render_rect.h <= 0) {
- GstVideoRectangle dst;
- dst.w = window_egl->dp_width;
- dst.h = window_egl->dp_height;
- dst.x = dst.y = 0;
- gst_video_sink_center_rect (src, dst, &res, FALSE);
- } else {
- gst_video_sink_center_rect (src, window_egl->render_rect, &res, FALSE);
- }
-
- dst_rect.x = res.x;
- dst_rect.y = res.y;
- dst_rect.width = res.w;
- dst_rect.height = res.h;
-
- src_rect.x = 0;
- src_rect.y = 0;
- src_rect.width = width << 16;
- src_rect.height = height << 16;
-
- dispman_update = vc_dispmanx_update_start (0);
-
- if (window_egl->native.element) {
- uint32_t change_flags =
- ELEMENT_CHANGE_OPACITY | ELEMENT_CHANGE_DEST_RECT |
- ELEMENT_CHANGE_SRC_RECT;
- vc_dispmanx_element_change_attributes (dispman_update,
- window_egl->native.element, change_flags, 0, opacity, &dst_rect,
- &src_rect, 0, 0);
- } else {
- window_egl->native.element = vc_dispmanx_element_add (dispman_update,
- window_egl->display, 0, &dst_rect, 0, &src_rect,
- DISPMANX_PROTECTION_NONE, &alpha, 0, 0);
- }
-
- vc_dispmanx_update_submit_sync (dispman_update);
-
- gst_gl_window_resize (window, width, height);
- }
-
- window_egl->native.width = width;
- window_egl->native.height = height;
-}
-
-static gboolean
-gst_gl_window_dispmanx_egl_set_render_rectangle (GstGLWindow * window,
- gint x, gint y, gint width, gint height)
-{
- GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
- window_egl->render_rect.x = x;
- window_egl->render_rect.y = y;
- window_egl->render_rect.w = width;
- window_egl->render_rect.h = height;
-
- window_resize (window_egl, window_egl->render_rect.w,
- window_egl->render_rect.h, TRUE);
- return TRUE;
-}
-
-static void
-gst_gl_window_dispmanx_egl_show (GstGLWindow * window)
-{
- GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
-
- if (!window_egl->visible) {
- if (window_egl->render_rect.w <= 0 || window_egl->render_rect.h <= 0) {
- window_resize (window_egl, window_egl->preferred_width,
- window_egl->preferred_height, TRUE);
- }
- window_egl->visible = TRUE;
- }
-}
-
-static guintptr
-gst_gl_window_dispmanx_egl_get_display (GstGLWindow * window)
-{
- GstGLWindowDispmanxEGL *window_egl;
-
- window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
-
- return (guintptr) window_egl->egldisplay;
-}
diff --git a/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.h b/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.h
deleted file mode 100644
index 34f1964be..000000000
--- a/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Julien Isorce <julien.isorce@collabora.co.uk>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_WINDOW_DISPMANX_EGL_H__
-#define __GST_GL_WINDOW_DISPMANX_EGL_H__
-
-#include <gst/video/gstvideosink.h>
-#include <gst/gl/gl.h>
-#include <gst/gl/egl/gstegl.h>
-
-#if defined(__GNUC__)
-#ifndef __VCCOREVER__
-#define __VCCOREVER__ 0x04000000
-#endif
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wredundant-decls"
-#pragma GCC optimize ("gnu89-inline")
-#endif
-
-#include <bcm_host.h>
-
-#if defined(__GNUC__)
-#pragma GCC reset_options
-#pragma GCC diagnostic pop
-#endif
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_WINDOW_DISPMANX_EGL (gst_gl_window_dispmanx_egl_get_type())
-#define GST_GL_WINDOW_DISPMANX_EGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW_DISPMANX_EGL, GstGLWindowDispmanxEGL))
-#define GST_GL_WINDOW_DISPMANX_EGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_WINDOW_DISPMANX_EGL, GstGLWindowDispmanxEGLClass))
-#define GST_IS_GL_WINDOW_DISPMANX_EGL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW_DISPMANX_EGL))
-#define GST_IS_GL_WINDOW_DISPMANX_EGL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW_DISPMANX_EGL))
-#define GST_GL_WINDOW_DISPMANX_EGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW_DISPMANX_EGL, GstGLWindowDispmanxEGL_Class))
-
-typedef struct _GstGLWindowDispmanxEGL GstGLWindowDispmanxEGL;
-typedef struct _GstGLWindowDispmanxEGLClass GstGLWindowDispmanxEGLClass;
-
-struct _GstGLWindowDispmanxEGL {
- /*< private >*/
- GstGLWindow parent;
-
- EGLDisplay egldisplay;
-
- DISPMANX_DISPLAY_HANDLE_T display;
- uint32_t dp_height;
- uint32_t dp_width;
- EGL_DISPMANX_WINDOW_T native;
- EGL_DISPMANX_WINDOW_T foreign;
-
- gint preferred_width;
- gint preferred_height;
- GstVideoRectangle render_rect;
-
- gboolean visible;
-
- gpointer _reserved[GST_PADDING];
-};
-
-struct _GstGLWindowDispmanxEGLClass {
- /*< private >*/
- GstGLWindowClass parent_class;
-
- /*< private >*/
- gpointer _reserved[GST_PADDING];
-};
-
-GType gst_gl_window_dispmanx_egl_get_type (void);
-
-GstGLWindowDispmanxEGL * gst_gl_window_dispmanx_egl_new (GstGLDisplay * display);
-gboolean gst_gl_window_dispmanx_egl_create_window (GstGLWindowDispmanxEGL * window_egl);
-
-G_END_DECLS
-
-#endif /* __GST_GL_WINDOW_X11_H__ */
diff --git a/gst-libs/gst/gl/eagl/Makefile.am b/gst-libs/gst/gl/eagl/Makefile.am
deleted file mode 100644
index a02092012..000000000
--- a/gst-libs/gst/gl/eagl/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-noinst_LTLIBRARIES = libgstgl-eagl.la
-
-libgstgl_eagl_la_SOURCES = \
- gstglwindow_eagl.m \
- gstglcontext_eagl.m
-
-noinst_HEADERS = \
- gstglwindow_eagl.h \
- gstglcontext_eagl.h
-
-libgstgl_eagl_la_CFLAGS = \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- $(GL_CFLAGS) \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) \
- $(GST_CFLAGS)
-
-libgstgl_eagl_la_OBJCFLAGS = \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- -fobjc-arc \
- $(GL_CFLAGS) \
- $(GL_OBJCFLAGS) \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) \
- $(GST_CFLAGS)
-
-libgstgl_eagl_la_LDFLAGS = \
- $(GST_LIB_LDFLAGS) \
- $(GST_ALL_LDFLAGS)
-
-libgstgl_eagl_la_LIBTOOLFLAGS = --tag=CC
diff --git a/gst-libs/gst/gl/eagl/gstglcontext_eagl.h b/gst-libs/gst/gl/eagl/gstglcontext_eagl.h
deleted file mode 100644
index 670adb5e9..000000000
--- a/gst-libs/gst/gl/eagl/gstglcontext_eagl.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_CONTEXT_EAGL_H__
-#define __GST_GL_CONTEXT_EAGL_H__
-
-#include <gst/gst.h>
-#include <gst/gl/gl.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_CONTEXT_EAGL (gst_gl_context_eagl_get_type())
-#define GST_GL_CONTEXT_EAGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_CONTEXT_EAGL, GstGLContextEagl))
-#define GST_GL_CONTEXT_EAGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_CONTEXT_EAGL, GstGLContextEaglClass))
-#define GST_IS_GL_CONTEXT_EAGL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_CONTEXT_EAGL))
-#define GST_IS_GL_CONTEXT_EAGL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_CONTEXT_EAGL))
-#define GST_GL_CONTEXT_EAGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_CONTEXT_EAGL, GstGLContextEaglClass))
-
-#define GS_GL_CONTEXT_EAGL_CONTEXT(obj) \
- ((__bridge EAGLContext *)(obj->priv->eagl_context))
-#define GS_GL_CONTEXT_EAGL_LAYER(obj) \
- ((__bridge CAEAGLLayer *)(obj->priv->eagl_layer))
-
-typedef struct _GstGLContextEagl GstGLContextEagl;
-typedef struct _GstGLContextEaglPrivate GstGLContextEaglPrivate;
-typedef struct _GstGLContextEaglClass GstGLContextEaglClass;
-
-struct _GstGLContextEagl {
- /*< private >*/
- GstGLContext parent;
-
- /*< private >*/
- GstGLContextEaglPrivate *priv;
-
- gpointer _reserved[GST_PADDING];
-};
-
-struct _GstGLContextEaglClass {
- /*< private >*/
- GstGLContextClass parent_class;
-
- /*< private >*/
- gpointer _reserved[GST_PADDING_LARGE];
-};
-
-GType gst_gl_context_eagl_get_type (void);
-
-GstGLContextEagl * gst_gl_context_eagl_new (GstGLDisplay * display);
-
-void gst_gl_context_eagl_update_layer (GstGLContext * context);
-void gst_gl_context_eagl_resize (GstGLContextEagl * eagl_context);
-void gst_gl_context_eagl_prepare_draw (GstGLContextEagl * context);
-void gst_gl_context_eagl_finish_draw (GstGLContextEagl * context);
-guintptr gst_gl_context_eagl_get_current_context (void);
-
-G_END_DECLS
-
-#endif /* __GST_GL_CONTEXT_EAGL_H__ */
diff --git a/gst-libs/gst/gl/eagl/gstglcontext_eagl.m b/gst-libs/gst/gl/eagl/gstglcontext_eagl.m
deleted file mode 100644
index 392eeee49..000000000
--- a/gst-libs/gst/gl/eagl/gstglcontext_eagl.m
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#import <OpenGLES/EAGL.h>
-#import <QuartzCore/QuartzCore.h>
-#import <UIKit/UIKit.h>
-#include <OpenGLES/ES2/gl.h>
-
-#include "gstglcontext_eagl.h"
-#include "../gstglcontext_private.h"
-
-#define GST_CAT_DEFAULT gst_gl_context_debug
-
-static gboolean gst_gl_context_eagl_create_context (GstGLContext * context,
- GstGLAPI gl_api, GstGLContext * other_context, GError ** error);
-static void gst_gl_context_eagl_destroy_context (GstGLContext * context);
-static gboolean gst_gl_context_eagl_choose_format (GstGLContext * context,
- GError ** error);
-static guintptr gst_gl_context_eagl_get_gl_context (GstGLContext * window);
-static gboolean gst_gl_context_eagl_activate (GstGLContext * context,
- gboolean activate);
-static void gst_gl_context_eagl_swap_buffers (GstGLContext * context);
-static GstGLAPI gst_gl_context_eagl_get_gl_api (GstGLContext * context);
-static GstGLPlatform gst_gl_context_eagl_get_gl_platform (GstGLContext *
- context);
-
-struct _GstGLContextEaglPrivate
-{
- gpointer eagl_context;
-
- /* Used if we render to a window */
- gpointer eagl_layer;
- GLuint framebuffer;
- GLuint color_renderbuffer;
- GLuint depth_renderbuffer;
-};
-
-#define GST_GL_CONTEXT_EAGL_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_CONTEXT_EAGL, GstGLContextEaglPrivate))
-
-G_DEFINE_TYPE (GstGLContextEagl, gst_gl_context_eagl, GST_TYPE_GL_CONTEXT);
-
-static void
-gst_gl_context_eagl_class_init (GstGLContextEaglClass * klass)
-{
- GstGLContextClass *context_class;
-
- context_class = (GstGLContextClass *) klass;
-
- g_type_class_add_private (klass, sizeof (GstGLContextEaglPrivate));
-
- context_class->destroy_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_eagl_destroy_context);
- context_class->create_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_eagl_create_context);
- context_class->choose_format =
- GST_DEBUG_FUNCPTR (gst_gl_context_eagl_choose_format);
- context_class->get_gl_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_eagl_get_gl_context);
- context_class->activate = GST_DEBUG_FUNCPTR (gst_gl_context_eagl_activate);
- context_class->swap_buffers =
- GST_DEBUG_FUNCPTR (gst_gl_context_eagl_swap_buffers);
- context_class->get_gl_api =
- GST_DEBUG_FUNCPTR (gst_gl_context_eagl_get_gl_api);
- context_class->get_gl_platform =
- GST_DEBUG_FUNCPTR (gst_gl_context_eagl_get_gl_platform);
-}
-
-static void
-gst_gl_context_eagl_init (GstGLContextEagl * context)
-{
- context->priv = GST_GL_CONTEXT_EAGL_GET_PRIVATE (context);
-}
-
-/* Must be called in the gl thread */
-GstGLContextEagl *
-gst_gl_context_eagl_new (GstGLDisplay * display)
-{
- GstGLContextEagl *context;
-
- /* there isn't actually a display type for eagl yet? */
- context = g_object_new (GST_TYPE_GL_CONTEXT_EAGL, NULL);
- gst_object_ref_sink (context);
-
- return context;
-}
-
-void
-gst_gl_context_eagl_resize (GstGLContextEagl * eagl_context)
-{
- int width, height;
-
- glBindRenderbuffer (GL_RENDERBUFFER, eagl_context->priv->color_renderbuffer);
- [GS_GL_CONTEXT_EAGL_CONTEXT(eagl_context) renderbufferStorage:GL_RENDERBUFFER fromDrawable:GS_GL_CONTEXT_EAGL_LAYER(eagl_context)];
- glGetRenderbufferParameteriv (GL_RENDERBUFFER,
- GL_RENDERBUFFER_WIDTH, &width);
- glGetRenderbufferParameteriv (GL_RENDERBUFFER,
- GL_RENDERBUFFER_HEIGHT, &height);
- glBindRenderbuffer (GL_RENDERBUFFER, eagl_context->priv->depth_renderbuffer);
- glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width,
- height);
-}
-
-static void
-gst_gl_context_eagl_release_layer (GstGLContext * context)
-{
- GstGLContextEagl *context_eagl;
-
- context_eagl = GST_GL_CONTEXT_EAGL (context);
-
- if (context_eagl->priv->eagl_layer) {
- gst_gl_context_eagl_activate (context, TRUE);
-
- [GS_GL_CONTEXT_EAGL_CONTEXT(context_eagl) renderbufferStorage: GL_RENDERBUFFER fromDrawable:nil];
-
- glDeleteFramebuffers (1, &context_eagl->priv->framebuffer);
- context_eagl->priv->framebuffer = 0;
-
- glDeleteRenderbuffers (1, &context_eagl->priv->depth_renderbuffer);
- context_eagl->priv->depth_renderbuffer = 0;
- glDeleteRenderbuffers (1, &context_eagl->priv->color_renderbuffer);
- context_eagl->priv->color_renderbuffer = 0;
-
- context_eagl->priv->eagl_layer = nil;
- gst_gl_context_eagl_activate (context, FALSE);
- }
-}
-
-void
-gst_gl_context_eagl_update_layer (GstGLContext * context)
-{
- GLuint framebuffer;
- GLuint color_renderbuffer;
- GLuint depth_renderbuffer;
- GLint width;
- GLint height;
- CAEAGLLayer *eagl_layer;
- GLenum status;
- GstGLContextEagl *context_eagl = GST_GL_CONTEXT_EAGL (context);
- GstGLContextEaglPrivate *priv = context_eagl->priv;
- UIView *window_handle = nil;
- GstGLWindow *window = gst_gl_context_get_window (context);
- if (window)
- window_handle = (__bridge UIView *)((void *)gst_gl_window_get_window_handle (window));
-
- if (!window_handle) {
- GST_INFO_OBJECT (context, "window handle not set yet, not updating layer");
- goto out;
- }
-
- GST_INFO_OBJECT (context, "updating layer, frame %fx%f",
- window_handle.frame.size.width, window_handle.frame.size.height);
-
- if (priv->eagl_layer)
- gst_gl_context_eagl_release_layer (context);
-
- eagl_layer = (CAEAGLLayer *)[window_handle layer];
- [EAGLContext setCurrentContext:GS_GL_CONTEXT_EAGL_CONTEXT(context_eagl)];
-
- /* Allocate framebuffer */
- glGenFramebuffers (1, &framebuffer);
- glBindFramebuffer (GL_FRAMEBUFFER, framebuffer);
- /* Allocate color render buffer */
- glGenRenderbuffers (1, &color_renderbuffer);
- glBindRenderbuffer (GL_RENDERBUFFER, color_renderbuffer);
- [GS_GL_CONTEXT_EAGL_CONTEXT(context_eagl) renderbufferStorage: GL_RENDERBUFFER fromDrawable:eagl_layer];
- glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_RENDERBUFFER, color_renderbuffer);
- /* Get renderbuffer width/height */
- glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH,
- &width);
- glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT,
- &height);
- /* allocate depth render buffer */
- glGenRenderbuffers (1, &depth_renderbuffer);
- glBindRenderbuffer (GL_RENDERBUFFER, depth_renderbuffer);
- glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width,
- height);
- glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
- GL_RENDERBUFFER, depth_renderbuffer);
-
- /* check creation status */
- status = glCheckFramebufferStatus (GL_FRAMEBUFFER);
- if (status != GL_FRAMEBUFFER_COMPLETE) {
- GST_ERROR ("Failed to make complete framebuffer object %x", status);
- goto out;
- }
- glBindRenderbuffer (GL_RENDERBUFFER, 0);
- glBindFramebuffer (GL_FRAMEBUFFER, 0);
-
- priv->eagl_layer = (__bridge_retained gpointer)eagl_layer;
- priv->framebuffer = framebuffer;
- priv->color_renderbuffer = color_renderbuffer;
- priv->depth_renderbuffer = depth_renderbuffer;
-
-out:
- if (window)
- gst_object_unref (window);
-}
-
-static gboolean
-gst_gl_context_eagl_create_context (GstGLContext * context, GstGLAPI gl_api,
- GstGLContext * other_context, GError ** error)
-{
- GstGLContextEagl *context_eagl = GST_GL_CONTEXT_EAGL (context);
- GstGLContextEaglPrivate *priv = context_eagl->priv;
- EAGLSharegroup *share_group;
-
- if (other_context) {
- EAGLContext *external_gl_context = (__bridge EAGLContext *)(void *)
- gst_gl_context_get_gl_context (other_context);
- share_group = [external_gl_context sharegroup];
- } else {
- share_group = nil;
- }
-
- priv->eagl_context = (__bridge_retained gpointer)[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3 sharegroup:share_group];
- if (!priv->eagl_context) {
- priv->eagl_context = (__bridge_retained gpointer)[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup:share_group];
- }
- if (!priv->eagl_context) {
- g_set_error_literal (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
- "Failed to create OpenGL ES context");
- return FALSE;
- }
-
- priv->eagl_layer = NULL;
- priv->framebuffer = 0;
- priv->color_renderbuffer = 0;
- priv->depth_renderbuffer = 0;
-
- GST_INFO_OBJECT (context, "context created, updating layer");
- gst_gl_context_eagl_update_layer (context);
-
- return TRUE;
-}
-
-static void
-gst_gl_context_eagl_destroy_context (GstGLContext * context)
-{
- GstGLContextEagl *context_eagl;
-
- context_eagl = GST_GL_CONTEXT_EAGL (context);
-
- if (!context_eagl->priv->eagl_context)
- return;
-
- gst_gl_context_eagl_release_layer (context);
-
- CFRelease(context_eagl->priv->eagl_context);
- context_eagl->priv->eagl_context = NULL;
-}
-
-static gboolean
-gst_gl_context_eagl_choose_format (GstGLContext * context, GError ** error)
-{
- GstGLContextEagl *context_eagl;
- GstGLWindow *window;
- UIView *window_handle = nil;
-
- context_eagl = GST_GL_CONTEXT_EAGL (context);
- window = gst_gl_context_get_window (context);
-
- if (!window)
- return TRUE;
-
- if (window)
- window_handle = (__bridge UIView *)(void *)gst_gl_window_get_window_handle (window);
-
- if (!window_handle) {
- gst_object_unref (window);
- return TRUE;
- }
-
- CAEAGLLayer *eagl_layer;
- NSDictionary * dict =[NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking,
- kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
-
- eagl_layer = (CAEAGLLayer *)[window_handle layer];
- [eagl_layer setOpaque:YES];
- [eagl_layer setDrawableProperties:dict];
-
- gst_object_unref (window);
-
- return TRUE;
-}
-
-static guintptr
-gst_gl_context_eagl_get_gl_context (GstGLContext * context)
-{
- return (guintptr) GST_GL_CONTEXT_EAGL (context)->priv->eagl_context;
-}
-
-void
-gst_gl_context_eagl_prepare_draw (GstGLContextEagl * context)
-{
- if (!context->priv->eagl_layer)
- return;
-
- glBindFramebuffer (GL_FRAMEBUFFER, context->priv->framebuffer);
- glBindRenderbuffer (GL_RENDERBUFFER, context->priv->color_renderbuffer);
-}
-
-void
-gst_gl_context_eagl_finish_draw (GstGLContextEagl * context)
-{
- if (!context->priv->eagl_layer)
- return;
-
- glBindRenderbuffer (GL_RENDERBUFFER, 0);
- glBindFramebuffer (GL_FRAMEBUFFER, 0);
-}
-
-static void
-gst_gl_context_eagl_swap_buffers (GstGLContext * context)
-{
- GstGLContextEagl *context_eagl;
-
- context_eagl = GST_GL_CONTEXT_EAGL (context);
-
- if (!context_eagl->priv->eagl_layer)
- return;
-
- [GS_GL_CONTEXT_EAGL_CONTEXT(context_eagl) presentRenderbuffer:GL_RENDERBUFFER];
-}
-
-static gboolean
-gst_gl_context_eagl_activate (GstGLContext * context, gboolean activate)
-{
- GstGLContextEagl *context_eagl;
-
- context_eagl = GST_GL_CONTEXT_EAGL (context);
-
- if (activate) {
- EAGLContext *cur_ctx =[EAGLContext currentContext];
-
- if (cur_ctx == context_eagl->priv->eagl_context) {
- GST_DEBUG ("Already attached the context to thread %p", g_thread_self ());
- return TRUE;
- }
-
- GST_DEBUG ("Attaching context to thread %p", g_thread_self ());
- if ([EAGLContext setCurrentContext:GS_GL_CONTEXT_EAGL_CONTEXT(context_eagl)] == NO) {
- GST_ERROR ("Couldn't make context current");
- return FALSE;
- }
- } else {
- GST_DEBUG ("Detaching context from thread %p", g_thread_self ());
- if ([EAGLContext setCurrentContext:nil] == NO) {
- GST_ERROR ("Couldn't unbind context");
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static GstGLAPI
-gst_gl_context_eagl_get_gl_api (GstGLContext * context)
-{
- return GST_GL_API_GLES2;
-}
-
-static GstGLPlatform
-gst_gl_context_eagl_get_gl_platform (GstGLContext * context)
-{
- return GST_GL_PLATFORM_EAGL;
-}
-
-guintptr
-gst_gl_context_eagl_get_current_context (void)
-{
- return (guintptr) [EAGLContext currentContext];
-}
diff --git a/gst-libs/gst/gl/eagl/gstglwindow_eagl.h b/gst-libs/gst/gl/eagl/gstglwindow_eagl.h
deleted file mode 100644
index 6c80963d6..000000000
--- a/gst-libs/gst/gl/eagl/gstglwindow_eagl.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_WINDOW_EAGL_H__
-#define __GST_GL_WINDOW_EAGL_H__
-
-#include <gst/gst.h>
-#include <gst/gl/gl.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_WINDOW_EAGL (gst_gl_window_eagl_get_type())
-#define GST_GL_WINDOW_EAGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW_EAGL, GstGLWindowEagl))
-#define GST_GL_WINDOW_EAGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_WINDOW_EAGL, GstGLWindowEaglClass))
-#define GST_IS_GL_WINDOW_EAGL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW_EAGL))
-#define GST_IS_GL_WINDOW_EAGL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW_EAGL))
-#define GST_GL_WINDOW_EAGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW_EAGL, GstGLWindowEaglClass))
-
-#define GS_GL_WINDOW_EAGL_VIEW(obj) \
- ((__bridge UIView *)(obj->priv->view))
-#define GS_GL_WINDOW_EAGL_QUEUE(obj) \
- ((__bridge dispatch_queue_t)(obj->priv->gl_queue))
-
-typedef struct _GstGLWindowEagl GstGLWindowEagl;
-typedef struct _GstGLWindowEaglPrivate GstGLWindowEaglPrivate;
-typedef struct _GstGLWindowEaglClass GstGLWindowEaglClass;
-
-struct _GstGLWindowEagl {
- /*< private >*/
- GstGLWindow parent;
-
- /*< private >*/
- GstGLWindowEaglPrivate *priv;
-
- gpointer _reserved[GST_PADDING];
-};
-
-struct _GstGLWindowEaglClass {
- /*< private >*/
- GstGLWindowClass parent_class;
-
- /*< private >*/
- gpointer _reserved[GST_PADDING_LARGE];
-};
-
-GType gst_gl_window_eagl_get_type (void);
-
-GstGLWindowEagl * gst_gl_window_eagl_new (GstGLDisplay * display);
-
-G_END_DECLS
-
-#endif /* __GST_GL_WINDOW_EAGL_H__ */
diff --git a/gst-libs/gst/gl/eagl/gstglwindow_eagl.m b/gst-libs/gst/gl/eagl/gstglwindow_eagl.m
deleted file mode 100644
index d98cb84c2..000000000
--- a/gst-libs/gst/gl/eagl/gstglwindow_eagl.m
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it un der the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#import <OpenGLES/EAGL.h>
-#import <QuartzCore/QuartzCore.h>
-#import <UIKit/UIKit.h>
-
-#include "gstglwindow_eagl.h"
-#include "gstglcontext_eagl.h"
-
-#define GST_GL_WINDOW_EAGL_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_WINDOW_EAGL, GstGLWindowEaglPrivate))
-
-#define GST_CAT_DEFAULT gst_gl_window_eagl_debug
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-
-#define DEBUG_INIT \
- GST_DEBUG_CATEGORY_GET (GST_CAT_DEFAULT, "glwindow");
-#define gst_gl_window_eagl_parent_class parent_class
-G_DEFINE_TYPE_WITH_CODE (GstGLWindowEagl, gst_gl_window_eagl,
- GST_TYPE_GL_WINDOW, DEBUG_INIT);
-static void gst_gl_window_eagl_finalize (GObject * object);
-
-static guintptr gst_gl_window_eagl_get_display (GstGLWindow * window);
-static guintptr gst_gl_window_eagl_get_window_handle (GstGLWindow * window);
-static void gst_gl_window_eagl_set_window_handle (GstGLWindow * window,
- guintptr handle);
-static void gst_gl_window_eagl_set_preferred_size (GstGLWindow * window,
- gint width, gint height);
-static void gst_gl_window_eagl_draw (GstGLWindow * window);
-static void gst_gl_window_eagl_send_message_async (GstGLWindow * window,
- GstGLWindowCB callback, gpointer data, GDestroyNotify destroy);
-
-struct _GstGLWindowEaglPrivate
-{
- gpointer view;
- gint window_width, window_height;
- gint preferred_width, preferred_height;
- gpointer gl_queue;
-};
-
-static void
-gst_gl_window_eagl_class_init (GstGLWindowEaglClass * klass)
-{
- GObjectClass *gobject_class = (GObjectClass *) klass;
- GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
-
- g_type_class_add_private (klass, sizeof (GstGLWindowEaglPrivate));
-
- gobject_class->finalize = gst_gl_window_eagl_finalize;
-
- window_class->get_display =
- GST_DEBUG_FUNCPTR (gst_gl_window_eagl_get_display);
- window_class->get_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_eagl_get_window_handle);
- window_class->set_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_eagl_set_window_handle);
- window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_draw);
- window_class->set_preferred_size =
- GST_DEBUG_FUNCPTR (gst_gl_window_eagl_set_preferred_size);
- window_class->send_message_async =
- GST_DEBUG_FUNCPTR (gst_gl_window_eagl_send_message_async);
-}
-
-static void
-gst_gl_window_eagl_init (GstGLWindowEagl * window)
-{
- window->priv = GST_GL_WINDOW_EAGL_GET_PRIVATE (window);
- window->priv->gl_queue =
- (__bridge_retained gpointer)dispatch_queue_create ("org.freedesktop.gstreamer.glwindow", NULL);
-}
-
-static void
-gst_gl_window_eagl_finalize (GObject * object)
-{
- GstGLWindowEagl *window = GST_GL_WINDOW_EAGL (object);
- CFRelease(window->priv->gl_queue);
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-/* Must be called in the gl thread */
-GstGLWindowEagl *
-gst_gl_window_eagl_new (GstGLDisplay * display)
-{
- GstGLWindowEagl *window;
-
- /* there isn't an eagl display type */
- window = g_object_new (GST_TYPE_GL_WINDOW_EAGL, NULL);
- gst_object_ref_sink (window);
-
- return window;
-}
-
-static guintptr
-gst_gl_window_eagl_get_display (GstGLWindow * window)
-{
- return 0;
-}
-
-static guintptr
-gst_gl_window_eagl_get_window_handle (GstGLWindow * window)
-{
- return (guintptr) GST_GL_WINDOW_EAGL (window)->priv->view;
-}
-
-static void
-gst_gl_window_eagl_set_window_handle (GstGLWindow * window, guintptr handle)
-{
- GstGLWindowEagl *window_eagl;
- GstGLContext *context;
-
- window_eagl = GST_GL_WINDOW_EAGL (window);
- context = gst_gl_window_get_context (window);
-
- window_eagl->priv->view = (gpointer)handle;
- GST_INFO_OBJECT (context, "handle set, updating layer");
- gst_gl_context_eagl_update_layer (context);
-
- gst_object_unref (context);
-}
-
-static void
-gst_gl_window_eagl_set_preferred_size (GstGLWindow * window, gint width, gint height)
-{
- GstGLWindowEagl *window_eagl = GST_GL_WINDOW_EAGL (window);
-
- window_eagl->priv->preferred_width = width;
- window_eagl->priv->preferred_height = height;
-}
-
-static void
-gst_gl_window_eagl_send_message_async (GstGLWindow * window,
- GstGLWindowCB callback, gpointer data, GDestroyNotify destroy)
-{
- GstGLWindowEagl *window_eagl = (GstGLWindowEagl *) window;
- GstGLContext *context = gst_gl_window_get_context (window);
- GThread *thread = gst_gl_context_get_thread (context);
-
- if (thread == g_thread_self()) {
- /* this case happens for nested calls happening from inside the GCD queue */
- callback (data);
- if (destroy)
- destroy (data);
- gst_object_unref (context);
- } else {
- dispatch_async ((__bridge dispatch_queue_t)(window_eagl->priv->gl_queue), ^{
- gst_gl_context_activate (context, TRUE);
- callback (data);
- gst_object_unref (context);
- if (destroy)
- destroy (data);
- });
- }
- if (thread)
- g_thread_unref (thread);
-}
-
-static void
-draw_cb (gpointer data)
-{
- GstGLWindowEagl *window_eagl = data;
- GstGLWindow *window = GST_GL_WINDOW (window_eagl);
- GstGLContext *context = gst_gl_window_get_context (window);
- GstGLContextEagl *eagl_context = GST_GL_CONTEXT_EAGL (context);
-
- if (window_eagl->priv->view) {
- CGSize size;
- CAEAGLLayer *eagl_layer;
-
- eagl_layer = (CAEAGLLayer *)[GS_GL_WINDOW_EAGL_VIEW(window_eagl) layer];
- size = eagl_layer.frame.size;
-
- if (window->queue_resize || window_eagl->priv->window_width != size.width ||
- window_eagl->priv->window_height != size.height) {
-
- window_eagl->priv->window_width = size.width;
- window_eagl->priv->window_height = size.height;
-
- gst_gl_context_eagl_resize (eagl_context);
-
- gst_gl_window_resize (window, window_eagl->priv->window_width,
- window_eagl->priv->window_height);
- }
- }
-
- gst_gl_context_eagl_prepare_draw (eagl_context);
-
- if (window->draw)
- window->draw (window->draw_data);
-
- gst_gl_context_swap_buffers (context);
-
- gst_gl_context_eagl_finish_draw (eagl_context);
-
- gst_object_unref (context);
-}
-
-static void
-gst_gl_window_eagl_draw (GstGLWindow * window)
-{
- gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
-}
diff --git a/gst-libs/gst/gl/egl/Makefile.am b/gst-libs/gst/gl/egl/Makefile.am
deleted file mode 100644
index da80fbc4f..000000000
--- a/gst-libs/gst/gl/egl/Makefile.am
+++ /dev/null
@@ -1,32 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-noinst_LTLIBRARIES = libgstgl-egl.la
-
-libgstgl_egl_la_SOURCES = \
- gstgldisplay_egl.c \
- gstglcontext_egl.c \
- gstglmemoryegl.c \
- gsteglimage.c \
- gstegl.c
-
-noinst_HEADERS = \
- gstglcontext_egl.h
-
-libgstgl_eglincludedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl/egl
-libgstgl_eglinclude_HEADERS = \
- gstgldisplay_egl.h \
- gstglmemoryegl.h \
- gsteglimage.h \
- gstegl.h
-
-libgstgl_egl_la_CFLAGS = \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- $(GL_CFLAGS) \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) \
- $(GST_CFLAGS)
-
-libgstgl_egl_la_LDFLAGS = \
- $(GST_LIB_LDFLAGS) \
- $(GST_ALL_LDFLAGS)
diff --git a/gst-libs/gst/gl/egl/gstegl.c b/gst-libs/gst/gl/egl/gstegl.c
deleted file mode 100644
index 9f455e52c..000000000
--- a/gst-libs/gst/gl/egl/gstegl.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2016 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include <gst/gl/egl/gstegl.h>
-
-/**
- * gst_egl_get_error_string:
- * @err: an EGL error code
- *
- * Returns: the short string representation of @err
- */
-const gchar *
-gst_egl_get_error_string (EGLint err)
-{
- switch (err) {
- case EGL_SUCCESS:
- return "EGL_SUCCESS";
- case EGL_BAD_DISPLAY:
- return "EGL_BAD_DISPLAY";
- case EGL_NOT_INITIALIZED:
- return "EGL_NOT_INITIALIZED";
- case EGL_BAD_ACCESS:
- return "EGL_BAD_ACCESS";
- case EGL_BAD_ALLOC:
- return "EGL_BAD_ALLOC";
- case EGL_BAD_ATTRIBUTE:
- return "EGL_BAD_ATTRIBUTE";
- case EGL_BAD_CONFIG:
- return "EGL_BAD_CONFIG";
- case EGL_BAD_CONTEXT:
- return "EGL_BAD_CONTEXT";
- case EGL_BAD_CURRENT_SURFACE:
- return "EGL_BAD_CURRENT_SURFACE";
- case EGL_BAD_MATCH:
- return "EGL_BAD_MATCH";
- case EGL_BAD_NATIVE_PIXMAP:
- return "EGL_BAD_NATIVE_PIXMAP";
- case EGL_BAD_NATIVE_WINDOW:
- return "EGL_BAD_NATIVE_WINDOW";
- case EGL_BAD_PARAMETER:
- return "EGL_BAD_PARAMETER";
- case EGL_BAD_SURFACE:
- return "EGL_BAD_SURFACE";
- default:
- return "unknown";
- }
-}
diff --git a/gst-libs/gst/gl/egl/gstegl.h b/gst-libs/gst/gl/egl/gstegl.h
deleted file mode 100644
index 0bbda81dc..000000000
--- a/gst-libs/gst/gl/egl/gstegl.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_EGL_H_
-#define _GST_EGL_H_
-
-#include <gst/gl/gstglconfig.h>
-
-#if GST_GL_HAVE_WINDOW_DISPMANX && defined(__GNUC__)
-#ifndef __VCCOREVER__
-#define __VCCOREVER__ 0x04000000
-#endif
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wredundant-decls"
-#if !defined(__cplusplus)
-#pragma GCC optimize ("gnu89-inline")
-#endif
-#endif
-
-#ifndef EGL_EGLEXT_PROTOTYPES
-#define EGL_EGLEXT_PROTOTYPES 1
-#endif
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-#if GST_GL_HAVE_WINDOW_DISPMANX && defined(__GNUC__)
-#pragma GCC reset_options
-#pragma GCC diagnostic pop
-#endif
-
-/* compatibility definitions... */
-#if !GST_GL_HAVE_EGLATTRIB
-typedef gintptr EGLAttrib;
-#endif
-
-GST_EXPORT
-const gchar * gst_egl_get_error_string (EGLint err);
-
-#endif /* _GST_EGL_H_ */
diff --git a/gst-libs/gst/gl/egl/gsteglimage.c b/gst-libs/gst/gl/egl/gsteglimage.c
deleted file mode 100644
index fdd603807..000000000
--- a/gst-libs/gst/gl/egl/gsteglimage.c
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Collabora Ltd.
- * @author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
- * Copyright (C) 2014 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2016 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gsteglimage
- * @short_description: EGLImage abstraction
- * @title: GstEGLImage
- * @see_also: #GstGLMemoryEGL, #GstGLContext
- *
- * #GstEGLImage represents and holds an #EGLImage handle.
- *
- * A #GstEGLImage can be created from a dmabuf with gst_egl_image_from_dmabuf()
- * or #GstGLMemoryEGL provides a #GstAllocator to allocate #EGLImage's bound to
- * and OpenGL texture.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gsteglimage.h"
-
-#include <string.h>
-
-#include <gst/gl/gstglfeature.h>
-#include <gst/gl/gstglmemory.h>
-
-#include "gst/gl/egl/gstegl.h"
-#include "gst/gl/egl/gstglcontext_egl.h"
-#include "gst/gl/egl/gstgldisplay_egl.h"
-
-#if GST_GL_HAVE_DMABUF
-#include <gst/allocators/gstdmabuf.h>
-#include <libdrm/drm_fourcc.h>
-
-#ifndef DRM_FORMAT_R8
-#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ')
-#endif
-
-#ifndef DRM_FORMAT_RG88
-#define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8')
-#endif
-
-#ifndef DRM_FORMAT_GR88
-#define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8')
-#endif
-#endif
-
-#ifndef EGL_LINUX_DMA_BUF_EXT
-#define EGL_LINUX_DMA_BUF_EXT 0x3270
-#endif
-
-#ifndef EGL_LINUX_DRM_FOURCC_EXT
-#define EGL_LINUX_DRM_FOURCC_EXT 0x3271
-#endif
-
-#ifndef EGL_DMA_BUF_PLANE0_FD_EXT
-#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272
-#endif
-
-#ifndef EGL_DMA_BUF_PLANE0_OFFSET_EXT
-#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273
-#endif
-
-#ifndef EGL_DMA_BUF_PLANE0_PITCH_EXT
-#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274
-#endif
-
-GST_DEFINE_MINI_OBJECT_TYPE (GstEGLImage, gst_egl_image);
-
-#ifndef GST_DISABLE_GST_DEBUG
-#define GST_CAT_DEFAULT gst_egl_image_ensure_debug_category()
-
-static GstDebugCategory *
-gst_egl_image_ensure_debug_category (void)
-{
- static gsize cat_gonce = 0;
-
- if (g_once_init_enter (&cat_gonce)) {
- GstDebugCategory *cat = NULL;
-
- GST_DEBUG_CATEGORY_INIT (cat, "gleglimage", 0, "EGLImage wrapper");
-
- g_once_init_leave (&cat_gonce, (gsize) cat);
- }
-
- return (GstDebugCategory *) cat_gonce;
-}
-#endif /* GST_DISABLE_GST_DEBUG */
-
-/**
- * gst_egl_image_get_image:
- * @image: a #GstEGLImage
- *
- * Returns: the #EGLImageKHR of @image
- */
-gpointer
-gst_egl_image_get_image (GstEGLImage * image)
-{
- g_return_val_if_fail (GST_IS_EGL_IMAGE (image), EGL_NO_IMAGE_KHR);
-
- return image->image;
-}
-
-static void
-_gst_egl_image_free_thread (GstGLContext * context, GstEGLImage * image)
-{
- if (image->destroy_notify)
- image->destroy_notify (image, image->destroy_data);
-}
-
-static void
-_gst_egl_image_free (GstMiniObject * object)
-{
- GstEGLImage *image = GST_EGL_IMAGE (object);
-
- if (image->context) {
- gst_gl_context_thread_add (GST_GL_CONTEXT (image->context),
- (GstGLContextThreadFunc) _gst_egl_image_free_thread, image);
- gst_object_unref (image->context);
- }
-}
-
-static GstMiniObject *
-_gst_egl_image_copy (GstMiniObject * obj)
-{
- return gst_mini_object_ref (obj);
-}
-
-/**
- * gst_egl_image_new_wrapped:
- * @context: a #GstGLContext (must be an EGL context)
- * @image: the image to wrap
- * @format: the #GstGLFormat
- * @user_data: user data
- * @user_data_destroy: called when @user_data is no longer needed
- *
- * Returns: a new #GstEGLImage wrapping @image
- */
-GstEGLImage *
-gst_egl_image_new_wrapped (GstGLContext * context, gpointer image,
- GstGLFormat format, gpointer user_data,
- GstEGLImageDestroyNotify user_data_destroy)
-{
- GstEGLImage *img = NULL;
-
- g_return_val_if_fail (context != NULL, NULL);
- g_return_val_if_fail ((gst_gl_context_get_gl_platform (context) &
- GST_GL_PLATFORM_EGL) != 0, NULL);
- g_return_val_if_fail (image != EGL_NO_IMAGE_KHR, NULL);
-
- img = g_new0 (GstEGLImage, 1);
- gst_mini_object_init (GST_MINI_OBJECT_CAST (img), 0, GST_TYPE_EGL_IMAGE,
- (GstMiniObjectCopyFunction) _gst_egl_image_copy, NULL,
- (GstMiniObjectFreeFunction) _gst_egl_image_free);
-
- img->context = gst_object_ref (context);
- img->image = image;
- img->format = format;
-
- img->destroy_data = user_data;
- img->destroy_notify = user_data_destroy;
-
- return img;
-}
-
-static EGLImageKHR
-_gst_egl_image_create (GstGLContext * context, guint target,
- EGLClientBuffer buffer, guintptr * attribs)
-{
- EGLDisplay egl_display = EGL_DEFAULT_DISPLAY;
- EGLContext egl_context = EGL_NO_CONTEXT;
- EGLImageKHR img = EGL_NO_IMAGE_KHR;
- GstGLDisplayEGL *display_egl;
- gint plat_major, plat_minor;
- guint attrib_len = 0;
-
- gst_gl_context_get_gl_platform_version (context, &plat_major, &plat_minor);
-
- display_egl = gst_gl_display_egl_from_gl_display (context->display);
- if (!display_egl) {
- GST_WARNING_OBJECT (context, "Failed to retrieve GstGLDisplayEGL from %"
- GST_PTR_FORMAT, context->display);
- return EGL_NO_IMAGE_KHR;
- }
- egl_display =
- (EGLDisplay) gst_gl_display_get_handle (GST_GL_DISPLAY (display_egl));
- gst_object_unref (display_egl);
-
- if (target != EGL_LINUX_DMA_BUF_EXT)
- egl_context = (EGLContext) gst_gl_context_get_gl_context (context);
-
- if (attribs)
- while (attribs[attrib_len++] != EGL_NONE) {
- }
-#ifdef EGL_VERSION_1_5
- if (GST_GL_CHECK_GL_VERSION (plat_major, plat_minor, 1, 5)) {
- EGLImageKHR (*gst_eglCreateImage) (EGLDisplay dpy, EGLContext ctx,
- EGLenum target, EGLClientBuffer buffer, const EGLAttrib * attrib_list);
- EGLAttrib *egl_attribs = NULL;
- guint i;
-
- gst_eglCreateImage = gst_gl_context_get_proc_address (context,
- "eglCreateImage");
- if (!gst_eglCreateImage) {
- GST_ERROR_OBJECT (context, "\"eglCreateImage\" not exposed by the "
- "implementation as required by EGL >= 1.5");
- return EGL_NO_IMAGE_KHR;
- }
-
- if (attribs) {
- egl_attribs = g_new0 (EGLAttrib, attrib_len);
- for (i = 0; i < attrib_len; i++)
- egl_attribs[i] = (EGLAttrib) attribs[i];
- }
-
- img = gst_eglCreateImage (egl_display, egl_context, target, buffer,
- egl_attribs);
-
- g_free (egl_attribs);
- } else
-#endif
- {
- EGLImageKHR (*gst_eglCreateImageKHR) (EGLDisplay dpy, EGLContext ctx,
- EGLenum target, EGLClientBuffer buffer, const EGLint * attrib_list);
- EGLint *egl_attribs = NULL;
- gint i;
-
- gst_eglCreateImageKHR = gst_gl_context_get_proc_address (context,
- "eglCreateImageKHR");
- if (!gst_eglCreateImageKHR) {
- GST_WARNING_OBJECT (context, "\"eglCreateImageKHR\" not exposed by the "
- "implementation");
- return EGL_NO_IMAGE_KHR;
- }
-
- if (attribs) {
- egl_attribs = g_new0 (EGLint, attrib_len);
- for (i = 0; i < attrib_len; i++)
- egl_attribs[i] = (EGLint) attribs[i];
- }
-
- img = gst_eglCreateImageKHR (egl_display, egl_context, target, buffer,
- egl_attribs);
-
- g_free (egl_attribs);
- }
-
- return img;
-}
-
-static void
-_gst_egl_image_destroy (GstGLContext * context, EGLImageKHR image)
-{
- EGLBoolean (*gst_eglDestroyImage) (EGLDisplay dpy, EGLImageKHR image);
- EGLDisplay egl_display = EGL_DEFAULT_DISPLAY;
- GstGLDisplayEGL *display_egl;
-
- gst_eglDestroyImage = gst_gl_context_get_proc_address (context,
- "eglDestroyImage");
- if (!gst_eglDestroyImage) {
- gst_eglDestroyImage = gst_gl_context_get_proc_address (context,
- "eglDestroyImageKHR");
- if (!gst_eglDestroyImage) {
- GST_ERROR_OBJECT (context, "\"eglDestroyImage\" not exposed by the "
- "implementation");
- return;
- }
- }
-
- display_egl = gst_gl_display_egl_from_gl_display (context->display);
- if (!display_egl) {
- GST_WARNING_OBJECT (context, "Failed to retrieve GstGLDisplayEGL from %"
- GST_PTR_FORMAT, context->display);
- return;
- }
- egl_display =
- (EGLDisplay) gst_gl_display_get_handle (GST_GL_DISPLAY (display_egl));
- gst_object_unref (display_egl);
-
- if (!gst_eglDestroyImage (egl_display, image))
- GST_WARNING_OBJECT (context, "eglDestroyImage failed");
-}
-
-static void
-_destroy_egl_image (GstEGLImage * image, gpointer user_data)
-{
- _gst_egl_image_destroy (image->context, image->image);
-}
-
-/**
- * gst_egl_image_from_texture:
- * @context: a #GstGLContext (must be an EGL context)
- * @gl_mem: a #GstGLMemory
- * @attribs: additional attributes to add to the eglCreateImage() call.
- *
- * Returns: (transfer full): a #GstEGLImage wrapping @gl_mem or %NULL on failure
- */
-GstEGLImage *
-gst_egl_image_from_texture (GstGLContext * context, GstGLMemory * gl_mem,
- guintptr * attribs)
-{
- EGLenum egl_target;
- EGLImageKHR img;
-
- if (gl_mem->tex_target != GST_GL_TEXTURE_TARGET_2D) {
- GST_FIXME_OBJECT (context, "Only know how to create EGLImage's from 2D "
- "textures");
- return NULL;
- }
-
- egl_target = EGL_GL_TEXTURE_2D_KHR;
-
- img = _gst_egl_image_create (context, egl_target,
- (EGLClientBuffer) (guintptr) gl_mem->tex_id, attribs);
- if (!img)
- return NULL;
-
- return gst_egl_image_new_wrapped (context, img, gl_mem->tex_format, NULL,
- (GstEGLImageDestroyNotify) _destroy_egl_image);
-}
-
-#if GST_GL_HAVE_DMABUF
-/*
- * GStreamer format descriptions differ from DRM formats as the representation
- * is relative to a register, hence in native endianness. To reduce the driver
- * requirement, we only import with a subset of texture formats and use
- * shaders to convert. This way we avoid having to use external texture
- * target.
- */
-static int
-_drm_fourcc_from_info (GstVideoInfo * info, int plane)
-{
- GstVideoFormat format = GST_VIDEO_INFO_FORMAT (info);
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
- const gint rgba_fourcc = DRM_FORMAT_ABGR8888;
- const gint rgb_fourcc = DRM_FORMAT_BGR888;
- const gint rg_fourcc = DRM_FORMAT_GR88;
-#else
- const gint rgba_fourcc = DRM_FORMAT_RGBA8888;
- const gint rgb_fourcc = DRM_FORMAT_RGB888;
- const gint rg_fourcc = DRM_FORMAT_RG88;
-#endif
-
- GST_DEBUG ("Getting DRM fourcc for %s plane %i",
- gst_video_format_to_string (format), plane);
-
- switch (format) {
- case GST_VIDEO_FORMAT_RGB16:
- case GST_VIDEO_FORMAT_BGR16:
- return DRM_FORMAT_RGB565;
-
- case GST_VIDEO_FORMAT_RGB:
- case GST_VIDEO_FORMAT_BGR:
- return rgb_fourcc;
-
- case GST_VIDEO_FORMAT_RGBA:
- case GST_VIDEO_FORMAT_RGBx:
- case GST_VIDEO_FORMAT_BGRA:
- case GST_VIDEO_FORMAT_BGRx:
- case GST_VIDEO_FORMAT_ARGB:
- case GST_VIDEO_FORMAT_xRGB:
- case GST_VIDEO_FORMAT_ABGR:
- case GST_VIDEO_FORMAT_xBGR:
- case GST_VIDEO_FORMAT_AYUV:
- return rgba_fourcc;
-
- case GST_VIDEO_FORMAT_GRAY8:
- return DRM_FORMAT_R8;
-
- case GST_VIDEO_FORMAT_YUY2:
- case GST_VIDEO_FORMAT_UYVY:
- case GST_VIDEO_FORMAT_GRAY16_LE:
- case GST_VIDEO_FORMAT_GRAY16_BE:
- return rg_fourcc;
-
- case GST_VIDEO_FORMAT_NV12:
- case GST_VIDEO_FORMAT_NV21:
- return plane == 0 ? DRM_FORMAT_R8 : rg_fourcc;
-
- case GST_VIDEO_FORMAT_I420:
- case GST_VIDEO_FORMAT_YV12:
- case GST_VIDEO_FORMAT_Y41B:
- case GST_VIDEO_FORMAT_Y42B:
- case GST_VIDEO_FORMAT_Y444:
- return DRM_FORMAT_R8;
-
- default:
- GST_ERROR ("Unsupported format for DMABuf.");
- return -1;
- }
-}
-
-/**
- * gst_egl_image_from_dmabuf:
- * @context: a #GstGLContext (must be an EGL context)
- * @dmabuf: the DMA-Buf file descriptor
- * @in_info: the #GstVideoInfo in @dmabuf
- * @plane: the plane in @in_info to create and #GstEGLImage for
- * @offset: the byte-offset in the data
- *
- * Returns: a #GstEGLImage wrapping @dmabuf or %NULL on failure
- */
-GstEGLImage *
-gst_egl_image_from_dmabuf (GstGLContext * context,
- gint dmabuf, GstVideoInfo * in_info, gint plane, gsize offset)
-{
- GstGLFormat format;
- guintptr attribs[13];
- EGLImageKHR img;
- gint atti = 0;
- gint fourcc;
- gint i;
-
- fourcc = _drm_fourcc_from_info (in_info, plane);
- format = gst_gl_format_from_video_info (context, in_info, plane);
-
- GST_DEBUG ("fourcc %.4s (%d) plane %d (%dx%d)",
- (char *) &fourcc, fourcc, plane,
- GST_VIDEO_INFO_COMP_WIDTH (in_info, plane),
- GST_VIDEO_INFO_COMP_HEIGHT (in_info, plane));
-
- attribs[atti++] = EGL_WIDTH;
- attribs[atti++] = GST_VIDEO_INFO_COMP_WIDTH (in_info, plane);
- attribs[atti++] = EGL_HEIGHT;
- attribs[atti++] = GST_VIDEO_INFO_COMP_HEIGHT (in_info, plane);
- attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT;
- attribs[atti++] = fourcc;
- attribs[atti++] = EGL_DMA_BUF_PLANE0_FD_EXT;
- attribs[atti++] = dmabuf;
- attribs[atti++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
- attribs[atti++] = offset;
- attribs[atti++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
- attribs[atti++] = GST_VIDEO_INFO_PLANE_STRIDE (in_info, plane);
- attribs[atti] = EGL_NONE;
-
- for (i = 0; i < atti; i++)
- GST_LOG ("attr %i: %" G_GINTPTR_FORMAT, i, attribs[i]);
-
- g_assert (atti == 12);
-
- img = _gst_egl_image_create (context, EGL_LINUX_DMA_BUF_EXT, NULL, attribs);
- if (!img) {
- GST_WARNING ("eglCreateImage failed: %s",
- gst_egl_get_error_string (eglGetError ()));
- return NULL;
- }
-
- return gst_egl_image_new_wrapped (context, img, format, NULL,
- (GstEGLImageDestroyNotify) _destroy_egl_image);
-}
-
-gboolean
-gst_egl_image_export_dmabuf (GstEGLImage * image, int *fd, gint * stride,
- gsize * offset)
-{
- EGLBoolean (*gst_eglExportDMABUFImageQueryMESA) (EGLDisplay dpy,
- EGLImageKHR image, int *fourcc, int *num_planes,
- EGLuint64KHR * modifiers);
- EGLBoolean (*gst_eglExportDMABUFImageMESA) (EGLDisplay dpy, EGLImageKHR image,
- int *fds, EGLint * strides, EGLint * offsets);
- GstGLDisplayEGL *display_egl;
- EGLDisplay egl_display = EGL_DEFAULT_DISPLAY;
- int num_planes = 0;
- int egl_fd = 0;
- EGLint egl_stride = 0;
- EGLint egl_offset = 0;
-
- gst_eglExportDMABUFImageQueryMESA =
- gst_gl_context_get_proc_address (image->context,
- "eglExportDMABUFImageQueryMESA");
- gst_eglExportDMABUFImageMESA =
- gst_gl_context_get_proc_address (image->context,
- "eglExportDMABUFImageMESA");
-
- if (!gst_eglExportDMABUFImageQueryMESA || !gst_eglExportDMABUFImageMESA)
- return FALSE;
-
- display_egl =
- (GstGLDisplayEGL *) gst_gl_display_egl_from_gl_display (image->
- context->display);
- if (!display_egl) {
- GST_WARNING_OBJECT (image->context,
- "Failed to retrieve GstGLDisplayEGL from %" GST_PTR_FORMAT,
- image->context->display);
- return FALSE;
- }
- egl_display =
- (EGLDisplay) gst_gl_display_get_handle (GST_GL_DISPLAY (display_egl));
- gst_object_unref (display_egl);
-
- if (!gst_eglExportDMABUFImageQueryMESA (egl_display, image->image,
- NULL, &num_planes, NULL))
- return FALSE;
-
- /* Don't allow multi-plane dmabufs */
- if (num_planes > 1)
- return FALSE;
-
- if (!gst_eglExportDMABUFImageMESA (egl_display, image->image, &egl_fd,
- &egl_stride, &egl_offset))
- return FALSE;
-
- *fd = egl_fd;
- *stride = egl_stride;
- *offset = egl_offset;
-
- return TRUE;
-}
-
-#endif /* GST_GL_HAVE_DMABUF */
diff --git a/gst-libs/gst/gl/egl/gsteglimage.h b/gst-libs/gst/gl/egl/gsteglimage.h
deleted file mode 100644
index b96cc2d3d..000000000
--- a/gst-libs/gst/gl/egl/gsteglimage.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Collabora Ltd.
- * @author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
- * Copyright (C) 2014 Julien Isorce <julien.isorce@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_EGL_IMAGE_H_
-#define _GST_EGL_IMAGE_H_
-
-#include <gst/gl/gstgl_fwd.h>
-#include <gst/gl/gstglformat.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT GType gst_egl_image_get_type (void);
-
-#define GST_TYPE_EGL_IMAGE (gst_egl_image_get_type())
-#define GST_IS_EGL_IMAGE(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_EGL_IMAGE))
-#define GST_EGL_IMAGE_CAST(obj) ((GstEGLImage *)(obj))
-#define GST_EGL_IMAGE(obj) (GST_EGL_IMAGE_CAST(obj))
-
-typedef struct _GstEGLImage GstEGLImage;
-
-/**
- * GstEGLImageDestroyNotify:
- * @image: a #GstEGLImage
- * @data: user data passed to gst_egl_image_new_wrapped()
- *
- * Function to be called when the GstEGLImage is destroyed. It should free
- * the associated #EGLImage if necessary
- */
-typedef void (*GstEGLImageDestroyNotify) (GstEGLImage * image,
- gpointer data);
-
-/**
- * GstEGLImage:
- *
- * Opaque #GstEGLImage struct.
- */
-struct _GstEGLImage
-{
- GstMiniObject parent;
-
- GstGLContext *context;
- gpointer image;
- GstGLFormat format;
-
- /* <private> */
- gpointer destroy_data;
- GstEGLImageDestroyNotify destroy_notify;
-
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GstEGLImage * gst_egl_image_new_wrapped (GstGLContext * context,
- gpointer image,
- GstGLFormat format,
- gpointer user_data,
- GstEGLImageDestroyNotify user_data_destroy);
-GST_EXPORT
-gpointer gst_egl_image_get_image (GstEGLImage * image);
-
-GST_EXPORT
-GstEGLImage * gst_egl_image_from_texture (GstGLContext * context,
- GstGLMemory * gl_mem,
- guintptr * attribs);
-#if GST_GL_HAVE_DMABUF
-GST_EXPORT
-GstEGLImage * gst_egl_image_from_dmabuf (GstGLContext * context,
- gint dmabuf,
- GstVideoInfo * in_info,
- gint plane,
- gsize offset);
-GST_EXPORT
-gboolean gst_egl_image_export_dmabuf (GstEGLImage *image, int *fd, gint *stride, gsize *offset);
-#endif
-
-/**
- * gst_egl_image_ref:
- * @image: a #GstEGLImage.
- *
- * Increases the refcount of the given image by one.
- *
- * Returns: (transfer full): @image
- */
-static inline GstEGLImage *
-gst_egl_image_ref (GstEGLImage * image)
-{
- return (GstEGLImage *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (image));
-}
-
-/**
- * gst_egl_image_unref:
- * @image: (transfer full): a #GstEGLImage.
- *
- * Decreases the refcount of the image. If the refcount reaches 0, the image
- * with the associated metadata and memory will be freed.
- */
-static inline void
-gst_egl_image_unref (GstEGLImage * image)
-{
- gst_mini_object_unref (GST_MINI_OBJECT_CAST (image));
-}
-
-G_END_DECLS
-
-#endif /* _GST_EGL_IMAGE_H_ */
diff --git a/gst-libs/gst/gl/egl/gstglcontext_egl.c b/gst-libs/gst/gl/egl/gstglcontext_egl.c
deleted file mode 100644
index 868e766c2..000000000
--- a/gst-libs/gst/gl/egl/gstglcontext_egl.c
+++ /dev/null
@@ -1,798 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Sebastian Dröge <slomo@circular-chaos.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gmodule.h>
-
-/* FIXME: Sharing contexts requires the EGLDisplay to be the same
- * may need to box it.
- */
-
-#include "gstglcontext_egl.h"
-
-#include <gst/gl/gstglcontext_private.h>
-#include <gst/gl/gstglfeature.h>
-#include <gst/gl/gstglwindow.h>
-
-#include "gstegl.h"
-#include "../utils/opengl_versions.h"
-#include "../utils/gles_versions.h"
-
-#if GST_GL_HAVE_WINDOW_X11
-#include "../x11/gstglwindow_x11.h"
-#include <gst/gl/x11/gstgldisplay_x11.h>
-#endif
-#if GST_GL_HAVE_WINDOW_WAYLAND
-#include "../wayland/gstglwindow_wayland_egl.h"
-#endif
-#if GST_GL_HAVE_WINDOW_WIN32
-#include "../win32/gstglwindow_win32.h"
-#endif
-#if GST_GL_HAVE_WINDOW_DISPMANX
-#include "../dispmanx/gstglwindow_dispmanx_egl.h"
-#endif
-
-#define GST_CAT_DEFAULT gst_gl_context_debug
-
-static gboolean gst_gl_context_egl_create_context (GstGLContext * context,
- GstGLAPI gl_api, GstGLContext * other_context, GError ** error);
-static void gst_gl_context_egl_destroy_context (GstGLContext * context);
-static gboolean gst_gl_context_egl_choose_format (GstGLContext * context,
- GError ** error);
-
-static gboolean gst_gl_context_egl_activate (GstGLContext * context,
- gboolean activate);
-static void gst_gl_context_egl_swap_buffers (GstGLContext * context);
-static guintptr gst_gl_context_egl_get_gl_context (GstGLContext * context);
-static GstGLAPI gst_gl_context_egl_get_gl_api (GstGLContext * context);
-static GstGLPlatform gst_gl_context_egl_get_gl_platform (GstGLContext *
- context);
-static gboolean gst_gl_context_egl_check_feature (GstGLContext * context,
- const gchar * feature);
-static void gst_gl_context_egl_get_gl_platform_version (GstGLContext * context,
- gint * major, gint * minor);
-
-G_DEFINE_TYPE (GstGLContextEGL, gst_gl_context_egl, GST_TYPE_GL_CONTEXT);
-
-static void
-gst_gl_context_egl_class_init (GstGLContextEGLClass * klass)
-{
- GstGLContextClass *context_class = (GstGLContextClass *) klass;
-
- context_class->get_gl_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_egl_get_gl_context);
- context_class->activate = GST_DEBUG_FUNCPTR (gst_gl_context_egl_activate);
- context_class->create_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_egl_create_context);
- context_class->destroy_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_egl_destroy_context);
- context_class->choose_format =
- GST_DEBUG_FUNCPTR (gst_gl_context_egl_choose_format);
- context_class->swap_buffers =
- GST_DEBUG_FUNCPTR (gst_gl_context_egl_swap_buffers);
-
- context_class->get_gl_api = GST_DEBUG_FUNCPTR (gst_gl_context_egl_get_gl_api);
- context_class->get_gl_platform =
- GST_DEBUG_FUNCPTR (gst_gl_context_egl_get_gl_platform);
- context_class->get_proc_address =
- GST_DEBUG_FUNCPTR (gst_gl_context_egl_get_proc_address);
- context_class->check_feature =
- GST_DEBUG_FUNCPTR (gst_gl_context_egl_check_feature);
- context_class->get_current_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_egl_get_current_context);
- context_class->get_gl_platform_version =
- GST_DEBUG_FUNCPTR (gst_gl_context_egl_get_gl_platform_version);
-}
-
-static void
-gst_gl_context_egl_init (GstGLContextEGL * context)
-{
-}
-
-/* Must be called in the gl thread */
-GstGLContextEGL *
-gst_gl_context_egl_new (GstGLDisplay * display)
-{
- GstGLContextEGL *context;
-
- /* XXX: display type could theoretically be anything, as long as
- * eglGetDisplay supports it. */
- context = g_object_new (GST_TYPE_GL_CONTEXT_EGL, NULL);
- gst_object_ref_sink (context);
-
- return context;
-}
-
-static gboolean
-gst_gl_context_egl_choose_format (GstGLContext * context, GError ** error)
-{
-#if GST_GL_HAVE_WINDOW_X11
- if (GST_IS_GL_WINDOW_X11 (context->window)) {
- GstGLWindow *window = gst_gl_context_get_window (context);
- GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window);
- gint ret;
-
- window_x11->visual_info = g_new0 (XVisualInfo, 1);
- ret = XMatchVisualInfo (window_x11->device, window_x11->screen_num,
- window_x11->depth, TrueColor, window_x11->visual_info);
-
- gst_object_unref (window);
-
- if (ret == 0) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_WRONG_CONFIG, "Failed to match XVisualInfo");
- return FALSE;
- }
- }
-#endif
-
- return TRUE;
-}
-
-static gboolean
-gst_gl_context_egl_choose_config (GstGLContextEGL * egl, GstGLAPI gl_api,
- gint major, GError ** error)
-{
- gboolean create_context;
- EGLint numConfigs;
- gint i = 0;
- EGLint config_attrib[20];
-
- create_context =
- gst_gl_check_extension ("EGL_KHR_create_context", egl->egl_exts);
- /* silence unused warnings */
- (void) create_context;
-
- config_attrib[i++] = EGL_SURFACE_TYPE;
- config_attrib[i++] = EGL_WINDOW_BIT;
- config_attrib[i++] = EGL_RENDERABLE_TYPE;
- if (gl_api & GST_GL_API_GLES2) {
- if (major == 3) {
-#if defined(EGL_KHR_create_context)
- if (create_context) {
- config_attrib[i++] = EGL_OPENGL_ES3_BIT_KHR;
- } else
-#endif
- {
- return FALSE;
- }
- } else {
- config_attrib[i++] = EGL_OPENGL_ES2_BIT;
- }
- } else
- config_attrib[i++] = EGL_OPENGL_BIT;
-#if defined(USE_EGL_RPI) && GST_GL_HAVE_WINDOW_WAYLAND
- /* The configurations with a=0 seems to be buggy whereas
- * it works when using dispmanx directly */
- config_attrib[i++] = EGL_ALPHA_SIZE;
- config_attrib[i++] = 1;
-#endif
- config_attrib[i++] = EGL_DEPTH_SIZE;
- config_attrib[i++] = 16;
- config_attrib[i++] = EGL_RED_SIZE;
- config_attrib[i++] = 1;
- config_attrib[i++] = EGL_GREEN_SIZE;
- config_attrib[i++] = 1;
- config_attrib[i++] = EGL_BLUE_SIZE;
- config_attrib[i++] = 1;
- config_attrib[i++] = EGL_NONE;
-
- if (eglChooseConfig (egl->egl_display, config_attrib,
- &egl->egl_config, 1, &numConfigs)) {
- GST_INFO ("config set: %" G_GUINTPTR_FORMAT ", %u",
- (guintptr) egl->egl_config, (unsigned int) numConfigs);
- } else {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
- "Failed to set window configuration: %s",
- gst_egl_get_error_string (eglGetError ()));
- goto failure;
- }
-
- return TRUE;
-
-failure:
- return FALSE;
-}
-
-static EGLContext
-_create_context_with_flags (GstGLContextEGL * egl, EGLContext share_context,
- GstGLAPI gl_api, gint major, gint minor, gint contextFlags,
- gint profileMask)
-{
- gboolean create_context;
-#define N_ATTRIBS 20
- gint attribs[N_ATTRIBS];
- gint n = 0;
-
- /* fail creation of apis/versions/flags that require EGL_KHR_create_context
- * if the extension doesn't exist, namely:0
- *
- * - profile mask
- * - context flags
- * - GL3 > 3.1
- * - GLES2 && minor > 0
- */
- create_context =
- gst_gl_check_extension ("EGL_KHR_create_context", egl->egl_exts);
- (void) create_context;
- if (!create_context && (profileMask || contextFlags
- || ((gl_api & GST_GL_API_OPENGL3)
- && GST_GL_CHECK_GL_VERSION (major, minor, 3, 2))
- || ((gl_api & GST_GL_API_GLES2) && minor > 0))) {
- return 0;
- }
-
- GST_DEBUG_OBJECT (egl, "attempting to create OpenGL%s context version %d.%d "
- "flags %x profile %x", gl_api & GST_GL_API_GLES2 ? " ES" : "", major,
- minor, contextFlags, profileMask);
-
-#if defined(EGL_KHR_create_context)
- if (create_context) {
- if (major) {
- attribs[n++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
- attribs[n++] = major;
- }
- if (minor) {
- attribs[n++] = EGL_CONTEXT_MINOR_VERSION_KHR;
- attribs[n++] = minor;
- }
- if (contextFlags) {
- attribs[n++] = EGL_CONTEXT_FLAGS_KHR;
- attribs[n++] = contextFlags;
- }
- if (profileMask) {
- attribs[n++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
- attribs[n++] = profileMask;
- }
- } else
-#endif
- {
- attribs[n++] = EGL_CONTEXT_CLIENT_VERSION;
- attribs[n++] = major;
- }
- attribs[n++] = EGL_NONE;
-
- g_assert (n < N_ATTRIBS);
-#undef N_ATTRIBS
-
- return eglCreateContext (egl->egl_display, egl->egl_config, share_context,
- attribs);
-}
-
-static gboolean
-gst_gl_context_egl_create_context (GstGLContext * context,
- GstGLAPI gl_api, GstGLContext * other_context, GError ** error)
-{
- GstGLContextEGL *egl;
- GstGLWindow *window = NULL;
- guintptr window_handle = 0;
- EGLint egl_major;
- EGLint egl_minor;
- gboolean need_surface = TRUE;
- guintptr external_gl_context = 0;
- guintptr egl_display;
-
- egl = GST_GL_CONTEXT_EGL (context);
- window = gst_gl_context_get_window (context);
-
- GST_DEBUG_OBJECT (context, "Creating EGL context");
-
- if (other_context) {
- if (gst_gl_context_get_gl_platform (other_context) != GST_GL_PLATFORM_EGL) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
- "Cannot share context with non-EGL context");
- goto failure;
- }
- external_gl_context = gst_gl_context_get_gl_context (other_context);
- }
-
- if ((gl_api & (GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2)) ==
- GST_GL_API_NONE) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_WRONG_API,
- "EGL supports opengl or gles2");
- goto failure;
- }
-
- if (!egl->display_egl) {
- GstGLDisplay *display = gst_gl_context_get_display (context);
-
- egl->display_egl = gst_gl_display_egl_from_gl_display (display);
- if (!egl->display_egl) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE,
- "Failed to create EGLDisplay from native display");
- gst_object_unref (display);
- goto failure;
- }
-
- gst_object_unref (display);
- }
-
- egl_display = gst_gl_display_get_handle (GST_GL_DISPLAY (egl->display_egl));
- egl->egl_display = (EGLDisplay) egl_display;
-
- if (eglInitialize (egl->egl_display, &egl_major, &egl_minor)) {
- GST_INFO ("egl initialized, version: %d.%d", egl_major, egl_minor);
- } else {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE,
- "Failed to initialize egl: %s",
- gst_egl_get_error_string (eglGetError ()));
- goto failure;
- }
-
- egl->egl_exts = eglQueryString (egl->egl_display, EGL_EXTENSIONS);
-
- if (gl_api & (GST_GL_API_OPENGL | GST_GL_API_OPENGL3)) {
- GstGLAPI chosen_gl_api = 0;
- gint i;
-
- /* egl + opengl only available with EGL 1.4+ */
- if (egl_major == 1 && egl_minor <= 3) {
- if ((gl_api & ~GST_GL_API_OPENGL) == GST_GL_API_NONE) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_OLD_LIBS,
- "EGL version (%i.%i) too old for OpenGL support, (needed at least 1.4)",
- egl_major, egl_minor);
- goto failure;
- } else {
- GST_WARNING
- ("EGL version (%i.%i) too old for OpenGL support, (needed at least 1.4)",
- egl_major, egl_minor);
- if (gl_api & GST_GL_API_GLES2) {
- goto try_gles2;
- } else {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
- "Failed to choose a suitable OpenGL API");
- goto failure;
- }
- }
- }
-
- if (!eglBindAPI (EGL_OPENGL_API)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "Failed to bind OpenGL API: %s",
- gst_egl_get_error_string (eglGetError ()));
- goto failure;
- }
-
- GST_INFO ("Bound OpenGL");
-
- /* api, version only matters for gles */
- if (!gst_gl_context_egl_choose_config (egl, GST_GL_API_OPENGL, 0, error)) {
- g_assert (error == NULL || *error != NULL);
- goto failure;
- }
-
- for (i = 0; i < G_N_ELEMENTS (opengl_versions); i++) {
- gint profileMask = 0;
- gint contextFlags = 0;
-
- if (GST_GL_CHECK_GL_VERSION (opengl_versions[i].major,
- opengl_versions[i].minor, 3, 2)) {
- /* skip gl3 contexts if requested */
- if ((gl_api & GST_GL_API_OPENGL3) == 0)
- continue;
-
- chosen_gl_api = GST_GL_API_OPENGL3;
-#if defined(EGL_KHR_create_context)
- profileMask |= EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
- contextFlags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
-#endif
- } else if (opengl_versions[i].major == 3 && opengl_versions[i].minor == 1) {
- /* skip 3.1, the implementation is free to give us either a core or a
- * compatibility context (we have no say) */
- continue;
- } else {
- /* skip legacy contexts if requested */
- if ((gl_api & GST_GL_API_OPENGL) == 0)
- continue;
-
- chosen_gl_api = GST_GL_API_OPENGL;
- }
-
- egl->egl_context =
- _create_context_with_flags (egl, (EGLContext) external_gl_context,
- chosen_gl_api, opengl_versions[i].major,
- opengl_versions[i].minor, contextFlags, profileMask);
-
- if (egl->egl_context)
- break;
-
-#if defined(EGL_KHR_create_context)
- profileMask &= ~EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
-
- egl->egl_context =
- _create_context_with_flags (egl, (EGLContext) external_gl_context,
- chosen_gl_api, opengl_versions[i].major,
- opengl_versions[i].minor, contextFlags, profileMask);
-
- if (egl->egl_context)
- break;
-#endif
- }
-
- egl->gl_api = chosen_gl_api;
- } else if (gl_api & GST_GL_API_GLES2) {
- gint i;
-
- try_gles2:
- if (!eglBindAPI (EGL_OPENGL_ES_API)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "Failed to bind OpenGL|ES API: %s",
- gst_egl_get_error_string (eglGetError ()));
- goto failure;
- }
-
- GST_INFO ("Bound OpenGL|ES");
-
- for (i = 0; i < G_N_ELEMENTS (gles2_versions); i++) {
- gint profileMask = 0;
- gint contextFlags = 0;
- guint maj = gles2_versions[i].major;
- guint min = gles2_versions[i].minor;
-
- if (!gst_gl_context_egl_choose_config (egl, GST_GL_API_GLES2, maj, error)) {
- GST_DEBUG_OBJECT (context, "Failed to choose a GLES%d config: %s",
- maj, error && *error ? (*error)->message : "Unknown");
- g_clear_error (error);
- continue;
- }
-#if defined(EGL_KHR_create_context)
- /* try a debug context */
- contextFlags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
-
- egl->egl_context =
- _create_context_with_flags (egl, (EGLContext) external_gl_context,
- GST_GL_API_GLES2, maj, min, contextFlags, profileMask);
-
- if (egl->egl_context)
- break;
-
- /* try without a debug context */
- contextFlags &= ~EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
-#endif
-
- egl->egl_context =
- _create_context_with_flags (egl, (EGLContext) external_gl_context,
- GST_GL_API_GLES2, maj, min, contextFlags, profileMask);
-
- if (egl->egl_context)
- break;
- }
- egl->gl_api = GST_GL_API_GLES2;
- }
-
- if (egl->egl_context != EGL_NO_CONTEXT) {
- GST_INFO ("gl context created: %" G_GUINTPTR_FORMAT,
- (guintptr) egl->egl_context);
- } else {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
- "Failed to create a OpenGL context: %s",
- gst_egl_get_error_string (eglGetError ()));
- goto failure;
- }
- /* FIXME do we want a window vfunc ? */
-#if GST_GL_HAVE_WINDOW_X11
- if (GST_IS_GL_WINDOW_X11 (context->window)) {
- gst_gl_window_x11_create_window ((GstGLWindowX11 *) context->window);
- }
-#endif
-
- if (other_context == NULL) {
- /* FIXME: fails to show two outputs at all. We need a property/option for
- * glimagesink to say its a visible context */
-#if GST_GL_HAVE_WINDOW_WAYLAND
- if (GST_IS_GL_WINDOW_WAYLAND_EGL (context->window)) {
- gst_gl_window_wayland_egl_create_window ((GstGLWindowWaylandEGL *)
- context->window);
- }
-#endif
-#if GST_GL_HAVE_WINDOW_WIN32
- if (GST_IS_GL_WINDOW_WIN32 (context->window)) {
- gst_gl_window_win32_create_window ((GstGLWindowWin32 *) context->window);
- }
-#endif
-#if GST_GL_HAVE_WINDOW_DISPMANX
- if (GST_IS_GL_WINDOW_DISPMANX_EGL (context->window)) {
- gst_gl_window_dispmanx_egl_create_window ((GstGLWindowDispmanxEGL *)
- context->window);
- }
-#endif
- }
-
- if (window)
- window_handle = gst_gl_window_get_window_handle (window);
-
- if (window_handle) {
- GST_DEBUG ("Creating EGLSurface from window_handle %p",
- (void *) window_handle);
- egl->egl_surface =
- eglCreateWindowSurface (egl->egl_display, egl->egl_config,
- (EGLNativeWindowType) window_handle, NULL);
- /* Store window handle for later comparision */
- egl->window_handle = window_handle;
- } else if (!gst_gl_check_extension ("EGL_KHR_surfaceless_context",
- egl->egl_exts)) {
- EGLint surface_attrib[7];
- gint j = 0;
-
- GST_DEBUG ("Surfaceless context, creating PBufferSurface");
- /* FIXME: Width/height doesn't seem to matter but we can't leave them
- * at 0, otherwise X11 complains about BadValue */
- surface_attrib[j++] = EGL_WIDTH;
- surface_attrib[j++] = 1;
- surface_attrib[j++] = EGL_HEIGHT;
- surface_attrib[j++] = 1;
- surface_attrib[j++] = EGL_LARGEST_PBUFFER;
- surface_attrib[j++] = EGL_TRUE;
- surface_attrib[j++] = EGL_NONE;
-
- egl->egl_surface =
- eglCreatePbufferSurface (egl->egl_display, egl->egl_config,
- surface_attrib);
- } else {
- GST_DEBUG ("No surface/handle !");
- egl->egl_surface = EGL_NO_SURFACE;
- need_surface = FALSE;
- }
-
- if (need_surface) {
- if (egl->egl_surface != EGL_NO_SURFACE) {
- GST_INFO ("surface created");
- } else {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "Failed to create window surface: %s",
- gst_egl_get_error_string (eglGetError ()));
- goto failure;
- }
- }
- egl->egl_major = egl_major;
- egl->egl_minor = egl_minor;
-
- if (window)
- gst_object_unref (window);
-
- return TRUE;
-
-failure:
- if (window)
- gst_object_unref (window);
-
- return FALSE;
-}
-
-static void
-gst_gl_context_egl_destroy_context (GstGLContext * context)
-{
- GstGLContextEGL *egl;
-
- egl = GST_GL_CONTEXT_EGL (context);
-
- gst_gl_context_egl_activate (context, FALSE);
-
- if (egl->egl_surface) {
- eglDestroySurface (egl->egl_display, egl->egl_surface);
- egl->egl_surface = EGL_NO_SURFACE;
- }
-
- if (egl->egl_context) {
- eglDestroyContext (egl->egl_display, egl->egl_context);
- egl->egl_context = NULL;
- }
- egl->window_handle = 0;
-
- eglReleaseThread ();
-
- if (egl->display_egl) {
- gst_object_unref (egl->display_egl);
- egl->display_egl = NULL;
- }
-}
-
-static gboolean
-gst_gl_context_egl_activate (GstGLContext * context, gboolean activate)
-{
- GstGLContextEGL *egl;
- gboolean result;
-
- egl = GST_GL_CONTEXT_EGL (context);
-
- if (activate) {
- GstGLWindow *window = gst_gl_context_get_window (context);
- guintptr handle = 0;
- /* Check if the backing handle changed */
- if (window) {
- handle = gst_gl_window_get_window_handle (window);
- gst_object_unref (window);
- }
- if (handle && handle != egl->window_handle) {
- GST_DEBUG_OBJECT (context,
- "Handle changed (have:%p, now:%p), switching surface",
- (void *) egl->window_handle, (void *) handle);
- if (egl->egl_surface) {
- result = eglDestroySurface (egl->egl_display, egl->egl_surface);
- egl->egl_surface = EGL_NO_SURFACE;
- if (!result) {
- GST_ERROR_OBJECT (context, "Failed to destroy old window surface: %s",
- gst_egl_get_error_string (eglGetError ()));
- goto done;
- }
- }
- egl->egl_surface =
- eglCreateWindowSurface (egl->egl_display, egl->egl_config,
- (EGLNativeWindowType) handle, NULL);
- egl->window_handle = handle;
-
- if (egl->egl_surface == EGL_NO_SURFACE) {
- GST_ERROR_OBJECT (context, "Failed to create window surface: %s",
- gst_egl_get_error_string (eglGetError ()));
- result = FALSE;
- goto done;
- }
- }
- result = eglMakeCurrent (egl->egl_display, egl->egl_surface,
- egl->egl_surface, egl->egl_context);
- } else {
- result = eglMakeCurrent (egl->egl_display, EGL_NO_SURFACE,
- EGL_NO_SURFACE, EGL_NO_CONTEXT);
- }
-
- if (!result) {
- GST_ERROR_OBJECT (context,
- "Failed to bind context to the current rendering thread: %s",
- gst_egl_get_error_string (eglGetError ()));
- }
-
-done:
- return result;
-}
-
-static guintptr
-gst_gl_context_egl_get_gl_context (GstGLContext * context)
-{
- return (guintptr) GST_GL_CONTEXT_EGL (context)->egl_context;
-}
-
-static void
-gst_gl_context_egl_swap_buffers (GstGLContext * context)
-{
- GstGLContextEGL *egl;
-
- egl = GST_GL_CONTEXT_EGL (context);
-
- eglSwapBuffers (egl->egl_display, egl->egl_surface);
-}
-
-static GstGLAPI
-gst_gl_context_egl_get_gl_api (GstGLContext * context)
-{
- return GST_GL_CONTEXT_EGL (context)->gl_api;
-}
-
-static GstGLPlatform
-gst_gl_context_egl_get_gl_platform (GstGLContext * context)
-{
- return GST_GL_PLATFORM_EGL;
-}
-
-static GModule *module_egl;
-
-static gpointer
-load_egl_module (gpointer user_data)
-{
-#ifdef GST_GL_LIBEGL_MODULE_NAME
- module_egl = g_module_open (GST_GL_LIBEGL_MODULE_NAME, G_MODULE_BIND_LAZY);
-#else
- /* On Linux the .so is only in -dev packages, try with a real soname
- * Proper compilers will optimize away the strcmp */
- if (g_strcmp0 (G_MODULE_SUFFIX, "so") == 0)
- module_egl = g_module_open ("libEGL.so.1", G_MODULE_BIND_LAZY);
-
- /* This automatically handles the suffix and even .la files */
- if (!module_egl)
- module_egl = g_module_open ("libEGL", G_MODULE_BIND_LAZY);
-#endif
-
- return NULL;
-}
-
-gpointer
-gst_gl_context_egl_get_proc_address (GstGLAPI gl_api, const gchar * name)
-{
- gpointer result = NULL;
- static GOnce g_once = G_ONCE_INIT;
-
-#ifdef __APPLE__
-#if GST_GL_HAVE_OPENGL && !defined(GST_GL_LIBGL_MODULE_NAME)
- if (!result && (gl_api & (GST_GL_API_OPENGL | GST_GL_API_OPENGL3))) {
- static GModule *module_opengl = NULL;
- if (g_once_init_enter (&module_opengl)) {
- GModule *setup_module_opengl =
- g_module_open ("libGL.dylib", G_MODULE_BIND_LAZY);
- g_once_init_leave (&module_opengl, setup_module_opengl);
- }
- if (module_opengl)
- g_module_symbol (module_opengl, name, &result);
- }
-#endif
-#if GST_GL_HAVE_GLES2 && !defined(GST_GL_LIBGLESV2_MODULE_NAME)
- if (!result && (gl_api & (GST_GL_API_GLES2))) {
- static GModule *module_gles2 = NULL;
- if (g_once_init_enter (&module_gles2)) {
- GModule *setup_module_gles2 =
- g_module_open ("libGLESv2.dylib", G_MODULE_BIND_LAZY);
- g_once_init_leave (&module_gles2, setup_module_gles2);
- }
- if (module_gles2)
- g_module_symbol (module_gles2, name, &result);
- }
-#endif
-#endif // __APPLE__
-
- if (!result)
- result = gst_gl_context_default_get_proc_address (gl_api, name);
-
- g_once (&g_once, load_egl_module, NULL);
-
- if (!result && module_egl) {
- g_module_symbol (module_egl, name, &result);
- }
-
- /* FIXME: On Android this returns wrong addresses for non-EGL functions */
-#if GST_GL_HAVE_WINDOW_ANDROID
- if (!result && g_str_has_prefix (name, "egl")) {
-#else
- if (!result) {
- result = eglGetProcAddress (name);
-#endif
- }
-
- return result;
-}
-
-static gboolean
-gst_gl_context_egl_check_feature (GstGLContext * context, const gchar * feature)
-{
- GstGLContextEGL *context_egl = GST_GL_CONTEXT_EGL (context);
-
- return gst_gl_check_extension (feature, context_egl->egl_exts);
-}
-
-guintptr
-gst_gl_context_egl_get_current_context (void)
-{
- return (guintptr) eglGetCurrentContext ();
-}
-
-static void
-gst_gl_context_egl_get_gl_platform_version (GstGLContext * context,
- gint * major, gint * minor)
-{
- GstGLContextEGL *context_egl = GST_GL_CONTEXT_EGL (context);
-
- *major = context_egl->egl_major;
- *minor = context_egl->egl_minor;
-}
diff --git a/gst-libs/gst/gl/egl/gstglcontext_egl.h b/gst-libs/gst/gl/egl/gstglcontext_egl.h
deleted file mode 100644
index 67947a885..000000000
--- a/gst-libs/gst/gl/egl/gstglcontext_egl.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Sebastian Dröge <slomo@circular-chaos.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_EGL_H__
-#define __GST_GL_EGL_H__
-
-#include <gst/gl/gstglcontext.h>
-#include <gst/gl/egl/gstgldisplay_egl.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GstGLContextEGL GstGLContextEGL;
-typedef struct _GstGLContextEGLClass GstGLContextEGLClass;
-
-G_GNUC_INTERNAL GType gst_gl_context_egl_get_type (void);
-#define GST_TYPE_GL_CONTEXT_EGL (gst_gl_context_egl_get_type())
-
-/* FIXME: remove this when moving to -base */
-#ifndef GST_DISABLE_DEPRECATED
-#define GST_GL_TYPE_CONTEXT_EGL GST_TYPE_GL_CONTEXT_EGL
-#endif
-#define GST_GL_CONTEXT_EGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_CONTEXT_EGL, GstGLContextEGL))
-#define GST_GL_CONTEXT_EGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_CONTEXT_EGL, GstGLContextEGLClass))
-#define GST_IS_GL_CONTEXT_EGL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_CONTEXT_EGL))
-#define GST_IS_GL_CONTEXT_EGL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_CONTEXT_EGL))
-#define GST_GL_CONTEXT_EGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_CONTEXT_EGL, GstGLContextEGLClass))
-
-/**
- * GstGLContextEGL:
- *
- * Opaque #GstGLContextEGL struct
- */
-struct _GstGLContextEGL
-{
- /* <private> */
- GstGLContext context;
-
- GstGLDisplayEGL *display_egl;
-
- gpointer egl_context;
- gpointer egl_display;
- gpointer egl_surface;
- gpointer egl_config;
-
- gint egl_major;
- gint egl_minor;
-
- GstGLAPI gl_api;
-
- const gchar *egl_exts;
-
- /* Cached handle */
- guintptr window_handle;
-};
-
-/**
- * GstGLContextEGLCLass:
- *
- * Opaque #GstGLContextEGLClass struct
- */
-struct _GstGLContextEGLClass
-{
- /* <private> */
- GstGLContextClass parent;
-};
-
-G_GNUC_INTERNAL
-GstGLContextEGL * gst_gl_context_egl_new (GstGLDisplay * display);
-
-G_GNUC_INTERNAL
-guintptr gst_gl_context_egl_get_current_context (void);
-
-G_GNUC_INTERNAL
-gpointer gst_gl_context_egl_get_proc_address (GstGLAPI gl_api, const gchar * name);
-
-G_END_DECLS
-
-#endif /* __GST_GL_EGL_H__ */
diff --git a/gst-libs/gst/gl/egl/gstgldisplay_egl.c b/gst-libs/gst/gl/egl/gstgldisplay_egl.c
deleted file mode 100644
index 448899ccc..000000000
--- a/gst-libs/gst/gl/egl/gstgldisplay_egl.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstgldisplay_egl.h"
-
-#include <gst/gl/gstglfeature.h>
-
-#include "gstegl.h"
-#include "gsteglimage.h"
-#include "gstglmemoryegl.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_gl_display_debug);
-#define GST_CAT_DEFAULT gst_gl_display_debug
-
-#ifndef EGL_PLATFORM_X11
-#define EGL_PLATFORM_X11 0x31D5
-#endif
-#ifndef EGL_PLATFORM_WAYLAND
-#define EGL_PLATFORM_WAYLAND 0x31D8
-#endif
-#ifndef EGL_PLATFORM_ANDROID
-#define EGL_PLATFORM_ANDROID 0x3141
-#endif
-
-typedef EGLDisplay (*_gst_eglGetPlatformDisplay_type) (EGLenum platform,
- void *native_display, const EGLint * attrib_list);
-
-G_DEFINE_TYPE (GstGLDisplayEGL, gst_gl_display_egl, GST_TYPE_GL_DISPLAY);
-
-static void gst_gl_display_egl_finalize (GObject * object);
-static guintptr gst_gl_display_egl_get_handle (GstGLDisplay * display);
-
-static void
-gst_gl_display_egl_class_init (GstGLDisplayEGLClass * klass)
-{
- GST_GL_DISPLAY_CLASS (klass)->get_handle =
- GST_DEBUG_FUNCPTR (gst_gl_display_egl_get_handle);
-
- G_OBJECT_CLASS (klass)->finalize = gst_gl_display_egl_finalize;
-}
-
-static void
-gst_gl_display_egl_init (GstGLDisplayEGL * display_egl)
-{
- GstGLDisplay *display = (GstGLDisplay *) display_egl;
-
- display->type = GST_GL_DISPLAY_TYPE_EGL;
- display_egl->foreign_display = FALSE;
-
- gst_gl_memory_egl_init_once ();
-}
-
-static void
-gst_gl_display_egl_finalize (GObject * object)
-{
- GstGLDisplayEGL *display_egl = GST_GL_DISPLAY_EGL (object);
-
- if (display_egl->display && !display_egl->foreign_display) {
- eglTerminate (display_egl->display);
- display_egl->display = NULL;
- }
-
- G_OBJECT_CLASS (gst_gl_display_egl_parent_class)->finalize (object);
-}
-
-/**
- * gst_gl_display_egl_get_from_native:
- * @type: a #GstGLDisplayType
- * @display: pointer to a display (or 0)
- *
- * Attempts to create a new #EGLDisplay from @display. If @type is
- * %GST_GL_DISPLAY_TYPE_ANY, then @display must be 0.
- *
- * Returns: A #EGLDisplay or %EGL_NO_DISPLAY
- *
- * Since: 1.12
- */
-gpointer
-gst_gl_display_egl_get_from_native (GstGLDisplayType type, guintptr display)
-{
- const gchar *egl_exts;
- EGLDisplay ret = EGL_NO_DISPLAY;
- _gst_eglGetPlatformDisplay_type _gst_eglGetPlatformDisplay;
-
- g_return_val_if_fail ((type != GST_GL_DISPLAY_TYPE_ANY && display != 0)
- || (type == GST_GL_DISPLAY_TYPE_ANY && display == 0), EGL_NO_DISPLAY);
- g_return_val_if_fail ((type != GST_GL_DISPLAY_TYPE_NONE
- || (type == GST_GL_DISPLAY_TYPE_NONE
- && display == 0)), EGL_NO_DISPLAY);
-
- /* given an EGLDisplay already */
- if (type == GST_GL_DISPLAY_TYPE_EGL)
- return (gpointer) display;
-
- if (type == GST_GL_DISPLAY_TYPE_NONE)
- type = GST_GL_DISPLAY_TYPE_ANY;
-
- egl_exts = eglQueryString (EGL_NO_DISPLAY, EGL_EXTENSIONS);
- GST_DEBUG ("egl no display extensions: %s", egl_exts);
-
- if (eglGetError () != EGL_SUCCESS || !egl_exts)
- goto default_display;
-
- /* check if we can actually choose the egl display type */
- if (!gst_gl_check_extension ("EGL_KHR_client_get_all_proc_addresses",
- egl_exts))
- goto default_display;
- if (!gst_gl_check_extension ("EGL_EXT_platform_base", egl_exts))
- goto default_display;
-
- _gst_eglGetPlatformDisplay = (_gst_eglGetPlatformDisplay_type)
- eglGetProcAddress ("eglGetPlatformDisplay");
- if (!_gst_eglGetPlatformDisplay)
- _gst_eglGetPlatformDisplay = (_gst_eglGetPlatformDisplay_type)
- eglGetProcAddress ("eglGetPlatformDisplayEXT");
- if (!_gst_eglGetPlatformDisplay)
- goto default_display;
-
- /* try each platform in turn */
-#if GST_GL_HAVE_WINDOW_X11
- if (ret == EGL_NO_DISPLAY && (type & GST_GL_DISPLAY_TYPE_X11) &&
- (gst_gl_check_extension ("EGL_KHR_platform_x11", egl_exts) ||
- gst_gl_check_extension ("EGL_EXT_platform_x11", egl_exts))) {
- ret = _gst_eglGetPlatformDisplay (EGL_PLATFORM_X11, (gpointer) display,
- NULL);
- }
-#endif
-#if GST_GL_HAVE_WINDOW_WAYLAND
- if (ret == EGL_NO_DISPLAY && (type & GST_GL_DISPLAY_TYPE_WAYLAND) &&
- (gst_gl_check_extension ("EGL_KHR_platform_wayland", egl_exts) ||
- gst_gl_check_extension ("EGL_EXT_platform_wayland", egl_exts))) {
- ret = _gst_eglGetPlatformDisplay (EGL_PLATFORM_WAYLAND, (gpointer) display,
- NULL);
- }
-#endif
- /* android only has one winsys/display connection */
-
- if (ret != EGL_NO_DISPLAY)
- return ret;
-
- /* otherwise rely on the implementation to choose the correct display
- * based on the pointer */
-default_display:
- return (gpointer) eglGetDisplay ((EGLNativeDisplayType) display);
-}
-
-/**
- * gst_gl_display_egl_new:
- *
- * Create a new #GstGLDisplayEGL using the default EGL_DEFAULT_DISPLAY.
- *
- * Returns: (transfer full): a new #GstGLDisplayEGL or %NULL
- */
-GstGLDisplayEGL *
-gst_gl_display_egl_new (void)
-{
- GstGLDisplayEGL *ret;
-
- GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");
-
- ret = g_object_new (GST_TYPE_GL_DISPLAY_EGL, NULL);
- gst_object_ref_sink (ret);
- ret->display =
- gst_gl_display_egl_get_from_native (GST_GL_DISPLAY_TYPE_ANY, 0);
-
- if (!ret->display) {
- GST_INFO ("Failed to open EGL display connection");
- }
-
- return ret;
-}
-
-/**
- * gst_gl_display_egl_new_with_display:
- * @display: an existing and connected EGLDisplay
- *
- * Creates a new display connection from a EGLDisplay.
- *
- * Returns: (transfer full): a new #GstGLDisplayEGL
- *
- * Since: 1.12
- */
-GstGLDisplayEGL *
-gst_gl_display_egl_new_with_egl_display (gpointer display)
-{
- GstGLDisplayEGL *ret;
-
- g_return_val_if_fail (display != NULL, NULL);
-
- GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");
-
- ret = g_object_new (GST_TYPE_GL_DISPLAY_EGL, NULL);
- gst_object_ref_sink (ret);
-
- ret->display = display;
- ret->foreign_display = TRUE;
-
- return ret;
-}
-
-static gpointer
-_ref_if_set (gpointer data, gpointer user_data)
-{
- if (data)
- gst_object_ref (data);
- return data;
-}
-
-/**
- * gst_gl_display_egl_from_gl_display:
- * @display: an existing #GstGLDisplay
- *
- * Creates a EGL display connection from a native Display.
- *
- * This function will return the same value for multiple calls with the same
- * @display.
- *
- * Returns: (transfer full): a new #GstGLDisplayEGL
- *
- * Since: 1.12
- */
-GstGLDisplayEGL *
-gst_gl_display_egl_from_gl_display (GstGLDisplay * display)
-{
- GstGLDisplayEGL *ret;
- GstGLDisplayType display_type;
- guintptr native_display;
-
- g_return_val_if_fail (GST_IS_GL_DISPLAY (display), NULL);
-
- GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");
-
- if (GST_IS_GL_DISPLAY_EGL (display)) {
- GST_LOG_OBJECT (display, "display %" GST_PTR_FORMAT "is already a "
- "GstGLDisplayEGL", display);
- return gst_object_ref (display);
- }
-
- /* try to get a previously set GstGLDisplayEGL */
- ret = g_object_dup_data (G_OBJECT (display), GST_GL_DISPLAY_EGL_NAME,
- (GDuplicateFunc) _ref_if_set, NULL);
- if (ret && GST_IS_GL_DISPLAY_EGL (ret)) {
- GST_LOG_OBJECT (display, "display %" GST_PTR_FORMAT "already has a "
- "GstGLDisplayEGL %" GST_PTR_FORMAT, display, ret);
- return ret;
- }
-
- if (ret)
- gst_object_unref (ret);
-
- display_type = gst_gl_display_get_handle_type (display);
- native_display = gst_gl_display_get_handle (display);
-
- g_return_val_if_fail (native_display != 0, NULL);
- g_return_val_if_fail (display_type != GST_GL_DISPLAY_TYPE_NONE, NULL);
-
- ret = g_object_new (GST_TYPE_GL_DISPLAY_EGL, NULL);
- gst_object_ref_sink (ret);
-
- ret->display =
- gst_gl_display_egl_get_from_native (display_type, native_display);
-
- if (!ret->display) {
- GST_WARNING_OBJECT (ret, "failed to get EGLDisplay from native display");
- gst_object_unref (ret);
- return NULL;
- }
- g_object_set_data_full (G_OBJECT (display), GST_GL_DISPLAY_EGL_NAME,
- gst_object_ref (ret), (GDestroyNotify) gst_object_unref);
-
- return ret;
-}
-
-static guintptr
-gst_gl_display_egl_get_handle (GstGLDisplay * display)
-{
- return (guintptr) GST_GL_DISPLAY_EGL (display)->display;
-}
diff --git a/gst-libs/gst/gl/egl/gstgldisplay_egl.h b/gst-libs/gst/gl/egl/gstgldisplay_egl.h
deleted file mode 100644
index 319a04724..000000000
--- a/gst-libs/gst/gl/egl/gstgldisplay_egl.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_DISPLAY_EGL_H__
-#define __GST_GL_DISPLAY_EGL_H__
-
-#include <gst/gl/gstgldisplay.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GType gst_gl_display_egl_get_type (void);
-
-#define GST_TYPE_GL_DISPLAY_EGL (gst_gl_display_egl_get_type())
-#define GST_GL_DISPLAY_EGL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_DISPLAY_EGL,GstGLDisplayEGL))
-#define GST_GL_DISPLAY_EGL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_GL_DISPLAY_EGL,GstGLDisplayEGLClass))
-#define GST_IS_GL_DISPLAY_EGL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_DISPLAY_EGL))
-#define GST_IS_GL_DISPLAY_EGL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GL_DISPLAY_EGL))
-#define GST_GL_DISPLAY_EGL_CAST(obj) ((GstGLDisplayEGL*)(obj))
-
-typedef struct _GstGLDisplayEGL GstGLDisplayEGL;
-typedef struct _GstGLDisplayEGLClass GstGLDisplayEGLClass;
-
-/**
- * GstGLDisplayEGL:
- *
- * the contents of a #GstGLDisplayEGL are private and should only be accessed
- * through the provided API
- */
-struct _GstGLDisplayEGL
-{
- GstGLDisplay parent;
-
- /* <private> */
- gpointer display;
-
- gboolean foreign_display;
-
- gpointer _padding[GST_PADDING];
-};
-
-struct _GstGLDisplayEGLClass
-{
- GstGLDisplayClass object_class;
-
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GstGLDisplayEGL *gst_gl_display_egl_new (void);
-
-GST_EXPORT
-GstGLDisplayEGL *gst_gl_display_egl_new_with_egl_display (gpointer display);
-
-GST_EXPORT
-GstGLDisplayEGL *gst_gl_display_egl_from_gl_display (GstGLDisplay * display);
-
-GST_EXPORT
-gpointer gst_gl_display_egl_get_from_native (GstGLDisplayType type, guintptr display);
-
-#define GST_GL_DISPLAY_EGL_NAME "gst.gl.display.egl"
-
-G_END_DECLS
-
-#endif /* __GST_GL_DISPLAY_EGL_H__ */
diff --git a/gst-libs/gst/gl/egl/gstglmemoryegl.c b/gst-libs/gst/gl/egl/gstglmemoryegl.c
deleted file mode 100644
index 1f461149d..000000000
--- a/gst-libs/gst/gl/egl/gstglmemoryegl.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Collabora Ltd.
- * @author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
- * Copyright (C) 2014 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2015 Igalia
- * Author: Gwang Yoon Hwang <yoon@igalia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstglmemoryegl
- * @short_description: memory subclass for EGLImage's
- * @see_also: #GstGLMemory, #GstGLAllocator, #GstGLBufferPool
- *
- * #GstGLMemoryEGL is created or wrapped through gst_gl_base_memory_alloc()
- * with #GstGLVideoAllocationParams.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "gstglmemoryegl.h"
-
-#include <gst/gl/gstglfuncs.h>
-
-#include "gstegl.h"
-#include "gsteglimage.h"
-#include "gstglcontext_egl.h"
-
-static GstAllocator *_gl_memory_egl_allocator;
-
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_MEMORY);
-#define GST_CAT_DEFAULT GST_CAT_GL_MEMORY
-
-#define parent_class gst_gl_memory_egl_allocator_parent_class
-G_DEFINE_TYPE (GstGLMemoryEGLAllocator, gst_gl_memory_egl_allocator,
- GST_TYPE_GL_MEMORY_ALLOCATOR);
-
-/**
- * gst_is_gl_memory_egl:
- * @mem: a #GstMemory to test
- *
- * Returns: whether @mem is a #GstGLMemoryEGL
- *
- * Since: 1.10
- */
-gboolean
-gst_is_gl_memory_egl (GstMemory * mem)
-{
- return mem != NULL && mem->allocator != NULL
- && g_type_is_a (G_OBJECT_TYPE (mem->allocator),
- GST_TYPE_GL_MEMORY_EGL_ALLOCATOR);
-}
-
-static GstGLMemoryEGL *
-_gl_mem_get_parent (GstGLMemoryEGL * gl_mem)
-{
- GstGLMemoryEGL *parent = (GstGLMemoryEGL *) gl_mem->mem.mem.mem.parent;
- return parent ? parent : gl_mem;
-}
-
-/**
- * gst_gl_memory_egl_get_image:
- * @mem: a #GstGLMemoryEGL
- *
- * Returns: The EGLImage held by @mem
- *
- * Since: 1.10
- */
-gpointer
-gst_gl_memory_egl_get_image (GstGLMemoryEGL * mem)
-{
- g_return_val_if_fail (gst_is_gl_memory_egl (GST_MEMORY_CAST (mem)),
- EGL_NO_IMAGE_KHR);
- return gst_egl_image_get_image (_gl_mem_get_parent (mem)->image);
-}
-
-/**
- * gst_gl_memory_egl_get_display:
- * @mem: a #GstGLMemoryEGL
- *
- * Returns: The EGLDisplay @mem is associated with
- *
- * Since: 1.10
- */
-gpointer
-gst_gl_memory_egl_get_display (GstGLMemoryEGL * mem)
-{
- g_return_val_if_fail (gst_is_gl_memory_egl (GST_MEMORY_CAST (mem)), NULL);
- return GST_GL_CONTEXT_EGL (_gl_mem_get_parent (mem)->mem.mem.
- context)->egl_display;
-}
-
-static GstMemory *
-_gl_mem_alloc (GstAllocator * allocator, gsize size,
- GstAllocationParams * params)
-{
- g_warning ("Use gst_gl_base_memory_allocator_alloc() to allocate from this "
- "GstGLMemoryEGL allocator");
-
- return NULL;
-}
-
-static void
-_gl_mem_destroy (GstGLMemoryEGL * mem)
-{
- if (mem->image)
- gst_egl_image_unref (mem->image);
-
- GST_GL_BASE_MEMORY_ALLOCATOR_CLASS (parent_class)->destroy ((GstGLBaseMemory
- *) mem);
-}
-
-static GstGLMemoryEGL *
-_gl_mem_egl_alloc (GstGLBaseMemoryAllocator * allocator,
- GstGLVideoAllocationParams * params)
-{
- guint alloc_flags = params->parent.alloc_flags;
- GstGLMemoryEGL *mem;
-
- g_return_val_if_fail (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
- NULL);
- g_return_val_if_fail ((alloc_flags &
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM) == 0, NULL);
- if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
- g_return_val_if_fail (GST_IS_EGL_IMAGE (params->parent.gl_handle), NULL);
- }
-
- mem = g_new0 (GstGLMemoryEGL, 1);
- if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
- if (params->target != GST_GL_TEXTURE_TARGET_2D) {
- g_free (mem);
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "GstGLMemoryEGL only supports wrapping "
- "2D textures");
- return NULL;
- }
- mem->image = gst_egl_image_ref (params->parent.gl_handle);
- }
-
- gst_gl_memory_init (GST_GL_MEMORY_CAST (mem), GST_ALLOCATOR_CAST (allocator),
- NULL, params->parent.context, params->target, params->tex_format,
- params->parent.alloc_params, params->v_info, params->plane,
- params->valign, params->parent.user_data, params->parent.notify);
-
- if (!mem->image) {
- gst_allocator_free (GST_ALLOCATOR_CAST (allocator), GST_MEMORY_CAST (mem));
- return NULL;
- }
-
- return mem;
-}
-
-static gboolean
-_gl_mem_create (GstGLMemoryEGL * gl_mem, GError ** error)
-{
- GstGLContext *context = gl_mem->mem.mem.context;
- const GstGLFuncs *gl = context->gl_vtable;
- GstGLBaseMemoryAllocatorClass *alloc_class;
-
- if (!gst_gl_context_check_feature (GST_GL_CONTEXT (context),
- "EGL_KHR_image_base")) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_WRONG_API,
- "EGL_KHR_image_base is not supported");
- return FALSE;
- }
-
- alloc_class = GST_GL_BASE_MEMORY_ALLOCATOR_CLASS (parent_class);
- if (!alloc_class->create ((GstGLBaseMemory *) gl_mem, error))
- return FALSE;
-
- if (gl_mem->image == NULL) {
- gl_mem->image = gst_egl_image_from_texture (context,
- (GstGLMemory *) gl_mem, NULL);
-
- if (!gl_mem->image) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "Failed to create EGLImage");
- return FALSE;
- }
- } else {
- gl->ActiveTexture (GL_TEXTURE0 + gl_mem->mem.plane);
- gl->BindTexture (GL_TEXTURE_2D, gl_mem->mem.tex_id);
- gl->EGLImageTargetTexture2D (GL_TEXTURE_2D,
- gst_egl_image_get_image (GST_EGL_IMAGE (gl_mem->image)));
- }
-
- return TRUE;
-}
-
-static GstMemory *
-_gl_mem_copy (GstGLMemoryEGL * src, gssize offset, gssize size)
-{
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "GstGLMemoryEGL does not support copy");
- return NULL;
-}
-
-static void
-gst_gl_memory_egl_allocator_class_init (GstGLMemoryEGLAllocatorClass * klass)
-{
- GstGLBaseMemoryAllocatorClass *gl_base;
- GstGLMemoryAllocatorClass *gl_tex;
- GstAllocatorClass *allocator_class;
-
- gl_tex = (GstGLMemoryAllocatorClass *) klass;
- gl_base = (GstGLBaseMemoryAllocatorClass *) klass;
- allocator_class = (GstAllocatorClass *) klass;
-
- gl_base->alloc = (GstGLBaseMemoryAllocatorAllocFunction) _gl_mem_egl_alloc;
- gl_base->create = (GstGLBaseMemoryAllocatorCreateFunction) _gl_mem_create;
- gl_base->destroy = (GstGLBaseMemoryAllocatorDestroyFunction) _gl_mem_destroy;
- gl_tex->copy = (GstGLBaseMemoryAllocatorCopyFunction) _gl_mem_copy;
-
- allocator_class->alloc = _gl_mem_alloc;
-}
-
-static void
-gst_gl_memory_egl_allocator_init (GstGLMemoryEGLAllocator * allocator)
-{
- GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator);
-
- alloc->mem_type = GST_GL_MEMORY_EGL_ALLOCATOR_NAME;
-
- GST_OBJECT_FLAG_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC);
-}
-
-/**
- * gst_gl_memory_egl_init_once:
- *
- * Initializes the GL Memory allocator. It is safe to call this function
- * multiple times. This must be called before any other GstGLMemoryEGL operation.
- *
- * Since: 1.10
- */
-void
-gst_gl_memory_egl_init_once (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- gst_gl_memory_init_once ();
-
- GST_DEBUG_CATEGORY_INIT (GST_CAT_GL_MEMORY, "glmemory", 0,
- "OpenGL Texture with EGLImage memory");
-
- _gl_memory_egl_allocator =
- g_object_new (GST_TYPE_GL_MEMORY_EGL_ALLOCATOR, NULL);
- gst_object_ref_sink (_gl_memory_egl_allocator);
-
- /* The allocator is never unreffed */
- GST_OBJECT_FLAG_SET (_gl_memory_egl_allocator,
- GST_OBJECT_FLAG_MAY_BE_LEAKED);
-
- gst_allocator_register (GST_GL_MEMORY_EGL_ALLOCATOR_NAME,
- gst_object_ref (_gl_memory_egl_allocator));
- g_once_init_leave (&_init, 1);
- }
-}
diff --git a/gst-libs/gst/gl/egl/gstglmemoryegl.h b/gst-libs/gst/gl/egl/gstglmemoryegl.h
deleted file mode 100644
index 098e7cf0d..000000000
--- a/gst-libs/gst/gl/egl/gstglmemoryegl.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Collabora Ltd.
- * @author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
- * Copyright (C) 2014 Julien Isorce <julien.isorce@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_GL_MEMORY_EGL_H_
-#define _GST_GL_MEMORY_EGL_H_
-
-#include <gst/gl/gstglmemory.h>
-#include <gst/gl/egl/gsteglimage.h>
-#include <gst/gl/egl/gstgldisplay_egl.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_MEMORY_EGL_ALLOCATOR (gst_gl_memory_egl_allocator_get_type())
-GST_EXPORT GType gst_gl_memory_egl_allocator_get_type(void);
-
-#define GST_IS_GL_MEMORY_EGL_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_MEMORY_EGL_ALLOCATOR))
-#define GST_IS_GL_MEMORY_EGL_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GL_MEMORY_EGL_ALLOCATOR))
-#define GST_GL_MEMORY_EGL_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GL_MEMORY_EGL_ALLOCATOR, GstGLMemoryEGLAllocatorClass))
-#define GST_GL_MEMORY_EGL_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_MEMORY_EGL_ALLOCATOR, GstGLMemoryEGLAllocator))
-#define GST_GL_MEMORY_EGL_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_MEMORY_EGL_ALLOCATOR, GstGLAllocatorClass))
-#define GST_GL_MEMORY_EGL_ALLOCATOR_CAST(obj) ((GstGLMemoryEGLAllocator *)(obj))
-
-/**
- * GstGLMemoryEGL:
- *
- * Private instance
- */
-struct _GstGLMemoryEGL
-{
- /* <private> */
- GstGLMemory mem;
-
- GstEGLImage *image;
-
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GST_GL_MEMORY_EGL_ALLOCATOR_NAME:
- *
- * The name of the GL Memory EGL allocator
- */
-#define GST_GL_MEMORY_EGL_ALLOCATOR_NAME "GLMemoryEGL"
-
-GST_EXPORT
-void gst_gl_memory_egl_init_once (void);
-
-GST_EXPORT
-gboolean gst_is_gl_memory_egl (GstMemory * mem);
-
-GST_EXPORT
-gpointer gst_gl_memory_egl_get_image (GstGLMemoryEGL * mem);
-
-GST_EXPORT
-gpointer gst_gl_memory_egl_get_display (GstGLMemoryEGL * mem);
-
-/**
- * GstGLMemoryEGLAllocator
- *
- * Opaque #GstGLMemoryEGLAllocator struct
- */
-struct _GstGLMemoryEGLAllocator
-{
- /* <private> */
-
- GstGLMemoryAllocator parent;
-
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GstGLMemoryEGLAllocatorClass:
- *
- * The #GstGLMemoryEGLAllocatorClass only contains private data
- */
-struct _GstGLMemoryEGLAllocatorClass
-{
- /* <private> */
- GstGLMemoryAllocatorClass parent_class;
-
- gpointer _padding[GST_PADDING];
-};
-
-G_END_DECLS
-
-#endif /* _GST_GL_MEMORY_EGL_H_ */
diff --git a/gst-libs/gst/gl/gl.h b/gst-libs/gst/gl/gl.h
deleted file mode 100644
index 33d1f3578..000000000
--- a/gst-libs/gst/gl/gl.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Julien Isorce <julien.isorce@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_H__
-#define __GST_GL_H__
-
-#ifndef GST_USE_UNSTABLE_API
-#warning "The GL library from gst-plugins-bad is unstable API and may change in future."
-#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
-#endif
-
-#include <gst/gl/gstgl_fwd.h>
-#include <gst/gl/gstglapi.h>
-#include <gst/gl/gstglconfig.h>
-#include <gst/gl/gstglcontext.h>
-#include <gst/gl/gstgldebug.h>
-#include <gst/gl/gstgldisplay.h>
-#include <gst/gl/gstglfeature.h>
-#include <gst/gl/gstglformat.h>
-#include <gst/gl/gstglutils.h>
-#include <gst/gl/gstglwindow.h>
-#include <gst/gl/gstglslstage.h>
-#include <gst/gl/gstglshader.h>
-#include <gst/gl/gstglshaderstrings.h>
-#include <gst/gl/gstglcolorconvert.h>
-#include <gst/gl/gstglupload.h>
-#include <gst/gl/gstglbasememory.h>
-#include <gst/gl/gstglbuffer.h>
-#include <gst/gl/gstglmemory.h>
-#include <gst/gl/gstglmemorypbo.h>
-#include <gst/gl/gstglrenderbuffer.h>
-#include <gst/gl/gstglbufferpool.h>
-#include <gst/gl/gstglframebuffer.h>
-#include <gst/gl/gstglbasefilter.h>
-#include <gst/gl/gstglviewconvert.h>
-#include <gst/gl/gstglfilter.h>
-#include <gst/gl/gstglsyncmeta.h>
-#include <gst/gl/gstgloverlaycompositor.h>
-#include <gst/gl/gstglquery.h>
-
-#endif /* __GST_GL_H__ */
diff --git a/gst-libs/gst/gl/glprototypes/Makefile.am b/gst-libs/gst/gl/glprototypes/Makefile.am
deleted file mode 100644
index 54ebc27ce..000000000
--- a/gst-libs/gst/gl/glprototypes/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-prototypedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl/glprototypes
-
-prototype_HEADERS = \
- all_functions.h \
- base.h \
- blending.h \
- eglimage.h \
- fbo.h \
- fixedfunction.h \
- gles.h \
- opengl.h \
- shaders.h \
- gstgl_compat.h \
- gstgl_gles2compat.h \
- debug.h \
- vao.h \
- sync.h \
- buffers.h \
- query.h
-
diff --git a/gst-libs/gst/gl/glprototypes/README b/gst-libs/gst/gl/glprototypes/README
deleted file mode 100644
index fbd911e6d..000000000
--- a/gst-libs/gst/gl/glprototypes/README
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/* Original files and function definitions courtesy of cogl
- *
- * Changes:
- * - Namespace COGL -> GST_GL
- * - remove gl from each function (i.e. glTexImage2D -> TexImage2D)
- **/
-
-/* The files in this folder are included multiple times with different
- * definitions for these macros. The macros are given the following arguments:
- *
- * GST_GL_EXT_BEGIN:
- *
- * @name: a unique symbol name for this feature
- *
- * @min_gl_major: the major part of the minimum GL version where these
- * functions are available in core, or 255 if it isn't available in
- * any version.
- * @min_gl_minor: the minor part of the minimum GL version where these
- * functions are available in core, or 255 if it isn't available in
- * any version.
- *
- * @gles_availability: flags to specify which versions of GLES the
- * functions are available in. Should be a combination of
- * GST_GL_API_GLES and GST_GL_API_GLES2.
- *
- * @extension_suffixes: A zero-separated list of suffixes in a
- * string. These are appended to the extension name to get a complete
- * extension name to try. The suffix is also appended to all of the
- * function names. The suffix can optionally include a ':' to specify
- * an alternate suffix for the function names.
- *
- * @extension_names: A list of extension names to try. If any of these
- * extensions match then it will be used.
- */
diff --git a/gst-libs/gst/gl/glprototypes/all_functions.h b/gst-libs/gst/gl/glprototypes/all_functions.h
deleted file mode 100644
index 9f7e4f112..000000000
--- a/gst-libs/gst/gl/glprototypes/all_functions.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "base.h"
-#include "blending.h"
-#include "eglimage.h"
-#include "fbo.h"
-#include "fixedfunction.h"
-#include "gles.h"
-#include "opengl.h"
-#include "shaders.h"
-#include "debug.h"
-#include "vao.h"
-#include "sync.h"
-#include "buffers.h"
-#include "query.h"
diff --git a/gst-libs/gst/gl/glprototypes/base.h b/gst-libs/gst/gl/glprototypes/base.h
deleted file mode 100644
index 8394a3872..000000000
--- a/gst-libs/gst/gl/glprototypes/base.h
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-/*
- * Cogl
- *
- * An object oriented GL/GLES Abstraction/Utility Layer
- *
- * Copyright (C) 2009, 2011 Intel Corporation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-/* These are the core GL functions which we assume will always be
- available */
-GST_GL_EXT_BEGIN (core,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES1 | GST_GL_API_GLES2,
- 1, 0,
- 1, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, BindTexture,
- (GLenum target, GLuint texture))
-GST_GL_EXT_FUNCTION (void, BlendFunc,
- (GLenum sfactor, GLenum dfactor))
-GST_GL_EXT_FUNCTION (void, Clear,
- (GLbitfield mask))
-GST_GL_EXT_FUNCTION (void, ClearColor,
- (GLclampf red,
- GLclampf green,
- GLclampf blue,
- GLclampf alpha))
-GST_GL_EXT_FUNCTION (void, ClearStencil,
- (GLint s))
-GST_GL_EXT_FUNCTION (void, ColorMask,
- (GLboolean red,
- GLboolean green,
- GLboolean blue,
- GLboolean alpha))
-GST_GL_EXT_FUNCTION (void, CopyTexSubImage2D,
- (GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLint x,
- GLint y,
- GLsizei width,
- GLsizei height))
-GST_GL_EXT_FUNCTION (void, DeleteTextures,
- (GLsizei n, const GLuint* textures))
-GST_GL_EXT_FUNCTION (void, DepthFunc,
- (GLenum func))
-GST_GL_EXT_FUNCTION (void, DepthMask,
- (GLboolean flag))
-GST_GL_EXT_FUNCTION (void, Disable,
- (GLenum cap))
-GST_GL_EXT_FUNCTION (void, DrawArrays,
- (GLenum mode, GLint first, GLsizei count))
-GST_GL_EXT_FUNCTION (void, DrawElements,
- (GLenum mode,
- GLsizei count,
- GLenum type,
- const GLvoid* indices))
-GST_GL_EXT_FUNCTION (void, Enable,
- (GLenum cap))
-GST_GL_EXT_FUNCTION (void, Finish,
- (void))
-GST_GL_EXT_FUNCTION (void, Flush,
- (void))
-GST_GL_EXT_FUNCTION (void, FrontFace,
- (GLenum mode))
-GST_GL_EXT_FUNCTION (void, CullFace,
- (GLenum mode))
-GST_GL_EXT_FUNCTION (void, GenTextures,
- (GLsizei n, GLuint* textures))
-GST_GL_EXT_FUNCTION (GLenum, GetError,
- (void))
-GST_GL_EXT_FUNCTION (void, GetIntegerv,
- (GLenum pname, GLint* params))
-GST_GL_EXT_FUNCTION (void, GetBooleanv,
- (GLenum pname, GLboolean* params))
-GST_GL_EXT_FUNCTION (void, GetFloatv,
- (GLenum pname, GLfloat* params))
-GST_GL_EXT_FUNCTION (const GLubyte*, GetString,
- (GLenum name))
-GST_GL_EXT_FUNCTION (void, Hint,
- (GLenum target, GLenum mode))
-GST_GL_EXT_FUNCTION (GLboolean, IsTexture,
- (GLuint texture))
-GST_GL_EXT_FUNCTION (void, PixelStorei,
- (GLenum pname, GLint param))
-GST_GL_EXT_FUNCTION (void, ReadPixels,
- (GLint x,
- GLint y,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- GLvoid* pixels))
-GST_GL_EXT_FUNCTION (void, Scissor,
- (GLint x, GLint y, GLsizei width, GLsizei height))
-GST_GL_EXT_FUNCTION (void, StencilFunc,
- (GLenum func, GLint ref, GLuint mask))
-GST_GL_EXT_FUNCTION (void, StencilMask,
- (GLuint mask))
-GST_GL_EXT_FUNCTION (void, StencilOp,
- (GLenum fail, GLenum zfail, GLenum zpass))
-GST_GL_EXT_FUNCTION (void, TexImage2D,
- (GLenum target,
- GLint level,
- GLint internalformat,
- GLsizei width,
- GLsizei height,
- GLint border,
- GLenum format,
- GLenum type,
- const GLvoid* pixels))
-GST_GL_EXT_FUNCTION (void, TexParameterfv,
- (GLenum target, GLenum pname, const GLfloat* params))
-GST_GL_EXT_FUNCTION (void, TexParameteri,
- (GLenum target, GLenum pname, GLint param))
-GST_GL_EXT_FUNCTION (void, TexParameteriv,
- (GLenum target, GLenum pname, const GLint* params))
-GST_GL_EXT_FUNCTION (void, GetTexParameterfv,
- (GLenum target, GLenum pname, GLfloat* params))
-GST_GL_EXT_FUNCTION (void, GetTexParameteriv,
- (GLenum target, GLenum pname, GLint* params))
-GST_GL_EXT_FUNCTION (void, TexSubImage2D,
- (GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- const GLvoid* pixels))
-GST_GL_EXT_FUNCTION (void, CopyTexImage2D,
- (GLenum target,
- GLint level,
- GLenum internalformat,
- GLint x,
- GLint y,
- GLsizei width,
- GLsizei height,
- GLint border))
-GST_GL_EXT_FUNCTION (void, Viewport,
- (GLint x, GLint y, GLsizei width, GLsizei height))
-GST_GL_EXT_FUNCTION (GLboolean, IsEnabled, (GLenum cap))
-GST_GL_EXT_FUNCTION (void, LineWidth, (GLfloat width))
-GST_GL_EXT_FUNCTION (void, PolygonOffset, (GLfloat factor, GLfloat units))
-GST_GL_EXT_FUNCTION (void, TexParameterf,
- (GLenum target,
- GLenum pname,
- GLfloat param))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (texture_3d,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3,
- 1, 2,
- 255, 255, /* not in either GLES */
- "OES\0",
- "texture_3D\0")
-GST_GL_EXT_FUNCTION (void, TexImage3D,
- (GLenum target, GLint level,
- GLint internalFormat,
- GLsizei width, GLsizei height,
- GLsizei depth, GLint border,
- GLenum format, GLenum type,
- const GLvoid *pixels))
-GST_GL_EXT_FUNCTION (void, TexSubImage3D,
- (GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint zoffset, GLsizei width,
- GLsizei height, GLsizei depth,
- GLenum format,
- GLenum type, const GLvoid *pixels))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (only_in_both_gles_and_gl_1_3,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES1 | GST_GL_API_GLES2,
- 1, 3,
- 1, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, CompressedTexImage2D,
- (GLenum target,
- GLint level,
- GLenum internalformat,
- GLsizei width,
- GLsizei height,
- GLint border,
- GLsizei imageSize,
- const GLvoid* data))
-GST_GL_EXT_FUNCTION (void, CompressedTexSubImage2D,
- (GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLsizei imageSize,
- const GLvoid* data))
-GST_GL_EXT_FUNCTION (void, SampleCoverage,
- (GLclampf value, GLboolean invert))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (only_in_both_gles_and_gl_1_5,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES1 | GST_GL_API_GLES2,
- 1, 5,
- 1, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, GetBufferParameteriv,
- (GLenum target, GLenum pname, GLint* params))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (vbos,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES1 | GST_GL_API_GLES2,
- 1, 5,
- 1, 0,
- "ARB\0",
- "vertex_buffer_object\0")
-GST_GL_EXT_FUNCTION (void, GenBuffers,
- (GLsizei n,
- GLuint *buffers))
-GST_GL_EXT_FUNCTION (void, BindBuffer,
- (GLenum target,
- GLuint buffer))
-GST_GL_EXT_FUNCTION (void, BufferData,
- (GLenum target,
- GLsizeiptr size,
- const GLvoid *data,
- GLenum usage))
-GST_GL_EXT_FUNCTION (void, BufferSubData,
- (GLenum target,
- GLintptr offset,
- GLsizeiptr size,
- const GLvoid *data))
-GST_GL_EXT_FUNCTION (void, DeleteBuffers,
- (GLsizei n,
- const GLuint *buffers))
-GST_GL_EXT_FUNCTION (GLboolean, IsBuffer,
- (GLuint buffer))
-GST_GL_EXT_END ()
-
-/* Available in GL 1.3, the multitexture extension or GLES. These are
- required */
-GST_GL_EXT_BEGIN (multitexture_part0,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES1 | GST_GL_API_GLES2,
- 1, 3,
- 1, 0,
- "ARB\0",
- "multitexture\0")
-GST_GL_EXT_FUNCTION (void, ActiveTexture,
- (GLenum texture))
-GST_GL_EXT_END ()
-
-
- /* GLES doesn't support mapping buffers in core so this has to be a
- separate check */
-GST_GL_EXT_BEGIN (map_vbos,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3,
- 1, 5,
- 255, 255, /* not in GLES core */
- "ARB\0OES\0",
- "vertex_buffer_object\0mapbuffer\0")
-GST_GL_EXT_FUNCTION (void *, MapBuffer,
- (GLenum target,
- GLenum access))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (unmap_buffer,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2,
- 1, 5,
- 3, 0,
- "ARB\0OES\0",
- "vertex_buffer_object\0mapbuffer\0")
-GST_GL_EXT_FUNCTION (GLboolean, UnmapBuffer,
- (GLenum target))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (gl3,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 3, 0,
- 3, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (const GLubyte*, GetStringi,
- (GLenum name, GLint index))
-GST_GL_EXT_FUNCTION (void *, MapBufferRange,
- (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/glprototypes/blending.h b/gst-libs/gst/gl/glprototypes/blending.h
deleted file mode 100644
index 8ea514880..000000000
--- a/gst-libs/gst/gl/glprototypes/blending.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-/*
- * Cogl
- *
- * An object oriented GL/GLES Abstraction/Utility Layer
- *
- * Copyright (C) 2009, 2011 Intel Corporation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-GST_GL_EXT_BEGIN (blending,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 1, 2,
- 2, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, BlendEquation,
- (GLenum mode))
-GST_GL_EXT_FUNCTION (void, BlendColor,
- (GLclampf red,
- GLclampf green,
- GLclampf blue,
- GLclampf alpha))
-GST_GL_EXT_END ()
-
-/* Optional, declared in 1.4 or GLES 1.2 */
-GST_GL_EXT_BEGIN (blend_func_separate,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 1, 4,
- 2, 0,
- "EXT\0",
- "blend_func_separate\0")
-GST_GL_EXT_FUNCTION (void, BlendFuncSeparate,
- (GLenum srcRGB,
- GLenum dstRGB,
- GLenum srcAlpha,
- GLenum dstAlpha))
-GST_GL_EXT_END ()
-
-/* Optional, declared in 2.0 */
-GST_GL_EXT_BEGIN (blend_equation_separate,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 2, 0,
- 2, 0,
- "EXT\0",
- "blend_equation_separate\0")
-GST_GL_EXT_FUNCTION (void, BlendEquationSeparate,
- (GLenum modeRGB,
- GLenum modeAlpha))
-GST_GL_EXT_END ()
-
-/* GL and GLES 2.0 apis */
-GST_GL_EXT_BEGIN (two_point_zero_api,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 2, 0,
- 2, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, StencilFuncSeparate,
- (GLenum face, GLenum func, GLint ref, GLuint mask))
-GST_GL_EXT_FUNCTION (void, StencilMaskSeparate,
- (GLenum face, GLuint mask))
-GST_GL_EXT_FUNCTION (void, StencilOpSeparate,
- (GLenum face, GLenum fail, GLenum zfail, GLenum zpass))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/glprototypes/buffers.h b/gst-libs/gst/gl/glprototypes/buffers.h
deleted file mode 100644
index 5e73c624f..000000000
--- a/gst-libs/gst/gl/glprototypes/buffers.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-GST_GL_EXT_BEGIN (buffer_copy_sub_data,
- GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 3, 1,
- 3, 0,
- /* extension is available in GL 3.0 */
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, CopyBufferSubData,
- (GLenum readTarget,
- GLenum writeTarget,
- GLintptr readOffset,
- GLintptr writeOffset,
- GLsizeiptr size))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (get_buffer_sub_data,
- GST_GL_API_OPENGL3,
- 1, 5,
- 255, 255,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, GetBufferSubData,
- (GLenum target,
- GLintptr offset,
- GLsizeiptr size,
- void * data))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/glprototypes/debug.h b/gst-libs/gst/gl/glprototypes/debug.h
deleted file mode 100644
index 135d4e672..000000000
--- a/gst-libs/gst/gl/glprototypes/debug.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-GST_GL_EXT_BEGIN (debug,
- GST_GL_API_OPENGL3,
- 4, 3,
- 255, 255,
- "KHR:\0KHR\0ARB\0",
- "debug\0debug_output\0")
-GST_GL_EXT_FUNCTION (void, DebugMessageControl,
- (GLenum source,
- GLenum type,
- GLenum severity,
- GLsizei count,
- const GLuint* ids,
- gboolean enabled))
-GST_GL_EXT_FUNCTION (void, DebugMessageInsert,
- (GLenum source,
- GLenum type,
- GLuint id,
- GLenum severity,
- GLsizei length,
- const gchar *message))
-GST_GL_EXT_FUNCTION (void, DebugMessageCallback,
- (GST_GL_DEBUG_PROC callback,
- gpointer user_data))
-GST_GL_EXT_FUNCTION (GLuint, GetDebugMessageLog,
- (GLuint count,
- GLsizei bufSize,
- GLenum* sources,
- GLenum* types,
- GLuint* ids,
- GLenum* severities,
- GLsizei* lengths,
- gchar* messageLog))
-GST_GL_EXT_FUNCTION (void, GetPointerv,
- (GLenum pname,
- gpointer * params))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (khr_debug,
- GST_GL_API_OPENGL3,
- 4, 3,
- 255, 255,
- "KHR:\0KHR\0",
- "debug\0")
-GST_GL_EXT_FUNCTION (void, PushDebugGroup,
- (GLenum source,
- GLuint id,
- GLsizei length,
- const gchar * message))
-GST_GL_EXT_FUNCTION (void, PopDebugGroup, (void))
-GST_GL_EXT_FUNCTION (void, ObjectLabel,
- (GLenum identifier,
- GLuint name,
- GLsizei length,
- const gchar *label))
-GST_GL_EXT_FUNCTION (void, GetObjectLabel,
- (GLenum identifier,
- GLuint name,
- GLsizei bufSize,
- GLsizei *length,
- gchar *label))
-GST_GL_EXT_FUNCTION (void, ObjectPtrLabel,
- (gpointer ptr,
- GLsizei length,
- const gchar *label))
-GST_GL_EXT_FUNCTION (void, GetObjectPtrLabel,
- (gpointer ptr,
- GLsizei bufSize,
- GLsizei *length,
- gchar *label))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (ext_debug_marker,
- GST_GL_API_NONE,
- 255, 255,
- 255, 255,
- "EXT\0",
- "debug_marker\0")
-GST_GL_EXT_FUNCTION (void, InsertEventMarker,
- (GLsizei length,
- const gchar * message))
-GST_GL_EXT_FUNCTION (void, PushGroupMarker,
- (GLsizei length,
- const gchar * message))
-GST_GL_EXT_FUNCTION (void, PopGroupMarker,
- (void))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (gremedy_string_marker,
- GST_GL_API_NONE,
- 255, 255,
- 255, 255,
- "GREMEDY\0",
- "string_marker\0")
-GST_GL_EXT_FUNCTION (void, StringMarker,
- (GLsizei length,
- const gchar * message))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/glprototypes/eglimage.h b/gst-libs/gst/gl/glprototypes/eglimage.h
deleted file mode 100644
index 0256003b0..000000000
--- a/gst-libs/gst/gl/glprototypes/eglimage.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-/*
- * Cogl
- *
- * An object oriented GL/GLES Abstraction/Utility Layer
- *
- * Copyright (C) 2009, 2011 Intel Corporation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-GST_GL_EXT_BEGIN (EGL_image,
- GST_GL_API_NONE,
- 255, 255,
- 255, 255, /* not in either GLES */
- "OES\0",
- "EGL_image\0")
-GST_GL_EXT_FUNCTION (void, EGLImageTargetTexture2D,
- (GLenum target,
- GLeglImageOES image))
-GST_GL_EXT_FUNCTION (void, EGLImageTargetRenderbufferStorage,
- (GLenum target,
- GLeglImageOES image))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/glprototypes/fbo.h b/gst-libs/gst/gl/glprototypes/fbo.h
deleted file mode 100644
index f210f997d..000000000
--- a/gst-libs/gst/gl/glprototypes/fbo.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-/*
- * Cogl
- *
- * An object oriented GL/GLES Abstraction/Utility Layer
- *
- * Copyright (C) 2009, 2011 Intel Corporation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-GST_GL_EXT_BEGIN (offscreen,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 3, 0,
- 2, 0,
- /* for some reason the ARB version of this
- extension doesn't have an ARB suffix for the
- functions */
- "ARB:\0EXT\0OES\0",
- "framebuffer_object\0")
-GST_GL_EXT_FUNCTION (void, GenRenderbuffers,
- (GLsizei n,
- GLuint *renderbuffers))
-GST_GL_EXT_FUNCTION (void, DeleteRenderbuffers,
- (GLsizei n,
- const GLuint *renderbuffers))
-GST_GL_EXT_FUNCTION (void, BindRenderbuffer,
- (GLenum target,
- GLuint renderbuffer))
-GST_GL_EXT_FUNCTION (void, RenderbufferStorage,
- (GLenum target,
- GLenum internalformat,
- GLsizei width,
- GLsizei height))
-GST_GL_EXT_FUNCTION (void, GenFramebuffers,
- (GLsizei n,
- GLuint *framebuffers))
-GST_GL_EXT_FUNCTION (void, BindFramebuffer,
- (GLenum target,
- GLuint framebuffer))
-GST_GL_EXT_FUNCTION (void, FramebufferTexture2D,
- (GLenum target,
- GLenum attachment,
- GLenum textarget,
- GLuint texture,
- GLint level))
-GST_GL_EXT_FUNCTION (void, FramebufferRenderbuffer,
- (GLenum target,
- GLenum attachment,
- GLenum renderbuffertarget,
- GLuint renderbuffer))
-GST_GL_EXT_FUNCTION (GLboolean, IsRenderbuffer,
- (GLuint renderbuffer))
-GST_GL_EXT_FUNCTION (GLenum, CheckFramebufferStatus,
- (GLenum target))
-GST_GL_EXT_FUNCTION (void, DeleteFramebuffers,
- (GLsizei n,
- const GLuint *framebuffers))
-GST_GL_EXT_FUNCTION (void, GenerateMipmap,
- (GLenum target))
-GST_GL_EXT_FUNCTION (void, GetFramebufferAttachmentParameteriv,
- (GLenum target,
- GLenum attachment,
- GLenum pname,
- GLint *params))
-GST_GL_EXT_FUNCTION (void, GetRenderbufferParameteriv,
- (GLenum target,
- GLenum pname,
- GLint *params))
-GST_GL_EXT_FUNCTION (GLboolean, IsFramebuffer,
- (GLuint framebuffer))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (offscreen_blit,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 3, 0,
- 3, 0,
- "EXT\0ANGLE\0",
- "framebuffer_blit\0")
-GST_GL_EXT_FUNCTION (void, BlitFramebuffer,
- (GLint srcX0,
- GLint srcY0,
- GLint srcX1,
- GLint srcY1,
- GLint dstX0,
- GLint dstY0,
- GLint dstX1,
- GLint dstY1,
- GLbitfield mask,
- GLenum filter))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (framebuffer_discard,
- GST_GL_API_NONE,
- 255, 255,
- 255, 255, /* not in either GLES */
- "EXT\0",
- "framebuffer_discard\0")
-GST_GL_EXT_FUNCTION (void, DiscardFramebuffer,
- (GLenum target,
- GLsizei numAttachments,
- const GLenum *attachments))
-GST_GL_EXT_END ()
-
-
-GST_GL_EXT_BEGIN (read_buffer,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 1, 0,
- 3, 0,
- "NV\0",
- "read_buffer\0")
-GST_GL_EXT_FUNCTION (void, ReadBuffer,
- (GLenum mode))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (draw_buffers,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 2, 1,
- 3, 0,
- "ARB\0ATI\0NV\0",
- "draw_buffers\0")
-GST_GL_EXT_FUNCTION (void, DrawBuffers,
- (GLsizei n, const GLenum *bufs))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/glprototypes/fixedfunction.h b/gst-libs/gst/gl/glprototypes/fixedfunction.h
deleted file mode 100644
index 3aecbd227..000000000
--- a/gst-libs/gst/gl/glprototypes/fixedfunction.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-/*
- * Cogl
- *
- * An object oriented GL/GLES Abstraction/Utility Layer
- *
- * Copyright (C) 2009, 2011 Intel Corporation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-GST_GL_EXT_BEGIN (multitexture_part1,
- GST_GL_API_OPENGL |
- GST_GL_API_GLES1,
- 1, 3,
- 1, 0,
- "ARB\0",
- "multitexture\0")
-GST_GL_EXT_FUNCTION (void, ClientActiveTexture,
- (GLenum texture))
-GST_GL_EXT_END ()
-
-/* These are the core GL functions which are available when the API
- supports fixed-function (ie, GL and GLES1.1) */
-GST_GL_EXT_BEGIN (fixed_function_core,
- GST_GL_API_OPENGL |
- GST_GL_API_GLES1,
- 0, 0,
- 1, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, AlphaFunc,
- (GLenum func, GLclampf ref))
-GST_GL_EXT_FUNCTION (void, Fogf,
- (GLenum pname, GLfloat param))
-GST_GL_EXT_FUNCTION (void, Fogfv,
- (GLenum pname, const GLfloat *params))
-GST_GL_EXT_FUNCTION (void, LoadMatrixf,
- (const GLfloat *m))
-GST_GL_EXT_FUNCTION (void, Materialfv,
- (GLenum face, GLenum pname, const GLfloat *params))
-GST_GL_EXT_FUNCTION (void, PointSize,
- (GLfloat size))
-GST_GL_EXT_FUNCTION (void, TexEnvfv,
- (GLenum target, GLenum pname, const GLfloat *params))
-GST_GL_EXT_FUNCTION (void, Color4ub,
- (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
-GST_GL_EXT_FUNCTION (void, ColorPointer,
- (GLint size,
- GLenum type,
- GLsizei stride,
- const GLvoid *pointer))
-GST_GL_EXT_FUNCTION (void, DisableClientState,
- (GLenum array))
-GST_GL_EXT_FUNCTION (void, EnableClientState,
- (GLenum array))
-GST_GL_EXT_FUNCTION (void, LoadIdentity,
- (void))
-GST_GL_EXT_FUNCTION (void, MatrixMode,
- (GLenum mode))
-GST_GL_EXT_FUNCTION (void, NormalPointer,
- (GLenum type, GLsizei stride, const GLvoid *pointer))
-GST_GL_EXT_FUNCTION (void, TexCoordPointer,
- (GLint size,
- GLenum type,
- GLsizei stride,
- const GLvoid *pointer))
-GST_GL_EXT_FUNCTION (void, TexEnvi,
- (GLenum target,
- GLenum pname,
- GLint param))
-GST_GL_EXT_FUNCTION (void, VertexPointer,
- (GLint size,
- GLenum type,
- GLsizei stride,
- const GLvoid *pointer))
-GST_GL_EXT_FUNCTION (void, PushMatrix,
- (void))
-GST_GL_EXT_FUNCTION (void, PopMatrix,
- (void))
-GST_GL_EXT_END ()
-
-/* Eventually we want to remove this category */
-GST_GL_EXT_BEGIN (fixed_function_gl_only,
- GST_GL_API_OPENGL,
- 0, 0,
- 0, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, PushAttrib,
- (GLbitfield mask))
-GST_GL_EXT_FUNCTION (void, PopAttrib,
- (void))
-GST_GL_EXT_FUNCTION (void, TexImage1D,
- (GLenum target,
- GLint level,
- GLint internalFormat,
- GLsizei width,
- GLint border,
- GLenum format,
- GLenum type,
- const GLvoid *data))
-GST_GL_EXT_FUNCTION (void, Rotatef,
- (GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
-GST_GL_EXT_FUNCTION (void, Translatef,
- (GLfloat x, GLfloat y, GLfloat z))
-GST_GL_EXT_FUNCTION (void, Scalef,
- (GLfloat x, GLfloat y, GLfloat z))
-GST_GL_EXT_FUNCTION (void, Lightfv,
- (GLenum light, GLenum pname, const GLfloat *params))
-GST_GL_EXT_FUNCTION (void, ColorMaterial,
- (GLenum face, GLenum pname))
-GST_GL_EXT_FUNCTION (void, ShadeModel,
- (GLenum value))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/glprototypes/gles.h b/gst-libs/gst/gl/glprototypes/gles.h
deleted file mode 100644
index 7d1cd8871..000000000
--- a/gst-libs/gst/gl/glprototypes/gles.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-/*
- * Cogl
- *
- * An object oriented GL/GLES Abstraction/Utility Layer
- *
- * Copyright (C) 2009, 2011 Intel Corporation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-GST_GL_EXT_BEGIN (only_in_both_gles,
- GST_GL_API_GLES1 |
- GST_GL_API_GLES2,
- 255, 255,
- 1, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, DepthRangef,
- (GLfloat near_val, GLfloat far_val))
-GST_GL_EXT_FUNCTION (void, ClearDepthf,
- (GLclampf depth))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (only_in_gles1,
- GST_GL_API_GLES1,
- 255, 255,
- 1, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, ClipPlanef, (GLenum plane, const GLfloat *equation))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (gles2_only_api,
- GST_GL_API_GLES2,
- 255, 255,
- 2, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, ReleaseShaderCompiler, (void))
-GST_GL_EXT_FUNCTION (void, GetShaderPrecisionFormat,
- (GLenum shadertype,
- GLenum precisiontype,
- GLint* range,
- GLint* precision))
-GST_GL_EXT_FUNCTION (void, ShaderBinary,
- (GLsizei n,
- const GLuint* shaders,
- GLenum binaryformat,
- const GLvoid* binary,
- GLsizei length))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (IMG_multisampled_render_to_texture,
- GST_GL_API_NONE,
- 255, 255,
- 255, 255, /* not in either GLES */
- "\0",
- "IMG_multisampled_render_to_texture\0")
-GST_GL_EXT_FUNCTION (void, RenderbufferStorageMultisampleIMG,
- (GLenum target,
- GLsizei samples,
- GLenum internal_format,
- GLsizei width,
- GLsizei height))
-GST_GL_EXT_FUNCTION (void, FramebufferTexture2DMultisampleIMG,
- (GLenum target,
- GLenum attachment,
- GLenum textarget,
- GLuint texture,
- GLint level,
- GLsizei samples))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/glprototypes/gstgl_compat.h b/gst-libs/gst/gl/glprototypes/gstgl_compat.h
deleted file mode 100644
index 31b1e005d..000000000
--- a/gst-libs/gst/gl/glprototypes/gstgl_compat.h
+++ /dev/null
@@ -1,67 +0,0 @@
- /*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_COMPAT_H__
-#define __GST_GL_COMPAT_H__
-
-#include <gst/gl/gstglconfig.h>
-
-/* undefined typedefs */
-#if !GST_GL_HAVE_GLEGLIMAGEOES
-typedef gpointer GLeglImageOES;
-#endif
-#if !GST_GL_HAVE_GLCHAR
-typedef gchar GLchar;
-#endif
-#if !GST_GL_HAVE_GLSIZEIPTR
-typedef ptrdiff_t GLsizeiptr;
-#endif
-#if !GST_GL_HAVE_GLINTPTR
-typedef ptrdiff_t GLintptr;
-#endif
-#if !GST_GL_HAVE_GLSYNC
-typedef gpointer GLsync;
-#endif
-#if !GST_GL_HAVE_GLUINT64
-typedef guint64 GLuint64;
-#endif
-#if !GST_GL_HAVE_GLINT64
-typedef gint64 GLint64;
-#endif
-
-#if !defined(GST_GL_DEBUG_PROC)
-#if defined(GLDEBUGPROC)
-#define GST_GL_DEBUG_PROC GLDEBUGPROC
-#elif defined(GLDEBUGPROCARB)
-#define GST_GL_DEBUG_PROC GLDEBUGPROCARB
-#elif defined(GLDEBUGPROCKHR)
-#define GST_GL_DEBUG_PROC GLDEBUGPROCKHR
-#else
-typedef void (GSTGLAPI *GST_GL_DEBUG_PROC) (GLenum source,
- GLenum type,
- GLuint id,
- GLenum severity,
- GLsizei length,
- const gchar* message,
- gpointer user_data);
-#endif
-#endif
-
-#endif
diff --git a/gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h b/gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h
deleted file mode 100644
index 6dfd2c3b2..000000000
--- a/gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/* Compatibility for OpenGL ES 2.0 */
-
-#ifndef __GST_GL_ES2__
-#define __GST_GL_ES2__
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-#ifndef GL_RGB16
-#define GL_RGB16 GL_RGB565
-#endif
-#ifndef GL_RGB8
-#define GL_RGB8 GL_RGB
-#endif
-
-/* UNSUPPORTED */
-
-#ifndef GL_COLOR_ATTACHMENT1
-#define GL_COLOR_ATTACHMENT1 0x8CE1
-#endif
-#ifndef GL_COLOR_ATTACHMENT2
-#define GL_COLOR_ATTACHMENT2 0x8CE2
-#endif
-#ifndef GL_TEXTURE_ENV
-#define GL_TEXTURE_ENV 0
-#endif
-#ifndef GL_TEXTURE_ENV_MODE
-#define GL_TEXTURE_ENV_MODE 0
-#endif
-#ifndef GL_DEPTH24_STENCIL8
-#define GL_DEPTH24_STENCIL8 0x88F0
-#endif
-
-G_END_DECLS
-
-#endif /* __GST_GL_ES2__ */
diff --git a/gst-libs/gst/gl/glprototypes/opengl.h b/gst-libs/gst/gl/glprototypes/opengl.h
deleted file mode 100644
index ac47d5280..000000000
--- a/gst-libs/gst/gl/glprototypes/opengl.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-/*
- * Cogl
- *
- * An object oriented GL/GLES Abstraction/Utility Layer
- *
- * Copyright (C) 2009, 2011 Intel Corporation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* These are the core GL functions which are only available in big
- GL */
-GST_GL_EXT_BEGIN (only_in_big_gl,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3,
- 1, 0,
- 255, 255, /* not in GLES */
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, GetTexLevelParameteriv,
- (GLenum target, GLint level,
- GLenum pname, GLint *params))
-GST_GL_EXT_FUNCTION (void, GetTexImage,
- (GLenum target, GLint level,
- GLenum format, GLenum type,
- GLvoid *pixels))
-GST_GL_EXT_FUNCTION (void, DepthRange,
- (double near_val, double far_val))
-GST_GL_EXT_FUNCTION (void, DrawBuffer,
- (GLenum mode))
-GST_GL_EXT_FUNCTION (void, ClearDepth,
- (double depth))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (only_in_big_gl_compat,
- GST_GL_API_OPENGL,
- 1, 0,
- 255, 255, /* not in GLES */
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, ClipPlane,
- (GLenum plane, const double *equation))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/glprototypes/query.h b/gst-libs/gst/gl/glprototypes/query.h
deleted file mode 100644
index 09f1ba23f..000000000
--- a/gst-libs/gst/gl/glprototypes/query.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2016 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-GST_GL_EXT_BEGIN (timer_query,
- GST_GL_API_OPENGL3,
- 3, 3,
- 3, 0,
- "ARB:\0ANGLE\0EXT\0",
- "timer_query\0disjoint_timer_query\0")
-GST_GL_EXT_FUNCTION (void, GenQueries,
- (GLsizei n,
- GLuint *ids))
-GST_GL_EXT_FUNCTION (void, DeleteQueries,
- (GLsizei n,
- GLuint *ids))
-GST_GL_EXT_FUNCTION (GLboolean, IsQuery,
- (GLuint id))
-GST_GL_EXT_FUNCTION (void, BeginQuery,
- (GLenum target,
- GLuint id))
-GST_GL_EXT_FUNCTION (void, EndQuery,
- (GLenum target))
-GST_GL_EXT_FUNCTION (void, QueryCounter,
- (GLuint id,
- GLenum target))
-GST_GL_EXT_FUNCTION (void, GetQueryiv,
- (GLenum target,
- GLenum pname,
- GLint *params))
-GST_GL_EXT_FUNCTION (void, GetQueryObjectiv,
- (GLuint id,
- GLenum pname,
- GLint *params))
-GST_GL_EXT_FUNCTION (void, GetQueryObjectuiv,
- (GLuint id,
- GLenum pname,
- GLuint *params))
-GST_GL_EXT_FUNCTION (void, GetQueryObjecti64v,
- (GLuint id,
- GLenum pname,
- GLint64 *params))
-GST_GL_EXT_FUNCTION (void, GetQueryObjectui64v,
- (GLuint id,
- GLenum pname,
- GLuint64 *params))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/glprototypes/shaders.h b/gst-libs/gst/gl/glprototypes/shaders.h
deleted file mode 100644
index 6d828dbac..000000000
--- a/gst-libs/gst/gl/glprototypes/shaders.h
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-/*
- * Cogl
- *
- * An object oriented GL/GLES Abstraction/Utility Layer
- *
- * Copyright (C) 2009, 2011 Intel Corporation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* This lists functions that are unique to GL 2.0 or GLES 2.0 and are
- * not in the old GLSL extensions */
-GST_GL_EXT_BEGIN (shaders_glsl_2_only,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 2, 0,
- 2, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (GLuint, CreateProgram,
- (void))
-GST_GL_EXT_FUNCTION (GLuint, CreateShader,
- (GLenum shaderType))
-GST_GL_EXT_FUNCTION (void, DeleteShader,
- (GLuint shader))
-GST_GL_EXT_FUNCTION (void, AttachShader,
- (GLuint program,
- GLuint shader))
-GST_GL_EXT_FUNCTION (void, UseProgram,
- (GLuint program))
-GST_GL_EXT_FUNCTION (void, DeleteProgram,
- (GLuint program))
-GST_GL_EXT_FUNCTION (void, GetShaderInfoLog,
- (GLuint shader,
- GLsizei maxLength,
- GLsizei *length,
- char *infoLog))
-GST_GL_EXT_FUNCTION (void, GetProgramInfoLog,
- (GLuint program,
- GLsizei bufSize,
- GLsizei *length,
- char *infoLog))
-GST_GL_EXT_FUNCTION (void, GetShaderiv,
- (GLuint shader,
- GLenum pname,
- GLint *params))
-GST_GL_EXT_FUNCTION (void, GetProgramiv,
- (GLuint program,
- GLenum pname,
- GLint *params))
-GST_GL_EXT_FUNCTION (void, DetachShader,
- (GLuint program, GLuint shader))
-GST_GL_EXT_FUNCTION (void, GetAttachedShaders,
- (GLuint program,
- GLsizei maxcount,
- GLsizei* count,
- GLuint* shaders))
-GST_GL_EXT_FUNCTION (GLboolean, IsShader,
- (GLuint shader))
-GST_GL_EXT_FUNCTION (GLboolean, IsProgram,
- (GLuint program))
-GST_GL_EXT_END ()
-
-/* These functions are provided by GL_ARB_shader_objects or are in GL
- * 2.0 core */
-GST_GL_EXT_BEGIN (shader_objects_or_gl2,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 2, 0,
- 2, 0,
- "ARB\0",
- "shader_objects\0")
-GST_GL_EXT_FUNCTION (void, ShaderSource,
- (GLuint shader,
- GLsizei count,
- const char **string,
- const GLint *length))
-GST_GL_EXT_FUNCTION (void, CompileShader,
- (GLuint shader))
-GST_GL_EXT_FUNCTION (void, LinkProgram,
- (GLuint program))
-GST_GL_EXT_FUNCTION (GLint, GetUniformLocation,
- (GLuint program,
- const char *name))
-GST_GL_EXT_FUNCTION (void, Uniform1f,
- (GLint location,
- GLfloat v0))
-GST_GL_EXT_FUNCTION (void, Uniform2f,
- (GLint location,
- GLfloat v0,
- GLfloat v1))
-GST_GL_EXT_FUNCTION (void, Uniform3f,
- (GLint location,
- GLfloat v0,
- GLfloat v1,
- GLfloat v2))
-GST_GL_EXT_FUNCTION (void, Uniform4f,
- (GLint location,
- GLfloat v0,
- GLfloat v1,
- GLfloat v2,
- GLfloat v3))
-GST_GL_EXT_FUNCTION (void, Uniform1fv,
- (GLint location,
- GLsizei count,
- const GLfloat * value))
-GST_GL_EXT_FUNCTION (void, Uniform2fv,
- (GLint location,
- GLsizei count,
- const GLfloat * value))
-GST_GL_EXT_FUNCTION (void, Uniform3fv,
- (GLint location,
- GLsizei count,
- const GLfloat * value))
-GST_GL_EXT_FUNCTION (void, Uniform4fv,
- (GLint location,
- GLsizei count,
- const GLfloat * value))
-GST_GL_EXT_FUNCTION (void, Uniform1i,
- (GLint location,
- GLint v0))
-GST_GL_EXT_FUNCTION (void, Uniform2i,
- (GLint location,
- GLint v0,
- GLint v1))
-GST_GL_EXT_FUNCTION (void, Uniform3i,
- (GLint location,
- GLint v0,
- GLint v1,
- GLint v2))
-GST_GL_EXT_FUNCTION (void, Uniform4i,
- (GLint location,
- GLint v0,
- GLint v1,
- GLint v2,
- GLint v3))
-GST_GL_EXT_FUNCTION (void, Uniform1iv,
- (GLint location,
- GLsizei count,
- const GLint * value))
-GST_GL_EXT_FUNCTION (void, Uniform2iv,
- (GLint location,
- GLsizei count,
- const GLint * value))
-GST_GL_EXT_FUNCTION (void, Uniform3iv,
- (GLint location,
- GLsizei count,
- const GLint * value))
-GST_GL_EXT_FUNCTION (void, Uniform4iv,
- (GLint location,
- GLsizei count,
- const GLint * value))
-GST_GL_EXT_FUNCTION (void, UniformMatrix2fv,
- (GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat *value))
-GST_GL_EXT_FUNCTION (void, UniformMatrix3fv,
- (GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat *value))
-GST_GL_EXT_FUNCTION (void, UniformMatrix4fv,
- (GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat *value))
-
-GST_GL_EXT_FUNCTION (void, GetUniformfv,
- (GLuint program,
- GLint location,
- GLfloat *params))
-GST_GL_EXT_FUNCTION (void, GetUniformiv,
- (GLuint program,
- GLint location,
- GLint *params))
-GST_GL_EXT_FUNCTION (void, GetActiveUniform,
- (GLuint program,
- GLuint index,
- GLsizei bufsize,
- GLsizei* length,
- GLint* size,
- GLenum* type,
- GLchar* name))
-GST_GL_EXT_FUNCTION (void, GetShaderSource,
- (GLuint shader,
- GLsizei bufsize,
- GLsizei* length,
- GLchar* source))
-GST_GL_EXT_FUNCTION (void, ValidateProgram, (GLuint program))
-GST_GL_EXT_END ()
-
-/* These functions are provided by GL_ARB_vertex_shader or are in GL
- * 2.0 core */
-GST_GL_EXT_BEGIN (vertex_shaders,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 2, 0,
- 2, 0,
- "ARB\0",
- "vertex_shader\0")
-GST_GL_EXT_FUNCTION (void, VertexAttribPointer,
- (GLuint index,
- GLint size,
- GLenum type,
- GLboolean normalized,
- GLsizei stride,
- const GLvoid *pointer))
-GST_GL_EXT_FUNCTION (void, EnableVertexAttribArray,
- (GLuint index))
-GST_GL_EXT_FUNCTION (void, DisableVertexAttribArray,
- (GLuint index))
-GST_GL_EXT_FUNCTION (void, VertexAttrib1f, (GLuint indx, GLfloat x))
-GST_GL_EXT_FUNCTION (void, VertexAttrib1fv,
- (GLuint indx, const GLfloat* values))
-GST_GL_EXT_FUNCTION (void, VertexAttrib2f, (GLuint indx, GLfloat x, GLfloat y))
-GST_GL_EXT_FUNCTION (void, VertexAttrib2fv,
- (GLuint indx, const GLfloat* values))
-GST_GL_EXT_FUNCTION (void, VertexAttrib3f,
- (GLuint indx, GLfloat x, GLfloat y, GLfloat z))
-GST_GL_EXT_FUNCTION (void, VertexAttrib3fv,
- (GLuint indx, const GLfloat* values))
-GST_GL_EXT_FUNCTION (void, VertexAttrib4f,
- (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w))
-GST_GL_EXT_FUNCTION (void, VertexAttrib4fv,
- (GLuint indx, const GLfloat* values))
-GST_GL_EXT_FUNCTION (void, GetVertexAttribfv,
- (GLuint index, GLenum pname, GLfloat* params))
-GST_GL_EXT_FUNCTION (void, GetVertexAttribiv,
- (GLuint index, GLenum pname, GLint* params))
-GST_GL_EXT_FUNCTION (void, GetVertexAttribPointerv,
- (GLuint index, GLenum pname, GLvoid** pointer))
-GST_GL_EXT_FUNCTION (GLint, GetAttribLocation,
- (GLuint program, const char *name))
-GST_GL_EXT_FUNCTION (void, BindAttribLocation,
- (GLuint program,
- GLuint index,
- const GLchar* name))
-GST_GL_EXT_FUNCTION (void, GetActiveAttrib,
- (GLuint program,
- GLuint index,
- GLsizei bufsize,
- GLsizei* length,
- GLint* size,
- GLenum* type,
- GLchar* name))
-GST_GL_EXT_END ()
-
-/* These only list functions that come from the old GLSL extensions.
- * Functions that are common to the extensions and GLSL 2.0 should
- * instead be listed in cogl-glsl-functions.h */
-GST_GL_EXT_BEGIN (shader_objects,
- GST_GL_API_NONE,
- 255, 255,
- 255, 255, /* not in either GLES */
- "ARB\0",
- "shader_objects\0")
-GST_GL_EXT_FUNCTION (GLuint, CreateProgramObject,
- (void))
-GST_GL_EXT_FUNCTION (GLuint, CreateShaderObject,
- (GLenum shaderType))
-GST_GL_EXT_FUNCTION (void, DeleteObject,
- (GLuint obj))
-GST_GL_EXT_FUNCTION (void, AttachObject,
- (GLuint container, GLuint obj))
-GST_GL_EXT_FUNCTION (void, UseProgramObject,
- (GLuint programObj))
-GST_GL_EXT_FUNCTION (void, GetInfoLog,
- (GLuint obj,
- GLsizei maxLength,
- GLsizei *length,
- char *infoLog))
-GST_GL_EXT_FUNCTION (void, GetObjectParameteriv,
- (GLuint obj,
- GLenum pname,
- GLint *params))
-GST_GL_EXT_FUNCTION (void, DetachObject,
- (GLuint container, GLuint obj))
-GST_GL_EXT_FUNCTION (void, GetAttachedObjects,
- (GLuint program,
- GLsizei maxcount,
- GLsizei* count,
- GLuint* shaders))
-GST_GL_EXT_END ()
-
-/* ARB_fragment_program */
-GST_GL_EXT_BEGIN (arbfp,
- GST_GL_API_NONE,
- 255, 255,
- 255, 255, /* not in either GLES */
- "ARB\0",
- "fragment_program\0")
-GST_GL_EXT_FUNCTION (void, GenPrograms,
- (GLsizei n,
- GLuint *programs))
-GST_GL_EXT_FUNCTION (void, DeletePrograms,
- (GLsizei n,
- GLuint *programs))
-GST_GL_EXT_FUNCTION (void, BindProgram,
- (GLenum target,
- GLuint program))
-GST_GL_EXT_FUNCTION (void, ProgramString,
- (GLenum target,
- GLenum format,
- GLsizei len,
- const void *program))
-GST_GL_EXT_FUNCTION (void, ProgramLocalParameter4fv,
- (GLenum target,
- GLuint index,
- GLfloat *params))
-GST_GL_EXT_END ()
-
-/* This lists functions that are unique to GL 2.1 or GLES 3.0 and are
- * not in the old GLSL extensions */
-GST_GL_EXT_BEGIN (shaders_2_1,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 |
- GST_GL_API_GLES2,
- 2, 1,
- 3, 0,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, UniformMatrix2x3fv,
- (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
-GST_GL_EXT_FUNCTION (void, UniformMatrix3x2fv,
- (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
-GST_GL_EXT_FUNCTION (void, UniformMatrix2x4fv,
- (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
-GST_GL_EXT_FUNCTION (void, UniformMatrix4x2fv,
- (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
-GST_GL_EXT_FUNCTION (void, UniformMatrix3x4fv,
- (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
-GST_GL_EXT_FUNCTION (void, UniformMatrix4x3fv,
- (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
-GST_GL_EXT_END ()
-
-GST_GL_EXT_BEGIN (bind_frag_data,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3,
- 3, 0,
- 255, 255,
- "\0",
- "\0")
-GST_GL_EXT_FUNCTION (void, BindFragDataLocation,
- (GLuint program, GLuint index, const GLchar * name))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/glprototypes/sync.h b/gst-libs/gst/gl/glprototypes/sync.h
deleted file mode 100644
index 30c60e44c..000000000
--- a/gst-libs/gst/gl/glprototypes/sync.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014-2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-GST_GL_EXT_BEGIN (sync,
- GST_GL_API_OPENGL3 | GST_GL_API_GLES2,
- 3, 2,
- 3, 0,
- "APPLE\0",
- "sync\0")
-GST_GL_EXT_FUNCTION (GLsync, FenceSync,
- (GLenum condition,
- GLbitfield flags))
-GST_GL_EXT_FUNCTION (GLboolean, IsSync,
- (GLsync sync))
-GST_GL_EXT_FUNCTION (void, DeleteSync,
- (GLsync sync))
-GST_GL_EXT_FUNCTION (GLenum, ClientWaitSync,
- (GLsync sync,
- GLbitfield flags,
- GLuint64 timeout))
-GST_GL_EXT_FUNCTION (void, WaitSync,
- (GLsync sync,
- GLbitfield flags,
- GLuint64 timeout))
-GST_GL_EXT_FUNCTION (void, GetSynciv,
- (GLsync sync,
- GLenum flags,
- GLuint64 timeout))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/glprototypes/vao.h b/gst-libs/gst/gl/glprototypes/vao.h
deleted file mode 100644
index 32d11599f..000000000
--- a/gst-libs/gst/gl/glprototypes/vao.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-GST_GL_EXT_BEGIN (vao,
- GST_GL_API_OPENGL3 | GST_GL_API_GLES2,
- 3, 0,
- 3, 0,
- "ARB:\0OES\0",
- "vertex_array_object\0")
-GST_GL_EXT_FUNCTION (void, GenVertexArrays,
- (GLsizei n,
- GLuint *arrays))
-GST_GL_EXT_FUNCTION (void, DeleteVertexArrays,
- (GLsizei n,
- GLuint *arrays))
-GST_GL_EXT_FUNCTION (void, BindVertexArray,
- (GLuint array))
-GST_GL_EXT_FUNCTION (GLboolean, IsVertexArray,
- (GLuint array))
-GST_GL_EXT_END ()
diff --git a/gst-libs/gst/gl/gstgl_enums.h b/gst-libs/gst/gl/gstgl_enums.h
deleted file mode 100644
index 25c7b39ac..000000000
--- a/gst-libs/gst/gl/gstgl_enums.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_GL_ENUMS_H_
-#define _GST_GL_ENUMS_H_
-
-/**
- * GstGLTextureTarget:
- * @GST_GL_TEXTURE_TARGET_NONE: no texture target
- * @GST_GL_TEXTURE_TARGET_2D: 2D texture target
- * @GST_GL_TEXTURE_TARGET_RECTANGLE: rectangle texture target
- * @GST_GL_TEXTURE_TARGET_EXTERNAL_OES: external oes texture target
- *
- * Since: 1.8
- */
-typedef enum
-{
- GST_GL_TEXTURE_TARGET_NONE,
- GST_GL_TEXTURE_TARGET_2D,
- GST_GL_TEXTURE_TARGET_RECTANGLE,
- GST_GL_TEXTURE_TARGET_EXTERNAL_OES,
-} GstGLTextureTarget;
-
-#endif /* _GST_GL_ENUMS_H_ */
diff --git a/gst-libs/gst/gl/gstgl_fwd.h b/gst-libs/gst/gl/gstgl_fwd.h
deleted file mode 100644
index 19ca6f358..000000000
--- a/gst-libs/gst/gl/gstgl_fwd.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Julien Isorce <julien.isorce@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_FWD_H__
-#define __GST_GL_FWD_H__
-
-#include <gst/gst.h>
-
-#include <gst/gl/gstglapi.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GstGLDisplay GstGLDisplay;
-typedef struct _GstGLDisplayClass GstGLDisplayClass;
-typedef struct _GstGLDisplayPrivate GstGLDisplayPrivate;
-
-typedef struct _GstGLContext GstGLContext;
-typedef struct _GstGLContextClass GstGLContextClass;
-typedef struct _GstGLContextPrivate GstGLContextPrivate;
-
-typedef struct _GstGLWindow GstGLWindow;
-typedef struct _GstGLWindowPrivate GstGLWindowPrivate;
-typedef struct _GstGLWindowClass GstGLWindowClass;
-
-typedef struct _GstGLBaseMemory GstGLBaseMemory;
-typedef struct _GstGLBaseMemoryAllocator GstGLBaseMemoryAllocator;
-typedef struct _GstGLBaseMemoryAllocatorClass GstGLBaseMemoryAllocatorClass;
-
-typedef struct _GstGLBuffer GstGLBuffer;
-typedef struct _GstGLBufferAllocator GstGLBufferAllocator;
-typedef struct _GstGLBufferAllocatorClass GstGLBufferAllocatorClass;
-
-typedef struct _GstGLMemory GstGLMemory;
-typedef struct _GstGLMemoryAllocator GstGLMemoryAllocator;
-typedef struct _GstGLMemoryAllocatorClass GstGLMemoryAllocatorClass;
-
-typedef struct _GstGLMemoryPBO GstGLMemoryPBO;
-typedef struct _GstGLMemoryPBOAllocator GstGLMemoryPBOAllocator;
-typedef struct _GstGLMemoryPBOAllocatorClass GstGLMemoryPBOAllocatorClass;
-
-typedef struct _GstGLMemoryEGL GstGLMemoryEGL;
-typedef struct _GstGLMemoryEGLAllocator GstGLMemoryEGLAllocator;
-typedef struct _GstGLMemoryEGLAllocatorClass GstGLMemoryEGLAllocatorClass;
-
-typedef struct _GstGLRenderbuffer GstGLRenderbuffer;
-typedef struct _GstGLRenderbufferAllocator GstGLRenderbufferAllocator;
-typedef struct _GstGLRenderbufferAllocatorClass GstGLRenderbufferAllocatorClass;
-
-typedef struct _GstGLFramebuffer GstGLFramebuffer;
-typedef struct _GstGLFramebufferClass GstGLFramebufferClass;
-
-typedef struct _GstGLSLStage GstGLSLStage;
-typedef struct _GstGLSLStagePrivate GstGLSLStagePrivate;
-typedef struct _GstGLSLStageClass GstGLSLStageClass;
-
-typedef struct _GstGLShader GstGLShader;
-typedef struct _GstGLShaderPrivate GstGLShaderPrivate;
-typedef struct _GstGLShaderClass GstGLShaderClass;
-
-typedef struct _GstGLUpload GstGLUpload;
-typedef struct _GstGLUploadClass GstGLUploadClass;
-typedef struct _GstGLUploadPrivate GstGLUploadPrivate;
-
-typedef struct _GstGLBufferPool GstGLBufferPool;
-typedef struct _GstGLBufferPoolClass GstGLBufferPoolClass;
-typedef struct _GstGLBufferPoolPrivate GstGLBufferPoolPrivate;
-
-typedef struct _GstGLColorConvert GstGLColorConvert;
-typedef struct _GstGLColorConvertClass GstGLColorConvertClass;
-typedef struct _GstGLColorConvertPrivate GstGLColorConvertPrivate;
-
-typedef struct _GstGLBaseFilter GstGLBaseFilter;
-typedef struct _GstGLBaseFilterClass GstGLBaseFilterClass;
-typedef struct _GstGLBaseFilterPrivate GstGLBaseFilterPrivate;
-
-typedef struct _GstGLFilter GstGLFilter;
-typedef struct _GstGLFilterClass GstGLFilterClass;
-
-typedef struct _GstGLViewConvert GstGLViewConvert;
-typedef struct _GstGLViewConvertClass GstGLViewConvertClass;
-typedef struct _GstGLViewConvertPrivate GstGLViewConvertPrivate;
-
-typedef struct _GstGLOverlayCompositor GstGLOverlayCompositor;
-typedef struct _GstGLOverlayCompositorClass GstGLOverlayCompositorClass;
-
-typedef struct _GstGLQuery GstGLQuery;
-
-typedef struct _GstGLFuncs GstGLFuncs;
-
-typedef struct _GstGLAsyncDebug GstGLAsyncDebug;
-
-#include <gst/gl/gstgl_enums.h>
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLBaseFilter, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLBaseMemoryAllocator, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLBufferAllocator, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLBufferPool, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLColorConvert, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLContext, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLDisplay, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLFilter, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLMemoryAllocator, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLMemoryPBOAllocator, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLOverlayCompositor, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLSLStage, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLShader, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLUpload, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLViewConvert, gst_object_unref)
-#endif
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLWindow, gst_object_unref)
-#endif
-
-G_END_DECLS
-
-#endif /* __GST_GL_FWD_H__ */
diff --git a/gst-libs/gst/gl/gstglapi.c b/gst-libs/gst/gl/gstglapi.c
deleted file mode 100644
index 6960a5545..000000000
--- a/gst-libs/gst/gl/gstglapi.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstglapi
- * @title: GstGLAPI
- * @short_description: OpenGL API specific functionality
- * @see_also: #GstGLDisplay, #GstGLContext
- *
- * Provides some helper API for dealing with OpenGL API's and platforms
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstglapi.h"
-
-/**
- * gst_gl_api_to_string:
- * @api: a #GstGLAPI to stringify
- *
- * Returns: A space seperated string of the OpenGL api's enabled in @api
- */
-gchar *
-gst_gl_api_to_string (GstGLAPI api)
-{
- GString *str = NULL;
- gchar *ret;
-
- if (api == GST_GL_API_NONE) {
- str = g_string_new ("none");
- goto out;
- } else if (api == GST_GL_API_ANY) {
- str = g_string_new ("any");
- goto out;
- }
-
- if (api & GST_GL_API_OPENGL) {
- str = g_string_new (GST_GL_API_OPENGL_NAME);
- }
- if (api & GST_GL_API_OPENGL3) {
- if (str) {
- g_string_append (str, " " GST_GL_API_OPENGL3_NAME);
- } else {
- str = g_string_new (GST_GL_API_OPENGL3_NAME);
- }
- }
- if (api & GST_GL_API_GLES1) {
- if (str) {
- g_string_append (str, " " GST_GL_API_GLES1_NAME);
- } else {
- str = g_string_new (GST_GL_API_GLES1_NAME);
- }
- }
- if (api & GST_GL_API_GLES2) {
- if (str) {
- g_string_append (str, " " GST_GL_API_GLES2_NAME);
- } else {
- str = g_string_new (GST_GL_API_GLES2_NAME);
- }
- }
-
-out:
- if (!str)
- str = g_string_new ("unknown");
-
- ret = g_string_free (str, FALSE);
- return ret;
-}
-
-/**
- * gst_gl_api_from_string:
- * @api_s: a space seperated string of OpenGL apis
- *
- * Returns: The #GstGLAPI represented by @api_s
- */
-GstGLAPI
-gst_gl_api_from_string (const gchar * apis_s)
-{
- GstGLAPI ret = GST_GL_API_NONE;
- gchar *apis = (gchar *) apis_s;
-
- if (!apis || apis[0] == '\0') {
- ret = GST_GL_API_ANY;
- } else {
- while (apis) {
- if (apis[0] == '\0') {
- break;
- } else if (apis[0] == ' ' || apis[0] == ',') {
- apis = &apis[1];
- } else if (g_strstr_len (apis, 7, GST_GL_API_OPENGL3_NAME)) {
- ret |= GST_GL_API_OPENGL3;
- apis = &apis[7];
- } else if (g_strstr_len (apis, 6, GST_GL_API_OPENGL_NAME)) {
- ret |= GST_GL_API_OPENGL;
- apis = &apis[6];
- } else if (g_strstr_len (apis, 5, GST_GL_API_GLES1_NAME)) {
- ret |= GST_GL_API_GLES1;
- apis = &apis[5];
- } else if (g_strstr_len (apis, 5, GST_GL_API_GLES2_NAME)) {
- ret |= GST_GL_API_GLES2;
- apis = &apis[5];
- } else {
- GST_ERROR ("Error parsing \'%s\'", apis);
- break;
- }
- }
- }
-
- return ret;
-}
-
-/**
- * gst_gl_platform_to_string:
- * @platform: a #GstGLPlatform to stringify
- *
- * Returns: A space seperated string of the OpenGL platforms enabled in @platform
- */
-gchar *
-gst_gl_platform_to_string (GstGLPlatform platform)
-{
- GString *str = NULL;
- gchar *ret;
-
- if (platform == GST_GL_PLATFORM_NONE) {
- str = g_string_new ("none");
- goto out;
- } else if (platform == GST_GL_PLATFORM_ANY) {
- str = g_string_new ("any");
- goto out;
- }
-
- str = g_string_new ("");
-
- if (platform & GST_GL_PLATFORM_GLX) {
- str = g_string_append (str, "glx ");
- }
- if (platform & GST_GL_PLATFORM_EGL) {
- str = g_string_append (str, "egl ");
- }
- if (platform & GST_GL_PLATFORM_WGL) {
- str = g_string_append (str, "wgl ");
- }
- if (platform & GST_GL_PLATFORM_CGL) {
- str = g_string_append (str, "cgl ");
- }
-
-out:
- if (!str)
- str = g_string_new ("unknown");
-
- ret = g_string_free (str, FALSE);
- return ret;
-}
-
-/**
- * gst_gl_platform_from_string:
- * @platform_s: a space seperated string of OpenGL platformss
- *
- * Returns: The #GstGLPlatform represented by @platform_s
- */
-GstGLPlatform
-gst_gl_platform_from_string (const gchar * platform_s)
-{
- GstGLPlatform ret = GST_GL_PLATFORM_NONE;
- gchar *platform = (gchar *) platform_s;
-
- if (!platform || platform[0] == '\0') {
- ret = GST_GL_PLATFORM_ANY;
- } else {
- while (platform) {
- if (platform[0] == '\0') {
- break;
- } else if (platform[0] == ' ' || platform[0] == ',') {
- platform = &platform[1];
- } else if (g_strstr_len (platform, 3, "glx")) {
- ret |= GST_GL_PLATFORM_GLX;
- platform = &platform[3];
- } else if (g_strstr_len (platform, 3, "egl")) {
- ret |= GST_GL_PLATFORM_EGL;
- platform = &platform[3];
- } else if (g_strstr_len (platform, 3, "wgl")) {
- ret |= GST_GL_PLATFORM_WGL;
- platform = &platform[3];
- } else if (g_strstr_len (platform, 3, "cgl")) {
- ret |= GST_GL_PLATFORM_CGL;
- platform = &platform[3];
- } else {
- GST_ERROR ("Error parsing \'%s\'", platform);
- break;
- }
- }
- }
-
- return ret;
-}
diff --git a/gst-libs/gst/gl/gstglapi.h b/gst-libs/gst/gl/gstglapi.h
deleted file mode 100644
index 1622d9095..000000000
--- a/gst-libs/gst/gl/gstglapi.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_API_H__
-#define __GST_GL_API_H__
-
-#include <gst/gl/gstglconfig.h>
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-/**
- * GstGLAPI:
- * @GST_GL_API_NONE: no API
- * @GST_GL_API_OPENGL: Desktop OpenGL up to and including 3.1. The
- * compatibility profile when the OpenGL version is >= 3.2
- * @GST_GL_API_OPENGL3: Desktop OpenGL >= 3.2 core profile
- * @GST_GL_API_GLES1: OpenGL ES 1.x
- * @GST_GL_API_GLES2: OpenGL ES 2.x and 3.x
- * @GST_GL_API_ANY: Any OpenGL API
- */
-typedef enum {
- GST_GL_API_NONE = 0,
- GST_GL_API_OPENGL = (1 << 0),
- GST_GL_API_OPENGL3 = (1 << 1),
- GST_GL_API_GLES1 = (1 << 15),
- GST_GL_API_GLES2 = (1 << 16),
-
- GST_GL_API_ANY = G_MAXUINT32
-} GstGLAPI;
-
-/**
- * GST_GL_API_OPENGL_NAME:
- *
- * The name for %GST_GL_API_OPENGL used in various places
- */
-#define GST_GL_API_OPENGL_NAME "opengl"
-
-/**
- * GST_GL_API_OPENGL3_NAME:
- *
- * The name for %GST_GL_API_OPENGL3 used in various places
- */
-#define GST_GL_API_OPENGL3_NAME "opengl3"
-
-/**
- * GST_GL_API_GLES1_NAME:
- *
- * The name for %GST_GL_API_GLES1 used in various places
- */
-#define GST_GL_API_GLES1_NAME "gles1"
-
-/**
- * GST_GL_API_GLES2_NAME:
- *
- * The name for %GST_GL_API_GLES2 used in various places
- */
-#define GST_GL_API_GLES2_NAME "gles2"
-
-/**
- * GstGLPlatform:
- * @GST_GL_PLATFORM_NONE: no platform
- * @GST_GL_PLATFORM_EGL: the EGL platform used primarily with the X11, wayland
- * and android window systems as well as on embedded Linux
- * @GST_GL_PLATFORM_GLX: the GLX platform used primarily with the X11 window system
- * @GST_GL_PLATFORM_WGL: the WGL platform used primarily on Windows
- * @GST_GL_PLATFORM_CGL: the CGL platform used primarily on OS X
- * @GST_GL_PLATFORM_EAGL: the EAGL platform used primarily on iOS
- * @GST_GL_PLATFORM_ANY: any OpenGL platform
- */
-typedef enum
-{
- GST_GL_PLATFORM_NONE = 0,
- GST_GL_PLATFORM_EGL = (1 << 0),
- GST_GL_PLATFORM_GLX = (1 << 1),
- GST_GL_PLATFORM_WGL = (1 << 2),
- GST_GL_PLATFORM_CGL = (1 << 3),
- GST_GL_PLATFORM_EAGL = (1 << 4),
-
- GST_GL_PLATFORM_ANY = G_MAXUINT32
-} GstGLPlatform;
-
-GST_EXPORT
-gchar * gst_gl_api_to_string (GstGLAPI api);
-GST_EXPORT
-GstGLAPI gst_gl_api_from_string (const gchar * api_s);
-
-GST_EXPORT
-gchar * gst_gl_platform_to_string (GstGLPlatform platform);
-GST_EXPORT
-GstGLPlatform gst_gl_platform_from_string (const gchar * platform_s);
-
-G_END_DECLS
-
-#endif /* __GST_GL_API_H__ */
diff --git a/gst-libs/gst/gl/gstglbasefilter.c b/gst-libs/gst/gl/gstglbasefilter.c
deleted file mode 100644
index 3c9eb9118..000000000
--- a/gst-libs/gst/gl/gstglbasefilter.c
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/video/gstvideometa.h>
-
-#include <gst/gl/gl.h>
-#include <gst/gl/gstglutils_private.h>
-
-/**
- * SECTION:gstglbasefilter
- * @short_description: #GstBaseTransform subclass for transforming OpenGL resources
- * @title: GstGLBaseFilter
- * @see_also: #GstBaseTransform
- *
- * #GstGLBaseFilter handles the nitty gritty details of retrieving an OpenGL
- * context. It also provided some wrappers around #GstBaseTransform's
- * start(), stop() and set_caps() virtual methods that ensure an OpenGL context
- * is available and current in the calling thread.
- */
-
-#define GST_CAT_DEFAULT gst_gl_base_filter_debug
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-
-#define GST_GL_BASE_FILTER_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_BASE_FILTER, GstGLBaseFilterPrivate))
-
-struct _GstGLBaseFilterPrivate
-{
- GstGLContext *other_context;
-
- gboolean gl_result;
- gboolean gl_started;
-};
-
-/* Properties */
-enum
-{
- PROP_0,
- PROP_CONTEXT
-};
-
-#define gst_gl_base_filter_parent_class parent_class
-G_DEFINE_TYPE_WITH_CODE (GstGLBaseFilter, gst_gl_base_filter,
- GST_TYPE_BASE_TRANSFORM, GST_DEBUG_CATEGORY_INIT (gst_gl_base_filter_debug,
- "glbasefilter", 0, "glbasefilter element"););
-
-static void gst_gl_base_filter_finalize (GObject * object);
-static void gst_gl_base_filter_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_gl_base_filter_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static void gst_gl_base_filter_set_context (GstElement * element,
- GstContext * context);
-static GstStateChangeReturn gst_gl_base_filter_change_state (GstElement *
- element, GstStateChange transition);
-static gboolean gst_gl_base_filter_query (GstBaseTransform * trans,
- GstPadDirection direction, GstQuery * query);
-static void gst_gl_base_filter_reset (GstGLBaseFilter * filter);
-static gboolean gst_gl_base_filter_start (GstBaseTransform * bt);
-static gboolean gst_gl_base_filter_stop (GstBaseTransform * bt);
-static gboolean gst_gl_base_filter_set_caps (GstBaseTransform * bt,
- GstCaps * incaps, GstCaps * outcaps);
-static gboolean gst_gl_base_filter_decide_allocation (GstBaseTransform * trans,
- GstQuery * query);
-
-/* GstGLContextThreadFunc */
-static void gst_gl_base_filter_gl_start (GstGLContext * context, gpointer data);
-static void gst_gl_base_filter_gl_stop (GstGLContext * context, gpointer data);
-
-static gboolean gst_gl_base_filter_default_gl_start (GstGLBaseFilter * filter);
-static void gst_gl_base_filter_default_gl_stop (GstGLBaseFilter * filter);
-
-static void
-gst_gl_base_filter_class_init (GstGLBaseFilterClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *element_class;
-
- g_type_class_add_private (klass, sizeof (GstGLBaseFilterPrivate));
-
- gobject_class = (GObjectClass *) klass;
- element_class = GST_ELEMENT_CLASS (klass);
-
- gobject_class->finalize = gst_gl_base_filter_finalize;
- gobject_class->set_property = gst_gl_base_filter_set_property;
- gobject_class->get_property = gst_gl_base_filter_get_property;
-
- GST_BASE_TRANSFORM_CLASS (klass)->query = gst_gl_base_filter_query;
- GST_BASE_TRANSFORM_CLASS (klass)->set_caps = gst_gl_base_filter_set_caps;
- GST_BASE_TRANSFORM_CLASS (klass)->start = gst_gl_base_filter_start;
- GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_base_filter_stop;
- GST_BASE_TRANSFORM_CLASS (klass)->decide_allocation =
- gst_gl_base_filter_decide_allocation;
-
- element_class->set_context = gst_gl_base_filter_set_context;
- element_class->change_state = gst_gl_base_filter_change_state;
-
- g_object_class_install_property (gobject_class, PROP_CONTEXT,
- g_param_spec_object ("context",
- "OpenGL context",
- "Get OpenGL context",
- GST_TYPE_GL_CONTEXT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- klass->supported_gl_api = GST_GL_API_ANY;
- klass->gl_start = gst_gl_base_filter_default_gl_start;
- klass->gl_stop = gst_gl_base_filter_default_gl_stop;
-}
-
-static void
-gst_gl_base_filter_init (GstGLBaseFilter * filter)
-{
- gst_base_transform_set_qos_enabled (GST_BASE_TRANSFORM (filter), TRUE);
-
- filter->priv = GST_GL_BASE_FILTER_GET_PRIVATE (filter);
-}
-
-static void
-gst_gl_base_filter_finalize (GObject * object)
-{
- GstGLBaseFilter *filter = GST_GL_BASE_FILTER (object);
-
- gst_caps_replace (&filter->in_caps, NULL);
- gst_caps_replace (&filter->out_caps, NULL);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-gst_gl_base_filter_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_gl_base_filter_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstGLBaseFilter *filter = GST_GL_BASE_FILTER (object);
-
- switch (prop_id) {
- case PROP_CONTEXT:
- g_value_set_object (value, filter->context);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_gl_base_filter_set_context (GstElement * element, GstContext * context)
-{
- GstGLBaseFilter *filter = GST_GL_BASE_FILTER (element);
- GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (filter);
-
- gst_gl_handle_set_context (element, context, &filter->display,
- &filter->priv->other_context);
- if (filter->display)
- gst_gl_display_filter_gl_api (filter->display,
- filter_class->supported_gl_api);
-
- GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
-}
-
-static gboolean
-_find_local_gl_context (GstGLBaseFilter * filter)
-{
- if (gst_gl_query_local_gl_context (GST_ELEMENT (filter), GST_PAD_SRC,
- &filter->context))
- return TRUE;
- if (gst_gl_query_local_gl_context (GST_ELEMENT (filter), GST_PAD_SINK,
- &filter->context))
- return TRUE;
- return FALSE;
-}
-
-static gboolean
-gst_gl_base_filter_query (GstBaseTransform * trans, GstPadDirection direction,
- GstQuery * query)
-{
- GstGLBaseFilter *filter = GST_GL_BASE_FILTER (trans);
-
- switch (GST_QUERY_TYPE (query)) {
- case GST_QUERY_ALLOCATION:
- {
- if (direction == GST_PAD_SINK
- && gst_base_transform_is_passthrough (trans)) {
- _find_local_gl_context (filter);
-
- return gst_pad_peer_query (GST_BASE_TRANSFORM_SRC_PAD (trans), query);
- }
- break;
- }
- case GST_QUERY_CONTEXT:
- {
- if (gst_gl_handle_context_query ((GstElement *) filter, query,
- filter->display, filter->context, filter->priv->other_context))
- return TRUE;
- break;
- }
- default:
- break;
- }
-
- return GST_BASE_TRANSFORM_CLASS (parent_class)->query (trans, direction,
- query);
-}
-
-static void
-gst_gl_base_filter_reset (GstGLBaseFilter * filter)
-{
- GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (filter);
-
- if (filter->context) {
- if (filter_class->gl_stop != NULL) {
- gst_gl_context_thread_add (filter->context, gst_gl_base_filter_gl_stop,
- filter);
- }
-
- gst_object_unref (filter->context);
- filter->context = NULL;
- }
-}
-
-static gboolean
-gst_gl_base_filter_start (GstBaseTransform * bt)
-{
- return TRUE;
-}
-
-static gboolean
-gst_gl_base_filter_stop (GstBaseTransform * bt)
-{
- GstGLBaseFilter *filter = GST_GL_BASE_FILTER (bt);
-
- gst_gl_base_filter_reset (filter);
-
- return TRUE;
-}
-
-static gboolean
-gst_gl_base_filter_default_gl_start (GstGLBaseFilter * filter)
-{
- return TRUE;
-}
-
-static void
-gst_gl_base_filter_gl_start (GstGLContext * context, gpointer data)
-{
- GstGLBaseFilter *filter = GST_GL_BASE_FILTER (data);
- GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (filter);
-
- gst_gl_insert_debug_marker (filter->context,
- "starting element %s", GST_OBJECT_NAME (filter));
-
- filter->priv->gl_started = filter_class->gl_start (filter);
-}
-
-static void
-gst_gl_base_filter_default_gl_stop (GstGLBaseFilter * filter)
-{
-}
-
-static void
-gst_gl_base_filter_gl_stop (GstGLContext * context, gpointer data)
-{
- GstGLBaseFilter *filter = GST_GL_BASE_FILTER (data);
- GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (filter);
-
- gst_gl_insert_debug_marker (filter->context,
- "stopping element %s", GST_OBJECT_NAME (filter));
-
- if (filter->priv->gl_started)
- filter_class->gl_stop (filter);
-
- filter->priv->gl_started = FALSE;
-}
-
-static void
-_gl_set_caps (GstGLContext * context, GstGLBaseFilter * filter)
-{
- GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (filter);
-
- if (filter_class->gl_set_caps)
- filter->priv->gl_result =
- filter_class->gl_set_caps (filter, filter->in_caps, filter->out_caps);
-}
-
-static gboolean
-gst_gl_base_filter_decide_allocation (GstBaseTransform * trans,
- GstQuery * query)
-{
- GstGLBaseFilter *filter = GST_GL_BASE_FILTER (trans);
- GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (filter);
- GError *error = NULL;
- gboolean new_context = FALSE;
-
- if (!filter->context)
- new_context = TRUE;
-
- _find_local_gl_context (filter);
-
- if (!filter->context) {
- GST_OBJECT_LOCK (filter->display);
- do {
- if (filter->context)
- gst_object_unref (filter->context);
- /* just get a GL context. we don't care */
- filter->context =
- gst_gl_display_get_gl_context_for_thread (filter->display, NULL);
- if (!filter->context) {
- if (!gst_gl_display_create_context (filter->display,
- filter->priv->other_context, &filter->context, &error)) {
- GST_OBJECT_UNLOCK (filter->display);
- goto context_error;
- }
- }
- } while (!gst_gl_display_add_context (filter->display, filter->context));
- GST_OBJECT_UNLOCK (filter->display);
- }
-
- if (new_context || !filter->priv->gl_started) {
- if (filter->priv->gl_started)
- gst_gl_context_thread_add (filter->context, gst_gl_base_filter_gl_stop,
- filter);
-
- {
- GstGLAPI current_gl_api = gst_gl_context_get_gl_api (filter->context);
- if ((current_gl_api & filter_class->supported_gl_api) == 0)
- goto unsupported_gl_api;
- }
-
- gst_gl_context_thread_add (filter->context, gst_gl_base_filter_gl_start,
- filter);
-
- if (!filter->priv->gl_started)
- goto error;
- }
-
- if (filter_class->gl_set_caps) {
- gst_gl_context_thread_add (filter->context,
- (GstGLContextThreadFunc) _gl_set_caps, filter);
- if (!filter->priv->gl_result)
- goto error;
- }
-
- return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans,
- query);
-
-
-unsupported_gl_api:
- {
- GstGLAPI gl_api = gst_gl_context_get_gl_api (filter->context);
- gchar *gl_api_str = gst_gl_api_to_string (gl_api);
- gchar *supported_gl_api_str =
- gst_gl_api_to_string (filter_class->supported_gl_api);
- GST_ELEMENT_ERROR (filter, RESOURCE, BUSY,
- ("GL API's not compatible context: %s supported: %s", gl_api_str,
- supported_gl_api_str), (NULL));
-
- g_free (supported_gl_api_str);
- g_free (gl_api_str);
- return FALSE;
- }
-context_error:
- {
- GST_ELEMENT_ERROR (trans, RESOURCE, NOT_FOUND, ("%s", error->message),
- (NULL));
- g_clear_error (&error);
- return FALSE;
- }
-error:
- {
- GST_ELEMENT_ERROR (trans, LIBRARY, INIT,
- ("Subclass failed to initialize."), (NULL));
- return FALSE;
- }
-}
-
-static gboolean
-gst_gl_base_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
- GstCaps * outcaps)
-{
- GstGLBaseFilter *filter = GST_GL_BASE_FILTER (bt);
-
- gst_caps_replace (&filter->in_caps, incaps);
- gst_caps_replace (&filter->out_caps, outcaps);
-
- return TRUE;
-}
-
-static GstStateChangeReturn
-gst_gl_base_filter_change_state (GstElement * element,
- GstStateChange transition)
-{
- GstGLBaseFilter *filter = GST_GL_BASE_FILTER (element);
- GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (filter);
- GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
-
- GST_DEBUG_OBJECT (filter, "changing state: %s => %s",
- gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
- gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
-
- switch (transition) {
- case GST_STATE_CHANGE_NULL_TO_READY:
- if (!gst_gl_ensure_element_data (element, &filter->display,
- &filter->priv->other_context))
- return GST_STATE_CHANGE_FAILURE;
-
- gst_gl_display_filter_gl_api (filter->display,
- filter_class->supported_gl_api);
- break;
- default:
- break;
- }
-
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- if (ret == GST_STATE_CHANGE_FAILURE)
- return ret;
-
- switch (transition) {
- case GST_STATE_CHANGE_READY_TO_NULL:
- if (filter->priv->other_context) {
- gst_object_unref (filter->priv->other_context);
- filter->priv->other_context = NULL;
- }
-
- if (filter->display) {
- gst_object_unref (filter->display);
- filter->display = NULL;
- }
- break;
- default:
- break;
- }
-
- return ret;
-}
diff --git a/gst-libs/gst/gl/gstglbasefilter.h b/gst-libs/gst/gl/gstglbasefilter.h
deleted file mode 100644
index fa4958d89..000000000
--- a/gst-libs/gst/gl/gstglbasefilter.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2007 David Schleef <ds@schleef.org>
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_GL_BASE_FILTER_H_
-#define _GST_GL_BASE_FILTER_H_
-
-#include <gst/base/gstbasetransform.h>
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GType gst_gl_base_filter_get_type(void);
-#define GST_TYPE_GL_BASE_FILTER (gst_gl_base_filter_get_type())
-#define GST_GL_BASE_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_BASE_FILTER,GstGLBaseFilter))
-#define GST_IS_GL_BASE_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_BASE_FILTER))
-#define GST_GL_BASE_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_GL_BASE_FILTER,GstGLBaseFilterClass))
-#define GST_IS_GL_BASE_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_GL_BASE_FILTER))
-#define GST_GL_BASE_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_GL_BASE_FILTER,GstGLBaseFilterClass))
-
-/**
- * GstGLBaseFilter:
- * @parent: parent #GstBaseTransform
- * @display: the currently configured #GstGLDisplay
- * @context: the currently configured #GstGLContext
- * @in_caps: the currently configured input #GstCaps
- * @out_caps: the currently configured output #GstCaps
- */
-struct _GstGLBaseFilter
-{
- GstBaseTransform parent;
-
- GstGLDisplay *display;
- GstGLContext *context;
-
- GstCaps *in_caps;
- GstCaps *out_caps;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-
- GstGLBaseFilterPrivate *priv;
-};
-
-/**
- * GstGLBaseFilterClass:
- * @parent_class: parent class
- * @supported_gl_api: the logical-OR of #GstGLAPI's supported by this element
- * @gl_start: called in the GL thread to setup the element GL state.
- * @gl_stop: called in the GL thread to setup the element GL state.
- * @gl_set_caps: called in the GL thread when caps are set on @filter.
- */
-struct _GstGLBaseFilterClass
-{
- GstBaseTransformClass parent_class;
- GstGLAPI supported_gl_api;
-
- gboolean (*gl_start) (GstGLBaseFilter *filter);
- void (*gl_stop) (GstGLBaseFilter *filter);
- gboolean (*gl_set_caps) (GstGLBaseFilter *filter, GstCaps * incaps, GstCaps * outcaps);
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-G_END_DECLS
-
-#endif /* _GST_GL_BASE_FILTER_H_ */
diff --git a/gst-libs/gst/gl/gstglbasememory.c b/gst-libs/gst/gl/gstglbasememory.c
deleted file mode 100644
index 4bebedc37..000000000
--- a/gst-libs/gst/gl/gstglbasememory.c
+++ /dev/null
@@ -1,759 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "gstglbasememory.h"
-
-#include "gstglcontext.h"
-#include "gstglquery.h"
-
-/**
- * SECTION:gstglbasememory
- * @title: GstGLBaseMemory
- * @short_description: memory subclass for GL buffers
- * @see_also: #GstMemory, #GstAllocator
- *
- * GstGLBaseMemory is a #GstMemory subclass providing the basis of support
- * for the mapping of GL buffers.
- *
- * Data is uploaded or downloaded from the GPU as is necessary.
- */
-
-#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
-#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
-#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
-#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
-#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_BASE_MEMORY);
-#define GST_CAT_DEFUALT GST_CAT_GL_BASE_MEMORY
-
-GST_DEFINE_MINI_OBJECT_TYPE (GstGLBaseMemory, gst_gl_base_memory);
-
-GQuark
-gst_gl_base_memory_error_quark (void)
-{
- return g_quark_from_static_string ("gst-gl-base-buffer-error-quark");
-}
-
-static gboolean
-_default_create (GstGLBaseMemory * mem, GError ** error)
-{
- g_set_error (error, GST_GL_BASE_MEMORY_ERROR, GST_GL_BASE_MEMORY_ERROR_FAILED,
- "subclass should define create() vfunc");
-
- g_critical ("subclass should override "
- "GstGLBaseMemoryAllocatorClass::create() function");
-
- return FALSE;
-}
-
-struct create_data
-{
- GstGLBaseMemory *mem;
- gboolean result;
-};
-
-static void
-_mem_create_gl (GstGLContext * context, struct create_data *transfer)
-{
- GstGLBaseMemoryAllocatorClass *alloc_class;
- GError *error = NULL;
-
- GST_CAT_TRACE (GST_CAT_GL_BASE_MEMORY, "Create memory %p", transfer->mem);
-
- alloc_class =
- GST_GL_BASE_MEMORY_ALLOCATOR_GET_CLASS (transfer->mem->mem.allocator);
-
- g_return_if_fail (alloc_class->create != NULL);
-
- transfer->mem->query = gst_gl_query_new (context, GST_GL_QUERY_TIME_ELAPSED);
-
- if ((transfer->result = alloc_class->create (transfer->mem, &error)))
- return;
-
- g_assert (error != NULL);
-
- GST_CAT_ERROR (GST_CAT_GL_BASE_MEMORY, "Failed to create GL buffer: %s",
- error->message);
- g_clear_error (&error);
-}
-
-/**
- * gst_gl_base_memory_init:
- * @mem: the #GstGLBaseMemory to initialize
- * @allocator: the #GstAllocator to initialize with
- * @parent: (allow-none): the parent #GstMemory to initialize with
- * @context: the #GstGLContext to initialize with
- * @params: (allow-none): the @GstAllocationParams to initialize with
- * @size: the number of bytes to be allocated
- * @user_data: (allow-none): user data to call @notify with
- * @notify: (allow-none): a #GDestroyNotify
- *
- * Initializes @mem with the required parameters
- *
- * Since: 1.8
- */
-void
-gst_gl_base_memory_init (GstGLBaseMemory * mem, GstAllocator * allocator,
- GstMemory * parent, GstGLContext * context, GstAllocationParams * params,
- gsize size, gpointer user_data, GDestroyNotify notify)
-{
- gsize align = gst_memory_alignment, offset = 0, maxsize;
- GstMemoryFlags flags = 0;
- struct create_data data;
-
- /* A note on sizes.
- * gl_mem->alloc_size: the size to allocate when we control the allocation.
- * Size of the unaligned allocation.
- * mem->maxsize: the size that is used by GstMemory for mapping, to map the
- * entire memory. The size of the aligned allocation
- * mem->size: represents the size of the valid data. Can be reduced with
- * gst_memory_resize()
- *
- * It holds that:
- * mem->size + mem->offset <= mem->maxsize
- * and
- * mem->maxsize + alignment offset <= gl_mem->alloc_size
- *
- * We need to add the alignment mask to the allocated size in order to have
- * the freedom to align the gl_mem->data pointer correctly which may be offset
- * by at most align bytes in the alloc_data pointer.
- *
- * maxsize is not suitable for this as it is used by GstMemory as the size
- * to map with.
- */
- mem->alloc_size = maxsize = size;
- if (params) {
- flags = params->flags;
- align |= params->align;
- offset = params->prefix;
- maxsize += params->prefix + params->padding;
-
- /* deals with any alignment */
- mem->alloc_size = maxsize + align;
- }
-
- gst_memory_init (GST_MEMORY_CAST (mem), flags, allocator, parent, maxsize,
- align, offset, size);
-
- mem->context = gst_object_ref (context);
- mem->notify = notify;
- mem->user_data = user_data;
-
- g_mutex_init (&mem->lock);
-
- data.mem = mem;
-
- gst_gl_context_thread_add (context,
- (GstGLContextThreadFunc) _mem_create_gl, &data);
- if (!data.result) {
- GST_CAT_ERROR (GST_CAT_GL_BASE_MEMORY,
- "Could not create GL buffer with context:%p", context);
- }
-
- GST_CAT_DEBUG (GST_CAT_GL_BASE_MEMORY, "new GL buffer memory:%p size:%"
- G_GSIZE_FORMAT, mem, maxsize);
-}
-
-static gpointer
-_align_data (gpointer data, gsize align)
-{
- guint8 *ret = data;
- gsize aoffset;
-
- /* do alignment, data must have enough padding at the end to move at most
- * align bytes */
- if ((aoffset = ((guintptr) ret & align))) {
- aoffset = (align + 1) - aoffset;
- ret += aoffset;
- }
-
- return ret;
-}
-
-/* subclass usage only */
-/**
- * gst_gl_base_memory_alloc_data:
- * @gl_mem: a #GstGLBaseMemory
- *
- * Note: only intended for subclass usage to allocate the sytem memory buffer
- * on demand. If there is already a non-NULL data pointer in @gl_mem->data,
- * then this function imply returns TRUE.
- *
- * Returns: whether the system memory could be allocated
- */
-gboolean
-gst_gl_base_memory_alloc_data (GstGLBaseMemory * gl_mem)
-{
- GstMemory *mem = (GstMemory *) gl_mem;
-
- if (gl_mem->data)
- return TRUE;
-
- GST_CAT_LOG (GST_CAT_GL_BASE_MEMORY, "%p attempting allocation of data "
- "pointer of size %" G_GSIZE_FORMAT, gl_mem, gl_mem->alloc_size);
- gl_mem->alloc_data = g_try_malloc (gl_mem->alloc_size);
-
- if (gl_mem->alloc_data == NULL)
- return FALSE;
-
- gl_mem->data = _align_data (gl_mem->alloc_data, mem->align);
-
- GST_CAT_DEBUG (GST_CAT_GL_BASE_MEMORY, "%p allocated data pointer alloc %p, "
- "data %p", gl_mem, gl_mem->alloc_data, gl_mem->data);
-
- return TRUE;
-}
-
-struct map_data
-{
- GstGLBaseMemory *mem;
- GstMapInfo *info;
- gsize size;
- gpointer data;
-};
-
-static void
-_map_data_gl (GstGLContext * context, struct map_data *transfer)
-{
- GstGLBaseMemoryAllocatorClass *alloc_class;
- GstGLBaseMemory *mem = transfer->mem;
- GstMapInfo *info = transfer->info;
- guint prev_map_flags;
- guint prev_gl_map_count;
-
- alloc_class =
- GST_GL_BASE_MEMORY_ALLOCATOR_GET_CLASS (transfer->mem->mem.allocator);
-
- g_return_if_fail (alloc_class->map != NULL);
-
- g_mutex_lock (&mem->lock);
-
- prev_map_flags = mem->map_flags;
- prev_gl_map_count = mem->gl_map_count;
-
- GST_CAT_LOG (GST_CAT_GL_BASE_MEMORY, "mapping mem %p flags %04x", mem,
- info->flags);
-
- /* FIXME: validate map flags based on the memory domain */
- if (mem->map_count++ == 0)
- mem->map_flags = info->flags;
- else {
- /* assert that the flags are a subset of the first map flags */
- g_assert ((((GST_MAP_GL - 1) & info->flags) & mem->map_flags) != 0);
- GST_CAT_LOG (GST_CAT_GL_BASE_MEMORY, "multiple map no %d flags %04x "
- "all flags %04x", mem->map_count, info->flags, mem->map_flags);
- }
-
- if ((info->flags & GST_MAP_GL) != (mem->map_flags & GST_MAP_GL))
- mem->map_flags |= GST_MAP_GL;
-
- if (info->flags & GST_MAP_GL)
- mem->gl_map_count++;
-
- transfer->data = alloc_class->map (transfer->mem, transfer->info,
- transfer->size);
-
- if (transfer->data) {
- if (info->flags & GST_MAP_GL) {
- if (info->flags & GST_MAP_WRITE)
- GST_MINI_OBJECT_FLAG_SET (mem,
- GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);
- GST_MEMORY_FLAG_UNSET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD);
- } else {
- if (info->flags & GST_MAP_WRITE)
- GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD);
- GST_MEMORY_FLAG_UNSET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);
- }
- } else {
- /* undo state tracking on error */
- mem->map_flags = prev_map_flags;
- mem->gl_map_count = prev_gl_map_count;
- mem->map_count--;
- }
-
- g_mutex_unlock (&mem->lock);
-}
-
-static gpointer
-_mem_map_full (GstGLBaseMemory * mem, GstMapInfo * info, gsize size)
-{
- struct map_data transfer;
-
- transfer.mem = mem;
- transfer.info = info;
- transfer.size = size;
- transfer.data = NULL;
-
- gst_gl_context_thread_add (mem->context,
- (GstGLContextThreadFunc) _map_data_gl, &transfer);
-
- return transfer.data;
-}
-
-struct unmap_data
-{
- GstGLBaseMemory *mem;
- GstMapInfo *info;
-};
-
-static void
-_unmap_data_gl (GstGLContext * context, struct unmap_data *transfer)
-{
- GstGLBaseMemoryAllocatorClass *alloc_class;
- GstGLBaseMemory *mem = transfer->mem;
- GstMapInfo *info = transfer->info;
-
- alloc_class =
- GST_GL_BASE_MEMORY_ALLOCATOR_GET_CLASS (transfer->mem->mem.allocator);
-
- g_return_if_fail (alloc_class->unmap != NULL);
-
- g_mutex_lock (&mem->lock);
-
- GST_CAT_LOG (GST_CAT_GL_BASE_MEMORY, "unmapping mem %p flags %04x", mem,
- info->flags);
-
- alloc_class->unmap (transfer->mem, transfer->info);
-
- if (info->flags & GST_MAP_GL && --mem->gl_map_count)
- /* unset the gl flag */
- mem->map_flags &= ~GST_MAP_GL;
-
- if (--mem->map_count <= 0) {
- mem->map_flags = 0;
- }
-
- if (info->flags & GST_MAP_GL) {
- if (info->flags & GST_MAP_WRITE)
- GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);
- } else {
- if (info->flags & GST_MAP_WRITE)
- GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD);
- }
-
- g_mutex_unlock (&mem->lock);
-}
-
-static void
-_mem_unmap_full (GstGLBaseMemory * mem, GstMapInfo * info)
-{
- struct unmap_data transfer;
-
- transfer.mem = mem;
- transfer.info = info;
-
- gst_gl_context_thread_add (mem->context,
- (GstGLContextThreadFunc) _unmap_data_gl, &transfer);
-}
-
-static GstGLBaseMemory *
-_default_copy (GstGLBaseMemory * src, gssize offset, gssize size)
-{
- return NULL;
-}
-
-struct copy_params
-{
- GstGLBaseMemory *src;
- GstGLBaseMemory *dest;
- gssize offset;
- gssize size;
- gboolean result;
-};
-
-static void
-_mem_copy_gl (GstGLContext * context, struct copy_params *transfer)
-{
- GstGLBaseMemoryAllocatorClass *alloc_class;
-
- alloc_class =
- GST_GL_BASE_MEMORY_ALLOCATOR_GET_CLASS (transfer->src->mem.allocator);
-
- g_return_if_fail (alloc_class->copy != NULL);
-
- transfer->dest =
- alloc_class->copy (transfer->src, transfer->offset, transfer->size);
-}
-
-static GstMemory *
-_mem_copy (GstGLBaseMemory * src, gssize offset, gssize size)
-{
- struct copy_params transfer;
-
- transfer.dest = NULL;
- transfer.src = src;
- transfer.offset = offset;
- transfer.size = size;
- if (size == -1 || size > 0)
- gst_gl_context_thread_add (src->context,
- (GstGLContextThreadFunc) _mem_copy_gl, &transfer);
-
- return (GstMemory *) transfer.dest;
-}
-
-static GstMemory *
-_mem_share (GstGLBaseMemory * mem, gssize offset, gssize size)
-{
- return NULL;
-}
-
-static gboolean
-_mem_is_span (GstGLBaseMemory * mem1, GstGLBaseMemory * mem2, gsize * offset)
-{
- return FALSE;
-}
-
-static GstMemory *
-_mem_alloc (GstAllocator * allocator, gsize size, GstAllocationParams * params)
-{
- g_critical ("Subclass should override GstAllocatorClass::alloc() function");
-
- return NULL;
-}
-
-static void
-_default_destroy (GstGLBaseMemory * mem)
-{
-}
-
-static void
-_destroy_gl_objects (GstGLContext * context, GstGLBaseMemory * mem)
-{
- GstGLBaseMemoryAllocatorClass *alloc_class;
-
- alloc_class = GST_GL_BASE_MEMORY_ALLOCATOR_GET_CLASS (mem->mem.allocator);
-
- g_return_if_fail (alloc_class->destroy != NULL);
-
- alloc_class->destroy (mem);
-
- if (mem->query)
- gst_gl_query_free (mem->query);
-}
-
-static void
-_mem_free (GstAllocator * allocator, GstMemory * memory)
-{
- GstGLBaseMemory *mem = (GstGLBaseMemory *) memory;
-
- GST_CAT_TRACE (GST_CAT_GL_BASE_MEMORY, "freeing buffer memory:%p", mem);
-
- gst_gl_context_thread_add (mem->context,
- (GstGLContextThreadFunc) _destroy_gl_objects, mem);
-
- g_mutex_clear (&mem->lock);
-
- if (mem->alloc_data) {
- g_free (mem->alloc_data);
- mem->alloc_data = NULL;
- }
- mem->data = NULL;
-
- if (mem->notify)
- mem->notify (mem->user_data);
-
- gst_object_unref (mem->context);
-
- g_free (memory);
-}
-
-/**
- * gst_gl_base_memory_init_once:
- *
- * Initializes the GL Base Memory allocator. It is safe to call this function
- * multiple times. This must be called before any other GstGLBaseMemory operation.
- *
- * Since: 1.8
- */
-void
-gst_gl_base_memory_init_once (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- GST_DEBUG_CATEGORY_INIT (GST_CAT_GL_BASE_MEMORY, "glbasememory", 0,
- "OpenGL BaseMemory");
-
- g_once_init_leave (&_init, 1);
- }
-}
-
-G_DEFINE_ABSTRACT_TYPE (GstGLBaseMemoryAllocator, gst_gl_base_memory_allocator,
- GST_TYPE_ALLOCATOR);
-
-static void
-gst_gl_base_memory_allocator_class_init (GstGLBaseMemoryAllocatorClass * klass)
-{
- GstAllocatorClass *allocator_class = (GstAllocatorClass *) klass;
-
- allocator_class->alloc = _mem_alloc;
- allocator_class->free = _mem_free;
-
- klass->create = _default_create;
- klass->copy = _default_copy;
- klass->destroy = _default_destroy;
-}
-
-static void
-gst_gl_base_memory_allocator_init (GstGLBaseMemoryAllocator * allocator)
-{
- GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator);
-
- /* Keep the fallback copy function around, we will need it when copying with
- * at an offset or smaller size */
- allocator->fallback_mem_copy = alloc->mem_copy;
-
- alloc->mem_map_full = (GstMemoryMapFullFunction) _mem_map_full;
- alloc->mem_unmap_full = (GstMemoryUnmapFullFunction) _mem_unmap_full;
- alloc->mem_copy = (GstMemoryCopyFunction) _mem_copy;
- alloc->mem_share = (GstMemoryShareFunction) _mem_share;
- alloc->mem_is_span = (GstMemoryIsSpanFunction) _mem_is_span;
-}
-
-/**
- * gst_is_gl_base_memory:
- * @mem:a #GstMemory
- *
- * Returns: whether the memory at @mem is a #GstGLBaseMemory
- *
- * Since: 1.8
- */
-gboolean
-gst_is_gl_base_memory (GstMemory * mem)
-{
- return mem != NULL && mem->allocator != NULL &&
- g_type_is_a (G_OBJECT_TYPE (mem->allocator),
- GST_TYPE_GL_BASE_MEMORY_ALLOCATOR);
-}
-
-/**
- * gst_gl_base_memory_memcpy:
- * @src: the source #GstGLBaseMemory
- * @dest: the destination #GstGLBaseMemory
- * @offset: the offset to start at
- * @size: the number of bytes to copy
- *
- * Returns: whether the copy suceeded.
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_base_memory_memcpy (GstGLBaseMemory * src, GstGLBaseMemory * dest,
- gssize offset, gssize size)
-{
- GstMapInfo sinfo, dinfo;
-
- if (!gst_gl_base_memory_alloc_data (GST_GL_BASE_MEMORY_CAST (dest)))
- return FALSE;
-
- if (!gst_memory_map ((GstMemory *) src, &sinfo, GST_MAP_READ)) {
- GST_CAT_WARNING (GST_CAT_GL_BASE_MEMORY,
- "could not read map source memory %p", src);
- return FALSE;
- }
-
- if (!gst_memory_map ((GstMemory *) dest, &dinfo, GST_MAP_WRITE)) {
- GST_CAT_WARNING (GST_CAT_GL_BASE_MEMORY,
- "could not write map dest memory %p", dest);
- gst_memory_unmap ((GstMemory *) src, &sinfo);
- return FALSE;
- }
-
- if (size == -1)
- size = sinfo.size > offset ? sinfo.size - offset : 0;
-
- GST_CAT_DEBUG (GST_CAT_GL_BASE_MEMORY,
- "memcpy %" G_GSSIZE_FORMAT " memory %p -> %p", size, src, dest);
- memcpy (dinfo.data, sinfo.data + offset, size);
- gst_memory_unmap ((GstMemory *) dest, &dinfo);
- gst_memory_unmap ((GstMemory *) src, &sinfo);
-
- return TRUE;
-}
-
-/**
- * gst_gl_allocation_params_init:
- * @params: the #GstGLAllocationParams to initialize
- * @struct_size: the struct size of the implementation
- * @alloc_flags: some alloc flags
- * @copy: a copy function
- * @free: a free function
- * @context: (transfer none): a #GstGLContext
- * @alloc_size: the number of bytes to allocate.
- * @alloc_params: (transfer none) (allow-none): a #GstAllocationParams to apply
- * @wrapped_data: (transfer none) (allow-none): a sysmem data pointer to initialize the allocation with
- * @gl_handle: (transfer none): a GL handle to initialize the allocation with
- * @user_data: (transfer none) (allow-none): user data to call @notify with
- * @notify: (allow-none): a #GDestroyNotify
- *
- * @notify will be called once for each allocated memory using these @params
- * when freeing the memory.
- *
- * Returns: whether the paramaters could be initialized
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_allocation_params_init (GstGLAllocationParams * params,
- gsize struct_size, guint alloc_flags, GstGLAllocationParamsCopyFunc copy,
- GstGLAllocationParamsFreeFunc free, GstGLContext * context,
- gsize alloc_size, GstAllocationParams * alloc_params,
- gpointer wrapped_data, gpointer gl_handle, gpointer user_data,
- GDestroyNotify notify)
-{
- memset (params, 0, sizeof (*params));
-
- g_return_val_if_fail (struct_size > 0, FALSE);
- g_return_val_if_fail (copy != NULL, FALSE);
- g_return_val_if_fail (free != NULL, FALSE);
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
-
- params->struct_size = struct_size;
- params->alloc_size = alloc_size;
- params->copy = copy;
- params->free = free;
- params->alloc_flags = alloc_flags;
- params->context = gst_object_ref (context);
- if (alloc_params)
- params->alloc_params = gst_allocation_params_copy (alloc_params);
- params->notify = notify;
- params->user_data = user_data;
- params->wrapped_data = wrapped_data;
- params->gl_handle = gl_handle;
-
- return TRUE;
-}
-
-/**
- * gst_gl_allocation_params_copy:
- * @src: the #GstGLAllocationParams to initialize
- *
- * Returns: (transfer full): a copy of the #GstGLAllocationParams specified by
- * @src or %NULL on failure
- *
- * Since: 1.8
- */
-GstGLAllocationParams *
-gst_gl_allocation_params_copy (GstGLAllocationParams * src)
-{
- GstGLAllocationParams *dest;
-
- g_return_val_if_fail (src != NULL, NULL);
-
- dest = g_malloc0 (src->struct_size);
-
- if (src->copy)
- src->copy (src, dest);
-
- return dest;
-}
-
-/**
- * gst_gl_allocation_params_free:
- * @params: the #GstGLAllocationParams to initialize
- *
- * Frees the #GstGLAllocationParams and all associated data.
- *
- * Since: 1.8
- */
-void
-gst_gl_allocation_params_free (GstGLAllocationParams * params)
-{
- if (params->free)
- params->free (params);
-
- g_free (params);
-}
-
-/**
- * gst_gl_allocation_params_free_data:
- * @params: the source #GstGLAllocationParams
- *
- * Frees the dynamically allocated data in @params. Direct subclasses
- * should call this function in their own overriden free function.
- *
- * Since: 1.8
- */
-void
-gst_gl_allocation_params_free_data (GstGLAllocationParams * params)
-{
- if (params->context)
- gst_object_unref (params->context);
- if (params->alloc_params)
- gst_allocation_params_free (params->alloc_params);
-}
-
-/**
- * gst_gl_allocation_params_copy_data:
- * @src: the source #GstGLAllocationParams
- * @dest: the destination #GstGLAllocationParams
- *
- * Copies the dynamically allocated data from @src to @dest. Direct subclasses
- * should call this function in their own overriden copy function.
- *
- * Since: 1.8
- */
-void
-gst_gl_allocation_params_copy_data (GstGLAllocationParams * src,
- GstGLAllocationParams * dest)
-{
- gst_gl_allocation_params_init (dest, src->struct_size, src->alloc_flags,
- src->copy, src->free, src->context, src->alloc_size, NULL,
- src->wrapped_data, src->gl_handle, src->user_data, src->notify);
-
- if (src->alloc_params)
- dest->alloc_params = gst_allocation_params_copy (src->alloc_params);
-}
-
-G_DEFINE_BOXED_TYPE (GstGLAllocationParams, gst_gl_allocation_params,
- (GBoxedCopyFunc) gst_gl_allocation_params_copy,
- (GBoxedFreeFunc) gst_gl_allocation_params_free);
-
-/**
- * gst_gl_base_memory_alloc:
- * @allocator: a #GstGLBaseMemoryAllocator
- * @params: the #GstGLAllocationParams to allocate the memory with
- *
- * Returns: a new #GstGLBaseMemory from @allocator with the requested @params.
- *
- * Since: 1.8
- */
-GstGLBaseMemory *
-gst_gl_base_memory_alloc (GstGLBaseMemoryAllocator * allocator,
- GstGLAllocationParams * params)
-{
- GstGLBaseMemoryAllocatorClass *alloc_class;
-
- g_return_val_if_fail (GST_IS_GL_BASE_MEMORY_ALLOCATOR (allocator), NULL);
-
- alloc_class = GST_GL_BASE_MEMORY_ALLOCATOR_GET_CLASS (allocator);
-
- g_return_val_if_fail (alloc_class != NULL, NULL);
- g_return_val_if_fail (alloc_class->alloc != NULL, NULL);
-
- return alloc_class->alloc (allocator, params);
-}
diff --git a/gst-libs/gst/gl/gstglbasememory.h b/gst-libs/gst/gl/gstglbasememory.h
deleted file mode 100644
index 175fbf610..000000000
--- a/gst-libs/gst/gl/gstglbasememory.h
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_GL_BASE_MEMORY_H_
-#define _GST_GL_BASE_MEMORY_H_
-
-#include <gst/gst.h>
-#include <gst/gstallocator.h>
-#include <gst/gstmemory.h>
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-/**
- * GST_GL_BASE_MEMORY_ERROR:
- *
- * Error domain for GStreamer's GL memory module. Errors in this domain will be
- * from the #GstGLBaseMemoryError enumeration
- */
-#define GST_TYPE_GL_BASE_MEMORY (gst_gl_base_memory_get_type())
-GST_EXPORT
-GType gst_gl_base_memory_get_type(void);
-
-#define GST_TYPE_GL_BASE_MEMORY_ALLOCATOR (gst_gl_base_memory_allocator_get_type())
-GST_EXPORT
-GType gst_gl_base_memory_allocator_get_type(void);
-
-#define GST_IS_GL_BASE_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_BASE_MEMORY_ALLOCATOR))
-#define GST_IS_GL_BASE_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GL_BASE_MEMORY_ALLOCATOR))
-#define GST_GL_BASE_MEMORY_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GL_BASE_MEMORY_ALLOCATOR, GstGLBaseMemoryAllocatorClass))
-#define GST_GL_BASE_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_BASE_MEMORY_ALLOCATOR, GstGLBaseMemoryAllocator))
-#define GST_GL_BASE_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_BASE_MEMORY_ALLOCATOR, GstGLBaseMemoryAllocatorClass))
-#define GST_GL_BASE_MEMORY_ALLOCATOR_CAST(obj) ((GstGLBaseMemoryAllocator *)(obj))
-
-#define GST_GL_BASE_MEMORY_CAST(mem) ((GstGLBaseMemory *)mem)
-
-GST_EXPORT
-GQuark gst_gl_base_memory_error_quark (void);
-#define GST_GL_BASE_MEMORY_ERROR (gst_gl_base_memory_error_quark ())
-
-/**
- * GstGLBaseMemoryError:
- * @GST_GL_BASE_MEMORY_ERROR_FAILED: generic faliure
- * @GST_GL_BASE_MEMORY_ERROR_OLD_LIBS: the implementation is too old and doesn't
- * implement enough features
- * @GST_GL_BASE_MEMORY_ERROR_RESOURCE_UNAVAILABLE: a resource could not be found
- */
-typedef enum
-{
- GST_GL_BASE_MEMORY_ERROR_FAILED,
- GST_GL_BASE_MEMORY_ERROR_OLD_LIBS,
- GST_GL_BASE_MEMORY_ERROR_RESOURCE_UNAVAILABLE,
-} GstGLBaseMemoryError;
-
-/**
- * GstGLBaseMemoryTransfer:
- * @GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD: the texture needs downloading
- * to the data pointer
- * @GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD: the data pointer needs uploading
- * to the texture
- */
-typedef enum
-{
- GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD = (GST_MEMORY_FLAG_LAST << 0),
- GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD = (GST_MEMORY_FLAG_LAST << 1)
-} GstGLBaseMemoryTransfer;
-
-/**
- * GST_MAP_GL:
- *
- * Flag indicating that we should map the GL object instead of to system memory.
- *
- * Combining #GST_MAP_GL with #GST_MAP_WRITE has the same semantics as though
- * you are writing to OpenGL. Conversely, combining #GST_MAP_GL with
- * #GST_MAP_READ has the same semantics as though you are reading from OpenGL.
- */
-#define GST_MAP_GL (GST_MAP_FLAG_LAST << 1)
-
-/**
- * GstGLBaseMemory:
- * @mem: the parent object
- * @context: the #GstGLContext to use for GL operations
- *
- * Represents information about a GL memory object
- */
-struct _GstGLBaseMemory
-{
- GstMemory mem;
-
- GstGLContext *context;
-
- /* <protected> */
- GMutex lock;
-
- GstMapFlags map_flags; /* cumulative map flags */
- gint map_count;
- gint gl_map_count;
-
- gpointer data;
-
- GstGLQuery *query;
-
- /* <private> */
- gsize alloc_size; /* because maxsize is used for mapping */
- gpointer alloc_data;
-
- GDestroyNotify notify;
- gpointer user_data;
-
- gpointer _padding[GST_PADDING];
-};
-
-typedef struct _GstGLAllocationParams GstGLAllocationParams;
-/**
- * GstGLAllocationParamsCopyFunc:
- * @src: the source #GstGLAllocationParams to copy from
- * @dest: the source #GstGLAllocationParams to copy
- *
- * Copies the parameters from @src into @dest. The subclass must compose copy
- * functions from the superclass.
- */
-typedef void (*GstGLAllocationParamsCopyFunc) (GstGLAllocationParams * src, GstGLAllocationParams * dest);
-/**
- * GstGLAllocationParamsFreeFunc:
- * @params: a #GstGLAllocationParams
- *
- * Free any dynamically allocated data. The subclass must call the superclass'
- * free.
- */
-typedef void (*GstGLAllocationParamsFreeFunc) (gpointer params);
-
-#define GST_TYPE_GL_ALLOCATION_PARAMS (gst_gl_allocation_params_get_type())
-GST_EXPORT
-GType gst_gl_allocation_params_get_type (void);
-
-/**
- * GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_ALLOC:
- *
- * GL Allocation flag indicating that the implementation should allocate the
- * necessary resources.
- */
-#define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_ALLOC (1 << 0)
-
-/**
- * GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM:
- *
- * GL Allocation flag for using the provided system memory data as storage.
- */
-#define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM (1 << 1)
-
-/**
- * GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE:
- *
- * GL Allocation flag for using the provided GPU handle as storage.
- */
-#define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE (1 << 2)
-
-/**
- * GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_USER:
- *
- * Values >= than #GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_USER can be used for
- * user-defined purposes.
- */
-#define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_USER (1 << 16)
-
-/**
- * GstGLAllocationParams:
- * @struct_size: the size of the struct (including and subclass data)
- * @copy: a #GstGLAllocationParamsCopyFunc
- * @free: a #GstGLAllocationParamsFreeFunc
- * @alloc_flags: allocation flags
- * @alloc_size: the allocation size
- * @alloc_params: the #GstAllocationParams
- * @context: a #GstGLContext
- * @notify: a #GDestroyNotify
- * @user_data: argument to call @notify with
- * @wrapped_data: the wrapped data pointer
- * @gl_handle: the wrapped OpenGL handle
- */
-/* Because GstAllocationParams is not subclassable, start our own subclass
- * chain. FIXME: 2.0 make GstAllocationParams subclassable */
-struct _GstGLAllocationParams
-{
- gsize struct_size;
- GstGLAllocationParamsCopyFunc copy;
- GstGLAllocationParamsFreeFunc free;
-
- guint alloc_flags;
- gsize alloc_size;
- GstAllocationParams *alloc_params;
- GstGLContext *context;
- GDestroyNotify notify;
- gpointer user_data;
-
- /* GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM only */
- gpointer wrapped_data;
- /* GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE only */
- gpointer gl_handle;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-gboolean gst_gl_allocation_params_init (GstGLAllocationParams * params,
- gsize struct_size,
- guint alloc_flags,
- GstGLAllocationParamsCopyFunc copy,
- GstGLAllocationParamsFreeFunc free,
- GstGLContext * context,
- gsize alloc_size,
- GstAllocationParams * alloc_params,
- gpointer wrapped_data,
- gpointer gl_handle,
- gpointer user_data,
- GDestroyNotify notify);
-
-/* free with gst_gl_allocation_params_free */
-GST_EXPORT
-GstGLAllocationParams * gst_gl_allocation_params_copy (GstGLAllocationParams * src);
-
-GST_EXPORT
-void gst_gl_allocation_params_free (GstGLAllocationParams * params);
-
-/* subclass usage */
-GST_EXPORT
-void gst_gl_allocation_params_free_data (GstGLAllocationParams * params);
-
-/* subclass usage */
-GST_EXPORT
-void gst_gl_allocation_params_copy_data (GstGLAllocationParams * src,
- GstGLAllocationParams * dest);
-
-/**
- * GstGLBaseMemoryAllocatorAllocFunction:
- * @allocator: a #GstGLBaseMemoryAllocator
- * @params: the #GstGLAllocationParams to allocate the memory with
- *
- * Note: not called with a GL context current
- *
- * Returns: a newly allocated #GstGLBaseMemory from @allocator and @params
- *
- * Since: 1.8
- */
-typedef GstGLBaseMemory * (*GstGLBaseMemoryAllocatorAllocFunction) (GstGLBaseMemoryAllocator * allocator,
- GstGLAllocationParams * params);
-
-/**
- * GstGLBaseMemoryAllocatorCreateFunction:
- * @mem: a #GstGLBaseMemory
- * @error: a #GError to use on failure
- *
- * As this virtual method is called with an OpenGL context current, use this
- * function to allocate and OpenGL resources needed for your application
- *
- * Returns: whether the creation succeeded
- *
- * Since: 1.8
- */
-typedef gboolean (*GstGLBaseMemoryAllocatorCreateFunction) (GstGLBaseMemory * mem,
- GError ** error);
-
-/**
- * GstGLBaseMemoryAllocatorMapFunction:
- * @mem: a #GstGLBaseMemory
- * @info: a #GstMapInfo to map with
- * @maxsize: the size to map
- *
- * Also see gst_memory_map();
- *
- * Returns: the mapped pointer
- *
- * Since: 1.8
- */
-typedef gpointer (*GstGLBaseMemoryAllocatorMapFunction) (GstGLBaseMemory * mem,
- GstMapInfo * info,
- gsize maxsize);
-/**
- * GstGLBaseMemoryAllocatorUnmapFunction:
- * @mem: a #GstGLBaseMemory
- * @info: a #GstMapInfo to map with
- *
- * Also see gst_memory_unmap();
- *
- * Since: 1.8
- */
-typedef void (*GstGLBaseMemoryAllocatorUnmapFunction) (GstGLBaseMemory * mem,
- GstMapInfo * info);
-
-/**
- * GstGLBaseMemoryAllocatorCopyFunction:
- * @mem: a #GstGLBaseMemory
- * @offset: the offset to copy from
- * @size: the number of bytes to copy
- *
- * Also see gst_memory_copy();
- *
- * Returns: the newly copied #GstGLMemory or %NULL
- *
- * Since: 1.8
- */
-typedef GstGLBaseMemory * (*GstGLBaseMemoryAllocatorCopyFunction) (GstGLBaseMemory * mem,
- gssize offset,
- gssize size);
-
-/**
- * GstGLBaseMemoryAllocatorDestroyFunction:
- * @mem: a #GstGLBaseMemory
- *
- * Destroy any resources allocated throughout the lifetime of @mem
- *
- * Since: 1.8
- */
-typedef void (*GstGLBaseMemoryAllocatorDestroyFunction) (GstGLBaseMemory * mem);
-
-/**
- * GstGLBaseMemoryAllocator
- *
- * Opaque #GstGLBaseMemoryAllocator struct
- *
- * Since: 1.8
- */
-struct _GstGLBaseMemoryAllocator
-{
- /*< private >*/
- GstAllocator parent;
- GstMemoryCopyFunction fallback_mem_copy;
-
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GstGLBaseMemoryAllocatorClass:
- * @parent_class: the parent class
- * @alloc: a #GstGLBaseMemoryAllocatorAllocFunction
- * @create: a #GstGLBaseMemoryAllocatorCreateFunction
- * @map: a #GstGLBaseMemoryAllocatorMapFunction
- * @unmap: a #GstGLBaseMemoryAllocatorUnmapFunction
- * @copy: a #GstGLBaseMemoryAllocatorCopyFunction
- * @destroy: a #GstGLBaseMemoryAllocatorDestroyFunction
- *
- * Since: 1.8
- */
-struct _GstGLBaseMemoryAllocatorClass
-{
- GstAllocatorClass parent_class;
-
- GstGLBaseMemoryAllocatorAllocFunction alloc;
-
- GstGLBaseMemoryAllocatorCreateFunction create;
- GstGLBaseMemoryAllocatorMapFunction map;
- GstGLBaseMemoryAllocatorUnmapFunction unmap;
- GstGLBaseMemoryAllocatorCopyFunction copy;
- GstGLBaseMemoryAllocatorDestroyFunction destroy;
- /* <private> */
-
- gpointer _padding[GST_PADDING];
-};
-
-#include <gst/gl/gstglconfig.h>
-#include <gst/gl/gstglformat.h>
-
-/**
- * GST_GL_BASE_MEMORY_ALLOCATOR_NAME:
- *
- * The name of the GL buffer allocator
- *
- * Since: 1.8
- */
-#define GST_GL_BASE_MEMORY_ALLOCATOR_NAME "GLBaseMemory"
-
-GST_EXPORT
-void gst_gl_base_memory_init_once (void);
-
-GST_EXPORT
-gboolean gst_is_gl_base_memory (GstMemory * mem);
-
-GST_EXPORT
-void gst_gl_base_memory_init (GstGLBaseMemory * mem,
- GstAllocator * allocator,
- GstMemory * parent,
- GstGLContext * context,
- GstAllocationParams * params,
- gsize size,
- gpointer user_data,
- GDestroyNotify notify);
-
-GST_EXPORT
-gboolean gst_gl_base_memory_alloc_data (GstGLBaseMemory * gl_mem);
-
-GST_EXPORT
-gboolean gst_gl_base_memory_memcpy (GstGLBaseMemory * src,
- GstGLBaseMemory * dest,
- gssize offset,
- gssize size);
-
-GST_EXPORT
-GstGLBaseMemory * gst_gl_base_memory_alloc (GstGLBaseMemoryAllocator * allocator,
- GstGLAllocationParams * params);
-
-G_END_DECLS
-
-#endif /* _GST_GL_BUFFER_H_ */
diff --git a/gst-libs/gst/gl/gstglbuffer.c b/gst-libs/gst/gl/gstglbuffer.c
deleted file mode 100644
index 5a4500757..000000000
--- a/gst-libs/gst/gl/gstglbuffer.c
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "gstglbuffer.h"
-
-#include "gstglcontext.h"
-#include "gstglfuncs.h"
-#include "gstglutils.h"
-
-/**
- * SECTION:gstglbuffer
- * @title: GstGLBuffer
- * @short_description: memory subclass for GL buffers
- * @see_also: #GstMemory, #GstAllocator
- *
- * GstGLBuffer is a #GstMemory subclass providing support for the mapping of
- * GL buffers.
- *
- * Data is uploaded or downloaded from the GPU as is necessary.
- */
-
-/* Implementation notes:
- *
- * Currently does not take into account GLES2 differences (no mapbuffer)
- */
-
-#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
-#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
-#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
-#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
-#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-
-/* compatibility definitions... */
-#ifndef GL_MAP_READ_BIT
-#define GL_MAP_READ_BIT 0x0001
-#endif
-#ifndef GL_MAP_WRITE_BIT
-#define GL_MAP_WRITE_BIT 0x0002
-#endif
-#ifndef GL_COPY_READ_BUFFER
-#define GL_COPY_READ_BUFFER 0x8F36
-#endif
-#ifndef GL_COPY_WRITE_BUFFER
-#define GL_COPY_WRITE_BUFFER 0x8F37
-#endif
-
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_BUFFER);
-#define GST_CAT_DEFUALT GST_CAT_GL_BUFFER
-
-static GstAllocator *_gl_buffer_allocator;
-
-static gboolean
-_gl_buffer_create (GstGLBuffer * gl_mem, GError ** error)
-{
- const GstGLFuncs *gl = gl_mem->mem.context->gl_vtable;
-
- gl->GenBuffers (1, &gl_mem->id);
- gl->BindBuffer (gl_mem->target, gl_mem->id);
- gl->BufferData (gl_mem->target, gl_mem->mem.mem.maxsize, NULL,
- gl_mem->usage_hints);
- gl->BindBuffer (gl_mem->target, 0);
-
- return TRUE;
-}
-
-struct create_data
-{
- GstGLBuffer *mem;
- gboolean result;
-};
-
-static void
-_gl_buffer_init (GstGLBuffer * mem, GstAllocator * allocator,
- GstMemory * parent, GstGLContext * context, guint gl_target, guint gl_usage,
- GstAllocationParams * params, gsize size)
-{
- mem->target = gl_target;
- mem->usage_hints = gl_usage;
-
- gst_gl_base_memory_init ((GstGLBaseMemory *) mem, allocator, parent, context,
- params, size, NULL, NULL);
-
- GST_CAT_DEBUG (GST_CAT_GL_BUFFER, "new GL buffer memory:%p size:%"
- G_GSIZE_FORMAT, mem, mem->mem.mem.maxsize);
-}
-
-static GstGLBuffer *
-_gl_buffer_new (GstAllocator * allocator, GstMemory * parent,
- GstGLContext * context, guint gl_target, guint gl_usage,
- GstAllocationParams * params, gsize size)
-{
- GstGLBuffer *ret = g_new0 (GstGLBuffer, 1);
- _gl_buffer_init (ret, allocator, parent, context, gl_target, gl_usage,
- params, size);
-
- return ret;
-}
-
-static gpointer
-gst_gl_buffer_cpu_access (GstGLBuffer * mem, GstMapInfo * info, gsize size)
-{
- const GstGLFuncs *gl = mem->mem.context->gl_vtable;
- gpointer data, ret;
-
- if (!gst_gl_base_memory_alloc_data (GST_GL_BASE_MEMORY_CAST (mem)))
- return NULL;
-
- ret = mem->mem.data;
-
- GST_CAT_LOG (GST_CAT_GL_BUFFER, "mapping id %d size %" G_GSIZE_FORMAT,
- mem->id, size);
-
- /* The extra data pointer indirection/memcpy is needed for coherent across
- * concurrent map()'s in both GL and CPU */
- if (GST_MEMORY_FLAG_IS_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)
- && (info->flags & GST_MAP_GL) == 0 && (info->flags & GST_MAP_READ) != 0) {
- gl->BindBuffer (mem->target, mem->id);
-
- if (gl->MapBufferRange) {
- /* FIXME: optionally remove this with a flag and return the
- * glMapBufferRange pointer (requires
- * GL_ARB_buffer_storage/GL4/GL_COHERENT_BIT) */
- guint gl_map_flags = GL_MAP_READ_BIT;
-
- data = gl->MapBufferRange (mem->target, 0, size, gl_map_flags);
-
- if (data)
- memcpy (mem->mem.data, data, size);
-
- gl->UnmapBuffer (mem->target);
- ret = mem->mem.data;
- } else if (gl->GetBufferSubData) {
- gl->GetBufferSubData (mem->target, 0, size, mem->mem.data);
- ret = mem->mem.data;
- } else {
- ret = NULL;
- }
- gl->BindBuffer (mem->target, 0);
- }
-
- return ret;
-}
-
-static void
-gst_gl_buffer_upload_cpu_write (GstGLBuffer * mem, GstMapInfo * info,
- gsize size)
-{
- const GstGLFuncs *gl = mem->mem.context->gl_vtable;
- gpointer data;
-
- if (!mem->mem.data)
- /* no data pointer has been written */
- return;
-
- /* The extra data pointer indirection/memcpy is needed for coherent across
- * concurrent map()'s in both GL and CPU */
- /* FIXME: uploading potentially half-written data for libav pushing READWRITE
- * mapped buffers */
- if (GST_MEMORY_FLAG_IS_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)
- || (mem->mem.map_flags & GST_MAP_WRITE) != 0) {
- gl->BindBuffer (mem->target, mem->id);
-
- if (gl->MapBufferRange) {
- /* FIXME: optionally remove this with a flag and return the
- * glMapBufferRange pointer (requires
- * GL_ARB_buffer_storage/GL4/GL_COHERENT_BIT) */
- guint gl_map_flags = GL_MAP_WRITE_BIT;
-
- data = gl->MapBufferRange (mem->target, 0, size, gl_map_flags);
-
- if (data)
- memcpy (data, mem->mem.data, size);
-
- gl->UnmapBuffer (mem->target);
- } else if (gl->BufferSubData) {
- gl->BufferSubData (mem->target, 0, size, mem->mem.data);
- }
- gl->BindBuffer (mem->target, 0);
- }
-}
-
-static gpointer
-_gl_buffer_map (GstGLBuffer * mem, GstMapInfo * info, gsize size)
-{
- const GstGLFuncs *gl = mem->mem.context->gl_vtable;
-
- if ((info->flags & GST_MAP_GL) != 0) {
- if (info->flags & GST_MAP_READ) {
- gst_gl_buffer_upload_cpu_write (mem, info, size);
- }
- gl->BindBuffer (mem->target, mem->id);
- return &mem->id;
- } else {
- return gst_gl_buffer_cpu_access (mem, info, size);
- }
-
- return NULL;
-}
-
-static void
-_gl_buffer_unmap (GstGLBuffer * mem, GstMapInfo * info)
-{
- const GstGLFuncs *gl = mem->mem.context->gl_vtable;
-
- if ((info->flags & GST_MAP_GL) != 0) {
- gl->BindBuffer (mem->target, 0);
- }
- /* XXX: optimistically transfer data */
-}
-
-/**
- * gst_gl_buffer_copy_buffer_sub_data:
- * @src: the source #GstGLBuffer
- * @dest: the destination #GstGLBuffer
- * @offset: the offset to copy from @src
- * @size: the size to copy from @src
- *
- * Copies @src into @dest using glCopyBufferSubData().
- *
- * Returns: whether the copy operation succeeded
- *
- * Since: 1.8
- */
-static gboolean
-gst_gl_buffer_copy_buffer_sub_data (GstGLBuffer * src,
- GstGLBuffer * dest, gssize offset, gssize size)
-{
- const GstGLFuncs *gl = src->mem.context->gl_vtable;
- GstMapInfo sinfo, dinfo;
-
- if (!gl->CopyBufferSubData)
- /* This is GL(ES) 3.0+ only */
- return FALSE;
-
- if (!gst_memory_map ((GstMemory *) src, &sinfo, GST_MAP_READ | GST_MAP_GL)) {
- GST_CAT_WARNING (GST_CAT_GL_BUFFER,
- "failed to read map source memory %p", src);
- return FALSE;
- }
-
- if (!gst_memory_map ((GstMemory *) dest, &dinfo, GST_MAP_WRITE | GST_MAP_GL)) {
- GST_CAT_WARNING (GST_CAT_GL_BUFFER,
- "failed to write map destination memory %p", dest);
- gst_memory_unmap ((GstMemory *) src, &sinfo);
- return FALSE;
- }
-
- gl->BindBuffer (GL_COPY_READ_BUFFER, src->id);
- gl->BindBuffer (GL_COPY_WRITE_BUFFER, dest->id);
- gl->CopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER,
- offset, 0, size);
-
- gst_memory_unmap ((GstMemory *) src, &sinfo);
- gst_memory_unmap ((GstMemory *) dest, &dinfo);
-
- return TRUE;
-}
-
-static GstGLBuffer *
-_gl_buffer_copy (GstGLBuffer * src, gssize offset, gssize size)
-{
- GstAllocator *allocator = src->mem.mem.allocator;
- GstAllocationParams params = { 0, src->mem.mem.align, 0, 0 };
- GstGLBuffer *dest = NULL;
-
- dest = _gl_buffer_new (allocator, NULL, src->mem.context,
- src->target, src->usage_hints, &params, src->mem.mem.maxsize);
-
- /* If not doing a full copy, then copy to sysmem, the 2D represention of the
- * texture would become wrong */
- if (GST_MEMORY_FLAG_IS_SET (src, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)) {
- if (!gst_gl_base_memory_memcpy (GST_GL_BASE_MEMORY_CAST (src),
- GST_GL_BASE_MEMORY_CAST (dest), offset, size)) {
- GST_CAT_WARNING (GST_CAT_GL_BUFFER, "Could not copy GL Buffer");
- gst_memory_unref (GST_MEMORY_CAST (dest));
- dest = NULL;
- }
- } else {
- if (!gst_gl_buffer_copy_buffer_sub_data (src, dest, offset, size)) {
- if (!gst_gl_base_memory_memcpy (GST_GL_BASE_MEMORY_CAST (src),
- GST_GL_BASE_MEMORY_CAST (dest), offset, size)) {
- GST_CAT_WARNING (GST_CAT_GL_BUFFER, "Could not copy GL Buffer");
- gst_memory_unref (GST_MEMORY_CAST (dest));
- dest = NULL;
- }
- }
- }
-
- return dest;
-}
-
-static GstMemory *
-_gl_buffer_alloc (GstAllocator * allocator, gsize size,
- GstAllocationParams * params)
-{
- g_critical ("Need to use gst_gl_base_memory_alloc() to allocate from "
- "this allocator");
-
- return NULL;
-}
-
-static void
-_gl_buffer_destroy (GstGLBuffer * mem)
-{
- const GstGLFuncs *gl = mem->mem.context->gl_vtable;
-
- gl->DeleteBuffers (1, &mem->id);
-}
-
-static void
-_gst_gl_buffer_allocation_params_copy_data (GstGLBufferAllocationParams * src,
- GstGLBufferAllocationParams * dest)
-{
- memset (dest, 0, sizeof (*dest));
-
- gst_gl_allocation_params_copy_data (&src->parent, &dest->parent);
-
- dest->gl_target = src->gl_target;
- dest->gl_usage = src->gl_usage;
-}
-
-static void
-_gst_gl_buffer_allocation_params_free_data (GstGLBufferAllocationParams *
- params)
-{
- gst_gl_allocation_params_free_data (&params->parent);
-}
-
-G_DEFINE_BOXED_TYPE (GstGLBufferAllocationParams,
- gst_gl_buffer_allocation_params,
- (GBoxedCopyFunc) gst_gl_allocation_params_copy,
- (GBoxedFreeFunc) gst_gl_allocation_params_free);
-
-/**
- * gst_gl_buffer_allocation_params_new:
- * @context: a #GstGLContext
- * @alloc_size: the size in bytes to allocate
- * @alloc_params: (allow-none): the #GstAllocationParams for @tex_id
- * @gl_target: the OpenGL target to allocate
- * @gl_usage: the OpenGL usage hint to allocate with
- *
- * Returns: a new #GstGLBufferAllocationParams for allocating OpenGL buffer
- * objects
- *
- * Since: 1.8
- */
-GstGLBufferAllocationParams *
-gst_gl_buffer_allocation_params_new (GstGLContext * context, gsize alloc_size,
- GstAllocationParams * alloc_params, guint gl_target, guint gl_usage)
-{
- GstGLBufferAllocationParams *params;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), NULL);
- g_return_val_if_fail (alloc_size > 0, NULL);
-
- params = g_new0 (GstGLBufferAllocationParams, 1);
-
- if (!gst_gl_allocation_params_init (&params->parent, sizeof (*params),
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_BUFFER |
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_ALLOC,
- (GstGLAllocationParamsCopyFunc)
- _gst_gl_buffer_allocation_params_copy_data,
- (GstGLAllocationParamsFreeFunc)
- _gst_gl_buffer_allocation_params_free_data, context, alloc_size,
- alloc_params, NULL, 0, NULL, NULL)) {
- g_free (params);
- return NULL;
- }
-
- params->gl_target = gl_target;
- params->gl_usage = gl_usage;
-
- return params;
-}
-
-static GstGLBuffer *
-_gl_buffer_alloc_mem (GstGLBufferAllocator * allocator,
- GstGLBufferAllocationParams * params)
-{
- guint alloc_flags = params->parent.alloc_flags;
-
- g_return_val_if_fail (alloc_flags &
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_BUFFER, NULL);
- g_return_val_if_fail (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_ALLOC,
- NULL);
-
- return _gl_buffer_new (GST_ALLOCATOR (allocator), NULL,
- params->parent.context, params->gl_target, params->gl_usage,
- params->parent.alloc_params, params->parent.alloc_size);
-}
-
-G_DEFINE_TYPE (GstGLBufferAllocator, gst_gl_buffer_allocator,
- GST_TYPE_GL_BASE_MEMORY_ALLOCATOR);
-
-static void
-gst_gl_buffer_allocator_class_init (GstGLBufferAllocatorClass * klass)
-{
- GstAllocatorClass *allocator_class = (GstAllocatorClass *) klass;
- GstGLBaseMemoryAllocatorClass *gl_base;
-
- gl_base = (GstGLBaseMemoryAllocatorClass *) klass;
-
- gl_base->alloc = (GstGLBaseMemoryAllocatorAllocFunction) _gl_buffer_alloc_mem;
- gl_base->create = (GstGLBaseMemoryAllocatorCreateFunction) _gl_buffer_create;
- gl_base->map = (GstGLBaseMemoryAllocatorMapFunction) _gl_buffer_map;
- gl_base->unmap = (GstGLBaseMemoryAllocatorUnmapFunction) _gl_buffer_unmap;
- gl_base->copy = (GstGLBaseMemoryAllocatorCopyFunction) _gl_buffer_copy;
- gl_base->destroy =
- (GstGLBaseMemoryAllocatorDestroyFunction) _gl_buffer_destroy;
-
- allocator_class->alloc = _gl_buffer_alloc;
-}
-
-static void
-gst_gl_buffer_allocator_init (GstGLBufferAllocator * allocator)
-{
- GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator);
-
- alloc->mem_type = GST_GL_BUFFER_ALLOCATOR_NAME;
-
- GST_OBJECT_FLAG_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC);
-}
-
-/**
- * gst_gl_buffer_init_once:
- *
- * Initializes the GL Buffer allocator. It is safe to call this function
- * multiple times. This must be called before any other #GstGLBuffer operation.
- *
- * Since: 1.8
- */
-void
-gst_gl_buffer_init_once (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- gst_gl_base_memory_init_once ();
-
- GST_DEBUG_CATEGORY_INIT (GST_CAT_GL_BUFFER, "glbuffer", 0, "OpenGL Buffer");
-
- _gl_buffer_allocator =
- g_object_new (gst_gl_buffer_allocator_get_type (), NULL);
- gst_object_ref_sink (_gl_buffer_allocator);
-
- /* The allocator is never unreffed */
- GST_OBJECT_FLAG_SET (_gl_buffer_allocator, GST_OBJECT_FLAG_MAY_BE_LEAKED);
-
- gst_allocator_register (GST_GL_BUFFER_ALLOCATOR_NAME,
- gst_object_ref (_gl_buffer_allocator));
- g_once_init_leave (&_init, 1);
- }
-}
-
-/**
- * gst_is_gl_buffer:
- * @mem:a #GstMemory
- *
- * Returns: whether the memory at @mem is a #GstGLBuffer
- *
- * Since: 1.8
- */
-gboolean
-gst_is_gl_buffer (GstMemory * mem)
-{
- return mem != NULL && mem->allocator != NULL &&
- g_type_is_a (G_OBJECT_TYPE (mem->allocator),
- GST_TYPE_GL_BUFFER_ALLOCATOR);
-}
diff --git a/gst-libs/gst/gl/gstglbuffer.h b/gst-libs/gst/gl/gstglbuffer.h
deleted file mode 100644
index 52a6576fd..000000000
--- a/gst-libs/gst/gl/gstglbuffer.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_GL_BUFFER_H_
-#define _GST_GL_BUFFER_H_
-
-#include <gst/gl/gstglbasememory.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_BUFFER_ALLOCATOR (gst_gl_buffer_allocator_get_type())
-GST_EXPORT
-GType gst_gl_buffer_allocator_get_type(void);
-
-#define GST_IS_GL_BUFFER_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_ALLOCATOR))
-#define GST_IS_GL_BUFFER_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GL_BUFFER_ALLOCATOR))
-#define GST_GL_BUFFER_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GL_BUFFER_ALLOCATOR, GstGLBufferAllocatorClass))
-#define GST_GL_BUFFER_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_BUFFER_ALLOCATOR, GstGLBufferAllocator))
-#define GST_GL_BUFFER_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_BUFFER_ALLOCATOR, GstGLBufferAllocatorClass))
-#define GST_GL_BUFFER_ALLOCATOR_CAST(obj) ((GstGLBufferAllocator *)(obj))
-
-/**
- * GstGLBuffer:
- * @mem: the parent object
- * @id: the buffer id for this memory
- * @target: the OpenGL target of this texture for binding purposes
- * @usage_hints: the OpenGL usage hints this buffer was created with
- *
- * Represents information about a GL buffer
- */
-struct _GstGLBuffer
-{
- GstGLBaseMemory mem;
-
- guint id;
- guint target; /* XXX: put this in the allocator? */
- guint usage_hints; /* XXX: put this in the allocator? */
-};
-
-typedef struct _GstGLBufferAllocationParams GstGLBufferAllocationParams;
-
-#define GST_TYPE_GL_BUFFER_ALLOCATION_PARAMS (gst_gl_buffer_allocation_params_get_type())
-GST_EXPORT
-GType gst_gl_buffer_allocation_params_get_type (void);
-
-/**
- * GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_BUFFER:
- *
- * GL allocation flag indicating the allocation of a GL buffer.
- */
-#define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_BUFFER (1 << 4)
-
-/**
- * GstGLBufferAllocationParams:
- * @parent: parent object
- * @gl_target: the OpenGL target to bind the buffer to
- * @gl_usage: the OpenGL usage hint to create the buffer with
- */
-struct _GstGLBufferAllocationParams
-{
- GstGLAllocationParams parent;
-
- guint gl_target;
- guint gl_usage;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GstGLBufferAllocationParams * gst_gl_buffer_allocation_params_new (GstGLContext * context,
- gsize alloc_size,
- GstAllocationParams * alloc_params,
- guint gl_target,
- guint gl_usage);
-
-/**
- * GstGLBufferAllocator
- *
- * Opaque #GstGLAllocator struct
- */
-struct _GstGLBufferAllocator
-{
- GstGLBaseMemoryAllocator parent;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GstGLBufferAllocatorClass:
- *
- * The #GstGLBufferAllocatorClass only contains private data
- */
-struct _GstGLBufferAllocatorClass
-{
- GstGLBaseMemoryAllocatorClass parent_class;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GST_CAPS_FEATURE_MEMORY_GL_BUFFER:
- *
- * Name of the caps feature indicating the use of GL buffers
- */
-#define GST_CAPS_FEATURE_MEMORY_GL_BUFFER "memory:GLBuffer"
-
-/**
- * GST_GL_BUFFER_ALLOCATOR_NAME:
- *
- * The name of the GL buffer allocator
- */
-#define GST_GL_BUFFER_ALLOCATOR_NAME "GLBuffer"
-
-GST_EXPORT
-void gst_gl_buffer_init_once (void);
-GST_EXPORT
-gboolean gst_is_gl_buffer (GstMemory * mem);
-
-G_END_DECLS
-
-#endif /* _GST_GL_BUFFER_H_ */
diff --git a/gst-libs/gst/gl/gstglbufferpool.c b/gst-libs/gst/gl/gstglbufferpool.c
deleted file mode 100644
index 309bc367b..000000000
--- a/gst-libs/gst/gl/gstglbufferpool.c
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstglbufferpool.h"
-
-#include "gstglmemory.h"
-#include "gstglsyncmeta.h"
-#include "gstglutils.h"
-
-/**
- * SECTION:gstglbufferpool
- * @title: GstGLBufferPool
- * @short_description: buffer pool for #GstGLBaseMemory objects
- * @see_also: #GstBufferPool, #GstGLBaseMemory, #GstGLMemory
- *
- * a #GstGLBufferPool is an object that allocates buffers with #GstGLBaseMemory
- *
- * A #GstGLBufferPool is created with gst_gl_buffer_pool_new()
- *
- * #GstGLBufferPool implements the VideoMeta buffer pool option
- * %GST_BUFFER_POOL_OPTION_VIDEO_META, the VideoAligment buffer pool option
- * %GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT as well as the OpenGL specific
- * %GST_BUFFER_POOL_OPTION_GL_SYNC_META buffer pool option.
- */
-
-/* bufferpool */
-struct _GstGLBufferPoolPrivate
-{
- GstAllocator *allocator;
- GstGLVideoAllocationParams *gl_params;
- GstCaps *caps;
- gboolean add_videometa;
- gboolean add_glsyncmeta;
-};
-
-static void gst_gl_buffer_pool_finalize (GObject * object);
-
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_BUFFER_POOL);
-#define GST_CAT_DEFAULT GST_CAT_GL_BUFFER_POOL
-
-#define GST_GL_BUFFER_POOL_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_GL_BUFFER_POOL, GstGLBufferPoolPrivate))
-
-#define gst_gl_buffer_pool_parent_class parent_class
-G_DEFINE_TYPE_WITH_CODE (GstGLBufferPool, gst_gl_buffer_pool,
- GST_TYPE_BUFFER_POOL, GST_DEBUG_CATEGORY_INIT (GST_CAT_GL_BUFFER_POOL,
- "glbufferpool", 0, "GL Buffer Pool"));
-
-static const gchar **
-gst_gl_buffer_pool_get_options (GstBufferPool * pool)
-{
- static const gchar *options[] = { GST_BUFFER_POOL_OPTION_VIDEO_META,
- GST_BUFFER_POOL_OPTION_GL_SYNC_META,
- GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT,
- GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_2D,
- GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_RECTANGLE,
- NULL
- };
-
- return options;
-}
-
-static gboolean
-gst_gl_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
-{
- GstGLBufferPool *glpool = GST_GL_BUFFER_POOL_CAST (pool);
- GstGLBufferPoolPrivate *priv = glpool->priv;
- GstVideoInfo info;
- GstCaps *caps = NULL;
- guint min_buffers, max_buffers;
- guint max_align, n;
- GstAllocator *allocator = NULL;
- GstAllocationParams alloc_params;
- GstGLTextureTarget tex_target;
- gboolean ret = TRUE;
- gint p;
-
- if (!gst_buffer_pool_config_get_params (config, &caps, NULL, &min_buffers,
- &max_buffers))
- goto wrong_config;
-
- if (caps == NULL)
- goto no_caps;
-
- /* now parse the caps from the config */
- if (!gst_video_info_from_caps (&info, caps))
- goto wrong_caps;
-
- GST_LOG_OBJECT (pool, "%dx%d, caps %" GST_PTR_FORMAT, info.width, info.height,
- caps);
-
- if (!gst_buffer_pool_config_get_allocator (config, &allocator, &alloc_params))
- goto wrong_config;
-
- gst_caps_replace (&priv->caps, caps);
-
- if (priv->allocator)
- gst_object_unref (priv->allocator);
-
- if (allocator) {
- if (!GST_IS_GL_MEMORY_ALLOCATOR (allocator)) {
- gst_object_unref (allocator);
- goto wrong_allocator;
- } else {
- priv->allocator = gst_object_ref (allocator);
- }
- } else {
- priv->allocator =
- GST_ALLOCATOR (gst_gl_memory_allocator_get_default (glpool->context));
- g_assert (priv->allocator);
- }
-
- priv->add_videometa = gst_buffer_pool_config_has_option (config,
- GST_BUFFER_POOL_OPTION_VIDEO_META);
- priv->add_glsyncmeta = gst_buffer_pool_config_has_option (config,
- GST_BUFFER_POOL_OPTION_GL_SYNC_META);
-
- if (priv->gl_params)
- gst_gl_allocation_params_free ((GstGLAllocationParams *) priv->gl_params);
- priv->gl_params = (GstGLVideoAllocationParams *)
- gst_buffer_pool_config_get_gl_allocation_params (config);
- if (!priv->gl_params)
- priv->gl_params = gst_gl_video_allocation_params_new (glpool->context,
- &alloc_params, &info, -1, NULL, 0, 0);
-
- max_align = alloc_params.align;
-
- if (gst_buffer_pool_config_has_option (config,
- GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT)) {
- priv->add_videometa = TRUE;
-
- gst_buffer_pool_config_get_video_alignment (config,
- priv->gl_params->valign);
-
- for (n = 0; n < GST_VIDEO_MAX_PLANES; ++n)
- max_align |= priv->gl_params->valign->stride_align[n];
-
- for (n = 0; n < GST_VIDEO_MAX_PLANES; ++n)
- priv->gl_params->valign->stride_align[n] = max_align;
-
- gst_video_info_align (priv->gl_params->v_info, priv->gl_params->valign);
-
- gst_buffer_pool_config_set_video_alignment (config,
- priv->gl_params->valign);
- }
-
- if (alloc_params.align < max_align) {
- GST_WARNING_OBJECT (pool, "allocation params alignment %u is smaller "
- "than the max specified video stride alignment %u, fixing",
- (guint) alloc_params.align, max_align);
-
- alloc_params.align = max_align;
- gst_buffer_pool_config_set_allocator (config, allocator, &alloc_params);
- if (priv->gl_params->parent.alloc_params)
- gst_allocation_params_free (priv->gl_params->parent.alloc_params);
- priv->gl_params->parent.alloc_params =
- gst_allocation_params_copy (&alloc_params);
- }
-
- {
- GstStructure *s = gst_caps_get_structure (caps, 0);
- const gchar *target_str = gst_structure_get_string (s, "texture-target");
- gboolean multiple_texture_targets = FALSE;
-
- tex_target = priv->gl_params->target;
- if (target_str)
- tex_target = gst_gl_texture_target_from_string (target_str);
-
- if (gst_buffer_pool_config_has_option (config,
- GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_2D)) {
- if (tex_target && tex_target != GST_GL_TEXTURE_TARGET_2D)
- multiple_texture_targets = TRUE;
- tex_target = GST_GL_TEXTURE_TARGET_2D;
- }
- if (gst_buffer_pool_config_has_option (config,
- GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_RECTANGLE)) {
- if (tex_target && tex_target != GST_GL_TEXTURE_TARGET_RECTANGLE)
- multiple_texture_targets = TRUE;
- tex_target = GST_GL_TEXTURE_TARGET_RECTANGLE;
- }
- if (gst_buffer_pool_config_has_option (config,
- GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_EXTERNAL_OES)) {
- if (tex_target && tex_target != GST_GL_TEXTURE_TARGET_EXTERNAL_OES)
- multiple_texture_targets = TRUE;
- tex_target = GST_GL_TEXTURE_TARGET_EXTERNAL_OES;
- }
-
- if (!tex_target)
- tex_target = GST_GL_TEXTURE_TARGET_2D;
-
- if (multiple_texture_targets) {
- GST_WARNING_OBJECT (pool, "Multiple texture targets configured either "
- "through caps or buffer pool options");
- ret = FALSE;
- }
-
- priv->gl_params->target = tex_target;
- }
-
- /* Recalulate the size and offset as we don't add padding between planes. */
- priv->gl_params->v_info->size = 0;
- for (p = 0; p < GST_VIDEO_INFO_N_PLANES (priv->gl_params->v_info); p++) {
- priv->gl_params->v_info->offset[p] = priv->gl_params->v_info->size;
- priv->gl_params->v_info->size +=
- gst_gl_get_plane_data_size (priv->gl_params->v_info,
- priv->gl_params->valign, p);
- }
-
- gst_buffer_pool_config_set_params (config, caps,
- priv->gl_params->v_info->size, min_buffers, max_buffers);
-
- return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config) && ret;
-
- /* ERRORS */
-wrong_config:
- {
- GST_WARNING_OBJECT (pool, "invalid config");
- return FALSE;
- }
-no_caps:
- {
- GST_WARNING_OBJECT (pool, "no caps in config");
- return FALSE;
- }
-wrong_caps:
- {
- GST_WARNING_OBJECT (pool,
- "failed getting geometry from caps %" GST_PTR_FORMAT, caps);
- return FALSE;
- }
-wrong_allocator:
- {
- GST_WARNING_OBJECT (pool, "Incorrect allocator type for this pool");
- return FALSE;
- }
-}
-
-static gboolean
-gst_gl_buffer_pool_start (GstBufferPool * pool)
-{
- return GST_BUFFER_POOL_CLASS (parent_class)->start (pool);
-}
-
-/* This function handles GstBuffer creation */
-static GstFlowReturn
-gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
- GstBufferPoolAcquireParams * params)
-{
- GstGLMemoryAllocator *alloc;
- GstGLBufferPool *glpool = GST_GL_BUFFER_POOL_CAST (pool);
- GstGLBufferPoolPrivate *priv = glpool->priv;
- GstBuffer *buf;
-
- if (!(buf = gst_buffer_new ())) {
- goto no_buffer;
- }
-
- alloc = GST_GL_MEMORY_ALLOCATOR (priv->allocator);
- if (!gst_gl_memory_setup_buffer (alloc, buf, priv->gl_params, NULL, NULL, 0))
- goto mem_create_failed;
-
- if (priv->add_glsyncmeta)
- gst_buffer_add_gl_sync_meta (glpool->context, buf);
-
- *buffer = buf;
-
- return GST_FLOW_OK;
-
- /* ERROR */
-no_buffer:
- {
- GST_WARNING_OBJECT (pool, "can't create image");
- return GST_FLOW_ERROR;
- }
-mem_create_failed:
- {
- GST_WARNING_OBJECT (pool, "Could not create GL Memory");
- return GST_FLOW_ERROR;
- }
-}
-
-/**
- * gst_gl_buffer_pool_new:
- * @context: the #GstGLContext to use
- *
- * Returns: a #GstBufferPool that allocates buffers with #GstGLMemory
- */
-GstBufferPool *
-gst_gl_buffer_pool_new (GstGLContext * context)
-{
- GstGLBufferPool *pool;
-
- pool = g_object_new (GST_TYPE_GL_BUFFER_POOL, NULL);
- gst_object_ref_sink (pool);
- pool->context = gst_object_ref (context);
-
- GST_LOG_OBJECT (pool, "new GL buffer pool for context %" GST_PTR_FORMAT,
- context);
-
- return GST_BUFFER_POOL_CAST (pool);
-}
-
-static void
-gst_gl_buffer_pool_class_init (GstGLBufferPoolClass * klass)
-{
- GObjectClass *gobject_class = (GObjectClass *) klass;
- GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass;
-
- g_type_class_add_private (klass, sizeof (GstGLBufferPoolPrivate));
-
- gobject_class->finalize = gst_gl_buffer_pool_finalize;
-
- gstbufferpool_class->get_options = gst_gl_buffer_pool_get_options;
- gstbufferpool_class->set_config = gst_gl_buffer_pool_set_config;
- gstbufferpool_class->alloc_buffer = gst_gl_buffer_pool_alloc;
- gstbufferpool_class->start = gst_gl_buffer_pool_start;
-}
-
-static void
-gst_gl_buffer_pool_init (GstGLBufferPool * pool)
-{
- GstGLBufferPoolPrivate *priv = NULL;
-
- pool->priv = GST_GL_BUFFER_POOL_GET_PRIVATE (pool);
- priv = pool->priv;
-
- priv->allocator = NULL;
- priv->caps = NULL;
- priv->add_videometa = TRUE;
- priv->add_glsyncmeta = FALSE;
-}
-
-static void
-gst_gl_buffer_pool_finalize (GObject * object)
-{
- GstGLBufferPool *pool = GST_GL_BUFFER_POOL_CAST (object);
- GstGLBufferPoolPrivate *priv = pool->priv;
-
- GST_LOG_OBJECT (pool, "finalize GL buffer pool %p", pool);
-
- if (priv->caps)
- gst_caps_unref (priv->caps);
-
- G_OBJECT_CLASS (gst_gl_buffer_pool_parent_class)->finalize (object);
-
- /* only release the context once all our memory have been deleted */
- if (pool->context) {
- gst_object_unref (pool->context);
- pool->context = NULL;
- }
-
- if (priv->allocator) {
- gst_object_unref (priv->allocator);
- priv->allocator = NULL;
- }
-
- if (priv->gl_params)
- gst_gl_allocation_params_free ((GstGLAllocationParams *) priv->gl_params);
- priv->gl_params = NULL;
-}
-
-/**
- * gst_buffer_pool_config_get_gl_allocation_params:
- * @config: a buffer pool config
- *
- * Returns: (transfer full): the currently set #GstGLAllocationParams or %NULL
- */
-GstGLAllocationParams *
-gst_buffer_pool_config_get_gl_allocation_params (GstStructure * config)
-{
- GstGLAllocationParams *ret;
-
- if (!gst_structure_get (config, "gl-allocation-params",
- GST_TYPE_GL_ALLOCATION_PARAMS, &ret, NULL))
- ret = NULL;
-
- return ret;
-}
-
-/**
- * gst_buffer_pool_config_set_gl_allocation_params:
- * @config: a buffer pool config
- * @params: (transfer none): a #GstGLAllocationParams
- *
- * Sets @params on @config
- */
-void
-gst_buffer_pool_config_set_gl_allocation_params (GstStructure * config,
- GstGLAllocationParams * params)
-{
- g_return_if_fail (config != NULL);
- g_return_if_fail (params != NULL);
-
- gst_structure_set (config, "gl-allocation-params",
- GST_TYPE_GL_ALLOCATION_PARAMS, params, NULL);
-}
diff --git a/gst-libs/gst/gl/gstglbufferpool.h b/gst-libs/gst/gl/gstglbufferpool.h
deleted file mode 100644
index 0921464d5..000000000
--- a/gst-libs/gst/gl/gstglbufferpool.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_GL_BUFFER_POOL_H_
-#define _GST_GL_BUFFER_POOL_H_
-
-#include <gst/video/gstvideometa.h>
-#include <gst/video/gstvideopool.h>
-
-#include <gst/gl/gstglbasememory.h>
-
-G_BEGIN_DECLS
-
-/* buffer pool functions */
-GST_EXPORT
-GType gst_gl_buffer_pool_get_type (void);
-#define GST_TYPE_GL_BUFFER_POOL (gst_gl_buffer_pool_get_type())
-#define GST_IS_GL_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_BUFFER_POOL))
-#define GST_GL_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_BUFFER_POOL, GstGLBufferPool))
-#define GST_GL_BUFFER_POOL_CAST(obj) ((GstGLBufferPool*)(obj))
-
-/**
- * GstGLBufferPool:
- *
- * Opaque GstGLBufferPool struct
- */
-struct _GstGLBufferPool
-{
- GstBufferPool bufferpool;
-
- GstGLContext *context;
-
- /* <private> */
- GstGLBufferPoolPrivate *priv;
-
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GstGLBufferPoolClass:
- *
- * The #GstGLBufferPoolClass structure contains only private data
- */
-struct _GstGLBufferPoolClass
-{
- GstBufferPoolClass parent_class;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GstBufferPool *gst_gl_buffer_pool_new (GstGLContext * context);
-
-GST_EXPORT
-GstGLAllocationParams * gst_buffer_pool_config_get_gl_allocation_params (GstStructure * config);
-GST_EXPORT
-void gst_buffer_pool_config_set_gl_allocation_params (GstStructure * config,
- GstGLAllocationParams * params);
-
-G_END_DECLS
-
-#endif /* _GST_GL_BUFFER_POOL_H_ */
diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c
deleted file mode 100644
index 6bd919754..000000000
--- a/gst-libs/gst/gl/gstglcolorconvert.c
+++ /dev/null
@@ -1,2524 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012-2014 Matthew Waters <ystree00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <stdio.h>
-
-#include "gstglcolorconvert.h"
-
-#include "gl.h"
-#include "gstglfuncs.h"
-#include "gstglsl_private.h"
-
-/**
- * SECTION:gstglcolorconvert
- * @title: GstGLColorConvert
- * @short_description: convert between video color spaces and formats
- * @see_also: #GstGLUpload, #GstGLMemory, #GstGLBaseMemory
- *
- * #GstGLColorConvert is an object that converts between color spaces and/or
- * formats using OpenGL Shaders.
- *
- * A #GstGLColorConvert can be created with gst_gl_color_convert_new(), the
- * configuration negotiated with gst_gl_color_convert_transform_caps() and the
- * conversion performed with gst_gl_color_convert_perform().
- *
- * The glcolorconvertelement provides a GStreamer element that uses
- * #GstGLColorConvert to convert between video formats and color spaces.
- */
-
-#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
-#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
-#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
-#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
-#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-
-static void _do_convert (GstGLContext * context, GstGLColorConvert * convert);
-static gboolean _init_convert (GstGLColorConvert * convert);
-static gboolean _init_convert_fbo (GstGLColorConvert * convert);
-static GstBuffer *_gst_gl_color_convert_perform_unlocked (GstGLColorConvert *
- convert, GstBuffer * inbuf);
-
-static gboolean _do_convert_draw (GstGLContext * context,
- GstGLColorConvert * convert);
-
-/* *INDENT-OFF* */
-
-#define YUV_TO_RGB_COEFFICIENTS \
- "uniform vec3 offset;\n" \
- "uniform vec3 coeff1;\n" \
- "uniform vec3 coeff2;\n" \
- "uniform vec3 coeff3;\n"
-
-/* FIXME: use the colormatrix support from videoconvert */
-
-/* BT. 601 standard with the following ranges:
- * Y = [16..235] (of 255)
- * Cb/Cr = [16..240] (of 255)
- */
-static const gfloat from_yuv_bt601_offset[] = {-0.0625f, -0.5f, -0.5f};
-static const gfloat from_yuv_bt601_rcoeff[] = {1.164f, 0.000f, 1.596f};
-static const gfloat from_yuv_bt601_gcoeff[] = {1.164f,-0.391f,-0.813f};
-static const gfloat from_yuv_bt601_bcoeff[] = {1.164f, 2.018f, 0.000f};
-
-/* BT. 709 standard with the following ranges:
- * Y = [16..235] (of 255)
- * Cb/Cr = [16..240] (of 255)
- */
-static const gfloat from_yuv_bt709_offset[] = {-0.0625f, -0.5f, -0.5f};
-static const gfloat from_yuv_bt709_rcoeff[] = {1.164f, 0.000f, 1.787f};
-static const gfloat from_yuv_bt709_gcoeff[] = {1.164f,-0.213f,-0.531f};
-static const gfloat from_yuv_bt709_bcoeff[] = {1.164f,2.112f, 0.000f};
-
-#define RGB_TO_YUV_COEFFICIENTS \
- "uniform vec3 offset;\n" \
- "uniform vec3 coeff1;\n" \
- "uniform vec3 coeff2;\n" \
- "uniform vec3 coeff3;\n"
-
-/* Matrix inverses of the color matrices found above */
-/* BT. 601 standard with the following ranges:
- * Y = [16..235] (of 255)
- * Cb/Cr = [16..240] (of 255)
- */
-static const gfloat from_rgb_bt601_offset[] = {0.0625f, 0.5f, 0.5f};
-static const gfloat from_rgb_bt601_ycoeff[] = {0.256816f, 0.504154f, 0.0979137f};
-static const gfloat from_rgb_bt601_ucoeff[] = {-0.148246f, -0.29102f, 0.439266f};
-static const gfloat from_rgb_bt601_vcoeff[] = {0.439271f, -0.367833f, -0.071438f};
-
-/* BT. 709 standard with the following ranges:
- * Y = [16..235] (of 255)
- * Cb/Cr = [16..240] (of 255)
- */
-static const gfloat from_rgb_bt709_offset[] = {0.0625f, 0.5f, 0.5f};
-static const gfloat from_rgb_bt709_ycoeff[] = {0.182604f, 0.614526f, 0.061976f};
-static const gfloat from_rgb_bt709_ucoeff[] = {-0.100640f, -0.338688f, 0.439327f};
-static const gfloat from_rgb_bt709_vcoeff[] = {0.440654f, -0.400285f, -0.040370f};
-
-/* GRAY16 to RGB conversion
- * data transfered as GL_LUMINANCE_ALPHA then convert back to GRAY16
- * high byte weight as : 255*256/65535
- * ([0~1] denormalize to [0~255],shift to high byte,normalize to [0~1])
- * low byte weight as : 255/65535 (similar)
- * */
-#define COMPOSE_WEIGHT \
- "const vec2 compose_weight = vec2(0.996109, 0.003891);\n"
-
-#define DEFAULT_UNIFORMS \
- "#ifdef GL_ES\n" \
- "precision mediump float;\n" \
- "#endif\n" \
- "uniform vec2 tex_scale0;\n" \
- "uniform vec2 tex_scale1;\n" \
- "uniform vec2 tex_scale2;\n" \
- "uniform float width;\n" \
- "uniform float height;\n" \
- "uniform float poffset_x;\n" \
- "uniform float poffset_y;\n"
-
-#define MAX_FUNCTIONS 4
-
-#define glsl_OES_extension_string "#extension GL_OES_EGL_image_external : require \n"
-
-struct shader_templ
-{
- const gchar *extensions;
- const gchar *uniforms;
- const gchar *functions[MAX_FUNCTIONS];
- const gchar *body;
-
- GstGLTextureTarget target;
-};
-
-#define glsl_func_yuv_to_rgb \
- "vec3 yuv_to_rgb (vec3 val, vec3 offset, vec3 ycoeff, vec3 ucoeff, vec3 vcoeff) {\n" \
- " vec3 rgb;\n" \
- " val += offset;\n" \
- " rgb.r = dot(val, ycoeff);\n" \
- " rgb.g = dot(val, ucoeff);\n" \
- " rgb.b = dot(val, vcoeff);\n" \
- " return rgb;\n" \
- "}\n"
-
-#define glsl_func_rgb_to_yuv \
- "vec3 rgb_to_yuv (vec3 val, vec3 offset, vec3 rcoeff, vec3 gcoeff, vec3 bcoeff) {\n" \
- " vec3 yuv;\n" \
- " yuv.r = dot(val.rgb, rcoeff);\n" \
- " yuv.g = dot(val.rgb, gcoeff);\n" \
- " yuv.b = dot(val.rgb, bcoeff);\n" \
- " yuv += offset;\n" \
- " return yuv;\n" \
- "}\n"
-
-/* Channel reordering for XYZ <-> ZYX conversion */
-static const struct shader_templ templ_REORDER =
- { NULL,
- DEFAULT_UNIFORMS "uniform sampler2D tex;\n",
- { NULL, },
- "vec4 t = texture2D(tex, texcoord * tex_scale0);\n"
- "%s\n" /* clobber alpha channel? */
- "gl_FragColor = vec4(t.%c, t.%c, t.%c, t.%c);\n",
- GST_GL_TEXTURE_TARGET_2D
- };
-
-/* GRAY16 to RGB conversion
- * data transfered as GL_LUMINANCE_ALPHA then convert back to GRAY16
- * high byte weight as : 255*256/65535
- * ([0~1] denormalize to [0~255],shift to high byte,normalize to [0~1])
- * low byte weight as : 255/65535 (similar)
- * */
-static const struct shader_templ templ_COMPOSE =
- { NULL,
- DEFAULT_UNIFORMS COMPOSE_WEIGHT "uniform sampler2D tex;\n",
- { NULL, },
- "vec4 rgba;\n"
- "vec4 t = texture2D(tex, texcoord * tex_scale0);\n"
- "rgba.rgb = vec3 (dot(t.%c%c, compose_weight));"
- "rgba.a = 1.0;\n"
- "gl_FragColor = vec4(rgba.%c, rgba.%c, rgba.%c, rgba.%c);\n",
- GST_GL_TEXTURE_TARGET_2D
- };
-
-static const struct shader_templ templ_AYUV_to_RGB =
- { NULL,
- DEFAULT_UNIFORMS YUV_TO_RGB_COEFFICIENTS "uniform sampler2D tex;\n",
- { glsl_func_yuv_to_rgb, NULL, },
- "vec4 texel, rgba;\n"
- "texel = texture2D(tex, texcoord * tex_scale0);\n"
- "rgba.rgb = yuv_to_rgb (texel.yzw, offset, coeff1, coeff2, coeff3);\n"
- "rgba.a = texel.r;\n"
- "gl_FragColor=vec4(rgba.%c,rgba.%c,rgba.%c,rgba.%c);\n",
- GST_GL_TEXTURE_TARGET_2D
- };
-
-static const struct shader_templ templ_RGB_to_AYUV =
- { NULL,
- DEFAULT_UNIFORMS RGB_TO_YUV_COEFFICIENTS "uniform sampler2D tex;\n",
- { glsl_func_rgb_to_yuv, NULL, },
- "vec4 texel, ayuv;\n"
- "texel = texture2D(tex, texcoord).%c%c%c%c;\n"
- "ayuv.yzw = rgb_to_yuv (texel.rgb, offset, coeff1, coeff2, coeff3);\n"
- "ayuv.x = %s;\n"
- "gl_FragColor = ayuv;\n",
- GST_GL_TEXTURE_TARGET_2D
- };
-
-/* YUV to RGB conversion */
-static const struct shader_templ templ_PLANAR_YUV_to_RGB =
- { NULL,
- DEFAULT_UNIFORMS YUV_TO_RGB_COEFFICIENTS "uniform sampler2D Ytex, Utex, Vtex;\n",
- { glsl_func_yuv_to_rgb, NULL, },
- "vec4 texel, rgba;\n"
- /* FIXME: should get the sampling right... */
- "texel.x = texture2D(Ytex, texcoord * tex_scale0).r;\n"
- "texel.y = texture2D(Utex, texcoord * tex_scale1).r;\n"
- "texel.z = texture2D(Vtex, texcoord * tex_scale2).r;\n"
- "rgba.rgb = yuv_to_rgb (texel.xyz, offset, coeff1, coeff2, coeff3);\n"
- "rgba.a = 1.0;\n"
- "gl_FragColor=vec4(rgba.%c,rgba.%c,rgba.%c,rgba.%c);\n",
- GST_GL_TEXTURE_TARGET_2D
- };
-
-static const struct shader_templ templ_RGB_to_PLANAR_YUV =
- { NULL,
- DEFAULT_UNIFORMS RGB_TO_YUV_COEFFICIENTS "uniform sampler2D tex;\n"
- "uniform vec2 chroma_sampling;\n",
- { glsl_func_rgb_to_yuv, NULL, },
- "vec4 texel;\n"
- "vec3 yuv;\n"
- "texel = texture2D(tex, texcoord).%c%c%c%c;\n"
- /* FIXME: this is not quite correct yet */
- "vec4 uv_texel = vec4(0.0);\n"
- /* One u and v sample can be generated by a nxm sized block given by
- * @chroma_sampling. The result is the average of all the values in the
- * block computed with a rolling average.
- */
- "vec2 unnormalization;\n"
- "if (texcoord.x == v_texcoord.x) {\n"
- " unnormalization = vec2(width, height);\n"
- "} else {\n"
- " unnormalization = vec2 (1.0);\n"
- "}\n"
- /* scale for chroma size */
- "vec2 chroma_pos = texcoord * chroma_sampling * unnormalization;\n"
- /* offset chroma to the center of the first texel in the block */
- "chroma_pos -= clamp(chroma_sampling * 0.5 - 0.5, vec2(0.0), chroma_sampling);\n"
- "if (chroma_pos.x < width && chroma_pos.y < height) {\n"
- " for (int i = 0; i < int(chroma_sampling.x); i++) {\n"
- " vec2 delta = vec2 (float(i), 0.0);\n"
- " for (int j = 0; j < int(chroma_sampling.y); j++) {\n"
- " int n = (i+1)*(j+1);\n"
- " delta.y = float(j);\n"
- " vec4 s = texture2D(tex, (chroma_pos + delta) / unnormalization).%c%c%c%c;\n"
- /* rolling average */
- " uv_texel = (float(n-1) * uv_texel + s) / float(n);\n"
- " }\n"
- " }\n"
- "}\n"
- "yuv.x = rgb_to_yuv (texel.rgb, offset, coeff1, coeff2, coeff3).x;\n"
- "yuv.yz = rgb_to_yuv (uv_texel.rgb, offset, coeff1, coeff2, coeff3).yz;\n"
- "gl_FragData[0] = vec4(yuv.x, 0.0, 0.0, 1.0);\n"
- "gl_FragData[1] = vec4(yuv.y, 0.0, 0.0, 1.0);\n"
- "gl_FragData[2] = vec4(yuv.z, 0.0, 0.0, 1.0);\n",
- GST_GL_TEXTURE_TARGET_2D
- };
-
-/* NV12/NV21 to RGB conversion */
-static const struct shader_templ templ_NV12_NV21_to_RGB =
- { NULL,
- DEFAULT_UNIFORMS YUV_TO_RGB_COEFFICIENTS "uniform sampler2D Ytex, UVtex;\n",
- { glsl_func_yuv_to_rgb, NULL, },
- "vec4 rgba;\n"
- "vec3 yuv;\n"
- /* FIXME: should get the sampling right... */
- "yuv.x=texture2D(Ytex, texcoord * tex_scale0).r;\n"
- "yuv.yz=texture2D(UVtex, texcoord * tex_scale1).%c%c;\n"
- "rgba.rgb = yuv_to_rgb (yuv, offset, coeff1, coeff2, coeff3);\n"
- "rgba.a = 1.0;\n"
- "gl_FragColor=vec4(rgba.%c,rgba.%c,rgba.%c,rgba.%c);\n",
- GST_GL_TEXTURE_TARGET_2D
- };
-
-/* RGB to NV12/NV21 conversion */
-/* NV12: u, v
- NV21: v, u */
-static const struct shader_templ templ_RGB_to_NV12_NV21 =
- { NULL,
- DEFAULT_UNIFORMS RGB_TO_YUV_COEFFICIENTS "uniform sampler2D tex;\n",
- { glsl_func_rgb_to_yuv, NULL, },
- "vec4 texel, uv_texel;\n"
- "vec3 yuv;\n"
- "texel = texture2D(tex, texcoord).%c%c%c%c;\n"
- "uv_texel = texture2D(tex, texcoord * tex_scale0 * 2.0).%c%c%c%c;\n"
- "yuv.x = rgb_to_yuv (texel.rgb, offset, coeff1, coeff2, coeff3).x;\n"
- "yuv.yz = rgb_to_yuv (uv_texel.rgb, offset, coeff1, coeff2, coeff3).yz;\n"
- "gl_FragData[0] = vec4(yuv.x, 0.0, 0.0, 1.0);\n"
- "gl_FragData[1] = vec4(yuv.%c, yuv.%c, 0.0, 1.0);\n",
- GST_GL_TEXTURE_TARGET_2D
- };
-
-/* YUY2:r,g,a
- UYVY:a,b,r */
-static const struct shader_templ templ_YUY2_UYVY_to_RGB =
- { NULL,
- DEFAULT_UNIFORMS YUV_TO_RGB_COEFFICIENTS "uniform sampler2D Ytex;\n",
- { glsl_func_yuv_to_rgb, NULL, },
- "vec4 rgba, uv_texel;\n"
- "vec3 yuv;\n"
- /* FIXME: should get the sampling right... */
- "float dx1 = -poffset_x;\n"
- "float dx2 = 0.0;\n"
- "yuv.x = texture2D(Ytex, texcoord * tex_scale0).%c;\n"
- /* v_texcoord are normalized, texcoord may not be e.g. rectangle textures */
- "float inorder = mod (v_texcoord.x * width, 2.0);\n"
- "if (inorder < 1.0) {\n"
- " dx2 = -dx1;\n"
- " dx1 = 0.0;\n"
- "}\n"
- "uv_texel.rg = texture2D(Ytex, texcoord * tex_scale0 + vec2(dx1, 0.0)).r%c;\n"
- "uv_texel.ba = texture2D(Ytex, texcoord * tex_scale0 + vec2(dx2, 0.0)).r%c;\n"
- "yuv.yz = uv_texel.%c%c;\n"
- "rgba.rgb = yuv_to_rgb (yuv, offset, coeff1, coeff2, coeff3);\n"
- "rgba.a = 1.0;\n"
- "gl_FragColor = vec4(rgba.%c,rgba.%c,rgba.%c,rgba.%c);\n",
- GST_GL_TEXTURE_TARGET_2D
- };
-
-static const struct shader_templ templ_RGB_to_YUY2_UYVY =
- { NULL,
- DEFAULT_UNIFORMS RGB_TO_YUV_COEFFICIENTS "uniform sampler2D tex;\n",
- { glsl_func_rgb_to_yuv, NULL, },
- "vec4 texel1, texel2;\n"
- "vec3 yuv, yuv1, yuv2;\n"
- "float fx, dx, fy;\n"
- /* v_texcoord are normalized, texcoord may not be e.g. rectangle textures */
- "float inorder = mod (v_texcoord.x * width, 2.0);\n"
- "fx = texcoord.x;\n"
- "dx = poffset_x;\n"
- "if (inorder > 1.0) {\n"
- " dx = -dx;\n"
- "}\n"
- "fy = texcoord.y;\n"
- "texel1 = texture2D(tex, vec2(fx, fy)).%c%c%c%c;\n"
- "texel2 = texture2D(tex, vec2(fx + dx, fy)).%c%c%c%c;\n"
- "yuv1 = rgb_to_yuv (texel1.rgb, offset, coeff1, coeff2, coeff3);\n"
- "yuv2 = rgb_to_yuv (texel2.rgb, offset, coeff1, coeff2, coeff3);\n"
- "yuv.x = yuv1.x;\n"
- "yuv.yz = (yuv1.yz + yuv2.yz) * 0.5;\n"
- "if (inorder < 1.0) {\n"
- " gl_FragColor = vec4(yuv.%c, yuv.%c, 0.0, 0.0);\n"
- "} else {\n"
- " gl_FragColor = vec4(yuv.%c, yuv.%c, 0.0, 0.0);\n"
- "}\n",
- GST_GL_TEXTURE_TARGET_2D
- };
-
-static const gchar text_vertex_shader[] =
- "attribute vec4 a_position; \n"
- "attribute vec2 a_texcoord; \n"
- "varying vec2 v_texcoord; \n"
- "void main() \n"
- "{ \n"
- " gl_Position = a_position; \n"
- " v_texcoord = a_texcoord; \n"
- "} \n";
-
-static const GLfloat vertices[] = {
- 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
- -1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
- -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
- 1.0f, 1.0f, 0.0f, 1.0f, 1.0f
-};
-
-static const GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
-
-/* *INDENT-ON* */
-
-struct ConvertInfo
-{
- gint in_n_textures;
- gint out_n_textures;
- const struct shader_templ *templ;
- gchar *frag_body;
- gchar *frag_prog;
- const gchar *shader_tex_names[GST_VIDEO_MAX_PLANES];
- gfloat *cms_offset;
- gfloat *cms_coeff1; /* r,y */
- gfloat *cms_coeff2; /* g,u */
- gfloat *cms_coeff3; /* b,v */
- gfloat chroma_sampling[2];
-};
-
-struct _GstGLColorConvertPrivate
-{
- gboolean result;
-
- struct ConvertInfo convert_info;
-
- GstGLTextureTarget from_texture_target;
- GstGLTextureTarget to_texture_target;
-
- GstGLMemory *in_tex[GST_VIDEO_MAX_PLANES];
- GstGLMemory *out_tex[GST_VIDEO_MAX_PLANES];
-
- GstGLFormat in_tex_formats[GST_VIDEO_MAX_PLANES];
-
- GLuint vao;
- GLuint vertex_buffer;
- GLuint vbo_indices;
- GLuint attr_position;
- GLuint attr_texture;
-
- GstCaps *in_caps;
- GstCaps *out_caps;
-
- GstBufferPool *pool;
- gboolean pool_started;
-};
-
-GST_DEBUG_CATEGORY_STATIC (gst_gl_color_convert_debug);
-#define GST_CAT_DEFAULT gst_gl_color_convert_debug
-
-#define DEBUG_INIT \
- GST_DEBUG_CATEGORY_INIT (gst_gl_color_convert_debug, "glconvert", 0, "convert");
-
-G_DEFINE_TYPE_WITH_CODE (GstGLColorConvert, gst_gl_color_convert,
- GST_TYPE_OBJECT, DEBUG_INIT);
-static void gst_gl_color_convert_finalize (GObject * object);
-static void gst_gl_color_convert_reset (GstGLColorConvert * convert);
-
-#define GST_GL_COLOR_CONVERT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
- GST_TYPE_GL_COLOR_CONVERT, GstGLColorConvertPrivate))
-
-static void
-gst_gl_color_convert_class_init (GstGLColorConvertClass * klass)
-{
- g_type_class_add_private (klass, sizeof (GstGLColorConvertPrivate));
-
- G_OBJECT_CLASS (klass)->finalize = gst_gl_color_convert_finalize;
-}
-
-static void
-gst_gl_color_convert_init (GstGLColorConvert * convert)
-{
- convert->priv = GST_GL_COLOR_CONVERT_GET_PRIVATE (convert);
-
- gst_gl_color_convert_reset (convert);
-}
-
-/**
- * gst_gl_color_convert_new:
- * @context: a #GstGLContext
- *
- * Returns: (transfer full): a new #GstGLColorConvert object
- *
- * Since: 1.4
- */
-GstGLColorConvert *
-gst_gl_color_convert_new (GstGLContext * context)
-{
- GstGLColorConvert *convert;
-
- convert = g_object_new (GST_TYPE_GL_COLOR_CONVERT, NULL);
- gst_object_ref_sink (convert);
-
- convert->context = gst_object_ref (context);
-
- gst_video_info_set_format (&convert->in_info, GST_VIDEO_FORMAT_ENCODED, 0, 0);
- gst_video_info_set_format (&convert->out_info, GST_VIDEO_FORMAT_ENCODED, 0,
- 0);
-
- GST_DEBUG_OBJECT (convert,
- "Created new colorconvert for context %" GST_PTR_FORMAT, context);
-
- return convert;
-}
-
-static void
-gst_gl_color_convert_finalize (GObject * object)
-{
- GstGLColorConvert *convert;
-
- convert = GST_GL_COLOR_CONVERT (object);
-
- gst_gl_color_convert_reset (convert);
-
- if (convert->context) {
- gst_object_unref (convert->context);
- convert->context = NULL;
- }
-
- G_OBJECT_CLASS (gst_gl_color_convert_parent_class)->finalize (object);
-}
-
-static void
-_reset_gl (GstGLContext * context, GstGLColorConvert * convert)
-{
- const GstGLFuncs *gl = context->gl_vtable;
-
- if (convert->priv->vao) {
- gl->DeleteVertexArrays (1, &convert->priv->vao);
- convert->priv->vao = 0;
- }
-
- if (convert->priv->vertex_buffer) {
- gl->DeleteBuffers (1, &convert->priv->vertex_buffer);
- convert->priv->vertex_buffer = 0;
- }
-
- if (convert->priv->vbo_indices) {
- gl->DeleteBuffers (1, &convert->priv->vbo_indices);
- convert->priv->vbo_indices = 0;
- }
-}
-
-static void
-gst_gl_color_convert_reset_shader (GstGLColorConvert * convert)
-{
- convert->priv->convert_info.chroma_sampling[0] = 1.0f;
- convert->priv->convert_info.chroma_sampling[1] = 1.0f;
-
- if (convert->priv->convert_info.frag_prog) {
- g_free (convert->priv->convert_info.frag_prog);
- convert->priv->convert_info.frag_prog = NULL;
- }
- if (convert->priv->convert_info.frag_body) {
- g_free (convert->priv->convert_info.frag_body);
- convert->priv->convert_info.frag_body = NULL;
- }
- if (convert->shader) {
- gst_object_unref (convert->shader);
- convert->shader = NULL;
- }
-
- convert->initted = FALSE;
-}
-
-static void
-gst_gl_color_convert_reset (GstGLColorConvert * convert)
-{
- guint i;
-
- if (convert->fbo) {
- gst_object_unref (convert->fbo);
- convert->fbo = NULL;
- }
-
- for (i = 0; i < convert->priv->convert_info.out_n_textures; i++) {
- if (convert->priv->out_tex[i])
- gst_memory_unref ((GstMemory *) convert->priv->out_tex[i]);
- convert->priv->out_tex[i] = NULL;
- }
-
- if (convert->priv->pool) {
- convert->priv->pool_started = FALSE;
-
- gst_object_unref (convert->priv->pool);
- convert->priv->pool = NULL;
- }
-
- gst_caps_replace (&convert->priv->in_caps, NULL);
- gst_caps_replace (&convert->priv->out_caps, NULL);
-
- if (convert->context) {
- gst_gl_context_thread_add (convert->context,
- (GstGLContextThreadFunc) _reset_gl, convert);
- }
-
- gst_gl_color_convert_reset_shader (convert);
-}
-
-static gboolean
-_gst_gl_color_convert_can_passthrough_info (GstVideoInfo * in,
- GstVideoInfo * out)
-{
- gint i;
-
- if (GST_VIDEO_INFO_FORMAT (in) != GST_VIDEO_INFO_FORMAT (out))
- return FALSE;
- if (GST_VIDEO_INFO_WIDTH (in) != GST_VIDEO_INFO_WIDTH (out))
- return FALSE;
- if (GST_VIDEO_INFO_HEIGHT (in) != GST_VIDEO_INFO_HEIGHT (out))
- return FALSE;
- if (GST_VIDEO_INFO_SIZE (in) != GST_VIDEO_INFO_SIZE (out))
- return FALSE;
-
- for (i = 0; i < in->finfo->n_planes; i++) {
- if (in->stride[i] != out->stride[i])
- return FALSE;
- if (in->offset[i] != out->offset[i])
- return FALSE;
- }
-
- if (!gst_video_colorimetry_is_equal (&in->colorimetry, &out->colorimetry))
- return FALSE;
- if (in->chroma_site != out->chroma_site)
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
-_gst_gl_color_convert_set_caps_unlocked (GstGLColorConvert * convert,
- GstCaps * in_caps, GstCaps * out_caps)
-{
- GstVideoInfo in_info, out_info;
- GstCapsFeatures *in_features, *out_features;
- GstGLTextureTarget from_target, to_target;
- gboolean passthrough;
-
- g_return_val_if_fail (convert != NULL, FALSE);
- g_return_val_if_fail (in_caps, FALSE);
- g_return_val_if_fail (out_caps, FALSE);
-
- GST_LOG_OBJECT (convert, "Setting caps in %" GST_PTR_FORMAT
- " out %" GST_PTR_FORMAT, in_caps, out_caps);
-
- if (!gst_video_info_from_caps (&in_info, in_caps))
- g_assert_not_reached ();
-
- if (!gst_video_info_from_caps (&out_info, out_caps))
- g_assert_not_reached ();
-
- g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&in_info) !=
- GST_VIDEO_FORMAT_UNKNOWN, FALSE);
- g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&in_info) !=
- GST_VIDEO_FORMAT_ENCODED, FALSE);
- g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&out_info) !=
- GST_VIDEO_FORMAT_UNKNOWN, FALSE);
- g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&out_info) !=
- GST_VIDEO_FORMAT_ENCODED, FALSE);
-
- in_features = gst_caps_get_features (in_caps, 0);
- out_features = gst_caps_get_features (out_caps, 0);
-
- if (!gst_caps_features_contains (in_features,
- GST_CAPS_FEATURE_MEMORY_GL_MEMORY)
- || !gst_caps_features_contains (out_features,
- GST_CAPS_FEATURE_MEMORY_GL_MEMORY)) {
- return FALSE;
- }
-
- {
- GstStructure *in_s = gst_caps_get_structure (in_caps, 0);
- GstStructure *out_s = gst_caps_get_structure (out_caps, 0);
-
- if (gst_structure_has_field_typed (in_s, "texture-target", G_TYPE_STRING))
- from_target =
- gst_gl_texture_target_from_string (gst_structure_get_string (in_s,
- "texture-target"));
- else
- from_target = GST_GL_TEXTURE_TARGET_2D;
-
- if (gst_structure_has_field_typed (out_s, "texture-target", G_TYPE_STRING))
- to_target =
- gst_gl_texture_target_from_string (gst_structure_get_string (out_s,
- "texture-target"));
- else
- to_target = GST_GL_TEXTURE_TARGET_2D;
-
- if (to_target == GST_GL_TEXTURE_TARGET_NONE
- || from_target == GST_GL_TEXTURE_TARGET_NONE)
- /* invalid caps */
- return FALSE;
- }
-
- if (gst_video_info_is_equal (&convert->in_info, &in_info) &&
- gst_video_info_is_equal (&convert->out_info, &out_info) &&
- convert->priv->from_texture_target == from_target &&
- convert->priv->to_texture_target == to_target)
- return TRUE;
-
- /* If input and output are identical, pass through directly */
- passthrough =
- _gst_gl_color_convert_can_passthrough_info (&in_info, &out_info) &&
- from_target == to_target;
-
- if (!passthrough && to_target != GST_GL_TEXTURE_TARGET_2D
- && to_target != GST_GL_TEXTURE_TARGET_RECTANGLE)
- return FALSE;
-
- {
- guint yuv_gray_flags, in_flags, out_flags;
-
- in_flags = GST_VIDEO_FORMAT_INFO_FLAGS (in_info.finfo);
- out_flags = GST_VIDEO_FORMAT_INFO_FLAGS (out_info.finfo);
- yuv_gray_flags = GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_GRAY;
-
- /* GRAY/YUV -> GRAY/YUV is not supported for non-passthrough */
- if (!passthrough && (in_flags & yuv_gray_flags) != 0
- && (out_flags & yuv_gray_flags) != 0)
- return FALSE;
- }
-
- gst_gl_color_convert_reset (convert);
- convert->in_info = in_info;
- convert->out_info = out_info;
- gst_caps_replace (&convert->priv->in_caps, in_caps);
- gst_caps_replace (&convert->priv->out_caps, out_caps);
- convert->priv->from_texture_target = from_target;
- convert->priv->to_texture_target = to_target;
- convert->initted = FALSE;
-
- convert->passthrough = passthrough;
-#ifndef GST_DISABLE_GST_DEBUG
- if (G_UNLIKELY (convert->passthrough))
- GST_DEBUG_OBJECT (convert,
- "Configuring passthrough mode for same in/out caps");
- else {
- GST_DEBUG_OBJECT (convert, "Color converting %" GST_PTR_FORMAT
- " to %" GST_PTR_FORMAT, in_caps, out_caps);
- }
-#endif
-
- return TRUE;
-}
-
-/**
- * gst_gl_color_convert_set_caps:
- * @convert: a #GstGLColorConvert
- * @in_caps: input #GstCaps
- * @out_caps: output #GstCaps
- *
- * Initializes @convert with the information required for conversion.
- *
- * Since: 1.6
- */
-gboolean
-gst_gl_color_convert_set_caps (GstGLColorConvert * convert,
- GstCaps * in_caps, GstCaps * out_caps)
-{
- gboolean ret;
-
- GST_OBJECT_LOCK (convert);
- ret = _gst_gl_color_convert_set_caps_unlocked (convert, in_caps, out_caps);
- GST_OBJECT_UNLOCK (convert);
-
- return ret;
-}
-
-/**
- * gst_gl_color_convert_decide_allocation:
- * @convert: a #GstGLColorConvert
- * @query: a completed ALLOCATION #GstQuery
- *
- * Provides an implementation of #GstBaseTransfromClass::decide_allocation()
- *
- * Returns: whether the allocation parameters were successfully chosen
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_color_convert_decide_allocation (GstGLColorConvert * convert,
- GstQuery * query)
-{
- GstBufferPool *pool = NULL;
- GstStructure *config;
- GstCaps *caps;
- guint min, max, size, n, i;
- gboolean update_pool;
- GstGLVideoAllocationParams *params;
- GstVideoInfo vinfo;
-
- gst_query_parse_allocation (query, &caps, NULL);
- if (!caps)
- return FALSE;
-
- gst_video_info_from_caps (&vinfo, caps);
-
- n = gst_query_get_n_allocation_pools (query);
- if (n > 0) {
- update_pool = TRUE;
- for (i = 0; i < n; i++) {
- gst_query_parse_nth_allocation_pool (query, i, &pool, &size, &min, &max);
-
- if (!pool || !GST_IS_GL_BUFFER_POOL (pool)) {
- if (pool)
- gst_object_unref (pool);
- pool = NULL;
- }
- }
- }
-
- if (!pool) {
- GstVideoInfo vinfo;
-
- gst_video_info_init (&vinfo);
- size = vinfo.size;
- min = max = 0;
- update_pool = FALSE;
- }
-
- if (!pool)
- pool = gst_gl_buffer_pool_new (convert->context);
-
- config = gst_buffer_pool_get_config (pool);
-
- gst_buffer_pool_config_set_params (config, caps, size, min, max);
- gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
- if (gst_query_find_allocation_meta (query, GST_GL_SYNC_META_API_TYPE, NULL))
- gst_buffer_pool_config_add_option (config,
- GST_BUFFER_POOL_OPTION_GL_SYNC_META);
-
- params = gst_gl_video_allocation_params_new (convert->context, NULL, &vinfo,
- 0, NULL, convert->priv->to_texture_target, 0);
- gst_buffer_pool_config_set_gl_allocation_params (config,
- (GstGLAllocationParams *) params);
- gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
-
- if (!gst_buffer_pool_set_config (pool, config))
- GST_WARNING_OBJECT (convert, "Failed to set buffer pool config");
-
- if (update_pool)
- gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
- else
- gst_query_add_allocation_pool (query, pool, size, min, max);
-
- if (convert->priv->pool) {
- gst_object_unref (convert->priv->pool);
- convert->priv->pool_started = FALSE;
- }
- convert->priv->pool = pool;
-
- return TRUE;
-}
-
-static void
-_init_value_string_list (GValue * list, ...)
-{
- GValue item = G_VALUE_INIT;
- gchar *str;
- va_list args;
-
- g_value_init (list, GST_TYPE_LIST);
-
- va_start (args, list);
- while ((str = va_arg (args, gchar *))) {
- g_value_init (&item, G_TYPE_STRING);
- g_value_set_string (&item, str);
-
- gst_value_list_append_value (list, &item);
- g_value_unset (&item);
- }
- va_end (args);
-}
-
-/* copies the given caps */
-static GstCaps *
-gst_gl_color_convert_caps_transform_format_info (GstCaps * caps)
-{
- GstStructure *st;
- GstCapsFeatures *f;
- gint i, n;
- GstCaps *res;
- GValue rgb_formats = G_VALUE_INIT;
-
- _init_value_string_list (&rgb_formats, "RGBA", "ARGB", "BGRA", "ABGR", "RGBx",
- "xRGB", "BGRx", "xBGR", "RGB", "BGR", NULL);
-
- res = gst_caps_new_empty ();
-
- n = gst_caps_get_size (caps);
- for (i = 0; i < n; i++) {
- const GValue *format;
-
- st = gst_caps_get_structure (caps, i);
- f = gst_caps_get_features (caps, i);
-
- format = gst_structure_get_value (st, "format");
- st = gst_structure_copy (st);
- if (GST_VALUE_HOLDS_LIST (format)) {
- gboolean have_rgb_formats = FALSE;
- GValue passthrough_formats = G_VALUE_INIT;
- gint j, len;
-
- g_value_init (&passthrough_formats, GST_TYPE_LIST);
- len = gst_value_list_get_size (format);
- for (j = 0; j < len; j++) {
- const GValue *val;
-
- val = gst_value_list_get_value (format, j);
- if (G_VALUE_HOLDS_STRING (val)) {
- const gchar *format_str = g_value_get_string (val);
- GstVideoFormat v_format = gst_video_format_from_string (format_str);
- const GstVideoFormatInfo *t_info =
- gst_video_format_get_info (v_format);
- if (GST_VIDEO_FORMAT_INFO_FLAGS (t_info) & (GST_VIDEO_FORMAT_FLAG_YUV
- | GST_VIDEO_FORMAT_FLAG_GRAY)) {
- gst_value_list_append_value (&passthrough_formats, val);
- } else if (GST_VIDEO_FORMAT_INFO_FLAGS (t_info) &
- GST_VIDEO_FORMAT_FLAG_RGB) {
- have_rgb_formats = TRUE;
- break;
- }
- }
- }
- if (have_rgb_formats) {
- gst_structure_remove_fields (st, "format", NULL);
- } else {
- /* add passthrough structure, then the rgb conversion structure */
- gst_structure_set_value (st, "format", &passthrough_formats);
- gst_caps_append_structure_full (res, gst_structure_copy (st),
- gst_caps_features_copy (f));
- gst_structure_set_value (st, "format", &rgb_formats);
- }
- g_value_unset (&passthrough_formats);
- } else if (G_VALUE_HOLDS_STRING (format)) {
- const gchar *format_str = g_value_get_string (format);
- GstVideoFormat v_format = gst_video_format_from_string (format_str);
- const GstVideoFormatInfo *t_info = gst_video_format_get_info (v_format);
- if (GST_VIDEO_FORMAT_INFO_FLAGS (t_info) & (GST_VIDEO_FORMAT_FLAG_YUV |
- GST_VIDEO_FORMAT_FLAG_GRAY)) {
- /* add passthrough structure, then the rgb conversion structure */
- gst_structure_set_value (st, "format", format);
- gst_caps_append_structure_full (res, gst_structure_copy (st),
- gst_caps_features_copy (f));
- gst_structure_set_value (st, "format", &rgb_formats);
- } else { /* RGB */
- gst_structure_remove_fields (st, "format", NULL);
- }
- }
- gst_structure_remove_fields (st, "colorimetry", "chroma-site",
- "texture-target", NULL);
-
- gst_caps_append_structure_full (res, st, gst_caps_features_copy (f));
- }
-
- g_value_unset (&rgb_formats);
-
- return res;
-}
-
-/**
- * gst_gl_color_convert_transform_caps:
- * @context: a #GstGLContext to use for transforming @caps
- * @direction: a #GstPadDirection
- * @caps: (transfer none): the #GstCaps to transform
- * @filter: (transfer none): a set of filter #GstCaps
- *
- * Provides an implementation of #GstBaseTransformClass::transform_caps()
- *
- * Returns: (transfer full): the converted #GstCaps
- *
- * Since: 1.6
- */
-GstCaps *
-gst_gl_color_convert_transform_caps (GstGLContext * context,
- GstPadDirection direction, GstCaps * caps, GstCaps * filter)
-{
- caps = gst_gl_color_convert_caps_transform_format_info (caps);
-
- if (filter) {
- GstCaps *tmp;
-
- tmp = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
- gst_caps_unref (caps);
- caps = tmp;
- }
-
- return caps;
-}
-
-/* fixation from videoconvert */
-#define SCORE_FORMAT_CHANGE 1
-#define SCORE_DEPTH_CHANGE 1
-#define SCORE_ALPHA_CHANGE 1
-#define SCORE_CHROMA_W_CHANGE 1
-#define SCORE_CHROMA_H_CHANGE 1
-#define SCORE_PALETTE_CHANGE 1
-
-#define SCORE_COLORSPACE_LOSS 2 /* RGB <-> YUV */
-#define SCORE_DEPTH_LOSS 4 /* change bit depth */
-#define SCORE_ALPHA_LOSS 8 /* lose the alpha channel */
-#define SCORE_CHROMA_W_LOSS 16 /* vertical subsample */
-#define SCORE_CHROMA_H_LOSS 32 /* horizontal subsample */
-#define SCORE_PALETTE_LOSS 64 /* convert to palette format */
-#define SCORE_COLOR_LOSS 128 /* convert to GRAY */
-
-#define COLORSPACE_MASK (GST_VIDEO_FORMAT_FLAG_YUV | \
- GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_GRAY)
-#define ALPHA_MASK (GST_VIDEO_FORMAT_FLAG_ALPHA)
-#define PALETTE_MASK (GST_VIDEO_FORMAT_FLAG_PALETTE)
-
-static GstGLTextureTarget
-_texture_target_demask (guint target_mask)
-{
- if (target_mask & (1 << GST_GL_TEXTURE_TARGET_2D)) {
- return GST_GL_TEXTURE_TARGET_2D;
- }
- if (target_mask & (1 << GST_GL_TEXTURE_TARGET_RECTANGLE)) {
- return GST_GL_TEXTURE_TARGET_RECTANGLE;
- }
- if (target_mask & (1 << GST_GL_TEXTURE_TARGET_EXTERNAL_OES)) {
- return GST_GL_TEXTURE_TARGET_EXTERNAL_OES;
- }
-
- return 0;
-}
-
-/* calculate how much loss a conversion would be */
-static void
-score_format_target (const GstVideoFormatInfo * in_info, guint targets_mask,
- GstVideoFormat v_format, guint other_targets_mask, gint * min_loss,
- const GstVideoFormatInfo ** out_info, GstGLTextureTarget * result)
-{
- const GstVideoFormatInfo *t_info;
- GstVideoFormatFlags in_flags, t_flags;
- gint loss;
-
- t_info = gst_video_format_get_info (v_format);
- if (!t_info)
- return;
-
- /* accept input format immediately without loss */
- if (in_info == t_info && (targets_mask & other_targets_mask) != 0) {
- *min_loss = 0;
- *out_info = t_info;
- *result = _texture_target_demask (targets_mask & other_targets_mask);
- return;
- }
-
- /* can only passthrough external-oes textures */
- other_targets_mask &= ~(1 << GST_GL_TEXTURE_TARGET_EXTERNAL_OES);
- if (other_targets_mask == 0)
- return;
- /* try to keep the same target */
- if (targets_mask & other_targets_mask)
- other_targets_mask = targets_mask & other_targets_mask;
-
- loss = SCORE_FORMAT_CHANGE;
-
- in_flags = GST_VIDEO_FORMAT_INFO_FLAGS (in_info);
- in_flags &= ~GST_VIDEO_FORMAT_FLAG_LE;
- in_flags &= ~GST_VIDEO_FORMAT_FLAG_COMPLEX;
- in_flags &= ~GST_VIDEO_FORMAT_FLAG_UNPACK;
-
- t_flags = GST_VIDEO_FORMAT_INFO_FLAGS (t_info);
- t_flags &= ~GST_VIDEO_FORMAT_FLAG_LE;
- t_flags &= ~GST_VIDEO_FORMAT_FLAG_COMPLEX;
- t_flags &= ~GST_VIDEO_FORMAT_FLAG_UNPACK;
-
- /* GRAY/YUV -> GRAY/YUV is not supported */
- if ((in_flags & (GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_GRAY)) != 0
- && (t_flags & (GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_GRAY)) !=
- 0)
- return;
-
- if ((t_flags & PALETTE_MASK) != (in_flags & PALETTE_MASK)) {
- loss += SCORE_PALETTE_CHANGE;
- if (t_flags & PALETTE_MASK)
- loss += SCORE_PALETTE_LOSS;
- }
-
- if ((t_flags & COLORSPACE_MASK) != (in_flags & COLORSPACE_MASK)) {
- loss += SCORE_COLORSPACE_LOSS;
- if (t_flags & GST_VIDEO_FORMAT_FLAG_GRAY)
- loss += SCORE_COLOR_LOSS;
- }
-
- if ((t_flags & ALPHA_MASK) != (in_flags & ALPHA_MASK)) {
- loss += SCORE_ALPHA_CHANGE;
- if (in_flags & ALPHA_MASK)
- loss += SCORE_ALPHA_LOSS;
- }
-
- if ((in_info->h_sub[1]) != (t_info->h_sub[1])) {
- loss += SCORE_CHROMA_H_CHANGE;
- if ((in_info->h_sub[1]) < (t_info->h_sub[1]))
- loss += SCORE_CHROMA_H_LOSS;
- }
- if ((in_info->w_sub[1]) != (t_info->w_sub[1])) {
- loss += SCORE_CHROMA_W_CHANGE;
- if ((in_info->w_sub[1]) < (t_info->w_sub[1]))
- loss += SCORE_CHROMA_W_LOSS;
- }
-
- if ((in_info->bits) != (t_info->bits)) {
- loss += SCORE_DEPTH_CHANGE;
- if ((in_info->bits) > (t_info->bits))
- loss += SCORE_DEPTH_LOSS;
- }
-
- if (loss < *min_loss) {
- GstGLTextureTarget target = _texture_target_demask (other_targets_mask);
-
- if (target != 0) {
- *out_info = t_info;
- *min_loss = loss;
- *result = target;
- }
- }
-}
-
-static void
-gst_gl_color_convert_fixate_format_target (GstCaps * caps, GstCaps * result)
-{
- GstStructure *ins, *outs;
- const gchar *in_format;
- const GstVideoFormatInfo *in_info, *out_info = NULL;
- const GValue *targets;
- guint targets_mask = 0;
- GstGLTextureTarget target;
- gint min_loss = G_MAXINT;
- guint i, capslen;
-
- ins = gst_caps_get_structure (caps, 0);
- in_format = gst_structure_get_string (ins, "format");
- if (!in_format)
- return;
- targets = gst_structure_get_value (ins, "texture-target");
- targets_mask = gst_gl_value_get_texture_target_mask (targets);
- if (!targets_mask)
- return;
-
- in_info =
- gst_video_format_get_info (gst_video_format_from_string (in_format));
- if (!in_info)
- return;
-
- outs = gst_caps_get_structure (result, 0);
-
- capslen = gst_caps_get_size (result);
- for (i = 0; i < capslen; i++) {
- GstStructure *tests;
- const GValue *format;
- const GValue *other_targets;
- guint other_targets_mask = 0;
-
- tests = gst_caps_get_structure (result, i);
-
- format = gst_structure_get_value (tests, "format");
- other_targets = gst_structure_get_value (tests, "texture-target");
- /* should not happen */
- if (format == NULL || other_targets == NULL)
- continue;
-
- other_targets_mask = gst_gl_value_get_texture_target_mask (other_targets);
-
- if (GST_VALUE_HOLDS_LIST (format)) {
- gint j, len;
-
- len = gst_value_list_get_size (format);
- for (j = 0; j < len; j++) {
- const GValue *val;
-
- val = gst_value_list_get_value (format, j);
- if (G_VALUE_HOLDS_STRING (val)) {
- const gchar *format_str = g_value_get_string (val);
- GstVideoFormat v_format = gst_video_format_from_string (format_str);
- score_format_target (in_info, targets_mask, v_format,
- other_targets_mask, &min_loss, &out_info, &target);
- if (min_loss == 0)
- break;
- }
- }
- } else if (G_VALUE_HOLDS_STRING (format)) {
- const gchar *format_str = g_value_get_string (format);
- GstVideoFormat v_format = gst_video_format_from_string (format_str);
- score_format_target (in_info, targets_mask, v_format, other_targets_mask,
- &min_loss, &out_info, &target);
- }
- }
- if (out_info)
- gst_structure_set (outs, "format", G_TYPE_STRING,
- GST_VIDEO_FORMAT_INFO_NAME (out_info), NULL);
- if (target)
- gst_structure_set (outs, "texture-target", G_TYPE_STRING,
- gst_gl_texture_target_to_string (target), NULL);
-}
-
-/**
- * gst_gl_color_convert_fixate_caps:
- * @context: a #GstGLContext to use for transforming @caps
- * @direction: a #GstPadDirection
- * @caps: (transfer none): the #GstCaps of @direction
- * @other: (transfer full): the #GstCaps to fixate
- *
- * Provides an implementation of #GstBaseTransformClass::fixate_caps()
- *
- * Returns: (transfer full): the fixated #GstCaps
- *
- * Since: 1.8
- */
-GstCaps *
-gst_gl_color_convert_fixate_caps (GstGLContext * context,
- GstPadDirection direction, GstCaps * caps, GstCaps * other)
-{
- GstCaps *result;
-
- result = gst_caps_intersect (other, caps);
- if (gst_caps_is_empty (result)) {
- gst_caps_unref (result);
- result = other;
- } else {
- gst_caps_unref (other);
- }
-
- result = gst_caps_make_writable (result);
- gst_gl_color_convert_fixate_format_target (caps, result);
-
- result = gst_caps_fixate (result);
-
- if (direction == GST_PAD_SINK) {
- if (gst_caps_is_subset (caps, result)) {
- gst_caps_replace (&result, caps);
- }
- }
-
- return result;
-}
-
-/**
- * gst_gl_color_convert_perform:
- * @convert: a #GstGLColorConvert
- * @inbuf: (transfer none): the #GstGLMemory filled #GstBuffer to convert
- *
- * Converts the data contained by @inbuf using the formats specified by the
- * #GstCaps passed to gst_gl_color_convert_set_caps()
- *
- * Returns: (transfer full): a converted #GstBuffer or %NULL
- *
- * Since: 1.4
- */
-GstBuffer *
-gst_gl_color_convert_perform (GstGLColorConvert * convert, GstBuffer * inbuf)
-{
- GstBuffer *ret;
-
- g_return_val_if_fail (convert != NULL, FALSE);
-
- GST_OBJECT_LOCK (convert);
- ret = _gst_gl_color_convert_perform_unlocked (convert, inbuf);
- GST_OBJECT_UNLOCK (convert);
-
- return ret;
-}
-
-static GstBuffer *
-_gst_gl_color_convert_perform_unlocked (GstGLColorConvert * convert,
- GstBuffer * inbuf)
-{
- g_return_val_if_fail (convert != NULL, FALSE);
- g_return_val_if_fail (inbuf, FALSE);
-
- if (G_UNLIKELY (convert->passthrough))
- return gst_buffer_ref (inbuf);
-
- convert->inbuf = inbuf;
-
- gst_gl_context_thread_add (convert->context,
- (GstGLContextThreadFunc) _do_convert, convert);
-
- if (!convert->priv->result) {
- if (convert->outbuf)
- gst_buffer_unref (convert->outbuf);
- convert->outbuf = NULL;
- return NULL;
- }
-
- return convert->outbuf;
-}
-
-static inline gboolean
-_is_RGBx (GstVideoFormat v_format)
-{
- switch (v_format) {
- case GST_VIDEO_FORMAT_RGBx:
- case GST_VIDEO_FORMAT_xRGB:
- case GST_VIDEO_FORMAT_BGRx:
- case GST_VIDEO_FORMAT_xBGR:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-static inline gchar
-_index_to_shader_swizzle (int idx)
-{
- switch (idx) {
- case 0:
- return 'r';
- case 1:
- return 'g';
- case 2:
- return 'b';
- case 3:
- return 'a';
- default:
- return '#';
- }
-}
-
-/* attempts to transform expected to want using swizzling */
-static gchar *
-_RGB_pixel_order (const gchar * expected, const gchar * wanted)
-{
- GString *ret = g_string_sized_new (4);
- gchar *expect, *want;
- gchar *orig_want;
- int len;
- gboolean discard_output = TRUE;
-
- if (g_ascii_strcasecmp (expected, wanted) == 0) {
- g_string_free (ret, TRUE);
- return g_ascii_strdown (expected, -1);
- }
-
- expect = g_ascii_strdown (expected, -1);
- orig_want = want = g_ascii_strdown (wanted, -1);
-
- if (strcmp (expect, "rgb16") == 0 || strcmp (expect, "bgr16") == 0) {
- gchar *temp = expect;
- expect = g_strndup (temp, 3);
- g_free (temp);
- }
-
- if (strcmp (want, "rgb16") == 0 || strcmp (want, "bgr16") == 0) {
- gchar *temp = want;
- orig_want = want = g_strndup (temp, 3);
- g_free (temp);
- }
-
- /* pad want with 'a's */
- if ((len = strlen (want)) < 4) {
- gchar *new_want = g_strndup (want, 4);
- while (len < 4) {
- new_want[len] = 'a';
- len++;
- }
- g_free (want);
- orig_want = want = new_want;
- }
-
- /* pad expect with 'a's */
- if ((len = strlen (expect)) < 4) {
- gchar *new_expect = g_strndup (expect, 4);
- while (len < 4) {
- new_expect[len] = 'a';
- len++;
- }
- g_free (expect);
- expect = new_expect;
- }
-
- /* build the swizzle format */
- while (want && want[0] != '\0') {
- gchar *val;
- gint idx;
- gchar needle = want[0];
-
- if (needle == 'x')
- needle = 'a';
-
- if (!(val = strchr (expect, needle))
- && needle == 'a' && !(val = strchr (expect, 'x')))
- goto out;
-
- idx = (gint) (val - expect);
-
- ret = g_string_append_c (ret, _index_to_shader_swizzle (idx));
- want = &want[1];
- }
-
- discard_output = FALSE;
-out:
- g_free (orig_want);
- g_free (expect);
-
- return g_string_free (ret, discard_output);
-}
-
-static guint
-_get_n_textures (GstVideoFormat v_format)
-{
- switch (v_format) {
- case GST_VIDEO_FORMAT_RGBA:
- case GST_VIDEO_FORMAT_RGBx:
- case GST_VIDEO_FORMAT_ARGB:
- case GST_VIDEO_FORMAT_xRGB:
- case GST_VIDEO_FORMAT_BGRA:
- case GST_VIDEO_FORMAT_BGRx:
- case GST_VIDEO_FORMAT_ABGR:
- case GST_VIDEO_FORMAT_xBGR:
- case GST_VIDEO_FORMAT_RGB:
- case GST_VIDEO_FORMAT_BGR:
- case GST_VIDEO_FORMAT_AYUV:
- case GST_VIDEO_FORMAT_GRAY8:
- case GST_VIDEO_FORMAT_GRAY16_LE:
- case GST_VIDEO_FORMAT_GRAY16_BE:
- case GST_VIDEO_FORMAT_YUY2:
- case GST_VIDEO_FORMAT_UYVY:
- case GST_VIDEO_FORMAT_RGB16:
- case GST_VIDEO_FORMAT_BGR16:
- return 1;
- case GST_VIDEO_FORMAT_NV12:
- case GST_VIDEO_FORMAT_NV21:
- return 2;
- case GST_VIDEO_FORMAT_I420:
- case GST_VIDEO_FORMAT_Y444:
- case GST_VIDEO_FORMAT_Y42B:
- case GST_VIDEO_FORMAT_Y41B:
- case GST_VIDEO_FORMAT_YV12:
- return 3;
- default:
- g_assert_not_reached ();
- return 0;
- }
-}
-
-static void
-_RGB_to_RGB (GstGLColorConvert * convert)
-{
- struct ConvertInfo *info = &convert->priv->convert_info;
- GstVideoFormat in_format = GST_VIDEO_INFO_FORMAT (&convert->in_info);
- const gchar *in_format_str = gst_video_format_to_string (in_format);
- GstVideoFormat out_format = GST_VIDEO_INFO_FORMAT (&convert->out_info);
- const gchar *out_format_str = gst_video_format_to_string (out_format);
- gchar *pixel_order = _RGB_pixel_order (in_format_str, out_format_str);
- gchar *alpha = NULL;
-
- if (_is_RGBx (in_format)) {
- int i;
- char input_alpha_channel = 'a';
- for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
- if (in_format_str[i] == 'X' || in_format_str[i] == 'x') {
- input_alpha_channel = _index_to_shader_swizzle (i);
- break;
- }
- }
- alpha = g_strdup_printf ("t.%c = 1.0;", input_alpha_channel);
- }
- info->templ = &templ_REORDER;
- info->frag_body = g_strdup_printf (info->templ->body, alpha ? alpha : "",
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]);
- info->shader_tex_names[0] = "tex";
-
- g_free (alpha);
- g_free (pixel_order);
-}
-
-static void
-_YUV_to_RGB (GstGLColorConvert * convert)
-{
- struct ConvertInfo *info = &convert->priv->convert_info;
- GstVideoFormat out_format = GST_VIDEO_INFO_FORMAT (&convert->out_info);
- const gchar *out_format_str = gst_video_format_to_string (out_format);
- gchar *pixel_order = _RGB_pixel_order ("rgba", out_format_str);
- gboolean apple_ycbcr = gst_gl_context_check_feature (convert->context,
- "GL_APPLE_ycbcr_422");
- gboolean in_tex_rectangular = FALSE;
-
-#if GST_GL_HAVE_OPENGL
- GstMemory *memory = gst_buffer_peek_memory (convert->inbuf, 0);
- if (gst_is_gl_memory (memory) && (USING_OPENGL (convert->context)
- || USING_OPENGL3 (convert->context))) {
- in_tex_rectangular =
- convert->priv->from_texture_target == GST_GL_TEXTURE_TARGET_RECTANGLE;
- }
-#endif
-
- info->out_n_textures = 1;
-
- if (in_tex_rectangular && apple_ycbcr
- && gst_buffer_n_memory (convert->inbuf) == 1) {
- /* FIXME: We should probably also check if tex_target actually is using
- * the Apple YCbCr422 extension. It could also be a normal UYVY texture
- * with RB or Lum/Alpha
- */
- /* The mangling will change this to the correct texture2DRect, sampler2DRect
- * for us */
- info->templ = &templ_REORDER;
- info->frag_body =
- g_strdup_printf (info->templ->body, pixel_order[0], pixel_order[1],
- pixel_order[2], pixel_order[3]);
- info->shader_tex_names[0] = "tex";
- } else {
- switch (GST_VIDEO_INFO_FORMAT (&convert->in_info)) {
- case GST_VIDEO_FORMAT_AYUV:
- info->templ = &templ_AYUV_to_RGB;
- info->frag_body = g_strdup_printf (info->templ->body, pixel_order[0],
- pixel_order[1], pixel_order[2], pixel_order[3]);
- info->shader_tex_names[0] = "tex";
- break;
- case GST_VIDEO_FORMAT_I420:
- case GST_VIDEO_FORMAT_Y444:
- case GST_VIDEO_FORMAT_Y42B:
- case GST_VIDEO_FORMAT_Y41B:
- info->templ = &templ_PLANAR_YUV_to_RGB;
- info->frag_body =
- g_strdup_printf (info->templ->body, pixel_order[0],
- pixel_order[1], pixel_order[2], pixel_order[3]);
- info->shader_tex_names[0] = "Ytex";
- info->shader_tex_names[1] = "Utex";
- info->shader_tex_names[2] = "Vtex";
- break;
- case GST_VIDEO_FORMAT_YV12:
- info->templ = &templ_PLANAR_YUV_to_RGB;
- info->frag_body =
- g_strdup_printf (info->templ->body, pixel_order[0],
- pixel_order[1], pixel_order[2], pixel_order[3]);
- info->shader_tex_names[0] = "Ytex";
- info->shader_tex_names[1] = "Vtex";
- info->shader_tex_names[2] = "Utex";
- break;
- case GST_VIDEO_FORMAT_YUY2:
- {
- char uv_val = convert->priv->in_tex_formats[0] == GST_GL_RG ? 'g' : 'a';
- info->templ = &templ_YUY2_UYVY_to_RGB;
- info->frag_body = g_strdup_printf (info->templ->body, 'r', uv_val,
- uv_val, 'g', 'a', pixel_order[0], pixel_order[1], pixel_order[2],
- pixel_order[3]);
- info->shader_tex_names[0] = "Ytex";
- break;
- }
- case GST_VIDEO_FORMAT_UYVY:
- {
- char y_val = convert->priv->in_tex_formats[0] == GST_GL_RG ? 'g' : 'a';
- info->templ = &templ_YUY2_UYVY_to_RGB;
- info->frag_body = g_strdup_printf (info->templ->body, y_val, 'g',
- 'g', 'r', 'b', pixel_order[0], pixel_order[1], pixel_order[2],
- pixel_order[3]);
- info->shader_tex_names[0] = "Ytex";
- break;
- }
- case GST_VIDEO_FORMAT_NV12:
- {
- char val2 = convert->priv->in_tex_formats[1] == GST_GL_RG ? 'g' : 'a';
- info->templ = &templ_NV12_NV21_to_RGB;
- info->frag_body = g_strdup_printf (info->templ->body, 'r', val2,
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]);
- info->shader_tex_names[0] = "Ytex";
- info->shader_tex_names[1] = "UVtex";
- break;
- }
- case GST_VIDEO_FORMAT_NV21:
- {
- char val2 = convert->priv->in_tex_formats[1] == GST_GL_RG ? 'g' : 'a';
- info->templ = &templ_NV12_NV21_to_RGB;
- info->frag_body = g_strdup_printf (info->templ->body, val2, 'r',
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]);
- info->shader_tex_names[0] = "Ytex";
- info->shader_tex_names[1] = "UVtex";
- break;
- }
- default:
- break;
- }
- }
-
- if (gst_video_colorimetry_matches (&convert->in_info.colorimetry,
- GST_VIDEO_COLORIMETRY_BT709)) {
- info->cms_offset = (gfloat *) from_yuv_bt709_offset;
- info->cms_coeff1 = (gfloat *) from_yuv_bt709_rcoeff;
- info->cms_coeff2 = (gfloat *) from_yuv_bt709_gcoeff;
- info->cms_coeff3 = (gfloat *) from_yuv_bt709_bcoeff;
- } else {
- /* defaults/bt601 */
- info->cms_offset = (gfloat *) from_yuv_bt601_offset;
- info->cms_coeff1 = (gfloat *) from_yuv_bt601_rcoeff;
- info->cms_coeff2 = (gfloat *) from_yuv_bt601_gcoeff;
- info->cms_coeff3 = (gfloat *) from_yuv_bt601_bcoeff;
- }
-
- g_free (pixel_order);
-}
-
-static void
-_RGB_to_YUV (GstGLColorConvert * convert)
-{
- struct ConvertInfo *info = &convert->priv->convert_info;
- GstVideoFormat in_format = GST_VIDEO_INFO_FORMAT (&convert->in_info);
- const gchar *in_format_str = gst_video_format_to_string (in_format);
- GstVideoFormat out_format = GST_VIDEO_INFO_FORMAT (&convert->out_info);
- gchar *pixel_order = _RGB_pixel_order (in_format_str, "rgba");
- const gchar *alpha;
-
- info->frag_prog = NULL;
-
- info->shader_tex_names[0] = "tex";
-
- switch (out_format) {
- case GST_VIDEO_FORMAT_AYUV:
- alpha = _is_RGBx (in_format) ? "1.0" : "texel.a";
- info->templ = &templ_RGB_to_AYUV;
- info->frag_body = g_strdup_printf (info->templ->body, pixel_order[0],
- pixel_order[1], pixel_order[2], pixel_order[3], alpha);
- info->out_n_textures = 1;
- break;
- case GST_VIDEO_FORMAT_I420:
- case GST_VIDEO_FORMAT_YV12:
- case GST_VIDEO_FORMAT_Y444:
- case GST_VIDEO_FORMAT_Y42B:
- case GST_VIDEO_FORMAT_Y41B:
- info->templ = &templ_RGB_to_PLANAR_YUV;
- info->frag_body = g_strdup_printf (info->templ->body,
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3],
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]);
- info->out_n_textures = 3;
- if (out_format == GST_VIDEO_FORMAT_Y444) {
- info->chroma_sampling[0] = info->chroma_sampling[1] = 1.0f;
- } else if (out_format == GST_VIDEO_FORMAT_Y42B) {
- info->chroma_sampling[0] = 2.0f;
- info->chroma_sampling[1] = 1.0f;
- } else if (out_format == GST_VIDEO_FORMAT_Y41B) {
- info->chroma_sampling[0] = 4.0f;
- info->chroma_sampling[1] = 1.0f;
- } else {
- info->chroma_sampling[0] = info->chroma_sampling[1] = 2.0f;
- }
- break;
- case GST_VIDEO_FORMAT_YUY2:
- info->templ = &templ_RGB_to_YUY2_UYVY;
- info->frag_body = g_strdup_printf (info->templ->body,
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3],
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3],
- 'x', 'y', 'x', 'z');
- info->out_n_textures = 1;
- break;
- case GST_VIDEO_FORMAT_UYVY:
- info->templ = &templ_RGB_to_YUY2_UYVY,
- info->frag_body = g_strdup_printf (info->templ->body,
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3],
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3],
- 'y', 'x', 'z', 'x');
- info->out_n_textures = 1;
- break;
- case GST_VIDEO_FORMAT_NV12:
- info->templ = &templ_RGB_to_NV12_NV21,
- info->frag_body = g_strdup_printf (info->templ->body,
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3],
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3],
- 'y', 'z');
- info->out_n_textures = 2;
- break;
- case GST_VIDEO_FORMAT_NV21:
- info->templ = &templ_RGB_to_NV12_NV21,
- info->frag_body = g_strdup_printf (info->templ->body,
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3],
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3],
- 'z', 'y');
- info->out_n_textures = 2;
- break;
- default:
- break;
- }
-
- if (gst_video_colorimetry_matches (&convert->in_info.colorimetry,
- GST_VIDEO_COLORIMETRY_BT709)) {
- info->cms_offset = (gfloat *) from_rgb_bt709_offset;
- info->cms_coeff1 = (gfloat *) from_rgb_bt709_ycoeff;
- info->cms_coeff2 = (gfloat *) from_rgb_bt709_ucoeff;
- info->cms_coeff3 = (gfloat *) from_rgb_bt709_vcoeff;
- } else {
- /* defaults/bt601 */
- info->cms_offset = (gfloat *) from_rgb_bt601_offset;
- info->cms_coeff1 = (gfloat *) from_rgb_bt601_ycoeff;
- info->cms_coeff2 = (gfloat *) from_rgb_bt601_ucoeff;
- info->cms_coeff3 = (gfloat *) from_rgb_bt601_vcoeff;
- }
-
- g_free (pixel_order);
-}
-
-static void
-_RGB_to_GRAY (GstGLColorConvert * convert)
-{
- struct ConvertInfo *info = &convert->priv->convert_info;
- GstVideoFormat in_format = GST_VIDEO_INFO_FORMAT (&convert->in_info);
- const gchar *in_format_str = gst_video_format_to_string (in_format);
- gchar *pixel_order = _RGB_pixel_order (in_format_str, "rgba");
- gchar *alpha = NULL;
-
- info->out_n_textures = 1;
- info->shader_tex_names[0] = "tex";
-
- if (_is_RGBx (in_format))
- alpha = g_strdup_printf ("t.%c = 1.0;", pixel_order[3]);
-
- switch (GST_VIDEO_INFO_FORMAT (&convert->out_info)) {
- case GST_VIDEO_FORMAT_GRAY8:
- info->templ = &templ_REORDER;
- info->frag_body = g_strdup_printf (info->templ->body, alpha ? alpha : "",
- pixel_order[0], pixel_order[0], pixel_order[0], pixel_order[3]);
- break;
- default:
- break;
- }
-
- g_free (alpha);
- g_free (pixel_order);
-}
-
-static void
-_GRAY_to_RGB (GstGLColorConvert * convert)
-{
- struct ConvertInfo *info = &convert->priv->convert_info;
- GstVideoFormat out_format = GST_VIDEO_INFO_FORMAT (&convert->out_info);
- const gchar *out_format_str = gst_video_format_to_string (out_format);
- gchar *pixel_order = _RGB_pixel_order ("rgba", out_format_str);
-
- info->shader_tex_names[0] = "tex";
-
- switch (GST_VIDEO_INFO_FORMAT (&convert->in_info)) {
- case GST_VIDEO_FORMAT_GRAY8:
- info->templ = &templ_REORDER;
- info->frag_body = g_strdup_printf (info->templ->body, "", pixel_order[0],
- pixel_order[0], pixel_order[0], pixel_order[3]);
- break;
- case GST_VIDEO_FORMAT_GRAY16_LE:
- {
- char val2 = convert->priv->in_tex_formats[0] == GST_GL_RG ? 'g' : 'a';
- info->templ = &templ_COMPOSE;
- info->frag_body = g_strdup_printf (info->templ->body, val2, 'r',
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]);
- break;
- }
- case GST_VIDEO_FORMAT_GRAY16_BE:
- {
- char val2 = convert->priv->in_tex_formats[0] == GST_GL_RG ? 'g' : 'a';
- info->templ = &templ_COMPOSE;
- info->frag_body = g_strdup_printf (info->templ->body, 'r', val2,
- pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]);
- break;
- }
- default:
- break;
- }
-
- g_free (pixel_order);
-}
-
-static void
-_bind_buffer (GstGLColorConvert * convert)
-{
- const GstGLFuncs *gl = convert->context->gl_vtable;
-
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, convert->priv->vbo_indices);
- gl->BindBuffer (GL_ARRAY_BUFFER, convert->priv->vertex_buffer);
-
- /* Load the vertex position */
- gl->VertexAttribPointer (convert->priv->attr_position, 3, GL_FLOAT, GL_FALSE,
- 5 * sizeof (GLfloat), (void *) 0);
-
- /* Load the texture coordinate */
- gl->VertexAttribPointer (convert->priv->attr_texture, 2, GL_FLOAT, GL_FALSE,
- 5 * sizeof (GLfloat), (void *) (3 * sizeof (GLfloat)));
-
- gl->EnableVertexAttribArray (convert->priv->attr_position);
- gl->EnableVertexAttribArray (convert->priv->attr_texture);
-}
-
-static void
-_unbind_buffer (GstGLColorConvert * convert)
-{
- const GstGLFuncs *gl = convert->context->gl_vtable;
-
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
- gl->BindBuffer (GL_ARRAY_BUFFER, 0);
-
- gl->DisableVertexAttribArray (convert->priv->attr_position);
- gl->DisableVertexAttribArray (convert->priv->attr_texture);
-}
-
-static GstGLShader *
-_create_shader (GstGLColorConvert * convert)
-{
- struct ConvertInfo *info = &convert->priv->convert_info;
- GString *str = g_string_new (NULL);
- GstGLShader *ret = NULL;
- GstGLSLStage *stage;
- GstGLSLVersion version;
- GstGLSLProfile profile;
- gchar *version_str, *tmp, *tmp1;
- const gchar *strings[2];
- GError *error = NULL;
- int i;
-
- ret = gst_gl_shader_new (convert->context);
-
- tmp =
- _gst_glsl_mangle_shader (text_vertex_shader, GL_VERTEX_SHADER,
- info->templ->target, convert->priv->from_texture_target, convert->context,
- &version, &profile);
-
- tmp1 = gst_glsl_version_profile_to_string (version, profile);
- version_str = g_strdup_printf ("#version %s\n", tmp1);
- g_free (tmp1);
-
- strings[0] = version_str;
- strings[1] = tmp;
- if (!(stage = gst_glsl_stage_new_with_strings (convert->context,
- GL_VERTEX_SHADER, version, profile, 2, strings))) {
- GST_ERROR_OBJECT (convert, "Failed to create vertex stage");
- g_free (version_str);
- g_free (tmp);
- gst_object_unref (ret);
- return NULL;
- }
- g_free (tmp);
-
- if (!gst_gl_shader_compile_attach_stage (ret, stage, &error)) {
- GST_ERROR_OBJECT (convert, "Failed to compile vertex shader %s",
- error->message);
- g_clear_error (&error);
- g_free (version_str);
- gst_object_unref (stage);
- gst_object_unref (ret);
- return NULL;
- }
-
- if (info->templ->extensions)
- g_string_append (str, info->templ->extensions);
-
- if (convert->priv->from_texture_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES
- && info->templ->target != GST_GL_TEXTURE_TARGET_EXTERNAL_OES)
- g_string_append (str, glsl_OES_extension_string);
-
- if (info->templ->uniforms)
- g_string_append (str, info->templ->uniforms);
-
- g_string_append_c (str, '\n');
-
- /* GL 3.3+ and GL ES 3.x */
- if ((profile == GST_GLSL_PROFILE_CORE && version >= GST_GLSL_VERSION_330)
- || (profile == GST_GLSL_PROFILE_ES && version >= GST_GLSL_VERSION_300)) {
- if (info->out_n_textures > 1) {
- gint i;
-
- for (i = 0; i < info->out_n_textures; i++) {
- g_string_append_printf (str,
- "layout(location = %d) out vec4 fragColor_%d;\n", i, i);
- }
- } else {
- g_string_append (str, "layout (location = 0) out vec4 fragColor;\n");
- }
- } else if (profile == GST_GLSL_PROFILE_CORE
- && version >= GST_GLSL_VERSION_150) {
- /* no layout specifiers, use glBindFragDataLocation instead */
- if (info->out_n_textures > 1) {
- gint i;
-
- for (i = 0; i < info->out_n_textures; i++) {
- gchar *var_name = g_strdup_printf ("fragColor_%d", i);
- g_string_append_printf (str, "out vec4 %s;\n", var_name);
- gst_gl_shader_bind_frag_data_location (ret, i, var_name);
- g_free (var_name);
- }
- } else {
- g_string_append (str, "out vec4 fragColor;\n");
- gst_gl_shader_bind_frag_data_location (ret, 0, "fragColor");
- }
- }
-
- for (i = 0; i < MAX_FUNCTIONS; i++) {
- if (info->templ->functions[i] == NULL)
- break;
-
- g_string_append_c (str, '\n');
- g_string_append (str, info->templ->functions[i]);
- g_string_append_c (str, '\n');
- }
-
- {
- const gchar *varying = NULL;
-
- if ((profile == GST_GLSL_PROFILE_ES && version >= GST_GLSL_VERSION_300)
- || (profile == GST_GLSL_PROFILE_CORE
- && version >= GST_GLSL_VERSION_150)) {
- varying = "in";
- } else {
- varying = "varying";
- }
- g_string_append_printf (str, "\n%s vec2 v_texcoord;\nvoid main (void) {\n",
- varying);
- }
- if (info->frag_body) {
- g_string_append (str, "vec2 texcoord;\n");
- if (convert->priv->from_texture_target == GST_GL_TEXTURE_TARGET_RECTANGLE
- && info->templ->target != GST_GL_TEXTURE_TARGET_RECTANGLE) {
- g_string_append (str, "texcoord = v_texcoord * vec2 (width, height);\n");
- } else {
- g_string_append (str, "texcoord = v_texcoord;\n");
- }
-
- g_string_append (str, info->frag_body);
- }
- g_string_append (str, "\n}");
- tmp = g_string_free (str, FALSE);
- info->frag_prog = _gst_glsl_mangle_shader (tmp, GL_FRAGMENT_SHADER,
- info->templ->target, convert->priv->from_texture_target, convert->context,
- &version, &profile);
- g_free (tmp);
-
- strings[1] = info->frag_prog;
- if (!(stage = gst_glsl_stage_new_with_strings (convert->context,
- GL_FRAGMENT_SHADER, version, profile, 2, strings))) {
- GST_ERROR_OBJECT (convert, "Failed to create fragment stage");
- g_free (info->frag_prog);
- info->frag_prog = NULL;
- g_free (version_str);
- gst_object_unref (ret);
- return NULL;
- }
- g_free (version_str);
- if (!gst_gl_shader_compile_attach_stage (ret, stage, &error)) {
- GST_ERROR_OBJECT (convert, "Failed to compile fragment shader %s",
- error->message);
- g_clear_error (&error);
- g_free (info->frag_prog);
- info->frag_prog = NULL;
- gst_object_unref (stage);
- gst_object_unref (ret);
- return NULL;
- }
-
- if (!gst_gl_shader_link (ret, &error)) {
- GST_ERROR_OBJECT (convert, "Failed to link shader %s", error->message);
- g_clear_error (&error);
- g_free (info->frag_prog);
- info->frag_prog = NULL;
- gst_object_unref (ret);
- return NULL;
- }
-
- return ret;
-}
-
-/* Called in the gl thread */
-static gboolean
-_init_convert (GstGLColorConvert * convert)
-{
- GstGLFuncs *gl;
- struct ConvertInfo *info = &convert->priv->convert_info;
- gint i;
-
- gl = convert->context->gl_vtable;
-
- if (convert->initted)
- return TRUE;
-
- GST_INFO ("Initializing color conversion from %s to %s",
- gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&convert->in_info)),
- gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&convert->out_info)));
-
- if (!gl->CreateProgramObject && !gl->CreateProgram) {
- GST_ERROR_OBJECT (convert, "Cannot perform color conversion without "
- "OpenGL shaders");
- goto error;
- }
-
- if (GST_VIDEO_INFO_IS_RGB (&convert->in_info)) {
- if (GST_VIDEO_INFO_IS_RGB (&convert->out_info)) {
- _RGB_to_RGB (convert);
- }
- }
-
- if (GST_VIDEO_INFO_IS_YUV (&convert->in_info)) {
- if (GST_VIDEO_INFO_IS_RGB (&convert->out_info)) {
- _YUV_to_RGB (convert);
- }
- }
-
- if (GST_VIDEO_INFO_IS_RGB (&convert->in_info)) {
- if (GST_VIDEO_INFO_IS_YUV (&convert->out_info)) {
- _RGB_to_YUV (convert);
- }
- }
-
- if (GST_VIDEO_INFO_IS_RGB (&convert->in_info)) {
- if (GST_VIDEO_INFO_IS_GRAY (&convert->out_info)) {
- _RGB_to_GRAY (convert);
- }
- }
-
- if (GST_VIDEO_INFO_IS_GRAY (&convert->in_info)) {
- if (GST_VIDEO_INFO_IS_RGB (&convert->out_info)) {
- _GRAY_to_RGB (convert);
- }
- }
-
- if (!info->frag_body || info->in_n_textures == 0 || info->out_n_textures == 0)
- goto unhandled_format;
-
- /* multiple draw targets not supported on GLES2... */
- if (info->out_n_textures > 1 && !gl->DrawBuffers) {
- GST_ERROR ("Conversion requires output to multiple draw buffers");
- goto incompatible_api;
- }
-
- /* Requires reading from a RG/LA framebuffer... */
- if (USING_GLES2 (convert->context) && !USING_GLES3 (convert->context) &&
- (GST_VIDEO_INFO_FORMAT (&convert->out_info) == GST_VIDEO_FORMAT_YUY2 ||
- GST_VIDEO_INFO_FORMAT (&convert->out_info) ==
- GST_VIDEO_FORMAT_UYVY)) {
- GST_ERROR ("Conversion requires reading with an unsupported format");
- goto incompatible_api;
- }
-
- if (!(convert->shader = _create_shader (convert)))
- goto error;
-
- convert->priv->attr_position =
- gst_gl_shader_get_attribute_location (convert->shader, "a_position");
- convert->priv->attr_texture =
- gst_gl_shader_get_attribute_location (convert->shader, "a_texcoord");
-
- gst_gl_shader_use (convert->shader);
-
- if (info->cms_offset && info->cms_coeff1
- && info->cms_coeff2 && info->cms_coeff3) {
- gst_gl_shader_set_uniform_3fv (convert->shader, "offset", 1,
- info->cms_offset);
- gst_gl_shader_set_uniform_3fv (convert->shader, "coeff1", 1,
- info->cms_coeff1);
- gst_gl_shader_set_uniform_3fv (convert->shader, "coeff2", 1,
- info->cms_coeff2);
- gst_gl_shader_set_uniform_3fv (convert->shader, "coeff3", 1,
- info->cms_coeff3);
- }
-
- for (i = info->in_n_textures; i >= 0; i--) {
- if (info->shader_tex_names[i])
- gst_gl_shader_set_uniform_1i (convert->shader, info->shader_tex_names[i],
- i);
- }
-
- gst_gl_shader_set_uniform_1f (convert->shader, "width",
- GST_VIDEO_INFO_WIDTH (&convert->in_info));
- gst_gl_shader_set_uniform_1f (convert->shader, "height",
- GST_VIDEO_INFO_HEIGHT (&convert->in_info));
-
- if (convert->priv->from_texture_target == GST_GL_TEXTURE_TARGET_RECTANGLE) {
- gst_gl_shader_set_uniform_1f (convert->shader, "poffset_x", 1.);
- gst_gl_shader_set_uniform_1f (convert->shader, "poffset_y", 1.);
- } else {
- gst_gl_shader_set_uniform_1f (convert->shader, "poffset_x",
- 1. / (gfloat) GST_VIDEO_INFO_WIDTH (&convert->in_info));
- gst_gl_shader_set_uniform_1f (convert->shader, "poffset_y",
- 1. / (gfloat) GST_VIDEO_INFO_HEIGHT (&convert->in_info));
- }
-
- if (info->chroma_sampling[0] > 0.0f && info->chroma_sampling[1] > 0.0f) {
- gst_gl_shader_set_uniform_2fv (convert->shader, "chroma_sampling", 1,
- info->chroma_sampling);
- }
-
- gst_gl_context_clear_shader (convert->context);
-
- if (convert->fbo == NULL && !_init_convert_fbo (convert)) {
- goto error;
- }
-
- if (!convert->priv->vertex_buffer) {
- if (gl->GenVertexArrays) {
- gl->GenVertexArrays (1, &convert->priv->vao);
- gl->BindVertexArray (convert->priv->vao);
- }
-
- gl->GenBuffers (1, &convert->priv->vertex_buffer);
- gl->BindBuffer (GL_ARRAY_BUFFER, convert->priv->vertex_buffer);
- gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), vertices,
- GL_STATIC_DRAW);
-
- gl->GenBuffers (1, &convert->priv->vbo_indices);
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, convert->priv->vbo_indices);
- gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
- GL_STATIC_DRAW);
-
- if (gl->GenVertexArrays) {
- _bind_buffer (convert);
- gl->BindVertexArray (0);
- }
-
- gl->BindBuffer (GL_ARRAY_BUFFER, 0);
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
- }
-
- gl->BindTexture (GL_TEXTURE_2D, 0);
-
- convert->initted = TRUE;
-
- return TRUE;
-
-unhandled_format:
- GST_ERROR_OBJECT (convert, "Don't know how to convert from %s to %s",
- gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&convert->in_info)),
- gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&convert->out_info)));
-
-error:
- return FALSE;
-
-incompatible_api:
- {
- GST_ERROR_OBJECT (convert, "Converting from %s to %s requires "
- "functionality that the current OpenGL setup does not support",
- gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&convert->in_info)),
- gst_video_format_to_string (GST_VIDEO_INFO_FORMAT
- (&convert->out_info)));
- return FALSE;
- }
-}
-
-/* called by _init_convert (in the gl thread) */
-static gboolean
-_init_convert_fbo (GstGLColorConvert * convert)
-{
- guint out_width, out_height;
-
- out_width = GST_VIDEO_INFO_WIDTH (&convert->out_info);
- out_height = GST_VIDEO_INFO_HEIGHT (&convert->out_info);
-
- convert->fbo =
- gst_gl_framebuffer_new_with_default_depth (convert->context, out_width,
- out_height);
-
- return convert->fbo != NULL;
-}
-
-static gboolean
-_do_convert_one_view (GstGLContext * context, GstGLColorConvert * convert,
- guint view_num)
-{
- guint in_width, in_height, out_width, out_height;
- struct ConvertInfo *c_info = &convert->priv->convert_info;
- GstMapInfo out_info[GST_VIDEO_MAX_PLANES], in_info[GST_VIDEO_MAX_PLANES];
- gboolean res = TRUE;
- gint i, j = 0;
- const gint in_plane_offset = view_num * c_info->in_n_textures;
- const gint out_plane_offset = view_num * c_info->out_n_textures;
-
- out_width = GST_VIDEO_INFO_WIDTH (&convert->out_info);
- out_height = GST_VIDEO_INFO_HEIGHT (&convert->out_info);
- in_width = GST_VIDEO_INFO_WIDTH (&convert->in_info);
- in_height = GST_VIDEO_INFO_HEIGHT (&convert->in_info);
-
- for (i = 0; i < c_info->in_n_textures; i++) {
- convert->priv->in_tex[i] =
- (GstGLMemory *) gst_buffer_peek_memory (convert->inbuf,
- i + in_plane_offset);
- if (!gst_is_gl_memory ((GstMemory *) convert->priv->in_tex[i])) {
- GST_ERROR_OBJECT (convert, "input must be GstGLMemory");
- res = FALSE;
- goto out;
- }
- if (!gst_memory_map ((GstMemory *) convert->priv->in_tex[i], &in_info[i],
- GST_MAP_READ | GST_MAP_GL)) {
- GST_ERROR_OBJECT (convert, "failed to map input memory %p",
- convert->priv->in_tex[i]);
- res = FALSE;
- goto out;
- }
- }
-
- for (j = 0; j < c_info->out_n_textures; j++) {
- GstGLMemory *out_tex =
- (GstGLMemory *) gst_buffer_peek_memory (convert->outbuf,
- j + out_plane_offset);
- gint mem_width, mem_height;
-
- if (!gst_is_gl_memory ((GstMemory *) out_tex)) {
- GST_ERROR_OBJECT (convert, "output must be GstGLMemory");
- res = FALSE;
- goto out;
- }
-
- mem_width = gst_gl_memory_get_texture_width (out_tex);
- mem_height = gst_gl_memory_get_texture_height (out_tex);
-
- if (out_tex->tex_format == GST_GL_LUMINANCE
- || out_tex->tex_format == GST_GL_LUMINANCE_ALPHA
- || out_width != mem_width || out_height != mem_height) {
- /* Luminance formats are not color renderable */
- /* renderering to a framebuffer only renders the intersection of all
- * the attachments i.e. the smallest attachment size */
- if (!convert->priv->out_tex[j]) {
- GstGLVideoAllocationParams *params;
- GstGLBaseMemoryAllocator *base_mem_allocator;
- GstAllocator *allocator;
- GstVideoInfo temp_info;
-
- gst_video_info_set_format (&temp_info, GST_VIDEO_FORMAT_RGBA, out_width,
- out_height);
-
- allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME);
- base_mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator);
- params = gst_gl_video_allocation_params_new (context, NULL, &temp_info,
- 0, NULL, convert->priv->to_texture_target, GST_GL_RGBA);
-
- convert->priv->out_tex[j] =
- (GstGLMemory *) gst_gl_base_memory_alloc (base_mem_allocator,
- (GstGLAllocationParams *) params);
-
- gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
- gst_object_unref (allocator);
- }
- } else {
- convert->priv->out_tex[j] = out_tex;
- }
-
- if (!gst_memory_map ((GstMemory *) convert->priv->out_tex[j], &out_info[j],
- GST_MAP_WRITE | GST_MAP_GL)) {
- GST_ERROR_OBJECT (convert, "failed to map output memory %p",
- convert->priv->out_tex[i]);
- res = FALSE;
- goto out;
- }
- }
-
- GST_LOG_OBJECT (convert, "converting to textures:%p,%p,%p,%p "
- "dimensions:%ux%u, from textures:%p,%p,%p,%p dimensions:%ux%u",
- convert->priv->out_tex[0], convert->priv->out_tex[1],
- convert->priv->out_tex[2], convert->priv->out_tex[3], out_width,
- out_height, convert->priv->in_tex[0], convert->priv->in_tex[1],
- convert->priv->in_tex[2], convert->priv->in_tex[3], in_width, in_height);
-
- if (!_do_convert_draw (context, convert))
- res = FALSE;
-
-out:
- for (j--; j >= 0; j--) {
- GstGLMemory *out_tex =
- (GstGLMemory *) gst_buffer_peek_memory (convert->outbuf,
- j + out_plane_offset);
- gint mem_width, mem_height;
-
- gst_memory_unmap ((GstMemory *) convert->priv->out_tex[j], &out_info[j]);
-
- mem_width = gst_gl_memory_get_texture_width (out_tex);
- mem_height = gst_gl_memory_get_texture_height (out_tex);
-
- if (out_tex->tex_format == GST_GL_LUMINANCE
- || out_tex->tex_format == GST_GL_LUMINANCE_ALPHA
- || out_width != mem_width || out_height != mem_height) {
- GstMapInfo to_info, from_info;
-
- if (!gst_memory_map ((GstMemory *) convert->priv->out_tex[j], &from_info,
- GST_MAP_READ | GST_MAP_GL)) {
- GST_ERROR_OBJECT (convert, "Failed to map intermediate memory");
- res = FALSE;
- continue;
- }
- if (!gst_memory_map ((GstMemory *) out_tex, &to_info,
- GST_MAP_WRITE | GST_MAP_GL)) {
- GST_ERROR_OBJECT (convert, "Failed to map intermediate memory");
- res = FALSE;
- continue;
- }
- gst_gl_memory_copy_into (convert->priv->out_tex[j],
- out_tex->tex_id, convert->priv->to_texture_target,
- out_tex->tex_format, mem_width, mem_height);
- gst_memory_unmap ((GstMemory *) convert->priv->out_tex[j], &from_info);
- gst_memory_unmap ((GstMemory *) out_tex, &to_info);
- } else {
- convert->priv->out_tex[j] = NULL;
- }
- }
-
- /* YV12 the same as I420 except planes 1+2 swapped */
- if (GST_VIDEO_INFO_FORMAT (&convert->out_info) == GST_VIDEO_FORMAT_YV12) {
- GstMemory *mem1 =
- gst_buffer_get_memory (convert->outbuf, 1 + out_plane_offset);
- GstMemory *mem2 =
- gst_buffer_get_memory (convert->outbuf, 2 + out_plane_offset);
-
- gst_buffer_replace_memory (convert->outbuf, 1 + out_plane_offset, mem2);
- gst_buffer_replace_memory (convert->outbuf, 2 + out_plane_offset, mem1);
- }
-
- for (i--; i >= 0; i--) {
- gst_memory_unmap ((GstMemory *) convert->priv->in_tex[i], &in_info[i]);
- }
-
- return res;
-}
-
-/* Called by the idle function in the gl thread */
-void
-_do_convert (GstGLContext * context, GstGLColorConvert * convert)
-{
- GstVideoInfo *in_info = &convert->in_info;
- struct ConvertInfo *c_info = &convert->priv->convert_info;
- gboolean res = TRUE;
- gint views, v;
- GstVideoOverlayCompositionMeta *composition_meta;
- GstGLSyncMeta *sync_meta;
- GstFlowReturn ret;
-
- convert->outbuf = NULL;
-
- if (GST_VIDEO_INFO_MULTIVIEW_MODE (in_info) ==
- GST_VIDEO_MULTIVIEW_MODE_SEPARATED)
- views = GST_VIDEO_INFO_VIEWS (in_info);
- else
- views = 1;
-
- c_info->in_n_textures =
- _get_n_textures (GST_VIDEO_INFO_FORMAT (&convert->in_info));
- c_info->out_n_textures =
- _get_n_textures (GST_VIDEO_INFO_FORMAT (&convert->out_info));
-
- {
- gboolean tex_format_change = FALSE;
- guint i, v;
-
- for (v = 0; v < views; v++) {
- for (i = 0; i < c_info->in_n_textures; i++) {
- guint j = v * c_info->in_n_textures + i;
- GstGLMemory *in_tex =
- (GstGLMemory *) gst_buffer_peek_memory (convert->inbuf, j);
- if (!gst_is_gl_memory ((GstMemory *) in_tex)) {
- GST_ERROR_OBJECT (convert, "input must be GstGLMemory");
- convert->priv->result = FALSE;
- return;
- }
-
- if (j >= GST_VIDEO_MAX_PLANES)
- /* our arrays aren't that big */
- g_assert_not_reached ();
-
- if (v > 0 && in_tex->tex_format != convert->priv->in_tex_formats[i]) {
- GST_ERROR_OBJECT (convert, "Cannot convert textures with "
- "different types");
- convert->priv->result = FALSE;
- return;
- }
-
- if (convert->priv->in_tex_formats[j] != in_tex->tex_format)
- tex_format_change = TRUE;
-
- convert->priv->in_tex_formats[j] = in_tex->tex_format;
- }
- }
-
- if (tex_format_change)
- gst_gl_color_convert_reset_shader (convert);
- }
-
- if (!_init_convert (convert)) {
- convert->priv->result = FALSE;
- return;
- }
-
- sync_meta = gst_buffer_get_gl_sync_meta (convert->inbuf);
- if (sync_meta)
- gst_gl_sync_meta_wait (sync_meta, convert->context);
-
- if (!convert->priv->pool) {
- gboolean ret;
- /* No pool! */
- GstQuery *query = gst_query_new_allocation (convert->priv->out_caps, TRUE);
- ret = gst_gl_color_convert_decide_allocation (convert, query);
- gst_query_unref (query);
-
- if (!ret) {
- GST_ERROR_OBJECT (convert, "Failed to choose allocation parameters");
- convert->priv->result = FALSE;
- return;
- }
-
- if (!convert->priv->pool) {
- GST_ERROR_OBJECT (convert, "Failed to create a buffer pool");
- convert->priv->result = FALSE;
- return;
- }
- }
-
- if (!convert->priv->pool_started) {
- if (!gst_buffer_pool_set_active (convert->priv->pool, TRUE)) {
- GST_ERROR_OBJECT (convert, "Failed to start buffer pool");
- convert->priv->result = FALSE;
- return;
- }
- convert->priv->pool_started = TRUE;
- }
-
- ret =
- gst_buffer_pool_acquire_buffer (convert->priv->pool, &convert->outbuf,
- NULL);
- if (ret != GST_FLOW_OK) {
- GST_ERROR_OBJECT (convert, "Failed to acquire buffer from pool: %s",
- gst_flow_get_name (ret));
- convert->priv->result = FALSE;
- return;
- }
-
- gst_gl_insert_debug_marker (context, "%s converting from %s to %s",
- GST_OBJECT_NAME (convert),
- gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (in_info)),
- gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&convert->out_info)));
- /* Handle all views on input and output one at a time */
- for (v = 0; res && v < views; v++)
- res = _do_convert_one_view (context, convert, v);
-
- if (!res) {
- gst_buffer_unref (convert->outbuf);
- convert->outbuf = NULL;
- }
-
- if (convert->outbuf) {
- GstGLSyncMeta *sync_meta =
- gst_buffer_add_gl_sync_meta (convert->context, convert->outbuf);
-
- if (sync_meta)
- gst_gl_sync_meta_set_sync_point (sync_meta, convert->context);
- }
-
- composition_meta =
- gst_buffer_get_video_overlay_composition_meta (convert->inbuf);
- if (composition_meta) {
- GST_DEBUG ("found video overlay composition meta, appliying on output.");
- gst_buffer_add_video_overlay_composition_meta
- (convert->outbuf, composition_meta->overlay);
- }
-
- convert->priv->result = res;
- return;
-}
-
-static gboolean
-_do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
-{
- GstGLFuncs *gl;
- struct ConvertInfo *c_info = &convert->priv->convert_info;
- guint out_width, out_height;
- gint i;
- gboolean ret = TRUE;
-
- GLint viewport_dim[4] = { 0 };
-
- GLenum multipleRT[] = {
- GL_COLOR_ATTACHMENT0,
- GL_COLOR_ATTACHMENT1,
- GL_COLOR_ATTACHMENT2
- };
-
- gl = context->gl_vtable;
-
- gst_gl_framebuffer_bind (convert->fbo);
-
- /* attach the texture to the FBO to renderer to */
- for (i = 0; i < c_info->out_n_textures; i++) {
- GstGLBaseMemory *tex = (GstGLBaseMemory *) convert->priv->out_tex[i];
-
- gst_gl_framebuffer_attach (convert->fbo, GL_COLOR_ATTACHMENT0 + i, tex);
- }
-
- if (gl->DrawBuffers)
- gl->DrawBuffers (c_info->out_n_textures, multipleRT);
- else if (gl->DrawBuffer)
- gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
-
- gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
-
- gst_gl_framebuffer_get_effective_dimensions (convert->fbo, &out_width,
- &out_height);
- gl->Viewport (0, 0, out_width, out_height);
-
- gst_gl_shader_use (convert->shader);
-
- if (gl->BindVertexArray)
- gl->BindVertexArray (convert->priv->vao);
- _bind_buffer (convert);
-
- for (i = c_info->in_n_textures - 1; i >= 0; i--) {
- gchar *scale_name = g_strdup_printf ("tex_scale%u", i);
- guint gl_target =
- gst_gl_texture_target_to_gl (convert->priv->from_texture_target);
-
- gl->ActiveTexture (GL_TEXTURE0 + i);
- gl->BindTexture (gl_target, convert->priv->in_tex[i]->tex_id);
- gl->TexParameteri (gl_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- gl->TexParameteri (gl_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- gl->TexParameteri (gl_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- gl->TexParameteri (gl_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- gst_gl_shader_set_uniform_2fv (convert->shader, scale_name, 1,
- convert->priv->in_tex[i]->tex_scaling);
-
- g_free (scale_name);
- }
-
- gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
-
- if (gl->BindVertexArray)
- gl->BindVertexArray (0);
- _unbind_buffer (convert);
-
- if (gl->DrawBuffer)
- gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
-
- /* we are done with the shader */
- gst_gl_context_clear_shader (context);
-
- gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
- viewport_dim[3]);
-
- if (!gst_gl_context_check_framebuffer_status (context, GL_FRAMEBUFFER))
- ret = FALSE;
-
- gst_gl_context_clear_framebuffer (context);
-
- return ret;
-}
diff --git a/gst-libs/gst/gl/gstglcolorconvert.h b/gst-libs/gst/gl/gstglcolorconvert.h
deleted file mode 100644
index 76a5247cd..000000000
--- a/gst-libs/gst/gl/gstglcolorconvert.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystree00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_COLOR_CONVERT_H__
-#define __GST_GL_COLOR_CONVERT_H__
-
-#include <gst/video/video.h>
-#include <gst/gstmemory.h>
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GType gst_gl_color_convert_get_type (void);
-#define GST_TYPE_GL_COLOR_CONVERT (gst_gl_color_convert_get_type())
-#define GST_GL_COLOR_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_COLOR_CONVERT,GstGLColorConvert))
-#define GST_GL_COLOR_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_DISPLAY,GstGLColorConvertClass))
-#define GST_IS_GL_COLOR_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_COLOR_CONVERT))
-#define GST_IS_GL_COLOR_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_COLOR_CONVERT))
-#define GST_GL_COLOR_CONVERT_CAST(obj) ((GstGLColorConvert*)(obj))
-
-/**
- * GstGLColorConvert
- *
- * Opaque #GstGLColorConvert object
- */
-struct _GstGLColorConvert
-{
- /* <private> */
- GstObject parent;
-
- GstGLContext *context;
-
- /* input data */
- GstVideoInfo in_info;
- GstVideoInfo out_info;
-
- gboolean initted;
- gboolean passthrough;
-
- GstBuffer * inbuf;
- GstBuffer * outbuf;
-
- /* used for the conversion */
- GstGLFramebuffer *fbo;
- GstGLShader *shader;
-
- /* <private> */
- GstGLColorConvertPrivate *priv;
-
- gpointer _reserved[GST_PADDING];
-};
-
-/**
- * GstGLColorConvertClass:
- *
- * The #GstGLColorConvertClass struct only contains private data
- */
-struct _GstGLColorConvertClass
-{
- /* <private> */
- GstObjectClass object_class;
-
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GST_GL_COLOR_CONVERT_FORMATS:
- *
- * The currently supported formats that can be converted
- */
-#define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \
- "xBGR, ARGB, ABGR, Y444, I420, YV12, Y42B, " \
- "Y41B, NV12, NV21, YUY2, UYVY, AYUV, " \
- "GRAY8, GRAY16_LE, GRAY16_BE, RGB16, BGR16 }"
-
-/**
- * GST_GL_COLOR_CONVERT_VIDEO_CAPS:
- *
- * The currently supported #GstCaps that can be converted
- */
-#define GST_GL_COLOR_CONVERT_VIDEO_CAPS \
- "video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), " \
- "format = (string) " GST_GL_COLOR_CONVERT_FORMATS ", " \
- "width = " GST_VIDEO_SIZE_RANGE ", " \
- "height = " GST_VIDEO_SIZE_RANGE ", " \
- "framerate = " GST_VIDEO_FPS_RANGE ", " \
- "texture-target = (string) { 2D, rectangle, external-oes } " \
- " ; " \
- "video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "," \
- GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION "), " \
- "format = (string) " GST_GL_COLOR_CONVERT_FORMATS ", " \
- "width = " GST_VIDEO_SIZE_RANGE ", " \
- "height = " GST_VIDEO_SIZE_RANGE ", " \
- "framerate = " GST_VIDEO_FPS_RANGE ", " \
- "texture-target = (string) { 2D, rectangle, external-oes }"
-
-GST_EXPORT
-GstGLColorConvert * gst_gl_color_convert_new (GstGLContext * context);
-
-GST_EXPORT
-GstCaps * gst_gl_color_convert_transform_caps (GstGLContext * context,
- GstPadDirection direction,
- GstCaps * caps,
- GstCaps * filter);
-GST_EXPORT
-GstCaps * gst_gl_color_convert_fixate_caps (GstGLContext * context,
- GstPadDirection direction,
- GstCaps * caps,
- GstCaps * other);
-GST_EXPORT
-gboolean gst_gl_color_convert_set_caps (GstGLColorConvert * convert,
- GstCaps * in_caps,
- GstCaps * out_caps);
-GST_EXPORT
-gboolean gst_gl_color_convert_decide_allocation (GstGLColorConvert * convert,
- GstQuery * query);
-
-GST_EXPORT
-GstBuffer * gst_gl_color_convert_perform (GstGLColorConvert * convert, GstBuffer * inbuf);
-
-G_END_DECLS
-
-#endif /* __GST_GL_COLOR_CONVERT_H__ */
diff --git a/gst-libs/gst/gl/gstglconfig.h.meson b/gst-libs/gst/gl/gstglconfig.h.meson
deleted file mode 100644
index ea74934f7..000000000
--- a/gst-libs/gst/gl/gstglconfig.h.meson
+++ /dev/null
@@ -1,48 +0,0 @@
-/* gstglconfig.h
- *
- * This is a generated file. Please modify `configure.ac'
- */
-
-#ifndef __GST_GL_CONFIG_H__
-#define __GST_GL_CONFIG_H__
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-
-#mesondefine GST_GL_HAVE_OPENGL
-#mesondefine GST_GL_HAVE_GLES2
-#mesondefine GST_GL_HAVE_GLES3
-#mesondefine GST_GL_HAVE_GLES3EXT3_H
-
-#mesondefine GST_GL_HAVE_WINDOW_X11
-#mesondefine GST_GL_HAVE_WINDOW_COCOA
-#mesondefine GST_GL_HAVE_WINDOW_WIN32
-#mesondefine GST_GL_HAVE_WINDOW_WAYLAND
-#mesondefine GST_GL_HAVE_WINDOW_ANDROID
-#mesondefine GST_GL_HAVE_WINDOW_DISPMANX
-#mesondefine GST_GL_HAVE_WINDOW_EAGL
-#mesondefine GST_GL_HAVE_WINDOW_VIV_FB
-
-#mesondefine GST_GL_HAVE_PLATFORM_EGL
-#mesondefine GST_GL_HAVE_PLATFORM_GLX
-#mesondefine GST_GL_HAVE_PLATFORM_WGL
-#mesondefine GST_GL_HAVE_PLATFORM_CGL
-#mesondefine GST_GL_HAVE_PLATFORM_EAGL
-
-#mesondefine GST_GL_HAVE_DMABUF
-#mesondefine GST_GL_HAVE_VIV_DIRECTVIV
-
-#mesondefine GST_GL_HAVE_GLEGLIMAGEOES
-#mesondefine GST_GL_HAVE_GLCHAR
-#mesondefine GST_GL_HAVE_GLSIZEIPTR
-#mesondefine GST_GL_HAVE_GLINTPTR
-#mesondefine GST_GL_HAVE_GLSYNC
-#mesondefine GST_GL_HAVE_GLUINT64
-#mesondefine GST_GL_HAVE_GLINT64
-#mesondefine GST_GL_HAVE_EGLATTRIB
-
-G_END_DECLS
-
-#endif /* __GST_GL_CONFIG_H__ */
diff --git a/gst-libs/gst/gl/gstglcontext.c b/gst-libs/gst/gl/gstglcontext.c
deleted file mode 100644
index d89e4db43..000000000
--- a/gst-libs/gst/gl/gstglcontext.c
+++ /dev/null
@@ -1,1857 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstglcontext
- * @short_description: OpenGL context abstraction
- * @title: GstGLContext
- * @see_also: #GstGLDisplay, #GstGLWindow
- *
- * #GstGLContext wraps an OpenGL context object in a uniform API. As a result
- * of the limitation on OpenGL context, this object is not thread safe unless
- * specified and must only be activated in a single thread.
- */
-
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#if defined(ANDROID) || defined(__ANDROID__)
-/* Avoid a linker error with _isoc99_sscanf() when building a shared library
- * for android
- */
-#define _GNU_SOURCE
-#endif
-
-#include "gstglcontext.h"
-#include <gst/gl/gl.h>
-
-#include <gmodule.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "gstglcontext_private.h"
-#include "gstglfeature.h"
-#include "gstglfeature_private.h"
-#include "gstglfuncs.h"
-
-#ifndef GL_NUM_EXTENSIONS
-#define GL_NUM_EXTENSIONS 0x0000821d
-#endif
-
-#if GST_GL_HAVE_PLATFORM_GLX
-#include "x11/gstglcontext_glx.h"
-#endif
-#if GST_GL_HAVE_PLATFORM_EGL
-#include "egl/gstglcontext_egl.h"
-#endif
-#if GST_GL_HAVE_PLATFORM_CGL
-#include "cocoa/gstglcontext_cocoa.h"
-#endif
-#if GST_GL_HAVE_PLATFORM_WGL
-#include "win32/gstglcontext_wgl.h"
-#endif
-#if GST_GL_HAVE_PLATFORM_EAGL
-#include "eagl/gstglcontext_eagl.h"
-#endif
-
-extern void _gst_gl_debug_enable (GstGLContext * context);
-
-static GPrivate current_context_key;
-
-static GModule *module_self;
-static GOnce module_self_gonce = G_ONCE_INIT;
-
-#if GST_GL_HAVE_OPENGL
-static GOnce module_opengl_gonce = G_ONCE_INIT;
-static GModule *module_opengl;
-
-static gpointer
-load_opengl_module (gpointer user_data)
-{
-#ifdef GST_GL_LIBGL_MODULE_NAME
- module_opengl = g_module_open (GST_GL_LIBGL_MODULE_NAME, G_MODULE_BIND_LAZY);
-#else
- /* On Linux the .so is only in -dev packages, try with a real soname
- * Proper compilers will optimize away the strcmp */
- if (g_strcmp0 (G_MODULE_SUFFIX, "so") == 0)
- module_opengl = g_module_open ("libGL.so.1", G_MODULE_BIND_LAZY);
-
- /* This automatically handles the suffix and even .la files */
- if (!module_opengl)
- module_opengl = g_module_open ("libGL", G_MODULE_BIND_LAZY);
-#endif
-
- return NULL;
-}
-#endif
-
-#if GST_GL_HAVE_GLES2
-static GOnce module_gles2_gonce = G_ONCE_INIT;
-static GModule *module_gles2;
-
-static gpointer
-load_gles2_module (gpointer user_data)
-{
-#ifdef GST_GL_LIBGLESV2_MODULE_NAME
- module_gles2 =
- g_module_open (GST_GL_LIBGLESV2_MODULE_NAME, G_MODULE_BIND_LAZY);
-#else
- /* On Linux the .so is only in -dev packages, try with a real soname
- * Proper compilers will optimize away the strcmp */
- if (g_strcmp0 (G_MODULE_SUFFIX, "so") == 0)
- module_gles2 = g_module_open ("libGLESv2.so.2", G_MODULE_BIND_LAZY);
-
- /* This automatically handles the suffix and even .la files */
- if (!module_gles2)
- module_gles2 = g_module_open ("libGLESv2", G_MODULE_BIND_LAZY);
-
-#endif
-
- return NULL;
-}
-#endif
-
-static gpointer
-load_self_module (gpointer user_data)
-{
- module_self = g_module_open (NULL, G_MODULE_BIND_LAZY);
-
- return NULL;
-}
-
-/* Context sharedness is tracked by a refcounted pointer stored in each context
- * object to track complex creation/deletion scenarios. As a result,
- * sharedness can only be successfully validated between two GstGLContext's
- * where one is not a wrapped context.
- *
- * As there is no API at the winsys level to tell whether two OpenGL contexts
- * can share GL resources, this is the next best thing.
- *
- * XXX: we may need a way to associate two wrapped GstGLContext's as being
- * shared however I have not come across a use case that requries this yet.
- */
-struct ContextShareGroup
-{
- volatile int refcount;
-};
-
-static struct ContextShareGroup *
-_context_share_group_new (void)
-{
- struct ContextShareGroup *ret = g_new0 (struct ContextShareGroup, 1);
-
- ret->refcount = 1;
-
- return ret;
-}
-
-static struct ContextShareGroup *
-_context_share_group_ref (struct ContextShareGroup *share)
-{
- g_atomic_int_inc (&share->refcount);
- return share;
-}
-
-static void
-_context_share_group_unref (struct ContextShareGroup *share)
-{
- if (g_atomic_int_dec_and_test (&share->refcount))
- g_free (share);
-}
-
-static gboolean
-_context_share_group_is_shared (struct ContextShareGroup *share)
-{
- return g_atomic_int_get (&share->refcount) > 1;
-}
-
-#define GST_CAT_DEFAULT gst_gl_context_debug
-GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
-GST_DEBUG_CATEGORY_STATIC (gst_gl_debug);
-
-#define gst_gl_context_parent_class parent_class
-G_DEFINE_ABSTRACT_TYPE (GstGLContext, gst_gl_context, GST_TYPE_OBJECT);
-
-#define GST_GL_CONTEXT_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_CONTEXT, GstGLContextPrivate))
-
-static void _init_debug (void);
-
-static gpointer gst_gl_context_create_thread (GstGLContext * context);
-static void gst_gl_context_finalize (GObject * object);
-static void gst_gl_context_default_get_gl_platform_version (GstGLContext *
- context, gint * major, gint * minor);
-
-struct _GstGLContextPrivate
-{
- GThread *gl_thread;
- GThread *active_thread;
-
- /* conditions */
- GMutex render_lock;
- GCond create_cond;
- GCond destroy_cond;
-
- gboolean created;
- gboolean alive;
-
- GWeakRef other_context_ref;
- struct ContextShareGroup *sharegroup;
- GError **error;
-
- gint gl_major;
- gint gl_minor;
-
- gchar *gl_exts;
-};
-
-typedef struct
-{
- GstGLContext parent;
-
- guintptr handle;
- GstGLPlatform platform;
- GstGLAPI available_apis;
-} GstGLWrappedContext;
-
-typedef struct
-{
- GstGLContextClass parent;
-} GstGLWrappedContextClass;
-
-#define GST_TYPE_GL_WRAPPED_CONTEXT (gst_gl_wrapped_context_get_type())
-static GType gst_gl_wrapped_context_get_type (void);
-G_DEFINE_TYPE (GstGLWrappedContext, gst_gl_wrapped_context,
- GST_TYPE_GL_CONTEXT);
-
-#define GST_GL_WRAPPED_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WRAPPED_CONTEXT, GstGLWrappedContext))
-#define GST_GL_WRAPPED_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_CONTEXT, GstGLContextClass))
-#define GST_IS_GL_WRAPPED_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WRAPPED_CONTEXT))
-#define GST_IS_GL_WRAPPED_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WRAPPED_CONTEXT))
-#define GST_GL_WRAPPED_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WRAPPED_CONTEXT, GstGLWrappedContextClass))
-
-GQuark
-gst_gl_context_error_quark (void)
-{
- return g_quark_from_static_string ("gst-gl-context-error-quark");
-}
-
-static void
-_ensure_window (GstGLContext * context)
-{
- GstGLWindow *window;
-
- if (context->window)
- return;
-
- window = gst_gl_display_create_window (context->display);
-
- gst_gl_context_set_window (context, window);
-
- gst_object_unref (window);
-}
-
-static void
-gst_gl_context_init (GstGLContext * context)
-{
- context->priv = GST_GL_CONTEXT_GET_PRIVATE (context);
-
- context->window = NULL;
- context->gl_vtable = g_slice_alloc0 (sizeof (GstGLFuncs));
-
- g_mutex_init (&context->priv->render_lock);
-
- g_cond_init (&context->priv->create_cond);
- g_cond_init (&context->priv->destroy_cond);
- context->priv->created = FALSE;
-
- g_weak_ref_init (&context->priv->other_context_ref, NULL);
-}
-
-static void
-gst_gl_context_class_init (GstGLContextClass * klass)
-{
- g_type_class_add_private (klass, sizeof (GstGLContextPrivate));
-
- klass->get_proc_address =
- GST_DEBUG_FUNCPTR (gst_gl_context_default_get_proc_address);
- klass->get_gl_platform_version =
- GST_DEBUG_FUNCPTR (gst_gl_context_default_get_gl_platform_version);
-
- G_OBJECT_CLASS (klass)->finalize = gst_gl_context_finalize;
-
- _init_debug ();
-}
-
-static void
-_init_debug (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- GST_DEBUG_CATEGORY_INIT (gst_gl_context_debug, "glcontext", 0,
- "glcontext element");
- GST_DEBUG_CATEGORY_INIT (gst_gl_debug, "gldebug", 0, "OpenGL Debugging");
- g_once_init_leave (&_init, 1);
- }
-}
-
-/**
- * gst_gl_context_new:
- * @display: a #GstGLDisplay
- *
- * Create a new #GstGLContext with the specified @display
- *
- * Returns: a new #GstGLContext
- *
- * Since: 1.4
- */
-GstGLContext *
-gst_gl_context_new (GstGLDisplay * display)
-{
- GstGLContext *context = NULL;
- const gchar *user_choice;
-
- _init_debug ();
-
- user_choice = g_getenv ("GST_GL_PLATFORM");
- GST_INFO ("creating a context for display %" GST_PTR_FORMAT
- ", user choice:%s", display, user_choice);
-#if GST_GL_HAVE_PLATFORM_CGL
- if (!context && (!user_choice || g_strstr_len (user_choice, 3, "cgl")))
- context = GST_GL_CONTEXT (gst_gl_context_cocoa_new (display));
-#endif
-#if GST_GL_HAVE_PLATFORM_GLX
- if (!context && (!user_choice || g_strstr_len (user_choice, 3, "glx")))
- context = GST_GL_CONTEXT (gst_gl_context_glx_new (display));
-#endif
-#if GST_GL_HAVE_PLATFORM_EGL
- if (!context && (!user_choice || g_strstr_len (user_choice, 3, "egl")))
- context = GST_GL_CONTEXT (gst_gl_context_egl_new (display));
-#endif
-#if GST_GL_HAVE_PLATFORM_WGL
- if (!context && (!user_choice || g_strstr_len (user_choice, 3, "wgl")))
- context = GST_GL_CONTEXT (gst_gl_context_wgl_new (display));
-#endif
-#if GST_GL_HAVE_PLATFORM_EAGL
- if (!context && (!user_choice || g_strstr_len (user_choice, 4, "eagl")))
- context = GST_GL_CONTEXT (gst_gl_context_eagl_new (display));
-#endif
-
- if (!context) {
- /* subclass returned a NULL context */
- GST_WARNING ("Could not create context. user specified %s",
- user_choice ? user_choice : "(null)");
-
- return NULL;
- }
-
- context->display = gst_object_ref (display);
-
- GST_DEBUG_OBJECT (context,
- "Done creating context for display %" GST_PTR_FORMAT " (user_choice:%s)",
- display, user_choice);
-
- return context;
-}
-
-/**
- * gst_gl_context_new_wrapped:
- * @display: a #GstGLDisplay
- * @handle: the OpenGL context to wrap
- * @context_type: a #GstGLPlatform specifying the type of context in @handle
- * @available_apis: a #GstGLAPI containing the available OpenGL apis in @handle
- *
- * Wraps an existing OpenGL context into a #GstGLContext.
- *
- * Note: The caller is responsible for ensuring that the OpenGL context
- * represented by @handle stays alive while the returned #GstGLContext is
- * active.
- *
- * Returns: (transfer full): a #GstGLContext wrapping @handle
- *
- * Since: 1.4
- */
-GstGLContext *
-gst_gl_context_new_wrapped (GstGLDisplay * display, guintptr handle,
- GstGLPlatform context_type, GstGLAPI available_apis)
-{
- GstGLContext *context;
- GstGLWrappedContext *context_wrap = NULL;
- GstGLContextClass *context_class;
- GstGLAPI display_api;
-
- _init_debug ();
-
- display_api = gst_gl_display_get_gl_api (display);
- g_return_val_if_fail ((display_api & available_apis) != GST_GL_API_NONE,
- NULL);
-
- context_wrap = g_object_new (GST_TYPE_GL_WRAPPED_CONTEXT, NULL);
- gst_object_ref_sink (context_wrap);
-
- if (!context_wrap) {
- /* subclass returned a NULL context */
- GST_ERROR ("Could not wrap existing context");
-
- return NULL;
- }
-
- context = (GstGLContext *) context_wrap;
-
- context->display = gst_object_ref (display);
- context->priv->sharegroup = _context_share_group_new ();
- context_wrap->handle = handle;
- context_wrap->platform = context_type;
- context_wrap->available_apis = available_apis;
-
- context_class = GST_GL_CONTEXT_GET_CLASS (context);
-
-#if GST_GL_HAVE_PLATFORM_GLX
- if (context_type == GST_GL_PLATFORM_GLX) {
- context_class->get_current_context = gst_gl_context_glx_get_current_context;
- context_class->get_proc_address = gst_gl_context_glx_get_proc_address;
- }
-#endif
-#if GST_GL_HAVE_PLATFORM_EGL
- if (context_type == GST_GL_PLATFORM_EGL) {
- context_class->get_current_context = gst_gl_context_egl_get_current_context;
- context_class->get_proc_address = gst_gl_context_egl_get_proc_address;
- }
-#endif
-#if GST_GL_HAVE_PLATFORM_CGL
- if (context_type == GST_GL_PLATFORM_CGL) {
- context_class->get_current_context =
- gst_gl_context_cocoa_get_current_context;
- context_class->get_proc_address = gst_gl_context_default_get_proc_address;
- }
-#endif
-#if GST_GL_HAVE_PLATFORM_WGL
- if (context_type == GST_GL_PLATFORM_WGL) {
- context_class->get_current_context = gst_gl_context_wgl_get_current_context;
- context_class->get_proc_address = gst_gl_context_wgl_get_proc_address;
- }
-#endif
-#if GST_GL_HAVE_PLATFORM_EAGL
- if (context_type == GST_GL_PLATFORM_EAGL) {
- context_class->get_current_context =
- gst_gl_context_eagl_get_current_context;
- context_class->get_proc_address = gst_gl_context_default_get_proc_address;
- }
-#endif
-
- if (!context_class->get_current_context) {
- /* we don't have API support */
- gst_object_unref (context);
- return NULL;
- }
-
- return context;
-}
-
-/**
- * gst_gl_context_get_current_gl_context:
- * @context_type: a #GstGLPlatform specifying the type of context to retrieve
- *
- * Returns: The OpenGL context handle current in the calling thread or %NULL
- *
- * Since: 1.6
- */
-guintptr
-gst_gl_context_get_current_gl_context (GstGLPlatform context_type)
-{
- guintptr handle = 0;
-
- _init_debug ();
-
-#if GST_GL_HAVE_PLATFORM_GLX
- if (!handle && (context_type & GST_GL_PLATFORM_GLX) != 0)
- handle = gst_gl_context_glx_get_current_context ();
-#endif
-#if GST_GL_HAVE_PLATFORM_EGL
- if (!handle && (context_type & GST_GL_PLATFORM_EGL) != 0)
- handle = gst_gl_context_egl_get_current_context ();
-#endif
-#if GST_GL_HAVE_PLATFORM_CGL
- if (!handle && (context_type & GST_GL_PLATFORM_CGL) != 0)
- handle = gst_gl_context_cocoa_get_current_context ();
-#endif
-#if GST_GL_HAVE_PLATFORM_WGL
- if (!handle && (context_type & GST_GL_PLATFORM_WGL) != 0)
- handle = gst_gl_context_wgl_get_current_context ();
-#endif
-#if GST_GL_HAVE_PLATFORM_EAGL
- if (!handle && (context_type & GST_GL_PLATFORM_EAGL) != 0)
- handle = gst_gl_context_eagl_get_current_context ();
-#endif
-
- if (!handle)
- GST_WARNING ("Could not retrieve current context");
-
- return handle;
-}
-
-/**
- * gst_gl_context_get_proc_address_with_platform:
- * @context_type: a #GstGLPlatform
- * @gl_api: a #GstGLAPI
- * @name: the name of the function to retrieve
- *
- * Attempts to use the @context_type specific GetProcAddress implementations
- * to retreive @name.
- *
- * See also gst_gl_context_get_proc_address().
- *
- * Returns: a function pointer for @name, or %NULL
- *
- * Since: 1.6
- */
-gpointer
-gst_gl_context_get_proc_address_with_platform (GstGLPlatform context_type,
- GstGLAPI gl_api, const gchar * name)
-{
- gpointer ret = NULL;
-
-#if GST_GL_HAVE_PLATFORM_GLX
- if (!ret && (context_type & GST_GL_PLATFORM_GLX) != 0)
- ret = gst_gl_context_glx_get_proc_address (gl_api, name);
-#endif
-#if GST_GL_HAVE_PLATFORM_EGL
- if (!ret && (context_type & GST_GL_PLATFORM_EGL) != 0)
- ret = gst_gl_context_egl_get_proc_address (gl_api, name);
-#endif
-#if GST_GL_HAVE_PLATFORM_WGL
- if (!ret && (context_type & GST_GL_PLATFORM_WGL) != 0)
- ret = gst_gl_context_wgl_get_proc_address (gl_api, name);
-#endif
- /* CGL and EAGL rely on the default impl */
-
- if (!ret)
- ret = gst_gl_context_default_get_proc_address (gl_api, name);
-
- return ret;
-}
-
-/**
- * gst_gl_context_get_current_gl_api:
- * @platform: the #GstGLPlatform to retrieve the API for
- * @major: (out) (allow-none): the major version
- * @minor: (out) (allow-none): the minor version
- *
- * If an error occurs, @major and @minor are not modified and %GST_GL_API_NONE is
- * returned.
- *
- * Returns: The version supported by the OpenGL context current in the calling
- * thread or %GST_GL_API_NONE
- *
- * Since: 1.6
- */
-GstGLAPI
-gst_gl_context_get_current_gl_api (GstGLPlatform platform, guint * major,
- guint * minor)
-{
- const GLubyte *(GSTGLAPI * GetString) (GLenum name);
-#if GST_GL_HAVE_OPENGL
- void (GSTGLAPI * GetIntegerv) (GLenum name, GLuint * n);
-#endif
- const gchar *version;
- gint maj, min, n;
- GstGLAPI ret = (1U << 31);
-
- _init_debug ();
-
- while (ret != GST_GL_API_NONE) {
- /* FIXME: attempt to delve into the platform specific GetProcAddress */
- GetString =
- gst_gl_context_get_proc_address_with_platform (platform, ret,
- "glGetString");
-#if GST_GL_HAVE_OPENGL
- GetIntegerv =
- gst_gl_context_get_proc_address_with_platform (platform, ret,
- "glGetIntegerv");
-#endif
- if (!GetString) {
- goto next;
- }
-
- version = (const gchar *) GetString (GL_VERSION);
- if (!version)
- goto next;
-
- /* strlen (x.x) == 3 */
- n = strlen (version);
- if (n < 3)
- goto next;
-
- if (g_strstr_len (version, 9, "OpenGL ES")) {
- /* strlen (OpenGL ES x.x) == 13 */
- if (n < 13)
- goto next;
-
- sscanf (&version[10], "%d.%d", &maj, &min);
-
- if (maj <= 0 || min < 0)
- goto next;
-
- if (maj == 1) {
- ret = GST_GL_API_GLES1;
- break;
- } else if (maj == 2 || maj == 3) {
- ret = GST_GL_API_GLES2;
- break;
- }
-
- goto next;
- } else {
- sscanf (version, "%d.%d", &maj, &min);
-
- if (maj <= 0 || min < 0)
- goto next;
-
-#if GST_GL_HAVE_OPENGL
- if (GetIntegerv && (maj > 3 || (maj == 3 && min > 1))) {
- GLuint context_flags = 0;
-
- ret = GST_GL_API_NONE;
- GetIntegerv (GL_CONTEXT_PROFILE_MASK, &context_flags);
- if (context_flags & GL_CONTEXT_CORE_PROFILE_BIT)
- ret |= GST_GL_API_OPENGL3;
- if (context_flags & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
- ret |= GST_GL_API_OPENGL;
- break;
- }
-#endif
- ret = GST_GL_API_OPENGL;
- break;
- }
-
- next:
- /* iterate through the apis */
- ret >>= 1;
- }
-
- if (ret == GST_GL_API_NONE)
- return GST_GL_API_NONE;
-
- if (major)
- *major = maj;
- if (minor)
- *minor = min;
-
- return ret;
-}
-
-static void
-gst_gl_context_finalize (GObject * object)
-{
- GstGLContext *context = GST_GL_CONTEXT (object);
-
- if (context->window) {
- gst_gl_window_set_resize_callback (context->window, NULL, NULL, NULL);
- gst_gl_window_set_draw_callback (context->window, NULL, NULL, NULL);
-
- g_mutex_lock (&context->priv->render_lock);
- if (context->priv->alive) {
- GST_INFO_OBJECT (context, "send quit gl window loop");
- gst_gl_window_quit (context->window);
-
- GST_INFO_OBJECT (context, "joining gl thread");
- while (context->priv->alive)
- g_cond_wait (&context->priv->destroy_cond, &context->priv->render_lock);
- GST_INFO_OBJECT (context, "gl thread joined");
-
- if (context->priv->gl_thread) {
- g_thread_unref (context->priv->gl_thread);
- context->priv->gl_thread = NULL;
- }
- }
- g_mutex_unlock (&context->priv->render_lock);
-
- gst_gl_window_set_close_callback (context->window, NULL, NULL, NULL);
- gst_object_unref (context->window);
- context->window = NULL;
- }
-
- if (context->priv->active_thread) {
- g_thread_unref (context->priv->active_thread);
- context->priv->active_thread = NULL;
- }
-
- if (context->priv->gl_thread) {
- g_thread_unref (context->priv->gl_thread);
- context->priv->gl_thread = NULL;
- }
-
- if (context->priv->sharegroup) {
- _context_share_group_unref (context->priv->sharegroup);
- context->priv->sharegroup = NULL;
- }
-
- if (context->display) {
- gst_object_unref (context->display);
- context->display = NULL;
- }
-
- if (context->gl_vtable) {
- g_slice_free (GstGLFuncs, context->gl_vtable);
- context->gl_vtable = NULL;
- }
-
- g_mutex_clear (&context->priv->render_lock);
-
- g_cond_clear (&context->priv->create_cond);
- g_cond_clear (&context->priv->destroy_cond);
-
- g_free (context->priv->gl_exts);
- g_weak_ref_clear (&context->priv->other_context_ref);
-
- GST_DEBUG_OBJECT (context, "End of finalize");
- G_OBJECT_CLASS (gst_gl_context_parent_class)->finalize (object);
-}
-
-/**
- * gst_gl_context_activate:
- * @context: a #GstGLContext
- * @activate: %TRUE to activate, %FALSE to deactivate
- *
- * (De)activate the OpenGL context represented by this @context.
- *
- * In OpenGL terms, calls eglMakeCurrent or similar with this context and the
- * currently set window. See gst_gl_context_set_window() for details.
- *
- * Returns: Whether the activation succeeded
- *
- * Since: 1.4
- */
-gboolean
-gst_gl_context_activate (GstGLContext * context, gboolean activate)
-{
- GstGLContextClass *context_class;
- gboolean result;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
- context_class = GST_GL_CONTEXT_GET_CLASS (context);
- g_return_val_if_fail (context_class->activate != NULL, FALSE);
-
- GST_DEBUG_OBJECT (context, "activate:%d", activate);
-
- GST_OBJECT_LOCK (context);
- result = context_class->activate (context, activate);
-
- if (result && activate) {
- GThread *old_thread = context->priv->active_thread;
- context->priv->active_thread = g_thread_ref (g_thread_self ());
- if (old_thread) {
- g_thread_unref (old_thread);
- }
-
- g_private_set (&current_context_key, context);
- } else {
- if (context->priv->active_thread) {
- g_thread_unref (context->priv->active_thread);
- context->priv->active_thread = NULL;
- }
- g_private_set (&current_context_key, NULL);
- }
- GST_OBJECT_UNLOCK (context);
-
- return result;
-}
-
-/**
- * gst_gl_context_get_thread:
- * @context: a #GstGLContext
- *
- * Returns: (transfer full): The #GThread, @context is current in or NULL
- *
- * Since: 1.6
- */
-GThread *
-gst_gl_context_get_thread (GstGLContext * context)
-{
- GThread *ret;
-
- GST_OBJECT_LOCK (context);
- ret = context->priv->active_thread;
- if (ret)
- g_thread_ref (ret);
- GST_OBJECT_UNLOCK (context);
-
- return ret;
-}
-
-/**
- * gst_gl_context_get_gl_api:
- * @context: a #GstGLContext
- *
- * Get the currently enabled OpenGL api.
- *
- * The currently available API may be limited by the #GstGLDisplay in use and/or
- * the #GstGLWindow chosen.
- *
- * Returns: the available OpenGL api
- *
- * Since: 1.4
- */
-GstGLAPI
-gst_gl_context_get_gl_api (GstGLContext * context)
-{
- GstGLContextClass *context_class;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), GST_GL_API_NONE);
- context_class = GST_GL_CONTEXT_GET_CLASS (context);
- g_return_val_if_fail (context_class->get_gl_api != NULL, GST_GL_API_NONE);
-
- return context_class->get_gl_api (context);
-}
-
-/**
- * gst_gl_context_get_proc_address:
- * @context: a #GstGLContext
- * @name: an opengl function name
- *
- * Get a function pointer to a specified opengl function, @name. If the the
- * specific function does not exist, NULL is returned instead.
- *
- * Platform specfic functions (names starting 'egl', 'glX', 'wgl', etc) can also
- * be retrieved using this method.
- *
- * Note: This function may return valid function pointers that may not be valid
- * to call in @context. The caller is responsible for ensuring that the
- * returned function is a valid function to call in @context by either checking
- * the OpenGL API and version or for an appropriate OpenGL extension.
- *
- * Note: On success, you need to cast the returned function pointer to the
- * correct type to be able to call it correctly. On 32-bit Windows, this will
- * include the %GSTGLAPI identifier to use the correct calling convention.
- * e.g.
- *
- * |[<!-- language="C" -->
- * void (GSTGLAPI *PFN_glGetIntegerv) (GLenum name, GLint * ret)
- * ]|
- *
- * Returns: a function pointer or %NULL
- *
- * Since: 1.4
- */
-gpointer
-gst_gl_context_get_proc_address (GstGLContext * context, const gchar * name)
-{
- gpointer ret;
- GstGLContextClass *context_class;
- GstGLAPI gl_api;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), NULL);
- context_class = GST_GL_CONTEXT_GET_CLASS (context);
- g_return_val_if_fail (context_class->get_proc_address != NULL, NULL);
-
- gl_api = gst_gl_context_get_gl_api (context);
- ret = context_class->get_proc_address (gl_api, name);
-
- return ret;
-}
-
-/**
- * gst_gl_context_default_get_proc_address:
- * @gl_api: a #GstGLAPI
- * @name: then function to get the address of
- *
- * A default implementation of the various GetProcAddress functions that looks
- * for @name in the OpenGL shared libraries or in the current process.
- *
- * See also: gst_gl_context_get_proc_address()
- *
- * Returns: an address pointing to @name or %NULL
- *
- * Since: 1.4
- */
-gpointer
-gst_gl_context_default_get_proc_address (GstGLAPI gl_api, const gchar * name)
-{
- gpointer ret = NULL;
-
- /* First try to load symbol from the selected GL API for this context */
-#if GST_GL_HAVE_GLES2
- if (!ret && (gl_api & GST_GL_API_GLES2)) {
- g_once (&module_gles2_gonce, load_gles2_module, NULL);
- if (module_gles2)
- g_module_symbol (module_gles2, name, &ret);
- }
-#endif
-
-#if GST_GL_HAVE_OPENGL
- if (!ret && (gl_api & (GST_GL_API_OPENGL | GST_GL_API_OPENGL3))) {
- g_once (&module_opengl_gonce, load_opengl_module, NULL);
- if (module_opengl)
- g_module_symbol (module_opengl, name, &ret);
- }
-#endif
-
- /* Otherwise fall back to the current module */
- g_once (&module_self_gonce, load_self_module, NULL);
- if (!ret)
- g_module_symbol (module_self, name, &ret);
-
- return ret;
-}
-
-/**
- * gst_gl_context_set_window:
- * @context: a #GstGLContext
- * @window: (transfer full): a #GstGLWindow
- *
- * Set's the current window on @context to @window. The window can only be
- * changed before gst_gl_context_create() has been called and the @window is not
- * already running.
- *
- * Returns: Whether the window was successfully updated
- *
- * Since: 1.4
- */
-gboolean
-gst_gl_context_set_window (GstGLContext * context, GstGLWindow * window)
-{
- g_return_val_if_fail (!GST_IS_GL_WRAPPED_CONTEXT (context), FALSE);
-
- GST_DEBUG_OBJECT (context, "window:%" GST_PTR_FORMAT, window);
-
- /* we can't change the window while we are running */
- if (context->priv->alive)
- return FALSE;
-
- if (window)
- g_weak_ref_set (&window->context_ref, context);
-
- if (context->window)
- gst_object_unref (context->window);
-
- context->window = window ? gst_object_ref (window) : NULL;
-
- return TRUE;
-}
-
-/**
- * gst_gl_context_get_window:
- * @context: a #GstGLContext
- *
- * Returns: (transfer full) (nullable): the currently set window
- *
- * Since: 1.4
- */
-GstGLWindow *
-gst_gl_context_get_window (GstGLContext * context)
-{
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), NULL);
-
- if (GST_IS_GL_WRAPPED_CONTEXT (context)) {
- GST_WARNING_OBJECT (context, "context is not toplevel, returning NULL");
- return NULL;
- }
-
- _ensure_window (context);
-
- return gst_object_ref (context->window);
-}
-
-/**
- * gst_gl_context_can_share:
- * @context: a #GstGLContext
- * @other_context: another #GstGLContext
- *
- * Note: This will always fail for two wrapped #GstGLContext's
- *
- * Returns: whether @context and @other_context are able to share OpenGL
- * resources.
- *
- * Since: 1.6
- */
-gboolean
-gst_gl_context_can_share (GstGLContext * context, GstGLContext * other_context)
-{
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
- g_return_val_if_fail (GST_IS_GL_CONTEXT (other_context), FALSE);
-
- /* check if the contexts are descendants or the root nodes are the same */
- return context->priv->sharegroup != NULL
- && context->priv->sharegroup == other_context->priv->sharegroup;
-}
-
-/**
- * gst_gl_context_create:
- * @context: a #GstGLContext:
- * @other_context: (allow-none): a #GstGLContext to share OpenGL objects with
- * @error: (allow-none): a #GError
- *
- * Creates an OpenGL context with the specified @other_context as a context
- * to share shareable OpenGL objects with. See the OpenGL specification for
- * what is shared between OpenGL contexts.
- *
- * If an error occurs, and @error is not %NULL, then error will contain details
- * of the error and %FALSE will be returned.
- *
- * Should only be called once.
- *
- * Returns: whether the context could successfully be created
- *
- * Since: 1.4
- */
-gboolean
-gst_gl_context_create (GstGLContext * context,
- GstGLContext * other_context, GError ** error)
-{
- gboolean alive = FALSE;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
- g_return_val_if_fail (!GST_IS_GL_WRAPPED_CONTEXT (context), FALSE);
-
- GST_DEBUG_OBJECT (context, " other_context:%" GST_PTR_FORMAT, other_context);
-
- _ensure_window (context);
-
- g_mutex_lock (&context->priv->render_lock);
-
- if (!context->priv->created) {
- g_weak_ref_set (&context->priv->other_context_ref, other_context);
- context->priv->error = error;
- if (other_context == NULL)
- context->priv->sharegroup = _context_share_group_new ();
- else
- context->priv->sharegroup =
- _context_share_group_ref (other_context->priv->sharegroup);
-
- context->priv->gl_thread = g_thread_new ("gstglcontext",
- (GThreadFunc) gst_gl_context_create_thread, context);
-
- while (!context->priv->created)
- g_cond_wait (&context->priv->create_cond, &context->priv->render_lock);
-
- GST_INFO_OBJECT (context, "gl thread created");
- }
-
- alive = context->priv->alive;
-
- g_mutex_unlock (&context->priv->render_lock);
-
- return alive;
-}
-
-static gboolean
-_create_context_info (GstGLContext * context, GstGLAPI gl_api, gint * gl_major,
- gint * gl_minor, GError ** error)
-{
- const GstGLFuncs *gl;
- guint maj = 0, min = 0;
- GLenum gl_err = GL_NO_ERROR;
- const gchar *opengl_version = NULL;
-
- gl = context->gl_vtable;
-
- if (!gl->GetString || !gl->GetString (GL_VERSION)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "glGetString not defined or returned invalid value");
- return FALSE;
- }
-
- if (!gl->GetString (GL_SHADING_LANGUAGE_VERSION)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "No GL shader support available");
- return FALSE;
- }
-
- GST_INFO_OBJECT (context, "GL_VERSION: %s",
- GST_STR_NULL ((const gchar *) gl->GetString (GL_VERSION)));
- GST_INFO_OBJECT (context, "GL_SHADING_LANGUAGE_VERSION: %s",
- GST_STR_NULL ((const gchar *)
- gl->GetString (GL_SHADING_LANGUAGE_VERSION)));
- GST_INFO_OBJECT (context, "GL_VENDOR: %s",
- GST_STR_NULL ((const gchar *) gl->GetString (GL_VENDOR)));
- GST_INFO_OBJECT (context, "GL_RENDERER: %s",
- GST_STR_NULL ((const gchar *) gl->GetString (GL_RENDERER)));
-
- gl_err = gl->GetError ();
- if (gl_err != GL_NO_ERROR) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "glGetString error: 0x%x", gl_err);
- return FALSE;
- }
-
- opengl_version = (const gchar *) gl->GetString (GL_VERSION);
- if (opengl_version && gl_api & GST_GL_API_GLES2)
- /* gles starts with "OpenGL ES " */
- opengl_version = &opengl_version[10];
-
- if (opengl_version)
- sscanf (opengl_version, "%d.%d", &maj, &min);
-
- /* OpenGL > 1.2.0 */
- if (gl_api & GST_GL_API_OPENGL || gl_api & GST_GL_API_OPENGL3) {
- if ((maj < 1) || (maj < 2 && maj >= 1 && min < 2)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_OLD_LIBS,
- "OpenGL >= 1.2.0 required, found %u.%u", maj, min);
- return FALSE;
- }
- }
-
- if (gl_major)
- *gl_major = maj;
- if (gl_minor)
- *gl_minor = min;
-
- return TRUE;
-}
-
-static GstGLAPI
-_compiled_api (void)
-{
- GstGLAPI ret = GST_GL_API_NONE;
-
-#if GST_GL_HAVE_OPENGL
- ret |= GST_GL_API_OPENGL | GST_GL_API_OPENGL3;
-#endif
-#if GST_GL_HAVE_GLES2
- ret |= GST_GL_API_GLES2;
-#endif
-
- return ret;
-}
-
-static void
-_unlock_create_thread (GstGLContext * context)
-{
- context->priv->created = TRUE;
- GST_INFO_OBJECT (context, "gl thread running");
- g_cond_signal (&context->priv->create_cond);
- g_mutex_unlock (&context->priv->render_lock);
-}
-
-static GString *
-_build_extension_string (GstGLContext * context)
-{
- const GstGLFuncs *gl = context->gl_vtable;
- GString *ext_g_str = g_string_sized_new (1024);
- const gchar *ext_const_c_str = NULL;
- GLint i = 0;
- GLint n = 0;
-
- gl->GetIntegerv (GL_NUM_EXTENSIONS, &n);
-
- for (i = 0; i < n; i++) {
- ext_const_c_str = (const gchar *) gl->GetStringi (GL_EXTENSIONS, i);
- if (ext_const_c_str)
- g_string_append_printf (ext_g_str, "%s ", ext_const_c_str);
- }
-
- return ext_g_str;
-}
-
-//gboolean
-//gst_gl_context_create (GstGLContext * context, GstGLContext * other_context, GError ** error)
-static gpointer
-gst_gl_context_create_thread (GstGLContext * context)
-{
- GstGLContextClass *context_class;
- GstGLWindowClass *window_class;
- GstGLAPI compiled_api, user_api, gl_api, display_api;
- gchar *api_string;
- gchar *compiled_api_s;
- gchar *user_api_s;
- gchar *display_api_s;
- const gchar *user_choice;
- GError **error;
- GstGLContext *other_context;
-
- g_mutex_lock (&context->priv->render_lock);
-
- GST_DEBUG_OBJECT (context, "Creating thread");
-
- error = context->priv->error;
- other_context = g_weak_ref_get (&context->priv->other_context_ref);
-
- context_class = GST_GL_CONTEXT_GET_CLASS (context);
- window_class = GST_GL_WINDOW_GET_CLASS (context->window);
-
- display_api = gst_gl_display_get_gl_api_unlocked (context->display);
- if (display_api == GST_GL_API_NONE) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_WRONG_API,
- "Cannot create context with satisfying requested apis "
- "(display has no GL api!)");
- goto failure;
- }
-
- if (window_class->open) {
- if (!window_class->open (context->window, error)) {
- GST_WARNING_OBJECT (context, "Failed to open window");
- g_assert (error == NULL || *error != NULL);
- goto failure;
- }
- }
-
- compiled_api = _compiled_api ();
- compiled_api_s = gst_gl_api_to_string (compiled_api);
-
- user_choice = g_getenv ("GST_GL_API");
- user_api = gst_gl_api_from_string (user_choice);
- user_api_s = gst_gl_api_to_string (user_api);
-
- display_api_s = gst_gl_api_to_string (display_api);
-
- if ((user_api & compiled_api & display_api) == GST_GL_API_NONE) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_WRONG_API,
- "Cannot create context with the user requested api (%s). "
- "We have support for (%s), display api (%s)", user_api_s,
- compiled_api_s, display_api_s);
- g_free (user_api_s);
- g_free (compiled_api_s);
- g_free (display_api_s);
- goto failure;
- }
-
- if (context_class->choose_format &&
- !context_class->choose_format (context, error)) {
- GST_WARNING_OBJECT (context, "Failed to choose format");
- g_assert (error == NULL || *error != NULL);
- g_free (compiled_api_s);
- g_free (user_api_s);
- g_free (display_api_s);
- goto failure;
- }
-
- GST_INFO_OBJECT (context,
- "Attempting to create opengl context. user chosen api(s) (%s), "
- "compiled api support (%s) display api (%s)", user_api_s, compiled_api_s,
- display_api_s);
-
- if (!context_class->create_context (context,
- compiled_api & user_api & display_api, other_context, error)) {
- GST_WARNING_OBJECT (context, "Failed to create context");
- g_assert (error == NULL || *error != NULL);
- g_free (compiled_api_s);
- g_free (user_api_s);
- g_free (display_api_s);
- goto failure;
- }
- GST_INFO_OBJECT (context, "created context");
-
- if (!gst_gl_context_activate (context, TRUE)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE,
- "Failed to activate the GL Context");
- g_free (compiled_api_s);
- g_free (user_api_s);
- g_free (display_api_s);
- goto failure;
- }
-
- gl_api = gst_gl_context_get_gl_api (context);
- g_assert (gl_api != GST_GL_API_NONE && gl_api != GST_GL_API_ANY);
-
- api_string = gst_gl_api_to_string (gl_api);
- GST_INFO_OBJECT (context, "available GL APIs: %s", api_string);
-
- if (((compiled_api & gl_api & display_api) & user_api) == GST_GL_API_NONE) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_WRONG_API,
- "failed to create context, context "
- "could not provide correct api. user (%s), compiled (%s), context (%s)",
- user_api_s, compiled_api_s, api_string);
- g_free (api_string);
- g_free (compiled_api_s);
- g_free (user_api_s);
- g_free (display_api_s);
- goto failure;
- }
-
- g_free (api_string);
- g_free (compiled_api_s);
- g_free (user_api_s);
- g_free (display_api_s);
-
- GST_DEBUG_OBJECT (context, "Filling info");
- if (!gst_gl_context_fill_info (context, error)) {
- g_assert (error == NULL || *error != NULL);
- goto failure;
- }
-
- context->priv->alive = TRUE;
-
-#if !defined(GST_DISABLE_GST_DEBUG)
- _gst_gl_debug_enable (context);
-#endif
-
- if (other_context) {
- GST_DEBUG_OBJECT (context, "Unreffing other_context %" GST_PTR_FORMAT,
- other_context);
- gst_object_unref (other_context);
- }
-
- /* unlocking of the render_lock happens when the
- * context's loop is running from inside that loop */
- gst_gl_window_send_message_async (context->window,
- (GstGLWindowCB) _unlock_create_thread, context, NULL);
-
- gst_gl_window_run (context->window);
-
- GST_INFO_OBJECT (context, "loop exited");
-
- g_mutex_lock (&context->priv->render_lock);
- context->priv->alive = FALSE;
-
- gst_gl_context_activate (context, FALSE);
-
- context_class->destroy_context (context);
-
- /* User supplied callback */
- if (context->window->close)
- context->window->close (context->window->close_data);
-
- /* window specific shutdown */
- if (window_class->close) {
- window_class->close (context->window);
- }
-
- context->priv->created = FALSE;
- g_cond_signal (&context->priv->destroy_cond);
- g_mutex_unlock (&context->priv->render_lock);
-
- return NULL;
-
-failure:
- {
- if (other_context)
- gst_object_unref (other_context);
-
- /* A context that fails to be created is considered created but not alive
- * and will never be able to be alive as creation can't happen */
- context->priv->created = TRUE;
- g_cond_signal (&context->priv->create_cond);
- g_mutex_unlock (&context->priv->render_lock);
- return NULL;
- }
-}
-
-/**
- * gst_gl_context_destroy:
- * @context: a #GstGLContext:
- *
- * Destroys an OpenGL context.
- *
- * Should only be called after gst_gl_context_create() has been successfully
- * called for this context.
- *
- * Since: 1.6
- */
-void
-gst_gl_context_destroy (GstGLContext * context)
-{
- GstGLContextClass *context_class;
-
- g_return_if_fail (GST_IS_GL_CONTEXT (context));
- context_class = GST_GL_CONTEXT_GET_CLASS (context);
- g_return_if_fail (context_class->destroy_context != NULL);
-
- context_class->destroy_context (context);
-}
-
-/**
- * gst_gl_context_fill_info:
- * @context: a #GstGLContext:
- * @error: (allow-none): a #GError to fill on failure
- *
- * Fills @context's info (version, extensions, vtable, etc) from the GL
- * context in the current thread. Typically used with wrapped contexts to
- * allow wrapped contexts to be used as regular #GstGLContext's.
- *
- * Since: 1.6
- */
-gboolean
-gst_gl_context_fill_info (GstGLContext * context, GError ** error)
-{
- GstGLFuncs *gl;
- GString *ext_g_str = NULL;
- const gchar *ext_const_c_str = NULL;
- GstGLAPI gl_api;
- gboolean ret;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
- g_return_val_if_fail (context->priv->active_thread == g_thread_self (),
- FALSE);
-
- gl = context->gl_vtable;
- gl_api = gst_gl_context_get_gl_api (context);
-
- gl->GetError = gst_gl_context_get_proc_address (context, "glGetError");
- gl->GetString = gst_gl_context_get_proc_address (context, "glGetString");
- gl->GetStringi = gst_gl_context_get_proc_address (context, "glGetStringi");
- gl->GetIntegerv = gst_gl_context_get_proc_address (context, "glGetIntegerv");
-
- if (!gl->GetError || !gl->GetString) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "could not GetProcAddress core opengl functions");
- goto failure;
- }
-
- /* gl api specific code */
- ret = _create_context_info (context, gl_api, &context->priv->gl_major,
- &context->priv->gl_minor, error);
-
- if (!ret) {
- g_assert (error == NULL || *error != NULL);
- goto failure;
- }
-
- /* GL core contexts and GLES3 */
- if (gl->GetIntegerv && gl->GetStringi && context->priv->gl_major >= 3)
- ext_g_str = _build_extension_string (context);
-
- if (ext_g_str && ext_g_str->len) {
- GST_DEBUG_OBJECT (context, "GL_EXTENSIONS: %s", ext_g_str->str);
- _gst_gl_feature_check_ext_functions (context, context->priv->gl_major,
- context->priv->gl_minor, ext_g_str->str);
-
- context->priv->gl_exts = g_string_free (ext_g_str, FALSE);
- } else {
- ext_const_c_str = (const gchar *) gl->GetString (GL_EXTENSIONS);
- if (!ext_const_c_str)
- ext_const_c_str = "";
-
- GST_DEBUG_OBJECT (context, "GL_EXTENSIONS: %s", ext_const_c_str);
- _gst_gl_feature_check_ext_functions (context, context->priv->gl_major,
- context->priv->gl_minor, ext_const_c_str);
-
- context->priv->gl_exts = g_strdup (ext_const_c_str);
- }
-
- if (gl_api & GST_GL_API_OPENGL3
- && !gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 4, 1)
- && !gst_gl_check_extension ("GL_ARB_ES2_compatibility",
- context->priv->gl_exts)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "An opengl3 context created but the required ES2 compatibility was not found");
- goto failure;
- }
-
- /* Does not implement OES_vertex_array_object properly, see
- * https://bugzilla.gnome.org/show_bug.cgi?id=750185 */
- if (g_strcmp0 ((const gchar *) gl->GetString (GL_VENDOR),
- "Imagination Technologies") == 0
- && g_strcmp0 ((const gchar *) gl->GetString (GL_RENDERER),
- "PowerVR SGX 544MP") == 0) {
- gl->GenVertexArrays = NULL;
- gl->DeleteVertexArrays = NULL;
- gl->BindVertexArray = NULL;
- gl->IsVertexArray = NULL;
- }
-
- return TRUE;
-
-failure:
- return FALSE;
-}
-
-/**
- * gst_gl_context_get_gl_context:
- * @context: a #GstGLContext:
- *
- * Gets the backing OpenGL context used by @context.
- *
- * Returns: The platform specific backing OpenGL context
- *
- * Since: 1.4
- */
-guintptr
-gst_gl_context_get_gl_context (GstGLContext * context)
-{
- GstGLContextClass *context_class;
- guintptr result;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), 0);
- context_class = GST_GL_CONTEXT_GET_CLASS (context);
- g_return_val_if_fail (context_class->get_gl_context != NULL, 0);
-
- result = context_class->get_gl_context (context);
-
- return result;
-}
-
-/**
- * gst_gl_context_get_gl_platform:
- * @context: a #GstGLContext:
- *
- * Gets the OpenGL platform that used by @context.
- *
- * Returns: The platform specific backing OpenGL context
- *
- * Since: 1.4
- */
-GstGLPlatform
-gst_gl_context_get_gl_platform (GstGLContext * context)
-{
- GstGLContextClass *context_class;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), 0);
- context_class = GST_GL_CONTEXT_GET_CLASS (context);
- g_return_val_if_fail (context_class->get_gl_platform != NULL, 0);
-
- return context_class->get_gl_platform (context);
-}
-
-/**
- * gst_gl_context_get_display:
- * @context: a #GstGLContext:
- *
- * Returns: (transfer full): the #GstGLDisplay associated with this @context
- *
- * Since: 1.4
- */
-GstGLDisplay *
-gst_gl_context_get_display (GstGLContext * context)
-{
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), NULL);
-
- return gst_object_ref (context->display);
-}
-
-typedef struct
-{
- GstGLContext *context;
- GstGLContextThreadFunc func;
- gpointer data;
-} RunGenericData;
-
-static void
-_gst_gl_context_thread_run_generic (RunGenericData * data)
-{
- GST_TRACE_OBJECT (data->context, "running function:%p data:%p", data->func,
- data->data);
-
- data->func (data->context, data->data);
-}
-
-/**
- * gst_gl_context_thread_add:
- * @context: a #GstGLContext
- * @func: (scope call): a #GstGLContextThreadFunc
- * @data: (closure): user data to call @func with
- *
- * Execute @func in the OpenGL thread of @context with @data
- *
- * MT-safe
- *
- * Since: 1.4
- */
-void
-gst_gl_context_thread_add (GstGLContext * context,
- GstGLContextThreadFunc func, gpointer data)
-{
- GstGLWindow *window;
- RunGenericData rdata;
-
- g_return_if_fail (GST_IS_GL_CONTEXT (context));
- g_return_if_fail (func != NULL);
-
- if (GST_IS_GL_WRAPPED_CONTEXT (context))
- g_return_if_fail (context->priv->active_thread == g_thread_self ());
-
- if (context->priv->active_thread == g_thread_self ()) {
- func (context, data);
- return;
- }
-
- rdata.context = context;
- rdata.data = data;
- rdata.func = func;
-
- window = gst_gl_context_get_window (context);
-
- gst_gl_window_send_message (window,
- GST_GL_WINDOW_CB (_gst_gl_context_thread_run_generic), &rdata);
-
- gst_object_unref (window);
-}
-
-/**
- * gst_gl_context_get_gl_version:
- * @context: a #GstGLContext
- * @maj: (out): resulting major version
- * @min: (out): resulting minor version
- *
- * Returns the OpenGL version implemented by @context. See
- * gst_gl_context_get_gl_api() for retreiving the OpenGL api implemented by
- * @context.
- *
- * Since: 1.4
- */
-void
-gst_gl_context_get_gl_version (GstGLContext * context, gint * maj, gint * min)
-{
- g_return_if_fail (GST_IS_GL_CONTEXT (context));
- g_return_if_fail (!(maj == NULL && min == NULL));
-
- if (maj)
- *maj = context->priv->gl_major;
-
- if (min)
- *min = context->priv->gl_minor;
-}
-
-/**
- * gst_gl_context_check_gl_version:
- * @context: a #GstGLContext
- * @api: api type required
- * @maj: major version required
- * @min: minor version required
- *
- * Returns: whether OpenGL context implements the required api and specified
- * version.
- *
- * Since: 1.4
- */
-gboolean
-gst_gl_context_check_gl_version (GstGLContext * context, GstGLAPI api,
- gint maj, gint min)
-{
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
-
- if (maj > context->priv->gl_major)
- return FALSE;
-
- if ((gst_gl_context_get_gl_api (context) & api) == GST_GL_API_NONE)
- return FALSE;
-
- if (maj < context->priv->gl_major)
- return TRUE;
-
- if (min > context->priv->gl_minor)
- return FALSE;
-
- return TRUE;
-}
-
-/**
- * gst_gl_context_check_feature:
- * @context: a #GstGLContext
- * @feature: a platform specific feature
- *
- * Check for an OpenGL @feature being supported.
- *
- * Note: Most features require that the context be created before it is
- * possible to determine their existence and so will fail if that is not the
- * case.
- *
- * Returns: Whether @feature is supported by @context
- *
- * Since: 1.4
- */
-gboolean
-gst_gl_context_check_feature (GstGLContext * context, const gchar * feature)
-{
- GstGLContextClass *context_class;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
- g_return_val_if_fail (feature != NULL, FALSE);
-
- context_class = GST_GL_CONTEXT_GET_CLASS (context);
-
- if (g_strstr_len (feature, 3, "GL_"))
- return gst_gl_check_extension (feature, context->priv->gl_exts);
-
- if (!context_class->check_feature)
- return FALSE;
-
- return context_class->check_feature (context, feature);
-}
-
-/**
- * gst_gl_context_get_current:
- *
- * See also gst_gl_context_activate().
- *
- * Returns: (transfer none): the #GstGLContext active in the current thread or %NULL
- *
- * Since: 1.6
- */
-GstGLContext *
-gst_gl_context_get_current (void)
-{
- return g_private_get (&current_context_key);
-}
-
-/**
- * gst_gl_context_is_shared:
- * @context: a #GstGLContext
- *
- * Returns: Whether the #GstGLContext has been shared with another #GstGLContext
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_context_is_shared (GstGLContext * context)
-{
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
-
- if (!context->priv->sharegroup)
- return FALSE;
-
- if (GST_IS_GL_WRAPPED_CONTEXT (context))
- g_return_val_if_fail (context->priv->active_thread, FALSE);
- else
- g_return_val_if_fail (context->priv->alive, FALSE);
-
- return _context_share_group_is_shared (context->priv->sharegroup);
-}
-
-/**
- * gst_gl_context_set_shared_with:
- * @context: a wrapped #GstGLContext
- * @share: another #GstGLContext
- *
- * Will internally set @context as shared with @share
- *
- * Since: 1.8
- */
-void
-gst_gl_context_set_shared_with (GstGLContext * context, GstGLContext * share)
-{
- g_return_if_fail (GST_IS_GL_CONTEXT (context));
- g_return_if_fail (GST_IS_GL_CONTEXT (share));
- g_return_if_fail (!gst_gl_context_is_shared (context));
- /* XXX: may be a little too strict */
- g_return_if_fail (GST_IS_GL_WRAPPED_CONTEXT (context));
-
- if (context->priv->sharegroup)
- _context_share_group_unref (context->priv->sharegroup);
- context->priv->sharegroup =
- _context_share_group_ref (share->priv->sharegroup);
-}
-
-static void
-gst_gl_context_default_get_gl_platform_version (GstGLContext * context,
- gint * major, gint * minor)
-{
- if (major)
- *major = 0;
- if (minor)
- *minor = 0;
-}
-
-/**
- * gst_gl_context_get_gl_platform_version:
- * @context: a #GstGLContext
- * @major: (out): return for the major version
- * @minor: (out): return for the minor version
- *
- * Get the version of the OpenGL platform (GLX, EGL, etc) used. Only valid
- * after a call to gst_gl_context_create_context().
- */
-void
-gst_gl_context_get_gl_platform_version (GstGLContext * context, gint * major,
- gint * minor)
-{
- GstGLContextClass *context_class;
-
- g_return_if_fail (GST_IS_GL_CONTEXT (context));
- g_return_if_fail (major != NULL);
- g_return_if_fail (minor != NULL);
- context_class = GST_GL_CONTEXT_GET_CLASS (context);
- g_return_if_fail (context_class->get_gl_platform_version != NULL);
-
- context_class->get_gl_platform_version (context, major, minor);
-}
-
-/**
- * gst_gl_context_swap_buffers:
- * @context: a #GstGLContext
- *
- * Swap the front and back buffers on the window attached to @context.
- * This will display the frame on the next refresh cycle.
- */
-void
-gst_gl_context_swap_buffers (GstGLContext * context)
-{
- GstGLContextClass *context_class;
-
- g_return_if_fail (GST_IS_GL_CONTEXT (context));
- context_class = GST_GL_CONTEXT_GET_CLASS (context);
- g_return_if_fail (context_class->swap_buffers != NULL);
-
- context_class->swap_buffers (context);
-}
-
-static GstGLAPI
-gst_gl_wrapped_context_get_gl_api (GstGLContext * context)
-{
- GstGLWrappedContext *context_wrap = GST_GL_WRAPPED_CONTEXT (context);
-
- return context_wrap->available_apis;
-}
-
-static guintptr
-gst_gl_wrapped_context_get_gl_context (GstGLContext * context)
-{
- GstGLWrappedContext *context_wrap = GST_GL_WRAPPED_CONTEXT (context);
-
- return context_wrap->handle;
-}
-
-static GstGLPlatform
-gst_gl_wrapped_context_get_gl_platform (GstGLContext * context)
-{
- GstGLWrappedContext *context_wrap = GST_GL_WRAPPED_CONTEXT (context);
-
- return context_wrap->platform;
-}
-
-static gboolean
-gst_gl_wrapped_context_activate (GstGLContext * context, gboolean activate)
-{
- if (activate) {
- GThread *old_thread = context->priv->gl_thread;
- context->priv->gl_thread = g_thread_ref (g_thread_self ());
- if (old_thread) {
- g_thread_unref (old_thread);
- }
- } else {
- if (context->priv->gl_thread) {
- g_thread_unref (context->priv->gl_thread);
- context->priv->gl_thread = NULL;
- }
- }
-
- return TRUE;
-}
-
-static void
-gst_gl_wrapped_context_class_init (GstGLWrappedContextClass * klass)
-{
- GstGLContextClass *context_class = (GstGLContextClass *) klass;
-
- context_class->get_gl_context =
- GST_DEBUG_FUNCPTR (gst_gl_wrapped_context_get_gl_context);
- context_class->get_gl_api =
- GST_DEBUG_FUNCPTR (gst_gl_wrapped_context_get_gl_api);
- context_class->get_gl_platform =
- GST_DEBUG_FUNCPTR (gst_gl_wrapped_context_get_gl_platform);
- context_class->activate = GST_DEBUG_FUNCPTR (gst_gl_wrapped_context_activate);
-}
-
-static void
-gst_gl_wrapped_context_init (GstGLWrappedContext * context)
-{
-}
diff --git a/gst-libs/gst/gl/gstglcontext.h b/gst-libs/gst/gl/gstglcontext.h
deleted file mode 100644
index 54383c56e..000000000
--- a/gst-libs/gst/gl/gstglcontext.h
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_CONTEXT_H__
-#define __GST_GL_CONTEXT_H__
-
-#include <gst/gst.h>
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GType gst_gl_context_get_type (void);
-#define GST_TYPE_GL_CONTEXT (gst_gl_context_get_type())
-
-/* FIXME: remove this when moving to -base */
-#ifndef GST_DISABLE_DEPRECATED
-#define GST_GL_TYPE_CONTEXT GST_TYPE_GL_CONTEXT
-#endif
-#define GST_GL_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_CONTEXT, GstGLContext))
-#define GST_GL_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GST_TYPE_GL_CONTEXT, GstGLContextClass))
-#define GST_IS_GL_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_CONTEXT))
-#define GST_IS_GL_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_CONTEXT))
-#define GST_GL_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_CONTEXT, GstGLContextClass))
-
-GST_EXPORT
-GQuark gst_gl_context_error_quark (void);
-
-/**
- * GST_GL_CONTEXT_ERROR:
- *
- * Error domain for GStreamer's GL context module. Errors in this domain will
- * be from the #GstGLContextError enumeration
- */
-#define GST_GL_CONTEXT_ERROR (gst_gl_context_error_quark ())
-
-/**
- * GstGLContextThreadFunc:
- * @context: a #GstGLContext
- * @data: user data
- *
- * Represents a function to run in the GL thread with @context and @data
- */
-typedef void (*GstGLContextThreadFunc) (GstGLContext * context, gpointer data);
-
-#define GST_GL_CONTEXT_TYPE_CGL "gst.gl.context.CGL"
-#define GST_GL_CONTEXT_TYPE_GLX "gst.gl.context.GLX"
-#define GST_GL_CONTEXT_TYPE_EGL "gst.gl.context.EGL"
-#define GST_GL_CONTEXT_TYPE_WGL "gst.gl.context.WGL"
-#define GST_GL_CONTEXT_TYPE_EAGL "gst.gl.context.EAGL"
-
-/**
- * GstGLContextError:
- * @GST_GL_CONTEXT_ERROR_FAILED: Failed for an unspecified reason
- * @GST_GL_CONTEXT_ERROR_WRONG_CONFIG: The configuration requested is not correct
- * @GST_GL_CONTEXT_ERROR_WRONG_API: The OpenGL API requested is not correct
- * @GST_GL_CONTEXT_ERROR_OLD_LIBS: The OpenGL libraries are too old
- * @GST_GL_CONTEXT_ERROR_CREATE_CONTEXT: glXCreateContext (or similar) failed
- * @GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE: A resource is not available
- *
- * OpenGL context errors.
- */
-typedef enum
-{
- GST_GL_CONTEXT_ERROR_FAILED,
- GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
- GST_GL_CONTEXT_ERROR_WRONG_API,
- GST_GL_CONTEXT_ERROR_OLD_LIBS,
- GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
- GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE,
-} GstGLContextError;
-
-/**
- * GstGLContext:
- * @gl_vtable: a list of OpenGL function pointers
- *
- * Opaque #GstGLContext object
- */
-struct _GstGLContext {
- /*< private >*/
- GstObject parent;
-
- GstGLDisplay *display;
- GstGLWindow *window;
-
- /*< public >*/
- GstGLFuncs *gl_vtable;
-
- /*< private >*/
- GstGLContextPrivate *priv;
-
- gpointer _reserved[GST_PADDING];
-};
-
-/**
- * GstGLContextClass:
- * @get_gl_context: get the backing platform specific OpenGL context
- * @get_gl_api: get the available OpenGL api's that this context can work with
- * @get_proc_address: get an function pointer to an OpenGL function
- * @activate: call eglMakeCurrent or similar
- * @choose_format: choose a format for the framebuffer
- * @create_context: create the OpenGL context
- * @destroy_context: destroy the OpenGL context
- * @swap_buffers: swap the default framebuffer's front/back buffers
- */
-struct _GstGLContextClass {
- GstObjectClass parent_class;
-
- guintptr (*get_current_context) (void);
- guintptr (*get_gl_context) (GstGLContext *context);
- GstGLAPI (*get_gl_api) (GstGLContext *context);
- GstGLPlatform (*get_gl_platform) (GstGLContext *context);
- gpointer (*get_proc_address) (GstGLAPI gl_api, const gchar *name);
- gboolean (*activate) (GstGLContext *context, gboolean activate);
- gboolean (*choose_format) (GstGLContext *context, GError **error);
- gboolean (*create_context) (GstGLContext *context, GstGLAPI gl_api,
- GstGLContext *other_context, GError ** error);
- void (*destroy_context) (GstGLContext *context);
- void (*swap_buffers) (GstGLContext *context);
- gboolean (*check_feature) (GstGLContext *context, const gchar *feature);
- void (*get_gl_platform_version) (GstGLContext *context, gint *major, gint *minor);
-
- /*< private >*/
- gpointer _reserved[GST_PADDING];
-};
-
-/* methods */
-
-GST_EXPORT
-GstGLContext * gst_gl_context_new (GstGLDisplay *display);
-GST_EXPORT
-GstGLContext * gst_gl_context_new_wrapped (GstGLDisplay *display,
- guintptr handle,
- GstGLPlatform context_type,
- GstGLAPI available_apis);
-
-GST_EXPORT
-gboolean gst_gl_context_activate (GstGLContext *context, gboolean activate);
-GST_EXPORT
-GThread * gst_gl_context_get_thread (GstGLContext *context);
-GST_EXPORT
-GstGLContext * gst_gl_context_get_current (void);
-
-GST_EXPORT
-GstGLDisplay * gst_gl_context_get_display (GstGLContext *context);
-GST_EXPORT
-gpointer gst_gl_context_get_proc_address (GstGLContext *context, const gchar *name);
-GST_EXPORT
-GstGLPlatform gst_gl_context_get_gl_platform (GstGLContext *context);
-GST_EXPORT
-GstGLAPI gst_gl_context_get_gl_api (GstGLContext *context);
-GST_EXPORT
-guintptr gst_gl_context_get_gl_context (GstGLContext *context);
-GST_EXPORT
-gboolean gst_gl_context_can_share (GstGLContext * context, GstGLContext *other_context);
-GST_EXPORT
-void gst_gl_context_swap_buffers (GstGLContext * context);
-
-GST_EXPORT
-gboolean gst_gl_context_create (GstGLContext *context, GstGLContext *other_context, GError ** error);
-GST_EXPORT
-void gst_gl_context_destroy (GstGLContext *context);
-
-GST_EXPORT
-gpointer gst_gl_context_default_get_proc_address (GstGLAPI gl_api, const gchar *name);
-GST_EXPORT
-gpointer gst_gl_context_get_proc_address_with_platform (GstGLPlatform context_type, GstGLAPI gl_api, const gchar *name);
-
-GST_EXPORT
-gboolean gst_gl_context_set_window (GstGLContext *context, GstGLWindow *window);
-GST_EXPORT
-GstGLWindow * gst_gl_context_get_window (GstGLContext *context);
-
-GST_EXPORT
-void gst_gl_context_get_gl_version (GstGLContext *context, gint *maj, gint *min);
-GST_EXPORT
-gboolean gst_gl_context_check_gl_version (GstGLContext * context, GstGLAPI api, gint maj, gint min);
-GST_EXPORT
-gboolean gst_gl_context_check_feature (GstGLContext *context, const gchar *feature);
-GST_EXPORT
-void gst_gl_context_get_gl_platform_version (GstGLContext * context, gint * major, gint * minor);
-
-GST_EXPORT
-guintptr gst_gl_context_get_current_gl_context (GstGLPlatform context_type);
-GST_EXPORT
-GstGLAPI gst_gl_context_get_current_gl_api (GstGLPlatform platform, guint *major, guint *minor);
-
-GST_EXPORT
-gboolean gst_gl_context_is_shared (GstGLContext * context);
-GST_EXPORT
-void gst_gl_context_set_shared_with (GstGLContext * context, GstGLContext * share);
-
-GST_EXPORT
-gboolean gst_gl_context_fill_info (GstGLContext * context, GError ** error);
-
-/* FIXME: remove */
-GST_EXPORT
-void gst_gl_context_thread_add (GstGLContext * context,
- GstGLContextThreadFunc func, gpointer data);
-
-G_END_DECLS
-
-#endif /* __GST_GL_CONTEXT_H__ */
diff --git a/gst-libs/gst/gl/gstglcontext_private.h b/gst-libs/gst/gl/gstglcontext_private.h
deleted file mode 100644
index 4d190bf33..000000000
--- a/gst-libs/gst/gl/gstglcontext_private.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_CONTEXT_PRIVATE_H__
-#define __GST_GL_CONTEXT_PRIVATE_H__
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-G_GNUC_INTERNAL extern GstDebugCategory *gst_gl_context_debug;
-
-G_END_DECLS
-
-#endif /* __GST_GL_CONTEXT_PRIVATE_H__ */
diff --git a/gst-libs/gst/gl/gstgldebug.c b/gst-libs/gst/gl/gstgldebug.c
deleted file mode 100644
index 6f8eb4aa8..000000000
--- a/gst-libs/gst/gl/gstgldebug.c
+++ /dev/null
@@ -1,521 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstgldebug.h"
-
-#include <glib/gprintf.h>
-#include <string.h>
-
-#include "gstglcontext.h"
-#include "gstglcontext_private.h"
-#include "gstglfuncs.h"
-
-/**
- * SECTION:gstgldebug
- * @short_description: helper routines for dealing with OpenGL debugging
- * @title: OpenGL debugging
- * @see_also: #GstGLContext
- */
-
-#define ASYNC_DEBUG_FILLED (1 << 0)
-#define ASYNC_DEBUG_FROZEN (1 << 1)
-
-/* compatibility defines */
-#ifndef GL_DEBUG_TYPE_ERROR
-#define GL_DEBUG_TYPE_ERROR 0x824C
-#endif
-#ifndef GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR
-#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
-#endif
-#ifndef GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR
-#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
-#endif
-#ifndef GL_DEBUG_TYPE_PORTABILITY
-#define GL_DEBUG_TYPE_PORTABILITY 0x824F
-#endif
-#ifndef GL_DEBUG_TYPE_PERFORMANCE
-#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
-#endif
-#ifndef GL_DEBUG_TYPE_MARKER
-#define GL_DEBUG_TYPE_MARKER 0x8268
-#endif
-#ifndef GL_DEBUG_TYPE_OTHER
-#define GL_DEBUG_TYPE_OTHER 0x8251
-#endif
-
-#ifndef GL_DEBUG_SEVERITY_HIGH
-#define GL_DEBUG_SEVERITY_HIGH 0x9146
-#endif
-#ifndef GL_DEBUG_SEVERITY_MEDIUM
-#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
-#endif
-#ifndef GL_DEBUG_SEVERITY_LOW
-#define GL_DEBUG_SEVERITY_LOW 0x9148
-#endif
-#ifndef GL_DEBUG_SEVERITY_NOTIFICATION
-#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
-#endif
-
-#ifndef GL_DEBUG_SOURCE_API
-#define GL_DEBUG_SOURCE_API 0x8246
-#endif
-#ifndef GL_DEBUG_SOURCE_WINDOW_SYSTEM
-#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
-#endif
-#ifndef GL_DEBUG_SOURCE_SHADER_COMPILER
-#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
-#endif
-#ifndef GL_DEBUG_SOURCE_THIRD_PARTY
-#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
-#endif
-#ifndef GL_DEBUG_SOURCE_APPLICATION
-#define GL_DEBUG_SOURCE_APPLICATION 0x824A
-#endif
-#ifndef GL_DEBUG_SOURCE_OTHER
-#define GL_DEBUG_SOURCE_OTHER 0x824B
-#endif
-
-GST_DEBUG_CATEGORY_STATIC (gst_performance);
-#define GST_CAT_DEFAULT gst_gl_debug
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-GST_DEBUG_CATEGORY_STATIC (default_debug);
-GST_DEBUG_CATEGORY_STATIC (gst_gl_marker_debug);
-
-static void
-_init_debug (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- GST_DEBUG_CATEGORY_GET (gst_performance, "GST_PERFORMANCE");
- GST_DEBUG_CATEGORY_GET (gst_gl_debug, "gldebug");
- GST_DEBUG_CATEGORY_GET (default_debug, "default");
- GST_DEBUG_CATEGORY_INIT (gst_gl_marker_debug, "gldebugmarker", 0,
- "OpenGL Markers");
- g_once_init_leave (&_init, 1);
- }
-}
-
-static void
-_free_async_debug_data (GstGLAsyncDebug * ad)
-{
- if (ad->debug_msg) {
- g_free (ad->debug_msg);
- ad->debug_msg = NULL;
- if (ad->object)
- g_object_unref (ad->object);
- ad->object = NULL;
- ad->state_flags &= ~ASYNC_DEBUG_FILLED;
- }
-}
-
-/**
- * gst_gl_async_debug_init:
- * @ad: a #GstGLAsyncDebug
- *
- * Initialize @ad. Intended for use with #GstGLAsyncDebug's that are embedded
- * in other structs.
- *
- * Since: 1.8
- */
-void
-gst_gl_async_debug_init (GstGLAsyncDebug * ad)
-{
- _init_debug ();
-
- memset (ad, 0, sizeof (*ad));
-}
-
-/**
- * gst_gl_async_debug_unset:
- * @ad: a #GstGLAsyncDebug
- *
- * Unset any dynamically allocated data. Intended for use with
- * #GstGLAsyncDebug's that are embedded in other structs.
- */
-void
-gst_gl_async_debug_unset (GstGLAsyncDebug * ad)
-{
- gst_gl_async_debug_output_log_msg (ad);
-
- _free_async_debug_data (ad);
-
- if (ad->notify)
- ad->notify (ad->user_data);
-}
-
-/**
- * gst_gl_async_debug_new: (skip)
- *
- * Free with gst_gl_async_debug_free()
- *
- * Returns: a new #GstGLAsyncDebug
- *
- * Since: 1.8
- */
-GstGLAsyncDebug *
-gst_gl_async_debug_new (void)
-{
- return g_new0 (GstGLAsyncDebug, 1);
-}
-
-/**
- * gst_gl_async_debug_free:
- * @ad: a #GstGLAsyncDebug
- *
- * Frees @ad
- *
- * Since: 1.8
- */
-void
-gst_gl_async_debug_free (GstGLAsyncDebug * ad)
-{
- gst_gl_async_debug_unset (ad);
- g_free (ad);
-}
-
-/**
- * gst_gl_async_debug_freeze:
- * @ad: a #GstGLAsyncDebug
- *
- * freeze the debug output. While frozen, any call to
- * gst_gl_async_debug_output_log_msg() will not output any messages but
- * subsequent calls to gst_gl_async_debug_store_log_msg() will overwrite previous
- * messages.
- *
- * Since: 1.8
- */
-void
-gst_gl_async_debug_freeze (GstGLAsyncDebug * ad)
-{
- ad->state_flags |= ASYNC_DEBUG_FROZEN;
-}
-
-/**
- * gst_gl_async_debug_thaw:
- * @ad: a #GstGLAsyncDebug
- *
- * unfreeze the debug output. See gst_gl_async_debug_freeze() for what freezing means
- *
- * Since: 1.8
- */
-void
-gst_gl_async_debug_thaw (GstGLAsyncDebug * ad)
-{
- ad->state_flags &= ~ASYNC_DEBUG_FROZEN;
-}
-
-#if !defined(GST_DISABLE_GST_DEBUG)
-
-static inline const gchar *
-_debug_severity_to_string (GLenum severity)
-{
- switch (severity) {
- case GL_DEBUG_SEVERITY_HIGH:
- return "high";
- case GL_DEBUG_SEVERITY_MEDIUM:
- return "medium";
- case GL_DEBUG_SEVERITY_LOW:
- return "low";
- case GL_DEBUG_SEVERITY_NOTIFICATION:
- return "notification";
- default:
- return "invalid";
- }
-}
-
-static inline const gchar *
-_debug_source_to_string (GLenum source)
-{
- switch (source) {
- case GL_DEBUG_SOURCE_API:
- return "API";
- case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
- return "winsys";
- case GL_DEBUG_SOURCE_SHADER_COMPILER:
- return "shader compiler";
- case GL_DEBUG_SOURCE_THIRD_PARTY:
- return "third party";
- case GL_DEBUG_SOURCE_APPLICATION:
- return "application";
- case GL_DEBUG_SOURCE_OTHER:
- return "other";
- default:
- return "invalid";
- }
-}
-
-static inline const gchar *
-_debug_type_to_string (GLenum type)
-{
- switch (type) {
- case GL_DEBUG_TYPE_ERROR:
- return "error";
- case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
- return "deprecated";
- case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
- return "undefined";
- case GL_DEBUG_TYPE_PORTABILITY:
- return "portability";
- case GL_DEBUG_TYPE_PERFORMANCE:
- return "performance";
- case GL_DEBUG_TYPE_MARKER:
- return "debug marker";
- case GL_DEBUG_TYPE_OTHER:
- return "other";
- default:
- return "invalid";
- }
-}
-
-static void GSTGLAPI
-_gst_gl_debug_callback (GLenum source, GLenum type, GLuint id, GLenum severity,
- GLsizei length, const gchar * message, gpointer user_data)
-{
- GstGLContext *context = user_data;
- const gchar *severity_str = _debug_severity_to_string (severity);
- const gchar *source_str = _debug_source_to_string (source);
- const gchar *type_str = _debug_type_to_string (type);
-
- _init_debug ();
-
- switch (type) {
- case GL_DEBUG_TYPE_ERROR:
- case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
- GST_ERROR_OBJECT (context, "%s: GL %s from %s id:%u, %s", severity_str,
- type_str, source_str, id, message);
- break;
- case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
- case GL_DEBUG_TYPE_PORTABILITY:
- GST_FIXME_OBJECT (context, "%s: GL %s from %s id:%u, %s", severity_str,
- type_str, source_str, id, message);
- break;
- case GL_DEBUG_TYPE_PERFORMANCE:
- GST_CAT_DEBUG_OBJECT (gst_performance, context, "%s: GL %s from %s id:%u,"
- " %s", severity_str, type_str, source_str, id, message);
- break;
- default:
- GST_DEBUG_OBJECT (context, "%s: GL %s from %s id:%u, %s", severity_str,
- type_str, source_str, id, message);
- break;
- }
-}
-
-G_GNUC_INTERNAL void _gst_gl_debug_enable (GstGLContext * context);
-
-G_GNUC_INTERNAL void
-_gst_gl_debug_enable (GstGLContext * context)
-{
- const GstGLFuncs *gl = context->gl_vtable;
- GstDebugLevel level;
- GLenum debug_types[8];
- guint i, n = 0;
-
- _init_debug ();
-
- if (!gl->DebugMessageCallback) {
- GST_CAT_INFO_OBJECT (gst_gl_context_debug, context,
- "No debugging support available");
- return;
- }
-
- level = gst_debug_category_get_threshold (gst_gl_debug);
-
- if (level < GST_LEVEL_ERROR) {
- GST_CAT_INFO_OBJECT (gst_gl_context_debug, context,
- "Disabling GL context debugging (gldebug category debug level < error)");
- return;
- }
-
- GST_CAT_INFO_OBJECT (gst_gl_context_debug, context,
- "Enabling GL context debugging");
-
- gl->DebugMessageCallback (_gst_gl_debug_callback, context);
- if (level >= GST_LEVEL_DEBUG) {
- /* enable them all */
- gl->DebugMessageControl (GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, 0,
- GL_TRUE);
- } else {
- if (level >= GST_LEVEL_FIXME) {
- debug_types[n++] = GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR;
- debug_types[n++] = GL_DEBUG_TYPE_PORTABILITY;
- }
- if (level >= GST_LEVEL_ERROR) {
- debug_types[n++] = GL_DEBUG_TYPE_ERROR;
- debug_types[n++] = GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR;
- }
- g_assert (n < G_N_ELEMENTS (debug_types));
- for (i = 0; i < n; i++) {
- gl->DebugMessageControl (GL_DONT_CARE, debug_types[i], GL_DONT_CARE,
- 0, 0, GL_TRUE);
- }
- }
-}
-
-/**
- * gst_gl_insert_debug_marker:
- * @context: a #GstGLContext
- * @format: a printf-style format string
- * @...: arguments form @format
- *
- * Inserts a marker into a GL debug stream. Requires the 'gldebugmarker'
- * debug category to be at least %GST_LEVEL_FIXME.
- *
- * Since: 1.8
- */
-void
-gst_gl_insert_debug_marker (GstGLContext * context, const gchar * format, ...)
-{
- const GstGLFuncs *gl = context->gl_vtable;
- gchar *string;
- gint len;
- va_list args;
-
- _init_debug ();
-
- /* are we enabled */
- if (gst_debug_category_get_threshold (gst_gl_marker_debug) < GST_LEVEL_FIXME)
- return;
-
- va_start (args, format);
- len = gst_info_vasprintf (&string, format, args);
- va_end (args);
-
- /* gst_info_vasprintf() returns -1 on error, the various debug marker
- * functions take len=-1 to mean null terminated */
- if (len < 0 || string == NULL)
- /* no debug output */
- return;
-
- if (gl->DebugMessageInsert)
- gl->DebugMessageInsert (GL_DEBUG_SOURCE_THIRD_PARTY, GL_DEBUG_TYPE_MARKER,
- 0, GL_DEBUG_SEVERITY_LOW, (gsize) len, string);
- else if (gl->InsertEventMarker)
- gl->InsertEventMarker (len, string);
- else if (gl->StringMarker)
- gl->StringMarker (len, string);
-
- g_free (string);
-}
-
-/**
- * gst_gl_async_debug_store_log_msg_valist:
- * @ad: the #GstGLAsyncDebug to store the message in
- * @cat: the #GstDebugCategory to output the message in
- * @level: the #GstLevel
- * @file: the file where the debug message originates from
- * @function: the function where the debug message originates from
- * @line: the line in @file where the debug message originates from
- * @object: (allow-none): a #GObject to associate with the debug message
- * @format: a printf style format string
- * @varargs: the list of arguments for @format
- *
- * Stores a debug message for later output by gst_gl_async_debug_output_log_msg()
- *
- * Since: 1.8
- */
-void
-gst_gl_async_debug_store_log_msg_valist (GstGLAsyncDebug * ad,
- GstDebugCategory * cat, GstDebugLevel level, const gchar * file,
- const gchar * function, gint line, GObject * object, const gchar * format,
- va_list varargs)
-{
- gst_gl_async_debug_output_log_msg (ad);
- _free_async_debug_data (ad);
-
- if (G_UNLIKELY (level <= GST_LEVEL_MAX && level <= _gst_debug_min)) {
- if (!cat)
- cat = default_debug;
-
- ad->cat = cat;
- ad->level = level;
- ad->file = file;
- ad->function = function;
- ad->line = line;
- if (object)
- ad->object = g_object_ref (object);
- else
- ad->object = NULL;
-
- ad->debug_msg = gst_info_strdup_vprintf (format, varargs);
- ad->state_flags |= ASYNC_DEBUG_FILLED;
- }
-}
-
-/**
- * gst_gl_async_debug_output_log_msg:
- * @ad: the #GstGLAsyncDebug to store the message in
- *
- * Outputs a previously stored debug message.
- */
-void
-gst_gl_async_debug_output_log_msg (GstGLAsyncDebug * ad)
-{
- if ((ad->state_flags & ASYNC_DEBUG_FILLED) != 0
- && (ad->state_flags & ASYNC_DEBUG_FROZEN) == 0) {
- gchar *msg = NULL;
-
- if (ad->callback)
- msg = ad->callback (ad->user_data);
-
- gst_debug_log (ad->cat, ad->level, ad->file, ad->function, ad->line,
- ad->object, "%s %s", GST_STR_NULL (ad->debug_msg), msg ? msg : "");
- g_free (msg);
- _free_async_debug_data (ad);
- }
-}
-
-/**
- * gst_gl_async_debug_store_log_msg:
- * @ad: the #GstGLAsyncDebug to store the message in
- * @cat: the #GstDebugCategory to output the message in
- * @level: the #GstLevel
- * @file: the file where the debug message originates from
- * @function: the function where the debug message originates from
- * @line: the line in @file where the debug message originates from
- * @object: (allow-none): a #GObject to associate with the debug message
- * @format: a printf style format string
- * @...: the list of arguments for @format
- *
- * Stores a debug message for later output by gst_gl_async_debug_output_log_msg()
- *
- * Since: 1.8
- */
-void
-gst_gl_async_debug_store_log_msg (GstGLAsyncDebug * ad, GstDebugCategory * cat,
- GstDebugLevel level, const gchar * file, const gchar * function, gint line,
- GObject * object, const gchar * format, ...)
-{
- va_list varargs;
-
- if (G_UNLIKELY (level <= GST_LEVEL_MAX && level <= _gst_debug_min)) {
- va_start (varargs, format);
- gst_gl_async_debug_store_log_msg_valist (ad, cat, level, file, function,
- line, object, format, varargs);
- va_end (varargs);
- }
-}
-#else
-G_GNUC_INTERNAL void _gst_gl_debug_enable (GstGLContext * context);
-#endif
diff --git a/gst-libs/gst/gl/gstgldebug.h b/gst-libs/gst/gl/gstgldebug.h
deleted file mode 100644
index 503115544..000000000
--- a/gst-libs/gst/gl/gstgldebug.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_DEBUG_H__
-#define __GST_GL_DEBUG_H__
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GstGLAsyncDebug GstGLAsyncDebug;
-
-typedef gchar * (*GstGLAsyncDebugLogGetMessage) (gpointer user_data);
-
-/**
- * GstGLAsyncDebug:
- *
- * #GstGLAsyncDebug an opaque structure and should only be accessed through the
- * provided API.
- */
-struct _GstGLAsyncDebug
-{
- /* <private> */
- guint state_flags;
- GstDebugCategory *cat;
- GstDebugLevel level;
- const gchar *file;
- const gchar *function;
- gint line;
- GObject *object;
- gchar *debug_msg;
-
- /* <protected> */
- GstGLAsyncDebugLogGetMessage callback;
- gpointer user_data;
- GDestroyNotify notify;
-
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GstGLAsyncDebug * gst_gl_async_debug_new (void);
-GST_EXPORT
-void gst_gl_async_debug_free (GstGLAsyncDebug * ad);
-GST_EXPORT
-void gst_gl_async_debug_init (GstGLAsyncDebug * ad);
-GST_EXPORT
-void gst_gl_async_debug_unset (GstGLAsyncDebug * ad);
-GST_EXPORT
-void gst_gl_async_debug_freeze (GstGLAsyncDebug * ad);
-GST_EXPORT
-void gst_gl_async_debug_thaw (GstGLAsyncDebug * ad);
-
-/**
- * GST_GL_ASYNC_CAT_LEVEL_LOG_valist:
- * @ad: the #GstGLAsyncDebug to store the message in
- * @cat: the #GstDebugCategory to output the message in
- * @level: the #GstLevel
- * @object: (allow-none): a #GObject to associate with the debug message
- * @format: a printf style format string
- * @varargs: the list of arguments for @format
- *
- * Stores a debug message in @ad for later output
- */
-#define GST_GL_ASYNC_CAT_LEVEL_LOG_valist(ad,cat,level,object,format,varargs) \
- gst_gl_async_debug_store_log_msg_valist (ad, cat, level, __FILE__, \
- GST_FUNCTION, __LINE__, object, format, varargs)
-
-/**
- * GST_GL_ASYNC_CAT_LEVEL_LOG:
- * @ad: the #GstGLAsyncDebug to store the message in
- * @cat: the #GstDebugCategory to output the message in
- * @level: the #GstLevel
- * @object: (allow-none): a #GObject to associate with the debug message
- * @format: a printf style format string
- * @...: the list of arguments for @format
- *
- * Stores a debug message in @ad for later output
- */
-#if G_HAVE_ISO_VARARGS
-#define GST_GL_ASYNC_CAT_LEVEL_LOG(ad,cat,level,object,format,...) \
- gst_gl_async_debug_store_log_msg (ad, cat, level, __FILE__, GST_FUNCTION, \
- __LINE__, object, format, __VA_ARGS__)
-#else /* G_HAVE_ISO_VARARGS */
-#if G_HAVE_GNUC_VARARGS
-#define GST_GL_ASYNC_CAT_LEVEL_LOG(ad,cat,level,object,format,args...) \
- gst_gl_async_debug_store_log_msg (ad, cat, level, __FILE__, GST_FUNCTION, \
- __LINE__, object, format, ##args)
-#else /* G_HAVE_GNUC_VARARGS */
-static inline void
-GST_GL_ASYNC_CAT_LEVEL_LOG(GstGLAsyncDebug * ad, GstDebugCategory * cat,
- GstDebugLevel level, GObject * object, const gchar * format, ...)
-{
- va_list varargs;
-
- va_start (varargs, format);
- GST_GL_ASYNC_CAT_LEVEL_LOG_valist (ad, cat, level, object, format, varargs);
- va_end (varargs);
-}
-#endif /* G_HAVE_GNUC_VARARGS */
-#endif /* G_HAVE_ISO_VARARGS */
-
-#if !defined(GST_DISABLE_GST_DEBUG)
-
-GST_EXPORT
-void gst_gl_insert_debug_marker (GstGLContext * context,
- const gchar * format, ...) G_GNUC_PRINTF (2, 3);
-GST_EXPORT
-void gst_gl_async_debug_output_log_msg (GstGLAsyncDebug * ad);
-GST_EXPORT
-void gst_gl_async_debug_store_log_msg (GstGLAsyncDebug * ad,
- GstDebugCategory * cat,
- GstDebugLevel level,
- const gchar * file,
- const gchar * function,
- gint line,
- GObject * object,
- const gchar * format, ...) G_GNUC_PRINTF (8, 9);
-GST_EXPORT
-void gst_gl_async_debug_store_log_msg_valist (GstGLAsyncDebug * ad,
- GstDebugCategory * cat,
- GstDebugLevel level,
- const gchar * file,
- const gchar * function,
- gint line,
- GObject * object,
- const gchar * format,
- va_list varargs) G_GNUC_PRINTF (8, 0);
-
-#else /* GST_DISABLE_GST_DEBUG */
-
-#define gst_gl_async_debug_output_log_msg(ad) G_STMT_START{ }G_STMT_END
-#define gst_gl_async_debug_store_log_msg_valist(ad,cat,level,file,function,line,object,format,args) G_STMT_START{ }G_STMT_END
-
-#if G_HAVE_ISO_VARARGS
-
-#define gst_gl_insert_debug_marker(...) G_STMT_START{ }G_STMT_END
-#define gst_gl_async_debug_store_log_msg(...) G_STMT_START{ }G_STMT_END
-
-#else /* G_HAVE_ISO_VARARGS */
-#if G_HAVE_GNUC_VARARGS
-
-#define gst_gl_insert_debug_marker(args...) G_STMT_START{ }G_STMT_END
-#define gst_gl_async_debug_store_log_msg(args...) G_STMT_START{ }G_STMT_END
-
-#else /* G_HAVE_GNUC_VARARGS */
-
-static inline void
-gst_gl_insert_debug_marker (GstGLContext * context, const gchar * format, ...)
-{
-}
-
-static inline void
-gst_gl_async_debug_store_log_msg (GstGLAsyncDebug * ad,
- GstDebugCategory * cat, GstDebugLevel level, const gchar * file,
- const gchar * function, gint line, GstObject * object,
- const gchar * format, ...)
-{
-}
-
-#endif /* G_HAVE_GNUC_VARARGS */
-#endif /* G_HAVE_ISO_VARARGS */
-#endif /* GST_DISABLE_GST_DEBUG */
-
-G_END_DECLS
-
-#endif /* __GST_GL_DEBUG_H__ */
diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c
deleted file mode 100644
index 459392abc..000000000
--- a/gst-libs/gst/gl/gstgldisplay.c
+++ /dev/null
@@ -1,792 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2007 David A. Schleef <ds@schleef.org>
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
- * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstgldisplay
- * @short_description: window system display connection abstraction
- * @title: GstGLDisplay
- * @see_also: #GstContext, #GstGLContext, #GstGLWindow
- *
- * #GstGLDisplay represents a connection to the underlying windowing system.
- * Elements are required to make use of #GstContext to share and propogate
- * a #GstGLDisplay.
- *
- * There are a number of environment variables that influence the choice of
- * platform and window system specific functionality.
- * - GST_GL_WINDOW influences the window system to use. Common values are
- * 'x11', 'wayland', 'win32' or 'cocoa'.
- * - GST_GL_PLATFORM influences the OpenGL platform to use. Common values are
- * 'egl', 'glx', 'wgl' or 'cgl'.
- * - GST_GL_API influences the OpenGL API requested by the OpenGL platform.
- * Common values are 'opengl', 'opengl3' and 'gles2'.
- *
- * > Certain window systems require a special function to be called to
- * > initialize threading support. As this GStreamer GL library does not preclude
- * > concurrent access to the windowing system, it is strongly advised that
- * > applications ensure that threading support has been initialized before any
- * > other toolkit/library functionality is accessed. Failure to do so could
- * > result in sudden application abortion during execution. The most notably
- * > example of such a function is X11's XInitThreads\().
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gl.h"
-#include "gstgldisplay.h"
-
-#if GST_GL_HAVE_WINDOW_COCOA
-#include <gst/gl/cocoa/gstgldisplay_cocoa.h>
-#endif
-#if GST_GL_HAVE_WINDOW_X11
-#include <gst/gl/x11/gstgldisplay_x11.h>
-#endif
-#if GST_GL_HAVE_WINDOW_WAYLAND
-#include <gst/gl/wayland/gstgldisplay_wayland.h>
-#endif
-#if GST_GL_HAVE_PLATFORM_EGL
-#include <gst/gl/egl/gstgldisplay_egl.h>
-#include <gst/gl/egl/gsteglimage.h>
-#include <gst/gl/egl/gstglmemoryegl.h>
-#endif
-#if GST_GL_HAVE_WINDOW_VIV_FB
-#include <gst/gl/viv-fb/gstgldisplay_viv_fb.h>
-#endif
-
-GST_DEBUG_CATEGORY_STATIC (gst_context);
-GST_DEBUG_CATEGORY_STATIC (gst_gl_display_debug);
-#define GST_CAT_DEFAULT gst_gl_display_debug
-
-#define DEBUG_INIT \
- GST_DEBUG_CATEGORY_INIT (gst_gl_display_debug, "gldisplay", 0, "opengl display"); \
- GST_DEBUG_CATEGORY_GET (gst_context, "GST_CONTEXT");
-
-G_DEFINE_TYPE_WITH_CODE (GstGLDisplay, gst_gl_display, GST_TYPE_OBJECT,
- DEBUG_INIT);
-
-#define GST_GL_DISPLAY_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_DISPLAY, GstGLDisplayPrivate))
-
-enum
-{
- SIGNAL_0,
- CREATE_CONTEXT,
- LAST_SIGNAL
-};
-
-static guint gst_gl_display_signals[LAST_SIGNAL] = { 0 };
-
-
-static void gst_gl_display_dispose (GObject * object);
-static void gst_gl_display_finalize (GObject * object);
-static guintptr gst_gl_display_default_get_handle (GstGLDisplay * display);
-static GstGLWindow *gst_gl_display_default_create_window (GstGLDisplay *
- display);
-
-struct _GstGLDisplayPrivate
-{
- GstGLAPI gl_api;
-
- GList *contexts;
-
- GThread *event_thread;
-
- GMutex thread_lock;
- GCond thread_cond;
-};
-
-static gboolean
-_unlock_main_thread (GstGLDisplay * display)
-{
- g_mutex_unlock (&display->priv->thread_lock);
-
- return G_SOURCE_REMOVE;
-}
-
-static gpointer
-_event_thread_main (GstGLDisplay * display)
-{
- g_mutex_lock (&display->priv->thread_lock);
-
- display->main_context = g_main_context_new ();
- display->main_loop = g_main_loop_new (display->main_context, FALSE);
-
- g_main_context_invoke (display->main_context,
- (GSourceFunc) _unlock_main_thread, display);
-
- g_cond_broadcast (&display->priv->thread_cond);
-
- g_main_loop_run (display->main_loop);
-
- g_mutex_lock (&display->priv->thread_lock);
- g_main_loop_unref (display->main_loop);
- g_main_context_unref (display->main_context);
-
- display->main_loop = NULL;
- display->main_context = NULL;
-
- g_cond_broadcast (&display->priv->thread_cond);
- g_mutex_unlock (&display->priv->thread_lock);
-
- return NULL;
-}
-
-static void
-gst_gl_display_class_init (GstGLDisplayClass * klass)
-{
- g_type_class_add_private (klass, sizeof (GstGLDisplayPrivate));
-
- /**
- * GstGLDisplay::create-context:
- * @object: the #GstGLDisplay
- * @context: (transfer none): other context to share resources with.
- *
- * Overrides the @GstGLContext creation mechanism.
- * It can be called in any thread and it is emitted with
- * display's object lock held.
- *
- * Returns: (transfer full): the new context.
- */
- gst_gl_display_signals[CREATE_CONTEXT] =
- g_signal_new ("create-context", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic,
- GST_TYPE_GL_CONTEXT, 1, GST_TYPE_GL_CONTEXT);
-
- klass->get_handle = gst_gl_display_default_get_handle;
- klass->create_window = gst_gl_display_default_create_window;
-
- G_OBJECT_CLASS (klass)->finalize = gst_gl_display_finalize;
- G_OBJECT_CLASS (klass)->dispose = gst_gl_display_dispose;
-}
-
-static void
-gst_gl_display_init (GstGLDisplay * display)
-{
- display->priv = GST_GL_DISPLAY_GET_PRIVATE (display);
-
- display->type = GST_GL_DISPLAY_TYPE_ANY;
- display->priv->gl_api = GST_GL_API_ANY;
-
- g_mutex_init (&display->priv->thread_lock);
- g_cond_init (&display->priv->thread_cond);
-
- display->priv->event_thread = g_thread_new ("gldisplay-event",
- (GThreadFunc) _event_thread_main, display);
-
- g_mutex_lock (&display->priv->thread_lock);
- while (!display->main_loop)
- g_cond_wait (&display->priv->thread_cond, &display->priv->thread_lock);
- g_mutex_unlock (&display->priv->thread_lock);
-
- GST_TRACE ("init %p", display);
-
- gst_gl_buffer_init_once ();
- gst_gl_memory_pbo_init_once ();
- gst_gl_renderbuffer_init_once ();
-
-#if GST_GL_HAVE_PLATFORM_EGL
- gst_gl_memory_egl_init_once ();
-#endif
-}
-
-static void
-gst_gl_display_dispose (GObject * object)
-{
- GstGLDisplay *display = GST_GL_DISPLAY (object);
-
- if (display->main_loop)
- g_main_loop_quit (display->main_loop);
-
- if (display->priv->event_thread) {
- /* can't use g_thread_join() as we could lose the last ref from a user
- * function */
- g_mutex_lock (&display->priv->thread_lock);
- while (display->main_loop)
- g_cond_wait (&display->priv->thread_cond, &display->priv->thread_lock);
- g_mutex_unlock (&display->priv->thread_lock);
- g_thread_unref (display->priv->event_thread);
- }
- display->priv->event_thread = NULL;
-
- if (display->event_source) {
- g_source_destroy (display->event_source);
- g_source_unref (display->event_source);
- }
- display->event_source = NULL;
-
- G_OBJECT_CLASS (gst_gl_display_parent_class)->dispose (object);
-}
-
-static void
-gst_gl_display_finalize (GObject * object)
-{
- GstGLDisplay *display = GST_GL_DISPLAY (object);
- GList *l;
-
- GST_TRACE_OBJECT (object, "finalizing");
-
- for (l = display->priv->contexts; l; l = l->next) {
- g_weak_ref_clear ((GWeakRef *) l->data);
- g_free (l->data);
- }
-
- g_list_free (display->windows);
- g_list_free (display->priv->contexts);
-
- g_cond_clear (&display->priv->thread_cond);
- g_mutex_clear (&display->priv->thread_lock);
-
- G_OBJECT_CLASS (gst_gl_display_parent_class)->finalize (object);
-}
-
-/**
- * gst_gl_display_new:
- *
- * Returns: (transfer full): a new #GstGLDisplay
- *
- * Since: 1.4
- */
-GstGLDisplay *
-gst_gl_display_new (void)
-{
- GstGLDisplay *display = NULL;
- const gchar *user_choice, *platform_choice;
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- GST_DEBUG_CATEGORY_INIT (gst_gl_display_debug, "gldisplay", 0,
- "gldisplay element");
- g_once_init_leave (&_init, 1);
- }
-
- user_choice = g_getenv ("GST_GL_WINDOW");
- platform_choice = g_getenv ("GST_GL_PLATFORM");
- GST_INFO ("creating a display, user choice:%s (platform: %s)",
- GST_STR_NULL (user_choice), GST_STR_NULL (platform_choice));
-
-#if GST_GL_HAVE_WINDOW_COCOA
- if (!display && (!user_choice || g_strstr_len (user_choice, 5, "cocoa"))) {
- display = GST_GL_DISPLAY (gst_gl_display_cocoa_new ());
- if (!display)
- return NULL;
- }
-#endif
-#if GST_GL_HAVE_WINDOW_WAYLAND
- if (!display && (!user_choice || g_strstr_len (user_choice, 7, "wayland")))
- display = GST_GL_DISPLAY (gst_gl_display_wayland_new (NULL));
-#endif
-#if GST_GL_HAVE_WINDOW_X11
- if (!display && (!user_choice || g_strstr_len (user_choice, 3, "x11")))
- display = GST_GL_DISPLAY (gst_gl_display_x11_new (NULL));
-#endif
-#if GST_GL_HAVE_WINDOW_VIV_FB
- if (!display && (!user_choice || g_strstr_len (user_choice, 6, "viv-fb"))) {
- const gchar *disp_idx_str = NULL;
- gint disp_idx = 0;
- disp_idx_str = g_getenv ("GST_GL_VIV_FB");
- if (disp_idx_str) {
- gint64 v = g_ascii_strtoll (disp_idx_str, NULL, 10);
- if (v >= G_MININT && v <= G_MAXINT)
- disp_idx = v;
- }
- display = GST_GL_DISPLAY (gst_gl_display_viv_fb_new (disp_idx));
- }
-#endif
-#if GST_GL_HAVE_PLATFORM_EGL
- if (!display && (!platform_choice
- || g_strstr_len (platform_choice, 3, "egl")))
- display = GST_GL_DISPLAY (gst_gl_display_egl_new ());
-#endif
- if (!display) {
- GST_INFO ("Could not create platform/winsys display. user specified %s "
- "(platform: %s), creating dummy",
- GST_STR_NULL (user_choice), GST_STR_NULL (platform_choice));
-
- display = g_object_new (GST_TYPE_GL_DISPLAY, NULL);
- gst_object_ref_sink (display);
- }
-
- return display;
-}
-
-/**
- * gst_gl_display_get_handle:
- * @display: a #GstGLDisplay
- *
- * Returns: the native handle for the display
- *
- * Since: 1.4
- */
-guintptr
-gst_gl_display_get_handle (GstGLDisplay * display)
-{
- GstGLDisplayClass *klass;
-
- g_return_val_if_fail (GST_IS_GL_DISPLAY (display), 0);
- klass = GST_GL_DISPLAY_GET_CLASS (display);
- g_return_val_if_fail (klass->get_handle != NULL, 0);
-
- return klass->get_handle (display);
-}
-
-static guintptr
-gst_gl_display_default_get_handle (GstGLDisplay * display)
-{
- return 0;
-}
-
-/**
- * gst_gl_display_filter_gl_api:
- * @display: a #GstGLDisplay
- * @gl_api: a #GstGLAPI to filter with
- *
- * limit the use of OpenGL to the requested @gl_api. This is intended to allow
- * application and elements to request a specific set of OpenGL API's based on
- * what they support. See gst_gl_context_get_gl_api() for the retreiving the
- * API supported by a #GstGLContext.
- */
-void
-gst_gl_display_filter_gl_api (GstGLDisplay * display, GstGLAPI gl_api)
-{
- gchar *gl_api_s;
-
- g_return_if_fail (GST_IS_GL_DISPLAY (display));
-
- gl_api_s = gst_gl_api_to_string (gl_api);
- GST_TRACE_OBJECT (display, "filtering with api %s", gl_api_s);
- g_free (gl_api_s);
-
- GST_OBJECT_LOCK (display);
- display->priv->gl_api &= gl_api;
- GST_OBJECT_UNLOCK (display);
-}
-
-GstGLAPI
-gst_gl_display_get_gl_api_unlocked (GstGLDisplay * display)
-{
- g_return_val_if_fail (GST_IS_GL_DISPLAY (display), GST_GL_API_NONE);
-
- return display->priv->gl_api;
-}
-
-/**
- * gst_gl_display_get_gl_api:
- * @display: a #GstGLDisplay
- *
- * see gst_gl_display_filter_gl_api() for what the returned value represents
- *
- * Returns: the #GstGLAPI configured for @display
- */
-GstGLAPI
-gst_gl_display_get_gl_api (GstGLDisplay * display)
-{
- GstGLAPI ret;
-
- g_return_val_if_fail (GST_IS_GL_DISPLAY (display), GST_GL_API_NONE);
-
- GST_OBJECT_LOCK (display);
- ret = display->priv->gl_api;
- GST_OBJECT_UNLOCK (display);
-
- return ret;
-}
-
-/**
- * gst_gl_display_get_handle_type:
- * @display: a #GstGLDisplay
- *
- * Returns: the #GstGLDisplayType of @display
- *
- * Since: 1.4
- */
-GstGLDisplayType
-gst_gl_display_get_handle_type (GstGLDisplay * display)
-{
- g_return_val_if_fail (GST_IS_GL_DISPLAY (display), GST_GL_DISPLAY_TYPE_NONE);
-
- return display->type;
-}
-
-/**
- * gst_context_set_gl_display:
- * @context: a #GstContext
- * @display: (transfer none): resulting #GstGLDisplay
- *
- * Sets @display on @context
- *
- * Since: 1.4
- */
-void
-gst_context_set_gl_display (GstContext * context, GstGLDisplay * display)
-{
- GstStructure *s;
-
- g_return_if_fail (context != NULL);
-
- if (display)
- GST_CAT_LOG (gst_context,
- "setting GstGLDisplay(%" GST_PTR_FORMAT ") on context(%" GST_PTR_FORMAT
- ")", display, context);
-
- s = gst_context_writable_structure (context);
- gst_structure_set (s, GST_GL_DISPLAY_CONTEXT_TYPE, GST_TYPE_GL_DISPLAY,
- display, NULL);
-}
-
-/**
- * gst_context_get_gl_display:
- * @context: a #GstContext
- * @display: (transfer full): resulting #GstGLDisplay
- *
- * Returns: Whether @display was in @context
- *
- * Since: 1.4
- */
-gboolean
-gst_context_get_gl_display (GstContext * context, GstGLDisplay ** display)
-{
- const GstStructure *s;
- gboolean ret;
-
- g_return_val_if_fail (display != NULL, FALSE);
- g_return_val_if_fail (context != NULL, FALSE);
-
- s = gst_context_get_structure (context);
- ret = gst_structure_get (s, GST_GL_DISPLAY_CONTEXT_TYPE,
- GST_TYPE_GL_DISPLAY, display, NULL);
-
- GST_CAT_LOG (gst_context, "got GstGLDisplay(%p) from context(%p)", *display,
- context);
-
- return ret;
-}
-
-/**
- * gst_gl_display_create_context:
- * @display: a #GstGLDisplay
- * @other_context: (transfer none): other #GstGLContext to share resources with.
- * @p_context: (transfer full) (out): resulting #GstGLContext
- * @error: (allow-none): resulting #GError
- *
- * It requires the display's object lock to be held.
- *
- * Returns: whether a new context could be created.
- *
- * Since: 1.6
- */
-gboolean
-gst_gl_display_create_context (GstGLDisplay * display,
- GstGLContext * other_context, GstGLContext ** p_context, GError ** error)
-{
- GstGLContext *context = NULL;
- gboolean ret = FALSE;
-
- g_return_val_if_fail (display != NULL, FALSE);
- g_return_val_if_fail (p_context != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- g_signal_emit (display, gst_gl_display_signals[CREATE_CONTEXT], 0,
- other_context, &context);
-
- if (context) {
- *p_context = context;
- return TRUE;
- }
-
- context = gst_gl_context_new (display);
- if (!context) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "Failed to create GL context");
- return FALSE;
- }
-
- GST_DEBUG_OBJECT (display,
- "creating context %" GST_PTR_FORMAT " from other context %"
- GST_PTR_FORMAT, context, other_context);
-
- ret = gst_gl_context_create (context, other_context, error);
-
- if (ret)
- *p_context = context;
-
- return ret;
-}
-
-/**
- * gst_gl_display_create_window:
- * @display: a #GstGLDisplay
- *
- * It requires the display's object lock to be held.
- *
- * Returns: (transfer full): a new #GstGLWindow for @display or %NULL.
- */
-GstGLWindow *
-gst_gl_display_create_window (GstGLDisplay * display)
-{
- GstGLDisplayClass *klass;
- GstGLWindow *window;
-
- g_return_val_if_fail (GST_IS_GL_DISPLAY (display), NULL);
- klass = GST_GL_DISPLAY_GET_CLASS (display);
- g_return_val_if_fail (klass->create_window != NULL, NULL);
-
- window = klass->create_window (display);
-
- if (window)
- display->windows = g_list_prepend (display->windows, window);
-
- return window;
-}
-
-static GstGLWindow *
-gst_gl_display_default_create_window (GstGLDisplay * display)
-{
- return gst_gl_window_new (display);
-}
-
-/**
- * gst_gl_display_remove_window:
- * @display: a #GstGLDisplay
- * @window: a #GstGLWindow to remove
- *
- * Returns: if @window could be removed from @display
- *
- * Since: 1.12
- */
-gboolean
-gst_gl_display_remove_window (GstGLDisplay * display, GstGLWindow * window)
-{
- gboolean ret = FALSE;
- GList *l;
-
- GST_OBJECT_LOCK (display);
- l = g_list_find (display->windows, window);
- if (l) {
- display->windows = g_list_delete_link (display->windows, l);
- ret = TRUE;
- }
- GST_OBJECT_UNLOCK (display);
-
- return ret;
-}
-
-/**
- * gst_gl_display_find_window:
- * @display: a #GstGLDisplay
- * @data: (closure): some data to pass to @compare_func
- * @compare_func: (scope call): a comparison function to run
- *
- * Execute @compare_func over the list of windows stored by @display. The
- * first argment to @compare_func is the #GstGLWindow being checked and the
- * second argument is @data.
- *
- * Returns: (transfer none): The first #GstGLWindow that causes a match
- * from @compare_func
- *
- * Since: 1.12
- */
-GstGLWindow *
-gst_gl_display_find_window (GstGLDisplay * display, gpointer data,
- GCompareFunc compare_func)
-{
- GstGLWindow *ret = NULL;
- GList *l;
-
- GST_OBJECT_LOCK (display);
- l = g_list_find_custom (display->windows, data, compare_func);
- if (l)
- ret = l->data;
- GST_OBJECT_UNLOCK (display);
-
- return ret;
-}
-
-static GstGLContext *
-_get_gl_context_for_thread_unlocked (GstGLDisplay * display, GThread * thread)
-{
- GstGLContext *context = NULL;
- GList *prev = NULL, *l = display->priv->contexts;
-
- while (l) {
- GWeakRef *ref = l->data;
- GThread *context_thread;
-
- context = g_weak_ref_get (ref);
- if (!context) {
- /* remove dead contexts */
- g_weak_ref_clear (l->data);
- g_free (l->data);
- display->priv->contexts = g_list_delete_link (display->priv->contexts, l);
- l = prev ? prev->next : display->priv->contexts;
- continue;
- }
-
- if (thread == NULL) {
- GST_DEBUG_OBJECT (display, "Returning GL context %" GST_PTR_FORMAT " for "
- "NULL thread", context);
- return context;
- }
-
- context_thread = gst_gl_context_get_thread (context);
- if (thread != context_thread) {
- g_thread_unref (context_thread);
- gst_object_unref (context);
- prev = l;
- l = l->next;
- continue;
- }
-
- if (context_thread)
- g_thread_unref (context_thread);
-
- GST_DEBUG_OBJECT (display, "Returning GL context %" GST_PTR_FORMAT " for "
- "thread %p", context, thread);
- return context;
- }
-
- GST_DEBUG_OBJECT (display, "No GL context for thread %p", thread);
- return NULL;
-}
-
-/**
- * gst_gl_display_get_gl_context_for_thread:
- * @display: a #GstGLDisplay
- * @thread: a #GThread
- *
- * Returns: (transfer full): the #GstGLContext current on @thread or %NULL
- *
- * Must be called with the object lock held.
- *
- * Since: 1.6
- */
-GstGLContext *
-gst_gl_display_get_gl_context_for_thread (GstGLDisplay * display,
- GThread * thread)
-{
- GstGLContext *context;
-
- g_return_val_if_fail (GST_IS_GL_DISPLAY (display), NULL);
-
- context = _get_gl_context_for_thread_unlocked (display, thread);
- GST_DEBUG_OBJECT (display, "returning context %" GST_PTR_FORMAT " for thread "
- "%p", context, thread);
-
- return context;
-}
-
-static gboolean
-_check_collision (GstGLContext * context, GstGLContext * collision)
-{
- GThread *thread, *collision_thread;
- gboolean ret = FALSE;
-
- if (!context || !collision)
- return FALSE;
-
- thread = gst_gl_context_get_thread (context);
- collision_thread = gst_gl_context_get_thread (collision);
-
- if (!thread || !collision_thread) {
- ret = FALSE;
- goto out;
- }
-
- if (thread == collision_thread) {
- ret = TRUE;
- goto out;
- }
-
-out:
- if (thread)
- g_thread_unref (thread);
- if (collision_thread)
- g_thread_unref (collision_thread);
-
- return ret;
-}
-
-/**
- * gst_gl_display_add_context:
- * @display: a #GstGLDisplay
- * @context: (transfer none): a #GstGLContext
- *
- * Returns: whether @context was successfully added. %FALSE may be returned
- * if there already exists another context for @context's active thread.
- *
- * Must be called with the object lock held.
- *
- * Since: 1.6
- */
-gboolean
-gst_gl_display_add_context (GstGLDisplay * display, GstGLContext * context)
-{
- GstGLContext *collision = NULL;
- GstGLDisplay *context_display;
- gboolean ret = TRUE;
- GThread *thread;
- GWeakRef *ref;
-
- g_return_val_if_fail (GST_IS_GL_DISPLAY (display), FALSE);
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
-
- context_display = gst_gl_context_get_display (context);
- g_assert (context_display == display);
- gst_object_unref (context_display);
-
- thread = gst_gl_context_get_thread (context);
- if (thread) {
- collision = _get_gl_context_for_thread_unlocked (display, thread);
- g_thread_unref (thread);
-
- /* adding the same context is a no-op */
- if (context == collision) {
- GST_LOG_OBJECT (display, "Attempting to add the same GL context %"
- GST_PTR_FORMAT ". Ignoring", context);
- ret = TRUE;
- goto out;
- }
-
- if (_check_collision (context, collision)) {
- GST_DEBUG_OBJECT (display, "Collision detected adding GL context "
- "%" GST_PTR_FORMAT, context);
- ret = FALSE;
- goto out;
- }
- }
-
- ref = g_new0 (GWeakRef, 1);
- g_weak_ref_init (ref, context);
-
- GST_DEBUG_OBJECT (display, "Adding GL context %" GST_PTR_FORMAT, context);
- display->priv->contexts = g_list_prepend (display->priv->contexts, ref);
-
-out:
- if (collision)
- gst_object_unref (collision);
-
- GST_DEBUG_OBJECT (display, "%ssuccessfully inserted context %" GST_PTR_FORMAT,
- ret ? "" : "un", context);
-
- return ret;
-}
diff --git a/gst-libs/gst/gl/gstgldisplay.h b/gst-libs/gst/gl/gstgldisplay.h
deleted file mode 100644
index 7e8fe68a7..000000000
--- a/gst-libs/gst/gl/gstgldisplay.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2007 David A. Schleef <ds@schleef.org>
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
- * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_DISPLAY_H__
-#define __GST_GL_DISPLAY_H__
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GType gst_gl_display_get_type (void);
-
-#define GST_TYPE_GL_DISPLAY (gst_gl_display_get_type())
-#define GST_GL_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_DISPLAY,GstGLDisplay))
-#define GST_GL_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_GL_DISPLAY,GstGLDisplayClass))
-#define GST_IS_GL_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_DISPLAY))
-#define GST_IS_GL_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GL_DISPLAY))
-#define GST_GL_DISPLAY_CAST(obj) ((GstGLDisplay*)(obj))
-#define GST_GL_DISPLAY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_DISPLAY, GstGLDisplayClass))
-
-/**
- * GstGLDisplayType:
- * @GST_GL_DISPLAY_TYPE_NONE: no display type
- * @GST_GL_DISPLAY_TYPE_X11: X11 display
- * @GST_GL_DISPLAY_TYPE_WAYLAND: Wayland display
- * @GST_GL_DISPLAY_TYPE_COCOA: Cocoa display
- * @GST_GL_DISPLAY_TYPE_WIN32: Win32 display
- * @GST_GL_DISPLAY_TYPE_DISPMANX: Dispmanx display
- * @GST_GL_DISPLAY_TYPE_EGL: EGL display
- * @GST_GL_DISPLAY_TYPE_VIV_FB: Vivante Framebuffer display
- * @GST_GL_DISPLAY_TYPE_ANY: any display type
- */
-typedef enum
-{
- GST_GL_DISPLAY_TYPE_NONE = 0,
- GST_GL_DISPLAY_TYPE_X11 = (1 << 0),
- GST_GL_DISPLAY_TYPE_WAYLAND = (1 << 1),
- GST_GL_DISPLAY_TYPE_COCOA = (1 << 2),
- GST_GL_DISPLAY_TYPE_WIN32 = (1 << 3),
- GST_GL_DISPLAY_TYPE_DISPMANX = (1 << 4),
- GST_GL_DISPLAY_TYPE_EGL = (1 << 5),
- GST_GL_DISPLAY_TYPE_VIV_FB = (1 << 6),
-
- GST_GL_DISPLAY_TYPE_ANY = G_MAXUINT32
-} GstGLDisplayType;
-
-/**
- * GstGLDisplay:
- *
- * The contents of a #GstGLDisplay are private and should only be accessed
- * through the provided API
- */
-struct _GstGLDisplay
-{
- /* <private> */
- GstObject object;
-
- GstGLDisplayType type;
-
- /* <protected> */
- GList *windows; /* OBJECT lock */
- GMainContext *main_context;
- GMainLoop *main_loop;
- GSource *event_source;
-
- GstGLDisplayPrivate *priv;
-};
-
-struct _GstGLDisplayClass
-{
- GstObjectClass object_class;
-
- guintptr (*get_handle) (GstGLDisplay * display);
- GstGLWindow * (*create_window) (GstGLDisplay * display);
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GstGLDisplay *gst_gl_display_new (void);
-
-#define gst_gl_display_lock(display) GST_OBJECT_LOCK (display)
-#define gst_gl_display_unlock(display) GST_OBJECT_UNLOCK (display)
-
-GST_EXPORT
-guintptr gst_gl_display_get_handle (GstGLDisplay * display);
-GST_EXPORT
-GstGLDisplayType gst_gl_display_get_handle_type (GstGLDisplay * display);
-GST_EXPORT
-void gst_gl_display_filter_gl_api (GstGLDisplay * display,
- GstGLAPI gl_api);
-GST_EXPORT
-GstGLAPI gst_gl_display_get_gl_api (GstGLDisplay * display);
-GST_EXPORT
-GstGLAPI gst_gl_display_get_gl_api_unlocked (GstGLDisplay * display);
-
-/**
- * GST_GL_DISPLAY_CONTEXT_TYPE:
- *
- * The name used in #GstContext queries for requesting a #GstGLDisplay
- */
-#define GST_GL_DISPLAY_CONTEXT_TYPE "gst.gl.GLDisplay"
-GST_EXPORT
-void gst_context_set_gl_display (GstContext * context, GstGLDisplay * display);
-GST_EXPORT
-gboolean gst_context_get_gl_display (GstContext * context, GstGLDisplay ** display);
-
-GST_EXPORT
-gboolean gst_gl_display_create_context (GstGLDisplay * display,
- GstGLContext * other_context, GstGLContext ** p_context, GError **error);
-GST_EXPORT
-GstGLContext * gst_gl_display_get_gl_context_for_thread (GstGLDisplay * display,
- GThread * thread);
-GST_EXPORT
-gboolean gst_gl_display_add_context (GstGLDisplay * display,
- GstGLContext * context);
-
-GST_EXPORT
-GstGLWindow * gst_gl_display_create_window (GstGLDisplay * display);
-GST_EXPORT
-gboolean gst_gl_display_remove_window (GstGLDisplay * display, GstGLWindow * window);
-GST_EXPORT
-GstGLWindow * gst_gl_display_find_window (GstGLDisplay * display, gpointer data, GCompareFunc compare_func);
-
-G_END_DECLS
-
-#endif /* __GST_GL_DISPLAY_H__ */
diff --git a/gst-libs/gst/gl/gstglfeature.c b/gst-libs/gst/gl/gstglfeature.c
deleted file mode 100644
index a1cadc277..000000000
--- a/gst-libs/gst/gl/gstglfeature.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "gstglfeature.h"
-
-#include "gstglcontext.h"
-#include "gstglfeature_private.h"
-#include "gstglfuncs.h"
-
-#define GST_CAT_DEFAULT gl_feature
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-
-static void
-_init_debug (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "glfeature", 0,
- "OpenGL feature detection");
- g_once_init_leave (&_init, 1);
- }
-}
-
-/**
- * gst_gl_check_extension:
- * @name: the extension to search for
- * @ext: the list of possible extensions
- *
- * Returns: whether @name is in the space seperated list of @ext
- */
-gboolean
-gst_gl_check_extension (const char *name, const gchar * ext)
-{
- char *end;
- int name_len, n;
-
- if (name == NULL || ext == NULL)
- return FALSE;
-
- end = (char *) (ext + strlen (ext));
-
- name_len = strlen (name);
-
- while (ext < end) {
- n = strcspn (ext, " ");
-
- if ((name_len == n) && (!strncmp (name, ext, n)))
- return TRUE;
- ext += (n + 1);
- }
-
- return FALSE;
-}
-
-/* Define a set of arrays containing the functions required from GL
- for each feature */
-#define GST_GL_EXT_BEGIN(name, \
- gl_availability, \
- min_gl_major, min_gl_minor, \
- min_gles_major, min_gles_minor, \
- namespaces, extension_names) \
- static const GstGLFeatureFunction gst_gl_ext_ ## name ## _funcs[] = {
-#define GST_GL_EXT_FUNCTION(ret, name, args) \
- { G_STRINGIFY (name), G_STRUCT_OFFSET (GstGLFuncs, name) },
-#define GST_GL_EXT_END() \
- { NULL, 0 }, \
- };
-#include "glprototypes/all_functions.h"
-
-#undef GST_GL_EXT_BEGIN
-#undef GST_GL_EXT_FUNCTION
-#undef GST_GL_EXT_END
-
-#define GST_GL_EXT_BEGIN(name, \
- gl_availability, \
- min_gl_major, min_gl_minor, \
- min_gles_major, min_gles_minor, \
- namespaces, extension_names) \
- { G_STRINGIFY (name), gl_availability, min_gl_major, min_gl_minor, min_gles_major, \
- min_gles_minor, namespaces, extension_names, \
- gst_gl_ext_ ## name ## _funcs },
-#define GST_GL_EXT_FUNCTION(ret, name, args)
-#define GST_GL_EXT_END()
-
-static const GstGLFeatureData gst_gl_feature_ext_functions_data[] = {
-#include "glprototypes/all_functions.h"
-};
-
-#undef GST_GL_EXT_BEGIN
-#undef GST_GL_EXT_FUNCTION
-#undef GST_GL_EXT_END
-
-static gboolean
-_gst_gl_feature_check_for_extension (const GstGLFeatureData * data,
- const char *driver_prefix, const char *extensions_string,
- const char **suffix)
-{
- const char *namespace, *namespace_suffix;
- unsigned int namespace_len;
-
- g_return_val_if_fail (suffix != NULL, FALSE);
-
- for (namespace = data->namespaces; *namespace;
- namespace += strlen (namespace) + 1) {
- const char *extension;
- GString *full_extension_name = g_string_new ("");
-
- /* If the namespace part contains a ':' then the suffix for
- the function names is different from the name space */
- if ((namespace_suffix = strchr (namespace, ':'))) {
- namespace_len = namespace_suffix - namespace;
- namespace_suffix++;
- } else {
- namespace_len = strlen (namespace);
- namespace_suffix = namespace;
- }
-
- for (extension = data->extension_names; *extension;
- extension += strlen (extension) + 1) {
- g_string_assign (full_extension_name, driver_prefix);
- g_string_append_c (full_extension_name, '_');
- g_string_append_len (full_extension_name, namespace, namespace_len);
- g_string_append_c (full_extension_name, '_');
- g_string_append (full_extension_name, extension);
-
- if (gst_gl_check_extension (full_extension_name->str, extensions_string)) {
- GST_TRACE ("found %s in extension string", full_extension_name->str);
- break;
- }
- }
-
- g_string_free (full_extension_name, TRUE);
-
- /* If we found an extension with this namespace then use it
- as the suffix */
- if (*extension) {
- *suffix = namespace_suffix;
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-gboolean
-_gst_gl_feature_check (GstGLContext * context,
- const char *driver_prefix,
- const GstGLFeatureData * data,
- int gl_major, int gl_minor, const char *extensions_string)
-{
- char *full_function_name = NULL;
- gboolean in_core = FALSE;
- const char *suffix = NULL;
- int func_num;
- GstGLFuncs *gst_gl = context->gl_vtable;
- guint gl_min = 0, gl_maj = 0;
- GstGLAPI gl_api = gst_gl_context_get_gl_api (context);
-
- if (gl_api & (GST_GL_API_OPENGL | GST_GL_API_OPENGL3)) {
- gl_maj = data->min_gl_major;
- gl_min = data->min_gl_minor;
- } else if (gl_api & (GST_GL_API_GLES1 | GST_GL_API_GLES2)) {
- gl_maj = data->min_gles_major;
- gl_min = data->min_gles_minor;
- }
-
- GST_DEBUG ("%s, 0x%x, %d.%d vs 0x%x, %d.%d", data->feature_name,
- data->gl_availability, gl_maj, gl_min,
- gst_gl_context_get_gl_api (context), gl_major, gl_minor);
-
- /* First check whether the functions should be directly provided by
- GL */
- if (gst_gl_context_check_gl_version (context, data->gl_availability, gl_maj,
- gl_min)) {
- in_core = TRUE;
- suffix = "";
- } else {
- /* Otherwise try all of the extensions */
- if (!_gst_gl_feature_check_for_extension (data, driver_prefix,
- extensions_string, &suffix))
- goto error;
- }
-
- /* If we couldn't find anything that provides the functions then
- give up */
- if (suffix == NULL)
- goto error;
-
- /* Try to get all of the entry points */
- for (func_num = 0; data->functions[func_num].name; func_num++) {
- void *func;
-
- g_free (full_function_name);
-
- full_function_name = g_strconcat ("gl", data->functions[func_num].name,
- suffix, NULL);
- GST_TRACE ("%s should %sbe in core", full_function_name,
- in_core ? "" : "not ");
- func = gst_gl_context_get_proc_address (context, full_function_name);
-
- if (func == NULL && in_core) {
- GST_TRACE ("%s was not found in core, trying the extension version",
- full_function_name);
- if (!_gst_gl_feature_check_for_extension (data, driver_prefix,
- extensions_string, &suffix)) {
- goto error;
- } else {
- g_free (full_function_name);
- full_function_name = g_strconcat ("gl", data->functions[func_num].name,
- suffix, NULL);
- func = gst_gl_context_get_proc_address (context, full_function_name);
- }
- }
-
- if (func == NULL) {
- goto error;
- }
-
- /* Set the function pointer in the context */
- *(void **) ((guint8 *) gst_gl +
- data->functions[func_num].pointer_offset) = func;
-
- }
-
- g_free (full_function_name);
-
- return TRUE;
-
- /* If the extension isn't found or one of the functions wasn't found
- * then set all of the functions pointers to NULL so we can safely
- * do feature testing by just looking at the function pointers */
-error:
- GST_DEBUG ("failed to find feature %s", data->feature_name);
-
- for (func_num = 0; data->functions[func_num].name; func_num++) {
- *(void **) ((guint8 *) gst_gl +
- data->functions[func_num].pointer_offset) = NULL;
- }
-
- if (full_function_name) {
- GST_DEBUG ("failed to find function %s", full_function_name);
- g_free (full_function_name);
- }
-
- return FALSE;
-}
-
-void
-_gst_gl_feature_check_ext_functions (GstGLContext * context,
- int gl_major, int gl_minor, const char *gl_extensions)
-{
- int i;
-
- _init_debug ();
-
- for (i = 0; i < G_N_ELEMENTS (gst_gl_feature_ext_functions_data); i++) {
- _gst_gl_feature_check (context, "GL",
- gst_gl_feature_ext_functions_data + i, gl_major, gl_minor,
- gl_extensions);
- }
-}
diff --git a/gst-libs/gst/gl/gstglfeature.h b/gst-libs/gst/gl/gstglfeature.h
deleted file mode 100644
index 201712257..000000000
--- a/gst-libs/gst/gl/gstglfeature.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-/*
- * Cogl
- *
- * An object oriented GL/GLES Abstraction/Utility Layer
- *
- * Copyright (C) 2009 Intel Corporation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- *
- */
-
-#ifndef __GST_GL_FEATURE_H__
-#define __GST_GL_FEATURE_H__
-
-#include <gst/gst.h>
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-#define GST_GL_CHECK_GL_VERSION(driver_major, driver_minor, \
- target_major, target_minor) \
- ((driver_major) > (target_major) || \
- ((driver_major) == (target_major) && (driver_minor) >= (target_minor)))
-
-GST_EXPORT
-gboolean gst_gl_check_extension (const char *name, const gchar * ext);
-
-G_END_DECLS
-
-#endif /* __GST_GL_FEATURE_H__ */
diff --git a/gst-libs/gst/gl/gstglfeature_private.h b/gst-libs/gst/gl/gstglfeature_private.h
deleted file mode 100644
index db4a6ea78..000000000
--- a/gst-libs/gst/gl/gstglfeature_private.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-/*
- * Cogl
- *
- * An object oriented GL/GLES Abstraction/Utility Layer
- *
- * Copyright (C) 2009 Intel Corporation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- *
- */
-
-#ifndef __GST_GL_FEATURE_PRIVATE_H__
-#define __GST_GL_FEATURE_PRIVATE_H__
-
-#include <gst/gst.h>
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GstGLFeatureFunction GstGLFeatureFunction;
-
-struct _GstGLFeatureFunction
-{
- /* The name of the function without the "EXT" or "ARB" suffix */
- const char *name;
- /* The offset in the context of where to store the function pointer */
- unsigned int pointer_offset;
-};
-
-typedef struct _GstGLFeatureData GstGLFeatureData;
-
-struct _GstGLFeatureData
-{
- /* name of the feature */
- const char *feature_name;
- /* Flags specifying which versions of GL the feature is available
- in core in */
- GstGLAPI gl_availability;
- /* A minimum GL version which the functions should be defined in
- without needing an extension. Set to 255, 255 if it's only
- provided in an extension */
- int min_gl_major, min_gl_minor;
- /* A minimum GLES version which the functions should be defined in
- without needing an extension. Set to 255, 255 if it's only
- provided in an extension */
- int min_gles_major, min_gles_minor;
- /* \0 separated list of namespaces to try. Eg "EXT\0ARB\0" */
- const char *namespaces;
- /* \0 separated list of required extension names without the GL_EXT
- or GL_ARB prefix. Any of the extensions must be available for the
- feature to be considered available. If the suffix for an
- extension is different from the namespace, you can specify it
- with a ':' after the namespace */
- const char *extension_names;
- /* A list of functions required for this feature. Terminated with a
- NULL name */
- const GstGLFeatureFunction *functions;
-};
-
-G_GNUC_INTERNAL gboolean
-_gst_gl_feature_check (GstGLContext *context,
- const char *driver_prefix,
- const GstGLFeatureData *data,
- int gl_major,
- int gl_minor,
- const char *extensions_string);
-
-G_GNUC_INTERNAL void
-_gst_gl_feature_check_ext_functions (GstGLContext *context,
- int gl_major,
- int gl_minor,
- const char *gl_extensions);
-
-G_END_DECLS
-
-#endif /* __GST_GL_FEATURE_PRIVATE_H__ */
diff --git a/gst-libs/gst/gl/gstglfilter.c b/gst-libs/gst/gl/gstglfilter.c
deleted file mode 100644
index 5c9e140fd..000000000
--- a/gst-libs/gst/gl/gstglfilter.c
+++ /dev/null
@@ -1,1223 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2007 David Schleef <ds@schleef.org>
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstglfilter
- * @title: GstGLFilter
- * @short_description: GstBaseTransform subclass for dealing with RGBA textures
- * @see_also: #GstBaseTransform, #GstGLContext, #GstGLFramebuffer
- *
- * #GstGLFilter helps to implement simple OpenGL filter elements taking a
- * single input and producing a single output with a #GstGLFramebuffer
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/video/gstvideometa.h>
-
-#include "gstglfilter.h"
-
-#include "gstglfuncs.h"
-
-#define GST_CAT_DEFAULT gst_gl_filter_debug
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-
-/* *INDENT-OFF* */
-static GstStaticPadTemplate gst_gl_filter_src_pad_template =
-GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), "
- "format = (string) RGBA, "
- "width = " GST_VIDEO_SIZE_RANGE ", "
- "height = " GST_VIDEO_SIZE_RANGE ", "
- "framerate = " GST_VIDEO_FPS_RANGE ","
- "texture-target = (string) 2D ; "
- "video/x-raw(ANY), "
- "format = (string) RGBA, "
- "width = " GST_VIDEO_SIZE_RANGE ", "
- "height = " GST_VIDEO_SIZE_RANGE ", "
- "framerate = " GST_VIDEO_FPS_RANGE ","
- "texture-target = (string) 2D"
- ));
-
-static GstStaticPadTemplate gst_gl_filter_sink_pad_template =
-GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw(ANY), "
- "format = (string) RGBA, "
- "width = " GST_VIDEO_SIZE_RANGE ", "
- "height = " GST_VIDEO_SIZE_RANGE ", "
- "framerate = " GST_VIDEO_FPS_RANGE ","
- "texture-target = (string) 2D ; "
- "video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), "
- "format = (string) RGBA, "
- "width = " GST_VIDEO_SIZE_RANGE ", "
- "height = " GST_VIDEO_SIZE_RANGE ", "
- "framerate = " GST_VIDEO_FPS_RANGE ","
- "texture-target = (string) 2D"
- ));
-/* *INDENT-ON* */
-
-/* Properties */
-enum
-{
- PROP_0,
-};
-
-#define gst_gl_filter_parent_class parent_class
-G_DEFINE_TYPE_WITH_CODE (GstGLFilter, gst_gl_filter, GST_TYPE_GL_BASE_FILTER,
- GST_DEBUG_CATEGORY_INIT (gst_gl_filter_debug, "glfilter", 0,
- "glfilter element");
- );
-
-static void gst_gl_filter_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_gl_filter_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static GstCaps *gst_gl_filter_transform_caps (GstBaseTransform * bt,
- GstPadDirection direction, GstCaps * caps, GstCaps * filter);
-static GstCaps *default_transform_internal_caps (GstGLFilter * filter,
- GstPadDirection direction, GstCaps * caps, GstCaps * filter_caps);
-static GstCaps *gst_gl_filter_fixate_caps (GstBaseTransform * bt,
- GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
-static void gst_gl_filter_reset (GstGLFilter * filter);
-static gboolean gst_gl_filter_stop (GstBaseTransform * bt);
-static gboolean gst_gl_filter_get_unit_size (GstBaseTransform * trans,
- GstCaps * caps, gsize * size);
-static GstFlowReturn gst_gl_filter_transform (GstBaseTransform * bt,
- GstBuffer * inbuf, GstBuffer * outbuf);
-static gboolean gst_gl_filter_propose_allocation (GstBaseTransform * trans,
- GstQuery * decide_query, GstQuery * query);
-static gboolean gst_gl_filter_decide_allocation (GstBaseTransform * trans,
- GstQuery * query);
-static gboolean gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
- GstCaps * outcaps);
-static void gst_gl_filter_gl_stop (GstGLBaseFilter * filter);
-static gboolean gst_gl_filter_gl_set_caps (GstGLBaseFilter * bt,
- GstCaps * incaps, GstCaps * outcaps);
-
-void
-gst_gl_filter_add_rgba_pad_templates (GstGLFilterClass * klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class,
- &gst_gl_filter_src_pad_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_gl_filter_sink_pad_template);
-}
-
-static void
-gst_gl_filter_class_init (GstGLFilterClass * klass)
-{
- GObjectClass *gobject_class;
-
- gobject_class = (GObjectClass *) klass;
-
- gobject_class->set_property = gst_gl_filter_set_property;
- gobject_class->get_property = gst_gl_filter_get_property;
-
- GST_BASE_TRANSFORM_CLASS (klass)->transform_caps =
- gst_gl_filter_transform_caps;
- GST_BASE_TRANSFORM_CLASS (klass)->fixate_caps = gst_gl_filter_fixate_caps;
- GST_BASE_TRANSFORM_CLASS (klass)->transform = gst_gl_filter_transform;
- GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_filter_stop;
- GST_BASE_TRANSFORM_CLASS (klass)->set_caps = gst_gl_filter_set_caps;
- GST_BASE_TRANSFORM_CLASS (klass)->propose_allocation =
- gst_gl_filter_propose_allocation;
- GST_BASE_TRANSFORM_CLASS (klass)->decide_allocation =
- gst_gl_filter_decide_allocation;
- GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size = gst_gl_filter_get_unit_size;
-
- GST_GL_BASE_FILTER_CLASS (klass)->gl_stop = gst_gl_filter_gl_stop;
- GST_GL_BASE_FILTER_CLASS (klass)->gl_set_caps = gst_gl_filter_gl_set_caps;
-
- klass->transform_internal_caps = default_transform_internal_caps;
-}
-
-static void
-gst_gl_filter_init (GstGLFilter * filter)
-{
- filter->draw_attr_position_loc = -1;
- filter->draw_attr_texture_loc = -1;
-}
-
-static void
-gst_gl_filter_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_gl_filter_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_gl_filter_reset (GstGLFilter * filter)
-{
- gst_caps_replace (&filter->out_caps, NULL);
-}
-
-static gboolean
-gst_gl_filter_stop (GstBaseTransform * bt)
-{
- GstGLFilter *filter = GST_GL_FILTER (bt);
-
- gst_gl_filter_reset (filter);
-
- return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (bt);
-}
-
-static void
-gst_gl_filter_gl_stop (GstGLBaseFilter * base_filter)
-{
- GstGLFilter *filter = GST_GL_FILTER (base_filter);
- GstGLContext *context = base_filter->context;
- const GstGLFuncs *gl = context->gl_vtable;
-
- if (filter->vao) {
- gl->DeleteVertexArrays (1, &filter->vao);
- filter->vao = 0;
- }
-
- if (filter->vertex_buffer) {
- gl->DeleteBuffers (1, &filter->vertex_buffer);
- filter->vertex_buffer = 0;
- }
-
- if (filter->vbo_indices) {
- gl->DeleteBuffers (1, &filter->vbo_indices);
- filter->vbo_indices = 0;
- }
-
- if (filter->fbo != NULL) {
- gst_object_unref (filter->fbo);
- filter->fbo = NULL;
- }
-
- filter->default_shader = NULL;
- filter->draw_attr_position_loc = -1;
- filter->draw_attr_texture_loc = -1;
-
- GST_GL_BASE_FILTER_CLASS (parent_class)->gl_stop (base_filter);
-}
-
-static GstCaps *
-gst_gl_filter_fixate_caps (GstBaseTransform * bt,
- GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
-{
- GstStructure *ins, *outs;
- const GValue *from_par, *to_par;
- GValue fpar = { 0, }, tpar = {
- 0,};
-
- othercaps = gst_caps_make_writable (othercaps);
- othercaps = gst_caps_truncate (othercaps);
-
- GST_DEBUG_OBJECT (bt, "trying to fixate othercaps %" GST_PTR_FORMAT
- " based on caps %" GST_PTR_FORMAT, othercaps, caps);
-
- ins = gst_caps_get_structure (caps, 0);
- outs = gst_caps_get_structure (othercaps, 0);
-
- from_par = gst_structure_get_value (ins, "pixel-aspect-ratio");
- to_par = gst_structure_get_value (outs, "pixel-aspect-ratio");
-
- /* If we're fixating from the sinkpad we always set the PAR and
- * assume that missing PAR on the sinkpad means 1/1 and
- * missing PAR on the srcpad means undefined
- */
- if (direction == GST_PAD_SINK) {
- if (!from_par) {
- g_value_init (&fpar, GST_TYPE_FRACTION);
- gst_value_set_fraction (&fpar, 1, 1);
- from_par = &fpar;
- }
- if (!to_par) {
- g_value_init (&tpar, GST_TYPE_FRACTION);
- gst_value_set_fraction (&tpar, 1, 1);
- to_par = &tpar;
- }
- } else {
- if (!to_par) {
- g_value_init (&tpar, GST_TYPE_FRACTION);
- gst_value_set_fraction (&tpar, 1, 1);
- to_par = &tpar;
-
- gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
- NULL);
- }
- if (!from_par) {
- g_value_init (&fpar, GST_TYPE_FRACTION);
- gst_value_set_fraction (&fpar, 1, 1);
- from_par = &fpar;
- }
- }
-
- /* we have both PAR but they might not be fixated */
- {
- gint from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d;
- gint w = 0, h = 0;
- gint from_dar_n, from_dar_d;
- gint num, den;
-
- /* from_par should be fixed */
- g_return_val_if_fail (gst_value_is_fixed (from_par), othercaps);
-
- from_par_n = gst_value_get_fraction_numerator (from_par);
- from_par_d = gst_value_get_fraction_denominator (from_par);
-
- gst_structure_get_int (ins, "width", &from_w);
- gst_structure_get_int (ins, "height", &from_h);
-
- gst_structure_get_int (outs, "width", &w);
- gst_structure_get_int (outs, "height", &h);
-
- /* if both width and height are already fixed, we can't do anything
- * about it anymore */
- if (w && h) {
- GST_DEBUG_OBJECT (bt, "dimensions already set to %dx%d, not fixating",
- w, h);
- if (!gst_value_is_fixed (to_par)) {
- GST_DEBUG_OBJECT (bt, "fixating to_par to %dx%d", 1, 1);
- if (gst_structure_has_field (outs, "pixel-aspect-ratio"))
- gst_structure_fixate_field_nearest_fraction (outs,
- "pixel-aspect-ratio", 1, 1);
- }
- goto done;
- }
-
- /* Calculate input DAR */
- if (!gst_util_fraction_multiply (from_w, from_h, from_par_n, from_par_d,
- &from_dar_n, &from_dar_d)) {
- GST_ELEMENT_ERROR (bt, CORE, NEGOTIATION, (NULL),
- ("Error calculating the output scaled size - integer overflow"));
- goto done;
- }
-
- GST_DEBUG_OBJECT (bt, "Input DAR is %d/%d", from_dar_n, from_dar_d);
-
- /* If either width or height are fixed there's not much we
- * can do either except choosing a height or width and PAR
- * that matches the DAR as good as possible
- */
- if (h) {
- gint num, den;
-
- GST_DEBUG_OBJECT (bt, "height is fixed (%d)", h);
-
- if (!gst_value_is_fixed (to_par)) {
- /* (shortcut) copy-paste (??) of videoscale seems to aim for 1/1,
- * so let's make it so ...
- * especially if following code assumes fixed */
- GST_DEBUG_OBJECT (bt, "fixating to_par to 1x1");
- gst_structure_fixate_field_nearest_fraction (outs,
- "pixel-aspect-ratio", 1, 1);
- to_par = gst_structure_get_value (outs, "pixel-aspect-ratio");
- }
-
- /* PAR is fixed, choose the height that is nearest to the
- * height with the same DAR */
- to_par_n = gst_value_get_fraction_numerator (to_par);
- to_par_d = gst_value_get_fraction_denominator (to_par);
-
- GST_DEBUG_OBJECT (bt, "PAR is fixed %d/%d", to_par_n, to_par_d);
-
- if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_d,
- to_par_n, &num, &den)) {
- GST_ELEMENT_ERROR (bt, CORE, NEGOTIATION, (NULL),
- ("Error calculating the output scaled size - integer overflow"));
- goto done;
- }
-
- w = (guint) gst_util_uint64_scale_int (h, num, den);
- gst_structure_fixate_field_nearest_int (outs, "width", w);
-
- goto done;
- } else if (w) {
- gint num, den;
-
- GST_DEBUG_OBJECT (bt, "width is fixed (%d)", w);
-
- if (!gst_value_is_fixed (to_par)) {
- /* (shortcut) copy-paste (??) of videoscale seems to aim for 1/1,
- * so let's make it so ...
- * especially if following code assumes fixed */
- GST_DEBUG_OBJECT (bt, "fixating to_par to 1x1");
- gst_structure_fixate_field_nearest_fraction (outs,
- "pixel-aspect-ratio", 1, 1);
- to_par = gst_structure_get_value (outs, "pixel-aspect-ratio");
- }
-
- /* PAR is fixed, choose the height that is nearest to the
- * height with the same DAR */
- to_par_n = gst_value_get_fraction_numerator (to_par);
- to_par_d = gst_value_get_fraction_denominator (to_par);
-
- GST_DEBUG_OBJECT (bt, "PAR is fixed %d/%d", to_par_n, to_par_d);
-
- if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_d,
- to_par_n, &num, &den)) {
- GST_ELEMENT_ERROR (bt, CORE, NEGOTIATION, (NULL),
- ("Error calculating the output scaled size - integer overflow"));
- goto done;
- }
-
- h = (guint) gst_util_uint64_scale_int (w, den, num);
- gst_structure_fixate_field_nearest_int (outs, "height", h);
-
- goto done;
- } else if (gst_value_is_fixed (to_par)) {
- GstStructure *tmp;
- gint set_h, set_w, f_h, f_w;
-
- to_par_n = gst_value_get_fraction_numerator (to_par);
- to_par_d = gst_value_get_fraction_denominator (to_par);
-
- /* Calculate scale factor for the PAR change */
- if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, to_par_n,
- to_par_d, &num, &den)) {
- GST_ELEMENT_ERROR (bt, CORE, NEGOTIATION, (NULL),
- ("Error calculating the output scaled size - integer overflow"));
- goto done;
- }
-
- /* Try to keep the input height */
- tmp = gst_structure_copy (outs);
- gst_structure_fixate_field_nearest_int (tmp, "height", from_h);
- gst_structure_get_int (tmp, "height", &set_h);
-
- /* This might have failed but try to scale the width
- * to keep the DAR nonetheless */
- w = (guint) gst_util_uint64_scale_int (set_h, num, den);
- gst_structure_fixate_field_nearest_int (tmp, "width", w);
- gst_structure_get_int (tmp, "width", &set_w);
- gst_structure_free (tmp);
-
- /* We kept the DAR and the height is nearest to the original height */
- if (set_w == w) {
- gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
- G_TYPE_INT, set_h, NULL);
- goto done;
- }
-
- f_h = set_h;
- f_w = set_w;
-
- /* If the former failed, try to keep the input width at least */
- tmp = gst_structure_copy (outs);
- gst_structure_fixate_field_nearest_int (tmp, "width", from_w);
- gst_structure_get_int (tmp, "width", &set_w);
-
- /* This might have failed but try to scale the width
- * to keep the DAR nonetheless */
- h = (guint) gst_util_uint64_scale_int (set_w, den, num);
- gst_structure_fixate_field_nearest_int (tmp, "height", h);
- gst_structure_get_int (tmp, "height", &set_h);
- gst_structure_free (tmp);
-
- /* We kept the DAR and the width is nearest to the original width */
- if (set_h == h) {
- gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
- G_TYPE_INT, set_h, NULL);
- goto done;
- }
-
- /* If all this failed, keep the height that was nearest to the orignal
- * height and the nearest possible width. This changes the DAR but
- * there's not much else to do here.
- */
- gst_structure_set (outs, "width", G_TYPE_INT, f_w, "height", G_TYPE_INT,
- f_h, NULL);
- goto done;
- } else {
- GstStructure *tmp;
- gint set_h, set_w, set_par_n, set_par_d, tmp2;
-
- /* width, height and PAR are not fixed */
-
- /* First try to keep the height and width as good as possible
- * and scale PAR */
- tmp = gst_structure_copy (outs);
- gst_structure_fixate_field_nearest_int (tmp, "height", from_h);
- gst_structure_get_int (tmp, "height", &set_h);
- gst_structure_fixate_field_nearest_int (tmp, "width", from_w);
- gst_structure_get_int (tmp, "width", &set_w);
-
- if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_h, set_w,
- &to_par_n, &to_par_d)) {
- GST_ELEMENT_ERROR (bt, CORE, NEGOTIATION, (NULL),
- ("Error calculating the output scaled size - integer overflow"));
- gst_structure_free (tmp);
- goto done;
- }
-
- if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
- gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
- gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
- to_par_n, to_par_d);
- gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
- &set_par_d);
- gst_structure_free (tmp);
-
- if (set_par_n == to_par_n && set_par_d == to_par_d) {
- gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
- G_TYPE_INT, set_h, NULL);
-
- if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
- set_par_n != set_par_d)
- gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
- set_par_n, set_par_d, NULL);
- goto done;
- }
-
- /* Otherwise try to scale width to keep the DAR with the set
- * PAR and height */
- if (!gst_util_fraction_multiply (from_dar_n, from_dar_d, set_par_d,
- set_par_n, &num, &den)) {
- GST_ELEMENT_ERROR (bt, CORE, NEGOTIATION, (NULL),
- ("Error calculating the output scaled size - integer overflow"));
- goto done;
- }
-
- w = (guint) gst_util_uint64_scale_int (set_h, num, den);
- tmp = gst_structure_copy (outs);
- gst_structure_fixate_field_nearest_int (tmp, "width", w);
- gst_structure_get_int (tmp, "width", &tmp2);
- gst_structure_free (tmp);
-
- if (tmp2 == w) {
- gst_structure_set (outs, "width", G_TYPE_INT, tmp2, "height",
- G_TYPE_INT, set_h, NULL);
- if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
- set_par_n != set_par_d)
- gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
- set_par_n, set_par_d, NULL);
- goto done;
- }
-
- /* ... or try the same with the height */
- h = (guint) gst_util_uint64_scale_int (set_w, den, num);
- tmp = gst_structure_copy (outs);
- gst_structure_fixate_field_nearest_int (tmp, "height", h);
- gst_structure_get_int (tmp, "height", &tmp2);
- gst_structure_free (tmp);
-
- if (tmp2 == h) {
- gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
- G_TYPE_INT, tmp2, NULL);
- if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
- set_par_n != set_par_d)
- gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
- set_par_n, set_par_d, NULL);
- goto done;
- }
-
- /* If all fails we can't keep the DAR and take the nearest values
- * for everything from the first try */
- gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
- G_TYPE_INT, set_h, NULL);
- if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
- set_par_n != set_par_d)
- gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
- set_par_n, set_par_d, NULL);
- }
- }
-
-
-done:
- othercaps = gst_caps_fixate (othercaps);
-
- GST_DEBUG_OBJECT (bt, "fixated othercaps to %" GST_PTR_FORMAT, othercaps);
-
- if (from_par == &fpar)
- g_value_unset (&fpar);
- if (to_par == &tpar)
- g_value_unset (&tpar);
-
- return othercaps;
-}
-
-/* copies the given caps */
-static GstCaps *
-gst_gl_filter_caps_remove_size (GstCaps * caps)
-{
- GstStructure *st;
- GstCapsFeatures *f;
- gint i, n;
- GstCaps *res;
-
- res = gst_caps_new_empty ();
-
- n = gst_caps_get_size (caps);
- for (i = 0; i < n; i++) {
- st = gst_caps_get_structure (caps, i);
- f = gst_caps_get_features (caps, i);
-
- /* If this is already expressed by the existing caps
- * skip this structure */
- if (i > 0 && gst_caps_is_subset_structure_full (res, st, f))
- continue;
-
- st = gst_structure_copy (st);
- gst_structure_set (st, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
- "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
-
- /* if pixel aspect ratio, make a range of it */
- if (gst_structure_has_field (st, "pixel-aspect-ratio")) {
- gst_structure_set (st, "pixel-aspect-ratio",
- GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1, NULL);
- }
-
- gst_caps_append_structure_full (res, st, gst_caps_features_copy (f));
- }
-
- return res;
-}
-
-static GstCaps *
-gst_gl_filter_set_caps_features (const GstCaps * caps,
- const gchar * feature_name)
-{
- GstCaps *ret = gst_caps_copy (caps);
- guint n = gst_caps_get_size (ret);
- guint i = 0;
-
- for (i = 0; i < n; i++) {
- gst_caps_set_features (ret, i,
- gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY));
- }
-
- return ret;
-}
-
-static GstCaps *
-default_transform_internal_caps (GstGLFilter * filter,
- GstPadDirection direction, GstCaps * caps, GstCaps * filter_caps)
-{
- GstCaps *tmp = gst_gl_filter_caps_remove_size (caps);
-
- GST_DEBUG_OBJECT (filter, "size removal returned caps %" GST_PTR_FORMAT, tmp);
- return tmp;
-}
-
-static GstCaps *
-gst_gl_filter_transform_caps (GstBaseTransform * bt,
- GstPadDirection direction, GstCaps * caps, GstCaps * filter_caps)
-{
- GstGLFilter *filter = GST_GL_FILTER (bt);
- GstCaps *tmp = NULL;
- GstCaps *result = NULL;
-
- if (gst_base_transform_is_passthrough (bt)) {
- tmp = gst_caps_ref (caps);
- } else {
- tmp = GST_GL_FILTER_GET_CLASS (filter)->transform_internal_caps (filter,
- direction, caps, NULL);
-
- result =
- gst_gl_filter_set_caps_features (tmp,
- GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
- gst_caps_unref (tmp);
- tmp = result;
- }
-
- if (filter_caps) {
- result =
- gst_caps_intersect_full (filter_caps, tmp, GST_CAPS_INTERSECT_FIRST);
- gst_caps_unref (tmp);
- } else {
- result = tmp;
- }
-
- GST_DEBUG_OBJECT (bt, "returning caps: %" GST_PTR_FORMAT, result);
-
- return result;
-}
-
-static gboolean
-gst_gl_filter_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
- gsize * size)
-{
- gboolean ret = FALSE;
- GstVideoInfo info;
-
- ret = gst_video_info_from_caps (&info, caps);
- if (ret)
- *size = GST_VIDEO_INFO_SIZE (&info);
-
- return TRUE;
-}
-
-static gboolean
-gst_gl_filter_gl_set_caps (GstGLBaseFilter * bt, GstCaps * incaps,
- GstCaps * outcaps)
-{
- GstGLFilter *filter = GST_GL_FILTER (bt);
- GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
- GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
- gint out_width, out_height;
-
- out_width = GST_VIDEO_INFO_WIDTH (&filter->out_info);
- out_height = GST_VIDEO_INFO_HEIGHT (&filter->out_info);
-
- if (filter->fbo)
- gst_object_unref (filter->fbo);
-
- if (!(filter->fbo =
- gst_gl_framebuffer_new_with_default_depth (context, out_width,
- out_height)))
- goto context_error;
-
- if (filter_class->init_fbo) {
- if (!filter_class->init_fbo (filter))
- goto error;
- }
-
- return TRUE;
-
-context_error:
- {
- GST_ELEMENT_ERROR (filter, RESOURCE, NOT_FOUND, ("Could not generate FBO"),
- (NULL));
- return FALSE;
- }
-error:
- {
- GST_ELEMENT_ERROR (filter, LIBRARY, INIT,
- ("Subclass failed to initialize."), (NULL));
- return FALSE;
- }
-}
-
-static gboolean
-gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
- GstCaps * outcaps)
-{
- GstGLFilter *filter;
- GstGLFilterClass *filter_class;
-
- filter = GST_GL_FILTER (bt);
- filter_class = GST_GL_FILTER_GET_CLASS (filter);
-
- if (!gst_video_info_from_caps (&filter->in_info, incaps))
- goto wrong_caps;
- if (!gst_video_info_from_caps (&filter->out_info, outcaps))
- goto wrong_caps;
-
- if (filter_class->set_caps) {
- if (!filter_class->set_caps (filter, incaps, outcaps))
- goto error;
- }
-
- gst_caps_replace (&filter->out_caps, outcaps);
-
- GST_DEBUG_OBJECT (filter, "set_caps %dx%d in %" GST_PTR_FORMAT
- " out %" GST_PTR_FORMAT,
- GST_VIDEO_INFO_WIDTH (&filter->out_info),
- GST_VIDEO_INFO_HEIGHT (&filter->out_info), incaps, outcaps);
-
- return GST_BASE_TRANSFORM_CLASS (parent_class)->set_caps (bt, incaps,
- outcaps);
-
-/* ERRORS */
-wrong_caps:
- {
- GST_WARNING ("Wrong caps");
- return FALSE;
- }
-error:
- {
- return FALSE;
- }
-}
-
-static gboolean
-gst_gl_filter_propose_allocation (GstBaseTransform * trans,
- GstQuery * decide_query, GstQuery * query)
-{
- GstGLFilter *filter = GST_GL_FILTER (trans);
- GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
- GstCaps *caps;
- GstVideoInfo info;
- guint size;
- GstBufferPool *pool = NULL;
- gboolean need_pool;
-
- gst_query_parse_allocation (query, &caps, &need_pool);
-
- if (caps == NULL)
- goto no_caps;
-
- if (!gst_video_info_from_caps (&info, caps))
- goto invalid_caps;
-
- /* the normal size of a frame */
- size = info.size;
-
- if (need_pool) {
- GstStructure *config;
-
- GST_DEBUG_OBJECT (filter, "create new pool");
- pool = gst_gl_buffer_pool_new (context);
-
- config = gst_buffer_pool_get_config (pool);
- gst_buffer_pool_config_set_params (config, caps, size, 0, 0);
-
- if (!gst_buffer_pool_set_config (pool, config)) {
- g_object_unref (pool);
- goto config_failed;
- }
- }
-
- gst_query_add_allocation_pool (query, pool, size, 1, 0);
- if (pool)
- g_object_unref (pool);
-
- if (context->gl_vtable->FenceSync)
- gst_query_add_allocation_meta (query, GST_GL_SYNC_META_API_TYPE, 0);
-
- return TRUE;
-
- /* ERRORS */
-no_caps:
- {
- GST_DEBUG_OBJECT (trans, "no caps specified");
- return FALSE;
- }
-invalid_caps:
- {
- GST_DEBUG_OBJECT (trans, "invalid caps specified");
- return FALSE;
- }
-config_failed:
- {
- GST_DEBUG_OBJECT (trans, "failed setting config");
- return FALSE;
- }
-}
-
-static gboolean
-gst_gl_filter_decide_allocation (GstBaseTransform * trans, GstQuery * query)
-{
- GstGLContext *context;
- GstBufferPool *pool = NULL;
- GstStructure *config;
- GstCaps *caps;
- guint min, max, size;
- gboolean update_pool;
-
- gst_query_parse_allocation (query, &caps, NULL);
- if (!caps)
- return FALSE;
-
- /* get gl context */
- if (!GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans,
- query))
- return FALSE;
-
- context = GST_GL_BASE_FILTER (trans)->context;
-
- if (gst_query_get_n_allocation_pools (query) > 0) {
- gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
-
- update_pool = TRUE;
- } else {
- GstVideoInfo vinfo;
-
- gst_video_info_init (&vinfo);
- gst_video_info_from_caps (&vinfo, caps);
- size = vinfo.size;
- min = max = 0;
- update_pool = FALSE;
- }
-
- if (!pool || !GST_IS_GL_BUFFER_POOL (pool)) {
- if (pool)
- gst_object_unref (pool);
- pool = gst_gl_buffer_pool_new (context);
- }
-
- config = gst_buffer_pool_get_config (pool);
-
- gst_buffer_pool_config_set_params (config, caps, size, min, max);
- gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
- if (gst_query_find_allocation_meta (query, GST_GL_SYNC_META_API_TYPE, NULL))
- gst_buffer_pool_config_add_option (config,
- GST_BUFFER_POOL_OPTION_GL_SYNC_META);
-
- gst_buffer_pool_set_config (pool, config);
-
- if (update_pool)
- gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
- else
- gst_query_add_allocation_pool (query, pool, size, min, max);
-
- gst_object_unref (pool);
-
- return TRUE;
-}
-
-/**
- * gst_gl_filter_filter_texture:
- * @filter: a #GstGLFilter
- * @inbuf: an input buffer
- * @outbuf: an output buffer
- *
- * Calls filter_texture vfunc with correctly mapped #GstGLMemorys
- *
- * Returns: whether the transformation succeeded
- *
- * Since: 1.4
- */
-gboolean
-gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf)
-{
- GstGLFilterClass *filter_class;
- GstMemory *in_tex, *out_tex;
- GstVideoFrame gl_frame, out_frame;
- gboolean ret;
-
- filter_class = GST_GL_FILTER_GET_CLASS (filter);
-
- if (!gst_video_frame_map (&gl_frame, &filter->in_info, inbuf,
- GST_MAP_READ | GST_MAP_GL)) {
- ret = FALSE;
- goto inbuf_error;
- }
-
- in_tex = gl_frame.map[0].memory;
- if (!gst_is_gl_memory (in_tex)) {
- ret = FALSE;
- GST_ERROR_OBJECT (filter, "Input memory must be GstGLMemory");
- goto unmap_out_error;
- }
-
- if (!gst_video_frame_map (&out_frame, &filter->out_info, outbuf,
- GST_MAP_WRITE | GST_MAP_GL)) {
- ret = FALSE;
- goto unmap_out_error;
- }
-
- out_tex = out_frame.map[0].memory;
- g_return_val_if_fail (gst_is_gl_memory (out_tex), FALSE);
-
- GST_DEBUG ("calling filter_texture with textures in:%i out:%i",
- GST_GL_MEMORY_CAST (in_tex)->tex_id,
- GST_GL_MEMORY_CAST (out_tex)->tex_id);
-
- g_assert (filter_class->filter_texture);
-
- ret = filter_class->filter_texture (filter, GST_GL_MEMORY_CAST (in_tex),
- GST_GL_MEMORY_CAST (out_tex));
-
- gst_video_frame_unmap (&out_frame);
-unmap_out_error:
- gst_video_frame_unmap (&gl_frame);
-inbuf_error:
-
- return ret;
-}
-
-static void
-_filter_gl (GstGLContext * context, GstGLFilter * filter)
-{
- GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
-
- gst_gl_insert_debug_marker (context,
- "processing in element %s", GST_OBJECT_NAME (filter));
-
- if (filter_class->filter)
- filter->gl_result =
- filter_class->filter (filter, filter->inbuf, filter->outbuf);
- else
- filter->gl_result =
- gst_gl_filter_filter_texture (filter, filter->inbuf, filter->outbuf);
-}
-
-static GstFlowReturn
-gst_gl_filter_transform (GstBaseTransform * bt, GstBuffer * inbuf,
- GstBuffer * outbuf)
-{
- GstGLFilter *filter = GST_GL_FILTER (bt);
- GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (bt);
- GstGLDisplay *display = GST_GL_BASE_FILTER (bt)->display;
- GstGLContext *context = GST_GL_BASE_FILTER (bt)->context;
- GstGLSyncMeta *out_sync_meta, *in_sync_meta;
- gboolean ret;
-
- if (!display)
- return GST_FLOW_NOT_NEGOTIATED;
-
- g_assert (filter_class->filter || filter_class->filter_texture);
-
- in_sync_meta = gst_buffer_get_gl_sync_meta (inbuf);
- if (in_sync_meta)
- gst_gl_sync_meta_wait (in_sync_meta, context);
-
- filter->inbuf = inbuf;
- filter->outbuf = outbuf;
- gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _filter_gl,
- filter);
- ret = filter->gl_result;
-
- out_sync_meta = gst_buffer_get_gl_sync_meta (outbuf);
- if (out_sync_meta)
- gst_gl_sync_meta_set_sync_point (out_sync_meta, context);
-
- return ret ? GST_FLOW_OK : GST_FLOW_ERROR;
-}
-
-struct glcb
-{
- GstGLFilter *filter;
- GstGLFilterRenderFunc func;
- GstGLMemory *in_tex;
- gpointer data;
-};
-
-static gboolean
-_glcb (gpointer data)
-{
- struct glcb *cb = data;
-
- return cb->func (cb->filter, cb->in_tex, cb->data);
-}
-
-/**
- * gst_gl_filter_render_to_target:
- * @filter: a #GstGLFilter
- * @input: the input texture
- * @output: the output texture
- * @func: (scope call): the function to transform @input into @output. called with @data
- * @data: (allow-none): the data associated with @func
- *
- * Transforms @input into @output using @func on through FBO.
- *
- * Returns: the return value of @func
- *
- * Since: 1.10
- */
-gboolean
-gst_gl_filter_render_to_target (GstGLFilter * filter, GstGLMemory * input,
- GstGLMemory * output, GstGLFilterRenderFunc func, gpointer data)
-{
- struct glcb cb;
-
- cb.filter = filter;
- cb.func = func;
- cb.in_tex = input;
- cb.data = data;
-
- return gst_gl_framebuffer_draw_to_texture (filter->fbo, output, _glcb, &cb);
-}
-
-static void
-_get_attributes (GstGLFilter * filter)
-{
- if (!filter->default_shader)
- return;
-
- if (filter->valid_attributes)
- return;
-
- if (filter->draw_attr_position_loc == -1)
- filter->draw_attr_position_loc =
- gst_gl_shader_get_attribute_location (filter->default_shader,
- "a_position");
-
- if (filter->draw_attr_texture_loc == -1)
- filter->draw_attr_texture_loc =
- gst_gl_shader_get_attribute_location (filter->default_shader,
- "a_texcoord");
-
- filter->valid_attributes = TRUE;
-}
-
-static gboolean
-_draw_with_shader_cb (GstGLFilter * filter, GstGLMemory * in_tex,
- gpointer unused)
-{
- GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
- GstGLFuncs *gl = context->gl_vtable;
-
-#if GST_GL_HAVE_OPENGL
- if (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL) {
- gl->MatrixMode (GL_PROJECTION);
- gl->LoadIdentity ();
- }
-#endif
-
- _get_attributes (filter);
- gst_gl_shader_use (filter->default_shader);
-
- gl->ActiveTexture (GL_TEXTURE1);
- gl->BindTexture (GL_TEXTURE_2D, gst_gl_memory_get_texture_id (in_tex));
-
- gst_gl_shader_set_uniform_1i (filter->default_shader, "tex", 1);
- gst_gl_shader_set_uniform_1f (filter->default_shader, "width",
- GST_VIDEO_INFO_WIDTH (&filter->out_info));
- gst_gl_shader_set_uniform_1f (filter->default_shader, "height",
- GST_VIDEO_INFO_HEIGHT (&filter->out_info));
-
- gst_gl_filter_draw_fullscreen_quad (filter);
-
- return TRUE;
-}
-
-/**
- * gst_gl_filter_render_to_target_with_shader:
- * @filter: a #GstGLFilter
- * @input: the input texture
- * @output: the output texture
- * @shader: the shader to use.
- *
- * Transforms @input into @output using @shader with a FBO.
- *
- * See also: gst_gl_filter_render_to_target()
- *
- * Since: 1.4
- */
-/* attach target to a FBO, use shader, pass input as "tex" uniform to
- * the shader, render input to a quad */
-void
-gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter,
- GstGLMemory * input, GstGLMemory * output, GstGLShader * shader)
-{
- if (filter->default_shader != shader)
- filter->valid_attributes = FALSE;
- filter->default_shader = shader;
-
- gst_gl_filter_render_to_target (filter, input, output, _draw_with_shader_cb,
- NULL);
-}
-
-/* *INDENT-OFF* */
-static const GLfloat vertices[] = {
- -1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
- 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
- 1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
- -1.0f, 1.0f, 0.0f, 0.0f, 1.0f
-};
-
-static const GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
-/* *INDENT-ON* */
-
-static void
-_bind_buffer (GstGLFilter * filter)
-{
- GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
- const GstGLFuncs *gl = context->gl_vtable;
-
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, filter->vbo_indices);
- gl->BindBuffer (GL_ARRAY_BUFFER, filter->vertex_buffer);
-
- _get_attributes (filter);
- /* Load the vertex position */
- gl->VertexAttribPointer (filter->draw_attr_position_loc, 3, GL_FLOAT,
- GL_FALSE, 5 * sizeof (GLfloat), (void *) 0);
-
- /* Load the texture coordinate */
- gl->VertexAttribPointer (filter->draw_attr_texture_loc, 2, GL_FLOAT, GL_FALSE,
- 5 * sizeof (GLfloat), (void *) (3 * sizeof (GLfloat)));
-
-
- gl->EnableVertexAttribArray (filter->draw_attr_position_loc);
- gl->EnableVertexAttribArray (filter->draw_attr_texture_loc);
-}
-
-static void
-_unbind_buffer (GstGLFilter * filter)
-{
- GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
- const GstGLFuncs *gl = context->gl_vtable;
-
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
- gl->BindBuffer (GL_ARRAY_BUFFER, 0);
-
- gl->DisableVertexAttribArray (filter->draw_attr_position_loc);
- gl->DisableVertexAttribArray (filter->draw_attr_texture_loc);
-}
-
-/**
- * gst_gl_filter_draw_fullscreen_quad:
- * @filter: a #GstGLFilter
- *
- * Render a fullscreen quad using the current GL state. The only GL state this
- * modifies is the necessary vertex/index buffers and, if necessary, a
- * Vertex Array Object for drawing a fullscreen quad. Framebuffer state,
- * any shaders, viewport state, etc must be setup by the caller.
- *
- * Since: 1.10
- */
-void
-gst_gl_filter_draw_fullscreen_quad (GstGLFilter * filter)
-{
- GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
- GstGLFuncs *gl = context->gl_vtable;
-
- {
- if (!filter->vertex_buffer) {
- if (gl->GenVertexArrays) {
- gl->GenVertexArrays (1, &filter->vao);
- gl->BindVertexArray (filter->vao);
- }
-
- gl->GenBuffers (1, &filter->vertex_buffer);
- gl->BindBuffer (GL_ARRAY_BUFFER, filter->vertex_buffer);
- gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), vertices,
- GL_STATIC_DRAW);
-
- gl->GenBuffers (1, &filter->vbo_indices);
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, filter->vbo_indices);
- gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
- GL_STATIC_DRAW);
- }
-
- if (gl->GenVertexArrays)
- gl->BindVertexArray (filter->vao);
- _bind_buffer (filter);
-
- gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
-
- if (gl->GenVertexArrays)
- gl->BindVertexArray (0);
- _unbind_buffer (filter);
- }
-}
diff --git a/gst-libs/gst/gl/gstglfilter.h b/gst-libs/gst/gl/gstglfilter.h
deleted file mode 100644
index fc1928b9d..000000000
--- a/gst-libs/gst/gl/gstglfilter.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2007 David Schleef <ds@schleef.org>
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_GL_FILTER_H_
-#define _GST_GL_FILTER_H_
-
-#include <gst/gst.h>
-#include <gst/video/video.h>
-
-#include <gst/gl/gl.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GType gst_gl_filter_get_type(void);
-#define GST_TYPE_GL_FILTER (gst_gl_filter_get_type())
-#define GST_GL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_FILTER,GstGLFilter))
-#define GST_IS_GL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_FILTER))
-#define GST_GL_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_GL_FILTER,GstGLFilterClass))
-#define GST_IS_GL_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_GL_FILTER))
-#define GST_GL_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_GL_FILTER,GstGLFilterClass))
-
-/**
- * GstGLFilterRenderFunc:
- * @filter: the #GstGLFIlter
- * @in_tex: the input #GstGLMemory to render
- * @user_data: user data
- *
- * Returns: whether the render succeeded
- *
- * Since: 1.10
- */
-typedef gboolean (*GstGLFilterRenderFunc) (GstGLFilter * filter, GstGLMemory * in_tex, gpointer user_data);
-
-/**
- * GstGLFilter:
- * @parent: parent #GstGLBaseFilter
- * @in_info: the video info for input buffers
- * @out_info: the video info for output buffers
- * @out_caps: the output #GstCaps
- * @fbo: #GstGLFramebuffer object used for transformations
- */
-struct _GstGLFilter
-{
- GstGLBaseFilter parent;
-
- GstVideoInfo in_info;
- GstVideoInfo out_info;
-
- GstCaps *out_caps;
-
- /* <protected> */
- GstGLFramebuffer *fbo;
-
- /* <private> */
- gboolean gl_result;
- GstBuffer *inbuf;
- GstBuffer *outbuf;
-
- GstGLShader *default_shader;
- gboolean valid_attributes;
-
- guint vao;
- guint vbo_indices;
- guint vertex_buffer;
- gint draw_attr_position_loc;
- gint draw_attr_texture_loc;
-
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GstGLFilterClass:
- * @parent_class: parent #GstGLBaseFilterClass
- * @set_caps: mirror from #GstBaseTransform
- * @filter: perform operations on the input and output buffers. In general,
- * you should avoid using this method if at all possible. One valid
- * use-case for using this is keeping previous buffers for future calculations.
- * Note: If @filter exists, then @filter_texture is not run
- * @filter_texture: given @in_tex, transform it into @out_tex. Not used
- * if @filter exists
- * @init_fbo: perform initialization when the Framebuffer object is created
- * @transform_internal_caps: Perform sub-class specific modifications of the
- * caps to be processed between upload on input and before download for output.
- */
-struct _GstGLFilterClass
-{
- GstGLBaseFilterClass parent_class;
-
- gboolean (*set_caps) (GstGLFilter* filter, GstCaps* incaps, GstCaps* outcaps);
- gboolean (*filter) (GstGLFilter *filter, GstBuffer *inbuf, GstBuffer *outbuf);
- gboolean (*filter_texture) (GstGLFilter *filter, GstGLMemory *in_tex, GstGLMemory *out_tex);
- gboolean (*init_fbo) (GstGLFilter *filter);
-
- GstCaps *(*transform_internal_caps) (GstGLFilter *filter,
- GstPadDirection direction, GstCaps * caps, GstCaps * filter_caps);
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-void gst_gl_filter_add_rgba_pad_templates (GstGLFilterClass *klass);
-
-GST_EXPORT
-gboolean gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf);
-
-GST_EXPORT
-gboolean gst_gl_filter_render_to_target (GstGLFilter *filter,
- GstGLMemory * input,
- GstGLMemory * output,
- GstGLFilterRenderFunc func,
- gpointer data);
-
-GST_EXPORT
-void gst_gl_filter_draw_fullscreen_quad (GstGLFilter *filter);
-GST_EXPORT
-void gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter,
- GstGLMemory * input,
- GstGLMemory * output,
- GstGLShader *shader);
-
-G_END_DECLS
-
-#endif /* _GST_GL_FILTER_H_ */
diff --git a/gst-libs/gst/gl/gstglformat.c b/gst-libs/gst/gl/gstglformat.c
deleted file mode 100644
index 8427be43f..000000000
--- a/gst-libs/gst/gl/gstglformat.c
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstglformat
- * @title: GstGLFormat
- * @short_description: utilities for dealing with OpenGL formats
- * @see_also: #GstGLBaseMemory, #GstGLMemory, #GstGLFramebuffer, #GstGLBuffer
- *
- * Some useful utilities for converting between various formats and OpenGL
- * formats.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstglformat.h"
-
-#include "gstglcontext.h"
-#include "gstglfuncs.h"
-
-#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
-#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
-#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
-#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
-#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-
-#ifndef GL_TEXTURE_RECTANGLE
-#define GL_TEXTURE_RECTANGLE 0x84F5
-#endif
-#ifndef GL_TEXTURE_EXTERNAL_OES
-#define GL_TEXTURE_EXTERNAL_OES 0x8D65
-#endif
-
-static inline guint
-_gl_format_n_components (guint format)
-{
- switch (format) {
- case GST_VIDEO_GL_TEXTURE_TYPE_RGBA:
- case GST_GL_RGBA:
- return 4;
- case GST_VIDEO_GL_TEXTURE_TYPE_RGB:
- case GST_VIDEO_GL_TEXTURE_TYPE_RGB16:
- case GST_GL_RGB:
- case GST_GL_RGB565:
- return 3;
- case GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA:
- case GST_VIDEO_GL_TEXTURE_TYPE_RG:
- case GST_GL_LUMINANCE_ALPHA:
- case GST_GL_RG:
- return 2;
- case GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE:
- case GST_VIDEO_GL_TEXTURE_TYPE_R:
- case GST_GL_LUMINANCE:
- case GST_GL_RED:
- return 1;
- default:
- return 0;
- }
-}
-
-static inline guint
-_gl_type_n_components (guint type)
-{
- switch (type) {
- case GL_UNSIGNED_BYTE:
- return 1;
- case GL_UNSIGNED_SHORT_5_6_5:
- return 3;
- default:
- g_assert_not_reached ();
- return 0;
- }
-}
-
-static inline guint
-_gl_type_n_bytes (guint type)
-{
- switch (type) {
- case GL_UNSIGNED_BYTE:
- return 1;
- case GL_UNSIGNED_SHORT_5_6_5:
- return 2;
- default:
- g_assert_not_reached ();
- return 0;
- }
-}
-
-/**
- * gst_gl_format_type_n_bytes:
- * @format: the OpenGL format, %GL_RGBA, %GL_LUMINANCE, etc
- * @type: the OpenGL type, %GL_UNSIGNED_BYTE, %GL_FLOAT, etc
- *
- * Returns: the number of bytes the specified @format, @type combination takes
- * per pixel
- */
-guint
-gst_gl_format_type_n_bytes (guint format, guint type)
-{
- return _gl_format_n_components (format) / _gl_type_n_components (type) *
- _gl_type_n_bytes (type);
-}
-
-/**
- * gst_gl_format_from_video_info:
- * @context: a #GstGLContext
- * @vinfo: a #GstVideoInfo
- * @plane: the plane number in @vinfo
- *
- * Returns: the #GstGLFormat necessary for holding the data in @plane of @vinfo
- */
-GstGLFormat
-gst_gl_format_from_video_info (GstGLContext * context, GstVideoInfo * vinfo,
- guint plane)
-{
- gboolean texture_rg =
- gst_gl_context_check_feature (context, "GL_EXT_texture_rg")
- || gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0)
- || gst_gl_context_check_feature (context, "GL_ARB_texture_rg")
- || gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 0);
- GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (vinfo);
- guint n_plane_components;
-
- switch (v_format) {
- case GST_VIDEO_FORMAT_RGBx:
- case GST_VIDEO_FORMAT_BGRx:
- case GST_VIDEO_FORMAT_xRGB:
- case GST_VIDEO_FORMAT_xBGR:
- case GST_VIDEO_FORMAT_RGBA:
- case GST_VIDEO_FORMAT_BGRA:
- case GST_VIDEO_FORMAT_ARGB:
- case GST_VIDEO_FORMAT_ABGR:
- case GST_VIDEO_FORMAT_AYUV:
- n_plane_components = 4;
- break;
- case GST_VIDEO_FORMAT_RGB:
- case GST_VIDEO_FORMAT_BGR:
- n_plane_components = 3;
- break;
- case GST_VIDEO_FORMAT_RGB16:
- case GST_VIDEO_FORMAT_BGR16:
- return GST_GL_RGB565;
- case GST_VIDEO_FORMAT_GRAY16_BE:
- case GST_VIDEO_FORMAT_GRAY16_LE:
- case GST_VIDEO_FORMAT_YUY2:
- case GST_VIDEO_FORMAT_UYVY:
- n_plane_components = 2;
- break;
- case GST_VIDEO_FORMAT_NV12:
- case GST_VIDEO_FORMAT_NV21:
- n_plane_components = plane == 0 ? 1 : 2;
- break;
- case GST_VIDEO_FORMAT_GRAY8:
- case GST_VIDEO_FORMAT_Y444:
- case GST_VIDEO_FORMAT_Y42B:
- case GST_VIDEO_FORMAT_Y41B:
- case GST_VIDEO_FORMAT_I420:
- case GST_VIDEO_FORMAT_YV12:
- n_plane_components = 1;
- break;
- default:
- n_plane_components = 4;
- g_assert_not_reached ();
- break;
- }
-
- switch (n_plane_components) {
- case 4:
- return GST_GL_RGBA;
- break;
- case 3:
- return GST_GL_RGB;
- break;
- case 2:
- return texture_rg ? GST_GL_RG : GST_GL_LUMINANCE_ALPHA;
- break;
- case 1:
- return texture_rg ? GST_GL_RED : GST_GL_LUMINANCE;
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- return GST_GL_RGBA;
-}
-
-/**
- * gst_gl_sized_gl_format_from_gl_format_type:
- * @context: a #GstGLContext
- * @format: an OpenGL format, %GL_RGBA, %GL_LUMINANCE, etc
- * @type: an OpenGL type, %GL_UNSIGNED_BYTE, %GL_FLOAT, etc
- *
- * Returns: the sized internal format specified by @format and @type that can
- * be used in @context
- */
-guint
-gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context,
- guint format, guint type)
-{
- gboolean ext_texture_rg =
- gst_gl_context_check_feature (context, "GL_EXT_texture_rg");
-
- switch (format) {
- case GST_GL_RGBA:
- switch (type) {
- case GL_UNSIGNED_BYTE:
- return USING_GLES2 (context)
- && !USING_GLES3 (context) ? GST_GL_RGBA : GST_GL_RGBA8;
- break;
- }
- break;
- case GST_GL_RGB:
- switch (type) {
- case GL_UNSIGNED_BYTE:
- return USING_GLES2 (context)
- && !USING_GLES3 (context) ? GST_GL_RGB : GST_GL_RGB8;
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- return GST_GL_RGB565;
- break;
- }
- break;
- case GST_GL_RG:
- switch (type) {
- case GL_UNSIGNED_BYTE:
- if (!USING_GLES3 (context) && USING_GLES2 (context) && ext_texture_rg)
- return GST_GL_RG;
- return GST_GL_RG8;
- break;
- }
- break;
- case GST_GL_RED:
- switch (type) {
- case GL_UNSIGNED_BYTE:
- if (!USING_GLES3 (context) && USING_GLES2 (context) && ext_texture_rg)
- return GST_GL_RED;
- return GST_GL_R8;
- break;
- }
- break;
- case GST_GL_RGBA8:
- case GST_GL_RGB8:
- case GST_GL_RGB565:
- case GST_GL_RG8:
- case GST_GL_R8:
- case GST_GL_LUMINANCE:
- case GST_GL_LUMINANCE_ALPHA:
- case GST_GL_ALPHA:
- case GST_GL_DEPTH_COMPONENT16:
- case GST_GL_DEPTH24_STENCIL8:
- return format;
- default:
- break;
- }
-
- g_assert_not_reached ();
- return 0;
-}
-
-/**
- * gst_gl_texture_target_to_string:
- * @target: a #GstGLTextureTarget
- *
- * Returns: the stringified version of @target or %NULL
- */
-const gchar *
-gst_gl_texture_target_to_string (GstGLTextureTarget target)
-{
- switch (target) {
- case GST_GL_TEXTURE_TARGET_2D:
- return GST_GL_TEXTURE_TARGET_2D_STR;
- case GST_GL_TEXTURE_TARGET_RECTANGLE:
- return GST_GL_TEXTURE_TARGET_RECTANGLE_STR;
- case GST_GL_TEXTURE_TARGET_EXTERNAL_OES:
- return GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR;
- default:
- return NULL;
- }
-}
-
-/**
- * gst_gl_texture_target_from_string:
- * @str: a string equivalant to one of the GST_GL_TEXTURE_TARGET_*_STR values
- *
- * Returns: the #GstGLTextureTarget represented by @str or
- * %GST_GL_TEXTURE_TARGET_NONE
- */
-GstGLTextureTarget
-gst_gl_texture_target_from_string (const gchar * str)
-{
- if (!str)
- return GST_GL_TEXTURE_TARGET_NONE;
-
- if (g_strcmp0 (str, GST_GL_TEXTURE_TARGET_2D_STR) == 0)
- return GST_GL_TEXTURE_TARGET_2D;
- if (g_strcmp0 (str, GST_GL_TEXTURE_TARGET_RECTANGLE_STR) == 0)
- return GST_GL_TEXTURE_TARGET_RECTANGLE;
- if (g_strcmp0 (str, GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR) == 0)
- return GST_GL_TEXTURE_TARGET_EXTERNAL_OES;
-
- return GST_GL_TEXTURE_TARGET_NONE;
-}
-
-/**
- * gst_gl_texture_target_to_gl:
- * @target: a #GstGLTextureTarget
- *
- * Returns: the OpenGL value for binding the @target with glBindTexture() and
- * similar functions or 0
- */
-guint
-gst_gl_texture_target_to_gl (GstGLTextureTarget target)
-{
- switch (target) {
- case GST_GL_TEXTURE_TARGET_2D:
- return GL_TEXTURE_2D;
- case GST_GL_TEXTURE_TARGET_RECTANGLE:
- return GL_TEXTURE_RECTANGLE;
- case GST_GL_TEXTURE_TARGET_EXTERNAL_OES:
- return GL_TEXTURE_EXTERNAL_OES;
- default:
- return 0;
- }
-}
-
-/**
- * gst_gl_texture_target_from_gl:
- * @target: an OpenGL texture binding target
- *
- * Returns: the #GstGLTextureTarget that's equiavalant to @target or
- * %GST_GL_TEXTURE_TARGET_NONE
- */
-GstGLTextureTarget
-gst_gl_texture_target_from_gl (guint target)
-{
- switch (target) {
- case GL_TEXTURE_2D:
- return GST_GL_TEXTURE_TARGET_2D;
- case GL_TEXTURE_RECTANGLE:
- return GST_GL_TEXTURE_TARGET_RECTANGLE;
- case GL_TEXTURE_EXTERNAL_OES:
- return GST_GL_TEXTURE_TARGET_EXTERNAL_OES;
- default:
- return GST_GL_TEXTURE_TARGET_NONE;
- }
-}
-
-/**
- * gst_gl_texture_target_to_buffer_pool_option:
- * @target: a #GstGLTextureTarget
- *
- * Returns: a string representing the @GstBufferPoolOption specified by @target
- */
-const gchar *
-gst_gl_texture_target_to_buffer_pool_option (GstGLTextureTarget target)
-{
- switch (target) {
- case GST_GL_TEXTURE_TARGET_2D:
- return GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_2D;
- case GST_GL_TEXTURE_TARGET_RECTANGLE:
- return GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_RECTANGLE;
- case GST_GL_TEXTURE_TARGET_EXTERNAL_OES:
- return GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_EXTERNAL_OES;
- default:
- return NULL;
- }
-}
diff --git a/gst-libs/gst/gl/gstglformat.h b/gst-libs/gst/gl/gstglformat.h
deleted file mode 100644
index 2bd667da6..000000000
--- a/gst-libs/gst/gl/gstglformat.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_GL_FORMAT_H_
-#define _GST_GL_FORMAT_H_
-
-#include <gst/gst.h>
-
-#include <gst/gl/gstgl_fwd.h>
-#include <gst/video/video.h>
-
-/**
- * GST_GL_TEXTURE_TARGET_2D_STR:
- *
- * String used for %GST_GL_TEXTURE_TARGET_2D in things like caps values
- */
-#define GST_GL_TEXTURE_TARGET_2D_STR "2D"
-
-/**
- * GST_GL_TEXTURE_TARGET_RECTANGLE_STR:
- *
- * String used for %GST_GL_TEXTURE_TARGET_RECTANGLE in things like caps values
- */
-#define GST_GL_TEXTURE_TARGET_RECTANGLE_STR "rectangle"
-
-/**
- * GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR:
- *
- * String used for %GST_GL_TEXTURE_TARGET_EXTERNAL_OES in things like caps values
- */
-#define GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR "external-oes"
-
-/**
- * GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_2D:
- *
- * String used for %GST_GL_TEXTURE_TARGET_2D as a #GstBufferPool pool option
- */
-#define GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_2D "GstBufferPoolOptionGLTextureTarget2D"
-
-/**
- * GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_RECTANGLE:
- *
- * String used for %GST_GL_TEXTURE_TARGET_RECTANGLE as a #GstBufferPool pool option
- */
-#define GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_RECTANGLE "GstBufferPoolOptionGLTextureTargetRectangle"
-
-/**
- * GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_EXTERNAL_OES:
- *
- * String used for %GST_GL_TEXTURE_TARGET_EXTERNAL_OES as a #GstBufferPool pool option
- */
-#define GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_EXTERNAL_OES "GstBufferPoolOptionGLTextureTargetExternalOES"
-
-G_BEGIN_DECLS
-
-/**
- * GstGLFormat:
- * @GST_GL_LUMINANCE: Single component replicated across R, G, and B textures
- * components
- * @GST_GL_ALPHA: Single component stored in the A texture component
- * @GST_GL_LUMINANCE_ALPHA: Combination of #GST_GL_LUMINANCE and #GST_GL_ALPHA
- * @GST_GL_RED: Single component stored in the R texture component
- * @GST_GL_R8: Single 8-bit component stored in the R texture component
- * @GST_GL_RG: Two components stored in the R and G texture components
- * @GST_GL_RG8: Two 8-bit components stored in the R and G texture components
- * @GST_GL_RGB: Three components stored in the R, G, and B texture components
- * @GST_GL_RGB8: Three 8-bit components stored in the R, G, and B
- * texture components
- * @GST_GL_RGB565: Three components of bit depth 5, 6 and 5 stored in the R, G,
- * and B texture components respectively.
- * @GST_GL_RGBA: Four components stored in the R, G, B, and A texture
- * components respectively.
- * @GST_GL_RGBA8: Four 8-bit components stored in the R, G, B, and A texture
- * components respectively.
- * @GST_GL_DEPTH_COMPONENT16: A single 16-bit component for depth information.
- * @GST_GL_DEPTH24_STENCIL8: A 24-bit component for depth information and
- * a 8-bit component for stencil informat.
- */
-typedef enum
-{
- /* values taken from the GL headers */
- GST_GL_LUMINANCE = 0x1909,
-
- GST_GL_ALPHA = 0x1906,
-
- GST_GL_LUMINANCE_ALPHA = 0x190A,
-
- GST_GL_RED = 0x1903,
- GST_GL_R8 = 0x8229,
-
- GST_GL_RG = 0x8227,
- GST_GL_RG8 = 0x822B,
-
- GST_GL_RGB = 0x1907,
- GST_GL_RGB8 = 0x8051,
- GST_GL_RGB565 = 0x8D62,
-
- GST_GL_RGBA = 0x1908,
- GST_GL_RGBA8 = 0x8058,
-
- GST_GL_DEPTH_COMPONENT16 = 0x81A5,
-
- GST_GL_DEPTH24_STENCIL8 = 0x88F0,
-} GstGLFormat;
-
-GST_EXPORT
-guint gst_gl_format_type_n_bytes (guint format,
- guint type);
-GST_EXPORT
-GstGLFormat gst_gl_format_from_video_info (GstGLContext * context,
- GstVideoInfo * vinfo,
- guint plane);
-GST_EXPORT
-guint gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context,
- guint format,
- guint type);
-
-GST_EXPORT
-GstGLTextureTarget gst_gl_texture_target_from_string (const gchar * str);
-GST_EXPORT
-const gchar * gst_gl_texture_target_to_string (GstGLTextureTarget target);
-GST_EXPORT
-guint gst_gl_texture_target_to_gl (GstGLTextureTarget target);
-GST_EXPORT
-GstGLTextureTarget gst_gl_texture_target_from_gl (guint target);
-GST_EXPORT
-const gchar * gst_gl_texture_target_to_buffer_pool_option (GstGLTextureTarget target);
-
-G_END_DECLS
-
-#endif /* _GST_GL_FORMAT_H_ */
diff --git a/gst-libs/gst/gl/gstglframebuffer.c b/gst-libs/gst/gl/gstglframebuffer.c
deleted file mode 100644
index b1d64b288..000000000
--- a/gst-libs/gst/gl/gstglframebuffer.c
+++ /dev/null
@@ -1,579 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstglframebuffer
- * @short_description: OpenGL framebuffer abstraction
- * @title: GstGLFramebuffer
- * @see_also: #GstGLBaseMemory, #GstGLMemory, #GstGLContext
- *
- * A #GstGLFramebuffer represents and holds an OpenGL framebuffer object with
- * it's associated attachments.
- *
- * A #GstGLFramebuffer can be created with gst_gl_framebuffer_new() or
- * gst_gl_framebuffer_new_with_default_depth() and bound with
- * gst_gl_framebuffer_bind(). Other resources can be bound with
- * gst_gl_framebuffer_attach()
- *
- * Note: OpenGL framebuffers are not shareable resources so cannot be used
- * between multiple OpenGL contexts.
- *
- * Since: 1.10
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstglframebuffer.h"
-
-#include "gstglcontext.h"
-#include "gstglfuncs.h"
-#include "gstglmemory.h"
-#include "gstglrenderbuffer.h"
-
-#ifndef GL_FRAMEBUFFER_UNDEFINED
-#define GL_FRAMEBUFFER_UNDEFINED 0x8219
-#endif
-#ifndef GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
-#endif
-#ifndef GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
-#endif
-#ifndef GL_FRAMEBUFFER_UNSUPPORTED
-#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
-#endif
-#ifndef GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS
-#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
-#endif
-
-#ifndef GL_DEPTH_STENCIL_ATTACHMENT
-#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
-#endif
-
-#ifndef GL_READ_FRAMEBUFFER
-#define GL_READ_FRAMEBUFFER 0x8CA8
-#endif
-#ifndef GL_DRAW_FRAMEBUFFER
-#define GL_DRAW_FRAMEBUFFER 0x8CA9
-#endif
-
-GST_DEBUG_CATEGORY_STATIC (gst_gl_framebuffer_debug);
-#define GST_CAT_DEFAULT gst_gl_framebuffer_debug
-
-#define DEBUG_INIT \
- GST_DEBUG_CATEGORY_INIT (gst_gl_framebuffer_debug, "glframebuffer", 0, "GL Framebuffer");
-
-G_DEFINE_TYPE_WITH_CODE (GstGLFramebuffer, gst_gl_framebuffer, GST_TYPE_OBJECT,
- DEBUG_INIT);
-
-#define GST_GL_FRAMEBUFFER_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_FRAMEBUFFER, GstGLFramebufferPrivate))
-
-static void gst_gl_framebuffer_finalize (GObject * object);
-
-struct _GstGLFramebufferPrivate
-{
- guint effective_width;
- guint effective_height;
-};
-
-struct fbo_attachment
-{
- guint attachment_point;
- GstGLBaseMemory *mem;
-};
-
-static void
-_fbo_attachment_init (struct fbo_attachment *attach, guint point,
- GstGLBaseMemory * mem)
-{
- attach->attachment_point = point;
- attach->mem = (GstGLBaseMemory *) gst_memory_ref (GST_MEMORY_CAST (mem));
-}
-
-static void
-_fbo_attachment_unset (struct fbo_attachment *attach)
-{
- if (!attach)
- return;
-
- if (attach->mem)
- gst_memory_unref (GST_MEMORY_CAST (attach->mem));
- attach->mem = NULL;
-}
-
-static void
-gst_gl_framebuffer_class_init (GstGLFramebufferClass * klass)
-{
- g_type_class_add_private (klass, sizeof (GstGLFramebufferPrivate));
-
- G_OBJECT_CLASS (klass)->finalize = gst_gl_framebuffer_finalize;
-}
-
-static void
-gst_gl_framebuffer_init (GstGLFramebuffer * fb)
-{
- fb->priv = GST_GL_FRAMEBUFFER_GET_PRIVATE (fb);
-
- fb->attachments =
- g_array_new (FALSE, FALSE, (sizeof (struct fbo_attachment)));
- g_array_set_clear_func (fb->attachments,
- (GDestroyNotify) _fbo_attachment_unset);
-}
-
-static void
-_delete_fbo_gl (GstGLContext * context, GstGLFramebuffer * fb)
-{
- const GstGLFuncs *gl = context->gl_vtable;
-
- if (fb->fbo_id)
- gl->DeleteFramebuffers (1, &fb->fbo_id);
- fb->fbo_id = 0;
-}
-
-static void
-gst_gl_framebuffer_finalize (GObject * object)
-{
- GstGLFramebuffer *fb = GST_GL_FRAMEBUFFER (object);
-
- if (fb->context) {
- if (fb->fbo_id)
- gst_gl_context_thread_add (fb->context,
- (GstGLContextThreadFunc) _delete_fbo_gl, fb);
-
- gst_object_unref (fb->context);
- fb->context = NULL;
- }
-
- if (fb->attachments)
- g_array_free (fb->attachments, TRUE);
- fb->attachments = NULL;
-
- G_OBJECT_CLASS (gst_gl_framebuffer_parent_class)->finalize (object);
-}
-
-/**
- * gst_gl_framebuffer_new:
- * @context: a #GstGLContext
- *
- * Returns: (transfer full): a new #GstGLFramebuffer
- *
- * Since: 1.10
- */
-GstGLFramebuffer *
-gst_gl_framebuffer_new (GstGLContext * context)
-{
- GstGLFramebuffer *fb;
- const GstGLFuncs *gl;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), NULL);
- g_return_val_if_fail (gst_gl_context_get_current () == context, NULL);
-
- gl = context->gl_vtable;
-
- if (!gl->GenFramebuffers) {
- GST_ERROR_OBJECT (context, "Framebuffers are not supported!");
- return NULL;
- }
-
- fb = g_object_new (GST_TYPE_GL_FRAMEBUFFER, NULL);
- fb->context = gst_object_ref (context);
- gl->GenFramebuffers (1, &fb->fbo_id);
- gst_object_ref_sink (fb);
-
- return fb;
-}
-
-/**
- * gst_gl_framebuffer_new_with_default_depth:
- * @context: a #GstGLContext
- * @width: width for the depth buffer
- * @height: for the depth buffer
- *
- * Returns: a new #GstGLFramebuffer with a depth buffer of @width and @height
- *
- * Since: 1.10
- */
-GstGLFramebuffer *
-gst_gl_framebuffer_new_with_default_depth (GstGLContext * context, guint width,
- guint height)
-{
- GstGLFramebuffer *fb = gst_gl_framebuffer_new (context);
- GstGLBaseMemoryAllocator *render_alloc;
- GstGLAllocationParams *params;
- GstGLBaseMemory *renderbuffer;
- guint attach_point, attach_type;
-
- if (!fb)
- return NULL;
-
- if (gst_gl_context_get_gl_api (fb->context) & (GST_GL_API_OPENGL |
- GST_GL_API_OPENGL3)) {
- attach_point = GL_DEPTH_STENCIL_ATTACHMENT;
- attach_type = GST_GL_DEPTH24_STENCIL8;
- } else if (gst_gl_context_get_gl_api (fb->context) & GST_GL_API_GLES2) {
- attach_point = GL_DEPTH_ATTACHMENT;
- attach_type = GST_GL_DEPTH_COMPONENT16;
- } else {
- g_assert_not_reached ();
- return NULL;
- }
-
- render_alloc = (GstGLBaseMemoryAllocator *)
- gst_allocator_find (GST_GL_RENDERBUFFER_ALLOCATOR_NAME);
- params = (GstGLAllocationParams *)
- gst_gl_renderbuffer_allocation_params_new (context, NULL, attach_type,
- width, height);
-
- renderbuffer = gst_gl_base_memory_alloc (render_alloc, params);
- gst_gl_allocation_params_free (params);
- gst_object_unref (render_alloc);
-
- gst_gl_framebuffer_bind (fb);
- gst_gl_framebuffer_attach (fb, attach_point, renderbuffer);
- gst_gl_context_clear_framebuffer (fb->context);
- gst_memory_unref (GST_MEMORY_CAST (renderbuffer));
-
- return fb;
-}
-
-/**
- * gst_gl_framebuffer_draw_to_texture:
- * @fb: a #GstGLFramebuffer
- * @mem: the #GstGLMemory to draw to
- * @func: (scope call): the function to run
- * @user_data: data to pass to @func
- *
- * Perform the steps necessary to have the output of a glDraw* command in
- * @func update the contents of @mem.
- *
- * Returns: the result of executing @func
- *
- * Since: 1.10
- */
-gboolean
-gst_gl_framebuffer_draw_to_texture (GstGLFramebuffer * fb, GstGLMemory * mem,
- GstGLFramebufferFunc func, gpointer user_data)
-{
- GLint viewport_dim[4] = { 0 };
- const GstGLFuncs *gl;
- gboolean ret;
-
- g_return_val_if_fail (GST_IS_GL_FRAMEBUFFER (fb), FALSE);
- g_return_val_if_fail (gst_is_gl_memory (GST_MEMORY_CAST (mem)), FALSE);
-
- gl = fb->context->gl_vtable;
-
- GST_TRACE_OBJECT (fb, "drawing to texture %u, dimensions %ix%i", mem->tex_id,
- gst_gl_memory_get_texture_width (mem),
- gst_gl_memory_get_texture_height (mem));
-
- gst_gl_framebuffer_bind (fb);
- gst_gl_framebuffer_attach (fb, GL_COLOR_ATTACHMENT0, (GstGLBaseMemory *) mem);
-
- gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
- gl->Viewport (0, 0, fb->priv->effective_width, fb->priv->effective_height);
- if (gst_gl_context_get_gl_api (fb->context) & (GST_GL_API_OPENGL |
- GST_GL_API_OPENGL3))
- gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
-
- ret = func (user_data);
-
- if (gst_gl_context_get_gl_api (fb->context) & (GST_GL_API_OPENGL |
- GST_GL_API_OPENGL3))
- gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
- gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
- viewport_dim[3]);
- gst_gl_context_clear_framebuffer (fb->context);
-
- return ret;
-}
-
-/**
- * gst_gl_framebuffer_bind:
- * @fb: a #GstGLFramebuffer
- *
- * Bind @fb into the current thread
- *
- * Since: 1.10
- */
-void
-gst_gl_framebuffer_bind (GstGLFramebuffer * fb)
-{
- const GstGLFuncs *gl;
-
- g_return_if_fail (GST_IS_GL_FRAMEBUFFER (fb));
- g_return_if_fail (gst_gl_context_get_current () == fb->context);
- g_return_if_fail (fb->fbo_id != 0);
-
- gl = fb->context->gl_vtable;
-
- gl->BindFramebuffer (GL_FRAMEBUFFER, fb->fbo_id);
-}
-
-/**
- * gst_gl_context_clear_framebuffer:
- * @context: a #GstGLContext
- *
- * Unbind the current framebuffer
- *
- * Since: 1.10
- */
-void
-gst_gl_context_clear_framebuffer (GstGLContext * context)
-{
- const GstGLFuncs *gl;
-
- g_return_if_fail (GST_IS_GL_CONTEXT (context));
-
- gl = context->gl_vtable;
-
- gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
-}
-
-static void
-_update_effective_dimensions (GstGLFramebuffer * fb)
-{
- int i;
- guint min_width = -1, min_height = -1;
-
- /* remove the previous attachment */
- for (i = 0; i < fb->attachments->len; i++) {
- struct fbo_attachment *attach;
- int width, height;
-
- attach = &g_array_index (fb->attachments, struct fbo_attachment, i);
-
- if (gst_is_gl_memory (GST_MEMORY_CAST (attach->mem))) {
- GstGLMemory *mem = (GstGLMemory *) attach->mem;
-
- width = gst_gl_memory_get_texture_width (mem);
- height = gst_gl_memory_get_texture_height (mem);
- } else if (gst_is_gl_renderbuffer (GST_MEMORY_CAST (attach->mem))) {
- GstGLRenderbuffer *mem = (GstGLRenderbuffer *) attach->mem;
-
- width = mem->width;
- height = mem->height;
- } else {
- g_assert_not_reached ();
- }
-
- if (width < min_width)
- min_width = width;
- if (height < min_height)
- min_height = height;
- }
-
- fb->priv->effective_width = min_width;
- fb->priv->effective_height = min_height;
-}
-
-static gboolean
-_is_valid_attachment_point (guint attachment_point)
-{
- /* all 31 possible color attachments */
- if (attachment_point >= 0x8CE0 && attachment_point <= 0x8CFF)
- return TRUE;
-
- /* depth-stencil attachment */
- if (attachment_point == 0x821A)
- return TRUE;
-
- /* depth attachment */
- if (attachment_point == 0x8D00)
- return TRUE;
-
- /* stencil attachment */
- if (attachment_point == 0x8D20)
- return TRUE;
-
- return FALSE;
-}
-
-static void
-_attach_gl_memory (GstGLFramebuffer * fb, guint attachment_point,
- GstGLMemory * mem)
-{
- struct fbo_attachment attach;
- const GstGLFuncs *gl = fb->context->gl_vtable;
- guint gl_target = gst_gl_texture_target_to_gl (mem->tex_target);
-
- gst_gl_framebuffer_bind (fb);
-
- gl->FramebufferTexture2D (GL_FRAMEBUFFER, attachment_point, gl_target,
- mem->tex_id, 0);
-
- _fbo_attachment_init (&attach, attachment_point, (GstGLBaseMemory *) mem);
- fb->attachments = g_array_append_val (fb->attachments, attach);
-}
-
-static void
-_attach_renderbuffer (GstGLFramebuffer * fb, guint attachment_point,
- GstGLRenderbuffer * rb)
-{
- struct fbo_attachment attach;
- const GstGLFuncs *gl = fb->context->gl_vtable;
-
- gst_gl_framebuffer_bind (fb);
- gl->BindRenderbuffer (GL_RENDERBUFFER, rb->renderbuffer_id);
-
- gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, attachment_point,
- GL_RENDERBUFFER, rb->renderbuffer_id);
-
- _fbo_attachment_init (&attach, attachment_point, (GstGLBaseMemory *) rb);
- fb->attachments = g_array_append_val (fb->attachments, attach);
-}
-
-/**
- * gst_gl_framebuffer_attach:
- * @fb: a #GstGLFramebuffer
- * @attachment_point: the OpenGL attachment point to bind @mem to
- * @mem: the memory object to bind to @attachment_point
- *
- * attach @mem to @attachment_point
- *
- * Since: 1.10
- */
-void
-gst_gl_framebuffer_attach (GstGLFramebuffer * fb, guint attachment_point,
- GstGLBaseMemory * mem)
-{
- int i;
-
- g_return_if_fail (GST_IS_GL_FRAMEBUFFER (fb));
- g_return_if_fail (gst_gl_context_get_current () == fb->context);
- g_return_if_fail (_is_valid_attachment_point (attachment_point));
-
- /* remove the previous attachment */
- for (i = 0; i < fb->attachments->len; i++) {
- struct fbo_attachment *attach;
-
- attach = &g_array_index (fb->attachments, struct fbo_attachment, i);
-
- if (attach->attachment_point == attachment_point) {
- g_array_remove_index_fast (fb->attachments, i);
- break;
- }
- }
-
- if (gst_is_gl_memory (GST_MEMORY_CAST (mem))) {
- _attach_gl_memory (fb, attachment_point, (GstGLMemory *) mem);
- } else if (gst_is_gl_renderbuffer (GST_MEMORY_CAST (mem))) {
- _attach_renderbuffer (fb, attachment_point, (GstGLRenderbuffer *) mem);
- } else {
- g_assert_not_reached ();
- return;
- }
-
- _update_effective_dimensions (fb);
-}
-
-/**
- * gst_gl_framebuffer_get_effective_dimensions:
- * @fb: a #GstGLFramebuffer
- * @width: (out) (allow-none): output width
- * @height: (out) (allow-none): output height
- *
- * Retreive the effective dimensions from the current attachments attached to
- * @fb.
- *
- * Since: 1.10
- */
-void
-gst_gl_framebuffer_get_effective_dimensions (GstGLFramebuffer * fb,
- guint * width, guint * height)
-{
- g_return_if_fail (GST_IS_GL_FRAMEBUFFER (fb));
-
- if (width)
- *width = fb->priv->effective_width;
- if (height)
- *height = fb->priv->effective_height;
-}
-
-/**
- * gst_gl_context_check_framebuffer_status:
- * @context: a #GstGLContext
- * @fbo_target: the GL value of the framebuffer target, GL_FRAMEBUFFER,
- * GL_READ_FRAMEBUFFER, GL_DRAW_FRAMEBUFFER
- *
- * Returns: whether whether the current framebuffer is complete
- *
- * Since: 1.10
- */
-gboolean
-gst_gl_context_check_framebuffer_status (GstGLContext * context,
- guint fbo_target)
-{
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
-
- if (fbo_target != GL_FRAMEBUFFER && fbo_target != GL_READ_FRAMEBUFFER
- && fbo_target != GL_DRAW_FRAMEBUFFER) {
- GST_ERROR_OBJECT (context, "fbo target is invalid");
- return FALSE;
- }
-
- switch (context->gl_vtable->CheckFramebufferStatus (fbo_target)) {
- case GL_FRAMEBUFFER_COMPLETE:
- return TRUE;
- break;
- case GL_FRAMEBUFFER_UNSUPPORTED:
- GST_WARNING_OBJECT (context, "GL_FRAMEBUFFER_UNSUPPORTED");
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
- GST_WARNING_OBJECT (context, "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
- GST_WARNING_OBJECT (context,
- "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
- GST_WARNING_OBJECT (context, "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
- break;
-#if GST_GL_HAVE_OPENGL
- case GL_FRAMEBUFFER_UNDEFINED:
- GST_WARNING_OBJECT (context, "GL_FRAMEBUFFER_UNDEFINED");
- break;
-#endif
- default:
- GST_WARNING_OBJECT (context, "Unknown FBO error");
- break;
- }
-
- return FALSE;
-}
-
-/**
- * gst_gl_framebuffer_get_id:
- * @fb: a #GstGLFramebuffer
- *
- * Returns: the OpenGL id for @fb
- *
- * Since: 1.10
- */
-guint
-gst_gl_framebuffer_get_id (GstGLFramebuffer * fb)
-{
- g_return_val_if_fail (GST_IS_GL_FRAMEBUFFER (fb), 0);
-
- return fb->fbo_id;
-}
diff --git a/gst-libs/gst/gl/gstglframebuffer.h b/gst-libs/gst/gl/gstglframebuffer.h
deleted file mode 100644
index aaf60ec8a..000000000
--- a/gst-libs/gst/gl/gstglframebuffer.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_FRAMEBUFFER_H__
-#define __GST_GL_FRAMEBUFFER_H__
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GType gst_gl_framebuffer_get_type (void);
-
-#define GST_TYPE_GL_FRAMEBUFFER (gst_gl_framebuffer_get_type())
-#define GST_GL_FRAMEBUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_FRAMEBUFFER,GstGLFramebuffer))
-#define GST_GL_FRAMEBUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_GL_FRAMEBUFFER,GstGLFramebufferClass))
-#define GST_IS_GL_FRAMEBUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_FRAMEBUFFER))
-#define GST_IS_GL_FRAMEBUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GL_FRAMEBUFFER))
-#define GST_GL_FRAMEBUFFER_CAST(obj) ((GstGLFramebuffer*)(obj))
-
-typedef struct _GstGLFramebufferPrivate GstGLFramebufferPrivate;
-
-/**
- * GstGLFramebufferFunc:
- * @stuff: user data
- *
- * callback definition for operating through a #GstGLFramebuffer object
- */
-typedef gboolean (*GstGLFramebufferFunc) (gpointer stuff);
-
-/**
- * GstGLFramebuffer:
- *
- * Opaque #GstGLFramebuffer struct
- */
-struct _GstGLFramebuffer
-{
- /* <private> */
- GstObject object;
-
- GstGLContext *context;
-
- guint fbo_id;
- GArray *attachments;
-
- gpointer _padding[GST_PADDING];
-
- GstGLFramebufferPrivate *priv;
-};
-
-/**
- * GstGLFramebufferClass:
- *
- * Opaque #GstGLFramebufferClass struct
- */
-struct _GstGLFramebufferClass
-{
- /* <private> */
- GstObjectClass object_class;
-
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GstGLFramebuffer * gst_gl_framebuffer_new (GstGLContext *context);
-GST_EXPORT
-GstGLFramebuffer * gst_gl_framebuffer_new_with_default_depth (GstGLContext *context,
- guint width,
- guint height);
-
-GST_EXPORT
-guint gst_gl_framebuffer_get_id (GstGLFramebuffer * fb);
-
-GST_EXPORT
-void gst_gl_framebuffer_attach (GstGLFramebuffer * fb,
- guint attachment_point,
- GstGLBaseMemory * mem);
-GST_EXPORT
-void gst_gl_framebuffer_bind (GstGLFramebuffer * fb);
-GST_EXPORT
-void gst_gl_context_clear_framebuffer (GstGLContext * context);
-
-GST_EXPORT
-void gst_gl_framebuffer_get_effective_dimensions (GstGLFramebuffer * fb,
- guint * width,
- guint * height);
-
-GST_EXPORT
-gboolean gst_gl_context_check_framebuffer_status (GstGLContext * context,
- guint fbo_target);
-
-GST_EXPORT
-gboolean gst_gl_framebuffer_draw_to_texture (GstGLFramebuffer * fb,
- GstGLMemory * mem,
- GstGLFramebufferFunc func,
- gpointer user_data);
-
-#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLFramebuffer, gst_object_unref)
-#endif
-
-G_END_DECLS
-
-#endif
diff --git a/gst-libs/gst/gl/gstglfuncs.h b/gst-libs/gst/gl/gstglfuncs.h
deleted file mode 100644
index 805abcf3d..000000000
--- a/gst-libs/gst/gl/gstglfuncs.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_FUNCS_H__
-#define __GST_GL_FUNCS_H__
-
-#include <gst/gl/gstglconfig.h>
-
-/* This mimic GCC behaviour with system headers files even if GL headers may
- * not be in the system header path. */
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wredundant-decls"
-#endif
-
-/* OpenGL 2.0 for Embedded Systems */
-#if GST_GL_HAVE_GLES2
-# if GST_GL_HAVE_PLATFORM_EAGL
-# include <OpenGLES/ES2/gl.h>
-# include <OpenGLES/ES2/glext.h>
-# else
-# if GST_GL_HAVE_GLES3
-# include <GLES3/gl3.h>
-# if GST_GL_HAVE_GLES3EXT3_H
-# include <GLES3/gl3ext.h>
-# endif
-# include <GLES2/gl2ext.h>
-# else
-# include <GLES2/gl2.h>
-# include <GLES2/gl2ext.h>
-# endif
-# endif
-# if !GST_GL_HAVE_OPENGL
-# include <gst/gl/glprototypes/gstgl_gles2compat.h>
-# endif
-#endif
-
-/* OpenGL for desktop systems */
-#if GST_GL_HAVE_OPENGL
-# ifdef __APPLE__
-# include <OpenGL/OpenGL.h>
-# include <OpenGL/gl.h>
-# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
-# define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
-# include <OpenGL/gl3.h>
-# endif
-# else
-# if defined(_MSC_VER)
-# include <windows.h>
-# endif
-# include <GL/gl.h>
-# if defined(__WIN32__) || defined(_WIN32)
-# include <GL/glext.h>
-# endif
-# endif
-#endif
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
-
-#if defined(WINAPI)
-#define GSTGLAPI WINAPI
-#else
-#define GSTGLAPI
-#endif
-#include <gst/gl/glprototypes/gstgl_compat.h>
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-#define GST_GL_EXT_BEGIN(name, gl_availability, min_gl, maj_gl, gles_maj, \
- gles_min, ext_suf, ext_name)
-#define GST_GL_EXT_FUNCTION(ret, name, args) \
- ret (GSTGLAPI *name) args;
-#define GST_GL_EXT_END()
-
-typedef struct _GstGLFuncs
-{
-#include <gst/gl/glprototypes/all_functions.h>
- gpointer padding[GST_PADDING_LARGE*6];
-} GstGLFuncs;
-
-#undef GST_GL_EXT_BEGIN
-#undef GST_GL_EXT_FUNCTION
-#undef GST_GL_EXT_END
-
-G_END_DECLS
-
-#endif /* __GST_GL_API_H__ */
diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c
deleted file mode 100644
index a4a137233..000000000
--- a/gst-libs/gst/gl/gstglmemory.c
+++ /dev/null
@@ -1,1526 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "gstglmemory.h"
-
-#include "gl.h"
-#include "gstglfuncs.h"
-
-/**
- * SECTION:gstglmemory
- * @title: GstGLMemory
- * @short_description: memory subclass for GL textures
- * @see_also: #GstMemory, #GstAllocator, #GstGLBufferPool
- *
- * GstGLMemory is a #GstGLBaseMemory subclass providing support for the mapping of
- * OpenGL textures.
- *
- * #GstGLMemory is created or wrapped through gst_gl_base_memory_alloc()
- * with #GstGLVideoAllocationParams.
- *
- * Data is uploaded or downloaded from the GPU as is necessary.
- */
-
-#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
-#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
-#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
-#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
-#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-
-#define GL_MEM_WIDTH(gl_mem) _get_plane_width (&gl_mem->info, gl_mem->plane)
-#define GL_MEM_HEIGHT(gl_mem) _get_plane_height (&gl_mem->info, gl_mem->plane)
-#define GL_MEM_STRIDE(gl_mem) GST_VIDEO_INFO_PLANE_STRIDE (&gl_mem->info, gl_mem->plane)
-
-static GstAllocator *_gl_memory_allocator;
-
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_MEMORY);
-#define GST_CAT_DEFAULT GST_CAT_GL_MEMORY
-
-/* compatability definitions... */
-#ifndef GL_UNPACK_ROW_LENGTH
-#define GL_UNPACK_ROW_LENGTH 0x0CF2
-#endif
-
-#ifndef GL_TEXTURE_RECTANGLE
-#define GL_TEXTURE_RECTANGLE 0x84F5
-#endif
-#ifndef GL_TEXTURE_EXTERNAL_OES
-#define GL_TEXTURE_EXTERNAL_OES 0x8D65
-#endif
-
-#ifndef GL_READ_FRAMEBUFFER
-#define GL_READ_FRAMEBUFFER 0x8CA8
-#endif
-#ifndef GL_DRAW_FRAMEBUFFER
-#define GL_DRAW_FRAMEBUFFER 0x8CA9
-#endif
-
-G_DEFINE_TYPE (GstGLMemoryAllocator, gst_gl_memory_allocator,
- GST_TYPE_GL_BASE_MEMORY_ALLOCATOR);
-
-typedef struct
-{
- /* in */
- GstGLMemory *src;
- GstGLFormat out_format;
- guint out_width, out_height;
- GstGLTextureTarget tex_target;
- GstGLFormat tex_format;
- /* inout */
- guint tex_id;
- /* out */
- gboolean result;
-} GstGLMemoryCopyParams;
-
-static inline guint
-_get_plane_width (GstVideoInfo * info, guint plane)
-{
- if (GST_VIDEO_INFO_IS_YUV (info))
- /* For now component width and plane width are the same and the
- * plane-component mapping matches
- */
- return GST_VIDEO_INFO_COMP_WIDTH (info, plane);
- else /* RGB, GRAY */
- return GST_VIDEO_INFO_WIDTH (info);
-}
-
-static inline guint
-_get_plane_height (GstVideoInfo * info, guint plane)
-{
- if (GST_VIDEO_INFO_IS_YUV (info))
- /* For now component width and plane width are the same and the
- * plane-component mapping matches
- */
- return GST_VIDEO_INFO_COMP_HEIGHT (info, plane);
- else /* RGB, GRAY */
- return GST_VIDEO_INFO_HEIGHT (info);
-}
-
-static inline void
-_calculate_unpack_length (GstGLMemory * gl_mem, GstGLContext * context)
-{
- guint n_gl_bytes;
- guint tex_type;
-
- gl_mem->tex_scaling[0] = 1.0f;
- gl_mem->tex_scaling[1] = 1.0f;
- gl_mem->unpack_length = 1;
- gl_mem->tex_width = GL_MEM_WIDTH (gl_mem);
-
- tex_type = GL_UNSIGNED_BYTE;
- if (gl_mem->tex_format == GST_GL_RGB565)
- tex_type = GL_UNSIGNED_SHORT_5_6_5;
-
- n_gl_bytes = gst_gl_format_type_n_bytes (gl_mem->tex_format, tex_type);
- if (n_gl_bytes == 0) {
- GST_ERROR ("Unsupported texture type %d", gl_mem->tex_format);
- return;
- }
-
- if (USING_OPENGL (context) || USING_GLES3 (context)
- || USING_OPENGL3 (context)) {
- gl_mem->unpack_length = GL_MEM_STRIDE (gl_mem) / n_gl_bytes;
- } else if (USING_GLES2 (context)) {
- guint j = 8;
-
- while (j >= n_gl_bytes) {
- /* GST_ROUND_UP_j(GL_MEM_WIDTH (gl_mem) * n_gl_bytes) */
- guint round_up_j =
- ((GL_MEM_WIDTH (gl_mem) * n_gl_bytes) + j - 1) & ~(j - 1);
-
- if (round_up_j == GL_MEM_STRIDE (gl_mem)) {
- GST_CAT_LOG (GST_CAT_GL_MEMORY, "Found alignment of %u based on "
- "width (with plane width:%u, plane stride:%u and pixel stride:%u. "
- "RU%u(%u*%u) = %u)", j, GL_MEM_WIDTH (gl_mem),
- GL_MEM_STRIDE (gl_mem), n_gl_bytes, j, GL_MEM_WIDTH (gl_mem),
- n_gl_bytes, round_up_j);
-
- gl_mem->unpack_length = j;
- break;
- }
- j >>= 1;
- }
-
- if (j < n_gl_bytes) {
- /* Failed to find a suitable alignment, try based on plane_stride and
- * scale in the shader. Useful for alignments that are greater than 8.
- */
- j = 8;
-
- while (j >= n_gl_bytes) {
- /* GST_ROUND_UP_j((GL_MEM_STRIDE (gl_mem)) */
- guint round_up_j = ((GL_MEM_STRIDE (gl_mem)) + j - 1) & ~(j - 1);
-
- if (round_up_j == (GL_MEM_STRIDE (gl_mem))) {
- GST_CAT_LOG (GST_CAT_GL_MEMORY, "Found alignment of %u based "
- "on stride (with plane stride:%u and pixel stride:%u. "
- "RU%u(%u) = %u)", j, GL_MEM_STRIDE (gl_mem), n_gl_bytes, j,
- GL_MEM_STRIDE (gl_mem), round_up_j);
-
- gl_mem->unpack_length = j;
- gl_mem->tex_scaling[0] =
- (gfloat) (GL_MEM_WIDTH (gl_mem) * n_gl_bytes) /
- (gfloat) GL_MEM_STRIDE (gl_mem);
- gl_mem->tex_width = GL_MEM_STRIDE (gl_mem) / n_gl_bytes;
- break;
- }
- j >>= 1;
- }
-
- if (j < n_gl_bytes) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Failed to find matching "
- "alignment. Image may look corrupted. plane width:%u, "
- "plane stride:%u and pixel stride:%u", GL_MEM_WIDTH (gl_mem),
- GL_MEM_STRIDE (gl_mem), n_gl_bytes);
- }
- }
- }
-
- if (gl_mem->tex_target == GST_GL_TEXTURE_TARGET_RECTANGLE) {
- guint w_sub =
- GST_VIDEO_FORMAT_INFO_W_SUB (gl_mem->info.finfo, gl_mem->plane);
- guint h_sub =
- GST_VIDEO_FORMAT_INFO_H_SUB (gl_mem->info.finfo, gl_mem->plane);
-
- if (w_sub)
- gl_mem->tex_scaling[0] /= (1 << w_sub);
- if (h_sub)
- gl_mem->tex_scaling[1] /= (1 << h_sub);
- }
-}
-
-static guint
-_new_texture (GstGLContext * context, guint target, guint internal_format,
- guint format, guint type, guint width, guint height)
-{
- const GstGLFuncs *gl = context->gl_vtable;
- guint tex_id;
-
- gl->GenTextures (1, &tex_id);
- gl->BindTexture (target, tex_id);
- if (target == GL_TEXTURE_2D || target == GL_TEXTURE_RECTANGLE)
- gl->TexImage2D (target, 0, internal_format, width, height, 0, format, type,
- NULL);
-
- gl->TexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- gl->TexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- gl->TexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- gl->TexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- gl->BindTexture (target, 0);
-
- return tex_id;
-}
-
-static gboolean
-_gl_tex_create (GstGLMemory * gl_mem, GError ** error)
-{
- GstGLContext *context = gl_mem->mem.context;
- GLenum internal_format;
- GLenum tex_format;
- GLenum tex_type;
-
- tex_format = gl_mem->tex_format;
- tex_type = GL_UNSIGNED_BYTE;
- if (gl_mem->tex_format == GST_GL_RGB565) {
- tex_format = GST_GL_RGB;
- tex_type = GL_UNSIGNED_SHORT_5_6_5;
- }
-
- internal_format =
- gst_gl_sized_gl_format_from_gl_format_type (context, tex_format,
- tex_type);
-
- if (!gl_mem->texture_wrapped) {
- gl_mem->tex_id =
- _new_texture (context, gst_gl_texture_target_to_gl (gl_mem->tex_target),
- internal_format, tex_format, tex_type, gl_mem->tex_width,
- GL_MEM_HEIGHT (gl_mem));
-
- GST_TRACE ("Generating texture id:%u format:%u type:%u dimensions:%ux%u",
- gl_mem->tex_id, tex_format, tex_type, gl_mem->tex_width,
- GL_MEM_HEIGHT (gl_mem));
- }
-
- return TRUE;
-}
-
-/**
- * gst_gl_memory_init:
- * @mem: the #GstGLBaseMemory to initialize
- * @allocator: the #GstAllocator to initialize with
- * @parent: (allow-none): the parent #GstMemory to initialize with
- * @context: the #GstGLContext to initialize with
- * @target: the #GstGLTextureTarget for this #GstGLMemory
- * @tex_format: the #GstGLFormat for this #GstGLMemory
- * @params: (allow-none): the @GstAllocationParams to initialize with
- * @info: the #GstVideoInfo for this #GstGLMemory
- * @plane: the plane number (starting from 0) for this #GstGLMemory
- * @valign: (allow-none): optional #GstVideoAlignment parameters
- * @notify: (allow-none): a #GDestroyNotify
- * @user_data: (allow-none): user data to call @notify with
- *
- * Initializes @mem with the required parameters. @info is assumed to have
- * already have been modified with gst_video_info_align().
- *
- * Since: 1.8
- */
-void
-gst_gl_memory_init (GstGLMemory * mem, GstAllocator * allocator,
- GstMemory * parent, GstGLContext * context, GstGLTextureTarget target,
- GstGLFormat tex_format, GstAllocationParams * params,
- GstVideoInfo * info, guint plane, GstVideoAlignment * valign,
- gpointer user_data, GDestroyNotify notify)
-{
- const gchar *target_str;
- gsize size;
-
- g_return_if_fail (plane < GST_VIDEO_INFO_N_PLANES (info));
-
- mem->info = *info;
- if (valign)
- mem->valign = *valign;
- else
- gst_video_alignment_reset (&mem->valign);
-
- /* double-check alignment requirements (caller should've taken care of this) */
- if (params) {
- guint max_align, n;
-
- max_align = gst_memory_alignment;
- max_align |= params->align;
- for (n = 0; n < GST_VIDEO_MAX_PLANES; ++n)
- max_align |= mem->valign.stride_align[n];
-
- if (params->align < max_align && max_align > gst_memory_alignment) {
- GST_WARNING ("allocation params alignment %" G_GSIZE_FORMAT " is smaller "
- "than the max required video alignment %u", params->align, max_align);
- }
- }
-
- size = gst_gl_get_plane_data_size (info, valign, plane);
-
- mem->tex_target = target;
- mem->tex_format = tex_format;
- mem->plane = plane;
-
- _calculate_unpack_length (mem, context);
-
- gst_gl_base_memory_init ((GstGLBaseMemory *) mem, allocator, parent, context,
- params, size, user_data, notify);
-
- target_str = gst_gl_texture_target_to_string (target);
- GST_CAT_DEBUG (GST_CAT_GL_MEMORY, "new GL texture context:%"
- GST_PTR_FORMAT " memory:%p target:%s format:%u dimensions:%ux%u "
- "stride:%u size:%" G_GSIZE_FORMAT, context, mem, target_str,
- mem->tex_format, mem->tex_width, GL_MEM_HEIGHT (mem), GL_MEM_STRIDE (mem),
- mem->mem.mem.size);
-}
-
-/**
- * gst_gl_memory_read_pixels:
- * @gl_mem: a #GstGLMemory
- * @read_pointer: the data pointer to pass to glReadPixels
- *
- * Reads the texture in #GstGLMemory into @read_pointer if no buffer is bound
- * to %GL_PIXEL_PACK_BUFFER. Otherwise @read_pointer is the byte offset into
- * the currently bound %GL_PIXEL_PACK_BUFFER buffer to store the result of
- * glReadPixels. See the OpenGL specification for glReadPixels for more
- * details.
- *
- * Returns: whether theread operation succeeded
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_memory_read_pixels (GstGLMemory * gl_mem, gpointer read_pointer)
-{
- GstGLContext *context = gl_mem->mem.context;
- const GstGLFuncs *gl = context->gl_vtable;
- guint format, type;
- guint fbo;
-
- format = gl_mem->tex_format;
- type = GL_UNSIGNED_BYTE;
- if (gl_mem->tex_format == GST_GL_RGB565)
- type = GL_UNSIGNED_SHORT_5_6_5;
-
- /* FIXME: avoid creating a framebuffer every download/copy */
- gl->GenFramebuffers (1, &fbo);
- gl->BindFramebuffer (GL_FRAMEBUFFER, fbo);
-
- gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- gst_gl_texture_target_to_gl (gl_mem->tex_target), gl_mem->tex_id, 0);
-
- if (!gst_gl_context_check_framebuffer_status (context, GL_FRAMEBUFFER)) {
- GST_CAT_WARNING (GST_CAT_GL_MEMORY,
- "Could not create framebuffer to read pixels for memory %p", gl_mem);
- gl->DeleteFramebuffers (1, &fbo);
- return FALSE;
- }
-
- if (USING_GLES2 (context) || USING_GLES3 (context)) {
- if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
- /* explicitly supported */
- } else {
- gint supported_format, supported_type;
-
- gl->GetIntegerv (GL_IMPLEMENTATION_COLOR_READ_FORMAT, &supported_format);
- gl->GetIntegerv (GL_IMPLEMENTATION_COLOR_READ_TYPE, &supported_type);
-
- if (supported_format != format || supported_type != type) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "cannot read pixels with "
- "unsupported format and type. Supported format 0x%x type 0x%x",
- supported_format, supported_type);
- gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
- gl->DeleteFramebuffers (1, &fbo);
- return FALSE;
- }
- }
- }
-
- gst_gl_query_start_log (GST_GL_BASE_MEMORY_CAST (gl_mem)->query,
- GST_CAT_GL_MEMORY, GST_LEVEL_LOG, NULL, "%s", "glReadPixels took");
- gl->ReadPixels (0, 0, gl_mem->tex_width, GL_MEM_HEIGHT (gl_mem), format,
- type, read_pointer);
- gst_gl_query_end (GST_GL_BASE_MEMORY_CAST (gl_mem)->query);
-
- gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
- gl->DeleteFramebuffers (1, &fbo);
-
- return TRUE;
-}
-
-static gpointer
-_gl_tex_download_get_tex_image (GstGLMemory * gl_mem, GstMapInfo * info,
- gsize size)
-{
- GstGLContext *context = gl_mem->mem.context;
- const GstGLFuncs *gl = context->gl_vtable;
-
- if (size != -1 && size != ((GstMemory *) gl_mem)->maxsize)
- return NULL;
-
- if (USING_GLES2 (context) || USING_GLES3 (context))
- return NULL;
-
- /* taken care of by read pixels */
- if (gl_mem->tex_format != GST_GL_LUMINANCE
- && gl_mem->tex_format != GST_GL_LUMINANCE_ALPHA)
- return NULL;
-
- if (info->flags & GST_MAP_READ
- && GST_MEMORY_FLAG_IS_SET (gl_mem,
- GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)) {
- guint format, type;
- guint target;
-
- GST_CAT_TRACE (GST_CAT_GL_MEMORY, "attempting download of texture %u "
- "using glGetTexImage", gl_mem->tex_id);
-
- format = gl_mem->tex_format;
- type = GL_UNSIGNED_BYTE;
- if (gl_mem->tex_format == GST_GL_RGB565)
- type = GL_UNSIGNED_SHORT_5_6_5;
-
- target = gst_gl_texture_target_to_gl (gl_mem->tex_target);
- gl->BindTexture (target, gl_mem->tex_id);
- gst_gl_query_start_log (GST_GL_BASE_MEMORY_CAST (gl_mem)->query,
- GST_CAT_GL_MEMORY, GST_LEVEL_LOG, NULL, "%s", "glGetTexImage took");
- gl->GetTexImage (target, 0, format, type, gl_mem->mem.data);
- gst_gl_query_end (GST_GL_BASE_MEMORY_CAST (gl_mem)->query);
- gl->BindTexture (target, 0);
- }
-
- return gl_mem->mem.data;
-}
-
-static gpointer
-_gl_tex_download_read_pixels (GstGLMemory * gl_mem, GstMapInfo * info,
- gsize size)
-{
- if (size != -1 && size != ((GstMemory *) gl_mem)->maxsize)
- return NULL;
-
- if (info->flags & GST_MAP_READ
- && GST_MEMORY_FLAG_IS_SET (gl_mem,
- GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)) {
- GST_CAT_TRACE (GST_CAT_GL_MEMORY,
- "attempting download of texture %u " "using glReadPixels",
- gl_mem->tex_id);
- if (!gst_gl_memory_read_pixels (gl_mem, gl_mem->mem.data))
- return NULL;
- }
-
- return gl_mem->mem.data;
-}
-
-static gpointer
-_gl_tex_map_cpu_access (GstGLMemory * gl_mem, GstMapInfo * info, gsize size)
-{
- gpointer data = NULL;
-
- if (!gst_gl_base_memory_alloc_data (GST_GL_BASE_MEMORY_CAST (gl_mem)))
- return NULL;
-
- if (!data)
- data = _gl_tex_download_get_tex_image (gl_mem, info, size);
-
- if (!data)
- data = _gl_tex_download_read_pixels (gl_mem, info, size);
-
- return data;
-}
-
-static void
-_upload_cpu_write (GstGLMemory * gl_mem, GstMapInfo * info, gsize maxsize)
-{
- gst_gl_memory_texsubimage (gl_mem, gl_mem->mem.data);
-}
-
-/**
- * gst_gl_memory_texsubimage:
- * @gl_mem: a #GstGLMemory
- * @read_pointer: the data pointer to pass to glTexSubImage
- *
- * See gst_gl_memory_read_pixels() for what @read_pointer signifies.
- *
- * Since: 1.8
- */
-void
-gst_gl_memory_texsubimage (GstGLMemory * gl_mem, gpointer read_pointer)
-{
- GstGLContext *context = gl_mem->mem.context;
- const GstGLFuncs *gl;
- GLenum gl_format, gl_type, gl_target;
- gpointer data;
- gsize plane_start;
-
- if (!GST_MEMORY_FLAG_IS_SET (gl_mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD))
- return;
-
- gl = context->gl_vtable;
-
- gl_type = GL_UNSIGNED_BYTE;
- if (gl_mem->tex_format == GST_GL_RGB565)
- gl_type = GL_UNSIGNED_SHORT_5_6_5;
-
- gl_format = gl_mem->tex_format;
- gl_target = gst_gl_texture_target_to_gl (gl_mem->tex_target);
-
- if (USING_OPENGL (context) || USING_GLES3 (context)
- || USING_OPENGL3 (context)) {
- gl->PixelStorei (GL_UNPACK_ROW_LENGTH, gl_mem->unpack_length);
- } else if (USING_GLES2 (context)) {
- gl->PixelStorei (GL_UNPACK_ALIGNMENT, gl_mem->unpack_length);
- }
-
- GST_CAT_LOG (GST_CAT_GL_MEMORY, "upload for texture id:%u, %ux%u",
- gl_mem->tex_id, gl_mem->tex_width, GL_MEM_HEIGHT (gl_mem));
-
- /* find the start of the plane data including padding */
- plane_start =
- gst_gl_get_plane_start (&gl_mem->info, &gl_mem->valign,
- gl_mem->plane) + gl_mem->mem.mem.offset;
-
- data = (gpointer) ((gintptr) plane_start + (gintptr) read_pointer);
-
- gl->BindTexture (gl_target, gl_mem->tex_id);
- gst_gl_query_start_log (GST_GL_BASE_MEMORY_CAST (gl_mem)->query,
- GST_CAT_GL_MEMORY, GST_LEVEL_LOG, NULL, "%s", "glTexSubImage took");
- gl->TexSubImage2D (gl_target, 0, 0, 0, gl_mem->tex_width,
- GL_MEM_HEIGHT (gl_mem), gl_format, gl_type, data);
- gst_gl_query_end (GST_GL_BASE_MEMORY_CAST (gl_mem)->query);
-
- /* Reset to default values */
- if (USING_OPENGL (context) || USING_GLES3 (context)
- || USING_OPENGL3 (context)) {
- gl->PixelStorei (GL_UNPACK_ROW_LENGTH, 0);
- } else if (USING_GLES2 (context)) {
- gl->PixelStorei (GL_UNPACK_ALIGNMENT, 4);
- }
-
- gl->BindTexture (gl_target, 0);
-}
-
-static gpointer
-_default_gl_tex_map (GstGLMemory * gl_mem, GstMapInfo * info, gsize size)
-{
- if ((info->flags & GST_MAP_GL) == GST_MAP_GL) {
- _upload_cpu_write (gl_mem, info, size);
- return &gl_mem->tex_id;
- } else {
- return _gl_tex_map_cpu_access (gl_mem, info, size);
- }
-}
-
-static gpointer
-_gl_tex_map (GstGLMemory * gl_mem, GstMapInfo * info, gsize maxsize)
-{
- GstGLMemoryAllocatorClass *alloc_class;
- gpointer data;
-
- alloc_class = GST_GL_MEMORY_ALLOCATOR_GET_CLASS (gl_mem->mem.mem.allocator);
-
- if ((info->flags & GST_MAP_GL) == GST_MAP_GL) {
- if (gl_mem->tex_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES)
- return &gl_mem->tex_id;
- } else { /* not GL */
- if (gl_mem->tex_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Cannot map External OES textures");
- return NULL;
- }
- }
-
- g_return_val_if_fail (alloc_class->map != NULL, NULL);
- data = alloc_class->map (GST_GL_BASE_MEMORY_CAST (gl_mem), info, maxsize);
-
- return data;
-}
-
-static void
-_default_gl_tex_unmap (GstGLMemory * gl_mem, GstMapInfo * info)
-{
-}
-
-static void
-_gl_tex_unmap (GstGLMemory * gl_mem, GstMapInfo * info)
-{
- GstGLMemoryAllocatorClass *alloc_class;
-
- alloc_class = GST_GL_MEMORY_ALLOCATOR_GET_CLASS (gl_mem->mem.mem.allocator);
- g_return_if_fail (alloc_class->unmap != NULL);
-
- alloc_class->unmap (GST_GL_BASE_MEMORY_CAST (gl_mem), info);
-}
-
-/**
- * gst_gl_memory_copy_teximage:
- * @gl_mem: the source #GstGLMemory
- * @tex_id: the destination texture id
- * @out_target: the destination #GstGLTextureTarget
- * @out_tex_format: the destination #GstGLFormat
- * @out_width: the destination width
- * @out_height: the destination height
- *
- * Copies the texture in #GstGLMemory into the texture specified by @tex_id,
- * @out_target, @out_tex_format, @out_width and @out_height.
- *
- * Returns: whether the copy succeeded.
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id,
- GstGLTextureTarget out_target, GstGLFormat out_tex_format,
- gint out_width, gint out_height)
-{
- const GstGLFuncs *gl;
- guint out_tex_target;
- GstMapInfo sinfo;
- guint src_tex_id;
- guint fbo[2];
- guint n_fbos;
-
- gl = src->mem.context->gl_vtable;
- out_tex_target = gst_gl_texture_target_to_gl (out_target);
-
- if (!gl->GenFramebuffers) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Framebuffer objects not supported");
- goto error;
- }
-
- if (USING_GLES2 (src->mem.context)
- && (src->tex_format == GST_GL_LUMINANCE
- || src->tex_format == GST_GL_LUMINANCE_ALPHA)) {
- GST_CAT_FIXME (GST_CAT_GL_MEMORY,
- "Cannot copy Luminance/Luminance Alpha textures in GLES");
- goto error;
- }
-
- if (!gst_memory_map (GST_MEMORY_CAST (src), &sinfo,
- GST_MAP_READ | GST_MAP_GL)) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY,
- "Failed to map source memory for copying");
- goto error;
- }
-
- src_tex_id = *(guint *) sinfo.data;
-
- GST_CAT_LOG (GST_CAT_GL_MEMORY, "copying memory %p, tex %u into "
- "texture %i", src, src_tex_id, tex_id);
-
- /* FIXME: try and avoid creating and destroying fbo's every copy... */
- if (!gl->BlitFramebuffer || (!gl->DrawBuffer && !gl->DrawBuffers)
- || !gl->ReadBuffer) {
- /* create a framebuffer object */
- n_fbos = 1;
- gl->GenFramebuffers (n_fbos, &fbo[0]);
- gl->BindFramebuffer (GL_FRAMEBUFFER, fbo[0]);
-
- gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- gst_gl_texture_target_to_gl (src->tex_target), src_tex_id, 0);
-
- if (!gst_gl_context_check_framebuffer_status (src->mem.context,
- GL_FRAMEBUFFER))
- goto fbo_error;
-
- gl->BindTexture (out_tex_target, tex_id);
- gst_gl_query_start_log (GST_GL_BASE_MEMORY_CAST (src)->query,
- GST_CAT_GL_MEMORY, GST_LEVEL_LOG, NULL, "%s", "CopyTexImage2D took");
- gl->CopyTexImage2D (out_tex_target, 0, out_tex_format, 0, 0, out_width,
- out_height, 0);
- gst_gl_query_end (GST_GL_BASE_MEMORY_CAST (src)->query);
-
- gl->BindTexture (out_tex_target, 0);
- gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
-
- gl->DeleteFramebuffers (n_fbos, &fbo[0]);
- } else {
- GLenum multipleRT[] = {
- GL_COLOR_ATTACHMENT0,
- GL_COLOR_ATTACHMENT1,
- GL_COLOR_ATTACHMENT2
- };
-
- /* create a framebuffer object */
- n_fbos = 2;
- gl->GenFramebuffers (n_fbos, &fbo[0]);
-
- gl->BindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
- gl->FramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- gst_gl_texture_target_to_gl (src->tex_target), src_tex_id, 0);
-
- if (!gst_gl_context_check_framebuffer_status (src->mem.context,
- GL_READ_FRAMEBUFFER))
- goto fbo_error;
-
- gl->BindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
-
- gl->FramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- gst_gl_texture_target_to_gl (src->tex_target), tex_id, 0);
-
- if (!gst_gl_context_check_framebuffer_status (src->mem.context,
- GL_DRAW_FRAMEBUFFER))
- goto fbo_error;
-
- gl->BindTexture (out_tex_target, tex_id);
- gst_gl_query_start_log (GST_GL_BASE_MEMORY_CAST (src)->query,
- GST_CAT_GL_MEMORY, GST_LEVEL_LOG, NULL, "%s", "BlitFramebuffer took");
- gl->ReadBuffer (GL_COLOR_ATTACHMENT0);
- if (gl->DrawBuffers)
- gl->DrawBuffers (1, multipleRT);
- else
- gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
- gl->BlitFramebuffer (0, 0, out_width, out_height,
- 0, 0, out_width, out_height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
- gst_gl_query_end (GST_GL_BASE_MEMORY_CAST (src)->query);
-
- gl->BindTexture (out_tex_target, 0);
- gl->BindFramebuffer (GL_DRAW_FRAMEBUFFER, 0);
- gl->BindFramebuffer (GL_READ_FRAMEBUFFER, 0);
-
- gl->DeleteFramebuffers (n_fbos, &fbo[0]);
-
- if (gl->DrawBuffer)
- gl->DrawBuffer (GL_BACK);
- }
-
- gst_memory_unmap (GST_MEMORY_CAST (src), &sinfo);
-
- return TRUE;
-
-fbo_error:
- {
- gl->BindTexture (out_tex_target, 0);
- if (!gl->BlitFramebuffer) {
- gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
- } else {
- gl->BindFramebuffer (GL_DRAW_FRAMEBUFFER, 0);
- gl->BindFramebuffer (GL_READ_FRAMEBUFFER, 0);
- }
-
- gl->DeleteFramebuffers (n_fbos, &fbo[0]);
-
- gst_memory_unmap (GST_MEMORY_CAST (src), &sinfo);
- }
-error:
- return FALSE;
-}
-
-static void
-_gl_tex_copy_thread (GstGLContext * context, gpointer data)
-{
- GstGLMemoryCopyParams *copy_params;
-
- copy_params = (GstGLMemoryCopyParams *) data;
-
- if (!copy_params->tex_id) {
- guint internal_format, out_gl_format, out_gl_type, out_tex_target;
-
- out_tex_target = gst_gl_texture_target_to_gl (copy_params->tex_target);
- out_gl_format = copy_params->src->tex_format;
- out_gl_type = GL_UNSIGNED_BYTE;
- if (copy_params->out_format == GST_GL_RGB565) {
- out_gl_format = GST_GL_RGB;
- out_gl_type = GL_UNSIGNED_SHORT_5_6_5;
- }
-
- internal_format =
- gst_gl_sized_gl_format_from_gl_format_type (context, out_gl_format,
- out_gl_type);
-
- copy_params->tex_id =
- _new_texture (context, out_tex_target,
- internal_format, out_gl_format, out_gl_type, copy_params->out_width,
- copy_params->out_height);
- }
-
- copy_params->result = gst_gl_memory_copy_teximage (copy_params->src,
- copy_params->tex_id, copy_params->tex_target, copy_params->tex_format,
- copy_params->out_width, copy_params->out_height);
-}
-
-static GstMemory *
-_default_gl_tex_copy (GstGLMemory * src, gssize offset, gssize size)
-{
- GstAllocationParams params = { 0, GST_MEMORY_CAST (src)->align, 0, 0 };
- GstGLBaseMemoryAllocator *base_mem_allocator;
- GstAllocator *allocator;
- GstGLMemory *dest = NULL;
-
- allocator = GST_MEMORY_CAST (src)->allocator;
- base_mem_allocator = (GstGLBaseMemoryAllocator *) allocator;
-
- if (src->tex_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Cannot copy External OES textures");
- return NULL;
- }
-
- /* If not doing a full copy, then copy to sysmem, the 2D represention of the
- * texture would become wrong */
- if (offset > 0 || size < GST_MEMORY_CAST (src)->size) {
- return base_mem_allocator->fallback_mem_copy (GST_MEMORY_CAST (src), offset,
- size);
- }
-
- dest = g_new0 (GstGLMemory, 1);
-
- gst_gl_memory_init (dest, allocator, NULL, src->mem.context, src->tex_target,
- src->tex_format, &params, &src->info, src->plane, &src->valign, NULL,
- NULL);
-
- if (!GST_MEMORY_FLAG_IS_SET (src, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)) {
- GstMapInfo dinfo;
-
- if (!gst_memory_map (GST_MEMORY_CAST (dest), &dinfo,
- GST_MAP_WRITE | GST_MAP_GL)) {
- GST_CAT_WARNING (GST_CAT_GL_MEMORY,
- "Failed not map destination for writing");
- gst_memory_unref (GST_MEMORY_CAST (dest));
- return NULL;
- }
-
- if (!gst_gl_memory_copy_into ((GstGLMemory *) src,
- ((GstGLMemory *) dest)->tex_id, src->tex_target,
- src->tex_format, src->tex_width, GL_MEM_HEIGHT (src))) {
- GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory");
- gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo);
- goto memcpy;
- }
-
- gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo);
- } else {
- memcpy:
- if (!gst_gl_base_memory_memcpy ((GstGLBaseMemory *) src,
- (GstGLBaseMemory *) dest, offset, size)) {
- GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory");
- gst_memory_unref (GST_MEMORY_CAST (dest));
- return NULL;
- }
- }
-
- return (GstMemory *) dest;
-}
-
-static GstMemory *
-_gl_tex_copy (GstGLMemory * src, gssize offset, gssize size)
-{
- GstGLMemoryAllocatorClass *alloc_class;
-
- alloc_class = GST_GL_MEMORY_ALLOCATOR_GET_CLASS (src->mem.mem.allocator);
-
- if (src->tex_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Cannot copy External OES textures");
- return NULL;
- }
-
- g_return_val_if_fail (alloc_class->copy, NULL);
- return (GstMemory *) alloc_class->copy (GST_GL_BASE_MEMORY_CAST (src), offset,
- size);
-}
-
-static GstMemory *
-_gl_tex_alloc (GstAllocator * allocator, gsize size,
- GstAllocationParams * params)
-{
- g_warning ("Use gst_gl_base_memory_alloc to allocate from this allocator");
-
- return NULL;
-}
-
-static void
-_gl_tex_destroy (GstGLMemory * gl_mem)
-{
- const GstGLFuncs *gl = gl_mem->mem.context->gl_vtable;
-
- if (gl_mem->tex_id && !gl_mem->texture_wrapped)
- gl->DeleteTextures (1, &gl_mem->tex_id);
-}
-
-static GstGLMemory *
-_default_gl_tex_alloc (GstGLMemoryAllocator * allocator,
- GstGLVideoAllocationParams * params)
-{
- guint alloc_flags = params->parent.alloc_flags;
- GstGLMemory *mem;
-
- g_return_val_if_fail (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
- NULL);
-
- mem = g_new0 (GstGLMemory, 1);
-
- if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
- mem->tex_id = GPOINTER_TO_UINT (params->parent.gl_handle);
- mem->texture_wrapped = TRUE;
- }
-
- gst_gl_memory_init (mem, GST_ALLOCATOR_CAST (allocator), NULL,
- params->parent.context, params->target, params->tex_format,
- params->parent.alloc_params, params->v_info, params->plane,
- params->valign, params->parent.user_data, params->parent.notify);
-
- if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
- GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);
- }
- if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM) {
- mem->mem.data = params->parent.wrapped_data;
- GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD);
- }
-
- return mem;
-}
-
-static void
-gst_gl_memory_allocator_class_init (GstGLMemoryAllocatorClass * klass)
-{
- GstGLBaseMemoryAllocatorClass *gl_base;
- GstAllocatorClass *allocator_class;
-
- gl_base = (GstGLBaseMemoryAllocatorClass *) klass;
- allocator_class = (GstAllocatorClass *) klass;
-
- klass->map = (GstGLBaseMemoryAllocatorMapFunction) _default_gl_tex_map;
- klass->unmap = (GstGLBaseMemoryAllocatorUnmapFunction) _default_gl_tex_unmap;
- klass->copy = (GstGLBaseMemoryAllocatorCopyFunction) _default_gl_tex_copy;
-
- gl_base->alloc =
- (GstGLBaseMemoryAllocatorAllocFunction) _default_gl_tex_alloc;
- gl_base->create = (GstGLBaseMemoryAllocatorCreateFunction) _gl_tex_create;
- gl_base->map = (GstGLBaseMemoryAllocatorMapFunction) _gl_tex_map;
- gl_base->unmap = (GstGLBaseMemoryAllocatorUnmapFunction) _gl_tex_unmap;
- gl_base->copy = (GstGLBaseMemoryAllocatorCopyFunction) _gl_tex_copy;
- gl_base->destroy = (GstGLBaseMemoryAllocatorDestroyFunction) _gl_tex_destroy;
-
- allocator_class->alloc = _gl_tex_alloc;
-}
-
-static void
-gst_gl_memory_allocator_init (GstGLMemoryAllocator * allocator)
-{
- GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator);
-
- alloc->mem_type = GST_GL_MEMORY_ALLOCATOR_NAME;
-
- GST_OBJECT_FLAG_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC);
-}
-
-/**
- * gst_gl_memory_copy_into:
- * @gl_mem:a #GstGLMemory
- * @tex_id:OpenGL texture id
- * @target: the #GstGLTextureTarget
- * @tex_format: the #GstGLFormat
- * @width: width of @tex_id
- * @height: height of @tex_id
- *
- * Copies @gl_mem into the texture specfified by @tex_id. The format of @tex_id
- * is specified by @tex_format, @width and @height.
- *
- * Returns: Whether the copy suceeded
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_memory_copy_into (GstGLMemory * gl_mem, guint tex_id,
- GstGLTextureTarget target, GstGLFormat tex_format, gint width, gint height)
-{
- GstGLMemoryCopyParams copy_params;
-
- copy_params.src = gl_mem;
- copy_params.tex_id = tex_id;
- copy_params.tex_target = target;
- copy_params.tex_format = tex_format;
- copy_params.out_width = width;
- copy_params.out_height = height;
-
- gst_gl_context_thread_add (gl_mem->mem.context, _gl_tex_copy_thread,
- &copy_params);
-
- return copy_params.result;
-}
-
-/**
- * gst_gl_memory_get_texture_width:
- * @gl_mem: a #GstGLMemory
- *
- * Returns: the texture width of @gl_mem
- *
- * Since: 1.8
- */
-gint
-gst_gl_memory_get_texture_width (GstGLMemory * gl_mem)
-{
- g_return_val_if_fail (gst_is_gl_memory ((GstMemory *) gl_mem), 0);
-
- return gl_mem->tex_width;
-}
-
-/**
- * gst_gl_memory_get_texture_height:
- * @gl_mem: a #GstGLMemory
- *
- * Returns: the texture height of @gl_mem
- *
- * Since: 1.8
- */
-gint
-gst_gl_memory_get_texture_height (GstGLMemory * gl_mem)
-{
- g_return_val_if_fail (gst_is_gl_memory ((GstMemory *) gl_mem), 0);
-
- return _get_plane_height (&gl_mem->info, gl_mem->plane);
-}
-
-/**
- * gst_gl_memory_get_texture_format:
- * @gl_mem: a #GstGLMemory
- *
- * Returns: the #GstGLFormat of @gl_mem
- *
- * Since: 1.12
- */
-GstGLFormat
-gst_gl_memory_get_texture_format (GstGLMemory * gl_mem)
-{
- g_return_val_if_fail (gst_is_gl_memory ((GstMemory *) gl_mem), 0);
-
- return gl_mem->tex_format;
-}
-
-/**
- * gst_gl_memory_get_texture_target:
- * @gl_mem: a #GstGLMemory
- *
- * Returns: the #GstGLTextureTarget of @gl_mem
- *
- * Since: 1.8
- */
-GstGLTextureTarget
-gst_gl_memory_get_texture_target (GstGLMemory * gl_mem)
-{
- g_return_val_if_fail (gst_is_gl_memory ((GstMemory *) gl_mem), 0);
-
- return gl_mem->tex_target;
-}
-
-/**
- * gst_gl_memory_get_texture_id:
- * @gl_mem: a #GstGLMemory
- *
- * Returns: the OpenGL texture handle of @gl_mem
- *
- * Since: 1.8
- */
-guint
-gst_gl_memory_get_texture_id (GstGLMemory * gl_mem)
-{
- g_return_val_if_fail (gst_is_gl_memory ((GstMemory *) gl_mem), 0);
-
- return gl_mem->tex_id;
-}
-
-/**
- * gst_gl_memory_init_once:
- *
- * Initializes the GL Base Texture allocator. It is safe to call this function
- * multiple times. This must be called before any other GstGLMemory operation.
- *
- * Since: 1.4
- */
-void
-gst_gl_memory_init_once (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- gst_gl_base_memory_init_once ();
-
- GST_DEBUG_CATEGORY_INIT (GST_CAT_GL_MEMORY, "glbasetexture", 0,
- "OpenGL Base Texture Memory");
-
- _gl_memory_allocator = g_object_new (GST_TYPE_GL_MEMORY_ALLOCATOR, NULL);
- gst_object_ref_sink (_gl_memory_allocator);
-
- gst_allocator_register (GST_GL_MEMORY_ALLOCATOR_NAME, _gl_memory_allocator);
-
- g_once_init_leave (&_init, 1);
- }
-}
-
-/**
- * gst_is_gl_memory:
- * @mem:a #GstMemory
- *
- * Returns: whether the memory at @mem is a #GstGLMemory
- *
- * Since: 1.4
- */
-gboolean
-gst_is_gl_memory (GstMemory * mem)
-{
- return mem != NULL && mem->allocator != NULL
- && g_type_is_a (G_OBJECT_TYPE (mem->allocator),
- GST_TYPE_GL_MEMORY_ALLOCATOR);
-}
-
-G_DEFINE_BOXED_TYPE (GstGLVideoAllocationParams, gst_gl_video_allocation_params,
- (GBoxedCopyFunc) gst_gl_allocation_params_copy,
- (GBoxedFreeFunc) gst_gl_allocation_params_free);
-
-static void
-_gst_gl_video_allocation_params_set_video_alignment (GstGLVideoAllocationParams
- * params, GstVideoAlignment * valign)
-{
- g_return_if_fail (params != NULL);
-
- if (!params->valign)
- params->valign = g_new0 (GstVideoAlignment, 1);
-
- if (valign) {
- *params->valign = *valign;
- } else {
- gst_video_alignment_reset (params->valign);
- }
-}
-
-/**
- * gst_gl_video_allocation_params_init_full:
- * @params: a #GstGLVideoAllocationParams to initialize
- * @struct_size: the size of the struct in @params
- * @alloc_flags: some allocation flags
- * @copy: a copy function
- * @free: a free function
- * @context: a #GstGLContext
- * @alloc_params: (allow-none): the #GstAllocationParams for @wrapped_data
- * @v_info: the #GstVideoInfo for @wrapped_data
- * @plane: the video plane @wrapped_data represents
- * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @wrapped_data
- * @target: the #GstGLTextureTarget
- * @tex_format: the #GstGLFormat
- * @wrapped_data: (allow-none): the optional data pointer to wrap
- * @gl_handle: the optional OpenGL handle to wrap or 0
- * @user_data: (allow-none): user data to call @notify with
- * @notify: (allow-none): a #GDestroyNotify
- *
- * Intended for subclass usage
- *
- * Returns: initializes @params with the parameters specified
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params,
- gsize struct_size, guint alloc_flags, GstGLAllocationParamsCopyFunc copy,
- GstGLAllocationParamsFreeFunc free, GstGLContext * context,
- GstAllocationParams * alloc_params, GstVideoInfo * v_info,
- guint plane, GstVideoAlignment * valign, GstGLTextureTarget target,
- GstGLFormat tex_format, gpointer wrapped_data, gpointer gl_handle,
- gpointer user_data, GDestroyNotify notify)
-{
- guint i;
-
- g_return_val_if_fail (params != NULL, FALSE);
- g_return_val_if_fail (copy != NULL, FALSE);
- g_return_val_if_fail (free != NULL, FALSE);
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
- g_return_val_if_fail (v_info != NULL, FALSE);
-
- memset (params, 0, sizeof (*params));
-
- if (!gst_gl_allocation_params_init ((GstGLAllocationParams *) params,
- struct_size, alloc_flags, copy, free, context, 0, alloc_params,
- wrapped_data, gl_handle, user_data, notify))
- return FALSE;
-
- params->v_info = g_new0 (GstVideoInfo, 1);
- *params->v_info = *v_info;
- for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
- params->v_info->offset[i] = v_info->offset[i];
- params->v_info->stride[i] = v_info->stride[i];
- }
- _gst_gl_video_allocation_params_set_video_alignment (params, valign);
- params->target = target;
- params->tex_format = tex_format;
- params->plane = plane;
-
- return TRUE;
-}
-
-/**
- * gst_gl_video_allocation_params_new:
- * @context: a #GstGLContext
- * @alloc_params: (allow-none): the #GstAllocationParams for sysmem mappings of the texture
- * @v_info: the #GstVideoInfo for the texture
- * @plane: the video plane of @v_info to allocate
- * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of the texture
- * @target: the #GstGLTextureTarget for the created textures
- * @tex_format: the #GstGLFormat for the created textures
- *
- * Returns: a new #GstGLVideoAllocationParams for allocating #GstGLMemory's
- *
- * Since: 1.8
- */
-GstGLVideoAllocationParams *
-gst_gl_video_allocation_params_new (GstGLContext * context,
- GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
- GstVideoAlignment * valign, GstGLTextureTarget target,
- GstGLFormat tex_format)
-{
- GstGLVideoAllocationParams *params = g_new0 (GstGLVideoAllocationParams, 1);
-
- if (!gst_gl_video_allocation_params_init_full (params,
- sizeof (GstGLVideoAllocationParams),
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_ALLOC |
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
- (GstGLAllocationParamsCopyFunc)
- gst_gl_video_allocation_params_copy_data,
- (GstGLAllocationParamsFreeFunc)
- gst_gl_video_allocation_params_free_data, context, alloc_params,
- v_info, plane, valign, target, tex_format, NULL, 0, NULL, NULL)) {
- g_free (params);
- return NULL;
- }
-
- return params;
-}
-
-/**
- * gst_gl_video_allocation_params_new_wrapped_data:
- * @context: a #GstGLContext
- * @alloc_params: (allow-none): the #GstAllocationParams for @wrapped_data
- * @v_info: the #GstVideoInfo for @wrapped_data
- * @plane: the video plane @wrapped_data represents
- * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @wrapped_data
- * @target: the #GstGLTextureTarget for @wrapped_data
- * @tex_format: the #GstGLFormat for @wrapped_data
- * @wrapped_data: the data pointer to wrap
- * @user_data: (allow-none): user data to call @notify with
- * @notify: (allow-none): a #GDestroyNotify
- *
- * Returns: a new #GstGLVideoAllocationParams for wrapping @wrapped_data
- *
- * Since: 1.8
- */
-GstGLVideoAllocationParams *
-gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
- GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
- GstVideoAlignment * valign, GstGLTextureTarget target,
- GstGLFormat tex_format, gpointer wrapped_data, gpointer user_data,
- GDestroyNotify notify)
-{
- GstGLVideoAllocationParams *params = g_new0 (GstGLVideoAllocationParams, 1);
-
- if (!gst_gl_video_allocation_params_init_full (params,
- sizeof (GstGLVideoAllocationParams),
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM |
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
- (GstGLAllocationParamsCopyFunc)
- gst_gl_video_allocation_params_copy_data,
- (GstGLAllocationParamsFreeFunc)
- gst_gl_video_allocation_params_free_data, context, alloc_params,
- v_info, plane, valign, target, tex_format, wrapped_data, 0, user_data,
- notify)) {
- g_free (params);
- return NULL;
- }
-
- return params;
-}
-
-/**
- * gst_gl_video_allocation_params_new_wrapped_gl_handle:
- * @context: a #GstGLContext
- * @alloc_params: (allow-none): the #GstAllocationParams for @tex_id
- * @v_info: the #GstVideoInfo for @tex_id
- * @plane: the video plane @tex_id represents
- * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @tex_id
- * @target: the #GstGLTextureTarget for @tex_id
- * @tex_format: the #GstGLFormat for @tex_id
- * @gl_handle: the GL handle to wrap
- * @user_data: (allow-none): user data to call @notify with
- * @notify: (allow-none): a #GDestroyNotify
- *
- * @gl_handle is defined by the specific OpenGL handle being wrapped
- * For #GstGLMemory and #GstGLMemoryPBO it is an OpenGL texture id.
- * Other memory types may define it to require a different type of parameter.
- *
- * Returns: a new #GstGLVideoAllocationParams for wrapping @gl_handle
- *
- * Since: 1.8
- */
-GstGLVideoAllocationParams *
-gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context,
- GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
- GstVideoAlignment * valign, GstGLTextureTarget target,
- GstGLFormat tex_format, gpointer gl_handle, gpointer user_data,
- GDestroyNotify notify)
-{
- GstGLVideoAllocationParams *params = g_new0 (GstGLVideoAllocationParams, 1);
-
- if (!gst_gl_video_allocation_params_init_full (params,
- sizeof (GstGLVideoAllocationParams),
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE |
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
- (GstGLAllocationParamsCopyFunc)
- gst_gl_video_allocation_params_copy_data,
- (GstGLAllocationParamsFreeFunc)
- gst_gl_video_allocation_params_free_data, context, alloc_params,
- v_info, plane, valign, target, tex_format, NULL, gl_handle, user_data,
- notify)) {
- g_free (params);
- return NULL;
- }
-
- return params;
-}
-
-/**
- * gst_gl_video_allocation_params_new_wrapped_texture:
- * @context: a #GstGLContext
- * @alloc_params: (allow-none): the #GstAllocationParams for @tex_id
- * @v_info: the #GstVideoInfo for @tex_id
- * @plane: the video plane @tex_id represents
- * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @tex_id
- * @target: the #GstGLTextureTarget for @tex_id
- * @tex_format: the #GstGLFormat for @tex_id
- * @tex_id: the GL texture to wrap
- * @user_data: (allow-none): user data to call @notify with
- * @notify: (allow-none): a #GDestroyNotify
- *
- * Returns: a new #GstGLVideoAllocationParams for wrapping @tex_id
- *
- * Since: 1.8
- */
-GstGLVideoAllocationParams *
-gst_gl_video_allocation_params_new_wrapped_texture (GstGLContext * context,
- GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
- GstVideoAlignment * valign, GstGLTextureTarget target,
- GstGLFormat tex_format, guint tex_id, gpointer user_data,
- GDestroyNotify notify)
-{
- return gst_gl_video_allocation_params_new_wrapped_gl_handle (context,
- alloc_params, v_info, plane, valign, target, tex_format,
- GUINT_TO_POINTER (tex_id), user_data, notify);
-}
-
-/**
- * gst_gl_video_allocation_params_free_data:
- * @params: a #GstGLVideoAllocationParams
- *
- * Unset and free any dynamically allocated resources. Intended for subclass
- * usage only to chain up at the end of a subclass free function.
- *
- * Since: 1.8
- */
-void
-gst_gl_video_allocation_params_free_data (GstGLVideoAllocationParams * params)
-{
- g_free (params->v_info);
- g_free (params->valign);
-
- gst_gl_allocation_params_free_data (&params->parent);
-}
-
-/**
- * gst_gl_video_allocation_params_copy_data:
- * @src_vid: source #GstGLVideoAllocationParams to copy from
- * @dest_vid: destination #GstGLVideoAllocationParams to copy into
- *
- * Copy and set any dynamically allocated resources in @dest_vid. Intended
- * for subclass usage only to chain up at the end of a subclass copy function.
- *
- * Since: 1.8
- */
-void
-gst_gl_video_allocation_params_copy_data (GstGLVideoAllocationParams * src_vid,
- GstGLVideoAllocationParams * dest_vid)
-{
- GstGLAllocationParams *src = (GstGLAllocationParams *) src_vid;
- GstGLAllocationParams *dest = (GstGLAllocationParams *) dest_vid;
- guint i;
-
- gst_gl_allocation_params_copy_data (src, dest);
-
- dest_vid->v_info = g_new0 (GstVideoInfo, 1);
- *dest_vid->v_info = *src_vid->v_info;
- for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
- dest_vid->v_info->offset[i] = src_vid->v_info->offset[i];
- dest_vid->v_info->stride[i] = src_vid->v_info->stride[i];
- }
- _gst_gl_video_allocation_params_set_video_alignment (dest_vid,
- src_vid->valign);
- dest_vid->target = src_vid->target;
- dest_vid->tex_format = src_vid->tex_format;
- dest_vid->plane = src_vid->plane;
-}
-
-/**
- * gst_gl_memory_setup_buffer:
- * @allocator: the @GstGLMemoryAllocator to allocate from
- * @buffer: a #GstBuffer to setup
- * @params: the #GstGLVideoAllocationParams to allocate with
- * @tex_formats: (allow-none): a list of #GstGLFormat's to allocate with.
- * @wrapped_data: a list of wrapped data pointers
- * @n_wrapped_pointers: the number of elements in @tex_formats and @wrapped_data
- *
- * Returns: whether the buffer was correctly setup
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
- GstBuffer * buffer, GstGLVideoAllocationParams * params,
- GstGLFormat * tex_formats, gpointer * wrapped_data,
- gsize n_wrapped_pointers)
-{
- GstGLBaseMemoryAllocator *base_allocator;
- guint n_mem, i, v, views;
- guint alloc_flags = params->parent.alloc_flags;
-
- g_return_val_if_fail (params != NULL, FALSE);
- g_return_val_if_fail (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
- FALSE);
-
- base_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator);
- n_mem = GST_VIDEO_INFO_N_PLANES (params->v_info);
-
- if (GST_VIDEO_INFO_MULTIVIEW_MODE (params->v_info) ==
- GST_VIDEO_MULTIVIEW_MODE_SEPARATED)
- views = params->v_info->views;
- else
- views = 1;
-
- g_return_val_if_fail (!wrapped_data
- || views * n_mem != n_wrapped_pointers, FALSE);
-
- for (v = 0; v < views; v++) {
- for (i = 0; i < n_mem; i++) {
- GstGLMemory *gl_mem;
-
- if (tex_formats) {
- params->tex_format = tex_formats[i];
- } else {
- params->tex_format =
- gst_gl_format_from_video_info (params->parent.context,
- params->v_info, i);
- }
-
- params->plane = i;
- if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM) {
- g_return_val_if_fail (wrapped_data != NULL, FALSE);
- params->parent.wrapped_data = wrapped_data[i];
- } else if (alloc_flags &
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
- g_return_val_if_fail (wrapped_data != NULL, FALSE);
- params->parent.gl_handle = wrapped_data[i];
- }
-
- if (!(gl_mem = (GstGLMemory *) gst_gl_base_memory_alloc (base_allocator,
- (GstGLAllocationParams *) params)))
- return FALSE;
-
- gst_buffer_append_memory (buffer, (GstMemory *) gl_mem);
- }
-
- gst_buffer_add_video_meta_full (buffer, v,
- GST_VIDEO_INFO_FORMAT (params->v_info),
- GST_VIDEO_INFO_WIDTH (params->v_info),
- GST_VIDEO_INFO_HEIGHT (params->v_info), n_mem, params->v_info->offset,
- params->v_info->stride);
- }
-
- return TRUE;
-}
-
-/**
- * gst_gl_memory_allocator_get_default:
- * @context: a #GstGLContext
- *
- * Returns: (transfer full): the default #GstGLMemoryAllocator supported by
- * @context
- *
- * Since: 1.8
- */
-GstGLMemoryAllocator *
-gst_gl_memory_allocator_get_default (GstGLContext * context)
-{
- GstGLMemoryAllocator *allocator = NULL;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), NULL);
-
- /* we can only use the pbo allocator with GL > 3.0 contexts */
- if (gst_gl_context_check_gl_version (context,
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2, 3, 0)) {
- allocator = (GstGLMemoryAllocator *)
- gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
- } else {
- allocator = (GstGLMemoryAllocator *)
- gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME);
- }
-
- return allocator;
-}
diff --git a/gst-libs/gst/gl/gstglmemory.h b/gst-libs/gst/gl/gstglmemory.h
deleted file mode 100644
index e7721a79f..000000000
--- a/gst-libs/gst/gl/gstglmemory.h
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_GL_MEMORY_H_
-#define _GST_GL_MEMORY_H_
-
-#include <gst/gl/gstglbasememory.h>
-#include <gst/gl/gstglformat.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_MEMORY_ALLOCATOR (gst_gl_memory_allocator_get_type())
-GST_EXPORT
-GType gst_gl_memory_allocator_get_type(void);
-
-#define GST_IS_GL_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_MEMORY_ALLOCATOR))
-#define GST_IS_GL_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GL_MEMORY_ALLOCATOR))
-#define GST_GL_MEMORY_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GL_MEMORY_ALLOCATOR, GstGLMemoryAllocatorClass))
-#define GST_GL_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_MEMORY_ALLOCATOR, GstGLMemoryAllocator))
-#define GST_GL_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_MEMORY_ALLOCATOR, GstGLMemoryAllocatorClass))
-#define GST_GL_MEMORY_ALLOCATOR_CAST(obj) ((GstGLMemoryAllocator *)(obj))
-
-#define GST_GL_MEMORY_CAST(obj) ((GstGLMemory *) obj)
-
-/**
- * GST_CAPS_FEATURE_MEMORY_GL_MEMORY:
- *
- * Name of the caps feature for indicating the use of #GstGLMemory
- */
-#define GST_CAPS_FEATURE_MEMORY_GL_MEMORY "memory:GLMemory"
-/**
- * GST_GL_MEMORY_VIDEO_FORMATS_STR:
- *
- * List of video formats that are supported by #GstGLMemory
- */
-#define GST_GL_MEMORY_VIDEO_FORMATS_STR \
- "{ RGBA, BGRA, RGBx, BGRx, ARGB, ABGR, xRGB, xBGR, RGB, BGR, RGB16, BGR16, " \
- "AYUV, I420, YV12, NV12, NV21, YUY2, UYVY, Y41B, Y42B, Y444, " \
- "GRAY8, GRAY16_LE, GRAY16_BE }"
-
-/**
- * GstGLMemory:
- * @mem: the parent #GstGLBaseMemory object
- * @tex_id: the GL texture id for this memory
- * @tex_target: the GL texture target for this memory
- * @tex_type: the texture type
- * @info: the texture's #GstVideoInfo
- * @valign: data alignment for system memory mapping
- * @plane: data plane in @info
- * @tex_scaling: GL shader scaling parameters for @valign and/or width/height
- *
- * Represents information about a GL texture
- */
-struct _GstGLMemory
-{
- GstGLBaseMemory mem;
-
- guint tex_id;
- GstGLTextureTarget tex_target;
- GstGLFormat tex_format;
- GstVideoInfo info;
- GstVideoAlignment valign;
- guint plane;
- gfloat tex_scaling[2];
-
- /* <protected> */
- gboolean texture_wrapped;
- guint unpack_length;
- guint tex_width;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-
-#define GST_TYPE_GL_VIDEO_ALLOCATION_PARAMS (gst_gl_video_allocation_params_get_type())
-GST_EXPORT
-GType gst_gl_video_allocation_params_get_type (void);
-
-typedef struct _GstGLVideoAllocationParams GstGLVideoAllocationParams;
-
-/**
- * GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO:
- *
- * GL allocation flag indicating the allocation of 2D video frames
- */
-#define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO (1 << 3)
-
-/**
- * GstGLVideoAllocationParams:
- * @parent: the parent #GstGLAllocationParams structure
- * @v_info: the #GstVideoInfo to allocate
- * @plane: the video plane index to allocate
- * @valign: the #GstVideoAlignment to align the system representation to (may be %NULL for the default)
- * @target: the #GstGLTextureTarget to allocate
- * @tex_format: the #GstGLFormat to allocate
- */
-struct _GstGLVideoAllocationParams
-{
- GstGLAllocationParams parent;
-
- GstVideoInfo *v_info;
- guint plane;
- GstVideoAlignment *valign;
- GstGLTextureTarget target;
- GstGLFormat tex_format;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-gboolean gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params,
- gsize struct_size,
- guint alloc_flags,
- GstGLAllocationParamsCopyFunc copy,
- GstGLAllocationParamsFreeFunc free,
- GstGLContext * context,
- GstAllocationParams * alloc_params,
- GstVideoInfo * v_info,
- guint plane,
- GstVideoAlignment * valign,
- GstGLTextureTarget target,
- GstGLFormat tex_format,
- gpointer wrapped_data,
- gpointer gl_handle,
- gpointer user_data,
- GDestroyNotify notify);
-GST_EXPORT
-GstGLVideoAllocationParams * gst_gl_video_allocation_params_new (GstGLContext * context,
- GstAllocationParams * alloc_params,
- GstVideoInfo * v_info,
- guint plane,
- GstVideoAlignment * valign,
- GstGLTextureTarget target,
- GstGLFormat tex_format);
-GST_EXPORT
-GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
- GstAllocationParams * alloc_params,
- GstVideoInfo * v_info,
- guint plane,
- GstVideoAlignment * valign,
- GstGLTextureTarget target,
- GstGLFormat tex_format,
- gpointer wrapped_data,
- gpointer user_data,
- GDestroyNotify notify);
-
-GST_EXPORT
-GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_texture (GstGLContext * context,
- GstAllocationParams * alloc_params,
- GstVideoInfo * v_info,
- guint plane,
- GstVideoAlignment * valign,
- GstGLTextureTarget target,
- GstGLFormat tex_format,
- guint tex_id,
- gpointer user_data,
- GDestroyNotify notify);
-
-GST_EXPORT
-GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context,
- GstAllocationParams * alloc_params,
- GstVideoInfo * v_info,
- guint plane,
- GstVideoAlignment * valign,
- GstGLTextureTarget target,
- GstGLFormat tex_format,
- gpointer gl_handle,
- gpointer user_data,
- GDestroyNotify notify);
-
-/* subclass usage */
-GST_EXPORT
-void gst_gl_video_allocation_params_free_data (GstGLVideoAllocationParams * params);
-/* subclass usage */
-GST_EXPORT
-void gst_gl_video_allocation_params_copy_data (GstGLVideoAllocationParams * src_vid,
- GstGLVideoAllocationParams * dest_vid);
-
-/**
- * GstGLMemoryAllocator
- *
- * Opaque #GstGLMemoryAllocator struct
- */
-struct _GstGLMemoryAllocator
-{
- /* <private> */
- GstGLBaseMemoryAllocator parent;
-
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GstGLMemoryAllocatorClass:
- * @map: provide a custom map implementation
- * @copy: provide a custom copy implementation
- * @unmap: provide a custom unmap implementation
- */
-struct _GstGLMemoryAllocatorClass
-{
- /* <private> */
- GstGLBaseMemoryAllocatorClass parent_class;
-
- /* <public> */
- GstGLBaseMemoryAllocatorMapFunction map;
- GstGLBaseMemoryAllocatorCopyFunction copy;
- GstGLBaseMemoryAllocatorUnmapFunction unmap;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-#include <gst/gl/gstglbasememory.h>
-
-/**
- * GST_GL_MEMORY_ALLOCATOR_NAME:
- *
- * The name of the GL memory allocator
- */
-#define GST_GL_MEMORY_ALLOCATOR_NAME "GLMemory"
-
-GST_EXPORT
-void gst_gl_memory_init_once (void);
-GST_EXPORT
-gboolean gst_is_gl_memory (GstMemory * mem);
-
-GST_EXPORT
-void gst_gl_memory_init (GstGLMemory * mem,
- GstAllocator * allocator,
- GstMemory * parent,
- GstGLContext * context,
- GstGLTextureTarget target,
- GstGLFormat tex_format,
- GstAllocationParams *params,
- GstVideoInfo * info,
- guint plane,
- GstVideoAlignment *valign,
- gpointer user_data,
- GDestroyNotify notify);
-
-GST_EXPORT
-gboolean gst_gl_memory_copy_into (GstGLMemory *gl_mem,
- guint tex_id,
- GstGLTextureTarget target,
- GstGLFormat tex_format,
- gint width,
- gint height);
-GST_EXPORT
-gboolean gst_gl_memory_copy_teximage (GstGLMemory * src,
- guint tex_id,
- GstGLTextureTarget out_target,
- GstGLFormat out_tex_format,
- gint width,
- gint height);
-
-GST_EXPORT
-gboolean gst_gl_memory_read_pixels (GstGLMemory * gl_mem,
- gpointer read_pointer);
-GST_EXPORT
-void gst_gl_memory_texsubimage (GstGLMemory * gl_mem,
- gpointer read_pointer);
-
-/* accessors */
-GST_EXPORT
-gint gst_gl_memory_get_texture_width (GstGLMemory * gl_mem);
-GST_EXPORT
-gint gst_gl_memory_get_texture_height (GstGLMemory * gl_mem);
-GST_EXPORT
-GstGLFormat gst_gl_memory_get_texture_format (GstGLMemory * gl_mem);
-GST_EXPORT
-GstGLTextureTarget gst_gl_memory_get_texture_target (GstGLMemory * gl_mem);
-GST_EXPORT
-guint gst_gl_memory_get_texture_id (GstGLMemory * gl_mem);
-
-GST_EXPORT
-gboolean gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
- GstBuffer * buffer,
- GstGLVideoAllocationParams * params,
- GstGLFormat *tex_formats,
- gpointer *wrapped_data,
- gsize n_wrapped_pointers);
-
-GST_EXPORT
-GstGLMemoryAllocator * gst_gl_memory_allocator_get_default (GstGLContext *context);
-
-G_END_DECLS
-
-#endif /* _GST_GL_MEMORY_H_ */
diff --git a/gst-libs/gst/gl/gstglmemorypbo.c b/gst-libs/gst/gl/gstglmemorypbo.c
deleted file mode 100644
index 4a62a383c..000000000
--- a/gst-libs/gst/gl/gstglmemorypbo.c
+++ /dev/null
@@ -1,867 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "gstglmemorypbo.h"
-
-#include "gstglbuffer.h"
-#include "gstglcontext.h"
-#include "gstglfuncs.h"
-#include "gstglutils.h"
-
-/**
- * SECTION:gstglmemorypbo
- * @title: GstGLMemoryPBO
- * @short_description: memory subclass for GL textures
- * @see_also: #GstMemory, #GstAllocator, #GstGLBufferPool
- *
- * #GstGLMemoryPBO is created or wrapped through gst_gl_base_memory_alloc()
- * with #GstGLVideoAllocationParams.
- *
- * Data is uploaded or downloaded from the GPU as is necessary.
- */
-
-/* Implementation notes
- *
- * PBO transfer's are implemented using GstGLBuffer. We just need to
- * ensure that the texture data is written/read to/from before/after calling
- * map (mem->pbo, READ) which performs the pbo buffer transfer.
- */
-
-#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
-#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
-#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
-#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
-#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-
-#define GL_MEM_HEIGHT(gl_mem) _get_plane_height (&gl_mem->mem.info, gl_mem->mem.plane)
-#define GL_MEM_STRIDE(gl_mem) GST_VIDEO_INFO_PLANE_STRIDE (&gl_mem->mem.info, gl_mem->mem.plane)
-
-#define CONTEXT_SUPPORTS_PBO_UPLOAD(context) \
- (gst_gl_context_check_gl_version (context, \
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3, 2, 1) \
- || gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-#define CONTEXT_SUPPORTS_PBO_DOWNLOAD(context) \
- (gst_gl_context_check_gl_version (context, \
- GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2, 3, 0))
-
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_MEMORY);
-#define GST_CAT_DEFAULT GST_CAT_GL_MEMORY
-
-static GstAllocator *_gl_allocator;
-
-/* compatability definitions... */
-#ifndef GL_PIXEL_PACK_BUFFER
-#define GL_PIXEL_PACK_BUFFER 0x88EB
-#endif
-#ifndef GL_PIXEL_UNPACK_BUFFER
-#define GL_PIXEL_UNPACK_BUFFER 0x88EC
-#endif
-#ifndef GL_STREAM_READ
-#define GL_STREAM_READ 0x88E1
-#endif
-#ifndef GL_STREAM_DRAW
-#define GL_STREAM_DRAW 0x88E0
-#endif
-#ifndef GL_STREAM_COPY
-#define GL_STREAM_COPY 0x88E2
-#endif
-#ifndef GL_UNPACK_ROW_LENGTH
-#define GL_UNPACK_ROW_LENGTH 0x0CF2
-#endif
-
-#ifndef GL_TEXTURE_RECTANGLE
-#define GL_TEXTURE_RECTANGLE 0x84F5
-#endif
-#ifndef GL_TEXTURE_EXTERNAL_OES
-#define GL_TEXTURE_EXTERNAL_OES 0x8D65
-#endif
-
-#define parent_class gst_gl_memory_pbo_allocator_parent_class
-G_DEFINE_TYPE (GstGLMemoryPBOAllocator, gst_gl_memory_pbo_allocator,
- GST_TYPE_GL_MEMORY_ALLOCATOR);
-
-typedef struct
-{
- /* in */
- GstGLMemoryPBO *src;
- GstGLFormat out_format;
- guint out_width, out_height;
- guint out_stride;
- gboolean respecify;
- GstGLTextureTarget tex_target;
- /* inout */
- guint tex_id;
- /* out */
- gboolean result;
-} GstGLMemoryPBOCopyParams;
-
-static inline guint
-_get_plane_height (GstVideoInfo * info, guint plane)
-{
- if (GST_VIDEO_INFO_IS_YUV (info))
- /* For now component width and plane width are the same and the
- * plane-component mapping matches
- */
- return GST_VIDEO_INFO_COMP_HEIGHT (info, plane);
- else /* RGB, GRAY */
- return GST_VIDEO_INFO_HEIGHT (info);
-}
-
-static void
-_upload_pbo_memory (GstGLMemoryPBO * gl_mem, GstMapInfo * info,
- GstGLBuffer * pbo, GstMapInfo * pbo_info)
-{
- GstGLContext *context = gl_mem->mem.mem.context;
- const GstGLFuncs *gl;
- guint pbo_id;
-
- if (!GST_MEMORY_FLAG_IS_SET (gl_mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD))
- return;
-
- g_return_if_fail (CONTEXT_SUPPORTS_PBO_UPLOAD (context));
-
- gl = context->gl_vtable;
- pbo_id = *(guint *) pbo_info->data;
-
- GST_CAT_LOG (GST_CAT_GL_MEMORY, "upload for texture id:%u, with pbo %u %ux%u",
- gl_mem->mem.tex_id, pbo_id, gl_mem->mem.tex_width,
- GL_MEM_HEIGHT (gl_mem));
-
- gl->BindBuffer (GL_PIXEL_UNPACK_BUFFER, pbo_id);
- gst_gl_memory_texsubimage (GST_GL_MEMORY_CAST (gl_mem), NULL);
- gl->BindBuffer (GL_PIXEL_UNPACK_BUFFER, 0);
-}
-
-static guint
-_new_texture (GstGLContext * context, guint target, guint internal_format,
- guint format, guint type, guint width, guint height)
-{
- const GstGLFuncs *gl = context->gl_vtable;
- guint tex_id;
-
- gl->GenTextures (1, &tex_id);
- gl->BindTexture (target, tex_id);
- if (target == GL_TEXTURE_2D || target == GL_TEXTURE_RECTANGLE)
- gl->TexImage2D (target, 0, internal_format, width, height, 0, format, type,
- NULL);
-
- gl->TexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- gl->TexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- gl->TexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- gl->TexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- gl->BindTexture (target, 0);
-
- return tex_id;
-}
-
-static gboolean
-_gl_mem_create (GstGLMemoryPBO * gl_mem, GError ** error)
-{
- GstGLContext *context = gl_mem->mem.mem.context;
- GstGLBaseMemoryAllocatorClass *alloc_class;
-
- alloc_class = GST_GL_BASE_MEMORY_ALLOCATOR_CLASS (parent_class);
- if (!alloc_class->create ((GstGLBaseMemory *) gl_mem, error))
- return FALSE;
-
- if (CONTEXT_SUPPORTS_PBO_DOWNLOAD (context)
- || CONTEXT_SUPPORTS_PBO_UPLOAD (context)) {
- GstAllocationParams alloc_params =
- { 0, GST_MEMORY_CAST (gl_mem)->align, 0, 0 };
- GstGLBaseMemoryAllocator *buf_allocator;
- GstGLBufferAllocationParams *params;
-
- buf_allocator =
- GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find
- (GST_GL_BUFFER_ALLOCATOR_NAME));
- params =
- gst_gl_buffer_allocation_params_new (context,
- GST_MEMORY_CAST (gl_mem)->size, &alloc_params, GL_PIXEL_UNPACK_BUFFER,
- GL_STREAM_DRAW);
-
- /* FIXME: lazy init this for resource constrained platforms
- * Will need to fix pbo detection based on the existence of the mem.id then */
- gl_mem->pbo = (GstGLBuffer *) gst_gl_base_memory_alloc (buf_allocator,
- (GstGLAllocationParams *) params);
-
- gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
- gst_object_unref (buf_allocator);
-
- GST_CAT_LOG (GST_CAT_GL_MEMORY, "generated pbo %u", gl_mem->pbo->id);
- }
-
- return TRUE;
-}
-
-static gboolean
-_read_pixels_to_pbo (GstGLMemoryPBO * gl_mem)
-{
- if (!gl_mem->pbo || !CONTEXT_SUPPORTS_PBO_DOWNLOAD (gl_mem->mem.mem.context)
- || gl_mem->mem.tex_format == GST_GL_LUMINANCE
- || gl_mem->mem.tex_format == GST_GL_LUMINANCE_ALPHA)
- /* unsupported */
- return FALSE;
-
- if (GST_MEMORY_FLAG_IS_SET (gl_mem,
- GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)) {
- /* copy texture data into into the pbo and map that */
- gsize plane_start;
- GstMapInfo pbo_info;
-
- plane_start =
- gst_gl_get_plane_start (&gl_mem->mem.info, &gl_mem->mem.valign,
- gl_mem->mem.plane) + GST_MEMORY_CAST (gl_mem)->offset;
-
- gl_mem->pbo->target = GL_PIXEL_PACK_BUFFER;
- if (!gst_memory_map (GST_MEMORY_CAST (gl_mem->pbo), &pbo_info,
- GST_MAP_WRITE | GST_MAP_GL)) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Failed to map pbo for writing");
- return FALSE;
- }
-
- if (!gst_gl_memory_read_pixels ((GstGLMemory *) gl_mem,
- (gpointer) plane_start)) {
- gst_memory_unmap (GST_MEMORY_CAST (gl_mem->pbo), &pbo_info);
- return FALSE;
- }
-
- gst_memory_unmap (GST_MEMORY_CAST (gl_mem->pbo), &pbo_info);
- }
-
- return TRUE;
-}
-
-static gpointer
-_pbo_download_transfer (GstGLMemoryPBO * gl_mem, GstMapInfo * info, gsize size)
-{
- GstMapInfo *pbo_info;
-
- gl_mem->pbo->target = GL_PIXEL_PACK_BUFFER;
- /* texture -> pbo */
- if (info->flags & GST_MAP_READ
- && GST_MEMORY_FLAG_IS_SET (gl_mem,
- GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD)) {
- GstMapInfo info;
-
- GST_CAT_TRACE (GST_CAT_GL_MEMORY,
- "attempting download of texture %u " "using pbo %u", gl_mem->mem.tex_id,
- gl_mem->pbo->id);
-
- if (!gst_memory_map (GST_MEMORY_CAST (gl_mem->pbo), &info,
- GST_MAP_WRITE | GST_MAP_GL)) {
- GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Failed to write to PBO");
- return NULL;
- }
-
- if (!_read_pixels_to_pbo (gl_mem)) {
- gst_memory_unmap (GST_MEMORY_CAST (gl_mem->pbo), &info);
- return NULL;
- }
-
- gst_memory_unmap (GST_MEMORY_CAST (gl_mem->pbo), &info);
- }
-
- pbo_info = g_new0 (GstMapInfo, 1);
-
- /* pbo -> data */
- /* get a cpu accessible mapping from the pbo */
- if (!gst_memory_map (GST_MEMORY_CAST (gl_mem->pbo), pbo_info, info->flags)) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Failed to map pbo");
- g_free (pbo_info);
- return NULL;
- }
- info->user_data[0] = pbo_info;
-
- return pbo_info->data;
-}
-
-static gpointer
-_gl_mem_map_cpu_access (GstGLMemoryPBO * gl_mem, GstMapInfo * info, gsize size)
-{
- gpointer data = NULL;
-
- gst_gl_base_memory_alloc_data ((GstGLBaseMemory *) gl_mem);
-
- if (!data && gl_mem->pbo
- && CONTEXT_SUPPORTS_PBO_DOWNLOAD (gl_mem->mem.mem.context))
- data = _pbo_download_transfer (gl_mem, info, size);
-
- if (!data) {
- GstGLMemoryAllocatorClass *alloc_class;
-
- alloc_class = GST_GL_MEMORY_ALLOCATOR_CLASS (parent_class);
-
- data = alloc_class->map ((GstGLBaseMemory *) gl_mem, info, size);
- }
-
- return data;
-}
-
-static gpointer
-_gl_mem_map_gpu_access (GstGLMemoryPBO * gl_mem, GstMapInfo * info, gsize size)
-{
- gpointer data = &gl_mem->mem.tex_id;
-
- if ((info->flags & GST_MAP_READ) == GST_MAP_READ) {
- if (gl_mem->pbo && CONTEXT_SUPPORTS_PBO_UPLOAD (gl_mem->mem.mem.context)) {
- GstMapInfo pbo_info;
-
- /* data -> pbo */
- if (!gst_memory_map (GST_MEMORY_CAST (gl_mem->pbo), &pbo_info,
- GST_MAP_READ | GST_MAP_GL)) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Failed to map pbo");
- return NULL;
- }
-
- /* pbo -> texture */
- _upload_pbo_memory (gl_mem, info, gl_mem->pbo, &pbo_info);
-
- gst_memory_unmap (GST_MEMORY_CAST (gl_mem->pbo), &pbo_info);
- } else {
- GstGLMemoryAllocatorClass *alloc_class;
-
- alloc_class = GST_GL_MEMORY_ALLOCATOR_CLASS (parent_class);
-
- data = alloc_class->map ((GstGLBaseMemory *) gl_mem, info, size);
- }
- }
-
- return data;
-}
-
-static gpointer
-_gl_mem_map (GstGLMemoryPBO * gl_mem, GstMapInfo * info, gsize maxsize)
-{
- gpointer data;
-
- if ((info->flags & GST_MAP_GL) == GST_MAP_GL) {
- if (gl_mem->mem.tex_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES)
- return &gl_mem->mem.tex_id;
-
- data = _gl_mem_map_gpu_access (gl_mem, info, maxsize);
- } else { /* not GL */
- if (gl_mem->mem.tex_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Cannot map External OES textures");
- return NULL;
- }
-
- data = _gl_mem_map_cpu_access (gl_mem, info, maxsize);
- }
-
- return data;
-}
-
-static void
-_gl_mem_unmap_cpu_access (GstGLMemoryPBO * gl_mem, GstMapInfo * info)
-{
- if (!gl_mem->pbo || !CONTEXT_SUPPORTS_PBO_DOWNLOAD (gl_mem->mem.mem.context))
- /* PBO's not supported */
- return;
-
- gl_mem->pbo->target = GL_PIXEL_PACK_BUFFER;
- gst_memory_unmap (GST_MEMORY_CAST (gl_mem->pbo),
- (GstMapInfo *) info->user_data[0]);
- g_free (info->user_data[0]);
-}
-
-static void
-_gl_mem_unmap (GstGLMemoryPBO * gl_mem, GstMapInfo * info)
-{
- if ((info->flags & GST_MAP_GL) == 0) {
- _gl_mem_unmap_cpu_access (gl_mem, info);
- }
-}
-
-static void
-_gl_mem_copy_thread (GstGLContext * context, gpointer data)
-{
- const GstGLFuncs *gl;
- GstGLMemoryPBOCopyParams *copy_params;
- GstGLMemoryPBO *src;
- guint tex_id;
- guint out_tex_target;
- GLuint fboId;
- gsize out_width, out_height, out_stride;
- GLuint out_gl_format, out_gl_type;
- GLuint in_gl_format, in_gl_type;
- gsize in_size, out_size;
-
- copy_params = (GstGLMemoryPBOCopyParams *) data;
- src = copy_params->src;
- tex_id = copy_params->tex_id;
- out_tex_target = gst_gl_texture_target_to_gl (copy_params->tex_target);
- out_width = copy_params->out_width;
- out_height = copy_params->out_height;
- out_stride = copy_params->out_stride;
-
- gl = context->gl_vtable;
- out_gl_format = copy_params->out_format;
- out_gl_type = GL_UNSIGNED_BYTE;
- if (copy_params->out_format == GST_GL_RGB565) {
- out_gl_format = GST_GL_RGB;
- out_gl_type = GL_UNSIGNED_SHORT_5_6_5;
- }
- in_gl_format = src->mem.tex_format;
- in_gl_type = GL_UNSIGNED_BYTE;
- if (src->mem.tex_format == GST_GL_RGB565)
- in_gl_type = GL_UNSIGNED_SHORT_5_6_5;
-
- if (!gl->GenFramebuffers) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY,
- "Context, EXT_framebuffer_object not supported");
- goto error;
- }
-
- in_size = GL_MEM_HEIGHT (src) * GL_MEM_STRIDE (src);
- out_size = out_height * out_stride;
-
- if (copy_params->respecify) {
- if (in_size != out_size) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Cannot copy between textures with "
- "backing data of different sizes. input %" G_GSIZE_FORMAT " output %"
- G_GSIZE_FORMAT, in_size, out_size);
- goto error;
- }
- }
-
- if (!tex_id) {
- guint internal_format;
- guint out_gl_type;
-
- out_gl_type = GL_UNSIGNED_BYTE;
- if (copy_params->out_format == GST_GL_RGB565)
- out_gl_type = GL_UNSIGNED_SHORT_5_6_5;
-
- internal_format =
- gst_gl_sized_gl_format_from_gl_format_type (context, out_gl_format,
- out_gl_type);
-
- tex_id =
- _new_texture (context, out_tex_target,
- internal_format, out_gl_format, out_gl_type, copy_params->out_width,
- copy_params->out_height);
- }
-
- if (!tex_id) {
- GST_WARNING ("Could not create GL texture with context:%p", context);
- }
-
- GST_LOG ("copying memory %p, tex %u into texture %i",
- src, src->mem.tex_id, tex_id);
-
- /* FIXME: try and avoid creating and destroying fbo's every copy... */
- /* create a framebuffer object */
- gl->GenFramebuffers (1, &fboId);
- gl->BindFramebuffer (GL_FRAMEBUFFER, fboId);
-
- gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- gst_gl_texture_target_to_gl (src->mem.tex_target), src->mem.tex_id, 0);
-
-// if (!gst_gl_context_check_framebuffer_status (src->mem.mem.context))
-// goto fbo_error;
-
- gl->BindTexture (out_tex_target, tex_id);
- if (copy_params->respecify) {
- GstMapInfo pbo_info;
-
- if (!gl->GenBuffers || !src->pbo) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Cannot reinterpret texture contents "
- "without pixel buffer objects");
- gl->BindTexture (out_tex_target, 0);
- goto fbo_error;
- }
-
- if (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2
- && (in_gl_format != GL_RGBA || in_gl_type != GL_UNSIGNED_BYTE)) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Cannot copy non RGBA/UNSIGNED_BYTE "
- "textures on GLES2");
- gl->BindTexture (out_tex_target, 0);
- goto fbo_error;
- }
-
- GST_TRACE ("copying texture data with size of %u*%u*%u",
- gst_gl_format_type_n_bytes (in_gl_format, in_gl_type),
- src->mem.tex_width, GL_MEM_HEIGHT (src));
-
- /* copy tex */
- _read_pixels_to_pbo (src);
-
- src->pbo->target = GL_PIXEL_UNPACK_BUFFER;
- if (!gst_memory_map (GST_MEMORY_CAST (src->pbo), &pbo_info,
- GST_MAP_READ | GST_MAP_GL)) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Failed to map pbo for reading");
- goto fbo_error;
- }
- gl->TexSubImage2D (out_tex_target, 0, 0, 0, out_width, out_height,
- out_gl_format, out_gl_type, 0);
- gst_memory_unmap (GST_MEMORY_CAST (src->pbo), &pbo_info);
- } else { /* different sizes */
- gst_gl_memory_copy_teximage (GST_GL_MEMORY_CAST (src),
- tex_id, copy_params->tex_target, copy_params->out_format, out_width,
- out_height);
- }
-
- gl->BindTexture (out_tex_target, 0);
- gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
-
- gl->DeleteFramebuffers (1, &fboId);
-
- copy_params->tex_id = tex_id;
- copy_params->result = TRUE;
-
- return;
-
-/* ERRORS */
-fbo_error:
- {
- gl->DeleteFramebuffers (1, &fboId);
-
- copy_params->tex_id = 0;
- copy_params->result = FALSE;
- return;
- }
-
-error:
- {
- copy_params->result = FALSE;
- return;
- }
-}
-
-static GstMemory *
-_gl_mem_copy (GstGLMemoryPBO * src, gssize offset, gssize size)
-{
- GstAllocationParams params = { 0, GST_MEMORY_CAST (src)->align, 0, 0 };
- GstGLBaseMemoryAllocator *base_mem_allocator;
- GstAllocator *allocator;
- GstMemory *dest = NULL;
-
- allocator = GST_MEMORY_CAST (src)->allocator;
- base_mem_allocator = (GstGLBaseMemoryAllocator *) allocator;
-
- if (src->mem.tex_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES) {
- GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Cannot copy External OES textures");
- return NULL;
- }
-
- /* If not doing a full copy, then copy to sysmem, the 2D represention of the
- * texture would become wrong */
- if (offset > 0 || size < GST_MEMORY_CAST (src)->size) {
- return base_mem_allocator->fallback_mem_copy (GST_MEMORY_CAST (src), offset,
- size);
- }
-
- dest = (GstMemory *) g_new0 (GstGLMemoryPBO, 1);
- gst_gl_memory_init (GST_GL_MEMORY_CAST (dest), allocator, NULL,
- src->mem.mem.context, src->mem.tex_target, src->mem.tex_format, &params,
- &src->mem.info, src->mem.plane, &src->mem.valign, NULL, NULL);
-
- if (!GST_MEMORY_FLAG_IS_SET (src, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD)) {
- GstMapInfo dinfo;
-
- if (!gst_memory_map (GST_MEMORY_CAST (dest), &dinfo,
- GST_MAP_WRITE | GST_MAP_GL)) {
- GST_CAT_WARNING (GST_CAT_GL_MEMORY,
- "Failed not map destination " "for writing");
- gst_memory_unref (GST_MEMORY_CAST (dest));
- return NULL;
- }
-
- if (!gst_gl_memory_copy_into ((GstGLMemory *) src,
- ((GstGLMemory *) dest)->tex_id, src->mem.tex_target,
- src->mem.tex_format, src->mem.tex_width, GL_MEM_HEIGHT (src))) {
- GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory");
- gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo);
- goto memcpy;
- }
-
- gst_memory_unmap (GST_MEMORY_CAST (dest), &dinfo);
- } else {
- memcpy:
- if (!gst_gl_base_memory_memcpy ((GstGLBaseMemory *) src,
- (GstGLBaseMemory *) dest, offset, size)) {
- GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory");
- gst_memory_unref (GST_MEMORY_CAST (dest));
- return NULL;
- }
- }
-
- return dest;
-}
-
-static GstMemory *
-_gl_mem_alloc (GstAllocator * allocator, gsize size,
- GstAllocationParams * params)
-{
- g_warning ("Use gst_gl_base_memory_alloc () to allocate from this "
- "GstGLMemoryPBO allocator");
-
- return NULL;
-}
-
-static void
-_gl_mem_destroy (GstGLMemoryPBO * gl_mem)
-{
- if (gl_mem->pbo)
- gst_memory_unref (GST_MEMORY_CAST (gl_mem->pbo));
- gl_mem->pbo = NULL;
-
- GST_GL_BASE_MEMORY_ALLOCATOR_CLASS (parent_class)->destroy ((GstGLBaseMemory
- *) gl_mem);
-}
-
-static GstGLMemoryPBO *
-_gl_mem_pbo_alloc (GstGLBaseMemoryAllocator * allocator,
- GstGLVideoAllocationParams * params)
-{
- GstGLMemoryPBO *mem;
- guint alloc_flags;
-
- alloc_flags = params->parent.alloc_flags;
-
- g_return_val_if_fail (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
- NULL);
-
- mem = g_new0 (GstGLMemoryPBO, 1);
-
- if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
- mem->mem.tex_id = GPOINTER_TO_UINT (params->parent.gl_handle);
- mem->mem.texture_wrapped = TRUE;
- }
-
- gst_gl_memory_init (GST_GL_MEMORY_CAST (mem), GST_ALLOCATOR_CAST (allocator),
- NULL, params->parent.context, params->target, params->tex_format,
- params->parent.alloc_params, params->v_info, params->plane,
- params->valign, params->parent.user_data, params->parent.notify);
-
- if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
- GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);
- }
- if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM) {
- GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD);
- if (mem->pbo) {
- GST_MINI_OBJECT_FLAG_SET (mem->pbo,
- GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD);
- mem->pbo->mem.data = params->parent.wrapped_data;
- }
- mem->mem.mem.data = params->parent.wrapped_data;
- }
-
- return mem;
-}
-
-static void
-gst_gl_memory_pbo_allocator_class_init (GstGLMemoryPBOAllocatorClass * klass)
-{
- GstGLBaseMemoryAllocatorClass *gl_base;
- GstGLMemoryAllocatorClass *gl_tex;
- GstAllocatorClass *allocator_class;
-
- gl_tex = (GstGLMemoryAllocatorClass *) klass;
- gl_base = (GstGLBaseMemoryAllocatorClass *) klass;
- allocator_class = (GstAllocatorClass *) klass;
-
- gl_base->alloc = (GstGLBaseMemoryAllocatorAllocFunction) _gl_mem_pbo_alloc;
- gl_base->create = (GstGLBaseMemoryAllocatorCreateFunction) _gl_mem_create;
- gl_tex->map = (GstGLBaseMemoryAllocatorMapFunction) _gl_mem_map;
- gl_tex->unmap = (GstGLBaseMemoryAllocatorUnmapFunction) _gl_mem_unmap;
- gl_tex->copy = (GstGLBaseMemoryAllocatorCopyFunction) _gl_mem_copy;
- gl_base->destroy = (GstGLBaseMemoryAllocatorDestroyFunction) _gl_mem_destroy;
-
- allocator_class->alloc = _gl_mem_alloc;
-}
-
-static void
-gst_gl_memory_pbo_allocator_init (GstGLMemoryPBOAllocator * allocator)
-{
- GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator);
-
- alloc->mem_type = GST_GL_MEMORY_PBO_ALLOCATOR_NAME;
-
- GST_OBJECT_FLAG_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC);
-}
-
-/**
- * gst_gl_memory_pbo_copy_into_texture:
- * @gl_mem:a #GstGLMemoryPBO
- * @tex_id: the destination texture id
- * @target: the destination #GstGLTextureTarget
- * @tex_format: the destination #GstGLFormat
- * @width: width of @tex_id
- * @height: height of @tex_id
- * @stride: stride of the backing texture data
- * @respecify: whether to copy the data or copy per texel
- *
- * Copies @gl_mem into the texture specfified by @tex_id. The format of @tex_id
- * is specified by @tex_format, @width and @height.
- *
- * If @respecify is %TRUE, then the copy is performed in terms of the texture
- * data. This is useful for splitting RGBA textures into RG or R textures or
- * vice versa. The requirement for this to succeed is that the backing texture
- * data must be the same size, i.e. say a RGBA8 texture is converted into a RG8
- * texture, then the RG texture must have twice as many pixels available for
- * output as the RGBA texture.
- *
- * Otherwise, if @respecify is %FALSE, then the copy is performed per texel
- * using glCopyTexImage. See the OpenGL specification for details on the
- * mappings between texture formats.
- *
- * Returns: Whether the copy suceeded
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_memory_pbo_copy_into_texture (GstGLMemoryPBO * gl_mem, guint tex_id,
- GstGLTextureTarget target, GstGLFormat tex_format, gint width,
- gint height, gint stride, gboolean respecify)
-{
- GstGLMemoryPBOCopyParams copy_params;
-
- copy_params.src = gl_mem;
- copy_params.tex_target = target;
- copy_params.tex_id = tex_id;
- copy_params.out_format = tex_format;
- copy_params.out_width = width;
- copy_params.out_height = height;
- copy_params.out_stride = stride;
- copy_params.respecify = respecify;
-
- gst_gl_context_thread_add (gl_mem->mem.mem.context, _gl_mem_copy_thread,
- &copy_params);
-
- return copy_params.result;
-}
-
-static void
-_download_transfer (GstGLContext * context, GstGLMemoryPBO * gl_mem)
-{
- GstGLBaseMemory *mem = (GstGLBaseMemory *) gl_mem;
-
- g_mutex_lock (&mem->lock);
- if (_read_pixels_to_pbo (gl_mem)) {
- GST_CAT_TRACE (GST_CAT_GL_MEMORY, "optimistic download of texture %u "
- "using pbo %u", gl_mem->mem.tex_id, gl_mem->pbo->id);
- GST_MEMORY_FLAG_UNSET (gl_mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);
- }
- g_mutex_unlock (&mem->lock);
-}
-
-/**
- * gst_gl_memory_pbo_download_transfer:
- * @gl_mem: a #GstGLMemoryPBO
- *
- * Transfer the texture data from the texture into the PBO if necessary.
- *
- * Since: 1.8
- */
-void
-gst_gl_memory_pbo_download_transfer (GstGLMemoryPBO * gl_mem)
-{
- g_return_if_fail (gst_is_gl_memory ((GstMemory *) gl_mem));
-
- gst_gl_context_thread_add (gl_mem->mem.mem.context,
- (GstGLContextThreadFunc) _download_transfer, gl_mem);
-}
-
-static void
-_upload_transfer (GstGLContext * context, GstGLMemoryPBO * gl_mem)
-{
- GstGLBaseMemory *mem = (GstGLBaseMemory *) gl_mem;
- GstMapInfo info;
-
- g_mutex_lock (&mem->lock);
- gl_mem->pbo->target = GL_PIXEL_UNPACK_BUFFER;
- if (!gst_memory_map (GST_MEMORY_CAST (gl_mem->pbo), &info,
- GST_MAP_READ | GST_MAP_GL)) {
- GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Failed to map pbo for reading");
- } else {
- gst_memory_unmap (GST_MEMORY_CAST (gl_mem->pbo), &info);
- }
- g_mutex_unlock (&mem->lock);
-}
-
-/**
- * gst_gl_memory_pbo_upload_transfer:
- * @gl_mem: a #GstGLMemoryPBO
- *
- * Transfer the texture data from the PBO into the texture if necessary.
- *
- * Since: 1.8
- */
-void
-gst_gl_memory_pbo_upload_transfer (GstGLMemoryPBO * gl_mem)
-{
- g_return_if_fail (gst_is_gl_memory ((GstMemory *) gl_mem));
-
- if (gl_mem->pbo && CONTEXT_SUPPORTS_PBO_UPLOAD (gl_mem->mem.mem.context))
- gst_gl_context_thread_add (gl_mem->mem.mem.context,
- (GstGLContextThreadFunc) _upload_transfer, gl_mem);
-}
-
-/**
- * gst_gl_memory_pbo_init:
- *
- * Initializes the GL Memory allocator. It is safe to call this function
- * multiple times. This must be called before any other GstGLMemoryPBO operation.
- */
-void
-gst_gl_memory_pbo_init_once (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- gst_gl_memory_init_once ();
-
- GST_DEBUG_CATEGORY_INIT (GST_CAT_GL_MEMORY, "glmemory", 0, "OpenGL Memory");
-
- _gl_allocator = g_object_new (GST_TYPE_GL_MEMORY_PBO_ALLOCATOR, NULL);
- gst_object_ref_sink (_gl_allocator);
- /* The allocator is never unreffed */
- GST_OBJECT_FLAG_SET (_gl_allocator, GST_OBJECT_FLAG_MAY_BE_LEAKED);
-
- gst_allocator_register (GST_GL_MEMORY_PBO_ALLOCATOR_NAME,
- gst_object_ref (_gl_allocator));
- g_once_init_leave (&_init, 1);
- }
-}
-
-/**
- * gst_is_gl_memory_pbo:
- * @mem:a #GstMemory
- *
- * Returns: whether the memory at @mem is a #GstGLMemoryPBO
- *
- * Since: 1.8
- */
-gboolean
-gst_is_gl_memory_pbo (GstMemory * mem)
-{
- return mem != NULL && mem->allocator != NULL
- && g_type_is_a (G_OBJECT_TYPE (mem->allocator),
- GST_TYPE_GL_MEMORY_PBO_ALLOCATOR);
-}
diff --git a/gst-libs/gst/gl/gstglmemorypbo.h b/gst-libs/gst/gl/gstglmemorypbo.h
deleted file mode 100644
index c57bf1734..000000000
--- a/gst-libs/gst/gl/gstglmemorypbo.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_GL_MEMORY_PBO_H_
-#define _GST_GL_MEMORY_PBO_H_
-
-#include <gst/gl/gstglmemory.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_MEMORY_PBO_ALLOCATOR (gst_gl_memory_pbo_allocator_get_type())
-GST_EXPORT
-GType gst_gl_memory_pbo_allocator_get_type(void);
-
-#define GST_IS_GL_MEMORY_PBO_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_MEMORY_PBO_ALLOCATOR))
-#define GST_IS_GL_MEMORY_PBO_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GL_MEMORY_PBO_ALLOCATOR))
-#define GST_GL_MEMORY_PBO_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GL_MEMORY_PBO_ALLOCATOR, GstGLMemoryPBOAllocatorClass))
-#define GST_GL_MEMORY_PBO_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_MEMORY_PBO_ALLOCATOR, GstGLMemoryPBOAllocator))
-#define GST_GL_MEMORY_PBO_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_MEMORY_PBO_ALLOCATOR, GstGLAllocatorClass))
-#define GST_GL_MEMORY_PBO_ALLOCATOR_CAST(obj) ((GstGLMemoryPBOAllocator *)(obj))
-
-/**
- * GstGLMemoryPBO:
- *
- * Private instance
- */
-struct _GstGLMemoryPBO
-{
- /* <private> */
- GstGLMemory mem;
-
- GstGLBuffer *pbo;
-
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GST_GL_MEMORY_PBO_ALLOCATOR_NAME:
- *
- * The name of the GL Memory PBO allocator
- */
-#define GST_GL_MEMORY_PBO_ALLOCATOR_NAME "GLMemoryPBO"
-
-GST_EXPORT
-void gst_gl_memory_pbo_init_once (void);
-GST_EXPORT
-gboolean gst_is_gl_memory_pbo (GstMemory * mem);
-
-GST_EXPORT
-void gst_gl_memory_pbo_download_transfer (GstGLMemoryPBO * gl_mem);
-GST_EXPORT
-void gst_gl_memory_pbo_upload_transfer (GstGLMemoryPBO * gl_mem);
-
-GST_EXPORT
-gboolean gst_gl_memory_pbo_copy_into_texture (GstGLMemoryPBO *gl_mem,
- guint tex_id,
- GstGLTextureTarget target,
- GstGLFormat tex_format,
- gint width,
- gint height,
- gint stride,
- gboolean respecify);
-
-/**
- * GstGLAllocator
- *
- * Opaque #GstGLAllocator struct
- */
-struct _GstGLMemoryPBOAllocator
-{
- GstGLMemoryAllocator parent;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GstGLAllocatorClass:
- *
- * The #GstGLAllocatorClass only contains private data
- */
-struct _GstGLMemoryPBOAllocatorClass
-{
- GstGLMemoryAllocatorClass parent_class;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-G_END_DECLS
-
-#endif /* _GST_GL_MEMORY_PBO_H_ */
diff --git a/gst-libs/gst/gl/gstgloverlaycompositor.c b/gst-libs/gst/gl/gstgloverlaycompositor.c
deleted file mode 100644
index 05575aa8b..000000000
--- a/gst-libs/gst/gl/gstgloverlaycompositor.c
+++ /dev/null
@@ -1,649 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Lubosz Sarnecki <lubosz.sarnecki@collabora.co.uk>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstgloverlaycompositor
- * @title: GstGLOverlayCompositor
- * @short_description: Composite multiple overlays using OpenGL
- * @see_also: #GstGLMemory, #GstGLContext
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-
-#include "gstgloverlaycompositor.h"
-
-#include "gstglcontext.h"
-#include "gstglfuncs.h"
-#include "gstglmemory.h"
-#include "gstglshader.h"
-#include "gstglslstage.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_gl_overlay_compositor_debug);
-#define GST_CAT_DEFAULT gst_gl_overlay_compositor_debug
-
-/*****************************************************************************
- * GstGLCompositionOverlay object is internally used by GstGLOverlayCompositor
- *****************************************************************************/
-
-#define GST_TYPE_GL_COMPOSITION_OVERLAY (gst_gl_composition_overlay_get_type())
-#define GST_GL_COMPOSITION_OVERLAY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_COMPOSITION_OVERLAY,\
- GstGLCompositionOverlay))
-
-typedef struct _GstGLCompositionOverlay GstGLCompositionOverlay;
-typedef struct _GstGLCompositionOverlayClass GstGLCompositionOverlayClass;
-
-static GType gst_gl_composition_overlay_get_type (void);
-
-/* *INDENT-OFF* */
-const gchar *fragment_shader =
- "#ifdef GL_ES\n"
- "precision mediump float;\n"
- "#endif\n"
- "varying vec2 v_texcoord;\n"
- "uniform sampler2D tex;\n"
- "void main(void)\n"
- "{\n"
- " vec4 t = texture2D(tex, v_texcoord);\n"
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
- " gl_FragColor = t.bgra;\n"
-#else
- " gl_FragColor = t.gbar;\n"
-#endif
- "}";
-/* *INDENT-ON* */
-
-struct _GstGLCompositionOverlay
-{
- GstObject parent;
- GstGLContext *context;
-
- GLuint vao;
- GLuint index_buffer;
- GLuint position_buffer;
- GLuint texcoord_buffer;
- GLint position_attrib;
- GLint texcoord_attrib;
-
- GLfloat positions[16];
-
- GLuint texture_id;
- GstGLMemory *gl_memory;
- GstVideoOverlayRectangle *rectangle;
-};
-
-struct _GstGLCompositionOverlayClass
-{
- GstObjectClass object_class;
-};
-
-G_DEFINE_TYPE (GstGLCompositionOverlay, gst_gl_composition_overlay,
- GST_TYPE_OBJECT);
-
-static void
-gst_gl_composition_overlay_init_vertex_buffer (GstGLContext * context,
- gpointer overlay_pointer)
-{
- const GstGLFuncs *gl = context->gl_vtable;
- GstGLCompositionOverlay *overlay =
- (GstGLCompositionOverlay *) overlay_pointer;
-
- /* *INDENT-OFF* */
- static const GLfloat texcoords[] = {
- 1.0f, 0.0f,
- 0.0f, 0.0f,
- 0.0f, 1.0f,
- 1.0f, 1.0f
- };
-
- static const GLushort indices[] = {
- 0, 1, 2, 0, 2, 3
- };
- /* *INDENT-ON* */
-
- if (gl->GenVertexArrays) {
- gl->GenVertexArrays (1, &overlay->vao);
- gl->BindVertexArray (overlay->vao);
- }
-
- gl->GenBuffers (1, &overlay->position_buffer);
- gl->BindBuffer (GL_ARRAY_BUFFER, overlay->position_buffer);
- gl->BufferData (GL_ARRAY_BUFFER, 4 * 4 * sizeof (GLfloat), overlay->positions,
- GL_STATIC_DRAW);
-
- /* Load the vertex position */
- gl->VertexAttribPointer (overlay->position_attrib, 4, GL_FLOAT, GL_FALSE,
- 4 * sizeof (GLfloat), NULL);
-
- gl->GenBuffers (1, &overlay->texcoord_buffer);
- gl->BindBuffer (GL_ARRAY_BUFFER, overlay->texcoord_buffer);
- gl->BufferData (GL_ARRAY_BUFFER, 4 * 2 * sizeof (GLfloat), texcoords,
- GL_STATIC_DRAW);
-
- /* Load the texture coordinate */
- gl->VertexAttribPointer (overlay->texcoord_attrib, 2, GL_FLOAT, GL_FALSE,
- 2 * sizeof (GLfloat), NULL);
-
- gl->GenBuffers (1, &overlay->index_buffer);
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, overlay->index_buffer);
- gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
- GL_STATIC_DRAW);
-
- gl->EnableVertexAttribArray (overlay->position_attrib);
- gl->EnableVertexAttribArray (overlay->texcoord_attrib);
-
- if (gl->GenVertexArrays) {
- gl->BindVertexArray (0);
- }
-
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
- gl->BindBuffer (GL_ARRAY_BUFFER, 0);
-}
-
-static void
-gst_gl_composition_overlay_free_vertex_buffer (GstGLContext * context,
- gpointer overlay_pointer)
-{
- const GstGLFuncs *gl = context->gl_vtable;
- GstGLCompositionOverlay *overlay =
- (GstGLCompositionOverlay *) overlay_pointer;
- if (overlay->vao) {
- gl->DeleteVertexArrays (1, &overlay->vao);
- overlay->vao = 0;
- }
-
- if (overlay->position_buffer) {
- gl->DeleteBuffers (1, &overlay->position_buffer);
- overlay->position_buffer = 0;
- }
-
- if (overlay->texcoord_buffer) {
- gl->DeleteBuffers (1, &overlay->position_buffer);
- overlay->position_buffer = 0;
- }
-
- if (overlay->index_buffer) {
- gl->DeleteBuffers (1, &overlay->index_buffer);
- overlay->index_buffer = 0;
- }
-}
-
-static void
-gst_gl_composition_overlay_bind_vertex_buffer (GstGLCompositionOverlay *
- overlay)
-{
- const GstGLFuncs *gl = overlay->context->gl_vtable;
- gl->BindBuffer (GL_ARRAY_BUFFER, overlay->position_buffer);
- gl->VertexAttribPointer (overlay->position_attrib, 4, GL_FLOAT, GL_FALSE,
- 4 * sizeof (GLfloat), NULL);
-
- gl->BindBuffer (GL_ARRAY_BUFFER, overlay->texcoord_buffer);
- gl->VertexAttribPointer (overlay->texcoord_attrib, 2, GL_FLOAT, GL_FALSE,
- 2 * sizeof (GLfloat), NULL);
-
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, overlay->index_buffer);
-
- gl->EnableVertexAttribArray (overlay->position_attrib);
- gl->EnableVertexAttribArray (overlay->texcoord_attrib);
-}
-
-static void
-gst_gl_composition_overlay_finalize (GObject * object)
-{
- GstGLCompositionOverlay *overlay;
-
- overlay = GST_GL_COMPOSITION_OVERLAY (object);
-
- if (overlay->gl_memory)
- gst_memory_unref ((GstMemory *) overlay->gl_memory);
-
- if (overlay->context) {
- gst_gl_context_thread_add (overlay->context,
- gst_gl_composition_overlay_free_vertex_buffer, overlay);
- gst_object_unref (overlay->context);
- }
-
- G_OBJECT_CLASS (gst_gl_composition_overlay_parent_class)->finalize (object);
-}
-
-
-static void
-gst_gl_composition_overlay_class_init (GstGLCompositionOverlayClass * klass)
-{
- G_OBJECT_CLASS (klass)->finalize = gst_gl_composition_overlay_finalize;
-}
-
-static void
-gst_gl_composition_overlay_init (GstGLCompositionOverlay * overlay)
-{
-}
-
-static void
-gst_gl_composition_overlay_add_transformation (GstGLCompositionOverlay *
- overlay, GstBuffer * video_buffer)
-{
- gint comp_x, comp_y;
- guint comp_width, comp_height;
- GstVideoMeta *meta;
- guint width, height;
-
- float rel_x, rel_y, rel_w, rel_h;
-
- meta = gst_buffer_get_video_meta (video_buffer);
-
- gst_video_overlay_rectangle_get_render_rectangle (overlay->rectangle,
- &comp_x, &comp_y, &comp_width, &comp_height);
-
- width = meta->width;
- height = meta->height;
-
- /* calculate relative position */
- rel_x = (float) comp_x / (float) width;
- rel_y = (float) comp_y / (float) height;
-
- rel_w = (float) comp_width / (float) width;
- rel_h = (float) comp_height / (float) height;
-
- /* transform from [0,1] to [-1,1], invert y axis */
- rel_x = rel_x * 2.0 - 1.0;
- rel_y = (1.0 - rel_y) * 2.0 - 1.0;
- rel_w = rel_w * 2.0;
- rel_h = rel_h * 2.0;
-
- /* initialize position array */
- overlay->positions[0] = rel_x + rel_w;
- overlay->positions[1] = rel_y;
- overlay->positions[2] = 0.0;
- overlay->positions[3] = 1.0;
- overlay->positions[4] = rel_x;
- overlay->positions[5] = rel_y;
- overlay->positions[6] = 0.0;
- overlay->positions[7] = 1.0;
- overlay->positions[8] = rel_x;
- overlay->positions[9] = rel_y - rel_h;
- overlay->positions[10] = 0.0;
- overlay->positions[11] = 1.0;
- overlay->positions[12] = rel_x + rel_w;
- overlay->positions[13] = rel_y - rel_h;
- overlay->positions[14] = 0.0;
- overlay->positions[15] = 1.0;
-
- gst_gl_context_thread_add (overlay->context,
- gst_gl_composition_overlay_free_vertex_buffer, overlay);
-
- gst_gl_context_thread_add (overlay->context,
- gst_gl_composition_overlay_init_vertex_buffer, overlay);
-
- GST_DEBUG
- ("overlay position: (%d,%d) size: %dx%d video size: %dx%d",
- comp_x, comp_y, comp_width, comp_height, meta->width, meta->height);
-}
-
-/* helper object API functions */
-
-static GstGLCompositionOverlay *
-gst_gl_composition_overlay_new (GstGLContext * context,
- GstVideoOverlayRectangle * rectangle,
- GLint position_attrib, GLint texcoord_attrib)
-{
- GstGLCompositionOverlay *overlay =
- g_object_new (GST_TYPE_GL_COMPOSITION_OVERLAY, NULL);
-
- overlay->gl_memory = NULL;
- overlay->texture_id = -1;
- overlay->rectangle = rectangle;
- overlay->context = gst_object_ref (context);
- overlay->vao = 0;
- overlay->position_attrib = position_attrib;
- overlay->texcoord_attrib = texcoord_attrib;
-
- GST_DEBUG_OBJECT (overlay, "Created new GstGLCompositionOverlay");
-
- return overlay;
-}
-
-static void
-_video_frame_unmap_and_free (gpointer user_data)
-{
- GstVideoFrame *frame = user_data;
-
- gst_video_frame_unmap (frame);
- g_slice_free (GstVideoFrame, frame);
-}
-
-static void
-gst_gl_composition_overlay_upload (GstGLCompositionOverlay * overlay,
- GstBuffer * buf)
-{
- GstGLMemory *comp_gl_memory = NULL;
- GstBuffer *comp_buffer = NULL;
- GstBuffer *overlay_buffer = NULL;
- GstVideoInfo vinfo;
- GstVideoMeta *vmeta;
- GstVideoFrame *comp_frame;
- GstVideoFrame gl_frame;
-
- comp_buffer =
- gst_video_overlay_rectangle_get_pixels_unscaled_argb (overlay->rectangle,
- GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA);
-
- comp_frame = g_slice_new (GstVideoFrame);
-
- vmeta = gst_buffer_get_video_meta (comp_buffer);
- gst_video_info_set_format (&vinfo, vmeta->format, vmeta->width,
- vmeta->height);
- vinfo.stride[0] = vmeta->stride[0];
-
- if (gst_video_frame_map (comp_frame, &vinfo, comp_buffer, GST_MAP_READ)) {
- GstGLVideoAllocationParams *params;
- GstGLBaseMemoryAllocator *mem_allocator;
- GstAllocator *allocator;
-
- allocator =
- GST_ALLOCATOR (gst_gl_memory_allocator_get_default (overlay->context));
- mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator);
-
- gst_gl_composition_overlay_add_transformation (overlay, buf);
-
- params = gst_gl_video_allocation_params_new_wrapped_data (overlay->context,
- NULL, &comp_frame->info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
- GST_GL_RGBA, comp_frame->data[0], comp_frame,
- _video_frame_unmap_and_free);
-
- comp_gl_memory =
- (GstGLMemory *) gst_gl_base_memory_alloc (mem_allocator,
- (GstGLAllocationParams *) params);
-
- gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
- gst_object_unref (allocator);
-
- overlay_buffer = gst_buffer_new ();
- gst_buffer_append_memory (overlay_buffer, (GstMemory *) comp_gl_memory);
-
- if (!gst_video_frame_map (&gl_frame, &comp_frame->info, overlay_buffer,
- GST_MAP_READ | GST_MAP_GL)) {
- gst_buffer_unref (overlay_buffer);
- _video_frame_unmap_and_free (comp_frame);
- GST_WARNING_OBJECT (overlay, "Cannot upload overlay texture");
- return;
- }
-
- gst_memory_ref ((GstMemory *) comp_gl_memory);
- overlay->gl_memory = comp_gl_memory;
- overlay->texture_id = comp_gl_memory->tex_id;
-
- gst_buffer_unref (overlay_buffer);
- gst_video_frame_unmap (&gl_frame);
-
- GST_DEBUG ("uploaded overlay texture %d", overlay->texture_id);
- } else {
- g_slice_free (GstVideoFrame, comp_frame);
- }
-}
-
-static void
-gst_gl_composition_overlay_draw (GstGLCompositionOverlay * overlay,
- GstGLShader * shader)
-{
- const GstGLFuncs *gl = overlay->context->gl_vtable;
- if (gl->GenVertexArrays)
- gl->BindVertexArray (overlay->vao);
- else
- gst_gl_composition_overlay_bind_vertex_buffer (overlay);
-
- if (overlay->texture_id != -1)
- gl->BindTexture (GL_TEXTURE_2D, overlay->texture_id);
- gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
-}
-
-
-/********************************************************************
- * GstGLOverlayCompositor object, the public helper object to render
- * GstVideoCompositionOverlayMeta
- ********************************************************************/
-
-#define DEBUG_INIT \
- GST_DEBUG_CATEGORY_INIT (gst_gl_overlay_compositor_debug, \
- "gloverlaycompositor", 0, "overlaycompositor");
-
-G_DEFINE_TYPE_WITH_CODE (GstGLOverlayCompositor, gst_gl_overlay_compositor,
- GST_TYPE_OBJECT, DEBUG_INIT);
-
-static void gst_gl_overlay_compositor_finalize (GObject * object);
-static gboolean _is_rectangle_in_overlays (GList * overlays,
- GstVideoOverlayRectangle * rectangle);
-static gboolean _is_overlay_in_rectangles (GstVideoOverlayComposition *
- composition, GstGLCompositionOverlay * overlay);
-
-static void
-gst_gl_overlay_compositor_class_init (GstGLOverlayCompositorClass * klass)
-{
- G_OBJECT_CLASS (klass)->finalize = gst_gl_overlay_compositor_finalize;
-}
-
-static void
-gst_gl_overlay_compositor_init (GstGLOverlayCompositor * compositor)
-{
-}
-
-static void
-gst_gl_overlay_compositor_init_gl (GstGLContext * context,
- gpointer compositor_pointer)
-{
- GstGLOverlayCompositor *compositor =
- (GstGLOverlayCompositor *) compositor_pointer;
- GError *error = NULL;
-
- if (!(compositor->shader =
- gst_gl_shader_new_link_with_stages (context, &error,
- gst_glsl_stage_new_default_vertex (context),
- gst_glsl_stage_new_with_string (context, GL_FRAGMENT_SHADER,
- GST_GLSL_VERSION_NONE,
- GST_GLSL_PROFILE_ES | GST_GLSL_PROFILE_COMPATIBILITY,
- fragment_shader), NULL))) {
- GST_ERROR_OBJECT (compositor, "could not initialize shader: %s",
- error->message);
- return;
- }
-
- compositor->position_attrib =
- gst_gl_shader_get_attribute_location (compositor->shader, "a_position");
- compositor->texcoord_attrib =
- gst_gl_shader_get_attribute_location (compositor->shader, "a_texcoord");
-}
-
-GstGLOverlayCompositor *
-gst_gl_overlay_compositor_new (GstGLContext * context)
-{
- GstGLOverlayCompositor *compositor =
- g_object_new (GST_TYPE_GL_OVERLAY_COMPOSITOR, NULL);
-
- gst_object_ref_sink (compositor);
-
- compositor->context = gst_object_ref (context);
-
- gst_gl_context_thread_add (compositor->context,
- gst_gl_overlay_compositor_init_gl, compositor);
-
- GST_DEBUG_OBJECT (compositor, "Created new GstGLOverlayCompositor");
-
- return compositor;
-}
-
-static void
-gst_gl_overlay_compositor_finalize (GObject * object)
-{
- GstGLOverlayCompositor *compositor;
-
- compositor = GST_GL_OVERLAY_COMPOSITOR (object);
-
- gst_gl_overlay_compositor_free_overlays (compositor);
-
- if (compositor->context)
- gst_object_unref (compositor->context);
-
- if (compositor->shader) {
- gst_object_unref (compositor->shader);
- compositor->shader = NULL;
- }
-
- G_OBJECT_CLASS (gst_gl_overlay_compositor_parent_class)->finalize (object);
-}
-
-static gboolean
-_is_rectangle_in_overlays (GList * overlays,
- GstVideoOverlayRectangle * rectangle)
-{
- GList *l;
-
- for (l = overlays; l != NULL; l = l->next) {
- GstGLCompositionOverlay *overlay = (GstGLCompositionOverlay *) l->data;
- if (overlay->rectangle == rectangle)
- return TRUE;
- }
- return FALSE;
-}
-
-static gboolean
-_is_overlay_in_rectangles (GstVideoOverlayComposition * composition,
- GstGLCompositionOverlay * overlay)
-{
- guint i;
-
- for (i = 0; i < gst_video_overlay_composition_n_rectangles (composition); i++) {
- GstVideoOverlayRectangle *rectangle =
- gst_video_overlay_composition_get_rectangle (composition, i);
- if (overlay->rectangle == rectangle)
- return TRUE;
- }
- return FALSE;
-}
-
-
-void
-gst_gl_overlay_compositor_free_overlays (GstGLOverlayCompositor * compositor)
-{
- GList *l = compositor->overlays;
- while (l != NULL) {
- GList *next = l->next;
- GstGLCompositionOverlay *overlay = (GstGLCompositionOverlay *) l->data;
- compositor->overlays = g_list_delete_link (compositor->overlays, l);
- gst_object_unref (overlay);
- l = next;
- }
- g_list_free (compositor->overlays);
- compositor->overlays = NULL;
-}
-
-void
-gst_gl_overlay_compositor_upload_overlays (GstGLOverlayCompositor * compositor,
- GstBuffer * buf)
-{
- GstVideoOverlayCompositionMeta *composition_meta;
-
- composition_meta = gst_buffer_get_video_overlay_composition_meta (buf);
- if (composition_meta) {
- GstVideoOverlayComposition *composition = NULL;
- guint num_overlays, i;
- GList *l = compositor->overlays;
-
- GST_DEBUG ("GstVideoOverlayCompositionMeta found.");
-
- composition = composition_meta->overlay;
- num_overlays = gst_video_overlay_composition_n_rectangles (composition);
-
- /* add new overlays to list */
- for (i = 0; i < num_overlays; i++) {
- GstVideoOverlayRectangle *rectangle =
- gst_video_overlay_composition_get_rectangle (composition, i);
-
- if (!_is_rectangle_in_overlays (compositor->overlays, rectangle)) {
- GstGLCompositionOverlay *overlay =
- gst_gl_composition_overlay_new (compositor->context, rectangle,
- compositor->position_attrib, compositor->texcoord_attrib);
- gst_object_ref_sink (overlay);
-
- gst_gl_composition_overlay_upload (overlay, buf);
-
- compositor->overlays = g_list_append (compositor->overlays, overlay);
- }
- }
-
- /* remove old overlays from list */
- while (l != NULL) {
- GList *next = l->next;
- GstGLCompositionOverlay *overlay = (GstGLCompositionOverlay *) l->data;
- if (!_is_overlay_in_rectangles (composition, overlay)) {
- compositor->overlays = g_list_delete_link (compositor->overlays, l);
- gst_object_unref (overlay);
- }
- l = next;
- }
- } else {
- gst_gl_overlay_compositor_free_overlays (compositor);
- }
-}
-
-void
-gst_gl_overlay_compositor_draw_overlays (GstGLOverlayCompositor * compositor)
-{
- const GstGLFuncs *gl = compositor->context->gl_vtable;
- if (compositor->overlays != NULL) {
- GList *l;
-
- gl->Enable (GL_BLEND);
- gl->BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- gst_gl_shader_use (compositor->shader);
- gl->ActiveTexture (GL_TEXTURE0);
- gst_gl_shader_set_uniform_1i (compositor->shader, "tex", 0);
-
- for (l = compositor->overlays; l != NULL; l = l->next) {
- GstGLCompositionOverlay *overlay = (GstGLCompositionOverlay *) l->data;
- gst_gl_composition_overlay_draw (overlay, compositor->shader);
- }
-
- gl->BindTexture (GL_TEXTURE_2D, 0);
- gl->Disable (GL_BLEND);
- }
-}
-
-GstCaps *
-gst_gl_overlay_compositor_add_caps (GstCaps * caps)
-{
- GstCaps *composition_caps;
- int i;
-
- composition_caps = gst_caps_copy (caps);
-
- for (i = 0; i < gst_caps_get_size (composition_caps); i++) {
- GstCapsFeatures *f = gst_caps_get_features (composition_caps, i);
- gst_caps_features_add (f,
- GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
- }
-
- caps = gst_caps_merge (composition_caps, caps);
-
- return caps;
-}
diff --git a/gst-libs/gst/gl/gstgloverlaycompositor.h b/gst-libs/gst/gl/gstgloverlaycompositor.h
deleted file mode 100644
index 3bc24620d..000000000
--- a/gst-libs/gst/gl/gstgloverlaycompositor.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Lubosz Sarnecki <lubosz.sarnecki@collabora.co.uk>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_OVERLAY_COMPOSITOR_H__
-#define __GST_GL_OVERLAY_COMPOSITOR_H__
-
-#include <gst/video/video.h>
-#include <gst/gl/gstgl_fwd.h>
-
-#define GST_TYPE_GL_OVERLAY_COMPOSITOR (gst_gl_overlay_compositor_get_type())
-#define GST_GL_OVERLAY_COMPOSITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_OVERLAY_COMPOSITOR,GstGLOverlayCompositor))
-#define GST_GL_OVERLAY_COMPOSITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_OVERLAY_COMPOSITOR,GstGLOverlayCompositorClass))
-#define GST_IS_GL_OVERLAY_COMPOSITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_OVERLAY_COMPOSITOR))
-#define GST_IS_GL_OVERLAY_COMPOSITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_OVERLAY_COMPOSITOR))
-#define GST_GL_OVERLAY_COMPOSITOR_CAST(obj) ((GstGLOverlayCompositor*)(obj))
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GType gst_gl_overlay_compositor_get_type (void);
-
-/**
- * GstGLOverlayCompositor
- *
- * Opaque #GstGLOverlayCompositor object
- */
-struct _GstGLOverlayCompositor
-{
- GstObject parent;
-
- GstGLContext *context;
-
- /* <private> */
- guint last_window_width;
- guint last_window_height;
-
- GList * overlays;
-
- GstGLShader *shader;
- gint position_attrib;
- gint texcoord_attrib;
-
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GstGLOverlayCompositorClass:
- *
- */
-struct _GstGLOverlayCompositorClass
-{
- GstObjectClass object_class;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GstGLOverlayCompositor *gst_gl_overlay_compositor_new (GstGLContext * context);
-
-GST_EXPORT
-void gst_gl_overlay_compositor_free_overlays (GstGLOverlayCompositor * compositor);
-
-GST_EXPORT
-void gst_gl_overlay_compositor_upload_overlays (GstGLOverlayCompositor * compositor,
- GstBuffer * buf);
-
-GST_EXPORT
-void gst_gl_overlay_compositor_draw_overlays (GstGLOverlayCompositor * compositor);
-
-GST_EXPORT
-GstCaps * gst_gl_overlay_compositor_add_caps(GstCaps * caps);
-
-G_END_DECLS
-#endif /* __GST_GL_OVERLAY_COMPOSITOR_H__ */
diff --git a/gst-libs/gst/gl/gstglpixelformat.c b/gst-libs/gst/gl/gstglpixelformat.c
deleted file mode 100644
index 0a35887ea..000000000
--- a/gst-libs/gst/gl/gstglpixelformat.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
diff --git a/gst-libs/gst/gl/gstglquery.c b/gst-libs/gst/gl/gstglquery.c
deleted file mode 100644
index 3023959ae..000000000
--- a/gst-libs/gst/gl/gstglquery.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2016 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstglquery
- * @short_description: OpenGL query abstraction
- * @title: GstGLQuery
- * @see_also:
- *
- * A #GstGLQuery represents and holds an OpenGL query object. Various types of
- * queries can be run or counters retrieved.
- *
- * Since: 1.10
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "gstglquery.h"
-
-#include "gstglcontext.h"
-#include "gstglfuncs.h"
-
-#ifndef GL_TIME_ELAPSED
-#define GL_TIME_ELAPSED 0x88BF
-#endif
-
-#ifndef GL_TIMESTAMP
-#define GL_TIMESTAMP 0x8E28
-#endif
-
-#ifndef GL_QUERY_RESULT
-#define GL_QUERY_RESULT 0x8866
-#endif
-
-#define GST_CAT_DEFAULT gst_gl_query_debug
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-
-static void
-_init_debug (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "glquery", 0, "glquery element");
- g_once_init_leave (&_init, 1);
- }
-}
-
-static const gchar *
-_query_type_to_string (guint query_type)
-{
- switch (query_type) {
- case GST_GL_QUERY_TIME_ELAPSED:
- case GL_TIME_ELAPSED:
- return "time elapsed";
- case GL_TIMESTAMP:
- case GST_GL_QUERY_TIMESTAMP:
- return "timestamp";
- default:
- return "unknown";
- }
-}
-
-static guint
-_gst_gl_query_type_to_gl (GstGLQueryType query_type)
-{
- if (query_type == GST_GL_QUERY_TIME_ELAPSED)
- return GL_TIME_ELAPSED;
- if (query_type == GST_GL_QUERY_TIMESTAMP)
- return GL_TIMESTAMP;
-
- return 0;
-}
-
-static gboolean
-_query_type_supports_counter (guint gl_query_type)
-{
- return gl_query_type == GL_TIMESTAMP;
-}
-
-static gboolean
-_query_type_supports_begin_end (guint gl_query_type)
-{
- return gl_query_type == GL_TIME_ELAPSED;
-}
-
-static gboolean
-_context_supports_query_type (GstGLContext * context, guint gl_query_type)
-{
- return gl_query_type != 0 && context->gl_vtable->GenQueries != NULL;
-}
-
-static gchar *
-_log_time (gpointer user_data)
-{
- GstGLQuery *query = user_data;
- gint64 result;
-
- result = gst_gl_query_result (query);
-
- return gst_info_strdup_printf ("%" GST_TIME_FORMAT, GST_TIME_ARGS (result));
-}
-
-/**
- * gst_gl_query_init:
- * @query: a #GstGLQuery
- * @context: a #GstGLContext
- * @query_type: the #GstGLQueryType
- *
- * Since: 1.10
- */
-void
-gst_gl_query_init (GstGLQuery * query, GstGLContext * context,
- GstGLQueryType query_type)
-{
- const GstGLFuncs *gl;
- GLenum gl_query_type;
-
- g_return_if_fail (query != NULL);
- g_return_if_fail (GST_IS_GL_CONTEXT (context));
- gl = context->gl_vtable;
- gl_query_type = _gst_gl_query_type_to_gl (query_type);
- g_return_if_fail (gl_query_type != GL_NONE);
-
- memset (query, 0, sizeof (*query));
-
- _init_debug ();
-
- query->query_type = gl_query_type;
- query->context = gst_object_ref (context);
- query->supported = _context_supports_query_type (context, query->query_type);
-
- if (query->supported)
- gl->GenQueries (1, &query->query_id);
-
- gst_gl_async_debug_init (&query->debug);
- query->debug.callback = _log_time;
- query->debug.user_data = query;
-}
-
-/**
- * gst_gl_query_unset:
- * @query: a #GstGLQuery
- *
- * Free any dynamically allocated resources
- *
- * Since: 1.10
- */
-void
-gst_gl_query_unset (GstGLQuery * query)
-{
- const GstGLFuncs *gl;
-
- g_return_if_fail (query != NULL);
- if (query->start_called)
- g_critical ("Unsetting a running query. This may not be what you wanted."
- "Be sure to pair calls to gst_gl_query_start() and gst_gl_query_end()");
-
- GST_TRACE ("%p unsetting query %u", query, query->query_id);
-
- gl = query->context->gl_vtable;
-
- /* unset the debug object as it may callback to print the last message */
- gst_gl_async_debug_unset (&query->debug);
-
- if (query->query_id)
- gl->DeleteQueries (1, &query->query_id);
-
- gst_object_unref (query->context);
-}
-
-/**
- * gst_gl_query_new: (skip)
- * @context: a #GstGLContext
- * @query_type: the #GstGLQueryType to create
- *
- * Free with gst_gl_query_free()
- *
- * Returns: a new #GstGLQuery
- *
- * Since: 1.10
- */
-GstGLQuery *
-gst_gl_query_new (GstGLContext * context, GstGLQueryType query_type)
-{
- GstGLQuery *query = g_new0 (GstGLQuery, 1);
-
- gst_gl_query_init (query, context, query_type);
-
- return query;
-}
-
-/**
- * gst_gl_query_free:
- * @query: a #GstGLQuery
- *
- * Frees a #GstGLQuery
- *
- * Since: 1.10
- */
-void
-gst_gl_query_free (GstGLQuery * query)
-{
- g_return_if_fail (query != NULL);
-
- gst_gl_query_unset (query);
- g_free (query);
-}
-
-/**
- * gst_gl_query_start:
- * @query: a #GstGLQuery
- *
- * Start counting the query
- *
- * Since: 1.10
- */
-void
-gst_gl_query_start (GstGLQuery * query)
-{
- const GstGLFuncs *gl;
-
- g_return_if_fail (query != NULL);
- g_return_if_fail (_query_type_supports_begin_end (query->query_type));
- g_return_if_fail (query->start_called == FALSE);
-
- query->start_called = TRUE;
-
- if (!query->supported)
- return;
-
- gst_gl_async_debug_output_log_msg (&query->debug);
-
- GST_TRACE ("%p start query type \'%s\' id %u", query,
- _query_type_to_string (query->query_type), query->query_id);
-
- gl = query->context->gl_vtable;
- gl->BeginQuery (query->query_type, query->query_id);
-}
-
-/**
- * gst_gl_query_end:
- * @query: a #GstGLQuery
- *
- * End counting the query
- *
- * Since: 1.10
- */
-void
-gst_gl_query_end (GstGLQuery * query)
-{
- const GstGLFuncs *gl;
-
- g_return_if_fail (query != NULL);
- g_return_if_fail (_query_type_supports_begin_end (query->query_type));
- g_return_if_fail (query->start_called);
-
- query->start_called = FALSE;
-
- if (!query->supported)
- return;
-
- GST_TRACE ("%p end query type \'%s\' id %u", query,
- _query_type_to_string (query->query_type), query->query_id);
-
- gl = query->context->gl_vtable;
-
- gl->EndQuery (query->query_type);
-}
-
-/**
- * gst_gl_query_counter:
- * @query: a #GstGLQuery
- *
- * Record the result of a counter
- *
- * Since: 1.10
- */
-void
-gst_gl_query_counter (GstGLQuery * query)
-{
- const GstGLFuncs *gl;
-
- g_return_if_fail (query != NULL);
- g_return_if_fail (_query_type_supports_counter (query->query_type));
-
- if (!query->supported)
- return;
-
- GST_TRACE ("%p query counter type \'%s\' id %u", query,
- _query_type_to_string (query->query_type), query->query_id);
-
- gst_gl_async_debug_output_log_msg (&query->debug);
-
- gl = query->context->gl_vtable;
- gl->QueryCounter (query->query_id, query->query_type);
-}
-
-/**
- * gst_gl_query_result:
- * @query: a #GstGLQuery
- *
- * Returns: the result of the query
- *
- * Since: 1.10
- */
-guint64
-gst_gl_query_result (GstGLQuery * query)
-{
- const GstGLFuncs *gl;
- guint64 ret;
-
- g_return_val_if_fail (query != NULL, 0);
- g_return_val_if_fail (!query->start_called, 0);
-
- if (!query->supported)
- return 0;
-
- gl = query->context->gl_vtable;
- if (gl->GetQueryObjectui64v) {
- gl->GetQueryObjectui64v (query->query_id, GL_QUERY_RESULT,
- (GLuint64 *) & ret);
- } else {
- guint tmp;
- gl->GetQueryObjectuiv (query->query_id, GL_QUERY_RESULT, &tmp);
- ret = tmp;
- }
-
- GST_TRACE ("%p get result %" G_GUINT64_FORMAT " type \'%s\' id %u", query,
- ret, _query_type_to_string (query->query_type), query->query_id);
-
- return ret;
-}
diff --git a/gst-libs/gst/gl/gstglquery.h b/gst-libs/gst/gl/gstglquery.h
deleted file mode 100644
index 48634b809..000000000
--- a/gst-libs/gst/gl/gstglquery.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2016 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_QUERY_H__
-#define __GST_GL_QUERY_H__
-
-#include <gst/gl/gstgl_fwd.h>
-#include <gst/gl/gstgldebug.h>
-
-G_BEGIN_DECLS
-
-/**
- * GstGLQueryType:
- * @GST_GL_QUERY_NONE: no query
- * @GST_GL_QUERY_TIME_ELAPSED: query the time elapsed
- * @GST_GL_QUERY_TIMESTAMP: query the current time
- */
-typedef enum
-{
- GST_GL_QUERY_NONE,
- GST_GL_QUERY_TIME_ELAPSED,
- GST_GL_QUERY_TIMESTAMP,
-} GstGLQueryType;
-
-/**
- * GstGLQuery:
- *
- * Opaque #GstGLQuery struct
- */
-struct _GstGLQuery
-{
- /* <private> */
- GstGLContext * context;
- guint query_type;
- guint query_id;
- gboolean supported;
-
- gboolean start_called;
- GstGLAsyncDebug debug;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-void gst_gl_query_init (GstGLQuery * query,
- GstGLContext * context,
- GstGLQueryType query_type);
-GST_EXPORT
-void gst_gl_query_unset (GstGLQuery * query);
-GST_EXPORT
-GstGLQuery * gst_gl_query_new (GstGLContext * context,
- GstGLQueryType query_type);
-GST_EXPORT
-void gst_gl_query_free (GstGLQuery * query);
-
-GST_EXPORT
-void gst_gl_query_start (GstGLQuery * query);
-GST_EXPORT
-void gst_gl_query_end (GstGLQuery * query);
-GST_EXPORT
-void gst_gl_query_counter (GstGLQuery * query);
-GST_EXPORT
-guint64 gst_gl_query_result (GstGLQuery * query);
-
-#define gst_gl_query_start_log_valist(query,cat,level,object,format,varargs) \
- G_STMT_START { \
- GST_GL_ASYNC_CAT_LEVEL_LOG_valist (&(query)->debug, cat, level, object, format, varargs); \
- gst_gl_async_debug_freeze (&(query)->debug); \
- gst_gl_query_start (query); \
- gst_gl_async_debug_thaw (&(query)->debug); \
- } G_STMT_END
-
-#define gst_gl_query_counter_log_valist(query,cat,level,object,format,varargs) \
- G_STMT_START { \
- GST_GL_ASYNC_CAT_LEVEL_LOG_valist (&(query)->debug, cat, level, object, format, varargs); \
- gst_gl_async_debug_freeze (&(query)->debug); \
- gst_gl_query_counter (query); \
- gst_gl_async_debug_thaw (&(query)->debug); \
- } G_STMT_END
-
-#if G_HAVE_ISO_VARARGS
-
-#define gst_gl_query_start_log(query,cat,level,object,format,...) \
- G_STMT_START { \
- GST_GL_ASYNC_CAT_LEVEL_LOG (&(query)->debug, cat, level, object, format, __VA_ARGS__); \
- gst_gl_async_debug_freeze (&(query)->debug); \
- gst_gl_query_start (query); \
- gst_gl_async_debug_thaw (&(query)->debug); \
- } G_STMT_END
-#define gst_gl_query_counter_log(query,cat,level,object,format,...) \
- G_STMT_START { \
- GST_GL_ASYNC_CAT_LEVEL_LOG (&(query)->debug, cat, level, object, format, __VA_ARGS__); \
- gst_gl_async_debug_freeze (&(query)->debug); \
- gst_gl_query_counter (query); \
- gst_gl_async_debug_thaw (&(query)->debug); \
- } G_STMT_END
-
-#else /* G_HAVE_ISO_VARARGS */
-#if G_HAVE_GNUC_VARARGS
-
-#define gst_gl_query_start_log(query,cat,level,object,format,args...) \
- G_STMT_START { \
- GST_GL_ASYNC_CAT_LEVEL_LOG (&(query)->debug, cat, level, object, format, ##args); \
- gst_gl_async_debug_freeze (&(query)->debug); \
- gst_gl_query_start (query); \
- gst_gl_async_debug_thaw (&(query)->debug); \
- } G_STMT_END
-#define gst_gl_query_counter_log(query,cat,level,object,format,args...) \
- G_STMT_START { \
- GST_GL_ASYNC_CAT_LEVEL_LOG (&(query)->debug, cat, level, object, format, ##args); \
- gst_gl_async_debug_freeze (&(query)->debug); \
- gst_gl_query_counter (query); \
- gst_gl_async_debug_thaw (&(query)->debug); \
- } G_STMT_END
-
-#else /* G_HAVE_GNUC_VARARGS */
-
-static inline void
-gst_gl_query_start_log(GstGLQuery * query, GstDebugCategory * cat,
- GstDebugLevel level, GObject * object, const gchar * format, ...)
-{
- va_list varargs;
-
- va_start (varargs, format);
- gst_gl_query_start_log_valist (query, cat, level, object, format, varargs);
- va_end (varargs);
-}
-
-static inline void
-gst_gl_query_counter_log(GstGLQuery * query, GstDebugCategory * cat,
- GstDebugLevel level, GObject * object, const gchar * format, ...)
-{
- va_list varargs;
-
- va_start (varargs, format);
- gst_gl_query_counter_log_valist (query, cat, level, object, format, varargs);
- va_end (varargs);
-}
-
-#endif /* G_HAVE_GNUC_VARARGS */
-#endif /* G_HAVE_ISO_VARARGS */
-
-G_END_DECLS
-
-#endif /* __GST_GL_QUERY_H__ */
diff --git a/gst-libs/gst/gl/gstglrenderbuffer.c b/gst-libs/gst/gl/gstglrenderbuffer.c
deleted file mode 100644
index 4399c7ef8..000000000
--- a/gst-libs/gst/gl/gstglrenderbuffer.c
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "gstglrenderbuffer.h"
-
-#include "gstglcontext.h"
-#include "gstglfuncs.h"
-#include "gstglmemory.h"
-
-/**
- * SECTION:gstglrenderbuffer
- * @title: GstGLRenderBuffer
- * @short_description: memory subclass for GL renderbuffer objects
- * @see_also: #GstMemory, #GstAllocator
- *
- * GstGLRenderbuffer is a #GstGLBaseMemory subclass providing support for
- * OpenGL renderbuffers.
- *
- * #GstGLRenderbuffer is created or wrapped through gst_gl_base_memory_alloc()
- * with #GstGLRenderbufferAllocationParams.
- *
- * Since: 1.10
- */
-
-#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
-#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
-#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
-#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
-#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-
-static GstAllocator *_gl_renderbuffer_allocator;
-
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_RENDERBUFFER);
-#define GST_CAT_DEFAULT GST_CAT_GL_RENDERBUFFER
-
-G_DEFINE_TYPE (GstGLRenderbufferAllocator, gst_gl_renderbuffer_allocator,
- GST_TYPE_GL_BASE_MEMORY_ALLOCATOR);
-
-static guint
-_new_renderbuffer (GstGLContext * context, guint format, guint width,
- guint height)
-{
- const GstGLFuncs *gl = context->gl_vtable;
- guint rbo_id;
-
- gl->GenRenderbuffers (1, &rbo_id);
- gl->BindRenderbuffer (GL_RENDERBUFFER, rbo_id);
-
- gl->RenderbufferStorage (GL_RENDERBUFFER, format, width, height);
-
- gl->BindRenderbuffer (GL_RENDERBUFFER, 0);
-
- return rbo_id;
-}
-
-static gboolean
-_gl_rbo_create (GstGLRenderbuffer * gl_mem, GError ** error)
-{
- if (!gl_mem->renderbuffer_wrapped) {
- GstGLContext *context = gl_mem->mem.context;
- GLenum internal_format;
- GLenum tex_format;
- GLenum renderbuffer_type;
-
- tex_format = gl_mem->renderbuffer_format;
- renderbuffer_type = GL_UNSIGNED_BYTE;
- if (gl_mem->renderbuffer_format == GST_GL_RGB565) {
- tex_format = GST_GL_RGB;
- renderbuffer_type = GL_UNSIGNED_SHORT_5_6_5;
- }
-
- internal_format =
- gst_gl_sized_gl_format_from_gl_format_type (context, tex_format,
- renderbuffer_type);
-
- gl_mem->renderbuffer_id =
- _new_renderbuffer (context, internal_format,
- gst_gl_renderbuffer_get_width (gl_mem),
- gst_gl_renderbuffer_get_height (gl_mem));
-
- GST_CAT_TRACE (GST_CAT_GL_RENDERBUFFER, "Generating renderbuffer id:%u "
- "format:%u dimensions:%ux%u", gl_mem->renderbuffer_id, internal_format,
- gst_gl_renderbuffer_get_width (gl_mem),
- gst_gl_renderbuffer_get_height (gl_mem));
- }
-
- return TRUE;
-}
-
-static void
-gst_gl_renderbuffer_init (GstGLRenderbuffer * mem, GstAllocator * allocator,
- GstMemory * parent, GstGLContext * context,
- GstGLFormat renderbuffer_format, GstAllocationParams * params,
- guint width, guint height, gpointer user_data, GDestroyNotify notify)
-{
- gsize size;
- guint tex_type;
-
- tex_type = GL_UNSIGNED_BYTE;
- if (renderbuffer_format == GST_GL_RGB565)
- tex_type = GL_UNSIGNED_SHORT_5_6_5;
- size =
- gst_gl_format_type_n_bytes (renderbuffer_format,
- tex_type) * width * height;
-
- mem->renderbuffer_format = renderbuffer_format;
- mem->width = width;
- mem->height = height;
-
- gst_gl_base_memory_init ((GstGLBaseMemory *) mem, allocator, parent, context,
- params, size, user_data, notify);
-
- GST_CAT_DEBUG (GST_CAT_GL_RENDERBUFFER, "new GL renderbuffer context:%"
- GST_PTR_FORMAT " memory:%p format:%u dimensions:%ux%u ", context, mem,
- mem->renderbuffer_format, gst_gl_renderbuffer_get_width (mem),
- gst_gl_renderbuffer_get_height (mem));
-}
-
-static gpointer
-_gl_rbo_map (GstGLRenderbuffer * gl_mem, GstMapInfo * info, gsize maxsize)
-{
- GST_CAT_WARNING (GST_CAT_GL_RENDERBUFFER, "Renderbuffer's cannot be mapped");
-
- return NULL;
-}
-
-static void
-_gl_rbo_unmap (GstGLRenderbuffer * gl_mem, GstMapInfo * info)
-{
-}
-
-static GstMemory *
-_gl_rbo_copy (GstGLRenderbuffer * src, gssize offset, gssize size)
-{
- GST_CAT_WARNING (GST_CAT_GL_RENDERBUFFER, "Renderbuffer's cannot be copied");
-
- return NULL;
-}
-
-static GstMemory *
-_gl_rbo_alloc (GstAllocator * allocator, gsize size,
- GstAllocationParams * params)
-{
- g_warning ("Use gst_gl_base_memory_alloc to allocate from this allocator");
-
- return NULL;
-}
-
-static void
-_gl_rbo_destroy (GstGLRenderbuffer * gl_mem)
-{
- const GstGLFuncs *gl = gl_mem->mem.context->gl_vtable;
-
- if (gl_mem->renderbuffer_id && !gl_mem->renderbuffer_wrapped)
- gl->DeleteRenderbuffers (1, &gl_mem->renderbuffer_id);
-}
-
-static GstGLRenderbuffer *
-_default_gl_rbo_alloc (GstGLRenderbufferAllocator * allocator,
- GstGLRenderbufferAllocationParams * params)
-{
- guint alloc_flags = params->parent.alloc_flags;
- GstGLRenderbuffer *mem;
-
- g_return_val_if_fail ((alloc_flags &
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM) == 0, NULL);
-
- mem = g_new0 (GstGLRenderbuffer, 1);
-
- if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
- mem->renderbuffer_id = GPOINTER_TO_UINT (params->parent.gl_handle);
- mem->renderbuffer_wrapped = TRUE;
- }
-
- gst_gl_renderbuffer_init (mem, GST_ALLOCATOR_CAST (allocator), NULL,
- params->parent.context, params->renderbuffer_format,
- params->parent.alloc_params, params->width, params->height,
- params->parent.user_data, params->parent.notify);
-
- return mem;
-}
-
-static void
-gst_gl_renderbuffer_allocator_class_init (GstGLRenderbufferAllocatorClass *
- klass)
-{
- GstGLBaseMemoryAllocatorClass *gl_base;
- GstAllocatorClass *allocator_class;
-
- gl_base = (GstGLBaseMemoryAllocatorClass *) klass;
- allocator_class = (GstAllocatorClass *) klass;
-
- gl_base->alloc =
- (GstGLBaseMemoryAllocatorAllocFunction) _default_gl_rbo_alloc;
- gl_base->create = (GstGLBaseMemoryAllocatorCreateFunction) _gl_rbo_create;
- gl_base->destroy = (GstGLBaseMemoryAllocatorDestroyFunction) _gl_rbo_destroy;
-
- allocator_class->alloc = _gl_rbo_alloc;
-}
-
-static void
-gst_gl_renderbuffer_allocator_init (GstGLRenderbufferAllocator * allocator)
-{
- GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator);
-
- alloc->mem_type = GST_GL_RENDERBUFFER_ALLOCATOR_NAME;
-
- alloc->mem_map_full = (GstMemoryMapFullFunction) _gl_rbo_map;
- alloc->mem_unmap_full = (GstMemoryUnmapFullFunction) _gl_rbo_unmap;
- alloc->mem_copy = (GstMemoryCopyFunction) _gl_rbo_copy;
-
- GST_OBJECT_FLAG_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC);
-}
-
-/**
- * gst_gl_renderbuffer_get_width:
- * @gl_mem: a #GstGLRenderbuffer
- *
- * Returns: the configured width of @gl_mem
- *
- * Since: 1.10
- */
-gint
-gst_gl_renderbuffer_get_width (GstGLRenderbuffer * gl_mem)
-{
- g_return_val_if_fail (gst_is_gl_renderbuffer ((GstMemory *) gl_mem), 0);
-
- return gl_mem->width;
-}
-
-/**
- * gst_gl_renderbuffer_get_height:
- * @gl_mem: a #GstGLRenderbuffer
- *
- * Returns: the configured height of @gl_mem
- *
- * Since: 1.10
- */
-gint
-gst_gl_renderbuffer_get_height (GstGLRenderbuffer * gl_mem)
-{
- g_return_val_if_fail (gst_is_gl_renderbuffer ((GstMemory *) gl_mem), 0);
-
- return gl_mem->height;
-}
-
-/**
- * gst_gl_renderbuffer_get_format:
- * @gl_mem: a #GstGLRenderbuffer
- *
- * Returns: the #GstGLFormat of @gl_mem
- *
- * Since: 1.12
- */
-GstGLFormat
-gst_gl_renderbuffer_get_format (GstGLRenderbuffer * gl_mem)
-{
- g_return_val_if_fail (gst_is_gl_renderbuffer ((GstMemory *) gl_mem), 0);
-
- return gl_mem->renderbuffer_format;
-}
-
-/**
- * gst_gl_renderbuffer_get_id:
- * @gl_mem: a #GstGLRenderbuffer
- *
- * Returns: the OpenGL renderbuffer handle of @gl_mem
- *
- * Since: 1.10
- */
-guint
-gst_gl_renderbuffer_get_id (GstGLRenderbuffer * gl_mem)
-{
- g_return_val_if_fail (gst_is_gl_renderbuffer ((GstMemory *) gl_mem), 0);
-
- return gl_mem->renderbuffer_id;
-}
-
-/**
- * gst_gl_renderbuffer_init_once:
- *
- * Initializes the GL Base Texture allocator. It is safe to call this function
- * multiple times. This must be called before any other GstGLRenderbuffer operation.
- *
- * Since: 1.10
- */
-void
-gst_gl_renderbuffer_init_once (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- gst_gl_base_memory_init_once ();
-
- GST_DEBUG_CATEGORY_INIT (GST_CAT_GL_RENDERBUFFER, "glrenderbuffermemory", 0,
- "OpenGL Renderbuffer memory");
-
- _gl_renderbuffer_allocator =
- g_object_new (GST_TYPE_GL_RENDERBUFFER_ALLOCATOR, NULL);
- gst_object_ref_sink (_gl_renderbuffer_allocator);
- GST_OBJECT_FLAG_SET (_gl_renderbuffer_allocator,
- GST_OBJECT_FLAG_MAY_BE_LEAKED);
-
- gst_allocator_register (GST_GL_RENDERBUFFER_ALLOCATOR_NAME,
- _gl_renderbuffer_allocator);
-
- g_once_init_leave (&_init, 1);
- }
-}
-
-/**
- * gst_is_gl_renderbuffer:
- * @mem:a #GstMemory
- *
- * Returns: whether the memory at @mem is a #GstGLRenderbuffer
- *
- * Since: 1.10
- */
-gboolean
-gst_is_gl_renderbuffer (GstMemory * mem)
-{
- return mem != NULL && mem->allocator != NULL
- && g_type_is_a (G_OBJECT_TYPE (mem->allocator),
- GST_TYPE_GL_RENDERBUFFER_ALLOCATOR);
-}
-
-G_DEFINE_BOXED_TYPE (GstGLRenderbufferAllocationParams,
- gst_gl_renderbuffer_allocation_params,
- (GBoxedCopyFunc) gst_gl_allocation_params_copy,
- (GBoxedFreeFunc) gst_gl_allocation_params_free);
-
-static void
-_gst_gl_rb_alloc_params_free_data (GstGLRenderbufferAllocationParams * params)
-{
- gst_gl_allocation_params_free_data (&params->parent);
-}
-
-static void
-_gst_gl_rb_alloc_params_copy_data (GstGLRenderbufferAllocationParams * src_vid,
- GstGLRenderbufferAllocationParams * dest_vid)
-{
- GstGLAllocationParams *src = (GstGLAllocationParams *) src_vid;
- GstGLAllocationParams *dest = (GstGLAllocationParams *) dest_vid;
-
- gst_gl_allocation_params_copy_data (src, dest);
-
- dest_vid->renderbuffer_format = src_vid->renderbuffer_format;
- dest_vid->width = src_vid->width;
- dest_vid->height = src_vid->height;
-}
-
-static gboolean
- _gst_gl_renderbuffer_allocation_params_init_full
- (GstGLRenderbufferAllocationParams * params, gsize struct_size,
- guint alloc_flags, GstGLAllocationParamsCopyFunc copy,
- GstGLAllocationParamsFreeFunc free, GstGLContext * context,
- GstAllocationParams * alloc_params, guint width, guint height,
- GstGLFormat renderbuffer_format, gpointer wrapped_data,
- gpointer gl_handle, gpointer user_data, GDestroyNotify notify)
-{
- g_return_val_if_fail (params != NULL, FALSE);
- g_return_val_if_fail (copy != NULL, FALSE);
- g_return_val_if_fail (free != NULL, FALSE);
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
-
- memset (params, 0, sizeof (*params));
-
- if (!gst_gl_allocation_params_init ((GstGLAllocationParams *) params,
- struct_size, alloc_flags, copy, free, context, 0, alloc_params,
- wrapped_data, gl_handle, user_data, notify))
- return FALSE;
-
- params->renderbuffer_format = renderbuffer_format;
- params->width = width;
- params->height = height;
-
- return TRUE;
-}
-
-/**
- * gst_gl_renderbuffer_allocation_params_new:
- * @context: a #GstGLContext
- * @alloc_params: (allow-none): the #GstAllocationParams for sysmem mappings of the texture
- * @width: the width of the renderbuffer
- * @height: the height of the renderbuffer
- * @renderbuffer_format: the #GstGLFormat for the created textures
- *
- * Returns: a new #GstGLRenderbufferAllocationParams for allocating #GstGLRenderbuffer's
- *
- * Since: 1.10
- */
-GstGLRenderbufferAllocationParams *
-gst_gl_renderbuffer_allocation_params_new (GstGLContext * context,
- GstAllocationParams * alloc_params, GstGLFormat renderbuffer_format,
- guint width, guint height)
-{
- GstGLRenderbufferAllocationParams *params =
- g_new0 (GstGLRenderbufferAllocationParams, 1);
-
- if (!_gst_gl_renderbuffer_allocation_params_init_full (params,
- sizeof (GstGLRenderbufferAllocationParams),
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_ALLOC |
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
- (GstGLAllocationParamsCopyFunc) _gst_gl_rb_alloc_params_copy_data,
- (GstGLAllocationParamsFreeFunc) _gst_gl_rb_alloc_params_free_data,
- context, alloc_params, width, height, renderbuffer_format, NULL, 0,
- NULL, NULL)) {
- g_free (params);
- return NULL;
- }
-
- return params;
-}
-
-/**
- * gst_gl_renderbuffer_allocation_params_new_wrapped:
- * @context: a #GstGLContext
- * @alloc_params: (allow-none): the #GstAllocationParams for @tex_id
- * @width: the width of the renderbuffer
- * @height: the height of the renderbuffer
- * @renderbuffer_format: the #GstGLFormat for @tex_id
- * @gl_handle: the GL handle to wrap
- * @user_data: (allow-none): user data to call @notify with
- * @notify: (allow-none): a #GDestroyNotify
- *
- * Returns: a new #GstGLRenderbufferAllocationParams for wrapping @gl_handle as a
- * renderbuffer
- *
- * Since: 1.10
- */
-GstGLRenderbufferAllocationParams *
-gst_gl_renderbuffer_allocation_params_new_wrapped (GstGLContext * context,
- GstAllocationParams * alloc_params, GstGLFormat renderbuffer_format,
- guint width, guint height, gpointer gl_handle, gpointer user_data,
- GDestroyNotify notify)
-{
- GstGLRenderbufferAllocationParams *params =
- g_new0 (GstGLRenderbufferAllocationParams, 1);
-
- if (!_gst_gl_renderbuffer_allocation_params_init_full (params,
- sizeof (GstGLRenderbufferAllocationParams),
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE |
- GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO,
- (GstGLAllocationParamsCopyFunc) _gst_gl_rb_alloc_params_copy_data,
- (GstGLAllocationParamsFreeFunc) _gst_gl_rb_alloc_params_free_data,
- context, alloc_params, width, height, renderbuffer_format, NULL,
- gl_handle, user_data, notify)) {
- g_free (params);
- return NULL;
- }
-
- return params;
-}
diff --git a/gst-libs/gst/gl/gstglrenderbuffer.h b/gst-libs/gst/gl/gstglrenderbuffer.h
deleted file mode 100644
index 598f0ab9c..000000000
--- a/gst-libs/gst/gl/gstglrenderbuffer.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_GL_RENDERBUFFER_H_
-#define _GST_GL_RENDERBUFFER_H_
-
-#include <gst/gl/gstglbasememory.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_RENDERBUFFER_ALLOCATOR (gst_gl_renderbuffer_allocator_get_type())
-GST_EXPORT GType gst_gl_renderbuffer_allocator_get_type(void);
-
-#define GST_IS_GL_RENDERBUFFER_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_RENDERBUFFER_ALLOCATOR))
-#define GST_IS_GL_RENDERBUFFER_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GL_RENDERBUFFER_ALLOCATOR))
-#define GST_GL_RENDERBUFFER_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GL_RENDERBUFFER_ALLOCATOR, GstGLRenderbufferAllocatorClass))
-#define GST_GL_RENDERBUFFER_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_RENDERBUFFER_ALLOCATOR, GstGLRenderbufferAllocator))
-#define GST_GL_RENDERBUFFER_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_RENDERBUFFER_ALLOCATOR, GstGLRenderbufferAllocatorClass))
-#define GST_GL_RENDERBUFFER_ALLOCATOR_CAST(obj) ((GstGLRenderbufferAllocator *)(obj))
-
-#define GST_GL_RENDERBUFFER_CAST(obj) ((GstGLRenderbuffer *) obj)
-
-/**
- * GST_GL_RENDERBUFFER_ALLOCATOR_NAME:
- *
- * The name of the GL renderbuffer allocator
- */
-#define GST_GL_RENDERBUFFER_ALLOCATOR_NAME "GLRenderbuffer"
-
-/**
- * GstGLRenderbuffer:
- * @mem: the parent object
- * @renderbuffer_id: the GL texture id for this memory
- * @renderbuffer_type: the texture type
- * @width: the width
- * @height: the height
- *
- * Represents information about a GL renderbuffer
- */
-struct _GstGLRenderbuffer
-{
- GstGLBaseMemory mem;
-
- guint renderbuffer_id;
- GstGLFormat renderbuffer_format;
- guint width;
- guint height;
-
- /* <protected> */
- gboolean renderbuffer_wrapped;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GstGLRenderbufferAllocator
- *
- * Opaque #GstGLRenderbufferAllocator struct
- */
-struct _GstGLRenderbufferAllocator
-{
- GstGLBaseMemoryAllocator parent;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GstGLRenderbufferAllocatorClass:
- *
- * The #GstGLRenderbufferAllocatorClass only contains private data
- */
-struct _GstGLRenderbufferAllocatorClass
-{
- GstGLBaseMemoryAllocatorClass parent_class;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-#include <gst/gl/gstglbasememory.h>
-
-GST_EXPORT GType gst_gl_renderbuffer_allocation_params_get_type (void);
-#define GST_TYPE_RENDERBUFFER_ALLOCATION_PARAMS (gst_gl_renderbuffer_allocation_params_get_type)
-
-typedef struct
-{
- GstGLAllocationParams parent;
-
- GstGLFormat renderbuffer_format;
- guint width;
- guint height;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-} GstGLRenderbufferAllocationParams;
-
-GST_EXPORT
-GstGLRenderbufferAllocationParams * gst_gl_renderbuffer_allocation_params_new (GstGLContext * context,
- GstAllocationParams * alloc_params,
- GstGLFormat renderbuffer_format,
- guint width,
- guint height);
-
-GST_EXPORT
-GstGLRenderbufferAllocationParams * gst_gl_renderbuffer_allocation_params_new_wrapped (GstGLContext * context,
- GstAllocationParams * alloc_params,
- GstGLFormat renderbuffer_format,
- guint width,
- guint height,
- gpointer gl_handle,
- gpointer user_data,
- GDestroyNotify notify);
-
-GST_EXPORT
-void gst_gl_renderbuffer_init_once (void);
-
-GST_EXPORT
-gboolean gst_is_gl_renderbuffer (GstMemory * mem);
-
-/* accessors */
-GST_EXPORT
-gint gst_gl_renderbuffer_get_width (GstGLRenderbuffer * gl_mem);
-
-GST_EXPORT
-gint gst_gl_renderbuffer_get_height (GstGLRenderbuffer * gl_mem);
-
-GST_EXPORT
-GstGLFormat gst_gl_renderbuffer_get_format (GstGLRenderbuffer * gl_mem);
-
-GST_EXPORT
-guint gst_gl_renderbuffer_get_id (GstGLRenderbuffer * gl_mem);
-
-G_END_DECLS
-
-#endif /* _GST_GL_RENDERBUFFER_H_ */
diff --git a/gst-libs/gst/gl/gstglshader.c b/gst-libs/gst/gl/gstglshader.c
deleted file mode 100644
index 9e5e1f780..000000000
--- a/gst-libs/gst/gl/gstglshader.c
+++ /dev/null
@@ -1,1589 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
- * Copyright (C) 2014 Julien Isorce <julien.isorce@collabora.co.uk>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gl.h"
-#include "gstglshader.h"
-#include "gstglsl_private.h"
-
-/**
- * SECTION:gstglshader
- * @title: GstGLShader
- * @short_description: object representing an OpenGL shader program
- * @see_also: #GstGLSLStage
- */
-
-#ifndef GLhandleARB
-#define GLhandleARB GLuint
-#endif
-
-#define GST_GL_SHADER_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_SHADER, GstGLShaderPrivate))
-
-#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
-#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
-#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
-#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
-#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-
-typedef struct _GstGLShaderVTable
-{
- GLuint (GSTGLAPI * CreateProgram) (void);
- void (GSTGLAPI * DeleteProgram) (GLuint program);
- void (GSTGLAPI * UseProgram) (GLuint program);
- void (GSTGLAPI * GetAttachedShaders) (GLuint program, GLsizei maxcount,
- GLsizei * count, GLuint * shaders);
-
- GLuint (GSTGLAPI * CreateShader) (GLenum shaderType);
- void (GSTGLAPI * DeleteShader) (GLuint shader);
- void (GSTGLAPI * AttachShader) (GLuint program, GLuint shader);
- void (GSTGLAPI * DetachShader) (GLuint program, GLuint shader);
-
- void (GSTGLAPI * GetShaderiv) (GLuint program, GLenum pname, GLint * params);
- void (GSTGLAPI * GetProgramiv) (GLuint program, GLenum pname, GLint * params);
- void (GSTGLAPI * GetShaderInfoLog) (GLuint shader, GLsizei maxLength,
- GLsizei * length, char *log);
- void (GSTGLAPI * GetProgramInfoLog) (GLuint shader, GLsizei maxLength,
- GLsizei * length, char *log);
-} GstGLShaderVTable;
-
-enum
-{
- PROP_0,
- PROP_LINKED,
-};
-
-struct _GstGLShaderPrivate
-{
- GLhandleARB program_handle;
- GList *stages;
-
- gboolean linked;
- GHashTable *uniform_locations;
-
- GstGLSLFuncs vtable;
-};
-
-GST_DEBUG_CATEGORY_STATIC (gst_gl_shader_debug);
-#define GST_CAT_DEFAULT gst_gl_shader_debug
-
-#define DEBUG_INIT \
- GST_DEBUG_CATEGORY_INIT (gst_gl_shader_debug, "glshader", 0, "shader");
-G_DEFINE_TYPE_WITH_CODE (GstGLShader, gst_gl_shader, GST_TYPE_OBJECT,
- DEBUG_INIT);
-
-static void
-_cleanup_shader (GstGLContext * context, GstGLShader * shader)
-{
- GstGLShaderPrivate *priv = shader->priv;
-
- GST_OBJECT_LOCK (shader);
-
- /* release shader objects */
- gst_gl_shader_release_unlocked (shader);
-
- /* delete program */
- if (priv->program_handle) {
- GST_TRACE ("finalizing program shader %u", priv->program_handle);
-
- priv->vtable.DeleteProgram (priv->program_handle);
- }
-
- GST_DEBUG ("shader deleted %u", priv->program_handle);
-
- GST_OBJECT_UNLOCK (shader);
-}
-
-static void
-gst_gl_shader_finalize (GObject * object)
-{
- GstGLShader *shader;
- GstGLShaderPrivate *priv;
-
- shader = GST_GL_SHADER (object);
- priv = shader->priv;
-
- GST_TRACE_OBJECT (shader, "finalizing shader %u", priv->program_handle);
-
- gst_gl_context_thread_add (shader->context,
- (GstGLContextThreadFunc) _cleanup_shader, shader);
-
- priv->program_handle = 0;
- g_hash_table_destroy (priv->uniform_locations);
-
- if (shader->context) {
- gst_object_unref (shader->context);
- shader->context = NULL;
- }
-
- G_OBJECT_CLASS (gst_gl_shader_parent_class)->finalize (object);
-}
-
-static void
-gst_gl_shader_set_property (GObject * object,
- guint prop_id, const GValue * value, GParamSpec * pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_gl_shader_get_property (GObject * object,
- guint prop_id, GValue * value, GParamSpec * pspec)
-{
- GstGLShader *shader = GST_GL_SHADER (object);
- GstGLShaderPrivate *priv = shader->priv;
-
- switch (prop_id) {
- case PROP_LINKED:
- g_value_set_boolean (value, priv->linked);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_gl_shader_class_init (GstGLShaderClass * klass)
-{
- /* bind class methods .. */
- GObjectClass *obj_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GstGLShaderPrivate));
-
- obj_class->finalize = gst_gl_shader_finalize;
- obj_class->set_property = gst_gl_shader_set_property;
- obj_class->get_property = gst_gl_shader_get_property;
-
- /* .. and install properties */
- g_object_class_install_property (obj_class,
- PROP_LINKED,
- g_param_spec_boolean ("linked",
- "Linked",
- "Shader link status", FALSE,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-}
-
-static void
-gst_gl_shader_init (GstGLShader * self)
-{
- /* initialize sources and create program object */
- GstGLShaderPrivate *priv;
-
- priv = self->priv = GST_GL_SHADER_GET_PRIVATE (self);
-
- priv->linked = FALSE;
- priv->uniform_locations =
- g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
-}
-
-static int
-_get_uniform_location (GstGLShader * shader, const gchar * name)
-{
- GstGLShaderPrivate *priv = shader->priv;
- int location;
- gpointer value;
-
- g_return_val_if_fail (priv->linked, 0);
-
- if (!g_hash_table_lookup_extended (priv->uniform_locations, name, NULL,
- &value)) {
- const GstGLFuncs *gl = shader->context->gl_vtable;
- location = gl->GetUniformLocation (priv->program_handle, name);
- g_hash_table_insert (priv->uniform_locations, g_strdup (name),
- GINT_TO_POINTER (location));
- } else {
- location = GPOINTER_TO_INT (value);
- }
-
- return location;
-}
-
-static GstGLShader *
-_new_with_stages_va_list (GstGLContext * context, GError ** error,
- va_list varargs)
-{
- GstGLShader *shader;
- GstGLSLStage *stage;
- gboolean to_unref_and_out = FALSE;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), NULL);
-
- shader = g_object_new (GST_TYPE_GL_SHADER, NULL);
- gst_object_ref_sink (shader);
- shader->context = gst_object_ref (context);
-
- while ((stage = va_arg (varargs, GstGLSLStage *))) {
- if (to_unref_and_out) {
- gst_object_unref (stage);
- continue;
- }
-
- if (!gst_glsl_stage_compile (stage, error)) {
- gst_object_unref (stage);
- to_unref_and_out = TRUE;
- continue;
- }
- if (!gst_gl_shader_attach (shader, stage)) {
- g_set_error (error, GST_GLSL_ERROR, GST_GLSL_ERROR_PROGRAM,
- "Failed to attach stage to program");
- to_unref_and_out = TRUE;
- continue;
- }
- }
-
- if (to_unref_and_out) {
- gst_object_unref (shader);
- return NULL;
- }
-
- return shader;
-}
-
-/**
- * gst_gl_shader_new_link_with_stages:
- * @context: a #GstGLContext
- * @error: a #GError
- * @...: a NULL terminated list of #GstGLSLStage's
- *
- * Each stage will attempt to be compiled and attached to @shader. Then
- * the shader will be linked. On error, %NULL will be returned and @error will
- * contain the details of the error.
- *
- * Note: must be called in the GL thread
- *
- * Returns: (transfer full): a new @shader with the specified stages.
- *
- * Since: 1.8
- */
-GstGLShader *
-gst_gl_shader_new_link_with_stages (GstGLContext * context, GError ** error,
- ...)
-{
- GstGLShader *shader;
- va_list varargs;
-
- va_start (varargs, error);
- shader = _new_with_stages_va_list (context, error, varargs);
- va_end (varargs);
-
- if (!shader)
- return NULL;
-
- if (!gst_gl_shader_link (shader, error))
- return NULL;
-
- return shader;
-}
-
-/**
- * gst_gl_shader_new_with_stages:
- * @context: a #GstGLContext
- * @error: a #GError
- * @...: a NULL terminated list of #GstGLSLStage's
- *
- * Each stage will attempt to be compiled and attached to @shader. On error,
- * %NULL will be returned and @error will contain the details of the error.
- *
- * Note: must be called in the GL thread
- *
- * Returns: (transfer full): a new @shader with the specified stages.
- *
- * Since: 1.8
- */
-GstGLShader *
-gst_gl_shader_new_with_stages (GstGLContext * context, GError ** error, ...)
-{
- GstGLShader *shader;
- va_list varargs;
-
- va_start (varargs, error);
- shader = _new_with_stages_va_list (context, error, varargs);
- va_end (varargs);
-
- return shader;
-}
-
-/**
- * gst_gl_shader_new:
- * @context: a #GstGLContext
- *
- * Note: must be called in the GL thread
- *
- * Returns: (transfer full): a new empty @shader
- */
-GstGLShader *
-gst_gl_shader_new (GstGLContext * context)
-{
- return gst_gl_shader_new_with_stages (context, NULL, NULL);
-}
-
-/**
- * gst_gl_shader_new_default:
- * @context: a #GstGLContext
- * @error: a #GError that is filled on failure
- *
- * Note: must be called in the GL thread
- *
- * Returns: (transfer full): a default @shader or %NULL on failure
- *
- * Since: 1.8
- */
-GstGLShader *
-gst_gl_shader_new_default (GstGLContext * context, GError ** error)
-{
- return gst_gl_shader_new_link_with_stages (context, error,
- gst_glsl_stage_new_default_vertex (context),
- gst_glsl_stage_new_default_fragment (context), NULL);
-}
-
-/**
- * gst_gl_shader_is_linked:
- * @shader: a #GstGLShader
- *
- * Note: must be called in the GL thread
- *
- * Returns: whether @shader has been successfully linked
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_shader_is_linked (GstGLShader * shader)
-{
- gboolean ret;
-
- g_return_val_if_fail (GST_IS_GL_SHADER (shader), FALSE);
-
- GST_OBJECT_LOCK (shader);
- ret = shader->priv->linked;
- GST_OBJECT_UNLOCK (shader);
-
- return ret;
-}
-
-static gboolean
-_ensure_program (GstGLShader * shader)
-{
- if (shader->priv->program_handle)
- return TRUE;
-
- shader->priv->program_handle = shader->priv->vtable.CreateProgram ();
- return shader->priv->program_handle != 0;
-}
-
-/**
- * gst_gl_shader_get_program_handle:
- * @shader: a #GstGLShader
- *
- * Returns: the GL program handle for this shader
- *
- * Since: 1.8
- */
-int
-gst_gl_shader_get_program_handle (GstGLShader * shader)
-{
- int ret;
-
- g_return_val_if_fail (GST_IS_GL_SHADER (shader), 0);
-
- GST_OBJECT_LOCK (shader);
- ret = (int) shader->priv->program_handle;
- GST_OBJECT_UNLOCK (shader);
-
- return ret;
-}
-
-/**
- * gst_gl_shader_detach_unlocked:
- * @shader: a #GstGLShader
- * @stage: a #GstGLSLStage to attach
- *
- * Detaches @stage from @shader. @stage must have been successfully attached
- * to @shader with gst_gl_shader_attach() or gst_gl_shader_attach_unlocked().
- *
- * Note: must be called in the GL thread
- *
- * Since: 1.8
- */
-void
-gst_gl_shader_detach_unlocked (GstGLShader * shader, GstGLSLStage * stage)
-{
- guint stage_handle;
- GList *elem;
-
- g_return_if_fail (GST_IS_GL_SHADER (shader));
- g_return_if_fail (GST_IS_GLSL_STAGE (stage));
-
- if (!_gst_glsl_funcs_fill (&shader->priv->vtable, shader->context)) {
- GST_WARNING_OBJECT (shader, "Failed to retreive required GLSL functions");
- return;
- }
-
- if (!shader->priv->program_handle)
- return;
-
- elem = g_list_find (shader->priv->stages, stage);
- if (!elem) {
- GST_FIXME_OBJECT (shader, "Could not find stage %p in shader %p", stage,
- shader);
- return;
- }
-
- stage_handle = gst_glsl_stage_get_handle (stage);
- if (!stage_handle) {
- GST_FIXME_OBJECT (shader, "Stage %p doesn't have a GL handle", stage);
- return;
- }
-
- if (shader->context->gl_vtable->IsProgram)
- g_assert (shader->context->gl_vtable->IsProgram (shader->priv->
- program_handle));
- if (shader->context->gl_vtable->IsShader)
- g_assert (shader->context->gl_vtable->IsShader (stage_handle));
-
- GST_LOG_OBJECT (shader, "detaching shader %i from program %i", stage_handle,
- (int) shader->priv->program_handle);
- shader->priv->vtable.DetachShader (shader->priv->program_handle,
- stage_handle);
-
- shader->priv->stages = g_list_delete_link (shader->priv->stages, elem);
- gst_object_unref (stage);
-}
-
-/**
- * gst_gl_shader_detach:
- * @shader: a #GstGLShader
- * @stage: a #GstGLSLStage to attach
- *
- * Detaches @stage from @shader. @stage must have been successfully attached
- * to @shader with gst_gl_shader_attach() or gst_gl_shader_attach_unlocked().
- *
- * Note: must be called in the GL thread
- *
- * Since: 1.8
- */
-void
-gst_gl_shader_detach (GstGLShader * shader, GstGLSLStage * stage)
-{
- g_return_if_fail (GST_IS_GL_SHADER (shader));
- g_return_if_fail (GST_IS_GLSL_STAGE (stage));
-
- GST_OBJECT_LOCK (shader);
- gst_gl_shader_detach_unlocked (shader, stage);
- GST_OBJECT_UNLOCK (shader);
-}
-
-/**
- * gst_gl_shader_attach_unlocked:
- * @shader: a #GstGLShader
- * @stage: (transfer floating): a #GstGLSLStage to attach
- *
- * Attaches @stage to @shader. @stage must have been successfully compiled
- * with gst_glsl_stage_compile().
- *
- * Note: must be called in the GL thread
- *
- * Returns: whether @stage could be attached to @shader
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_shader_attach_unlocked (GstGLShader * shader, GstGLSLStage * stage)
-{
- guint stage_handle;
-
- g_return_val_if_fail (GST_IS_GL_SHADER (shader), FALSE);
- g_return_val_if_fail (GST_IS_GLSL_STAGE (stage), FALSE);
-
- if (!_gst_glsl_funcs_fill (&shader->priv->vtable, shader->context)) {
- GST_WARNING_OBJECT (shader, "Failed to retreive required GLSL functions");
- gst_object_ref_sink (stage);
- gst_object_unref (stage);
- return FALSE;
- }
-
- if (!_ensure_program (shader)) {
- gst_object_ref_sink (stage);
- gst_object_unref (stage);
- return FALSE;
- }
-
- /* already attached? */
- if (g_list_find (shader->priv->stages, stage)) {
- gst_object_ref_sink (stage);
- gst_object_unref (stage);
- return TRUE;
- }
-
- stage_handle = gst_glsl_stage_get_handle (stage);
- if (!stage_handle) {
- gst_object_ref_sink (stage);
- gst_object_unref (stage);
- return FALSE;
- }
-
- if (shader->context->gl_vtable->IsProgram)
- g_assert (shader->context->gl_vtable->IsProgram (shader->priv->
- program_handle));
- if (shader->context->gl_vtable->IsShader)
- g_assert (shader->context->gl_vtable->IsShader (stage_handle));
-
- shader->priv->stages =
- g_list_prepend (shader->priv->stages, gst_object_ref_sink (stage));
- GST_LOG_OBJECT (shader, "attaching shader %i to program %i", stage_handle,
- (int) shader->priv->program_handle);
- shader->priv->vtable.AttachShader (shader->priv->program_handle,
- stage_handle);
-
- return TRUE;
-}
-
-/**
- * gst_gl_shader_attach:
- * @shader: a #GstGLShader
- * @stage: (transfer floating): a #GstGLSLStage to attach
- *
- * Attaches @stage to @shader. @stage must have been successfully compiled
- * with gst_glsl_stage_compile().
- *
- * Note: must be called in the GL thread
- *
- * Returns: whether @stage could be attached to @shader
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_shader_attach (GstGLShader * shader, GstGLSLStage * stage)
-{
- gboolean ret;
-
- g_return_val_if_fail (GST_IS_GL_SHADER (shader), FALSE);
- g_return_val_if_fail (GST_IS_GLSL_STAGE (stage), FALSE);
-
- GST_OBJECT_LOCK (shader);
- ret = gst_gl_shader_attach_unlocked (shader, stage);
- GST_OBJECT_UNLOCK (shader);
-
- return ret;
-}
-
-/**
- * gst_gl_shader_compile_attach_stage:
- * @shader: a #GstGLShader
- * @stage: a #GstGLSLStage to attach
- * @error: a #GError
- *
- * Compiles @stage and attaches it to @shader.
- *
- * Note: must be called in the GL thread
- *
- * Returns: whether @stage could be compiled and attached to @shader
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_shader_compile_attach_stage (GstGLShader * shader, GstGLSLStage * stage,
- GError ** error)
-{
- g_return_val_if_fail (GST_IS_GLSL_STAGE (stage), FALSE);
-
- if (!gst_glsl_stage_compile (stage, error)) {
- return FALSE;
- }
-
- if (!gst_gl_shader_attach (shader, stage)) {
- g_set_error (error, GST_GLSL_ERROR, GST_GLSL_ERROR_COMPILE,
- "Failed to attach stage to shader");
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
- * gst_gl_shader_link:
- * @shader: a #GstGLShader
- * @error: a #GError
- *
- * Links the current list of #GstGLSLStage's in @shader.
- *
- * Note: must be called in the GL thread
- *
- * Returns: whether @shader could be linked together.
- *
- * Since: 1.8
- */
-gboolean
-gst_gl_shader_link (GstGLShader * shader, GError ** error)
-{
- GstGLShaderPrivate *priv;
- const GstGLFuncs *gl;
- gchar info_buffer[2048];
- GLint status = GL_FALSE;
- gint len = 0;
- gboolean ret;
- GList *elem;
-
- g_return_val_if_fail (GST_IS_GL_SHADER (shader), FALSE);
-
- GST_OBJECT_LOCK (shader);
-
- priv = shader->priv;
- gl = shader->context->gl_vtable;
-
- if (priv->linked) {
- GST_OBJECT_UNLOCK (shader);
- return TRUE;
- }
-
- if (!_gst_glsl_funcs_fill (&shader->priv->vtable, shader->context)) {
- g_set_error (error, GST_GLSL_ERROR, GST_GLSL_ERROR_PROGRAM,
- "Failed to retreive required GLSL functions");
- GST_OBJECT_UNLOCK (shader);
- return FALSE;
- }
-
- if (!_ensure_program (shader)) {
- g_set_error (error, GST_GLSL_ERROR, GST_GLSL_ERROR_PROGRAM,
- "Failed to create GL program object");
- GST_OBJECT_UNLOCK (shader);
- return FALSE;
- }
-
- GST_TRACE ("shader created %u", shader->priv->program_handle);
-
- for (elem = shader->priv->stages; elem; elem = elem->next) {
- GstGLSLStage *stage = elem->data;
-
- if (!gst_glsl_stage_compile (stage, error)) {
- GST_OBJECT_UNLOCK (shader);
- return FALSE;
- }
-
- if (!gst_gl_shader_attach_unlocked (shader, stage)) {
- g_set_error (error, GST_GLSL_ERROR, GST_GLSL_ERROR_COMPILE,
- "Failed to attach shader %" GST_PTR_FORMAT "to program %"
- GST_PTR_FORMAT, stage, shader);
- GST_OBJECT_UNLOCK (shader);
- return FALSE;
- }
- }
-
- /* if nothing failed link shaders */
- gl->LinkProgram (priv->program_handle);
- status = GL_FALSE;
- priv->vtable.GetProgramiv (priv->program_handle, GL_LINK_STATUS, &status);
-
- priv->vtable.GetProgramInfoLog (priv->program_handle,
- sizeof (info_buffer) - 1, &len, info_buffer);
- info_buffer[len] = '\0';
-
- if (status != GL_TRUE) {
- GST_ERROR ("Shader linking failed:\n%s", info_buffer);
-
- g_set_error (error, GST_GLSL_ERROR, GST_GLSL_ERROR_LINK,
- "Shader Linking failed:\n%s", info_buffer);
- ret = priv->linked = FALSE;
- GST_OBJECT_UNLOCK (shader);
- return ret;
- } else if (len > 1) {
- GST_FIXME ("shader link log:\n%s\n", info_buffer);
- }
-
- ret = priv->linked = TRUE;
- GST_OBJECT_UNLOCK (shader);
-
- g_object_notify (G_OBJECT (shader), "linked");
-
- return ret;
-}
-
-/**
- * gst_gl_shader_release_unlocked:
- * @shader: a #GstGLShader
- *
- * Releases the shader and stages.
- *
- * Note: must be called in the GL thread
- *
- * Since: 1.8
- */
-void
-gst_gl_shader_release_unlocked (GstGLShader * shader)
-{
- GstGLShaderPrivate *priv;
- GList *elem;
-
- g_return_if_fail (GST_IS_GL_SHADER (shader));
-
- priv = shader->priv;
-
- for (elem = shader->priv->stages; elem;) {
- GstGLSLStage *stage = elem->data;
- GList *next = elem->next;
-
- gst_gl_shader_detach_unlocked (shader, stage);
- elem = next;
- }
-
- g_list_free_full (shader->priv->stages, (GDestroyNotify) gst_object_unref);
- shader->priv->stages = NULL;
-
- priv->linked = FALSE;
- g_hash_table_remove_all (priv->uniform_locations);
-
- g_object_notify (G_OBJECT (shader), "linked");
-}
-
-/**
- * gst_gl_shader_release:
- * @shader: a #GstGLShader
- *
- * Releases the shader and stages.
- *
- * Note: must be called in the GL thread
- *
- * Since: 1.8
- */
-void
-gst_gl_shader_release (GstGLShader * shader)
-{
- g_return_if_fail (GST_IS_GL_SHADER (shader));
-
- GST_OBJECT_LOCK (shader);
- gst_gl_shader_release_unlocked (shader);
- GST_OBJECT_UNLOCK (shader);
-}
-
-/**
- * gst_gl_shader_use:
- * @shader: a #GstGLShader
- *
- * Mark's @shader as being used for the next GL draw command.
- *
- * Note: must be called in the GL thread and @shader must have been linked.
- */
-void
-gst_gl_shader_use (GstGLShader * shader)
-{
- GstGLShaderPrivate *priv;
-
- g_return_if_fail (GST_IS_GL_SHADER (shader));
-
- priv = shader->priv;
-
- g_return_if_fail (priv->program_handle);
-
- priv->vtable.UseProgram (priv->program_handle);
-
- return;
-}
-
-/**
- * gst_gl_context_clear_shader:
- * @context: a #GstGLContext
- *
- * Clear's the currently set shader from the GL state machine.
- *
- * Note: must be called in the GL thread.
- */
-void
-gst_gl_context_clear_shader (GstGLContext * context)
-{
- GstGLFuncs *gl;
-
- g_return_if_fail (GST_IS_GL_CONTEXT (context));
-
- gl = context->gl_vtable;
-
- if (gl->CreateProgram)
- gl->UseProgram (0);
- else if (gl->CreateProgramObject)
- gl->UseProgramObject (0);
-}
-
-/**
- * gst_gl_shader_set_uniform_1f:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @value: value to set
- *
- * Perform glUniform1f() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_1f (GstGLShader * shader, const gchar * name,
- gfloat value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
-
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform1f (location, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_1fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of values to set
- * @value: (array length=count): values to set
- *
- * Perform glUniform1fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_1fv (GstGLShader * shader, const gchar * name,
- guint count, gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform1fv (location, count, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_1i:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @value: value to set
- *
- * Perform glUniform1i() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_1i (GstGLShader * shader, const gchar * name,
- gint value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform1i (location, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_1iv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of values to set
- * @value: (array length=count): values to set
- *
- * Perform glUniform1iv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_1iv (GstGLShader * shader, const gchar * name,
- guint count, gint * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform1iv (location, count, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_2f:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @value: value to set
- *
- * Perform glUniform2f() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_2f (GstGLShader * shader, const gchar * name,
- gfloat value0, gfloat value1)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform2f (location, value0, value1);
-}
-
-/**
- * gst_gl_shader_set_uniform_2fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of values to set
- * @value: (array length=count): values to set
- *
- * Perform glUniform2fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_2fv (GstGLShader * shader, const gchar * name,
- guint count, gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform2fv (location, count, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_2i:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @value: value to set
- *
- * Perform glUniform2i() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_2i (GstGLShader * shader, const gchar * name,
- gint v0, gint v1)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform2i (location, v0, v1);
-}
-
-/**
- * gst_gl_shader_set_uniform_2iv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of values to set
- * @value: (array length=count): values to set
- *
- * Perform glUniform2iv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_2iv (GstGLShader * shader, const gchar * name,
- guint count, gint * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform2iv (location, count, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_3f:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @value: value to set
- *
- * Perform glUniform3f() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_3f (GstGLShader * shader, const gchar * name,
- gfloat v0, gfloat v1, gfloat v2)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform3f (location, v0, v1, v2);
-}
-
-/**
- * gst_gl_shader_set_uniform_3fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of values to set
- * @value: (array length=count): values to set
- *
- * Perform glUniform3fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_3fv (GstGLShader * shader, const gchar * name,
- guint count, gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform3fv (location, count, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_3i:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @value: value to set
- *
- * Perform glUniform3i() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_3i (GstGLShader * shader, const gchar * name,
- gint v0, gint v1, gint v2)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform3i (location, v0, v1, v2);
-}
-
-/**
- * gst_gl_shader_set_uniform_3iv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of values to set
- * @value: (array length=count): values to set
- *
- * Perform glUniform3iv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_3iv (GstGLShader * shader, const gchar * name,
- guint count, gint * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform3iv (location, count, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_4f:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @value: value to set
- *
- * Perform glUniform4f() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_4f (GstGLShader * shader, const gchar * name,
- gfloat v0, gfloat v1, gfloat v2, gfloat v3)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform4f (location, v0, v1, v2, v3);
-}
-
-/**
- * gst_gl_shader_set_uniform_4fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of values to set
- * @value: (array length=count): values to set
- *
- * Perform glUniform4fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_4fv (GstGLShader * shader, const gchar * name,
- guint count, gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform4fv (location, count, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_4i:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @value: value to set
- *
- * Perform glUniform4i() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_4i (GstGLShader * shader, const gchar * name,
- gint v0, gint v1, gint v2, gint v3)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform4i (location, v0, v1, v2, v3);
-}
-
-/**
- * gst_gl_shader_set_uniform_4iv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of values to set
- * @value: (array length=count): values to set
- *
- * Perform glUniform4iv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_4iv (GstGLShader * shader, const gchar * name,
- guint count, gint * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->Uniform4iv (location, count, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_matrix_2fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of 2x2 matrices to set
- * @transpose: transpose the matrix
- * @value: values to set
- *
- * Perform glUniformMatrix2fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_matrix_2fv (GstGLShader * shader, const gchar * name,
- gint count, gboolean transpose, const gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->UniformMatrix2fv (location, count, transpose, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_matrix_3fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of 3x3 matrices to set
- * @transpose: transpose the matrix
- * @value: values to set
- *
- * Perform glUniformMatrix3fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_matrix_3fv (GstGLShader * shader, const gchar * name,
- gint count, gboolean transpose, const gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->UniformMatrix3fv (location, count, transpose, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_matrix_4fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of 4x4 matrices to set
- * @transpose: transpose the matrix
- * @value: values to set
- *
- * Perform glUniformMatrix4fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_matrix_4fv (GstGLShader * shader, const gchar * name,
- gint count, gboolean transpose, const gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->UniformMatrix4fv (location, count, transpose, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_matrix_2x3fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of 2x3 matrices to set
- * @transpose: transpose the matrix
- * @value: values to set
- *
- * Perform glUniformMatrix2x3fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_matrix_2x3fv (GstGLShader * shader,
- const gchar * name, gint count, gboolean transpose, const gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->UniformMatrix2x3fv (location, count, transpose, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_matrix_2x4fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of 2x4 matrices to set
- * @transpose: transpose the matrix
- * @value: values to set
- *
- * Perform glUniformMatrix2x4fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_matrix_2x4fv (GstGLShader * shader,
- const gchar * name, gint count, gboolean transpose, const gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->UniformMatrix2x4fv (location, count, transpose, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_matrix_3x2fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of 3x2 matrices to set
- * @transpose: transpose the matrix
- * @value: values to set
- *
- * Perform glUniformMatrix3x2fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_matrix_3x2fv (GstGLShader * shader,
- const gchar * name, gint count, gboolean transpose, const gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->UniformMatrix3x2fv (location, count, transpose, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_matrix_3x4fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of 3x4 matrices to set
- * @transpose: transpose the matrix
- * @value: values to set
- *
- * Perform glUniformMatrix3x4fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_matrix_3x4fv (GstGLShader * shader,
- const gchar * name, gint count, gboolean transpose, const gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->UniformMatrix3x4fv (location, count, transpose, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_matrix_4x2fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of 4x2 matrices to set
- * @transpose: transpose the matrix
- * @value: values to set
- *
- * Perform glUniformMatrix4x2fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_matrix_4x2fv (GstGLShader * shader,
- const gchar * name, gint count, gboolean transpose, const gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->UniformMatrix4x2fv (location, count, transpose, value);
-}
-
-/**
- * gst_gl_shader_set_uniform_matrix_4x3fv:
- * @shader: a #GstGLShader
- * @name: name of the uniform
- * @count: number of 4x3 matrices to set
- * @transpose: transpose the matrix
- * @value: values to set
- *
- * Perform glUniformMatrix4x3fv() for @name on @shader
- */
-void
-gst_gl_shader_set_uniform_matrix_4x3fv (GstGLShader * shader,
- const gchar * name, gint count, gboolean transpose, const gfloat * value)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- GLint location = -1;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- location = _get_uniform_location (shader, name);
-
- gl->UniformMatrix4x3fv (location, count, transpose, value);
-}
-
-/**
- * gst_gl_shader_get_attribute_location:
- * @shader: a #GstGLShader
- * @name: name of the attribute
- *
- * Returns: the attribute index for @name in @shader or -1 on failure
- */
-GLint
-gst_gl_shader_get_attribute_location (GstGLShader * shader, const gchar * name)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
- gint ret;
-
- g_return_val_if_fail (shader != NULL, -1);
- priv = shader->priv;
- g_return_val_if_fail (priv->program_handle != 0, -1);
-
- gl = shader->context->gl_vtable;
-
- ret = gl->GetAttribLocation (priv->program_handle, name);
-
- GST_TRACE_OBJECT (shader, "retreived program %i attribute \'%s\' location %i",
- (int) priv->program_handle, name, ret);
-
- return ret;
-}
-
-/**
- * gst_gl_shader_bind_attribute_location:
- * @shader: a #GstGLShader
- * @index: attribute index to set
- * @name: name of the attribute
- *
- * Bind attribute @name to the specified location @index using
- * glBindAttributeLocation().
- */
-void
-gst_gl_shader_bind_attribute_location (GstGLShader * shader, GLuint index,
- const gchar * name)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
-
- g_return_if_fail (shader != NULL);
- priv = shader->priv;
- g_return_if_fail (priv->program_handle != 0);
- gl = shader->context->gl_vtable;
-
- GST_TRACE_OBJECT (shader, "binding program %i attribute \'%s\' location %i",
- (int) priv->program_handle, name, index);
-
- gl->BindAttribLocation (priv->program_handle, index, name);
-}
-
-/**
- * gst_gl_shader_bind_frag_data_location:
- * @shader: a #GstGLShader
- * @index: attribute index to set
- * @name: name of the attribute
- *
- * Bind attribute @name to the specified location @index using
- * glBindFragDataLocation().
- */
-void
-gst_gl_shader_bind_frag_data_location (GstGLShader * shader,
- guint index, const gchar * name)
-{
- GstGLShaderPrivate *priv;
- GstGLFuncs *gl;
-
- g_return_if_fail (shader != NULL);
- if (!_ensure_program (shader))
- g_return_if_fail (shader->priv->program_handle);
- priv = shader->priv;
- gl = shader->context->gl_vtable;
- g_return_if_fail (gl->BindFragDataLocation);
-
- GST_TRACE_OBJECT (shader, "binding program %i frag data \'%s\' location %i",
- (int) priv->program_handle, name, index);
-
- gl->BindFragDataLocation (priv->program_handle, index, name);
-}
diff --git a/gst-libs/gst/gl/gstglshader.h b/gst-libs/gst/gl/gstglshader.h
deleted file mode 100644
index 0e4912373..000000000
--- a/gst-libs/gst/gl/gstglshader.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
- * Copyright (C) 2014 Julien Isorce <julien.isorce@collabora.co.uk>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_SHADER_H__
-#define __GST_GL_SHADER_H__
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GType gst_gl_shader_get_type (void);
-#define GST_TYPE_GL_SHADER (gst_gl_shader_get_type())
-
-/* FIXME: remove this when moving to -base */
-#ifndef GST_DISABLE_DEPRECATED
-#define GST_GL_TYPE_SHADER GST_TYPE_GL_SHADER
-#endif
-#define GST_GL_SHADER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_SHADER, GstGLShader))
-#define GST_GL_SHADER_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_SHADER, GstGLShaderClass))
-#define GST_IS_GL_SHADER(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_SHADER))
-#define GST_IS_GL_SHADER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_SHADER))
-#define GST_GL_SHADER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_SHADER, GstGLShaderClass))
-
-struct _GstGLShader
-{
- GstObject parent;
-
- GstGLContext *context;
-
- /*< private >*/
- GstGLShaderPrivate *priv;
-
- gpointer _padding[GST_PADDING];
-};
-
-struct _GstGLShaderClass {
- /*< private >*/
- GstObjectClass parent_class;
-};
-
-GST_EXPORT
-GstGLShader * gst_gl_shader_new (GstGLContext *context);
-GST_EXPORT
-GstGLShader * gst_gl_shader_new_with_stages (GstGLContext * context, GError ** error, ...);
-GST_EXPORT
-GstGLShader * gst_gl_shader_new_link_with_stages (GstGLContext * context, GError ** error, ...);
-GST_EXPORT
-GstGLShader * gst_gl_shader_new_default (GstGLContext * context, GError ** error);
-
-GST_EXPORT
-gboolean gst_gl_shader_attach (GstGLShader * shader, GstGLSLStage * stage);
-GST_EXPORT
-gboolean gst_gl_shader_attach_unlocked (GstGLShader * shader, GstGLSLStage * stage);
-
-GST_EXPORT
-void gst_gl_shader_detach (GstGLShader * shader, GstGLSLStage * stage);
-GST_EXPORT
-void gst_gl_shader_detach_unlocked (GstGLShader * shader, GstGLSLStage * stage);
-
-GST_EXPORT
-gboolean gst_gl_shader_compile_attach_stage (GstGLShader * shader,
- GstGLSLStage *stage,
- GError ** error);
-GST_EXPORT
-gboolean gst_gl_shader_link (GstGLShader * shader, GError ** error);
-GST_EXPORT
-gboolean gst_gl_shader_is_linked (GstGLShader *shader);
-
-GST_EXPORT
-int gst_gl_shader_get_program_handle (GstGLShader * shader);
-
-GST_EXPORT
-void gst_gl_shader_release (GstGLShader *shader);
-GST_EXPORT
-void gst_gl_shader_release_unlocked (GstGLShader * shader);
-GST_EXPORT
-void gst_gl_shader_use (GstGLShader *shader);
-GST_EXPORT
-void gst_gl_context_clear_shader (GstGLContext *context);
-
-GST_EXPORT
-void gst_gl_shader_set_uniform_1i (GstGLShader *shader, const gchar *name, gint value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_1iv (GstGLShader *shader, const gchar *name, guint count, gint *value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_1f (GstGLShader *shader, const gchar *name, gfloat value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_1fv (GstGLShader *shader, const gchar *name, guint count, gfloat *value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_2i (GstGLShader *shader, const gchar *name, gint v0, gint v1);
-GST_EXPORT
-void gst_gl_shader_set_uniform_2iv (GstGLShader *shader, const gchar *name, guint count, gint *value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_2f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1);
-GST_EXPORT
-void gst_gl_shader_set_uniform_2fv (GstGLShader *shader, const gchar *name, guint count, gfloat *value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_3i (GstGLShader *shader, const gchar *name, gint v0, gint v1, gint v2);
-GST_EXPORT
-void gst_gl_shader_set_uniform_3iv (GstGLShader *shader, const gchar *name, guint count, gint * value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_3f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1, gfloat v2);
-GST_EXPORT
-void gst_gl_shader_set_uniform_3fv (GstGLShader *shader, const gchar *name, guint count, gfloat *value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_4i (GstGLShader *shader, const gchar *name, gint v0, gint v1, gint v2, gint v3);
-GST_EXPORT
-void gst_gl_shader_set_uniform_4iv (GstGLShader *shader, const gchar *name, guint count, gint *value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_4f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1, gfloat v2, gfloat v3);
-GST_EXPORT
-void gst_gl_shader_set_uniform_4fv (GstGLShader *shader, const gchar *name, guint count, gfloat *value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_matrix_2fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_matrix_3fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_matrix_4fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_matrix_2x3fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_matrix_2x4fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_matrix_3x2fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_matrix_3x4fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_matrix_4x2fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
-GST_EXPORT
-void gst_gl_shader_set_uniform_matrix_4x3fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
-
-GST_EXPORT
-gint gst_gl_shader_get_attribute_location (GstGLShader *shader, const gchar *name);
-GST_EXPORT
-void gst_gl_shader_bind_attribute_location (GstGLShader * shader, guint index, const gchar * name);
-GST_EXPORT
-void gst_gl_shader_bind_frag_data_location (GstGLShader * shader, guint index, const gchar * name);
-
-G_END_DECLS
-
-#endif /* __GST_GL_SHADER_H__ */
diff --git a/gst-libs/gst/gl/gstglshaderstrings.c b/gst-libs/gst/gl/gstglshaderstrings.c
deleted file mode 100644
index e6bf5f33c..000000000
--- a/gst-libs/gst/gl/gstglshaderstrings.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstglshaderstrings.h"
-
-/* *INDENT-OFF* */
-const gchar *gst_gl_shader_string_vertex_default =
- "attribute vec4 a_position;\n"
- "attribute vec2 a_texcoord;\n"
- "varying vec2 v_texcoord;\n"
- "void main()\n"
- "{\n"
- " gl_Position = a_position;\n"
- " v_texcoord = a_texcoord;\n"
- "}\n";
-
-const gchar *gst_gl_shader_string_vertex_mat4_texture_transform =
- "uniform mat4 u_transformation;\n"
- "attribute vec4 a_position;\n"
- "attribute vec2 a_texcoord;\n"
- "varying vec2 v_texcoord;\n"
- "void main()\n"
- "{\n"
- " gl_Position = a_position;\n"
- " v_texcoord = (u_transformation * vec4(a_texcoord, 0, 1)).xy;\n"
- "}\n";
-
-const gchar *gst_gl_shader_string_vertex_mat4_vertex_transform =
- "uniform mat4 u_transformation;\n"
- "attribute vec4 a_position;\n"
- "attribute vec2 a_texcoord;\n"
- "varying vec2 v_texcoord;\n"
- "void main()\n"
- "{\n"
- " gl_Position = u_transformation * a_position;\n"
- " v_texcoord = a_texcoord;\n"
- "}\n";
-
-const gchar *gst_gl_shader_string_fragment_default =
- "#ifdef GL_ES\n"
- "precision mediump float;\n"
- "#endif\n"
- "varying vec2 v_texcoord;\n"
- "uniform sampler2D tex;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = texture2D(tex, v_texcoord);\n"
- "}";
-
-const gchar *gst_gl_shader_string_fragment_external_oes_default =
- "#extension GL_OES_EGL_image_external : require\n"
- "#ifdef GL_ES\n"
- "precision mediump float;\n"
- "#endif\n"
- "varying vec2 v_texcoord;\n"
- "uniform samplerExternalOES tex;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = texture2D(tex, v_texcoord);\n"
- "}";
-/* *INDENT-ON* */
diff --git a/gst-libs/gst/gl/gstglshaderstrings.h b/gst-libs/gst/gl/gstglshaderstrings.h
deleted file mode 100644
index 48ea20085..000000000
--- a/gst-libs/gst/gl/gstglshaderstrings.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_SHADER_STRINGS_H__
-#define __GST_GL_SHADER_STRINGS_H__
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-const gchar *gst_gl_shader_string_vertex_default;
-GST_EXPORT
-const gchar *gst_gl_shader_string_fragment_default;
-
-GST_EXPORT
-const gchar *gst_gl_shader_string_vertex_mat4_texture_transform;
-GST_EXPORT
-const gchar *gst_gl_shader_string_vertex_mat4_vertex_transform;
-GST_EXPORT
-const gchar *gst_gl_shader_string_fragment_external_oes_default;
-
-G_END_DECLS
-
-#endif /* __GST_GL_SHADER_STRINGS_H__ */
diff --git a/gst-libs/gst/gl/gstglsl.c b/gst-libs/gst/gl/gstglsl.c
deleted file mode 100644
index 81226260f..000000000
--- a/gst-libs/gst/gl/gstglsl.c
+++ /dev/null
@@ -1,931 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gl/gl.h>
-
-#include "gstglsl.h"
-#include "gstglsl_private.h"
-
-/**
- * SECTION:gstglsl
- * @title: GstGLSL
- * @short_description: helpers for dealing with OpenGL shaders
- * @see_also: #GstGLSLStage, #GstGLShader
- */
-
-#define GST_CAT_DEFAULT gst_glsl_debug
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-
-static void
-_init_debug (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "glsl", 0,
- "OpenGL Shading Language");
- g_once_init_leave (&_init, 1);
- }
-}
-
-GQuark
-gst_glsl_error_quark (void)
-{
- return g_quark_from_static_string ("gst-glsl-error");
-}
-
-struct glsl_version_string
-{
- GstGLSLVersion version;
- const gchar *name;
-};
-
-static const struct glsl_version_string glsl_versions[] = {
- /* keep in sync with definition in the header */
- {GST_GLSL_VERSION_100, "100"},
- {GST_GLSL_VERSION_110, "110"},
- {GST_GLSL_VERSION_120, "120"},
- {GST_GLSL_VERSION_130, "130"},
- {GST_GLSL_VERSION_140, "140"},
- {GST_GLSL_VERSION_150, "150"},
- {GST_GLSL_VERSION_300, "300"},
- {GST_GLSL_VERSION_310, "310"},
- {GST_GLSL_VERSION_320, "320"},
- {GST_GLSL_VERSION_330, "330"},
- {GST_GLSL_VERSION_400, "400"},
- {GST_GLSL_VERSION_410, "410"},
- {GST_GLSL_VERSION_420, "420"},
- {GST_GLSL_VERSION_430, "430"},
- {GST_GLSL_VERSION_440, "440"},
- {GST_GLSL_VERSION_450, "450"},
-};
-
-struct glsl_profile_string
-{
- GstGLSLProfile profile;
- const gchar *name;
-};
-
-static const struct glsl_profile_string glsl_profiles[] = {
- /* keep in sync with definition in the header */
- {GST_GLSL_PROFILE_ES, "es"},
- {GST_GLSL_PROFILE_CORE, "core"},
- {GST_GLSL_PROFILE_COMPATIBILITY, "compatibility"},
-};
-
-/**
- * gst_glsl_version_to_string:
- * @version: a #GstGLSLVersion
- *
- * Returns: (nullable): the name of @version or %NULL on error
- */
-const gchar *
-gst_glsl_version_to_string (GstGLSLVersion version)
-{
- int i;
-
- if (version == GST_GLSL_VERSION_NONE)
- return NULL;
-
- for (i = 0; i < G_N_ELEMENTS (glsl_versions); i++) {
- if (version == glsl_versions[i].version)
- return glsl_versions[i].name;
- }
-
- return NULL;
-}
-
-/**
- * gst_glsl_version_from_string:
- * @string: a GLSL version string
- *
- * Returns: the #GstGLSLVersion of @string or %GST_GLSL_VERSION_NONE on error
- */
-GstGLSLVersion
-gst_glsl_version_from_string (const gchar * string)
-{
- gchar *str;
- int i;
-
- if (string == NULL)
- return 0;
-
- str = g_strdup (string);
- str = g_strstrip (str);
-
- for (i = 0; i < G_N_ELEMENTS (glsl_versions); i++) {
- if (g_strcmp0 (str, glsl_versions[i].name) == 0) {
- g_free (str);
- return glsl_versions[i].version;
- }
- }
-
- g_free (str);
- return 0;
-}
-
-/**
- * gst_glsl_profile_to_string:
- * @profile: a #GstGLSLProfile
- *
- * Returns: (nullable): the name for @profile or %NULL on error
- */
-const gchar *
-gst_glsl_profile_to_string (GstGLSLProfile profile)
-{
- int i;
-
- if (profile == GST_GLSL_PROFILE_NONE)
- return NULL;
-
- /* multiple profiles are not allowed */
- if ((profile & (profile - 1)) != 0)
- return NULL;
-
- for (i = 0; i < G_N_ELEMENTS (glsl_profiles); i++) {
- if (profile == glsl_profiles[i].profile)
- return glsl_profiles[i].name;
- }
-
- return NULL;
-}
-
-/**
- * gst_glsl_profile_from_string:
- * @string: a GLSL version string
- *
- * Returns: the #GstGLSLProfile of @string or %GST_GLSL_PROFILE_NONE on error
- */
-GstGLSLProfile
-gst_glsl_profile_from_string (const gchar * string)
-{
- gchar *str;
- int i;
-
- if (string == NULL)
- return GST_GLSL_PROFILE_NONE;
-
- str = g_strdup (string);
- str = g_strstrip (str);
-
- for (i = 0; i < G_N_ELEMENTS (glsl_profiles); i++) {
- if (g_strcmp0 (str, glsl_profiles[i].name) == 0) {
- g_free (str);
- return glsl_profiles[i].profile;
- }
- }
-
- g_free (str);
- return GST_GLSL_PROFILE_NONE;
-}
-
-static gboolean
-_is_valid_version_profile (GstGLSLVersion version, GstGLSLProfile profile)
-{
- if (version == GST_GLSL_VERSION_NONE)
- return TRUE;
-
- /* versions that may not need an explicit profile */
- if (version <= GST_GLSL_VERSION_150 && profile == GST_GLSL_PROFILE_NONE)
- return TRUE;
-
- /* ES versions require an ES profile */
- if (version == GST_GLSL_VERSION_100 || version == GST_GLSL_VERSION_300
- || version == GST_GLSL_VERSION_310 || version == GST_GLSL_VERSION_320)
- return profile == GST_GLSL_PROFILE_ES;
-
- /* required profile and no ES profile for normal GL contexts */
- if (version == GST_GLSL_VERSION_150 || version >= GST_GLSL_VERSION_330)
- return profile == GST_GLSL_PROFILE_NONE || profile == GST_GLSL_PROFILE_CORE
- || profile == GST_GLSL_PROFILE_COMPATIBILITY;
-
- if (version <= GST_GLSL_VERSION_140)
- return profile == GST_GLSL_PROFILE_NONE
- || profile == GST_GLSL_PROFILE_COMPATIBILITY;
-
- return FALSE;
-}
-
-/**
- * gst_glsl_version_profile_to_string:
- * @version: a #GstGLSLVersion
- * @profile: a #GstGLSLVersion
- *
- * Returns: the combined GLSL #version string for @version and @profile
- */
-gchar *
-gst_glsl_version_profile_to_string (GstGLSLVersion version,
- GstGLSLProfile profile)
-{
- const gchar *version_s, *profile_s;
-
- if (!_is_valid_version_profile (version, profile))
- return NULL;
-
- version_s = gst_glsl_version_to_string (version);
- /* no profiles in GL/ES <= 150 */
- if (version <= GST_GLSL_VERSION_140)
- profile_s = NULL;
- else
- profile_s = gst_glsl_profile_to_string (profile);
-
- if (!version_s)
- return NULL;
-
- if (profile_s)
- return g_strdup_printf ("%s %s", version_s, profile_s);
-
- return g_strdup (version_s);
-}
-
-static void
-_fixup_version_profile (GstGLSLVersion * version, GstGLSLProfile * profile)
-{
- if (*version == GST_GLSL_VERSION_100 || *version == GST_GLSL_VERSION_300
- || *version == GST_GLSL_VERSION_310 || *version == GST_GLSL_VERSION_320)
- *profile = GST_GLSL_PROFILE_ES;
- else if (*version <= GST_GLSL_VERSION_140)
- *profile = GST_GLSL_PROFILE_COMPATIBILITY;
- else if (*profile == GST_GLSL_PROFILE_NONE
- && (*version >= GST_GLSL_VERSION_150 || *version >= GST_GLSL_VERSION_330))
- *profile = GST_GLSL_PROFILE_CORE;
-}
-
-/* @str points to the start of "#version", "# version" or "#\tversion", etc */
-static const gchar *
-_check_valid_version_preprocessor_string (const gchar * str)
-{
- gint i = 0;
-
- if (!str || !str[i])
- return NULL;
-
- /* there can be whitespace between the '#' and 'version' */
- do {
- i++;
- if (str[i] == '\0' || str[i] == '\n' || str[i] == '\r')
- return NULL;
- } while (g_ascii_isspace (str[i]));
- if (g_strstr_len (&str[i], 7, "version"))
- return &str[i + 7];
-
- return NULL;
-}
-
-/**
- * gst_glsl_version_profile_from_string:
- * @string: a valid GLSL #version string
- * @version_ret: (out): resulting #GstGLSLVersion
- * @profile_ret: (out): resulting #GstGLSLVersion
- *
- * Note: this function expects either a #version GLSL preprocesser directive
- * or a valid GLSL version and/or profile.
- *
- * Returns: TRUE if a valid #version string was found, FALSE otherwise
- */
-gboolean
-gst_glsl_version_profile_from_string (const gchar * string,
- GstGLSLVersion * version_ret, GstGLSLProfile * profile_ret)
-{
- gchar *str, *version_s, *profile_s;
- GstGLSLVersion version = GST_GLSL_VERSION_NONE;
- GstGLSLProfile profile = GST_GLSL_PROFILE_NONE;
- gint i;
-
- _init_debug ();
-
- if (!string)
- goto error;
-
- str = g_strdup (string);
- version_s = g_strstrip (str);
-
- /* skip possible #version prefix */
- if (str[0] == '#') {
- if (!(version_s =
- (gchar *) _check_valid_version_preprocessor_string (version_s))) {
- GST_WARNING ("Invalid preprocesser directive detected: %s", version_s);
- g_free (str);
- goto error;
- }
- }
-
- version_s = g_strstrip (version_s);
-
- i = 0;
- while (version_s && version_s[i] != '\0' && g_ascii_isdigit (version_s[i]))
- i++;
- /* wrong version length */
- if (i != 3) {
- GST_WARNING ("version number has the wrong number of digits: %s",
- version_s);
- g_free (str);
- goto error;
- }
-
- if (version_s[i] != 0) {
- version_s[i] = '\0';
- i++;
- profile_s = &version_s[i];
- profile_s = g_strstrip (profile_s);
-
- profile = gst_glsl_profile_from_string (profile_s);
- }
- version = gst_glsl_version_from_string (version_s);
- g_free (str);
-
- /* check whether the parsed data is valid */
- if (!version) {
- GST_WARNING ("Could not map the version number to a valid GLSL version:");
- goto error;
- }
- if (!_is_valid_version_profile (version, profile)) {
- GST_WARNING ("Invalid version/profile combination specified: %s %s",
- gst_glsl_version_to_string (version),
- gst_glsl_profile_to_string (profile));
- goto error;
- }
- /* got a profile when none was expected */
- if (version <= GST_GLSL_VERSION_140 && profile != GST_GLSL_PROFILE_NONE) {
- GST_WARNING
- ("Found a profile (%s) with a version (%s) that does not support "
- "profiles", gst_glsl_version_to_string (version),
- gst_glsl_profile_to_string (profile));
- goto error;
- }
-
- _fixup_version_profile (&version, &profile);
-
- if (profile_ret)
- *profile_ret = profile;
- if (version_ret)
- *version_ret = version;
-
- return TRUE;
-
-error:
- {
- if (profile_ret)
- *profile_ret = GST_GLSL_PROFILE_NONE;
- if (version_ret)
- *version_ret = GST_GLSL_VERSION_NONE;
- return FALSE;
- }
-}
-
-/* returns the pointer in @str to the #version declaration */
-const gchar *
-_gst_glsl_shader_string_find_version (const gchar * str)
-{
- gboolean sl_comment = FALSE;
- gboolean ml_comment = FALSE;
- gboolean newline = TRUE;
- gint i = 0;
-
- _init_debug ();
-
- /* search for #version while allowing for preceeding comments/whitespace as
- * permitted by the GLSL specification */
- while (str && str[i] != '\0' && i < 1024) {
- if (str[i] == '\n' || str[i] == '\r') {
- newline = TRUE;
- sl_comment = FALSE;
- i++;
- continue;
- }
-
- if (g_ascii_isspace (str[i]))
- goto next;
-
- if (sl_comment)
- goto next;
-
- if (ml_comment) {
- if (g_strstr_len (&str[i], 2, "*/")) {
- ml_comment = FALSE;
- i++;
- }
- goto next;
- }
-
- if (g_strstr_len (&str[i], 2, "//")) {
- sl_comment = TRUE;
- i++;
- goto next;
- }
-
- if (g_strstr_len (&str[i], 2, "/*")) {
- ml_comment = TRUE;
- i++;
- goto next;
- }
-
- if (str[i] == '#') {
- if (newline && _check_valid_version_preprocessor_string (&str[i])) {
- GST_DEBUG ("found #version declaration at index %i", i);
- return &str[i];
- }
- break;
- }
-
- next:
- newline = FALSE;
- i++;
- }
-
- GST_DEBUG ("no #version declaration found in the first 1K");
-
- return NULL;
-}
-
-/**
- * gst_glsl_string_get_version_profile:
- * @s: string to search for a valid #version string
- * @version: (out): resulting #GstGLSLVersion
- * @profile: (out): resulting #GstGLSLProfile
- *
- * Note: this function first searches the first 1 kilobytes for a #version
- * preprocessor directive and then executes gst_glsl_version_profile_from_string().
- *
- * Returns: TRUE if a valid #version string was found, FALSE otherwise
- */
-gboolean
-gst_glsl_string_get_version_profile (const gchar * s, GstGLSLVersion * version,
- GstGLSLProfile * profile)
-{
- const gchar *version_profile_s;
-
- version_profile_s = _gst_glsl_shader_string_find_version (s);
- if (!version_profile_s)
- goto error;
-
- if (!gst_glsl_version_profile_from_string (version_profile_s, version,
- profile))
- goto error;
-
- return TRUE;
-
-error:
- {
- if (version)
- *version = GST_GLSL_VERSION_NONE;
- if (profile)
- *profile = GST_GLSL_PROFILE_NONE;
- return FALSE;
- }
-}
-
-/**
- * gst_gl_version_to_glsl_version:
- * @gl_api: the #GstGLAPI
- * @maj: the major GL version
- * @min: the minor GL version
- *
- * Returns: The minimum supported #GstGLSLVersion available for @gl_api, @maj and @min
- */
-GstGLSLVersion
-gst_gl_version_to_glsl_version (GstGLAPI gl_api, gint maj, gint min)
-{
- g_return_val_if_fail (gl_api != GST_GL_API_NONE, 0);
-
- _init_debug ();
-
- if (gl_api & GST_GL_API_GLES2) {
- if (maj == 2 && min == 0)
- return 100;
-
- if (maj == 3 && min >= 0 && min <= 2)
- return maj * 100 + min * 10;
-
- GST_WARNING ("unknown GLES version");
- return 0;
- }
-
- /* versions match for >= 3.3 */
- if (gl_api & (GST_GL_API_OPENGL3 | GST_GL_API_OPENGL)) {
- if (maj > 3 || (maj == 3 && min >= 3))
- return maj * 100 + min * 10;
-
- if (maj == 3 && min == 2)
- return 150;
- if (maj == 3 && min == 1)
- return 140;
- if (maj == 3 && min == 0)
- return 130;
- if (maj == 2 && min == 1)
- return 120;
- if (maj == 2 && min == 0)
- return 110;
-
- GST_WARNING ("unknown GL version");
- return 0;
- }
-
- GST_WARNING ("unknown GL API");
- return 0;
-}
-
-/**
- * gst_gl_context_supports_glsl_profile_version:
- * @context: a #GstGLContext
- * @version: a #GstGLSLVersion
- * @profile: a #GstGLSLProfile
- *
- * Returns: Whether @context supports the combination of @version with @profile
- */
-gboolean
-gst_gl_context_supports_glsl_profile_version (GstGLContext * context,
- GstGLSLVersion version, GstGLSLProfile profile)
-{
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
-
- if (!_is_valid_version_profile (version, profile))
- return FALSE;
-
- if (profile != GST_GLSL_PROFILE_NONE) {
- if (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0)) {
- if ((profile & GST_GLSL_PROFILE_ES) == 0)
- return FALSE;
- } else if ((gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL) != 0) {
- if ((profile & GST_GLSL_PROFILE_COMPATIBILITY) == 0)
- return FALSE;
- } else if ((gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL3) != 0) {
- /* GL_ARB_es2_compatibility is requried for GL3 contexts */
- if ((profile & (GST_GLSL_PROFILE_CORE | GST_GLSL_PROFILE_ES)) == 0)
- return FALSE;
- } else {
- g_assert_not_reached ();
- }
- }
-
- if (version != GST_GLSL_VERSION_NONE) {
- GstGLAPI gl_api;
- gint maj, min, glsl_version;
-
- if (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 1)) {
- if (version > GST_GLSL_VERSION_310)
- return FALSE;
- } else if (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3,
- 0)) {
- if (version > GST_GLSL_VERSION_300)
- return FALSE;
- } else if (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2,
- 0)) {
- if (version > GST_GLSL_VERSION_100)
- return FALSE;
- }
-
- gl_api = gst_gl_context_get_gl_api (context);
- gst_gl_context_get_gl_version (context, &maj, &min);
- glsl_version = gst_gl_version_to_glsl_version (gl_api, maj, min);
- if (version > glsl_version)
- return FALSE;
-
- if (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 1, 0))
- /* GL_ARB_es2_compatibility is requried for GL3 contexts */
- if (version < GST_GLSL_VERSION_150 && version != GST_GLSL_VERSION_100)
- return FALSE;
-
- if (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0)
- && version < GST_GLSL_VERSION_110)
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-_gst_glsl_funcs_fill (GstGLSLFuncs * vtable, GstGLContext * context)
-{
- GstGLFuncs *gl = context->gl_vtable;
-
- if (vtable->initialized)
- return TRUE;
-
- if (gl->CreateProgram) {
- vtable->CreateProgram = gl->CreateProgram;
- vtable->DeleteProgram = gl->DeleteProgram;
- vtable->UseProgram = gl->UseProgram;
-
- vtable->CreateShader = gl->CreateShader;
- vtable->DeleteShader = gl->DeleteShader;
- vtable->AttachShader = gl->AttachShader;
- vtable->DetachShader = gl->DetachShader;
-
- vtable->GetAttachedShaders = gl->GetAttachedShaders;
-
- vtable->GetShaderInfoLog = gl->GetShaderInfoLog;
- vtable->GetShaderiv = gl->GetShaderiv;
- vtable->GetProgramInfoLog = gl->GetProgramInfoLog;
- vtable->GetProgramiv = gl->GetProgramiv;
- } else if (gl->CreateProgramObject) {
- vtable->CreateProgram = gl->CreateProgramObject;
- vtable->DeleteProgram = gl->DeleteObject;
- vtable->UseProgram = gl->UseProgramObject;
-
- vtable->CreateShader = gl->CreateShaderObject;
- vtable->DeleteShader = gl->DeleteObject;
- vtable->AttachShader = gl->AttachObject;
- vtable->DetachShader = gl->DetachObject;
-
- vtable->GetAttachedShaders = gl->GetAttachedObjects;
-
- vtable->GetShaderInfoLog = gl->GetInfoLog;
- vtable->GetShaderiv = gl->GetObjectParameteriv;
- vtable->GetProgramInfoLog = gl->GetInfoLog;
- vtable->GetProgramiv = gl->GetObjectParameteriv;
- } else {
- vtable->initialized = FALSE;
- return FALSE;
- }
-
- vtable->initialized = TRUE;
- return TRUE;
-}
-
-static gchar *
-_mangle_external_image_extension (const gchar * str, GstGLContext * context,
- GstGLTextureTarget from, GstGLTextureTarget to, GstGLSLVersion version,
- GstGLSLProfile profile)
-{
- GST_DEBUG ("is oes? %d, profile == ES? %d, version >= 300? %d, "
- "have essl3? %d", to == GST_GL_TEXTURE_TARGET_EXTERNAL_OES,
- profile == GST_GLSL_PROFILE_ES, version >= GST_GLSL_VERSION_300,
- gst_gl_context_check_feature (context,
- "GL_OES_EGL_image_external_essl3"));
-
- /* replace GL_OES_EGL_image_external with GL_OES_EGL_image_external_essl3 where supported */
- if (to == GST_GL_TEXTURE_TARGET_EXTERNAL_OES && profile == GST_GLSL_PROFILE_ES
- && version >= GST_GLSL_VERSION_300) {
- if (gst_gl_context_check_feature (context,
- "GL_OES_EGL_image_external_essl3")) {
- GRegex *regex = g_regex_new (
- /* '#extension ' with optional spacing */
- "(#[ \\t]*extension[ \\t]+)"
- /* what we're looking to replace */
- "GL_OES_EGL_image_external"
- /* ':' with optional spacing */
- "([ \\t]*:[ \\t]*"
- /* some word like require, disable, etc followed by spacing and a newline */
- "\\S+[ \\t]*\\R)",
- 0, 0, NULL);
- gchar *tmp = g_regex_replace (regex, str, -1, 0,
- "\\1GL_OES_EGL_image_external_essl3\\2", 0, NULL);
- g_regex_unref (regex);
- return tmp;
- } else {
- GST_FIXME ("Undefined situation detected. GLES3 supported but "
- "GL_OES_EGL_image_external_essl3 not supported. Falling back to the "
- "older GL_OES_EGL_image_external extension");
- return g_strdup (str);
- }
- } else {
- return g_strdup (str);
- }
-}
-
-static gchar *
-_mangle_texture_access (const gchar * str, GstGLContext * context,
- GstGLTextureTarget from, GstGLTextureTarget to, GstGLSLVersion version,
- GstGLSLProfile profile)
-{
- const gchar *from_str = NULL, *to_str = NULL;
- gchar *ret, *tmp;
- gchar *regex_find;
- GRegex *regex;
-
- if (from == GST_GL_TEXTURE_TARGET_2D)
- from_str = "texture2D";
- if (from == GST_GL_TEXTURE_TARGET_RECTANGLE)
- from_str = "texture2DRect";
- if (from == GST_GL_TEXTURE_TARGET_EXTERNAL_OES)
- from_str = "texture2D";
-
- /* GL3 || gles3 but not when external-oes unless the image_external_essl3 extension is supported */
- if (profile == GST_GLSL_PROFILE_CORE || (profile == GST_GLSL_PROFILE_ES
- && version >= GST_GLSL_VERSION_300
- && (to != GST_GL_TEXTURE_TARGET_EXTERNAL_OES
- || gst_gl_context_check_feature (context,
- "GL_OES_EGL_image_external_essl3")))) {
- to_str = "texture";
- } else {
- if (to == GST_GL_TEXTURE_TARGET_2D)
- to_str = "texture2D";
- if (to == GST_GL_TEXTURE_TARGET_RECTANGLE)
- to_str = "texture2DRect";
- if (to == GST_GL_TEXTURE_TARGET_EXTERNAL_OES)
- to_str = "texture2D";
- }
-
- /* followed by any amount of whitespace then a bracket */
- regex_find = g_strdup_printf ("%s(?=\\s*\\()", from_str);
- regex = g_regex_new (regex_find, 0, 0, NULL);
- tmp = g_regex_replace_literal (regex, str, -1, 0, to_str, 0, NULL);
- g_free (regex_find);
- g_regex_unref (regex);
-
- if (tmp) {
- ret = tmp;
- } else {
- GST_FIXME ("Couldn't mangle texture access successfully from %s to %s",
- from_str, to_str);
- ret = g_strdup (str);
- }
-
- return ret;
-}
-
-static gchar *
-_mangle_sampler_type (const gchar * str, GstGLTextureTarget from,
- GstGLTextureTarget to)
-{
- const gchar *from_str = NULL, *to_str = NULL;
- gchar *ret, *tmp;
- gchar *regex_find;
- GRegex *regex;
-
- if (from == GST_GL_TEXTURE_TARGET_2D)
- from_str = "sampler2D";
- if (from == GST_GL_TEXTURE_TARGET_RECTANGLE)
- from_str = "sampler2DRect";
- if (from == GST_GL_TEXTURE_TARGET_EXTERNAL_OES)
- from_str = "samplerExternalOES";
-
- if (to == GST_GL_TEXTURE_TARGET_2D)
- to_str = "sampler2D";
- if (to == GST_GL_TEXTURE_TARGET_RECTANGLE)
- to_str = "sampler2DRect";
- if (to == GST_GL_TEXTURE_TARGET_EXTERNAL_OES)
- to_str = "samplerExternalOES";
-
- /* followed by some whitespace */
- regex_find = g_strdup_printf ("%s(?=\\s)", from_str);
- regex = g_regex_new (regex_find, 0, 0, NULL);
- tmp = g_regex_replace_literal (regex, str, -1, 0, to_str, 0, NULL);
- g_free (regex_find);
- g_regex_unref (regex);
-
- if (tmp) {
- ret = tmp;
- } else {
- GST_FIXME ("Couldn't mangle sampler type successfully from %s to %s",
- from_str, to_str);
- ret = g_strdup (str);
- }
-
- return ret;
-}
-
-static gchar *
-_mangle_varying_attribute (const gchar * str, guint shader_type,
- GstGLSLVersion version, GstGLSLProfile profile)
-{
- if (shader_type == GL_VERTEX_SHADER) {
- if (profile == GST_GLSL_PROFILE_CORE || (profile == GST_GLSL_PROFILE_ES
- && version >= GST_GLSL_VERSION_300)) {
- gchar *tmp, *tmp2;
- GRegex *regex;
-
- /* followed by some whitespace */
- regex = g_regex_new ("varying(?=\\s)", 0, 0, NULL);
- tmp = g_regex_replace_literal (regex, str, -1, 0, "out", 0, NULL);
- g_regex_unref (regex);
-
- /* followed by some whitespace */
- regex = g_regex_new ("attribute(?=\\s)", 0, 0, NULL);
- tmp2 = g_regex_replace_literal (regex, tmp, -1, 0, "in", 0, NULL);
- g_regex_unref (regex);
-
- g_free (tmp);
- return tmp2;
- }
- } else if (shader_type == GL_FRAGMENT_SHADER) {
- if (profile == GST_GLSL_PROFILE_CORE || (profile == GST_GLSL_PROFILE_ES
- && version >= GST_GLSL_VERSION_300)) {
- gchar *tmp;
- GRegex *regex;
-
- /* followed by some whitespace */
- regex = g_regex_new ("varying(?=\\s)", 0, 0, NULL);
- tmp = g_regex_replace_literal (regex, str, -1, 0, "in", 0, NULL);
- g_regex_unref (regex);
-
- return tmp;
- }
- }
- return g_strdup (str);
-}
-
-static gchar *
-_mangle_frag_color_data (const gchar * str)
-{
- GRegex *regex;
- gchar *ret, *tmp;
-
- regex = g_regex_new ("gl_FragColor", 0, 0, NULL);
- ret = g_regex_replace_literal (regex, str, -1, 0, "fragColor", 0, NULL);
- g_regex_unref (regex);
-
- tmp = ret;
- /* search and replace 'gl_FragData[NUM]' into fragColor_NUM */
- regex = g_regex_new ("gl_FragData\\[(\\d+)\\]", 0, 0, NULL);
- ret = g_regex_replace (regex, tmp, -1, 0, "fragColor_\\1", 0, NULL);
- g_regex_unref (regex);
- g_free (tmp);
-
- return ret;
-}
-
-static void
-_mangle_version_profile_from_gl_api (GstGLContext * context,
- GstGLTextureTarget from, GstGLTextureTarget to, GstGLSLVersion * version,
- GstGLSLProfile * profile)
-{
- GstGLAPI gl_api;
- gint gl_major, gl_minor;
-
- gl_api = gst_gl_context_get_gl_api (context);
- gst_gl_context_get_gl_version (context, &gl_major, &gl_minor);
-
- *version = GST_GLSL_VERSION_NONE;
- *profile = GST_GLSL_PROFILE_NONE;
-
- if (gl_api & GST_GL_API_OPENGL3) {
- if (gl_major > 3 || gl_minor >= 3) {
- *version = GST_GLSL_VERSION_330;
- *profile = GST_GLSL_PROFILE_CORE;
- } else {
- *version = GST_GLSL_VERSION_150;
- *profile = GST_GLSL_PROFILE_NONE;
- }
- } else if (gl_api & GST_GL_API_GLES2) {
- /* We don't know which texture function to use if we have GLES3 and
- * don't have the essl3 extension */
- if (gl_major >= 3 && (to != GST_GL_TEXTURE_TARGET_EXTERNAL_OES
- || gst_gl_context_check_feature (context,
- "GL_OES_EGL_image_external_essl3"))) {
- *version = GST_GLSL_VERSION_300;
- *profile = GST_GLSL_PROFILE_ES;
- } else if (gl_major >= 2) {
- *version = GST_GLSL_VERSION_100;
- *profile = GST_GLSL_PROFILE_ES;
- }
- } else if (gl_api & GST_GL_API_OPENGL) {
- *version = GST_GLSL_VERSION_110;
- *profile = GST_GLSL_PROFILE_COMPATIBILITY;
- }
-}
-
-gchar *
-_gst_glsl_mangle_shader (const gchar * str, guint shader_type,
- GstGLTextureTarget from, GstGLTextureTarget to, GstGLContext * context,
- GstGLSLVersion * version, GstGLSLProfile * profile)
-{
- gchar *tmp, *tmp2;
-
- _init_debug ();
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), NULL);
-
- _mangle_version_profile_from_gl_api (context, from, to, version, profile);
- tmp2 =
- _mangle_external_image_extension (str, context, from, to, *version,
- *profile);
- tmp = _mangle_texture_access (tmp2, context, from, to, *version, *profile);
- g_free (tmp2);
- tmp2 = _mangle_sampler_type (tmp, from, to);
- g_free (tmp);
- tmp = _mangle_varying_attribute (tmp2, shader_type, *version, *profile);
- g_free (tmp2);
- if (shader_type == GL_FRAGMENT_SHADER) {
- if ((*profile == GST_GLSL_PROFILE_ES && *version >= GST_GLSL_VERSION_300)
- || (*profile == GST_GLSL_PROFILE_CORE
- && *version >= GST_GLSL_VERSION_150)) {
- tmp2 = _mangle_frag_color_data (tmp);
- g_free (tmp);
- tmp = tmp2;
- }
- }
- return tmp;
-}
diff --git a/gst-libs/gst/gl/gstglsl.h b/gst-libs/gst/gl/gstglsl.h
deleted file mode 100644
index af837fd94..000000000
--- a/gst-libs/gst/gl/gstglsl.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GLSL_H__
-#define __GST_GLSL_H__
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GQuark gst_glsl_error_quark (void);
-
-/**
- * GST_GLSL_ERROR:
- *
- * Error domain for GStreamer's GLSL module. Errors in this domain will be
- * from the #GstGLSLError enumeration
- */
-#define GST_GLSL_ERROR (gst_glsl_error_quark ())
-
-/**
- * GstGLSLError:
- * @GST_GLSL_ERROR_COMPILE: Compilation error occured
- * @GST_GLSL_ERROR_LINK: Link error occured
- * @GST_GLSL_ERROR_PROGRAM: General program error occured
- *
- * Compilation stage that caused an error
- *
- * Since: 1.8
- */
-typedef enum {
- GST_GLSL_ERROR_COMPILE,
- GST_GLSL_ERROR_LINK,
- GST_GLSL_ERROR_PROGRAM,
-} GstGLSLError;
-
-/**
- * GstGLSLVersion:
- * @GST_GLSL_VERSION_NONE: no version
- * @GST_GLSL_VERSION_100: version 100 (only valid for ES)
- * @GST_GLSL_VERSION_110: version 110 (only valid for compatibility desktop GL)
- * @GST_GLSL_VERSION_120: version 120 (only valid for compatibility desktop GL)
- * @GST_GLSL_VERSION_130: version 130 (only valid for compatibility desktop GL)
- * @GST_GLSL_VERSION_140: version 140 (only valid for compatibility desktop GL)
- * @GST_GLSL_VERSION_150: version 150 (valid for compatibility/core desktop GL)
- * @GST_GLSL_VERSION_300: version 300 (only valid for ES)
- * @GST_GLSL_VERSION_310: version 310 (only valid for ES)
- * @GST_GLSL_VERSION_320: version 320 (only valid for ES)
- * @GST_GLSL_VERSION_330: version 330 (valid for compatibility/core desktop GL)
- * @GST_GLSL_VERSION_400: version 400 (valid for compatibility/core desktop GL)
- * @GST_GLSL_VERSION_410: version 410 (valid for compatibility/core desktop GL)
- * @GST_GLSL_VERSION_420: version 420 (valid for compatibility/core desktop GL)
- * @GST_GLSL_VERSION_430: version 430 (valid for compatibility/core desktop GL)
- * @GST_GLSL_VERSION_440: version 440 (valid for compatibility/core desktop GL)
- * @GST_GLSL_VERSION_450: version 450 (valid for compatibility/core desktop GL)
- *
- * GLSL version list
- *
- * Since: 1.8
- */
-typedef enum
-{
- GST_GLSL_VERSION_NONE = 0,
-
- GST_GLSL_VERSION_100 = 100, /* ES */
- GST_GLSL_VERSION_110 = 110, /* GL */
- GST_GLSL_VERSION_120 = 120, /* GL */
- GST_GLSL_VERSION_130 = 130, /* GL */
- GST_GLSL_VERSION_140 = 140, /* GL */
- GST_GLSL_VERSION_150 = 150, /* GL */
- GST_GLSL_VERSION_300 = 300, /* ES */
- GST_GLSL_VERSION_310 = 310, /* ES */
- GST_GLSL_VERSION_320 = 320, /* ES */
- GST_GLSL_VERSION_330 = 330, /* GL */
- GST_GLSL_VERSION_400 = 400, /* GL */
- GST_GLSL_VERSION_410 = 410, /* GL */
- GST_GLSL_VERSION_420 = 420, /* GL */
- GST_GLSL_VERSION_430 = 430, /* GL */
- GST_GLSL_VERSION_440 = 440, /* GL */
- GST_GLSL_VERSION_450 = 450, /* GL */
-} GstGLSLVersion;
-
-/**
- * GstGLSLProfile:
- * @GST_GLSL_PROFILE_NONE: no profile supported/available
- * @GST_GLSL_PROFILE_ES: OpenGL|ES profile
- * @GST_GLSL_PROFILE_CORE: OpenGL core profile
- * @GST_GLSL_PROFILE_COMPATIBILITY: OpenGL compatibility profile
- * @GST_GLSL_PROFILE_ANY: any OpenGL/OpenGL|ES profile
- *
- * GLSL profiles
- *
- * Since: 1.8
- */
-typedef enum
-{
- /* XXX: maybe make GstGLAPI instead */
- GST_GLSL_PROFILE_NONE = 0,
-
- GST_GLSL_PROFILE_ES = (1 << 0),
- GST_GLSL_PROFILE_CORE = (1 << 1),
- GST_GLSL_PROFILE_COMPATIBILITY = (1 << 2),
-
- GST_GLSL_PROFILE_ANY = -1,
-} GstGLSLProfile;
-
-GST_EXPORT
-GstGLSLVersion gst_glsl_version_from_string (const gchar * string);
-GST_EXPORT
-const gchar * gst_glsl_version_to_string (GstGLSLVersion version);
-
-GST_EXPORT
-GstGLSLProfile gst_glsl_profile_from_string (const gchar * string);
-GST_EXPORT
-const gchar * gst_glsl_profile_to_string (GstGLSLProfile profile);
-
-GST_EXPORT
-gchar * gst_glsl_version_profile_to_string (GstGLSLVersion version,
- GstGLSLProfile profile);
-GST_EXPORT
-gboolean gst_glsl_version_profile_from_string (const gchar * string,
- GstGLSLVersion * version,
- GstGLSLProfile * profile);
-
-GST_EXPORT
-gboolean gst_glsl_string_get_version_profile (const gchar *s,
- GstGLSLVersion * version,
- GstGLSLProfile * profile);
-
-GST_EXPORT
-GstGLSLVersion gst_gl_version_to_glsl_version (GstGLAPI gl_api, gint maj, gint min);
-GST_EXPORT
-gboolean gst_gl_context_supports_glsl_profile_version (GstGLContext * context,
- GstGLSLVersion version,
- GstGLSLProfile profile);
-
-G_END_DECLS
-
-#endif /* __GST_GLSL_H__ */
diff --git a/gst-libs/gst/gl/gstglsl_private.h b/gst-libs/gst/gl/gstglsl_private.h
deleted file mode 100644
index 992c41752..000000000
--- a/gst-libs/gst/gl/gstglsl_private.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GLSL_PRIVATE_H__
-#define __GST_GLSL_PRIVATE_H__
-
-#include <gst/gl/gstgl_fwd.h>
-#include <gst/gl/gstglfuncs.h>
-
-G_BEGIN_DECLS
-
-#ifndef GL_COMPILE_STATUS
-#define GL_COMPILE_STATUS 0x8B81
-#endif
-#ifndef GLhandleARB
-#define GLhandleARB GLuint
-#endif
-
-typedef struct _GstGLSLFuncs
-{
- gboolean initialized;
-
- GLuint (GSTGLAPI *CreateProgram) (void);
- void (GSTGLAPI *DeleteProgram) (GLuint program);
- void (GSTGLAPI *UseProgram) (GLuint program);
- void (GSTGLAPI *GetAttachedShaders) (GLuint program, GLsizei maxcount,
- GLsizei * count, GLuint * shaders);
-
- GLuint (GSTGLAPI *CreateShader) (GLenum shaderType);
- void (GSTGLAPI *DeleteShader) (GLuint shader);
- void (GSTGLAPI *AttachShader) (GLuint program, GLuint shader);
- void (GSTGLAPI *DetachShader) (GLuint program, GLuint shader);
-
- void (GSTGLAPI *GetShaderiv) (GLuint program, GLenum pname, GLint * params);
- void (GSTGLAPI *GetProgramiv) (GLuint program, GLenum pname, GLint * params);
- void (GSTGLAPI *GetShaderInfoLog) (GLuint shader, GLsizei maxLength,
- GLsizei * length, char *log);
- void (GSTGLAPI *GetProgramInfoLog) (GLuint shader, GLsizei maxLength,
- GLsizei * length, char *log);
-} GstGLSLFuncs;
-
-G_GNUC_INTERNAL gboolean _gst_glsl_funcs_fill (GstGLSLFuncs * vtable, GstGLContext * context);
-G_GNUC_INTERNAL const gchar * _gst_glsl_shader_string_find_version (const gchar * str);
-
-G_GNUC_INTERNAL gchar *
-_gst_glsl_mangle_shader (const gchar * str, guint shader_type, GstGLTextureTarget from,
- GstGLTextureTarget to, GstGLContext * context, GstGLSLVersion * version, GstGLSLProfile * profile);
-
-G_END_DECLS
-
-#endif /* __GST_GLSL_PRIVATE_H__ */
diff --git a/gst-libs/gst/gl/gstglslstage.c b/gst-libs/gst/gl/gstglslstage.c
deleted file mode 100644
index 0205f384f..000000000
--- a/gst-libs/gst/gl/gstglslstage.c
+++ /dev/null
@@ -1,549 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstglslstage.h"
-
-#include "gl.h"
-#include "gstglfuncs.h"
-#include "gstglsl_private.h"
-
-#ifndef GL_GEOMETRY_SHADER
-#define GL_GEOMETRY_SHADER 0x8DD9
-#endif
-#ifndef GL_COMPUTE_SHADER
-#define GL_COMPUTE_SHADER 0x91B9
-#endif
-#ifndef GL_TESS_CONTROL_SHADER
-#define GL_TESS_CONTROL_SHADER 0x8E88
-#endif
-#ifndef GL_TESS_EVALUATION_SHADER
-#define GL_TESS_EVALUATION_SHADER 0x8E87
-#endif
-
-/**
- * SECTION:gstglslstage
- * @short_description: object for dealing with OpenGL shader stages
- * @title: GstGLSLStage
- * @see_also: #GstGLShader
- *
- * #GstGLSLStage holds and represents a single OpenGL shader stage.
- */
-
-static const gchar *es2_version_header = "#version 100\n";
-
-GST_DEBUG_CATEGORY_STATIC (gst_glsl_stage_debug);
-#define GST_CAT_DEFAULT gst_glsl_stage_debug
-
-G_DEFINE_TYPE_WITH_CODE (GstGLSLStage, gst_glsl_stage, GST_TYPE_OBJECT,
- GST_DEBUG_CATEGORY_INIT (gst_glsl_stage_debug, "glslstage", 0,
- "GLSL Stage");
- );
-
-#define GST_GLSL_STAGE_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GLSL_STAGE, GstGLSLStagePrivate))
-
-struct _GstGLSLStagePrivate
-{
- GstGLSLFuncs vtable;
-
- GLenum type;
- GLhandleARB handle;
- GstGLSLVersion version;
- GstGLSLProfile profile;
- gchar **strings;
- gint n_strings;
-
- gboolean compiled;
-};
-
-static void
-gst_glsl_stage_finalize (GObject * object)
-{
- GstGLSLStage *stage = GST_GLSL_STAGE (object);
- gint i;
-
- if (stage->context) {
- gst_object_unref (stage->context);
- stage->context = NULL;
- }
-
- for (i = 0; i < stage->priv->n_strings; i++) {
- g_free (stage->priv->strings[i]);
- }
- g_free (stage->priv->strings);
- stage->priv->strings = NULL;
-
- G_OBJECT_CLASS (gst_glsl_stage_parent_class)->finalize (object);
-}
-
-static void
-gst_glsl_stage_set_property (GObject * object,
- guint prop_id, const GValue * value, GParamSpec * pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_glsl_stage_get_property (GObject * object,
- guint prop_id, GValue * value, GParamSpec * pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
-}
-
-static void
-gst_glsl_stage_class_init (GstGLSLStageClass * klass)
-{
- GObjectClass *obj_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GstGLSLStagePrivate));
-
- obj_class->finalize = gst_glsl_stage_finalize;
- obj_class->set_property = gst_glsl_stage_set_property;
- obj_class->get_property = gst_glsl_stage_get_property;
-}
-
-static void
-gst_glsl_stage_init (GstGLSLStage * stage)
-{
- stage->priv = GST_GLSL_STAGE_GET_PRIVATE (stage);
-}
-
-static gboolean
-_is_valid_shader_type (GLenum type)
-{
- switch (type) {
- case GL_VERTEX_SHADER:
- case GL_FRAGMENT_SHADER:
- case GL_TESS_CONTROL_SHADER:
- case GL_TESS_EVALUATION_SHADER:
- case GL_GEOMETRY_SHADER:
- case GL_COMPUTE_SHADER:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-static const gchar *
-_shader_type_to_string (GLenum type)
-{
- switch (type) {
- case GL_VERTEX_SHADER:
- return "vertex";
- case GL_FRAGMENT_SHADER:
- return "fragment";
- case GL_TESS_CONTROL_SHADER:
- return "tesselation control";
- case GL_TESS_EVALUATION_SHADER:
- return "tesselation evaluation";
- case GL_GEOMETRY_SHADER:
- return "geometry";
- case GL_COMPUTE_SHADER:
- return "compute";
- default:
- return "unknown";
- }
-}
-
-static gboolean
-_ensure_shader (GstGLSLStage * stage)
-{
- if (stage->priv->handle)
- return TRUE;
-
- if (!(stage->priv->handle =
- stage->priv->vtable.CreateShader (stage->priv->type)))
- return FALSE;
-
- return stage->priv->handle != 0;
-}
-
-/**
- * gst_glsl_stage_new_with_strings:
- * @context: a #GstGLContext
- * @type: the GL enum shader stage type
- * @version: the #GstGLSLVersion
- * @profile: the #GstGLSLProfile
- * @n_strings: the number of strings in @str
- * @str: an array of strings concatted together to produce a shader
- *
- * Returns: (transfer floating): a new #GstGLSLStage of the specified @type
- *
- * Since: 1.8
- */
-GstGLSLStage *
-gst_glsl_stage_new_with_strings (GstGLContext * context, guint type,
- GstGLSLVersion version, GstGLSLProfile profile, gint n_strings,
- const gchar ** str)
-{
- GstGLSLStage *stage;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), NULL);
- g_return_val_if_fail (_is_valid_shader_type (type), NULL);
-
- stage = g_object_new (GST_TYPE_GLSL_STAGE, NULL);
- /* FIXME: GInittable */
- if (!_gst_glsl_funcs_fill (&stage->priv->vtable, context)) {
- gst_object_unref (stage);
- return NULL;
- }
-
- stage->context = gst_object_ref (context);
- stage->priv->type = type;
- if (!gst_glsl_stage_set_strings (stage, version, profile, n_strings, str)) {
- gst_object_unref (stage);
- return NULL;
- }
-
- return stage;
-}
-
-/**
- * gst_glsl_stage_new_with_string:
- * @context: a #GstGLContext
- * @type: the GL enum shader stage type
- * @version: the #GstGLSLVersion
- * @profile: the #GstGLSLProfile
- * @str: a shader string
- *
- * Returns: (transfer floating): a new #GstGLSLStage of the specified @type
- *
- * Since: 1.8
- */
-GstGLSLStage *
-gst_glsl_stage_new_with_string (GstGLContext * context, guint type,
- GstGLSLVersion version, GstGLSLProfile profile, const gchar * str)
-{
- return gst_glsl_stage_new_with_strings (context, type, version, profile, 1,
- &str);
-}
-
-/**
- * gst_glsl_stage_new:
- * @context: a #GstGLContext
- * @type: the GL enum shader stage type
- *
- * Returns: (transfer floating): a new #GstGLSLStage of the specified @type
- *
- * Since: 1.8
- */
-GstGLSLStage *
-gst_glsl_stage_new (GstGLContext * context, guint type)
-{
- return gst_glsl_stage_new_with_string (context, type, GST_GLSL_VERSION_NONE,
- GST_GLSL_PROFILE_NONE, NULL);
-}
-
-/**
- * gst_glsl_stage_new_with_default_vertex:
- * @context: a #GstGLContext
- *
- * Returns: (transfer floating): a new #GstGLSLStage with the default vertex shader
- *
- * Since: 1.8
- */
-GstGLSLStage *
-gst_glsl_stage_new_default_vertex (GstGLContext * context)
-{
- return gst_glsl_stage_new_with_string (context, GL_VERTEX_SHADER,
- GST_GLSL_VERSION_NONE,
- GST_GLSL_PROFILE_ES | GST_GLSL_PROFILE_COMPATIBILITY,
- gst_gl_shader_string_vertex_default);
-}
-
-/**
- * gst_glsl_stage_new_with_default_fragment:
- * @context: a #GstGLContext
- *
- * Returns: (transfer floating): a new #GstGLSLStage with the default fragment shader
- *
- * Since: 1.8
- */
-GstGLSLStage *
-gst_glsl_stage_new_default_fragment (GstGLContext * context)
-{
- return gst_glsl_stage_new_with_string (context, GL_FRAGMENT_SHADER,
- GST_GLSL_VERSION_NONE,
- GST_GLSL_PROFILE_ES | GST_GLSL_PROFILE_COMPATIBILITY,
- gst_gl_shader_string_fragment_default);
-}
-
-/**
- * gst_glsl_stage_set_strings:
- * @stage: a #GstGLSLStage
- * @version: a #GstGLSLVersion
- * @profile: a #GstGLSLProfile
- * @n_strings: number of strings in @str
- * @str: (transfer none): a GLSL shader string
- *
- * Replaces the current shader string with @str.
- *
- * Since: 1.8
- */
-gboolean
-gst_glsl_stage_set_strings (GstGLSLStage * stage, GstGLSLVersion version,
- GstGLSLProfile profile, gint n_strings, const gchar ** str)
-{
- gint i;
-
- g_return_val_if_fail (GST_IS_GLSL_STAGE (stage), FALSE);
- g_return_val_if_fail (n_strings > 0, FALSE);
- g_return_val_if_fail (str != NULL, FALSE);
-
- if (!gst_gl_context_supports_glsl_profile_version (stage->context, version,
- profile)) {
- const gchar *version_str = gst_glsl_version_to_string (version);
- const gchar *profile_str = gst_glsl_profile_to_string (profile);
- GST_ERROR_OBJECT (stage, "GL context does not support version %s and "
- "profile %s", version_str, profile_str);
- return FALSE;
- }
-
- stage->priv->version = version;
- stage->priv->profile = profile;
-
- for (i = 0; i < stage->priv->n_strings; i++) {
- g_free (stage->priv->strings[i]);
- }
-
- if (stage->priv->n_strings < n_strings) {
- /* only realloc if we need more space */
- g_free (stage->priv->strings);
- stage->priv->strings = g_new0 (gchar *, n_strings);
- }
-
- for (i = 0; i < n_strings; i++)
- stage->priv->strings[i] = g_strdup (str[i]);
- stage->priv->n_strings = n_strings;
-
- return TRUE;
-}
-
-/**
- * gst_glsl_stage_get_shader_type:
- * @stage: a #GstGLSLStage
- *
- * Returns: The GL shader type for this shader stage
- *
- * Since: 1.8
- */
-guint
-gst_glsl_stage_get_shader_type (GstGLSLStage * stage)
-{
- g_return_val_if_fail (GST_IS_GLSL_STAGE (stage), 0);
-
- return stage->priv->type;
-}
-
-/**
- * gst_glsl_stage_get_handle:
- * @stage: a #GstGLSLStage
- *
- * Returns: The GL handle for this shader stage
- *
- * Since: 1.8
- */
-guint
-gst_glsl_stage_get_handle (GstGLSLStage * stage)
-{
- g_return_val_if_fail (GST_IS_GLSL_STAGE (stage), 0);
- g_return_val_if_fail (stage->priv->compiled, 0);
-
- return stage->priv->handle;
-}
-
-/**
- * gst_glsl_stage_get_version:
- * @stage: a #GstGLSLStage
- *
- * Returns: The GLSL version for the current shader stage
- *
- * Since: 1.8
- */
-GstGLSLVersion
-gst_glsl_stage_get_version (GstGLSLStage * stage)
-{
- g_return_val_if_fail (GST_IS_GLSL_STAGE (stage), 0);
-
- return stage->priv->version;
-}
-
-/**
- * gst_glsl_stage_get_profile:
- * @stage: a #GstGLSLStage
- *
- * Returns: The GLSL profile for the current shader stage
- *
- * Since: 1.8
- */
-GstGLSLProfile
-gst_glsl_stage_get_profile (GstGLSLStage * stage)
-{
- g_return_val_if_fail (GST_IS_GLSL_STAGE (stage), 0);
-
- return stage->priv->profile;
-}
-
-static void
-_maybe_prepend_version (GstGLSLStage * stage, gchar ** shader_str,
- gint * n_vertex_sources, const gchar *** vertex_sources)
-{
- gint n = *n_vertex_sources;
- gboolean add_header = FALSE;
- gint i, j;
-
- /* FIXME: this all an educated guess */
- if (gst_gl_context_check_gl_version (stage->context, GST_GL_API_OPENGL3, 3, 0)
- && (stage->priv->profile & GST_GLSL_PROFILE_ES) != 0
- && !_gst_glsl_shader_string_find_version (shader_str[0])) {
- add_header = TRUE;
- n++;
- }
-
- *vertex_sources = g_malloc0 (n * sizeof (gchar *));
-
- i = 0;
- if (add_header)
- (*vertex_sources)[i++] = es2_version_header;
-
- for (j = 0; j < stage->priv->n_strings; i++, j++)
- (*vertex_sources)[i] = shader_str[j];
- *n_vertex_sources = n;
-}
-
-struct compile
-{
- GstGLSLStage *stage;
- GError **error;
- gboolean result;
-};
-
-static void
-_compile_shader (GstGLContext * context, struct compile *data)
-{
- GstGLSLStagePrivate *priv = data->stage->priv;
- GstGLSLFuncs *vtable = &data->stage->priv->vtable;
- const GstGLFuncs *gl = context->gl_vtable;
- const gchar **vertex_sources;
- gchar info_buffer[2048];
- gint n_vertex_sources;
- GLint status;
- gint len;
- gint i;
-
- if (data->stage->priv->compiled) {
- data->result = TRUE;
- return;
- }
-
- if (!_ensure_shader (data->stage)) {
- g_set_error (data->error, GST_GLSL_ERROR, GST_GLSL_ERROR_COMPILE,
- "Failed to create shader object");
- data->result = FALSE;
- return;
- }
-
- n_vertex_sources = data->stage->priv->n_strings;
- _maybe_prepend_version (data->stage, priv->strings, &n_vertex_sources,
- &vertex_sources);
-
- GST_TRACE_OBJECT (data->stage, "compiling shader:");
- for (i = 0; i < n_vertex_sources; i++) {
- GST_TRACE_OBJECT (data->stage, "%s", vertex_sources[i]);
- }
-
- gl->ShaderSource (priv->handle, n_vertex_sources,
- (const gchar **) vertex_sources, NULL);
- gl->CompileShader (priv->handle);
- g_free (vertex_sources);
- /* FIXME: supported threaded GLSL compilers and don't destroy compilation
- * performance by getting the compilation result directly after compilation */
- status = GL_FALSE;
- vtable->GetShaderiv (priv->handle, GL_COMPILE_STATUS, &status);
-
- len = 0;
- vtable->GetShaderInfoLog (priv->handle, sizeof (info_buffer) - 1, &len,
- info_buffer);
- info_buffer[len] = '\0';
-
- if (status != GL_TRUE) {
- GST_ERROR_OBJECT (data->stage, "%s shader compilation failed:%s",
- _shader_type_to_string (priv->type), info_buffer);
-
- g_set_error (data->error, GST_GLSL_ERROR, GST_GLSL_ERROR_COMPILE,
- "%s shader compilation failed:%s",
- _shader_type_to_string (priv->type), info_buffer);
-
- vtable->DeleteShader (priv->handle);
- data->result = FALSE;
- return;
- } else if (len > 1) {
- GST_FIXME_OBJECT (data->stage, "%s shader info log:%s",
- _shader_type_to_string (priv->type), info_buffer);
- }
-
- data->result = TRUE;
-}
-
-/**
- * gst_glsl_stage_compile:
- * @stage: a #GstGLSLStage
- * @error: a #GError to use on failure
- *
- * Returns: whether the compilation suceeded
- *
- * Since: 1.8
- */
-gboolean
-gst_glsl_stage_compile (GstGLSLStage * stage, GError ** error)
-{
- struct compile data;
-
- g_return_val_if_fail (GST_IS_GLSL_STAGE (stage), FALSE);
-
- if (!stage->priv->strings) {
- g_set_error (error, GST_GLSL_ERROR, GST_GLSL_ERROR_COMPILE,
- "No shader source to compile");
- return FALSE;
- }
-
- data.stage = stage;
- data.error = error;
-
- gst_gl_context_thread_add (stage->context,
- (GstGLContextThreadFunc) _compile_shader, &data);
-
- stage->priv->compiled = TRUE;
-
- return data.result;
-}
diff --git a/gst-libs/gst/gl/gstglslstage.h b/gst-libs/gst/gl/gstglslstage.h
deleted file mode 100644
index f37e8f653..000000000
--- a/gst-libs/gst/gl/gstglslstage.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GLSL_STAGE_H__
-#define __GST_GLSL_STAGE_H__
-
-#include <gst/gl/gstglsl.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GLSL_STAGE (gst_glsl_stage_get_type())
-#define GST_GLSL_STAGE(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GLSL_STAGE, GstGLSLStage))
-#define GST_GLSL_STAGE_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GLSL_STAGE, GstGLSLStageClass))
-#define GST_IS_GLSL_STAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GLSL_STAGE))
-#define GST_IS_GLSL_STAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GLSL_STAGE))
-#define GST_GLSL_STAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GLSL_STAGE, GstGLSLStageClass))
-
-/**
- * GstGLSLStage:
- *
- * Opaque #GstGLSLStage struct
- */
-struct _GstGLSLStage
-{
- /*< private >*/
- GstObject parent;
-
- GstGLContext *context;
-
- GstGLSLStagePrivate *priv;
-
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GstGLSLStageClass:
- *
- * Opaque #GstGLSLStageClass struct
- */
-struct _GstGLSLStageClass
-{
- /* <private> */
- GstObjectClass parent;
-
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GType gst_glsl_stage_get_type (void);
-GST_EXPORT
-GstGLSLStage * gst_glsl_stage_new (GstGLContext * context, guint type);
-GST_EXPORT
-GstGLSLStage * gst_glsl_stage_new_with_string (GstGLContext * context,
- guint type,
- GstGLSLVersion version,
- GstGLSLProfile profile,
- const gchar * str);
-GST_EXPORT
-GstGLSLStage * gst_glsl_stage_new_with_strings (GstGLContext * context,
- guint type,
- GstGLSLVersion version,
- GstGLSLProfile profile,
- gint n_strings,
- const gchar ** str);
-
-GST_EXPORT
-GstGLSLStage * gst_glsl_stage_new_default_fragment (GstGLContext * context);
-GST_EXPORT
-GstGLSLStage * gst_glsl_stage_new_default_vertex (GstGLContext * context);
-
-GST_EXPORT
-guint gst_glsl_stage_get_handle (GstGLSLStage * stage);
-GST_EXPORT
-GstGLSLProfile gst_glsl_stage_get_profile (GstGLSLStage * stage);
-GST_EXPORT
-GstGLSLVersion gst_glsl_stage_get_version (GstGLSLStage * stage);
-GST_EXPORT
-guint gst_glsl_stage_get_shader_type (GstGLSLStage * stage);
-GST_EXPORT
-gboolean gst_glsl_stage_set_strings (GstGLSLStage * stage,
- GstGLSLVersion version,
- GstGLSLProfile profile,
- gint n_strings,
- const gchar ** str);
-GST_EXPORT
-gboolean gst_glsl_stage_compile (GstGLSLStage * stage,
- GError ** error);
-
-G_END_DECLS
-
-#endif /* __GST_GLSL_STAGE_H__ */
diff --git a/gst-libs/gst/gl/gstglsyncmeta.c b/gst-libs/gst/gl/gstglsyncmeta.c
deleted file mode 100644
index d74b3cd46..000000000
--- a/gst-libs/gst/gl/gstglsyncmeta.c
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstglsyncmeta
- * @title: GstGLSyncMeta
- * @short_description: synchronization primitives
- * @see_also: #GstGLBaseMemory, #GstGLContext
- *
- * #GstGLSyncMeta provides the ability to synchronize the OpenGL command stream
- * with the CPU or with other OpenGL contexts.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstglsyncmeta.h"
-
-#include "gstglcontext.h"
-#include "gstglfuncs.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_gl_sync_meta_debug);
-#define GST_CAT_DEFAULT gst_gl_sync_meta_debug
-
-#ifndef GL_SYNC_GPU_COMMANDS_COMPLETE
-#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
-#endif
-#ifndef GL_SYNC_FLUSH_COMMANDS_BIT
-#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
-#endif
-#ifndef GL_TIMEOUT_EXPIRED
-#define GL_TIMEOUT_EXPIRED 0x911B
-#endif
-#ifndef GL_TIMEOUT_IGNORED
-#define GL_TIMEOUT_IGNORED G_GUINT64_CONSTANT(0xFFFFFFFFFFFFFFFF)
-#endif
-
-static void
-_default_set_sync_gl (GstGLSyncMeta * sync_meta, GstGLContext * context)
-{
- const GstGLFuncs *gl = context->gl_vtable;
-
- if (gl->FenceSync) {
- if (sync_meta->data) {
- GST_LOG ("deleting sync object %p", sync_meta->data);
- gl->DeleteSync ((GLsync) sync_meta->data);
- }
- sync_meta->data =
- (gpointer) gl->FenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
- GST_LOG ("setting sync object %p", sync_meta->data);
- }
-
- if (gst_gl_context_is_shared (context))
- gl->Flush ();
-}
-
-static void
-_default_wait_gl (GstGLSyncMeta * sync_meta, GstGLContext * context)
-{
- const GstGLFuncs *gl = context->gl_vtable;
-
- if (sync_meta->data && gl->WaitSync) {
- GST_LOG ("waiting on sync object %p", sync_meta->data);
- gl->WaitSync ((GLsync) sync_meta->data, 0, GL_TIMEOUT_IGNORED);
- }
-}
-
-static void
-_default_wait_cpu_gl (GstGLSyncMeta * sync_meta, GstGLContext * context)
-{
- const GstGLFuncs *gl = context->gl_vtable;
- GLenum res;
-
- if (sync_meta->data && gl->ClientWaitSync) {
- do {
- GST_LOG ("waiting on sync object %p", sync_meta->data);
- res =
- gl->ClientWaitSync ((GLsync) sync_meta->data,
- GL_SYNC_FLUSH_COMMANDS_BIT, 1000000000 /* 1s */ );
- } while (res == GL_TIMEOUT_EXPIRED);
- } else {
- gl->Finish ();
- }
-}
-
-static void
-_default_copy (GstGLSyncMeta * src, GstBuffer * sbuffer, GstGLSyncMeta * dest,
- GstBuffer * dbuffer)
-{
- GST_LOG ("copy sync object %p from meta %p to %p", src->data, src, dest);
-
- /* Setting a sync point here relies on GstBuffer copying
- * metas after data */
- gst_gl_sync_meta_set_sync_point (src, src->context);
-}
-
-static void
-_default_free_gl (GstGLSyncMeta * sync_meta, GstGLContext * context)
-{
- const GstGLFuncs *gl = context->gl_vtable;
-
- if (sync_meta->data) {
- GST_LOG ("deleting sync object %p", sync_meta->data);
- gl->DeleteSync ((GLsync) sync_meta->data);
- sync_meta->data = NULL;
- }
-}
-
-/**
- * gst_buffer_add_gl_sync_meta_full:
- * @context: a #GstGLContext
- * @buffer: a #GstBuffer
- * @data: sync data to hold
- *
- * Returns: (transfer none): the #GstGLSyncMeta added to #GstBuffer
- *
- * Since: 1.8
- */
-GstGLSyncMeta *
-gst_buffer_add_gl_sync_meta_full (GstGLContext * context, GstBuffer * buffer,
- gpointer data)
-{
- GstGLSyncMeta *meta;
-
- g_return_val_if_fail (GST_IS_GL_CONTEXT (context), NULL);
-
- meta =
- (GstGLSyncMeta *) gst_buffer_add_meta ((buffer), GST_GL_SYNC_META_INFO,
- NULL);
-
- if (!meta)
- return NULL;
-
- meta->context = gst_object_ref (context);
- meta->data = data;
-
- return meta;
-}
-
-/**
- * gst_buffer_add_gl_sync_meta:
- * @context: a #GstGLContext
- * @buffer: a #GstBuffer
- *
- * Returns: (transfer none): the #GstGLSyncMeta added to #GstBuffer
- *
- * Since: 1.6
- */
-GstGLSyncMeta *
-gst_buffer_add_gl_sync_meta (GstGLContext * context, GstBuffer * buffer)
-{
- GstGLSyncMeta *ret = gst_buffer_add_gl_sync_meta_full (context, buffer, NULL);
- if (!ret)
- return NULL;
-
- ret->set_sync_gl = _default_set_sync_gl;
- ret->wait_gl = _default_wait_gl;
- ret->wait_cpu_gl = _default_wait_cpu_gl;
- ret->copy = _default_copy;
- ret->free_gl = _default_free_gl;
-
- return ret;
-}
-
-static void
-_set_sync_point (GstGLContext * context, GstGLSyncMeta * sync_meta)
-{
- g_assert (sync_meta->set_sync_gl != NULL);
-
- GST_LOG ("setting sync point %p", sync_meta);
- sync_meta->set_sync_gl (sync_meta, context);
-}
-
-/**
- * gst_gl_sync_meta_set_sync_point:
- * @sync_meta: a #GstGLSyncMeta
- * @context: a #GstGLContext
- *
- * Set a sync point to possibly wait on at a later time.
- *
- * Since: 1.6
- */
-void
-gst_gl_sync_meta_set_sync_point (GstGLSyncMeta * sync_meta,
- GstGLContext * context)
-{
- if (sync_meta->set_sync)
- sync_meta->set_sync (sync_meta, context);
- else
- gst_gl_context_thread_add (context,
- (GstGLContextThreadFunc) _set_sync_point, sync_meta);
-}
-
-static void
-_wait (GstGLContext * context, GstGLSyncMeta * sync_meta)
-{
- g_assert (sync_meta->wait_gl != NULL);
-
- GST_LOG ("waiting %p", sync_meta);
- sync_meta->wait_gl (sync_meta, context);
-}
-
-/**
- * gst_gl_sync_meta_wait:
- * @sync_meta: a #GstGLSyncMeta
- * @context: a #GstGLContext
- *
- * Insert a wait into @context's command stream ensuring all previous OpenGL
- * commands before @sync_meta have completed.
- *
- * Since: 1.6
- */
-void
-gst_gl_sync_meta_wait (GstGLSyncMeta * sync_meta, GstGLContext * context)
-{
- if (sync_meta->wait)
- sync_meta->wait (sync_meta, context);
- else
- gst_gl_context_thread_add (context,
- (GstGLContextThreadFunc) _wait, sync_meta);
-}
-
-static void
-_wait_cpu (GstGLContext * context, GstGLSyncMeta * sync_meta)
-{
- g_assert (sync_meta->wait_cpu_gl != NULL);
-
- GST_LOG ("waiting %p", sync_meta);
- sync_meta->wait_cpu_gl (sync_meta, context);
-}
-
-/**
- * gst_gl_sync_meta_wait_cpu:
- * @sync_meta: a #GstGLSyncMeta
- * @context: a #GstGLContext
- *
- * Perform a wait so that the sync point has passed from the CPU's perspective
- * What that means, is that all GL operations changing CPU-visible data before
- * the sync point are now visible.
- *
- * Since: 1.8
- */
-void
-gst_gl_sync_meta_wait_cpu (GstGLSyncMeta * sync_meta, GstGLContext * context)
-{
- if (sync_meta->wait_cpu)
- sync_meta->wait_cpu (sync_meta, context);
- else
- gst_gl_context_thread_add (context,
- (GstGLContextThreadFunc) _wait_cpu, sync_meta);
-}
-
-static gboolean
-_gst_gl_sync_meta_transform (GstBuffer * dest, GstMeta * meta,
- GstBuffer * buffer, GQuark type, gpointer data)
-{
- GstGLSyncMeta *dmeta, *smeta;
-
- smeta = (GstGLSyncMeta *) meta;
-
- if (GST_META_TRANSFORM_IS_COPY (type)) {
- GstMetaTransformCopy *copy = data;
-
- g_assert (smeta->copy != NULL);
-
- if (!copy->region) {
- /* only copy if the complete data is copied as well */
- dmeta = gst_buffer_add_gl_sync_meta_full (smeta->context, dest, NULL);
- if (!dmeta)
- return FALSE;
-
- dmeta->set_sync = smeta->set_sync;
- dmeta->set_sync_gl = smeta->set_sync_gl;
- dmeta->wait = smeta->wait;
- dmeta->wait_gl = smeta->wait_gl;
- dmeta->wait_cpu = smeta->wait_cpu;
- dmeta->wait_cpu_gl = smeta->wait_cpu_gl;
- dmeta->copy = smeta->copy;
- dmeta->free = smeta->free;
- dmeta->free_gl = smeta->free_gl;
-
- GST_LOG ("copying sync meta %p into %p", smeta, dmeta);
- smeta->copy (smeta, buffer, dmeta, dest);
- }
- } else {
- /* return FALSE, if transform type is not supported */
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-_free_gl_sync_meta (GstGLContext * context, GstGLSyncMeta * sync_meta)
-{
- g_assert (sync_meta->free_gl != NULL);
-
- GST_LOG ("free sync meta %p", sync_meta);
- sync_meta->free_gl (sync_meta, context);
-}
-
-static void
-_gst_gl_sync_meta_free (GstGLSyncMeta * sync_meta, GstBuffer * buffer)
-{
- if (sync_meta->free)
- sync_meta->free (sync_meta, sync_meta->context);
- else
- gst_gl_context_thread_add (sync_meta->context,
- (GstGLContextThreadFunc) _free_gl_sync_meta, sync_meta);
-
- gst_object_unref (sync_meta->context);
-}
-
-static gboolean
-_gst_gl_sync_meta_init (GstGLSyncMeta * sync_meta, gpointer params,
- GstBuffer * buffer)
-{
- static volatile gsize _init;
-
- if (g_once_init_enter (&_init)) {
- GST_DEBUG_CATEGORY_INIT (gst_gl_sync_meta_debug, "glsyncmeta", 0,
- "glsyncmeta");
- g_once_init_leave (&_init, 1);
- }
-
- sync_meta->context = NULL;
- sync_meta->data = NULL;
- sync_meta->set_sync = NULL;
- sync_meta->set_sync_gl = NULL;
- sync_meta->wait = NULL;
- sync_meta->wait_gl = NULL;
- sync_meta->wait_cpu = NULL;
- sync_meta->wait_cpu_gl = NULL;
- sync_meta->copy = NULL;
- sync_meta->free = NULL;
- sync_meta->free_gl = NULL;
-
- return TRUE;
-}
-
-GType
-gst_gl_sync_meta_api_get_type (void)
-{
- static volatile GType type = 0;
- static const gchar *tags[] = { NULL };
-
- if (g_once_init_enter (&type)) {
- GType _type = gst_meta_api_type_register ("GstGLSyncMetaAPI", tags);
- g_once_init_leave (&type, _type);
- }
-
- return type;
-}
-
-const GstMetaInfo *
-gst_gl_sync_meta_get_info (void)
-{
- static const GstMetaInfo *meta_info = NULL;
-
- if (g_once_init_enter (&meta_info)) {
- const GstMetaInfo *meta =
- gst_meta_register (GST_GL_SYNC_META_API_TYPE, "GstGLSyncMeta",
- sizeof (GstGLSyncMeta), (GstMetaInitFunction) _gst_gl_sync_meta_init,
- (GstMetaFreeFunction) _gst_gl_sync_meta_free,
- _gst_gl_sync_meta_transform);
- g_once_init_leave (&meta_info, meta);
- }
-
- return meta_info;
-}
diff --git a/gst-libs/gst/gl/gstglsyncmeta.h b/gst-libs/gst/gl/gstglsyncmeta.h
deleted file mode 100644
index ea67b7910..000000000
--- a/gst-libs/gst/gl/gstglsyncmeta.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_SYNC_META_H__
-#define __GST_GL_SYNC_META_H__
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-#define GST_GL_SYNC_META_API_TYPE (gst_gl_sync_meta_api_get_type())
-#define GST_GL_SYNC_META_INFO (gst_gl_sync_meta_get_info())
-typedef struct _GstGLSyncMeta GstGLSyncMeta;
-
-/**
- * GST_BUFFER_POOL_OPTION_GL_SYNC_META:
- *
- * An option that can be activated on bufferpools to request OpenGL
- * synchronization metadata on buffers from the pool.
- */
-#define GST_BUFFER_POOL_OPTION_GL_SYNC_META "GstBufferPoolOptionGLSyncMeta"
-
-/**
- * GstGLSyncMeta:
- * @parent: the parent #GstMeta
- * @context: the #GstGLContext used to allocate the meta
- * @data: a custom data pointer for the implementation
- * @set_sync: set a sync point in the OpenGL command stream
- * @set_sync_gl: the same as @set_sync but called from @context's thread
- * @wait: execute a wait on the previously set sync point into the OpenGL command stream
- * @wait_gl: the same as @wait but called from @context's thread
- * @wait_cpu: wait for the previously set sync point to pass from the CPU
- * @wait_cpu_gl: the same as @wait_cpu but called from @context's thread
- * @copy: copy @data into a new #GstGLSyncMeta
- * @free: free @data
- * @free_gl: free @data in @context's thread
- */
-struct _GstGLSyncMeta
-{
- GstMeta parent;
-
- GstGLContext *context;
-
- gpointer data;
-
- void (*set_sync) (GstGLSyncMeta * sync, GstGLContext * context);
- void (*set_sync_gl) (GstGLSyncMeta * sync, GstGLContext * context);
- void (*wait) (GstGLSyncMeta * sync, GstGLContext * context);
- void (*wait_gl) (GstGLSyncMeta * sync, GstGLContext * context);
- void (*wait_cpu) (GstGLSyncMeta * sync, GstGLContext * context);
- void (*wait_cpu_gl) (GstGLSyncMeta * sync, GstGLContext * context);
- void (*copy) (GstGLSyncMeta * src, GstBuffer * sbuffer, GstGLSyncMeta * dest, GstBuffer * dbuffer);
- void (*free) (GstGLSyncMeta * sync, GstGLContext * context);
- void (*free_gl) (GstGLSyncMeta * sync, GstGLContext * context);
-};
-
-GST_EXPORT
-GType gst_gl_sync_meta_api_get_type (void);
-GST_EXPORT
-const GstMetaInfo * gst_gl_sync_meta_get_info (void);
-
-#define gst_buffer_get_gl_sync_meta(b) ((GstGLSyncMeta*)gst_buffer_get_meta((b),GST_GL_SYNC_META_API_TYPE))
-
-GST_EXPORT
-GstGLSyncMeta * gst_buffer_add_gl_sync_meta (GstGLContext * context, GstBuffer *buffer);
-GST_EXPORT
-GstGLSyncMeta * gst_buffer_add_gl_sync_meta_full (GstGLContext * context, GstBuffer * buffer,
- gpointer data);
-GST_EXPORT
-void gst_gl_sync_meta_set_sync_point (GstGLSyncMeta * sync_meta, GstGLContext * context);
-GST_EXPORT
-void gst_gl_sync_meta_wait (GstGLSyncMeta * sync_meta, GstGLContext * context);
-GST_EXPORT
-void gst_gl_sync_meta_wait_cpu (GstGLSyncMeta * sync_meta, GstGLContext * context);
-
-G_END_DECLS
-
-#endif /* __GST_GL_SYNC_META_H__ */
diff --git a/gst-libs/gst/gl/gstglupload.c b/gst-libs/gst/gl/gstglupload.c
deleted file mode 100644
index feaf2f68e..000000000
--- a/gst-libs/gst/gl/gstglupload.c
+++ /dev/null
@@ -1,1856 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012-2014 Matthew Waters <ystree00@gmail.com>
- * Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-
-#include "gl.h"
-#include "gstglupload.h"
-
-#if GST_GL_HAVE_PLATFORM_EGL
-#include "egl/gsteglimage.h"
-#include "egl/gstglmemoryegl.h"
-#include "egl/gstglcontext_egl.h"
-#endif
-
-#if GST_GL_HAVE_DMABUF
-#include <gst/allocators/gstdmabuf.h>
-#endif
-
-#if GST_GL_HAVE_VIV_DIRECTVIV
-#include <gst/allocators/gstphysmemory.h>
-#endif
-
-/**
- * SECTION:gstglupload
- * @title: GstGLUpload
- * @short_description: an object that uploads to GL textures
- * @see_also: #GstGLDownload, #GstGLMemory
- *
- * #GstGLUpload is an object that uploads data from system memory into GL textures.
- *
- * A #GstGLUpload can be created with gst_gl_upload_new()
- */
-
-#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
-#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
-#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
-#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
-#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-
-GST_DEBUG_CATEGORY_STATIC (gst_gl_upload_debug);
-#define GST_CAT_DEFAULT gst_gl_upload_debug
-
-#define DEBUG_INIT \
- GST_DEBUG_CATEGORY_INIT (gst_gl_upload_debug, "glupload", 0, "upload");
-
-G_DEFINE_TYPE_WITH_CODE (GstGLUpload, gst_gl_upload, GST_TYPE_OBJECT,
- DEBUG_INIT);
-static void gst_gl_upload_finalize (GObject * object);
-
-#define GST_GL_UPLOAD_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
- GST_TYPE_GL_UPLOAD, GstGLUploadPrivate))
-
-static GstGLTextureTarget
-_caps_get_texture_target (GstCaps * caps, GstGLTextureTarget default_target)
-{
- GstGLTextureTarget ret = 0;
- GstStructure *s = gst_caps_get_structure (caps, 0);
-
- if (gst_structure_has_field_typed (s, "texture-target", G_TYPE_STRING)) {
- const gchar *target_str = gst_structure_get_string (s, "texture-target");
- ret = gst_gl_texture_target_from_string (target_str);
- }
-
- if (!ret)
- ret = default_target;
-
- return ret;
-}
-
-/* Define the maximum number of planes we can upload - handle 2 views per buffer */
-#define GST_GL_UPLOAD_MAX_PLANES (GST_VIDEO_MAX_PLANES * 2)
-
-typedef struct _UploadMethod UploadMethod;
-
-struct _GstGLUploadPrivate
-{
- GstVideoInfo in_info;
- GstVideoInfo out_info;
- GstCaps *in_caps;
- GstCaps *out_caps;
-
- GstBuffer *outbuf;
-
- /* all method impl pointers */
- gpointer *upload_impl;
-
- /* current method */
- const UploadMethod *method;
- gpointer method_impl;
- int method_i;
-};
-
-static GstCaps *
-_set_caps_features_with_passthrough (const GstCaps * caps,
- const gchar * feature_name, GstCapsFeatures * passthrough)
-{
- guint i, j, m, n;
- GstCaps *tmp;
-
- tmp = gst_caps_new_empty ();
-
- n = gst_caps_get_size (caps);
- for (i = 0; i < n; i++) {
- GstCapsFeatures *features, *orig_features;
- GstStructure *s = gst_caps_get_structure (caps, i);
-
- orig_features = gst_caps_get_features (caps, i);
- features = gst_caps_features_new (feature_name, NULL);
-
- if (gst_caps_features_is_any (orig_features)) {
- /* if we have any features, we add both the features with and without @passthrough */
- gst_caps_append_structure_full (tmp, gst_structure_copy (s),
- gst_caps_features_copy (features));
-
- m = gst_caps_features_get_size (passthrough);
- for (j = 0; j < m; j++) {
- const gchar *feature = gst_caps_features_get_nth (passthrough, j);
-
- /* if we already have the features */
- if (gst_caps_features_contains (features, feature))
- continue;
-
- gst_caps_features_add (features, feature);
- }
- } else {
- m = gst_caps_features_get_size (orig_features);
- for (j = 0; j < m; j++) {
- const gchar *feature = gst_caps_features_get_nth (orig_features, j);
-
- /* if we already have the features */
- if (gst_caps_features_contains (features, feature))
- continue;
-
- if (g_strcmp0 (feature, GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY) == 0)
- continue;
-
- if (gst_caps_features_contains (passthrough, feature)) {
- gst_caps_features_add (features, feature);
- }
- }
- }
-
- gst_caps_append_structure_full (tmp, gst_structure_copy (s), features);
- }
-
- return tmp;
-}
-
-static GstCaps *
-_caps_intersect_texture_target (GstCaps * caps, GstGLTextureTarget target_mask)
-{
- GValue targets = G_VALUE_INIT;
- GstCaps *ret, *target;
-
- target = gst_caps_copy (caps);
- gst_gl_value_set_texture_target_from_mask (&targets, target_mask);
- gst_caps_set_value (target, "texture-target", &targets);
-
- ret = gst_caps_intersect_full (caps, target, GST_CAPS_INTERSECT_FIRST);
-
- g_value_unset (&targets);
- gst_caps_unref (target);
- return ret;
-}
-
-typedef enum
-{
- METHOD_FLAG_CAN_SHARE_CONTEXT = 1,
-} GstGLUploadMethodFlags;
-
-struct _UploadMethod
-{
- const gchar *name;
- GstGLUploadMethodFlags flags;
-
- GstStaticCaps *input_template_caps;
-
- gpointer (*new) (GstGLUpload * upload);
- GstCaps *(*transform_caps) (gpointer impl, GstGLContext * context,
- GstPadDirection direction, GstCaps * caps);
- gboolean (*accept) (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
- GstCaps * out_caps);
- void (*propose_allocation) (gpointer impl, GstQuery * decide_query,
- GstQuery * query);
- GstGLUploadReturn (*perform) (gpointer impl, GstBuffer * buffer,
- GstBuffer ** outbuf);
- void (*free) (gpointer impl);
-} _UploadMethod;
-
-struct GLMemoryUpload
-{
- GstGLUpload *upload;
- GstGLTextureTarget input_target;
- GstGLTextureTarget output_target;
-};
-
-static gpointer
-_gl_memory_upload_new (GstGLUpload * upload)
-{
- struct GLMemoryUpload *mem = g_new0 (struct GLMemoryUpload, 1);
-
- mem->upload = upload;
- mem->input_target = GST_GL_TEXTURE_TARGET_NONE;
- mem->output_target = GST_GL_TEXTURE_TARGET_NONE;
-
- return mem;
-}
-
-static GstCaps *
-_gl_memory_upload_transform_caps (gpointer impl, GstGLContext * context,
- GstPadDirection direction, GstCaps * caps)
-{
- struct GLMemoryUpload *upload = impl;
- GstCapsFeatures *passthrough =
- gst_caps_features_from_string
- (GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
- GstCaps *ret;
-
- ret =
- _set_caps_features_with_passthrough (caps,
- GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
-
- gst_caps_features_free (passthrough);
-
- if (direction == GST_PAD_SINK) {
- GstCaps *tmp;
- GstGLTextureTarget target_mask;
-
- if (upload->input_target != GST_GL_TEXTURE_TARGET_NONE) {
- target_mask = 1 << upload->input_target;
- } else {
- target_mask = 1 << GST_GL_TEXTURE_TARGET_2D |
- 1 << GST_GL_TEXTURE_TARGET_RECTANGLE |
- 1 << GST_GL_TEXTURE_TARGET_EXTERNAL_OES;
- }
-
- tmp = _caps_intersect_texture_target (ret, target_mask);
- gst_caps_unref (ret);
- ret = tmp;
- } else {
- gint i, n;
-
- n = gst_caps_get_size (ret);
- for (i = 0; i < n; i++) {
- GstStructure *s = gst_caps_get_structure (ret, i);
-
- gst_structure_remove_fields (s, "texture-target", NULL);
- }
- }
-
- return ret;
-}
-
-static gboolean
-_gl_memory_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
- GstCaps * out_caps)
-{
- struct GLMemoryUpload *upload = impl;
- GstCapsFeatures *features;
- int i;
-
- features = gst_caps_get_features (out_caps, 0);
- if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
- return FALSE;
-
- features = gst_caps_get_features (in_caps, 0);
- if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY)
- && !gst_caps_features_contains (features,
- GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY))
- return FALSE;
-
- if (buffer) {
- GstVideoInfo *in_info = &upload->upload->priv->in_info;
- guint expected_memories = GST_VIDEO_INFO_N_PLANES (in_info);
-
- /* Support stereo views for separated multiview mode */
- if (GST_VIDEO_INFO_MULTIVIEW_MODE (in_info) ==
- GST_VIDEO_MULTIVIEW_MODE_SEPARATED)
- expected_memories *= GST_VIDEO_INFO_VIEWS (in_info);
-
- if (gst_buffer_n_memory (buffer) != expected_memories)
- return FALSE;
-
- for (i = 0; i < expected_memories; i++) {
- GstMemory *mem = gst_buffer_peek_memory (buffer, i);
-
- if (!gst_is_gl_memory (mem))
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static void
-_gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
- GstQuery * query)
-{
- struct GLMemoryUpload *upload = impl;
- GstBufferPool *pool = NULL;
- guint n_pools, i;
- GstCaps *caps;
- GstCapsFeatures *features;
-
- gst_query_parse_allocation (query, &caps, NULL);
- if (caps == NULL)
- goto invalid_caps;
- features = gst_caps_get_features (caps, 0);
-
- /* Only offer our custom allocator if that type of memory was negotiated. */
- if (gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY)) {
- GstAllocator *allocator;
- GstAllocationParams params;
- gst_allocation_params_init (&params);
-
- allocator =
- GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->
- upload->context));
- gst_query_add_allocation_param (query, allocator, &params);
- gst_object_unref (allocator);
-
-#if GST_GL_HAVE_PLATFORM_EGL
- if (upload->upload->context
- && gst_gl_context_get_gl_platform (upload->upload->context) ==
- GST_GL_PLATFORM_EGL) {
- allocator =
- GST_ALLOCATOR (gst_allocator_find (GST_GL_MEMORY_EGL_ALLOCATOR_NAME));
- gst_query_add_allocation_param (query, allocator, &params);
- gst_object_unref (allocator);
- }
-#endif
- }
-
- n_pools = gst_query_get_n_allocation_pools (query);
- for (i = 0; i < n_pools; i++) {
- gst_query_parse_nth_allocation_pool (query, i, &pool, NULL, NULL, NULL);
- if (!GST_IS_GL_BUFFER_POOL (pool)) {
- gst_object_unref (pool);
- pool = NULL;
- }
- }
-
- if (!pool) {
- GstStructure *config;
- GstVideoInfo info;
- gsize size;
-
-
- if (!gst_video_info_from_caps (&info, caps))
- goto invalid_caps;
-
- pool = gst_gl_buffer_pool_new (upload->upload->context);
- config = gst_buffer_pool_get_config (pool);
-
- /* the normal size of a frame */
- size = info.size;
- gst_buffer_pool_config_set_params (config, caps, size, 0, 0);
- gst_buffer_pool_config_add_option (config,
- GST_BUFFER_POOL_OPTION_GL_SYNC_META);
- if (upload->upload->priv->out_caps) {
- GstGLTextureTarget target;
- const gchar *target_pool_option_str;
-
- target =
- _caps_get_texture_target (upload->upload->priv->out_caps,
- GST_GL_TEXTURE_TARGET_2D);
- target_pool_option_str =
- gst_gl_texture_target_to_buffer_pool_option (target);
- gst_buffer_pool_config_add_option (config, target_pool_option_str);
- }
-
- if (!gst_buffer_pool_set_config (pool, config)) {
- gst_object_unref (pool);
- goto config_failed;
- }
-
- gst_query_add_allocation_pool (query, pool, size, 1, 0);
- }
-
- if (pool)
- gst_object_unref (pool);
-
- return;
-
-invalid_caps:
- {
- GST_WARNING_OBJECT (upload->upload, "invalid caps specified");
- return;
- }
-config_failed:
- {
- GST_WARNING_OBJECT (upload->upload, "failed setting config");
- return;
- }
-}
-
-static GstGLUploadReturn
-_gl_memory_upload_perform (gpointer impl, GstBuffer * buffer,
- GstBuffer ** outbuf)
-{
- struct GLMemoryUpload *upload = impl;
- GstGLMemory *gl_mem;
- int i, n;
-
- n = gst_buffer_n_memory (buffer);
- for (i = 0; i < n; i++) {
- GstMemory *mem = gst_buffer_peek_memory (buffer, i);
-
- gl_mem = (GstGLMemory *) mem;
- if (!gst_gl_context_can_share (upload->upload->context,
- gl_mem->mem.context))
- return GST_GL_UPLOAD_UNSHARED_GL_CONTEXT;
-
- if (upload->output_target == GST_GL_TEXTURE_TARGET_NONE &&
- upload->upload->priv->out_caps) {
- upload->output_target =
- _caps_get_texture_target (upload->upload->priv->out_caps,
- GST_GL_TEXTURE_TARGET_NONE);
- }
-
- /* always track the last input texture target so ::transform_caps() can
- * use it to build the output caps */
- upload->input_target = gl_mem->tex_target;
- if (upload->output_target != gl_mem->tex_target) {
- *outbuf = NULL;
- return GST_GL_UPLOAD_RECONFIGURE;
- }
-
- if (gst_is_gl_memory_pbo (mem))
- gst_gl_memory_pbo_upload_transfer ((GstGLMemoryPBO *) mem);
- }
-
- *outbuf = gst_buffer_ref (buffer);
-
- return GST_GL_UPLOAD_DONE;
-}
-
-static void
-_gl_memory_upload_free (gpointer impl)
-{
- g_free (impl);
-}
-
-
-static GstStaticCaps _gl_memory_upload_caps =
-GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
- (GST_CAPS_FEATURE_MEMORY_GL_MEMORY, GST_GL_MEMORY_VIDEO_FORMATS_STR));
-
-static const UploadMethod _gl_memory_upload = {
- "GLMemory",
- METHOD_FLAG_CAN_SHARE_CONTEXT,
- &_gl_memory_upload_caps,
- &_gl_memory_upload_new,
- &_gl_memory_upload_transform_caps,
- &_gl_memory_upload_accept,
- &_gl_memory_upload_propose_allocation,
- &_gl_memory_upload_perform,
- &_gl_memory_upload_free
-};
-
-#if GST_GL_HAVE_DMABUF
-struct DmabufUpload
-{
- GstGLUpload *upload;
-
- GstEGLImage *eglimage[GST_VIDEO_MAX_PLANES];
- GstBuffer *outbuf;
- GstGLVideoAllocationParams *params;
-};
-
-static GstStaticCaps _dma_buf_upload_caps =
- GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
- (GST_CAPS_FEATURE_MEMORY_DMABUF,
- GST_GL_MEMORY_VIDEO_FORMATS_STR) ";"
- GST_VIDEO_CAPS_MAKE (GST_GL_MEMORY_VIDEO_FORMATS_STR));
-
-static gpointer
-_dma_buf_upload_new (GstGLUpload * upload)
-{
- struct DmabufUpload *dmabuf = g_new0 (struct DmabufUpload, 1);
- dmabuf->upload = upload;
- return dmabuf;
-}
-
-static GstCaps *
-_dma_buf_upload_transform_caps (gpointer impl, GstGLContext * context,
- GstPadDirection direction, GstCaps * caps)
-{
- GstCapsFeatures *passthrough =
- gst_caps_features_from_string
- (GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
- GstCaps *ret;
-
- if (direction == GST_PAD_SINK) {
- GstCaps *tmp;
-
- ret =
- _set_caps_features_with_passthrough (caps,
- GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
-
- tmp = _caps_intersect_texture_target (ret, 1 << GST_GL_TEXTURE_TARGET_2D);
- gst_caps_unref (ret);
- ret = tmp;
- } else {
- gint i, n;
-
- ret =
- _set_caps_features_with_passthrough (caps,
- GST_CAPS_FEATURE_MEMORY_DMABUF, passthrough);
-
- n = gst_caps_get_size (ret);
- for (i = 0; i < n; i++) {
- GstStructure *s = gst_caps_get_structure (ret, i);
-
- gst_structure_remove_fields (s, "texture-target", NULL);
- }
- }
-
- gst_caps_features_free (passthrough);
-
- return ret;
-}
-
-static GQuark
-_eglimage_quark (gint plane)
-{
- static GQuark quark[4] = { 0 };
- static const gchar *quark_str[] = {
- "GstGLDMABufEGLImage0",
- "GstGLDMABufEGLImage1",
- "GstGLDMABufEGLImage2",
- "GstGLDMABufEGLImage3",
- };
-
- if (!quark[plane])
- quark[plane] = g_quark_from_static_string (quark_str[plane]);
-
- return quark[plane];
-}
-
-static GstEGLImage *
-_get_cached_eglimage (GstMemory * mem, gint plane)
-{
- return gst_mini_object_get_qdata (GST_MINI_OBJECT (mem),
- _eglimage_quark (plane));
-}
-
-static void
-_set_cached_eglimage (GstMemory * mem, GstEGLImage * eglimage, gint plane)
-{
- return gst_mini_object_set_qdata (GST_MINI_OBJECT (mem),
- _eglimage_quark (plane), eglimage, (GDestroyNotify) gst_egl_image_unref);
-}
-
-static gboolean
-_dma_buf_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
- GstCaps * out_caps)
-{
- struct DmabufUpload *dmabuf = impl;
- GstVideoInfo *in_info = &dmabuf->upload->priv->in_info;
- guint n_planes = GST_VIDEO_INFO_N_PLANES (in_info);
- GstVideoMeta *meta;
- guint n_mem;
- guint mems_idx[GST_VIDEO_MAX_PLANES];
- gsize mems_skip[GST_VIDEO_MAX_PLANES];
- GstMemory *mems[GST_VIDEO_MAX_PLANES];
- guint i;
-
- n_mem = gst_buffer_n_memory (buffer);
- meta = gst_buffer_get_video_meta (buffer);
-
- /* dmabuf upload is only supported with EGL contexts. */
- if (gst_gl_context_get_gl_platform (dmabuf->upload->context) !=
- GST_GL_PLATFORM_EGL)
- return FALSE;
-
- if (!gst_gl_context_check_feature (dmabuf->upload->context,
- "EGL_KHR_image_base"))
- return FALSE;
-
- /* This will eliminate most non-dmabuf out there */
- if (!gst_is_dmabuf_memory (gst_buffer_peek_memory (buffer, 0)))
- return FALSE;
-
- /* We cannot have multiple dmabuf per plane */
- if (n_mem > n_planes)
- return FALSE;
-
- /* Update video info based on video meta */
- if (meta) {
- in_info->width = meta->width;
- in_info->height = meta->height;
-
- for (i = 0; i < meta->n_planes; i++) {
- in_info->offset[i] = meta->offset[i];
- in_info->stride[i] = meta->stride[i];
- }
- }
-
- if (dmabuf->params)
- gst_gl_allocation_params_free ((GstGLAllocationParams *) dmabuf->params);
- if (!(dmabuf->params =
- gst_gl_video_allocation_params_new_wrapped_gl_handle (dmabuf->
- upload->context, NULL, &dmabuf->upload->priv->in_info, -1, NULL,
- GST_GL_TEXTURE_TARGET_2D, 0, NULL, NULL, NULL)))
- return FALSE;
-
- /* Find and validate all memories */
- for (i = 0; i < n_planes; i++) {
- guint plane_size;
- guint length;
-
- plane_size = gst_gl_get_plane_data_size (in_info, NULL, i);
-
- if (!gst_buffer_find_memory (buffer, in_info->offset[i], plane_size,
- &mems_idx[i], &length, &mems_skip[i]))
- return FALSE;
-
- /* We can't have more then one dmabuf per plane */
- if (length != 1)
- return FALSE;
-
- mems[i] = gst_buffer_peek_memory (buffer, mems_idx[i]);
-
- /* And all memory found must be dmabuf */
- if (!gst_is_dmabuf_memory (mems[i]))
- return FALSE;
- }
-
- /* Now create an EGLImage for each dmabufs */
- for (i = 0; i < n_planes; i++) {
- /* check if one is cached */
- dmabuf->eglimage[i] = _get_cached_eglimage (mems[i], i);
- if (dmabuf->eglimage[i])
- continue;
-
- /* otherwise create one and cache it */
- dmabuf->eglimage[i] =
- gst_egl_image_from_dmabuf (dmabuf->upload->context,
- gst_dmabuf_memory_get_fd (mems[i]), in_info, i,
- mems[i]->offset + mems_skip[i]);
-
- if (!dmabuf->eglimage[i])
- return FALSE;
-
- _set_cached_eglimage (mems[i], dmabuf->eglimage[i], i);
- }
-
- return TRUE;
-}
-
-static void
-_dma_buf_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
- GstQuery * query)
-{
- /* nothing to do for now. */
-}
-
-static void
-_dma_buf_upload_perform_gl_thread (GstGLContext * context,
- struct DmabufUpload *dmabuf)
-{
- GstGLMemoryAllocator *allocator;
-
- allocator =
- GST_GL_MEMORY_ALLOCATOR (gst_allocator_find
- (GST_GL_MEMORY_EGL_ALLOCATOR_NAME));
-
- /* FIXME: buffer pool */
- dmabuf->outbuf = gst_buffer_new ();
- gst_gl_memory_setup_buffer (allocator, dmabuf->outbuf, dmabuf->params, NULL,
- (gpointer *) dmabuf->eglimage, gst_buffer_n_memory (dmabuf->outbuf));
- gst_object_unref (allocator);
-}
-
-static GstGLUploadReturn
-_dma_buf_upload_perform (gpointer impl, GstBuffer * buffer, GstBuffer ** outbuf)
-{
- struct DmabufUpload *dmabuf = impl;
-
- gst_gl_context_thread_add (dmabuf->upload->context,
- (GstGLContextThreadFunc) _dma_buf_upload_perform_gl_thread, dmabuf);
-
- if (!dmabuf->outbuf)
- return GST_GL_UPLOAD_ERROR;
-
- gst_buffer_add_parent_buffer_meta (dmabuf->outbuf, buffer);
-
- *outbuf = dmabuf->outbuf;
- dmabuf->outbuf = NULL;
-
- return GST_GL_UPLOAD_DONE;
-}
-
-static void
-_dma_buf_upload_free (gpointer impl)
-{
- struct DmabufUpload *dmabuf = impl;
-
- if (dmabuf->params)
- gst_gl_allocation_params_free ((GstGLAllocationParams *) dmabuf->params);
-
- g_free (impl);
-}
-
-static const UploadMethod _dma_buf_upload = {
- "Dmabuf",
- 0,
- &_dma_buf_upload_caps,
- &_dma_buf_upload_new,
- &_dma_buf_upload_transform_caps,
- &_dma_buf_upload_accept,
- &_dma_buf_upload_propose_allocation,
- &_dma_buf_upload_perform,
- &_dma_buf_upload_free
-};
-
-#endif /* GST_GL_HAVE_DMABUF */
-
-struct GLUploadMeta
-{
- GstGLUpload *upload;
-
- gboolean result;
- GstVideoGLTextureUploadMeta *meta;
- guint texture_ids[GST_GL_UPLOAD_MAX_PLANES];
- GstBufferPool *pool;
-};
-
-static gpointer
-_upload_meta_upload_new (GstGLUpload * upload)
-{
- struct GLUploadMeta *meta = g_new0 (struct GLUploadMeta, 1);
-
- meta->upload = upload;
- meta->pool = NULL;
-
- return meta;
-}
-
-static GstCaps *
-_upload_meta_upload_transform_caps (gpointer impl, GstGLContext * context,
- GstPadDirection direction, GstCaps * caps)
-{
- GstCapsFeatures *passthrough =
- gst_caps_features_from_string
- (GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
- GstCaps *ret;
-
- if (direction == GST_PAD_SINK) {
- GstCaps *tmp;
-
- ret =
- _set_caps_features_with_passthrough (caps,
- GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
-
- tmp = _caps_intersect_texture_target (ret, 1 << GST_GL_TEXTURE_TARGET_2D);
- gst_caps_unref (ret);
- ret = tmp;
- } else {
- gint i, n;
-
- ret =
- _set_caps_features_with_passthrough (caps,
- GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, passthrough);
- gst_caps_set_simple (ret, "format", G_TYPE_STRING, "RGBA", NULL);
-
- n = gst_caps_get_size (ret);
- for (i = 0; i < n; i++) {
- GstStructure *s = gst_caps_get_structure (ret, i);
-
- gst_structure_remove_fields (s, "texture-target", NULL);
- }
- }
-
- gst_caps_features_free (passthrough);
-
- return ret;
-}
-
-static gboolean
-_upload_meta_upload_accept (gpointer impl, GstBuffer * buffer,
- GstCaps * in_caps, GstCaps * out_caps)
-{
- struct GLUploadMeta *upload = impl;
- GstCapsFeatures *features;
- GstVideoGLTextureUploadMeta *meta;
- gboolean ret = TRUE;
- GstStructure *config;
- gsize size;
-
- features = gst_caps_get_features (in_caps, 0);
-
- if (!gst_caps_features_contains (features,
- GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META))
- ret = FALSE;
-
- features = gst_caps_get_features (out_caps, 0);
- if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
- ret = FALSE;
-
- if (!ret)
- return ret;
-
- if (upload->pool == NULL)
- upload->pool = gst_gl_buffer_pool_new (upload->upload->context);
-
- if (!gst_buffer_pool_is_active (upload->pool)) {
- config = gst_buffer_pool_get_config (upload->pool);
-
- size = upload->upload->priv->in_info.size;
- gst_buffer_pool_config_set_params (config, in_caps, size, 0, 0);
-
- if (!gst_buffer_pool_set_config (upload->pool, config)) {
- GST_WARNING_OBJECT (upload->upload, "failed to set bufferpool config");
- return FALSE;
- }
- gst_buffer_pool_set_active (upload->pool, TRUE);
- }
-
- if (buffer) {
- if ((meta = gst_buffer_get_video_gl_texture_upload_meta (buffer)) == NULL)
- return FALSE;
-
- if (meta->texture_type[0] != GST_VIDEO_GL_TEXTURE_TYPE_RGBA) {
- GST_FIXME_OBJECT (upload, "only single rgba texture supported");
- return FALSE;
- }
-
- if (meta->texture_orientation !=
- GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL) {
- GST_FIXME_OBJECT (upload, "only x-normal, y-normal textures supported");
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static void
-_upload_meta_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
- GstQuery * query)
-{
- struct GLUploadMeta *upload = impl;
- GstStructure *gl_context;
- gchar *platform, *gl_apis;
- gpointer handle;
-
- gl_apis =
- gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->upload->
- context));
- platform =
- gst_gl_platform_to_string (gst_gl_context_get_gl_platform (upload->
- upload->context));
- handle = (gpointer) gst_gl_context_get_gl_context (upload->upload->context);
-
- gl_context =
- gst_structure_new ("GstVideoGLTextureUploadMeta", "gst.gl.GstGLContext",
- GST_TYPE_GL_CONTEXT, upload->upload->context, "gst.gl.context.handle",
- G_TYPE_POINTER, handle, "gst.gl.context.type", G_TYPE_STRING, platform,
- "gst.gl.context.apis", G_TYPE_STRING, gl_apis, NULL);
- gst_query_add_allocation_meta (query,
- GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, gl_context);
-
- g_free (gl_apis);
- g_free (platform);
- gst_structure_free (gl_context);
-}
-
-/*
- * Uploads using gst_video_gl_texture_upload_meta_upload().
- * i.e. consumer of GstVideoGLTextureUploadMeta
- */
-static void
-_do_upload_with_meta (GstGLContext * context, struct GLUploadMeta *upload)
-{
- if (!gst_video_gl_texture_upload_meta_upload (upload->meta,
- upload->texture_ids)) {
- upload->result = FALSE;
- return;
- }
-
- upload->result = TRUE;
-}
-
-static GstGLUploadReturn
-_upload_meta_upload_perform (gpointer impl, GstBuffer * buffer,
- GstBuffer ** outbuf)
-{
- struct GLUploadMeta *upload = impl;
- int i;
- GstVideoInfo *in_info = &upload->upload->priv->in_info;
- guint max_planes = GST_VIDEO_INFO_N_PLANES (in_info);
-
- /* Support stereo views for separated multiview mode */
- if (GST_VIDEO_INFO_MULTIVIEW_MODE (in_info) ==
- GST_VIDEO_MULTIVIEW_MODE_SEPARATED)
- max_planes *= GST_VIDEO_INFO_VIEWS (in_info);
-
- GST_LOG_OBJECT (upload, "Attempting upload with GstVideoGLTextureUploadMeta");
-
- upload->meta = gst_buffer_get_video_gl_texture_upload_meta (buffer);
-
- if (gst_buffer_pool_acquire_buffer (upload->pool, outbuf,
- NULL) != GST_FLOW_OK) {
- GST_WARNING_OBJECT (upload, "failed to acquire buffer from bufferpool");
- return GST_GL_UPLOAD_ERROR;
- }
-
- for (i = 0; i < GST_GL_UPLOAD_MAX_PLANES; i++) {
- guint tex_id = 0;
-
- if (i < max_planes) {
- GstMemory *mem = gst_buffer_peek_memory (*outbuf, i);
- tex_id = ((GstGLMemory *) mem)->tex_id;
- }
-
- upload->texture_ids[i] = tex_id;
- }
-
- GST_LOG ("Uploading with GLTextureUploadMeta with textures "
- "%i,%i,%i,%i / %i,%i,%i,%i",
- upload->texture_ids[0], upload->texture_ids[1],
- upload->texture_ids[2], upload->texture_ids[3],
- upload->texture_ids[4], upload->texture_ids[5],
- upload->texture_ids[6], upload->texture_ids[7]);
-
- gst_gl_context_thread_add (upload->upload->context,
- (GstGLContextThreadFunc) _do_upload_with_meta, upload);
-
- if (!upload->result)
- return GST_GL_UPLOAD_ERROR;
-
- return GST_GL_UPLOAD_DONE;
-}
-
-static void
-_upload_meta_upload_free (gpointer impl)
-{
- struct GLUploadMeta *upload = impl;
-
- g_return_if_fail (impl != NULL);
-
- if (upload->pool)
- gst_object_unref (upload->pool);
-
- g_free (upload);
-}
-
-static GstStaticCaps _upload_meta_upload_caps =
-GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
- (GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, "RGBA"));
-
-static const UploadMethod _upload_meta_upload = {
- "UploadMeta",
- METHOD_FLAG_CAN_SHARE_CONTEXT,
- &_upload_meta_upload_caps,
- &_upload_meta_upload_new,
- &_upload_meta_upload_transform_caps,
- &_upload_meta_upload_accept,
- &_upload_meta_upload_propose_allocation,
- &_upload_meta_upload_perform,
- &_upload_meta_upload_free
-};
-
-struct RawUploadFrame
-{
- gint ref_count;
- GstVideoFrame frame;
-};
-
-struct RawUpload
-{
- GstGLUpload *upload;
- struct RawUploadFrame *in_frame;
- GstGLVideoAllocationParams *params;
-};
-
-static struct RawUploadFrame *
-_raw_upload_frame_new (struct RawUpload *raw, GstBuffer * buffer)
-{
- struct RawUploadFrame *frame;
- GstVideoInfo *info;
- gint i;
-
- if (!buffer)
- return NULL;
-
- frame = g_slice_new (struct RawUploadFrame);
- frame->ref_count = 1;
-
- if (!gst_video_frame_map (&frame->frame, &raw->upload->priv->in_info,
- buffer, GST_MAP_READ)) {
- g_slice_free (struct RawUploadFrame, frame);
- return NULL;
- }
-
- raw->upload->priv->in_info = frame->frame.info;
- info = &raw->upload->priv->in_info;
-
- /* Recalculate the offsets (and size) */
- info->size = 0;
- for (i = 0; i < GST_VIDEO_INFO_N_PLANES (info); i++) {
- info->offset[i] = info->size;
- info->size += gst_gl_get_plane_data_size (info, NULL, i);
- }
-
- return frame;
-}
-
-static void
-_raw_upload_frame_ref (struct RawUploadFrame *frame)
-{
- g_atomic_int_inc (&frame->ref_count);
-}
-
-static void
-_raw_upload_frame_unref (struct RawUploadFrame *frame)
-{
- if (g_atomic_int_dec_and_test (&frame->ref_count)) {
- gst_video_frame_unmap (&frame->frame);
- g_slice_free (struct RawUploadFrame, frame);
- }
-}
-
-static gpointer
-_raw_data_upload_new (GstGLUpload * upload)
-{
- struct RawUpload *raw = g_new0 (struct RawUpload, 1);
-
- raw->upload = upload;
-
- return raw;
-}
-
-static GstCaps *
-_raw_data_upload_transform_caps (gpointer impl, GstGLContext * context,
- GstPadDirection direction, GstCaps * caps)
-{
- GstCapsFeatures *passthrough =
- gst_caps_features_from_string
- (GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
- GstCaps *ret;
-
- if (direction == GST_PAD_SINK) {
- GstGLTextureTarget target_mask = 0;
- GstCaps *tmp;
-
- ret =
- _set_caps_features_with_passthrough (caps,
- GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
-
- target_mask |= 1 << GST_GL_TEXTURE_TARGET_2D;
- target_mask |= 1 << GST_GL_TEXTURE_TARGET_RECTANGLE;
- tmp = _caps_intersect_texture_target (ret, target_mask);
- gst_caps_unref (ret);
- ret = tmp;
- } else {
- gint i, n;
-
- ret =
- _set_caps_features_with_passthrough (caps,
- GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY, passthrough);
-
- n = gst_caps_get_size (ret);
- for (i = 0; i < n; i++) {
- GstStructure *s = gst_caps_get_structure (ret, i);
-
- gst_structure_remove_fields (s, "texture-target", NULL);
- }
- }
-
- gst_caps_features_free (passthrough);
-
- return ret;
-}
-
-static gboolean
-_raw_data_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
- GstCaps * out_caps)
-{
- struct RawUpload *raw = impl;
- GstCapsFeatures *features;
-
- features = gst_caps_get_features (out_caps, 0);
- if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
- return FALSE;
-
- if (raw->in_frame)
- _raw_upload_frame_unref (raw->in_frame);
- raw->in_frame = _raw_upload_frame_new (raw, buffer);
-
- if (raw->params)
- gst_gl_allocation_params_free ((GstGLAllocationParams *) raw->params);
- if (!(raw->params =
- gst_gl_video_allocation_params_new_wrapped_data (raw->upload->context,
- NULL, &raw->upload->priv->in_info, -1, NULL,
- GST_GL_TEXTURE_TARGET_2D, 0, NULL, raw->in_frame,
- (GDestroyNotify) _raw_upload_frame_unref)))
- return FALSE;
-
- return (raw->in_frame != NULL);
-}
-
-static void
-_raw_data_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
- GstQuery * query)
-{
- gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, 0);
-}
-
-static GstGLUploadReturn
-_raw_data_upload_perform (gpointer impl, GstBuffer * buffer,
- GstBuffer ** outbuf)
-{
- GstGLBaseMemoryAllocator *allocator;
- struct RawUpload *raw = impl;
- int i;
- GstVideoInfo *in_info = &raw->upload->priv->in_info;
- guint n_mem = GST_VIDEO_INFO_N_PLANES (in_info);
-
- allocator =
- GST_GL_BASE_MEMORY_ALLOCATOR (gst_gl_memory_allocator_get_default
- (raw->upload->context));
-
- /* FIXME Use a buffer pool to cache the generated textures */
- /* FIXME: multiview support with separated left/right frames? */
- *outbuf = gst_buffer_new ();
- for (i = 0; i < n_mem; i++) {
- GstGLBaseMemory *tex;
-
- raw->params->parent.wrapped_data = raw->in_frame->frame.data[i];
- raw->params->plane = i;
- raw->params->tex_format =
- gst_gl_format_from_video_info (raw->upload->context, in_info, i);
-
- tex =
- gst_gl_base_memory_alloc (allocator,
- (GstGLAllocationParams *) raw->params);
- if (!tex) {
- gst_buffer_unref (*outbuf);
- *outbuf = NULL;
- GST_ERROR_OBJECT (raw->upload, "Failed to allocate wrapped texture");
- return GST_GL_UPLOAD_ERROR;
- }
-
- _raw_upload_frame_ref (raw->in_frame);
- gst_buffer_append_memory (*outbuf, (GstMemory *) tex);
- }
- gst_object_unref (allocator);
-
- _raw_upload_frame_unref (raw->in_frame);
- raw->in_frame = NULL;
- return GST_GL_UPLOAD_DONE;
-}
-
-static void
-_raw_data_upload_free (gpointer impl)
-{
- struct RawUpload *raw = impl;
-
- if (raw->params)
- gst_gl_allocation_params_free ((GstGLAllocationParams *) raw->params);
-
- g_free (raw);
-}
-
-static GstStaticCaps _raw_data_upload_caps =
-GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_GL_MEMORY_VIDEO_FORMATS_STR));
-
-static const UploadMethod _raw_data_upload = {
- "Raw Data",
- 0,
- &_raw_data_upload_caps,
- &_raw_data_upload_new,
- &_raw_data_upload_transform_caps,
- &_raw_data_upload_accept,
- &_raw_data_upload_propose_allocation,
- &_raw_data_upload_perform,
- &_raw_data_upload_free
-};
-
-#if GST_GL_HAVE_VIV_DIRECTVIV
-#ifndef GL_BGRA_EXT
-#define GL_BGRA_EXT 0x80E1
-#endif
-#ifndef GL_VIV_YV12
-#define GL_VIV_YV12 0x8FC0
-#endif
-#ifndef GL_VIV_NV12
-#define GL_VIV_NV12 0x8FC1
-#endif
-#ifndef GL_VIV_YUY2
-#define GL_VIV_YUY2 0x8FC2
-#endif
-#ifndef GL_VIV_UYVY
-#define GL_VIV_UYVY 0x8FC3
-#endif
-#ifndef GL_VIV_NV21
-#define GL_VIV_NV21 0x8FC4
-#endif
-#ifndef GL_VIV_I420
-#define GL_VIV_I420 0x8FC5
-#endif
-
-struct DirectVIVUpload
-{
- GstGLUpload *upload;
-
- GstGLVideoAllocationParams *params;
- GstBuffer *inbuf, *outbuf;
- void (*TexDirectVIVMap) (GLenum Target, GLsizei Width, GLsizei Height,
- GLenum Format, GLvoid ** Logical, const GLuint * Physical);
- void (*TexDirectInvalidateVIV) (GLenum Target);
- gboolean loaded_functions;
-};
-
-#define GST_GL_DIRECTVIV_FORMAT "{RGBA, I420, YV12, NV12, NV21, YUY2, UYVY, BGRA, RGB16}"
-
-static GstStaticCaps _directviv_upload_caps =
-GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_GL_DIRECTVIV_FORMAT));
-
-static gpointer
-_directviv_upload_new (GstGLUpload * upload)
-{
- struct DirectVIVUpload *directviv = g_new0 (struct DirectVIVUpload, 1);
- directviv->upload = upload;
- directviv->loaded_functions = FALSE;
-
- return directviv;
-}
-
-static GstCaps *
-_directviv_upload_transform_caps (gpointer impl, GstGLContext * context,
- GstPadDirection direction, GstCaps * caps)
-{
- GstCapsFeatures *passthrough =
- gst_caps_features_from_string
- (GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
- GstCaps *ret;
-
- if (direction == GST_PAD_SINK) {
- GstCaps *tmp;
-
- ret =
- _set_caps_features_with_passthrough (caps,
- GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
-
- gst_caps_set_simple (ret, "format", G_TYPE_STRING, "RGBA", NULL);
- tmp = _caps_intersect_texture_target (ret, 1 << GST_GL_TEXTURE_TARGET_2D);
- gst_caps_unref (ret);
- ret = tmp;
- } else {
- GstCaps *tmp;
- tmp = gst_caps_from_string (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
- (GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY, GST_GL_DIRECTVIV_FORMAT));
- ret =
- _set_caps_features_with_passthrough (tmp,
- GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY, passthrough);
- gst_caps_unref (tmp);
- }
-
- gst_caps_features_free (passthrough);
- return ret;
-}
-
-
-static void
-_directviv_upload_load_functions_gl_thread (GstGLContext * context,
- struct DirectVIVUpload *directviv)
-{
- directviv->TexDirectVIVMap =
- gst_gl_context_get_proc_address (context, "glTexDirectVIVMap");
- directviv->TexDirectInvalidateVIV =
- gst_gl_context_get_proc_address (context, "glTexDirectInvalidateVIV");
-}
-
-static gboolean
-_directviv_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
- GstCaps * out_caps)
-{
- struct DirectVIVUpload *directviv = impl;
- GstCapsFeatures *features;
- guint n_mem;
- GstMemory *mem;
-
- if (!directviv->loaded_functions && (!directviv->TexDirectInvalidateVIV ||
- !directviv->TexDirectVIVMap)) {
- gst_gl_context_thread_add (directviv->upload->context,
- (GstGLContextThreadFunc) _directviv_upload_load_functions_gl_thread,
- directviv);
- directviv->loaded_functions = TRUE;
- }
- if (!directviv->TexDirectInvalidateVIV || !directviv->TexDirectVIVMap)
- return FALSE;
-
- features = gst_caps_get_features (out_caps, 0);
- if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
- return FALSE;
-
- if (directviv->params)
- gst_gl_allocation_params_free ((GstGLAllocationParams *) directviv->params);
- if (!(directviv->params =
- gst_gl_video_allocation_params_new (directviv->upload->context, NULL,
- &directviv->upload->priv->out_info, -1, NULL,
- GST_GL_TEXTURE_TARGET_2D, GST_VIDEO_GL_TEXTURE_TYPE_RGBA)))
- return FALSE;
-
- /* We only support a single memory per buffer at this point */
- n_mem = gst_buffer_n_memory (buffer);
- if (n_mem == 1) {
- mem = gst_buffer_peek_memory (buffer, 0);
- } else {
- mem = NULL;
- }
-
- return n_mem == 1 && mem && gst_is_phys_memory (mem);
-}
-
-static void
-_directviv_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
- GstQuery * query)
-{
-}
-
-static GLenum
-_directviv_upload_video_format_to_gl_format (GstVideoFormat format)
-{
- switch (format) {
- case GST_VIDEO_FORMAT_I420:
- return GL_VIV_I420;
- case GST_VIDEO_FORMAT_YV12:
- return GL_VIV_YV12;
- case GST_VIDEO_FORMAT_NV12:
- return GL_VIV_NV12;
- case GST_VIDEO_FORMAT_NV21:
- return GL_VIV_NV21;
- case GST_VIDEO_FORMAT_YUY2:
- return GL_VIV_YUY2;
- case GST_VIDEO_FORMAT_UYVY:
- return GL_VIV_UYVY;
- case GST_VIDEO_FORMAT_RGB16:
- return GL_RGB565;
- case GST_VIDEO_FORMAT_RGBA:
- return GL_RGBA;
- case GST_VIDEO_FORMAT_BGRA:
- return GL_BGRA_EXT;
- case GST_VIDEO_FORMAT_RGBx:
- return GL_RGBA;
- case GST_VIDEO_FORMAT_BGRx:
- return GL_BGRA_EXT;
- default:
- return 0;
- }
-}
-
-typedef struct
-{
- GstBuffer *buffer;
- GstMemory *memory;
- GstMapInfo map;
- guintptr phys_addr;
-} DirectVIVUnmapData;
-
-static void
-_directviv_memory_unmap (DirectVIVUnmapData * data)
-{
- gst_memory_unmap (data->memory, &data->map);
- gst_memory_unref (data->memory);
- gst_buffer_unref (data->buffer);
- g_free (data);
-}
-
-static void
-_directviv_upload_perform_gl_thread (GstGLContext * context,
- struct DirectVIVUpload *directviv)
-{
- static GQuark directviv_unmap_quark = 0;
- GstGLMemoryAllocator *allocator;
- GstMemory *in_mem;
- GstGLMemory *out_gl_mem;
- GstVideoInfo *in_info;
- DirectVIVUnmapData *unmap_data;
- GstVideoMeta *vmeta;
- gint width, height, gl_format;
- const GstGLFuncs *gl;
-
- if (!directviv_unmap_quark)
- directviv_unmap_quark = g_quark_from_static_string ("GstGLDirectVIVUnmap");
-
- gl = context->gl_vtable;
-
- g_assert (gst_buffer_n_memory (directviv->inbuf) == 1);
- in_info = &directviv->upload->priv->in_info;
- in_mem = gst_buffer_peek_memory (directviv->inbuf, 0);
- unmap_data = g_new0 (DirectVIVUnmapData, 1);
- if (!gst_memory_map (in_mem, &unmap_data->map, GST_MAP_READ)) {
- g_free (unmap_data);
- return;
- }
- unmap_data->phys_addr = gst_phys_memory_get_phys_addr (in_mem);
- if (!unmap_data->phys_addr) {
- gst_memory_unmap (in_mem, &unmap_data->map);
- g_free (unmap_data);
- return;
- }
- unmap_data->memory = gst_memory_ref (in_mem);
- unmap_data->buffer = gst_buffer_ref (directviv->inbuf);
-
- allocator =
- GST_GL_MEMORY_ALLOCATOR (gst_allocator_find
- (GST_GL_MEMORY_PBO_ALLOCATOR_NAME));
-
- /* FIXME: buffer pool */
- directviv->outbuf = gst_buffer_new ();
- gst_gl_memory_setup_buffer (allocator, directviv->outbuf, directviv->params,
- NULL, NULL, 0);
- gst_object_unref (allocator);
-
- out_gl_mem = (GstGLMemory *) gst_buffer_peek_memory (directviv->outbuf, 0);
-
- /* Need to keep the input memory and buffer mapped and valid until
- * the GL memory is not used anymore */
- gst_mini_object_set_qdata ((GstMiniObject *) out_gl_mem,
- directviv_unmap_quark, unmap_data,
- (GDestroyNotify) _directviv_memory_unmap);
- gst_buffer_add_parent_buffer_meta (directviv->outbuf, directviv->inbuf);
-
- /* width/height need to compensate for stride/padding */
- vmeta = gst_buffer_get_video_meta (directviv->inbuf);
- if (vmeta) {
- width = vmeta->stride[0];
- if (GST_VIDEO_INFO_N_PLANES (in_info) == 1)
- height = gst_memory_get_sizes (in_mem, NULL, NULL) / width;
- else
- height = vmeta->offset[1] / width;
- } else {
- width = GST_VIDEO_INFO_PLANE_STRIDE (in_info, 0);
- if (GST_VIDEO_INFO_N_PLANES (in_info) == 1)
- height = gst_memory_get_sizes (in_mem, NULL, NULL) / width;
- else
- height = GST_VIDEO_INFO_PLANE_OFFSET (in_info, 1) / width;
- }
- width /= GST_VIDEO_INFO_COMP_PSTRIDE (in_info, 0);
-
- gl_format =
- _directviv_upload_video_format_to_gl_format (GST_VIDEO_INFO_FORMAT
- (in_info));
-
- gl->BindTexture (GL_TEXTURE_2D, out_gl_mem->tex_id);
- directviv->TexDirectVIVMap (GL_TEXTURE_2D, width, height,
- gl_format, (void **) &unmap_data->map.data, &unmap_data->phys_addr);
- directviv->TexDirectInvalidateVIV (GL_TEXTURE_2D);
-}
-
-static GstGLUploadReturn
-_directviv_upload_perform (gpointer impl, GstBuffer * buffer,
- GstBuffer ** outbuf)
-{
- struct DirectVIVUpload *directviv = impl;
-
- directviv->inbuf = buffer;
- directviv->outbuf = NULL;
- gst_gl_context_thread_add (directviv->upload->context,
- (GstGLContextThreadFunc) _directviv_upload_perform_gl_thread, directviv);
- directviv->inbuf = NULL;
-
- if (!directviv->outbuf)
- return GST_GL_UPLOAD_ERROR;
-
- *outbuf = directviv->outbuf;
- directviv->outbuf = NULL;
-
- return GST_GL_UPLOAD_DONE;
-}
-
-static void
-_directviv_upload_free (gpointer impl)
-{
- struct DirectVIVUpload *directviv = impl;
-
- if (directviv->params)
- gst_gl_allocation_params_free ((GstGLAllocationParams *) directviv->params);
-
- g_free (impl);
-}
-
-static const UploadMethod _directviv_upload = {
- "DirectVIV",
- 0,
- &_directviv_upload_caps,
- &_directviv_upload_new,
- &_directviv_upload_transform_caps,
- &_directviv_upload_accept,
- &_directviv_upload_propose_allocation,
- &_directviv_upload_perform,
- &_directviv_upload_free
-};
-
-#endif /* GST_GL_HAVE_VIV_DIRECTVIV */
-
-static const UploadMethod *upload_methods[] = { &_gl_memory_upload,
-#if GST_GL_HAVE_DMABUF
- &_dma_buf_upload,
-#endif
-#if GST_GL_HAVE_VIV_DIRECTVIV
- &_directviv_upload,
-#endif
- &_upload_meta_upload, &_raw_data_upload
-};
-
-static GMutex upload_global_lock;
-
-GstCaps *
-gst_gl_upload_get_input_template_caps (void)
-{
- GstCaps *ret = NULL;
- gint i;
-
- g_mutex_lock (&upload_global_lock);
-
- /* FIXME: cache this and invalidate on changes to upload_methods */
- for (i = 0; i < G_N_ELEMENTS (upload_methods); i++) {
- GstCaps *template =
- gst_static_caps_get (upload_methods[i]->input_template_caps);
- ret = ret == NULL ? template : gst_caps_merge (ret, template);
- }
-
- ret = gst_caps_simplify (ret);
- ret = gst_gl_overlay_compositor_add_caps (ret);
- g_mutex_unlock (&upload_global_lock);
-
- return ret;
-}
-
-static void
-gst_gl_upload_class_init (GstGLUploadClass * klass)
-{
- g_type_class_add_private (klass, sizeof (GstGLUploadPrivate));
-
- G_OBJECT_CLASS (klass)->finalize = gst_gl_upload_finalize;
-}
-
-static void
-gst_gl_upload_init (GstGLUpload * upload)
-{
- upload->priv = GST_GL_UPLOAD_GET_PRIVATE (upload);
-}
-
-/**
- * gst_gl_upload_new:
- * @context: a #GstGLContext
- *
- * Returns: (transfer full): a new #GstGLUpload object
- */
-GstGLUpload *
-gst_gl_upload_new (GstGLContext * context)
-{
- GstGLUpload *upload = g_object_new (GST_TYPE_GL_UPLOAD, NULL);
- gint i, n;
-
- gst_object_ref_sink (upload);
-
- if (context)
- gst_gl_upload_set_context (upload, context);
- else
- upload->context = NULL;
-
- n = G_N_ELEMENTS (upload_methods);
- upload->priv->upload_impl = g_malloc (sizeof (gpointer) * n);
- for (i = 0; i < n; i++) {
- upload->priv->upload_impl[i] = upload_methods[i]->new (upload);
- }
-
- GST_DEBUG_OBJECT (upload, "Created new GLUpload for context %" GST_PTR_FORMAT,
- context);
-
- return upload;
-}
-
-void
-gst_gl_upload_set_context (GstGLUpload * upload, GstGLContext * context)
-{
- g_return_if_fail (upload != NULL);
-
- gst_object_replace ((GstObject **) & upload->context, (GstObject *) context);
-}
-
-static void
-gst_gl_upload_finalize (GObject * object)
-{
- GstGLUpload *upload;
- gint i, n;
-
- upload = GST_GL_UPLOAD (object);
-
- upload->priv->method_i = 0;
-
- if (upload->context) {
- gst_object_unref (upload->context);
- upload->context = NULL;
- }
-
- if (upload->priv->in_caps) {
- gst_caps_unref (upload->priv->in_caps);
- upload->priv->in_caps = NULL;
- }
-
- if (upload->priv->out_caps) {
- gst_caps_unref (upload->priv->out_caps);
- upload->priv->out_caps = NULL;
- }
-
- n = G_N_ELEMENTS (upload_methods);
- for (i = 0; i < n; i++) {
- if (upload->priv->upload_impl[i])
- upload_methods[i]->free (upload->priv->upload_impl[i]);
- }
- g_free (upload->priv->upload_impl);
-
- G_OBJECT_CLASS (gst_gl_upload_parent_class)->finalize (object);
-}
-
-GstCaps *
-gst_gl_upload_transform_caps (GstGLUpload * upload, GstGLContext * context,
- GstPadDirection direction, GstCaps * caps, GstCaps * filter)
-{
- GstCaps *result, *tmp;
- gint i;
-
- tmp = gst_caps_new_empty ();
-
- for (i = 0; i < G_N_ELEMENTS (upload_methods); i++) {
- GstCaps *tmp2;
-
- tmp2 =
- upload_methods[i]->transform_caps (upload->priv->upload_impl[i],
- context, direction, caps);
-
- if (tmp2)
- tmp = gst_caps_merge (tmp, tmp2);
- }
-
- if (filter) {
- result = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST);
- gst_caps_unref (tmp);
- } else {
- result = tmp;
- }
-
- return result;
-}
-
-/**
- * gst_gl_upload_propose_allocation:
- * @upload: a #GstGLUpload
- * @decide_query: (allow-none): a #GstQuery from a decide allocation
- * @query: the proposed allocation query
- *
- * Adds the required allocation parameters to support uploading.
- */
-void
-gst_gl_upload_propose_allocation (GstGLUpload * upload, GstQuery * decide_query,
- GstQuery * query)
-{
- gint i;
-
- for (i = 0; i < G_N_ELEMENTS (upload_methods); i++)
- upload_methods[i]->propose_allocation (upload->priv->upload_impl[i],
- decide_query, query);
-}
-
-static gboolean
-_gst_gl_upload_set_caps_unlocked (GstGLUpload * upload, GstCaps * in_caps,
- GstCaps * out_caps)
-{
- g_return_val_if_fail (upload != NULL, FALSE);
- g_return_val_if_fail (gst_caps_is_fixed (in_caps), FALSE);
-
- if (upload->priv->in_caps && upload->priv->out_caps
- && gst_caps_is_equal (upload->priv->in_caps, in_caps)
- && gst_caps_is_equal (upload->priv->out_caps, out_caps))
- return TRUE;
-
- gst_caps_replace (&upload->priv->in_caps, in_caps);
- gst_caps_replace (&upload->priv->out_caps, out_caps);
-
- gst_video_info_from_caps (&upload->priv->in_info, in_caps);
- gst_video_info_from_caps (&upload->priv->out_info, out_caps);
-
- upload->priv->method_impl = NULL;
- upload->priv->method_i = 0;
-
- return TRUE;
-}
-
-/**
- * gst_gl_upload_set_caps:
- * @upload: a #GstGLUpload
- * @in_caps: input #GstCaps
- * @out_caps: output #GstCaps
- *
- * Initializes @upload with the information required for upload.
- *
- * Returns: whether @in_caps and @out_caps could be set on @upload
- */
-gboolean
-gst_gl_upload_set_caps (GstGLUpload * upload, GstCaps * in_caps,
- GstCaps * out_caps)
-{
- gboolean ret;
-
- GST_OBJECT_LOCK (upload);
- ret = _gst_gl_upload_set_caps_unlocked (upload, in_caps, out_caps);
- GST_OBJECT_UNLOCK (upload);
-
- return ret;
-}
-
-/**
- * gst_gl_upload_get_caps:
- * @upload: a #GstGLUpload
- * @in_caps: (transfer full) (allow-none) (out): the input #GstCaps
- * @out_caps: (transfer full) (allow-none) (out): the output #GstCaps
- */
-void
-gst_gl_upload_get_caps (GstGLUpload * upload, GstCaps ** in_caps,
- GstCaps ** out_caps)
-{
- GST_OBJECT_LOCK (upload);
- if (in_caps)
- *in_caps =
- upload->priv->in_caps ? gst_caps_ref (upload->priv->in_caps) : NULL;
- if (out_caps)
- *out_caps =
- upload->priv->out_caps ? gst_caps_ref (upload->priv->out_caps) : NULL;
- GST_OBJECT_UNLOCK (upload);
-}
-
-static gboolean
-_upload_find_method (GstGLUpload * upload)
-{
- gint method_i;
-
- if (upload->priv->method_i >= G_N_ELEMENTS (upload_methods))
- return FALSE;
-
- method_i = upload->priv->method_i;
- upload->priv->method = upload_methods[method_i];
- upload->priv->method_impl = upload->priv->upload_impl[method_i];
-
- GST_DEBUG_OBJECT (upload, "attempting upload with uploader %s",
- upload->priv->method->name);
-
- upload->priv->method_i++;
-
- return TRUE;
-}
-
-/**
- * gst_gl_upload_perform_with_buffer:
- * @upload: a #GstGLUpload
- * @buffer: input #GstBuffer
- * @outbuf_ptr: resulting #GstBuffer
- *
- * Uploads @buffer using the transformation specified by
- * gst_gl_upload_set_caps() creating a new #GstBuffer in @outbuf_ptr.
- *
- * Returns: whether the upload was successful
- */
-GstGLUploadReturn
-gst_gl_upload_perform_with_buffer (GstGLUpload * upload, GstBuffer * buffer,
- GstBuffer ** outbuf_ptr)
-{
- GstGLUploadReturn ret = GST_GL_UPLOAD_ERROR;
- GstBuffer *outbuf;
-
- g_return_val_if_fail (GST_IS_GL_UPLOAD (upload), FALSE);
- g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
- g_return_val_if_fail (outbuf_ptr != NULL, FALSE);
-
- GST_OBJECT_LOCK (upload);
-
-#define NEXT_METHOD \
-do { \
- if (!_upload_find_method (upload)) { \
- GST_OBJECT_UNLOCK (upload); \
- return FALSE; \
- } \
- goto restart; \
-} while (0)
-
- if (!upload->priv->method_impl)
- _upload_find_method (upload);
-
-restart:
- if (!upload->priv->method->accept (upload->priv->method_impl, buffer,
- upload->priv->in_caps, upload->priv->out_caps))
- NEXT_METHOD;
-
- ret =
- upload->priv->method->perform (upload->priv->method_impl, buffer,
- &outbuf);
- if (ret == GST_GL_UPLOAD_UNSHARED_GL_CONTEXT) {
- gint i;
-
- for (i = 0; i < G_N_ELEMENTS (upload_methods); i++) {
- if (upload_methods[i] == &_raw_data_upload) {
- upload->priv->method = &_raw_data_upload;
- upload->priv->method_impl = upload->priv->upload_impl[i];
- upload->priv->method_i = i;
-
- break;
- }
- }
- goto restart;
- } else if (ret == GST_GL_UPLOAD_DONE || ret == GST_GL_UPLOAD_RECONFIGURE) {
- /* we are done */
- } else {
- upload->priv->method_impl = NULL;
- NEXT_METHOD;
- }
-
- if (outbuf && buffer != outbuf)
- gst_buffer_copy_into (outbuf, buffer,
- GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
- *outbuf_ptr = outbuf;
-
- GST_OBJECT_UNLOCK (upload);
-
- return ret;
-
-#undef NEXT_METHOD
-}
diff --git a/gst-libs/gst/gl/gstglupload.h b/gst-libs/gst/gl/gstglupload.h
deleted file mode 100644
index c672fe5e0..000000000
--- a/gst-libs/gst/gl/gstglupload.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystree00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_UPLOAD_H__
-#define __GST_GL_UPLOAD_H__
-
-#include <gst/video/video.h>
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GType gst_gl_upload_get_type (void);
-#define GST_TYPE_GL_UPLOAD (gst_gl_upload_get_type())
-#define GST_GL_UPLOAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_UPLOAD,GstGLUpload))
-#define GST_GL_UPLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_UPLOAD,GstGLUploadClass))
-#define GST_IS_GL_UPLOAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_UPLOAD))
-#define GST_IS_GL_UPLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_UPLOAD))
-#define GST_GL_UPLOAD_CAST(obj) ((GstGLUpload*)(obj))
-
-/**
- * GstGLUploadReturn:
- * @GST_GL_UPLOAD_DONE: No further processing required
- * @GST_GL_UPLOAD_ERROR: An unspecified error occured
- * @GST_GL_UPLOAD_UNSUPPORTED: The configuration is unsupported.
- * @GST_GL_UPLOAD_RECONFIGURE: This element requires a reconfiguration.
- */
-typedef enum
-{
- GST_GL_UPLOAD_DONE = 1,
-
- GST_GL_UPLOAD_ERROR = -1,
- GST_GL_UPLOAD_UNSUPPORTED = -2,
- GST_GL_UPLOAD_RECONFIGURE = -3,
- /* <private> */
- GST_GL_UPLOAD_UNSHARED_GL_CONTEXT = -100,
-} GstGLUploadReturn;
-
-/**
- * GstGLUpload
- *
- * Opaque #GstGLUpload object
- */
-struct _GstGLUpload
-{
- GstObject parent;
-
- GstGLContext *context;
-
- /* <private> */
- GstGLUploadPrivate *priv;
-
- gpointer _reserved[GST_PADDING];
-};
-
-/**
- * GstGLUploadClass:
- *
- * The #GstGLUploadClass struct only contains private data
- */
-struct _GstGLUploadClass
-{
- GstObjectClass object_class;
-
- /* <private> */
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GstCaps * gst_gl_upload_get_input_template_caps (void);
-
-GST_EXPORT
-GstGLUpload * gst_gl_upload_new (GstGLContext * context);
-
-GST_EXPORT
-void gst_gl_upload_set_context (GstGLUpload * upload,
- GstGLContext * context);
-
-GST_EXPORT
-GstCaps * gst_gl_upload_transform_caps (GstGLUpload * upload,
- GstGLContext * context,
- GstPadDirection direction,
- GstCaps * caps,
- GstCaps * filter);
-GST_EXPORT
-gboolean gst_gl_upload_set_caps (GstGLUpload * upload,
- GstCaps * in_caps,
- GstCaps * out_caps);
-GST_EXPORT
-void gst_gl_upload_get_caps (GstGLUpload * upload,
- GstCaps ** in_caps,
- GstCaps ** out_caps);
-GST_EXPORT
-void gst_gl_upload_propose_allocation (GstGLUpload * upload,
- GstQuery * decide_query,
- GstQuery * query);
-
-GST_EXPORT
-GstGLUploadReturn gst_gl_upload_perform_with_buffer (GstGLUpload * upload,
- GstBuffer * buffer,
- GstBuffer ** outbuf_ptr);
-
-G_END_DECLS
-
-#endif /* __GST_GL_UPLOAD_H__ */
diff --git a/gst-libs/gst/gl/gstglutils.c b/gst-libs/gst/gl/gstglutils.c
deleted file mode 100644
index 8310c415f..000000000
--- a/gst-libs/gst/gl/gstglutils.c
+++ /dev/null
@@ -1,874 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstglutils
- * @title: GstGLUtils
- * @short_description: some miscellaneous utilities for OpenGL
- * @see_also: #GstGLContext
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-
-#include <gst/gst.h>
-#include <glib/gprintf.h>
-
-#include "gl.h"
-#include "gstglutils.h"
-#include "gstglutils_private.h"
-
-#if GST_GL_HAVE_WINDOW_X11
-#include <gst/gl/x11/gstgldisplay_x11.h>
-#endif
-#if GST_GL_HAVE_WINDOW_WAYLAND
-#include <gst/gl/wayland/gstgldisplay_wayland.h>
-#endif
-
-#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
-#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
-#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
-#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
-#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-
-#ifndef GST_DISABLE_GST_DEBUG
-GST_DEBUG_CATEGORY_STATIC (gst_gl_utils_debug);
-static GstDebugCategory *
-_init_gl_utils_debug_category (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- GST_DEBUG_CATEGORY_INIT (gst_gl_utils_debug, "glutils", 0,
- "OpenGL Utilities");
- g_once_init_leave (&_init, 1);
- }
-
- return gst_gl_utils_debug;
-}
-
-#define GST_CAT_DEFAULT _init_gl_utils_debug_category()
-#endif
-
-static gboolean
-gst_gl_display_found (GstElement * element, GstGLDisplay * display)
-{
- if (display) {
- GST_LOG_OBJECT (element, "already have a display (%p)", display);
- return TRUE;
- }
-
- return FALSE;
-}
-
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT);
-
-static void
-_init_context_debug (void)
-{
-#ifndef GST_DISABLE_GST_DEBUG
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- GST_DEBUG_CATEGORY_GET (GST_CAT_CONTEXT, "GST_CONTEXT");
- g_once_init_leave (&_init, 1);
- }
-#endif
-}
-
-static gboolean
-pad_query (const GValue * item, GValue * value, gpointer user_data)
-{
- GstPad *pad = g_value_get_object (item);
- GstQuery *query = user_data;
- gboolean res;
-
- _init_context_debug ();
-
- res = gst_pad_peer_query (pad, query);
-
- if (res) {
- g_value_set_boolean (value, TRUE);
- return FALSE;
- }
-
- GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, pad, "pad peer query failed");
- return TRUE;
-}
-
-gboolean
-gst_gl_run_query (GstElement * element, GstQuery * query,
- GstPadDirection direction)
-{
- GstIterator *it;
- GstIteratorFoldFunction func = pad_query;
- GValue res = { 0 };
-
- g_value_init (&res, G_TYPE_BOOLEAN);
- g_value_set_boolean (&res, FALSE);
-
- /* Ask neighbor */
- if (direction == GST_PAD_SRC)
- it = gst_element_iterate_src_pads (element);
- else
- it = gst_element_iterate_sink_pads (element);
-
- while (gst_iterator_fold (it, func, &res, query) == GST_ITERATOR_RESYNC)
- gst_iterator_resync (it);
-
- gst_iterator_free (it);
-
- return g_value_get_boolean (&res);
-}
-
-static void
-_gst_context_query (GstElement * element, const gchar * display_type)
-{
- GstQuery *query;
- GstContext *ctxt;
-
- _init_context_debug ();
-
- /* 2a) Query downstream with GST_QUERY_CONTEXT for the context and
- * check if downstream already has a context of the specific type
- * 2b) Query upstream as above.
- */
- query = gst_query_new_context (display_type);
- if (gst_gl_run_query (element, query, GST_PAD_SRC)) {
- gst_query_parse_context (query, &ctxt);
- GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element,
- "found context (%p) in downstream query", ctxt);
- gst_element_set_context (element, ctxt);
- } else if (gst_gl_run_query (element, query, GST_PAD_SINK)) {
- gst_query_parse_context (query, &ctxt);
- GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element,
- "found context (%p) in upstream query", ctxt);
- gst_element_set_context (element, ctxt);
- } else {
- /* 3) Post a GST_MESSAGE_NEED_CONTEXT message on the bus with
- * the required context type and afterwards check if a
- * usable context was set now as in 1). The message could
- * be handled by the parent bins of the element and the
- * application.
- */
- GstMessage *msg;
-
- GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element,
- "posting need context message");
- msg = gst_message_new_need_context (GST_OBJECT_CAST (element),
- display_type);
- gst_element_post_message (element, msg);
- }
-
- /*
- * Whomever responds to the need-context message performs a
- * GstElement::set_context() with the required context in which the element
- * is required to update the display_ptr or call gst_gl_handle_set_context().
- */
-
- gst_query_unref (query);
-}
-
-static void
-gst_gl_display_context_query (GstElement * element, GstGLDisplay ** display_ptr)
-{
- _gst_context_query (element, GST_GL_DISPLAY_CONTEXT_TYPE);
- if (*display_ptr)
- return;
-
-#if GST_GL_HAVE_WINDOW_X11
- _gst_context_query (element, "gst.x11.display.handle");
- if (*display_ptr)
- return;
-#endif
-
-#if GST_GL_HAVE_WINDOW_WAYLAND
- _gst_context_query (element, "GstWaylandDisplayHandleContextType");
- if (*display_ptr)
- return;
-#endif
-}
-
-static void
-gst_gl_context_query (GstElement * element)
-{
- _gst_context_query (element, "gst.gl.app_context");
-}
-
-/* 4) Create a context by itself and post a GST_MESSAGE_HAVE_CONTEXT
- * message.
- */
-void
-gst_gl_element_propagate_display_context (GstElement * element,
- GstGLDisplay * display)
-{
- GstContext *context;
- GstMessage *msg;
-
- if (!display) {
- GST_ERROR_OBJECT (element, "Could not get GL display connection");
- return;
- }
-
- _init_context_debug ();
-
- context = gst_context_new (GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
- gst_context_set_gl_display (context, display);
-
- gst_element_set_context (element, context);
-
- GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element,
- "posting have context (%p) message with display (%p)", context, display);
- msg = gst_message_new_have_context (GST_OBJECT_CAST (element), context);
- gst_element_post_message (GST_ELEMENT_CAST (element), msg);
-}
-
-/**
- * gst_gl_ensure_element_data:
- * @element: the #GstElement running the query
- * @display_ptr: (inout): the resulting #GstGLDisplay
- * @other_context_ptr: (inout): the resulting #GstGLContext
- *
- * Perform the steps necessary for retrieving a #GstGLDisplay and (optionally)
- * an application provided #GstGLContext from the surrounding elements or from
- * the application using the #GstContext mechanism.
- *
- * If the contents of @display_ptr or @other_context_ptr are not %NULL, then no
- * #GstContext query is necessary for #GstGLDisplay or #GstGLContext retrieval
- * or is performed.
- *
- * This performs #GstContext queries (if necessary) for a winsys display
- * connection with %GST_GL_DISPLAY_CONTEXT_TYPE, "gst.x11.display.handle", and
- * "GstWaylandDisplayHandleContextType" stopping after the first successful
- * retrieval.
- *
- * This also performs a #GstContext query (if necessary) for an optional
- * application provided #GstGLContext using the name "gst.gl.app_context".
- * The returned #GstGLContext will be shared with a GStreamer created OpenGL context.
- *
- * Returns: whether a #GstGLDisplay exists in @display_ptr
- */
-gboolean
-gst_gl_ensure_element_data (gpointer element, GstGLDisplay ** display_ptr,
- GstGLContext ** other_context_ptr)
-{
- GstGLDisplay *display;
-
- g_return_val_if_fail (element != NULL, FALSE);
- g_return_val_if_fail (display_ptr != NULL, FALSE);
- g_return_val_if_fail (other_context_ptr != NULL, FALSE);
-
- /* 1) Check if the element already has a context of the specific
- * type.
- */
- display = *display_ptr;
- if (gst_gl_display_found (element, display))
- goto done;
-
- gst_gl_display_context_query (element, display_ptr);
-
- /* Neighbour found and it updated the display */
- if (gst_gl_display_found (element, *display_ptr))
- goto get_gl_context;
-
- /* If no neighboor, or application not interested, use system default */
- display = gst_gl_display_new ();
-
- *display_ptr = display;
-
- gst_gl_element_propagate_display_context (element, display);
-
-get_gl_context:
- if (*other_context_ptr)
- goto done;
-
- gst_gl_context_query (element);
-
-done:
- return *display_ptr != NULL;
-}
-
-/**
- * gst_gl_handle_set_context:
- * @element: a #GstElement
- * @context: a #GstContext
- * @display: (inout) (transfer full): location of a #GstGLDisplay
- * @other_context: (inout) (transfer full): location of a #GstGLContext
- *
- * Helper function for implementing GstElement::set_context() in OpenGL capable
- * elements.
- *
- * Retrieve's the #GstGLDisplay or #GstGLContext in @context and places the
- * result in @display or @other_context respectively.
- *
- * Returns: whether the @display or @other_context could be set successfully
- */
-gboolean
-gst_gl_handle_set_context (GstElement * element, GstContext * context,
- GstGLDisplay ** display, GstGLContext ** other_context)
-{
- GstGLDisplay *display_replacement = NULL;
- GstGLContext *context_replacement = NULL;
- const gchar *context_type;
-
- g_return_val_if_fail (display != NULL, FALSE);
- g_return_val_if_fail (other_context != NULL, FALSE);
-
- if (!context)
- return FALSE;
-
- context_type = gst_context_get_context_type (context);
-
- if (g_strcmp0 (context_type, GST_GL_DISPLAY_CONTEXT_TYPE) == 0) {
- if (!gst_context_get_gl_display (context, &display_replacement)) {
- GST_WARNING_OBJECT (element, "Failed to get display from context");
- return FALSE;
- }
- }
-#if GST_GL_HAVE_WINDOW_X11
- else if (g_strcmp0 (context_type, "gst.x11.display.handle") == 0) {
- const GstStructure *s;
- Display *display;
-
- s = gst_context_get_structure (context);
- if (gst_structure_get (s, "display", G_TYPE_POINTER, &display, NULL))
- display_replacement =
- (GstGLDisplay *) gst_gl_display_x11_new_with_display (display);
- }
-#endif
-#if GST_GL_HAVE_WINDOW_WAYLAND
- else if (g_strcmp0 (context_type, "GstWaylandDisplayHandleContextType") == 0) {
- const GstStructure *s;
- struct wl_display *display;
-
- s = gst_context_get_structure (context);
- if (gst_structure_get (s, "display", G_TYPE_POINTER, &display, NULL))
- display_replacement =
- (GstGLDisplay *) gst_gl_display_wayland_new_with_display (display);
- }
-#endif
- else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) {
- const GstStructure *s = gst_context_get_structure (context);
- GstGLDisplay *context_display;
- GstGLDisplay *element_display;
-
- if (gst_structure_get (s, "context", GST_TYPE_GL_CONTEXT,
- &context_replacement, NULL)) {
- context_display = gst_gl_context_get_display (context_replacement);
- element_display = display_replacement ? display_replacement : *display;
- if (element_display
- && (gst_gl_display_get_handle_type (element_display) &
- gst_gl_display_get_handle_type (context_display)) == 0) {
- GST_ELEMENT_WARNING (element, LIBRARY, SETTINGS, ("%s",
- "Cannot set a GL context with a different display type"), ("%s",
- "Cannot set a GL context with a different display type"));
- gst_object_unref (context_replacement);
- context_replacement = NULL;
- }
- gst_object_unref (context_display);
- }
- }
-
- if (display_replacement) {
- GstGLDisplay *old = *display;
- *display = display_replacement;
-
- if (old)
- gst_object_unref (old);
- }
-
- if (context_replacement) {
- GstGLContext *old = *other_context;
- *other_context = context_replacement;
-
- if (old)
- gst_object_unref (old);
- }
-
- return TRUE;
-}
-
-/**
- * gst_gl_handle_context_query:
- * @element: a #GstElement
- * @query: a #GstQuery of type %GST_QUERY_CONTEXT
- * @display: (transfer none) (nullable): a #GstGLDisplay
- * @context: (transfer none) (nullable): a #GstGLContext
- * @other_context: (transfer none) (nullable): application provided #GstGLContext
- *
- * Returns: Whether the @query was successfully responded to from the passed
- * @display, @context, and @other_context.
- */
-gboolean
-gst_gl_handle_context_query (GstElement * element, GstQuery * query,
- GstGLDisplay * display, GstGLContext * gl_context,
- GstGLContext * other_context)
-{
- const gchar *context_type;
- GstContext *context, *old_context;
-
- g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
- g_return_val_if_fail (GST_IS_QUERY (query), FALSE);
- g_return_val_if_fail (display == NULL || GST_IS_GL_DISPLAY (display), FALSE);
- g_return_val_if_fail (gl_context == NULL
- || GST_IS_GL_CONTEXT (gl_context), FALSE);
- g_return_val_if_fail (other_context == NULL
- || GST_IS_GL_CONTEXT (other_context), FALSE);
-
- GST_LOG_OBJECT (element, "handle context query %" GST_PTR_FORMAT, query);
- gst_query_parse_context_type (query, &context_type);
-
- if (display && g_strcmp0 (context_type, GST_GL_DISPLAY_CONTEXT_TYPE) == 0) {
- gst_query_parse_context (query, &old_context);
-
- if (old_context)
- context = gst_context_copy (old_context);
- else
- context = gst_context_new (GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
-
- gst_context_set_gl_display (context, display);
- gst_query_set_context (query, context);
- gst_context_unref (context);
- GST_DEBUG_OBJECT (element, "successfully set %" GST_PTR_FORMAT
- " on %" GST_PTR_FORMAT, display, query);
-
- return TRUE;
- }
-#if GST_GL_HAVE_WINDOW_X11
- else if (display && g_strcmp0 (context_type, "gst.x11.display.handle") == 0) {
- GstStructure *s;
-
- gst_query_parse_context (query, &old_context);
-
- if (old_context)
- context = gst_context_copy (old_context);
- else
- context = gst_context_new ("gst.x11.display.handle", TRUE);
-
- if (gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_X11) {
- Display *x11_display = (Display *) gst_gl_display_get_handle (display);
-
- if (x11_display) {
- s = gst_context_writable_structure (context);
- gst_structure_set (s, "display", G_TYPE_POINTER, x11_display, NULL);
-
- gst_query_set_context (query, context);
- gst_context_unref (context);
-
- GST_DEBUG_OBJECT (element, "successfully set x11 display %p (from %"
- GST_PTR_FORMAT ") on %" GST_PTR_FORMAT, x11_display, display,
- query);
-
- return TRUE;
- }
- }
- }
-#endif
-#if GST_GL_HAVE_WINDOW_WAYLAND
- else if (display
- && g_strcmp0 (context_type, "GstWaylandDisplayHandleContextType") == 0) {
- GstStructure *s;
-
- gst_query_parse_context (query, &old_context);
-
- if (old_context)
- context = gst_context_copy (old_context);
- else
- context = gst_context_new ("GstWaylandDisplayHandleContextType", TRUE);
-
- if (gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_WAYLAND) {
- struct wl_display *wayland_display =
- (struct wl_display *) gst_gl_display_get_handle (display);
-
- if (wayland_display) {
- s = gst_context_writable_structure (context);
- gst_structure_set (s, "display", G_TYPE_POINTER, wayland_display, NULL);
-
- gst_query_set_context (query, context);
- gst_context_unref (context);
-
- GST_DEBUG_OBJECT (element, "successfully set wayland display %p (from %"
- GST_PTR_FORMAT ") on %" GST_PTR_FORMAT, wayland_display, display,
- query);
-
- return TRUE;
- }
- }
- }
-#endif
- else if (other_context && g_strcmp0 (context_type, "gst.gl.app_context") == 0) {
- GstStructure *s;
-
- gst_query_parse_context (query, &old_context);
-
- if (old_context)
- context = gst_context_copy (old_context);
- else
- context = gst_context_new ("gst.gl.app_context", TRUE);
-
- s = gst_context_writable_structure (context);
- gst_structure_set (s, "context", GST_TYPE_GL_CONTEXT, other_context, NULL);
- gst_query_set_context (query, context);
- gst_context_unref (context);
-
- GST_DEBUG_OBJECT (element, "successfully set application GL context %"
- GST_PTR_FORMAT " on %" GST_PTR_FORMAT, other_context, query);
-
- return TRUE;
- } else if (gl_context
- && g_strcmp0 (context_type, "gst.gl.local_context") == 0) {
- GstStructure *s;
-
- gst_query_parse_context (query, &old_context);
-
- if (old_context)
- context = gst_context_copy (old_context);
- else
- context = gst_context_new ("gst.gl.local_context", TRUE);
-
- s = gst_context_writable_structure (context);
- gst_structure_set (s, "context", GST_TYPE_GL_CONTEXT, gl_context, NULL);
- gst_query_set_context (query, context);
- gst_context_unref (context);
-
- GST_DEBUG_OBJECT (element, "successfully set GL context %"
- GST_PTR_FORMAT " on %" GST_PTR_FORMAT, gl_context, query);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- * gst_gl_query_local_gl_context:
- * @element: a #GstElement to query from
- * @direction: the #GstPadDirection to query
- * @context_ptr: (inout): location containing the current and/or resulting
- * #GstGLContext
- *
- * Performs a GST_QUERY_CONTEXT query of type "gst.gl.local_context" on all
- * #GstPads in @element of @direction for the local OpenGL context used by
- * GStreamer elements.
- *
- * Returns: whether @context_ptr contains a #GstGLContext
- */
-gboolean
-gst_gl_query_local_gl_context (GstElement * element, GstPadDirection direction,
- GstGLContext ** context_ptr)
-{
- GstQuery *query;
- GstContext *context;
- const GstStructure *s;
-
- g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
- g_return_val_if_fail (context_ptr != NULL, FALSE);
-
- if (*context_ptr)
- return TRUE;
-
- query = gst_query_new_context ("gst.gl.local_context");
- if (gst_gl_run_query (GST_ELEMENT (element), query, direction)) {
- gst_query_parse_context (query, &context);
- if (context) {
- s = gst_context_get_structure (context);
- gst_structure_get (s, "context", GST_TYPE_GL_CONTEXT, context_ptr, NULL);
- }
- }
-
- gst_query_unref (query);
-
- return *context_ptr != NULL;
-}
-
-/**
- * gst_gl_get_plane_data_size:
- * @info: a #GstVideoInfo
- * @align: a #GstVideoAlignment or %NULL
- * @plane: plane number in @info to retrieve the data size of
- *
- * Retrieve the size in bytes of a video plane of data with a certain alignment
- */
-gsize
-gst_gl_get_plane_data_size (GstVideoInfo * info, GstVideoAlignment * align,
- guint plane)
-{
- gint padded_height;
- gsize plane_size;
-
- padded_height = info->height;
-
- if (align)
- padded_height += align->padding_top + align->padding_bottom;
-
- padded_height =
- GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info->finfo, plane, padded_height);
-
- plane_size = GST_VIDEO_INFO_PLANE_STRIDE (info, plane) * padded_height;
-
- return plane_size;
-}
-
-/**
- * gst_gl_get_plane_start:
- * @info: a #GstVideoInfo
- * @valign: a #GstVideoAlignment or %NULL
- * @plane: plane number in @info to retrieve the data size of
- *
- * Returns: difference between the supposed start of the plane from the @info
- * and where the data from the previous plane ends.
- */
-gsize
-gst_gl_get_plane_start (GstVideoInfo * info, GstVideoAlignment * valign,
- guint plane)
-{
- gsize plane_start;
- gint i;
-
- /* find the start of the plane data including padding */
- plane_start = 0;
- for (i = 0; i < plane; i++) {
- plane_start += gst_gl_get_plane_data_size (info, valign, i);
- }
-
- /* offset between the plane data start and where the video frame starts */
- return (GST_VIDEO_INFO_PLANE_OFFSET (info, plane)) - plane_start;
-}
-
-/**
- * gst_gl_value_get_texture_target_mask:
- * @value: an initialized #GValue of type G_TYPE_STRING
- *
- * See gst_gl_value_set_texture_target_from_mask() for what entails a mask
- *
- * Returns: the mask of #GstGLTextureTarget's in @value
- */
-GstGLTextureTarget
-gst_gl_value_get_texture_target_mask (const GValue * targets)
-{
- guint new_targets = 0;
-
- g_return_val_if_fail (targets != NULL, GST_GL_TEXTURE_TARGET_NONE);
-
- if (G_TYPE_CHECK_VALUE_TYPE (targets, G_TYPE_STRING)) {
- GstGLTextureTarget target;
- const gchar *str;
-
- str = g_value_get_string (targets);
- target = gst_gl_texture_target_from_string (str);
-
- if (target)
- new_targets |= 1 << target;
- } else if (G_TYPE_CHECK_VALUE_TYPE (targets, GST_TYPE_LIST)) {
- gint j, m;
-
- m = gst_value_list_get_size (targets);
- for (j = 0; j < m; j++) {
- const GValue *val = gst_value_list_get_value (targets, j);
- GstGLTextureTarget target;
- const gchar *str;
-
- str = g_value_get_string (val);
- target = gst_gl_texture_target_from_string (str);
- if (target)
- new_targets |= 1 << target;
- }
- }
-
- return new_targets;
-}
-
-/**
- * gst_gl_value_set_texture_target:
- * @value: an initialized #GValue of type G_TYPE_STRING
- * @target: a #GstGLTextureTarget's
- *
- * Returns: whether the @target could be set on @value
- */
-gboolean
-gst_gl_value_set_texture_target (GValue * value, GstGLTextureTarget target)
-{
- g_return_val_if_fail (value != NULL, FALSE);
- g_return_val_if_fail (target != GST_GL_TEXTURE_TARGET_NONE, FALSE);
-
- if (target == GST_GL_TEXTURE_TARGET_2D) {
- g_value_set_static_string (value, GST_GL_TEXTURE_TARGET_2D_STR);
- } else if (target == GST_GL_TEXTURE_TARGET_RECTANGLE) {
- g_value_set_static_string (value, GST_GL_TEXTURE_TARGET_RECTANGLE_STR);
- } else if (target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES) {
- g_value_set_static_string (value, GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR);
- } else {
- return FALSE;
- }
-
- return TRUE;
-}
-
-static guint64
-_gst_gl_log2_int64 (guint64 value)
-{
- guint64 ret = 0;
-
- while (value >>= 1)
- ret++;
-
- return ret;
-}
-
-/**
- * gst_gl_value_set_texture_target_from_mask:
- * @value: an uninitialized #GValue
- * @target_mask: a bitwise mask of #GstGLTextureTarget's
- *
- * A mask is a bitwise OR of (1 << target) where target is a valid
- * #GstGLTextureTarget
- *
- * Returns: whether the @target_mask could be set on @value
- */
-gboolean
-gst_gl_value_set_texture_target_from_mask (GValue * value,
- GstGLTextureTarget target_mask)
-{
- g_return_val_if_fail (value != NULL, FALSE);
- g_return_val_if_fail (target_mask != GST_GL_TEXTURE_TARGET_NONE, FALSE);
-
- if ((target_mask & (target_mask - 1)) == 0) {
- /* only one texture target set */
- g_value_init (value, G_TYPE_STRING);
- return gst_gl_value_set_texture_target (value,
- _gst_gl_log2_int64 (target_mask));
- } else {
- GValue item = G_VALUE_INIT;
- gboolean ret = FALSE;
-
- g_value_init (value, GST_TYPE_LIST);
- g_value_init (&item, G_TYPE_STRING);
- if (target_mask & (1 << GST_GL_TEXTURE_TARGET_2D)) {
- gst_gl_value_set_texture_target (&item, GST_GL_TEXTURE_TARGET_2D);
- gst_value_list_append_value (value, &item);
- ret = TRUE;
- }
- if (target_mask & (1 << GST_GL_TEXTURE_TARGET_RECTANGLE)) {
- gst_gl_value_set_texture_target (&item, GST_GL_TEXTURE_TARGET_RECTANGLE);
- gst_value_list_append_value (value, &item);
- ret = TRUE;
- }
- if (target_mask & (1 << GST_GL_TEXTURE_TARGET_EXTERNAL_OES)) {
- gst_gl_value_set_texture_target (&item,
- GST_GL_TEXTURE_TARGET_EXTERNAL_OES);
- gst_value_list_append_value (value, &item);
- ret = TRUE;
- }
-
- g_value_unset (&item);
- return ret;
- }
-}
-
-static const gfloat identity_matrix[] = {
- 1.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0,
-};
-
-static const gfloat from_ndc_matrix[] = {
- 0.5, 0.0, 0.0, 0.0,
- 0.0, 0.5, 0.0, 0.0,
- 0.0, 0.0, 0.5, 0.0,
- 0.5, 0.5, 0.5, 1.0,
-};
-
-static const gfloat to_ndc_matrix[] = {
- 2.0, 0.0, 0.0, 0.0,
- 0.0, 2.0, 0.0, 0.0,
- 0.0, 0.0, 2.0, 0.0,
- -1.0, -1.0, -1.0, 1.0,
-};
-
-/* multiplies two 4x4 matrices, @a X @b, and stores the result in @result
- * https://en.wikipedia.org/wiki/Matrix_multiplication
- */
-static void
-gst_gl_multiply_matrix4 (const gfloat * a, const gfloat * b, gfloat * result)
-{
- int i, j, k;
- gfloat tmp[16] = { 0.0f };
-
- if (!a || !b || !result)
- return;
- for (i = 0; i < 4; i++) { /* column */
- for (j = 0; j < 4; j++) { /* row */
- for (k = 0; k < 4; k++) {
- tmp[j + (i * 4)] += a[k + (i * 4)] * b[j + (k * 4)];
- }
- }
- }
-
- for (i = 0; i < 16; i++)
- result[i] = tmp[i];
-}
-
-/*
- * gst_gl_get_affine_transformation_meta_as_ndc:
- * @meta: (nullable): a #GstVideoAffineTransformationMeta
- * @matrix: (out): result of the 4x4 matrix
- *
- * Retrieves the stored 4x4 affine transformation matrix stored in @meta in
- * NDC coordinates. if @meta is NULL, an identity matrix is returned.
- *
- * NDC is a left-handed coordinate sytem
- * - x - [-1, 1] - +ve X moves right
- * - y - [-1, 1] - +ve Y moves up
- * - z - [-1, 1] - +ve Z moves into
- */
-void
-gst_gl_get_affine_transformation_meta_as_ndc (GstVideoAffineTransformationMeta *
- meta, gfloat * matrix)
-{
- if (!meta) {
- int i;
-
- for (i = 0; i < 16; i++) {
- matrix[i] = identity_matrix[i];
- }
- } else {
- float tmp[16];
-
- /* change of basis multiplications */
- gst_gl_multiply_matrix4 (to_ndc_matrix, meta->matrix, tmp);
- gst_gl_multiply_matrix4 (tmp, from_ndc_matrix, matrix);
- }
-}
-
-void gst_gl_set_affine_transformation_meta_from_ndc
- (GstVideoAffineTransformationMeta * meta, const gfloat * matrix)
-{
- float tmp[16];
-
- g_return_if_fail (meta != NULL);
-
- /* change of basis multiplications */
- gst_gl_multiply_matrix4 (from_ndc_matrix, matrix, tmp);
- gst_gl_multiply_matrix4 (tmp, to_ndc_matrix, meta->matrix);
-}
diff --git a/gst-libs/gst/gl/gstglutils.h b/gst-libs/gst/gl/gstglutils.h
deleted file mode 100644
index d39f68306..000000000
--- a/gst-libs/gst/gl/gstglutils.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_UTILS_H__
-#define __GST_GL_UTILS_H__
-
-#include <gst/video/video.h>
-#include <gst/video/gstvideoaffinetransformationmeta.h>
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-gboolean gst_gl_ensure_element_data (gpointer element,
- GstGLDisplay **display_ptr, GstGLContext ** other_context_ptr);
-GST_EXPORT
-gboolean gst_gl_handle_set_context (GstElement * element, GstContext * context,
- GstGLDisplay ** display, GstGLContext ** other_context);
-GST_EXPORT
-gboolean gst_gl_handle_context_query (GstElement * element, GstQuery * query,
- GstGLDisplay * display, GstGLContext * context, GstGLContext * other_context);
-GST_EXPORT
-gboolean gst_gl_query_local_gl_context (GstElement * element, GstPadDirection direction,
- GstGLContext ** context_ptr);
-
-GST_EXPORT
-void gst_gl_element_propagate_display_context (GstElement * element, GstGLDisplay * display);
-
-GST_EXPORT
-gsize gst_gl_get_plane_data_size (GstVideoInfo * info, GstVideoAlignment * align,
- guint plane);
-GST_EXPORT
-gsize gst_gl_get_plane_start (GstVideoInfo * info, GstVideoAlignment * valign,
- guint plane);
-
-GST_EXPORT
-gboolean gst_gl_value_set_texture_target_from_mask (GValue * value,
- GstGLTextureTarget target_mask);
-GST_EXPORT
-gboolean gst_gl_value_set_texture_target (GValue * value, GstGLTextureTarget target);
-GST_EXPORT
-GstGLTextureTarget gst_gl_value_get_texture_target_mask (const GValue * value);
-
-G_END_DECLS
-
-#endif /* __GST_GL_UTILS_H__ */
diff --git a/gst-libs/gst/gl/gstglutils_private.h b/gst-libs/gst/gl/gstglutils_private.h
deleted file mode 100644
index 5a314e37b..000000000
--- a/gst-libs/gst/gl/gstglutils_private.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2017 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_UTILS_PRIVATE_H__
-#define __GST_GL_UTILS_PRIVATE_H__
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-
-G_GNUC_INTERNAL gboolean gst_gl_run_query (GstElement * element, GstQuery * query, GstPadDirection direction);
-G_GNUC_INTERNAL void gst_gl_get_affine_transformation_meta_as_ndc (GstVideoAffineTransformationMeta * meta, gfloat * matrix);
-G_GNUC_INTERNAL void gst_gl_set_affine_transformation_meta_from_ndc (GstVideoAffineTransformationMeta * meta, const gfloat * matrix);
-
-G_END_DECLS
-
-#endif /* __GST_GL_UTILS_H__ */
diff --git a/gst-libs/gst/gl/gstglviewconvert.c b/gst-libs/gst/gl/gstglviewconvert.c
deleted file mode 100644
index 755f1b997..000000000
--- a/gst-libs/gst/gl/gstglviewconvert.c
+++ /dev/null
@@ -1,2381 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2009 Julien Isorce <julien.isorce@mail.com>
- * Copyright (C) 2014 Jan Schmidt <jan@centricular.com>
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstglviewconvert
- * @title: GstGLViewConvert
- * @short_description: convert between steroscopic/multiview video formats
- * @see_also: #GstGLColorConvert, #GstGLContext
- *
- * Convert stereoscopic/multiview video using fragment shaders.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstglviewconvert.h"
-
-#include <gst/video/gstvideoaffinetransformationmeta.h>
-
-#include "gstglcontext.h"
-#include "gstglframebuffer.h"
-#include "gstglmemory.h"
-#include "gstglshader.h"
-#include "gstglshaderstrings.h"
-#include "gstglsl.h"
-#include "gstglsl_private.h"
-#include "gstglslstage.h"
-#include "gstglutils_private.h"
-
-#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
-#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
-#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
-#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
-#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-
-static GstStaticCaps caps_template =
-GST_STATIC_CAPS ("video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), "
- "format = (string) RGBA, "
- "width = " GST_VIDEO_SIZE_RANGE ", "
- "height = " GST_VIDEO_SIZE_RANGE ", "
- "framerate = " GST_VIDEO_FPS_RANGE ", "
- "texture-target = (string) { 2D, rectangle, external-oes } ");
-
-#define GST_CAT_DEFAULT gst_gl_view_convert_debug
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-
-enum
-{
- PROP_0,
- PROP_INPUT_LAYOUT,
- PROP_INPUT_FLAGS,
- PROP_OUTPUT_LAYOUT,
- PROP_OUTPUT_FLAGS,
- PROP_OUTPUT_DOWNMIX_MODE
-};
-
-#define DEFAULT_DOWNMIX GST_GL_STEREO_DOWNMIX_ANAGLYPH_GREEN_MAGENTA_DUBOIS
-
-struct _GstGLViewConvertPrivate
-{
- gboolean result;
-
- GstVideoMultiviewMode input_mode;
- GstVideoMultiviewFlags input_flags;
- GstVideoMultiviewMode output_mode;
- GstVideoMultiviewFlags output_flags;
-
- GstBuffer *primary_in;
- GstBuffer *auxilliary_in;
-
- GstBuffer *primary_out;
- GstBuffer *auxilliary_out;
-
- GstGLMemory *in_tex[GST_VIDEO_MAX_PLANES];
- GstGLMemory *out_tex[GST_VIDEO_MAX_PLANES];
- guint n_out_tex;
-
- GLuint vao;
- GLuint vertex_buffer;
- GLuint vbo_indices;
- GLuint attr_position;
- GLuint attr_texture;
-};
-
-#define GST_GL_VIEW_CONVERT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
- GST_TYPE_GL_VIEW_CONVERT, GstGLViewConvertPrivate))
-
-#define DEBUG_INIT \
- GST_DEBUG_CATEGORY_INIT (gst_gl_view_convert_debug, "glviewconvert", 0, "glviewconvert object");
-
-G_DEFINE_TYPE_WITH_CODE (GstGLViewConvert, gst_gl_view_convert,
- GST_TYPE_OBJECT, DEBUG_INIT);
-
-static void gst_gl_view_convert_set_property (GObject * object,
- guint prop_id, const GValue * value, GParamSpec * pspec);
-static void gst_gl_view_convert_get_property (GObject * object,
- guint prop_id, GValue * value, GParamSpec * pspec);
-static void gst_gl_view_convert_finalize (GObject * object);
-
-static void _do_view_convert (GstGLContext * context,
- GstGLViewConvert * viewconvert);
-
-GType
-gst_gl_stereo_downmix_mode_get_type (void)
-{
- static volatile gsize g_define_type_id__volatile = 0;
- if (g_once_init_enter (&g_define_type_id__volatile)) {
- static const GEnumValue values[] = {
- {GST_GL_STEREO_DOWNMIX_ANAGLYPH_GREEN_MAGENTA_DUBOIS,
- "Dubois optimised Green-Magenta anaglyph", "green-magenta-dubois"},
- {GST_GL_STEREO_DOWNMIX_ANAGLYPH_RED_CYAN_DUBOIS,
- "Dubois optimised Red-Cyan anaglyph",
- "red-cyan-dubois"},
- {GST_GL_STEREO_DOWNMIX_ANAGLYPH_AMBER_BLUE_DUBOIS,
- "Dubois optimised Amber-Blue anaglyph", "amber-blue-dubois"},
- {0, NULL, NULL}
- };
- GType g_define_type_id =
- g_enum_register_static ("GstGLStereoDownmix", values);
- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
- }
- return g_define_type_id__volatile;
-}
-
-/* *INDENT-OFF* */
-/* These match the order and number of DOWNMIX_ANAGLYPH_* modes */
-static GLfloat downmix_matrices[][2][9] = {
- { /* Green-Magenta Dubois */
- {-0.062f, 0.284f, -0.015f, -0.158f, 0.668f, -0.027f, -0.039f, 0.143f, 0.021f},
- {0.529f, -0.016f, 0.009f, 0.705f, -0.015f, 0.075f, 0.024f, -0.065f, 0.937f}
- },
- { /* Red-Cyan Dubois */
- /* Source of this matrix: http://www.site.uottawa.ca/~edubois/anaglyph/LeastSquaresHowToPhotoshop.pdf */
- {0.437f, -0.062f, -0.048f, 0.449f, -0.062f, -0.050f, 0.164f, -0.024f, -0.017f},
- {-0.011f, 0.377f, -0.026f, -0.032f, 0.761f, -0.093f, -0.007f, 0.009f, 1.234f}
- },
- { /* Amber-blue Dubois */
- {1.062f, -0.026f, -0.038f, -0.205f, 0.908f, -0.173f, 0.299f, 0.068f, 0.022f},
- {-0.016f, 0.006f, 0.094f, -0.123f, 0.062f, 0.185f, -0.017f, -0.017f, 0.911f}
- }
-};
-
-static gfloat identity_matrix[] = {
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f,
-};
-/* *INDENT-ON* */
-
-#define glsl_OES_extension_string "#extension GL_OES_EGL_image_external : require \n"
-
-/* *INDENT-OFF* */
-static const gchar *fragment_header =
- "#ifdef GL_ES\n"
- "precision mediump float;\n"
- "#endif\n"
- "uniform sampler2D tex_l;\n"
- "uniform sampler2D tex_r;\n"
- "uniform float width;\n"
- "uniform float height;\n"
- "uniform mat3 downmix[2];\n"
- "uniform vec2 tex_scale[2];\n"
- "uniform vec2 offsets[2];\n";
-
-static const gchar *frag_input =
- " vec2 l_tex = v_texcoord * tex_scale[0] + offsets[0];\n"
- " vec2 r_tex = v_texcoord * tex_scale[1] + offsets[1];\n"
- " l = texture2D(tex_l, l_tex).rgba;\n"
- " r = texture2D(tex_r, r_tex).rgba;\n";
-
-static const gchar *frag_output_downmix =
- " vec3 lcol = l.rgb * l.a + vec3(1.0-l.a);\n"
- " vec3 rcol = r.rgb * r.a + vec3(1.0-r.a);\n"
- " if (l.a + r.a > 0.0) {\n"
- " lcol = clamp (downmix[0] * lcol, 0.0, 1.0);\n"
- " rcol = clamp (downmix[1] * rcol, 0.0, 1.0);\n"
- " gl_FragColor = vec4 (lcol + rcol, 1.0);\n"
- " } else {\n"
- " gl_FragColor = vec4 (0.0);\n"
- " }\n";
-
-static const gchar *frag_output_left =
- " gl_FragColor = l;\n";
-
-static const gchar *frag_output_right =
- " gl_FragColor = r;\n";
-
-static const gchar *frag_output_side_by_side =
- " if (v_texcoord.x < 0.5) {\n"
- " gl_FragColor = l;\n"
- " } else {\n"
- " gl_FragColor = r;\n"
- " };\n";
-
-static const gchar *frag_output_top_bottom =
- "if (v_texcoord.y < 0.5) {\n"
- " gl_FragColor = l;\n"
- "} else {\n"
- " gl_FragColor = r;\n"
- "};\n";
-
-static const gchar *frag_output_column_interleaved =
- "if (int(mod(l_tex.x * width, 2.0)) == 0) {\n"
- " gl_FragColor = l;\n"
- "} else {\n"
- " gl_FragColor = r;\n"
- "};\n";
-
-static const gchar *frag_output_row_interleaved =
- "if (int(mod(l_tex.y * height, 2.0)) == 0) {\n"
- " gl_FragColor = l;\n"
- "} else {\n"
- " gl_FragColor = r;\n"
- "};\n";
-
-static const gchar *frag_output_checkerboard =
- "if (int(mod(l_tex.x * width, 2.0)) == \n"
- " int(mod(l_tex.y * height, 2.0))) {\n"
- " gl_FragColor = l;\n"
- "} else {\n"
- " gl_FragColor = r;\n"
- "};\n";
-
-static const gchar *frag_output_separated =
- "gl_FragData[0] = l;\n"
- "gl_FragData[1] = r;\n";
-/* *INDENT-ON* */
-
-static const GLfloat vertices[] = {
- 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
- -1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
- -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
- 1.0f, 1.0f, 0.0f, 1.0f, 1.0f
-};
-
-static const GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
-
-static void
-gst_gl_view_convert_class_init (GstGLViewConvertClass * klass)
-{
- GObjectClass *gobject_class = (GObjectClass *) klass;
-
- g_type_class_add_private (klass, sizeof (GstGLViewConvertPrivate));
-
- gobject_class->set_property = gst_gl_view_convert_set_property;
- gobject_class->get_property = gst_gl_view_convert_get_property;
- gobject_class->finalize = gst_gl_view_convert_finalize;
-
- g_object_class_install_property (gobject_class, PROP_INPUT_LAYOUT,
- g_param_spec_enum ("input-mode-override",
- "Input Multiview Mode Override",
- "Override any input information about multiview layout",
- GST_TYPE_VIDEO_MULTIVIEW_MODE,
- GST_VIDEO_MULTIVIEW_MODE_NONE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_INPUT_FLAGS,
- g_param_spec_flags ("input-flags-override",
- "Input Multiview Flags Override",
- "Override any input information about multiview layout flags",
- GST_TYPE_VIDEO_MULTIVIEW_FLAGS, GST_VIDEO_MULTIVIEW_FLAGS_NONE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_OUTPUT_LAYOUT,
- g_param_spec_enum ("output-mode-override",
- "Output Multiview Mode Override",
- "Override automatic output mode selection for multiview layout",
- GST_TYPE_VIDEO_MULTIVIEW_MODE, GST_VIDEO_MULTIVIEW_MODE_NONE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_OUTPUT_FLAGS,
- g_param_spec_flags ("output-flags-override",
- "Output Multiview Flags Override",
- "Override automatic negotiation for output multiview layout flags",
- GST_TYPE_VIDEO_MULTIVIEW_FLAGS, GST_VIDEO_MULTIVIEW_FLAGS_NONE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_OUTPUT_DOWNMIX_MODE,
- g_param_spec_enum ("downmix-mode", "Mode for mono downmixed output",
- "Output anaglyph type to generate when downmixing to mono",
- GST_TYPE_GL_STEREO_DOWNMIX_MODE_TYPE, DEFAULT_DOWNMIX,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-static void
-gst_gl_view_convert_init (GstGLViewConvert * convert)
-{
- convert->priv = GST_GL_VIEW_CONVERT_GET_PRIVATE (convert);
-
- convert->shader = NULL;
- convert->downmix_mode = DEFAULT_DOWNMIX;
- convert->priv->input_mode = GST_VIDEO_MULTIVIEW_MODE_NONE;
- convert->priv->input_flags = GST_VIDEO_MULTIVIEW_FLAGS_NONE;
- convert->priv->output_mode = GST_VIDEO_MULTIVIEW_MODE_NONE;
- convert->priv->output_flags = GST_VIDEO_MULTIVIEW_FLAGS_NONE;
-
- convert->input_mode_override = GST_VIDEO_MULTIVIEW_MODE_NONE;
- convert->input_flags_override = GST_VIDEO_MULTIVIEW_FLAGS_NONE;
- convert->output_mode_override = GST_VIDEO_MULTIVIEW_MODE_NONE;
- convert->output_flags_override = GST_VIDEO_MULTIVIEW_FLAGS_NONE;
-
- gst_video_info_init (&convert->in_info);
- gst_video_info_init (&convert->out_info);
-}
-
-static void
-gst_gl_view_convert_finalize (GObject * object)
-{
- GstGLViewConvert *viewconvert;
-
- viewconvert = GST_GL_VIEW_CONVERT (object);
-
- gst_gl_view_convert_reset (viewconvert);
-
- gst_buffer_replace (&viewconvert->priv->primary_in, NULL);
- gst_buffer_replace (&viewconvert->priv->auxilliary_in, NULL);
- gst_buffer_replace (&viewconvert->priv->primary_out, NULL);
- gst_buffer_replace (&viewconvert->priv->auxilliary_out, NULL);
-
- if (viewconvert->context) {
- gst_object_unref (viewconvert->context);
- viewconvert->context = NULL;
- }
-
- G_OBJECT_CLASS (gst_gl_view_convert_parent_class)->finalize (object);
-}
-
-/**
- * gst_gl_view_convert_new:
- *
- * Returns: (transfer full): a new #GstGLViewConvert
- *
- * Since: 1.6
- */
-GstGLViewConvert *
-gst_gl_view_convert_new (void)
-{
- GstGLViewConvert *convert;
-
- convert = g_object_new (GST_TYPE_GL_VIEW_CONVERT, NULL);
- gst_object_ref_sink (convert);
-
- return convert;
-}
-
-/**
- * gst_gl_view_convert_set_context:
- * @viewconvert: a #GstGLViewConvert
- * @context: the #GstGLContext to set
- *
- * Set @context on @viewconvert
- *
- * Since: 1.6
- */
-void
-gst_gl_view_convert_set_context (GstGLViewConvert * viewconvert,
- GstGLContext * context)
-{
- g_return_if_fail (GST_IS_GL_VIEW_CONVERT (viewconvert));
-
- if (gst_object_replace ((GstObject **) & viewconvert->context,
- GST_OBJECT (context)))
- gst_gl_view_convert_reset (viewconvert);
-}
-
-static gboolean
-_view_convert_set_format (GstGLViewConvert * viewconvert,
- GstVideoInfo * in_info, GstGLTextureTarget from_target,
- GstVideoInfo * out_info, GstGLTextureTarget to_target)
-{
- gboolean passthrough;
- g_return_val_if_fail (GST_IS_GL_VIEW_CONVERT (viewconvert), FALSE);
-
- if (gst_video_info_is_equal (in_info, &viewconvert->in_info) &&
- gst_video_info_is_equal (out_info, &viewconvert->out_info) &&
- viewconvert->from_texture_target == from_target &&
- viewconvert->to_texture_target == to_target)
- return TRUE;
-
- if (GST_VIDEO_INFO_FORMAT (in_info) != GST_VIDEO_FORMAT_RGBA ||
- GST_VIDEO_INFO_FORMAT (out_info) != GST_VIDEO_FORMAT_RGBA) {
- GST_ERROR_OBJECT (viewconvert,
- "Multiview conversion can currently only be performed on RGBA textures");
- return FALSE;
- }
-
- passthrough = gst_video_info_is_equal (in_info, out_info) &&
- from_target == to_target;
-
- if (!passthrough && to_target != GST_GL_TEXTURE_TARGET_2D
- && to_target != GST_GL_TEXTURE_TARGET_RECTANGLE)
- return FALSE;
-
- /* FIXME: Compare what changed and decide if we need a full reset or not */
- GST_OBJECT_LOCK (viewconvert);
- gst_gl_view_convert_reset (viewconvert);
-
- viewconvert->in_info = *in_info;
- viewconvert->out_info = *out_info;
- viewconvert->from_texture_target = from_target;
- viewconvert->to_texture_target = to_target;
- viewconvert->caps_passthrough = passthrough;
-
- gst_buffer_replace (&viewconvert->priv->primary_in, NULL);
- gst_buffer_replace (&viewconvert->priv->auxilliary_in, NULL);
- gst_buffer_replace (&viewconvert->priv->primary_out, NULL);
- gst_buffer_replace (&viewconvert->priv->auxilliary_out, NULL);
- GST_OBJECT_UNLOCK (viewconvert);
-
- return TRUE;
-}
-
-/**
- * gst_gl_view_convert_set_caps:
- * @viewconvert: a #GstGLViewConvert
- * @in_caps: input #GstCaps
- * @out_caps: output #GstCaps
- *
- * Initializes @viewconvert with the information required for conversion.
- *
- * Since: 1.6
- */
-gboolean
-gst_gl_view_convert_set_caps (GstGLViewConvert * viewconvert,
- GstCaps * in_caps, GstCaps * out_caps)
-{
- GstVideoInfo in_info, out_info;
- GstCapsFeatures *in_features, *out_features;
- GstGLTextureTarget from_target = GST_GL_TEXTURE_TARGET_2D;
- GstGLTextureTarget to_target = GST_GL_TEXTURE_TARGET_2D;
-
- g_return_val_if_fail (GST_IS_GL_VIEW_CONVERT (viewconvert), FALSE);
- g_return_val_if_fail (GST_IS_CAPS (in_caps), FALSE);
- g_return_val_if_fail (GST_IS_CAPS (out_caps), FALSE);
-
- GST_INFO_OBJECT (viewconvert,
- "Configuring multiview conversion from caps %" GST_PTR_FORMAT
- " to %" GST_PTR_FORMAT, in_caps, out_caps);
-
- in_features = gst_caps_get_features (in_caps, 0);
- out_features = gst_caps_get_features (out_caps, 0);
-
- if (!gst_caps_features_contains (in_features,
- GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
- return FALSE;
- if (!gst_caps_features_contains (out_features,
- GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
- return FALSE;
-
- if (!gst_video_info_from_caps (&in_info, in_caps))
- return FALSE;
- if (!gst_video_info_from_caps (&out_info, out_caps))
- return FALSE;
-
- {
- GstStructure *in_s = gst_caps_get_structure (in_caps, 0);
- GstStructure *out_s = gst_caps_get_structure (out_caps, 0);
-
- if (gst_structure_has_field_typed (in_s, "texture-target", G_TYPE_STRING)) {
- from_target =
- gst_gl_texture_target_from_string (gst_structure_get_string (in_s,
- "texture-target"));
- }
-
- if (gst_structure_has_field_typed (out_s, "texture-target", G_TYPE_STRING)) {
- to_target =
- gst_gl_texture_target_from_string (gst_structure_get_string (out_s,
- "texture-target"));
- }
-
- if (to_target == GST_GL_TEXTURE_TARGET_NONE
- || from_target == GST_GL_TEXTURE_TARGET_NONE)
- /* invalid caps */
- return FALSE;
- }
-
- return _view_convert_set_format (viewconvert, &in_info, from_target,
- &out_info, to_target);
-}
-
-/* Function that can halve the value
- * of ints, fractions, int/fraction ranges and lists of ints/fractions */
-static gboolean
-_halve_value (GValue * out, const GValue * in_value)
-{
- /* Fundamental fixed types first */
- if (G_VALUE_HOLDS_INT (in_value)) {
- g_value_init (out, G_TYPE_INT);
- g_value_set_int (out, MAX (g_value_get_int (in_value) / 2, 1));
- } else if (GST_VALUE_HOLDS_FRACTION (in_value)) {
- gint num, den;
- num = gst_value_get_fraction_numerator (in_value);
- den = gst_value_get_fraction_denominator (in_value);
- g_value_init (out, GST_TYPE_FRACTION);
- /* Don't adjust 'infinite' fractions */
- if ((num != 1 || den != 2147483647) && (num != 2147483647 || den != 1)) {
- /* FIXME - could do better approximation when den > G_MAXINT/2? */
- den = den > G_MAXINT / 2 ? G_MAXINT : den * 2;
- }
- gst_value_set_fraction (out, num, den);
- } else if (GST_VALUE_HOLDS_INT_RANGE (in_value)) {
- gint range_min = gst_value_get_int_range_min (in_value);
- gint range_max = gst_value_get_int_range_max (in_value);
- gint range_step = gst_value_get_int_range_step (in_value);
- g_value_init (out, GST_TYPE_INT_RANGE);
- if (range_min != 1)
- range_min = MAX (1, range_min / 2);
- if (range_max != G_MAXINT)
- range_max = MAX (1, range_max / 2);
- gst_value_set_int_range_step (out, range_min,
- range_max, MAX (1, range_step / 2));
- } else if (GST_VALUE_HOLDS_FRACTION_RANGE (in_value)) {
- GValue min_out = G_VALUE_INIT;
- GValue max_out = G_VALUE_INIT;
- const GValue *range_min = gst_value_get_fraction_range_min (in_value);
- const GValue *range_max = gst_value_get_fraction_range_max (in_value);
- _halve_value (&min_out, range_min);
- _halve_value (&max_out, range_max);
- g_value_init (out, GST_TYPE_FRACTION_RANGE);
- gst_value_set_fraction_range (out, &min_out, &max_out);
- g_value_unset (&min_out);
- g_value_unset (&max_out);
- } else if (GST_VALUE_HOLDS_LIST (in_value)) {
- gint i;
- g_value_init (out, GST_TYPE_LIST);
- for (i = 0; i < gst_value_list_get_size (in_value); i++) {
- const GValue *entry;
- GValue tmp = G_VALUE_INIT;
-
- entry = gst_value_list_get_value (in_value, i);
- /* Random list values might not be the right type */
- if (!_halve_value (&tmp, entry))
- goto fail;
- gst_value_list_append_and_take_value (out, &tmp);
- }
- } else {
- return FALSE;
- }
-
- return TRUE;
-fail:
- g_value_unset (out);
- return FALSE;
-}
-
-static GstStructure *
-_halve_structure_field (const GstStructure * in, const gchar * field_name)
-{
- GstStructure *out;
- const GValue *in_value = gst_structure_get_value (in, field_name);
- GValue tmp = G_VALUE_INIT;
-
- if (G_UNLIKELY (in_value == NULL))
- return gst_structure_copy (in); /* Field doesn't exist, leave it as is */
-
- if (!_halve_value (&tmp, in_value))
- return NULL;
-
- out = gst_structure_copy (in);
- gst_structure_set_value (out, field_name, &tmp);
- g_value_unset (&tmp);
-
- return out;
-}
-
-/* Function that can double the value
- * of ints, fractions, int/fraction ranges and lists of ints/fractions */
-static gboolean
-_double_value (GValue * out, const GValue * in_value)
-{
- /* Fundamental fixed types first */
- if (G_VALUE_HOLDS_INT (in_value)) {
- gint n = g_value_get_int (in_value);
- g_value_init (out, G_TYPE_INT);
- if (n <= G_MAXINT / 2)
- g_value_set_int (out, n * 2);
- else
- g_value_set_int (out, G_MAXINT);
- } else if (GST_VALUE_HOLDS_FRACTION (in_value)) {
- gint num, den;
- num = gst_value_get_fraction_numerator (in_value);
- den = gst_value_get_fraction_denominator (in_value);
- g_value_init (out, GST_TYPE_FRACTION);
- /* Don't adjust 'infinite' fractions */
- if ((num != 1 || den != 2147483647) && (num != 2147483647 || den != 1)) {
- /* FIXME - could do better approximation when num > G_MAXINT/2? */
- num = num > G_MAXINT / 2 ? G_MAXINT : num * 2;
- }
- gst_value_set_fraction (out, num, den);
- } else if (GST_VALUE_HOLDS_INT_RANGE (in_value)) {
- gint range_min = gst_value_get_int_range_min (in_value);
- gint range_max = gst_value_get_int_range_max (in_value);
- gint range_step = gst_value_get_int_range_step (in_value);
- if (range_min != 1) {
- range_min = MIN (G_MAXINT / 2, range_min);
- range_min *= 2;
- }
- if (range_max != G_MAXINT) {
- range_max = MIN (G_MAXINT / 2, range_max);
- range_max *= 2;
- }
- range_step = MIN (G_MAXINT / 2, range_step);
- g_value_init (out, GST_TYPE_INT_RANGE);
- gst_value_set_int_range_step (out, range_min, range_max, range_step);
- } else if (GST_VALUE_HOLDS_FRACTION_RANGE (in_value)) {
- GValue min_out = G_VALUE_INIT;
- GValue max_out = G_VALUE_INIT;
- const GValue *range_min = gst_value_get_fraction_range_min (in_value);
- const GValue *range_max = gst_value_get_fraction_range_max (in_value);
- _double_value (&min_out, range_min);
- _double_value (&max_out, range_max);
- g_value_init (out, GST_TYPE_FRACTION_RANGE);
- gst_value_set_fraction_range (out, &min_out, &max_out);
- g_value_unset (&min_out);
- g_value_unset (&max_out);
- } else if (GST_VALUE_HOLDS_LIST (in_value)) {
- gint i;
- g_value_init (out, GST_TYPE_LIST);
- for (i = 0; i < gst_value_list_get_size (in_value); i++) {
- const GValue *entry;
- GValue tmp = G_VALUE_INIT;
-
- entry = gst_value_list_get_value (in_value, i);
- /* Random list values might not be the right type */
- if (!_double_value (&tmp, entry))
- goto fail;
- gst_value_list_append_and_take_value (out, &tmp);
- }
- } else {
- return FALSE;
- }
-
- return TRUE;
-fail:
- g_value_unset (out);
- return FALSE;
-}
-
-static GstStructure *
-_double_structure_field (const GstStructure * in, const gchar * field_name)
-{
- GstStructure *out;
- const GValue *in_value = gst_structure_get_value (in, field_name);
- GValue tmp = G_VALUE_INIT;
-
- if (G_UNLIKELY (in_value == NULL))
- return gst_structure_copy (in); /* Field doesn't exist, leave it as is */
-
- if (!_double_value (&tmp, in_value))
- return NULL;
-
- out = gst_structure_copy (in);
- gst_structure_set_value (out, field_name, &tmp);
- g_value_unset (&tmp);
-
- return out;
-}
-
-/* Return a copy of the caps with the requested field halved in value/range */
-#if 0
-static GstCaps *
-_halve_caps_field (const GstCaps * in, const gchar * field_name)
-{
- gint i;
- GstCaps *out = gst_caps_new_empty ();
-
- for (i = 0; i < gst_caps_get_size (in); i++) {
- const GstStructure *cur = gst_caps_get_structure (in, i);
- GstCapsFeatures *f = gst_caps_get_features (in, i);
-
- GstStructure *res = _halve_structure_field (cur, field_name);
- out =
- gst_caps_merge_structure_full (out, res,
- f ? gst_caps_features_copy (f) : NULL);
- }
-
- return out;
-}
-#endif
-
-/* Return a copy of the caps with the requested field doubled in value/range */
-static GstCaps *
-_double_caps_field (const GstCaps * in, const gchar * field_name)
-{
- gint i;
- GstCaps *out = gst_caps_new_empty ();
-
- for (i = 0; i < gst_caps_get_size (in); i++) {
- const GstStructure *cur = gst_caps_get_structure (in, i);
- GstCapsFeatures *f = gst_caps_get_features (in, i);
-
- GstStructure *res = _double_structure_field (cur, field_name);
- out =
- gst_caps_merge_structure_full (out, res,
- f ? gst_caps_features_copy (f) : NULL);
- }
-
- return out;
-}
-
-/* Takes ownership of the input caps */
-static GstCaps *
-_expand_par_for_half_aspect (GstCaps * in, gboolean vertical_half_aspect)
-{
-
- guint mview_flags, mview_flags_mask;
- GstCaps *out;
- GstStructure *tmp;
-
- out = gst_caps_new_empty ();
-
- while (gst_caps_get_size (in) > 0) {
- GstStructure *s;
- GstCapsFeatures *features;
-
- features = gst_caps_get_features (in, 0);
- if (features)
- features = gst_caps_features_copy (features);
-
- s = gst_caps_steal_structure (in, 0);
-
- if (!gst_structure_get_flagset (s, "multiview-flags", &mview_flags,
- &mview_flags_mask)) {
- gst_caps_append_structure_full (out, s, features);
- continue;
- }
- /* If the input doesn't care about the half-aspect flag, allow current PAR in either variant */
- if ((mview_flags_mask & GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT) == 0) {
- gst_caps_append_structure_full (out, s, features);
- continue;
- }
- if (!gst_structure_has_field (s, "pixel-aspect-ratio")) {
- /* No par field, dont-care the half-aspect flag */
- gst_structure_set (s, "multiview-flags",
- GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
- mview_flags & ~GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT,
- mview_flags_mask & ~GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT, NULL);
- gst_caps_append_structure_full (out, s, features);
- continue;
- }
-
- /* Halve or double PAR base on inputs input specified. */
-
- /* Append a copy with the half-aspect flag as-is */
- tmp = gst_structure_copy (s);
- out = gst_caps_merge_structure_full (out, tmp,
- features ? gst_caps_features_copy (features) : NULL);
-
- /* and then a copy inverted */
- if (mview_flags & GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT) {
- /* Input is half-aspect. Double/halve the PAR, clear the flag */
- if (vertical_half_aspect)
- tmp = _halve_structure_field (s, "pixel-aspect-ratio");
- else
- tmp = _double_structure_field (s, "pixel-aspect-ratio");
- /* Clear the flag */
- gst_structure_set (tmp, "multiview-flags",
- GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
- mview_flags & ~GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT,
- mview_flags_mask | GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT, NULL);
- } else {
- if (vertical_half_aspect)
- tmp = _double_structure_field (s, "pixel-aspect-ratio");
- else
- tmp = _halve_structure_field (s, "pixel-aspect-ratio");
- /* Set the flag */
- gst_structure_set (tmp, "multiview-flags",
- GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
- mview_flags | GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT,
- mview_flags_mask | GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT, NULL);
- }
-
- out = gst_caps_merge_structure_full (out, tmp,
- features ? gst_caps_features_copy (features) : NULL);
-
- gst_structure_free (s);
- if (features)
- gst_caps_features_free (features);
- }
-
- gst_caps_unref (in);
-
- return out;
-}
-
-/* If input supports top-bottom or row-interleaved, we may halve height to mono frames.
- * If input supports left-right, checkerboard, quincunx or column-interleaved,
- * we may halve width to mono frames.
- * For output of top-bottom or row-interleaved, we may double the mono height
- * For output of left-right, checkerboard, quincunx or column-interleaved,
- * we may double the mono width.
- * In all cases, if input has half-aspect and output does not, we may double the PAR
- * And if input does *not* have half-aspect flag and output does not, we may halve the PAR
- */
-static GstCaps *
-_expand_structure (GstGLViewConvert * viewconvert,
- GstCaps * out_caps, GstStructure * structure, GstCapsFeatures * features)
-{
- GstCaps *expanded_caps, *tmp;
- GstCaps *mono_caps;
- const gchar *default_mview_mode_str = NULL;
- guint mview_flags, mview_flags_mask;
- const GValue *in_modes;
- gint i;
-
- /* Empty caps to accumulate into */
- expanded_caps = gst_caps_new_empty ();
-
- /* First, set defaults if multiview flags are missing */
- default_mview_mode_str =
- gst_video_multiview_mode_to_caps_string (GST_VIDEO_MULTIVIEW_MODE_MONO);
-
- mview_flags = GST_VIDEO_MULTIVIEW_FLAGS_NONE;
- mview_flags_mask = GST_FLAG_SET_MASK_EXACT;
-
- if (!gst_structure_has_field (structure, "multiview-mode")) {
- gst_structure_set (structure,
- "multiview-mode", G_TYPE_STRING, default_mview_mode_str, NULL);
- }
- if (!gst_structure_has_field (structure, "multiview-flags")) {
- gst_structure_set (structure,
- "multiview-flags", GST_TYPE_VIDEO_MULTIVIEW_FLAGSET, mview_flags,
- mview_flags_mask, NULL);
- } else {
- gst_structure_get_flagset (structure, "multiview-flags",
- &mview_flags, &mview_flags_mask);
- }
-
- in_modes = gst_structure_get_value (structure, "multiview-mode");
- mono_caps = gst_caps_new_empty ();
- if (gst_value_intersect (NULL, in_modes,
- gst_video_multiview_get_mono_modes ())) {
- GstStructure *new_struct = gst_structure_copy (structure);
- gst_structure_set_value (new_struct, "multiview-mode",
- gst_video_multiview_get_mono_modes ());
- /* Half-aspect makes no sense for mono or unpacked, get rid of it */
- if (mview_flags & GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT) {
- gst_structure_set (new_struct, "multiview-flags",
- GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
- mview_flags & ~GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT,
- mview_flags_mask & ~GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT, NULL);
- }
- gst_caps_append_structure_full (mono_caps, new_struct,
- features ? gst_caps_features_copy (features) : NULL);
- }
- if (gst_value_intersect (NULL, in_modes,
- gst_video_multiview_get_unpacked_modes ())) {
- GstStructure *new_struct = gst_structure_copy (structure);
-
- gst_structure_set_value (new_struct, "multiview-mode",
- gst_video_multiview_get_mono_modes ());
-
- /* Half-aspect makes no sense for mono or unpacked, get rid of it */
- if (mview_flags & GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT) {
- gst_structure_set (new_struct, "multiview-flags",
- GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
- mview_flags & ~GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT,
- mview_flags_mask & ~GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT, NULL);
- }
- gst_caps_append_structure_full (mono_caps, new_struct,
- features ? gst_caps_features_copy (features) : NULL);
- }
-
- if (gst_value_intersect (NULL, in_modes,
- gst_video_multiview_get_doubled_height_modes ())) {
- /* Append mono formats with height halved */
- GstStructure *new_struct = _halve_structure_field (structure, "height");
- gst_structure_set_value (new_struct, "multiview-mode",
- gst_video_multiview_get_mono_modes ());
- /* Normalise the half-aspect flag away */
- if (mview_flags & GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT) {
- GstStructure *s =
- _halve_structure_field (new_struct, "pixel-aspect-ratio");
- gst_structure_set (structure, "multiview-flags",
- GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
- mview_flags & ~GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT,
- mview_flags_mask | GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT, NULL);
- gst_structure_free (new_struct);
- new_struct = s;
- }
- mono_caps = gst_caps_merge_structure_full (mono_caps, new_struct,
- features ? gst_caps_features_copy (features) : NULL);
- }
- if (gst_value_intersect (NULL, in_modes,
- gst_video_multiview_get_doubled_width_modes ())) {
- /* Append mono formats with width halved */
- GstStructure *new_struct = _halve_structure_field (structure, "width");
- gst_structure_set_value (new_struct, "multiview-mode",
- gst_video_multiview_get_mono_modes ());
- /* Normalise the half-aspect flag away */
- if (mview_flags & GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT) {
- GstStructure *s =
- _double_structure_field (new_struct, "pixel-aspect-ratio");
- gst_structure_set (structure, "multiview-flags",
- GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
- mview_flags & ~GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT,
- mview_flags_mask | GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT, NULL);
- gst_structure_free (new_struct);
- new_struct = s;
- }
- mono_caps = gst_caps_merge_structure_full (mono_caps, new_struct,
- features ? gst_caps_features_copy (features) : NULL);
- }
- if (gst_value_intersect (NULL, in_modes,
- gst_video_multiview_get_doubled_size_modes ())) {
- /* Append checkerboard/doubled size formats with width & height halved */
- GstStructure *new_struct_w = _halve_structure_field (structure, "width");
- GstStructure *new_struct_wh =
- _halve_structure_field (new_struct_w, "height");
- gst_structure_free (new_struct_w);
- gst_structure_set_value (new_struct_wh, "multiview-mode",
- gst_video_multiview_get_mono_modes ());
- mono_caps = gst_caps_merge_structure_full (mono_caps, new_struct_wh,
- features ? gst_caps_features_copy (features) : NULL);
- }
-
- /* Everything is normalised now, unset the flags we can change */
- /* Remove the views field, as these are all 'mono' modes
- * Need to do this before we expand caps back out to frame packed modes */
- for (i = 0; i < gst_caps_get_size (mono_caps); i++) {
- GstStructure *s = gst_caps_get_structure (mono_caps, i);
- gst_structure_remove_fields (s, "views", NULL);
- if (gst_structure_get_flagset (s, "multiview-flags", &mview_flags,
- &mview_flags_mask)) {
- /* Preserve only the half-aspect and mixed-mono flags, for now.
- * The rest we can change */
- mview_flags_mask &=
- (GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT |
- GST_VIDEO_MULTIVIEW_FLAGS_MIXED_MONO);
- gst_structure_set (s, "multiview-flags", GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
- mview_flags, mview_flags_mask, NULL);
- }
- }
-
- GST_TRACE_OBJECT (viewconvert,
- "Collected single-view caps %" GST_PTR_FORMAT, mono_caps);
- /* Put unpacked and mono modes first. We don't care about flags. Clear them */
- tmp = gst_caps_copy (mono_caps);
- for (i = 0; i < gst_caps_get_size (tmp); i++) {
- GstStructure *s = gst_caps_get_structure (tmp, i);
- gst_structure_remove_fields (s, "views", NULL);
- if (gst_structure_get_flagset (s, "multiview-flags", &mview_flags,
- &mview_flags_mask)) {
- /* We can change any flags for mono modes - half-aspect and mixed-mono have no meaning */
- mview_flags_mask = 0;
- gst_structure_set (s, "multiview-flags", GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
- mview_flags, mview_flags_mask, NULL);
- }
- }
- expanded_caps = gst_caps_merge (expanded_caps, tmp);
-
- /* Unpacked output modes have 2 views, for now */
- tmp = gst_caps_copy (mono_caps);
- gst_caps_set_value (tmp, "multiview-mode",
- gst_video_multiview_get_unpacked_modes ());
- for (i = 0; i < gst_caps_get_size (tmp); i++) {
- GstStructure *s = gst_caps_get_structure (tmp, i);
- gst_structure_set (s, "views", G_TYPE_INT, 2, NULL);
- if (gst_structure_get_flagset (s, "multiview-flags", &mview_flags,
- &mview_flags_mask)) {
- /* We can change any flags for unpacked modes - half-aspect and mixed-mono have no meaning */
- mview_flags_mask = 0;
- gst_structure_set (s, "multiview-flags", GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
- mview_flags, mview_flags_mask, NULL);
- }
- }
- expanded_caps = gst_caps_merge (expanded_caps, tmp);
-
- /* Double height output modes */
- tmp = _double_caps_field (mono_caps, "height");
- gst_caps_set_value (tmp, "multiview-mode",
- gst_video_multiview_get_doubled_height_modes ());
- tmp = _expand_par_for_half_aspect (tmp, TRUE);
-
- expanded_caps = gst_caps_merge (expanded_caps, tmp);
-
- /* Double width output modes */
- tmp = _double_caps_field (mono_caps, "width");
- gst_caps_set_value (tmp, "multiview-mode",
- gst_video_multiview_get_doubled_width_modes ());
- tmp = _expand_par_for_half_aspect (tmp, FALSE);
-
- expanded_caps = gst_caps_merge (expanded_caps, tmp);
-
- /* Double size output modes */
- {
- GstCaps *tmp_w = _double_caps_field (mono_caps, "width");
- tmp = _double_caps_field (tmp_w, "height");
- gst_caps_unref (tmp_w);
- gst_caps_set_value (tmp, "multiview-mode",
- gst_video_multiview_get_doubled_size_modes ());
- expanded_caps = gst_caps_merge (expanded_caps, tmp);
- }
-
- /* We're done with the mono caps now */
- gst_caps_unref (mono_caps);
-
- GST_TRACE_OBJECT (viewconvert,
- "expanded transform caps now %" GST_PTR_FORMAT, expanded_caps);
-
- if (gst_caps_is_empty (expanded_caps)) {
- gst_caps_unref (expanded_caps);
- return out_caps;
- }
- /* Really, we can rescale - so at this point we can append full-range
- * height/width/PAR as an unpreferred final option. */
- tmp = gst_caps_copy (expanded_caps);
- gst_caps_set_simple (tmp, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
- "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
-
- out_caps = gst_caps_merge (out_caps, expanded_caps);
- out_caps = gst_caps_merge (out_caps, tmp);
- return out_caps;
-}
-
-static GstCaps *
-_intersect_with_mview_mode (GstCaps * caps,
- GstVideoMultiviewMode mode, GstVideoMultiviewFlags flags)
-{
- GstCaps *filter, *result;
- const gchar *caps_str;
-
- caps_str = gst_video_multiview_mode_to_caps_string (mode);
-
- filter = gst_caps_new_simple ("video/x-raw",
- "multiview-mode", G_TYPE_STRING,
- caps_str, "multiview-flags", GST_TYPE_VIDEO_MULTIVIEW_FLAGSET, flags,
- GST_FLAG_SET_MASK_EXACT, NULL);
-
- if (mode == GST_VIDEO_MULTIVIEW_MODE_SEPARATED ||
- mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME)
- gst_caps_set_simple (filter, "views", G_TYPE_INT, 2, NULL);
-
- gst_caps_set_features (filter, 0, gst_caps_features_new_any ());
-
- GST_DEBUG ("Intersecting target caps %" GST_PTR_FORMAT
- " with caps %" GST_PTR_FORMAT, caps, filter);
-
- result = gst_caps_intersect_full (caps, filter, GST_CAPS_INTERSECT_FIRST);
- gst_caps_unref (filter);
- return result;
-}
-
-static GstCaps *
-_intersect_with_mview_modes (GstCaps * caps, const GValue * modes)
-{
- GstCaps *filter, *result;
-
- filter = gst_caps_new_empty_simple ("video/x-raw");
-
- gst_caps_set_value (filter, "multiview-mode", modes);
- gst_caps_set_features (filter, 0, gst_caps_features_new_any ());
-
- GST_DEBUG ("Intersecting target caps %" GST_PTR_FORMAT
- " with caps %" GST_PTR_FORMAT, caps, filter);
-
- result = gst_caps_intersect_full (caps, filter, GST_CAPS_INTERSECT_FIRST);
- gst_caps_unref (filter);
- return result;
-}
-
-/**
- * gst_gl_view_convert_transform_caps:
- * @viewconvert: a #GstGLViewConvert
- * @direction: a #GstPadDirection
- * @caps: (transfer none): the #GstCaps to transform
- * @filter: (transfer none): a set of filter #GstCaps
- *
- * Provides an implementation of #GstBaseTransformClass::transform_caps()
- *
- * Returns: (transfer full): the converted #GstCaps
- *
- * Since: 1.6
- */
-GstCaps *
-gst_gl_view_convert_transform_caps (GstGLViewConvert * viewconvert,
- GstPadDirection direction, GstCaps * caps, GstCaps * filter)
-{
- gint i, n;
- GstCaps *base_caps = gst_static_caps_get (&caps_template);
- GstCaps *out_caps, *tmp_caps;
-
- g_return_val_if_fail (GST_IS_GL_VIEW_CONVERT (viewconvert), NULL);
-
- GST_DEBUG_OBJECT (viewconvert, "Direction %s "
- "input caps %" GST_PTR_FORMAT " filter %" GST_PTR_FORMAT,
- direction == GST_PAD_SINK ? "sink" : "src", caps, filter);
-
- /* We can only process GLmemory RGBA caps, start from that */
- caps = gst_caps_intersect (caps, base_caps);
- gst_caps_unref (base_caps);
-
- /* Change input/output to the formats we can convert to/from,
- * but keep the original caps at the start - we will always prefer
- * passthrough */
- if (direction == GST_PAD_SINK) {
- out_caps = gst_caps_copy (caps);
- if (viewconvert->input_mode_override != GST_VIDEO_MULTIVIEW_MODE_NONE) {
- GstVideoMultiviewMode mode = viewconvert->input_mode_override;
- GstVideoMultiviewFlags flags = viewconvert->input_flags_override;
-
- const gchar *caps_str = gst_video_multiview_mode_to_caps_string (mode);
- /* Coerce the input caps before transforming, so the sizes come out right */
- gst_caps_set_simple (out_caps, "multiview-mode", G_TYPE_STRING,
- caps_str, "multiview-flags", GST_TYPE_VIDEO_MULTIVIEW_FLAGSET, flags,
- GST_FLAG_SET_MASK_EXACT, NULL);
- }
- } else {
- out_caps = gst_caps_new_empty ();
- }
-
- for (i = 0; i < gst_caps_get_size (caps); i++) {
- GstStructure *structure = gst_caps_get_structure (caps, i);
- GstCapsFeatures *features = gst_caps_get_features (caps, i);
- out_caps = _expand_structure (viewconvert, out_caps, structure, features);
- }
-
- if (gst_caps_is_empty (out_caps))
- goto out;
-
- /* If we have an output mode override, limit things to that */
- if (direction == GST_PAD_SINK &&
- viewconvert->output_mode_override != GST_VIDEO_MULTIVIEW_MODE_NONE) {
-
- tmp_caps = _intersect_with_mview_mode (out_caps,
- viewconvert->output_mode_override, viewconvert->output_flags_override);
-
- gst_caps_unref (out_caps);
- out_caps = tmp_caps;
- } else if (viewconvert->input_mode_override != GST_VIDEO_MULTIVIEW_MODE_NONE) {
- /* Prepend a copy of our preferred input caps in case the peer
- * can handle them */
- tmp_caps = _intersect_with_mview_mode (out_caps,
- viewconvert->input_mode_override, viewconvert->input_flags_override);
- out_caps = gst_caps_merge (out_caps, tmp_caps);
- }
- if (direction == GST_PAD_SRC) {
- GstStructure *s;
- /* When generating input caps, we also need a copy of the mono caps
- * without multiview-mode or flags for backwards compat, at the end */
- tmp_caps = _intersect_with_mview_mode (caps,
- GST_VIDEO_MULTIVIEW_MODE_MONO, GST_VIDEO_MULTIVIEW_FLAGS_NONE);
- if (!gst_caps_is_empty (tmp_caps)) {
- s = gst_caps_get_structure (tmp_caps, 0);
- gst_structure_remove_fields (s, "multiview-mode", "multiview-flags",
- NULL);
- out_caps = gst_caps_merge (out_caps, tmp_caps);
- } else
- gst_caps_unref (tmp_caps);
- }
-out:
- gst_caps_unref (caps);
-
- n = gst_caps_get_size (out_caps);
- for (i = 0; i < n; i++) {
- GstStructure *s = gst_caps_get_structure (out_caps, i);
-
- gst_structure_remove_fields (s, "texture-target", NULL);
- }
-
- GST_DEBUG_OBJECT (viewconvert, "Returning caps %" GST_PTR_FORMAT, out_caps);
- return out_caps;
-}
-
-static guint
-_get_target_bitmask_from_g_value (const GValue * targets)
-{
- guint new_targets = 0;
-
- if (targets == NULL) {
- new_targets = 1 << GST_GL_TEXTURE_TARGET_2D;
- } else if (G_TYPE_CHECK_VALUE_TYPE (targets, G_TYPE_STRING)) {
- GstGLTextureTarget target;
- const gchar *str;
-
- str = g_value_get_string (targets);
- target = gst_gl_texture_target_from_string (str);
-
- if (target)
- new_targets |= 1 << target;
- } else if (G_TYPE_CHECK_VALUE_TYPE (targets, GST_TYPE_LIST)) {
- gint j, m;
-
- m = gst_value_list_get_size (targets);
- for (j = 0; j < m; j++) {
- const GValue *val = gst_value_list_get_value (targets, j);
- GstGLTextureTarget target;
- const gchar *str;
-
- str = g_value_get_string (val);
- target = gst_gl_texture_target_from_string (str);
- if (target)
- new_targets |= 1 << target;
- }
- }
-
- return new_targets;
-}
-
-static GstCaps *
-_fixate_texture_target (GstGLViewConvert * viewconvert,
- GstPadDirection direction, GstCaps * caps, GstCaps * other)
-{
- GValue item = G_VALUE_INIT;
- const GValue *targets, *other_targets;
- guint targets_mask = 0, other_targets_mask = 0, result_mask;
- GstStructure *s, *s_other;
-
- other = gst_caps_make_writable (other);
- s = gst_caps_get_structure (caps, 0);
- s_other = gst_caps_get_structure (other, 0);
-
- other_targets = gst_structure_get_value (s_other, "texture-target");
- targets = gst_structure_get_value (s, "texture-target");
-
- targets_mask = _get_target_bitmask_from_g_value (targets);
- other_targets_mask = _get_target_bitmask_from_g_value (other_targets);
-
- result_mask = targets_mask & other_targets_mask;
- if (result_mask == 0) {
- /* nothing we can do here */
- return gst_caps_fixate (other);
- }
-
- if (direction == GST_PAD_SINK) {
- result_mask &=
- (1 << GST_GL_TEXTURE_TARGET_2D | 1 << GST_GL_TEXTURE_TARGET_RECTANGLE);
- } else {
- /* if the src caps has 2D support we can 'convert' to anything */
- if (targets_mask & (1 << GST_GL_TEXTURE_TARGET_2D))
- result_mask = -1;
- else
- result_mask = other_targets_mask;
- }
-
- g_value_init (&item, G_TYPE_STRING);
- if (result_mask & (1 << GST_GL_TEXTURE_TARGET_2D)) {
- g_value_set_static_string (&item, GST_GL_TEXTURE_TARGET_2D_STR);
- } else if (result_mask & (1 << GST_GL_TEXTURE_TARGET_RECTANGLE)) {
- g_value_set_static_string (&item, GST_GL_TEXTURE_TARGET_RECTANGLE_STR);
- } else if (result_mask & (1 << GST_GL_TEXTURE_TARGET_EXTERNAL_OES)) {
- g_value_set_static_string (&item, GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR);
- }
-
- gst_structure_set_value (s_other, "texture-target", &item);
-
- g_value_unset (&item);
-
- return gst_caps_fixate (other);
-}
-
-/**
- * gst_gl_view_convert_fixate_caps:
- * @viewconvert: a #GstGLViewConvert
- * @direction: a #GstPadDirection
- * @caps: (transfer none): the #GstCaps of @direction
- * @othercaps: (transfer full): the #GstCaps to fixate
- *
- * Provides an implementation of #GstBaseTransformClass::fixate_caps()
- *
- * Returns: (transfer full): the fixated #GstCaps
- *
- * Since: 1.6
- */
-GstCaps *
-gst_gl_view_convert_fixate_caps (GstGLViewConvert * viewconvert,
- GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
-{
- GstVideoMultiviewMode mode = viewconvert->output_mode_override;
- GstVideoMultiviewFlags flags = viewconvert->output_flags_override;
- GstCaps *tmp;
-
- g_return_val_if_fail (GST_IS_GL_VIEW_CONVERT (viewconvert), NULL);
-
- othercaps = gst_caps_make_writable (othercaps);
- GST_LOG_OBJECT (viewconvert, "dir %s fixating %" GST_PTR_FORMAT
- " against caps %" GST_PTR_FORMAT,
- direction == GST_PAD_SINK ? "sink" : "src", othercaps, caps);
-
- if (direction == GST_PAD_SINK) {
- if (mode != GST_VIDEO_MULTIVIEW_MODE_NONE) {
- /* We have a requested output mode and are fixating source caps, try and enforce it */
- tmp = _intersect_with_mview_mode (othercaps, mode, flags);
- gst_caps_unref (othercaps);
- othercaps = tmp;
- } else {
- /* See if we can do passthrough */
- GstVideoInfo info;
-
- if (gst_video_info_from_caps (&info, caps)) {
- GstVideoMultiviewMode mode = GST_VIDEO_INFO_MULTIVIEW_MODE (&info);
- GstVideoMultiviewFlags flags = GST_VIDEO_INFO_MULTIVIEW_FLAGS (&info);
-
- if (viewconvert->input_mode_override != GST_VIDEO_MULTIVIEW_MODE_NONE) {
- mode = viewconvert->input_mode_override;
- flags = viewconvert->input_flags_override;
- }
-
- tmp = _intersect_with_mview_mode (othercaps, mode, flags);
- if (gst_caps_is_empty (tmp)) {
- /* Nope, we can't pass our input caps downstream */
- gst_caps_unref (tmp);
- } else {
- gst_caps_unref (othercaps);
- othercaps = tmp;
- goto done;
- }
- }
-
- /* Prefer an unpacked mode for output */
- tmp =
- _intersect_with_mview_modes (othercaps,
- gst_video_multiview_get_unpacked_modes ());
- if (!gst_caps_is_empty (tmp)) {
- gst_caps_unref (othercaps);
- othercaps = tmp;
- } else {
- gst_caps_unref (tmp);
- }
- }
- } else if (viewconvert->input_mode_override != GST_VIDEO_MULTIVIEW_MODE_NONE) {
- /* See if we can coerce the caps into matching input mode/flags,
- * in case it doesn't care at all, but allow it not to too */
- mode = viewconvert->input_mode_override;
- flags = viewconvert->input_flags_override;
- tmp = _intersect_with_mview_mode (othercaps, mode, flags);
- if (gst_caps_is_empty (tmp)) {
- /* Nope, we can pass our input caps downstream */
- gst_caps_unref (tmp);
- } else {
- gst_caps_unref (othercaps);
- othercaps = tmp;
- }
- }
-
- othercaps = _fixate_texture_target (viewconvert, direction, caps, othercaps);
-
-done:
- GST_DEBUG_OBJECT (viewconvert, "dir %s fixated to %" GST_PTR_FORMAT
- " against caps %" GST_PTR_FORMAT,
- direction == GST_PAD_SINK ? "sink" : "src", othercaps, caps);
- return othercaps;
-}
-
-/**
- * gst_gl_view_convert_reset:
- * @viewconvert: a #GstGLViewConvert
- *
- * Reset @viewconvert to the default state. Further operation will require
- * setting the caps with gst_gl_view_convert_set_caps().
- *
- * Since: 1.6
- */
-void
-gst_gl_view_convert_reset (GstGLViewConvert * viewconvert)
-{
- g_return_if_fail (GST_IS_GL_VIEW_CONVERT (viewconvert));
- if (viewconvert->shader)
- gst_object_unref (viewconvert->shader);
- viewconvert->shader = NULL;
-
- if (viewconvert->fbo)
- gst_object_unref (viewconvert->fbo);
- viewconvert->fbo = NULL;
-
- viewconvert->initted = FALSE;
- viewconvert->reconfigure = FALSE;
-}
-
-static void
-gst_gl_view_convert_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstGLViewConvert *convert = GST_GL_VIEW_CONVERT (object);
- switch (prop_id) {
- case PROP_INPUT_LAYOUT:
- convert->input_mode_override = g_value_get_enum (value);
- break;
- case PROP_INPUT_FLAGS:
- convert->input_flags_override = g_value_get_flags (value);
- break;
- case PROP_OUTPUT_LAYOUT:
- convert->output_mode_override = g_value_get_enum (value);
- break;
- case PROP_OUTPUT_FLAGS:
- convert->output_flags_override = g_value_get_flags (value);
- break;
- case PROP_OUTPUT_DOWNMIX_MODE:
- convert->downmix_mode = g_value_get_enum (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
- GST_OBJECT_LOCK (convert);
- convert->reconfigure = TRUE;
- GST_OBJECT_UNLOCK (convert);
-}
-
-static void
-gst_gl_view_convert_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstGLViewConvert *convert = GST_GL_VIEW_CONVERT (object);
- switch (prop_id) {
- case PROP_INPUT_LAYOUT:
- g_value_set_enum (value, convert->input_mode_override);
- break;
- case PROP_INPUT_FLAGS:
- g_value_set_flags (value, convert->input_flags_override);
- break;
- case PROP_OUTPUT_LAYOUT:
- g_value_set_enum (value, convert->output_mode_override);
- break;
- case PROP_OUTPUT_FLAGS:
- g_value_set_flags (value, convert->output_flags_override);
- break;
- case PROP_OUTPUT_DOWNMIX_MODE:
- g_value_set_enum (value, convert->downmix_mode);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/**
- * gst_gl_view_convert_perform:
- * @viewconvert: a #GstGLViewConvert
- * @inbuf: (transfer none): the #GstGLMemory filled #GstBuffer to convert
- *
- * Converts the data contained by @inbuf using the formats specified by the
- * #GstCaps passed to gst_gl_view_convert_set_caps()
- *
- * Returns: (transfer full): a converted #GstBuffer or %NULL
- *
- * Since: 1.6
- */
-GstBuffer *
-gst_gl_view_convert_perform (GstGLViewConvert * viewconvert, GstBuffer * inbuf)
-{
- GstBuffer *out;
-
- if (gst_gl_view_convert_submit_input_buffer (viewconvert,
- GST_BUFFER_IS_DISCONT (inbuf), gst_buffer_ref (inbuf)) != GST_FLOW_OK)
- return NULL;
- if (gst_gl_view_convert_get_output (viewconvert, &out) != GST_FLOW_OK)
- return NULL;
-
- return out;
-}
-
-/* called by _init_convert (in the gl thread) */
-static gboolean
-_init_view_convert_fbo (GstGLViewConvert * viewconvert)
-{
- guint out_width, out_height;
-
- out_width = GST_VIDEO_INFO_WIDTH (&viewconvert->out_info);
- out_height = GST_VIDEO_INFO_HEIGHT (&viewconvert->out_info);
-
- viewconvert->fbo =
- gst_gl_framebuffer_new_with_default_depth (viewconvert->context,
- out_width, out_height);
-
- return viewconvert->fbo != NULL;
-}
-
-/* free after use */
-static gchar *
-_get_shader_string (GstGLViewConvert * viewconvert, GstGLShader * shader,
- GstVideoMultiviewMode in_mode, GstVideoMultiviewMode out_mode,
- GstGLSLVersion version, GstGLSLProfile profile)
-{
- const gchar *input_str, *output_str;
- gboolean mono_input = FALSE;
- gchar *tmp, *tmp2;
- GString *str = g_string_new (NULL);
- guint n_outputs = 1;
-
- switch (in_mode) {
- case GST_VIDEO_MULTIVIEW_MODE_NONE:
- case GST_VIDEO_MULTIVIEW_MODE_MONO:
- case GST_VIDEO_MULTIVIEW_MODE_LEFT:
- case GST_VIDEO_MULTIVIEW_MODE_RIGHT:
- mono_input = TRUE;
- /* Fall through */
- default:
- input_str = frag_input;
- break;
- }
-
- switch (out_mode) {
- case GST_VIDEO_MULTIVIEW_MODE_LEFT:
- output_str = frag_output_left;
- break;
- case GST_VIDEO_MULTIVIEW_MODE_RIGHT:
- output_str = frag_output_right;
- break;
- case GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE_QUINCUNX:
- /* FIXME: implement properly with sub-sampling */
- case GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE:
- output_str = frag_output_side_by_side;
- break;
- case GST_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM:
- output_str = frag_output_top_bottom;
- break;
- case GST_VIDEO_MULTIVIEW_MODE_COLUMN_INTERLEAVED:
- output_str = frag_output_column_interleaved;
- break;
- case GST_VIDEO_MULTIVIEW_MODE_ROW_INTERLEAVED:
- output_str = frag_output_row_interleaved;
- break;
- case GST_VIDEO_MULTIVIEW_MODE_SEPARATED:
- case GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME:
- output_str = frag_output_separated;
- n_outputs = 2;
- break;
- case GST_VIDEO_MULTIVIEW_MODE_CHECKERBOARD:
- output_str = frag_output_checkerboard;
- break;
- case GST_VIDEO_MULTIVIEW_MODE_NONE:
- case GST_VIDEO_MULTIVIEW_MODE_MONO:
- default:
- if (mono_input)
- output_str = frag_output_left;
- else
- output_str = frag_output_downmix;
- break;
- }
-
- if (viewconvert->from_texture_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES)
- g_string_append (str, glsl_OES_extension_string);
-
- g_string_append (str, fragment_header);
-
- /* GL 3.3+ and GL ES 3.x */
- if ((profile == GST_GLSL_PROFILE_CORE && version >= GST_GLSL_VERSION_330)
- || (profile == GST_GLSL_PROFILE_ES && version >= GST_GLSL_VERSION_300)) {
- if (n_outputs > 1) {
- gint i;
-
- for (i = 0; i < n_outputs; i++) {
- g_string_append_printf (str,
- "layout(location = %d) out vec4 fragColor_%d;\n", i, i);
- }
- } else {
- g_string_append (str, "layout (location = 0) out vec4 fragColor;\n");
- }
- } else if (profile == GST_GLSL_PROFILE_CORE
- && version >= GST_GLSL_VERSION_150) {
- /* no layout specifiers, use glBindFragDataLocation instead */
- if (n_outputs > 1) {
- gint i;
-
- for (i = 0; i < n_outputs; i++) {
- gchar *var_name = g_strdup_printf ("fragColor_%d", i);
- g_string_append_printf (str, "out vec4 %s;\n", var_name);
- gst_gl_shader_bind_frag_data_location (shader, i, var_name);
- g_free (var_name);
- }
- } else {
- g_string_append (str, "out vec4 fragColor;\n");
- gst_gl_shader_bind_frag_data_location (shader, 0, "fragColor");
- }
- }
-
- {
- const gchar *varying = NULL;
-
- if ((profile == GST_GLSL_PROFILE_ES && version >= GST_GLSL_VERSION_300)
- || (profile == GST_GLSL_PROFILE_CORE
- && version >= GST_GLSL_VERSION_150)) {
- varying = "in";
- } else {
- varying = "varying";
- }
- g_string_append_printf (str,
- "\n%s vec2 v_texcoord;\nvoid main() {\nvec4 l, r;\n", varying);
- }
-
- g_string_append (str, input_str);
- g_string_append (str, output_str);
- g_string_append (str, "\n}");
- tmp = g_string_free (str, FALSE);
-
- tmp2 =
- _gst_glsl_mangle_shader (tmp, GL_FRAGMENT_SHADER,
- GST_GL_TEXTURE_TARGET_2D, viewconvert->from_texture_target,
- viewconvert->context, &version, &profile);
-
- return tmp2;
-}
-
-static void
-_bind_buffer (GstGLViewConvert * viewconvert)
-{
- const GstGLFuncs *gl = viewconvert->context->gl_vtable;
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, viewconvert->priv->vbo_indices);
- gl->BindBuffer (GL_ARRAY_BUFFER, viewconvert->priv->vertex_buffer);
- /* Load the vertex position */
- gl->VertexAttribPointer (viewconvert->priv->attr_position, 3, GL_FLOAT,
- GL_FALSE, 5 * sizeof (GLfloat), (void *) 0);
- /* Load the texture coordinate */
- gl->VertexAttribPointer (viewconvert->priv->attr_texture, 2, GL_FLOAT,
- GL_FALSE, 5 * sizeof (GLfloat), (void *) (3 * sizeof (GLfloat)));
- gl->EnableVertexAttribArray (viewconvert->priv->attr_position);
- gl->EnableVertexAttribArray (viewconvert->priv->attr_texture);
-}
-
-static void
-_unbind_buffer (GstGLViewConvert * viewconvert)
-{
- const GstGLFuncs *gl = viewconvert->context->gl_vtable;
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
- gl->BindBuffer (GL_ARRAY_BUFFER, 0);
- gl->DisableVertexAttribArray (viewconvert->priv->attr_position);
- gl->DisableVertexAttribArray (viewconvert->priv->attr_texture);
-}
-
-/* Called in the gl thread */
-static gboolean
-_init_view_convert (GstGLViewConvert * viewconvert)
-{
- GstGLViewConvertPrivate *priv = viewconvert->priv;
- GstVideoMultiviewMode in_mode = priv->input_mode;
- GstVideoMultiviewMode out_mode = priv->output_mode;
- GstVideoMultiviewFlags in_flags = priv->input_flags;
- GstVideoMultiviewFlags out_flags = priv->output_flags;
- gfloat tex_scale[2][2] = {
- {1., 1.},
- {1., 1.}
- };
- gfloat offsets[2][2] = {
- {0., 0.},
- {0., 0.}
- };
- gchar *fragment_source_str;
- GstGLFuncs *gl;
- gint l_index, r_index;
-
- gl = viewconvert->context->gl_vtable;
- if (viewconvert->reconfigure)
- gst_gl_view_convert_reset (viewconvert);
- if (viewconvert->initted)
- return TRUE;
-
- GST_LOG_OBJECT (viewconvert,
- "Initializing multiview conversion from %s mode %d flags 0x%x w %u h %u to "
- "%s mode %d flags 0x%x w %u h %u",
- gst_video_format_to_string (GST_VIDEO_INFO_FORMAT
- (&viewconvert->in_info)), in_mode, in_flags,
- viewconvert->in_info.width, viewconvert->in_info.height,
- gst_video_format_to_string (GST_VIDEO_INFO_FORMAT
- (&viewconvert->out_info)), out_mode, out_flags,
- viewconvert->out_info.width, viewconvert->out_info.height);
-
- if (!gl->CreateProgramObject && !gl->CreateProgram) {
- GST_ERROR_OBJECT (viewconvert, "Cannot perform multiview conversion "
- "without OpenGL shaders");
- goto error;
- }
-
- if (out_mode == GST_VIDEO_MULTIVIEW_MODE_SEPARATED
- || out_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME) {
- if (!gl->DrawBuffers) {
- GST_ERROR_OBJECT (viewconvert,
- "Separate texture output mode requested however the current "
- "OpenGL API does not support drawing to multiple buffers");
- goto error;
- }
- }
-
- if ((in_flags & GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST) ==
- (out_flags & GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST)) {
- l_index = 0;
- r_index = 1;
- } else {
- GST_LOG_OBJECT (viewconvert, "Switching left/right views");
- /* Swap the views */
- l_index = 1;
- r_index = 0;
- }
-
- if (in_mode < GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE) { /* unknown/mono/left/right single image */
- } else if (in_mode == GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE ||
- in_mode == GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE_QUINCUNX) {
- /* Side-by-side input */
- offsets[r_index][0] += 0.5 * tex_scale[r_index][0];
- tex_scale[0][0] *= 0.5f; /* Half horizontal scale */
- tex_scale[1][0] *= 0.5f;
- } else if (in_mode == GST_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM) { /* top-bottom */
- offsets[r_index][1] += 0.5 * tex_scale[r_index][1];
- tex_scale[0][1] *= 0.5f; /* Half vertical scale */
- tex_scale[1][1] *= 0.5f;
- }
-
- /* Flipped is vertical, flopped is horizontal.
- * Adjust and offset per-view scaling. This needs to be done
- * after the input scaling already splits the views, before
- * adding any output scaling. */
- if ((in_flags & GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED) !=
- (out_flags & GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED)) {
- offsets[l_index][1] += tex_scale[l_index][1];
- tex_scale[l_index][1] *= -1.0;
- }
- if ((in_flags & GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLOPPED) !=
- (out_flags & GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLOPPED)) {
- offsets[l_index][0] += tex_scale[l_index][0];
- tex_scale[l_index][0] *= -1.0;
- }
- if ((in_flags & GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLIPPED) !=
- (out_flags & GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLIPPED)) {
- offsets[r_index][1] += tex_scale[r_index][1];
- tex_scale[r_index][1] *= -1.0;
- }
- if ((in_flags & GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED) !=
- (out_flags & GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED)) {
- offsets[r_index][0] += tex_scale[r_index][0];
- tex_scale[r_index][0] *= -1.0;
- }
-
- if (out_mode == GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE ||
- out_mode == GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE_QUINCUNX) {
- /* Side-by-Side */
- offsets[1][0] -= tex_scale[1][0];
- tex_scale[0][0] *= 2.0f;
- tex_scale[1][0] *= 2.0f;
- } else if (out_mode == GST_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM) {
- offsets[1][1] -= tex_scale[1][1];
- tex_scale[0][1] *= 2.0f;
- tex_scale[1][1] *= 2.0f;
- }
-
- GST_DEBUG_OBJECT (viewconvert,
- "Scaling matrix [ %f, %f ] [ %f %f]. Offsets [ %f, %f ] [ %f, %f ]",
- tex_scale[0][0], tex_scale[0][1],
- tex_scale[1][0], tex_scale[1][1],
- offsets[0][0], offsets[0][1], offsets[1][0], offsets[1][1]);
-
- viewconvert->shader = gst_gl_shader_new (viewconvert->context);
- {
- GstGLSLVersion version;
- GstGLSLProfile profile;
- GstGLSLStage *vert, *frag;
- gchar *tmp, *tmp1, *version_str;
- const gchar *strings[2];
- GError *error = NULL;
-
- tmp =
- _gst_glsl_mangle_shader
- (gst_gl_shader_string_vertex_mat4_vertex_transform, GL_VERTEX_SHADER,
- GST_GL_TEXTURE_TARGET_2D, viewconvert->from_texture_target,
- viewconvert->context, &version, &profile);
-
- tmp1 = gst_glsl_version_profile_to_string (version, profile);
- version_str = g_strdup_printf ("#version %s\n", tmp1);
- g_free (tmp1);
- strings[0] = version_str;
-
- strings[1] = tmp;
- vert =
- gst_glsl_stage_new_with_strings (viewconvert->context,
- GL_VERTEX_SHADER, version, profile, 2, strings);
- g_free (tmp);
-
- if (!gst_gl_shader_compile_attach_stage (viewconvert->shader, vert, &error)) {
- GST_ERROR_OBJECT (viewconvert, "Failed to compile vertex stage %s",
- error->message);
- gst_object_unref (viewconvert->shader);
- viewconvert->shader = NULL;
- g_free (version_str);
- goto error;
- }
-
- fragment_source_str = _get_shader_string (viewconvert, viewconvert->shader,
- in_mode, out_mode, version, profile);
- strings[1] = fragment_source_str;
-
- frag =
- gst_glsl_stage_new_with_strings (viewconvert->context,
- GL_FRAGMENT_SHADER, version, profile, 2, strings);
- g_free (version_str);
-
- if (!gst_gl_shader_compile_attach_stage (viewconvert->shader, frag, &error)) {
- GST_ERROR_OBJECT (viewconvert, "Failed to compile fragment stage %s",
- error->message);
- g_free (fragment_source_str);
- gst_object_unref (viewconvert->shader);
- viewconvert->shader = NULL;
- goto error;
- }
- g_free (fragment_source_str);
-
- if (!gst_gl_shader_link (viewconvert->shader, &error)) {
- GST_ERROR_OBJECT (viewconvert, "Failed to link conversion shader %s",
- error->message);
- gst_object_unref (viewconvert->shader);
- viewconvert->shader = NULL;
- goto error;
- }
- }
-
- viewconvert->priv->attr_position =
- gst_gl_shader_get_attribute_location (viewconvert->shader, "a_position");
- viewconvert->priv->attr_texture =
- gst_gl_shader_get_attribute_location (viewconvert->shader, "a_texcoord");
- gst_gl_shader_use (viewconvert->shader);
- gst_gl_shader_set_uniform_2fv (viewconvert->shader, "tex_scale",
- 2, tex_scale[0]);
- gst_gl_shader_set_uniform_2fv (viewconvert->shader, "offsets", 2, offsets[0]);
- gst_gl_shader_set_uniform_1f (viewconvert->shader, "width",
- GST_VIDEO_INFO_WIDTH (&viewconvert->out_info));
- gst_gl_shader_set_uniform_1f (viewconvert->shader, "height",
- GST_VIDEO_INFO_HEIGHT (&viewconvert->out_info));
- gst_gl_shader_set_uniform_matrix_3fv (viewconvert->shader, "downmix",
- 2, FALSE, &downmix_matrices[viewconvert->downmix_mode][0][0]);
- gst_gl_shader_set_uniform_matrix_4fv (viewconvert->shader, "u_transformation",
- 1, FALSE, identity_matrix);
- if (in_mode == GST_VIDEO_MULTIVIEW_MODE_SEPARATED ||
- in_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME) {
- gst_gl_shader_set_uniform_1i (viewconvert->shader, "tex_l", l_index);
- gst_gl_shader_set_uniform_1i (viewconvert->shader, "tex_r", r_index);
- } else {
- gst_gl_shader_set_uniform_1i (viewconvert->shader, "tex_l", 0);
- gst_gl_shader_set_uniform_1i (viewconvert->shader, "tex_r", 0);
- }
- gst_gl_context_clear_shader (viewconvert->context);
- if (!_init_view_convert_fbo (viewconvert)) {
- goto error;
- }
-
- if (!viewconvert->priv->vertex_buffer) {
- if (gl->GenVertexArrays) {
- gl->GenVertexArrays (1, &viewconvert->priv->vao);
- gl->BindVertexArray (viewconvert->priv->vao);
- }
-
- gl->GenBuffers (1, &viewconvert->priv->vertex_buffer);
- gl->BindBuffer (GL_ARRAY_BUFFER, viewconvert->priv->vertex_buffer);
- gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), vertices,
- GL_STATIC_DRAW);
- gl->GenBuffers (1, &viewconvert->priv->vbo_indices);
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, viewconvert->priv->vbo_indices);
- gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
- GL_STATIC_DRAW);
- if (gl->GenVertexArrays) {
- _bind_buffer (viewconvert);
- gl->BindVertexArray (0);
- }
-
- gl->BindBuffer (GL_ARRAY_BUFFER, 0);
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
- }
-
- viewconvert->initted = TRUE;
- return TRUE;
-error:
- return FALSE;
-}
-
-static gboolean
-_do_view_convert_draw (GstGLContext * context, GstGLViewConvert * viewconvert)
-{
- GstGLViewConvertPrivate *priv = viewconvert->priv;
- GstGLFuncs *gl;
- guint out_width, out_height;
- gint out_views, i;
- GLint viewport_dim[4] = { 0 };
- GLenum multipleRT[] = {
- GL_COLOR_ATTACHMENT0,
- GL_COLOR_ATTACHMENT1,
- GL_COLOR_ATTACHMENT2
- };
- GstVideoMultiviewMode in_mode = priv->input_mode;
- GstVideoMultiviewMode out_mode = priv->output_mode;
- guint from_gl_target =
- gst_gl_texture_target_to_gl (viewconvert->from_texture_target);
-
- gl = context->gl_vtable;
-
- gst_gl_framebuffer_bind (viewconvert->fbo);
-
- if (out_mode == GST_VIDEO_MULTIVIEW_MODE_SEPARATED ||
- out_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME) {
- out_views = viewconvert->out_info.views;
- } else {
- out_views = 1;
- }
-
- /* attach the texture to the FBO to renderer to */
- for (i = 0; i < out_views; i++) {
- GstGLBaseMemory *tex = (GstGLBaseMemory *) priv->out_tex[i];
-
- gst_gl_framebuffer_attach (viewconvert->fbo, GL_COLOR_ATTACHMENT0 + i, tex);
- }
-
- if (gl->DrawBuffers)
- gl->DrawBuffers (out_views, multipleRT);
- else if (gl->DrawBuffer)
- gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
-
- gst_gl_framebuffer_get_effective_dimensions (viewconvert->fbo, &out_width,
- &out_height);
- gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
- gl->Viewport (0, 0, out_width, out_height);
-
- gst_gl_shader_use (viewconvert->shader);
-
- /* FIXME: the auxillary buffer could have a different transform matrix */
- {
- GstVideoAffineTransformationMeta *af_meta;
- gfloat matrix[16];
-
- af_meta =
- gst_buffer_get_video_affine_transformation_meta (priv->primary_in);
- gst_gl_get_affine_transformation_meta_as_ndc (af_meta, matrix);
- gst_gl_shader_set_uniform_matrix_4fv (viewconvert->shader,
- "u_transformation", 1, FALSE, matrix);
- }
-
- if (gl->BindVertexArray)
- gl->BindVertexArray (priv->vao);
- _bind_buffer (viewconvert);
-
- if (in_mode == GST_VIDEO_MULTIVIEW_MODE_SEPARATED ||
- in_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME) {
- if (priv->in_tex[1] == NULL) {
- GST_ERROR_OBJECT (viewconvert,
- "No 2nd view available during conversion!");
- return FALSE;
- }
- gl->ActiveTexture (GL_TEXTURE1);
- gl->BindTexture (from_gl_target, priv->in_tex[1]->tex_id);
- }
-
- gl->ActiveTexture (GL_TEXTURE0);
- gl->BindTexture (from_gl_target, priv->in_tex[0]->tex_id);
-
- gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, NULL);
-
- if (gl->BindVertexArray)
- gl->BindVertexArray (0);
- _unbind_buffer (viewconvert);
- if (gl->DrawBuffer)
- gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
- /* we are done with the shader */
- gst_gl_context_clear_shader (context);
- gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
- viewport_dim[3]);
- gst_gl_context_clear_framebuffer (context);
-
- return TRUE;
-}
-
-static gboolean
-_gen_buffer (GstGLViewConvert * viewconvert, GstBuffer ** target)
-{
- GstGLVideoAllocationParams *params;
- GstGLMemoryAllocator *mem_allocator;
- GstAllocator *allocator;
-
- *target = gst_buffer_new ();
-
- allocator =
- GST_ALLOCATOR (gst_gl_memory_allocator_get_default
- (viewconvert->context));
- mem_allocator = GST_GL_MEMORY_ALLOCATOR (allocator);
- params = gst_gl_video_allocation_params_new (viewconvert->context, NULL,
- &viewconvert->out_info, 0, NULL, viewconvert->to_texture_target, 0);
-
- if (!gst_gl_memory_setup_buffer (mem_allocator, *target, params, NULL, NULL,
- 0)) {
- gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
- gst_object_unref (allocator);
- return FALSE;
- }
- gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
- gst_object_unref (allocator);
-
- gst_buffer_add_video_meta_full (*target, 0,
- GST_VIDEO_INFO_FORMAT (&viewconvert->out_info),
- GST_VIDEO_INFO_WIDTH (&viewconvert->out_info),
- GST_VIDEO_INFO_HEIGHT (&viewconvert->out_info),
- GST_VIDEO_INFO_N_PLANES (&viewconvert->out_info),
- viewconvert->out_info.offset, viewconvert->out_info.stride);
-
- return TRUE;
-}
-
-static void
-_do_view_convert (GstGLContext * context, GstGLViewConvert * viewconvert)
-{
- GstGLViewConvertPrivate *priv = viewconvert->priv;
- guint in_width, in_height, out_width, out_height;
- GstMapInfo out_info[GST_VIDEO_MAX_PLANES], in_info[GST_VIDEO_MAX_PLANES];
- GstGLMemory *dest_tex[GST_VIDEO_MAX_PLANES];
- gboolean res = TRUE;
- gint i = 0, j = 0;
- gint in_views, out_views;
- GstVideoMultiviewMode in_mode;
- GstVideoMultiviewMode out_mode;
-
- out_width = GST_VIDEO_INFO_WIDTH (&viewconvert->out_info);
- out_height = GST_VIDEO_INFO_HEIGHT (&viewconvert->out_info);
- in_width = GST_VIDEO_INFO_WIDTH (&viewconvert->in_info);
- in_height = GST_VIDEO_INFO_HEIGHT (&viewconvert->in_info);
-
- g_return_if_fail (priv->primary_out == NULL);
- g_return_if_fail (priv->auxilliary_out == NULL);
-
- in_mode = priv->input_mode;
- out_mode = priv->output_mode;
-
- if (in_mode == GST_VIDEO_MULTIVIEW_MODE_SEPARATED ||
- in_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME)
- in_views = viewconvert->in_info.views;
- else
- in_views = 1;
-
- if (out_mode == GST_VIDEO_MULTIVIEW_MODE_SEPARATED ||
- out_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME)
- out_views = viewconvert->out_info.views;
- else
- out_views = 1;
-
- if (!_init_view_convert (viewconvert)) {
- priv->result = FALSE;
- return;
- }
-
- if (!_gen_buffer (viewconvert, &priv->primary_out)) {
- GST_ERROR_OBJECT (viewconvert,
- "Failed to setup memory for primary output buffer");
- priv->result = FALSE;
- return;
- }
-
- if (out_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME) {
- if (!_gen_buffer (viewconvert, &priv->auxilliary_out)) {
- GST_ERROR_OBJECT (viewconvert,
- "Failed to setup memory for second view output buffer");
- priv->result = FALSE;
- return;
- }
- }
-
- for (i = 0; i < in_views; i++) {
- if (in_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME && i > 0) {
- priv->in_tex[i] =
- (GstGLMemory *) gst_buffer_peek_memory (priv->auxilliary_in, 0);
- } else {
- priv->in_tex[i] =
- (GstGLMemory *) gst_buffer_peek_memory (priv->primary_in, i);
- }
- if (!gst_is_gl_memory ((GstMemory *) priv->in_tex[i])) {
- GST_ERROR_OBJECT (viewconvert, "input must be GstGLMemory");
- res = FALSE;
- goto out;
- }
- if (!gst_memory_map ((GstMemory *) priv->in_tex[i],
- &in_info[i], GST_MAP_READ | GST_MAP_GL)) {
- GST_ERROR_OBJECT (viewconvert, "failed to map input memory %p",
- priv->in_tex[i]);
- res = FALSE;
- goto out;
- }
- }
-
- for (j = 0; j < out_views; j++) {
- GstGLMemory *out_tex;
- guint width, height;
- GstVideoInfo temp_info;
-
- if (j > 0 && out_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME) {
- dest_tex[j] = out_tex =
- (GstGLMemory *) gst_buffer_peek_memory (priv->auxilliary_out, 0);
- } else {
- dest_tex[j] = out_tex =
- (GstGLMemory *) gst_buffer_peek_memory (priv->primary_out, j);
- }
-
- if (!gst_is_gl_memory ((GstMemory *) out_tex)) {
- GST_ERROR_OBJECT (viewconvert, "output must be GstGLMemory");
- res = FALSE;
- goto out;
- }
-
- width = gst_gl_memory_get_texture_width (out_tex);
- height = gst_gl_memory_get_texture_height (out_tex);
- gst_video_info_set_format (&temp_info, GST_VIDEO_FORMAT_RGBA, width,
- height);
- if (out_tex->tex_format == GST_GL_LUMINANCE
- || out_tex->tex_format == GST_GL_LUMINANCE_ALPHA
- || out_width != width || out_height != height) {
- /* Luminance formats are not color renderable */
- /* renderering to a framebuffer only renders the intersection of all
- * the attachments i.e. the smallest attachment size */
- if (!priv->out_tex[j]) {
- GstGLVideoAllocationParams *params;
- GstGLBaseMemoryAllocator *base_mem_allocator;
- GstAllocator *allocator;
- GstVideoInfo temp_info;
-
- gst_video_info_set_format (&temp_info, GST_VIDEO_FORMAT_RGBA, out_width,
- out_height);
-
- allocator =
- GST_ALLOCATOR (gst_gl_memory_allocator_get_default (context));
- base_mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator);
- params = gst_gl_video_allocation_params_new (context, NULL, &temp_info,
- 0, NULL, viewconvert->to_texture_target, GST_GL_RGBA);
-
- priv->out_tex[j] =
- (GstGLMemory *) gst_gl_base_memory_alloc (base_mem_allocator,
- (GstGLAllocationParams *) params);
-
- gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
- gst_object_unref (allocator);
- }
- } else {
- priv->out_tex[j] = out_tex;
- }
-
- if (!gst_memory_map ((GstMemory *) priv->out_tex[j],
- &out_info[j], GST_MAP_WRITE | GST_MAP_GL)) {
- GST_ERROR_OBJECT (viewconvert, "failed to map output memory %p",
- priv->out_tex[i]);
- res = FALSE;
- goto out;
- }
- }
- priv->n_out_tex = out_views;
-
- GST_LOG_OBJECT (viewconvert, "multiview splitting to textures:%p,%p,%p,%p "
- "dimensions:%ux%u, from textures:%p,%p,%p,%p dimensions:%ux%u",
- priv->out_tex[0], priv->out_tex[1],
- priv->out_tex[2], priv->out_tex[3],
- out_width, out_height, priv->in_tex[0],
- priv->in_tex[1], priv->in_tex[2], priv->in_tex[3], in_width, in_height);
-
- if (!_do_view_convert_draw (context, viewconvert))
- res = FALSE;
-out:
- for (j--; j >= 0; j--) {
- GstGLMemory *out_tex;
- guint width, height;
-
- out_tex = dest_tex[j];
-
- width = gst_gl_memory_get_texture_width (out_tex);
- height = gst_gl_memory_get_texture_height (out_tex);
-
- gst_memory_unmap ((GstMemory *) priv->out_tex[j], &out_info[j]);
- if (out_tex != priv->out_tex[j]) {
- GstMapInfo to_info, from_info;
- if (!gst_memory_map ((GstMemory *) priv->out_tex[j],
- &from_info, GST_MAP_READ | GST_MAP_GL)) {
- GST_ERROR_OBJECT (viewconvert, "Failed to map intermediate memory");
- res = FALSE;
- continue;
- }
- if (!gst_memory_map ((GstMemory *) out_tex, &to_info,
- GST_MAP_WRITE | GST_MAP_GL)) {
- GST_ERROR_OBJECT (viewconvert, "Failed to map intermediate memory");
- res = FALSE;
- continue;
- }
- gst_gl_memory_copy_into (priv->out_tex[j], out_tex->tex_id,
- viewconvert->to_texture_target, out_tex->tex_format, width, height);
- gst_memory_unmap ((GstMemory *) out_tex, &to_info);
- }
-
- priv->out_tex[j] = NULL;
- }
-
- for (i--; i >= 0; i--) {
- gst_memory_unmap ((GstMemory *) priv->in_tex[i], &in_info[i]);
- }
-
- if (!res) {
- gst_buffer_replace (&priv->primary_out, NULL);
- gst_buffer_replace (&priv->auxilliary_out, NULL);
- }
-
- priv->result = res;
- return;
-}
-
-/**
- * gst_gl_view_convert_submit_input_buffer:
- * @viewconvert: a #GstGLViewConvert
- * @is_discont: true if we have a discontinuity
- * @input: (transfer full): a #GstBuffer
- *
- * Submit @input to be processed by @viewconvert
- *
- * Returns: a #GstFlowReturn
- *
- * Since: 1.6
- */
-GstFlowReturn
-gst_gl_view_convert_submit_input_buffer (GstGLViewConvert * viewconvert,
- gboolean is_discont, GstBuffer * input)
-{
- GstFlowReturn ret = GST_FLOW_OK;
- GstVideoMultiviewMode mode;
- GstBuffer **target;
-
- if (is_discont) {
- gst_buffer_replace (&viewconvert->priv->primary_in, NULL);
- gst_buffer_replace (&viewconvert->priv->auxilliary_in, NULL);
- }
-
- mode = viewconvert->input_mode_override;
- if (mode == GST_VIDEO_MULTIVIEW_MODE_NONE)
- mode = GST_VIDEO_INFO_MULTIVIEW_MODE (&viewconvert->in_info);
-
- target = &viewconvert->priv->primary_in;
-
- /* For frame-by-frame mode, we need to collect the 2nd eye into
- * our auxilliary buffer */
- if (mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME) {
- if (!GST_BUFFER_FLAG_IS_SET (input, GST_VIDEO_BUFFER_FLAG_FIRST_IN_BUNDLE))
- target = &viewconvert->priv->auxilliary_in;
- }
-
- if (*target)
- gst_buffer_unref (*target);
- *target = input;
-
- return ret;
-}
-
-/**
- * gst_gl_view_convert_get_output:
- * @viewconvert: a #GstGLViewConvert
- * @outbuf_ptr: (out): a #GstBuffer
- *
- * Retrieve the processed output buffer placing the output in @outbuf_ptr.
- *
- * Returns: a #GstFlowReturn
- *
- * Since: 1.6
- */
-GstFlowReturn
-gst_gl_view_convert_get_output (GstGLViewConvert * viewconvert,
- GstBuffer ** outbuf_ptr)
-{
- GstGLViewConvertPrivate *priv = viewconvert->priv;
- GstBuffer *outbuf = NULL;
- GstFlowReturn ret = GST_FLOW_OK;
- GstVideoMultiviewMode in_mode, out_mode;
- GstVideoMultiviewFlags in_flags, out_flags;
-
- g_return_val_if_fail (GST_IS_GL_VIEW_CONVERT (viewconvert), GST_FLOW_ERROR);
- g_return_val_if_fail (GST_IS_GL_CONTEXT (viewconvert->context),
- GST_FLOW_ERROR);
-
- GST_OBJECT_LOCK (viewconvert);
-
- /* See if a buffer is available already */
- if (priv->primary_out) {
- outbuf = viewconvert->priv->primary_out;
- priv->primary_out = NULL;
- goto done;
- }
- if (viewconvert->priv->auxilliary_out) {
- outbuf = priv->auxilliary_out;
- priv->auxilliary_out = NULL;
- goto done;
- }
-
- /* Check prereqs before processing a new input buffer */
- if (priv->primary_in == NULL)
- goto done;
-
- in_mode = viewconvert->input_mode_override;
- in_flags = viewconvert->input_flags_override;
- if (in_mode == GST_VIDEO_MULTIVIEW_MODE_NONE) {
- in_mode = GST_VIDEO_INFO_MULTIVIEW_MODE (&viewconvert->in_info);
- in_flags = GST_VIDEO_INFO_MULTIVIEW_FLAGS (&viewconvert->in_info);
- }
-
- /* Configured output mode already takes any override
- * into account */
- out_mode = GST_VIDEO_INFO_MULTIVIEW_MODE (&viewconvert->out_info);
- out_flags = GST_VIDEO_INFO_MULTIVIEW_FLAGS (&viewconvert->out_info);
-
- if (in_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME) {
- /* For frame-by-frame, we need 2 input buffers */
- if (priv->auxilliary_in == NULL) {
- GST_LOG_OBJECT (viewconvert,
- "Can't generate output yet - frame-by-frame mode");
- goto done;
- }
- }
-
- /* Store the current conversion in the priv vars */
- priv->input_mode = in_mode;
- priv->input_flags = in_flags;
- priv->output_mode = out_mode;
- priv->output_flags = out_flags;
-
- if (priv->input_mode == priv->output_mode &&
- priv->input_flags == priv->output_flags &&
- viewconvert->in_info.width == viewconvert->out_info.width &&
- viewconvert->in_info.height == viewconvert->out_info.height &&
- viewconvert->from_texture_target == viewconvert->to_texture_target) {
- /* passthrough - just pass input buffers */
- outbuf = gst_buffer_ref (priv->primary_in);
- if (in_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME)
- priv->auxilliary_out = gst_buffer_ref (priv->auxilliary_in);
- goto done_clear_input;
- }
-
- /* We can't output to OES textures, they're only supported for passthrough */
- if (viewconvert->to_texture_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES) {
- ret = GST_FLOW_ERROR;
- goto done_clear_input;
- }
-
- /* Generate new output buffer(s) */
- gst_gl_context_thread_add (viewconvert->context,
- (GstGLContextThreadFunc) _do_view_convert, viewconvert);
-
- if (!priv->result) {
- if (priv->primary_out)
- gst_object_unref (priv->primary_out);
- if (priv->auxilliary_out)
- gst_object_unref (priv->auxilliary_out);
- priv->primary_out = NULL;
- priv->auxilliary_out = NULL;
- ret = GST_FLOW_ERROR;
- goto done_clear_input;
- }
-
- outbuf = priv->primary_out;
- if (outbuf) {
- gst_buffer_copy_into (outbuf, priv->primary_in,
- GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
- GST_BUFFER_FLAG_SET (outbuf,
- GST_VIDEO_BUFFER_FLAG_FIRST_IN_BUNDLE |
- GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW);
- }
-
- if (priv->auxilliary_out) {
- gst_buffer_copy_into (priv->auxilliary_out,
- priv->primary_out, GST_BUFFER_COPY_FLAGS, 0, -1);
- GST_BUFFER_FLAG_UNSET (priv->auxilliary_out,
- GST_VIDEO_BUFFER_FLAG_FIRST_IN_BUNDLE);
- }
- priv->primary_out = NULL;
-
-done_clear_input:
- /* Invalidate input buffers now they've been used */
- gst_buffer_replace (&priv->primary_in, NULL);
- gst_buffer_replace (&priv->auxilliary_in, NULL);
-
-done:
- GST_OBJECT_UNLOCK (viewconvert);
- *outbuf_ptr = outbuf;
- return ret;
-}
diff --git a/gst-libs/gst/gl/gstglviewconvert.h b/gst-libs/gst/gl/gstglviewconvert.h
deleted file mode 100644
index 3cad3adeb..000000000
--- a/gst-libs/gst/gl/gstglviewconvert.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Jan Schmidt <jan@centricular.com>
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GST_GL_VIEW_CONVERT_H_
-#define _GST_GL_VIEW_CONVERT_H_
-
-#include <gst/gstmemory.h>
-#include <gst/video/video.h>
-
-#include <gst/gl/gstgl_fwd.h>
-
-G_BEGIN_DECLS
-#define GST_TYPE_GL_VIEW_CONVERT (gst_gl_view_convert_get_type())
-#define GST_GL_VIEW_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_VIEW_CONVERT,GstGLViewConvert))
-#define GST_IS_GL_VIEW_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_VIEW_CONVERT))
-#define GST_GL_VIEW_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_GL_VIEW_CONVERT,GstGLViewConvertClass))
-#define GST_IS_GL_VIEW_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_GL_VIEW_CONVERT))
-#define GST_GL_VIEW_CONVERT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_GL_VIEW_CONVERT,GstGLViewConvertClass))
-
-#define GST_TYPE_GL_STEREO_DOWNMIX_MODE_TYPE gst_gl_stereo_downmix_mode_get_type()
-GST_EXPORT
-GType gst_gl_stereo_downmix_mode_get_type (void);
-
-/**
- * GstGLStereoDownmix:
- * @GST_GL_STEREO_DOWNMIX_ANAGLYPH_GREEN_MAGENTA_DUBOIS: Dubois optimised Green-Magenta anaglyph
- * @GST_GL_STEREO_DOWNMIX_ANAGLYPH_RED_CYAN_DUBOIS: Dubois optimised Red-Cyan anaglyph
- * @GST_GL_STEREO_DOWNMIX_ANAGLYPH_AMBER_BLUE_DUBOIS: Dubois optimised Amber-Blue anaglyph
- *
- * Output anaglyph type to generate when downmixing to mono
- */
-enum _GstGLStereoDownmix {
- GST_GL_STEREO_DOWNMIX_ANAGLYPH_GREEN_MAGENTA_DUBOIS,
- GST_GL_STEREO_DOWNMIX_ANAGLYPH_RED_CYAN_DUBOIS,
- GST_GL_STEREO_DOWNMIX_ANAGLYPH_AMBER_BLUE_DUBOIS,
-};
-typedef enum _GstGLStereoDownmix GstGLStereoDownmix;
-
-/**
- * GstGLViewConvert:
- *
- * #GstGLViewConvert is an opaque struct and should only be accessed through the
- * provided api.
- */
-struct _GstGLViewConvert
-{
- GstObject object;
-
- GstGLContext *context;
-
- GstGLShader *shader;
-
- GstVideoMultiviewMode input_mode_override;
- GstVideoMultiviewFlags input_flags_override;
- GstVideoMultiviewMode output_mode_override;
- GstVideoMultiviewFlags output_flags_override;
-
- GstGLStereoDownmix downmix_mode;
-
- GstVideoInfo in_info;
- GstVideoInfo out_info;
-
- GstGLTextureTarget from_texture_target;
- GstGLTextureTarget to_texture_target;
- gboolean caps_passthrough;
-
- gboolean initted;
- gboolean reconfigure;
-
- GstGLFramebuffer *fbo;
-
- /* <private> */
- GstGLViewConvertPrivate *priv;
-
- gpointer _padding[GST_PADDING];
-};
-
-/**
- * GstGLViewConvertClass:
- *
- * Opaque #GstGLViewConvertClass struct
- */
-struct _GstGLViewConvertClass
-{
- /* <private> */
- GstObjectClass object_class;
-
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GType gst_gl_view_convert_get_type (void);
-GST_EXPORT
-GstGLViewConvert * gst_gl_view_convert_new (void);
-
-GST_EXPORT
-gboolean gst_gl_view_convert_set_caps (GstGLViewConvert * viewconvert, GstCaps * in_caps, GstCaps * out_caps);
-GST_EXPORT
-GstCaps * gst_gl_view_convert_transform_caps (GstGLViewConvert * viewconvert,
- GstPadDirection direction, GstCaps * caps, GstCaps * filter);
-GST_EXPORT
-GstCaps * gst_gl_view_convert_fixate_caps (GstGLViewConvert *viewconvert,
- GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
-GST_EXPORT
-GstFlowReturn gst_gl_view_convert_submit_input_buffer (GstGLViewConvert *viewconvert,
- gboolean is_discont, GstBuffer * input);
-GST_EXPORT
-GstFlowReturn gst_gl_view_convert_get_output (GstGLViewConvert *viewconvert,
- GstBuffer ** outbuf_ptr);
-
-GST_EXPORT
-GstBuffer * gst_gl_view_convert_perform (GstGLViewConvert * viewconvert, GstBuffer *inbuf);
-GST_EXPORT
-void gst_gl_view_convert_reset (GstGLViewConvert * viewconvert);
-GST_EXPORT
-void gst_gl_view_convert_set_context (GstGLViewConvert *viewconvert, GstGLContext * context);
-
-G_END_DECLS
-#endif /* _GST_GL_VIEW_CONVERT_H_ */
diff --git a/gst-libs/gst/gl/gstglwindow.c b/gst-libs/gst/gl/gstglwindow.c
deleted file mode 100644
index 3818ab16e..000000000
--- a/gst-libs/gst/gl/gstglwindow.c
+++ /dev/null
@@ -1,1022 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * SECTION:gstglwindow
- * @short_description: window/surface abstraction
- * @title: GstGLWindow
- * @see_also: #GstGLContext, #GstGLDisplay
- *
- * GstGLWindow represents a window that elements can render into. A window can
- * either be a user visible window (onscreen) or hidden (offscreen).
- */
-
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <gmodule.h>
-#include <stdio.h>
-
-#include "gl.h"
-#include "gstglwindow.h"
-#include "gstglwindow_private.h"
-
-/* FIXME make this work with windowless contexts */
-
-#if GST_GL_HAVE_WINDOW_X11
-#include "x11/gstglwindow_x11.h"
-#endif
-#if GST_GL_HAVE_WINDOW_WIN32
-#include "win32/gstglwindow_win32.h"
-#endif
-#if GST_GL_HAVE_WINDOW_COCOA
-#include "cocoa/gstglwindow_cocoa.h"
-#endif
-#if GST_GL_HAVE_WINDOW_WAYLAND
-#include "wayland/gstglwindow_wayland_egl.h"
-#endif
-#if GST_GL_HAVE_WINDOW_ANDROID
-#include "android/gstglwindow_android_egl.h"
-#endif
-#if GST_GL_HAVE_WINDOW_EAGL
-#include "eagl/gstglwindow_eagl.h"
-#endif
-#if GST_GL_HAVE_WINDOW_VIV_FB
-#include "viv-fb/gstglwindow_viv_fb_egl.h"
-#endif
-#if GST_GL_HAVE_WINDOW_DISPMANX
-#include "dispmanx/gstglwindow_dispmanx_egl.h"
-#endif
-
-#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
-#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
-#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
-#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
-#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-
-#define GST_CAT_DEFAULT gst_gl_window_debug
-GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
-
-#define gst_gl_window_parent_class parent_class
-G_DEFINE_ABSTRACT_TYPE (GstGLWindow, gst_gl_window, GST_TYPE_OBJECT);
-
-#define GST_GL_WINDOW_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_WINDOW, GstGLWindowPrivate))
-
-static void gst_gl_window_default_draw (GstGLWindow * window);
-static void gst_gl_window_default_run (GstGLWindow * window);
-static void gst_gl_window_default_quit (GstGLWindow * window);
-static void gst_gl_window_default_send_message (GstGLWindow * window,
- GstGLWindowCB callback, gpointer data);
-static void gst_gl_window_default_send_message_async (GstGLWindow * window,
- GstGLWindowCB callback, gpointer data, GDestroyNotify destroy);
-
-struct _GstGLWindowPrivate
-{
- GMainLoop *loop;
-
- guint surface_width;
- guint surface_height;
-
- gboolean alive;
-
- GMutex sync_message_lock;
- GCond sync_message_cond;
-};
-
-static void gst_gl_window_finalize (GObject * object);
-
-typedef struct _GstGLDummyWindow
-{
- GstGLWindow parent;
-
- guintptr handle;
-} GstGLDummyWindow;
-
-typedef struct _GstGLDummyWindowCass
-{
- GstGLWindowClass parent;
-} GstGLDummyWindowClass;
-
-static GstGLDummyWindow *gst_gl_dummy_window_new (void);
-
-enum
-{
- SIGNAL_0,
- EVENT_MOUSE_SIGNAL,
- EVENT_KEY_SIGNAL,
- LAST_SIGNAL
-};
-
-static guint gst_gl_window_signals[LAST_SIGNAL] = { 0 };
-
-GQuark
-gst_gl_window_error_quark (void)
-{
- return g_quark_from_static_string ("gst-gl-window-error-quark");
-}
-
-static gboolean
-gst_gl_window_default_open (GstGLWindow * window, GError ** error)
-{
- return TRUE;
-}
-
-static void
-gst_gl_window_default_close (GstGLWindow * window)
-{
-}
-
-static void
-_init_debug (void)
-{
- static volatile gsize _init = 0;
-
- if (g_once_init_enter (&_init)) {
- GST_DEBUG_CATEGORY_INIT (gst_gl_window_debug, "glwindow", 0,
- "glwindow element");
- g_once_init_leave (&_init, 1);
- }
-}
-
-static void
-gst_gl_window_init (GstGLWindow * window)
-{
- GstGLWindowPrivate *priv = GST_GL_WINDOW_GET_PRIVATE (window);
- window->priv = priv;
-
- g_mutex_init (&window->lock);
- window->is_drawing = FALSE;
-
- g_weak_ref_init (&window->context_ref, NULL);
-
- g_mutex_init (&window->priv->sync_message_lock);
- g_cond_init (&window->priv->sync_message_cond);
-
- window->main_context = g_main_context_new ();
- priv->loop = g_main_loop_new (window->main_context, FALSE);
-}
-
-static void
-gst_gl_window_class_init (GstGLWindowClass * klass)
-{
- g_type_class_add_private (klass, sizeof (GstGLWindowPrivate));
-
- klass->open = GST_DEBUG_FUNCPTR (gst_gl_window_default_open);
- klass->close = GST_DEBUG_FUNCPTR (gst_gl_window_default_close);
- klass->run = GST_DEBUG_FUNCPTR (gst_gl_window_default_run);
- klass->quit = GST_DEBUG_FUNCPTR (gst_gl_window_default_quit);
- klass->draw = GST_DEBUG_FUNCPTR (gst_gl_window_default_draw);
- klass->send_message = GST_DEBUG_FUNCPTR (gst_gl_window_default_send_message);
- klass->send_message_async =
- GST_DEBUG_FUNCPTR (gst_gl_window_default_send_message_async);
-
- G_OBJECT_CLASS (klass)->finalize = gst_gl_window_finalize;
-
- /**
- * GstGLWindow::mouse-event:
- * @object: the #GstGLWindow
- * @id: the name of the event
- * @button: the id of the button
- * @x: the x coordinate of the mouse event
- * @y: the y coordinate of the mouse event
- *
- * Will be emitted when a mouse event is received by the GstGLwindow.
- *
- * Since: 1.6
- */
- gst_gl_window_signals[EVENT_MOUSE_SIGNAL] =
- g_signal_new ("mouse-event", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic,
- G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
-
- /**
- * GstGLWindow::key-event:
- * @object: the #GstGLWindow
- * @id: the name of the event
- * @key: the id of the key pressed
- *
- * Will be emitted when a key event is received by the GstGLwindow.
- *
- * Since: 1.6
- */
- gst_gl_window_signals[EVENT_KEY_SIGNAL] =
- g_signal_new ("key-event", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic,
- G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
-
- _init_debug ();
-}
-
-/**
- * gst_gl_window_new:
- * @display: a #GstGLDisplay
- *
- * Returns: (transfer full): a new #GstGLWindow using @display's connection
- *
- * Since: 1.4
- */
-GstGLWindow *
-gst_gl_window_new (GstGLDisplay * display)
-{
- GstGLWindow *window = NULL;
- const gchar *user_choice;
-
- g_return_val_if_fail (display != NULL, NULL);
-
- _init_debug ();
-
- user_choice = g_getenv ("GST_GL_WINDOW");
- GST_INFO ("creating a window, user choice:%s", user_choice);
-
-#if GST_GL_HAVE_WINDOW_COCOA
- if (!window && (!user_choice || g_strstr_len (user_choice, 5, "cocoa")))
- window = GST_GL_WINDOW (gst_gl_window_cocoa_new (display));
-#endif
-#if GST_GL_HAVE_WINDOW_X11
- if (!window && (!user_choice || g_strstr_len (user_choice, 3, "x11")))
- window = GST_GL_WINDOW (gst_gl_window_x11_new (display));
-#endif
-#if GST_GL_HAVE_WINDOW_WIN32
- if (!window && (!user_choice || g_strstr_len (user_choice, 5, "win32")))
- window = GST_GL_WINDOW (gst_gl_window_win32_new (display));
-#endif
-#if GST_GL_HAVE_WINDOW_WAYLAND
- if (!window && (!user_choice || g_strstr_len (user_choice, 7, "wayland")))
- window = GST_GL_WINDOW (gst_gl_window_wayland_egl_new (display));
-#endif
-#if GST_GL_HAVE_WINDOW_DISPMANX
- if (!window && (!user_choice || g_strstr_len (user_choice, 8, "dispmanx")))
- window = GST_GL_WINDOW (gst_gl_window_dispmanx_egl_new (display));
-#endif
-#if GST_GL_HAVE_WINDOW_ANDROID
- if (!window && (!user_choice || g_strstr_len (user_choice, 7, "android")))
- window = GST_GL_WINDOW (gst_gl_window_android_egl_new (display));
-#endif
-#if GST_GL_HAVE_WINDOW_EAGL
- if (!window && (!user_choice || g_strstr_len (user_choice, 4, "eagl")))
- window = GST_GL_WINDOW (gst_gl_window_eagl_new (display));
-#endif
-#if GST_GL_HAVE_WINDOW_VIV_FB
- if (!window && (!user_choice || g_strstr_len (user_choice, 6, "viv-fb")))
- window = GST_GL_WINDOW (gst_gl_window_viv_fb_egl_new (display));
-#endif
-
- if (!window) {
- /* subclass returned a NULL window */
- GST_WARNING ("Could not create window. user specified %s, creating dummy"
- " window", user_choice ? user_choice : "(null)");
-
- window = GST_GL_WINDOW (gst_gl_dummy_window_new ());
- }
-
- window->display = gst_object_ref (display);
-
- return window;
-}
-
-static void
-gst_gl_window_finalize (GObject * object)
-{
- GstGLWindow *window = GST_GL_WINDOW (object);
- GstGLWindowPrivate *priv = window->priv;
-
- if (priv->loop)
- g_main_loop_unref (priv->loop);
-
- if (window->main_context)
- g_main_context_unref (window->main_context);
- window->main_context = NULL;
-
- g_weak_ref_clear (&window->context_ref);
-
- g_mutex_clear (&window->lock);
- g_mutex_clear (&window->priv->sync_message_lock);
- g_cond_clear (&window->priv->sync_message_cond);
- gst_object_unref (window->display);
-
- G_OBJECT_CLASS (gst_gl_window_parent_class)->finalize (object);
-}
-
-typedef struct _GstSetWindowHandleCb
-{
- GstGLWindow *window;
- guintptr handle;
-} GstSetWindowHandleCb;
-
-static void
-_set_window_handle_cb (GstSetWindowHandleCb * data)
-{
- GstGLContext *context = gst_gl_window_get_context (data->window);
- GstGLWindowClass *window_class = GST_GL_WINDOW_GET_CLASS (data->window);
- GThread *thread = NULL;
-
- /* deactivate if necessary */
- if (context) {
- thread = gst_gl_context_get_thread (context);
- if (thread) {
- /* This is only thread safe iff the context thread == g_thread_self() */
- g_assert (thread == g_thread_self ());
- gst_gl_context_activate (context, FALSE);
- }
- }
-
- window_class->set_window_handle (data->window, data->handle);
-
- /* reactivate */
- if (context && thread)
- gst_gl_context_activate (context, TRUE);
-
- if (context)
- gst_object_unref (context);
- if (thread)
- g_thread_unref (thread);
-}
-
-static void
-_free_swh_cb (GstSetWindowHandleCb * data)
-{
- gst_object_unref (data->window);
- g_slice_free (GstSetWindowHandleCb, data);
-}
-
-/**
- * gst_gl_window_set_window_handle:
- * @window: a #GstGLWindow
- * @handle: handle to the window
- *
- * Sets the window that this @window should render into. Some implementations
- * require this to be called with a valid handle before drawing can commence.
- *
- * Since: 1.4
- */
-void
-gst_gl_window_set_window_handle (GstGLWindow * window, guintptr handle)
-{
- GstGLWindowClass *window_class;
- GstSetWindowHandleCb *data;
-
- g_return_if_fail (GST_IS_GL_WINDOW (window));
- g_return_if_fail (handle != 0);
- window_class = GST_GL_WINDOW_GET_CLASS (window);
- g_return_if_fail (window_class->set_window_handle != NULL);
-
- data = g_slice_new (GstSetWindowHandleCb);
- data->window = gst_object_ref (window);
- data->handle = handle;
-
- /* FIXME: Move to a message which deactivates, calls implementation, activates */
- gst_gl_window_send_message_async (window,
- (GstGLWindowCB) _set_window_handle_cb, data,
- (GDestroyNotify) _free_swh_cb);
-
- /* window_class->set_window_handle (window, handle); */
-}
-
-static void
-draw_cb (gpointer data)
-{
- GstGLWindow *window = GST_GL_WINDOW (data);
- GstGLContext *context = gst_gl_window_get_context (window);
-
- if (window->queue_resize) {
- guint width, height;
-
- gst_gl_window_get_surface_dimensions (window, &width, &height);
- gst_gl_window_resize (window, width, height);
- }
-
- if (window->draw)
- window->draw (window->draw_data);
-
- gst_gl_context_swap_buffers (context);
-
- gst_object_unref (context);
-}
-
-static void
-gst_gl_window_default_draw (GstGLWindow * window)
-{
- gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
-}
-
-/**
- * gst_gl_window_draw:
- * @window: a #GstGLWindow
- *
- * Redraw the window contents. Implementations should invoke the draw callback.
- *
- * Since: 1.4
- */
-void
-gst_gl_window_draw (GstGLWindow * window)
-{
- GstGLWindowClass *window_class;
-
- g_return_if_fail (GST_IS_GL_WINDOW (window));
- window_class = GST_GL_WINDOW_GET_CLASS (window);
- g_return_if_fail (window_class->draw != NULL);
-
- /* avoid to overload the drawer */
- if (window->is_drawing) {
- return;
- }
-
- window_class->draw (window);
-}
-
-/**
- * gst_gl_window_set_preferred_size:
- * @window: a #GstGLWindow
- * @width: new preferred width
- * @height: new preferred height
- *
- * Set the preferred width and height of the window. Implementations are free
- * to ignore this information.
- *
- * Since: 1.6
- */
-void
-gst_gl_window_set_preferred_size (GstGLWindow * window, gint width, gint height)
-{
- GstGLWindowClass *window_class;
-
- g_return_if_fail (GST_IS_GL_WINDOW (window));
- window_class = GST_GL_WINDOW_GET_CLASS (window);
-
- if (window_class->set_preferred_size)
- window_class->set_preferred_size (window, width, height);
-}
-
-/**
- * gst_gl_window_show:
- * @window: a #GstGLWindow
- *
- * Present the window to the screen.
- *
- * Since: 1.6
- */
-void
-gst_gl_window_show (GstGLWindow * window)
-{
- GstGLWindowClass *window_class;
-
- g_return_if_fail (GST_IS_GL_WINDOW (window));
- window_class = GST_GL_WINDOW_GET_CLASS (window);
-
- if (window_class->show)
- window_class->show (window);
-}
-
-static void
-gst_gl_window_default_run (GstGLWindow * window)
-{
- GstGLWindowPrivate *priv = window->priv;
-
- g_main_context_push_thread_default (window->main_context);
-
- g_main_loop_run (priv->loop);
-
- g_main_context_pop_thread_default (window->main_context);
-}
-
-/**
- * gst_gl_window_run:
- * @window: a #GstGLWindow
- *
- * Start the execution of the runloop.
- *
- * Since: 1.4
- */
-void
-gst_gl_window_run (GstGLWindow * window)
-{
- GstGLWindowClass *window_class;
-
- g_return_if_fail (GST_IS_GL_WINDOW (window));
- window_class = GST_GL_WINDOW_GET_CLASS (window);
- g_return_if_fail (window_class->run != NULL);
-
- window->priv->alive = TRUE;
- window_class->run (window);
-}
-
-static void
-gst_gl_window_default_quit (GstGLWindow * window)
-{
- g_main_loop_quit (window->priv->loop);
-}
-
-/**
- * gst_gl_window_quit:
- * @window: a #GstGLWindow
- *
- * Quit the runloop's execution.
- *
- * Since: 1.4
- */
-void
-gst_gl_window_quit (GstGLWindow * window)
-{
- GstGLWindowClass *window_class;
-
- g_return_if_fail (GST_IS_GL_WINDOW (window));
- window_class = GST_GL_WINDOW_GET_CLASS (window);
- g_return_if_fail (window_class->quit != NULL);
-
- GST_GL_WINDOW_LOCK (window);
-
- window->priv->alive = FALSE;
-
- window_class->quit (window);
-
- GST_INFO ("quit sent to gl window loop");
-
- GST_GL_WINDOW_UNLOCK (window);
-}
-
-typedef struct _GstGLSyncMessage
-{
- GstGLWindow *window;
- gboolean fired;
-
- GstGLWindowCB callback;
- gpointer data;
-} GstGLSyncMessage;
-
-static void
-_run_message_sync (GstGLSyncMessage * message)
-{
-
- if (message->callback)
- message->callback (message->data);
-
- g_mutex_lock (&message->window->priv->sync_message_lock);
- message->fired = TRUE;
- g_cond_broadcast (&message->window->priv->sync_message_cond);
- g_mutex_unlock (&message->window->priv->sync_message_lock);
-}
-
-void
-gst_gl_window_default_send_message (GstGLWindow * window,
- GstGLWindowCB callback, gpointer data)
-{
- GstGLSyncMessage message;
-
- message.window = window;
- message.callback = callback;
- message.data = data;
- message.fired = FALSE;
-
- gst_gl_window_send_message_async (window, (GstGLWindowCB) _run_message_sync,
- &message, NULL);
-
- g_mutex_lock (&window->priv->sync_message_lock);
-
- /* block until opengl calls have been executed in the gl thread */
- while (!message.fired)
- g_cond_wait (&window->priv->sync_message_cond,
- &window->priv->sync_message_lock);
- g_mutex_unlock (&window->priv->sync_message_lock);
-}
-
-/**
- * gst_gl_window_send_message:
- * @window: a #GstGLWindow
- * @callback: (scope async): function to invoke
- * @data: (closure): data to invoke @callback with
- *
- * Invoke @callback with data on the window thread. @callback is guarenteed to
- * have executed when this function returns.
- *
- * Since: 1.4
- */
-void
-gst_gl_window_send_message (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data)
-{
- GstGLWindowClass *window_class;
-
- g_return_if_fail (GST_IS_GL_WINDOW (window));
- g_return_if_fail (callback != NULL);
- window_class = GST_GL_WINDOW_GET_CLASS (window);
- g_return_if_fail (window_class->send_message != NULL);
-
- window_class->send_message (window, callback, data);
-}
-
-typedef struct _GstGLAsyncMessage
-{
- GstGLWindowCB callback;
- gpointer data;
- GDestroyNotify destroy;
-} GstGLAsyncMessage;
-
-static gboolean
-_run_message_async (GstGLAsyncMessage * message)
-{
- if (message->callback)
- message->callback (message->data);
-
- if (message->destroy)
- message->destroy (message->data);
-
- g_slice_free (GstGLAsyncMessage, message);
-
- return FALSE;
-}
-
-static void
-gst_gl_window_default_send_message_async (GstGLWindow * window,
- GstGLWindowCB callback, gpointer data, GDestroyNotify destroy)
-{
- GstGLAsyncMessage *message = g_slice_new (GstGLAsyncMessage);
-
- message->callback = callback;
- message->data = data;
- message->destroy = destroy;
-
- g_main_context_invoke (window->main_context, (GSourceFunc) _run_message_async,
- message);
-}
-
-/**
- * gst_gl_window_send_message_async:
- * @window: a #GstGLWindow
- * @callback: (scope async): function to invoke
- * @data: (closure): data to invoke @callback with
- * @destroy: called when @data is not needed anymore
- *
- * Invoke @callback with @data on the window thread. The callback may not
- * have been executed when this function returns.
- *
- * Since: 1.4
- */
-void
-gst_gl_window_send_message_async (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data, GDestroyNotify destroy)
-{
- GstGLWindowClass *window_class;
-
- g_return_if_fail (GST_IS_GL_WINDOW (window));
- g_return_if_fail (callback != NULL);
- window_class = GST_GL_WINDOW_GET_CLASS (window);
- g_return_if_fail (window_class->send_message_async != NULL);
-
- window_class->send_message_async (window, callback, data, destroy);
-}
-
-/**
- * gst_gl_window_set_draw_callback:
- * @window: a #GstGLWindow
- * @callback: (scope notified): function to invoke
- * @data: (closure): data to invoke @callback with
- * @destroy_notify: called when @data is not needed any more
- *
- * Sets the draw callback called everytime gst_gl_window_draw() is called
- *
- * Since: 1.4
- */
-void
-gst_gl_window_set_draw_callback (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data, GDestroyNotify destroy_notify)
-{
- g_return_if_fail (GST_IS_GL_WINDOW (window));
-
- GST_GL_WINDOW_LOCK (window);
-
- if (window->draw_notify)
- window->draw_notify (window->draw_data);
-
- window->draw = callback;
- window->draw_data = data;
- window->draw_notify = destroy_notify;
-
- GST_GL_WINDOW_UNLOCK (window);
-}
-
-/**
- * gst_gl_window_set_resize_callback:
- * @window: a #GstGLWindow
- * @callback: (scope notified): function to invoke
- * @data: (closure): data to invoke @callback with
- * @destroy_notify: called when @data is not needed any more
- *
- * Sets the resize callback called everytime a resize of the window occurs.
- *
- * Since: 1.4
- */
-void
-gst_gl_window_set_resize_callback (GstGLWindow * window,
- GstGLWindowResizeCB callback, gpointer data, GDestroyNotify destroy_notify)
-{
- g_return_if_fail (GST_IS_GL_WINDOW (window));
-
- GST_GL_WINDOW_LOCK (window);
-
- if (window->resize_notify)
- window->resize_notify (window->resize_data);
-
- window->resize = callback;
- window->resize_data = data;
- window->resize_notify = destroy_notify;
-
- GST_GL_WINDOW_UNLOCK (window);
-}
-
-/**
- * gst_gl_window_set_close_callback:
- * @window: a #GstGLWindow
- * @callback: (scope notified): function to invoke
- * @data: (closure): data to invoke @callback with
- * @destroy_notify: called when @data is not needed any more
- *
- * Sets the callback called when the window is about to close.
- *
- * Since: 1.4
- */
-void
-gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data, GDestroyNotify destroy_notify)
-{
- g_return_if_fail (GST_IS_GL_WINDOW (window));
-
- GST_GL_WINDOW_LOCK (window);
-
- if (window->close_notify)
- window->close_notify (window->close_data);
-
- window->close = callback;
- window->close_data = data;
- window->close_notify = destroy_notify;
-
- GST_GL_WINDOW_UNLOCK (window);
-}
-
-/**
- * gst_gl_window_get_display:
- * @window: a #GstGLWindow
- *
- * Returns: the windowing system display handle for this @window
- *
- * Since: 1.4
- */
-guintptr
-gst_gl_window_get_display (GstGLWindow * window)
-{
- GstGLWindowClass *window_class;
-
- g_return_val_if_fail (GST_IS_GL_WINDOW (window), 0);
- window_class = GST_GL_WINDOW_GET_CLASS (window);
- g_return_val_if_fail (window_class->get_display != NULL, 0);
-
- return window_class->get_display (window);
-}
-
-/**
- * gst_gl_window_get_window_handle:
- * @window: a #GstGLWindow
- *
- * Returns: the window handle we are currently rendering into
- *
- * Since: 1.4
- */
-guintptr
-gst_gl_window_get_window_handle (GstGLWindow * window)
-{
- GstGLWindowClass *window_class;
-
- g_return_val_if_fail (GST_IS_GL_WINDOW (window), 0);
- window_class = GST_GL_WINDOW_GET_CLASS (window);
- g_return_val_if_fail (window_class->get_window_handle != NULL, 0);
-
- return window_class->get_window_handle (window);
-}
-
-/**
- * gst_gl_window_get_context:
- * @window: a #GstGLWindow
- *
- * Returns: (transfer full): the #GstGLContext associated with this @window
- *
- * Since: 1.4
- */
-GstGLContext *
-gst_gl_window_get_context (GstGLWindow * window)
-{
- g_return_val_if_fail (GST_IS_GL_WINDOW (window), NULL);
-
- return (GstGLContext *) g_weak_ref_get (&window->context_ref);
-}
-
-/**
- * gst_gl_window_get_surface_dimensions:
- * @window: a #GstGLWindow
- * @width: (out): resulting surface width
- * @height: (out): resulting surface height
- *
- * Since: 1.6
- */
-void
-gst_gl_window_get_surface_dimensions (GstGLWindow * window, guint * width,
- guint * height)
-{
- if (width)
- *width = window->priv->surface_width;
- if (height)
- *height = window->priv->surface_height;
-}
-
-void
-gst_gl_window_send_key_event (GstGLWindow * window, const char *event_type,
- const char *key_str)
-{
- g_signal_emit (window, gst_gl_window_signals[EVENT_KEY_SIGNAL], 0,
- event_type, key_str);
-}
-
-void
-gst_gl_window_send_mouse_event (GstGLWindow * window, const char *event_type,
- int button, double posx, double posy)
-{
- g_signal_emit (window, gst_gl_window_signals[EVENT_MOUSE_SIGNAL], 0,
- event_type, button, posx, posy);
-}
-
-/**
- * gst_gl_window_handle_events:
- * @window: a #GstGLWindow
- * @handle_events: a #gboolean indicating if events should be handled or not.
- *
- * Tell a @window that it should handle events from the window system. These
- * events are forwarded upstream as navigation events. In some window systems
- * events are not propagated in the window hierarchy if a client is listening
- * for them. This method allows you to disable events handling completely
- * from the @window.
- */
-void
-gst_gl_window_handle_events (GstGLWindow * window, gboolean handle_events)
-{
- GstGLWindowClass *window_class;
-
- g_return_if_fail (GST_IS_GL_WINDOW (window));
- window_class = GST_GL_WINDOW_GET_CLASS (window);
-
- if (window_class->handle_events)
- window_class->handle_events (window, handle_events);
-}
-
-/**
- * gst_gl_window_set_render_rectangle:
- * @window: a #GstGLWindow
- * @x: x position
- * @y: y position
- * @width: width
- * @height: height
- *
- * Tell a @window that it should render into a specific region of the window
- * according to the #GstVideoOverlay interface.
- *
- * Returns: whether the specified region could be set
- */
-gboolean
-gst_gl_window_set_render_rectangle (GstGLWindow * window, gint x, gint y,
- gint width, gint height)
-{
- GstGLWindowClass *window_class;
- gboolean ret = FALSE;
-
- g_return_val_if_fail (GST_IS_GL_WINDOW (window), FALSE);
- window_class = GST_GL_WINDOW_GET_CLASS (window);
-
- if (x < 0 || y < 0 || width <= 0 || height <= 0)
- return FALSE;
-
- if (window_class->set_render_rectangle)
- ret = window_class->set_render_rectangle (window, x, y, width, height);
-
- return ret;
-}
-
-void
-gst_gl_window_queue_resize (GstGLWindow * window)
-{
- GstGLWindowClass *window_class;
-
- g_return_if_fail (GST_IS_GL_WINDOW (window));
- window_class = GST_GL_WINDOW_GET_CLASS (window);
-
- window->queue_resize = TRUE;
- if (window_class->queue_resize)
- window_class->queue_resize (window);
-}
-
-struct resize_data
-{
- GstGLWindow *window;
- guint width, height;
-};
-
-static void
-_on_resize (gpointer data)
-{
- struct resize_data *resize = data;
-
- resize->window->resize (resize->window->resize_data, resize->width,
- resize->height);
-}
-
-void
-gst_gl_window_resize (GstGLWindow * window, guint width, guint height)
-{
- g_return_if_fail (GST_IS_GL_WINDOW (window));
-
- if (window->resize) {
- struct resize_data resize = { 0, };
-
- resize.window = window;
- resize.width = width;
- resize.height = height;
-
- gst_gl_window_send_message (window, (GstGLWindowCB) _on_resize, &resize);
- }
-
- window->priv->surface_width = width;
- window->priv->surface_height = height;
-
- window->queue_resize = FALSE;
-}
-
-static GType gst_gl_dummy_window_get_type (void);
-
-G_DEFINE_TYPE (GstGLDummyWindow, gst_gl_dummy_window, GST_TYPE_GL_WINDOW);
-
-static void
-gst_gl_dummy_window_set_window_handle (GstGLWindow * window, guintptr handle)
-{
- GstGLDummyWindow *dummy = (GstGLDummyWindow *) window;
-
- dummy->handle = handle;
-}
-
-static guintptr
-gst_gl_dummy_window_get_window_handle (GstGLWindow * window)
-{
- GstGLDummyWindow *dummy = (GstGLDummyWindow *) window;
-
- return (guintptr) dummy->handle;
-}
-
-static guintptr
-gst_gl_dummy_window_get_display (GstGLWindow * window)
-{
- return 0;
-}
-
-static void
-gst_gl_dummy_window_class_init (GstGLDummyWindowClass * klass)
-{
- GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
-
- window_class->get_display =
- GST_DEBUG_FUNCPTR (gst_gl_dummy_window_get_display);
- window_class->get_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_dummy_window_get_window_handle);
- window_class->set_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_dummy_window_set_window_handle);
-}
-
-static void
-gst_gl_dummy_window_init (GstGLDummyWindow * dummy)
-{
- dummy->handle = 0;
-}
-
-static GstGLDummyWindow *
-gst_gl_dummy_window_new (void)
-{
- GstGLDummyWindow *window;
-
- window = g_object_new (gst_gl_dummy_window_get_type (), NULL);
- gst_object_ref_sink (window);
-
- return window;
-}
diff --git a/gst-libs/gst/gl/gstglwindow.h b/gst-libs/gst/gl/gstglwindow.h
deleted file mode 100644
index d943b795f..000000000
--- a/gst-libs/gst/gl/gstglwindow.h
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_WINDOW_H__
-#define __GST_GL_WINDOW_H__
-
-#include <gst/gst.h>
-
-#include <gst/gl/gstgl_fwd.h>
-#include <gst/gl/gstglcontext.h>
-#include <gst/gl/gstgldisplay.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GType gst_gl_window_get_type (void);
-#define GST_TYPE_GL_WINDOW (gst_gl_window_get_type())
-
-/* FIXME: remove this when moving to -base */
-#ifndef GST_DISABLE_DEPRECATED
-#define GST_GL_TYPE_WINDOW GST_TYPE_GL_WINDOW
-#endif
-#define GST_GL_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW, GstGLWindow))
-#define GST_GL_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GST_TYPE_GL_WINDOW, GstGLWindowClass))
-#define GST_IS_GL_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW))
-#define GST_IS_GL_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW))
-#define GST_GL_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW, GstGLWindowClass))
-
-#define GST_GL_WINDOW_LOCK(w) g_mutex_lock(&GST_GL_WINDOW(w)->lock)
-#define GST_GL_WINDOW_UNLOCK(w) g_mutex_unlock(&GST_GL_WINDOW(w)->lock)
-#define GST_GL_WINDOW_GET_LOCK(w) (&GST_GL_WINDOW(w)->lock)
-
-GST_EXPORT
-GQuark gst_gl_window_error_quark (void);
-/**
- * GST_GL_WINDOW_ERROR:
- *
- * Error domain for GStreamer's GL window module. Errors in this domain will be
- * from the #GstGLWindowError enumeration
- */
-#define GST_GL_WINDOW_ERROR (gst_gl_window_error_quark ())
-
-/**
- * GstGLWindowError:
- * @GST_GL_WINDOW_ERROR_FAILED: failed for a unspecified reason
- * @GST_GL_WINDOW_ERROR_OLD_LIBS: the implementation is too old
- * @GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE: no such resource was found
- */
-typedef enum
-{
- GST_GL_WINDOW_ERROR_FAILED,
- GST_GL_WINDOW_ERROR_OLD_LIBS,
- GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
-} GstGLWindowError;
-
-typedef void (*GstGLWindowCB) (gpointer data);
-typedef void (*GstGLWindowResizeCB) (gpointer data, guint width, guint height);
-
-/**
- * GST_GL_WINDOW_CB:
- * @f: the function to cast
- *
- * Cast to the currect function type for generic window callbacks
- */
-#define GST_GL_WINDOW_CB(f) ((GstGLWindowCB) (f))
-
-/**
- * GST_GL_WINDOW_RESIZE_CB:
- * @f: the function to cast
- *
- * Cast to the currect function type for window resize callbacks
- */
-#define GST_GL_WINDOW_RESIZE_CB(f) ((GstGLWindowResizeCB) (f))
-
-/**
- * GstGLWindow:
- *
- * #GstGLWindow is an opaque struct and should only be accessed through the
- * provided api.
- */
-struct _GstGLWindow {
- /*< private >*/
- GstObject parent;
-
- GMutex lock;
-
- GstGLDisplay *display;
- GWeakRef context_ref;
-
- /*< protected >*/
- gboolean is_drawing;
-
- GstGLWindowCB draw;
- gpointer draw_data;
- GDestroyNotify draw_notify;
- GstGLWindowCB close;
- gpointer close_data;
- GDestroyNotify close_notify;
- GstGLWindowResizeCB resize;
- gpointer resize_data;
- GDestroyNotify resize_notify;
-
- gboolean queue_resize;
-
- GMainContext *main_context; /* default main_context */
-
- /*< private >*/
- GstGLWindowPrivate *priv;
-
- gpointer _reserved[GST_PADDING];
-};
-
-/**
- * GstGLWindowClass:
- * @parent_class: Parent class
- * @get_display: Gets the current windowing system display connection
- * @set_window_handle: Set a window handle to render into
- * @get_window_handle: Gets the current window handle that this #GstGLWindow is
- * rendering into. This may return a different value to
- * what is passed into @set_window_handle
- * @draw: redraw the window with the specified dimensions
- * @run: run the mainloop
- * @quit: send a quit to the mainloop
- * @send_message: invoke a function on the window thread. Required to be reentrant.
- * @send_message_async: invoke a function on the window thread. @run may or may
- * not have been called. Required to be reentrant.
- * @open: open the connection to the display
- * @close: close the connection to the display
- * @handle_events: whether to handle 'extra' events from the windowing system.
- * Basic events like surface moves and resizes are still valid
- * things to listen for.
- * @set_preferred_size: request that the window change surface size. The
- * implementation is free to ignore this information.
- * @show: request that the window be shown to the user
- * @set_render_rectangle: request a rectangle to render into. See #GstVideoOverlay
- * @queue_resize: request a resize to occur when possible
- */
-struct _GstGLWindowClass {
- GstObjectClass parent_class;
-
- guintptr (*get_display) (GstGLWindow *window);
- void (*set_window_handle) (GstGLWindow *window, guintptr handle);
- guintptr (*get_window_handle) (GstGLWindow *window);
- void (*draw) (GstGLWindow *window);
- void (*run) (GstGLWindow *window);
- void (*quit) (GstGLWindow *window);
- void (*send_message) (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
- void (*send_message_async) (GstGLWindow *window, GstGLWindowCB callback, gpointer data, GDestroyNotify destroy);
-
- gboolean (*open) (GstGLWindow *window, GError **error);
- void (*close) (GstGLWindow *window);
- void (*handle_events) (GstGLWindow *window, gboolean handle_events);
- void (*set_preferred_size) (GstGLWindow *window, gint width, gint height);
- void (*show) (GstGLWindow *window);
- gboolean (*set_render_rectangle)(GstGLWindow *window, gint x, gint y, gint width, gint height);
- void (*queue_resize) (GstGLWindow *window);
-
- /*< private >*/
- gpointer _reserved[GST_PADDING];
-};
-
-GST_EXPORT
-GstGLWindow * gst_gl_window_new (GstGLDisplay *display);
-
-/* callbacks */
-GST_EXPORT
-void gst_gl_window_set_draw_callback (GstGLWindow *window,
- GstGLWindowCB callback,
- gpointer data,
- GDestroyNotify destroy_notify);
-GST_EXPORT
-void gst_gl_window_set_resize_callback (GstGLWindow *window,
- GstGLWindowResizeCB callback,
- gpointer data,
- GDestroyNotify destroy_notify);
-GST_EXPORT
-void gst_gl_window_set_close_callback (GstGLWindow *window,
- GstGLWindowCB callback,
- gpointer data,
- GDestroyNotify destroy_notify);
-
-GST_EXPORT
-void gst_gl_window_set_window_handle (GstGLWindow *window, guintptr handle);
-GST_EXPORT
-guintptr gst_gl_window_get_window_handle (GstGLWindow *window);
-
-/* loop/events */
-GST_EXPORT
-void gst_gl_window_run (GstGLWindow *window);
-GST_EXPORT
-void gst_gl_window_quit (GstGLWindow *window);
-GST_EXPORT
-void gst_gl_window_send_message (GstGLWindow *window,
- GstGLWindowCB callback,
- gpointer data);
-GST_EXPORT
-void gst_gl_window_send_message_async (GstGLWindow *window,
- GstGLWindowCB callback,
- gpointer data,
- GDestroyNotify destroy);
-
-/* navigation */
-GST_EXPORT
-void gst_gl_window_handle_events (GstGLWindow * window,
- gboolean handle_events);
-
-GST_EXPORT
-void gst_gl_window_send_key_event (GstGLWindow * window,
- const char * event_type,
- const char * key_str);
-GST_EXPORT
-void gst_gl_window_send_mouse_event (GstGLWindow * window,
- const char * event_type,
- int button,
- double posx,
- double posy);
-
-/* surfaces/rendering */
-GST_EXPORT
-void gst_gl_window_queue_resize (GstGLWindow *window);
-GST_EXPORT
-void gst_gl_window_draw (GstGLWindow *window);
-GST_EXPORT
-void gst_gl_window_show (GstGLWindow *window);
-GST_EXPORT
-void gst_gl_window_set_preferred_size (GstGLWindow * window,
- gint width,
- gint height);
-GST_EXPORT
-void gst_gl_window_get_surface_dimensions (GstGLWindow * window,
- guint * width,
- guint * height);
-GST_EXPORT
-gboolean gst_gl_window_set_render_rectangle (GstGLWindow * window,
- gint x,
- gint y,
- gint width,
- gint height);
-
-/* subclass usage only */
-GST_EXPORT
-void gst_gl_window_resize (GstGLWindow *window, guint width, guint height);
-
-GST_EXPORT
-GstGLContext * gst_gl_window_get_context (GstGLWindow *window);
-GST_EXPORT
-guintptr gst_gl_window_get_display (GstGLWindow *window);
-
-G_END_DECLS
-
-#endif /* __GST_GL_WINDOW_H__ */
diff --git a/gst-libs/gst/gl/gstglwindow_private.h b/gst-libs/gst/gl/gstglwindow_private.h
deleted file mode 100644
index 001165bfe..000000000
--- a/gst-libs/gst/gl/gstglwindow_private.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_WINDOW_PRIVATE_H__
-#define __GST_GL_WINDOW_PRIVATE_H__
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-G_GNUC_INTERNAL extern GstDebugCategory *gst_gl_window_debug;
-
-G_END_DECLS
-
-#endif /* __GST_GL_WINDOW_PRIVATE_H__ */
diff --git a/gst-libs/gst/gl/meson.build b/gst-libs/gst/gl/meson.build
deleted file mode 100644
index b8d3687ae..000000000
--- a/gst-libs/gst/gl/meson.build
+++ /dev/null
@@ -1,702 +0,0 @@
-gl_sources = [
- 'gstglapi.c',
- 'gstglbasefilter.c',
- 'gstglbasememory.c',
- 'gstglcolorconvert.c',
- 'gstglbuffer.c',
- 'gstglbufferpool.c',
- 'gstglcontext.c',
- 'gstgldebug.c',
- 'gstgldisplay.c',
- 'gstglfeature.c',
- 'gstglfilter.c',
- 'gstglformat.c',
- 'gstglframebuffer.c',
- 'gstglmemory.c',
- 'gstglmemorypbo.c',
- 'gstgloverlaycompositor.c',
- 'gstglquery.c',
- 'gstglrenderbuffer.c',
- 'gstglshader.c',
- 'gstglshaderstrings.c',
- 'gstglsl.c',
- 'gstglslstage.c',
- 'gstglsyncmeta.c',
- 'gstglupload.c',
- 'gstglutils.c',
- 'gstglviewconvert.c',
- 'gstglwindow.c',
-]
-
-gl_headers = [
- 'gl.h',
- 'gstgl_enums.h',
- 'gstgl_fwd.h',
- 'gstglapi.h',
- 'gstglbasefilter.h',
- 'gstglbasememory.h',
- 'gstglbuffer.h',
- 'gstglbufferpool.h',
- 'gstglcolorconvert.h',
- 'gstglcontext.h',
- 'gstgldebug.h',
- 'gstgldisplay.h',
- 'gstglfeature.h',
- 'gstglfilter.h',
- 'gstglformat.h',
- 'gstglfuncs.h',
- 'gstglframebuffer.h',
- 'gstglmemory.h',
- 'gstglmemorypbo.h',
- 'gstgloverlaycompositor.h',
- 'gstglquery.h',
- 'gstglrenderbuffer.h',
- 'gstglshader.h',
- 'gstglshaderstrings.h',
- 'gstglsl.h',
- 'gstglslstage.h',
- 'gstglsyncmeta.h',
- 'gstglupload.h',
- 'gstglutils.h',
- 'gstglviewconvert.h',
- 'gstglwindow.h',
-]
-
-gl_prototype_headers = [
- 'glprototypes/all_functions.h',
- 'glprototypes/base.h',
- 'glprototypes/blending.h',
- 'glprototypes/buffers.h',
- 'glprototypes/debug.h',
- 'glprototypes/eglimage.h',
- 'glprototypes/fbo.h',
- 'glprototypes/fixedfunction.h',
- 'glprototypes/gles.h',
- 'glprototypes/gstgl_compat.h',
- 'glprototypes/gstgl_gles2compat.h',
- 'glprototypes/Makefile.am',
- 'glprototypes/opengl.h',
- 'glprototypes/query.h',
- 'glprototypes/README',
- 'glprototypes/shaders.h',
- 'glprototypes/sync.h',
- 'glprototypes/vao.h',
-]
-
-gl_x11_headers = []
-gl_wayland_headers = []
-gl_win32_headers = []
-gl_cocoa_headers = []
-gl_egl_headers = []
-
-glconf = configuration_data()
-glconf_options = [
- 'GST_GL_HAVE_OPENGL',
- 'GST_GL_HAVE_GLES2',
- 'GST_GL_HAVE_GLES3',
- 'GST_GL_HAVE_GLES3EXT3_H',
-
- 'GST_GL_HAVE_WINDOW_X11',
- 'GST_GL_HAVE_WINDOW_COCOA',
- 'GST_GL_HAVE_WINDOW_WIN32',
- 'GST_GL_HAVE_WINDOW_WAYLAND',
- 'GST_GL_HAVE_WINDOW_ANDROID',
- 'GST_GL_HAVE_WINDOW_DISPMANX',
- 'GST_GL_HAVE_WINDOW_EAGL',
- 'GST_GL_HAVE_WINDOW_VIV_FB',
-
- 'GST_GL_HAVE_PLATFORM_EGL',
- 'GST_GL_HAVE_PLATFORM_GLX',
- 'GST_GL_HAVE_PLATFORM_WGL',
- 'GST_GL_HAVE_PLATFORM_CGL',
- 'GST_GL_HAVE_PLATFORM_EAGL',
-
- 'GST_GL_HAVE_DMABUF',
- 'GST_GL_HAVE_VIV_DIRECTVIV',
-
- 'GST_GL_HAVE_GLEGLIMAGEOES',
- 'GST_GL_HAVE_GLCHAR',
- 'GST_GL_HAVE_GLSIZEIPTR',
- 'GST_GL_HAVE_GLINTPTR',
- 'GST_GL_HAVE_GLSYNC',
- 'GST_GL_HAVE_GLUINT64',
- 'GST_GL_HAVE_GLINT64',
- 'GST_GL_HAVE_EGLATTRIB',
-]
-
-foreach option : glconf_options
- glconf.set10(option, false)
-endforeach
-
-gmodule_dep = dependency('gmodule-no-export-2.0',
- fallback: ['glib', 'libgmodule_dep'])
-unneeded_dep = dependency('', required : false)
-if unneeded_dep.found()
- error ('Found unfindable dependency')
-endif
-
-# OpenGL/GLES2 libraries
-gl_lib_deps = []
-# GL platform - EGL, GLX, CGL, WGL, etc
-gl_platform_deps = []
-# GL winsys - wayland, X11, Cocoa, win32, etc
-gl_winsys_deps = []
-# other things we need.
-gl_misc_deps = []
-# Other preprocessor arguments
-gl_cpp_args = ['-DGST_USE_UNSTABLE_API', '-DGST_EXPORTS']
-
-enabled_gl_apis = []
-enabled_gl_platforms = []
-enabled_gl_winsys = []
-
-# parse provided options
-libegl_module_name = get_option('with_egl_module_name')
-if libegl_module_name != ''
- gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)]
-endif
-libgles2_module_name = get_option('with_gles2_module_name')
-if libgles2_module_name != ''
- gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)]
-endif
-libgl_module_name = get_option('with_opengl_module_name')
-if libgl_module_name != ''
- gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)]
-endif
-
-gl_apis_s = get_option ('with_gl_api')
-if gl_apis_s == 'auto'
- need_api_opengl = 'auto'
- need_api_gles2 = 'auto'
-else
- need_api_opengl = 'no'
- need_api_gles2 = 'no'
- gl_apis = gl_apis_s.split(',')
- foreach api : gl_apis
- if api == 'opengl'
- need_api_opengl = 'yes'
- elif api == 'gles2'
- need_api_gles2 = 'yes'
- else
- error('Unsupported GL api provided ' + api)
- endif
- endforeach
-endif
-
-gl_platforms_s = get_option ('with_gl_platform')
-if gl_platforms_s == 'auto'
- need_platform_egl = 'auto'
- need_platform_glx = 'auto'
- need_platform_cgl = 'auto'
- need_platform_wgl = 'auto'
- need_platform_eagl = 'auto'
-else
- need_platform_egl = 'no'
- need_platform_glx = 'no'
- need_platform_cgl = 'no'
- need_platform_wgl = 'no'
- need_platform_eagl = 'no'
- gl_platforms = gl_platforms_s.split(',')
- foreach platform : gl_platforms
- if platform == 'egl'
- need_platform_egl = 'yes'
- elif platform == 'glx'
- need_platform_glx = 'yes'
-# elif platform == 'cgl'
-# need_platform_cgl = 'yes'
- elif platform == 'wgl'
- need_platform_wgl = 'yes'
-# elif platform == 'eagl'
-# need_platform_eagl = 'yes'
- else
- error('Unsupported GL platform provided ' + platform)
- endif
- endforeach
-endif
-
-gl_winsys_s = get_option ('with_gl_winsys')
-if gl_winsys_s == 'auto'
- need_win_x11 = 'auto'
- need_win_wayland = 'auto'
- need_win_win32 = 'auto'
- need_win_cocoa = 'auto'
- need_win_eagl = 'auto'
- need_win_dispmanx = 'auto'
- need_win_viv_fb = 'auto'
-else
- need_win_x11 = 'no'
- need_win_wayland = 'no'
- need_win_win32 = 'no'
- need_win_cocoa = 'no'
- need_win_eagl = 'no'
- need_win_dispmanx = 'no'
- need_win_viv_fb = 'no'
- gl_winsys = gl_winsys_s.split(',')
- foreach winsys : gl_winsys
- if winsys == 'x11'
- need_win_x11 = 'yes'
- elif winsys == 'wayland'
- need_win_wayland = 'yes'
- elif winsys == 'win32'
- need_win_win32 = 'yes'
-# elif winsys == 'cocoa'
-# need_win_cocoa = 'yes'
-# elif winsys == 'eagl'
-# need_win_eagl = 'yes'
- elif winsys == 'dispmanx'
- need_win_dispmanx = 'yes'
- elif winsys == 'viv-fb'
- need_win_viv_fb = 'yes'
- else
- error('Unsupported GL winsys provided ' + winsys)
- endif
- endforeach
-endif
-
-gl_include_header = '''
-#ifdef __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wredundant-decls"
-#endif
-#ifndef GL_GLEXT_PROTOTYPES
-#define GL_GLEXT_PROTOTYPES 1
-#endif
-'''
-
-# Desktop OpenGL checks
-gl_dep = unneeded_dep
-glx_dep = unneeded_dep
-if need_api_opengl != 'no' or need_platform_glx != 'no'
- gl_dep = dependency('gl', required : false)
- if not gl_dep.found()
- if host_machine.system() == 'windows'
- gl_dep = cc.find_library('opengl32', required : false)
-# elif host_machine.system() == 'darwin'
-# gl_dep = cc.find_library('OpenGL', required : false)
- else
- gl_dep = cc.find_library('GL', required : false)
- endif
-
- if not cc.has_header('GL/gl.h', required : false)
- gl_dep = unneeded_dep
- endif
-
- if not gl_dep.found() and need_api_opengl == 'yes'
- error ('Could not find requested OpenGL library')
- endif
- endif
-
- glx_dep = gl_dep
- if need_api_opengl == 'no'
- gl_dep = unneeded_dep
- endif
- if need_platform_glx == 'no'
- glx_dep = unneeded_dep
- endif
-
- opengl_includes = '''
-#ifdef __APPLE__
-# include <OpenGL/OpenGL.h>
-# include <OpenGL/gl.h>
-# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
-# define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
-# include <OpenGL/gl3.h>
-# endif
-#else
-# if _MSC_VER
-# include <windows.h>
-# endif
-# include <GL/gl.h>
-# if __WIN32__ || _WIN32
-# include <GL/glext.h>
-# endif
-#endif
-'''
-endif
-
-# GLES2 checks
-gles2_dep = unneeded_dep
-gles3_h = false
-gles3ext3_h = false
-if need_api_gles2 != 'no'
- gles2_dep = dependency('glesv2', required : false)
- if not gles2_dep.found()
-# if host_machine.system() == 'windows'
-# elif host_machine.system() == 'darwin'
-# gles2_dep = cc.find_library('GLESv2', required : false)
-# else
- gles2_dep = cc.find_library('GLESv2', required : false)
-# endif
-
- if not cc.has_header('GLES2/gl2.h', required : false)
- gles2_dep = unneeded_dep
- endif
-
- if not gles2_dep.found() and need_api_gles2 == 'yes'
- error ('Could not find requested OpenGL ES library')
- endif
- endif
-
- gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', required : false, dependencies : gles2_dep)
-
- gles_includes = '''
-#ifdef HAVE_IOS /* FIXME */
-# include <OpenGLES/ES2/gl.h>
-# include <OpenGLES/ES2/glext.h>
-#else'''
- if gles3_h
- gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', required : false, dependencies : gles2_dep)
- gles_includes += '''
-# include <GLES3/gl3.h>
-# include <GLES2/gl2ext.h>'''
- if gles3ext3_h
- gles_includes += '''
-# include <GLES3/gl3ext.h>'''
- endif
- else
- gles_includes += '''
-# include <GLES2/gl2.h>
-# include <GLES2/gl2ext.h>'''
- endif
- gles_includes += '''
-#endif
-'''
-endif
-
-# can we include both gles2 and opengl headers?
-if gles2_dep.found() and gl_dep.found()
- gl_include_block = gl_include_header + gles_includes + opengl_includes
- if not cc.compiles('void f (void) {}', prefix : gl_include_block, dependencies : [gles2_dep, gl_dep] )
- message ('Cannot include both OpenGL and OpenGL ES headers')
- if need_gles2 != 'yes'
- gles2_dep = unneeded_dep
- elif need_opengl != 'yes'
- gl_dep = unneeded_dep
- else
- error('Both OpenGL and OpenGL ES were requested but cannot be included together')
- endif
- endif
-endif
-gl_include_block = gl_include_header
-if gles2_dep.found()
- gl_include_block += gles_includes
-endif
-if gl_dep.found()
- gl_include_block += opengl_includes
-endif
-
-if gles2_dep.found()
- gl_lib_deps += gles2_dep
- glconf.set10('GST_GL_HAVE_GLES2', 1)
- if gles3_h
- glconf.set10('GST_GL_HAVE_GLES3', 1)
- if gles3ext3_h
- glconf.set10('GST_GL_HAVE_GLES3EXT3_H', 1)
- endif
- endif
- enabled_gl_apis += 'gles2'
-endif
-
-if gl_dep.found()
- gl_lib_deps += gl_dep
- glconf.set10('GST_GL_HAVE_OPENGL', 1)
- enabled_gl_apis += 'opengl'
-endif
-
-# EGL checks
-egl_dep = unneeded_dep
-if need_platform_egl != 'no'
- egl_dep = dependency('egl', required : false)
- if not egl_dep.found()
- egl_dep = cc.find_library('EGL', required : false)
-
- if not egl_dep.found() and need_platform_egl == 'yes'
- error ('Could not find requested EGL library')
- endif
- endif
-
- if egl_dep.found()
- gl_sources += [
- 'egl/gstegl.c',
- 'egl/gsteglimage.c',
- 'egl/gstglcontext_egl.c',
- 'egl/gstgldisplay_egl.c',
- 'egl/gstglmemoryegl.c',
- ]
- gl_egl_headers += [
- 'egl/gstegl.h',
- 'egl/gsteglimage.h',
- 'egl/gstgldisplay_egl.h',
- 'egl/gstglmemoryegl.h',
- ]
- gl_platform_deps += egl_dep
- glconf.set10('GST_GL_HAVE_PLATFORM_EGL', 1)
-
- if cc.has_header('libdrm/drm_fourcc.h', required : false)
- gl_misc_deps += gstallocators_dep
- glconf.set10('GST_GL_HAVE_DMABUF', 1)
- endif
-
- egl_includes = '''
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-'''
- enabled_gl_platforms += 'egl'
- endif
-
-endif
-
-# wayland checks
-wayland_client_dep = unneeded_dep
-wayland_cursor_dep = unneeded_dep
-wayland_egl_dep = unneeded_dep
-if need_win_wayland != 'no'
- if need_win_wayland == 'yes'
- if need_platform_egl == 'no'
- error('Impossible situation requested: Cannot use Wayland without EGL support')
- endif
- endif
- if not egl_dep.found()
- if need_win_wayland == 'yes'
- error ('Could not find EGL libraries for wayland')
- else
- message ('Could not find EGL libraries for wayland')
- endif
- else
- wayland_client_dep = dependency('wayland-client', version : '>= 1.0', required : false)
- wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
- wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
-
- if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found()
- gl_sources += [
- 'wayland/gstgldisplay_wayland.c',
- 'wayland/gstglwindow_wayland_egl.c',
- 'wayland/wayland_event_source.c',
- ]
- gl_wayland_headers += [
- 'wayland/gstgldisplay_wayland.h'
- ]
- glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
- gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
- enabled_gl_winsys += 'wayland'
- else
- if need_win_wayland == 'yes'
- error ('Could not find requested Wayland libraries')
- endif
- wayland_client_dep = unneeded_dep
- wayland_cursor_dep = unneeded_dep
- wayland_egl_dep = unneeded_dep
- endif
- endif
-endif
-
-# X11 checks
-if need_platform_glx == 'yes'
- if need_win_x11 == 'no'
- error('Impossible situation requested: Cannot use GLX without X11 support')
- elif need_api_opengl == 'no'
- error('Impossible situation requested: Cannot use GLX without the OpenGL library')
- endif
-endif
-
-if need_win_x11 != 'no'
- xcb_dep = dependency('x11-xcb', required : false)
- if x11_dep.found() and xcb_dep.found()
- gl_sources += [
- 'x11/gstgldisplay_x11.c',
- 'x11/gstglwindow_x11.c',
- 'x11/xcb_event_source.c',
- ]
- gl_x11_headers += [
- 'x11/gstgldisplay_x11.h',
- ]
- glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
- gl_winsys_deps += [x11_dep, xcb_dep]
- enabled_gl_winsys += 'x11'
-
- if need_platform_glx != 'no' and glx_dep.found()
- glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
- gl_sources += [
- 'x11/gstglcontext_glx.c',
- ]
- # GLX is in the opengl library on linux
- gl_platform_deps += glx_dep
- enabled_gl_platforms += 'glx'
- endif
- elif need_win_x11 == 'yes'
- error ('Could not find requested X11 libraries')
- endif
-endif
-
-bcm_host_dep = unneeded_dep
-if need_win_dispmanx != 'no'
-
- # Try pkg-config for bcm_host then fallback to find_library to also
- # support older distribution
- bcm_host_dep = dependency('bcm_host', required : false)
- if not bcm_host_dep.found()
- bcm_host_dep = cc.find_library('bcm_host', required : false)
- endif
-
- if bcm_host_dep.found()
- if not egl_dep.found()
- error('dispmanx requires the use of egl')
- endif
-
- gl_sources += [
- 'dispmanx/gstglwindow_dispmanx_egl.c'
- ]
-
- glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
- gl_winsys_deps += bcm_host_dep
- enabled_gl_winsys += 'dispmanx'
- gl_cpp_args += ['-DUSE_EGL_RPI']
- elif need_win_dispmanx == 'yes'
- error('Could not find dispmanx libraries')
- endif
-endif
-
-# win32 checks
-if need_platform_wgl == 'yes'
- if need_win_win32 == 'no'
- error('Impossible situation requested: Cannot use WGL without the win32 window system')
- endif
-endif
-
-# XXX: untested
-if need_platform_wgl != 'no' and need_win_win32 != 'no'
- gdi_dep = cc.find_library('gdi32', required : false)
- # FIXME: Revert back to has_header once it gains prefix support
- wglext_h = cc.has_header_symbol('GL/wglext.h', 'WGL_WGLEXT_VERSION',
- prefix : '#include <windows.h>
- #include <GL/gl.h>')
-
- if wglext_h and gdi_dep.found() and gl_dep.found()
- gl_platform_deps += gdi_dep
- gl_sources += [
- 'win32/win32_message_source.c',
- 'win32/gstglwindow_win32.c',
- 'win32/gstglwindow_win32.c',
- ]
- enabled_gl_winsys += 'win32'
- gl_winsys_deps += gdi_dep
- enabled_gl_platforms += 'wgl'
- endif
-endif
-
-if host_machine.system() == 'darwin'
- # FIXME: how to know if we're on iOS or OS X?
-# gl_cocoa_headers += [
-# 'gstglcontext_cocoa.h',
-# 'gstglcaopengllayer.h',
-# ]
-endif
-
-if need_platform_egl != 'no' and need_win_viv_fb != 'no'
- if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
- if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
- enabled_gl_winsys += 'viv-fb'
- glconf.set10('GST_GL_HAVE_WINDOW_VIV_FB', 1)
- glconf.set10('GST_GL_HAVE_VIV_DIRECTVIV', 1)
- gl_sources += [
- 'viv-fb/gstgldisplay_viv_fb.c',
- 'viv-fb/gstglwindow_viv_fb_egl.c',
- ]
- gl_cpp_args += ['-DEGL_API_FB']
- endif
- endif
-endif
-
-# TODO: Add rest of gl config here.
-# iOS, OS X, win32 specific support
-
-build_gstgl = true
-if enabled_gl_apis.length() == 0
- message('No OpenGL API libraries found or requested')
- build_gstgl = false
-endif
-if enabled_gl_platforms.length() == 0
- message('No OpenGL Platforms found or requested')
- build_gstgl = false
-endif
-if enabled_gl_winsys.length() == 0
- message('No OpenGL Window systems found or requested')
- build_gstgl = false
-endif
-
-if build_gstgl
- # find some types that may or may not be defined
- if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps)
- glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
- endif
- if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps)
- glconf.set('GST_GL_HAVE_GLCHAR', 1)
- endif
- if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps)
- glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
- endif
- if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps)
- glconf.set('GST_GL_HAVE_GLINTPTR', 1)
- endif
- if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps)
- glconf.set('GST_GL_HAVE_GLSYNC', 1)
- endif
- if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps)
- glconf.set('GST_GL_HAVE_GLUINT64', 1)
- endif
- if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps)
- glconf.set('GST_GL_HAVE_GLINT64', 1)
- endif
- if egl_dep.found() and cc.has_type('EGLAttrib', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep])
- glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
- endif
-
- message('Building libgstgl with GL api: ' + ' '.join(enabled_gl_apis))
- message('Building libgstgl with GL platform: ' + ' '.join(enabled_gl_platforms))
- message('Building libgstgl with GL winsys: ' + ' '.join(enabled_gl_winsys))
-
- install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
- install_headers(gl_cocoa_headers, subdir : 'gstreamer-1.0/gst/gl/cocoa')
- install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
- install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
- install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
- install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
-
- configure_file(input : 'gstglconfig.h.meson',
- output : 'gstglconfig.h',
- install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
- configuration : glconf)
-
- gstgl = library('gstgl-' + api_version,
- gl_sources,
- c_args : gst_plugins_bad_args + gl_cpp_args,
- include_directories : [configinc, libsinc],
- version : libversion,
- soversion : soversion,
- install : true,
- dependencies : [gstbase_dep, gstvideo_dep, gstbadallocators_dep, gmodule_dep,
- gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps])
- gen_sources = []
- if build_gir
- gl_gir = gnome.generate_gir(gstgl,
- sources : gl_sources + gl_headers,
- namespace : 'GstGL',
- nsversion : api_version,
- identifier_prefix : 'Gst',
- symbol_prefix : 'gst',
- export_packages : 'gstreamer-gl-1.0',
- includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
- install : true,
- extra_args : gir_init_section + ['-DGST_USE_UNSTABLE_API',
- '--c-include=gst/gl/gl.h'],
- dependencies : [gst_dep, gstbase_dep, gstvideo_dep]
- )
- gen_sources += gl_gir
- endif
-
-
- gstgl_dep = declare_dependency(link_with : gstgl,
- include_directories : [libsinc],
- sources: gen_sources,
- dependencies : [gstbase_dep, gstvideo_dep] + gl_winsys_deps)
-endif
diff --git a/gst-libs/gst/gl/utils/gles_versions.h b/gst-libs/gst/gl/utils/gles_versions.h
deleted file mode 100644
index e80bf1e7e..000000000
--- a/gst-libs/gst/gl/utils/gles_versions.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _GLES_VERSIONS_H_
-#define _GLES_VERSIONS_H_
-
-/* list of known OpenGL versions */
-/* *INDENT-OFF* */
-
-static const struct { int major, minor; } gles2_versions[] = {
- {3, 2},
- {3, 1},
- {3, 0},
-
- {2, 0},
-
- {0, 0} /* end of list */
-};
-/* *INDENT-ON* */
-
-#endif /* _GLES_VERSIONS_H_ */
diff --git a/gst-libs/gst/gl/utils/opengl_versions.h b/gst-libs/gst/gl/utils/opengl_versions.h
deleted file mode 100644
index 081caeb47..000000000
--- a/gst-libs/gst/gl/utils/opengl_versions.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _OPENGL_VERSIONS_H_
-#define _OPENGL_VERSIONS_H_
-
-/* list of known OpenGL versions */
-/* *INDENT-OFF* */
-static const struct { int major, minor; } opengl_versions[] = {
- {4, 5},
- {4, 4},
- {4, 3},
- {4, 2},
- {4, 1},
- {4, 0},
-
- {3, 3},
- {3, 2},
- {3, 1},
- {3, 0},
-
- {2, 1},
- {2, 0},
-
- {1, 5},
- {1, 4},
- {1, 3},
- {1, 2},
- {1, 1},
- {1, 0},
-
- {0, 0} /* end of list */
-};
-
-/* *INDENT-ON* */
-
-#endif /* _OPENGL_VERSIONS_H_ */
diff --git a/gst-libs/gst/gl/viv-fb/Makefile.am b/gst-libs/gst/gl/viv-fb/Makefile.am
deleted file mode 100644
index 22294b130..000000000
--- a/gst-libs/gst/gl/viv-fb/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-noinst_LTLIBRARIES = libgstgl-viv-fb.la
-
-libgstgl_viv_fb_la_SOURCES = \
- gstgldisplay_viv_fb.c \
- gstglwindow_viv_fb_egl.c
-
-noinst_HEADERS = \
- gstgldisplay_viv_fb.h \
- gstglwindow_viv_fb_egl.h
-
-libgstgl_viv_fbincludedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl/viv-fb
-
-libgstgl_viv_fb_la_CFLAGS = \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- $(GL_CFLAGS) \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) \
- $(GST_CFLAGS)
-
-libgstgl_viv_fb_la_LDFLAGS = \
- $(GST_LIB_LDFLAGS) \
- $(GST_ALL_LDFLAGS)
diff --git a/gst-libs/gst/gl/viv-fb/gstgldisplay_viv_fb.c b/gst-libs/gst/gl/viv-fb/gstgldisplay_viv_fb.c
deleted file mode 100644
index b90273e4e..000000000
--- a/gst-libs/gst/gl/viv-fb/gstgldisplay_viv_fb.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Matthew Waters <ystreet00@gmail.com>
- * Copyright (C) 2015 Freescale Semiconductor <b55597@freescale.com>
- * Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstgldisplay_viv_fb.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_gl_display_debug);
-#define GST_CAT_DEFAULT gst_gl_display_debug
-
-G_DEFINE_TYPE (GstGLDisplayVivFB, gst_gl_display_viv_fb, GST_TYPE_GL_DISPLAY);
-
-static void gst_gl_display_viv_fb_finalize (GObject * object);
-static guintptr gst_gl_display_viv_fb_get_handle (GstGLDisplay * display);
-
-static void
-gst_gl_display_viv_fb_class_init (GstGLDisplayVivFBClass * klass)
-{
- GST_GL_DISPLAY_CLASS (klass)->get_handle =
- GST_DEBUG_FUNCPTR (gst_gl_display_viv_fb_get_handle);
-
- G_OBJECT_CLASS (klass)->finalize = gst_gl_display_viv_fb_finalize;
-}
-
-static void
-gst_gl_display_viv_fb_init (GstGLDisplayVivFB * display_viv_fb)
-{
- GstGLDisplay *display = (GstGLDisplay *) display_viv_fb;
-
- display->type = GST_GL_DISPLAY_TYPE_VIV_FB;
-
- display_viv_fb->disp_idx = 0;
- display_viv_fb->display = NULL;
-}
-
-static void
-gst_gl_display_viv_fb_finalize (GObject * object)
-{
- GstGLDisplayVivFB *display_viv_fb = GST_GL_DISPLAY_VIV_FB (object);
-
- // We don't destroy the FB Display - it causes crashes in applications
- // because Vivante doesn't seem to do any refcounting
-
- G_OBJECT_CLASS (gst_gl_display_viv_fb_parent_class)->finalize (object);
-}
-
-/**
- * gst_gl_display_viv_fb_new:
- * @disp_idx: a display index
- *
- * Create a new #GstGLDisplayVivFB from the FB display index.
- *
- * Returns: (transfer full): a new #GstGLDisplayVivFB or %NULL
- */
-GstGLDisplayVivFB *
-gst_gl_display_viv_fb_new (gint disp_idx)
-{
- GstGLDisplayVivFB *display;
-
- GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");
-
- GST_DEBUG ("creating Vivante FB EGL display %d", disp_idx);
-
- display = g_object_new (GST_TYPE_GL_DISPLAY_VIV_FB, NULL);
- gst_object_ref_sink (display);
- display->disp_idx = disp_idx;
- display->display = fbGetDisplayByIndex (display->disp_idx);
- if (!display->display) {
- GST_ERROR ("Failed to open Vivante FB display %d", disp_idx);
- return NULL;
- }
-
- GST_DEBUG ("Created Vivante FB EGL display %p", (gpointer) display->display);
-
- return display;
-}
-
-static guintptr
-gst_gl_display_viv_fb_get_handle (GstGLDisplay * display)
-{
- return (guintptr) GST_GL_DISPLAY_VIV_FB (display)->display;
-}
diff --git a/gst-libs/gst/gl/viv-fb/gstgldisplay_viv_fb.h b/gst-libs/gst/gl/viv-fb/gstgldisplay_viv_fb.h
deleted file mode 100644
index 9ce1dce84..000000000
--- a/gst-libs/gst/gl/viv-fb/gstgldisplay_viv_fb.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2014 Matthew Waters <ystreet00@gmail.com>
- * Copyright (C) 2015 Freescale Semiconductor <b55597@freescale.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_DISPLAY_VIV_FB_H__
-#define __GST_GL_DISPLAY_VIV_FB_H__
-
-#include <gst/gst.h>
-#include <gst/gl/gstgldisplay.h>
-#include <gst/gl/egl/gstegl.h>
-
-G_BEGIN_DECLS
-
-GType gst_gl_display_viv_fb_get_type (void);
-
-#define GST_TYPE_GL_DISPLAY_VIV_FB (gst_gl_display_viv_fb_get_type())
-#define GST_GL_DISPLAY_VIV_FB(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_DISPLAY_VIV_FB,GstGLDisplayVivFB))
-#define GST_GL_DISPLAY_VIV_FB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_GL_DISPLAY_VIV_FB,GstGLDisplayVivFBClass))
-#define GST_IS_GL_DISPLAY_VIV_FB(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_DISPLAY_VIV_FB))
-#define GST_IS_GL_DISPLAY_VIV_FB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GL_DISPLAY_VIV_FB))
-#define GST_GL_DISPLAY_VIV_FB_CAST(obj) ((GstGLDisplayVivFB*)(obj))
-
-typedef struct _GstGLDisplayVivFB GstGLDisplayVivFB;
-typedef struct _GstGLDisplayVivFBClass GstGLDisplayVivFBClass;
-
-/**
- * GstGLDisplayVivFB:
- *
- * the contents of a #GstGLDisplayVivFB are private and should only be accessed
- * through the provided API
- */
-struct _GstGLDisplayVivFB
-{
- GstGLDisplay parent;
-
- /* <private> */
- gint disp_idx;
- EGLNativeDisplayType display;
-};
-
-struct _GstGLDisplayVivFBClass
-{
- GstGLDisplayClass object_class;
-};
-
-GstGLDisplayVivFB *gst_gl_display_viv_fb_new (gint disp_idx);
-
-G_END_DECLS
-
-#endif /* __GST_GL_DISPLAY_VIV_FB_H__ */
diff --git a/gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.c b/gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.c
deleted file mode 100644
index 8515dc8ec..000000000
--- a/gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- * Copyright (C) 2015 Freescale Semiconductor <b55597@freescale.com>
- * Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "../gstgl_fwd.h"
-#include <gst/gl/gstglcontext.h>
-
-#include "gstglwindow_viv_fb_egl.h"
-#include "../gstglwindow_private.h"
-
-#define GST_CAT_DEFAULT gst_gl_window_debug
-
-#define gst_gl_window_viv_fb_egl_parent_class parent_class
-G_DEFINE_TYPE (GstGLWindowVivFBEGL, gst_gl_window_viv_fb_egl,
- GST_TYPE_GL_WINDOW);
-
-static guintptr gst_gl_window_viv_fb_egl_get_window_handle (GstGLWindow *
- window);
-static guintptr gst_gl_window_viv_fb_egl_get_display (GstGLWindow * window);
-static void gst_gl_window_viv_fb_egl_set_window_handle (GstGLWindow * window,
- guintptr handle);
-static void gst_gl_window_viv_fb_egl_close (GstGLWindow * window);
-static gboolean gst_gl_window_viv_fb_egl_open (GstGLWindow * window,
- GError ** error);
-static void gst_gl_window_viv_fb_egl_draw (GstGLWindow * window);
-static gboolean
-gst_gl_window_viv_fb_egl_set_render_rectangle (GstGLWindow * window,
- gint x, gint y, gint width, gint height);
-
-static void
-gst_gl_window_viv_fb_egl_class_init (GstGLWindowVivFBEGLClass * klass)
-{
- GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
-
- window_class->get_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_viv_fb_egl_get_window_handle);
- window_class->get_display =
- GST_DEBUG_FUNCPTR (gst_gl_window_viv_fb_egl_get_display);
- window_class->set_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_viv_fb_egl_set_window_handle);
- window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_viv_fb_egl_close);
- window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_viv_fb_egl_open);
- window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_viv_fb_egl_draw);
- window_class->set_render_rectangle =
- GST_DEBUG_FUNCPTR (gst_gl_window_viv_fb_egl_set_render_rectangle);
-}
-
-static void
-gst_gl_window_viv_fb_egl_init (GstGLWindowVivFBEGL * window)
-{
-}
-
-/* Must be called in the gl thread */
-GstGLWindowVivFBEGL *
-gst_gl_window_viv_fb_egl_new (GstGLDisplay * display)
-{
- GstGLWindowVivFBEGL *window;
-
- if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_VIV_FB) ==
- 0)
- /* we require a Vivante FB display to create windows */
- return NULL;
-
- window = g_object_new (GST_TYPE_GL_WINDOW_VIV_FB_EGL, NULL);
- gst_object_ref_sink (window);
-
- return window;
-}
-
-static void
-gst_gl_window_viv_fb_egl_close (GstGLWindow * window)
-{
- GstGLWindowVivFBEGL *window_egl = GST_GL_WINDOW_VIV_FB_EGL (window);
-
- if (window_egl->win_id && !window_egl->external_window) {
- fbDestroyWindow (window_egl->win_id);
- window_egl->win_id = 0;
- }
-
- GST_GL_WINDOW_CLASS (parent_class)->close (window);
-}
-
-static guintptr
-gst_gl_window_viv_fb_egl_get_display (GstGLWindow * window)
-{
- return gst_gl_display_get_handle (window->display);
-}
-
-static gboolean
-gst_gl_window_viv_fb_egl_open (GstGLWindow * window, GError ** error)
-{
- GstGLWindowVivFBEGL *window_egl = GST_GL_WINDOW_VIV_FB_EGL (window);
- EGLNativeDisplayType display;
-
- display = (EGLNativeDisplayType) gst_gl_window_get_display (window);
-
- window_egl->win_id = fbCreateWindow (display, -1, -1, 0, 0);
- window_egl->external_window = FALSE;
- if (!window_egl->win_id) {
- g_set_error (error, GST_GL_WINDOW_ERROR,
- GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE, "Can't create window");
- return FALSE;
- }
-
- fbGetWindowGeometry (window_egl->win_id, NULL, NULL,
- &window_egl->window_width, &window_egl->window_height);
- window_egl->render_rectangle.x = 0;
- window_egl->render_rectangle.y = 0;
- window_egl->render_rectangle.w = window_egl->window_width;
- window_egl->render_rectangle.h = window_egl->window_height;
- gst_gl_window_resize (window, window_egl->window_width,
- window_egl->window_height);
-
- GST_DEBUG
- ("Opened Vivante FB display succesfully, resolution is (%dx%d), display %p, window %p.",
- window_egl->window_width, window_egl->window_height, (gpointer) display,
- (gpointer) window_egl->win_id);
-
- return GST_GL_WINDOW_CLASS (parent_class)->open (window, error);
-}
-
-static guintptr
-gst_gl_window_viv_fb_egl_get_window_handle (GstGLWindow * window)
-{
- return (guintptr) GST_GL_WINDOW_VIV_FB_EGL (window)->win_id;
-}
-
-static void
-gst_gl_window_viv_fb_egl_set_window_handle (GstGLWindow * window,
- guintptr handle)
-{
- GstGLWindowVivFBEGL *window_egl = GST_GL_WINDOW_VIV_FB_EGL (window);
- gint width, height;
-
- if (window_egl->win_id)
- fbDestroyWindow (window_egl->win_id);
- window_egl->win_id = (EGLNativeWindowType) handle;
- window_egl->external_window = handle != 0;
-
- fbGetWindowGeometry (window_egl->win_id, NULL, NULL, &width, &height);
- gst_gl_window_resize (window, width, height);
-}
-
-static void
-draw_cb (gpointer data)
-{
- GstGLWindowVivFBEGL *window_egl = data;
- GstGLWindow *window = GST_GL_WINDOW (window_egl);
- GstGLContext *context = gst_gl_window_get_context (window);
- const GstGLFuncs *gl;
- gint viewport_dim[4];
-
- gl = context->gl_vtable;
-
- if (window->queue_resize) {
- guint width, height;
-
- gst_gl_window_get_surface_dimensions (window, &width, &height);
- gst_gl_window_resize (window, width, height);
-
- gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
- viewport_dim[0] += window_egl->render_rectangle.x;
- viewport_dim[1] += window_egl->render_rectangle.y;
- gl->Viewport (viewport_dim[0],
- viewport_dim[1], viewport_dim[2], viewport_dim[3]);
- }
-
- if (window->draw)
- window->draw (window->draw_data);
-
- gst_gl_context_swap_buffers (context);
-
- gst_object_unref (context);
-}
-
-static void
-gst_gl_window_viv_fb_egl_draw (GstGLWindow * window)
-{
- gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
-}
-
-typedef struct
-{
- GstGLWindowVivFBEGL *window_egl;
- GstVideoRectangle rect;
-} SetRenderRectangleData;
-
-static void
-_free_set_render_rectangle (SetRenderRectangleData * render)
-{
- if (render) {
- if (render->window_egl)
- gst_object_unref (render->window_egl);
- g_free (render);
- }
-}
-
-static void
-_calculate_viewport_coordinates(GstGLWindowVivFBEGL * window_egl,
- GstVideoRectangle * req, GstVideoRectangle * result)
-{
- result->x = req->x;
- result->y = window_egl->window_height - (req->y + req->h);
- result->w = req->w;
- result->h = req->h;
-}
-
-static void
-_set_render_rectangle (gpointer data)
-{
- SetRenderRectangleData *render = data;
- GstGLWindowVivFBEGL *window_egl = render->window_egl;
- GstGLWindow *window = GST_GL_WINDOW (window_egl);
-
- GST_LOG_OBJECT (render->window_egl, "setting render rectangle %i,%i+%ix%i",
- render->rect.x, render->rect.y, render->rect.w, render->rect.h);
-
- _calculate_viewport_coordinates (window_egl, &render->rect,
- &window_egl->render_rectangle);
-
- gst_gl_window_resize (window, render->rect.w, render->rect.h);
-
- window->queue_resize = TRUE;
-}
-
-static gboolean
-gst_gl_window_viv_fb_egl_set_render_rectangle (GstGLWindow * window,
- gint x, gint y, gint width, gint height)
-{
- GstGLWindowVivFBEGL *window_egl = GST_GL_WINDOW_VIV_FB_EGL (window);
- SetRenderRectangleData *render;
-
- render = g_new0 (SetRenderRectangleData, 1);
- render->window_egl = gst_object_ref (window_egl);
- render->rect.x = x;
- render->rect.y = y;
- render->rect.w = width;
- render->rect.h = height;
-
- gst_gl_window_send_message_async (window,
- (GstGLWindowCB) _set_render_rectangle, render,
- (GDestroyNotify) _free_set_render_rectangle);
-
- return TRUE;
-}
diff --git a/gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.h b/gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.h
deleted file mode 100644
index 60205e0dc..000000000
--- a/gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- * Copyright (C) 2015 Freescale Semiconductor <b55597@freescale.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_WINDOW_VIV_FB_EGL_H__
-#define __GST_GL_WINDOW_VIV_FB_EGL_H__
-
-#include <gst/gl/gl.h>
-#include <gst/gl/egl/gstegl.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_WINDOW_VIV_FB_EGL (gst_gl_window_viv_fb_egl_get_type())
-#define GST_GL_WINDOW_VIV_FB_EGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW_VIV_FB_EGL, GstGLWindowVivFBEGL))
-#define GST_GL_WINDOW_VIV_FB_EGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_WINDOW_VIV_FB_EGL, GstGLWindowVivFBEGLClass))
-#define GST_IS_GL_WINDOW_VIV_FB_EGL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW_VIV_FB_EGL))
-#define GST_IS_GL_WINDOW_VIV_FB_EGL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW_VIV_FB_EGL))
-#define GST_GL_WINDOW_VIV_FB_EGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW_VIV_FB_EGL, GstGLWindowVivFBEGL_Class))
-
-typedef struct _GstGLWindowVivFBEGL GstGLWindowVivFBEGL;
-typedef struct _GstGLWindowVivFBEGLClass GstGLWindowVivFBEGLClass;
-
-struct _GstGLWindowVivFBEGL {
- /*< private >*/
- GstGLWindow parent;
-
- /* <private> */
- EGLNativeWindowType win_id;
- gboolean external_window;
- gint window_width, window_height;
-
- GstVideoRectangle render_rectangle;
-};
-
-struct _GstGLWindowVivFBEGLClass {
- /*< private >*/
- GstGLWindowClass parent_class;
-
- /*< private >*/
- gpointer _reserved[GST_PADDING];
-};
-
-GType gst_gl_window_viv_fb_egl_get_type (void);
-
-GstGLWindowVivFBEGL * gst_gl_window_viv_fb_egl_new (GstGLDisplay * display);
-
-G_END_DECLS
-
-#endif /* __GST_GL_WINDOW_VIV_FB_EGL_H__ */
diff --git a/gst-libs/gst/gl/wayland/Makefile.am b/gst-libs/gst/gl/wayland/Makefile.am
deleted file mode 100644
index c739b9d82..000000000
--- a/gst-libs/gst/gl/wayland/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-noinst_LTLIBRARIES = libgstgl-wayland.la
-
-libgstgl_wayland_la_SOURCES = \
- gstgldisplay_wayland.c \
- gstglwindow_wayland_egl.c \
- wayland_event_source.c
-
-noinst_HEADERS = \
- gstgldisplay_wayland.h \
- gstglwindow_wayland_egl.h \
- wayland_event_source.h
-
-libgstgl_waylandincludedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl/wayland
-libgstgl_waylandinclude_HEADERS = \
- gstgldisplay_wayland.h
-
-libgstgl_wayland_la_CFLAGS = \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- $(GL_CFLAGS) \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) \
- $(GST_CFLAGS)
-
-libgstgl_wayland_la_LDFLAGS = \
- $(GST_LIB_LDFLAGS) \
- $(GST_ALL_LDFLAGS)
diff --git a/gst-libs/gst/gl/wayland/gstgldisplay_wayland.c b/gst-libs/gst/gl/wayland/gstgldisplay_wayland.c
deleted file mode 100644
index 054dcf432..000000000
--- a/gst-libs/gst/gl/wayland/gstgldisplay_wayland.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gl/wayland/gstgldisplay_wayland.h>
-
-GST_DEBUG_CATEGORY_STATIC (gst_gl_display_debug);
-#define GST_CAT_DEFAULT gst_gl_display_debug
-
-G_DEFINE_TYPE (GstGLDisplayWayland, gst_gl_display_wayland,
- GST_TYPE_GL_DISPLAY);
-
-static void gst_gl_display_wayland_finalize (GObject * object);
-static guintptr gst_gl_display_wayland_get_handle (GstGLDisplay * display);
-
-static void
-registry_handle_global (void *data, struct wl_registry *registry,
- uint32_t name, const char *interface, uint32_t version)
-{
- GstGLDisplayWayland *display = data;
-
- GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");
-
- GST_TRACE_OBJECT (display, "registry_handle_global with registry %p, "
- "interface %s, version %u", registry, interface, version);
-
- if (g_strcmp0 (interface, "wl_compositor") == 0) {
- display->compositor =
- wl_registry_bind (registry, name, &wl_compositor_interface, 1);
- } else if (g_strcmp0 (interface, "wl_subcompositor") == 0) {
- display->subcompositor =
- wl_registry_bind (registry, name, &wl_subcompositor_interface, 1);
- } else if (g_strcmp0 (interface, "wl_shell") == 0) {
- display->shell = wl_registry_bind (registry, name, &wl_shell_interface, 1);
- }
-}
-
-static const struct wl_registry_listener registry_listener = {
- registry_handle_global
-};
-
-static void
-_connect_listeners (GstGLDisplayWayland * display)
-{
- display->registry = wl_display_get_registry (display->display);
- wl_registry_add_listener (display->registry, &registry_listener, display);
-
- wl_display_roundtrip (display->display);
-}
-
-static void
-gst_gl_display_wayland_class_init (GstGLDisplayWaylandClass * klass)
-{
- GST_GL_DISPLAY_CLASS (klass)->get_handle =
- GST_DEBUG_FUNCPTR (gst_gl_display_wayland_get_handle);
-
- G_OBJECT_CLASS (klass)->finalize = gst_gl_display_wayland_finalize;
-}
-
-static void
-gst_gl_display_wayland_init (GstGLDisplayWayland * display_wayland)
-{
- GstGLDisplay *display = (GstGLDisplay *) display_wayland;
-
- display->type = GST_GL_DISPLAY_TYPE_WAYLAND;
- display_wayland->foreign_display = FALSE;
-}
-
-static void
-gst_gl_display_wayland_finalize (GObject * object)
-{
- GstGLDisplayWayland *display_wayland = GST_GL_DISPLAY_WAYLAND (object);
-
- /* Cause eglTerminate() to occur before wl_display_disconnect()
- * https://bugzilla.gnome.org/show_bug.cgi?id=787293 */
- g_object_set_data (object, "gst.gl.display.egl", NULL);
-
- if (!display_wayland->foreign_display && display_wayland->display) {
- wl_display_flush (display_wayland->display);
- wl_display_disconnect (display_wayland->display);
- }
-
- G_OBJECT_CLASS (gst_gl_display_wayland_parent_class)->finalize (object);
-}
-
-/**
- * gst_gl_display_wayland_new:
- * @name: (allow-none): a display name
- *
- * Create a new #GstGLDisplayWayland from the wayland display name. See wl_display_connect()
- * for details on what is a valid name.
- *
- * Returns: (transfer full): a new #GstGLDisplayWayland or %NULL
- */
-GstGLDisplayWayland *
-gst_gl_display_wayland_new (const gchar * name)
-{
- GstGLDisplayWayland *ret;
-
- GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");
-
- ret = g_object_new (GST_TYPE_GL_DISPLAY_WAYLAND, NULL);
- gst_object_ref_sink (ret);
- ret->display = wl_display_connect (name);
-
- if (!ret->display) {
- if (name != NULL) {
- GST_ERROR ("Failed to open Wayland display connection with name \'%s\'",
- name);
- } else {
- GST_INFO ("Failed to open Wayland display connection.");
- }
- return NULL;
- }
-
- _connect_listeners (ret);
-
- return ret;
-}
-
-/**
- * gst_gl_display_wayland_new_with_display:
- * @display: an existing, wayland display
- *
- * Creates a new display connection from a wl_display Display.
- *
- * Returns: (transfer full): a new #GstGLDisplayWayland
- */
-GstGLDisplayWayland *
-gst_gl_display_wayland_new_with_display (struct wl_display * display)
-{
- GstGLDisplayWayland *ret;
-
- g_return_val_if_fail (display != NULL, NULL);
-
- GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");
-
- ret = g_object_new (GST_TYPE_GL_DISPLAY_WAYLAND, NULL);
- gst_object_ref_sink (ret);
-
- ret->display = display;
- ret->foreign_display = TRUE;
-
- _connect_listeners (ret);
-
- return ret;
-}
-
-static guintptr
-gst_gl_display_wayland_get_handle (GstGLDisplay * display)
-{
- return (guintptr) GST_GL_DISPLAY_WAYLAND (display)->display;
-}
diff --git a/gst-libs/gst/gl/wayland/gstgldisplay_wayland.h b/gst-libs/gst/gl/wayland/gstgldisplay_wayland.h
deleted file mode 100644
index ab1d42afa..000000000
--- a/gst-libs/gst/gl/wayland/gstgldisplay_wayland.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_DISPLAY_WAYLAND_H__
-#define __GST_GL_DISPLAY_WAYLAND_H__
-
-#include <gst/gst.h>
-
-#include <wayland-client.h>
-
-#include <gst/gl/gstgl_fwd.h>
-#include <gst/gl/gstgldisplay.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT GType gst_gl_display_wayland_get_type (void);
-
-#define GST_TYPE_GL_DISPLAY_WAYLAND (gst_gl_display_wayland_get_type())
-#define GST_GL_DISPLAY_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_DISPLAY_WAYLAND,GstGLDisplayWayland))
-#define GST_GL_DISPLAY_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_GL_DISPLAY_WAYLAND,GstGLDisplayWaylandClass))
-#define GST_IS_GL_DISPLAY_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_DISPLAY_WAYLAND))
-#define GST_IS_GL_DISPLAY_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GL_DISPLAY_WAYLAND))
-#define GST_GL_DISPLAY_WAYLAND_CAST(obj) ((GstGLDisplayWayland*)(obj))
-
-typedef struct _GstGLDisplayWayland GstGLDisplayWayland;
-typedef struct _GstGLDisplayWaylandClass GstGLDisplayWaylandClass;
-
-/**
- * GstGLDisplayWayland:
- *
- * the contents of a #GstGLDisplayWayland are private and should only be accessed
- * through the provided API
- */
-struct _GstGLDisplayWayland
-{
- GstGLDisplay parent;
-
- struct wl_display *display;
- struct wl_registry *registry;
- struct wl_compositor *compositor;
- struct wl_subcompositor *subcompositor;
- struct wl_shell *shell;
-
- /* <private> */
- gboolean foreign_display;
-
- gpointer _padding[GST_PADDING];
-};
-
-struct _GstGLDisplayWaylandClass
-{
- GstGLDisplayClass object_class;
-
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GstGLDisplayWayland *gst_gl_display_wayland_new (const gchar * name);
-
-GST_EXPORT
-GstGLDisplayWayland *gst_gl_display_wayland_new_with_display (struct wl_display *display);
-
-G_END_DECLS
-
-#endif /* __GST_GL_DISPLAY_WAYLAND_H__ */
diff --git a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c
deleted file mode 100644
index 4c71bf51d..000000000
--- a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c
+++ /dev/null
@@ -1,583 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#define GLIB_DISABLE_DEPRECATION_WARNINGS
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <linux/input.h>
-
-#include "wayland_event_source.h"
-
-#include "../gstgl_fwd.h"
-#include <gst/gl/gstglcontext.h>
-
-#include "gstgldisplay_wayland.h"
-#include "gstglwindow_wayland_egl.h"
-
-#include "../gstglwindow_private.h"
-
-const gchar *WlEGLErrorString ();
-
-#define GST_CAT_DEFAULT gst_gl_window_debug
-
-#define gst_gl_window_wayland_egl_parent_class parent_class
-G_DEFINE_TYPE (GstGLWindowWaylandEGL, gst_gl_window_wayland_egl,
- GST_TYPE_GL_WINDOW);
-
-static guintptr gst_gl_window_wayland_egl_get_window_handle (GstGLWindow *
- window);
-static void gst_gl_window_wayland_egl_set_window_handle (GstGLWindow * window,
- guintptr handle);
-static void gst_gl_window_wayland_egl_show (GstGLWindow * window);
-static void gst_gl_window_wayland_egl_draw (GstGLWindow * window);
-static void gst_gl_window_wayland_egl_close (GstGLWindow * window);
-static gboolean gst_gl_window_wayland_egl_open (GstGLWindow * window,
- GError ** error);
-static guintptr gst_gl_window_wayland_egl_get_display (GstGLWindow * window);
-static gboolean gst_gl_window_wayland_egl_set_render_rectangle (GstGLWindow *
- window, gint x, gint y, gint width, gint height);
-
-#if 0
-static void
-pointer_handle_enter (void *data, struct wl_pointer *pointer, uint32_t serial,
- struct wl_surface *surface, wl_fixed_t sx_w, wl_fixed_t sy_w)
-{
- GstGLWindowWaylandEGL *window_egl = data;
- struct wl_buffer *buffer;
- struct wl_cursor_image *image = NULL;
-
- window_egl->display.serial = serial;
-
- if (window_egl->display.default_cursor) {
- image = window_egl->display.default_cursor->images[0];
- buffer = wl_cursor_image_get_buffer (image);
- wl_pointer_set_cursor (pointer, serial,
- window_egl->display.cursor_surface, image->hotspot_x, image->hotspot_y);
- wl_surface_attach (window_egl->display.cursor_surface, buffer, 0, 0);
- wl_surface_damage (window_egl->display.cursor_surface, 0, 0,
- image->width, image->height);
- wl_surface_commit (window_egl->display.cursor_surface);
- }
-}
-
-static void
-pointer_handle_leave (void *data, struct wl_pointer *pointer, uint32_t serial,
- struct wl_surface *surface)
-{
- GstGLWindowWaylandEGL *window_egl = data;
- window_egl->display.serial = serial;
-}
-
-static void
-pointer_handle_motion (void *data, struct wl_pointer *pointer, uint32_t time,
- wl_fixed_t sx_w, wl_fixed_t sy_w)
-{
- GstGLWindowWaylandEGL *window_egl = data;
-
- window_egl->display.pointer_x = wl_fixed_to_double (sx_w);
- window_egl->display.pointer_y = wl_fixed_to_double (sy_w);
-}
-
-enum wl_edges
-{
- WL_EDGE_NONE = 0,
- WL_EDGE_TOP = 1,
- WL_EDGE_BOTTOM = 2,
- WL_EDGE_LEFT = 4,
- WL_EDGE_RIGHT = 8,
-};
-
-static guint
-_get_closest_pointer_corner (GstGLWindowWaylandEGL * window_egl)
-{
- guint edges = 0;
- gdouble win_width, win_height;
- gdouble p_x, p_y;
-
- win_width = (gdouble) window_egl->window.window_width;
- win_height = (gdouble) window_egl->window.window_height;
- p_x = window_egl->display.pointer_x;
- p_y = window_egl->display.pointer_y;
-
- if (win_width == 0.0 || win_height == 0.0)
- return WL_EDGE_NONE;
-
- edges |= win_width / 2.0 - p_x < 0.0 ? WL_EDGE_RIGHT : WL_EDGE_LEFT;
- edges |= win_height / 2.0 - p_y < 0.0 ? WL_EDGE_BOTTOM : WL_EDGE_TOP;
-
- return edges;
-}
-
-static void
-pointer_handle_button (void *data, struct wl_pointer *pointer, uint32_t serial,
- uint32_t time, uint32_t button, uint32_t state_w)
-{
- GstGLWindowWaylandEGL *window_egl = data;
- guint edges = _get_closest_pointer_corner (window_egl);
- window_egl->display.serial = serial;
-
- if (button == BTN_LEFT && state_w == WL_POINTER_BUTTON_STATE_PRESSED)
- wl_shell_surface_move (window_egl->window.shell_surface,
- window_egl->display.seat, serial);
-
- if (button == BTN_RIGHT && state_w == WL_POINTER_BUTTON_STATE_PRESSED)
- wl_shell_surface_resize (window_egl->window.shell_surface,
- window_egl->display.seat, serial, edges);
-}
-
-static void
-pointer_handle_axis (void *data, struct wl_pointer *pointer, uint32_t time,
- uint32_t axis, wl_fixed_t value)
-{
-}
-
-static const struct wl_pointer_listener pointer_listener = {
- pointer_handle_enter,
- pointer_handle_leave,
- pointer_handle_motion,
- pointer_handle_button,
- pointer_handle_axis,
-};
-
-static void
-seat_handle_capabilities (void *data, struct wl_seat *seat,
- enum wl_seat_capability caps)
-{
- GstGLWindowWaylandEGL *window_egl = data;
- struct display *display = &window_egl->display;
-
- if ((caps & WL_SEAT_CAPABILITY_POINTER) && !display->pointer) {
- display->pointer = wl_seat_get_pointer (seat);
- wl_pointer_set_user_data (display->pointer, window_egl);
- wl_pointer_add_listener (display->pointer, &pointer_listener, window_egl);
- } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && display->pointer) {
- wl_pointer_destroy (display->pointer);
- display->pointer = NULL;
- }
-#if 0
- if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) {
- input->keyboard = wl_seat_get_keyboard (seat);
- wl_keyboard_set_user_data (input->keyboard, input);
- wl_keyboard_add_listener (input->keyboard, &keyboard_listener, input);
- } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
- wl_keyboard_destroy (input->keyboard);
- input->keyboard = NULL;
- }
-#endif
-}
-
-static const struct wl_seat_listener seat_listener = {
- seat_handle_capabilities,
-};
-#endif
-static void
-handle_ping (void *data, struct wl_shell_surface *shell_surface,
- uint32_t serial)
-{
- GstGLWindowWaylandEGL *window_egl = data;
-
- GST_TRACE_OBJECT (window_egl, "ping received serial %u", serial);
-
- wl_shell_surface_pong (shell_surface, serial);
-}
-
-static void window_resize (GstGLWindowWaylandEGL * window_egl, guint width,
- guint height);
-
-static void
-handle_configure (void *data, struct wl_shell_surface *shell_surface,
- uint32_t edges, int32_t width, int32_t height)
-{
- GstGLWindowWaylandEGL *window_egl = data;
-
- GST_DEBUG ("configure event on surface %p, %ix%i", shell_surface, width,
- height);
-
- window_resize (window_egl, width, height);
-}
-
-static void
-handle_popup_done (void *data, struct wl_shell_surface *shell_surface)
-{
-}
-
-static const struct wl_shell_surface_listener shell_surface_listener = {
- handle_ping,
- handle_configure,
- handle_popup_done
-};
-
-static void
-destroy_surfaces (GstGLWindowWaylandEGL * window_egl)
-{
- if (window_egl->window.subsurface) {
- wl_subsurface_destroy (window_egl->window.subsurface);
- window_egl->window.subsurface = NULL;
- }
- if (window_egl->window.shell_surface) {
- wl_shell_surface_destroy (window_egl->window.shell_surface);
- window_egl->window.shell_surface = NULL;
- }
- if (window_egl->window.surface) {
- wl_surface_destroy (window_egl->window.surface);
- window_egl->window.surface = NULL;
- }
- if (window_egl->window.native) {
- wl_egl_window_destroy (window_egl->window.native);
- window_egl->window.native = NULL;
- }
-}
-
-static void
-create_surfaces (GstGLWindowWaylandEGL * window_egl)
-{
- GstGLDisplayWayland *display =
- GST_GL_DISPLAY_WAYLAND (GST_GL_WINDOW (window_egl)->display);
- gint width, height;
-
- if (!window_egl->window.surface) {
- window_egl->window.surface =
- wl_compositor_create_surface (display->compositor);
- if (window_egl->window.queue)
- wl_proxy_set_queue ((struct wl_proxy *) window_egl->window.surface,
- window_egl->window.queue);
- }
-
- if (window_egl->window.foreign_surface) {
- /* (re)parent */
- if (!display->subcompositor) {
- GST_ERROR_OBJECT (window_egl,
- "Wayland server does not support subsurfaces");
- window_egl->window.foreign_surface = NULL;
- goto shell_window;
- }
-
- if (!window_egl->window.subsurface) {
- window_egl->window.subsurface =
- wl_subcompositor_get_subsurface (display->subcompositor,
- window_egl->window.surface, window_egl->window.foreign_surface);
- if (window_egl->window.queue)
- wl_proxy_set_queue ((struct wl_proxy *) window_egl->window.subsurface,
- window_egl->window.queue);
-
- wl_subsurface_set_position (window_egl->window.subsurface,
- window_egl->window.window_x, window_egl->window.window_y);
- wl_subsurface_set_desync (window_egl->window.subsurface);
- }
- } else {
- shell_window:
- if (!window_egl->window.shell_surface) {
- window_egl->window.shell_surface =
- wl_shell_get_shell_surface (display->shell,
- window_egl->window.surface);
- if (window_egl->window.queue)
- wl_proxy_set_queue ((struct wl_proxy *) window_egl->window.
- shell_surface, window_egl->window.queue);
-
- wl_shell_surface_add_listener (window_egl->window.shell_surface,
- &shell_surface_listener, window_egl);
-
- wl_shell_surface_set_title (window_egl->window.shell_surface,
- "OpenGL Renderer");
- wl_shell_surface_set_toplevel (window_egl->window.shell_surface);
- }
- }
-
- if (window_egl->window.window_width > 0)
- width = window_egl->window.window_width;
- else
- width = 320;
- window_egl->window.window_width = width;
-
- if (window_egl->window.window_height > 0)
- height = window_egl->window.window_height;
- else
- height = 240;
- window_egl->window.window_height = height;
-
- if (!window_egl->window.native) {
- gst_gl_window_resize (GST_GL_WINDOW (window_egl), width, height);
-
- window_egl->window.native =
- wl_egl_window_create (window_egl->window.surface, width, height);
- if (window_egl->window.queue)
- wl_proxy_set_queue ((struct wl_proxy *) window_egl->window.native,
- window_egl->window.queue);
- }
-}
-
-static void
-gst_gl_window_wayland_egl_class_init (GstGLWindowWaylandEGLClass * klass)
-{
- GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
-
- window_class->get_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_get_window_handle);
- window_class->set_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_set_window_handle);
- window_class->show = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_show);
- window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_draw);
- window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_close);
- window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_open);
- window_class->get_display =
- GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_get_display);
- window_class->set_render_rectangle =
- GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_set_render_rectangle);
-}
-
-static void
-gst_gl_window_wayland_egl_init (GstGLWindowWaylandEGL * window)
-{
-}
-
-/* Must be called in the gl thread */
-GstGLWindowWaylandEGL *
-gst_gl_window_wayland_egl_new (GstGLDisplay * display)
-{
- GstGLWindowWaylandEGL *window;
-
- if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_WAYLAND)
- == 0)
- /* we require a wayland display to create wayland surfaces */
- return NULL;
-
- GST_DEBUG ("creating Wayland EGL window");
-
- window = g_object_new (GST_TYPE_GL_WINDOW_WAYLAND_EGL, NULL);
- gst_object_ref_sink (window);
-
- return window;
-}
-
-static void
-gst_gl_window_wayland_egl_close (GstGLWindow * window)
-{
- GstGLWindowWaylandEGL *window_egl;
-
- window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
-
- destroy_surfaces (window_egl);
-
- g_source_destroy (window_egl->wl_source);
- g_source_unref (window_egl->wl_source);
- window_egl->wl_source = NULL;
-
- GST_GL_WINDOW_CLASS (parent_class)->close (window);
-}
-
-static gboolean
-gst_gl_window_wayland_egl_open (GstGLWindow * window, GError ** error)
-{
- GstGLDisplayWayland *display;
- GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
-
- if (!GST_IS_GL_DISPLAY_WAYLAND (window->display)) {
- g_set_error (error, GST_GL_WINDOW_ERROR,
- GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
- "Failed to retrieve Wayland display (wrong type?)");
- return FALSE;
- }
- display = GST_GL_DISPLAY_WAYLAND (window->display);
-
- if (!display->display) {
- g_set_error (error, GST_GL_WINDOW_ERROR,
- GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
- "Failed to retrieve Wayland display");
- return FALSE;
- }
-
- window_egl->window.queue = wl_display_create_queue (display->display);
-
- window_egl->wl_source = wayland_event_source_new (display->display,
- window_egl->window.queue);
-
- if (!GST_GL_WINDOW_CLASS (parent_class)->open (window, error))
- return FALSE;
-
- g_source_attach (window_egl->wl_source, window->main_context);
-
- return TRUE;
-}
-
-void
-gst_gl_window_wayland_egl_create_window (GstGLWindowWaylandEGL * window_egl)
-{
- create_surfaces (window_egl);
-}
-
-static guintptr
-gst_gl_window_wayland_egl_get_window_handle (GstGLWindow * window)
-{
- return (guintptr) GST_GL_WINDOW_WAYLAND_EGL (window)->window.native;
-}
-
-static void
-gst_gl_window_wayland_egl_set_window_handle (GstGLWindow * window,
- guintptr handle)
-{
- GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
- struct wl_surface *surface = (struct wl_surface *) handle;
-
- /* already set the NULL handle */
- if (surface == NULL && window_egl->window.foreign_surface == NULL)
- return;
-
- /* unparent */
- destroy_surfaces (window_egl);
- window_egl->window.foreign_surface = surface;
- create_surfaces (window_egl);
-}
-
-static void
-gst_gl_window_wayland_egl_show (GstGLWindow * window)
-{
- GstGLDisplayWayland *display_wayland =
- GST_GL_DISPLAY_WAYLAND (window->display);
- GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
-
- create_surfaces (window_egl);
-
- if (gst_gl_wl_display_roundtrip_queue (display_wayland->display,
- window_egl->window.queue) < 0)
- GST_WARNING_OBJECT (window, "failed a roundtrip");
-}
-
-static void
-window_resize (GstGLWindowWaylandEGL * window_egl, guint width, guint height)
-{
- GstGLWindow *window = GST_GL_WINDOW (window_egl);
-
- GST_DEBUG ("resizing window from %ux%u to %ux%u",
- window_egl->window.window_width, window_egl->window.window_height, width,
- height);
-
- if (window_egl->window.native) {
- wl_egl_window_resize (window_egl->window.native, width, height, 0, 0);
- }
-
- gst_gl_window_resize (window, width, height);
-
- window_egl->window.window_width = width;
- window_egl->window.window_height = height;
-}
-
-static void
-draw_cb (gpointer data)
-{
- GstGLWindowWaylandEGL *window_egl = data;
- GstGLWindow *window = GST_GL_WINDOW (window_egl);
- GstGLContext *context = gst_gl_window_get_context (window);
-
- create_surfaces (window_egl);
-
- if (window_egl->window.subsurface)
- wl_subsurface_set_desync (window_egl->window.subsurface);
-
- if (window->queue_resize) {
- guint width, height;
-
- gst_gl_window_get_surface_dimensions (window, &width, &height);
- gst_gl_window_resize (window, width, height);
- }
-
- if (window->draw)
- window->draw (window->draw_data);
-
- gst_gl_context_swap_buffers (context);
-
- if (window_egl->window.subsurface)
- wl_subsurface_set_desync (window_egl->window.subsurface);
-
- gst_object_unref (context);
-}
-
-static void
-gst_gl_window_wayland_egl_draw (GstGLWindow * window)
-{
- gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
-}
-
-struct SetRenderRectangle
-{
- GstGLWindowWaylandEGL *window_egl;
- GstVideoRectangle rect;
-};
-
-static void
-_free_set_render_rectangle (struct SetRenderRectangle *render)
-{
- if (render) {
- if (render->window_egl)
- gst_object_unref (render->window_egl);
- g_free (render);
- }
-}
-
-static void
-_set_render_rectangle (gpointer data)
-{
- struct SetRenderRectangle *render = data;
-
- GST_LOG_OBJECT (render->window_egl, "setting render rectangle %i,%i+%ix%i",
- render->rect.x, render->rect.y, render->rect.w, render->rect.h);
-
- if (render->window_egl->window.subsurface) {
- wl_subsurface_set_sync (render->window_egl->window.subsurface);
- wl_subsurface_set_position (render->window_egl->window.subsurface,
- render->rect.x, render->rect.y);
- render->window_egl->window.window_x = render->rect.x;
- render->window_egl->window.window_y = render->rect.y;
- }
-
- window_resize (render->window_egl, render->rect.w, render->rect.h);
-}
-
-static gboolean
-gst_gl_window_wayland_egl_set_render_rectangle (GstGLWindow * window,
- gint x, gint y, gint width, gint height)
-{
- GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
- struct SetRenderRectangle *render;
-
- render = g_new0 (struct SetRenderRectangle, 1);
- render->window_egl = gst_object_ref (window_egl);
- render->rect.x = x;
- render->rect.y = y;
- render->rect.w = width;
- render->rect.h = height;
-
- gst_gl_window_send_message_async (window,
- (GstGLWindowCB) _set_render_rectangle, render,
- (GDestroyNotify) _free_set_render_rectangle);
-
- return TRUE;
-}
-
-static guintptr
-gst_gl_window_wayland_egl_get_display (GstGLWindow * window)
-{
- GstGLDisplayWayland *display = GST_GL_DISPLAY_WAYLAND (window->display);
-
- return (guintptr) display->display;
-}
diff --git a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.h b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.h
deleted file mode 100644
index 07c7ad1b9..000000000
--- a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_WINDOW_WAYLAND_EGL_H__
-#define __GST_GL_WINDOW_WAYLAND_EGL_H__
-
-#include <wayland-client.h>
-#include <wayland-egl.h>
-#include <wayland-cursor.h>
-
-#include <gst/gl/gl.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_WINDOW_WAYLAND_EGL (gst_gl_window_wayland_egl_get_type())
-#define GST_GL_WINDOW_WAYLAND_EGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW_WAYLAND_EGL, GstGLWindowWaylandEGL))
-#define GST_GL_WINDOW_WAYLAND_EGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_WINDOW_WAYLAND_EGL, GstGLWindowWaylandEGLClass))
-#define GST_IS_GL_WINDOW_WAYLAND_EGL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW_WAYLAND_EGL))
-#define GST_IS_GL_WINDOW_WAYLAND_EGL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW_WAYLAND_EGL))
-#define GST_GL_WINDOW_WAYLAND_EGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW_WAYLAND_EGL, GstGLWindowWaylandEGL_Class))
-
-typedef struct _GstGLWindowWaylandEGL GstGLWindowWaylandEGL;
-typedef struct _GstGLWindowWaylandEGLClass GstGLWindowWaylandEGLClass;
-
-struct window;
-
-struct display {
- struct wl_display *display;
- struct wl_registry *registry;
- struct wl_compositor *compositor;
- struct wl_shell *shell;
- struct wl_seat *seat;
- struct wl_pointer *pointer;
- struct wl_keyboard *keyboard;
- struct wl_shm *shm;
- struct wl_cursor_theme *cursor_theme;
- struct wl_cursor *default_cursor;
- struct wl_surface *cursor_surface;
- struct window *window;
- guint32 serial;
-
- gdouble pointer_x;
- gdouble pointer_y;
-};
-
-struct window {
- struct display *display;
-
- struct wl_event_queue *queue;
- struct wl_surface *surface;
- struct wl_shell_surface *shell_surface;
- struct wl_egl_window *native;
- struct wl_surface *foreign_surface;
- struct wl_subsurface *subsurface;
- struct wl_callback *callback;
- int fullscreen, configured;
- int window_width, window_height;
- int window_x, window_y;
-};
-
-struct _GstGLWindowWaylandEGL {
- /*< private >*/
- GstGLWindow parent;
-
- struct display display;
- struct window window;
-
- GSource *wl_source;
-
- gpointer _reserved[GST_PADDING];
-};
-
-struct _GstGLWindowWaylandEGLClass {
- /*< private >*/
- GstGLWindowClass parent_class;
-
- /*< private >*/
- gpointer _reserved[GST_PADDING];
-};
-
-G_GNUC_INTERNAL
-GType gst_gl_window_wayland_egl_get_type (void);
-
-G_GNUC_INTERNAL
-GstGLWindowWaylandEGL * gst_gl_window_wayland_egl_new (GstGLDisplay * display);
-
-G_GNUC_INTERNAL
-void gst_gl_window_wayland_egl_create_window (GstGLWindowWaylandEGL * window_egl);
-
-G_END_DECLS
-
-#endif /* __GST_GL_WINDOW_WAYLAND_EGL_H__ */
diff --git a/gst-libs/gst/gl/wayland/wayland_event_source.c b/gst-libs/gst/gl/wayland/wayland_event_source.c
deleted file mode 100644
index ffb1503d2..000000000
--- a/gst-libs/gst/gl/wayland/wayland_event_source.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2010 Intel Corporation.
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Authors:
- * Matthew Allum
- * Robert Bragg
- * Kristian Høgsberg
- */
-
-/* code originally from clutter's wayland backend found here
- * http://git.gnome.org/browse/clutter/tree/clutter/wayland/clutter-event-wayland.c
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <wayland-client.h>
-
-#include "wayland_event_source.h"
-
-static void
-sync_callback (void *data, struct wl_callback *callback, uint32_t serial)
-{
- gboolean *done = data;
-
- *done = TRUE;
- wl_callback_destroy (callback);
-}
-
-static const struct wl_callback_listener sync_listener = {
- sync_callback
-};
-
-/* only thread safe iff called on the same thread @queue is being dispatched on */
-gint
-gst_gl_wl_display_roundtrip_queue (struct wl_display *display,
- struct wl_event_queue *queue)
-{
- struct wl_callback *callback;
- gboolean done = FALSE;
- gint ret = 0;
-
- if (queue) {
- /* creating a wl_proxy and setting the queue is racy with the dispatching
- * of the default queue */
- while (wl_display_prepare_read_queue (display, queue) != 0) {
- if ((ret = wl_display_dispatch_queue_pending (display, queue)) < 0)
- return ret;
- }
- }
- if (!(callback = wl_display_sync (display))) {
- return -1;
- }
- wl_callback_add_listener (callback, &sync_listener, &done);
- if (queue) {
- wl_proxy_set_queue ((struct wl_proxy *) callback, queue);
- wl_display_cancel_read (display);
- while (!done && ret >= 0)
- ret = wl_display_dispatch_queue (display, queue);
- } else {
- while (!done && ret >= 0)
- ret = wl_display_dispatch (display);
- }
-
- if (ret == -1 && !done)
- wl_callback_destroy (callback);
-
- return ret;
-}
-
-typedef struct _WaylandEventSource
-{
- GSource source;
- GPollFD pfd;
- uint32_t mask;
- struct wl_display *display;
- struct wl_event_queue *queue;
- gboolean reading;
-} WaylandEventSource;
-
-static gboolean
-wayland_event_source_prepare (GSource * base, gint * timeout)
-{
- WaylandEventSource *source = (WaylandEventSource *) base;
-
- *timeout = -1;
-
- /* we may be called multiple times for prepare */
- if (source->reading)
- wl_display_cancel_read (source->display);
-
- if (source->queue) {
- while (wl_display_prepare_read_queue (source->display, source->queue) != 0) {
- if (wl_display_dispatch_queue_pending (source->display,
- source->queue) < 0) {
- g_critical ("Failed to dispatch pending events\n");
- }
- }
- } else {
- while (wl_display_prepare_read (source->display) != 0) {
- if (wl_display_dispatch_pending (source->display) < 0) {
- g_critical ("Failed to dispatch pending events\n");
- }
- }
- }
- source->reading = TRUE;
-
- /* FIXME: this may return EAGAIN if the fd is full */
- if (wl_display_flush (source->display) < 0)
- g_critical ("Failed to flush Wayland connection\n");
-
- return FALSE;
-}
-
-static gboolean
-wayland_event_source_check (GSource * base)
-{
- WaylandEventSource *source = (WaylandEventSource *) base;
- gboolean retval;
-
- retval = source->pfd.revents;
-
- if (source->pfd.revents & G_IO_IN) {
- wl_display_read_events (source->display);
- } else {
- wl_display_cancel_read (source->display);
- }
- source->reading = FALSE;
-
- return retval;
-}
-
-static gboolean
-wayland_event_source_dispatch (GSource * base,
- GSourceFunc callback, gpointer data)
-{
- WaylandEventSource *source = (WaylandEventSource *) base;
-
- if (source->queue)
- wl_display_dispatch_queue_pending (source->display, source->queue);
- else
- wl_display_dispatch_pending (source->display);
- source->pfd.revents = 0;
-
- if (callback)
- callback (data);
-
- return TRUE;
-}
-
-static void
-wayland_event_source_finalize (GSource * base)
-{
- WaylandEventSource *source = (WaylandEventSource *) base;
-
- if (source->reading) {
- wl_display_cancel_read (source->display);
- }
- source->reading = FALSE;
-}
-
-static GSourceFuncs wayland_event_source_funcs = {
- wayland_event_source_prepare,
- wayland_event_source_check,
- wayland_event_source_dispatch,
- wayland_event_source_finalize
-};
-
-GSource *
-wayland_event_source_new (struct wl_display *display,
- struct wl_event_queue *queue)
-{
- WaylandEventSource *source;
-
- source = (WaylandEventSource *)
- g_source_new (&wayland_event_source_funcs, sizeof (WaylandEventSource));
- source->display = display;
- source->queue = queue;
- source->pfd.fd = wl_display_get_fd (display);
- source->pfd.events = G_IO_IN | G_IO_ERR;
- g_source_add_poll (&source->source, &source->pfd);
-
- return &source->source;
-}
diff --git a/gst-libs/gst/gl/wayland/wayland_event_source.h b/gst-libs/gst/gl/wayland/wayland_event_source.h
deleted file mode 100644
index fa20892be..000000000
--- a/gst-libs/gst/gl/wayland/wayland_event_source.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2011 Intel Corporation.
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- * Authors:
- * Robert Bragg <robert@linux.intel.com>
- */
-
-/* code originally from clutter's wayland backend found here
- * http://git.gnome.org/browse/clutter/tree/clutter/wayland/clutter-event-wayland.h
- */
-
-#ifndef __WAYLAND_EVENT_SOURCE_H__
-#define __WAYLAND_EVENT_SOURCE_H__
-
-#include <glib-object.h>
-//#include <clutter/clutter-event.h>
-
-#include <wayland-client.h>
-
-GSource * wayland_event_source_new (struct wl_display *display,
- struct wl_event_queue *queue);
-
-G_GNUC_INTERNAL gint gst_gl_wl_display_roundtrip_queue (struct wl_display *display,
- struct wl_event_queue *queue);
-
-#endif /* __WAYLAND_EVENT_SOURCE_H__ */
diff --git a/gst-libs/gst/gl/win32/Makefile.am b/gst-libs/gst/gl/win32/Makefile.am
deleted file mode 100644
index ed3cc6320..000000000
--- a/gst-libs/gst/gl/win32/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-noinst_LTLIBRARIES = libgstgl-win32.la
-
-libgstgl_win32_la_SOURCES = \
- gstglwindow_win32.c \
- win32_message_source.c
-
-noinst_HEADERS = \
- gstglwindow_win32.h \
- win32_message_source.h
-
-if USE_WGL
-libgstgl_win32_la_SOURCES += gstglcontext_wgl.c
-noinst_HEADERS += gstglcontext_wgl.h
-endif
-
-libgstgl_win32_la_CFLAGS = \
- -DGST_EXPORTS \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- $(GL_CFLAGS) \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) \
- $(GST_CFLAGS)
-
-libgstgl_win32_la_LDFLAGS = \
- $(GST_LIB_LDFLAGS) \
- $(GST_ALL_LDFLAGS)
diff --git a/gst-libs/gst/gl/win32/gstglcontext_wgl.c b/gst-libs/gst/gl/win32/gstglcontext_wgl.c
deleted file mode 100644
index 47b576c0b..000000000
--- a/gst-libs/gst/gl/win32/gstglcontext_wgl.c
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-#include <gst/gl/gl.h>
-#include <gst/gl/gstglfuncs.h>
-
-#include "gstglcontext_wgl.h"
-#include <GL/wglext.h>
-
-#include "../utils/opengl_versions.h"
-#include "../gstglcontext_private.h"
-
-struct _GstGLContextWGLPrivate
-{
- PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
-
- GstGLAPI context_api;
-};
-
-#define GST_CAT_DEFAULT gst_gl_context_debug
-
-#define gst_gl_context_wgl_parent_class parent_class
-G_DEFINE_TYPE (GstGLContextWGL, gst_gl_context_wgl, GST_TYPE_GL_CONTEXT);
-#define GST_GL_CONTEXT_WGL_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_CONTEXT_WGL, GstGLContextWGLPrivate))
-
-static guintptr gst_gl_context_wgl_get_gl_context (GstGLContext * context);
-static void gst_gl_context_wgl_swap_buffers (GstGLContext * context);
-static gboolean gst_gl_context_wgl_choose_format (GstGLContext * context,
- GError ** error);
-static gboolean gst_gl_context_wgl_activate (GstGLContext * context,
- gboolean activate);
-static gboolean gst_gl_context_wgl_create_context (GstGLContext * context,
- GstGLAPI gl_api, GstGLContext * other_context, GError ** error);
-static void gst_gl_context_wgl_destroy_context (GstGLContext * context);
-GstGLAPI gst_gl_context_wgl_get_gl_api (GstGLContext * context);
-static GstGLPlatform gst_gl_context_wgl_get_gl_platform (GstGLContext *
- context);
-
-static void
-gst_gl_context_wgl_class_init (GstGLContextWGLClass * klass)
-{
- GstGLContextClass *context_class = (GstGLContextClass *) klass;
-
- g_type_class_add_private (klass, sizeof (GstGLContextWGLPrivate));
-
- context_class->get_gl_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_wgl_get_gl_context);
- context_class->choose_format =
- GST_DEBUG_FUNCPTR (gst_gl_context_wgl_choose_format);
- context_class->activate = GST_DEBUG_FUNCPTR (gst_gl_context_wgl_activate);
- context_class->create_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_wgl_create_context);
- context_class->destroy_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_wgl_destroy_context);
- context_class->swap_buffers =
- GST_DEBUG_FUNCPTR (gst_gl_context_wgl_swap_buffers);
-
- context_class->get_proc_address =
- GST_DEBUG_FUNCPTR (gst_gl_context_wgl_get_proc_address);
- context_class->get_gl_api = GST_DEBUG_FUNCPTR (gst_gl_context_wgl_get_gl_api);
- context_class->get_gl_platform =
- GST_DEBUG_FUNCPTR (gst_gl_context_wgl_get_gl_platform);
-}
-
-static void
-gst_gl_context_wgl_init (GstGLContextWGL * context_wgl)
-{
- context_wgl->priv = GST_GL_CONTEXT_WGL_GET_PRIVATE (context_wgl);
-
- context_wgl->priv->context_api = GST_GL_API_OPENGL | GST_GL_API_OPENGL3;
-}
-
-/* Must be called in the gl thread */
-GstGLContextWGL *
-gst_gl_context_wgl_new (GstGLDisplay * display)
-{
- GstGLContextWGL *context;
-
- if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_WIN32) ==
- 0)
- /* we require an win32 display handle to create WGL contexts */
- return NULL;
-
- context = g_object_new (GST_TYPE_GL_CONTEXT_WGL, NULL);
- gst_object_ref_sink (context);
-
- return context;
-}
-
-static HGLRC
-_create_context_with_flags (GstGLContextWGL * context_wgl, HDC dpy,
- HGLRC share_context, gint major, gint minor, gint contextFlags,
- gint profileMask)
-{
- HGLRC ret;
-#define N_ATTRIBS 20
- gint attribs[N_ATTRIBS];
- gint n = 0;
-
- if (major) {
- attribs[n++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
- attribs[n++] = major;
- }
- if (minor) {
- attribs[n++] = WGL_CONTEXT_MINOR_VERSION_ARB;
- attribs[n++] = minor;
- }
- if (contextFlags) {
- attribs[n++] = WGL_CONTEXT_FLAGS_ARB;
- attribs[n++] = contextFlags;
- }
- if (profileMask) {
- attribs[n++] = WGL_CONTEXT_PROFILE_MASK_ARB;
- attribs[n++] = profileMask;
- }
- attribs[n++] = 0;
-
- g_assert (n < N_ATTRIBS);
-#undef N_ATTRIBS
-
- ret =
- context_wgl->priv->wglCreateContextAttribsARB (dpy, share_context,
- attribs);
-
- return ret;
-}
-
-static gboolean
-gst_gl_context_wgl_create_context (GstGLContext * context,
- GstGLAPI gl_api, GstGLContext * other_context, GError ** error)
-{
- GstGLWindow *window;
- GstGLContextWGL *context_wgl;
- HGLRC external_gl_context = NULL;
- HGLRC trampoline;
- HDC device;
-
- context_wgl = GST_GL_CONTEXT_WGL (context);
- window = gst_gl_context_get_window (context);
- device = (HDC) gst_gl_window_get_display (window);
-
- if (other_context) {
- if (gst_gl_context_get_gl_platform (other_context) != GST_GL_PLATFORM_WGL) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
- "Cannot share context with a non-WGL context");
- goto failure;
- }
- external_gl_context = (HGLRC) gst_gl_context_get_gl_context (other_context);
- }
-
- trampoline = wglCreateContext (device);
- if (trampoline)
- GST_DEBUG ("gl context created: %" G_GUINTPTR_FORMAT,
- (guintptr) trampoline);
- else {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_CREATE_CONTEXT, "failed to create glcontext:0x%x",
- (unsigned int) GetLastError ());
- goto failure;
- }
- g_assert (trampoline);
-
- /* get extension functions */
- wglMakeCurrent (device, trampoline);
-
- context_wgl->priv->wglCreateContextAttribsARB =
- (PFNWGLCREATECONTEXTATTRIBSARBPROC)
- wglGetProcAddress ("wglCreateContextAttribsARB");
-
- wglMakeCurrent (device, 0);
- wglDeleteContext (trampoline);
- trampoline = NULL;
-
- if (context_wgl->priv->wglCreateContextAttribsARB != NULL
- && gl_api & GST_GL_API_OPENGL3) {
- gint i;
-
- for (i = 0; i < G_N_ELEMENTS (opengl_versions); i++) {
- gint profileMask = 0;
- gint contextFlags = 0;
-
- if ((opengl_versions[i].major > 3
- || (opengl_versions[i].major == 3
- && opengl_versions[i].minor >= 2))) {
- profileMask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
- contextFlags |= WGL_CONTEXT_DEBUG_BIT_ARB;
- } else {
- break;
- }
-
- GST_DEBUG_OBJECT (context, "trying to create a GL %d.%d context",
- opengl_versions[i].major, opengl_versions[i].minor);
-
- context_wgl->wgl_context = _create_context_with_flags (context_wgl,
- device, external_gl_context, opengl_versions[i].major,
- opengl_versions[i].minor, contextFlags, profileMask);
-
- if (context_wgl->wgl_context) {
- context_wgl->priv->context_api = GST_GL_API_OPENGL3;
- break;
- }
- }
- }
-
- if (!context_wgl->wgl_context) {
-
- if (context_wgl->priv->wglCreateContextAttribsARB && external_gl_context) {
- context_wgl->wgl_context =
- context_wgl->priv->wglCreateContextAttribsARB (device,
- external_gl_context, 0);
- }
-
-
- if (!context_wgl->wgl_context) {
-
- context_wgl->wgl_context = wglCreateContext (device);
-
- if (!context_wgl->wgl_context) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
- "Failed to create WGL context 0x%x",
- (unsigned int) GetLastError ());
- goto failure;
- }
-
- if (external_gl_context) {
- if (!wglShareLists (external_gl_context, context_wgl->wgl_context)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
- "failed to share contexts through wglShareLists 0x%x",
- (unsigned int) GetLastError ());
- goto failure;
- }
- }
- }
-
- context_wgl->priv->context_api = GST_GL_API_OPENGL;
- }
-
- GST_LOG ("gl context id: %" G_GUINTPTR_FORMAT,
- (guintptr) context_wgl->wgl_context);
-
- gst_object_unref (window);
-
- return TRUE;
-
-failure:
- gst_object_unref (window);
-
- return FALSE;
-}
-
-static void
-gst_gl_context_wgl_destroy_context (GstGLContext * context)
-{
- GstGLContextWGL *context_wgl;
-
- context_wgl = GST_GL_CONTEXT_WGL (context);
-
- if (context_wgl->wgl_context)
- wglDeleteContext (context_wgl->wgl_context);
- context_wgl->wgl_context = NULL;
-}
-
-static gboolean
-gst_gl_context_wgl_choose_format (GstGLContext * context, GError ** error)
-{
- GstGLWindow *window;
- PIXELFORMATDESCRIPTOR pfd;
- gint pixelformat = 0;
- gboolean res = FALSE;
- HDC device;
-
- window = gst_gl_context_get_window (context);
- gst_gl_window_win32_create_window (GST_GL_WINDOW_WIN32 (window), error);
- device = (HDC) gst_gl_window_get_display (window);
- gst_object_unref (window);
-
- pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR);
- pfd.nVersion = 1;
- pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
- pfd.iPixelType = PFD_TYPE_RGBA;
- pfd.cColorBits = 24;
- pfd.cRedBits = 8;
- pfd.cRedShift = 0;
- pfd.cGreenBits = 8;
- pfd.cGreenShift = 0;
- pfd.cBlueBits = 8;
- pfd.cBlueShift = 0;
- pfd.cAlphaBits = 0;
- pfd.cAlphaShift = 0;
- pfd.cAccumBits = 0;
- pfd.cAccumRedBits = 0;
- pfd.cAccumGreenBits = 0;
- pfd.cAccumBlueBits = 0;
- pfd.cAccumAlphaBits = 0;
- pfd.cDepthBits = 24;
- pfd.cStencilBits = 8;
- pfd.cAuxBuffers = 0;
- pfd.iLayerType = PFD_MAIN_PLANE;
- pfd.bReserved = 0;
- pfd.dwLayerMask = 0;
- pfd.dwVisibleMask = 0;
- pfd.dwDamageMask = 0;
-
- pfd.cColorBits = (BYTE) GetDeviceCaps (device, BITSPIXEL);
-
- pixelformat = ChoosePixelFormat (device, &pfd);
-
- if (!pixelformat) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "Failed to choose a pixel format");
- return FALSE;
- }
-
- res = SetPixelFormat (device, pixelformat, &pfd);
-
- return res;
-}
-
-static void
-gst_gl_context_wgl_swap_buffers (GstGLContext * context)
-{
- GstGLWindow *window = gst_gl_context_get_window (context);
- HDC device = (HDC) gst_gl_window_get_display (window);
-
- SwapBuffers (device);
-
- gst_object_unref (window);
-}
-
-static guintptr
-gst_gl_context_wgl_get_gl_context (GstGLContext * context)
-{
- return (guintptr) GST_GL_CONTEXT_WGL (context)->wgl_context;
-}
-
-static gboolean
-gst_gl_context_wgl_activate (GstGLContext * context, gboolean activate)
-{
- GstGLWindow *window;
- GstGLContextWGL *context_wgl;
- HDC device;
- gboolean result;
-
- window = gst_gl_context_get_window (context);
- context_wgl = GST_GL_CONTEXT_WGL (context);
- device = (HDC) gst_gl_window_get_display (window);
-
- if (activate) {
- result = wglMakeCurrent (device, context_wgl->wgl_context);
- } else {
- result = wglMakeCurrent (NULL, NULL);
- }
-
- gst_object_unref (window);
-
- return result;
-}
-
-GstGLAPI
-gst_gl_context_wgl_get_gl_api (GstGLContext * context)
-{
- GstGLContextWGL *context_wgl = GST_GL_CONTEXT_WGL (context);
-
- return context_wgl->priv->context_api;
-}
-
-static GstGLPlatform
-gst_gl_context_wgl_get_gl_platform (GstGLContext * context)
-{
- return GST_GL_PLATFORM_WGL;
-}
-
-gpointer
-gst_gl_context_wgl_get_proc_address (GstGLAPI gl_api, const gchar * name)
-{
- gpointer result;
-
- if (!(result = gst_gl_context_default_get_proc_address (gl_api, name))) {
- result = wglGetProcAddress ((LPCSTR) name);
- }
-
- return result;
-}
-
-guintptr
-gst_gl_context_wgl_get_current_context (void)
-{
- return (guintptr) wglGetCurrentContext ();
-}
diff --git a/gst-libs/gst/gl/win32/gstglcontext_wgl.h b/gst-libs/gst/gl/win32/gstglcontext_wgl.h
deleted file mode 100644
index f44db50d3..000000000
--- a/gst-libs/gst/gl/win32/gstglcontext_wgl.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_CONTEXT_WGL_H__
-#define __GST_GL_CONTEXT_WGL_H__
-
-#include "gstglwindow_win32.h"
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_CONTEXT_WGL (gst_gl_context_wgl_get_type())
-#define GST_GL_CONTEXT_WGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_CONTEXT_WGL, GstGLContextWGL))
-#define GST_GL_CONTEXT_WGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_CONTEXT_WGL, GstGLContextWGLClass))
-#define GST_IS_GL_CONTEXT_WGL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_CONTEXT_WGL))
-#define GST_IS_GL_CONTEXT_WGL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_CONTEXT_WGL))
-#define GST_GL_CONTEXT_WGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_CONTEXT_WGL, GstGLContextWGLClass))
-
-typedef struct _GstGLContextWGL GstGLContextWGL;
-typedef struct _GstGLContextWGLClass GstGLContextWGLClass;
-typedef struct _GstGLContextWGLPrivate GstGLContextWGLPrivate;
-
-struct _GstGLContextWGL {
- /*< private >*/
- GstGLContext parent;
-
- HGLRC wgl_context;
- HGLRC external_gl_context;
-
- GstGLContextWGLPrivate *priv;
-
- gpointer _reserved[GST_PADDING];
-};
-
-struct _GstGLContextWGLClass {
- /*< private >*/
- GstGLContextClass parent_class;
-
- /*< private >*/
- gpointer _reserved[GST_PADDING];
-};
-
-GType gst_gl_context_wgl_get_type (void);
-
-GstGLContextWGL * gst_gl_context_wgl_new (GstGLDisplay * display);
-guintptr gst_gl_context_wgl_get_current_context (void);
-gpointer gst_gl_context_wgl_get_proc_address (GstGLAPI gl_api, const gchar * name);
-
-G_END_DECLS
-
-#endif /* __GST_GL_CONTEXT_WGL_H__ */
diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32.c b/gst-libs/gst/gl/win32/gstglwindow_win32.c
deleted file mode 100644
index 324954e58..000000000
--- a/gst-libs/gst/gl/win32/gstglwindow_win32.c
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstglwindow_win32.h"
-#include "win32_message_source.h"
-
-LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam,
- LPARAM lParam);
-LRESULT FAR PASCAL sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam,
- LPARAM lParam);
-
-#define GST_GL_WINDOW_WIN32_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_WINDOW_WIN32, GstGLWindowWin32Private))
-
-enum
-{
- PROP_0
-};
-
-struct _GstGLWindowWin32Private
-{
- gint preferred_width;
- gint preferred_height;
-};
-
-#define GST_CAT_DEFAULT gst_gl_window_win32_debug
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-
-#define DEBUG_INIT \
- GST_DEBUG_CATEGORY_GET (GST_CAT_DEFAULT, "glwindow");
-#define gst_gl_window_win32_parent_class parent_class
-G_DEFINE_TYPE_WITH_CODE (GstGLWindowWin32, gst_gl_window_win32,
- GST_TYPE_GL_WINDOW, DEBUG_INIT);
-
-static void gst_gl_window_win32_set_window_handle (GstGLWindow * window,
- guintptr handle);
-static guintptr gst_gl_window_win32_get_display (GstGLWindow * window);
-static void gst_gl_window_win32_set_preferred_size (GstGLWindow * window,
- gint width, gint height);
-static void gst_gl_window_win32_show (GstGLWindow * window);
-static void gst_gl_window_win32_draw (GstGLWindow * window);
-gboolean gst_gl_window_win32_open (GstGLWindow * window, GError ** error);
-void gst_gl_window_win32_close (GstGLWindow * window);
-static void release_parent_win_id (GstGLWindowWin32 * window_win32);
-
-static void
-gst_gl_window_win32_class_init (GstGLWindowWin32Class * klass)
-{
- GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
-
- g_type_class_add_private (klass, sizeof (GstGLWindowWin32Private));
-
- window_class->set_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_win32_set_window_handle);
- window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_win32_draw);
- window_class->get_display =
- GST_DEBUG_FUNCPTR (gst_gl_window_win32_get_display);
- window_class->set_preferred_size =
- GST_DEBUG_FUNCPTR (gst_gl_window_win32_set_preferred_size);
- window_class->show = GST_DEBUG_FUNCPTR (gst_gl_window_win32_show);
- window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_win32_open);
- window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_win32_close);
-}
-
-static void
-gst_gl_window_win32_init (GstGLWindowWin32 * window)
-{
- window->priv = GST_GL_WINDOW_WIN32_GET_PRIVATE (window);
-}
-
-GstGLWindowWin32 *
-gst_gl_window_win32_new (GstGLDisplay * display)
-{
- GstGLWindowWin32 *window;
-
- if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_WIN32) ==
- 0)
- /* we require an win32 display to create win32 windows */
- return NULL;
-
- window = g_object_new (GST_TYPE_GL_WINDOW_WIN32, NULL);
- gst_object_ref_sink (window);
-
- return window;
-}
-
-static void
-msg_cb (GstGLWindowWin32 * window_win32, MSG * msg, gpointer user_data)
-{
- GST_TRACE ("handle message");
- TranslateMessage (msg);
- DispatchMessage (msg);
-}
-
-gboolean
-gst_gl_window_win32_open (GstGLWindow * window, GError ** error)
-{
- GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
-
- if (!GST_GL_WINDOW_CLASS (parent_class)->open (window, error))
- return FALSE;
-
- window_win32->msg_source = win32_message_source_new (window_win32);
- g_source_set_callback (window_win32->msg_source, (GSourceFunc) msg_cb,
- NULL, NULL);
- g_source_attach (window_win32->msg_source, window->main_context);
-
- return TRUE;
-}
-
-void
-gst_gl_window_win32_close (GstGLWindow * window)
-{
- GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
-
- release_parent_win_id (window_win32);
-
- if (window_win32->internal_win_id) {
- RemoveProp (window_win32->internal_win_id, "gl_window");
- ShowWindow (window_win32->internal_win_id, SW_HIDE);
- SetParent (window_win32->internal_win_id, NULL);
- if (!DestroyWindow (window_win32->internal_win_id))
- GST_WARNING ("failed to destroy window %" G_GUINTPTR_FORMAT
- ", 0x%x", (guintptr) window_win32->internal_win_id,
- (unsigned int) GetLastError ());
- }
-
- g_source_destroy (window_win32->msg_source);
- g_source_unref (window_win32->msg_source);
- window_win32->msg_source = NULL;
-
- GST_GL_WINDOW_CLASS (parent_class)->close (window);
-}
-
-static void
-set_parent_win_id (GstGLWindowWin32 * window_win32)
-{
- WNDPROC window_parent_proc;
- RECT rect;
-
- if (!window_win32->parent_win_id) {
- /* no parent so the internal window needs borders and system menu */
- SetWindowLongPtr (window_win32->internal_win_id, GWL_STYLE,
- WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW);
- SetParent (window_win32->internal_win_id, NULL);
- return;
- }
-
- window_parent_proc =
- (WNDPROC) GetWindowLongPtr (window_win32->parent_win_id, GWLP_WNDPROC);
-
- GST_DEBUG ("set parent %" G_GUINTPTR_FORMAT,
- (guintptr) window_win32->parent_win_id);
-
- SetProp (window_win32->parent_win_id, "gl_window_id",
- window_win32->internal_win_id);
- SetProp (window_win32->parent_win_id, "gl_window_parent_proc",
- (WNDPROC) window_parent_proc);
- SetWindowLongPtr (window_win32->parent_win_id, GWLP_WNDPROC,
- (LONG_PTR) sub_class_proc);
-
- SetWindowLongPtr (window_win32->internal_win_id, GWL_STYLE,
- WS_CHILD | WS_MAXIMIZE);
- SetParent (window_win32->internal_win_id, window_win32->parent_win_id);
-
- /* take changes into account: SWP_FRAMECHANGED */
- GetClientRect (window_win32->parent_win_id, &rect);
- SetWindowPos (window_win32->internal_win_id, HWND_TOP, rect.left, rect.top,
- rect.right, rect.bottom,
- SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
- SWP_FRAMECHANGED | SWP_NOACTIVATE);
- MoveWindow (window_win32->internal_win_id, rect.left, rect.top, rect.right,
- rect.bottom, FALSE);
-}
-
-static void
-release_parent_win_id (GstGLWindowWin32 * window_win32)
-{
- WNDPROC parent_proc;
-
- if (!window_win32->parent_win_id)
- return;
-
- parent_proc = GetProp (window_win32->parent_win_id, "gl_window_parent_proc");
- if (!parent_proc)
- return;
-
- GST_DEBUG ("release parent %" G_GUINTPTR_FORMAT,
- (guintptr) window_win32->parent_win_id);
-
- SetWindowLongPtr (window_win32->parent_win_id, GWLP_WNDPROC,
- (LONG_PTR) parent_proc);
-
- RemoveProp (window_win32->parent_win_id, "gl_window_parent_proc");
-}
-
-gboolean
-gst_gl_window_win32_create_window (GstGLWindowWin32 * window_win32,
- GError ** error)
-{
-// GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
- WNDCLASSEX wc;
- ATOM atom = 0;
- HINSTANCE hinstance = GetModuleHandle (NULL);
-
- static gint x = 0;
- static gint y = 0;
-
- GST_LOG ("Attempting to create a win32 window");
-
- x += 20;
- y += 20;
-
- atom = GetClassInfoEx (hinstance, "GSTGL", &wc);
-
- if (atom == 0) {
- ZeroMemory (&wc, sizeof (WNDCLASSEX));
-
- wc.cbSize = sizeof (WNDCLASSEX);
- wc.lpfnWndProc = window_proc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hinstance;
- wc.hIcon = LoadIcon (NULL, IDI_WINLOGO);
- wc.hIconSm = NULL;
- wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
- wc.hCursor = LoadCursor (NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = "GSTGL";
-
- atom = RegisterClassEx (&wc);
-
- if (atom == 0) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "Failed to register window class 0x%x\n",
- (unsigned int) GetLastError ());
- goto failure;
- }
- }
-
- window_win32->internal_win_id = 0;
- window_win32->device = 0;
- window_win32->visible = FALSE;
-
- window_win32->internal_win_id = CreateWindowEx (0,
- "GSTGL",
- "OpenGL renderer",
- WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW,
- x, y, 0, 0, (HWND) NULL, (HMENU) NULL, hinstance, window_win32);
-
- if (!window_win32->internal_win_id) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "failed to create gl window");
- goto failure;
- }
-
- GST_DEBUG ("gl window created: %" G_GUINTPTR_FORMAT,
- (guintptr) window_win32->internal_win_id);
-
- //device is set in the window_proc
- if (!window_win32->device) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "failed to create device");
- goto failure;
- }
-
- ShowCursor (TRUE);
-
- GST_LOG ("Created a win32 window");
-
- /* The window has been created as if it had no parent, so there is nothing
- * else to do in that case. Even if user has already set a window,
- * parent_win_id could still be 0 at this point, and in that case calling
- * set_parent_win_id() here would steal focus from the parent window. */
- if (window_win32->parent_win_id)
- set_parent_win_id (window_win32);
-
- return TRUE;
-
-failure:
- return FALSE;
-}
-
-static guintptr
-gst_gl_window_win32_get_display (GstGLWindow * window)
-{
- GstGLWindowWin32 *window_win32;
-
- window_win32 = GST_GL_WINDOW_WIN32 (window);
-
- return (guintptr) window_win32->device;
-}
-
-static void
-gst_gl_window_win32_set_window_handle (GstGLWindow * window, guintptr id)
-{
- GstGLWindowWin32 *window_win32;
-
- window_win32 = GST_GL_WINDOW_WIN32 (window);
-
- if (!window_win32->internal_win_id) {
- window_win32->parent_win_id = (HWND) id;
- return;
- }
-
- if (window_win32->visible) {
- ShowWindow (window_win32->internal_win_id, SW_HIDE);
- window_win32->visible = FALSE;
- }
-
- release_parent_win_id (window_win32);
- window_win32->parent_win_id = (HWND) id;
- set_parent_win_id (window_win32);
-}
-
-static void
-gst_gl_window_win32_show (GstGLWindow * window)
-{
- GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
- gint width = window_win32->priv->preferred_width;
- gint height = window_win32->priv->preferred_height;
-
- if (!window_win32->visible) {
- HWND parent_id = window_win32->parent_win_id;
-
- /* if no parent the real size has to be set now because this has not been done
- * when at window creation */
- if (!parent_id) {
- RECT rect;
- GetClientRect (window_win32->internal_win_id, &rect);
- width += 2 * GetSystemMetrics (SM_CXSIZEFRAME);
- height +=
- 2 * GetSystemMetrics (SM_CYSIZEFRAME) +
- GetSystemMetrics (SM_CYCAPTION);
- MoveWindow (window_win32->internal_win_id, rect.left, rect.top, width,
- height, FALSE);
- }
-
- ShowWindowAsync (window_win32->internal_win_id, SW_SHOW);
- window_win32->visible = TRUE;
- }
-}
-
-static void
-gst_gl_window_win32_set_preferred_size (GstGLWindow * window, gint width,
- gint height)
-{
- GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
-
- window_win32->priv->preferred_width = width;
- window_win32->priv->preferred_height = height;
-}
-
-/* Thread safe */
-static void
-gst_gl_window_win32_draw (GstGLWindow * window)
-{
- GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
-
- RedrawWindow (window_win32->internal_win_id, NULL, NULL,
- RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE);
-}
-
-/* PRIVATE */
-
-LRESULT CALLBACK
-window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- GstGLWindowWin32 *window_win32;
- LRESULT ret = 0;
-
- if (uMsg == WM_CREATE) {
- window_win32 =
- GST_GL_WINDOW_WIN32 (((LPCREATESTRUCT) lParam)->lpCreateParams);
-
- GST_TRACE ("WM_CREATE");
-
- window_win32->device = GetDC (hWnd);
- /* Do this, otherwise we hang on exit. We can still use it (due to the
- * CS_OWNDC flag in the WindowClass) after we have Released.
- */
- ReleaseDC (hWnd, window_win32->device);
-
- SetProp (hWnd, "gl_window", window_win32);
- } else if (GetProp (hWnd, "gl_window")) {
- GstGLWindow *window;
- GstGLContext *context;
-
- window_win32 = GST_GL_WINDOW_WIN32 (GetProp (hWnd, "gl_window"));
- window = GST_GL_WINDOW (window_win32);
- context = gst_gl_window_get_context (window);
-
- g_assert (window_win32->internal_win_id == hWnd);
-
- switch (uMsg) {
- case WM_SIZE:
- gst_gl_window_resize (window, LOWORD (lParam), HIWORD (lParam));
- break;
- case WM_PAINT:
- {
- if (window->queue_resize) {
- guint width, height;
-
- gst_gl_window_get_surface_dimensions (window, &width, &height);
- gst_gl_window_resize (window, width, height);
- }
- if (window->draw) {
- PAINTSTRUCT ps;
- BeginPaint (hWnd, &ps);
- window->draw (window->draw_data);
- gst_gl_context_swap_buffers (context);
- EndPaint (hWnd, &ps);
- }
- break;
- }
- case WM_CLOSE:
- {
- ShowWindowAsync (window_win32->internal_win_id, SW_HIDE);
-
- GST_TRACE ("WM_CLOSE");
-
- if (window->close)
- window->close (window->close_data);
- break;
- }
- case WM_CAPTURECHANGED:
- {
- GST_DEBUG ("WM_CAPTURECHANGED");
- if (window->queue_resize) {
- guint width, height;
-
- gst_gl_window_get_surface_dimensions (window, &width, &height);
- gst_gl_window_resize (window, width, height);
- }
- if (window->draw)
- window->draw (window->draw_data);
- break;
- }
- case WM_ERASEBKGND:
- {
- ret = TRUE;
- break;
- }
- default:
- {
- /* transmit messages to the parrent (ex: mouse/keyboard input) */
- HWND parent_id = window_win32->parent_win_id;
- if (parent_id)
- PostMessage (parent_id, uMsg, wParam, lParam);
- ret = DefWindowProc (hWnd, uMsg, wParam, lParam);
- }
- }
-
- gst_object_unref (context);
- } else {
- ret = DefWindowProc (hWnd, uMsg, wParam, lParam);
- }
-
- return ret;
-}
-
-LRESULT FAR PASCAL
-sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- WNDPROC window_parent_proc = GetProp (hWnd, "gl_window_parent_proc");
-
- if (uMsg == WM_SIZE) {
- HWND gl_window_id = GetProp (hWnd, "gl_window_id");
- MoveWindow (gl_window_id, 0, 0, LOWORD (lParam), HIWORD (lParam), FALSE);
- }
-
- return CallWindowProc (window_parent_proc, hWnd, uMsg, wParam, lParam);
-}
diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32.h b/gst-libs/gst/gl/win32/gstglwindow_win32.h
deleted file mode 100644
index 8a6ca6824..000000000
--- a/gst-libs/gst/gl/win32/gstglwindow_win32.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_WINDOW_WIN32_H__
-#define __GST_GL_WINDOW_WIN32_H__
-
-#include <gst/gl/gl.h>
-
-#undef UNICODE
-#include <windows.h>
-#define UNICODE
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_WINDOW_WIN32 (gst_gl_window_win32_get_type())
-#define GST_GL_WINDOW_WIN32(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW_WIN32, GstGLWindowWin32))
-#define GST_GL_WINDOW_WIN32_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_WINDOW_WIN32, GstGLWindowWin32Class))
-#define GST_IS_GL_WINDOW_WIN32(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW_WIN32))
-#define GST_IS_GL_WINDOW_WIN32_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW_WIN32))
-#define GST_GL_WINDOW_WIN32_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW_WIN32, GstGLWindowWin32Class))
-
-typedef struct _GstGLWindowWin32 GstGLWindowWin32;
-typedef struct _GstGLWindowWin32Private GstGLWindowWin32Private;
-typedef struct _GstGLWindowWin32Class GstGLWindowWin32Class;
-
-struct _GstGLWindowWin32 {
- /*< private >*/
- GstGLWindow parent;
-
- HWND internal_win_id;
- HWND parent_win_id;
- HDC device;
- gboolean is_closed;
- gboolean visible;
-
- GSource *msg_source;
-
- /*< private >*/
- GstGLWindowWin32Private *priv;
-
- gpointer _reserved[GST_PADDING];
-};
-
-struct _GstGLWindowWin32Class {
- /*< private >*/
- GstGLWindowClass parent_class;
-
- gboolean (*choose_format) (GstGLWindowWin32 *window);
- gboolean (*create_context) (GstGLWindowWin32 *window, GstGLAPI gl_api,
- guintptr external_gl_context, GError ** error);
- gboolean (*share_context) (GstGLWindowWin32 *window, guintptr external_gl_context);
- void (*swap_buffers) (GstGLWindowWin32 *window);
- gboolean (*activate) (GstGLWindowWin32 *window, gboolean activate);
- void (*destroy_context) (GstGLWindowWin32 *window);
- guintptr (*get_gl_context) (GstGLWindowWin32 *window);
-
- /*< private >*/
- gpointer _reserved[GST_PADDING_LARGE];
-};
-
-GType gst_gl_window_win32_get_type (void);
-
-GstGLWindowWin32 * gst_gl_window_win32_new (GstGLDisplay * display);
-
-gboolean gst_gl_window_win32_create_window (GstGLWindowWin32 * window_win32, GError ** error);
-
-G_END_DECLS
-
-#endif /* __GST_GL_WINDOW_WIN32_H__ */
diff --git a/gst-libs/gst/gl/win32/win32_message_source.c b/gst-libs/gst/gl/win32/win32_message_source.c
deleted file mode 100644
index fd785f827..000000000
--- a/gst-libs/gst/gl/win32/win32_message_source.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- * Copyright (C) 2015 Collabora ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "win32_message_source.h"
-
-typedef struct _Win32MessageSource
-{
- GSource source;
- GPollFD pfd;
- GstGLWindowWin32 *window;
-} Win32MessageSource;
-
-static gboolean
-win32_message_source_check (GSource * base)
-{
- MSG msg;
-
- return PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);
-}
-
-static gboolean
-win32_message_source_dispatch (GSource * base, GSourceFunc callback,
- gpointer user_data)
-{
- Win32MessageSource *source = (Win32MessageSource *) base;
- Win32MessageSourceFunc func = (Win32MessageSourceFunc) callback;
- MSG msg;
-
- if (!PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
- return G_SOURCE_CONTINUE;
-
- if (func)
- func (source->window, &msg, user_data);
-
- return G_SOURCE_CONTINUE;
-}
-
-static GSourceFuncs win32_message_source_funcs = {
- NULL,
- win32_message_source_check,
- win32_message_source_dispatch,
- NULL
-};
-
-GSource *
-win32_message_source_new (GstGLWindowWin32 * window_win32)
-{
- Win32MessageSource *source;
-
- source = (Win32MessageSource *)
- g_source_new (&win32_message_source_funcs, sizeof (Win32MessageSource));
- source->window = window_win32;
- source->pfd.fd = G_WIN32_MSG_HANDLE;
- source->pfd.events = G_IO_IN;
- g_source_add_poll (&source->source, &source->pfd);
-
- return &source->source;
-}
diff --git a/gst-libs/gst/gl/win32/win32_message_source.h b/gst-libs/gst/gl/win32/win32_message_source.h
deleted file mode 100644
index eef3eac4d..000000000
--- a/gst-libs/gst/gl/win32/win32_message_source.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- * Copyright (C) 2015 Collabora ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __WIN32_MESSAGE_SOURCE_H__
-#define __WIN32_MESSAGE_SOURCE_H__
-
-#include <glib-object.h>
-#include "gstglwindow_win32.h"
-
-typedef void (*Win32MessageSourceFunc) (GstGLWindowWin32 *window_win32,
- MSG *msg, gpointer user_data);
-
-GSource *
-win32_message_source_new (GstGLWindowWin32 *window_win32);
-
-#endif /* __WIN32_MESSAGE_SOURCE_H__ */
diff --git a/gst-libs/gst/gl/x11/Makefile.am b/gst-libs/gst/gl/x11/Makefile.am
deleted file mode 100644
index d47d16f6d..000000000
--- a/gst-libs/gst/gl/x11/Makefile.am
+++ /dev/null
@@ -1,33 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-noinst_LTLIBRARIES = libgstgl-x11.la
-
-libgstgl_x11_la_SOURCES = \
- gstgldisplay_x11.c \
- gstglwindow_x11.c \
- xcb_event_source.c
-
-noinst_HEADERS = \
- gstglwindow_x11.h \
- xcb_event_source.h
-
-libgstgl_x11includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl/x11
-libgstgl_x11include_HEADERS = \
- gstgldisplay_x11.h
-
-if USE_GLX
-libgstgl_x11_la_SOURCES += gstglcontext_glx.c
-noinst_HEADERS += gstglcontext_glx.h
-endif
-
-libgstgl_x11_la_CFLAGS = \
- -I$(top_srcdir)/gst-libs \
- -I$(top_builddir)/gst-libs \
- $(GL_CFLAGS) \
- $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) \
- $(GST_CFLAGS)
-
-libgstgl_x11_la_LDFLAGS = \
- $(GST_LIB_LDFLAGS) \
- $(GST_ALL_LDFLAGS)
diff --git a/gst-libs/gst/gl/x11/gstglcontext_glx.c b/gst-libs/gst/gl/x11/gstglcontext_glx.c
deleted file mode 100644
index 877e5c6d8..000000000
--- a/gst-libs/gst/gl/x11/gstglcontext_glx.c
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#define GLIB_DISABLE_DEPRECATION_WARNINGS
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-/* FIXME: Sharing contexts requires the Display to be the same.
- * May need to box it
- */
-
-#include <gst/gst.h>
-
-#include "../gstgl_fwd.h"
-#include <gst/gl/gstglcontext.h>
-
-#include <gst/gl/gl.h>
-#include "gstglcontext_glx.h"
-#include "../utils/opengl_versions.h"
-#include "../gstglcontext_private.h"
-
-#define GST_CAT_DEFAULT gst_gl_context_debug
-
-#define gst_gl_context_glx_parent_class parent_class
-G_DEFINE_TYPE (GstGLContextGLX, gst_gl_context_glx, GST_TYPE_GL_CONTEXT);
-
-#define GST_GL_CONTEXT_GLX_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_CONTEXT_GLX, GstGLContextGLXPrivate))
-
-static guintptr gst_gl_context_glx_get_gl_context (GstGLContext * context);
-static void gst_gl_context_glx_swap_buffers (GstGLContext * context);
-static gboolean gst_gl_context_glx_activate (GstGLContext * context,
- gboolean activate);
-static gboolean gst_gl_context_glx_create_context (GstGLContext *
- context, GstGLAPI gl_api, GstGLContext * other_context, GError ** error);
-static void gst_gl_context_glx_destroy_context (GstGLContext * context);
-static gboolean gst_gl_context_glx_choose_format (GstGLContext *
- context, GError ** error);
-static GstGLAPI gst_gl_context_glx_get_gl_api (GstGLContext * context);
-static GstGLPlatform gst_gl_context_glx_get_gl_platform (GstGLContext *
- context);
-static void gst_gl_context_glx_get_gl_platform_version (GstGLContext * context,
- gint * major, gint * minor);
-
-struct _GstGLContextGLXPrivate
-{
- int glx_major;
- int glx_minor;
-
- GstGLAPI context_api;
-
- GLXFBConfig *fbconfigs;
- GLXContext (*glXCreateContextAttribsARB) (Display *, GLXFBConfig,
- GLXContext, Bool, const int *);
-};
-
-static void
-gst_gl_context_glx_class_init (GstGLContextGLXClass * klass)
-{
- GstGLContextClass *context_class = (GstGLContextClass *) klass;
-
- g_type_class_add_private (klass, sizeof (GstGLContextGLXPrivate));
-
- context_class->get_gl_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_glx_get_gl_context);
- context_class->activate = GST_DEBUG_FUNCPTR (gst_gl_context_glx_activate);
- context_class->create_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_glx_create_context);
- context_class->destroy_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_glx_destroy_context);
- context_class->choose_format =
- GST_DEBUG_FUNCPTR (gst_gl_context_glx_choose_format);
- context_class->swap_buffers =
- GST_DEBUG_FUNCPTR (gst_gl_context_glx_swap_buffers);
-
- context_class->get_gl_api = GST_DEBUG_FUNCPTR (gst_gl_context_glx_get_gl_api);
- context_class->get_gl_platform =
- GST_DEBUG_FUNCPTR (gst_gl_context_glx_get_gl_platform);
- context_class->get_proc_address =
- GST_DEBUG_FUNCPTR (gst_gl_context_glx_get_proc_address);
- context_class->get_current_context =
- GST_DEBUG_FUNCPTR (gst_gl_context_glx_get_current_context);
- context_class->get_gl_platform_version =
- GST_DEBUG_FUNCPTR (gst_gl_context_glx_get_gl_platform_version);
-}
-
-static void
-gst_gl_context_glx_init (GstGLContextGLX * context)
-{
- context->priv = GST_GL_CONTEXT_GLX_GET_PRIVATE (context);
-}
-
-GstGLContextGLX *
-gst_gl_context_glx_new (GstGLDisplay * display)
-{
- GstGLContextGLX *context;
-
- if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_X11) == 0)
- /* we require an x11 display handle to create GLX contexts */
- return NULL;
-
- context = g_object_new (GST_TYPE_GL_CONTEXT_GLX, NULL);
- gst_object_ref_sink (context);
-
- return context;
-}
-
-static inline void
-_describe_fbconfig (Display * display, GLXFBConfig config)
-{
- int val;
-
- glXGetFBConfigAttrib (display, config, GLX_FBCONFIG_ID, &val);
- GST_DEBUG ("ID: %d", val);
- glXGetFBConfigAttrib (display, config, GLX_DOUBLEBUFFER, &val);
- GST_DEBUG ("double buffering: %d", val);
- glXGetFBConfigAttrib (display, config, GLX_RED_SIZE, &val);
- GST_DEBUG ("red: %d", val);
- glXGetFBConfigAttrib (display, config, GLX_GREEN_SIZE, &val);
- GST_DEBUG ("green: %d", val);
- glXGetFBConfigAttrib (display, config, GLX_BLUE_SIZE, &val);
- GST_DEBUG ("blue: %d", val);
- glXGetFBConfigAttrib (display, config, GLX_ALPHA_SIZE, &val);
- GST_DEBUG ("alpha: %d", val);
- glXGetFBConfigAttrib (display, config, GLX_DEPTH_SIZE, &val);
- GST_DEBUG ("depth: %d", val);
- glXGetFBConfigAttrib (display, config, GLX_STENCIL_SIZE, &val);
- GST_DEBUG ("stencil: %d", val);
-}
-
-static GLXContext
-_create_context_with_flags (GstGLContextGLX * context_glx, Display * dpy,
- GLXFBConfig fbconfig, GLXContext share_context, gint major, gint minor,
- gint contextFlags, gint profileMask)
-{
- GLXContext ret;
-#define N_ATTRIBS 20
- gint attribs[N_ATTRIBS];
- int x_error = 0;
- gint n = 0;
-
- if (major) {
- attribs[n++] = GLX_CONTEXT_MAJOR_VERSION_ARB;
- attribs[n++] = major;
- }
- if (minor) {
- attribs[n++] = GLX_CONTEXT_MINOR_VERSION_ARB;
- attribs[n++] = minor;
- }
- if (contextFlags) {
- attribs[n++] = GLX_CONTEXT_FLAGS_ARB;
- attribs[n++] = contextFlags;
- }
-#ifdef GLX_ARB_create_context_profile
- if (profileMask) {
- attribs[n++] = GLX_CONTEXT_PROFILE_MASK_ARB;
- attribs[n++] = profileMask;
- }
-#endif
- attribs[n++] = None;
-
- g_assert (n < N_ATTRIBS);
-#undef N_ATTRIBS
-
- gst_gl_window_x11_trap_x_errors ();
- ret = context_glx->priv->glXCreateContextAttribsARB (dpy, fbconfig,
- share_context, True, attribs);
- x_error = gst_gl_window_x11_untrap_x_errors ();
-
- if (x_error)
- ret = 0;
-
- return ret;
-}
-
-static gboolean
-gst_gl_context_glx_create_context (GstGLContext * context,
- GstGLAPI gl_api, GstGLContext * other_context, GError ** error)
-{
- GstGLContextGLX *context_glx;
- GstGLWindow *window;
- GstGLWindowX11 *window_x11;
- GstGLDisplay *display = NULL;
- gboolean create_context;
- const char *glx_exts;
- Display *device;
- guintptr external_gl_context = 0;
-
- context_glx = GST_GL_CONTEXT_GLX (context);
- window = gst_gl_context_get_window (context);
-
- if (!GST_IS_GL_WINDOW_X11 (window)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
- "Cannot create an GLX context from a non-X11 window");
- goto failure;
- }
-
- window_x11 = GST_GL_WINDOW_X11 (window);
- display = gst_gl_context_get_display (context);
-
- if (other_context) {
- if (gst_gl_context_get_gl_platform (other_context) != GST_GL_PLATFORM_GLX) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
- "Cannot share context with non-GLX context");
- goto failure;
- }
-
- external_gl_context = gst_gl_context_get_gl_context (other_context);
- }
-
- device = (Display *) gst_gl_display_get_handle (display);
- if (!device) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE, "Invalid Display handle");
- goto failure;
- }
-
- glx_exts = glXQueryExtensionsString (device, DefaultScreen (device));
-
- create_context = gst_gl_check_extension ("GLX_ARB_create_context", glx_exts);
- context_glx->priv->glXCreateContextAttribsARB =
- (gpointer) glXGetProcAddressARB ((const GLubyte *)
- "glXCreateContextAttribsARB");
-
- if (!context_glx->glx_context && gl_api & GST_GL_API_OPENGL3 && create_context
- && context_glx->priv->glXCreateContextAttribsARB) {
- gint i;
-
- for (i = 0; i < G_N_ELEMENTS (opengl_versions); i++) {
- gint profileMask = 0;
- gint contextFlags = 0;
-
- if ((opengl_versions[i].major > 3
- || (opengl_versions[i].major == 3
- && opengl_versions[i].minor >= 2))) {
- profileMask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
- contextFlags |= GLX_CONTEXT_DEBUG_BIT_ARB;
- } else {
- break;
- }
-
- GST_DEBUG_OBJECT (context, "trying to create a GL %d.%d context",
- opengl_versions[i].major, opengl_versions[i].minor);
-
- context_glx->glx_context = _create_context_with_flags (context_glx,
- device, context_glx->priv->fbconfigs[0],
- (GLXContext) external_gl_context, opengl_versions[i].major,
- opengl_versions[i].minor, contextFlags, profileMask);
-
- if (context_glx->glx_context) {
- context_glx->priv->context_api = GST_GL_API_OPENGL3;
- break;
- }
- }
- }
- if (!context_glx->glx_context && gl_api & GST_GL_API_OPENGL) {
- context_glx->glx_context =
- glXCreateContext (device, window_x11->visual_info,
- (GLXContext) external_gl_context, TRUE);
- context_glx->priv->context_api = GST_GL_API_OPENGL;
- }
-
- if (context_glx->priv->fbconfigs)
- XFree (context_glx->priv->fbconfigs);
-
- if (!context_glx->glx_context) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_CREATE_CONTEXT, "Failed to create opengl context");
- goto failure;
- }
-
- GST_LOG ("gl context id: %ld", (gulong) context_glx->glx_context);
-
- gst_object_unref (window);
- gst_object_unref (display);
-
- return TRUE;
-
-failure:
- if (window)
- gst_object_unref (window);
- if (display)
- gst_object_unref (display);
-
- return FALSE;
-}
-
-static void
-gst_gl_context_glx_destroy_context (GstGLContext * context)
-{
- GstGLWindow *window;
- GstGLContextGLX *context_glx;
- Display *device;
-
- context_glx = GST_GL_CONTEXT_GLX (context);
- window = gst_gl_context_get_window (context);
- device = (Display *) gst_gl_display_get_handle (window->display);
-
- glXDestroyContext (device, context_glx->glx_context);
-
- context_glx->glx_context = 0;
-
- gst_object_unref (window);
-}
-
-static gboolean
-gst_gl_context_glx_choose_format (GstGLContext * context, GError ** error)
-{
- GstGLContextGLX *context_glx;
- GstGLWindow *window;
- GstGLWindowX11 *window_x11;
- gint error_base;
- gint event_base;
- Display *device;
-
- context_glx = GST_GL_CONTEXT_GLX (context);
- window = gst_gl_context_get_window (context);
-
- if (!GST_IS_GL_WINDOW_X11 (window)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
- "Cannot create an GLX context from a non-X11 window");
- goto failure;
- }
- window_x11 = GST_GL_WINDOW_X11 (window);
-
- device = (Display *) gst_gl_display_get_handle (window->display);
- if (!device) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE, "Invalid Display handle");
- goto failure;
- }
-
- if (!glXQueryExtension (device, &error_base, &event_base)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE, "No GLX extension");
- goto failure;
- }
-
- if (!glXQueryVersion (device, &context_glx->priv->glx_major,
- &context_glx->priv->glx_minor)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
- "Failed to query GLX version (glXQueryVersion failed)");
- goto failure;
- }
-
- GST_INFO ("GLX Version: %d.%d", context_glx->priv->glx_major,
- context_glx->priv->glx_minor);
-
- /* legacy case */
- if (context_glx->priv->glx_major < 1 || (context_glx->priv->glx_major == 1
- && context_glx->priv->glx_minor < 3)) {
- gint attribs[] = {
- GLX_RGBA,
- GLX_RED_SIZE, 1,
- GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1,
- GLX_DEPTH_SIZE, 16,
- GLX_DOUBLEBUFFER,
- None
- };
-
- window_x11->visual_info = glXChooseVisual (device,
- window_x11->screen_num, attribs);
-
- if (!window_x11->visual_info) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
- "Bad attributes in glXChooseVisual");
- goto failure;
- }
- } else {
- gint attribs[] = {
- GLX_RENDER_TYPE, GLX_RGBA_BIT,
- GLX_RED_SIZE, 1,
- GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1,
- GLX_DEPTH_SIZE, 16,
- GLX_DOUBLEBUFFER, True,
- None
- };
- int fbcount;
-
- context_glx->priv->fbconfigs = glXChooseFBConfig (device,
- DefaultScreen (device), attribs, &fbcount);
-
- if (!context_glx->priv->fbconfigs) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
- "Could not find any FBConfig's to use (check attributes?)");
- goto failure;
- }
-
- _describe_fbconfig (device, context_glx->priv->fbconfigs[0]);
-
- window_x11->visual_info = glXGetVisualFromFBConfig (device,
- context_glx->priv->fbconfigs[0]);
-
- if (!window_x11->visual_info) {
- g_set_error (error, GST_GL_CONTEXT_ERROR,
- GST_GL_CONTEXT_ERROR_WRONG_CONFIG, "Bad attributes in FBConfig");
- goto failure;
- }
- }
-
- gst_gl_window_x11_create_window ((GstGLWindowX11 *) window);
-
- gst_object_unref (window);
-
- return TRUE;
-
-failure:
- if (window)
- gst_object_unref (window);
-
- return FALSE;
-}
-
-static void
-gst_gl_context_glx_swap_buffers (GstGLContext * context)
-{
- GstGLWindow *window = gst_gl_context_get_window (context);
- Display *device = (Display *) gst_gl_display_get_handle (window->display);
- Window window_handle = (Window) gst_gl_window_get_window_handle (window);
-
- glXSwapBuffers (device, window_handle);
-
- gst_object_unref (window);
-}
-
-static guintptr
-gst_gl_context_glx_get_gl_context (GstGLContext * context)
-{
- return (guintptr) GST_GL_CONTEXT_GLX (context)->glx_context;
-}
-
-static gboolean
-gst_gl_context_glx_activate (GstGLContext * context, gboolean activate)
-{
- GstGLWindow *window = gst_gl_context_get_window (context);
- Display *device = (Display *) gst_gl_display_get_handle (window->display);
- Window window_handle = (Window) gst_gl_window_get_window_handle (window);
- gboolean result;
-
- if (activate) {
- result = glXMakeCurrent (device, window_handle,
- GST_GL_CONTEXT_GLX (context)->glx_context);
- } else {
- result = glXMakeCurrent (device, None, NULL);
- }
-
- gst_object_unref (window);
-
- return result;
-}
-
-GstGLAPI
-gst_gl_context_glx_get_gl_api (GstGLContext * context)
-{
- GstGLContextGLX *context_glx;
-
- context_glx = GST_GL_CONTEXT_GLX (context);
-
- return context_glx->priv->context_api;
-}
-
-static GstGLPlatform
-gst_gl_context_glx_get_gl_platform (GstGLContext * context)
-{
- return GST_GL_PLATFORM_GLX;
-}
-
-gpointer
-gst_gl_context_glx_get_proc_address (GstGLAPI gl_api, const gchar * name)
-{
- gpointer result;
-
- if (!(result = gst_gl_context_default_get_proc_address (gl_api, name))) {
- result = glXGetProcAddressARB ((const GLubyte *) name);
- }
-
- return result;
-}
-
-guintptr
-gst_gl_context_glx_get_current_context (void)
-{
- return (guintptr) glXGetCurrentContext ();
-}
-
-static void
-gst_gl_context_glx_get_gl_platform_version (GstGLContext * context,
- gint * major, gint * minor)
-{
- GstGLContextGLX *context_glx = GST_GL_CONTEXT_GLX (context);
-
- *major = context_glx->priv->glx_major;
- *minor = context_glx->priv->glx_minor;
-}
diff --git a/gst-libs/gst/gl/x11/gstglcontext_glx.h b/gst-libs/gst/gl/x11/gstglcontext_glx.h
deleted file mode 100644
index e3eb8fe3c..000000000
--- a/gst-libs/gst/gl/x11/gstglcontext_glx.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_CONTEXT_GLX_H__
-#define __GST_GL_CONTEXT_GLX_H__
-
-#include "gstglwindow_x11.h"
-
-#include <GL/glx.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_CONTEXT_GLX (gst_gl_context_glx_get_type())
-G_GNUC_INTERNAL GType gst_gl_context_glx_get_type (void);
-
-/* FIXME: remove this when moving to -base */
-#ifndef GST_DISABLE_DEPRECATED
-#define GST_GL_TYPE_CONTEXT_GLX GST_TYPE_GL_CONTEXT_GLX
-#endif
-#define GST_GL_CONTEXT_GLX(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_CONTEXT_GLX, GstGLContextGLX))
-#define GST_GL_CONTEXT_GLX_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_CONTEXT_GLX, GstGLContextGLXClass))
-#define GST_IS_GL_CONTEXT_GLX(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_CONTEXT_GLX))
-#define GST_IS_GL_CONTEXT_GLX_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_CONTEXT_GLX))
-#define GST_GL_CONTEXT_GLX_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_CONTEXT_GLX, GstGLContextGLX_Class))
-
-typedef struct _GstGLContextGLX GstGLContextGLX;
-typedef struct _GstGLContextGLXClass GstGLContextGLXClass;
-typedef struct _GstGLContextGLXPrivate GstGLContextGLXPrivate;
-
-struct _GstGLContextGLX {
- /*< private >*/
- GstGLContext parent;
-
- GLXContext glx_context;
-
- GstGLContextGLXPrivate *priv;
-
- gpointer _reserved[GST_PADDING];
-};
-
-struct _GstGLContextGLXClass {
- /*< private >*/
- GstGLContextClass parent_class;
-
- /*< private >*/
- gpointer _reserved[GST_PADDING];
-};
-
-G_GNUC_INTERNAL
-GstGLContextGLX * gst_gl_context_glx_new (GstGLDisplay * display);
-
-G_GNUC_INTERNAL
-guintptr gst_gl_context_glx_get_current_context (void);
-
-G_GNUC_INTERNAL
-gpointer gst_gl_context_glx_get_proc_address (GstGLAPI gl_api, const gchar * name);
-
-G_END_DECLS
-
-#endif /* __GST_GL_CONTEXT_H__ */
diff --git a/gst-libs/gst/gl/x11/gstgldisplay_x11.c b/gst-libs/gst/gl/x11/gstgldisplay_x11.c
deleted file mode 100644
index 00cdd3f9a..000000000
--- a/gst-libs/gst/gl/x11/gstgldisplay_x11.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gl/x11/gstgldisplay_x11.h>
-#include <gst/gl/x11/gstglwindow_x11.h>
-#include "xcb_event_source.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_gl_display_debug);
-#define GST_CAT_DEFAULT gst_gl_display_debug
-
-G_DEFINE_TYPE (GstGLDisplayX11, gst_gl_display_x11, GST_TYPE_GL_DISPLAY);
-
-static void gst_gl_display_x11_finalize (GObject * object);
-static guintptr gst_gl_display_x11_get_handle (GstGLDisplay * display);
-
-G_GNUC_INTERNAL
- gboolean gst_gl_display_x11_handle_event (GstGLDisplayX11 * display_x11);
-
-extern gboolean gst_gl_window_x11_handle_event (GstGLWindowX11 * window_x11,
- xcb_generic_event_t * event);
-
-static void
-gst_gl_display_x11_class_init (GstGLDisplayX11Class * klass)
-{
- GST_GL_DISPLAY_CLASS (klass)->get_handle =
- GST_DEBUG_FUNCPTR (gst_gl_display_x11_get_handle);
-
- G_OBJECT_CLASS (klass)->finalize = gst_gl_display_x11_finalize;
-}
-
-static void
-gst_gl_display_x11_init (GstGLDisplayX11 * display_x11)
-{
- GstGLDisplay *display = (GstGLDisplay *) display_x11;
-
- display->type = GST_GL_DISPLAY_TYPE_X11;
- display_x11->foreign_display = FALSE;
-}
-
-static void
-gst_gl_display_x11_finalize (GObject * object)
-{
- GstGLDisplayX11 *display_x11 = GST_GL_DISPLAY_X11 (object);
-
- g_free (display_x11->name);
-
- if (!display_x11->foreign_display && display_x11->display) {
- XSync (display_x11->display, FALSE);
- XCloseDisplay (display_x11->display);
- }
-
- G_OBJECT_CLASS (gst_gl_display_x11_parent_class)->finalize (object);
-}
-
-/**
- * gst_gl_display_x11_new:
- * @name: (allow-none): a display name
- *
- * Create a new #GstGLDisplayX11 from the x11 display name. See XOpenDisplay()
- * for details on what is a valid name.
- *
- * Returns: (transfer full): a new #GstGLDisplayX11 or %NULL
- */
-GstGLDisplayX11 *
-gst_gl_display_x11_new (const gchar * name)
-{
- GstGLDisplayX11 *ret;
-
- GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");
-
- ret = g_object_new (GST_TYPE_GL_DISPLAY_X11, NULL);
- gst_object_ref_sink (ret);
- ret->name = g_strdup (name);
- ret->display = XOpenDisplay (ret->name);
-
- if (!ret->display) {
- GST_INFO ("Failed to open X11 display connection with name, \'%s\'", name);
- gst_object_unref (ret);
- return NULL;
- }
-
- ret->xcb_connection = XGetXCBConnection (ret->display);
- if (!ret->xcb_connection) {
- GST_ERROR ("Failed to open retieve XCB connection from X11 Display");
- gst_object_unref (ret);
- return NULL;
- }
-
- XSetEventQueueOwner (ret->display, XCBOwnsEventQueue);
-
- GST_GL_DISPLAY (ret)->event_source = xcb_event_source_new (ret);
- g_source_attach (GST_GL_DISPLAY (ret)->event_source,
- GST_GL_DISPLAY (ret)->main_context);
-
- return ret;
-}
-
-/**
- * gst_gl_display_x11_new_with_display:
- * @display: an existing, x11 display
- *
- * Creates a new display connection from a X11 Display.
- *
- * Returns: (transfer full): a new #GstGLDisplayX11
- */
-GstGLDisplayX11 *
-gst_gl_display_x11_new_with_display (Display * display)
-{
- GstGLDisplayX11 *ret;
-
- g_return_val_if_fail (display != NULL, NULL);
-
- GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");
-
- ret = g_object_new (GST_TYPE_GL_DISPLAY_X11, NULL);
- gst_object_ref_sink (ret);
-
- ret->name = g_strdup (DisplayString (display));
- ret->display = display;
-
- ret->xcb_connection = XGetXCBConnection (ret->display);
- if (!ret->xcb_connection) {
- GST_ERROR ("Failed to open retieve XCB connection from X11 Display");
- gst_object_unref (ret);
- return NULL;
- }
-
- ret->foreign_display = TRUE;
-
- return ret;
-}
-
-static guintptr
-gst_gl_display_x11_get_handle (GstGLDisplay * display)
-{
- return (guintptr) GST_GL_DISPLAY_X11 (display)->display;
-}
-
-static int
-_compare_xcb_window (GstGLWindowX11 * window_x11, xcb_window_t * window_id)
-{
- return window_x11->internal_win_id - *window_id;
-}
-
-static GstGLWindowX11 *
-_find_window_from_xcb_window (GstGLDisplayX11 * display_x11,
- xcb_window_t window_id)
-{
- GstGLDisplay *display = GST_GL_DISPLAY (display_x11);
- GstGLWindowX11 *ret = NULL;
- GList *l;
-
- if (!window_id)
- return NULL;
-
- GST_OBJECT_LOCK (display);
- l = g_list_find_custom (display->windows, &window_id,
- (GCompareFunc) _compare_xcb_window);
- if (l)
- ret = gst_object_ref (l->data);
- GST_OBJECT_UNLOCK (display);
-
- return ret;
-}
-
-static GstGLWindowX11 *
-_window_from_event (GstGLDisplayX11 * display_x11, xcb_generic_event_t * event)
-{
- uint8_t event_code = event->response_type & 0x7f;
-
- switch (event_code) {
-/* *INDENT-OFF* */
-#define WIN_FROM_EVENT(case_val,event_type,window_field) \
- case case_val:{ \
- event_type * real_event = (event_type *) event; \
- return _find_window_from_xcb_window (display_x11, real_event->window_field); \
- }
- WIN_FROM_EVENT (XCB_CLIENT_MESSAGE, xcb_client_message_event_t, window)
- WIN_FROM_EVENT (XCB_CONFIGURE_NOTIFY, xcb_configure_notify_event_t, window)
- WIN_FROM_EVENT (XCB_EXPOSE, xcb_expose_event_t, window)
- WIN_FROM_EVENT (XCB_KEY_PRESS, xcb_key_press_event_t, event)
- WIN_FROM_EVENT (XCB_KEY_RELEASE, xcb_key_release_event_t, event)
- WIN_FROM_EVENT (XCB_BUTTON_PRESS, xcb_button_press_event_t, event)
- WIN_FROM_EVENT (XCB_BUTTON_RELEASE, xcb_button_release_event_t, event)
- WIN_FROM_EVENT (XCB_MOTION_NOTIFY, xcb_motion_notify_event_t, event)
-#undef WIN_FROM_EVENT
-/* *INDENT-ON* */
- default:
- return NULL;
- }
-}
-
-gboolean
-gst_gl_display_x11_handle_event (GstGLDisplayX11 * display_x11)
-{
- xcb_connection_t *connection = display_x11->xcb_connection;
- xcb_generic_event_t *event;
- gboolean ret = TRUE;
-
- while ((event = xcb_poll_for_event (connection))) {
- GstGLWindowX11 *window_x11 = _window_from_event (display_x11, event);
-
- GST_TRACE_OBJECT (display_x11, "got event %p to window %" GST_PTR_FORMAT,
- event, window_x11);
-
- if (window_x11) {
- ret = gst_gl_window_x11_handle_event (window_x11, event);
- } else {
- /* unknown window, ignore */
- ret = TRUE;
- }
-
- if (window_x11)
- gst_object_unref (window_x11);
- g_free (event);
- }
-
- return ret;
-}
diff --git a/gst-libs/gst/gl/x11/gstgldisplay_x11.h b/gst-libs/gst/gl/x11/gstgldisplay_x11.h
deleted file mode 100644
index 3ffe251bb..000000000
--- a/gst-libs/gst/gl/x11/gstgldisplay_x11.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_DISPLAY_X11_H__
-#define __GST_GL_DISPLAY_X11_H__
-
-#include <gst/gst.h>
-
-#include <X11/Xlib-xcb.h>
-
-#include <gst/gl/gstgldisplay.h>
-
-G_BEGIN_DECLS
-
-GST_EXPORT
-GType gst_gl_display_x11_get_type (void);
-
-#define GST_TYPE_GL_DISPLAY_X11 (gst_gl_display_x11_get_type())
-#define GST_GL_DISPLAY_X11(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_DISPLAY_X11,GstGLDisplayX11))
-#define GST_GL_DISPLAY_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_GL_DISPLAY_X11,GstGLDisplayX11Class))
-#define GST_IS_GL_DISPLAY_X11(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_DISPLAY_X11))
-#define GST_IS_GL_DISPLAY_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GL_DISPLAY_X11))
-#define GST_GL_DISPLAY_X11_CAST(obj) ((GstGLDisplayX11*)(obj))
-
-typedef struct _GstGLDisplayX11 GstGLDisplayX11;
-typedef struct _GstGLDisplayX11Class GstGLDisplayX11Class;
-
-/**
- * GstGLDisplayX11:
- *
- * the contents of a #GstGLDisplayX11 are private and should only be accessed
- * through the provided API
- */
-struct _GstGLDisplayX11
-{
- GstGLDisplay parent;
-
- /* <private> */
- gchar *name;
- Display *display;
- xcb_connection_t *xcb_connection;
- gboolean foreign_display;
-
- gpointer _padding[GST_PADDING];
-};
-
-struct _GstGLDisplayX11Class
-{
- GstGLDisplayClass object_class;
-
- gpointer _padding[GST_PADDING];
-};
-
-GST_EXPORT
-GstGLDisplayX11 *gst_gl_display_x11_new (const gchar * name);
-
-GST_EXPORT
-GstGLDisplayX11 *gst_gl_display_x11_new_with_display (Display *display);
-
-G_END_DECLS
-
-#endif /* __GST_GL_DISPLAY_X11_H__ */
diff --git a/gst-libs/gst/gl/x11/gstglwindow_x11.c b/gst-libs/gst/gl/x11/gstglwindow_x11.c
deleted file mode 100644
index 9898e0be7..000000000
--- a/gst-libs/gst/gl/x11/gstglwindow_x11.c
+++ /dev/null
@@ -1,670 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#define GLIB_DISABLE_DEPRECATION_WARNINGS
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-#include <locale.h>
-
-#include "gstglwindow_x11.h"
-#include "gstgldisplay_x11.h"
-
-#include "../gstglwindow_private.h"
-
-/* for XkbKeycodeToKeysym */
-#include <X11/XKBlib.h>
-
-#define GST_GL_WINDOW_X11_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_WINDOW_X11, GstGLWindowX11Private))
-
-#define GST_CAT_DEFAULT gst_gl_window_debug
-
-#define gst_gl_window_x11_parent_class parent_class
-G_DEFINE_TYPE (GstGLWindowX11, gst_gl_window_x11, GST_TYPE_GL_WINDOW);
-
-G_GNUC_INTERNAL
- gboolean gst_gl_window_x11_handle_event (GstGLWindowX11 * window_x11,
- xcb_generic_event_t * event);
-
-/* X error trap */
-static int TrappedErrorCode = 0;
-static int (*old_error_handler) (Display *, XErrorEvent *);
-
-enum
-{
- ARG_0,
- ARG_DISPLAY
-};
-
-struct _GstGLWindowX11Private
-{
- gboolean activate;
- gboolean activate_result;
-
- gint preferred_width;
- gint preferred_height;
-
- gboolean handle_events;
-
- GstVideoRectangle render_rect;
-};
-
-static guintptr gst_gl_window_x11_get_display (GstGLWindow * window);
-guintptr gst_gl_window_x11_get_gl_context (GstGLWindow * window);
-gboolean gst_gl_window_x11_activate (GstGLWindow * window, gboolean activate);
-static void gst_gl_window_x11_set_window_handle (GstGLWindow * window,
- guintptr handle);
-static gboolean gst_gl_window_x11_set_render_rectangle (GstGLWindow * window,
- int x, int y, int width, int height);
-static guintptr gst_gl_window_x11_get_window_handle (GstGLWindow * window);
-static void gst_gl_window_x11_set_preferred_size (GstGLWindow * window,
- gint width, gint height);
-static void gst_gl_window_x11_show (GstGLWindow * window);
-static void gst_gl_window_x11_draw (GstGLWindow * window);
-gboolean gst_gl_window_x11_create_context (GstGLWindow * window,
- GstGLAPI gl_api, guintptr external_gl_context, GError ** error);
-static gboolean gst_gl_window_x11_open (GstGLWindow * window, GError ** error);
-static void gst_gl_window_x11_close (GstGLWindow * window);
-static void gst_gl_window_x11_handle_events (GstGLWindow * window,
- gboolean handle_events);
-
-static void
-gst_gl_window_x11_finalize (GObject * object)
-{
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-gst_gl_window_x11_class_init (GstGLWindowX11Class * klass)
-{
- GObjectClass *obj_class = G_OBJECT_CLASS (klass);
- GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
-
- g_type_class_add_private (klass, sizeof (GstGLWindowX11Private));
-
- obj_class->finalize = gst_gl_window_x11_finalize;
-
- window_class->get_display = GST_DEBUG_FUNCPTR (gst_gl_window_x11_get_display);
- window_class->set_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_x11_set_window_handle);
- window_class->set_render_rectangle =
- GST_DEBUG_FUNCPTR (gst_gl_window_x11_set_render_rectangle);
- window_class->get_window_handle =
- GST_DEBUG_FUNCPTR (gst_gl_window_x11_get_window_handle);
- window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_x11_draw);
- window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_x11_open);
- window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_x11_close);
- window_class->handle_events =
- GST_DEBUG_FUNCPTR (gst_gl_window_x11_handle_events);
- window_class->set_preferred_size =
- GST_DEBUG_FUNCPTR (gst_gl_window_x11_set_preferred_size);
- window_class->show = GST_DEBUG_FUNCPTR (gst_gl_window_x11_show);
-}
-
-static void
-gst_gl_window_x11_init (GstGLWindowX11 * window)
-{
- window->priv = GST_GL_WINDOW_X11_GET_PRIVATE (window);
-}
-
-/* Must be called in the gl thread */
-GstGLWindowX11 *
-gst_gl_window_x11_new (GstGLDisplay * display)
-{
- GstGLWindowX11 *window;
-
- if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_X11)
- == GST_GL_DISPLAY_TYPE_NONE) {
- GST_INFO ("Wrong display type %u for this window type %u", display->type,
- GST_GL_DISPLAY_TYPE_X11);
- return NULL;
- }
-
- window = g_object_new (GST_TYPE_GL_WINDOW_X11, NULL);
- gst_object_ref_sink (window);
-
- return window;
-}
-
-static gboolean
-gst_gl_window_x11_open (GstGLWindow * window, GError ** error)
-{
- GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window);
- GstGLDisplayX11 *display_x11 = (GstGLDisplayX11 *) window->display;
-
- window_x11->device = display_x11->display;
-// window_x11->device = XOpenDisplay (display_x11->name);
- if (window_x11->device == NULL) {
- g_set_error (error, GST_GL_WINDOW_ERROR,
- GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
- "Failed to connect to X display server");
- goto failure;
- }
-
- GST_LOG ("gl device id: %ld", (gulong) window_x11->device);
-
- window_x11->screen = DefaultScreenOfDisplay (window_x11->device);
- window_x11->screen_num = DefaultScreen (window_x11->device);
- window_x11->visual =
- DefaultVisual (window_x11->device, window_x11->screen_num);
- window_x11->root = DefaultRootWindow (window_x11->device);
- window_x11->white = XWhitePixel (window_x11->device, window_x11->screen_num);
- window_x11->black = XBlackPixel (window_x11->device, window_x11->screen_num);
- window_x11->depth = DefaultDepthOfScreen (window_x11->screen);
-
- GST_LOG ("gl root id: %lud", (gulong) window_x11->root);
-
- window_x11->device_width =
- DisplayWidth (window_x11->device, window_x11->screen_num);
- window_x11->device_height =
- DisplayHeight (window_x11->device, window_x11->screen_num);
-
- window_x11->allow_extra_expose_events = TRUE;
-
- return GST_GL_WINDOW_CLASS (parent_class)->open (window, error);
-
-failure:
- return FALSE;
-}
-
-gboolean
-gst_gl_window_x11_create_window (GstGLWindowX11 * window_x11)
-{
- XSetWindowAttributes win_attr;
- XTextProperty text_property;
- XWMHints wm_hints;
- unsigned long mask;
- const gchar *title = "OpenGL renderer";
- Atom wm_atoms[1];
- gint x = 0, y = 0, width = 1, height = 1;
-
- if (window_x11->visual_info->visual != window_x11->visual)
- GST_LOG ("selected visual is different from the default");
-
- GST_LOG ("visual XID:%d, screen:%d, visualid:%d, depth:%d, class:%d, "
- "red_mask:%ld, green_mask:%ld, blue_mask:%ld bpp:%d",
- (gint) XVisualIDFromVisual (window_x11->visual_info->visual),
- window_x11->visual_info->screen, (gint) window_x11->visual_info->visualid,
- window_x11->visual_info->depth, window_x11->visual_info->class,
- window_x11->visual_info->red_mask, window_x11->visual_info->green_mask,
- window_x11->visual_info->blue_mask,
- window_x11->visual_info->bits_per_rgb);
-
- win_attr.event_mask =
- StructureNotifyMask | ExposureMask | VisibilityChangeMask;
- win_attr.do_not_propagate_mask = NoEventMask;
-
- win_attr.background_pixmap = None;
- win_attr.background_pixel = 0;
- win_attr.border_pixel = 0;
-
- win_attr.colormap =
- XCreateColormap (window_x11->device, window_x11->root,
- window_x11->visual_info->visual, AllocNone);
-
- mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
-
- window_x11->internal_win_id =
- XCreateWindow (window_x11->device,
- window_x11->parent_win ? window_x11->parent_win : window_x11->root,
- x, y, width, height, 0,
- window_x11->visual_info->depth, InputOutput,
- window_x11->visual_info->visual, mask, &win_attr);
-
- gst_gl_window_x11_handle_events (GST_GL_WINDOW (window_x11),
- window_x11->priv->handle_events);
-
- XSync (window_x11->device, FALSE);
-
- XSetWindowBackgroundPixmap (window_x11->device,
- window_x11->internal_win_id, None);
-
- GST_LOG ("gl window id: %lud", (gulong) window_x11->internal_win_id);
- GST_LOG ("gl window props: x:%d y:%d", x, y);
-
- wm_atoms[0] = XInternAtom (window_x11->device, "WM_DELETE_WINDOW", True);
- if (wm_atoms[0] == None)
- GST_DEBUG ("Cannot create WM_DELETE_WINDOW");
-
- XSetWMProtocols (window_x11->device, window_x11->internal_win_id,
- wm_atoms, 1);
-
- wm_hints.flags = StateHint;
- wm_hints.initial_state = NormalState;
- wm_hints.input = False;
-
- XStringListToTextProperty ((char **) &title, 1, &text_property);
-
- XSetWMProperties (window_x11->device, window_x11->internal_win_id,
- &text_property, &text_property, 0, 0, NULL, &wm_hints, NULL);
-
- XFree (text_property.value);
-
- return TRUE;
-}
-
-static void
-gst_gl_window_x11_close (GstGLWindow * window)
-{
- GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window);
-
- if (window_x11->device) {
- if (window_x11->internal_win_id) {
- XUnmapWindow (window_x11->device, window_x11->internal_win_id);
-
- XDestroyWindow (window_x11->device, window_x11->internal_win_id);
- }
- XFree (window_x11->visual_info);
-
- GST_DEBUG ("display receiver closed");
- }
-
- window_x11->running = FALSE;
-
- GST_GL_WINDOW_CLASS (parent_class)->close (window);
-}
-
-/* called by the gl thread */
-static void
-gst_gl_window_x11_set_window_handle (GstGLWindow * window, guintptr id)
-{
- GstGLWindowX11 *window_x11;
- gint x, y, width, height;
-
- window_x11 = GST_GL_WINDOW_X11 (window);
-
- window_x11->parent_win = (Window) id;
-
- if (window_x11->priv->render_rect.w > 0 &&
- window_x11->priv->render_rect.h > 0) {
- x = window_x11->priv->render_rect.x;
- y = window_x11->priv->render_rect.y;
- width = window_x11->priv->render_rect.w;
- height = window_x11->priv->render_rect.h;
- } else {
- x = y = 0;
- if (window_x11->parent_win) {
- XWindowAttributes attr;
-
- XGetWindowAttributes (window_x11->device, window_x11->parent_win, &attr);
- width = attr.width;
- height = attr.height;
- } else {
- width = window_x11->priv->preferred_width;
- height = window_x11->priv->preferred_height;
- }
- }
-
- XResizeWindow (window_x11->device, window_x11->internal_win_id,
- width, height);
-
- XReparentWindow (window_x11->device, window_x11->internal_win_id,
- window_x11->parent_win, x, y);
-
- XSync (window_x11->device, FALSE);
-}
-
-struct SetRenderRectangle
-{
- GstGLWindowX11 *window_x11;
- GstVideoRectangle rect;
-};
-
-static void
-_free_set_render_rectangle (struct SetRenderRectangle *render)
-{
- if (render) {
- if (render->window_x11)
- gst_object_unref (render->window_x11);
- g_free (render);
- }
-}
-
-static void
-_set_render_rectangle (gpointer data)
-{
- struct SetRenderRectangle *render = data;
-
- GST_LOG_OBJECT (render->window_x11, "setting render rectangle %i,%i+%ix%i",
- render->rect.x, render->rect.y, render->rect.w, render->rect.h);
-
- if (render->window_x11->internal_win_id)
- XMoveResizeWindow (render->window_x11->device,
- render->window_x11->internal_win_id, render->rect.x, render->rect.y,
- render->rect.w, render->rect.h);
-
- if (render->window_x11->device)
- XSync (render->window_x11->device, FALSE);
-
- render->window_x11->priv->render_rect = render->rect;
-}
-
-static gboolean
-gst_gl_window_x11_set_render_rectangle (GstGLWindow * window,
- int x, int y, int width, int height)
-{
- GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window);
- struct SetRenderRectangle *render;
-
- render = g_new0 (struct SetRenderRectangle, 1);
- render->window_x11 = gst_object_ref (window_x11);
- render->rect.x = x;
- render->rect.y = y;
- render->rect.w = width;
- render->rect.h = height;
-
- gst_gl_window_send_message_async (window,
- (GstGLWindowCB) _set_render_rectangle, render,
- (GDestroyNotify) _free_set_render_rectangle);
-
- return TRUE;
-}
-
-static guintptr
-gst_gl_window_x11_get_window_handle (GstGLWindow * window)
-{
- GstGLWindowX11 *window_x11;
-
- window_x11 = GST_GL_WINDOW_X11 (window);
-
- return window_x11->internal_win_id;
-}
-
-static void
-gst_gl_window_x11_set_preferred_size (GstGLWindow * window, gint width,
- gint height)
-{
- GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window);
-
- window_x11->priv->preferred_width = width;
- window_x11->priv->preferred_height = height;
-}
-
-static void
-_show_window (GstGLWindow * window)
-{
- GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window);
- guint width = window_x11->priv->preferred_width;
- guint height = window_x11->priv->preferred_height;
-
- if (!window_x11->visible) {
- if (!window_x11->parent_win) {
- XResizeWindow (window_x11->device, window_x11->internal_win_id,
- width, height);
- }
-
- XMapWindow (window_x11->device, window_x11->internal_win_id);
- XSync (window_x11->device, FALSE);
- window_x11->visible = TRUE;
- }
-}
-
-static void
-gst_gl_window_x11_show (GstGLWindow * window)
-{
- gst_gl_window_send_message (window, (GstGLWindowCB) _show_window, window);
-}
-
-static void
-_context_draw (GstGLContext * context, GstGLWindow * window)
-{
- window->draw (window->draw_data);
- gst_gl_context_swap_buffers (context);
-
- gst_object_unref (context);
-}
-
-static void
-draw_cb (gpointer data)
-{
- GstGLWindowX11 *window_x11 = data;
- GstGLWindow *window = GST_GL_WINDOW (window_x11);
- guint width, height;
- XWindowAttributes attr;
-
- if (window_x11->internal_win_id) {
- gboolean need_resize = FALSE;
-
- XGetWindowAttributes (window_x11->device, window_x11->internal_win_id,
- &attr);
- GST_TRACE_OBJECT (window, "window size %ux%u", attr.width, attr.height);
-
- if (window_x11->parent_win &&
- (window_x11->priv->render_rect.w < 0 ||
- window_x11->priv->render_rect.h < 0)) {
- XWindowAttributes attr_parent;
- XGetWindowAttributes (window_x11->device, window_x11->parent_win,
- &attr_parent);
- GST_TRACE_OBJECT (window, "parent window size %ux%u", attr_parent.width,
- attr_parent.height);
-
- if (attr.width != attr_parent.width || attr.height != attr_parent.height) {
- XMoveResizeWindow (window_x11->device, window_x11->internal_win_id,
- 0, 0, attr_parent.width, attr_parent.height);
- XSync (window_x11->device, FALSE);
-
- attr.width = attr_parent.width;
- attr.height = attr_parent.height;
-
- GST_LOG ("parent resize: %d, %d",
- attr_parent.width, attr_parent.height);
- need_resize = TRUE;
- }
- }
-
- gst_gl_window_get_surface_dimensions (window, &width, &height);
- if (attr.width != width || attr.height != height)
- need_resize = TRUE;
-
- if (need_resize)
- gst_gl_window_queue_resize (window);
-
- if (window_x11->allow_extra_expose_events) {
- if (window->queue_resize)
- gst_gl_window_resize (window, width, height);
-
- if (window->draw) {
- GstGLContext *context = gst_gl_window_get_context (window);
-
- _context_draw (context, window);
- }
- }
- }
-}
-
-/* Not called by the gl thread */
-static void
-gst_gl_window_x11_draw (GstGLWindow * window)
-{
- gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
-}
-
-static void
-gst_gl_window_x11_handle_events (GstGLWindow * window, gboolean handle_events)
-{
- GstGLWindowX11 *window_x11;
-
- g_return_if_fail (window != NULL);
-
- window_x11 = GST_GL_WINDOW_X11 (window);
-
- window_x11->priv->handle_events = handle_events;
-
- if (window_x11->internal_win_id) {
- if (handle_events) {
- XSelectInput (window_x11->device, window_x11->internal_win_id,
- StructureNotifyMask | ExposureMask | VisibilityChangeMask |
- PointerMotionMask | KeyPressMask | KeyReleaseMask | ButtonPressMask |
- ButtonReleaseMask);
- } else {
- XSelectInput (window_x11->device, window_x11->internal_win_id,
- StructureNotifyMask | ExposureMask | VisibilityChangeMask);
- }
- }
-}
-
-gboolean
-gst_gl_window_x11_handle_event (GstGLWindowX11 * window_x11,
- xcb_generic_event_t * event)
-{
- GstGLWindow *window = GST_GL_WINDOW (window_x11);
- GstGLDisplayX11 *display_x11 = GST_GL_DISPLAY_X11 (window->display);
- xcb_connection_t *connection = display_x11->xcb_connection;
- uint8_t event_code = event->response_type & 0x7f;
-
- switch (event_code) {
- case XCB_CLIENT_MESSAGE:{
- xcb_client_message_event_t *client_event;
- xcb_intern_atom_cookie_t cookie;
- xcb_intern_atom_reply_t *reply;
-
- client_event = (xcb_client_message_event_t *) event;
- cookie = xcb_intern_atom (connection, 0, 16, "WM_DELETE_WINDOW");
- reply = xcb_intern_atom_reply (connection, cookie, 0);
-
- if (client_event->data.data32[0] == reply->atom) {
- GST_INFO_OBJECT (window_x11, "Close requested");
-
- if (window->close)
- window->close (window->close_data);
-
- gst_gl_display_remove_window (GST_GL_DISPLAY (display_x11),
- GST_GL_WINDOW (window_x11));
- }
-
- g_free (reply);
- break;
- }
- case XCB_CONFIGURE_NOTIFY:{
- xcb_configure_notify_event_t *configure_event;
-
- configure_event = (xcb_configure_notify_event_t *) event;
-
- gst_gl_window_resize (window, configure_event->width,
- configure_event->height);
-
- gst_gl_window_draw (window);
- break;
- }
- case XCB_EXPOSE:{
- xcb_expose_event_t *expose_event = (xcb_expose_event_t *) event;
- /* non-zero means that other Expose follows
- * so just wait for the last one
- * in theory we should not receive non-zero because
- * we have no sub areas here but just in case */
- if (expose_event->count != 0)
- break;
-
- gst_gl_window_draw (window);
- break;
- }
- case XCB_KEY_PRESS:
- case XCB_KEY_RELEASE:{
- xcb_key_press_event_t *kp = (xcb_key_press_event_t *) event;
- const gchar *event_type_str;
- gchar *key_str;
- KeySym keysym;
-
- keysym = XkbKeycodeToKeysym (window_x11->device, kp->detail, 0, 0);
- key_str = XKeysymToString (keysym);
-
- if (event_code == XCB_KEY_PRESS)
- event_type_str = "key-press";
- else
- event_type_str = "key-release";
-
- gst_gl_window_send_key_event (window, event_type_str, key_str);
- break;
- }
- case XCB_BUTTON_PRESS:
- case XCB_BUTTON_RELEASE:{
- xcb_button_press_event_t *bp = (xcb_button_press_event_t *) event;
- const gchar *event_type_str;
-
- if (event_code == XCB_BUTTON_PRESS)
- event_type_str = "mouse-button-press";
- else
- event_type_str = "mouse-button-release";
-
- gst_gl_window_send_mouse_event (window, event_type_str, bp->detail,
- (double) bp->event_x, (double) bp->event_y);
- break;
- }
- case XCB_MOTION_NOTIFY:{
- xcb_motion_notify_event_t *motion = (xcb_motion_notify_event_t *) event;
-
- gst_gl_window_send_mouse_event (window, "mouse-move", 0,
- (double) motion->event_x, (double) motion->event_y);
- break;
- }
- default:
- GST_TRACE ("unhandled XCB event: %u", event_code);
- break;
- }
-
- return TRUE;
-}
-
-static int
-error_handler (Display * xdpy, XErrorEvent * error)
-{
- TrappedErrorCode = error->error_code;
- return 0;
-}
-
-/**
- * gst_gl_window_x11_trap_x_errors:
- *
- * Traps every X error until gst_gl_window_x11_untrap_x_errors() is called.
- */
-void
-gst_gl_window_x11_trap_x_errors (void)
-{
- TrappedErrorCode = 0;
- old_error_handler = XSetErrorHandler (error_handler);
-}
-
-/**
- * gst_gl_window_x11_untrap_x_errors:
- *
- * Removes the X error trap and returns the current status.
- *
- * Return value: the trapped error code, or 0 for success
- */
-gint
-gst_gl_window_x11_untrap_x_errors (void)
-{
- XSetErrorHandler (old_error_handler);
-
- return TrappedErrorCode;
-}
-
-static guintptr
-gst_gl_window_x11_get_display (GstGLWindow * window)
-{
- GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window);
-
- return (guintptr) window_x11->device;
-}
diff --git a/gst-libs/gst/gl/x11/gstglwindow_x11.h b/gst-libs/gst/gl/x11/gstglwindow_x11.h
deleted file mode 100644
index ba6fd16bd..000000000
--- a/gst-libs/gst/gl/x11/gstglwindow_x11.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GST_GL_WINDOW_X11_H__
-#define __GST_GL_WINDOW_X11_H__
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#include <gst/video/video.h>
-
-#include <gst/gl/gstgl_fwd.h>
-#include <gst/gl/gstglwindow.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GL_WINDOW_X11 (gst_gl_window_x11_get_type())
-G_GNUC_INTERNAL GType gst_gl_window_x11_get_type (void);
-
-#define GST_GL_WINDOW_X11(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW_X11, GstGLWindowX11))
-#define GST_GL_WINDOW_X11_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_WINDOW_X11, GstGLWindowX11Class))
-#define GST_IS_GL_WINDOW_X11(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW_X11))
-#define GST_IS_GL_WINDOW_X11_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW_X11))
-#define GST_GL_WINDOW_X11_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW_X11, GstGLWindowX11Class))
-
-typedef struct _GstGLWindowX11 GstGLWindowX11;
-typedef struct _GstGLWindowX11Private GstGLWindowX11Private;
-typedef struct _GstGLWindowX11Class GstGLWindowX11Class;
-
-/**
- * GstGLWindowX11:
- *
- * Opaque #GstGLWindowX11 object
- */
-struct _GstGLWindowX11
-{
- /*< private >*/
- GstGLWindow parent;
-
- gboolean running;
- gboolean visible;
- gboolean allow_extra_expose_events;
-
- /* opengl context */
- Display *device;
- Screen *screen;
- gint screen_num;
- Visual *visual;
- Window root;
- gulong white;
- gulong black;
- gint depth;
- gint device_width;
- gint device_height;
- gint connection;
- XVisualInfo *visual_info;
- Window parent_win;
-
- /* X window */
- Window internal_win_id;
-
- GSource *x11_source;
-
- /*< private >*/
- GstGLWindowX11Private *priv;
-
- gpointer _reserved[GST_PADDING];
-};
-
-/**
- * GstGLWindowX11Class:
- *
- * Opaque #GstGLWindowX11Class object
- */
-struct _GstGLWindowX11Class {
- /*< private >*/
- GstGLWindowClass parent_class;
-
- /*< private >*/
- gpointer _reserved[GST_PADDING_LARGE];
-};
-
-G_GNUC_INTERNAL
-GstGLWindowX11 * gst_gl_window_x11_new (GstGLDisplay * display);
-
-G_GNUC_INTERNAL
-void gst_gl_window_x11_trap_x_errors (void);
-
-G_GNUC_INTERNAL
-gint gst_gl_window_x11_untrap_x_errors (void);
-
-G_GNUC_INTERNAL
-gboolean gst_gl_window_x11_create_window (GstGLWindowX11 * window_x11);
-
-G_END_DECLS
-
-#endif /* __GST_GL_WINDOW_X11_H__ */
diff --git a/gst-libs/gst/gl/x11/xcb_event_source.c b/gst-libs/gst/gl/x11/xcb_event_source.c
deleted file mode 100644
index 8dbb15398..000000000
--- a/gst-libs/gst/gl/x11/xcb_event_source.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "xcb_event_source.h"
-#include "gstgldisplay_x11.h"
-#include "gstglwindow_x11.h"
-
-G_GNUC_INTERNAL
- extern gboolean gst_gl_display_x11_handle_event (GstGLDisplayX11 *
- display_x11);
-
-typedef struct _XCBEventSource
-{
- GSource source;
- GPollFD pfd;
- uint32_t mask;
- GstGLDisplayX11 *display_x11;
-} XCBEventSource;
-
-static gboolean
-xcb_event_source_prepare (GSource * base, gint * timeout)
-{
- XCBEventSource *source = (XCBEventSource *) base;
-
- xcb_flush (source->display_x11->xcb_connection);
-
- *timeout = -1;
- return FALSE;
-}
-
-static gboolean
-xcb_event_source_check (GSource * base)
-{
- XCBEventSource *source = (XCBEventSource *) base;
- gboolean retval;
-
- retval = source->pfd.revents;
-
- return retval;
-}
-
-static gboolean
-xcb_event_source_dispatch (GSource * base, GSourceFunc callback, gpointer data)
-{
- XCBEventSource *source = (XCBEventSource *) base;
-
- gboolean ret = gst_gl_display_x11_handle_event (source->display_x11);
-
- source->pfd.revents = 0;
-
- if (callback)
- callback (data);
-
- return ret;
-}
-
-static GSourceFuncs xcb_event_source_funcs = {
- xcb_event_source_prepare,
- xcb_event_source_check,
- xcb_event_source_dispatch,
- NULL
-};
-
-GSource *
-xcb_event_source_new (GstGLDisplayX11 * display_x11)
-{
- xcb_connection_t *connection;
- XCBEventSource *source;
-
- connection = display_x11->xcb_connection;
- g_return_val_if_fail (connection != NULL, NULL);
-
- source = (XCBEventSource *)
- g_source_new (&xcb_event_source_funcs, sizeof (XCBEventSource));
- source->display_x11 = display_x11;
- source->pfd.fd = xcb_get_file_descriptor (connection);
- source->pfd.events = G_IO_IN | G_IO_ERR;
- g_source_add_poll (&source->source, &source->pfd);
-
- return &source->source;
-}
diff --git a/gst-libs/gst/gl/x11/xcb_event_source.h b/gst-libs/gst/gl/x11/xcb_event_source.h
deleted file mode 100644
index ba476352a..000000000
--- a/gst-libs/gst/gl/x11/xcb_event_source.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * GStreamer
- * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __XCB_EVENT_SOURCE_H__
-#define __XCB_EVENT_SOURCE_H__
-
-#include <glib-object.h>
-#include "gstgldisplay_x11.h"
-
-GSource * xcb_event_source_new (GstGLDisplayX11 *display_x11);
-
-#endif /* __XCB_EVENT_SOURCE_H__ */
diff --git a/gst-libs/gst/meson.build b/gst-libs/gst/meson.build
index 63267eaa9..32b812667 100644
--- a/gst-libs/gst/meson.build
+++ b/gst-libs/gst/meson.build
@@ -13,4 +13,3 @@ subdir('opencv')
subdir('player')
subdir('video')
subdir('wayland')
-subdir('gl')