glfilterapp: remove the reshape/draw properties

The reshape property was never used.
Replace the draw property with a signal.

Based on patch by Mathieu Duponchelle <mathieu.duponchelle@epitech.eu>

https://bugzilla.gnome.org/show_bug.cgi?id=704507
This commit is contained in:
Matthew Waters 2014-06-12 12:49:42 +10:00 committed by Tim-Philipp Müller
parent 6a7ccd6f3e
commit e523cdd21a
4 changed files with 32 additions and 70 deletions

View file

@ -47,12 +47,13 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
enum enum
{ {
PROP_0, SIGNAL_0,
PROP_CLIENT_RESHAPE_CALLBACK, CLIENT_DRAW_SIGNAL,
PROP_CLIENT_DRAW_CALLBACK, LAST_SIGNAL
PROP_CLIENT_DATA
}; };
static guint gst_gl_filter_app_signals[LAST_SIGNAL] = { 0 };
#define DEBUG_INIT \ #define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_gl_filter_app_debug, "glfilterapp", 0, "glfilterapp element"); GST_DEBUG_CATEGORY_INIT (gst_gl_filter_app_debug, "glfilterapp", 0, "glfilterapp element");
@ -88,21 +89,20 @@ gst_gl_filter_app_class_init (GstGLFilterAppClass * klass)
GST_GL_FILTER_CLASS (klass)->filter_texture = GST_GL_FILTER_CLASS (klass)->filter_texture =
gst_gl_filter_app_filter_texture; gst_gl_filter_app_filter_texture;
g_object_class_install_property (gobject_class, PROP_CLIENT_RESHAPE_CALLBACK, /**
g_param_spec_pointer ("client-reshape-callback", * GstGLFilterApp::client-draw:
"Client reshape callback", * @object: the #GstGLImageSink
"Define a custom reshape callback in a client code", * @texture: the #guint id of the texture.
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)); * @width: the #guint width of the texture.
* @height: the #guint height of the texture.
g_object_class_install_property (gobject_class, PROP_CLIENT_DRAW_CALLBACK, *
g_param_spec_pointer ("client-draw-callback", "Client draw callback", * Will be emitted before to draw the texture. The client should
"Define a custom draw callback in a client code", * redraw the surface/contents with the @texture, @width and @height.
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)); */
gst_gl_filter_app_signals[CLIENT_DRAW_SIGNAL] =
g_object_class_install_property (gobject_class, PROP_CLIENT_DATA, g_signal_new ("client-draw", G_TYPE_FROM_CLASS (klass),
g_param_spec_pointer ("client-data", "Client data", G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic,
"Pass data to the draw and reshape callbacks", G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
gst_element_class_set_metadata (element_class, gst_element_class_set_metadata (element_class,
"OpenGL application filter", "Filter/Effect", "OpenGL application filter", "Filter/Effect",
@ -113,33 +113,13 @@ gst_gl_filter_app_class_init (GstGLFilterAppClass * klass)
static void static void
gst_gl_filter_app_init (GstGLFilterApp * filter) gst_gl_filter_app_init (GstGLFilterApp * filter)
{ {
filter->clientReshapeCallback = NULL;
filter->clientDrawCallback = NULL;
filter->client_data = NULL;
} }
static void static void
gst_gl_filter_app_set_property (GObject * object, guint prop_id, gst_gl_filter_app_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
{ {
GstGLFilterApp *filter = GST_GL_FILTER_APP (object);
switch (prop_id) { switch (prop_id) {
case PROP_CLIENT_RESHAPE_CALLBACK:
{
filter->clientReshapeCallback = g_value_get_pointer (value);
break;
}
case PROP_CLIENT_DRAW_CALLBACK:
{
filter->clientDrawCallback = g_value_get_pointer (value);
break;
}
case PROP_CLIENT_DATA:
{
filter->client_data = g_value_get_pointer (value);
break;
}
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -150,8 +130,6 @@ static void
gst_gl_filter_app_get_property (GObject * object, guint prop_id, gst_gl_filter_app_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec) GValue * value, GParamSpec * pspec)
{ {
//GstGLFilterApp* filter = GST_GL_FILTER_APP (object);
switch (prop_id) { switch (prop_id) {
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -168,6 +146,15 @@ gst_gl_filter_app_set_caps (GstGLFilter * filter, GstCaps * incaps,
return TRUE; return TRUE;
} }
static void
_emit_draw_signal (guint tex, gint width, gint height, gpointer data)
{
GstGLFilter *filter = data;
g_signal_emit (filter, gst_gl_filter_app_signals[CLIENT_DRAW_SIGNAL], 0,
tex, width, height);
}
static gboolean static gboolean
gst_gl_filter_app_filter_texture (GstGLFilter * filter, guint in_tex, gst_gl_filter_app_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex) guint out_tex)
@ -179,15 +166,13 @@ gst_gl_filter_app_filter_texture (GstGLFilter * filter, guint in_tex,
gst_gl_context_use_fbo (filter->context, gst_gl_context_use_fbo (filter->context,
GST_VIDEO_INFO_WIDTH (&filter->out_info), GST_VIDEO_INFO_WIDTH (&filter->out_info),
GST_VIDEO_INFO_HEIGHT (&filter->out_info), GST_VIDEO_INFO_HEIGHT (&filter->out_info),
filter->fbo, filter->depthbuffer, out_tex, filter->fbo, filter->depthbuffer, out_tex, (GLCB) _emit_draw_signal,
app_filter->clientDrawCallback,
GST_VIDEO_INFO_WIDTH (&filter->in_info), GST_VIDEO_INFO_WIDTH (&filter->in_info),
GST_VIDEO_INFO_HEIGHT (&filter->in_info), GST_VIDEO_INFO_HEIGHT (&filter->in_info),
in_tex, 45, in_tex, 45,
(gfloat) GST_VIDEO_INFO_WIDTH (&filter->out_info) / (gfloat) GST_VIDEO_INFO_WIDTH (&filter->out_info) /
(gfloat) GST_VIDEO_INFO_HEIGHT (&filter->out_info), (gfloat) GST_VIDEO_INFO_HEIGHT (&filter->out_info),
0.1, 100, GST_GL_DISPLAY_PROJECTION_PERSPECTIVE, 0.1, 100, GST_GL_DISPLAY_PROJECTION_PERSPECTIVE, filter);
app_filter->client_data);
} }
//default //default
else { else {

View file

@ -38,7 +38,6 @@ struct _GstGLFilterApp
{ {
GstGLFilter filter; GstGLFilter filter;
CRCB clientReshapeCallback;
GLCB clientDrawCallback; GLCB clientDrawCallback;
gpointer client_data; gpointer client_data;
}; };

View file

@ -39,15 +39,6 @@ typedef enum
GST_GL_DISPLAY_PROJECTION_PERSPECTIVE GST_GL_DISPLAY_PROJECTION_PERSPECTIVE
} GstGLDisplayProjection; } GstGLDisplayProjection;
/**
* CRCB:
* @width: new width
* @height: new height:
* @data: user data
*
* client reshape callback
*/
typedef void (*CRCB) (GLuint width, GLuint height, gpointer data);
/** /**
* CDCB: * CDCB:
* @texture: texture to draw * @texture: texture to draw

View file

@ -65,19 +65,8 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
return TRUE; return TRUE;
} }
//client reshape callback
static void reshapeCallback (GLuint width, GLuint height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
glMatrixMode(GL_MODELVIEW);
}
//client draw callback //client draw callback
static gboolean drawCallback (GLuint width, GLuint height, GLuint texture, gpointer data) static gboolean drawCallback (void *filter, GLuint width, GLuint height, GLuint texture, gpointer data)
{ {
static GLfloat xrot = 0; static GLfloat xrot = 0;
static GLfloat yrot = 0; static GLfloat yrot = 0;
@ -215,9 +204,7 @@ gint main (gint argc, gchar *argv[])
/* configure elements */ /* configure elements */
g_object_set(G_OBJECT(videosrc), "num-buffers", 400, NULL); g_object_set(G_OBJECT(videosrc), "num-buffers", 400, NULL);
g_object_set(G_OBJECT(glfilterapp), "client-reshape-callback", reshapeCallback, NULL); g_signal_connect(G_OBJECT(glfilterapp), "client-draw", G_CALLBACK (drawCallback), NULL);
g_object_set(G_OBJECT(glfilterapp), "client-draw-callback", drawCallback, NULL);
g_object_set(G_OBJECT(glfilterapp), "client-data", NULL, NULL);
g_object_set(G_OBJECT(filesink), "location", "record.avi", NULL); g_object_set(G_OBJECT(filesink), "location", "record.avi", NULL);
/* add elements */ /* add elements */