From 0a684a3d04df59a64bb674882fac58b7467eeffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 12 Jun 2009 14:59:28 +0200 Subject: frei0r: First version of a frei0r wrapper plugin Currently this only supports frei0r filters. --- gst/frei0r/gstfrei0rfilter.c | 255 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 gst/frei0r/gstfrei0rfilter.c (limited to 'gst/frei0r/gstfrei0rfilter.c') diff --git a/gst/frei0r/gstfrei0rfilter.c b/gst/frei0r/gstfrei0rfilter.c new file mode 100644 index 00000000..7862be6c --- /dev/null +++ b/gst/frei0r/gstfrei0rfilter.c @@ -0,0 +1,255 @@ +/* GStreamer + * Copyright (C) 2009 Sebastian Dröge + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "gstfrei0r.h" +#include "gstfrei0rfilter.h" + +typedef struct +{ + f0r_plugin_info_t info; + GstFrei0rFuncTable ftable; +} GstFrei0rFilterClassData; + +static gboolean +gst_frei0r_filter_get_unit_size (GstBaseTransform * trans, GstCaps * caps, + guint * size) +{ + GstVideoFormat fmt; + gint width, height; + + if (!gst_video_format_parse_caps (caps, &fmt, &width, &height)) + return FALSE; + + *size = gst_video_format_get_size (fmt, width, height); + return TRUE; +} + +static gboolean +gst_frei0r_filter_set_caps (GstBaseTransform * trans, GstCaps * incaps, + GstCaps * outcaps) +{ + GstFrei0rFilter *self = GST_FREI0R_FILTER (trans); + GstFrei0rFilterClass *klass = GST_FREI0R_FILTER_GET_CLASS (trans); + GstVideoFormat fmt; + gint width, height; + + if (!gst_video_format_parse_caps (incaps, &fmt, &width, &height)) + return FALSE; + + if (self->f0r_instance) { + klass->ftable->destruct (self->f0r_instance); + self->f0r_instance = NULL; + } + + self->f0r_instance = + gst_frei0r_instance_construct (klass->ftable, klass->properties, + klass->n_properties, self->property_cache, width, height); + + return TRUE; +} + +static gboolean +gst_frei0r_filter_stop (GstBaseTransform * trans) +{ + GstFrei0rFilter *self = GST_FREI0R_FILTER (trans); + GstFrei0rFilterClass *klass = GST_FREI0R_FILTER_GET_CLASS (trans); + + if (self->f0r_instance) { + klass->ftable->destruct (self->f0r_instance); + self->f0r_instance = NULL; + } + + return TRUE; +} + +static GstFlowReturn +gst_frei0r_filter_transform (GstBaseTransform * trans, GstBuffer * inbuf, + GstBuffer * outbuf) +{ + GstFrei0rFilter *self = GST_FREI0R_FILTER (trans); + GstFrei0rFilterClass *klass = GST_FREI0R_FILTER_GET_CLASS (trans); + gdouble time; + + if (!self->f0r_instance) + return GST_FLOW_NOT_NEGOTIATED; + + time = ((gdouble) GST_BUFFER_TIMESTAMP (inbuf)) / GST_SECOND; + + if (klass->ftable->update2) + klass->ftable->update2 (self->f0r_instance, time, + (const guint32 *) GST_BUFFER_DATA (inbuf), NULL, NULL, + (guint32 *) GST_BUFFER_DATA (outbuf)); + else + klass->ftable->update (self->f0r_instance, time, + (const guint32 *) GST_BUFFER_DATA (inbuf), + (guint32 *) GST_BUFFER_DATA (outbuf)); + + return GST_FLOW_OK; +} + +static void +gst_frei0r_filter_finalize (GObject * object) +{ + GstFrei0rFilter *self = GST_FREI0R_FILTER (object); + GstFrei0rFilterClass *klass = GST_FREI0R_FILTER_GET_CLASS (object); + + if (self->f0r_instance) { + klass->ftable->destruct (self->f0r_instance); + self->f0r_instance = NULL; + } + + if (self->property_cache) + gst_frei0r_property_cache_free (klass->properties, self->property_cache, + klass->n_properties); + self->property_cache = NULL; + + G_OBJECT_CLASS (g_type_class_peek_parent (klass))->finalize (object); +} + +static void +gst_frei0r_filter_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) +{ + GstFrei0rFilter *self = GST_FREI0R_FILTER (object); + GstFrei0rFilterClass *klass = GST_FREI0R_FILTER_GET_CLASS (object); + + if (!gst_frei0r_get_property (self->f0r_instance, klass->ftable, + klass->properties, klass->n_properties, self->property_cache, prop_id, + value)) + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); +} + +static void +gst_frei0r_filter_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) +{ + GstFrei0rFilter *self = GST_FREI0R_FILTER (object); + GstFrei0rFilterClass *klass = GST_FREI0R_FILTER_GET_CLASS (object); + + if (!gst_frei0r_set_property (self->f0r_instance, klass->ftable, + klass->properties, klass->n_properties, self->property_cache, prop_id, + value)) + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); +} + +static void +gst_frei0r_filter_class_init (GstFrei0rFilterClass * klass, + GstFrei0rFilterClassData * class_data) +{ + GObjectClass *gobject_class = (GObjectClass *) klass; + GstElementClass *gstelement_class = (GstElementClass *) klass; + GstBaseTransformClass *gsttrans_class = (GstBaseTransformClass *) klass; + GstPadTemplate *templ; + GstCaps *caps; + gchar *author; + + klass->ftable = &class_data->ftable; + klass->info = &class_data->info; + + gobject_class->finalize = gst_frei0r_filter_finalize; + gobject_class->set_property = gst_frei0r_filter_set_property; + gobject_class->get_property = gst_frei0r_filter_get_property; + + klass->n_properties = klass->info->num_params; + klass->properties = g_new0 (GstFrei0rProperty, klass->n_properties); + + gst_frei0r_klass_install_properties (gobject_class, klass->ftable, + klass->properties, klass->n_properties); + + author = + g_strdup_printf + ("Sebastian Dröge , %s", + class_data->info.author); + gst_element_class_set_details_simple (gstelement_class, class_data->info.name, + "Filter/Editor/Video", class_data->info.explanation, author); + g_free (author); + + caps = gst_frei0r_caps_from_color_model (class_data->info.color_model); + + templ = + gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, + gst_caps_ref (caps)); + gst_element_class_add_pad_template (gstelement_class, templ); + + templ = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps); + gst_element_class_add_pad_template (gstelement_class, templ); + + gsttrans_class->get_unit_size = + GST_DEBUG_FUNCPTR (gst_frei0r_filter_get_unit_size); + gsttrans_class->set_caps = GST_DEBUG_FUNCPTR (gst_frei0r_filter_set_caps); + gsttrans_class->stop = GST_DEBUG_FUNCPTR (gst_frei0r_filter_stop); + gsttrans_class->transform = GST_DEBUG_FUNCPTR (gst_frei0r_filter_transform); +} + +static void +gst_frei0r_filter_init (GstFrei0rFilter * self, GstFrei0rFilterClass * klass) +{ + self->property_cache = + gst_frei0r_property_cache_init (klass->properties, klass->n_properties); +} + +gboolean +gst_frei0r_filter_register (GstPlugin * plugin, const f0r_plugin_info_t * info, + const GstFrei0rFuncTable * ftable) +{ + GTypeInfo typeinfo = { + sizeof (GstFrei0rFilterClass), + NULL, + NULL, + (GClassInitFunc) gst_frei0r_filter_class_init, + NULL, + NULL, + sizeof (GstFrei0rFilter), + 0, + (GInstanceInitFunc) gst_frei0r_filter_init + }; + GType type; + gchar *type_name, *tmp; + GstFrei0rFilterClassData *class_data; + + tmp = g_strdup_printf ("frei0r-%s", info->name); + type_name = g_ascii_strdown (tmp, -1); + g_free (tmp); + g_strcanon (type_name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-+", '-'); + + if (g_type_from_name (type_name)) { + GST_WARNING ("Type '%s' already exists", type_name); + return FALSE; + } + + if (!ftable->init ()) { + GST_ERROR ("Initializing plugin failed"); + return FALSE; + } + + class_data = g_new0 (GstFrei0rFilterClassData, 1); + memcpy (&class_data->info, info, sizeof (f0r_plugin_info_t)); + memcpy (&class_data->ftable, ftable, sizeof (GstFrei0rFuncTable)); + typeinfo.class_data = class_data; + + type = + g_type_register_static (GST_TYPE_VIDEO_FILTER, type_name, &typeinfo, 0); + return (gst_element_register (plugin, type_name, GST_RANK_NONE, type)); +} -- cgit v1.2.1 From 455981d3368ba99b1a69f1968629d7cd036fd7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 12 Jun 2009 22:04:14 +0200 Subject: frei0r: Add the frei0r plugin type to the element name This makes it easier to distinguish generators from filters, etc --- gst/frei0r/gstfrei0rfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gst/frei0r/gstfrei0rfilter.c') diff --git a/gst/frei0r/gstfrei0rfilter.c b/gst/frei0r/gstfrei0rfilter.c index 7862be6c..e3df24c9 100644 --- a/gst/frei0r/gstfrei0rfilter.c +++ b/gst/frei0r/gstfrei0rfilter.c @@ -229,7 +229,7 @@ gst_frei0r_filter_register (GstPlugin * plugin, const f0r_plugin_info_t * info, gchar *type_name, *tmp; GstFrei0rFilterClassData *class_data; - tmp = g_strdup_printf ("frei0r-%s", info->name); + tmp = g_strdup_printf ("frei0r-filter-%s", info->name); type_name = g_ascii_strdown (tmp, -1); g_free (tmp); g_strcanon (type_name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-+", '-'); -- cgit v1.2.1 From d459b814f1f970fd5727e6a554cd9c264a6ce062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 14 Jun 2009 19:21:34 +0200 Subject: freir0: Add support for frei0r mixer plugins --- gst/frei0r/gstfrei0rfilter.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gst/frei0r/gstfrei0rfilter.c') diff --git a/gst/frei0r/gstfrei0rfilter.c b/gst/frei0r/gstfrei0rfilter.c index e3df24c9..df455120 100644 --- a/gst/frei0r/gstfrei0rfilter.c +++ b/gst/frei0r/gstfrei0rfilter.c @@ -26,6 +26,9 @@ #include "gstfrei0r.h" #include "gstfrei0rfilter.h" +GST_DEBUG_CATEGORY_EXTERN (frei0r_debug); +#define GST_CAT_DEFAULT frei0r_debug + typedef struct { f0r_plugin_info_t info; -- cgit v1.2.1 From 3aabf06c86118e69143a67e0aae26ca8a156324d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 14 Jun 2009 19:41:27 +0200 Subject: frei0r: Free type names --- gst/frei0r/gstfrei0rfilter.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gst/frei0r/gstfrei0rfilter.c') diff --git a/gst/frei0r/gstfrei0rfilter.c b/gst/frei0r/gstfrei0rfilter.c index df455120..ef178c97 100644 --- a/gst/frei0r/gstfrei0rfilter.c +++ b/gst/frei0r/gstfrei0rfilter.c @@ -231,6 +231,7 @@ gst_frei0r_filter_register (GstPlugin * plugin, const f0r_plugin_info_t * info, GType type; gchar *type_name, *tmp; GstFrei0rFilterClassData *class_data; + gboolean ret = FALSE; tmp = g_strdup_printf ("frei0r-filter-%s", info->name); type_name = g_ascii_strdown (tmp, -1); @@ -254,5 +255,8 @@ gst_frei0r_filter_register (GstPlugin * plugin, const f0r_plugin_info_t * info, type = g_type_register_static (GST_TYPE_VIDEO_FILTER, type_name, &typeinfo, 0); - return (gst_element_register (plugin, type_name, GST_RANK_NONE, type)); + ret = gst_element_register (plugin, type_name, GST_RANK_NONE, type); + + g_free (type_name); + return ret; } -- cgit v1.2.1 From ab0a9e3694b3b0b43891dbe2c498fbed98daa747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 15 Jun 2009 17:05:36 +0200 Subject: frei0r: Fix the klass of the filter elements --- gst/frei0r/gstfrei0rfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gst/frei0r/gstfrei0rfilter.c') diff --git a/gst/frei0r/gstfrei0rfilter.c b/gst/frei0r/gstfrei0rfilter.c index ef178c97..9b0279df 100644 --- a/gst/frei0r/gstfrei0rfilter.c +++ b/gst/frei0r/gstfrei0rfilter.c @@ -186,7 +186,7 @@ gst_frei0r_filter_class_init (GstFrei0rFilterClass * klass, ("Sebastian Dröge , %s", class_data->info.author); gst_element_class_set_details_simple (gstelement_class, class_data->info.name, - "Filter/Editor/Video", class_data->info.explanation, author); + "Filter/Effect/Video", class_data->info.explanation, author); g_free (author); caps = gst_frei0r_caps_from_color_model (class_data->info.color_model); -- cgit v1.2.1 From abffe58d43ff68071e139fd9316da37a8b8f26c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 16 Jun 2009 19:42:41 +0200 Subject: frei0r: Remove custom get_unit_size implementation This is already handled by the default one from GstVideoFilter --- gst/frei0r/gstfrei0rfilter.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'gst/frei0r/gstfrei0rfilter.c') diff --git a/gst/frei0r/gstfrei0rfilter.c b/gst/frei0r/gstfrei0rfilter.c index 9b0279df..a7aa3808 100644 --- a/gst/frei0r/gstfrei0rfilter.c +++ b/gst/frei0r/gstfrei0rfilter.c @@ -35,20 +35,6 @@ typedef struct GstFrei0rFuncTable ftable; } GstFrei0rFilterClassData; -static gboolean -gst_frei0r_filter_get_unit_size (GstBaseTransform * trans, GstCaps * caps, - guint * size) -{ - GstVideoFormat fmt; - gint width, height; - - if (!gst_video_format_parse_caps (caps, &fmt, &width, &height)) - return FALSE; - - *size = gst_video_format_get_size (fmt, width, height); - return TRUE; -} - static gboolean gst_frei0r_filter_set_caps (GstBaseTransform * trans, GstCaps * incaps, GstCaps * outcaps) @@ -199,8 +185,6 @@ gst_frei0r_filter_class_init (GstFrei0rFilterClass * klass, templ = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps); gst_element_class_add_pad_template (gstelement_class, templ); - gsttrans_class->get_unit_size = - GST_DEBUG_FUNCPTR (gst_frei0r_filter_get_unit_size); gsttrans_class->set_caps = GST_DEBUG_FUNCPTR (gst_frei0r_filter_set_caps); gsttrans_class->stop = GST_DEBUG_FUNCPTR (gst_frei0r_filter_stop); gsttrans_class->transform = GST_DEBUG_FUNCPTR (gst_frei0r_filter_transform); -- cgit v1.2.1 From 29aa30d9a05bf6c408160de108f2486a0c08bd48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 16 Jun 2009 21:34:56 +0200 Subject: frei0r: Make plugin scanning more robust --- gst/frei0r/gstfrei0rfilter.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'gst/frei0r/gstfrei0rfilter.c') diff --git a/gst/frei0r/gstfrei0rfilter.c b/gst/frei0r/gstfrei0rfilter.c index a7aa3808..43d8fc67 100644 --- a/gst/frei0r/gstfrei0rfilter.c +++ b/gst/frei0r/gstfrei0rfilter.c @@ -227,11 +227,6 @@ gst_frei0r_filter_register (GstPlugin * plugin, const f0r_plugin_info_t * info, return FALSE; } - if (!ftable->init ()) { - GST_ERROR ("Initializing plugin failed"); - return FALSE; - } - class_data = g_new0 (GstFrei0rFilterClassData, 1); memcpy (&class_data->info, info, sizeof (f0r_plugin_info_t)); memcpy (&class_data->ftable, ftable, sizeof (GstFrei0rFuncTable)); -- cgit v1.2.1