mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-21 07:46:38 +00:00
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:
parent
9e662b8229
commit
d7f8cc9a78
4 changed files with 32 additions and 70 deletions
|
@ -47,12 +47,13 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
|||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_CLIENT_RESHAPE_CALLBACK,
|
||||
PROP_CLIENT_DRAW_CALLBACK,
|
||||
PROP_CLIENT_DATA
|
||||
SIGNAL_0,
|
||||
CLIENT_DRAW_SIGNAL,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint gst_gl_filter_app_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
#define DEBUG_INIT \
|
||||
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_app_filter_texture;
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_CLIENT_RESHAPE_CALLBACK,
|
||||
g_param_spec_pointer ("client-reshape-callback",
|
||||
"Client reshape callback",
|
||||
"Define a custom reshape callback in a client code",
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_CLIENT_DRAW_CALLBACK,
|
||||
g_param_spec_pointer ("client-draw-callback", "Client draw callback",
|
||||
"Define a custom draw callback in a client code",
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_CLIENT_DATA,
|
||||
g_param_spec_pointer ("client-data", "Client data",
|
||||
"Pass data to the draw and reshape callbacks",
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
||||
/**
|
||||
* GstGLFilterApp::client-draw:
|
||||
* @object: the #GstGLImageSink
|
||||
* @texture: the #guint id of the texture.
|
||||
* @width: the #guint width of the texture.
|
||||
* @height: the #guint height of the texture.
|
||||
*
|
||||
* Will be emitted before to draw the texture. The client should
|
||||
* redraw the surface/contents with the @texture, @width and @height.
|
||||
*/
|
||||
gst_gl_filter_app_signals[CLIENT_DRAW_SIGNAL] =
|
||||
g_signal_new ("client-draw", G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic,
|
||||
G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
|
||||
|
||||
gst_element_class_set_metadata (element_class,
|
||||
"OpenGL application filter", "Filter/Effect",
|
||||
|
@ -113,33 +113,13 @@ gst_gl_filter_app_class_init (GstGLFilterAppClass * klass)
|
|||
static void
|
||||
gst_gl_filter_app_init (GstGLFilterApp * filter)
|
||||
{
|
||||
filter->clientReshapeCallback = NULL;
|
||||
filter->clientDrawCallback = NULL;
|
||||
filter->client_data = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_filter_app_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstGLFilterApp *filter = GST_GL_FILTER_APP (object);
|
||||
|
||||
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:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -150,8 +130,6 @@ static void
|
|||
gst_gl_filter_app_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
//GstGLFilterApp* filter = GST_GL_FILTER_APP (object);
|
||||
|
||||
switch (prop_id) {
|
||||
default:
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
gst_gl_filter_app_filter_texture (GstGLFilter * filter, guint in_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_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
filter->fbo, filter->depthbuffer, out_tex,
|
||||
app_filter->clientDrawCallback,
|
||||
filter->fbo, filter->depthbuffer, out_tex, (GLCB) _emit_draw_signal,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->in_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->in_info),
|
||||
in_tex, 45,
|
||||
(gfloat) GST_VIDEO_INFO_WIDTH (&filter->out_info) /
|
||||
(gfloat) GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
0.1, 100, GST_GL_DISPLAY_PROJECTION_PERSPECTIVE,
|
||||
app_filter->client_data);
|
||||
0.1, 100, GST_GL_DISPLAY_PROJECTION_PERSPECTIVE, filter);
|
||||
}
|
||||
//default
|
||||
else {
|
||||
|
|
|
@ -38,7 +38,6 @@ struct _GstGLFilterApp
|
|||
{
|
||||
GstGLFilter filter;
|
||||
|
||||
CRCB clientReshapeCallback;
|
||||
GLCB clientDrawCallback;
|
||||
gpointer client_data;
|
||||
};
|
||||
|
|
|
@ -39,15 +39,6 @@ typedef enum
|
|||
GST_GL_DISPLAY_PROJECTION_PERSPECTIVE
|
||||
} GstGLDisplayProjection;
|
||||
|
||||
/**
|
||||
* CRCB:
|
||||
* @width: new width
|
||||
* @height: new height:
|
||||
* @data: user data
|
||||
*
|
||||
* client reshape callback
|
||||
*/
|
||||
typedef void (*CRCB) (GLuint width, GLuint height, gpointer data);
|
||||
/**
|
||||
* CDCB:
|
||||
* @texture: texture to draw
|
||||
|
|
|
@ -65,19 +65,8 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
|
|||
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
|
||||
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 yrot = 0;
|
||||
|
@ -215,9 +204,7 @@ gint main (gint argc, gchar *argv[])
|
|||
|
||||
/* configure elements */
|
||||
g_object_set(G_OBJECT(videosrc), "num-buffers", 400, NULL);
|
||||
g_object_set(G_OBJECT(glfilterapp), "client-reshape-callback", reshapeCallback, NULL);
|
||||
g_object_set(G_OBJECT(glfilterapp), "client-draw-callback", drawCallback, NULL);
|
||||
g_object_set(G_OBJECT(glfilterapp), "client-data", NULL, NULL);
|
||||
g_signal_connect(G_OBJECT(glfilterapp), "client-draw", G_CALLBACK (drawCallback), NULL);
|
||||
g_object_set(G_OBJECT(filesink), "location", "record.avi", NULL);
|
||||
|
||||
/* add elements */
|
||||
|
|
Loading…
Reference in a new issue