2013-08-14 00:44:19 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
|
2017-07-07 15:15:12 +00:00
|
|
|
#include <gst/gl/gstgl_fwd.h>
|
2013-08-14 00:44:19 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2016-10-05 01:19:12 +00:00
|
|
|
GType gst_gl_context_get_type (void);
|
|
|
|
#define GST_TYPE_GL_CONTEXT (gst_gl_context_get_type())
|
|
|
|
|
|
|
|
/* FIXME: remove this when moving to -base */
|
2017-03-04 09:15:58 +00:00
|
|
|
#ifndef GST_DISABLE_DEPRECATED
|
2017-03-06 12:21:32 +00:00
|
|
|
#define GST_GL_TYPE_CONTEXT GST_TYPE_GL_CONTEXT
|
2017-03-04 09:15:58 +00:00
|
|
|
#endif
|
2016-10-05 01:19:12 +00:00
|
|
|
#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))
|
2013-08-14 00:44:19 +00:00
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-08-15 07:09:04 +00:00
|
|
|
GQuark gst_gl_context_error_quark (void);
|
2017-07-28 10:00:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GST_GL_CONTEXT_ERROR:
|
|
|
|
*
|
|
|
|
* Error domain for GStreamer's GL context module. Errors in this domain will
|
|
|
|
* be from the #GstGLContextError enumeration
|
|
|
|
*/
|
2016-10-05 01:19:12 +00:00
|
|
|
#define GST_GL_CONTEXT_ERROR (gst_gl_context_error_quark ())
|
2013-08-14 00:44:19 +00:00
|
|
|
|
2013-09-15 04:23:43 +00:00
|
|
|
/**
|
|
|
|
* GstGLContextThreadFunc:
|
2013-11-23 11:53:48 +00:00
|
|
|
* @context: a #GstGLContext
|
2013-09-15 04:23:43 +00:00
|
|
|
* @data: user data
|
|
|
|
*
|
2013-11-23 11:53:48 +00:00
|
|
|
* Represents a function to run in the GL thread with @context and @data
|
2013-09-15 04:23:43 +00:00
|
|
|
*/
|
|
|
|
typedef void (*GstGLContextThreadFunc) (GstGLContext * context, gpointer data);
|
|
|
|
|
2014-05-27 07:54:20 +00:00
|
|
|
#define GST_GL_CONTEXT_TYPE_CGL "gst.gl.context.CGL"
|
2014-02-10 21:57:29 +00:00
|
|
|
#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"
|
2014-05-27 07:54:20 +00:00
|
|
|
#define GST_GL_CONTEXT_TYPE_EAGL "gst.gl.context.EAGL"
|
2014-02-10 21:57:29 +00:00
|
|
|
|
2016-11-03 01:03:24 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2013-08-14 00:44:19 +00:00
|
|
|
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;
|
|
|
|
|
2013-11-23 11:53:48 +00:00
|
|
|
/**
|
|
|
|
* GstGLContext:
|
2016-11-03 01:03:24 +00:00
|
|
|
* @gl_vtable: a list of OpenGL function pointers
|
2013-11-23 11:53:48 +00:00
|
|
|
*
|
|
|
|
* Opaque #GstGLContext object
|
|
|
|
*/
|
2013-08-14 00:44:19 +00:00
|
|
|
struct _GstGLContext {
|
2016-11-03 01:03:24 +00:00
|
|
|
/*< private >*/
|
2014-05-08 05:30:49 +00:00
|
|
|
GstObject parent;
|
2013-08-14 00:44:19 +00:00
|
|
|
|
2015-06-15 15:36:26 +00:00
|
|
|
GstGLDisplay *display;
|
2013-08-14 00:44:19 +00:00
|
|
|
GstGLWindow *window;
|
|
|
|
|
2016-11-03 01:03:24 +00:00
|
|
|
/*< public >*/
|
2013-09-15 04:23:43 +00:00
|
|
|
GstGLFuncs *gl_vtable;
|
|
|
|
|
2016-09-28 05:20:25 +00:00
|
|
|
/*< private >*/
|
2013-08-14 00:44:19 +00:00
|
|
|
GstGLContextPrivate *priv;
|
2016-09-28 05:20:25 +00:00
|
|
|
|
|
|
|
gpointer _reserved[GST_PADDING];
|
2013-08-14 00:44:19 +00:00
|
|
|
};
|
|
|
|
|
2013-11-23 11:53:48 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2013-08-14 00:44:19 +00:00
|
|
|
struct _GstGLContextClass {
|
2014-05-08 05:30:49 +00:00
|
|
|
GstObjectClass parent_class;
|
2013-08-14 00:44:19 +00:00
|
|
|
|
2014-10-28 06:31:37 +00:00
|
|
|
guintptr (*get_current_context) (void);
|
2014-02-10 21:57:29 +00:00
|
|
|
guintptr (*get_gl_context) (GstGLContext *context);
|
|
|
|
GstGLAPI (*get_gl_api) (GstGLContext *context);
|
|
|
|
GstGLPlatform (*get_gl_platform) (GstGLContext *context);
|
2015-07-18 07:08:36 +00:00
|
|
|
gpointer (*get_proc_address) (GstGLAPI gl_api, const gchar *name);
|
2014-02-10 21:57:29 +00:00
|
|
|
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);
|
2014-05-14 07:33:21 +00:00
|
|
|
gboolean (*check_feature) (GstGLContext *context, const gchar *feature);
|
2016-11-16 14:45:38 +00:00
|
|
|
void (*get_gl_platform_version) (GstGLContext *context, gint *major, gint *minor);
|
2013-08-14 00:44:19 +00:00
|
|
|
|
|
|
|
/*< private >*/
|
|
|
|
gpointer _reserved[GST_PADDING];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* methods */
|
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-08-14 00:44:19 +00:00
|
|
|
GstGLContext * gst_gl_context_new (GstGLDisplay *display);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2014-02-10 21:57:29 +00:00
|
|
|
GstGLContext * gst_gl_context_new_wrapped (GstGLDisplay *display,
|
|
|
|
guintptr handle,
|
|
|
|
GstGLPlatform context_type,
|
|
|
|
GstGLAPI available_apis);
|
2013-08-14 00:44:19 +00:00
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-08-14 00:44:19 +00:00
|
|
|
gboolean gst_gl_context_activate (GstGLContext *context, gboolean activate);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2014-09-21 11:30:58 +00:00
|
|
|
GThread * gst_gl_context_get_thread (GstGLContext *context);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-02-27 13:30:38 +00:00
|
|
|
GstGLContext * gst_gl_context_get_current (void);
|
2013-08-14 00:44:19 +00:00
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-09-15 04:23:43 +00:00
|
|
|
GstGLDisplay * gst_gl_context_get_display (GstGLContext *context);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-08-14 00:44:19 +00:00
|
|
|
gpointer gst_gl_context_get_proc_address (GstGLContext *context, const gchar *name);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2014-02-10 21:57:29 +00:00
|
|
|
GstGLPlatform gst_gl_context_get_gl_platform (GstGLContext *context);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-08-14 00:44:19 +00:00
|
|
|
GstGLAPI gst_gl_context_get_gl_api (GstGLContext *context);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-08-29 10:10:42 +00:00
|
|
|
guintptr gst_gl_context_get_gl_context (GstGLContext *context);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2014-09-23 02:01:04 +00:00
|
|
|
gboolean gst_gl_context_can_share (GstGLContext * context, GstGLContext *other_context);
|
2017-05-21 10:03:01 +00:00
|
|
|
GST_EXPORT
|
|
|
|
void gst_gl_context_swap_buffers (GstGLContext * context);
|
2013-08-14 00:44:19 +00:00
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-08-29 10:10:42 +00:00
|
|
|
gboolean gst_gl_context_create (GstGLContext *context, GstGLContext *other_context, GError ** error);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2014-07-31 08:46:33 +00:00
|
|
|
void gst_gl_context_destroy (GstGLContext *context);
|
2013-08-14 00:44:19 +00:00
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2014-10-28 06:31:37 +00:00
|
|
|
gpointer gst_gl_context_default_get_proc_address (GstGLAPI gl_api, const gchar *name);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2016-03-06 08:35:38 +00:00
|
|
|
gpointer gst_gl_context_get_proc_address_with_platform (GstGLPlatform context_type, GstGLAPI gl_api, const gchar *name);
|
2013-08-14 00:44:19 +00:00
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-08-14 00:44:19 +00:00
|
|
|
gboolean gst_gl_context_set_window (GstGLContext *context, GstGLWindow *window);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-08-14 00:44:19 +00:00
|
|
|
GstGLWindow * gst_gl_context_get_window (GstGLContext *context);
|
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2014-04-13 03:39:14 +00:00
|
|
|
void gst_gl_context_get_gl_version (GstGLContext *context, gint *maj, gint *min);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2014-05-29 10:35:48 +00:00
|
|
|
gboolean gst_gl_context_check_gl_version (GstGLContext * context, GstGLAPI api, gint maj, gint min);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2014-05-14 07:33:21 +00:00
|
|
|
gboolean gst_gl_context_check_feature (GstGLContext *context, const gchar *feature);
|
2016-11-16 14:45:38 +00:00
|
|
|
GST_EXPORT
|
|
|
|
void gst_gl_context_get_gl_platform_version (GstGLContext * context, gint * major, gint * minor);
|
2014-04-13 03:39:14 +00:00
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2016-03-06 08:35:38 +00:00
|
|
|
guintptr gst_gl_context_get_current_gl_context (GstGLPlatform context_type);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2015-07-18 07:19:18 +00:00
|
|
|
GstGLAPI gst_gl_context_get_current_gl_api (GstGLPlatform platform, guint *major, guint *minor);
|
2014-10-28 06:31:37 +00:00
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2016-01-07 03:02:52 +00:00
|
|
|
gboolean gst_gl_context_is_shared (GstGLContext * context);
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2016-02-25 21:34:11 +00:00
|
|
|
void gst_gl_context_set_shared_with (GstGLContext * context, GstGLContext * share);
|
2016-01-07 03:02:52 +00:00
|
|
|
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2014-12-31 06:45:53 +00:00
|
|
|
gboolean gst_gl_context_fill_info (GstGLContext * context, GError ** error);
|
|
|
|
|
2013-09-15 04:23:43 +00:00
|
|
|
/* FIXME: remove */
|
2016-10-27 02:47:58 +00:00
|
|
|
GST_EXPORT
|
2013-11-23 11:53:48 +00:00
|
|
|
void gst_gl_context_thread_add (GstGLContext * context,
|
2013-09-15 04:23:43 +00:00
|
|
|
GstGLContextThreadFunc func, gpointer data);
|
|
|
|
|
2013-08-14 00:44:19 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_GL_CONTEXT_H__ */
|