2008-05-19 16:57:39 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 2008 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., 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__
|
|
|
|
|
2008-05-18 14:47:01 +00:00
|
|
|
#include <GL/glew.h>
|
2008-05-18 17:55:56 +00:00
|
|
|
#include <gstfreeglut.h>
|
2008-05-18 11:12:46 +00:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/video/video.h>
|
|
|
|
|
|
|
|
#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))
|
|
|
|
|
|
|
|
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 {
|
|
|
|
GST_GL_DISPLAY_CONVERSION_GLSL, //ARB_fragment_shade
|
|
|
|
GST_GL_DISPLAY_CONVERSION_MATRIX, //ARB_imaging
|
|
|
|
GST_GL_DISPLAY_CONVERSION_MESA, //MESA_ycbcr_texture
|
|
|
|
} GstGLDisplayConversion;
|
|
|
|
|
|
|
|
|
2008-05-18 11:12:46 +00:00
|
|
|
//Message type
|
|
|
|
typedef enum {
|
2008-06-29 17:27:43 +00:00
|
|
|
GST_GL_DISPLAY_ACTION_CREATE_CONTEXT,
|
|
|
|
GST_GL_DISPLAY_ACTION_DESTROY_CONTEXT,
|
|
|
|
GST_GL_DISPLAY_ACTION_VISIBLE_CONTEXT,
|
|
|
|
GST_GL_DISPLAY_ACTION_RESIZE_CONTEXT,
|
|
|
|
GST_GL_DISPLAY_ACTION_REDISPLAY_CONTEXT,
|
|
|
|
GST_GL_DISPLAY_ACTION_GEN_TEXTURE,
|
|
|
|
GST_GL_DISPLAY_ACTION_DEL_TEXTURE,
|
|
|
|
GST_GL_DISPLAY_ACTION_INIT_UPLOAD,
|
|
|
|
GST_GL_DISPLAY_ACTION_DO_UPLOAD,
|
2008-06-28 23:28:11 +00:00
|
|
|
GST_GL_DISPLAY_ACTION_INIT_DOWNLOAD,
|
2008-06-29 17:27:43 +00:00
|
|
|
GST_GL_DISPLAY_ACTION_DO_DOWNLOAD,
|
|
|
|
GST_GL_DISPLAY_ACTION_GEN_FBO,
|
|
|
|
GST_GL_DISPLAY_ACTION_USE_FBO,
|
|
|
|
GST_GL_DISPLAY_ACTION_USE_FBO2,
|
|
|
|
GST_GL_DISPLAY_ACTION_DEL_FBO,
|
|
|
|
GST_GL_DISPLAY_ACTION_GEN_SHADER,
|
|
|
|
GST_GL_DISPLAY_ACTION_DEL_SHADER
|
2008-05-18 11:12:46 +00:00
|
|
|
|
|
|
|
} GstGLDisplayAction;
|
|
|
|
|
|
|
|
|
2008-06-28 15:38:41 +00:00
|
|
|
//Message to communicate with the gl thread
|
2008-05-18 11:12:46 +00:00
|
|
|
typedef struct _GstGLDisplayMsg {
|
|
|
|
GstGLDisplayAction action;
|
|
|
|
gint glutWinId;
|
|
|
|
GstGLDisplay* display;
|
|
|
|
} GstGLDisplayMsg;
|
|
|
|
|
|
|
|
|
|
|
|
//Texture pool elements
|
|
|
|
typedef struct _GstGLDisplayTex {
|
|
|
|
GLuint texture;
|
|
|
|
} GstGLDisplayTex;
|
|
|
|
|
|
|
|
|
|
|
|
//Client callbacks
|
|
|
|
typedef void (* CRCB) ( GLuint, GLuint );
|
|
|
|
typedef gboolean (* CDCB) ( GLuint, GLuint, GLuint);
|
|
|
|
|
2008-06-07 15:27:12 +00:00
|
|
|
//opengl scene callback
|
2008-06-13 00:01:26 +00:00
|
|
|
typedef void (* GLCB) ( GLuint, GLuint, GLuint, GLhandleARB);
|
2008-06-11 23:04:52 +00:00
|
|
|
typedef void (* GLCB2) ( gpointer* p1, gpointer* p2, gint w, gint h);
|
2008-06-07 15:27:12 +00:00
|
|
|
|
2008-05-18 11:12:46 +00:00
|
|
|
struct _GstGLDisplay {
|
|
|
|
GObject object;
|
|
|
|
|
2008-06-30 00:38:39 +00:00
|
|
|
//thread safe
|
2008-06-07 00:01:18 +00:00
|
|
|
GMutex* mutex;
|
2008-06-30 00:38:39 +00:00
|
|
|
|
|
|
|
//gl context
|
|
|
|
gint glutWinId;
|
|
|
|
gulong winId;
|
|
|
|
GString* title;
|
|
|
|
gint win_xpos;
|
|
|
|
gint win_ypos;
|
|
|
|
gboolean visible;
|
|
|
|
gboolean isAlive;
|
2008-05-18 11:12:46 +00:00
|
|
|
GQueue* texturePool;
|
|
|
|
|
2008-06-29 17:27:43 +00:00
|
|
|
//conditions
|
|
|
|
GCond* cond_create_context;
|
|
|
|
GCond* cond_destroy_context;
|
|
|
|
GCond* cond_gen_texture;
|
|
|
|
GCond* cond_del_texture;
|
2008-06-28 15:38:41 +00:00
|
|
|
GCond* cond_init_upload;
|
2008-06-29 17:27:43 +00:00
|
|
|
GCond* cond_do_upload;
|
2008-06-28 23:28:11 +00:00
|
|
|
GCond* cond_init_download;
|
2008-06-29 17:27:43 +00:00
|
|
|
GCond* cond_do_download;
|
|
|
|
GCond* cond_gen_fbo;
|
|
|
|
GCond* cond_use_fbo;
|
|
|
|
GCond* cond_use_fbo_2;
|
|
|
|
GCond* cond_del_fbo;
|
|
|
|
GCond* cond_gen_shader;
|
|
|
|
GCond* cond_del_shader;
|
2008-06-07 00:01:18 +00:00
|
|
|
|
2008-06-30 00:38:39 +00:00
|
|
|
//action redisplay
|
|
|
|
GLuint redisplay_texture;
|
|
|
|
GLuint redisplay_texture_width;
|
|
|
|
GLuint redisplay_texture_height;
|
2008-06-07 21:56:00 +00:00
|
|
|
|
2008-06-30 00:38:39 +00:00
|
|
|
//action resize
|
2008-06-23 18:56:29 +00:00
|
|
|
gint resize_width;
|
|
|
|
gint resize_height;
|
|
|
|
|
2008-06-30 00:38:39 +00:00
|
|
|
//action gen and del texture
|
|
|
|
GLuint gen_texture;
|
|
|
|
GLuint del_texture;
|
2008-05-18 11:12:46 +00:00
|
|
|
|
2008-06-30 00:38:39 +00:00
|
|
|
//client callbacks
|
|
|
|
CRCB clientReshapeCallback;
|
|
|
|
CDCB clientDrawCallback;
|
2008-06-08 13:15:12 +00:00
|
|
|
|
2008-06-30 00:38:39 +00:00
|
|
|
//upload
|
|
|
|
GLuint upload_fbo;
|
|
|
|
GLuint upload_depth_buffer;
|
|
|
|
GLuint upload_texture;
|
|
|
|
GLuint upload_width;
|
|
|
|
GLuint upload_height;
|
|
|
|
GstVideoFormat upload_video_format;
|
2008-06-28 15:38:41 +00:00
|
|
|
GstGLDisplayConversion colorspace_conversion;
|
2008-06-30 00:38:39 +00:00
|
|
|
gint upload_data_with;
|
|
|
|
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;
|
|
|
|
|
|
|
|
//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;
|
|
|
|
GLhandleARB use_shader;
|
|
|
|
GLCB2 use_fbo_scene_cb_2;
|
|
|
|
gpointer* p1;
|
|
|
|
gpointer* p2;
|
|
|
|
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;
|
2008-06-28 15:38:41 +00:00
|
|
|
|
2008-06-30 00:38:39 +00:00
|
|
|
//action gen and del shader
|
|
|
|
gchar* gen_text_shader;
|
|
|
|
GLhandleARB gen_handle_shader;
|
|
|
|
GLhandleARB del_handle_shader;
|
2008-05-18 11:12:46 +00:00
|
|
|
|
2008-06-30 00:38:39 +00:00
|
|
|
//fragement shader upload
|
2008-05-18 11:12:46 +00:00
|
|
|
gchar* textFProgram_YUY2_UYVY;
|
|
|
|
GLhandleARB GLSLProgram_YUY2;
|
|
|
|
GLhandleARB GLSLProgram_UYVY;
|
2008-06-30 00:38:39 +00:00
|
|
|
|
2008-05-18 11:12:46 +00:00
|
|
|
gchar* textFProgram_I420_YV12;
|
|
|
|
GLhandleARB GLSLProgram_I420_YV12;
|
|
|
|
|
|
|
|
gchar* textFProgram_AYUV;
|
|
|
|
GLhandleARB GLSLProgram_AYUV;
|
|
|
|
|
2008-06-30 00:38:39 +00:00
|
|
|
//fragement shader download
|
2008-05-18 11:12:46 +00:00
|
|
|
gchar* textFProgram_to_YUY2_UYVY;
|
|
|
|
GLhandleARB GLSLProgram_to_YUY2;
|
|
|
|
GLhandleARB GLSLProgram_to_UYVY;
|
|
|
|
|
|
|
|
gchar* textFProgram_to_I420_YV12;
|
|
|
|
GLhandleARB GLSLProgram_to_I420_YV12;
|
|
|
|
|
|
|
|
gchar* textFProgram_to_AYUV;
|
|
|
|
GLhandleARB GLSLProgram_to_AYUV;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct _GstGLDisplayClass {
|
|
|
|
GObjectClass object_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
GType gst_gl_display_get_type (void);
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
2008-06-07 15:27:12 +00:00
|
|
|
//-------------------- Public declarations ------------------
|
2008-05-18 11:12:46 +00:00
|
|
|
//------------------------------------------------------------
|
2008-06-29 17:27:43 +00:00
|
|
|
GstGLDisplay* gst_gl_display_new (void);
|
|
|
|
|
|
|
|
void gst_gl_display_create_context (GstGLDisplay* display,
|
|
|
|
GLint x, GLint y,
|
|
|
|
GLint width, GLint height,
|
|
|
|
gulong winId,
|
|
|
|
gboolean visible);
|
|
|
|
void gst_gl_display_set_visible_context (GstGLDisplay* display, gboolean visible);
|
|
|
|
void gst_gl_display_resize_context (GstGLDisplay* display, gint width, gint height);
|
|
|
|
gboolean gst_gl_display_redisplay (GstGLDisplay* display, GLuint texture, gint width, gint height);
|
|
|
|
|
|
|
|
void gst_gl_display_gen_texture (GstGLDisplay* display, guint* pTexture);
|
|
|
|
void gst_gl_display_del_texture (GstGLDisplay* display, guint texture);
|
|
|
|
|
2008-06-28 15:38:41 +00:00
|
|
|
void gst_gl_display_init_upload (GstGLDisplay* display, GstVideoFormat video_format,
|
|
|
|
guint gl_width, guint gl_height);
|
2008-06-30 00:38:39 +00:00
|
|
|
void gst_gl_display_do_upload (GstGLDisplay* display, guint texture,
|
|
|
|
gint data_width, gint data_height,
|
|
|
|
gpointer data);
|
2008-06-28 23:28:11 +00:00
|
|
|
void gst_gl_display_init_download (GstGLDisplay* display, GstVideoFormat video_format,
|
|
|
|
gint width, gint height);
|
2008-06-30 00:38:39 +00:00
|
|
|
void gst_gl_display_do_download (GstGLDisplay* display, GLuint texture,
|
|
|
|
gint width, gint height,
|
|
|
|
gpointer data);
|
2008-06-29 17:27:43 +00:00
|
|
|
|
|
|
|
void gst_gl_display_gen_fbo (GstGLDisplay* display, gint width, gint height,
|
|
|
|
guint* fbo, guint* depthbuffer);
|
2008-06-30 00:38:39 +00:00
|
|
|
void gst_gl_display_use_fbo (GstGLDisplay* display, gint texture_fbo_width, gint texture_fbo_height,
|
|
|
|
guint fbo, guint depth_buffer, guint texture_fbo, GLCB cb,
|
|
|
|
guint input_texture_width, guint input_texture_height, guint input_texture,
|
|
|
|
GLhandleARB shader);
|
|
|
|
void gst_gl_display_use_fbo_2 (GstGLDisplay* display, gint texture_fbo_width, gint texture_fbo_height,
|
|
|
|
guint fbo, guint depth_buffer, guint texture_fbo, GLCB2 cb2,
|
2008-06-29 17:27:43 +00:00
|
|
|
gpointer* p1, gpointer* p2);
|
|
|
|
void gst_gl_display_del_fbo (GstGLDisplay* display, guint fbo,
|
2008-06-30 00:38:39 +00:00
|
|
|
guint depth_buffer);
|
2008-06-29 17:27:43 +00:00
|
|
|
|
|
|
|
void gst_gl_display_gen_shader (GstGLDisplay* display, gchar* textShader, GLhandleARB* handleShader);
|
|
|
|
void gst_gl_display_del_shader (GstGLDisplay* display, GLhandleARB shader);
|
|
|
|
|
|
|
|
void gst_gl_display_set_window_id (GstGLDisplay* display, gulong winId);
|
|
|
|
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
|