[114/906] git-svn-id: svn://svn.wobow.com/GStreamer_playground/gst-plugins-gl@555 93df14bb-0f41-7a43-8087-d3e2a2f0e464

This commit is contained in:
Julien Isorce 2008-06-29 17:27:43 +00:00 committed by Matthew Waters
parent 37a0568858
commit 5acf54ccf9
12 changed files with 988 additions and 925 deletions

View file

@ -29,8 +29,8 @@ static GObjectClass* gst_gl_buffer_parent_class;
static void
gst_gl_buffer_finalize (GstGLBuffer* buffer)
{
//wait clear textures end, blocking call
gst_gl_display_clearTexture (buffer->display, buffer->texture);
//blocking call, put the texture in the pool
gst_gl_display_del_texture (buffer->display, buffer->texture);
g_object_unref (buffer->display);
@ -99,8 +99,8 @@ gst_gl_buffer_new (GstGLDisplay* display,
//the one attached to the upload FBO
GST_BUFFER_SIZE (gl_buffer) = gst_gl_buffer_get_size (gl_width, gl_height);
//blocking call, request a texture and attach it to the upload FBO
gst_gl_display_prepare_texture (gl_buffer->display, &gl_buffer->texture) ;
//blocking call, generate a texture using the pool
gst_gl_display_gen_texture (gl_buffer->display, &gl_buffer->texture) ;
return gl_buffer;
}

File diff suppressed because it is too large Load diff

View file

@ -41,7 +41,7 @@
typedef struct _GstGLDisplay GstGLDisplay;
typedef struct _GstGLDisplayClass GstGLDisplayClass;
//Color space conversion metthod
//Color space conversion method
typedef enum {
GST_GL_DISPLAY_CONVERSION_GLSL, //ARB_fragment_shade
GST_GL_DISPLAY_CONVERSION_MATRIX, //ARB_imaging
@ -51,23 +51,23 @@ typedef enum {
//Message type
typedef enum {
GST_GL_DISPLAY_ACTION_CREATE,
GST_GL_DISPLAY_ACTION_DESTROY,
GST_GL_DISPLAY_ACTION_VISIBLE,
GST_GL_DISPLAY_ACTION_RESHAPE,
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_PREPARE,
GST_GL_DISPLAY_ACTION_CHANGE,
GST_GL_DISPLAY_ACTION_CLEAR,
GST_GL_DISPLAY_ACTION_VIDEO,
GST_GL_DISPLAY_ACTION_REDISPLAY,
GST_GL_DISPLAY_ACTION_GENFBO,
GST_GL_DISPLAY_ACTION_DELFBO,
GST_GL_DISPLAY_ACTION_USEFBO,
GST_GL_DISPLAY_ACTION_USEFBO2,
GST_GL_DISPLAY_ACTION_DO_UPLOAD,
GST_GL_DISPLAY_ACTION_INIT_DOWNLOAD,
GST_GL_DISPLAY_ACTION_GENSHADER,
GST_GL_DISPLAY_ACTION_DELSHADER
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
} GstGLDisplayAction;
@ -101,21 +101,23 @@ struct _GstGLDisplay {
GQueue* texturePool;
//conditions
GCond* cond_create_context;
GCond* cond_destroy_context;
GCond* cond_gen_texture;
GCond* cond_del_texture;
GCond* cond_init_upload;
GCond* cond_make;
GCond* cond_fill;
GCond* cond_clear;
GCond* cond_video;
GCond* cond_generateFBO;
GCond* cond_useFBO;
GCond* cond_useFBO2;
GCond* cond_destroyFBO;
GCond* cond_do_upload;
GCond* cond_init_download;
GCond* cond_initShader;
GCond* cond_destroyShader;
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;
GCond* cond_create;
GCond* cond_destroy;
gint glutWinId;
gulong winId;
GString* title;
@ -239,42 +241,49 @@ GType gst_gl_display_get_type (void);
//------------------------------------------------------------
//-------------------- Public declarations ------------------
//------------------------------------------------------------
GstGLDisplay *gst_gl_display_new (void);
void gst_gl_display_init_gl_context (GstGLDisplay* display,
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_setClientReshapeCallback (GstGLDisplay* display, CRCB cb);
void gst_gl_display_setClientDrawCallback (GstGLDisplay* display, CDCB cb);
void gst_gl_display_setVisibleWindow (GstGLDisplay* display, gboolean visible);
void gst_gl_display_resizeWindow (GstGLDisplay* display, gint width, gint height);
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);
void gst_gl_display_init_upload (GstGLDisplay* display, GstVideoFormat video_format,
guint gl_width, guint gl_height);
void gst_gl_display_prepare_texture (GstGLDisplay* display, guint* pTexture);
void gst_gl_display_do_upload (GstGLDisplay* display, GstVideoFormat video_format,
gint video_width, gint video_height, gpointer data,
guint gl_width, guint gl_height, guint pTexture);
void gst_gl_display_clearTexture (GstGLDisplay* display, guint texture);
void gst_gl_display_videoChanged (GstGLDisplay* display, GstVideoFormat video_format,
void gst_gl_display_init_download (GstGLDisplay* display, GstVideoFormat video_format,
gint width, gint height);
void gst_gl_display_do_download (GstGLDisplay* display, GstVideoFormat video_format,
gint width, gint height, GLuint recordedTexture, gpointer data);
gboolean gst_gl_display_postRedisplay (GstGLDisplay* display, GLuint texture, gint width, gint height);
void gst_gl_display_requestFBO (GstGLDisplay* display, gint width, gint height,
void gst_gl_display_gen_fbo (GstGLDisplay* display, gint width, gint height,
guint* fbo, guint* depthbuffer);
void gst_gl_display_useFBO (GstGLDisplay* display, gint textureFBOWidth, gint textureFBOheight,
void gst_gl_display_use_fbo (GstGLDisplay* display, gint textureFBOWidth, gint textureFBOheight,
guint fbo, guint depthbuffer, guint textureFBO, GLCB cb,
guint inputTextureWidth, guint inputTextureHeight, guint inputTexture,
GLhandleARB handleShader);
void gst_gl_display_useFBO2 (GstGLDisplay* display, gint textureFBOWidth, gint textureFBOheight,
void gst_gl_display_use_fbo_2 (GstGLDisplay* display, gint textureFBOWidth, gint textureFBOheight,
guint fbo, guint depthbuffer, guint textureFBO, GLCB2 cb,
gpointer* p1, gpointer* p2);
void gst_gl_display_rejectFBO (GstGLDisplay* display, guint fbo,
void gst_gl_display_del_fbo (GstGLDisplay* display, guint fbo,
guint depthbuffer);
void gst_gl_display_init_download (GstGLDisplay* display, GstVideoFormat video_format,
gint width, gint height);
void gst_gl_display_initShader (GstGLDisplay* display, gchar* textShader, GLhandleARB* handleShader);
void gst_gl_display_destroyShader (GstGLDisplay* display, GLhandleARB shader);
void gst_gl_display_set_windowId (GstGLDisplay* display, gulong winId);
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);
#endif

View file

@ -156,7 +156,7 @@ gst_gl_filter_reset (GstGLFilter* filter)
if (filter->display)
{
//blocking call, delete the FBO
gst_gl_display_rejectFBO (filter->display, filter->fbo,
gst_gl_display_del_fbo (filter->display, filter->fbo,
filter->depthbuffer);
g_object_unref (filter->display);
filter->display = NULL;
@ -247,7 +247,7 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform* trans,
filter->display = g_object_ref (gl_inbuf->display);
//blocking call, generate a FBO
gst_gl_display_requestFBO (filter->display, filter->width, filter->height,
gst_gl_display_gen_fbo (filter->display, filter->width, filter->height,
&filter->fbo, &filter->depthbuffer);
if (filter_class->onInitFBO)

View file

@ -389,7 +389,7 @@ gst_gl_colorscale_set_caps (GstBaseTransform* bt, GstCaps* incaps,
colorscale->display = gst_gl_display_new ();
//init unvisible opengl context
gst_gl_display_init_gl_context (colorscale->display,
gst_gl_display_create_context (colorscale->display,
50, y_pos++ * (colorscale->output_video_height+50) + 50,
colorscale->output_video_width, colorscale->output_video_height,
0, FALSE);
@ -455,7 +455,7 @@ gst_gl_colorscale_transform (GstBaseTransform* trans, GstBuffer* inbuf,
GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf));
//blocking call
gst_gl_display_videoChanged(colorscale->display, colorscale->output_video_format,
gst_gl_display_do_download(colorscale->display, colorscale->output_video_format,
gl_temp_buffer->width, gl_temp_buffer->height, gl_temp_buffer->texture,
GST_BUFFER_DATA (outbuf));

View file

@ -307,7 +307,7 @@ gst_gl_download_transform (GstBaseTransform* trans, GstBuffer* inbuf,
GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf));
//blocking call
gst_gl_display_videoChanged(download->display, download->video_format,
gst_gl_display_do_download(download->display, download->video_format,
gl_inbuf->width, gl_inbuf->height, gl_inbuf->texture, GST_BUFFER_DATA (outbuf));
return GST_FLOW_OK;

View file

@ -152,7 +152,7 @@ gst_gl_filter_app_filter (GstGLFilter* filter, GstGLBuffer* inbuf,
if (app_filter->clientDrawCallback)
{
//blocking call, use a FBO
gst_gl_display_useFBO (filter->display, filter->width, filter->height,
gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
filter->fbo, filter->depthbuffer, outbuf->texture, app_filter->clientDrawCallback,
inbuf->width, inbuf->height, inbuf->texture, 0);
}
@ -160,7 +160,7 @@ gst_gl_filter_app_filter (GstGLFilter* filter, GstGLBuffer* inbuf,
else
{
//blocking call, use a FBO
gst_gl_display_useFBO (filter->display, filter->width, filter->height,
gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
filter->fbo, filter->depthbuffer, outbuf->texture, gst_gl_filter_app_callback,
inbuf->width, inbuf->height, inbuf->texture, 0);
}

View file

@ -115,7 +115,7 @@ gst_gl_filter_cube_filter (GstGLFilter* filter, GstGLBuffer* inbuf,
//GstGLFilterCube* cube_filter = GST_GL_FILTER_CUBE(filter);
//blocking call, use a FBO
gst_gl_display_useFBO (filter->display, filter->width, filter->height,
gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
filter->fbo, filter->depthbuffer, outbuf->texture, gst_gl_filter_cube_callback,
inbuf->width, inbuf->height, inbuf->texture, 0);

View file

@ -122,7 +122,7 @@ gst_gl_filter_edge_reset (GstGLFilter* filter)
GstGLFilterEdge* edge_filter = GST_GL_FILTER_EDGE(filter);
//blocking call, wait the opengl thread has destroyed the shader program
gst_gl_display_destroyShader (filter->display, edge_filter->handleShader);
gst_gl_display_del_shader (filter->display, edge_filter->handleShader);
}
static void
@ -159,7 +159,7 @@ gst_gl_filter_edge_init_shader (GstGLFilter* filter)
GstGLFilterEdge* edge_filter = GST_GL_FILTER_EDGE(filter);
//blocking call, wait the opengl thread has compiled the shader program
gst_gl_display_initShader (filter->display, edge_filter->textShader, &edge_filter->handleShader);
gst_gl_display_gen_shader (filter->display, edge_filter->textShader, &edge_filter->handleShader);
}
static gboolean
@ -169,7 +169,7 @@ gst_gl_filter_edge_filter (GstGLFilter* filter, GstGLBuffer* inbuf,
GstGLFilterEdge* edge_filter = GST_GL_FILTER_EDGE(filter);
//blocking call, generate a FBO
gst_gl_display_useFBO (filter->display, filter->width, filter->height,
gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
filter->fbo, filter->depthbuffer, outbuf->texture, gst_gl_filter_edge_callback,
inbuf->width, inbuf->height, inbuf->texture, edge_filter->handleShader);

View file

@ -323,7 +323,7 @@ gst_glimage_sink_stop (GstBaseSink* bsink)
}
if (glimage_sink->display)
{
gst_gl_display_setVisibleWindow (glimage_sink->display, FALSE);
gst_gl_display_set_visible_context (glimage_sink->display, FALSE);
g_object_unref (glimage_sink->display);
glimage_sink->display = NULL;
}
@ -436,17 +436,17 @@ gst_glimage_sink_render (GstBaseSink* bsink, GstBuffer* buf)
gst_x_overlay_prepare_xwindow_id (GST_X_OVERLAY (glimage_sink));
if (glimage_sink->window_id)
gst_gl_display_set_windowId (glimage_sink->display, glimage_sink->window_id);
gst_gl_display_set_window_id (glimage_sink->display, glimage_sink->window_id);
gst_gl_display_setClientReshapeCallback (glimage_sink->display,
gst_gl_display_set_client_reshape_callback (glimage_sink->display,
glimage_sink->clientReshapeCallback);
gst_gl_display_setClientDrawCallback (glimage_sink->display,
gst_gl_display_set_client_draw_callback (glimage_sink->display,
glimage_sink->clientDrawCallback);
gst_gl_display_resizeWindow (glimage_sink->display, glimage_sink->width, glimage_sink->height);
gst_gl_display_resize_context (glimage_sink->display, glimage_sink->width, glimage_sink->height);
gst_gl_display_setVisibleWindow (glimage_sink->display, TRUE);
gst_gl_display_set_visible_context (glimage_sink->display, TRUE);
}
}
//is not gl
@ -467,7 +467,7 @@ gst_glimage_sink_render (GstBaseSink* bsink, GstBuffer* buf)
gst_x_overlay_prepare_xwindow_id (GST_X_OVERLAY (glimage_sink));
//init opengl context
gst_gl_display_init_gl_context (glimage_sink->display,
gst_gl_display_create_context (glimage_sink->display,
50, y_pos++ * (glimage_sink->height+50) + 50,
glimage_sink->width, glimage_sink->height,
glimage_sink->window_id, TRUE);
@ -476,10 +476,10 @@ gst_glimage_sink_render (GstBaseSink* bsink, GstBuffer* buf)
gst_gl_display_init_upload (glimage_sink->display, glimage_sink->format,
glimage_sink->width, glimage_sink->height);
gst_gl_display_setClientReshapeCallback (glimage_sink->display,
gst_gl_display_set_client_reshape_callback (glimage_sink->display,
glimage_sink->clientReshapeCallback);
gst_gl_display_setClientDrawCallback (glimage_sink->display,
gst_gl_display_set_client_draw_callback (glimage_sink->display,
glimage_sink->clientDrawCallback);
}
@ -506,7 +506,7 @@ gst_glimage_sink_render (GstBaseSink* bsink, GstBuffer* buf)
glimage_sink->stored_buffer = gl_buffer;
//redisplay opengl scene
isAlive = gst_gl_display_postRedisplay (glimage_sink->display,
isAlive = gst_gl_display_redisplay (glimage_sink->display,
gl_buffer->texture, gl_buffer->width, gl_buffer->height);
if (isAlive)
@ -557,7 +557,7 @@ gst_glimage_sink_expose (GstXOverlay* overlay)
//redisplay opengl scene
if (glimage_sink->display)
gst_gl_display_postRedisplay (glimage_sink->display, 0, 0, 0);
gst_gl_display_redisplay (glimage_sink->display, 0, 0, 0);
}

View file

@ -363,11 +363,11 @@ gst_gl_test_src_setcaps (GstBaseSrc* bsrc, GstCaps* caps)
gltestsrc->display = gst_gl_display_new ();
gst_gl_display_init_gl_context (gltestsrc->display,
gst_gl_display_create_context (gltestsrc->display,
50, y_pos++ * (gltestsrc->height+50) + 50,
gltestsrc->width, gltestsrc->height, 0, FALSE);
gst_gl_display_requestFBO (gltestsrc->display, gltestsrc->width, gltestsrc->height,
gst_gl_display_gen_fbo (gltestsrc->display, gltestsrc->width, gltestsrc->height,
&gltestsrc->fbo, &gltestsrc->depthbuffer);
}
return res;
@ -557,7 +557,7 @@ gst_gl_test_src_create (GstPushSrc* psrc, GstBuffer** buffer)
}
//blocking call, generate a FBO
gst_gl_display_useFBO2 (src->display, src->width, src->height,
gst_gl_display_use_fbo_2 (src->display, src->width, src->height,
src->fbo, src->depthbuffer, outbuf->texture, (GLCB2)src->make_image,
(gpointer*)src, (gpointer*)outbuf);
@ -625,7 +625,7 @@ gst_gl_test_src_stop (GstBaseSrc* basesrc)
if (src->display)
{
//blocking call, delete the FBO
gst_gl_display_rejectFBO (src->display, src->fbo,
gst_gl_display_del_fbo (src->display, src->fbo,
src->depthbuffer);
g_object_unref (src->display);
src->display = NULL;

View file

@ -397,7 +397,7 @@ gst_gl_upload_set_caps (GstBaseTransform* bt, GstCaps* incaps,
upload->display = gst_gl_display_new ();
//init unvisible opengl context
gst_gl_display_init_gl_context (upload->display,
gst_gl_display_create_context (upload->display,
50, y_pos++ * (upload->gl_height+50) + 50,
upload->gl_width, upload->gl_height, 0, FALSE);