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>
|
|
|
|
|
2013-08-29 10:10:42 +00:00
|
|
|
#include <gst/gl/gl.h>
|
2013-08-14 00:44:19 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
#define GST_GL_TYPE_CONTEXT (gst_gl_context_get_type())
|
|
|
|
#define GST_GL_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_GL_TYPE_CONTEXT, GstGLContext))
|
2015-05-27 14:25:40 +00:00
|
|
|
#define GST_GL_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GST_GL_TYPE_CONTEXT, GstGLContextClass))
|
2013-08-14 00:44:19 +00:00
|
|
|
#define GST_GL_IS_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_GL_TYPE_CONTEXT))
|
|
|
|
#define GST_GL_IS_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_GL_TYPE_CONTEXT))
|
|
|
|
#define GST_GL_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_GL_TYPE_CONTEXT, GstGLContextClass))
|
|
|
|
GType gst_gl_context_get_type (void);
|
|
|
|
|
|
|
|
#define GST_GL_CONTEXT_ERROR (gst_gl_context_error_quark ())
|
2013-08-15 07:09:04 +00:00
|
|
|
GQuark gst_gl_context_error_quark (void);
|
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
|
|
|
|
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:
|
|
|
|
*
|
|
|
|
* Opaque #GstGLContext object
|
|
|
|
*/
|
2013-08-14 00:44:19 +00:00
|
|
|
struct _GstGLContext {
|
|
|
|
/*< 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;
|
|
|
|
|
2013-09-15 04:23:43 +00:00
|
|
|
GstGLFuncs *gl_vtable;
|
|
|
|
|
2013-08-14 00:44:19 +00:00
|
|
|
gpointer _reserved[GST_PADDING];
|
|
|
|
|
|
|
|
GstGLContextPrivate *priv;
|
|
|
|
};
|
|
|
|
|
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);
|
2013-08-14 00:44:19 +00:00
|
|
|
|
|
|
|
/*< private >*/
|
|
|
|
gpointer _reserved[GST_PADDING];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* methods */
|
|
|
|
|
|
|
|
GstGLContext * gst_gl_context_new (GstGLDisplay *display);
|
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
|
|
|
|
|
|
|
gboolean gst_gl_context_activate (GstGLContext *context, gboolean activate);
|
2014-09-21 11:30:58 +00:00
|
|
|
GThread * gst_gl_context_get_thread (GstGLContext *context);
|
2015-02-27 13:30:38 +00:00
|
|
|
GstGLContext * gst_gl_context_get_current (void);
|
2013-08-14 00:44:19 +00:00
|
|
|
|
2013-09-15 04:23:43 +00:00
|
|
|
GstGLDisplay * gst_gl_context_get_display (GstGLContext *context);
|
2013-08-14 00:44:19 +00:00
|
|
|
gpointer gst_gl_context_get_proc_address (GstGLContext *context, const gchar *name);
|
2014-02-10 21:57:29 +00:00
|
|
|
GstGLPlatform gst_gl_context_get_gl_platform (GstGLContext *context);
|
2013-08-14 00:44:19 +00:00
|
|
|
GstGLAPI gst_gl_context_get_gl_api (GstGLContext *context);
|
2013-08-29 10:10:42 +00:00
|
|
|
guintptr gst_gl_context_get_gl_context (GstGLContext *context);
|
2014-09-23 02:01:04 +00:00
|
|
|
gboolean gst_gl_context_can_share (GstGLContext * context, GstGLContext *other_context);
|
2013-08-14 00:44:19 +00:00
|
|
|
|
2013-08-29 10:10:42 +00:00
|
|
|
gboolean gst_gl_context_create (GstGLContext *context, GstGLContext *other_context, GError ** error);
|
2014-07-31 08:46:33 +00:00
|
|
|
void gst_gl_context_destroy (GstGLContext *context);
|
2013-08-14 00:44:19 +00:00
|
|
|
|
2014-10-28 06:31:37 +00:00
|
|
|
gpointer gst_gl_context_default_get_proc_address (GstGLAPI gl_api, const gchar *name);
|
2015-07-18 07:08:36 +00:00
|
|
|
gpointer gst_gl_context_get_proc_address_with_platform (GstGLPlatform, GstGLAPI gl_api, const gchar *name);
|
2013-08-14 00:44:19 +00:00
|
|
|
|
|
|
|
gboolean gst_gl_context_set_window (GstGLContext *context, GstGLWindow *window);
|
|
|
|
GstGLWindow * gst_gl_context_get_window (GstGLContext *context);
|
|
|
|
|
2014-04-13 03:39:14 +00:00
|
|
|
void gst_gl_context_get_gl_version (GstGLContext *context, gint *maj, gint *min);
|
2014-05-29 10:35:48 +00:00
|
|
|
gboolean gst_gl_context_check_gl_version (GstGLContext * context, GstGLAPI api, gint maj, gint min);
|
2014-05-14 07:33:21 +00:00
|
|
|
gboolean gst_gl_context_check_feature (GstGLContext *context, const gchar *feature);
|
2014-04-13 03:39:14 +00:00
|
|
|
|
2014-10-28 06:31:37 +00:00
|
|
|
guintptr gst_gl_context_get_current_gl_context (GstGLPlatform platform);
|
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
|
|
|
|
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 */
|
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);
|
|
|
|
|
2015-02-12 13:58:14 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (gst_gl_context_debug);
|
|
|
|
|
2013-08-14 00:44:19 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_GL_CONTEXT_H__ */
|