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
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2008-05-18 11:12:46 +00:00
|
|
|
#ifndef __GST_GL_H__
|
|
|
|
#define __GST_GL_H__
|
|
|
|
|
|
|
|
#include <gst/video/video.h>
|
|
|
|
|
2008-11-05 01:06:33 +00:00
|
|
|
#include "gstglwindow.h"
|
2008-07-19 01:00:26 +00:00
|
|
|
#include "gstglshader.h"
|
|
|
|
|
2008-08-01 09:00:49 +00:00
|
|
|
#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))
|
2008-05-18 11:12:46 +00:00
|
|
|
|
|
|
|
typedef struct _GstGLDisplay GstGLDisplay;
|
|
|
|
typedef struct _GstGLDisplayClass GstGLDisplayClass;
|
|
|
|
|
2008-06-29 17:27:43 +00:00
|
|
|
//Color space conversion method
|
2008-06-28 15:38:41 +00:00
|
|
|
typedef enum {
|
2008-08-01 09:00:49 +00:00
|
|
|
GST_GL_DISPLAY_CONVERSION_GLSL, //ARB_fragment_shade
|
|
|
|
GST_GL_DISPLAY_CONVERSION_MATRIX, //ARB_imaging
|
|
|
|
GST_GL_DISPLAY_CONVERSION_MESA, //MESA_ycbcr_texture
|
2008-06-28 15:38:41 +00:00
|
|
|
} GstGLDisplayConversion;
|
|
|
|
|
|
|
|
|
2008-07-05 22:56:29 +00:00
|
|
|
//Projection type
|
|
|
|
typedef enum {
|
2008-08-01 09:00:49 +00:00
|
|
|
GST_GL_DISPLAY_PROJECTION_ORTHO2D,
|
|
|
|
GST_GL_DISPLAY_PROJECTION_PERSPECIVE
|
2008-07-05 22:56:29 +00:00
|
|
|
} GstGLDisplayProjection;
|
|
|
|
|
2008-05-18 11:12:46 +00:00
|
|
|
//Texture pool elements
|
|
|
|
typedef struct _GstGLDisplayTex {
|
2008-08-01 09:00:49 +00:00
|
|
|
GLuint texture;
|
2008-05-18 11:12:46 +00:00
|
|
|
} GstGLDisplayTex;
|
|
|
|
|
|
|
|
|
|
|
|
//Client callbacks
|
|
|
|
typedef void (* CRCB) ( GLuint, GLuint );
|
|
|
|
typedef gboolean (* CDCB) ( GLuint, GLuint, GLuint);
|
|
|
|
|
2008-08-11 07:00:40 +00:00
|
|
|
typedef void (* GstGLDisplayThreadFunc) (GstGLDisplay *display, gpointer data);
|
|
|
|
|
2008-06-07 15:27:12 +00:00
|
|
|
//opengl scene callback
|
2008-07-05 22:56:29 +00:00
|
|
|
typedef void (* GLCB) ( gint, gint, guint, gpointer stuff);
|
2008-06-07 15:27:12 +00:00
|
|
|
|
2008-05-18 11:12:46 +00:00
|
|
|
struct _GstGLDisplay {
|
2008-08-01 09:00:49 +00:00
|
|
|
GObject object;
|
2008-05-18 11:12:46 +00:00
|
|
|
|
2008-08-01 09:00:49 +00:00
|
|
|
//thread safe
|
|
|
|
GMutex* mutex;
|
2008-08-11 17:01:33 +00:00
|
|
|
|
2008-08-01 09:00:49 +00:00
|
|
|
//gl context
|
2008-10-22 23:40:52 +00:00
|
|
|
GThread* gl_thread;
|
|
|
|
GstGLWindow* gl_window;
|
2008-08-01 09:00:49 +00:00
|
|
|
gboolean visible;
|
|
|
|
gboolean isAlive;
|
2008-08-21 09:12:42 +00:00
|
|
|
GHashTable* texture_pool;
|
2008-08-11 17:01:33 +00:00
|
|
|
|
2008-08-01 09:00:49 +00:00
|
|
|
//conditions
|
|
|
|
GCond* cond_create_context;
|
|
|
|
|
2008-08-11 07:00:40 +00:00
|
|
|
//generic gl code
|
|
|
|
GstGLDisplayThreadFunc generic_callback;
|
|
|
|
gpointer data;
|
|
|
|
|
2008-08-01 09:00:49 +00:00
|
|
|
//action redisplay
|
|
|
|
GLuint redisplay_texture;
|
|
|
|
GLuint redisplay_texture_width;
|
|
|
|
GLuint redisplay_texture_height;
|
|
|
|
|
|
|
|
//action gen and del texture
|
|
|
|
GLuint gen_texture;
|
2008-08-11 17:01:33 +00:00
|
|
|
GLuint gen_texture_width;
|
|
|
|
GLuint gen_texture_height;
|
2008-08-01 09:00:49 +00:00
|
|
|
GLuint del_texture;
|
2008-08-11 17:01:33 +00:00
|
|
|
GLuint del_texture_width;
|
|
|
|
GLuint del_texture_height;
|
2008-08-01 09:00:49 +00:00
|
|
|
|
|
|
|
//client callbacks
|
|
|
|
CRCB clientReshapeCallback;
|
|
|
|
CDCB clientDrawCallback;
|
|
|
|
|
|
|
|
//upload
|
|
|
|
GLuint upload_fbo;
|
|
|
|
GLuint upload_depth_buffer;
|
2008-08-04 07:56:59 +00:00
|
|
|
GLuint upload_outtex;
|
2008-08-04 07:46:14 +00:00
|
|
|
GLuint upload_intex;
|
|
|
|
GLuint upload_intex_u;
|
|
|
|
GLuint upload_intex_v;
|
2008-08-01 09:00:49 +00:00
|
|
|
GLuint upload_width;
|
|
|
|
GLuint upload_height;
|
|
|
|
GstVideoFormat upload_video_format;
|
2008-08-24 01:12:12 +00:00
|
|
|
GstGLDisplayConversion upload_colorspace_conversion;
|
2008-08-13 15:59:09 +00:00
|
|
|
gint upload_data_width;
|
2008-08-01 09:00:49 +00:00
|
|
|
gint upload_data_height;
|
|
|
|
gpointer upload_data;
|
|
|
|
|
|
|
|
//filter gen fbo
|
|
|
|
GLuint gen_fbo_width;
|
|
|
|
GLuint gen_fbo_height;
|
|
|
|
GLuint generated_fbo;
|
|
|
|
GLuint generated_depth_buffer;
|
2008-08-11 17:01:33 +00:00
|
|
|
|
2008-08-01 09:00:49 +00:00
|
|
|
//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;
|
|
|
|
gdouble use_fbo_proj_param1;
|
|
|
|
gdouble use_fbo_proj_param2;
|
|
|
|
gdouble use_fbo_proj_param3;
|
|
|
|
gdouble use_fbo_proj_param4;
|
|
|
|
GstGLDisplayProjection use_fbo_projection;
|
|
|
|
gpointer* use_fbo_stuff;
|
|
|
|
GLuint input_texture_width;
|
|
|
|
GLuint input_texture_height;
|
|
|
|
GLuint input_texture;
|
|
|
|
|
|
|
|
//filter del fbo
|
|
|
|
GLuint del_fbo;
|
|
|
|
GLuint del_depth_buffer;
|
|
|
|
|
|
|
|
//download
|
|
|
|
GLuint download_fbo;
|
|
|
|
GLuint download_depth_buffer;
|
|
|
|
GLuint download_texture;
|
|
|
|
GLuint download_texture_u;
|
|
|
|
GLuint download_texture_v;
|
|
|
|
gint download_width;
|
|
|
|
gint download_height;
|
|
|
|
GstVideoFormat download_video_format;
|
|
|
|
gpointer download_data;
|
|
|
|
GLenum multipleRT[3];
|
|
|
|
GLuint ouput_texture;
|
|
|
|
GLuint ouput_texture_width;
|
|
|
|
GLuint ouput_texture_height;
|
|
|
|
|
|
|
|
//action gen and del shader
|
2008-09-06 22:45:34 +00:00
|
|
|
const gchar* gen_shader_fragment_source;
|
|
|
|
const gchar* gen_shader_vertex_source;
|
2008-08-01 09:00:49 +00:00
|
|
|
GstGLShader* gen_shader;
|
|
|
|
GstGLShader* del_shader;
|
|
|
|
|
|
|
|
//fragement shader upload
|
|
|
|
gchar* text_shader_upload_YUY2_UYVY;
|
|
|
|
GstGLShader* shader_upload_YUY2;
|
|
|
|
GstGLShader* shader_upload_UYVY;
|
|
|
|
|
|
|
|
gchar* text_shader_upload_I420_YV12;
|
|
|
|
GstGLShader* shader_upload_I420_YV12;
|
|
|
|
|
|
|
|
gchar* text_shader_upload_AYUV;
|
|
|
|
GstGLShader* shader_upload_AYUV;
|
|
|
|
|
|
|
|
//fragement shader download
|
|
|
|
gchar* text_shader_download_YUY2_UYVY;
|
|
|
|
GstGLShader* shader_download_YUY2;
|
|
|
|
GstGLShader* shader_download_UYVY;
|
|
|
|
|
|
|
|
gchar* text_shader_download_I420_YV12;
|
|
|
|
GstGLShader* shader_download_I420_YV12;
|
|
|
|
|
|
|
|
gchar* text_shader_download_AYUV;
|
|
|
|
GstGLShader* shader_download_AYUV;
|
2008-05-18 11:12:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct _GstGLDisplayClass {
|
2008-08-01 09:00:49 +00:00
|
|
|
GObjectClass object_class;
|
2008-05-18 11:12:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GType gst_gl_display_get_type (void);
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
2008-06-07 15:27:12 +00:00
|
|
|
//-------------------- Public declarations ------------------
|
2008-08-11 17:01:33 +00:00
|
|
|
//------------------------------------------------------------
|
2008-06-29 17:27:43 +00:00
|
|
|
GstGLDisplay* gst_gl_display_new (void);
|
|
|
|
|
2008-08-11 17:01:33 +00:00
|
|
|
void gst_gl_display_create_context (GstGLDisplay* display,
|
2008-10-27 23:22:27 +00:00
|
|
|
GLint width, GLint height);
|
2008-06-29 17:27:43 +00:00
|
|
|
void gst_gl_display_set_visible_context (GstGLDisplay* display, gboolean visible);
|
|
|
|
gboolean gst_gl_display_redisplay (GstGLDisplay* display, GLuint texture, gint width, gint height);
|
|
|
|
|
2008-08-11 07:00:40 +00:00
|
|
|
void gst_gl_display_thread_add (GstGLDisplay *display,
|
|
|
|
GstGLDisplayThreadFunc func, gpointer data);
|
|
|
|
|
2008-08-11 17:01:33 +00:00
|
|
|
void gst_gl_display_gen_texture (GstGLDisplay* display, GLuint* pTexture, GLint width, GLint height);
|
|
|
|
void gst_gl_display_del_texture (GstGLDisplay* display, GLuint texture, GLint width, GLint height);
|
2008-06-29 17:27:43 +00:00
|
|
|
|
2008-06-28 15:38:41 +00:00
|
|
|
void gst_gl_display_init_upload (GstGLDisplay* display, GstVideoFormat video_format,
|
2008-08-13 15:59:09 +00:00
|
|
|
guint gl_width, guint gl_height,
|
|
|
|
gint video_width, gint video_height);
|
2008-07-20 14:38:48 +00:00
|
|
|
gboolean gst_gl_display_do_upload (GstGLDisplay* display, GLuint texture,
|
2008-08-11 17:01:33 +00:00
|
|
|
gint data_width, gint data_height,
|
2008-07-20 14:38:48 +00:00
|
|
|
gpointer data);
|
2008-08-11 17:01:33 +00:00
|
|
|
void gst_gl_display_init_download (GstGLDisplay* display, GstVideoFormat video_format,
|
2008-06-28 23:28:11 +00:00
|
|
|
gint width, gint height);
|
2008-07-20 14:38:48 +00:00
|
|
|
gboolean gst_gl_display_do_download (GstGLDisplay* display, GLuint texture,
|
|
|
|
gint width, gint height,
|
|
|
|
gpointer data);
|
2008-06-29 17:27:43 +00:00
|
|
|
|
2008-08-11 17:01:33 +00:00
|
|
|
void gst_gl_display_gen_fbo (GstGLDisplay* display, gint width, gint height,
|
2008-07-16 22:23:36 +00:00
|
|
|
GLuint* fbo, GLuint* depthbuffer);
|
2008-07-20 14:38:48 +00:00
|
|
|
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);
|
2008-08-11 17:01:33 +00:00
|
|
|
void gst_gl_display_del_fbo (GstGLDisplay* display, GLuint fbo,
|
2008-07-16 22:23:36 +00:00
|
|
|
GLuint depth_buffer);
|
2008-06-29 17:27:43 +00:00
|
|
|
|
2008-11-05 01:06:33 +00:00
|
|
|
void gst_gl_display_gen_shader (GstGLDisplay* display,
|
2008-09-06 22:45:34 +00:00
|
|
|
const gchar* shader_vertex_source,
|
|
|
|
const gchar* shader_fragment_source,
|
|
|
|
GstGLShader** shader);
|
2008-07-19 01:00:26 +00:00
|
|
|
void gst_gl_display_del_shader (GstGLDisplay* display, GstGLShader* shader);
|
2008-06-29 17:27:43 +00:00
|
|
|
|
2008-10-27 23:22:27 +00:00
|
|
|
void gst_gl_display_set_window_id (GstGLDisplay* display, gulong window_id);
|
2008-06-29 17:27:43 +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);
|
2008-05-18 11:12:46 +00:00
|
|
|
|
|
|
|
#endif
|