glfilter: Remove onStart/onStop vfuncs, and unused onReset()

onStart/onStop are just duplicates of the basetransform ones, onReset
was never called but was used everywhere when stop should've been used.
This commit is contained in:
Sebastian Dröge 2015-04-26 21:39:06 +02:00 committed by Tim-Philipp Müller
parent 590c7032d8
commit 3613ecfd0a
10 changed files with 72 additions and 98 deletions

View file

@ -61,7 +61,7 @@ enum
#define DEBUG_INIT \ #define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_gl_colorscale_debug, "glcolorscale", 0, "glcolorscale element"); GST_DEBUG_CATEGORY_INIT (gst_gl_colorscale_debug, "glcolorscale", 0, "glcolorscale element");
#define gst_gl_colorscale_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLColorscale, gst_gl_colorscale, G_DEFINE_TYPE_WITH_CODE (GstGLColorscale, gst_gl_colorscale,
GST_TYPE_GL_FILTER, DEBUG_INIT); GST_TYPE_GL_FILTER, DEBUG_INIT);
@ -71,7 +71,7 @@ static void gst_gl_colorscale_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec); GValue * value, GParamSpec * pspec);
static gboolean gst_gl_colorscale_gen_gl_resources (GstGLFilter * filter); static gboolean gst_gl_colorscale_gen_gl_resources (GstGLFilter * filter);
static void gst_gl_colorscale_del_gl_resources (GstGLFilter * filter); static gboolean gst_gl_colorscale_del_gl_resources (GstBaseTransform * trans);
static gboolean gst_gl_colorscale_filter_texture (GstGLFilter * filter, static gboolean gst_gl_colorscale_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex); guint in_tex, guint out_tex);
@ -99,10 +99,11 @@ gst_gl_colorscale_class_init (GstGLColorscaleClass * klass)
filter_class->onInitFBO = filter_class->onInitFBO =
GST_DEBUG_FUNCPTR (gst_gl_colorscale_gen_gl_resources); GST_DEBUG_FUNCPTR (gst_gl_colorscale_gen_gl_resources);
filter_class->onStop = GST_DEBUG_FUNCPTR (gst_gl_colorscale_del_gl_resources);
filter_class->filter_texture = gst_gl_colorscale_filter_texture; filter_class->filter_texture = gst_gl_colorscale_filter_texture;
basetransform_class->stop =
GST_DEBUG_FUNCPTR (gst_gl_colorscale_del_gl_resources);
basetransform_class->passthrough_on_same_caps = TRUE; basetransform_class->passthrough_on_same_caps = TRUE;
GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api =
GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2; GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2;
@ -173,16 +174,18 @@ gst_gl_colorscale_gen_gl_resources (GstGLFilter * filter)
return TRUE; return TRUE;
} }
static void static gboolean
gst_gl_colorscale_del_gl_resources (GstGLFilter * filter) gst_gl_colorscale_del_gl_resources (GstBaseTransform * trans)
{ {
GstGLColorscale *colorscale = GST_GL_COLORSCALE (filter); GstGLColorscale *colorscale = GST_GL_COLORSCALE (trans);
if (colorscale->shader) { if (colorscale->shader) {
gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, gst_gl_context_del_shader (GST_GL_BASE_FILTER (trans)->context,
colorscale->shader); colorscale->shader);
colorscale->shader = NULL; colorscale->shader = NULL;
} }
return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (trans);
} }
static gboolean static gboolean

View file

@ -48,7 +48,7 @@ enum
#define DEBUG_INIT \ #define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_gl_deinterlace_debug, "gldeinterlace", 0, "gldeinterlace element"); GST_DEBUG_CATEGORY_INIT (gst_gl_deinterlace_debug, "gldeinterlace", 0, "gldeinterlace element");
#define gst_gl_deinterlace_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLDeinterlace, gst_gl_deinterlace, G_DEFINE_TYPE_WITH_CODE (GstGLDeinterlace, gst_gl_deinterlace,
GST_TYPE_GL_FILTER, DEBUG_INIT); GST_TYPE_GL_FILTER, DEBUG_INIT);
@ -57,7 +57,7 @@ static void gst_gl_deinterlace_set_property (GObject * object,
static void gst_gl_deinterlace_get_property (GObject * object, static void gst_gl_deinterlace_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec); guint prop_id, GValue * value, GParamSpec * pspec);
static void gst_gl_deinterlace_reset (GstGLFilter * filter); static gboolean gst_gl_deinterlace_reset (GstBaseTransform * trans);
static gboolean gst_gl_deinterlace_init_shader (GstGLFilter * filter); static gboolean gst_gl_deinterlace_init_shader (GstGLFilter * filter);
static gboolean gst_gl_deinterlace_filter (GstGLFilter * filter, static gboolean gst_gl_deinterlace_filter (GstGLFilter * filter,
GstBuffer * inbuf, GstBuffer * outbuf); GstBuffer * inbuf, GstBuffer * outbuf);
@ -163,11 +163,12 @@ gst_gl_deinterlace_class_init (GstGLDeinterlaceClass * klass)
"Deinterlacing based on fragment shaders", "Deinterlacing based on fragment shaders",
"Julien Isorce <julien.isorce@mail.com>"); "Julien Isorce <julien.isorce@mail.com>");
GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_deinterlace_reset;
GST_GL_FILTER_CLASS (klass)->filter = gst_gl_deinterlace_filter; GST_GL_FILTER_CLASS (klass)->filter = gst_gl_deinterlace_filter;
GST_GL_FILTER_CLASS (klass)->filter_texture = GST_GL_FILTER_CLASS (klass)->filter_texture =
gst_gl_deinterlace_filter_texture; gst_gl_deinterlace_filter_texture;
GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_deinterlace_init_shader; GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_deinterlace_init_shader;
GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_deinterlace_reset;
GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL;
} }
@ -180,18 +181,20 @@ gst_gl_deinterlace_init (GstGLDeinterlace * filter)
filter->prev_tex = 0; filter->prev_tex = 0;
} }
static void static gboolean
gst_gl_deinterlace_reset (GstGLFilter * filter) gst_gl_deinterlace_reset (GstBaseTransform * trans)
{ {
GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (filter); GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (trans);
gst_buffer_replace (&deinterlace_filter->prev_buffer, NULL); gst_buffer_replace (&deinterlace_filter->prev_buffer, NULL);
//blocking call, wait the opengl thread has destroyed the shader //blocking call, wait the opengl thread has destroyed the shader
if (deinterlace_filter->shader) if (deinterlace_filter->shader)
gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, gst_gl_context_del_shader (GST_GL_BASE_FILTER (trans)->context,
deinterlace_filter->shader); deinterlace_filter->shader);
deinterlace_filter->shader = NULL; deinterlace_filter->shader = NULL;
return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (trans);
} }
static void static void

View file

@ -61,9 +61,6 @@ static void gst_gl_differencematte_set_property (GObject * object,
static void gst_gl_differencematte_get_property (GObject * object, static void gst_gl_differencematte_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec); guint prop_id, GValue * value, GParamSpec * pspec);
static void gst_gl_differencematte_init_resources (GstGLFilter * filter);
static void gst_gl_differencematte_reset_resources (GstGLFilter * filter);
static gboolean gst_gl_differencematte_filter_texture (GstGLFilter * filter, static gboolean gst_gl_differencematte_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex); guint in_tex, guint out_tex);
@ -180,8 +177,6 @@ gst_gl_differencematte_class_init (GstGLDifferenceMatteClass * klass)
gst_gl_differencematte_init_gl_resources; gst_gl_differencematte_init_gl_resources;
GST_GL_FILTER_CLASS (klass)->display_reset_cb = GST_GL_FILTER_CLASS (klass)->display_reset_cb =
gst_gl_differencematte_reset_gl_resources; gst_gl_differencematte_reset_gl_resources;
GST_GL_FILTER_CLASS (klass)->onStart = gst_gl_differencematte_init_resources;
GST_GL_FILTER_CLASS (klass)->onStop = gst_gl_differencematte_reset_resources;
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_LOCATION, PROP_LOCATION,
@ -214,12 +209,6 @@ gst_gl_differencematte_init (GstGLDifferenceMatte * differencematte)
fill_gaussian_kernel (differencematte->kernel, 7, 30.0); fill_gaussian_kernel (differencematte->kernel, 7, 30.0);
} }
static void
gst_gl_differencematte_reset_resources (GstGLFilter * filter)
{
// GstGLDifferenceMatte* differencematte = GST_GL_DIFFERENCEMATTE(filter);
}
static void static void
gst_gl_differencematte_set_property (GObject * object, guint prop_id, gst_gl_differencematte_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
@ -255,12 +244,6 @@ gst_gl_differencematte_get_property (GObject * object, guint prop_id,
} }
} }
static void
gst_gl_differencematte_init_resources (GstGLFilter * filter)
{
// GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (filter);
}
static void static void
gst_gl_differencematte_save_texture (gint width, gint height, guint texture, gst_gl_differencematte_save_texture (gint width, gint height, guint texture,
gpointer stuff) gpointer stuff)

View file

@ -53,6 +53,7 @@ enum
#define DEBUG_INIT \ #define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_gl_effects_debug, "gleffects", 0, "gleffects element"); GST_DEBUG_CATEGORY_INIT (gst_gl_effects_debug, "gleffects", 0, "gleffects element");
#define gst_gl_effects_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLEffects, gst_gl_effects, GST_TYPE_GL_FILTER, G_DEFINE_TYPE_WITH_CODE (GstGLEffects, gst_gl_effects, GST_TYPE_GL_FILTER,
DEBUG_INIT); DEBUG_INIT);
@ -61,8 +62,8 @@ static void gst_gl_effects_set_property (GObject * object, guint prop_id,
static void gst_gl_effects_get_property (GObject * object, guint prop_id, static void gst_gl_effects_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec); GValue * value, GParamSpec * pspec);
static void gst_gl_effects_init_resources (GstGLFilter * filter); static gboolean gst_gl_effects_init_resources (GstBaseTransform * trans);
static void gst_gl_effects_reset_resources (GstGLFilter * filter); static gboolean gst_gl_effects_reset_resources (GstBaseTransform * trans);
static gboolean gst_gl_effects_on_init_gl_context (GstGLFilter * filter); static gboolean gst_gl_effects_on_init_gl_context (GstGLFilter * filter);
@ -318,13 +319,14 @@ gst_gl_effects_class_init (GstGLEffectsClass * klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GST_BASE_TRANSFORM_CLASS (klass)->start = gst_gl_effects_init_resources;
GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_effects_reset_resources;
GST_GL_FILTER_CLASS (klass)->filter_texture = gst_gl_effects_filter_texture; GST_GL_FILTER_CLASS (klass)->filter_texture = gst_gl_effects_filter_texture;
GST_GL_FILTER_CLASS (klass)->display_init_cb = GST_GL_FILTER_CLASS (klass)->display_init_cb =
gst_gl_effects_init_gl_resources; gst_gl_effects_init_gl_resources;
GST_GL_FILTER_CLASS (klass)->display_reset_cb = GST_GL_FILTER_CLASS (klass)->display_reset_cb =
gst_gl_effects_reset_gl_resources; gst_gl_effects_reset_gl_resources;
GST_GL_FILTER_CLASS (klass)->onStart = gst_gl_effects_init_resources;
GST_GL_FILTER_CLASS (klass)->onStop = gst_gl_effects_reset_resources;
GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_effects_on_init_gl_context; GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_effects_on_init_gl_context;
klass->filter_descriptor = NULL; klass->filter_descriptor = NULL;
@ -423,20 +425,22 @@ gst_gl_effects_ghash_func_clean (gpointer key, gpointer value, gpointer data)
value = NULL; value = NULL;
} }
static void static gboolean
gst_gl_effects_reset_resources (GstGLFilter * filter) gst_gl_effects_reset_resources (GstBaseTransform * trans)
{ {
GstGLEffects *effects = GST_GL_EFFECTS (filter); GstGLEffects *effects = GST_GL_EFFECTS (trans);
/* release shaders in the gl thread */ /* release shaders in the gl thread */
g_hash_table_foreach (effects->shaderstable, gst_gl_effects_ghash_func_clean, g_hash_table_foreach (effects->shaderstable, gst_gl_effects_ghash_func_clean,
filter); effects);
/* clean the htable without calling values destructors /* clean the htable without calling values destructors
* because shaders have been released in the glthread * because shaders have been released in the glthread
* through the foreach func */ * through the foreach func */
g_hash_table_unref (effects->shaderstable); g_hash_table_unref (effects->shaderstable);
effects->shaderstable = NULL; effects->shaderstable = NULL;
return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (trans);
} }
static void static void
@ -483,10 +487,10 @@ gst_gl_effects_get_property (GObject * object, guint prop_id,
} }
} }
static void static gboolean
gst_gl_effects_init_resources (GstGLFilter * filter) gst_gl_effects_init_resources (GstBaseTransform * trans)
{ {
GstGLEffects *effects = GST_GL_EFFECTS (filter); GstGLEffects *effects = GST_GL_EFFECTS (trans);
gint i; gint i;
effects->shaderstable = g_hash_table_new (g_str_hash, g_str_equal); effects->shaderstable = g_hash_table_new (g_str_hash, g_str_equal);
@ -497,6 +501,8 @@ gst_gl_effects_init_resources (GstGLFilter * filter)
for (i = 0; i < GST_GL_EFFECTS_N_CURVES; i++) { for (i = 0; i < GST_GL_EFFECTS_N_CURVES; i++) {
effects->curve[i] = 0; effects->curve[i] = 0;
} }
return GST_BASE_TRANSFORM_CLASS (parent_class)->start (trans);
} }
static gboolean static gboolean

View file

@ -64,7 +64,7 @@ enum
#define DEBUG_INIT \ #define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_gl_filter_cube_debug, "glfiltercube", 0, "glfiltercube element"); GST_DEBUG_CATEGORY_INIT (gst_gl_filter_cube_debug, "glfiltercube", 0, "glfiltercube element");
#define gst_gl_filter_cube_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLFilterCube, gst_gl_filter_cube, G_DEFINE_TYPE_WITH_CODE (GstGLFilterCube, gst_gl_filter_cube,
GST_TYPE_GL_FILTER, DEBUG_INIT); GST_TYPE_GL_FILTER, DEBUG_INIT);
@ -73,9 +73,10 @@ static void gst_gl_filter_cube_set_property (GObject * object, guint prop_id,
static void gst_gl_filter_cube_get_property (GObject * object, guint prop_id, static void gst_gl_filter_cube_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec); GValue * value, GParamSpec * pspec);
static gboolean gst_gl_filter_cube_stop (GstBaseTransform * trans);
static gboolean gst_gl_filter_cube_set_caps (GstGLFilter * filter, static gboolean gst_gl_filter_cube_set_caps (GstGLFilter * filter,
GstCaps * incaps, GstCaps * outcaps); GstCaps * incaps, GstCaps * outcaps);
static void gst_gl_filter_cube_reset (GstGLFilter * filter);
static void gst_gl_filter_cube_reset_gl (GstGLFilter * filter); static void gst_gl_filter_cube_reset_gl (GstGLFilter * filter);
static gboolean gst_gl_filter_cube_init_shader (GstGLFilter * filter); static gboolean gst_gl_filter_cube_init_shader (GstGLFilter * filter);
static void _callback (gpointer stuff); static void _callback (gpointer stuff);
@ -138,8 +139,9 @@ gst_gl_filter_cube_class_init (GstGLFilterCubeClass * klass)
gobject_class->set_property = gst_gl_filter_cube_set_property; gobject_class->set_property = gst_gl_filter_cube_set_property;
gobject_class->get_property = gst_gl_filter_cube_get_property; gobject_class->get_property = gst_gl_filter_cube_get_property;
GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_filter_cube_stop;
GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filter_cube_init_shader; GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filter_cube_init_shader;
GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_cube_reset;
GST_GL_FILTER_CLASS (klass)->display_reset_cb = gst_gl_filter_cube_reset_gl; GST_GL_FILTER_CLASS (klass)->display_reset_cb = gst_gl_filter_cube_reset_gl;
GST_GL_FILTER_CLASS (klass)->set_caps = gst_gl_filter_cube_set_caps; GST_GL_FILTER_CLASS (klass)->set_caps = gst_gl_filter_cube_set_caps;
GST_GL_FILTER_CLASS (klass)->filter_texture = GST_GL_FILTER_CLASS (klass)->filter_texture =
@ -292,16 +294,18 @@ gst_gl_filter_cube_reset_gl (GstGLFilter * filter)
} }
} }
static void static gboolean
gst_gl_filter_cube_reset (GstGLFilter * filter) gst_gl_filter_cube_stop (GstBaseTransform * trans)
{ {
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter); GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (trans);
/* blocking call, wait the opengl thread has destroyed the shader */ /* blocking call, wait the opengl thread has destroyed the shader */
if (cube_filter->shader) if (cube_filter->shader)
gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, gst_gl_context_del_shader (GST_GL_BASE_FILTER (trans)->context,
cube_filter->shader); cube_filter->shader);
cube_filter->shader = NULL; cube_filter->shader = NULL;
return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (trans);
} }
static gboolean static gboolean

View file

@ -53,7 +53,7 @@ enum
#define DEBUG_INIT \ #define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_gl_filter_glass_debug, "glfilterglass", 0, "glfilterglass element"); GST_DEBUG_CATEGORY_INIT (gst_gl_filter_glass_debug, "glfilterglass", 0, "glfilterglass element");
#define gst_gl_filter_glass_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLFilterGlass, gst_gl_filter_glass, G_DEFINE_TYPE_WITH_CODE (GstGLFilterGlass, gst_gl_filter_glass,
GST_TYPE_GL_FILTER, DEBUG_INIT); GST_TYPE_GL_FILTER, DEBUG_INIT);
@ -62,7 +62,8 @@ static void gst_gl_filter_glass_set_property (GObject * object, guint prop_id,
static void gst_gl_filter_glass_get_property (GObject * object, guint prop_id, static void gst_gl_filter_glass_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec); GValue * value, GParamSpec * pspec);
static void gst_gl_filter_glass_reset (GstGLFilter * filter); static gboolean gst_gl_filter_glass_reset (GstBaseTransform * trans);
static gboolean gst_gl_filter_glass_init_shader (GstGLFilter * filter); static gboolean gst_gl_filter_glass_init_shader (GstGLFilter * filter);
static gboolean gst_gl_filter_glass_filter_texture (GstGLFilter * filter, static gboolean gst_gl_filter_glass_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex); guint in_tex, guint out_tex);
@ -161,7 +162,7 @@ gst_gl_filter_glass_class_init (GstGLFilterGlassClass * klass)
GST_GL_FILTER_CLASS (klass)->filter_texture = GST_GL_FILTER_CLASS (klass)->filter_texture =
gst_gl_filter_glass_filter_texture; gst_gl_filter_glass_filter_texture;
GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filter_glass_init_shader; GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filter_glass_init_shader;
GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_glass_reset; GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_filter_glass_reset;
GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL;
} }
@ -173,20 +174,22 @@ gst_gl_filter_glass_init (GstGLFilterGlass * filter)
filter->timestamp = 0; filter->timestamp = 0;
} }
static void static gboolean
gst_gl_filter_glass_reset (GstGLFilter * filter) gst_gl_filter_glass_reset (GstBaseTransform * trans)
{ {
GstGLFilterGlass *glass_filter = GST_GL_FILTER_GLASS (filter); GstGLFilterGlass *glass_filter = GST_GL_FILTER_GLASS (trans);
//blocking call, wait the opengl thread has destroyed the shader //blocking call, wait the opengl thread has destroyed the shader
if (glass_filter->shader) if (glass_filter->shader)
gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, gst_gl_context_del_shader (GST_GL_BASE_FILTER (trans)->context,
glass_filter->shader); glass_filter->shader);
glass_filter->shader = NULL; glass_filter->shader = NULL;
if (glass_filter->passthrough_shader) if (glass_filter->passthrough_shader)
gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, gst_gl_context_del_shader (GST_GL_BASE_FILTER (trans)->context,
glass_filter->passthrough_shader); glass_filter->passthrough_shader);
glass_filter->passthrough_shader = NULL; glass_filter->passthrough_shader = NULL;
return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (trans);
} }
static void static void

View file

@ -67,7 +67,7 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
#define DEBUG_INIT \ #define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_gl_filtershader_debug, "glshader", 0, "glshader element"); GST_DEBUG_CATEGORY_INIT (gst_gl_filtershader_debug, "glshader", 0, "glshader element");
#define gst_gl_filtershader_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLFilterShader, gst_gl_filtershader, G_DEFINE_TYPE_WITH_CODE (GstGLFilterShader, gst_gl_filtershader,
GST_TYPE_GL_FILTER, DEBUG_INIT); GST_TYPE_GL_FILTER, DEBUG_INIT);
@ -75,7 +75,7 @@ static void gst_gl_filtershader_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec); const GValue * value, GParamSpec * pspec);
static void gst_gl_filtershader_get_property (GObject * object, guint prop_id, static void gst_gl_filtershader_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec); GValue * value, GParamSpec * pspec);
static void gst_gl_filter_filtershader_reset (GstGLFilter * filter); static gboolean gst_gl_filter_filtershader_reset (GstBaseTransform * trans);
static gboolean gst_gl_filtershader_load_shader (GstGLFilterShader * static gboolean gst_gl_filtershader_load_shader (GstGLFilterShader *
filter_shader, char *filename, char **storage); filter_shader, char *filename, char **storage);
@ -140,6 +140,8 @@ gst_gl_filtershader_class_init (GstGLFilterShaderClass * klass)
"OpenGL fragment shader filter", "Filter/Effect", "OpenGL fragment shader filter", "Filter/Effect",
"Load GLSL fragment shader from file", "<luc.deschenaux@freesurf.ch>"); "Load GLSL fragment shader from file", "<luc.deschenaux@freesurf.ch>");
GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_filter_filtershader_reset;
GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filtershader_filter; GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filtershader_filter;
GST_GL_FILTER_CLASS (klass)->filter_texture = GST_GL_FILTER_CLASS (klass)->filter_texture =
gst_gl_filtershader_filter_texture; gst_gl_filtershader_filter_texture;
@ -148,7 +150,6 @@ gst_gl_filtershader_class_init (GstGLFilterShaderClass * klass)
GST_GL_FILTER_CLASS (klass)->display_reset_cb = GST_GL_FILTER_CLASS (klass)->display_reset_cb =
gst_gl_filtershader_reset_resources; gst_gl_filtershader_reset_resources;
GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filtershader_init_shader; GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filtershader_init_shader;
GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_filtershader_reset;
GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api =
GST_GL_API_OPENGL | GST_GL_API_GLES2 | GST_GL_API_OPENGL3; GST_GL_API_OPENGL | GST_GL_API_GLES2 | GST_GL_API_OPENGL3;
@ -160,16 +161,18 @@ gst_gl_filtershader_init (GstGLFilterShader * filtershader)
filtershader->shader0 = NULL; filtershader->shader0 = NULL;
} }
static void static gboolean
gst_gl_filter_filtershader_reset (GstGLFilter * filter) gst_gl_filter_filtershader_reset (GstBaseTransform * trans)
{ {
GstGLFilterShader *filtershader = GST_GL_FILTERSHADER (filter); GstGLFilterShader *filtershader = GST_GL_FILTERSHADER (trans);
//blocking call, wait the opengl thread has destroyed the shader //blocking call, wait the opengl thread has destroyed the shader
if (filtershader->shader0) if (filtershader->shader0)
gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, gst_gl_context_del_shader (GST_GL_BASE_FILTER (trans)->context,
filtershader->shader0); filtershader->shader0);
filtershader->shader0 = NULL; filtershader->shader0 = NULL;
return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (trans);
} }
static void static void
@ -186,8 +189,9 @@ gst_gl_filtershader_set_property (GObject * object, guint prop_id,
g_free (filtershader->filename); g_free (filtershader->filename);
} }
if (filtershader->compiled) { if (filtershader->compiled) {
//gst_gl_context_del_shader (filtershader->filter.context, filtershader->shader0); if (filtershader->shader0)
gst_gl_filter_filtershader_reset (&filtershader->filter); gst_gl_context_del_shader (GST_GL_BASE_FILTER (filtershader)->context,
filtershader->shader0);
filtershader->shader0 = 0; filtershader->shader0 = 0;
} }
filtershader->filename = g_strdup (g_value_get_string (value)); filtershader->filename = g_strdup (g_value_get_string (value));

View file

@ -68,8 +68,6 @@ static void gst_gl_overlay_set_property (GObject * object, guint prop_id,
static void gst_gl_overlay_get_property (GObject * object, guint prop_id, static void gst_gl_overlay_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec); GValue * value, GParamSpec * pspec);
static void gst_gl_overlay_reset_resources (GstGLFilter * filter);
static void gst_gl_overlay_before_transform (GstBaseTransform * trans, static void gst_gl_overlay_before_transform (GstBaseTransform * trans,
GstBuffer * outbuf); GstBuffer * outbuf);
static gboolean gst_gl_overlay_filter_texture (GstGLFilter * filter, static gboolean gst_gl_overlay_filter_texture (GstGLFilter * filter,
@ -187,7 +185,6 @@ gst_gl_overlay_class_init (GstGLOverlayClass * klass)
GST_GL_FILTER_CLASS (klass)->filter_texture = gst_gl_overlay_filter_texture; GST_GL_FILTER_CLASS (klass)->filter_texture = gst_gl_overlay_filter_texture;
GST_GL_FILTER_CLASS (klass)->display_reset_cb = GST_GL_FILTER_CLASS (klass)->display_reset_cb =
gst_gl_overlay_reset_gl_resources; gst_gl_overlay_reset_gl_resources;
GST_GL_FILTER_CLASS (klass)->onStop = gst_gl_overlay_reset_resources;
GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_overlay_init_gl_resources; GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_overlay_init_gl_resources;
GST_BASE_TRANSFORM_CLASS (klass)->before_transform = GST_BASE_TRANSFORM_CLASS (klass)->before_transform =
@ -266,11 +263,6 @@ gst_gl_overlay_init (GstGLOverlay * overlay)
overlay->alpha = 1.0; overlay->alpha = 1.0;
} }
static void
gst_gl_overlay_reset_resources (GstGLFilter * filter)
{
}
static void static void
gst_gl_overlay_set_property (GObject * object, guint prop_id, gst_gl_overlay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)

View file

@ -75,7 +75,6 @@ static GstCaps *gst_gl_filter_transform_caps (GstBaseTransform * bt,
static GstCaps *gst_gl_filter_fixate_caps (GstBaseTransform * bt, static GstCaps *gst_gl_filter_fixate_caps (GstBaseTransform * bt,
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps); GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
static void gst_gl_filter_reset (GstGLFilter * filter); static void gst_gl_filter_reset (GstGLFilter * filter);
static gboolean gst_gl_filter_start (GstBaseTransform * bt);
static gboolean gst_gl_filter_stop (GstBaseTransform * bt); static gboolean gst_gl_filter_stop (GstBaseTransform * bt);
static gboolean gst_gl_filter_get_unit_size (GstBaseTransform * trans, static gboolean gst_gl_filter_get_unit_size (GstBaseTransform * trans,
GstCaps * caps, gsize * size); GstCaps * caps, gsize * size);
@ -106,7 +105,6 @@ gst_gl_filter_class_init (GstGLFilterClass * klass)
gst_gl_filter_transform_caps; gst_gl_filter_transform_caps;
GST_BASE_TRANSFORM_CLASS (klass)->fixate_caps = gst_gl_filter_fixate_caps; GST_BASE_TRANSFORM_CLASS (klass)->fixate_caps = gst_gl_filter_fixate_caps;
GST_BASE_TRANSFORM_CLASS (klass)->transform = gst_gl_filter_transform; GST_BASE_TRANSFORM_CLASS (klass)->transform = gst_gl_filter_transform;
GST_BASE_TRANSFORM_CLASS (klass)->start = gst_gl_filter_start;
GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_filter_stop; GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_filter_stop;
GST_BASE_TRANSFORM_CLASS (klass)->set_caps = gst_gl_filter_set_caps; GST_BASE_TRANSFORM_CLASS (klass)->set_caps = gst_gl_filter_set_caps;
GST_BASE_TRANSFORM_CLASS (klass)->propose_allocation = GST_BASE_TRANSFORM_CLASS (klass)->propose_allocation =
@ -164,26 +162,10 @@ gst_gl_filter_reset (GstGLFilter * filter)
} }
} }
static gboolean
gst_gl_filter_start (GstBaseTransform * bt)
{
GstGLFilter *filter = GST_GL_FILTER (bt);
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
if (filter_class->onStart)
filter_class->onStart (filter);
return GST_BASE_TRANSFORM_CLASS (parent_class)->start (bt);
}
static gboolean static gboolean
gst_gl_filter_stop (GstBaseTransform * bt) gst_gl_filter_stop (GstBaseTransform * bt)
{ {
GstGLFilter *filter = GST_GL_FILTER (bt); GstGLFilter *filter = GST_GL_FILTER (bt);
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
if (filter_class->onStop)
filter_class->onStop (filter);
gst_gl_filter_reset (filter); gst_gl_filter_reset (filter);

View file

@ -91,8 +91,6 @@ struct _GstGLFilter
* @filter_texture: given @in_tex, transform it into @out_tex. Not used * @filter_texture: given @in_tex, transform it into @out_tex. Not used
* if @filter exists * if @filter exists
* @onInitFBO: perform initialization when the Framebuffer object is created * @onInitFBO: perform initialization when the Framebuffer object is created
* @onStart: called when element activates see also #GstBaseTransform
* @onStop: called when the element deactivates e also #GstBaseTransform
* @onReset: called on inizialation and after @onStop * @onReset: called on inizialation and after @onStop
* @display_init_cb: execute arbitrary gl code on start * @display_init_cb: execute arbitrary gl code on start
* @display_reset_cb: execute arbitrary gl code at stop * @display_reset_cb: execute arbitrary gl code at stop
@ -106,10 +104,6 @@ struct _GstGLFilterClass
gboolean (*filter_texture) (GstGLFilter *filter, guint in_tex, guint out_tex); gboolean (*filter_texture) (GstGLFilter *filter, guint in_tex, guint out_tex);
gboolean (*onInitFBO) (GstGLFilter *filter); gboolean (*onInitFBO) (GstGLFilter *filter);
void (*onStart) (GstGLFilter *filter);
void (*onStop) (GstGLFilter *filter);
void (*onReset) (GstGLFilter *filter);
/* useful to init and cleanup custom gl resources */ /* useful to init and cleanup custom gl resources */
void (*display_init_cb) (GstGLFilter *filter); void (*display_init_cb) (GstGLFilter *filter);
void (*display_reset_cb) (GstGLFilter *filter); void (*display_reset_cb) (GstGLFilter *filter);