mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 05:46:36 +00:00
gl: remove GStreamer OpenGL integration library and move to -base
https://bugzilla.gnome.org/show_bug.cgi?id=754094
This commit is contained in:
parent
43631c63ea
commit
769a21d0bb
281 changed files with 280 additions and 58532 deletions
|
@ -17,7 +17,7 @@ EXTRA_DIST = \
|
|||
gst-libs/gst/interfaces/build_mkenum.py \
|
||||
gst-libs/gst/mpegts/mpegts_enum.py \
|
||||
ext/srtp/srtp_mkenum.py \
|
||||
ext/vulkan/vkconfig.h.meson gst-libs/gst/gl/gstglconfig.h.meson
|
||||
ext/vulkan/vkconfig.h.meson
|
||||
|
||||
DISTCLEANFILES = _stdint.h
|
||||
|
||||
|
@ -122,8 +122,9 @@ CRUFT_DIRS = \
|
|||
$(top_srcdir)/gst-libs/gst/baseparse \
|
||||
$(top_srcdir)/gst-libs/gst/base \
|
||||
$(top_srcdir)/gst-libs/gst/egl \
|
||||
$(top_srcdir)/gst-libs/gst/gl \
|
||||
$(top_srcdir)/gst-libs/gst/signalprocessor \
|
||||
$(top_srcdir)/tests/examples/gl/gtk/gtkvideooverlay \
|
||||
$(top_srcdir)/tests/examples/gl \
|
||||
$(top_srcdir)/tests/examples/scaletempo \
|
||||
$(top_srcdir)/tests/examples/shapewipe \
|
||||
$(top_srcdir)/tests/examples/switch \
|
||||
|
|
1091
configure.ac
1091
configure.ac
File diff suppressed because it is too large
Load diff
|
@ -40,9 +40,7 @@ IGNORE_HFILES = \
|
|||
$(top_srcdir)/gst-libs/gst/mpegts/gstmpegts-private.h \
|
||||
$(top_srcdir)/gst-libs/gst/player/gstplayer-signal-dispatcher-private.h \
|
||||
$(top_srcdir)/gst-libs/gst/player/gstplayer-video-renderer-private.h \
|
||||
$(top_srcdir)/gst-libs/gst/player/gstplayer-media-info-private.h \
|
||||
$(top_srcdir)/gst-libs/gst/gl/gstglcontext_private.h \
|
||||
$(top_srcdir)/gst-libs/gst/gl/gstglsl_private.h
|
||||
$(top_srcdir)/gst-libs/gst/player/gstplayer-media-info-private.h
|
||||
|
||||
# Images to copy into HTML directory.
|
||||
HTML_IMAGES =
|
||||
|
@ -60,7 +58,6 @@ GTKDOC_LIBS = \
|
|||
$(top_builddir)/gst-libs/gst/audio/libgstbadaudio-@GST_API_VERSION@.la \
|
||||
$(top_builddir)/gst-libs/gst/video/libgstbadvideo-@GST_API_VERSION@.la \
|
||||
$(top_builddir)/gst-libs/gst/codecparsers/libgstcodecparsers-@GST_API_VERSION@.la \
|
||||
$(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \
|
||||
$(top_builddir)/gst-libs/gst/insertbin/libgstinsertbin-@GST_API_VERSION@.la \
|
||||
$(top_builddir)/gst-libs/gst/mpegts/libgstmpegts-@GST_API_VERSION@.la \
|
||||
$(top_builddir)/gst-libs/gst/player/libgstplayer-@GST_API_VERSION@.la \
|
||||
|
|
|
@ -64,64 +64,6 @@
|
|||
<xi:include href="xml/gstvideoaggregatorpad.xml" />
|
||||
</chapter>
|
||||
|
||||
<chapter id="gl">
|
||||
<title>OpenGL Helper Library</title>
|
||||
<para>
|
||||
This library should be linked to by getting cflags and libs from
|
||||
<filename>gstreamer-gl-&GST_API_VERSION;.pc</filename>
|
||||
</para>
|
||||
<xi:include href="xml/gstglapi.xml"/>
|
||||
<xi:include href="xml/gstglbasefilter.xml"/>
|
||||
<xi:include href="xml/gstglbasememory.xml"/>
|
||||
<xi:include href="xml/gstglbuffer.xml"/>
|
||||
<xi:include href="xml/gstglbufferpool.xml"/>
|
||||
<xi:include href="xml/gstglcolorconvert.xml"/>
|
||||
<xi:include href="xml/gstglcontext.xml"/>
|
||||
<!-- Not exposed as public API
|
||||
<xi:include href="xml/gstglcontextcocoa.xml"/>
|
||||
<xi:include href="xml/gstglcontexteagl.xml"/>
|
||||
<xi:include href="xml/gstglcontextegl.xml"/>
|
||||
<xi:include href="xml/gstglcontextglx.xml"/>
|
||||
<xi:include href="xml/gstglcontextwgl.xml"/>
|
||||
-->
|
||||
<xi:include href="xml/gstgldisplay.xml"/>
|
||||
<!-- Not exposed as public API
|
||||
<xi:include href="xml/gstgldisplaycocoa.xml"/>
|
||||
<xi:include href="xml/gstgldisplayegl.xml"/>
|
||||
-->
|
||||
<xi:include href="xml/gstgldisplaywayland.xml"/>
|
||||
<xi:include href="xml/gstgldisplayx11.xml"/>
|
||||
<xi:include href="xml/gsteglimage.xml"/>
|
||||
<xi:include href="xml/gstglfilter.xml"/>
|
||||
<xi:include href="xml/gstglframebuffer.xml"/>
|
||||
<xi:include href="xml/gstglmemory.xml"/>
|
||||
<xi:include href="xml/gstglmemoryegl.xml"/>
|
||||
<xi:include href="xml/gstglmemorypbo.xml"/>
|
||||
<xi:include href="xml/gstgloverlaycompositor.xml"/>
|
||||
<xi:include href="xml/gstglquery.xml"/>
|
||||
<xi:include href="xml/gstglrenderbuffer.xml"/>
|
||||
<xi:include href="xml/gstglshader.xml"/>
|
||||
<xi:include href="xml/gstglsl.xml"/>
|
||||
<xi:include href="xml/gstglslstage.xml"/>
|
||||
<xi:include href="xml/gstglsyncmeta.xml"/>
|
||||
<xi:include href="xml/gstglupload.xml"/>
|
||||
<xi:include href="xml/gstglviewconvert.xml"/>
|
||||
<xi:include href="xml/gstglwindow.xml"/>
|
||||
<!-- Not exposed as public API
|
||||
<xi:include href="xml/gstglwindowandroid.xml"/>
|
||||
<xi:include href="xml/gstglwindowcocoa.xml"/>
|
||||
<xi:include href="xml/gstglwindowdispmanx.xml"/>
|
||||
<xi:include href="xml/gstglwindoweagl.xml"/>
|
||||
<xi:include href="xml/gstglwindowwayland.xml"/>
|
||||
<xi:include href="xml/gstglwindowwin32.xml"/>
|
||||
<xi:include href="xml/gstglwindowx11.xml"/>
|
||||
-->
|
||||
<!-- Some utilities -->
|
||||
<xi:include href="xml/gstgldebug.xml"/>
|
||||
<xi:include href="xml/gstglformat.xml"/>
|
||||
<xi:include href="xml/gstglutils.xml"/>
|
||||
</chapter>
|
||||
|
||||
<chapter id="player">
|
||||
<title>Player Library</title>
|
||||
<xi:include href="xml/gstplayer.xml"/>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,6 @@
|
|||
#include <gst/codecparsers/gstmpegvideoparser.h>
|
||||
#include <gst/insertbin/gstinsertbin.h>
|
||||
#include <gst/mpegts/mpegts.h>
|
||||
#include <gst/gl/gl.h>
|
||||
#include <gst/player/player.h>
|
||||
|
||||
gst_audio_aggregator_get_type
|
||||
|
@ -35,29 +34,6 @@ gst_mpegts_stream_type_get_type
|
|||
gst_insert_bin_get_type
|
||||
|
||||
|
||||
gst_gl_allocation_params_get_type
|
||||
gst_gl_base_memory_allocator_get_type
|
||||
gst_gl_buffer_allocation_params_get_type
|
||||
gst_gl_buffer_allocator_get_type
|
||||
gst_gl_video_allocation_params_get_type
|
||||
gst_gl_memory_allocator_get_type
|
||||
gst_gl_memory_pbo_allocator_get_type
|
||||
gst_gl_renderbuffer_allocation_params_get_type
|
||||
gst_gl_renderbuffer_allocator_get_type
|
||||
gst_gl_base_filter_get_type
|
||||
gst_gl_buffer_pool_get_type
|
||||
gst_gl_color_convert_get_type
|
||||
gst_gl_context_get_type
|
||||
gst_gl_display_get_type
|
||||
gst_gl_filter_get_type
|
||||
gst_gl_framebuffer_get_type
|
||||
gst_gl_shader_get_type
|
||||
gst_glsl_stage_get_type
|
||||
gst_gl_overlay_compositor_get_type
|
||||
gst_gl_upload_get_type
|
||||
gst_gl_view_convert_get_type
|
||||
gst_gl_window_get_type
|
||||
|
||||
gst_player_audio_info_get_type
|
||||
gst_player_color_balance_type_get_type
|
||||
gst_player_error_get_type
|
||||
|
|
|
@ -39,7 +39,7 @@ HFILE_GLOB= \
|
|||
CFILE_GLOB= \
|
||||
$(top_srcdir)/gst/*/*.c $(top_srcdir)/ext/*/*.c $(top_srcdir)/sys/*/*.c \
|
||||
$(top_srcdir)/ext/*/*.cc $(top_srcdir)/ext/*/*.cpp $(top_srcdir)/sys/*/*.cpp \
|
||||
$(top_srcdir)/ext/*/*.m $(top_srcdir)/sys/*/*.m
|
||||
$(top_srcdir)/sys/*/*.m
|
||||
|
||||
# Header files to ignore when scanning.
|
||||
IGNORE_HFILES =
|
||||
|
|
|
@ -57,52 +57,11 @@
|
|||
<xi:include href="xml/element-fisheye.xml" />
|
||||
<xi:include href="xml/element-fpsdisplaysink.xml" />
|
||||
<xi:include href="xml/element-gaussianblur.xml" />
|
||||
<xi:include href="xml/element-glcolorbalance.xml" />
|
||||
<xi:include href="xml/element-glcolorconvert.xml" />
|
||||
<xi:include href="xml/element-glcolorscale.xml" />
|
||||
<xi:include href="xml/element-gldeinterlace.xml" />
|
||||
<xi:include href="xml/element-gldifferencematte.xml" />
|
||||
<xi:include href="xml/element-gldownload.xml" />
|
||||
<xi:include href="xml/element-gleffects_blur.xml" />
|
||||
<xi:include href="xml/element-gleffects_bulge.xml" />
|
||||
<xi:include href="xml/element-gleffects_fisheye.xml" />
|
||||
<xi:include href="xml/element-gleffects_glow.xml" />
|
||||
<xi:include href="xml/element-gleffects_heat.xml" />
|
||||
<xi:include href="xml/element-gleffects_identity.xml" />
|
||||
<xi:include href="xml/element-gleffects_laplacian.xml" />
|
||||
<xi:include href="xml/element-gleffects_lumaxpro.xml" />
|
||||
<xi:include href="xml/element-gleffects_mirror.xml" />
|
||||
<xi:include href="xml/element-gleffects_sepia.xml" />
|
||||
<xi:include href="xml/element-gleffects_sin.xml" />
|
||||
<xi:include href="xml/element-gleffects_sobel.xml" />
|
||||
<xi:include href="xml/element-gleffects_square.xml" />
|
||||
<xi:include href="xml/element-gleffects_squeeze.xml" />
|
||||
<xi:include href="xml/element-gleffects_stretch.xml" />
|
||||
<xi:include href="xml/element-gleffects_tunnel.xml" />
|
||||
<xi:include href="xml/element-gleffects_twirl.xml" />
|
||||
<xi:include href="xml/element-gleffects.xml" />
|
||||
<xi:include href="xml/element-gleffects_xpro.xml" />
|
||||
<xi:include href="xml/element-gleffects_xray.xml" />
|
||||
<xi:include href="xml/element-glfilterapp.xml" />
|
||||
<xi:include href="xml/element-glfilterbin.xml" />
|
||||
<xi:include href="xml/element-glfiltercube.xml" />
|
||||
<xi:include href="xml/element-glfilterglass.xml" />
|
||||
<xi:include href="xml/element-glimagesinkelement.xml" />
|
||||
<xi:include href="xml/element-glimagesink.xml" />
|
||||
<xi:include href="xml/element-glmixerbin.xml" />
|
||||
<xi:include href="xml/element-glmosaic.xml" />
|
||||
<xi:include href="xml/element-gloverlay.xml" />
|
||||
<xi:include href="xml/element-glshader.xml" />
|
||||
<xi:include href="xml/element-glsinkbin.xml" />
|
||||
<xi:include href="xml/element-glsrcbin.xml" />
|
||||
<xi:include href="xml/element-glstereomix.xml" />
|
||||
<xi:include href="xml/element-glstereosplit.xml" />
|
||||
<xi:include href="xml/element-gltestsrc.xml" />
|
||||
<xi:include href="xml/element-gltransformation.xml" />
|
||||
<xi:include href="xml/element-glupload.xml" />
|
||||
<xi:include href="xml/element-glvideomixerelement.xml" />
|
||||
<xi:include href="xml/element-glvideomixer.xml" />
|
||||
<xi:include href="xml/element-glviewconvert.xml" />
|
||||
<xi:include href="xml/element-iqa.xml" />
|
||||
<xi:include href="xml/element-jpegparse.xml" />
|
||||
<xi:include href="xml/element-kaleidoscope.xml" />
|
||||
|
@ -189,7 +148,7 @@
|
|||
<xi:include href="xml/plugin-neon.xml" />
|
||||
<xi:include href="xml/plugin-ofa.xml" />
|
||||
<xi:include href="xml/plugin-openal.xml" />
|
||||
<xi:include href="xml/plugin-opengl.xml" />
|
||||
<xi:include href="xml/plugin-openglmixers.xml" />
|
||||
<xi:include href="xml/plugin-opencv.xml" />
|
||||
<xi:include href="xml/plugin-pcapparse.xml" />
|
||||
<xi:include href="xml/plugin-rawparse.xml" />
|
||||
|
|
|
@ -1439,231 +1439,6 @@ GST_TYPE_GDP_PAY
|
|||
gst_gdp_pay_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glcolorbalance</FILE>
|
||||
<TITLE>glcolorbalance</TITLE>
|
||||
GstGLColorBalance
|
||||
<SUBSECTION Standard>
|
||||
GstGLColorBalanceClass
|
||||
GST_GL_COLOR_BALANCE
|
||||
GST_GL_COLOR_BALANCE_CAST
|
||||
GST_IS_GL_COLOR_BALANCE
|
||||
GST_GL_COLOR_BALANCE_CLASS
|
||||
GST_IS_GL_COLOR_BALANCE_CLASS
|
||||
GST_TYPE_GL_COLOR_BALANCE
|
||||
<SUBSECTION Private>
|
||||
gst_gl_color_balance_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glcolorconvert</FILE>
|
||||
<TITLE>glcolorconvert</TITLE>
|
||||
GstGLColorConvertElement
|
||||
<SUBSECTION Standard>
|
||||
GstGLColorConvertElementClass
|
||||
GST_GL_COLOR_CONVERT_ELEMENT
|
||||
GST_GL_COLOR_CONVERT_ELEMENT_CAST
|
||||
GST_IS_GL_COLOR_CONVERT_ELEMENT
|
||||
GST_GL_COLOR_CONVERT_ELEMENT_CLASS
|
||||
GST_IS_GL_COLOR_CONVERT_ELEMENT_CLASS
|
||||
GST_TYPE_GL_COLOR_CONVERT_ELEMENT
|
||||
<SUBSECTION Private>
|
||||
gst_gl_color_convert_element_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glcolorscale</FILE>
|
||||
<TITLE>glcolorscale</TITLE>
|
||||
GstGLColorscale
|
||||
<SUBSECTION Standard>
|
||||
GstGLColorscaleClass
|
||||
GST_GL_COLORSCALE
|
||||
GST_GL_COLORSCALE_CAST
|
||||
GST_IS_GL_COLORSCALE
|
||||
GST_GL_COLORSCALE_CLASS
|
||||
GST_IS_GL_COLORSCALE_CLASS
|
||||
GST_TYPE_GL_COLORSCALE
|
||||
<SUBSECTION Private>
|
||||
gst_gl_colorscale_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gldeinterlace</FILE>
|
||||
<TITLE>gldeinterlace</TITLE>
|
||||
GstGLDeinterlace
|
||||
GstGLDeinterlaceMethod
|
||||
<SUBSECTION Standard>
|
||||
GstGLDeinterlaceClass
|
||||
GST_GL_DEINTERLACE
|
||||
GST_GL_DEINTERLACE_CAST
|
||||
GST_IS_GL_DEINTERLACE
|
||||
GST_GL_DEINTERLACE_CLASS
|
||||
GST_IS_GL_DEINTERLACE_CLASS
|
||||
GST_TYPE_GL_DEINTERLACE
|
||||
<SUBSECTION Private>
|
||||
gst_gl_deinterlace_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gldifferencematte</FILE>
|
||||
<TITLE>gldifferencematte</TITLE>
|
||||
GstGLDifferenceMatte
|
||||
<SUBSECTION Standard>
|
||||
GstGLDifferenceMatteClass
|
||||
GST_GL_DIFFERENCE_MATTE
|
||||
GST_GL_DIFFERENCE_MATTE_CAST
|
||||
GST_IS_GL_DIFFERENCE_MATTE
|
||||
GST_GL_DIFFERENCE_MATTE_CLASS
|
||||
GST_IS_GL_DIFFERENCE_MATTE_CLASS
|
||||
GST_TYPE_GL_DIFFERENCE_MATTE
|
||||
<SUBSECTION Private>
|
||||
gst_gl_difference_matte_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gldownload</FILE>
|
||||
<TITLE>gldownload</TITLE>
|
||||
GstGLDownloadElement
|
||||
<SUBSECTION Standard>
|
||||
GstGLDownloadElementClass
|
||||
GST_GL_DOWNLOAD_ELEMENT
|
||||
GST_GL_DOWNLOAD_ELEMENT_CAST
|
||||
GST_IS_GL_DOWNLOAD_ELEMENT
|
||||
GST_GL_DOWNLOAD_ELEMENT_CLASS
|
||||
GST_IS_GL_DOWNLOAD_ELEMENT_CLASS
|
||||
GST_TYPE_GL_DOWNLOAD_ELEMENT
|
||||
<SUBSECTION Private>
|
||||
gst_gl_download_element_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects</FILE>
|
||||
<TITLE>gleffects</TITLE>
|
||||
GstGLEffectsGeneric
|
||||
<SUBSECTION Standard>
|
||||
GstGLEffectsGenericClass
|
||||
GST_GL_EFFECTS_GENERIC
|
||||
GST_GL_EFFECTS_GENERIC_CAST
|
||||
GST_IS_GL_EFFECTS_GENERIC
|
||||
GST_GL_EFFECTS_GENERIC_CLASS
|
||||
GST_IS_GL_EFFECTS_GENERIC_CLASS
|
||||
GST_TYPE_GL_EFFECTS_GENERIC
|
||||
<SUBSECTION Private>
|
||||
gst_gl_effects_generic_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glfilterapp</FILE>
|
||||
<TITLE>glfilterapp</TITLE>
|
||||
GstGLFilterApp
|
||||
<SUBSECTION Standard>
|
||||
GstGLFilterAppClass
|
||||
GST_GL_FILTER_APP
|
||||
GST_GL_FILTER_APP_CAST
|
||||
GST_IS_GL_FILTER_APP
|
||||
GST_GL_FILTER_APP_CLASS
|
||||
GST_IS_GL_FILTER_APP_CLASS
|
||||
GST_TYPE_GL_FILTER_APP
|
||||
<SUBSECTION Private>
|
||||
gst_gl_filter_app_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glfilterbin</FILE>
|
||||
<TITLE>glfilterbin</TITLE>
|
||||
GstGLFilterBin
|
||||
<SUBSECTION Standard>
|
||||
GstGLFilterBinClass
|
||||
GST_GL_FILTER_BIN
|
||||
GST_GL_FILTER_BIN_CAST
|
||||
GST_IS_GL_FILTER_BIN
|
||||
GST_GL_FILTER_BIN_CLASS
|
||||
GST_IS_GL_FILTER_BIN_CLASS
|
||||
GST_TYPE_GL_FILTER_BIN
|
||||
<SUBSECTION Private>
|
||||
gst_gl_filter_bin_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glfiltercube</FILE>
|
||||
<TITLE>glfiltercube</TITLE>
|
||||
GstGLFilterCube
|
||||
<SUBSECTION Standard>
|
||||
GstGLFilterCubeClass
|
||||
GST_GL_FILTER_CUBE
|
||||
GST_GL_FILTER_CUBE_CAST
|
||||
GST_IS_GL_FILTER_CUBE
|
||||
GST_GL_FILTER_CUBE_CLASS
|
||||
GST_IS_GL_FILTER_CUBE_CLASS
|
||||
GST_TYPE_GL_FILTER_CUBE
|
||||
<SUBSECTION Private>
|
||||
gst_gl_filter_cube_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glfilterglass</FILE>
|
||||
<TITLE>glfilterglass</TITLE>
|
||||
GstGLFilterGlass
|
||||
<SUBSECTION Standard>
|
||||
GstGLFilterGlassClass
|
||||
GST_GL_FILTER_GLASS
|
||||
GST_GL_FILTER_GLASS_CAST
|
||||
GST_IS_GL_FILTER_GLASS
|
||||
GST_GL_FILTER_GLASS_CLASS
|
||||
GST_IS_GL_FILTER_GLASS_CLASS
|
||||
GST_TYPE_GL_FILTER_GLASS
|
||||
<SUBSECTION Private>
|
||||
gst_gl_filter_glass_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glshader</FILE>
|
||||
<TITLE>glshader</TITLE>
|
||||
GstGLFilterShader
|
||||
<SUBSECTION Standard>
|
||||
GstGLFilterShaderClass
|
||||
GST_GL_FILTER_SHADER
|
||||
GST_GL_FILTER_SHADER_CAST
|
||||
GST_IS_GL_FILTER_SHADER
|
||||
GST_GL_FILTER_SHADER_CLASS
|
||||
GST_IS_GL_FILTER_SHADER_CLASS
|
||||
GST_TYPE_GL_FILTER_SHADER
|
||||
<SUBSECTION Private>
|
||||
gst_gl_filter_shader_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glimagesinkelement</FILE>
|
||||
<TITLE>glimagesinkelement</TITLE>
|
||||
GstGLImageSink
|
||||
<SUBSECTION Standard>
|
||||
GstGLImageSinkClass
|
||||
GST_GL_IMAGE_SINK
|
||||
GST_GL_IMAGE_SINK_CAST
|
||||
GST_IS_GL_IMAGE_SINK
|
||||
GST_GL_IMAGE_SINK_CLASS
|
||||
GST_IS_GL_IMAGE_SINK_CLASS
|
||||
GST_TYPE_GL_IMAGE_SINK
|
||||
<SUBSECTION Private>
|
||||
gst_gl_image_sink_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glimagesink</FILE>
|
||||
<TITLE>glimagesink</TITLE>
|
||||
GstGLImageSinkBin
|
||||
<SUBSECTION Standard>
|
||||
GstGLImageSinkBinClass
|
||||
GST_GL_IMAGE_SINK_BIN
|
||||
GST_GL_IMAGE_SINK_BIN_CAST
|
||||
GST_IS_GL_IMAGE_SINK_BIN
|
||||
GST_GL_IMAGE_SINK_BIN_CLASS
|
||||
GST_IS_GL_IMAGE_SINK_BIN_CLASS
|
||||
GST_TYPE_GL_IMAGE_SINK_BIN
|
||||
<SUBSECTION Private>
|
||||
gst_gl_image_sink_bin_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glmixerbin</FILE>
|
||||
<TITLE>glmixerbin</TITLE>
|
||||
|
@ -1697,54 +1472,6 @@ GST_TYPE_GL_MOSAIC
|
|||
gst_gl_mosaic_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gloverlay</FILE>
|
||||
<TITLE>gloverlay</TITLE>
|
||||
GstGLOverlay
|
||||
<SUBSECTION Standard>
|
||||
GstGLOverlayClass
|
||||
GST_GL_OVERLAY
|
||||
GST_GL_OVERLAY_CAST
|
||||
GST_IS_GL_OVERLAY
|
||||
GST_GL_OVERLAY_CLASS
|
||||
GST_IS_GL_OVERLAY_CLASS
|
||||
GST_TYPE_GL_OVERLAY
|
||||
<SUBSECTION Private>
|
||||
gst_gl_overlay_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glsinkbin</FILE>
|
||||
<TITLE>glsinkbin</TITLE>
|
||||
GstGLSinkBin
|
||||
<SUBSECTION Standard>
|
||||
GstGLSinkBinClass
|
||||
GST_GL_SINK_BIN
|
||||
GST_GL_SINK_BIN_CAST
|
||||
GST_IS_GL_SINK_BIN
|
||||
GST_GL_SINK_BIN_CLASS
|
||||
GST_IS_GL_SINK_BIN_CLASS
|
||||
GST_TYPE_GL_SINK_BIN
|
||||
<SUBSECTION Private>
|
||||
gst_gl_sink_bin_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glsrcbin</FILE>
|
||||
<TITLE>glsrcbin</TITLE>
|
||||
GstGLSrcBin
|
||||
<SUBSECTION Standard>
|
||||
GstGLSrcBinClass
|
||||
GST_GL_SRC_BIN
|
||||
GST_GL_SRC_BIN_CAST
|
||||
GST_IS_GL_SRC_BIN
|
||||
GST_GL_SRC_BIN_CLASS
|
||||
GST_IS_GL_SRC_BIN_CLASS
|
||||
GST_TYPE_GL_SRC_BIN
|
||||
<SUBSECTION Private>
|
||||
gst_gl_src_bin_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glstereomix</FILE>
|
||||
<TITLE>glstereomix</TITLE>
|
||||
|
@ -1761,68 +1488,6 @@ GST_TYPE_GL_STEREO_MIX
|
|||
gst_gl_stereo_mix_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glstereosplit</FILE>
|
||||
<TITLE>glstereosplit</TITLE>
|
||||
GstGLStereoSplit
|
||||
<SUBSECTION Standard>
|
||||
GstGLStereoSplitClass
|
||||
GST_GL_STEREO_SPLIT
|
||||
GST_GL_STEREO_SPLIT_CAST
|
||||
GST_IS_GL_STEREO_SPLIT
|
||||
GST_GL_STEREO_SPLIT_CLASS
|
||||
GST_IS_GL_STEREO_SPLIT_CLASS
|
||||
GST_TYPE_GL_STEREO_SPLIT
|
||||
<SUBSECTION Private>
|
||||
gst_gl_stereo_split_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gltestsrc</FILE>
|
||||
<TITLE>gltestsrc</TITLE>
|
||||
GstGLTestSrc
|
||||
GstGLTestSrcPattern
|
||||
<SUBSECTION Standard>
|
||||
GstGLTestSrcClass
|
||||
GST_GL_TEST_SRC
|
||||
GST_GL_TEST_SRC_CAST
|
||||
GST_IS_GL_TEST_SRC
|
||||
GST_GL_TEST_SRC_CLASS
|
||||
GST_IS_GL_TEST_SRC_CLASS
|
||||
GST_TYPE_GL_TEST_SRC
|
||||
<SUBSECTION Private>
|
||||
gst_gl_test_src_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gltransformation</FILE>
|
||||
<TITLE>gltransformation</TITLE>
|
||||
GstGLTransformation
|
||||
<SUBSECTION Standard>
|
||||
GstGLTransformationClass
|
||||
GST_GL_TRANSFORMATION
|
||||
GST_GL_TRANSFORMATION_CLASS
|
||||
GST_IS_GL_TRANSFORMATION
|
||||
GST_IS_GL_TRANSFORMATION_CLASS
|
||||
GST_TYPE_GL_TRANSFORMATION
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glupload</FILE>
|
||||
<TITLE>glupload</TITLE>
|
||||
GstGLUploadElement
|
||||
<SUBSECTION Standard>
|
||||
GstGLUploadElementClass
|
||||
GST_GL_UPLOAD_ELEMENT
|
||||
GST_GL_UPLOAD_ELEMENT_CAST
|
||||
GST_IS_GL_UPLOAD_ELEMENT
|
||||
GST_GL_UPLOAD_ELEMENT_CLASS
|
||||
GST_IS_GL_UPLOAD_ELEMENT_CLASS
|
||||
GST_TYPE_GL_UPLOAD_ELEMENT
|
||||
<SUBSECTION Private>
|
||||
gst_gl_upload_element_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glvideomixerelement</FILE>
|
||||
<TITLE>glvideomixerelement</TITLE>
|
||||
|
@ -1856,22 +1521,6 @@ GST_TYPE_GL_VIDEO_MIXER_BIN
|
|||
gst_gl_video_mixer_bin_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-glviewconvert</FILE>
|
||||
<TITLE>glviewconvert</TITLE>
|
||||
GstGLViewConvertElement
|
||||
<SUBSECTION Standard>
|
||||
GstGLViewConvertElementClass
|
||||
GST_GL_VIEW_CONVERT_ELEMENT
|
||||
GST_GL_VIEW_CONVERT_ELEMENT_CAST
|
||||
GST_IS_GL_VIEW_CONVERT_ELEMENT
|
||||
GST_GL_VIEW_CONVERT_ELEMENT_CLASS
|
||||
GST_IS_GL_VIEW_CONVERT_ELEMENT_CLASS
|
||||
GST_TYPE_GL_VIEW_CONVERT_ELEMENT
|
||||
<SUBSECTION Private>
|
||||
gst_gl_view_convert_element_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gsmdec</FILE>
|
||||
<TITLE>gsmdec</TITLE>
|
||||
|
@ -4397,310 +4046,6 @@ GST_TYPE_DVD_BIN
|
|||
gst_dvd_bin_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_blur</FILE>
|
||||
<TITLE>gleffects_blur</TITLE>
|
||||
Gstffects_blur
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_blurClass
|
||||
GST_FFECTS_BLUR
|
||||
GST_FFECTS_BLUR_CAST
|
||||
GST_IS_FFECTS_BLUR
|
||||
GST_FFECTS_BLUR_CLASS
|
||||
GST_IS_FFECTS_BLUR_CLASS
|
||||
GST_TYPE_FFECTS_BLUR
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_blur_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_bulge</FILE>
|
||||
<TITLE>gleffects_bulge</TITLE>
|
||||
Gstffects_bulge
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_bulgeClass
|
||||
GST_FFECTS_BULGE
|
||||
GST_FFECTS_BULGE_CAST
|
||||
GST_IS_FFECTS_BULGE
|
||||
GST_FFECTS_BULGE_CLASS
|
||||
GST_IS_FFECTS_BULGE_CLASS
|
||||
GST_TYPE_FFECTS_BULGE
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_bulge_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_fisheye</FILE>
|
||||
<TITLE>gleffects_fisheye</TITLE>
|
||||
Gstffects_fisheye
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_fisheyeClass
|
||||
GST_FFECTS_FISHEYE
|
||||
GST_FFECTS_FISHEYE_CAST
|
||||
GST_IS_FFECTS_FISHEYE
|
||||
GST_FFECTS_FISHEYE_CLASS
|
||||
GST_IS_FFECTS_FISHEYE_CLASS
|
||||
GST_TYPE_FFECTS_FISHEYE
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_fisheye_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_glow</FILE>
|
||||
<TITLE>gleffects_glow</TITLE>
|
||||
Gstffects_glow
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_glowClass
|
||||
GST_FFECTS_GLOW
|
||||
GST_FFECTS_GLOW_CAST
|
||||
GST_IS_FFECTS_GLOW
|
||||
GST_FFECTS_GLOW_CLASS
|
||||
GST_IS_FFECTS_GLOW_CLASS
|
||||
GST_TYPE_FFECTS_GLOW
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_glow_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_heat</FILE>
|
||||
<TITLE>gleffects_heat</TITLE>
|
||||
Gstffects_heat
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_heatClass
|
||||
GST_FFECTS_HEAT
|
||||
GST_FFECTS_HEAT_CAST
|
||||
GST_IS_FFECTS_HEAT
|
||||
GST_FFECTS_HEAT_CLASS
|
||||
GST_IS_FFECTS_HEAT_CLASS
|
||||
GST_TYPE_FFECTS_HEAT
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_heat_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_identity</FILE>
|
||||
<TITLE>gleffects_identity</TITLE>
|
||||
Gstffects_identity
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_identityClass
|
||||
GST_FFECTS_IDENTITY
|
||||
GST_FFECTS_IDENTITY_CAST
|
||||
GST_IS_FFECTS_IDENTITY
|
||||
GST_FFECTS_IDENTITY_CLASS
|
||||
GST_IS_FFECTS_IDENTITY_CLASS
|
||||
GST_TYPE_FFECTS_IDENTITY
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_identity_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_laplacian</FILE>
|
||||
<TITLE>gleffects_laplacian</TITLE>
|
||||
Gstffects_laplacian
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_laplacianClass
|
||||
GST_FFECTS_LAPLACIAN
|
||||
GST_FFECTS_LAPLACIAN_CAST
|
||||
GST_IS_FFECTS_LAPLACIAN
|
||||
GST_FFECTS_LAPLACIAN_CLASS
|
||||
GST_IS_FFECTS_LAPLACIAN_CLASS
|
||||
GST_TYPE_FFECTS_LAPLACIAN
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_laplacian_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_lumaxpro</FILE>
|
||||
<TITLE>gleffects_lumaxpro</TITLE>
|
||||
Gstffects_lumaxpro
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_lumaxproClass
|
||||
GST_FFECTS_LUMAXPRO
|
||||
GST_FFECTS_LUMAXPRO_CAST
|
||||
GST_IS_FFECTS_LUMAXPRO
|
||||
GST_FFECTS_LUMAXPRO_CLASS
|
||||
GST_IS_FFECTS_LUMAXPRO_CLASS
|
||||
GST_TYPE_FFECTS_LUMAXPRO
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_lumaxpro_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_mirror</FILE>
|
||||
<TITLE>gleffects_mirror</TITLE>
|
||||
Gstffects_mirror
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_mirrorClass
|
||||
GST_FFECTS_MIRROR
|
||||
GST_FFECTS_MIRROR_CAST
|
||||
GST_IS_FFECTS_MIRROR
|
||||
GST_FFECTS_MIRROR_CLASS
|
||||
GST_IS_FFECTS_MIRROR_CLASS
|
||||
GST_TYPE_FFECTS_MIRROR
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_mirror_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_sepia</FILE>
|
||||
<TITLE>gleffects_sepia</TITLE>
|
||||
Gstffects_sepia
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_sepiaClass
|
||||
GST_FFECTS_SEPIA
|
||||
GST_FFECTS_SEPIA_CAST
|
||||
GST_IS_FFECTS_SEPIA
|
||||
GST_FFECTS_SEPIA_CLASS
|
||||
GST_IS_FFECTS_SEPIA_CLASS
|
||||
GST_TYPE_FFECTS_SEPIA
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_sepia_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_sin</FILE>
|
||||
<TITLE>gleffects_sin</TITLE>
|
||||
Gstffects_sin
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_sinClass
|
||||
GST_FFECTS_SIN
|
||||
GST_FFECTS_SIN_CAST
|
||||
GST_IS_FFECTS_SIN
|
||||
GST_FFECTS_SIN_CLASS
|
||||
GST_IS_FFECTS_SIN_CLASS
|
||||
GST_TYPE_FFECTS_SIN
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_sin_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_sobel</FILE>
|
||||
<TITLE>gleffects_sobel</TITLE>
|
||||
Gstffects_sobel
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_sobelClass
|
||||
GST_FFECTS_SOBEL
|
||||
GST_FFECTS_SOBEL_CAST
|
||||
GST_IS_FFECTS_SOBEL
|
||||
GST_FFECTS_SOBEL_CLASS
|
||||
GST_IS_FFECTS_SOBEL_CLASS
|
||||
GST_TYPE_FFECTS_SOBEL
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_sobel_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_square</FILE>
|
||||
<TITLE>gleffects_square</TITLE>
|
||||
Gstffects_square
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_squareClass
|
||||
GST_FFECTS_SQUARE
|
||||
GST_FFECTS_SQUARE_CAST
|
||||
GST_IS_FFECTS_SQUARE
|
||||
GST_FFECTS_SQUARE_CLASS
|
||||
GST_IS_FFECTS_SQUARE_CLASS
|
||||
GST_TYPE_FFECTS_SQUARE
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_square_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_squeeze</FILE>
|
||||
<TITLE>gleffects_squeeze</TITLE>
|
||||
Gstffects_squeeze
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_squeezeClass
|
||||
GST_FFECTS_SQUEEZE
|
||||
GST_FFECTS_SQUEEZE_CAST
|
||||
GST_IS_FFECTS_SQUEEZE
|
||||
GST_FFECTS_SQUEEZE_CLASS
|
||||
GST_IS_FFECTS_SQUEEZE_CLASS
|
||||
GST_TYPE_FFECTS_SQUEEZE
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_squeeze_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_stretch</FILE>
|
||||
<TITLE>gleffects_stretch</TITLE>
|
||||
Gstffects_stretch
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_stretchClass
|
||||
GST_FFECTS_STRETCH
|
||||
GST_FFECTS_STRETCH_CAST
|
||||
GST_IS_FFECTS_STRETCH
|
||||
GST_FFECTS_STRETCH_CLASS
|
||||
GST_IS_FFECTS_STRETCH_CLASS
|
||||
GST_TYPE_FFECTS_STRETCH
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_stretch_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_tunnel</FILE>
|
||||
<TITLE>gleffects_tunnel</TITLE>
|
||||
Gstffects_tunnel
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_tunnelClass
|
||||
GST_FFECTS_TUNNEL
|
||||
GST_FFECTS_TUNNEL_CAST
|
||||
GST_IS_FFECTS_TUNNEL
|
||||
GST_FFECTS_TUNNEL_CLASS
|
||||
GST_IS_FFECTS_TUNNEL_CLASS
|
||||
GST_TYPE_FFECTS_TUNNEL
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_tunnel_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_twirl</FILE>
|
||||
<TITLE>gleffects_twirl</TITLE>
|
||||
Gstffects_twirl
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_twirlClass
|
||||
GST_FFECTS_TWIRL
|
||||
GST_FFECTS_TWIRL_CAST
|
||||
GST_IS_FFECTS_TWIRL
|
||||
GST_FFECTS_TWIRL_CLASS
|
||||
GST_IS_FFECTS_TWIRL_CLASS
|
||||
GST_TYPE_FFECTS_TWIRL
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_twirl_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_xpro</FILE>
|
||||
<TITLE>gleffects_xpro</TITLE>
|
||||
Gstffects_xpro
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_xproClass
|
||||
GST_FFECTS_XPRO
|
||||
GST_FFECTS_XPRO_CAST
|
||||
GST_IS_FFECTS_XPRO
|
||||
GST_FFECTS_XPRO_CLASS
|
||||
GST_IS_FFECTS_XPRO_CLASS
|
||||
GST_TYPE_FFECTS_XPRO
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_xpro_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-gleffects_xray</FILE>
|
||||
<TITLE>gleffects_xray</TITLE>
|
||||
Gstffects_xray
|
||||
<SUBSECTION Standard>
|
||||
Gstffects_xrayClass
|
||||
GST_FFECTS_XRAY
|
||||
GST_FFECTS_XRAY_CAST
|
||||
GST_IS_FFECTS_XRAY
|
||||
GST_FFECTS_XRAY_CLASS
|
||||
GST_IS_FFECTS_XRAY_CLASS
|
||||
GST_TYPE_FFECTS_XRAY
|
||||
<SUBSECTION Private>
|
||||
gst_ffects_xray_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>element-ttmlparse</FILE>
|
||||
<TITLE>ttmlparse</TITLE>
|
||||
|
|
|
@ -47223,9 +47223,9 @@
|
|||
<TYPE>gint</TYPE>
|
||||
<RANGE>>= 0</RANGE>
|
||||
<FLAGS>rw</FLAGS>
|
||||
<NICK>height (kernel height)</NICK>
|
||||
<BLURB>The gaussian kernel height (must be positive and odd).</BLURB>
|
||||
<DEFAULT>3</DEFAULT>
|
||||
<NICK>height of area to blur</NICK>
|
||||
<BLURB>Height of the area to blur (in pixels).</BLURB>
|
||||
<DEFAULT>2147483647</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
|
@ -47241,13 +47241,53 @@
|
|||
<ARG>
|
||||
<NAME>GstCvSmooth::width</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
<RANGE>>= 0</RANGE>
|
||||
<FLAGS>rw</FLAGS>
|
||||
<NICK>width of area to blur</NICK>
|
||||
<BLURB>Width of the area to blur (in pixels).</BLURB>
|
||||
<DEFAULT>2147483647</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstCvSmooth::kernel-height</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
<RANGE>>= 0</RANGE>
|
||||
<FLAGS>rw</FLAGS>
|
||||
<NICK>kernel height</NICK>
|
||||
<BLURB>The gaussian kernel height (must be positive and odd).</BLURB>
|
||||
<DEFAULT>3</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstCvSmooth::kernel-width</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
<RANGE>>= 1</RANGE>
|
||||
<FLAGS>rw</FLAGS>
|
||||
<NICK>width (kernel width)</NICK>
|
||||
<NICK>kernel width</NICK>
|
||||
<BLURB>The gaussian kernel width (must be positive and odd).If type is median, this means the aperture linear size.Check OpenCV docs: http://docs.opencv.org/2.4/modules/imgproc/doc/filtering.htm.</BLURB>
|
||||
<DEFAULT>3</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstCvSmooth::position-x</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
<RANGE>>= 0</RANGE>
|
||||
<FLAGS>rw</FLAGS>
|
||||
<NICK>starting x position for blur</NICK>
|
||||
<BLURB>Starting x position for blur (in pixels).</BLURB>
|
||||
<DEFAULT>0</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstCvSmooth::position-y</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
<RANGE>>= 0</RANGE>
|
||||
<FLAGS>rw</FLAGS>
|
||||
<NICK>starting y position for blur</NICK>
|
||||
<BLURB>Starting y position for blur (in pixels).</BLURB>
|
||||
<DEFAULT>0</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstCvLaplace::aperture-size</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
|
@ -67910,6 +67950,16 @@ Gestures in the defined region of interest will emit messages.</BLURB>
|
|||
<DEFAULT>FALSE</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstDecklinkVideoSrc::hw-serial-number</NAME>
|
||||
<TYPE>gchar*</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>r</FLAGS>
|
||||
<NICK>Hardware serial number</NICK>
|
||||
<BLURB>The serial number (hardware ID) of the Decklink card.</BLURB>
|
||||
<DEFAULT>NULL</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstDecklinkVideoSink::device-number</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
|
@ -67950,6 +68000,36 @@ Gestures in the defined region of interest will emit messages.</BLURB>
|
|||
<DEFAULT>bmdTimecodeRP188Any</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstDecklinkVideoSink::hw-serial-number</NAME>
|
||||
<TYPE>gchar*</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>r</FLAGS>
|
||||
<NICK>Hardware serial number</NICK>
|
||||
<BLURB>The serial number (hardware ID) of the Decklink card.</BLURB>
|
||||
<DEFAULT>NULL</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstDecklinkVideoSink::keyer-level</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
<RANGE>[0,255]</RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>Keyer level</NICK>
|
||||
<BLURB>Keyer level.</BLURB>
|
||||
<DEFAULT>255</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstDecklinkVideoSink::keyer-mode</NAME>
|
||||
<TYPE>GstDecklinkKeyerMode</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>Keyer mode</NICK>
|
||||
<BLURB>Keyer mode to be enabled.</BLURB>
|
||||
<DEFAULT>Off</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstDecklinkAudioSrc::alignment-threshold</NAME>
|
||||
<TYPE>guint64</TYPE>
|
||||
|
@ -68010,6 +68090,16 @@ Gestures in the defined region of interest will emit messages.</BLURB>
|
|||
<DEFAULT>2 Channels</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstDecklinkAudioSrc::hw-serial-number</NAME>
|
||||
<TYPE>gchar*</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>r</FLAGS>
|
||||
<NICK>Hardware serial number</NICK>
|
||||
<BLURB>The serial number (hardware ID) of the Decklink card.</BLURB>
|
||||
<DEFAULT>NULL</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstDecklinkAudioSink::device-number</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
|
@ -68020,6 +68110,16 @@ Gestures in the defined region of interest will emit messages.</BLURB>
|
|||
<DEFAULT>0</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstDecklinkAudioSink::hw-serial-number</NAME>
|
||||
<TYPE>gchar*</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>r</FLAGS>
|
||||
<NICK>Hardware serial number</NICK>
|
||||
<BLURB>The serial number (hardware ID) of the Decklink card.</BLURB>
|
||||
<DEFAULT>NULL</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstOpenh264Enc::adaptive-quantization</NAME>
|
||||
<TYPE>gboolean</TYPE>
|
||||
|
@ -69446,7 +69546,7 @@ Gestures in the defined region of interest will emit messages.</BLURB>
|
|||
<RANGE></RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>Maximum delay (ms)</NICK>
|
||||
<BLURB>The maximum delay in ms to apply to buffers.</BLURB>
|
||||
<BLURB>The maximum delay (inclusive) in ms to apply to buffers.</BLURB>
|
||||
<DEFAULT>400</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
|
@ -69460,6 +69560,46 @@ Gestures in the defined region of interest will emit messages.</BLURB>
|
|||
<DEFAULT>200</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstNetSim::allow-reordering</NAME>
|
||||
<TYPE>gboolean</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>Allow Reordering</NICK>
|
||||
<BLURB>When delaying packets, are they allowed to be reordered or not.</BLURB>
|
||||
<DEFAULT>TRUE</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstNetSim::delay-distribution</NAME>
|
||||
<TYPE>GstNetSimDistribution</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>Delay Distribution</NICK>
|
||||
<BLURB>Distribution for the amount of delay.</BLURB>
|
||||
<DEFAULT>uniform</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstNetSim::max-bucket-size</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
<RANGE>>= G_MAXULONG</RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>Maximum Bucket Size (Kb)</NICK>
|
||||
<BLURB>The size of the token bucket, related to burstiness resilience (-1 = unlimited).</BLURB>
|
||||
<DEFAULT>-1</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstNetSim::max-kbps</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
<RANGE>>= G_MAXULONG</RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>Maximum Kbps</NICK>
|
||||
<BLURB>The maximum number of kilobits to let through per second (-1 = unlimited).</BLURB>
|
||||
<DEFAULT>-1</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstGDPDepay::ts-offset</NAME>
|
||||
<TYPE>gint64</TYPE>
|
||||
|
@ -72220,6 +72360,46 @@ Gestures in the defined region of interest will emit messages.</BLURB>
|
|||
<DEFAULT>FALSE</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstKMSSink::bus-id</NAME>
|
||||
<TYPE>gchar*</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>Bus ID</NICK>
|
||||
<BLURB>DRM bus ID.</BLURB>
|
||||
<DEFAULT>NULL</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstKMSSink::can-scale</NAME>
|
||||
<TYPE>gboolean</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>can scale</NICK>
|
||||
<BLURB>User can tell kmssink if the driver can support scale.</BLURB>
|
||||
<DEFAULT>TRUE</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstKMSSink::display-height</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
<RANGE>>= 0</RANGE>
|
||||
<FLAGS>r</FLAGS>
|
||||
<NICK>Display Height</NICK>
|
||||
<BLURB>Height of the display surface in pixels.</BLURB>
|
||||
<DEFAULT>0</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstKMSSink::display-width</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
<RANGE>>= 0</RANGE>
|
||||
<FLAGS>r</FLAGS>
|
||||
<NICK>Display Width</NICK>
|
||||
<BLURB>Width of the display surface in pixels.</BLURB>
|
||||
<DEFAULT>0</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstBs2b::fcut</NAME>
|
||||
<TYPE>gint</TYPE>
|
||||
|
@ -72880,6 +73060,16 @@ Gestures in the defined region of interest will emit messages.</BLURB>
|
|||
<DEFAULT>"00:00:00:00"</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstAvWait::end-timecode</NAME>
|
||||
<TYPE>GstVideoTimeCode*</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rw</FLAGS>
|
||||
<NICK>End timecode (object)</NICK>
|
||||
<BLURB>Timecode to end at in timecode mode (object).</BLURB>
|
||||
<DEFAULT></DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstDewarp::display-mode</NAME>
|
||||
<TYPE>GstDewarpDisplayMode</TYPE>
|
||||
|
@ -73102,12 +73292,12 @@ Gestures in the defined region of interest will emit messages.</BLURB>
|
|||
|
||||
<ARG>
|
||||
<NAME>GstCurlHttpSrc::http-version</NAME>
|
||||
<TYPE>gfloat</TYPE>
|
||||
<RANGE>[1,2]</RANGE>
|
||||
<TYPE>GstCurlHttpVersionType</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rw</FLAGS>
|
||||
<NICK>HTTP-Version</NICK>
|
||||
<BLURB>The preferred HTTP protocol version (Supported 1.0, 1.1, 2.0).</BLURB>
|
||||
<DEFAULT>2</DEFAULT>
|
||||
<BLURB>The preferred HTTP protocol version.</BLURB>
|
||||
<DEFAULT>HTTP Version 2.0</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
|
@ -73257,7 +73447,7 @@ Gestures in the defined region of interest will emit messages.</BLURB>
|
|||
<FLAGS>rw</FLAGS>
|
||||
<NICK>User-Agent</NICK>
|
||||
<BLURB>URI of resource requested.</BLURB>
|
||||
<DEFAULT>"GStreamer curlhttpsrc libcurl/7.52.1"</DEFAULT>
|
||||
<DEFAULT>"GStreamer curlhttpsrc libcurl/7.56.1"</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
|
@ -73380,3 +73570,62 @@ Gestures in the defined region of interest will emit messages.</BLURB>
|
|||
<DEFAULT>15</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstLcms::dest-profile</NAME>
|
||||
<TYPE>gchar*</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rw</FLAGS>
|
||||
<NICK>Destination ICC profile file</NICK>
|
||||
<BLURB>Specify the destination ICC profile file to apply.</BLURB>
|
||||
<DEFAULT>NULL</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstLcms::embedded-profile</NAME>
|
||||
<TYPE>gboolean</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>Embedded Profile</NICK>
|
||||
<BLURB>Extract and use source profiles embedded in images.</BLURB>
|
||||
<DEFAULT>TRUE</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstLcms::input-profile</NAME>
|
||||
<TYPE>gchar*</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rw</FLAGS>
|
||||
<NICK>Input ICC profile file</NICK>
|
||||
<BLURB>Specify the input ICC profile file to apply.</BLURB>
|
||||
<DEFAULT>NULL</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstLcms::intent</NAME>
|
||||
<TYPE>GstLcmsIntent</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>Rendering intent</NICK>
|
||||
<BLURB>Select the rendering intent of the color correction.</BLURB>
|
||||
<DEFAULT>Perceptual</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstLcms::lookup</NAME>
|
||||
<TYPE>GstLcmsLookupMethod</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>Lookup method</NICK>
|
||||
<BLURB>Select the caching method for the color compensation calculations.</BLURB>
|
||||
<DEFAULT>Calculate and cache color replacement values on first occurence</DEFAULT>
|
||||
</ARG>
|
||||
|
||||
<ARG>
|
||||
<NAME>GstLcms::preserve-black</NAME>
|
||||
<TYPE>gboolean</TYPE>
|
||||
<RANGE></RANGE>
|
||||
<FLAGS>rwx</FLAGS>
|
||||
<NICK>Preserve black</NICK>
|
||||
<BLURB>Select whether purely black pixels should be preserved.</BLURB>
|
||||
<DEFAULT>FALSE</DEFAULT>
|
||||
</ARG>
|
||||
|
|
|
@ -95,13 +95,10 @@ GObject
|
|||
GstVideoSink
|
||||
GstDfbVideoSink
|
||||
GstFBDEVSink
|
||||
GstGLImageSink
|
||||
GstGtkBaseSink
|
||||
GstGtkGLSink
|
||||
GstGtkSink
|
||||
GstInterVideoSink
|
||||
GstKMSSink
|
||||
GstQtSink
|
||||
GstVulkanSink
|
||||
GstWaylandSink
|
||||
GstBaseSrc
|
||||
|
@ -122,10 +119,8 @@ GObject
|
|||
GstDecklinkAudioSrc
|
||||
GstDecklinkVideoSrc
|
||||
GstDvbSrc
|
||||
GstGLTestSrc
|
||||
GstMMS
|
||||
GstNeonhttpSrc
|
||||
GstQtSrc
|
||||
GstRTMPSrc
|
||||
GstRfbSrc
|
||||
GstShmSrc
|
||||
|
@ -153,42 +148,6 @@ GObject
|
|||
GstDebugSpy
|
||||
GstDtmfDetect
|
||||
GstFreeverb
|
||||
GstGLBaseFilter
|
||||
GstGLColorConvertElement
|
||||
GstGLDownloadElement
|
||||
GstGLFilter
|
||||
GstGLColorBalance
|
||||
GstGLColorscale
|
||||
GstGLDeinterlace
|
||||
GstGLDifferenceMatte
|
||||
GstGLEffects
|
||||
GstGLEffectsGeneric
|
||||
gleffects_blur
|
||||
gleffects_bulge
|
||||
gleffects_fisheye
|
||||
gleffects_glow
|
||||
gleffects_heat
|
||||
gleffects_identity
|
||||
gleffects_laplacian
|
||||
gleffects_lumaxpro
|
||||
gleffects_mirror
|
||||
gleffects_sepia
|
||||
gleffects_sin
|
||||
gleffects_sobel
|
||||
gleffects_square
|
||||
gleffects_squeeze
|
||||
gleffects_stretch
|
||||
gleffects_tunnel
|
||||
gleffects_twirl
|
||||
gleffects_xpro
|
||||
gleffects_xray
|
||||
GstGLFilterApp
|
||||
GstGLFilterCube
|
||||
GstGLFilterGlass
|
||||
GstGLFilterShader
|
||||
GstGLOverlay
|
||||
GstGLViewConvertElement
|
||||
GstGLUploadElement
|
||||
GstIvtc
|
||||
GstRGB2Bayer
|
||||
GstRemoveSilence
|
||||
|
@ -221,6 +180,7 @@ GObject
|
|||
GstPerspective
|
||||
GstRotate
|
||||
GstSquare
|
||||
GstLcms
|
||||
GstOpencvVideoFilter
|
||||
GstCvDilateErode
|
||||
GstCvDilate
|
||||
|
@ -271,12 +231,8 @@ GObject
|
|||
GstDtlsSrtpEnc
|
||||
GstFPSDisplaySink
|
||||
GstFaceOverlay
|
||||
GstGLFilterBin
|
||||
GstGLMixerBin
|
||||
GstGLVideoMixerBin
|
||||
GstGLSinkBin
|
||||
GstGLImageSinkBin
|
||||
GstGLSrcBin
|
||||
GstHlsSink
|
||||
GstHlsSink2
|
||||
GstPipeline
|
||||
|
@ -303,7 +259,6 @@ GObject
|
|||
GstFluidDec
|
||||
GstGDPDepay
|
||||
GstGDPPay
|
||||
GstGLStereoSplit
|
||||
GstGmeDec
|
||||
GstInterlace
|
||||
GstIpcPipelineSink
|
||||
|
@ -343,6 +298,7 @@ GObject
|
|||
GstTtmlRender
|
||||
GstUvcH264MjpgDemux
|
||||
GstVideoDecoder
|
||||
GstLibde265Dec
|
||||
GstOpenEXRDec
|
||||
GstOpenJPEGDec
|
||||
GstOpenh264Dec
|
||||
|
@ -369,7 +325,6 @@ GObject
|
|||
MpegTSParse2
|
||||
MpegTsMux
|
||||
GstGLContext
|
||||
GstGLShader
|
||||
GstPad
|
||||
GstAggregatorPad
|
||||
GstAudioAggregatorPad
|
||||
|
|
|
@ -82,8 +82,9 @@ else
|
|||
DTS_DIR=
|
||||
endif
|
||||
|
||||
# FIXME: re-enable for gl mixers
|
||||
if USE_GL
|
||||
GL_DIR=gl
|
||||
#GL_DIR=gl
|
||||
else
|
||||
GL_DIR=
|
||||
endif
|
||||
|
|
|
@ -15,7 +15,7 @@ subdir('faad')
|
|||
subdir('fdkaac')
|
||||
subdir('flite')
|
||||
subdir('fluidsynth')
|
||||
subdir('gl')
|
||||
#subdir('gl') # FIXME: re-enable for gl mixers
|
||||
#subdir('gme')
|
||||
subdir('gsm')
|
||||
subdir('gtk')
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
2
gst-libs/gst/gl/.gitignore
vendored
2
gst-libs/gst/gl/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
gstglconfig.h
|
||||
stamp-gc-h
|
|
@ -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
|
|
@ -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)
|
|
@ -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;
|
||||
}
|
|
@ -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__ */
|
|
@ -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
|
|
@ -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__ */
|
|
@ -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__ */
|
|
@ -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
|
|
@ -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__ */
|
|
@ -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 ();
|
||||
}
|
|
@ -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__ */
|
|
@ -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;
|
||||
}
|
|
@ -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__ */
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -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)
|
|
@ -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;
|
||||
}
|
|
@ -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__ */
|
|
@ -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
|
|
@ -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__ */
|
|
@ -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];
|
||||
}
|
|
@ -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__ */
|
|
@ -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);
|
||||
}
|
|
@ -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)
|
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -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_ */
|
|
@ -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 */
|
|
@ -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_ */
|
|
@ -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;
|
||||
}
|
|
@ -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__ */
|
|
@ -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;
|
||||
}
|
|
@ -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__ */
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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_ */
|
|
@ -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__ */
|
|
@ -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
|
||||
|
|
@ -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.
|
||||
*/
|
|
@ -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"
|
|
@ -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 ()
|
|
@ -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 ()
|
|
@ -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 ()
|
|
@ -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 ()
|
|
@ -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 ()
|
|
@ -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 ()
|
|
@ -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 ()
|
|
@ -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 ()
|
|
@ -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
|
|
@ -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__ */
|
|
@ -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 ()
|
|
@ -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 ()
|
|
@ -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 ()
|
|
@ -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 ()
|
|
@ -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 ()
|
|
@ -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_ */
|
|
@ -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__ */
|
|
@ -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;
|
||||
}
|
|
@ -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__ */
|
|
@ -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;
|
||||
}
|
|
@ -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_ */
|
|
@ -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);
|
||||
}
|
|
@ -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_ */
|
|
@ -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, ¶ms, 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 (¶ms->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 (¶ms->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);
|
||||
}
|
|
@ -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_ */
|
|
@ -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);
|
||||
}
|
|
@ -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_ */
|
File diff suppressed because it is too large
Load diff
|
@ -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__ */
|
|
@ -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__ */
|
File diff suppressed because it is too large
Load diff
|
@ -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__ */
|
|
@ -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__ */
|
|
@ -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
|
|
@ -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__ */
|
|
@ -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;
|
||||
}
|
|
@ -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__ */
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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__ */
|
|
@ -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__ */
|
File diff suppressed because it is too large
Load diff
|
@ -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_ */
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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_ */
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -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__ */
|
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue