From 76bf415a9642c5a077d3ed9fc8fa48a69af68902 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Thu, 6 Jul 2017 21:09:50 +1000 Subject: [PATCH] glfilter: Remove hard-coded pad templates Add a function to install the default RGBA pad templates, but don't make them required so that there can be GstGLFilter sub-classes with different input/output caps if they want. Remove the hard-coded RGBA restriction in the set_caps_features call, as it will be taken care of by intersecting with the pad templates. Update all the sub-classes to match --- ext/gl/gstglbumper.c | 2 ++ ext/gl/gstglcolorbalance.c | 2 ++ ext/gl/gstglcolorscale.c | 2 ++ ext/gl/gstgldeinterlace.c | 2 ++ ext/gl/gstgldifferencematte.c | 3 +++ ext/gl/gstgleffects.c | 2 ++ ext/gl/gstglfilterapp.c | 2 ++ ext/gl/gstglfiltercube.c | 2 ++ ext/gl/gstglfilterglass.c | 2 ++ ext/gl/gstglfilterreflectedscreen.c | 2 ++ ext/gl/gstglfiltershader.c | 2 ++ ext/gl/gstgloverlay.c | 2 ++ ext/gl/gstgltransformation.c | 2 ++ ext/gl/gstglviewconvert.c | 2 ++ gst-libs/gst/gl/gstglfilter.c | 18 ++++++++++-------- gst-libs/gst/gl/gstglfilter.h | 3 +++ 16 files changed, 42 insertions(+), 8 deletions(-) diff --git a/ext/gl/gstglbumper.c b/ext/gl/gstglbumper.c index 8dd812c..2b7bd6e 100644 --- a/ext/gl/gstglbumper.c +++ b/ext/gl/gstglbumper.c @@ -280,6 +280,8 @@ gst_gl_bumper_class_init (GstGLBumperClass * klass) gobject_class->set_property = gst_gl_bumper_set_property; gobject_class->get_property = gst_gl_bumper_get_property; + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + GST_GL_FILTER_CLASS (klass)->filter_texture = gst_gl_bumper_filter_texture; GST_GL_FILTER_CLASS (klass)->display_init_cb = gst_gl_bumper_init_resources; GST_GL_FILTER_CLASS (klass)->display_reset_cb = gst_gl_bumper_reset_resources; diff --git a/ext/gl/gstglcolorbalance.c b/ext/gl/gstglcolorbalance.c index c2482a3..7a8a5b1 100644 --- a/ext/gl/gstglcolorbalance.c +++ b/ext/gl/gstglcolorbalance.c @@ -292,6 +292,8 @@ gst_gl_color_balance_class_init (GstGLColorBalanceClass * klass) GST_DEBUG_CATEGORY_INIT (glcolorbalance_debug, "glcolorbalance", 0, "glcolorbalance"); + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->finalize = gst_gl_color_balance_finalize; gobject_class->set_property = gst_gl_color_balance_set_property; gobject_class->get_property = gst_gl_color_balance_get_property; diff --git a/ext/gl/gstglcolorscale.c b/ext/gl/gstglcolorscale.c index b7b0709..3042734 100644 --- a/ext/gl/gstglcolorscale.c +++ b/ext/gl/gstglcolorscale.c @@ -89,6 +89,8 @@ gst_gl_colorscale_class_init (GstGLColorscaleClass * klass) base_filter_class = GST_GL_BASE_FILTER_CLASS (klass); filter_class = GST_GL_FILTER_CLASS (klass); + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->set_property = gst_gl_colorscale_set_property; gobject_class->get_property = gst_gl_colorscale_get_property; diff --git a/ext/gl/gstgldeinterlace.c b/ext/gl/gstgldeinterlace.c index dbc2c24..975128f 100644 --- a/ext/gl/gstgldeinterlace.c +++ b/ext/gl/gstgldeinterlace.c @@ -241,6 +241,8 @@ gst_gl_deinterlace_class_init (GstGLDeinterlaceClass * klass) gobject_class = (GObjectClass *) klass; element_class = GST_ELEMENT_CLASS (klass); + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->set_property = gst_gl_deinterlace_set_property; gobject_class->get_property = gst_gl_deinterlace_get_property; diff --git a/ext/gl/gstgldifferencematte.c b/ext/gl/gstgldifferencematte.c index aa1092a..c68bbbe 100644 --- a/ext/gl/gstgldifferencematte.c +++ b/ext/gl/gstgldifferencematte.c @@ -215,6 +215,9 @@ gst_gl_differencematte_class_init (GstGLDifferenceMatteClass * klass) gobject_class = (GObjectClass *) klass; element_class = GST_ELEMENT_CLASS (klass); + + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->set_property = gst_gl_differencematte_set_property; gobject_class->get_property = gst_gl_differencematte_get_property; diff --git a/ext/gl/gstgleffects.c b/ext/gl/gstgleffects.c index d8a7da1..4377310 100644 --- a/ext/gl/gstgleffects.c +++ b/ext/gl/gstgleffects.c @@ -327,6 +327,8 @@ gst_gl_effects_class_init (GstGLEffectsClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + GST_BASE_TRANSFORM_CLASS (klass)->start = gst_gl_effects_init_resources; GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_effects_reset_resources; diff --git a/ext/gl/gstglfilterapp.c b/ext/gl/gstglfilterapp.c index fc2e6ac..8426d03 100644 --- a/ext/gl/gstglfilterapp.c +++ b/ext/gl/gstglfilterapp.c @@ -81,6 +81,8 @@ gst_gl_filter_app_class_init (GstGLFilterAppClass * klass) gobject_class = (GObjectClass *) klass; element_class = GST_ELEMENT_CLASS (klass); + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->set_property = gst_gl_filter_app_set_property; gobject_class->get_property = gst_gl_filter_app_get_property; diff --git a/ext/gl/gstglfiltercube.c b/ext/gl/gstglfiltercube.c index 427782a..9e04ea0 100644 --- a/ext/gl/gstglfiltercube.c +++ b/ext/gl/gstglfiltercube.c @@ -135,6 +135,8 @@ gst_gl_filter_cube_class_init (GstGLFilterCubeClass * klass) gobject_class = (GObjectClass *) klass; element_class = GST_ELEMENT_CLASS (klass); + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->set_property = gst_gl_filter_cube_set_property; gobject_class->get_property = gst_gl_filter_cube_get_property; diff --git a/ext/gl/gstglfilterglass.c b/ext/gl/gstglfilterglass.c index ea20239..160543f 100644 --- a/ext/gl/gstglfilterglass.c +++ b/ext/gl/gstglfilterglass.c @@ -153,6 +153,8 @@ gst_gl_filter_glass_class_init (GstGLFilterGlassClass * klass) gobject_class = (GObjectClass *) klass; element_class = GST_ELEMENT_CLASS (klass); + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->set_property = gst_gl_filter_glass_set_property; gobject_class->get_property = gst_gl_filter_glass_get_property; diff --git a/ext/gl/gstglfilterreflectedscreen.c b/ext/gl/gstglfilterreflectedscreen.c index 62ccd9b..2ca090c 100644 --- a/ext/gl/gstglfilterreflectedscreen.c +++ b/ext/gl/gstglfilterreflectedscreen.c @@ -91,6 +91,8 @@ gst_gl_filter_reflected_screen_class_init (GstGLFilterReflectedScreenClass * gobject_class = (GObjectClass *) klass; element_class = GST_ELEMENT_CLASS (klass); + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->set_property = gst_gl_filter_reflected_screen_set_property; gobject_class->get_property = gst_gl_filter_reflected_screen_get_property; diff --git a/ext/gl/gstglfiltershader.c b/ext/gl/gstglfiltershader.c index 8f5a990..06a6195 100644 --- a/ext/gl/gstglfiltershader.c +++ b/ext/gl/gstglfiltershader.c @@ -115,6 +115,8 @@ gst_gl_filtershader_class_init (GstGLFilterShaderClass * klass) gobject_class = (GObjectClass *) klass; element_class = GST_ELEMENT_CLASS (klass); + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->finalize = gst_gl_filtershader_finalize; gobject_class->set_property = gst_gl_filtershader_set_property; gobject_class->get_property = gst_gl_filtershader_get_property; diff --git a/ext/gl/gstgloverlay.c b/ext/gl/gstgloverlay.c index 173d118..864ea64 100644 --- a/ext/gl/gstgloverlay.c +++ b/ext/gl/gstgloverlay.c @@ -189,6 +189,8 @@ gst_gl_overlay_class_init (GstGLOverlayClass * klass) gobject_class = (GObjectClass *) klass; element_class = GST_ELEMENT_CLASS (klass); + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->set_property = gst_gl_overlay_set_property; gobject_class->get_property = gst_gl_overlay_get_property; diff --git a/ext/gl/gstgltransformation.c b/ext/gl/gstgltransformation.c index 729a9f6..047fc73 100644 --- a/ext/gl/gstgltransformation.c +++ b/ext/gl/gstgltransformation.c @@ -129,6 +129,8 @@ gst_gl_transformation_class_init (GstGLTransformationClass * klass) element_class = GST_ELEMENT_CLASS (klass); base_transform_class = GST_BASE_TRANSFORM_CLASS (klass); + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->set_property = gst_gl_transformation_set_property; gobject_class->get_property = gst_gl_transformation_get_property; diff --git a/ext/gl/gstglviewconvert.c b/ext/gl/gstglviewconvert.c index 670305c..eafa084 100644 --- a/ext/gl/gstglviewconvert.c +++ b/ext/gl/gstglviewconvert.c @@ -101,6 +101,8 @@ gst_gl_view_convert_element_class_init (GstGLViewConvertElementClass * klass) gobject_class = (GObjectClass *) klass; element_class = GST_ELEMENT_CLASS (klass); + gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->set_property = gst_gl_view_convert_element_set_property; gobject_class->get_property = gst_gl_view_convert_element_get_property; gobject_class->dispose = gst_gl_view_convert_dispose; diff --git a/gst-libs/gst/gl/gstglfilter.c b/gst-libs/gst/gl/gstglfilter.c index e702a1e..544d79d 100644 --- a/gst-libs/gst/gl/gstglfilter.c +++ b/gst-libs/gst/gl/gstglfilter.c @@ -118,14 +118,22 @@ static void gst_gl_filter_gl_stop (GstGLBaseFilter * filter); static gboolean gst_gl_filter_gl_set_caps (GstGLBaseFilter * bt, GstCaps * incaps, GstCaps * outcaps); +void +gst_gl_filter_add_rgba_pad_templates (GstGLFilterClass * klass) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + gst_element_class_add_static_pad_template (element_class, + &gst_gl_filter_src_pad_template); + gst_element_class_add_static_pad_template (element_class, + &gst_gl_filter_sink_pad_template); +} + static void gst_gl_filter_class_init (GstGLFilterClass * klass) { GObjectClass *gobject_class; - GstElementClass *element_class; gobject_class = (GObjectClass *) klass; - element_class = GST_ELEMENT_CLASS (klass); gobject_class->set_property = gst_gl_filter_set_property; gobject_class->get_property = gst_gl_filter_get_property; @@ -146,11 +154,6 @@ gst_gl_filter_class_init (GstGLFilterClass * klass) GST_GL_BASE_FILTER_CLASS (klass)->gl_set_caps = gst_gl_filter_gl_set_caps; klass->transform_internal_caps = default_transform_internal_caps; - - gst_element_class_add_static_pad_template (element_class, - &gst_gl_filter_src_pad_template); - gst_element_class_add_static_pad_template (element_class, - &gst_gl_filter_sink_pad_template); } static void @@ -618,7 +621,6 @@ gst_gl_filter_set_caps_features (const GstCaps * caps, gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY)); } - gst_caps_set_simple (ret, "format", G_TYPE_STRING, "RGBA", NULL); return ret; } diff --git a/gst-libs/gst/gl/gstglfilter.h b/gst-libs/gst/gl/gstglfilter.h index 8b278d8..9dbb537 100644 --- a/gst-libs/gst/gl/gstglfilter.h +++ b/gst-libs/gst/gl/gstglfilter.h @@ -119,6 +119,9 @@ struct _GstGLFilterClass }; GST_EXPORT +void gst_gl_filter_add_rgba_pad_templates (GstGLFilterClass *klass); + +GST_EXPORT gboolean gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf, GstBuffer * outbuf); -- 2.7.4