2008-08-11 17:01:33 +00:00
|
|
|
/*
|
2008-05-19 16:57:39 +00:00
|
|
|
* GStreamer
|
2008-09-20 13:44:24 +00:00
|
|
|
* Copyright (C) 2007 David A. Schleef <ds@schleef.org>
|
2008-05-19 16:57:39 +00:00
|
|
|
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
2008-08-11 07:52:16 +00:00
|
|
|
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
|
2008-05-19 16:57:39 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-11-08 11:53:56 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2008-05-19 16:57:39 +00:00
|
|
|
*/
|
|
|
|
|
2008-05-18 11:12:46 +00:00
|
|
|
#ifndef __GST_GL_H__
|
|
|
|
#define __GST_GL_H__
|
|
|
|
|
2013-01-09 14:13:23 +00:00
|
|
|
#include "gstglconfig.h"
|
|
|
|
|
2008-05-18 11:12:46 +00:00
|
|
|
#include <gst/video/video.h>
|
|
|
|
|
2012-12-06 07:40:26 +00:00
|
|
|
typedef struct _GstGLUpload GstGLUpload;
|
|
|
|
typedef struct _GstGLDownload GstGLDownload;
|
|
|
|
typedef struct _GstGLShader GstGLShader;
|
|
|
|
|
2008-11-05 01:06:33 +00:00
|
|
|
#include "gstglwindow.h"
|
2008-07-19 01:00:26 +00:00
|
|
|
#include "gstglshader.h"
|
2012-09-16 11:23:09 +00:00
|
|
|
#include "gstglupload.h"
|
|
|
|
#include "gstgldownload.h"
|
2008-07-19 01:00:26 +00:00
|
|
|
|
2010-12-14 23:56:55 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
GType gst_gl_display_get_type (void);
|
2012-12-06 07:40:26 +00:00
|
|
|
#define GST_GL_TYPE_DISPLAY (gst_gl_display_get_type())
|
|
|
|
#define GST_GL_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_GL_TYPE_DISPLAY,GstGLDisplay))
|
2012-09-27 05:53:46 +00:00
|
|
|
#define GST_GL_DISPLAY_CLASS(klass) \
|
2012-12-06 07:40:26 +00:00
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_GL_TYPE_DISPLAY,GstGLDisplayClass))
|
2012-09-27 05:53:46 +00:00
|
|
|
#define GST_IS_GL_DISPLAY(obj) \
|
2012-12-06 07:40:26 +00:00
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_GL_TYPE_DISPLAY))
|
2012-09-27 05:53:46 +00:00
|
|
|
#define GST_IS_GL_DISPLAY_CLASS(klass) \
|
2012-12-06 07:40:26 +00:00
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_GL_TYPE_DISPLAY))
|
2011-11-24 15:02:32 +00:00
|
|
|
#define GST_GL_DISPLAY_CAST(obj) ((GstGLDisplay*)(obj))
|
2008-05-18 11:12:46 +00:00
|
|
|
|
|
|
|
typedef struct _GstGLDisplay GstGLDisplay;
|
|
|
|
typedef struct _GstGLDisplayClass GstGLDisplayClass;
|
2012-12-06 07:40:26 +00:00
|
|
|
typedef struct _GstGLDisplayPrivate GstGLDisplayPrivate;
|
2008-05-18 11:12:46 +00:00
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/**
|
|
|
|
* GstGLDisplayConversion:
|
|
|
|
*
|
|
|
|
* %GST_GL_DISPLAY_CONVERSION_GLSL: Convert using GLSL (shaders)
|
|
|
|
* %GST_GL_DISPLAY_CONVERSION_MATRIX: Convert using the ARB_imaging extension (not implemented)
|
|
|
|
* %GST_GL_DISPLAY_CONVERSION_MESA: Convert using support in MESA
|
|
|
|
*/
|
2009-04-10 18:30:46 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2012-09-27 05:53:46 +00:00
|
|
|
GST_GL_DISPLAY_CONVERSION_GLSL,
|
|
|
|
GST_GL_DISPLAY_CONVERSION_MATRIX,
|
|
|
|
GST_GL_DISPLAY_CONVERSION_MESA,
|
2008-06-28 15:38:41 +00:00
|
|
|
} GstGLDisplayConversion;
|
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/**
|
|
|
|
* GstGLDisplayProjection:
|
|
|
|
*
|
|
|
|
* %GST_GL_DISPLAY_PROJECTION_ORTHO2D: Orthogonal projection
|
|
|
|
* %GST_GL_DISPLAY_CONVERSION_MATRIX: Perspective projection
|
|
|
|
*/
|
2009-04-10 18:30:46 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2008-08-01 09:00:49 +00:00
|
|
|
GST_GL_DISPLAY_PROJECTION_ORTHO2D,
|
2009-06-12 10:33:02 +00:00
|
|
|
GST_GL_DISPLAY_PROJECTION_PERSPECTIVE
|
2008-07-05 22:56:29 +00:00
|
|
|
} GstGLDisplayProjection;
|
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/**
|
|
|
|
* CRCB:
|
|
|
|
* @width: new width
|
|
|
|
* @height: new height:
|
|
|
|
* @data: user data
|
|
|
|
*
|
|
|
|
* client reshape callback
|
|
|
|
*/
|
|
|
|
typedef void (*CRCB) (GLuint width, GLuint height, gpointer data);
|
|
|
|
/**
|
|
|
|
* CDCB:
|
|
|
|
* @texture: texture to draw
|
|
|
|
* @width: new width
|
|
|
|
* @height: new height:
|
|
|
|
* @data: user data
|
|
|
|
*
|
|
|
|
* client draw callback
|
|
|
|
*/
|
|
|
|
typedef gboolean (*CDCB) (GLuint texture, GLuint width, GLuint height, gpointer data);
|
|
|
|
/**
|
|
|
|
* GstGLDisplayThreadFunc:
|
|
|
|
* @display: a #GstGLDisplay
|
|
|
|
* @data: user data
|
|
|
|
*
|
|
|
|
* Represents a function to run in the GL thread
|
|
|
|
*/
|
2009-04-10 18:30:46 +00:00
|
|
|
typedef void (*GstGLDisplayThreadFunc) (GstGLDisplay * display, gpointer data);
|
2008-08-11 07:00:40 +00:00
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/**
|
|
|
|
* GLCB:
|
|
|
|
* @width: the width
|
|
|
|
* @height: the height
|
|
|
|
* @texture: texture
|
|
|
|
* @stuff: user data
|
|
|
|
*
|
|
|
|
* callback definition for operating on textures
|
|
|
|
*/
|
2009-04-10 18:30:46 +00:00
|
|
|
typedef void (*GLCB) (gint, gint, guint, gpointer stuff);
|
2012-09-27 05:53:46 +00:00
|
|
|
/**
|
|
|
|
* GLCB_V2:
|
|
|
|
* @stuff: user data
|
|
|
|
*
|
|
|
|
* callback definition for operating through a Framebuffer object
|
|
|
|
*/
|
2009-10-22 23:11:27 +00:00
|
|
|
typedef void (*GLCB_V2) (gpointer stuff);
|
2008-06-07 15:27:12 +00:00
|
|
|
|
2012-04-20 08:41:51 +00:00
|
|
|
#define GST_GL_DISPLAY_ERR_MSG(obj) ("%s", GST_GL_DISPLAY_CAST(obj)->error_message)
|
2011-11-24 15:02:32 +00:00
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/**
|
|
|
|
* GstGLDisplay:
|
|
|
|
*
|
|
|
|
* the contents of a #GstGLDisplay are private and should only be accessed
|
|
|
|
* through the provided API
|
|
|
|
*/
|
2009-04-10 18:30:46 +00:00
|
|
|
struct _GstGLDisplay
|
|
|
|
{
|
2012-09-27 05:53:46 +00:00
|
|
|
GObject object;
|
|
|
|
|
|
|
|
/* thread safe */
|
|
|
|
GMutex *mutex;
|
|
|
|
|
|
|
|
/* gl context */
|
|
|
|
GThread *gl_thread;
|
|
|
|
GstGLWindow *gl_window;
|
|
|
|
gboolean isAlive;
|
|
|
|
|
2012-12-06 07:40:26 +00:00
|
|
|
/* gl API we are using */
|
|
|
|
GstGLAPI gl_api;
|
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/* conditions */
|
|
|
|
GCond *cond_create_context;
|
|
|
|
GCond *cond_destroy_context;
|
|
|
|
|
|
|
|
/* generic gl code */
|
|
|
|
GstGLDisplayThreadFunc generic_callback;
|
|
|
|
gpointer data;
|
|
|
|
|
|
|
|
/* action redisplay */
|
|
|
|
GLuint redisplay_texture;
|
|
|
|
GLuint redisplay_texture_width;
|
|
|
|
GLuint redisplay_texture_height;
|
|
|
|
gboolean keep_aspect_ratio;
|
2013-01-09 14:13:23 +00:00
|
|
|
#if GST_GL_HAVE_GLES2
|
2012-09-27 05:53:46 +00:00
|
|
|
GstGLShader *redisplay_shader;
|
2012-12-06 07:40:26 +00:00
|
|
|
gchar *redisplay_vertex_shader_str_gles2;
|
|
|
|
gchar *redisplay_fragment_shader_str_gles2;
|
2012-09-27 05:53:46 +00:00
|
|
|
GLint redisplay_attr_position_loc;
|
|
|
|
GLint redisplay_attr_texture_loc;
|
2009-03-15 13:48:19 +00:00
|
|
|
#endif
|
2008-08-01 09:00:49 +00:00
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/* action gen and del texture */
|
|
|
|
GLuint gen_texture;
|
|
|
|
GLuint gen_texture_width;
|
|
|
|
GLuint gen_texture_height;
|
2012-07-06 08:51:02 +00:00
|
|
|
GstVideoFormat gen_texture_video_format;
|
2008-08-01 09:00:49 +00:00
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/* client callbacks */
|
|
|
|
CRCB clientReshapeCallback;
|
|
|
|
CDCB clientDrawCallback;
|
|
|
|
gpointer client_data;
|
2008-08-01 09:00:49 +00:00
|
|
|
|
2012-09-16 11:23:09 +00:00
|
|
|
GstGLDisplayConversion colorspace_conversion;
|
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
GSList *uploads;
|
|
|
|
GSList *downloads;
|
|
|
|
|
|
|
|
/* foreign gl context */
|
|
|
|
gulong external_gl_context;
|
|
|
|
|
|
|
|
/* filter gen fbo */
|
|
|
|
GLuint gen_fbo_width;
|
|
|
|
GLuint gen_fbo_height;
|
|
|
|
GLuint generated_fbo;
|
|
|
|
GLuint generated_depth_buffer;
|
|
|
|
|
|
|
|
/* filter use fbo */
|
|
|
|
GLuint use_fbo;
|
|
|
|
GLuint use_depth_buffer;
|
|
|
|
GLuint use_fbo_texture;
|
|
|
|
GLuint use_fbo_width;
|
|
|
|
GLuint use_fbo_height;
|
|
|
|
GLCB use_fbo_scene_cb;
|
|
|
|
GLCB_V2 use_fbo_scene_cb_v2;
|
|
|
|
gdouble use_fbo_proj_param1;
|
|
|
|
gdouble use_fbo_proj_param2;
|
|
|
|
gdouble use_fbo_proj_param3;
|
|
|
|
gdouble use_fbo_proj_param4;
|
2008-08-01 09:00:49 +00:00
|
|
|
GstGLDisplayProjection use_fbo_projection;
|
2012-09-27 05:53:46 +00:00
|
|
|
gpointer *use_fbo_stuff;
|
|
|
|
GLuint input_texture_width;
|
|
|
|
GLuint input_texture_height;
|
|
|
|
GLuint input_texture;
|
2008-08-01 09:00:49 +00:00
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/* filter del fbo */
|
|
|
|
GLuint del_fbo;
|
|
|
|
GLuint del_depth_buffer;
|
2008-08-01 09:00:49 +00:00
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/* action gen and del shader */
|
|
|
|
const gchar *gen_shader_fragment_source;
|
|
|
|
const gchar *gen_shader_vertex_source;
|
|
|
|
GstGLShader *gen_shader;
|
|
|
|
GstGLShader *del_shader;
|
2009-03-15 13:48:19 +00:00
|
|
|
|
2011-11-24 15:02:32 +00:00
|
|
|
gchar *error_message;
|
2012-12-06 07:40:26 +00:00
|
|
|
|
|
|
|
GstGLDisplayPrivate *priv;
|
2008-05-18 11:12:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-10 18:30:46 +00:00
|
|
|
struct _GstGLDisplayClass
|
|
|
|
{
|
2008-08-01 09:00:49 +00:00
|
|
|
GObjectClass object_class;
|
2008-05-18 11:12:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/*-----------------------------------------------------------*\
|
|
|
|
-------------------- Public declarations -------------------
|
|
|
|
\*-----------------------------------------------------------*/
|
2009-04-10 18:30:46 +00:00
|
|
|
GstGLDisplay *gst_gl_display_new (void);
|
|
|
|
|
2011-11-24 15:02:32 +00:00
|
|
|
gboolean gst_gl_display_create_context (GstGLDisplay * display,
|
2009-10-22 23:11:27 +00:00
|
|
|
gulong external_gl_context);
|
2009-04-10 18:30:46 +00:00
|
|
|
gboolean gst_gl_display_redisplay (GstGLDisplay * display, GLuint texture,
|
2010-05-04 09:37:38 +00:00
|
|
|
gint gl_width, gint gl_height, gint window_width, gint window_height,
|
|
|
|
gboolean keep_aspect_ratio);
|
2009-04-10 18:30:46 +00:00
|
|
|
|
|
|
|
void gst_gl_display_thread_add (GstGLDisplay * display,
|
|
|
|
GstGLDisplayThreadFunc func, gpointer data);
|
|
|
|
|
|
|
|
void gst_gl_display_gen_texture (GstGLDisplay * display, GLuint * pTexture,
|
2012-07-06 08:51:02 +00:00
|
|
|
GstVideoFormat v_format, GLint width, GLint height);
|
|
|
|
void gst_gl_display_gen_texture_thread (GstGLDisplay * display, GLuint * pTexture,
|
|
|
|
GstVideoFormat v_format, GLint width, GLint height);
|
|
|
|
void gst_gl_display_del_texture (GstGLDisplay * display, GLuint * pTexture);
|
2009-04-10 18:30:46 +00:00
|
|
|
|
2011-11-24 15:02:32 +00:00
|
|
|
gboolean gst_gl_display_gen_fbo (GstGLDisplay * display, gint width, gint height,
|
2009-04-10 18:30:46 +00:00
|
|
|
GLuint * fbo, GLuint * depthbuffer);
|
|
|
|
gboolean gst_gl_display_use_fbo (GstGLDisplay * display, gint texture_fbo_width,
|
|
|
|
gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
|
|
|
|
GLuint texture_fbo, GLCB cb, gint input_texture_width,
|
|
|
|
gint input_texture_height, GLuint input_texture, gdouble proj_param1,
|
|
|
|
gdouble proj_param2, gdouble proj_param3, gdouble proj_param4,
|
|
|
|
GstGLDisplayProjection projection, gpointer * stuff);
|
2009-10-22 23:11:27 +00:00
|
|
|
gboolean gst_gl_display_use_fbo_v2 (GstGLDisplay * display, gint texture_fbo_width,
|
|
|
|
gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
|
|
|
|
GLuint texture_fbo, GLCB_V2 cb, gpointer * stuff);
|
2009-04-10 18:30:46 +00:00
|
|
|
void gst_gl_display_del_fbo (GstGLDisplay * display, GLuint fbo,
|
|
|
|
GLuint depth_buffer);
|
|
|
|
|
2011-11-24 15:02:32 +00:00
|
|
|
gboolean gst_gl_display_gen_shader (GstGLDisplay * display,
|
2009-04-10 18:30:46 +00:00
|
|
|
const gchar * shader_vertex_source,
|
|
|
|
const gchar * shader_fragment_source, GstGLShader ** shader);
|
|
|
|
void gst_gl_display_del_shader (GstGLDisplay * display, GstGLShader * shader);
|
|
|
|
|
2012-11-14 09:39:38 +00:00
|
|
|
void gst_gl_display_set_window_id (GstGLDisplay * display, guintptr window_id);
|
2009-04-10 18:30:46 +00:00
|
|
|
void gst_gl_display_set_client_reshape_callback (GstGLDisplay * display,
|
|
|
|
CRCB cb);
|
|
|
|
void gst_gl_display_set_client_draw_callback (GstGLDisplay * display, CDCB cb);
|
2009-11-21 12:21:54 +00:00
|
|
|
void gst_gl_display_set_client_data (GstGLDisplay * display, gpointer data);
|
2008-05-18 11:12:46 +00:00
|
|
|
|
2009-10-22 23:11:27 +00:00
|
|
|
gulong gst_gl_display_get_internal_gl_context (GstGLDisplay * display);
|
|
|
|
void gst_gl_display_activate_gl_context (GstGLDisplay * display, gboolean activate);
|
|
|
|
|
2011-11-24 15:02:32 +00:00
|
|
|
/* Must be called inside a lock/unlock on display, or within the glthread */
|
|
|
|
void gst_gl_display_set_error (GstGLDisplay * display, const char * format, ...);
|
2012-09-16 11:23:09 +00:00
|
|
|
void gst_gl_display_check_framebuffer_status (void);
|
|
|
|
|
|
|
|
void gst_gl_display_lock (GstGLDisplay * display);
|
|
|
|
void gst_gl_display_unlock (GstGLDisplay * display);
|
2012-12-06 07:40:26 +00:00
|
|
|
GstGLAPI gst_gl_display_get_gl_api (GstGLDisplay * display);
|
|
|
|
GstGLAPI gst_gl_display_get_gl_api_unlocked (GstGLDisplay * display);
|
2011-11-24 15:02:32 +00:00
|
|
|
|
2010-12-14 23:56:55 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_GL_H__ */
|