diff options
author | George Hazan <ghazan@miranda.im> | 2022-08-03 21:02:36 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-08-03 21:02:36 +0300 |
commit | 5323a782c4e8c42781f22ce2f488962a18f82554 (patch) | |
tree | f71537197b16f0f8fd0d6937f7120d018d220814 /include/gst/gl | |
parent | 50acf9d37183f86f6f623aad410003392b0af41f (diff) |
Jabber: initial version of Jingle support
Diffstat (limited to 'include/gst/gl')
52 files changed, 6823 insertions, 0 deletions
diff --git a/include/gst/gl/gl-enumtypes.h b/include/gst/gl/gl-enumtypes.h new file mode 100644 index 0000000000..5285248e36 --- /dev/null +++ b/include/gst/gl/gl-enumtypes.h @@ -0,0 +1,87 @@ + +/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */ + +#pragma once + +#include <gst/gst.h> +#include <gst/gl/gstgl_fwd.h> +G_BEGIN_DECLS + +/* enumerations from "gstgl_enums.h" */ +GST_GL_API +GType gst_gl_texture_target_get_type (void); +#define GST_TYPE_GL_TEXTURE_TARGET (gst_gl_texture_target_get_type()) + +/* enumerations from "gstglapi.h" */ +GST_GL_API +GType gst_gl_api_get_type (void); +#define GST_TYPE_GL_API (gst_gl_api_get_type()) +GST_GL_API +GType gst_gl_platform_get_type (void); +#define GST_TYPE_GL_PLATFORM (gst_gl_platform_get_type()) + +/* enumerations from "gstglbasememory.h" */ +GST_GL_API +GType gst_gl_base_memory_error_get_type (void); +#define GST_TYPE_GL_BASE_MEMORY_ERROR (gst_gl_base_memory_error_get_type()) +GST_GL_API +GType gst_gl_base_memory_transfer_get_type (void); +#define GST_TYPE_GL_BASE_MEMORY_TRANSFER (gst_gl_base_memory_transfer_get_type()) + +/* enumerations from "gstglcontext.h" */ +GST_GL_API +GType gst_gl_context_error_get_type (void); +#define GST_TYPE_GL_CONTEXT_ERROR (gst_gl_context_error_get_type()) + +/* enumerations from "gstglcontextconfig.h" */ +GST_GL_API +GType gst_gl_config_caveat_get_type (void); +#define GST_TYPE_GL_CONFIG_CAVEAT (gst_gl_config_caveat_get_type()) +GST_GL_API +GType gst_gl_config_surface_type_get_type (void); +#define GST_TYPE_GL_CONFIG_SURFACE_TYPE (gst_gl_config_surface_type_get_type()) + +/* enumerations from "gstgldisplay.h" */ +GST_GL_API +GType gst_gl_display_type_get_type (void); +#define GST_TYPE_GL_DISPLAY_TYPE (gst_gl_display_type_get_type()) + +/* enumerations from "gstglformat.h" */ +GST_GL_API +GType gst_gl_format_get_type (void); +#define GST_TYPE_GL_FORMAT (gst_gl_format_get_type()) + +/* enumerations from "gstglquery.h" */ +GST_GL_API +GType gst_gl_query_type_get_type (void); +#define GST_TYPE_GL_QUERY_TYPE (gst_gl_query_type_get_type()) + +/* enumerations from "gstglsl.h" */ +GST_GL_API +GType gst_glsl_error_get_type (void); +#define GST_TYPE_GLSL_ERROR (gst_glsl_error_get_type()) +GST_GL_API +GType gst_glsl_version_get_type (void); +#define GST_TYPE_GLSL_VERSION (gst_glsl_version_get_type()) +GST_GL_API +GType gst_glsl_profile_get_type (void); +#define GST_TYPE_GLSL_PROFILE (gst_glsl_profile_get_type()) + +/* enumerations from "gstglupload.h" */ +GST_GL_API +GType gst_gl_upload_return_get_type (void); +#define GST_TYPE_GL_UPLOAD_RETURN (gst_gl_upload_return_get_type()) + +/* enumerations from "gstglviewconvert.h" */ +GST_GL_API +GType gst_gl_stereo_downmix_get_type (void); +#define GST_TYPE_GL_STEREO_DOWNMIX (gst_gl_stereo_downmix_get_type()) + +/* enumerations from "gstglwindow.h" */ +GST_GL_API +GType gst_gl_window_error_get_type (void); +#define GST_TYPE_GL_WINDOW_ERROR (gst_gl_window_error_get_type()) +G_END_DECLS + +/* Generated data ends here */ + diff --git a/include/gst/gl/gl-prelude.h b/include/gst/gl/gl-prelude.h new file mode 100644 index 0000000000..05e1f6229a --- /dev/null +++ b/include/gst/gl/gl-prelude.h @@ -0,0 +1,33 @@ +/* GStreamer GL Library + * Copyright (C) 2018 GStreamer developers + * + * gl-prelude.h: prelude include header for gst-gl library + * + * 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_PRELUDE_H__ +#define __GST_GL_PRELUDE_H__ + +#include <gst/gst.h> + +#ifdef BUILDING_GST_GL +#define GST_GL_API GST_API_EXPORT /* from config.h */ +#else +#define GST_GL_API GST_API_IMPORT +#endif + +#endif /* __GST_GL_PRELUDE_H__ */ diff --git a/include/gst/gl/gl.h b/include/gst/gl/gl.h new file mode 100644 index 0000000000..6c7a37ff64 --- /dev/null +++ b/include/gst/gl/gl.h @@ -0,0 +1,56 @@ +/* + * 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__ + +#include <gst/gl/gstgl_fwd.h> +#include <gst/gl/gl-enumtypes.h> +#include <gst/gl/gstglapi.h> +#include <gst/gl/gstglconfig.h> +#include <gst/gl/gstglcontext.h> +#include <gst/gl/gstglcontextconfig.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/gstglbasesrc.h> +#include <gst/gl/gstglviewconvert.h> +#include <gst/gl/gstglfilter.h> +#include <gst/gl/gstglsyncmeta.h> +#include <gst/gl/gstgloverlaycompositor.h> +#include <gst/gl/gstglquery.h> + +#endif /* __GST_GL_H__ */ diff --git a/include/gst/gl/glprototypes/all_functions.h b/include/gst/gl/glprototypes/all_functions.h new file mode 100644 index 0000000000..48007e9548 --- /dev/null +++ b/include/gst/gl/glprototypes/all_functions.h @@ -0,0 +1,34 @@ +/* + * 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" +#include "buffer_storage.h" diff --git a/include/gst/gl/glprototypes/base.h b/include/gst/gl/glprototypes/base.h new file mode 100644 index 0000000000..8394a38728 --- /dev/null +++ b/include/gst/gl/glprototypes/base.h @@ -0,0 +1,328 @@ +/* + * GStreamer + * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2009, 2011 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + + +/* These are the core GL functions which we assume will always be + available */ +GST_GL_EXT_BEGIN (core, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES1 | GST_GL_API_GLES2, + 1, 0, + 1, 0, + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, BindTexture, + (GLenum target, GLuint texture)) +GST_GL_EXT_FUNCTION (void, BlendFunc, + (GLenum sfactor, GLenum dfactor)) +GST_GL_EXT_FUNCTION (void, Clear, + (GLbitfield mask)) +GST_GL_EXT_FUNCTION (void, ClearColor, + (GLclampf red, + GLclampf green, + GLclampf blue, + GLclampf alpha)) +GST_GL_EXT_FUNCTION (void, ClearStencil, + (GLint s)) +GST_GL_EXT_FUNCTION (void, ColorMask, + (GLboolean red, + GLboolean green, + GLboolean blue, + GLboolean alpha)) +GST_GL_EXT_FUNCTION (void, CopyTexSubImage2D, + (GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLint x, + GLint y, + GLsizei width, + GLsizei height)) +GST_GL_EXT_FUNCTION (void, DeleteTextures, + (GLsizei n, const GLuint* textures)) +GST_GL_EXT_FUNCTION (void, DepthFunc, + (GLenum func)) +GST_GL_EXT_FUNCTION (void, DepthMask, + (GLboolean flag)) +GST_GL_EXT_FUNCTION (void, Disable, + (GLenum cap)) +GST_GL_EXT_FUNCTION (void, DrawArrays, + (GLenum mode, GLint first, GLsizei count)) +GST_GL_EXT_FUNCTION (void, DrawElements, + (GLenum mode, + GLsizei count, + GLenum type, + const GLvoid* indices)) +GST_GL_EXT_FUNCTION (void, Enable, + (GLenum cap)) +GST_GL_EXT_FUNCTION (void, Finish, + (void)) +GST_GL_EXT_FUNCTION (void, Flush, + (void)) +GST_GL_EXT_FUNCTION (void, FrontFace, + (GLenum mode)) +GST_GL_EXT_FUNCTION (void, CullFace, + (GLenum mode)) +GST_GL_EXT_FUNCTION (void, GenTextures, + (GLsizei n, GLuint* textures)) +GST_GL_EXT_FUNCTION (GLenum, GetError, + (void)) +GST_GL_EXT_FUNCTION (void, GetIntegerv, + (GLenum pname, GLint* params)) +GST_GL_EXT_FUNCTION (void, GetBooleanv, + (GLenum pname, GLboolean* params)) +GST_GL_EXT_FUNCTION (void, GetFloatv, + (GLenum pname, GLfloat* params)) +GST_GL_EXT_FUNCTION (const GLubyte*, GetString, + (GLenum name)) +GST_GL_EXT_FUNCTION (void, Hint, + (GLenum target, GLenum mode)) +GST_GL_EXT_FUNCTION (GLboolean, IsTexture, + (GLuint texture)) +GST_GL_EXT_FUNCTION (void, PixelStorei, + (GLenum pname, GLint param)) +GST_GL_EXT_FUNCTION (void, ReadPixels, + (GLint x, + GLint y, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + GLvoid* pixels)) +GST_GL_EXT_FUNCTION (void, Scissor, + (GLint x, GLint y, GLsizei width, GLsizei height)) +GST_GL_EXT_FUNCTION (void, StencilFunc, + (GLenum func, GLint ref, GLuint mask)) +GST_GL_EXT_FUNCTION (void, StencilMask, + (GLuint mask)) +GST_GL_EXT_FUNCTION (void, StencilOp, + (GLenum fail, GLenum zfail, GLenum zpass)) +GST_GL_EXT_FUNCTION (void, TexImage2D, + (GLenum target, + GLint level, + GLint internalformat, + GLsizei width, + GLsizei height, + GLint border, + GLenum format, + GLenum type, + const GLvoid* pixels)) +GST_GL_EXT_FUNCTION (void, TexParameterfv, + (GLenum target, GLenum pname, const GLfloat* params)) +GST_GL_EXT_FUNCTION (void, TexParameteri, + (GLenum target, GLenum pname, GLint param)) +GST_GL_EXT_FUNCTION (void, TexParameteriv, + (GLenum target, GLenum pname, const GLint* params)) +GST_GL_EXT_FUNCTION (void, GetTexParameterfv, + (GLenum target, GLenum pname, GLfloat* params)) +GST_GL_EXT_FUNCTION (void, GetTexParameteriv, + (GLenum target, GLenum pname, GLint* params)) +GST_GL_EXT_FUNCTION (void, TexSubImage2D, + (GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + const GLvoid* pixels)) +GST_GL_EXT_FUNCTION (void, CopyTexImage2D, + (GLenum target, + GLint level, + GLenum internalformat, + GLint x, + GLint y, + GLsizei width, + GLsizei height, + GLint border)) +GST_GL_EXT_FUNCTION (void, Viewport, + (GLint x, GLint y, GLsizei width, GLsizei height)) +GST_GL_EXT_FUNCTION (GLboolean, IsEnabled, (GLenum cap)) +GST_GL_EXT_FUNCTION (void, LineWidth, (GLfloat width)) +GST_GL_EXT_FUNCTION (void, PolygonOffset, (GLfloat factor, GLfloat units)) +GST_GL_EXT_FUNCTION (void, TexParameterf, + (GLenum target, + GLenum pname, + GLfloat param)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (texture_3d, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3, + 1, 2, + 255, 255, /* not in either GLES */ + "OES\0", + "texture_3D\0") +GST_GL_EXT_FUNCTION (void, TexImage3D, + (GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels)) +GST_GL_EXT_FUNCTION (void, TexSubImage3D, + (GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, + GLenum type, const GLvoid *pixels)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (only_in_both_gles_and_gl_1_3, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES1 | GST_GL_API_GLES2, + 1, 3, + 1, 0, + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, CompressedTexImage2D, + (GLenum target, + GLint level, + GLenum internalformat, + GLsizei width, + GLsizei height, + GLint border, + GLsizei imageSize, + const GLvoid* data)) +GST_GL_EXT_FUNCTION (void, CompressedTexSubImage2D, + (GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLsizei imageSize, + const GLvoid* data)) +GST_GL_EXT_FUNCTION (void, SampleCoverage, + (GLclampf value, GLboolean invert)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (only_in_both_gles_and_gl_1_5, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES1 | GST_GL_API_GLES2, + 1, 5, + 1, 0, + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, GetBufferParameteriv, + (GLenum target, GLenum pname, GLint* params)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (vbos, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES1 | GST_GL_API_GLES2, + 1, 5, + 1, 0, + "ARB\0", + "vertex_buffer_object\0") +GST_GL_EXT_FUNCTION (void, GenBuffers, + (GLsizei n, + GLuint *buffers)) +GST_GL_EXT_FUNCTION (void, BindBuffer, + (GLenum target, + GLuint buffer)) +GST_GL_EXT_FUNCTION (void, BufferData, + (GLenum target, + GLsizeiptr size, + const GLvoid *data, + GLenum usage)) +GST_GL_EXT_FUNCTION (void, BufferSubData, + (GLenum target, + GLintptr offset, + GLsizeiptr size, + const GLvoid *data)) +GST_GL_EXT_FUNCTION (void, DeleteBuffers, + (GLsizei n, + const GLuint *buffers)) +GST_GL_EXT_FUNCTION (GLboolean, IsBuffer, + (GLuint buffer)) +GST_GL_EXT_END () + +/* Available in GL 1.3, the multitexture extension or GLES. These are + required */ +GST_GL_EXT_BEGIN (multitexture_part0, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES1 | GST_GL_API_GLES2, + 1, 3, + 1, 0, + "ARB\0", + "multitexture\0") +GST_GL_EXT_FUNCTION (void, ActiveTexture, + (GLenum texture)) +GST_GL_EXT_END () + + + /* GLES doesn't support mapping buffers in core so this has to be a + separate check */ +GST_GL_EXT_BEGIN (map_vbos, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3, + 1, 5, + 255, 255, /* not in GLES core */ + "ARB\0OES\0", + "vertex_buffer_object\0mapbuffer\0") +GST_GL_EXT_FUNCTION (void *, MapBuffer, + (GLenum target, + GLenum access)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (unmap_buffer, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2, + 1, 5, + 3, 0, + "ARB\0OES\0", + "vertex_buffer_object\0mapbuffer\0") +GST_GL_EXT_FUNCTION (GLboolean, UnmapBuffer, + (GLenum target)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (gl3, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 3, 0, + 3, 0, + "\0", + "\0") +GST_GL_EXT_FUNCTION (const GLubyte*, GetStringi, + (GLenum name, GLint index)) +GST_GL_EXT_FUNCTION (void *, MapBufferRange, + (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)) +GST_GL_EXT_END () diff --git a/include/gst/gl/glprototypes/blending.h b/include/gst/gl/glprototypes/blending.h new file mode 100644 index 0000000000..8ea514880a --- /dev/null +++ b/include/gst/gl/glprototypes/blending.h @@ -0,0 +1,99 @@ +/* + * GStreamer + * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2009, 2011 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +GST_GL_EXT_BEGIN (blending, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 1, 2, + 2, 0, + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, BlendEquation, + (GLenum mode)) +GST_GL_EXT_FUNCTION (void, BlendColor, + (GLclampf red, + GLclampf green, + GLclampf blue, + GLclampf alpha)) +GST_GL_EXT_END () + +/* Optional, declared in 1.4 or GLES 1.2 */ +GST_GL_EXT_BEGIN (blend_func_separate, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 1, 4, + 2, 0, + "EXT\0", + "blend_func_separate\0") +GST_GL_EXT_FUNCTION (void, BlendFuncSeparate, + (GLenum srcRGB, + GLenum dstRGB, + GLenum srcAlpha, + GLenum dstAlpha)) +GST_GL_EXT_END () + +/* Optional, declared in 2.0 */ +GST_GL_EXT_BEGIN (blend_equation_separate, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 2, 0, + 2, 0, + "EXT\0", + "blend_equation_separate\0") +GST_GL_EXT_FUNCTION (void, BlendEquationSeparate, + (GLenum modeRGB, + GLenum modeAlpha)) +GST_GL_EXT_END () + +/* GL and GLES 2.0 apis */ +GST_GL_EXT_BEGIN (two_point_zero_api, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 2, 0, + 2, 0, + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, StencilFuncSeparate, + (GLenum face, GLenum func, GLint ref, GLuint mask)) +GST_GL_EXT_FUNCTION (void, StencilMaskSeparate, + (GLenum face, GLuint mask)) +GST_GL_EXT_FUNCTION (void, StencilOpSeparate, + (GLenum face, GLenum fail, GLenum zfail, GLenum zpass)) +GST_GL_EXT_END () diff --git a/include/gst/gl/glprototypes/buffer_storage.h b/include/gst/gl/glprototypes/buffer_storage.h new file mode 100644 index 0000000000..57a93a0040 --- /dev/null +++ b/include/gst/gl/glprototypes/buffer_storage.h @@ -0,0 +1,42 @@ +/* + * GStreamer + * Copyright (C) 2021 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_storage, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 4, 4, + 255, 255, + "EXT\0ARB:\0", /* ARB version doesn't have function suffixes */ + "buffer_storage\0") +GST_GL_EXT_FUNCTION (void, BufferStorage, + (GLenum target, GLsizeiptr, const void * data, GLbitfield flags)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (flush_mapped, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 3, 0, + 3, 0, + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, FlushMappedBufferRange, + (GLenum target, GLintptr offset, GLsizeiptr length)) +GST_GL_EXT_END () + diff --git a/include/gst/gl/glprototypes/buffers.h b/include/gst/gl/glprototypes/buffers.h new file mode 100644 index 0000000000..5e73c624fe --- /dev/null +++ b/include/gst/gl/glprototypes/buffers.h @@ -0,0 +1,48 @@ +/* + * GStreamer + * Copyright (C) 2015 Matthew Waters <matthew@centricular.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +GST_GL_EXT_BEGIN (buffer_copy_sub_data, + GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 3, 1, + 3, 0, + /* extension is available in GL 3.0 */ + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, CopyBufferSubData, + (GLenum readTarget, + GLenum writeTarget, + GLintptr readOffset, + GLintptr writeOffset, + GLsizeiptr size)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (get_buffer_sub_data, + GST_GL_API_OPENGL3, + 1, 5, + 255, 255, + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, GetBufferSubData, + (GLenum target, + GLintptr offset, + GLsizeiptr size, + void * data)) +GST_GL_EXT_END () diff --git a/include/gst/gl/glprototypes/debug.h b/include/gst/gl/glprototypes/debug.h new file mode 100644 index 0000000000..135d4e6720 --- /dev/null +++ b/include/gst/gl/glprototypes/debug.h @@ -0,0 +1,117 @@ +/* + * GStreamer + * Copyright (C) 2014 Matthew Waters <ystreet00@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +GST_GL_EXT_BEGIN (debug, + GST_GL_API_OPENGL3, + 4, 3, + 255, 255, + "KHR:\0KHR\0ARB\0", + "debug\0debug_output\0") +GST_GL_EXT_FUNCTION (void, DebugMessageControl, + (GLenum source, + GLenum type, + GLenum severity, + GLsizei count, + const GLuint* ids, + gboolean enabled)) +GST_GL_EXT_FUNCTION (void, DebugMessageInsert, + (GLenum source, + GLenum type, + GLuint id, + GLenum severity, + GLsizei length, + const gchar *message)) +GST_GL_EXT_FUNCTION (void, DebugMessageCallback, + (GST_GL_DEBUG_PROC callback, + gpointer user_data)) +GST_GL_EXT_FUNCTION (GLuint, GetDebugMessageLog, + (GLuint count, + GLsizei bufSize, + GLenum* sources, + GLenum* types, + GLuint* ids, + GLenum* severities, + GLsizei* lengths, + gchar* messageLog)) +GST_GL_EXT_FUNCTION (void, GetPointerv, + (GLenum pname, + gpointer * params)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (khr_debug, + GST_GL_API_OPENGL3, + 4, 3, + 255, 255, + "KHR:\0KHR\0", + "debug\0") +GST_GL_EXT_FUNCTION (void, PushDebugGroup, + (GLenum source, + GLuint id, + GLsizei length, + const gchar * message)) +GST_GL_EXT_FUNCTION (void, PopDebugGroup, (void)) +GST_GL_EXT_FUNCTION (void, ObjectLabel, + (GLenum identifier, + GLuint name, + GLsizei length, + const gchar *label)) +GST_GL_EXT_FUNCTION (void, GetObjectLabel, + (GLenum identifier, + GLuint name, + GLsizei bufSize, + GLsizei *length, + gchar *label)) +GST_GL_EXT_FUNCTION (void, ObjectPtrLabel, + (gpointer ptr, + GLsizei length, + const gchar *label)) +GST_GL_EXT_FUNCTION (void, GetObjectPtrLabel, + (gpointer ptr, + GLsizei bufSize, + GLsizei *length, + gchar *label)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (ext_debug_marker, + GST_GL_API_NONE, + 255, 255, + 255, 255, + "EXT\0", + "debug_marker\0") +GST_GL_EXT_FUNCTION (void, InsertEventMarker, + (GLsizei length, + const gchar * message)) +GST_GL_EXT_FUNCTION (void, PushGroupMarker, + (GLsizei length, + const gchar * message)) +GST_GL_EXT_FUNCTION (void, PopGroupMarker, + (void)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (gremedy_string_marker, + GST_GL_API_NONE, + 255, 255, + 255, 255, + "GREMEDY\0", + "string_marker\0") +GST_GL_EXT_FUNCTION (void, StringMarker, + (GLsizei length, + const gchar * message)) +GST_GL_EXT_END () diff --git a/include/gst/gl/glprototypes/eglimage.h b/include/gst/gl/glprototypes/eglimage.h new file mode 100644 index 0000000000..0256003b06 --- /dev/null +++ b/include/gst/gl/glprototypes/eglimage.h @@ -0,0 +1,53 @@ +/* + * GStreamer + * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2009, 2011 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +GST_GL_EXT_BEGIN (EGL_image, + GST_GL_API_NONE, + 255, 255, + 255, 255, /* not in either GLES */ + "OES\0", + "EGL_image\0") +GST_GL_EXT_FUNCTION (void, EGLImageTargetTexture2D, + (GLenum target, + GLeglImageOES image)) +GST_GL_EXT_FUNCTION (void, EGLImageTargetRenderbufferStorage, + (GLenum target, + GLeglImageOES image)) +GST_GL_EXT_END () diff --git a/include/gst/gl/glprototypes/fbo.h b/include/gst/gl/glprototypes/fbo.h new file mode 100644 index 0000000000..f210f997d8 --- /dev/null +++ b/include/gst/gl/glprototypes/fbo.h @@ -0,0 +1,157 @@ +/* + * GStreamer + * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2009, 2011 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +GST_GL_EXT_BEGIN (offscreen, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 3, 0, + 2, 0, + /* for some reason the ARB version of this + extension doesn't have an ARB suffix for the + functions */ + "ARB:\0EXT\0OES\0", + "framebuffer_object\0") +GST_GL_EXT_FUNCTION (void, GenRenderbuffers, + (GLsizei n, + GLuint *renderbuffers)) +GST_GL_EXT_FUNCTION (void, DeleteRenderbuffers, + (GLsizei n, + const GLuint *renderbuffers)) +GST_GL_EXT_FUNCTION (void, BindRenderbuffer, + (GLenum target, + GLuint renderbuffer)) +GST_GL_EXT_FUNCTION (void, RenderbufferStorage, + (GLenum target, + GLenum internalformat, + GLsizei width, + GLsizei height)) +GST_GL_EXT_FUNCTION (void, GenFramebuffers, + (GLsizei n, + GLuint *framebuffers)) +GST_GL_EXT_FUNCTION (void, BindFramebuffer, + (GLenum target, + GLuint framebuffer)) +GST_GL_EXT_FUNCTION (void, FramebufferTexture2D, + (GLenum target, + GLenum attachment, + GLenum textarget, + GLuint texture, + GLint level)) +GST_GL_EXT_FUNCTION (void, FramebufferRenderbuffer, + (GLenum target, + GLenum attachment, + GLenum renderbuffertarget, + GLuint renderbuffer)) +GST_GL_EXT_FUNCTION (GLboolean, IsRenderbuffer, + (GLuint renderbuffer)) +GST_GL_EXT_FUNCTION (GLenum, CheckFramebufferStatus, + (GLenum target)) +GST_GL_EXT_FUNCTION (void, DeleteFramebuffers, + (GLsizei n, + const GLuint *framebuffers)) +GST_GL_EXT_FUNCTION (void, GenerateMipmap, + (GLenum target)) +GST_GL_EXT_FUNCTION (void, GetFramebufferAttachmentParameteriv, + (GLenum target, + GLenum attachment, + GLenum pname, + GLint *params)) +GST_GL_EXT_FUNCTION (void, GetRenderbufferParameteriv, + (GLenum target, + GLenum pname, + GLint *params)) +GST_GL_EXT_FUNCTION (GLboolean, IsFramebuffer, + (GLuint framebuffer)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (offscreen_blit, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 3, 0, + 3, 0, + "EXT\0ANGLE\0", + "framebuffer_blit\0") +GST_GL_EXT_FUNCTION (void, BlitFramebuffer, + (GLint srcX0, + GLint srcY0, + GLint srcX1, + GLint srcY1, + GLint dstX0, + GLint dstY0, + GLint dstX1, + GLint dstY1, + GLbitfield mask, + GLenum filter)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (framebuffer_discard, + GST_GL_API_NONE, + 255, 255, + 255, 255, /* not in either GLES */ + "EXT\0", + "framebuffer_discard\0") +GST_GL_EXT_FUNCTION (void, DiscardFramebuffer, + (GLenum target, + GLsizei numAttachments, + const GLenum *attachments)) +GST_GL_EXT_END () + + +GST_GL_EXT_BEGIN (read_buffer, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 1, 0, + 3, 0, + "NV\0", + "read_buffer\0") +GST_GL_EXT_FUNCTION (void, ReadBuffer, + (GLenum mode)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (draw_buffers, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 2, 1, + 3, 0, + "ARB\0ATI\0NV\0", + "draw_buffers\0") +GST_GL_EXT_FUNCTION (void, DrawBuffers, + (GLsizei n, const GLenum *bufs)) +GST_GL_EXT_END () diff --git a/include/gst/gl/glprototypes/fixedfunction.h b/include/gst/gl/glprototypes/fixedfunction.h new file mode 100644 index 0000000000..3aecbd227b --- /dev/null +++ b/include/gst/gl/glprototypes/fixedfunction.h @@ -0,0 +1,144 @@ +/* + * GStreamer + * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2009, 2011 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +GST_GL_EXT_BEGIN (multitexture_part1, + GST_GL_API_OPENGL | + GST_GL_API_GLES1, + 1, 3, + 1, 0, + "ARB\0", + "multitexture\0") +GST_GL_EXT_FUNCTION (void, ClientActiveTexture, + (GLenum texture)) +GST_GL_EXT_END () + +/* These are the core GL functions which are available when the API + supports fixed-function (ie, GL and GLES1.1) */ +GST_GL_EXT_BEGIN (fixed_function_core, + GST_GL_API_OPENGL | + GST_GL_API_GLES1, + 0, 0, + 1, 0, + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, AlphaFunc, + (GLenum func, GLclampf ref)) +GST_GL_EXT_FUNCTION (void, Fogf, + (GLenum pname, GLfloat param)) +GST_GL_EXT_FUNCTION (void, Fogfv, + (GLenum pname, const GLfloat *params)) +GST_GL_EXT_FUNCTION (void, LoadMatrixf, + (const GLfloat *m)) +GST_GL_EXT_FUNCTION (void, Materialfv, + (GLenum face, GLenum pname, const GLfloat *params)) +GST_GL_EXT_FUNCTION (void, PointSize, + (GLfloat size)) +GST_GL_EXT_FUNCTION (void, TexEnvfv, + (GLenum target, GLenum pname, const GLfloat *params)) +GST_GL_EXT_FUNCTION (void, Color4ub, + (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)) +GST_GL_EXT_FUNCTION (void, ColorPointer, + (GLint size, + GLenum type, + GLsizei stride, + const GLvoid *pointer)) +GST_GL_EXT_FUNCTION (void, DisableClientState, + (GLenum array)) +GST_GL_EXT_FUNCTION (void, EnableClientState, + (GLenum array)) +GST_GL_EXT_FUNCTION (void, LoadIdentity, + (void)) +GST_GL_EXT_FUNCTION (void, MatrixMode, + (GLenum mode)) +GST_GL_EXT_FUNCTION (void, NormalPointer, + (GLenum type, GLsizei stride, const GLvoid *pointer)) +GST_GL_EXT_FUNCTION (void, TexCoordPointer, + (GLint size, + GLenum type, + GLsizei stride, + const GLvoid *pointer)) +GST_GL_EXT_FUNCTION (void, TexEnvi, + (GLenum target, + GLenum pname, + GLint param)) +GST_GL_EXT_FUNCTION (void, VertexPointer, + (GLint size, + GLenum type, + GLsizei stride, + const GLvoid *pointer)) +GST_GL_EXT_FUNCTION (void, PushMatrix, + (void)) +GST_GL_EXT_FUNCTION (void, PopMatrix, + (void)) +GST_GL_EXT_END () + +/* Eventually we want to remove this category */ +GST_GL_EXT_BEGIN (fixed_function_gl_only, + GST_GL_API_OPENGL, + 0, 0, + 0, 0, + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, PushAttrib, + (GLbitfield mask)) +GST_GL_EXT_FUNCTION (void, PopAttrib, + (void)) +GST_GL_EXT_FUNCTION (void, TexImage1D, + (GLenum target, + GLint level, + GLint internalFormat, + GLsizei width, + GLint border, + GLenum format, + GLenum type, + const GLvoid *data)) +GST_GL_EXT_FUNCTION (void, Rotatef, + (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)) +GST_GL_EXT_FUNCTION (void, Translatef, + (GLfloat x, GLfloat y, GLfloat z)) +GST_GL_EXT_FUNCTION (void, Scalef, + (GLfloat x, GLfloat y, GLfloat z)) +GST_GL_EXT_FUNCTION (void, Lightfv, + (GLenum light, GLenum pname, const GLfloat *params)) +GST_GL_EXT_FUNCTION (void, ColorMaterial, + (GLenum face, GLenum pname)) +GST_GL_EXT_FUNCTION (void, ShadeModel, + (GLenum value)) +GST_GL_EXT_END () diff --git a/include/gst/gl/glprototypes/gles.h b/include/gst/gl/glprototypes/gles.h new file mode 100644 index 0000000000..f8c833b173 --- /dev/null +++ b/include/gst/gl/glprototypes/gles.h @@ -0,0 +1,102 @@ +/* + * 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, + "ARB:\0", + "ES2_compatibility\0") +GST_GL_EXT_FUNCTION (void, ReleaseShaderCompiler, (void)) +GST_GL_EXT_FUNCTION (void, GetShaderPrecisionFormat, + (GLenum shadertype, + GLenum precisiontype, + GLint* range, + GLint* precision)) +GST_GL_EXT_FUNCTION (void, ShaderBinary, + (GLsizei n, + const GLuint* shaders, + GLenum binaryformat, + const GLvoid* binary, + GLsizei length)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (IMG_multisampled_render_to_texture, + GST_GL_API_NONE, + 255, 255, + 255, 255, /* not in either GLES */ + "\0", + "IMG_multisampled_render_to_texture\0") +GST_GL_EXT_FUNCTION (void, RenderbufferStorageMultisampleIMG, + (GLenum target, + GLsizei samples, + GLenum internal_format, + GLsizei width, + GLsizei height)) +GST_GL_EXT_FUNCTION (void, FramebufferTexture2DMultisampleIMG, + (GLenum target, + GLenum attachment, + GLenum textarget, + GLuint texture, + GLint level, + GLsizei samples)) +GST_GL_EXT_END () diff --git a/include/gst/gl/glprototypes/gstgl_compat.h b/include/gst/gl/glprototypes/gstgl_compat.h new file mode 100644 index 0000000000..31b1e005d1 --- /dev/null +++ b/include/gst/gl/glprototypes/gstgl_compat.h @@ -0,0 +1,67 @@ + /* + * GStreamer + * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_GL_COMPAT_H__ +#define __GST_GL_COMPAT_H__ + +#include <gst/gl/gstglconfig.h> + +/* undefined typedefs */ +#if !GST_GL_HAVE_GLEGLIMAGEOES +typedef gpointer GLeglImageOES; +#endif +#if !GST_GL_HAVE_GLCHAR +typedef gchar GLchar; +#endif +#if !GST_GL_HAVE_GLSIZEIPTR +typedef ptrdiff_t GLsizeiptr; +#endif +#if !GST_GL_HAVE_GLINTPTR +typedef ptrdiff_t GLintptr; +#endif +#if !GST_GL_HAVE_GLSYNC +typedef gpointer GLsync; +#endif +#if !GST_GL_HAVE_GLUINT64 +typedef guint64 GLuint64; +#endif +#if !GST_GL_HAVE_GLINT64 +typedef gint64 GLint64; +#endif + +#if !defined(GST_GL_DEBUG_PROC) +#if defined(GLDEBUGPROC) +#define GST_GL_DEBUG_PROC GLDEBUGPROC +#elif defined(GLDEBUGPROCARB) +#define GST_GL_DEBUG_PROC GLDEBUGPROCARB +#elif defined(GLDEBUGPROCKHR) +#define GST_GL_DEBUG_PROC GLDEBUGPROCKHR +#else +typedef void (GSTGLAPI *GST_GL_DEBUG_PROC) (GLenum source, + GLenum type, + GLuint id, + GLenum severity, + GLsizei length, + const gchar* message, + gpointer user_data); +#endif +#endif + +#endif diff --git a/include/gst/gl/glprototypes/gstgl_gles2compat.h b/include/gst/gl/glprototypes/gstgl_gles2compat.h new file mode 100644 index 0000000000..80600b44d1 --- /dev/null +++ b/include/gst/gl/glprototypes/gstgl_gles2compat.h @@ -0,0 +1,60 @@ +/* + * 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_COLOR_ATTACHMENT3 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#endif +#ifndef GL_TEXTURE_ENV +#define GL_TEXTURE_ENV 0 +#endif +#ifndef GL_TEXTURE_ENV_MODE +#define GL_TEXTURE_ENV_MODE 0 +#endif +#ifndef GL_DEPTH24_STENCIL8 +#define GL_DEPTH24_STENCIL8 0x88F0 +#endif + +G_END_DECLS + +#endif /* __GST_GL_ES2__ */ diff --git a/include/gst/gl/glprototypes/opengl.h b/include/gst/gl/glprototypes/opengl.h new file mode 100644 index 0000000000..ac47d52807 --- /dev/null +++ b/include/gst/gl/glprototypes/opengl.h @@ -0,0 +1,72 @@ +/* + * GStreamer + * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2009, 2011 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +/* These are the core GL functions which are only available in big + GL */ +GST_GL_EXT_BEGIN (only_in_big_gl, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3, + 1, 0, + 255, 255, /* not in GLES */ + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, GetTexLevelParameteriv, + (GLenum target, GLint level, + GLenum pname, GLint *params)) +GST_GL_EXT_FUNCTION (void, GetTexImage, + (GLenum target, GLint level, + GLenum format, GLenum type, + GLvoid *pixels)) +GST_GL_EXT_FUNCTION (void, DepthRange, + (double near_val, double far_val)) +GST_GL_EXT_FUNCTION (void, DrawBuffer, + (GLenum mode)) +GST_GL_EXT_FUNCTION (void, ClearDepth, + (double depth)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (only_in_big_gl_compat, + GST_GL_API_OPENGL, + 1, 0, + 255, 255, /* not in GLES */ + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, ClipPlane, + (GLenum plane, const double *equation)) +GST_GL_EXT_END () diff --git a/include/gst/gl/glprototypes/query.h b/include/gst/gl/glprototypes/query.h new file mode 100644 index 0000000000..09f1ba23fb --- /dev/null +++ b/include/gst/gl/glprototypes/query.h @@ -0,0 +1,63 @@ +/* + * GStreamer + * Copyright (C) 2016 Matthew Waters <matthew@centricular.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +GST_GL_EXT_BEGIN (timer_query, + GST_GL_API_OPENGL3, + 3, 3, + 3, 0, + "ARB:\0ANGLE\0EXT\0", + "timer_query\0disjoint_timer_query\0") +GST_GL_EXT_FUNCTION (void, GenQueries, + (GLsizei n, + GLuint *ids)) +GST_GL_EXT_FUNCTION (void, DeleteQueries, + (GLsizei n, + GLuint *ids)) +GST_GL_EXT_FUNCTION (GLboolean, IsQuery, + (GLuint id)) +GST_GL_EXT_FUNCTION (void, BeginQuery, + (GLenum target, + GLuint id)) +GST_GL_EXT_FUNCTION (void, EndQuery, + (GLenum target)) +GST_GL_EXT_FUNCTION (void, QueryCounter, + (GLuint id, + GLenum target)) +GST_GL_EXT_FUNCTION (void, GetQueryiv, + (GLenum target, + GLenum pname, + GLint *params)) +GST_GL_EXT_FUNCTION (void, GetQueryObjectiv, + (GLuint id, + GLenum pname, + GLint *params)) +GST_GL_EXT_FUNCTION (void, GetQueryObjectuiv, + (GLuint id, + GLenum pname, + GLuint *params)) +GST_GL_EXT_FUNCTION (void, GetQueryObjecti64v, + (GLuint id, + GLenum pname, + GLint64 *params)) +GST_GL_EXT_FUNCTION (void, GetQueryObjectui64v, + (GLuint id, + GLenum pname, + GLuint64 *params)) +GST_GL_EXT_END () diff --git a/include/gst/gl/glprototypes/shaders.h b/include/gst/gl/glprototypes/shaders.h new file mode 100644 index 0000000000..6d828dbac2 --- /dev/null +++ b/include/gst/gl/glprototypes/shaders.h @@ -0,0 +1,374 @@ +/* + * GStreamer + * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2009, 2011 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +/* This lists functions that are unique to GL 2.0 or GLES 2.0 and are + * not in the old GLSL extensions */ +GST_GL_EXT_BEGIN (shaders_glsl_2_only, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 2, 0, + 2, 0, + "\0", + "\0") +GST_GL_EXT_FUNCTION (GLuint, CreateProgram, + (void)) +GST_GL_EXT_FUNCTION (GLuint, CreateShader, + (GLenum shaderType)) +GST_GL_EXT_FUNCTION (void, DeleteShader, + (GLuint shader)) +GST_GL_EXT_FUNCTION (void, AttachShader, + (GLuint program, + GLuint shader)) +GST_GL_EXT_FUNCTION (void, UseProgram, + (GLuint program)) +GST_GL_EXT_FUNCTION (void, DeleteProgram, + (GLuint program)) +GST_GL_EXT_FUNCTION (void, GetShaderInfoLog, + (GLuint shader, + GLsizei maxLength, + GLsizei *length, + char *infoLog)) +GST_GL_EXT_FUNCTION (void, GetProgramInfoLog, + (GLuint program, + GLsizei bufSize, + GLsizei *length, + char *infoLog)) +GST_GL_EXT_FUNCTION (void, GetShaderiv, + (GLuint shader, + GLenum pname, + GLint *params)) +GST_GL_EXT_FUNCTION (void, GetProgramiv, + (GLuint program, + GLenum pname, + GLint *params)) +GST_GL_EXT_FUNCTION (void, DetachShader, + (GLuint program, GLuint shader)) +GST_GL_EXT_FUNCTION (void, GetAttachedShaders, + (GLuint program, + GLsizei maxcount, + GLsizei* count, + GLuint* shaders)) +GST_GL_EXT_FUNCTION (GLboolean, IsShader, + (GLuint shader)) +GST_GL_EXT_FUNCTION (GLboolean, IsProgram, + (GLuint program)) +GST_GL_EXT_END () + +/* These functions are provided by GL_ARB_shader_objects or are in GL + * 2.0 core */ +GST_GL_EXT_BEGIN (shader_objects_or_gl2, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 2, 0, + 2, 0, + "ARB\0", + "shader_objects\0") +GST_GL_EXT_FUNCTION (void, ShaderSource, + (GLuint shader, + GLsizei count, + const char **string, + const GLint *length)) +GST_GL_EXT_FUNCTION (void, CompileShader, + (GLuint shader)) +GST_GL_EXT_FUNCTION (void, LinkProgram, + (GLuint program)) +GST_GL_EXT_FUNCTION (GLint, GetUniformLocation, + (GLuint program, + const char *name)) +GST_GL_EXT_FUNCTION (void, Uniform1f, + (GLint location, + GLfloat v0)) +GST_GL_EXT_FUNCTION (void, Uniform2f, + (GLint location, + GLfloat v0, + GLfloat v1)) +GST_GL_EXT_FUNCTION (void, Uniform3f, + (GLint location, + GLfloat v0, + GLfloat v1, + GLfloat v2)) +GST_GL_EXT_FUNCTION (void, Uniform4f, + (GLint location, + GLfloat v0, + GLfloat v1, + GLfloat v2, + GLfloat v3)) +GST_GL_EXT_FUNCTION (void, Uniform1fv, + (GLint location, + GLsizei count, + const GLfloat * value)) +GST_GL_EXT_FUNCTION (void, Uniform2fv, + (GLint location, + GLsizei count, + const GLfloat * value)) +GST_GL_EXT_FUNCTION (void, Uniform3fv, + (GLint location, + GLsizei count, + const GLfloat * value)) +GST_GL_EXT_FUNCTION (void, Uniform4fv, + (GLint location, + GLsizei count, + const GLfloat * value)) +GST_GL_EXT_FUNCTION (void, Uniform1i, + (GLint location, + GLint v0)) +GST_GL_EXT_FUNCTION (void, Uniform2i, + (GLint location, + GLint v0, + GLint v1)) +GST_GL_EXT_FUNCTION (void, Uniform3i, + (GLint location, + GLint v0, + GLint v1, + GLint v2)) +GST_GL_EXT_FUNCTION (void, Uniform4i, + (GLint location, + GLint v0, + GLint v1, + GLint v2, + GLint v3)) +GST_GL_EXT_FUNCTION (void, Uniform1iv, + (GLint location, + GLsizei count, + const GLint * value)) +GST_GL_EXT_FUNCTION (void, Uniform2iv, + (GLint location, + GLsizei count, + const GLint * value)) +GST_GL_EXT_FUNCTION (void, Uniform3iv, + (GLint location, + GLsizei count, + const GLint * value)) +GST_GL_EXT_FUNCTION (void, Uniform4iv, + (GLint location, + GLsizei count, + const GLint * value)) +GST_GL_EXT_FUNCTION (void, UniformMatrix2fv, + (GLint location, + GLsizei count, + GLboolean transpose, + const GLfloat *value)) +GST_GL_EXT_FUNCTION (void, UniformMatrix3fv, + (GLint location, + GLsizei count, + GLboolean transpose, + const GLfloat *value)) +GST_GL_EXT_FUNCTION (void, UniformMatrix4fv, + (GLint location, + GLsizei count, + GLboolean transpose, + const GLfloat *value)) + +GST_GL_EXT_FUNCTION (void, GetUniformfv, + (GLuint program, + GLint location, + GLfloat *params)) +GST_GL_EXT_FUNCTION (void, GetUniformiv, + (GLuint program, + GLint location, + GLint *params)) +GST_GL_EXT_FUNCTION (void, GetActiveUniform, + (GLuint program, + GLuint index, + GLsizei bufsize, + GLsizei* length, + GLint* size, + GLenum* type, + GLchar* name)) +GST_GL_EXT_FUNCTION (void, GetShaderSource, + (GLuint shader, + GLsizei bufsize, + GLsizei* length, + GLchar* source)) +GST_GL_EXT_FUNCTION (void, ValidateProgram, (GLuint program)) +GST_GL_EXT_END () + +/* These functions are provided by GL_ARB_vertex_shader or are in GL + * 2.0 core */ +GST_GL_EXT_BEGIN (vertex_shaders, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 2, 0, + 2, 0, + "ARB\0", + "vertex_shader\0") +GST_GL_EXT_FUNCTION (void, VertexAttribPointer, + (GLuint index, + GLint size, + GLenum type, + GLboolean normalized, + GLsizei stride, + const GLvoid *pointer)) +GST_GL_EXT_FUNCTION (void, EnableVertexAttribArray, + (GLuint index)) +GST_GL_EXT_FUNCTION (void, DisableVertexAttribArray, + (GLuint index)) +GST_GL_EXT_FUNCTION (void, VertexAttrib1f, (GLuint indx, GLfloat x)) +GST_GL_EXT_FUNCTION (void, VertexAttrib1fv, + (GLuint indx, const GLfloat* values)) +GST_GL_EXT_FUNCTION (void, VertexAttrib2f, (GLuint indx, GLfloat x, GLfloat y)) +GST_GL_EXT_FUNCTION (void, VertexAttrib2fv, + (GLuint indx, const GLfloat* values)) +GST_GL_EXT_FUNCTION (void, VertexAttrib3f, + (GLuint indx, GLfloat x, GLfloat y, GLfloat z)) +GST_GL_EXT_FUNCTION (void, VertexAttrib3fv, + (GLuint indx, const GLfloat* values)) +GST_GL_EXT_FUNCTION (void, VertexAttrib4f, + (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)) +GST_GL_EXT_FUNCTION (void, VertexAttrib4fv, + (GLuint indx, const GLfloat* values)) +GST_GL_EXT_FUNCTION (void, GetVertexAttribfv, + (GLuint index, GLenum pname, GLfloat* params)) +GST_GL_EXT_FUNCTION (void, GetVertexAttribiv, + (GLuint index, GLenum pname, GLint* params)) +GST_GL_EXT_FUNCTION (void, GetVertexAttribPointerv, + (GLuint index, GLenum pname, GLvoid** pointer)) +GST_GL_EXT_FUNCTION (GLint, GetAttribLocation, + (GLuint program, const char *name)) +GST_GL_EXT_FUNCTION (void, BindAttribLocation, + (GLuint program, + GLuint index, + const GLchar* name)) +GST_GL_EXT_FUNCTION (void, GetActiveAttrib, + (GLuint program, + GLuint index, + GLsizei bufsize, + GLsizei* length, + GLint* size, + GLenum* type, + GLchar* name)) +GST_GL_EXT_END () + +/* These only list functions that come from the old GLSL extensions. + * Functions that are common to the extensions and GLSL 2.0 should + * instead be listed in cogl-glsl-functions.h */ +GST_GL_EXT_BEGIN (shader_objects, + GST_GL_API_NONE, + 255, 255, + 255, 255, /* not in either GLES */ + "ARB\0", + "shader_objects\0") +GST_GL_EXT_FUNCTION (GLuint, CreateProgramObject, + (void)) +GST_GL_EXT_FUNCTION (GLuint, CreateShaderObject, + (GLenum shaderType)) +GST_GL_EXT_FUNCTION (void, DeleteObject, + (GLuint obj)) +GST_GL_EXT_FUNCTION (void, AttachObject, + (GLuint container, GLuint obj)) +GST_GL_EXT_FUNCTION (void, UseProgramObject, + (GLuint programObj)) +GST_GL_EXT_FUNCTION (void, GetInfoLog, + (GLuint obj, + GLsizei maxLength, + GLsizei *length, + char *infoLog)) +GST_GL_EXT_FUNCTION (void, GetObjectParameteriv, + (GLuint obj, + GLenum pname, + GLint *params)) +GST_GL_EXT_FUNCTION (void, DetachObject, + (GLuint container, GLuint obj)) +GST_GL_EXT_FUNCTION (void, GetAttachedObjects, + (GLuint program, + GLsizei maxcount, + GLsizei* count, + GLuint* shaders)) +GST_GL_EXT_END () + +/* ARB_fragment_program */ +GST_GL_EXT_BEGIN (arbfp, + GST_GL_API_NONE, + 255, 255, + 255, 255, /* not in either GLES */ + "ARB\0", + "fragment_program\0") +GST_GL_EXT_FUNCTION (void, GenPrograms, + (GLsizei n, + GLuint *programs)) +GST_GL_EXT_FUNCTION (void, DeletePrograms, + (GLsizei n, + GLuint *programs)) +GST_GL_EXT_FUNCTION (void, BindProgram, + (GLenum target, + GLuint program)) +GST_GL_EXT_FUNCTION (void, ProgramString, + (GLenum target, + GLenum format, + GLsizei len, + const void *program)) +GST_GL_EXT_FUNCTION (void, ProgramLocalParameter4fv, + (GLenum target, + GLuint index, + GLfloat *params)) +GST_GL_EXT_END () + +/* This lists functions that are unique to GL 2.1 or GLES 3.0 and are + * not in the old GLSL extensions */ +GST_GL_EXT_BEGIN (shaders_2_1, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | + GST_GL_API_GLES2, + 2, 1, + 3, 0, + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, UniformMatrix2x3fv, + (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)) +GST_GL_EXT_FUNCTION (void, UniformMatrix3x2fv, + (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)) +GST_GL_EXT_FUNCTION (void, UniformMatrix2x4fv, + (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)) +GST_GL_EXT_FUNCTION (void, UniformMatrix4x2fv, + (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)) +GST_GL_EXT_FUNCTION (void, UniformMatrix3x4fv, + (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)) +GST_GL_EXT_FUNCTION (void, UniformMatrix4x3fv, + (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)) +GST_GL_EXT_END () + +GST_GL_EXT_BEGIN (bind_frag_data, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3, + 3, 0, + 255, 255, + "\0", + "\0") +GST_GL_EXT_FUNCTION (void, BindFragDataLocation, + (GLuint program, GLuint index, const GLchar * name)) +GST_GL_EXT_END () diff --git a/include/gst/gl/glprototypes/sync.h b/include/gst/gl/glprototypes/sync.h new file mode 100644 index 0000000000..d6620478db --- /dev/null +++ b/include/gst/gl/glprototypes/sync.h @@ -0,0 +1,49 @@ +/* + * 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_OPENGL | + 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 name, + GLsizei buf_size, + GLsizei *length, + GLint *values)) +GST_GL_EXT_END () diff --git a/include/gst/gl/glprototypes/vao.h b/include/gst/gl/glprototypes/vao.h new file mode 100644 index 0000000000..32d11599fd --- /dev/null +++ b/include/gst/gl/glprototypes/vao.h @@ -0,0 +1,37 @@ +/* + * GStreamer + * Copyright (C) 2014 Matthew Waters <matthew@centricular.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +GST_GL_EXT_BEGIN (vao, + GST_GL_API_OPENGL3 | GST_GL_API_GLES2, + 3, 0, + 3, 0, + "ARB:\0OES\0", + "vertex_array_object\0") +GST_GL_EXT_FUNCTION (void, GenVertexArrays, + (GLsizei n, + GLuint *arrays)) +GST_GL_EXT_FUNCTION (void, DeleteVertexArrays, + (GLsizei n, + GLuint *arrays)) +GST_GL_EXT_FUNCTION (void, BindVertexArray, + (GLuint array)) +GST_GL_EXT_FUNCTION (GLboolean, IsVertexArray, + (GLuint array)) +GST_GL_EXT_END () diff --git a/include/gst/gl/gstgl_enums.h b/include/gst/gl/gstgl_enums.h new file mode 100644 index 0000000000..93d9fed64e --- /dev/null +++ b/include/gst/gl/gstgl_enums.h @@ -0,0 +1,49 @@ +/* + * 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 (`GL_TEXTURE_2D`) + * @GST_GL_TEXTURE_TARGET_RECTANGLE: rectangle texture target + * (`GL_TEXTURE_RECTANGLE`) + * @GST_GL_TEXTURE_TARGET_EXTERNAL_OES: external oes texture target + * (`GL_TEXTURE_EXTERNAL_OES`) + * + * The OpenGL texture target that an OpenGL texture can be bound to. The + * gst_gl_value_set_texture_target_from_mask(), + * gst_gl_value_get_texture_target_mask(), and + * gst_gl_value_set_texture_target() functions can be used for handling texture + * targets with #GValue's when e.g. dealing with #GstCaps. + * + * Since: 1.8 + */ +typedef enum +{ + GST_GL_TEXTURE_TARGET_NONE, + GST_GL_TEXTURE_TARGET_2D, + GST_GL_TEXTURE_TARGET_RECTANGLE, + GST_GL_TEXTURE_TARGET_EXTERNAL_OES, +} GstGLTextureTarget; + +#endif /* _GST_GL_ENUMS_H_ */ diff --git a/include/gst/gl/gstgl_fwd.h b/include/gst/gl/gstgl_fwd.h new file mode 100644 index 0000000000..28af5c4a43 --- /dev/null +++ b/include/gst/gl/gstgl_fwd.h @@ -0,0 +1,147 @@ +/* + * 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 _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 _GstGLBaseSrc GstGLBaseSrc; +typedef struct _GstGLBaseSrcClass GstGLBaseSrcClass; +typedef struct _GstGLBaseSrcPrivate GstGLBaseSrcPrivate; + +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> + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLBaseFilter, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLBaseMemoryAllocator, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLBaseSrc, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLBufferAllocator, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLBufferPool, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLColorConvert, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLContext, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLDisplay, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLFilter, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLMemoryAllocator, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLMemoryPBOAllocator, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLOverlayCompositor, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLSLStage, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLShader, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLUpload, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLViewConvert, gst_object_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLWindow, gst_object_unref) + +G_END_DECLS + +#endif /* __GST_GL_FWD_H__ */ diff --git a/include/gst/gl/gstglapi.h b/include/gst/gl/gstglapi.h new file mode 100644 index 0000000000..a0d82f5342 --- /dev/null +++ b/include/gst/gl/gstglapi.h @@ -0,0 +1,114 @@ +/* + * 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/gl/gl-prelude.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 /*< underscore_name=gst_gl_api >*/ { + 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_GL_API +gchar * gst_gl_api_to_string (GstGLAPI api); +GST_GL_API +GstGLAPI gst_gl_api_from_string (const gchar * api_s); + +GST_GL_API +gchar * gst_gl_platform_to_string (GstGLPlatform platform); +GST_GL_API +GstGLPlatform gst_gl_platform_from_string (const gchar * platform_s); + +G_END_DECLS + +#endif /* __GST_GL_API_H__ */ diff --git a/include/gst/gl/gstglbasefilter.h b/include/gst/gl/gstglbasefilter.h new file mode 100644 index 0000000000..57fb3df5ba --- /dev/null +++ b/include/gst/gl/gstglbasefilter.h @@ -0,0 +1,100 @@ +/* + * 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_GL_API +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: + * @display: the currently configured #GstGLDisplay + * @context: the currently configured #GstGLContext + * @in_caps: the currently configured input #GstCaps + * @out_caps: the currently configured output #GstCaps + * + * The parent instance type of a base GStreamer GL Filter. + */ +struct _GstGLBaseFilter +{ + GstBaseTransform parent; + + /*< public >*/ + GstGLDisplay *display; + GstGLContext *context; + + GstCaps *in_caps; + GstCaps *out_caps; + + /*< private >*/ + gpointer _padding[GST_PADDING]; + + GstGLBaseFilterPrivate *priv; +}; + +/** + * GstGLBaseFilterClass: + * @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. + * Note: this will also be called when changing OpenGL contexts + * where #GstBaseTransform::set_caps may not. + * + * The base class for GStreamer GL Filter. + */ +struct _GstGLBaseFilterClass +{ + GstBaseTransformClass parent_class; + + /*< public >*/ + 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]; +}; + +GST_GL_API +gboolean gst_gl_base_filter_find_gl_context (GstGLBaseFilter * filter); +GST_GL_API +GstGLContext * gst_gl_base_filter_get_gl_context (GstGLBaseFilter * filter); + +G_END_DECLS + +#endif /* _GST_GL_BASE_FILTER_H_ */ diff --git a/include/gst/gl/gstglbasememory.h b/include/gst/gl/gstglbasememory.h new file mode 100644 index 0000000000..7582cf9f66 --- /dev/null +++ b/include/gst/gl/gstglbasememory.h @@ -0,0 +1,421 @@ +/* + * 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 + +#define GST_TYPE_GL_BASE_MEMORY (gst_gl_base_memory_get_type()) +GST_GL_API +GType gst_gl_base_memory_get_type(void); + +#define GST_TYPE_GL_BASE_MEMORY_ALLOCATOR (gst_gl_base_memory_allocator_get_type()) +GST_GL_API +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_GL_API +GQuark gst_gl_base_memory_error_quark (void); +/** + * 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_GL_BASE_MEMORY_ERROR (gst_gl_base_memory_error_quark ()) + +/** + * GstGLBaseMemoryError: + * @GST_GL_BASE_MEMORY_ERROR_FAILED: generic failure + * @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_GL_API +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_GL_API +gboolean gst_gl_allocation_params_init (GstGLAllocationParams * params, + gsize struct_size, + guint alloc_flags, + GstGLAllocationParamsCopyFunc copy, + GstGLAllocationParamsFreeFunc free, + GstGLContext * context, + gsize alloc_size, + const GstAllocationParams * alloc_params, + gpointer wrapped_data, + gpointer gl_handle, + gpointer user_data, + GDestroyNotify notify); + +/* free with gst_gl_allocation_params_free */ +GST_GL_API +GstGLAllocationParams * gst_gl_allocation_params_copy (GstGLAllocationParams * src); + +GST_GL_API +void gst_gl_allocation_params_free (GstGLAllocationParams * params); + +/* subclass usage */ +GST_GL_API +void gst_gl_allocation_params_free_data (GstGLAllocationParams * params); + +/* subclass usage */ +GST_GL_API +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_GL_API +void gst_gl_base_memory_init_once (void); + +GST_GL_API +gboolean gst_is_gl_base_memory (GstMemory * mem); + +GST_GL_API +void gst_gl_base_memory_init (GstGLBaseMemory * mem, + GstAllocator * allocator, + GstMemory * parent, + GstGLContext * context, + const GstAllocationParams * params, + gsize size, + gpointer user_data, + GDestroyNotify notify); + +GST_GL_API +gboolean gst_gl_base_memory_alloc_data (GstGLBaseMemory * gl_mem); + +GST_GL_API +gboolean gst_gl_base_memory_memcpy (GstGLBaseMemory * src, + GstGLBaseMemory * dest, + gssize offset, + gssize size); + +GST_GL_API +GstGLBaseMemory * gst_gl_base_memory_alloc (GstGLBaseMemoryAllocator * allocator, + GstGLAllocationParams * params); + +G_END_DECLS + +#endif /* _GST_GL_BUFFER_H_ */ diff --git a/include/gst/gl/gstglbasesrc.h b/include/gst/gl/gstglbasesrc.h new file mode 100644 index 0000000000..4c9d3a435c --- /dev/null +++ b/include/gst/gl/gstglbasesrc.h @@ -0,0 +1,100 @@ +/* + * GStreamer + * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> + * Copyright (C) 2002,2007 David A. Schleef <ds@schleef.org> + * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com> + * Copyright (C) 2019 Philippe Normand <philn@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. + */ + +#ifndef __GST_GL_BASE_SRC_H__ +#define __GST_GL_BASE_SRC_H__ + +#include <gst/base/gstpushsrc.h> +#include <gst/gl/gstgl_fwd.h> + +G_BEGIN_DECLS + +GST_GL_API +GType gst_gl_base_src_get_type(void); + +#define GST_TYPE_GL_BASE_SRC (gst_gl_base_src_get_type()) +#define GST_GL_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_BASE_SRC,GstGLBaseSrc)) +#define GST_GL_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_BASE_SRC,GstGLBaseSrcClass)) +#define GST_IS_GL_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_BASE_SRC)) +#define GST_IS_GL_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_BASE_SRC)) +#define GST_GL_BASE_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_GL_BASE_SRC,GstGLBaseSrcClass)) + +/** + * GstGLBaseSrc: + * @display: the currently configured #GstGLDisplay + * @context: the currently configured #GstGLContext + * @out_caps: the currently configured output #GstCaps + * @out_info: the currently configured output #GstVideoInfo + * @running_time: the total running time + * + * The parent instance type of a base GStreamer GL Video source. + * + * Since: 1.18 + */ +struct _GstGLBaseSrc { + GstPushSrc parent; + + /*< public >*/ + GstGLDisplay *display; + GstGLContext *context; + + /* video state */ + GstVideoInfo out_info; + GstCaps *out_caps; + + /* total running time */ + GstClockTime running_time; + + /*< private >*/ + gpointer _padding[GST_PADDING]; + + GstGLBaseSrcPrivate *priv; +}; + +/** + * GstGLBaseSrcClass: + * @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. + * @fill_gl_memory: called in the GL thread to fill the current video texture. + * + * The base class for GStreamer GL Video sources. + * + * Since: 1.18 + */ +struct _GstGLBaseSrcClass { + GstPushSrcClass parent_class; + + /*< public >*/ + GstGLAPI supported_gl_api; + gboolean (*gl_start) (GstGLBaseSrc *src); + void (*gl_stop) (GstGLBaseSrc *src); + gboolean (*fill_gl_memory) (GstGLBaseSrc *src, GstGLMemory *mem); + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + +G_END_DECLS + +#endif /* __GST_GL_BASE_SRC_H__ */ diff --git a/include/gst/gl/gstglbuffer.h b/include/gst/gl/gstglbuffer.h new file mode 100644 index 0000000000..4cc7f9b31e --- /dev/null +++ b/include/gst/gl/gstglbuffer.h @@ -0,0 +1,150 @@ +/* + * 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_GL_API +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_GL_API +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_GL_API +GstGLBufferAllocationParams * gst_gl_buffer_allocation_params_new (GstGLContext * context, + gsize alloc_size, + const GstAllocationParams * alloc_params, + guint gl_target, + guint gl_usage); + +/** + * GstGLBufferAllocator: + * + * Opaque #GstGLBufferAllocator 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_TYPE_GL_BUFFER: + * + * Since: 1.20 + */ +#define GST_TYPE_GL_BUFFER (gst_gl_buffer_get_type()) +GST_GL_API +GType gst_gl_buffer_get_type(void); + +GST_GL_API +void gst_gl_buffer_init_once (void); +GST_GL_API +gboolean gst_is_gl_buffer (GstMemory * mem); + +G_END_DECLS + +#endif /* _GST_GL_BUFFER_H_ */ diff --git a/include/gst/gl/gstglbufferpool.h b/include/gst/gl/gstglbufferpool.h new file mode 100644 index 0000000000..595eed53ad --- /dev/null +++ b/include/gst/gl/gstglbufferpool.h @@ -0,0 +1,83 @@ +/* + * 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_GL_API +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_GL_API +GstBufferPool *gst_gl_buffer_pool_new (GstGLContext * context); + +GST_GL_API +GstGLAllocationParams * gst_gl_buffer_pool_get_gl_allocation_params (GstGLBufferPool * pool); + +GST_GL_API +GstGLAllocationParams * gst_buffer_pool_config_get_gl_allocation_params (GstStructure * config); +GST_GL_API +void gst_buffer_pool_config_set_gl_allocation_params (GstStructure * config, + const GstGLAllocationParams * params); + +G_END_DECLS + +#endif /* _GST_GL_BUFFER_POOL_H_ */ diff --git a/include/gst/gl/gstglcolorconvert.h b/include/gst/gl/gstglcolorconvert.h new file mode 100644 index 0000000000..4512fe17c6 --- /dev/null +++ b/include/gst/gl/gstglcolorconvert.h @@ -0,0 +1,156 @@ +/* + * 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_GL_API +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_EXT_FORMATS: (skip) + * + */ +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +#define GST_GL_COLOR_CONVERT_EXT_FORMATS \ + ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE, Y212_LE, Y412_LE" +#else +#define GST_GL_COLOR_CONVERT_EXT_FORMATS \ + ", P010_10BE, P012_BE, P016_BE, Y212_BE, Y412_BE" +#endif + +/** + * 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, GBRA, GBR, RGBP, BGRP, Y444, I420, YV12, Y42B, " \ + "Y41B, NV12, NV21, NV16, NV61, YUY2, UYVY, Y210, AYUV, " \ + "VUYA, Y410, GRAY8, GRAY16_LE, GRAY16_BE, " \ + "RGB16, BGR16, ARGB64, A420, AV12" \ + GST_GL_COLOR_CONVERT_EXT_FORMATS "}" + +/** + * 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_GL_API +GstGLColorConvert * gst_gl_color_convert_new (GstGLContext * context); + +GST_GL_API +GstCaps * gst_gl_color_convert_transform_caps (GstGLContext * context, + GstPadDirection direction, + GstCaps * caps, + GstCaps * filter); +GST_GL_API +GstCaps * gst_gl_color_convert_fixate_caps (GstGLContext * context, + GstPadDirection direction, + GstCaps * caps, + GstCaps * other); +GST_GL_API +gboolean gst_gl_color_convert_set_caps (GstGLColorConvert * convert, + GstCaps * in_caps, + GstCaps * out_caps); +GST_GL_API +gboolean gst_gl_color_convert_decide_allocation (GstGLColorConvert * convert, + GstQuery * query); + +GST_GL_API +GstBuffer * gst_gl_color_convert_perform (GstGLColorConvert * convert, GstBuffer * inbuf); + +G_END_DECLS + +#endif /* __GST_GL_COLOR_CONVERT_H__ */ diff --git a/include/gst/gl/gstglcontext.h b/include/gst/gl/gstglcontext.h new file mode 100644 index 0000000000..9c1b5d8eff --- /dev/null +++ b/include/gst/gl/gstglcontext.h @@ -0,0 +1,252 @@ +/* + * 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_GL_API +GType gst_gl_context_get_type (void); +#define GST_TYPE_GL_CONTEXT (gst_gl_context_get_type()) + +#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_GL_API +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 + */ +/** + * GstGLContextClass::get_config: + * @context: the #GstGLContext + * + * Retrieve the configuration in use by this context. See also + * gst_gl_context_get_config(). + * + * Returns: (transfer full) (nullable): the configuration chosen for this + * #GstGLContext + * + * Since: 1.20 + */ +/** + * GstGLContextClass::request_config: + * @context: the #GstGLContext + * @gl_config: (nullable) (transfer full): a configuration structure for + * configuring on @context + * + * Request a configuration for this @context to use. + * + * Unknown fields within @gl_config should be ignored by subclasses. + * + * See also gst_gl_context_request_config(). + * + * Returns: Whether @gl_config could be successfull set on @context. + * + * Since: 1.20 + */ +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); + GstStructure *(*get_config) (GstGLContext * context); + gboolean (*request_config) (GstGLContext * context, GstStructure * gl_config); + + /*< private >*/ + gpointer _reserved[GST_PADDING-2]; +}; + +/* methods */ + +GST_GL_API +GstGLContext * gst_gl_context_new (GstGLDisplay *display); +GST_GL_API +GstGLContext * gst_gl_context_new_wrapped (GstGLDisplay *display, + guintptr handle, + GstGLPlatform context_type, + GstGLAPI available_apis); + +GST_GL_API +GstStructure * gst_gl_context_get_config (GstGLContext * context); +GST_GL_API +gboolean gst_gl_context_request_config (GstGLContext * context, GstStructure * gl_config); + +GST_GL_API +gboolean gst_gl_context_activate (GstGLContext *context, gboolean activate); +GST_GL_API +GThread * gst_gl_context_get_thread (GstGLContext *context); +GST_GL_API +GstGLContext * gst_gl_context_get_current (void); + +GST_GL_API +GstGLDisplay * gst_gl_context_get_display (GstGLContext *context); +GST_GL_API +gpointer gst_gl_context_get_proc_address (GstGLContext *context, const gchar *name); +GST_GL_API +GstGLPlatform gst_gl_context_get_gl_platform (GstGLContext *context); +GST_GL_API +GstGLAPI gst_gl_context_get_gl_api (GstGLContext *context); +GST_GL_API +guintptr gst_gl_context_get_gl_context (GstGLContext *context); +GST_GL_API +gboolean gst_gl_context_can_share (GstGLContext * context, GstGLContext *other_context); +GST_GL_API +void gst_gl_context_swap_buffers (GstGLContext * context); + +GST_GL_API +gboolean gst_gl_context_create (GstGLContext *context, GstGLContext *other_context, GError ** error); +GST_GL_API +void gst_gl_context_destroy (GstGLContext *context); + +GST_GL_API +gpointer gst_gl_context_default_get_proc_address (GstGLAPI gl_api, const gchar *name); +GST_GL_API +gpointer gst_gl_context_get_proc_address_with_platform (GstGLPlatform context_type, GstGLAPI gl_api, const gchar *name); + +GST_GL_API +gboolean gst_gl_context_set_window (GstGLContext *context, GstGLWindow *window); +GST_GL_API +GstGLWindow * gst_gl_context_get_window (GstGLContext *context); + +GST_GL_API +void gst_gl_context_get_gl_version (GstGLContext *context, gint *maj, gint *min); +GST_GL_API +gboolean gst_gl_context_check_gl_version (GstGLContext * context, GstGLAPI api, gint maj, gint min); +GST_GL_API +gboolean gst_gl_context_check_feature (GstGLContext *context, const gchar *feature); +GST_GL_API +void gst_gl_context_get_gl_platform_version (GstGLContext * context, gint * major, gint * minor); + +GST_GL_API +guintptr gst_gl_context_get_current_gl_context (GstGLPlatform context_type); +GST_GL_API +GstGLAPI gst_gl_context_get_current_gl_api (GstGLPlatform platform, guint *major, guint *minor); + +GST_GL_API +gboolean gst_gl_context_is_shared (GstGLContext * context); +GST_GL_API +void gst_gl_context_set_shared_with (GstGLContext * context, GstGLContext * share); + +GST_GL_API +gboolean gst_gl_context_fill_info (GstGLContext * context, GError ** error); + +/* FIXME: remove */ +GST_GL_API +void gst_gl_context_thread_add (GstGLContext * context, + GstGLContextThreadFunc func, gpointer data); + +G_END_DECLS + +#endif /* __GST_GL_CONTEXT_H__ */ diff --git a/include/gst/gl/gstglcontextconfig.h b/include/gst/gl/gstglcontextconfig.h new file mode 100644 index 0000000000..af33013742 --- /dev/null +++ b/include/gst/gl/gstglcontextconfig.h @@ -0,0 +1,160 @@ +/* + * GStreamer + * Copyright (C) 2020 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_CONTEXT_CONFIG_H__ +#define __GST_GL_CONTEXT_CONFIG_H__ + +#include <gst/gst.h> + +#include <gst/gl/gstgl_fwd.h> + +G_BEGIN_DECLS + +/** + * GST_GL_CONFIG_STRUCTURE_NAME: + * + * The canonical name of a #GstStructure that contains a configuration for a + * #GstGLContext. + * + * Since: 1.20 + */ +#define GST_GL_CONFIG_STRUCTURE_NAME "gst-gl-context-config" + +/** + * GST_GL_CONFIG_ATTRIB_NAME: + * + * Get a reference to the variable name of a particular configuration field. + * + * e.g. for `CONFIG_ID`: `GST_GL_CONFIG_ATTRIB_NAME (CONFIG_ID)` + * + * Since: 1.20 + */ +#define GST_GL_CONFIG_ATTRIB_NAME(UPPER_NAME) \ + G_PASTE(G_PASTE(GST_GL_CONFIG_ATTRIB_,UPPER_NAME),_NAME) +/** + * GST_GL_CONFIG_ATTRIB_GTYPE: + * + * Get a reference to the #GType of a particular configuration field. + * + * e.g. for `CONFIG_ID`: `GST_GL_CONFIG_ATTRIB_GTYPE (CONFIG_ID)` + * + * Since: 1.20 + */ +#define GST_GL_CONFIG_ATTRIB_GTYPE(UPPER_NAME) \ + G_PASTE(G_PASTE(GST_GL_CONFIG_ATTRIB_,UPPER_NAME),_GTYPE) + +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_CONFIG_ID_NAME; +#define GST_GL_CONFIG_ATTRIB_CONFIG_ID_GTYPE G_TYPE_UINT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_PLATFORM_NAME; +#define GST_GL_CONFIG_ATTRIB_PLATFORM_GTYPE GST_TYPE_GL_PLATFORM +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_CAVEAT_NAME; +#define GST_GL_CONFIG_ATTRIB_CAVEAT_GTYPE GST_TYPE_GL_CONFIG_CAVEAT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_SURFACE_TYPE_NAME; +#define GST_GL_CONFIG_ATTRIB_SURFACE_TYPE_GTYPE GST_TYPE_GL_CONFIG_SURFACE_TYPE +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_CONFORMANT_API_NAME; +#define GST_GL_CONFIG_ATTRIB_CONFORMANT_API_GTYPE GST_TYPE_GL_API +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_RENDERABLE_API_NAME; +#define GST_GL_CONFIG_ATTRIB_RENDERABLE_API_GTYPE GST_TYPE_GL_API +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_RED_SIZE_NAME; +#define GST_GL_CONFIG_ATTRIB_RED_SIZE_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_GREEN_SIZE_NAME; +#define GST_GL_CONFIG_ATTRIB_GREEN_SIZE_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_BLUE_SIZE_NAME; +#define GST_GL_CONFIG_ATTRIB_BLUE_SIZE_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_ALPHA_SIZE_NAME; +#define GST_GL_CONFIG_ATTRIB_ALPHA_SIZE_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_LUMINANCE_SIZE_NAME; +#define GST_GL_CONFIG_ATTRIB_LUMINANCE_SIZE_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_DEPTH_SIZE_NAME; +#define GST_GL_CONFIG_ATTRIB_DEPTH_SIZE_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_STENCIL_SIZE_NAME; +#define GST_GL_CONFIG_ATTRIB_STENCIL_SIZE_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_WIDTH_NAME; +#define GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_WIDTH_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_HEIGHT_NAME; +#define GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_HEIGHT_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_PIXELS_NAME; +#define GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_PIXELS_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_SAMPLE_BUFFERS_NAME; +#define GST_GL_CONFIG_ATTRIB_SAMPLE_BUFFERS_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_SAMPLES_NAME; +#define GST_GL_CONFIG_ATTRIB_SAMPLES_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_NATIVE_RENDERABLE_NAME; +#define GST_GL_CONFIG_ATTRIB_NATIVE_RENDERABLE_GTYPE G_TYPE_BOOLEAN +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_NATIVE_VISUAL_ID_NAME; +#define GST_GL_CONFIG_ATTRIB_NATIVE_VISUAL_ID_GTYPE G_TYPE_UINT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_LEVEL_NAME; +#define GST_GL_CONFIG_ATTRIB_LEVEL_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_MIN_SWAP_INTERVAL_NAME; +#define GST_GL_CONFIG_ATTRIB_MIN_SWAP_INTERVAL_GTYPE G_TYPE_INT +GST_GL_API const char * GST_GL_CONFIG_ATTRIB_MAX_SWAP_INTERVAL_NAME; +#define GST_GL_CONFIG_ATTRIB_MAX_SWAP_INTERVAL_GTYPE G_TYPE_INT + +/** + * GST_GL_CONFIG_STRUCTURE_SET_ARGS: + * + * Since: 1.20 + */ +#define GST_GL_CONFIG_STRUCTURE_SET_ARGS(def_name,ctype,val) \ + GST_GL_CONFIG_ATTRIB_NAME(def_name), \ + GST_GL_CONFIG_ATTRIB_GTYPE(def_name), \ + (ctype) (val) + +/** + * GstGLConfigCaveat: + * @GST_GL_CONFIG_CAVEAT_NONE: none + * @GST_GL_CONFIG_CAVEAT_SLOW: slow + * @GST_GL_CONFIG_CAVEAT_NON_CONFORMANT: non-conformant + * + * Since: 1.20 + */ +typedef enum +{ + GST_GL_CONFIG_CAVEAT_NONE, + GST_GL_CONFIG_CAVEAT_SLOW, + GST_GL_CONFIG_CAVEAT_NON_CONFORMANT, +} GstGLConfigCaveat; + +GST_GL_API +const gchar * gst_gl_config_caveat_to_string (GstGLConfigCaveat caveat); + +/** + * GstGLConfigSurfaceType: + * @GST_GL_CONFIG_SURFACE_TYPE_NONE: none + * @GST_GL_CONFIG_SURFACE_TYPE_WINDOW: window + * @GST_GL_CONFIG_SURFACE_TYPE_PBUFFER: pbuffer + * @GST_GL_CONFIG_SURFACE_TYPE_PIXMAP: pixmap + * + * Since: 1.20 + */ +typedef enum +{ + GST_GL_CONFIG_SURFACE_TYPE_NONE = 0, + GST_GL_CONFIG_SURFACE_TYPE_WINDOW = (1 << 0), + GST_GL_CONFIG_SURFACE_TYPE_PBUFFER = (1 << 1), + GST_GL_CONFIG_SURFACE_TYPE_PIXMAP = (1 << 2), +} GstGLConfigSurfaceType; + +GST_GL_API +const gchar * gst_gl_config_surface_type_to_string (GstGLConfigSurfaceType surface_type); + +G_END_DECLS + +#endif /* __GST_GL_CONTEXT_CONFIG_H__ */ diff --git a/include/gst/gl/gstgldebug.h b/include/gst/gl/gstgldebug.h new file mode 100644 index 0000000000..543335605f --- /dev/null +++ b/include/gst/gl/gstgldebug.h @@ -0,0 +1,182 @@ +/* + * 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 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_GL_API +GstGLAsyncDebug * gst_gl_async_debug_new (void); +GST_GL_API +void gst_gl_async_debug_free (GstGLAsyncDebug * ad); +GST_GL_API +void gst_gl_async_debug_init (GstGLAsyncDebug * ad); +GST_GL_API +void gst_gl_async_debug_unset (GstGLAsyncDebug * ad); +GST_GL_API +void gst_gl_async_debug_freeze (GstGLAsyncDebug * ad); +GST_GL_API +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 #GstDebugLevel + * @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 #GstDebugLevel + * @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 + */ +#ifdef 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_GL_API +void gst_gl_insert_debug_marker (GstGLContext * context, + const gchar * format, ...) G_GNUC_PRINTF (2, 3); +GST_GL_API +void gst_gl_async_debug_output_log_msg (GstGLAsyncDebug * ad); +GST_GL_API +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_GL_API +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 + +#ifdef G_HAVE_ISO_VARARGS + +#define gst_gl_insert_debug_marker(...) G_STMT_START{ }G_STMT_END +#define gst_gl_async_debug_store_log_msg(...) G_STMT_START{ }G_STMT_END + +#else /* G_HAVE_ISO_VARARGS */ +#if G_HAVE_GNUC_VARARGS + +#define gst_gl_insert_debug_marker(args...) G_STMT_START{ }G_STMT_END +#define gst_gl_async_debug_store_log_msg(args...) G_STMT_START{ }G_STMT_END + +#else /* G_HAVE_GNUC_VARARGS */ + +static inline void +gst_gl_insert_debug_marker (GstGLContext * context, const gchar * format, ...) +{ +} + +static inline void +gst_gl_async_debug_store_log_msg (GstGLAsyncDebug * ad, + GstDebugCategory * cat, GstDebugLevel level, const gchar * file, + const gchar * function, gint line, GstObject * object, + const gchar * format, ...) +{ +} + +#endif /* G_HAVE_GNUC_VARARGS */ +#endif /* G_HAVE_ISO_VARARGS */ +#endif /* GST_DISABLE_GST_DEBUG */ + +G_END_DECLS + +#endif /* __GST_GL_DEBUG_H__ */ diff --git a/include/gst/gl/gstgldisplay.h b/include/gst/gl/gstgldisplay.h new file mode 100644 index 0000000000..9f52d109f8 --- /dev/null +++ b/include/gst/gl/gstgldisplay.h @@ -0,0 +1,190 @@ +/* + * 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_GL_API +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_GBM: Mesa3D GBM display + * @GST_GL_DISPLAY_TYPE_ANY: any display type + */ +/** + * GST_GL_DISPLAY_TYPE_EGL_DEVICE: + * + * EGLDevice display. + * + * Since: 1.18 + */ +/** + * GST_GL_DISPLAY_TYPE_EAGL: + * + * EAGL display. + * + * Since: 1.20 + */ +/** + * GST_GL_DISPLAY_TYPE_WINRT: + * + * WinRT display. + * + * Since: 1.20 + */ +/** + * GST_GL_DISPLAY_TYPE_ANDROID: + * + * Android display. + * + * Since: 1.20 + */ +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_GBM = (1 << 7), + GST_GL_DISPLAY_TYPE_EGL_DEVICE = (1 << 8), + GST_GL_DISPLAY_TYPE_EAGL = (1 << 9), + GST_GL_DISPLAY_TYPE_WINRT = (1 << 10), + GST_GL_DISPLAY_TYPE_ANDROID = (1 << 11), + + 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; /* internal lock, use *_window functions instead */ + 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_GL_API +GstGLDisplay *gst_gl_display_new (void); +GST_GL_API +GstGLDisplay *gst_gl_display_new_with_type (GstGLDisplayType type); + +#define gst_gl_display_lock(display) GST_OBJECT_LOCK (display) +#define gst_gl_display_unlock(display) GST_OBJECT_UNLOCK (display) + +GST_GL_API +guintptr gst_gl_display_get_handle (GstGLDisplay * display); +GST_GL_API +GstGLDisplayType gst_gl_display_get_handle_type (GstGLDisplay * display); +GST_GL_API +void gst_gl_display_filter_gl_api (GstGLDisplay * display, + GstGLAPI gl_api); +GST_GL_API +GstGLAPI gst_gl_display_get_gl_api (GstGLDisplay * display); +GST_GL_API +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_GL_API +void gst_context_set_gl_display (GstContext * context, GstGLDisplay * display); +GST_GL_API +gboolean gst_context_get_gl_display (GstContext * context, GstGLDisplay ** display); + +GST_GL_API +gboolean gst_gl_display_create_context (GstGLDisplay * display, + GstGLContext * other_context, GstGLContext ** p_context, GError **error); +GST_GL_API +GstGLContext * gst_gl_display_get_gl_context_for_thread (GstGLDisplay * display, + GThread * thread); +GST_GL_API +gboolean gst_gl_display_add_context (GstGLDisplay * display, + GstGLContext * context); +GST_GL_API +void gst_gl_display_remove_context (GstGLDisplay * display, + GstGLContext * context); + +GST_GL_API +GstGLWindow * gst_gl_display_create_window (GstGLDisplay * display); +GST_GL_API +gboolean gst_gl_display_remove_window (GstGLDisplay * display, GstGLWindow * window); +GST_GL_API G_DEPRECATED_FOR(gst_gl_display_retrieve_window) +GstGLWindow * gst_gl_display_find_window (GstGLDisplay * display, gpointer data, GCompareFunc compare_func); +GST_GL_API +GstGLWindow * gst_gl_display_retrieve_window (GstGLDisplay * display, gpointer data, GCompareFunc compare_func); + +G_END_DECLS + +#endif /* __GST_GL_DISPLAY_H__ */ diff --git a/include/gst/gl/gstglfeature.h b/include/gst/gl/gstglfeature.h new file mode 100644 index 0000000000..780f2594fb --- /dev/null +++ b/include/gst/gl/gstglfeature.h @@ -0,0 +1,62 @@ +/* + * 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_GL_API +gboolean gst_gl_check_extension (const char *name, const gchar * ext); + +G_END_DECLS + +#endif /* __GST_GL_FEATURE_H__ */ diff --git a/include/gst/gl/gstglfilter.h b/include/gst/gl/gstglfilter.h new file mode 100644 index 0000000000..7f8108af42 --- /dev/null +++ b/include/gst/gl/gstglfilter.h @@ -0,0 +1,149 @@ +/* + * 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_GL_API +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: + * @in_info: the video info for input buffers + * @out_info: the video info for output buffers + * @in_texture_target: The texture target of the input buffers (usually 2D) + * @out_texture_target: The texture target of the output buffers (usually 2D) + * @out_caps: the output #GstCaps + * @fbo: #GstGLFramebuffer object used for transformations (only for subclass usage) + */ +struct _GstGLFilter +{ + GstGLBaseFilter parent; + + /*< public >*/ + GstVideoInfo in_info; + GstVideoInfo out_info; + GstGLTextureTarget in_texture_target; + GstGLTextureTarget out_texture_target; + + 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: + * @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; + + /*< public >*/ + gboolean (*set_caps) (GstGLFilter* filter, GstCaps* incaps, GstCaps* outcaps); + gboolean (*filter) (GstGLFilter *filter, GstBuffer *inbuf, GstBuffer *outbuf); + gboolean (*filter_texture) (GstGLFilter *filter, GstGLMemory *input, GstGLMemory *output); + gboolean (*init_fbo) (GstGLFilter *filter); + + GstCaps *(*transform_internal_caps) (GstGLFilter *filter, + GstPadDirection direction, GstCaps * caps, GstCaps * filter_caps); + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + +GST_GL_API +void gst_gl_filter_add_rgba_pad_templates (GstGLFilterClass *klass); + +GST_GL_API +gboolean gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * input, + GstBuffer * output); + +GST_GL_API +gboolean gst_gl_filter_render_to_target (GstGLFilter *filter, + GstGLMemory * input, + GstGLMemory * output, + GstGLFilterRenderFunc func, + gpointer data); + +GST_GL_API +void gst_gl_filter_draw_fullscreen_quad (GstGLFilter *filter); +GST_GL_API +void gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter, + GstGLMemory * input, + GstGLMemory * output, + GstGLShader *shader); + +G_END_DECLS + +#endif /* _GST_GL_FILTER_H_ */ diff --git a/include/gst/gl/gstglformat.h b/include/gst/gl/gstglformat.h new file mode 100644 index 0000000000..0db5a1422a --- /dev/null +++ b/include/gst/gl/gstglformat.h @@ -0,0 +1,171 @@ +/* + * 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_RGB16: Three 16-bit components stored in the R, G, and B + * texture components + * @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_RGBA16: Four 16-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. + * @GST_GL_RGBA10_A2: Four components of bit depth 10, 10, 10 and 2 stored in the + * R, G, B and A texture components respectively. + * @GST_GL_R16: Single 16-bit component stored in the R texture component + * @GST_GL_RG16: Two 16-bit components stored in the R and G texture components + */ +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_RGB16 = 0x8054, + + GST_GL_RGBA = 0x1908, + GST_GL_RGBA8 = 0x8058, + GST_GL_RGBA16 = 0x805B, + + GST_GL_DEPTH_COMPONENT16 = 0x81A5, + + GST_GL_DEPTH24_STENCIL8 = 0x88F0, + + GST_GL_RGB10_A2 = 0x8059, + + GST_GL_R16 = 0x822A, + GST_GL_RG16 = 0x822C, +} GstGLFormat; + +GST_GL_API +guint gst_gl_format_type_n_bytes (guint format, + guint type); +GST_GL_API +GstGLFormat gst_gl_format_from_video_info (GstGLContext * context, + const GstVideoInfo * vinfo, + guint plane); +GST_GL_API +guint gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context, + guint format, + guint type); +GST_GL_API +void gst_gl_format_type_from_sized_gl_format (GstGLFormat format, + GstGLFormat * unsized_format, + guint * gl_type); + +GST_GL_API +gboolean gst_gl_format_is_supported (GstGLContext * context, + GstGLFormat format); + +GST_GL_API +GstGLTextureTarget gst_gl_texture_target_from_string (const gchar * str); +GST_GL_API +const gchar * gst_gl_texture_target_to_string (GstGLTextureTarget target); +GST_GL_API +guint gst_gl_texture_target_to_gl (GstGLTextureTarget target); +GST_GL_API +GstGLTextureTarget gst_gl_texture_target_from_gl (guint target); +GST_GL_API +const gchar * gst_gl_texture_target_to_buffer_pool_option (GstGLTextureTarget target); + +G_END_DECLS + +#endif /* _GST_GL_FORMAT_H_ */ diff --git a/include/gst/gl/gstglframebuffer.h b/include/gst/gl/gstglframebuffer.h new file mode 100644 index 0000000000..5ee4aa0bb7 --- /dev/null +++ b/include/gst/gl/gstglframebuffer.h @@ -0,0 +1,119 @@ +/* + * 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_GL_API +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_GL_API +GstGLFramebuffer * gst_gl_framebuffer_new (GstGLContext *context); +GST_GL_API +GstGLFramebuffer * gst_gl_framebuffer_new_with_default_depth (GstGLContext *context, + guint width, + guint height); + +GST_GL_API +guint gst_gl_framebuffer_get_id (GstGLFramebuffer * fb); + +GST_GL_API +void gst_gl_framebuffer_attach (GstGLFramebuffer * fb, + guint attachment_point, + GstGLBaseMemory * mem); +GST_GL_API +void gst_gl_framebuffer_bind (GstGLFramebuffer * fb); +GST_GL_API +void gst_gl_context_clear_framebuffer (GstGLContext * context); + +GST_GL_API +void gst_gl_framebuffer_get_effective_dimensions (GstGLFramebuffer * fb, + guint * width, + guint * height); + +GST_GL_API +gboolean gst_gl_context_check_framebuffer_status (GstGLContext * context, + guint fbo_target); + +GST_GL_API +gboolean gst_gl_framebuffer_draw_to_texture (GstGLFramebuffer * fb, + GstGLMemory * mem, + GstGLFramebufferFunc func, + gpointer user_data); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLFramebuffer, gst_object_unref) + +G_END_DECLS + +#endif diff --git a/include/gst/gl/gstglfuncs.h b/include/gst/gl/gstglfuncs.h new file mode 100644 index 0000000000..81ba4d5f99 --- /dev/null +++ b/include/gst/gl/gstglfuncs.h @@ -0,0 +1,111 @@ +/* + * 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__ +# if !defined(MAC_OS_X_VERSION_MAX_ALLOWED) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1014 +# define GL_SILENCE_DEPRECATION +# endif +# 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() + +struct _GstGLFuncs +{ +#include <gst/gl/glprototypes/all_functions.h> + gpointer padding[GST_PADDING_LARGE*6-2]; +}; + +#undef GST_GL_EXT_BEGIN +#undef GST_GL_EXT_FUNCTION +#undef GST_GL_EXT_END + +G_END_DECLS + +#endif /* __GST_GL_API_H__ */ diff --git a/include/gst/gl/gstglmemory.h b/include/gst/gl/gstglmemory.h new file mode 100644 index 0000000000..daea4d12a7 --- /dev/null +++ b/include/gst/gl/gstglmemory.h @@ -0,0 +1,327 @@ +/* + * GStreamer + * Copyright (C) 2015 Matthew Waters <matthew@centricular.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GST_GL_MEMORY_H_ +#define _GST_GL_MEMORY_H_ + +#include <gst/gl/gstglbasememory.h> +#include <gst/gl/gstglformat.h> + +G_BEGIN_DECLS + +#define GST_TYPE_GL_MEMORY_ALLOCATOR (gst_gl_memory_allocator_get_type()) +GST_GL_API +GType gst_gl_memory_allocator_get_type(void); + +#define GST_IS_GL_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_MEMORY_ALLOCATOR)) +#define GST_IS_GL_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GL_MEMORY_ALLOCATOR)) +#define GST_GL_MEMORY_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GL_MEMORY_ALLOCATOR, GstGLMemoryAllocatorClass)) +#define GST_GL_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_MEMORY_ALLOCATOR, GstGLMemoryAllocator)) +#define GST_GL_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_MEMORY_ALLOCATOR, GstGLMemoryAllocatorClass)) +#define GST_GL_MEMORY_ALLOCATOR_CAST(obj) ((GstGLMemoryAllocator *)(obj)) + +#define GST_GL_MEMORY_CAST(obj) ((GstGLMemory *) obj) + +/** + * GST_CAPS_FEATURE_MEMORY_GL_MEMORY: + * + * Name of the caps feature for indicating the use of #GstGLMemory + */ +#define GST_CAPS_FEATURE_MEMORY_GL_MEMORY "memory:GLMemory" +/** + * GST_GL_MEMORY_VIDEO_EXT_FORMATS: (skip) + */ +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +#define GST_GL_MEMORY_VIDEO_EXT_FORMATS \ + ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE, Y212_LE, Y412_LE" +#else +#define GST_GL_MEMORY_VIDEO_EXT_FORMATS \ + ", P010_10BE, P012_BE, P016_BE, Y212_BE, Y412_BE" +#endif + +/** + * GST_GL_MEMORY_VIDEO_FORMATS_STR: + * + * List of video formats that are supported by #GstGLMemory + */ +#define GST_GL_MEMORY_VIDEO_FORMATS_STR \ + "{ RGBA, BGRA, RGBx, BGRx, ARGB, ABGR, xRGB, xBGR, GBRA, GBR, RGBP, BGRP, RGB, BGR, RGB16, BGR16, " \ + "AYUV, VUYA, Y410, I420, YV12, NV12, NV21, NV16, NV61, YUY2, UYVY, Y210, Y41B, " \ + "Y42B, Y444, GRAY8, GRAY16_LE, GRAY16_BE, ARGB64, A420, AV12" \ + GST_GL_MEMORY_VIDEO_EXT_FORMATS "}" + +/** + * GstGLMemory: + * @mem: the parent #GstGLBaseMemory object + * @tex_id: the GL texture id for this memory + * @tex_target: the GL texture target for this memory + * @tex_format: the texture type + * @info: the texture's #GstVideoInfo + * @valign: data alignment for system memory mapping + * @plane: data plane in @info + * @tex_scaling: GL shader scaling parameters for @valign and/or width/height + * + * Represents information about a GL texture + */ +struct _GstGLMemory +{ + GstGLBaseMemory mem; + + guint tex_id; + GstGLTextureTarget tex_target; + GstGLFormat tex_format; + GstVideoInfo info; + GstVideoAlignment valign; + guint plane; + gfloat tex_scaling[2]; + + /*< protected >*/ + gboolean texture_wrapped; + guint unpack_length; + guint tex_width; + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + + +#define GST_TYPE_GL_VIDEO_ALLOCATION_PARAMS (gst_gl_video_allocation_params_get_type()) +GST_GL_API +GType gst_gl_video_allocation_params_get_type (void); + +typedef struct _GstGLVideoAllocationParams GstGLVideoAllocationParams; + +/** + * GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO: + * + * GL allocation flag indicating the allocation of 2D video frames + */ +#define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO (1 << 3) + +/** + * GstGLVideoAllocationParams: + * @parent: the parent #GstGLAllocationParams structure + * @v_info: the #GstVideoInfo to allocate + * @plane: the video plane index to allocate + * @valign: the #GstVideoAlignment to align the system representation to (may be %NULL for the default) + * @target: the #GstGLTextureTarget to allocate + * @tex_format: the #GstGLFormat to allocate + */ +struct _GstGLVideoAllocationParams +{ + GstGLAllocationParams parent; + + GstVideoInfo *v_info; + guint plane; + GstVideoAlignment *valign; + GstGLTextureTarget target; + GstGLFormat tex_format; + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + +GST_GL_API +gboolean gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params, + gsize struct_size, + guint alloc_flags, + GstGLAllocationParamsCopyFunc copy, + GstGLAllocationParamsFreeFunc free, + GstGLContext * context, + const GstAllocationParams * alloc_params, + const GstVideoInfo * v_info, + guint plane, + const GstVideoAlignment * valign, + GstGLTextureTarget target, + GstGLFormat tex_format, + gpointer wrapped_data, + gpointer gl_handle, + gpointer user_data, + GDestroyNotify notify); +GST_GL_API +GstGLVideoAllocationParams * gst_gl_video_allocation_params_new (GstGLContext * context, + const GstAllocationParams * alloc_params, + const GstVideoInfo * v_info, + guint plane, + const GstVideoAlignment * valign, + GstGLTextureTarget target, + GstGLFormat tex_format); +GST_GL_API +GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context, + const GstAllocationParams * alloc_params, + const GstVideoInfo * v_info, + guint plane, + const GstVideoAlignment * valign, + GstGLTextureTarget target, + GstGLFormat tex_format, + gpointer wrapped_data, + gpointer user_data, + GDestroyNotify notify); + +GST_GL_API +GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_texture (GstGLContext * context, + const GstAllocationParams * alloc_params, + const GstVideoInfo * v_info, + guint plane, + const GstVideoAlignment * valign, + GstGLTextureTarget target, + GstGLFormat tex_format, + guint tex_id, + gpointer user_data, + GDestroyNotify notify); + +GST_GL_API +GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context, + const GstAllocationParams * alloc_params, + const GstVideoInfo * v_info, + guint plane, + const GstVideoAlignment * valign, + GstGLTextureTarget target, + GstGLFormat tex_format, + gpointer gl_handle, + gpointer user_data, + GDestroyNotify notify); + +/* subclass usage */ +GST_GL_API +void gst_gl_video_allocation_params_free_data (GstGLVideoAllocationParams * params); +/* subclass usage */ +GST_GL_API +void gst_gl_video_allocation_params_copy_data (GstGLVideoAllocationParams * src_vid, + GstGLVideoAllocationParams * dest_vid); + +/** + * GstGLMemoryAllocator + * + * Opaque #GstGLMemoryAllocator struct + */ +struct _GstGLMemoryAllocator +{ + /*< private >*/ + GstGLBaseMemoryAllocator parent; + + gpointer _padding[GST_PADDING]; +}; + +/** + * GstGLMemoryAllocatorClass: + * @map: provide a custom map implementation + * @copy: provide a custom copy implementation + * @unmap: provide a custom unmap implementation + */ +struct _GstGLMemoryAllocatorClass +{ + /*< private >*/ + GstGLBaseMemoryAllocatorClass parent_class; + + /*< public >*/ + GstGLBaseMemoryAllocatorMapFunction map; + GstGLBaseMemoryAllocatorCopyFunction copy; + GstGLBaseMemoryAllocatorUnmapFunction unmap; + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + +#include <gst/gl/gstglbasememory.h> + +/** + * GST_GL_MEMORY_ALLOCATOR_NAME: + * + * The name of the GL memory allocator + */ +#define GST_GL_MEMORY_ALLOCATOR_NAME "GLMemory" + +/** + * GST_TYPE_GL_MEMORY: + * + * Since: 1.20 + */ +#define GST_TYPE_GL_MEMORY (gst_gl_memory_get_type()) +GST_GL_API +GType gst_gl_memory_get_type(void); + +GST_GL_API +void gst_gl_memory_init_once (void); +GST_GL_API +gboolean gst_is_gl_memory (GstMemory * mem); + +GST_GL_API +void gst_gl_memory_init (GstGLMemory * mem, + GstAllocator * allocator, + GstMemory * parent, + GstGLContext * context, + GstGLTextureTarget target, + GstGLFormat tex_format, + const GstAllocationParams *params, + const GstVideoInfo * info, + guint plane, + const GstVideoAlignment *valign, + gpointer user_data, + GDestroyNotify notify); + +GST_GL_API +gboolean gst_gl_memory_copy_into (GstGLMemory *gl_mem, + guint tex_id, + GstGLTextureTarget target, + GstGLFormat tex_format, + gint width, + gint height); +GST_GL_API +gboolean gst_gl_memory_copy_teximage (GstGLMemory * src, + guint tex_id, + GstGLTextureTarget out_target, + GstGLFormat out_tex_format, + gint out_width, + gint out_height); + +GST_GL_API +gboolean gst_gl_memory_read_pixels (GstGLMemory * gl_mem, + gpointer write_pointer); +GST_GL_API +void gst_gl_memory_texsubimage (GstGLMemory * gl_mem, + gpointer read_pointer); + +/* accessors */ +GST_GL_API +gint gst_gl_memory_get_texture_width (GstGLMemory * gl_mem); +GST_GL_API +gint gst_gl_memory_get_texture_height (GstGLMemory * gl_mem); +GST_GL_API +GstGLFormat gst_gl_memory_get_texture_format (GstGLMemory * gl_mem); +GST_GL_API +GstGLTextureTarget gst_gl_memory_get_texture_target (GstGLMemory * gl_mem); +GST_GL_API +guint gst_gl_memory_get_texture_id (GstGLMemory * gl_mem); + +GST_GL_API +gboolean gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator, + GstBuffer * buffer, + GstGLVideoAllocationParams * params, + GstGLFormat *tex_formats, + gpointer *wrapped_data, + gsize n_wrapped_pointers); + +GST_GL_API +GstGLMemoryAllocator * gst_gl_memory_allocator_get_default (GstGLContext *context); + +G_END_DECLS + +#endif /* _GST_GL_MEMORY_H_ */ diff --git a/include/gst/gl/gstglmemorypbo.h b/include/gst/gl/gstglmemorypbo.h new file mode 100644 index 0000000000..f40ca4f5e2 --- /dev/null +++ b/include/gst/gl/gstglmemorypbo.h @@ -0,0 +1,119 @@ +/* + * GStreamer + * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com> + * Copyright (C) 2015 Matthew Waters <matthew@centricular.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GST_GL_MEMORY_PBO_H_ +#define _GST_GL_MEMORY_PBO_H_ + +#include <gst/gl/gstglmemory.h> + +G_BEGIN_DECLS + +#define GST_TYPE_GL_MEMORY_PBO_ALLOCATOR (gst_gl_memory_pbo_allocator_get_type()) +GST_GL_API +GType gst_gl_memory_pbo_allocator_get_type(void); + +#define GST_IS_GL_MEMORY_PBO_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_MEMORY_PBO_ALLOCATOR)) +#define GST_IS_GL_MEMORY_PBO_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GL_MEMORY_PBO_ALLOCATOR)) +#define GST_GL_MEMORY_PBO_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GL_MEMORY_PBO_ALLOCATOR, GstGLMemoryPBOAllocatorClass)) +#define GST_GL_MEMORY_PBO_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_MEMORY_PBO_ALLOCATOR, GstGLMemoryPBOAllocator)) +#define GST_GL_MEMORY_PBO_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_MEMORY_PBO_ALLOCATOR, GstGLMemoryPBOAllocatorClass)) +#define GST_GL_MEMORY_PBO_ALLOCATOR_CAST(obj) ((GstGLMemoryPBOAllocator *)(obj)) + +/** + * GstGLMemoryPBO: + * + * Private instance + */ +struct _GstGLMemoryPBO +{ + /*< private >*/ + GstGLMemory mem; + + GstGLBuffer *pbo; + + gpointer _padding[GST_PADDING]; +}; + +/** + * GST_GL_MEMORY_PBO_ALLOCATOR_NAME: + * + * The name of the GL Memory PBO allocator + */ +#define GST_GL_MEMORY_PBO_ALLOCATOR_NAME "GLMemoryPBO" + +/** + * GST_TYPE_GL_MEMORY_PBO + * + * Since: 1.20 + */ +#define GST_TYPE_GL_MEMORY_PBO (gst_gl_memory_pbo_get_type()) +GST_GL_API +GType gst_gl_memory_pbo_get_type(void); + +GST_GL_API +void gst_gl_memory_pbo_init_once (void); +GST_GL_API +gboolean gst_is_gl_memory_pbo (GstMemory * mem); + +GST_GL_API +void gst_gl_memory_pbo_download_transfer (GstGLMemoryPBO * gl_mem); +GST_GL_API +void gst_gl_memory_pbo_upload_transfer (GstGLMemoryPBO * gl_mem); + +GST_GL_API +gboolean gst_gl_memory_pbo_copy_into_texture (GstGLMemoryPBO *gl_mem, + guint tex_id, + GstGLTextureTarget target, + GstGLFormat tex_format, + gint width, + gint height, + gint stride, + gboolean respecify); + +/** + * GstGLMemoryPBOAllocator: + * + * Opaque #GstGLMemoryPBOAllocator struct + */ +struct _GstGLMemoryPBOAllocator +{ + GstGLMemoryAllocator parent; + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + +/** + * GstGLMemoryPBOAllocatorClass: + * + * Only contains private data + */ +struct _GstGLMemoryPBOAllocatorClass +{ + GstGLMemoryAllocatorClass parent_class; + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + +G_END_DECLS + +#endif /* _GST_GL_MEMORY_PBO_H_ */ diff --git a/include/gst/gl/gstgloverlaycompositor.h b/include/gst/gl/gstgloverlaycompositor.h new file mode 100644 index 0000000000..705963ee97 --- /dev/null +++ b/include/gst/gl/gstgloverlaycompositor.h @@ -0,0 +1,92 @@ +/* + * GStreamer + * Copyright (C) 2015 Lubosz Sarnecki <lubosz.sarnecki@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_GL_OVERLAY_COMPOSITOR_H__ +#define __GST_GL_OVERLAY_COMPOSITOR_H__ + +#include <gst/video/video.h> +#include <gst/gl/gstgl_fwd.h> + +#define GST_TYPE_GL_OVERLAY_COMPOSITOR (gst_gl_overlay_compositor_get_type()) +#define GST_GL_OVERLAY_COMPOSITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_OVERLAY_COMPOSITOR,GstGLOverlayCompositor)) +#define GST_GL_OVERLAY_COMPOSITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_OVERLAY_COMPOSITOR,GstGLOverlayCompositorClass)) +#define GST_IS_GL_OVERLAY_COMPOSITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_OVERLAY_COMPOSITOR)) +#define GST_IS_GL_OVERLAY_COMPOSITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_OVERLAY_COMPOSITOR)) +#define GST_GL_OVERLAY_COMPOSITOR_CAST(obj) ((GstGLOverlayCompositor*)(obj)) + +G_BEGIN_DECLS + +GST_GL_API +GType gst_gl_overlay_compositor_get_type (void); + +/** + * GstGLOverlayCompositor: + * + * Opaque #GstGLOverlayCompositor object + */ +struct _GstGLOverlayCompositor +{ + /*< private >*/ + GstObject parent; + + GstGLContext *context; + + guint last_window_width; + guint last_window_height; + + GList * overlays; + + GstGLShader *shader; + gint position_attrib; + gint texcoord_attrib; + + gpointer _padding[GST_PADDING]; +}; + +/** + * GstGLOverlayCompositorClass: + * + */ +struct _GstGLOverlayCompositorClass +{ + GstObjectClass object_class; + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + +GST_GL_API +GstGLOverlayCompositor *gst_gl_overlay_compositor_new (GstGLContext * context); + +GST_GL_API +void gst_gl_overlay_compositor_free_overlays (GstGLOverlayCompositor * compositor); + +GST_GL_API +void gst_gl_overlay_compositor_upload_overlays (GstGLOverlayCompositor * compositor, + GstBuffer * buf); + +GST_GL_API +void gst_gl_overlay_compositor_draw_overlays (GstGLOverlayCompositor * compositor); + +GST_GL_API +GstCaps * gst_gl_overlay_compositor_add_caps(GstCaps * caps); + +G_END_DECLS +#endif /* __GST_GL_OVERLAY_COMPOSITOR_H__ */ diff --git a/include/gst/gl/gstglquery.h b/include/gst/gl/gstglquery.h new file mode 100644 index 0000000000..5c3d4b280a --- /dev/null +++ b/include/gst/gl/gstglquery.h @@ -0,0 +1,162 @@ +/* + * GStreamer + * Copyright (C) 2016 Matthew Waters <matthew@centricular.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_GL_QUERY_H__ +#define __GST_GL_QUERY_H__ + +#include <gst/gl/gstgl_fwd.h> +#include <gst/gl/gstgldebug.h> + +G_BEGIN_DECLS + +/** + * GstGLQueryType: + * @GST_GL_QUERY_NONE: no query + * @GST_GL_QUERY_TIME_ELAPSED: query the time elapsed + * @GST_GL_QUERY_TIMESTAMP: query the current time + */ +typedef enum +{ + GST_GL_QUERY_NONE, + GST_GL_QUERY_TIME_ELAPSED, + GST_GL_QUERY_TIMESTAMP, +} GstGLQueryType; + +/** + * GstGLQuery: + * + * Opaque #GstGLQuery struct + */ +struct _GstGLQuery +{ + /*< private >*/ + GstGLContext * context; + guint query_type; + guint query_id; + gboolean supported; + + gboolean start_called; + GstGLAsyncDebug debug; + + gpointer _padding[GST_PADDING]; +}; + +GST_GL_API +void gst_gl_query_init (GstGLQuery * query, + GstGLContext * context, + GstGLQueryType query_type); +GST_GL_API +void gst_gl_query_unset (GstGLQuery * query); +GST_GL_API +GstGLQuery * gst_gl_query_new (GstGLContext * context, + GstGLQueryType query_type); +GST_GL_API +void gst_gl_query_free (GstGLQuery * query); + +GST_GL_API +void gst_gl_query_start (GstGLQuery * query); +GST_GL_API +void gst_gl_query_end (GstGLQuery * query); +GST_GL_API +void gst_gl_query_counter (GstGLQuery * query); +GST_GL_API +guint64 gst_gl_query_result (GstGLQuery * query); + +#define gst_gl_query_start_log_valist(query,cat,level,object,format,varargs) \ + G_STMT_START { \ + GST_GL_ASYNC_CAT_LEVEL_LOG_valist (&(query)->debug, cat, level, object, format, varargs); \ + gst_gl_async_debug_freeze (&(query)->debug); \ + gst_gl_query_start (query); \ + gst_gl_async_debug_thaw (&(query)->debug); \ + } G_STMT_END + +#define gst_gl_query_counter_log_valist(query,cat,level,object,format,varargs) \ + G_STMT_START { \ + GST_GL_ASYNC_CAT_LEVEL_LOG_valist (&(query)->debug, cat, level, object, format, varargs); \ + gst_gl_async_debug_freeze (&(query)->debug); \ + gst_gl_query_counter (query); \ + gst_gl_async_debug_thaw (&(query)->debug); \ + } G_STMT_END + +#ifdef G_HAVE_ISO_VARARGS + +#define gst_gl_query_start_log(query,cat,level,object,format,...) \ + G_STMT_START { \ + GST_GL_ASYNC_CAT_LEVEL_LOG (&(query)->debug, cat, level, object, format, __VA_ARGS__); \ + gst_gl_async_debug_freeze (&(query)->debug); \ + gst_gl_query_start (query); \ + gst_gl_async_debug_thaw (&(query)->debug); \ + } G_STMT_END +#define gst_gl_query_counter_log(query,cat,level,object,format,...) \ + G_STMT_START { \ + GST_GL_ASYNC_CAT_LEVEL_LOG (&(query)->debug, cat, level, object, format, __VA_ARGS__); \ + gst_gl_async_debug_freeze (&(query)->debug); \ + gst_gl_query_counter (query); \ + gst_gl_async_debug_thaw (&(query)->debug); \ + } G_STMT_END + +#else /* G_HAVE_ISO_VARARGS */ +#if G_HAVE_GNUC_VARARGS + +#define gst_gl_query_start_log(query,cat,level,object,format,args...) \ + G_STMT_START { \ + GST_GL_ASYNC_CAT_LEVEL_LOG (&(query)->debug, cat, level, object, format, ##args); \ + gst_gl_async_debug_freeze (&(query)->debug); \ + gst_gl_query_start (query); \ + gst_gl_async_debug_thaw (&(query)->debug); \ + } G_STMT_END +#define gst_gl_query_counter_log(query,cat,level,object,format,args...) \ + G_STMT_START { \ + GST_GL_ASYNC_CAT_LEVEL_LOG (&(query)->debug, cat, level, object, format, ##args); \ + gst_gl_async_debug_freeze (&(query)->debug); \ + gst_gl_query_counter (query); \ + gst_gl_async_debug_thaw (&(query)->debug); \ + } G_STMT_END + +#else /* G_HAVE_GNUC_VARARGS */ + +static inline void +gst_gl_query_start_log(GstGLQuery * query, GstDebugCategory * cat, + GstDebugLevel level, GObject * object, const gchar * format, ...) +{ + va_list varargs; + + va_start (varargs, format); + gst_gl_query_start_log_valist (query, cat, level, object, format, varargs); + va_end (varargs); +} + +static inline void +gst_gl_query_counter_log(GstGLQuery * query, GstDebugCategory * cat, + GstDebugLevel level, GObject * object, const gchar * format, ...) +{ + va_list varargs; + + va_start (varargs, format); + gst_gl_query_counter_log_valist (query, cat, level, object, format, varargs); + va_end (varargs); +} + +#endif /* G_HAVE_GNUC_VARARGS */ +#endif /* G_HAVE_ISO_VARARGS */ + +G_END_DECLS + +#endif /* __GST_GL_QUERY_H__ */ diff --git a/include/gst/gl/gstglrenderbuffer.h b/include/gst/gl/gstglrenderbuffer.h new file mode 100644 index 0000000000..f77528760d --- /dev/null +++ b/include/gst/gl/gstglrenderbuffer.h @@ -0,0 +1,176 @@ +/* + * GStreamer + * Copyright (C) 2015 Matthew Waters <matthew@centricular.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GST_GL_RENDERBUFFER_H_ +#define _GST_GL_RENDERBUFFER_H_ + +#include <gst/gl/gstglbasememory.h> + +G_BEGIN_DECLS + +#define GST_TYPE_GL_RENDERBUFFER_ALLOCATOR (gst_gl_renderbuffer_allocator_get_type()) +GST_GL_API GType gst_gl_renderbuffer_allocator_get_type(void); + +#define GST_IS_GL_RENDERBUFFER_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_RENDERBUFFER_ALLOCATOR)) +#define GST_IS_GL_RENDERBUFFER_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GL_RENDERBUFFER_ALLOCATOR)) +#define GST_GL_RENDERBUFFER_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GL_RENDERBUFFER_ALLOCATOR, GstGLRenderbufferAllocatorClass)) +#define GST_GL_RENDERBUFFER_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_RENDERBUFFER_ALLOCATOR, GstGLRenderbufferAllocator)) +#define GST_GL_RENDERBUFFER_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_RENDERBUFFER_ALLOCATOR, GstGLRenderbufferAllocatorClass)) +#define GST_GL_RENDERBUFFER_ALLOCATOR_CAST(obj) ((GstGLRenderbufferAllocator *)(obj)) + +#define GST_GL_RENDERBUFFER_CAST(obj) ((GstGLRenderbuffer *) obj) + +/** + * GST_GL_RENDERBUFFER_ALLOCATOR_NAME: + * + * The name of the GL renderbuffer allocator + */ +#define GST_GL_RENDERBUFFER_ALLOCATOR_NAME "GLRenderbuffer" + +/** + * GstGLRenderbuffer: + * @renderbuffer_id: the GL texture id for this memory + * @renderbuffer_format: the texture type + * @width: the width + * @height: the height + * + * Represents information about a GL renderbuffer + */ +struct _GstGLRenderbuffer +{ + /*< private >*/ + GstGLBaseMemory mem; + + /*< public >*/ + guint renderbuffer_id; + GstGLFormat renderbuffer_format; + guint width; + guint height; + + /*< protected >*/ + gboolean renderbuffer_wrapped; + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + +/** + * GstGLRenderbufferAllocator: + * + * Opaque #GstGLRenderbufferAllocator struct + */ +struct _GstGLRenderbufferAllocator +{ + GstGLBaseMemoryAllocator parent; + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + +/** + * GstGLRenderbufferAllocatorClass: + * + * The #GstGLRenderbufferAllocatorClass only contains private data + */ +struct _GstGLRenderbufferAllocatorClass +{ + GstGLBaseMemoryAllocatorClass parent_class; + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + +#include <gst/gl/gstglbasememory.h> + +typedef struct _GstGLRenderbufferAllocationParams GstGLRenderbufferAllocationParams; + +GST_GL_API GType gst_gl_renderbuffer_allocation_params_get_type (void); +#define GST_TYPE_RENDERBUFFER_ALLOCATION_PARAMS (gst_gl_renderbuffer_allocation_params_get_type) + +/** + * GstGLRenderbufferAllocationParams: + * @renderbuffer_format: the #GstGLFormat + * @width: the width + * @height: the height + * + * Allocation parameters + */ +struct _GstGLRenderbufferAllocationParams +{ + /*< private >*/ + GstGLAllocationParams parent; + + /*< public >*/ + GstGLFormat renderbuffer_format; + guint width; + guint height; + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + +GST_GL_API +GstGLRenderbufferAllocationParams * gst_gl_renderbuffer_allocation_params_new (GstGLContext * context, + const GstAllocationParams * alloc_params, + GstGLFormat renderbuffer_format, + guint width, + guint height); + +GST_GL_API +GstGLRenderbufferAllocationParams * gst_gl_renderbuffer_allocation_params_new_wrapped (GstGLContext * context, + const GstAllocationParams * alloc_params, + GstGLFormat renderbuffer_format, + guint width, + guint height, + gpointer gl_handle, + gpointer user_data, + GDestroyNotify notify); + +/** + * GST_TYPE_GL_RENDERBUFFER: + * + * Since: 1.20 + */ +#define GST_TYPE_GL_RENDERBUFFER (gst_gl_renderbuffer_get_type()) +GST_GL_API +GType gst_gl_renderbuffer_get_type(void); + +GST_GL_API +void gst_gl_renderbuffer_init_once (void); + +GST_GL_API +gboolean gst_is_gl_renderbuffer (GstMemory * mem); + +/* accessors */ +GST_GL_API +gint gst_gl_renderbuffer_get_width (GstGLRenderbuffer * gl_mem); + +GST_GL_API +gint gst_gl_renderbuffer_get_height (GstGLRenderbuffer * gl_mem); + +GST_GL_API +GstGLFormat gst_gl_renderbuffer_get_format (GstGLRenderbuffer * gl_mem); + +GST_GL_API +guint gst_gl_renderbuffer_get_id (GstGLRenderbuffer * gl_mem); + +G_END_DECLS + +#endif /* _GST_GL_RENDERBUFFER_H_ */ diff --git a/include/gst/gl/gstglshader.h b/include/gst/gl/gstglshader.h new file mode 100644 index 0000000000..4f96f91b3c --- /dev/null +++ b/include/gst/gl/gstglshader.h @@ -0,0 +1,156 @@ +/* + * GStreamer + * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com> + * Copyright (C) 2014 Julien Isorce <julien.isorce@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_GL_SHADER_H__ +#define __GST_GL_SHADER_H__ + +#include <gst/gl/gstgl_fwd.h> + +G_BEGIN_DECLS + +GST_GL_API +GType gst_gl_shader_get_type (void); +#define GST_TYPE_GL_SHADER (gst_gl_shader_get_type()) + +#define GST_GL_SHADER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_SHADER, GstGLShader)) +#define GST_GL_SHADER_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_SHADER, GstGLShaderClass)) +#define GST_IS_GL_SHADER(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_SHADER)) +#define GST_IS_GL_SHADER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_SHADER)) +#define GST_GL_SHADER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_SHADER, GstGLShaderClass)) + +struct _GstGLShader +{ + GstObject parent; + + GstGLContext *context; + + /*< private >*/ + GstGLShaderPrivate *priv; + + gpointer _padding[GST_PADDING]; +}; + +struct _GstGLShaderClass { + /*< private >*/ + GstObjectClass parent_class; +}; + +GST_GL_API +GstGLShader * gst_gl_shader_new (GstGLContext *context); +GST_GL_API +GstGLShader * gst_gl_shader_new_with_stages (GstGLContext * context, GError ** error, ...); +GST_GL_API +GstGLShader * gst_gl_shader_new_link_with_stages (GstGLContext * context, GError ** error, ...); +GST_GL_API +GstGLShader * gst_gl_shader_new_default (GstGLContext * context, GError ** error); + +GST_GL_API +gboolean gst_gl_shader_attach (GstGLShader * shader, GstGLSLStage * stage); +GST_GL_API +gboolean gst_gl_shader_attach_unlocked (GstGLShader * shader, GstGLSLStage * stage); + +GST_GL_API +void gst_gl_shader_detach (GstGLShader * shader, GstGLSLStage * stage); +GST_GL_API +void gst_gl_shader_detach_unlocked (GstGLShader * shader, GstGLSLStage * stage); + +GST_GL_API +gboolean gst_gl_shader_compile_attach_stage (GstGLShader * shader, + GstGLSLStage *stage, + GError ** error); +GST_GL_API +gboolean gst_gl_shader_link (GstGLShader * shader, GError ** error); +GST_GL_API +gboolean gst_gl_shader_is_linked (GstGLShader *shader); + +GST_GL_API +int gst_gl_shader_get_program_handle (GstGLShader * shader); + +GST_GL_API +void gst_gl_shader_release (GstGLShader *shader); +GST_GL_API +void gst_gl_shader_release_unlocked (GstGLShader * shader); +GST_GL_API +void gst_gl_shader_use (GstGLShader *shader); +GST_GL_API +void gst_gl_context_clear_shader (GstGLContext *context); + +GST_GL_API +void gst_gl_shader_set_uniform_1i (GstGLShader *shader, const gchar *name, gint value); +GST_GL_API +void gst_gl_shader_set_uniform_1iv (GstGLShader *shader, const gchar *name, guint count, const gint *value); +GST_GL_API +void gst_gl_shader_set_uniform_1f (GstGLShader *shader, const gchar *name, gfloat value); +GST_GL_API +void gst_gl_shader_set_uniform_1fv (GstGLShader *shader, const gchar *name, guint count, const gfloat *value); +GST_GL_API +void gst_gl_shader_set_uniform_2i (GstGLShader *shader, const gchar *name, gint v0, gint v1); +GST_GL_API +void gst_gl_shader_set_uniform_2iv (GstGLShader *shader, const gchar *name, guint count, const gint *value); +GST_GL_API +void gst_gl_shader_set_uniform_2f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1); +GST_GL_API +void gst_gl_shader_set_uniform_2fv (GstGLShader *shader, const gchar *name, guint count, const gfloat *value); +GST_GL_API +void gst_gl_shader_set_uniform_3i (GstGLShader *shader, const gchar *name, gint v0, gint v1, gint v2); +GST_GL_API +void gst_gl_shader_set_uniform_3iv (GstGLShader *shader, const gchar *name, guint count, const gint * value); +GST_GL_API +void gst_gl_shader_set_uniform_3f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1, gfloat v2); +GST_GL_API +void gst_gl_shader_set_uniform_3fv (GstGLShader *shader, const gchar *name, guint count, const gfloat *value); +GST_GL_API +void gst_gl_shader_set_uniform_4i (GstGLShader *shader, const gchar *name, gint v0, gint v1, gint v2, gint v3); +GST_GL_API +void gst_gl_shader_set_uniform_4iv (GstGLShader *shader, const gchar *name, guint count, const gint *value); +GST_GL_API +void gst_gl_shader_set_uniform_4f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1, gfloat v2, gfloat v3); +GST_GL_API +void gst_gl_shader_set_uniform_4fv (GstGLShader *shader, const gchar *name, guint count, const gfloat *value); +GST_GL_API +void gst_gl_shader_set_uniform_matrix_2fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value); +GST_GL_API +void gst_gl_shader_set_uniform_matrix_3fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value); +GST_GL_API +void gst_gl_shader_set_uniform_matrix_4fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value); +GST_GL_API +void gst_gl_shader_set_uniform_matrix_2x3fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value); +GST_GL_API +void gst_gl_shader_set_uniform_matrix_2x4fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value); +GST_GL_API +void gst_gl_shader_set_uniform_matrix_3x2fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value); +GST_GL_API +void gst_gl_shader_set_uniform_matrix_3x4fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value); +GST_GL_API +void gst_gl_shader_set_uniform_matrix_4x2fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value); +GST_GL_API +void gst_gl_shader_set_uniform_matrix_4x3fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value); + +GST_GL_API +gint gst_gl_shader_get_attribute_location (GstGLShader *shader, const gchar *name); +GST_GL_API +void gst_gl_shader_bind_attribute_location (GstGLShader * shader, guint index, const gchar * name); +GST_GL_API +void gst_gl_shader_bind_frag_data_location (GstGLShader * shader, guint index, const gchar * name); + +G_END_DECLS + +#endif /* __GST_GL_SHADER_H__ */ diff --git a/include/gst/gl/gstglshaderstrings.h b/include/gst/gl/gstglshaderstrings.h new file mode 100644 index 0000000000..eba1b9e472 --- /dev/null +++ b/include/gst/gl/gstglshaderstrings.h @@ -0,0 +1,63 @@ +/* + * GStreamer + * Copyright (C) 2015 Matthew Waters <matthew@centricular.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_GL_SHADER_STRINGS_H__ +#define __GST_GL_SHADER_STRINGS_H__ + +#include <gst/gst.h> +#include <gst/gl/gl-prelude.h> +#include <gst/gl/gl.h> + +G_BEGIN_DECLS + +GST_GL_API +const gchar *gst_gl_shader_string_fragment_highp_precision; +GST_GL_API +const gchar *gst_gl_shader_string_fragment_mediump_precision; + +GST_GL_API +const gchar *gst_gl_shader_string_vertex_default; +GST_GL_API G_DEPRECATED_FOR(gst_gl_shader_string_fragment_get_default) +const gchar *gst_gl_shader_string_fragment_default; + +GST_GL_API +const gchar *gst_gl_shader_string_vertex_mat4_texture_transform; +GST_GL_API +const gchar *gst_gl_shader_string_vertex_mat4_vertex_transform; +GST_GL_API G_DEPRECATED_FOR(gst_gl_shader_string_fragment_external_oes_get_default) +const gchar *gst_gl_shader_string_fragment_external_oes_default; + +GST_GL_API +const gchar * gst_gl_shader_string_get_highest_precision (GstGLContext * context, + GstGLSLVersion version, + GstGLSLProfile profile); + +GST_GL_API +gchar * gst_gl_shader_string_fragment_get_default (GstGLContext * context, + GstGLSLVersion version, + GstGLSLProfile profile); +GST_GL_API +gchar * gst_gl_shader_string_fragment_external_oes_get_default (GstGLContext * context, + GstGLSLVersion version, + GstGLSLProfile profile); + +G_END_DECLS + +#endif /* __GST_GL_SHADER_STRINGS_H__ */ diff --git a/include/gst/gl/gstglsl.h b/include/gst/gl/gstglsl.h new file mode 100644 index 0000000000..2cd0526afc --- /dev/null +++ b/include/gst/gl/gstglsl.h @@ -0,0 +1,169 @@ +/* + * GStreamer + * Copyright (C) 2015 Matthew Waters <matthew@centricular.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_GLSL_H__ +#define __GST_GLSL_H__ + +#include <gst/gl/gstgl_fwd.h> + +G_BEGIN_DECLS + +GST_GL_API +GQuark gst_glsl_error_quark (void); + +/** + * GST_GLSL_ERROR: + * + * Error domain for GStreamer's GLSL module. Errors in this domain will be + * from the #GstGLSLError enumeration + */ +#define GST_GLSL_ERROR (gst_glsl_error_quark ()) + +/** + * GstGLSLError: + * @GST_GLSL_ERROR_COMPILE: Compilation error occurred + * @GST_GLSL_ERROR_LINK: Link error occurred + * @GST_GLSL_ERROR_PROGRAM: General program error occurred + * + * Compilation stage that caused an error + * + * Since: 1.8 + */ +typedef enum { + GST_GLSL_ERROR_COMPILE, + GST_GLSL_ERROR_LINK, + GST_GLSL_ERROR_PROGRAM, +} GstGLSLError; + +/** + * GstGLSLVersion: + * @GST_GLSL_VERSION_NONE: no version + * @GST_GLSL_VERSION_100: version 100 (only valid for ES) + * @GST_GLSL_VERSION_110: version 110 (only valid for compatibility desktop GL) + * @GST_GLSL_VERSION_120: version 120 (only valid for compatibility desktop GL) + * @GST_GLSL_VERSION_130: version 130 (only valid for compatibility desktop GL) + * @GST_GLSL_VERSION_140: version 140 (only valid for compatibility desktop GL) + * @GST_GLSL_VERSION_150: version 150 (valid for compatibility/core desktop GL) + * @GST_GLSL_VERSION_300: version 300 (only valid for ES) + * @GST_GLSL_VERSION_310: version 310 (only valid for ES) + * @GST_GLSL_VERSION_320: version 320 (only valid for ES) + * @GST_GLSL_VERSION_330: version 330 (valid for compatibility/core desktop GL) + * @GST_GLSL_VERSION_400: version 400 (valid for compatibility/core desktop GL) + * @GST_GLSL_VERSION_410: version 410 (valid for compatibility/core desktop GL) + * @GST_GLSL_VERSION_420: version 420 (valid for compatibility/core desktop GL) + * @GST_GLSL_VERSION_430: version 430 (valid for compatibility/core desktop GL) + * @GST_GLSL_VERSION_440: version 440 (valid for compatibility/core desktop GL) + * @GST_GLSL_VERSION_450: version 450 (valid for compatibility/core desktop GL) + * + * GLSL version list + * + * Since: 1.8 + */ +typedef enum +{ + GST_GLSL_VERSION_NONE = 0, + + GST_GLSL_VERSION_100 = 100, /* ES */ + GST_GLSL_VERSION_110 = 110, /* GL */ + GST_GLSL_VERSION_120 = 120, /* GL */ + GST_GLSL_VERSION_130 = 130, /* GL */ + GST_GLSL_VERSION_140 = 140, /* GL */ + GST_GLSL_VERSION_150 = 150, /* GL */ + GST_GLSL_VERSION_300 = 300, /* ES */ + GST_GLSL_VERSION_310 = 310, /* ES */ + GST_GLSL_VERSION_320 = 320, /* ES */ + GST_GLSL_VERSION_330 = 330, /* GL */ + GST_GLSL_VERSION_400 = 400, /* GL */ + GST_GLSL_VERSION_410 = 410, /* GL */ + GST_GLSL_VERSION_420 = 420, /* GL */ + GST_GLSL_VERSION_430 = 430, /* GL */ + GST_GLSL_VERSION_440 = 440, /* GL */ + GST_GLSL_VERSION_450 = 450, /* GL */ +} GstGLSLVersion; + +/** + * GstGLSLProfile: + * @GST_GLSL_PROFILE_NONE: no profile supported/available + * @GST_GLSL_PROFILE_ES: OpenGL|ES profile + * @GST_GLSL_PROFILE_CORE: OpenGL core profile + * @GST_GLSL_PROFILE_COMPATIBILITY: OpenGL compatibility profile + * @GST_GLSL_PROFILE_ANY: any OpenGL/OpenGL|ES profile + * + * GLSL profiles + * + * Since: 1.8 + */ +/* FIXME: For GST_GLSL_PROFILE_ANY ~0 -> 0xffffffff see + * https://bugzilla.gnome.org/show_bug.cgi?id=732633 +*/ +typedef enum +{ + /* XXX: maybe make GstGLAPI instead */ + GST_GLSL_PROFILE_NONE = 0, + + GST_GLSL_PROFILE_ES = (1 << 0), + GST_GLSL_PROFILE_CORE = (1 << 1), + GST_GLSL_PROFILE_COMPATIBILITY = (1 << 2), + + GST_GLSL_PROFILE_ANY = (gint) (0xffffffff), +} GstGLSLProfile; + +GST_GL_API +GstGLSLVersion gst_glsl_version_from_string (const gchar * string); +GST_GL_API +const gchar * gst_glsl_version_to_string (GstGLSLVersion version); + +GST_GL_API +GstGLSLProfile gst_glsl_profile_from_string (const gchar * string); +GST_GL_API +const gchar * gst_glsl_profile_to_string (GstGLSLProfile profile); + +GST_GL_API +gchar * gst_glsl_version_profile_to_string (GstGLSLVersion version, + GstGLSLProfile profile); +GST_GL_API +gboolean gst_glsl_version_profile_from_string (const gchar * string, + GstGLSLVersion * version_ret, + GstGLSLProfile * profile_ret); + +GST_GL_API +gboolean gst_glsl_string_get_version_profile (const gchar *s, + GstGLSLVersion * version, + GstGLSLProfile * profile); + +GST_GL_API +GstGLSLVersion gst_gl_version_to_glsl_version (GstGLAPI gl_api, gint maj, gint min); +GST_GL_API +gboolean gst_gl_context_supports_glsl_profile_version (GstGLContext * context, + GstGLSLVersion version, + GstGLSLProfile profile); + +GST_GL_API +gboolean gst_gl_context_supports_precision (GstGLContext * context, + GstGLSLVersion version, + GstGLSLProfile profile); +GST_GL_API +gboolean gst_gl_context_supports_precision_highp (GstGLContext * context, + GstGLSLVersion version, + GstGLSLProfile profile); + +G_END_DECLS + +#endif /* __GST_GLSL_H__ */ diff --git a/include/gst/gl/gstglslstage.h b/include/gst/gl/gstglslstage.h new file mode 100644 index 0000000000..7f4aabba9b --- /dev/null +++ b/include/gst/gl/gstglslstage.h @@ -0,0 +1,108 @@ +/* + * GStreamer + * Copyright (C) 2015 Matthew Waters <matthew@centricular.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_GLSL_STAGE_H__ +#define __GST_GLSL_STAGE_H__ + +#include <gst/gl/gstglsl.h> + +G_BEGIN_DECLS + +#define GST_TYPE_GLSL_STAGE (gst_glsl_stage_get_type()) +#define GST_GLSL_STAGE(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GLSL_STAGE, GstGLSLStage)) +#define GST_GLSL_STAGE_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GLSL_STAGE, GstGLSLStageClass)) +#define GST_IS_GLSL_STAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GLSL_STAGE)) +#define GST_IS_GLSL_STAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GLSL_STAGE)) +#define GST_GLSL_STAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GLSL_STAGE, GstGLSLStageClass)) + +/** + * GstGLSLStage: + * + * Opaque #GstGLSLStage struct + */ +struct _GstGLSLStage +{ + /*< private >*/ + GstObject parent; + + GstGLContext *context; + + GstGLSLStagePrivate *priv; + + gpointer _padding[GST_PADDING]; +}; + +/** + * GstGLSLStageClass: + * + * Opaque #GstGLSLStageClass struct + */ +struct _GstGLSLStageClass +{ + /*< private >*/ + GstObjectClass parent; + + gpointer _padding[GST_PADDING]; +}; + +GST_GL_API +GType gst_glsl_stage_get_type (void); +GST_GL_API +GstGLSLStage * gst_glsl_stage_new (GstGLContext * context, guint type); +GST_GL_API +GstGLSLStage * gst_glsl_stage_new_with_string (GstGLContext * context, + guint type, + GstGLSLVersion version, + GstGLSLProfile profile, + const gchar * str); +GST_GL_API +GstGLSLStage * gst_glsl_stage_new_with_strings (GstGLContext * context, + guint type, + GstGLSLVersion version, + GstGLSLProfile profile, + gint n_strings, + const gchar ** str); + +GST_GL_API +GstGLSLStage * gst_glsl_stage_new_default_fragment (GstGLContext * context); +GST_GL_API +GstGLSLStage * gst_glsl_stage_new_default_vertex (GstGLContext * context); + +GST_GL_API +guint gst_glsl_stage_get_handle (GstGLSLStage * stage); +GST_GL_API +GstGLSLProfile gst_glsl_stage_get_profile (GstGLSLStage * stage); +GST_GL_API +GstGLSLVersion gst_glsl_stage_get_version (GstGLSLStage * stage); +GST_GL_API +guint gst_glsl_stage_get_shader_type (GstGLSLStage * stage); +GST_GL_API +gboolean gst_glsl_stage_set_strings (GstGLSLStage * stage, + GstGLSLVersion version, + GstGLSLProfile profile, + gint n_strings, + const gchar ** str); +GST_GL_API +gboolean gst_glsl_stage_compile (GstGLSLStage * stage, + GError ** error); + +G_END_DECLS + +#endif /* __GST_GLSL_STAGE_H__ */ diff --git a/include/gst/gl/gstglsyncmeta.h b/include/gst/gl/gstglsyncmeta.h new file mode 100644 index 0000000000..6daee86ca0 --- /dev/null +++ b/include/gst/gl/gstglsyncmeta.h @@ -0,0 +1,95 @@ +/* + * GStreamer + * Copyright (C) 2014 Matthew Waters <matthew@centricular.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_GL_SYNC_META_H__ +#define __GST_GL_SYNC_META_H__ + +#include <gst/gl/gstgl_fwd.h> + +G_BEGIN_DECLS + +#define GST_GL_SYNC_META_API_TYPE (gst_gl_sync_meta_api_get_type()) +#define GST_GL_SYNC_META_INFO (gst_gl_sync_meta_get_info()) +typedef struct _GstGLSyncMeta GstGLSyncMeta; + +/** + * GST_BUFFER_POOL_OPTION_GL_SYNC_META: + * + * An option that can be activated on bufferpools to request OpenGL + * synchronization metadata on buffers from the pool. + */ +#define GST_BUFFER_POOL_OPTION_GL_SYNC_META "GstBufferPoolOptionGLSyncMeta" + +/** + * GstGLSyncMeta: + * @parent: the parent #GstMeta + * @context: the #GstGLContext used to allocate the meta + * @data: a custom data pointer for the implementation + * @set_sync: set a sync point in the OpenGL command stream + * @set_sync_gl: the same as @set_sync but called from @context's thread + * @wait: execute a wait on the previously set sync point into the OpenGL command stream + * @wait_gl: the same as @wait but called from @context's thread + * @wait_cpu: wait for the previously set sync point to pass from the CPU + * @wait_cpu_gl: the same as @wait_cpu but called from @context's thread + * @copy: copy @data into a new #GstGLSyncMeta + * @free: free @data + * @free_gl: free @data in @context's thread + */ +struct _GstGLSyncMeta +{ + GstMeta parent; + + GstGLContext *context; + + gpointer data; + + void (*set_sync) (GstGLSyncMeta * sync, GstGLContext * context); + void (*set_sync_gl) (GstGLSyncMeta * sync, GstGLContext * context); + void (*wait) (GstGLSyncMeta * sync, GstGLContext * context); + void (*wait_gl) (GstGLSyncMeta * sync, GstGLContext * context); + void (*wait_cpu) (GstGLSyncMeta * sync, GstGLContext * context); + void (*wait_cpu_gl) (GstGLSyncMeta * sync, GstGLContext * context); + void (*copy) (GstGLSyncMeta * src, GstBuffer * sbuffer, GstGLSyncMeta * dest, GstBuffer * dbuffer); + void (*free) (GstGLSyncMeta * sync, GstGLContext * context); + void (*free_gl) (GstGLSyncMeta * sync, GstGLContext * context); +}; + +GST_GL_API +GType gst_gl_sync_meta_api_get_type (void); +GST_GL_API +const GstMetaInfo * gst_gl_sync_meta_get_info (void); + +#define gst_buffer_get_gl_sync_meta(b) ((GstGLSyncMeta*)gst_buffer_get_meta((b),GST_GL_SYNC_META_API_TYPE)) + +GST_GL_API +GstGLSyncMeta * gst_buffer_add_gl_sync_meta (GstGLContext * context, GstBuffer *buffer); +GST_GL_API +GstGLSyncMeta * gst_buffer_add_gl_sync_meta_full (GstGLContext * context, GstBuffer * buffer, + gpointer data); +GST_GL_API +void gst_gl_sync_meta_set_sync_point (GstGLSyncMeta * sync_meta, GstGLContext * context); +GST_GL_API +void gst_gl_sync_meta_wait (GstGLSyncMeta * sync_meta, GstGLContext * context); +GST_GL_API +void gst_gl_sync_meta_wait_cpu (GstGLSyncMeta * sync_meta, GstGLContext * context); + +G_END_DECLS + +#endif /* __GST_GL_SYNC_META_H__ */ diff --git a/include/gst/gl/gstglupload.h b/include/gst/gl/gstglupload.h new file mode 100644 index 0000000000..5911584222 --- /dev/null +++ b/include/gst/gl/gstglupload.h @@ -0,0 +1,124 @@ +/* + * GStreamer + * Copyright (C) 2012 Matthew Waters <ystree00@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_GL_UPLOAD_H__ +#define __GST_GL_UPLOAD_H__ + +#include <gst/video/video.h> + +#include <gst/gl/gstgl_fwd.h> + +G_BEGIN_DECLS + +GST_GL_API +GType gst_gl_upload_get_type (void); +#define GST_TYPE_GL_UPLOAD (gst_gl_upload_get_type()) +#define GST_GL_UPLOAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_UPLOAD,GstGLUpload)) +#define GST_GL_UPLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_UPLOAD,GstGLUploadClass)) +#define GST_IS_GL_UPLOAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_UPLOAD)) +#define GST_IS_GL_UPLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_UPLOAD)) +#define GST_GL_UPLOAD_CAST(obj) ((GstGLUpload*)(obj)) + +/** + * GstGLUploadReturn: + * @GST_GL_UPLOAD_DONE: No further processing required + * @GST_GL_UPLOAD_ERROR: An unspecified error occurred + * @GST_GL_UPLOAD_UNSUPPORTED: The configuration is unsupported. + * @GST_GL_UPLOAD_RECONFIGURE: This element requires a reconfiguration. + * @GST_GL_UPLOAD_UNSHARED_GL_CONTEXT: private return value. + */ +typedef enum +{ + GST_GL_UPLOAD_DONE = 1, + + GST_GL_UPLOAD_ERROR = -1, + GST_GL_UPLOAD_UNSUPPORTED = -2, + GST_GL_UPLOAD_RECONFIGURE = -3, + + GST_GL_UPLOAD_UNSHARED_GL_CONTEXT = -100, +} GstGLUploadReturn; + +/** + * GstGLUpload + * + * Opaque #GstGLUpload object + */ +struct _GstGLUpload +{ + GstObject parent; + + GstGLContext *context; + + /*< private >*/ + GstGLUploadPrivate *priv; + + gpointer _reserved[GST_PADDING]; +}; + +/** + * GstGLUploadClass: + * + * The #GstGLUploadClass struct only contains private data + */ +struct _GstGLUploadClass +{ + GstObjectClass object_class; + + /*< private >*/ + gpointer _padding[GST_PADDING]; +}; + +GST_GL_API +GstCaps * gst_gl_upload_get_input_template_caps (void); + +GST_GL_API +GstGLUpload * gst_gl_upload_new (GstGLContext * context); + +GST_GL_API +void gst_gl_upload_set_context (GstGLUpload * upload, + GstGLContext * context); + +GST_GL_API +GstCaps * gst_gl_upload_transform_caps (GstGLUpload * upload, + GstGLContext * context, + GstPadDirection direction, + GstCaps * caps, + GstCaps * filter); +GST_GL_API +gboolean gst_gl_upload_set_caps (GstGLUpload * upload, + GstCaps * in_caps, + GstCaps * out_caps); +GST_GL_API +void gst_gl_upload_get_caps (GstGLUpload * upload, + GstCaps ** in_caps, + GstCaps ** out_caps); +GST_GL_API +void gst_gl_upload_propose_allocation (GstGLUpload * upload, + GstQuery * decide_query, + GstQuery * query); + +GST_GL_API +GstGLUploadReturn gst_gl_upload_perform_with_buffer (GstGLUpload * upload, + GstBuffer * buffer, + GstBuffer ** outbuf_ptr); + +G_END_DECLS + +#endif /* __GST_GL_UPLOAD_H__ */ diff --git a/include/gst/gl/gstglutils.h b/include/gst/gl/gstglutils.h new file mode 100644 index 0000000000..b27145489f --- /dev/null +++ b/include/gst/gl/gstglutils.h @@ -0,0 +1,73 @@ +/* + * GStreamer + * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_GL_UTILS_H__ +#define __GST_GL_UTILS_H__ + +#include <gst/video/video.h> +#include <gst/video/gstvideoaffinetransformationmeta.h> + +#include <gst/gl/gstgl_fwd.h> + +G_BEGIN_DECLS + +GST_GL_API +gboolean gst_gl_ensure_element_data (gpointer element, + GstGLDisplay **display_ptr, GstGLContext ** other_context_ptr); +GST_GL_API +gboolean gst_gl_handle_set_context (GstElement * element, GstContext * context, + GstGLDisplay ** display, GstGLContext ** other_context); +GST_GL_API +gboolean gst_gl_handle_context_query (GstElement * element, GstQuery * query, + GstGLDisplay * display, GstGLContext * context, GstGLContext * other_context); +GST_GL_API +gboolean gst_gl_query_local_gl_context (GstElement * element, GstPadDirection direction, + GstGLContext ** context_ptr); + +GST_GL_API +void gst_gl_element_propagate_display_context (GstElement * element, GstGLDisplay * display); + +GST_GL_API +gsize gst_gl_get_plane_data_size (const GstVideoInfo * info, const GstVideoAlignment * align, + guint plane); +GST_GL_API +gsize gst_gl_get_plane_start (const GstVideoInfo * info, const GstVideoAlignment * valign, + guint plane); + +GST_GL_API +gboolean gst_gl_value_set_texture_target_from_mask (GValue * value, + GstGLTextureTarget target_mask); +GST_GL_API +gboolean gst_gl_value_set_texture_target (GValue * value, GstGLTextureTarget target); +GST_GL_API +GstGLTextureTarget gst_gl_value_get_texture_target_mask (const GValue * value); + +GST_GL_API +void gst_gl_get_affine_transformation_meta_as_ndc (GstVideoAffineTransformationMeta * meta, gfloat * matrix); +GST_GL_API +void gst_gl_set_affine_transformation_meta_from_ndc (GstVideoAffineTransformationMeta * meta, const gfloat * matrix); + +GST_GL_API +void gst_gl_multiply_matrix4 (const gfloat * a, const gfloat * b, gfloat * result); + + +G_END_DECLS + +#endif /* __GST_GL_UTILS_H__ */ diff --git a/include/gst/gl/gstglviewconvert.h b/include/gst/gl/gstglviewconvert.h new file mode 100644 index 0000000000..6d4802d169 --- /dev/null +++ b/include/gst/gl/gstglviewconvert.h @@ -0,0 +1,139 @@ +/* + * GStreamer + * Copyright (C) 2014 Jan Schmidt <jan@centricular.com> + * Copyright (C) 2015 Matthew Waters <matthew@centricular.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GST_GL_VIEW_CONVERT_H_ +#define _GST_GL_VIEW_CONVERT_H_ + +#include <gst/gstmemory.h> +#include <gst/video/video.h> + +#include <gst/gl/gstgl_fwd.h> + +G_BEGIN_DECLS +#define GST_TYPE_GL_VIEW_CONVERT (gst_gl_view_convert_get_type()) +#define GST_GL_VIEW_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_VIEW_CONVERT,GstGLViewConvert)) +#define GST_IS_GL_VIEW_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_VIEW_CONVERT)) +#define GST_GL_VIEW_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_GL_VIEW_CONVERT,GstGLViewConvertClass)) +#define GST_IS_GL_VIEW_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_GL_VIEW_CONVERT)) +#define GST_GL_VIEW_CONVERT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_GL_VIEW_CONVERT,GstGLViewConvertClass)) + +/** + * GstGLStereoDownmix: + * @GST_GL_STEREO_DOWNMIX_ANAGLYPH_GREEN_MAGENTA_DUBOIS: Dubois optimised Green-Magenta anaglyph + * @GST_GL_STEREO_DOWNMIX_ANAGLYPH_RED_CYAN_DUBOIS: Dubois optimised Red-Cyan anaglyph + * @GST_GL_STEREO_DOWNMIX_ANAGLYPH_AMBER_BLUE_DUBOIS: Dubois optimised Amber-Blue anaglyph + * + * Output anaglyph type to generate when downmixing to mono + */ +typedef enum { + GST_GL_STEREO_DOWNMIX_ANAGLYPH_GREEN_MAGENTA_DUBOIS, + GST_GL_STEREO_DOWNMIX_ANAGLYPH_RED_CYAN_DUBOIS, + GST_GL_STEREO_DOWNMIX_ANAGLYPH_AMBER_BLUE_DUBOIS, +} GstGLStereoDownmix; + +#ifndef GST_DISABLE_DEPRECATED +#define GST_TYPE_GL_STEREO_DOWNMIX_MODE_TYPE GST_TYPE_GL_STEREO_DOWNMIX + +GST_GL_API +GType gst_gl_stereo_downmix_mode_get_type (void); +#endif + +/** + * GstGLViewConvert: + * + * #GstGLViewConvert is an opaque struct and should only be accessed through the + * provided api. + */ +struct _GstGLViewConvert +{ + GstObject object; + + GstGLContext *context; + + GstGLShader *shader; + + GstVideoMultiviewMode input_mode_override; + GstVideoMultiviewFlags input_flags_override; + GstVideoMultiviewMode output_mode_override; + GstVideoMultiviewFlags output_flags_override; + + GstGLStereoDownmix downmix_mode; + + GstVideoInfo in_info; + GstVideoInfo out_info; + + GstGLTextureTarget from_texture_target; + GstGLTextureTarget to_texture_target; + gboolean caps_passthrough; + + gboolean initted; + gboolean reconfigure; + + GstGLFramebuffer *fbo; + + /*< private >*/ + GstGLViewConvertPrivate *priv; + + gpointer _padding[GST_PADDING]; +}; + +/** + * GstGLViewConvertClass: + * + * Opaque #GstGLViewConvertClass struct + */ +struct _GstGLViewConvertClass +{ + /*< private >*/ + GstObjectClass object_class; + + gpointer _padding[GST_PADDING]; +}; + +GST_GL_API +GType gst_gl_view_convert_get_type (void); +GST_GL_API +GstGLViewConvert * gst_gl_view_convert_new (void); + +GST_GL_API +gboolean gst_gl_view_convert_set_caps (GstGLViewConvert * viewconvert, GstCaps * in_caps, GstCaps * out_caps); +GST_GL_API +GstCaps * gst_gl_view_convert_transform_caps (GstGLViewConvert * viewconvert, + GstPadDirection direction, GstCaps * caps, GstCaps * filter); +GST_GL_API +GstCaps * gst_gl_view_convert_fixate_caps (GstGLViewConvert *viewconvert, + GstPadDirection direction, GstCaps * caps, GstCaps * othercaps); +GST_GL_API +GstFlowReturn gst_gl_view_convert_submit_input_buffer (GstGLViewConvert *viewconvert, + gboolean is_discont, GstBuffer * input); +GST_GL_API +GstFlowReturn gst_gl_view_convert_get_output (GstGLViewConvert *viewconvert, + GstBuffer ** outbuf_ptr); + +GST_GL_API +GstBuffer * gst_gl_view_convert_perform (GstGLViewConvert * viewconvert, GstBuffer *inbuf); +GST_GL_API +void gst_gl_view_convert_reset (GstGLViewConvert * viewconvert); +GST_GL_API +void gst_gl_view_convert_set_context (GstGLViewConvert *viewconvert, GstGLContext * context); + +G_END_DECLS +#endif /* _GST_GL_VIEW_CONVERT_H_ */ diff --git a/include/gst/gl/gstglwindow.h b/include/gst/gl/gstglwindow.h new file mode 100644 index 0000000000..6e70597584 --- /dev/null +++ b/include/gst/gl/gstglwindow.h @@ -0,0 +1,282 @@ +/* + * GStreamer + * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com> + * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_GL_WINDOW_H__ +#define __GST_GL_WINDOW_H__ + +#include <gst/gst.h> + +#include <gst/gl/gstgl_fwd.h> +#include <gst/gl/gstglcontext.h> +#include <gst/gl/gstgldisplay.h> + +G_BEGIN_DECLS + +GST_GL_API +GType gst_gl_window_get_type (void); +#define GST_TYPE_GL_WINDOW (gst_gl_window_get_type()) + +#define GST_GL_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW, GstGLWindow)) +#define GST_GL_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GST_TYPE_GL_WINDOW, GstGLWindowClass)) +#define GST_IS_GL_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW)) +#define GST_IS_GL_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW)) +#define GST_GL_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW, GstGLWindowClass)) + +#define GST_GL_WINDOW_LOCK(w) g_mutex_lock(&GST_GL_WINDOW(w)->lock) +#define GST_GL_WINDOW_UNLOCK(w) g_mutex_unlock(&GST_GL_WINDOW(w)->lock) +#define GST_GL_WINDOW_GET_LOCK(w) (&GST_GL_WINDOW(w)->lock) + +GST_GL_API +GQuark gst_gl_window_error_quark (void); +/** + * GST_GL_WINDOW_ERROR: + * + * Error domain for GStreamer's GL window module. Errors in this domain will be + * from the #GstGLWindowError enumeration + */ +#define GST_GL_WINDOW_ERROR (gst_gl_window_error_quark ()) + +/** + * GstGLWindowError: + * @GST_GL_WINDOW_ERROR_FAILED: failed for a unspecified reason + * @GST_GL_WINDOW_ERROR_OLD_LIBS: the implementation is too old + * @GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE: no such resource was found + */ +typedef enum +{ + GST_GL_WINDOW_ERROR_FAILED, + GST_GL_WINDOW_ERROR_OLD_LIBS, + GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE, +} GstGLWindowError; + +typedef void (*GstGLWindowCB) (gpointer data); +typedef void (*GstGLWindowResizeCB) (gpointer data, guint width, guint height); + +/** + * GST_GL_WINDOW_CB: + * @f: the function to cast + * + * Cast to the current function type for generic window callbacks + */ +#define GST_GL_WINDOW_CB(f) ((GstGLWindowCB) (f)) + +/** + * GST_GL_WINDOW_RESIZE_CB: + * @f: the function to cast + * + * Cast to the current function type for window resize callbacks + */ +#define GST_GL_WINDOW_RESIZE_CB(f) ((GstGLWindowResizeCB) (f)) + +/** + * GstGLWindow: + * + * #GstGLWindow is an opaque struct and should only be accessed through the + * provided api. + */ +struct _GstGLWindow { + /*< private >*/ + GstObject parent; + + GMutex lock; + + GstGLDisplay *display; + GWeakRef context_ref; + + /*< protected >*/ + gboolean is_drawing; + + GstGLWindowCB draw; + gpointer draw_data; + GDestroyNotify draw_notify; + GstGLWindowCB close; + gpointer close_data; + GDestroyNotify close_notify; + GstGLWindowResizeCB resize; + gpointer resize_data; + GDestroyNotify resize_notify; + + gboolean queue_resize; + + GMainContext *main_context; /* default main_context */ + + /*< private >*/ + GstGLWindowPrivate *priv; + + gpointer _reserved[GST_PADDING]; +}; + +/** + * GstGLWindowClass: + * @parent_class: Parent class + * @get_display: Gets the current windowing system display connection + * @set_window_handle: Set a window handle to render into + * @get_window_handle: Gets the current window handle that this #GstGLWindow is + * rendering into. This may return a different value to + * what is passed into @set_window_handle + * @draw: redraw the window with the specified dimensions + * @run: run the mainloop + * @quit: send a quit to the mainloop + * @send_message: invoke a function on the window thread. Required to be reentrant. + * @send_message_async: invoke a function on the window thread. @run may or may + * not have been called. Required to be reentrant. + * @open: open the connection to the display + * @close: close the connection to the display + * @handle_events: whether to handle 'extra' events from the windowing system. + * Basic events like surface moves and resizes are still valid + * things to listen for. + * @set_preferred_size: request that the window change surface size. The + * implementation is free to ignore this information. + * @show: request that the window be shown to the user + * @set_render_rectangle: request a rectangle to render into. See #GstVideoOverlay + * @queue_resize: request a resize to occur when possible + * @controls_viewport: Whether the window takes care of glViewport setup. + * and the user does not need to deal with viewports + * @has_output_surface: Whether the window has output surface or not. (Since: 1.18) + */ +struct _GstGLWindowClass { + GstObjectClass parent_class; + + guintptr (*get_display) (GstGLWindow *window); + void (*set_window_handle) (GstGLWindow *window, guintptr handle); + guintptr (*get_window_handle) (GstGLWindow *window); + void (*draw) (GstGLWindow *window); + void (*run) (GstGLWindow *window); + void (*quit) (GstGLWindow *window); + void (*send_message) (GstGLWindow *window, GstGLWindowCB callback, gpointer data); + void (*send_message_async) (GstGLWindow *window, GstGLWindowCB callback, gpointer data, GDestroyNotify destroy); + + gboolean (*open) (GstGLWindow *window, GError **error); + void (*close) (GstGLWindow *window); + void (*handle_events) (GstGLWindow *window, gboolean handle_events); + void (*set_preferred_size) (GstGLWindow *window, gint width, gint height); + void (*show) (GstGLWindow *window); + gboolean (*set_render_rectangle)(GstGLWindow *window, gint x, gint y, gint width, gint height); + void (*queue_resize) (GstGLWindow *window); + gboolean (*controls_viewport) (GstGLWindow *window); + gboolean (*has_output_surface) (GstGLWindow *window); + + /*< private >*/ + gpointer _reserved[GST_PADDING-2]; +}; + +GST_GL_API +GstGLWindow * gst_gl_window_new (GstGLDisplay *display); + +/* callbacks */ +GST_GL_API +void gst_gl_window_set_draw_callback (GstGLWindow *window, + GstGLWindowCB callback, + gpointer data, + GDestroyNotify destroy_notify); +GST_GL_API +void gst_gl_window_set_resize_callback (GstGLWindow *window, + GstGLWindowResizeCB callback, + gpointer data, + GDestroyNotify destroy_notify); +GST_GL_API +void gst_gl_window_set_close_callback (GstGLWindow *window, + GstGLWindowCB callback, + gpointer data, + GDestroyNotify destroy_notify); + +GST_GL_API +void gst_gl_window_set_window_handle (GstGLWindow *window, guintptr handle); +GST_GL_API +guintptr gst_gl_window_get_window_handle (GstGLWindow *window); + +/* loop/events */ +GST_GL_API +void gst_gl_window_run (GstGLWindow *window); +GST_GL_API +void gst_gl_window_quit (GstGLWindow *window); +GST_GL_API +void gst_gl_window_send_message (GstGLWindow *window, + GstGLWindowCB callback, + gpointer data); +GST_GL_API +void gst_gl_window_send_message_async (GstGLWindow *window, + GstGLWindowCB callback, + gpointer data, + GDestroyNotify destroy); + +/* navigation */ +GST_GL_API +void gst_gl_window_handle_events (GstGLWindow * window, + gboolean handle_events); + +GST_GL_API +void gst_gl_window_send_key_event (GstGLWindow * window, + const char * event_type, + const char * key_str); +GST_GL_API +void gst_gl_window_send_mouse_event (GstGLWindow * window, + const char * event_type, + int button, + double posx, + double posy); + +GST_GL_API +void gst_gl_window_send_scroll_event (GstGLWindow * window, + double posx, + double posy, + double delta_x, + double delta_y); + +/* surfaces/rendering */ +GST_GL_API +void gst_gl_window_queue_resize (GstGLWindow *window); +GST_GL_API +void gst_gl_window_draw (GstGLWindow *window); +GST_GL_API +void gst_gl_window_show (GstGLWindow *window); +GST_GL_API +void gst_gl_window_set_preferred_size (GstGLWindow * window, + gint width, + gint height); +GST_GL_API +void gst_gl_window_get_surface_dimensions (GstGLWindow * window, + guint * width, + guint * height); +GST_GL_API +gboolean gst_gl_window_set_render_rectangle (GstGLWindow * window, + gint x, + gint y, + gint width, + gint height); +GST_GL_API +gboolean gst_gl_window_controls_viewport (GstGLWindow * window); + +/* subclass usage only */ +GST_GL_API +void gst_gl_window_resize (GstGLWindow *window, guint width, guint height); + +GST_GL_API +GstGLContext * gst_gl_window_get_context (GstGLWindow *window); +GST_GL_API +guintptr gst_gl_window_get_display (GstGLWindow *window); + +GST_GL_API +gboolean gst_gl_window_has_output_surface (GstGLWindow *window); + +G_END_DECLS + +#endif /* __GST_GL_WINDOW_H__ */ |