[573/906] add upload and download library objects

allows multiple upload pipelines that previously wasn't possible
 (i.e. upload RGB and I420 and ... on the same GstGLDisplay)
This commit is contained in:
Matthew Waters 2012-09-16 21:23:09 +10:00
parent d163ecce23
commit 88cb7e3060
6 changed files with 2749 additions and 2364 deletions

File diff suppressed because it is too large Load diff

View file

@ -27,6 +27,8 @@
#include "gstglwindow.h"
#include "gstglshader.h"
#include "gstglupload.h"
#include "gstgldownload.h"
G_BEGIN_DECLS
@ -125,20 +127,10 @@ struct _GstGLDisplay
CDCB clientDrawCallback;
gpointer client_data;
//upload
GLuint upload_fbo;
GLuint upload_depth_buffer;
GLuint upload_outtex;
GLuint upload_intex;
GLuint upload_intex_u;
GLuint upload_intex_v;
GLuint upload_width;
GLuint upload_height;
GstVideoFormat upload_video_format;
GstGLDisplayConversion upload_colorspace_conversion;
gint upload_data_width;
gint upload_data_height;
GstVideoFrame *upload_frame;
GstGLDisplayConversion colorspace_conversion;
GHashTable *uploads;
GHashTable *downloads;
//foreign gl context
gulong external_gl_context;
@ -171,21 +163,6 @@ struct _GstGLDisplay
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;
GstVideoFrame *download_frame;
GLenum multipleRT[3];
GLuint ouput_texture;
GLuint ouput_texture_width;
GLuint ouput_texture_height;
//action gen and del shader
const gchar *gen_shader_fragment_source;
const gchar *gen_shader_vertex_source;
@ -209,25 +186,6 @@ struct _GstGLDisplay
GLint shader_upload_attr_texture_loc;
#endif
//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;
#ifdef OPENGL_ES2
gchar *text_vertex_shader_download;
GLint shader_download_attr_position_loc;
GLint shader_download_attr_texture_loc;
gchar *text_fragment_shader_download_RGB;
GstGLShader *shader_download_RGB;
#endif
gchar *error_message;
};
@ -266,10 +224,6 @@ gboolean gst_gl_display_init_upload (GstGLDisplay * display,
gint video_width, gint video_height);
gboolean gst_gl_display_do_upload (GstGLDisplay * display, GLuint texture,
GstVideoFrame * frame);
gboolean gst_gl_display_init_download (GstGLDisplay * display,
GstVideoFormat video_format, gint width, gint height);
gboolean gst_gl_display_do_download (GstGLDisplay * display, GLuint texture,
GstVideoFrame *frame);
gboolean gst_gl_display_gen_fbo (GstGLDisplay * display, gint width, gint height,
GLuint * fbo, GLuint * depthbuffer);
@ -301,6 +255,10 @@ void gst_gl_display_activate_gl_context (GstGLDisplay * display, gboolean activa
/* Must be called inside a lock/unlock on display, or within the glthread */
void gst_gl_display_set_error (GstGLDisplay * display, const char * format, ...);
void gst_gl_display_check_framebuffer_status (void);
void gst_gl_display_lock (GstGLDisplay * display);
void gst_gl_display_unlock (GstGLDisplay * display);
G_END_DECLS

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,93 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystree00@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.
*/
#ifndef __GST_GL_DOWNLOAD_H__
#define __GST_GL_DOWNLOAD_H__
#include <gst/video/video.h>
#include <gst/gstmemory.h>
#include "gstglshader.h"
#include "gstgldisplay.h"
G_BEGIN_DECLS
/* forward declare */
typedef struct _GstGLMemory GstGLMemory;
typedef struct _GstGLDisplay GstGLDisplay;
GType gst_gl_download_get_type (void);
#define GST_TYPE_GL_DOWNLOAD (gst_gl_download_get_type())
#define GST_GL_DOWNLOAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_DOWNLOAD,GstGLDownload))
#define GST_GL_DOWNLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_DISPLAY,GstGLDownloadClass))
#define GST_IS_GL_DOWNLOAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_DOWNLOAD))
#define GST_IS_GL_DOWNLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_DOWNLOAD))
#define GST_GL_DOWNLOAD_CAST(obj) ((GstGLDownload*)(obj))
typedef struct _GstGLDownload GstGLDownload;
typedef struct _GstGLDownloadClass GstGLDownloadClass;
struct _GstGLDownload
{
GObject parent;
GMutex lock;
GstGLDisplay *display;
gpointer data[GST_VIDEO_MAX_PLANES];
/* used for the conversion */
GLuint fbo;
GLuint depth_buffer;
GLuint in_texture;
GLuint out_texture[GST_VIDEO_MAX_PLANES];
GstGLShader *shader;
#ifdef OPENGL_ES2
GLint shader_attr_position_loc;
GLint shader_attr_texture_loc;
#endif
/* output data */
GstVideoInfo info;
/* <private> */
gpointer _reserved[GST_PADDING];
};
struct _GstGLDownloadClass
{
GObjectClass object_class;
};
GstGLDownload * gst_gl_download_new (GstGLDisplay * display);
gboolean gst_gl_download_init_format (GstGLDownload * download, GstVideoFormat v_format,
guint width, guint height);
gboolean gst_gl_download_perform_with_memory (GstGLDownload * download, GstGLMemory * gl_mem);
gboolean gst_gl_download_perform_with_data (GstGLDownload * download, GLuint texture_id,
gpointer data[GST_VIDEO_MAX_PLANES]);
GstGLDownload * gst_gl_display_find_download (GstGLDisplay * display, GstVideoFormat v_format,
guint width, guint height);
G_END_DECLS
#endif /* __GST_GL_DOWNLOAD_H__ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,95 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystree00@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.
*/
#ifndef __GST_GL_UPLOAD_H__
#define __GST_GL_UPLOAD_H__
#include <gst/video/video.h>
#include <gst/gstmemory.h>
#include "gstglshader.h"
#include "gstgldisplay.h"
G_BEGIN_DECLS
/* forward declare */
typedef struct _GstGLMemory GstGLMemory;
typedef struct _GstGLDisplay GstGLDisplay;
GType gst_gl_upload_get_type (void);
#define GST_TYPE_GL_UPLOAD (gst_gl_upload_get_type())
#define GST_GL_UPLOAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_UPLOAD,GstGLUpload))
#define GST_GL_UPLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_DISPLAY,GstGLUploadClass))
#define GST_IS_GL_UPLOAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_UPLOAD))
#define GST_IS_GL_UPLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_UPLOAD))
#define GST_GL_UPLOAD_CAST(obj) ((GstGLUpload*)(obj))
typedef struct _GstGLUpload GstGLUpload;
typedef struct _GstGLUploadClass GstGLUploadClass;
struct _GstGLUpload
{
GObject parent;
GMutex lock;
GstGLDisplay *display;
gpointer data[GST_VIDEO_MAX_PLANES];
gboolean initted;
/* used for the conversion */
GLuint fbo;
GLuint depth_buffer;
GLuint out_texture;
GLuint in_texture[GST_VIDEO_MAX_PLANES];
GstGLShader *shader;
#ifdef OPENGL_ES2
GLint shader_attr_position_loc;
GLint shader_attr_texture_loc;
#endif
/* output data */
GstVideoInfo info;
/* <private> */
gpointer _reserved[GST_PADDING];
};
struct _GstGLUploadClass
{
GObjectClass object_class;
};
GstGLUpload * gst_gl_upload_new (GstGLDisplay * display);
gboolean gst_gl_upload_init_format (GstGLUpload * upload, GstVideoFormat v_format,
guint width, guint height);
gboolean gst_gl_upload_perform_with_memory (GstGLUpload * upload, GstGLMemory * gl_mem);
gboolean gst_gl_upload_perform_with_data (GstGLUpload * upload, GLuint texture_id,
gpointer data[GST_VIDEO_MAX_PLANES]);
GstGLUpload * gst_gl_display_find_upload (GstGLDisplay * display, GstVideoFormat v_format,
guint width, guint height);
G_END_DECLS
#endif /* __GST_GL_UPLOAD_H__ */