summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sourceforge.net>2008-08-11 14:51:39 +0000
committerStefan Kost <ensonic@users.sourceforge.net>2008-08-11 14:51:39 +0000
commit09f9a894c43c34c75db831ce42060ceafee5d588 (patch)
treeda9ef6a86bcb19d54e57f5fdc2f0a88bef41c852
parent2046a46c15951da0005f3508cfaf3f5001fb598e (diff)
Integrate new template and improve search'n'replace ops. Update templates to use current API.
Original commit message from CVS: * README: * src/gstaudiofilter.c: * src/gstplugin.c: * src/gsttransform.c: * tools/make_element: Integrate new template and improve search'n'replace ops. Update templates to use current API.
m---------common0
-rw-r--r--gst-plugin/ChangeLog10
-rw-r--r--gst-plugin/README3
-rw-r--r--gst-plugin/src/gstaudiofilter.c274
-rw-r--r--gst-plugin/src/gstplugin.c25
-rw-r--r--gst-plugin/src/gsttransform.c32
-rwxr-xr-xgst-plugin/tools/make_element19
7 files changed, 326 insertions, 37 deletions
diff --git a/common b/common
-Subproject e79879859bc866545379eb77e1378a906dc30eb
+Subproject d70ca17ae6fbe6020996e4567275d5e14972ed4
diff --git a/gst-plugin/ChangeLog b/gst-plugin/ChangeLog
index 171a248..fd587e4 100644
--- a/gst-plugin/ChangeLog
+++ b/gst-plugin/ChangeLog
@@ -1,3 +1,13 @@
+2008-08-11 Stefan Kost <ensonic@users.sf.net>
+
+ * README:
+ * src/gstaudiofilter.c:
+ * src/gstplugin.c:
+ * src/gsttransform.c:
+ * tools/make_element:
+ Integrate new template and improve search'n'replace ops. Update
+ templates to use current API.
+
2008-07-26 Stefan Kost <ensonic@users.sf.net>
* tools/make_element:
diff --git a/gst-plugin/README b/gst-plugin/README
index 1acafff..1905684 100644
--- a/gst-plugin/README
+++ b/gst-plugin/README
@@ -27,7 +27,8 @@ cd src;
This will create gstmyfilter.c and gstmyfilter.h. Open them in an editor and
start editing. There are several occurances of the string "template", update
those with real values. The plugin will be called 'myfilter' and it will have
-one element called 'myfilter' too.
+one element called 'myfilter' too. Also look for "FIXME:" markers that point you
+to places where you need to edit the code.
You still need to adjust the Makefile.am.
diff --git a/gst-plugin/src/gstaudiofilter.c b/gst-plugin/src/gstaudiofilter.c
new file mode 100644
index 0000000..04b2b07
--- /dev/null
+++ b/gst-plugin/src/gstaudiofilter.c
@@ -0,0 +1,274 @@
+/*
+ * GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) <2003> David Schleef <ds@schleef.org>
+ * Copyright (C) YEAR AUTHOR_NAME AUTHOR_EMAIL
+ *
+ * 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.
+ */
+
+/**
+ * SECTION:element-plugin
+ *
+ * FIXME:Describe plugin here.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch -v -m audiotestsrc ! plugin ! autoaudiosink
+ * ]|
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+#include <gst/audio/audio.h>
+#include <gst/audio/gstaudiofilter.h>
+#include <string.h>
+
+GST_DEBUG_CATEGORY_STATIC (gst_plugin_template_debug);
+#define GST_CAT_DEFAULT gst_plugin_template_debug
+
+typedef struct _GstPluginTemplate GstPluginTemplate;
+typedef struct _GstPluginTemplateClass GstPluginTemplateClass;
+
+#define GST_TYPE_PLUGIN_TEMPLATE \
+ (gst_plugin_template_get_type())
+#define GST_PLUGIN_TEMPLATE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLUGIN_TEMPLATE,GstPluginTemplate))
+#define GST_PLUGIN_TEMPLATE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLUGIN_TEMPLATE,GstPluginTemplateClass))
+#define GST_IS_PLUGIN_TEMPLATE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLUGIN_TEMPLATE))
+#define GST_IS_PLUGIN_TEMPLATE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLUGIN_TEMPLATE))
+
+struct _GstPluginTemplate
+{
+ GstAudioFilter audiofilter;
+};
+
+struct _GstPluginTemplateClass
+{
+ GstAudioFilterClass parent_class;
+};
+
+
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+
+enum
+{
+ ARG_0
+ /* FILL ME */
+};
+
+/* debug category for fltering log messages
+ *
+ * FIXME:exchange the string 'Template plugin' with your description
+ */
+#define DEBUG_INIT(bla) \
+ GST_DEBUG_CATEGORY_INIT (gst_plugin_template_debug, "plugin", 0, "Template plugin");
+
+GST_BOILERPLATE_FULL (GstPluginTemplate, gst_plugin_template,
+ GstAudioFilter, GST_TYPE_AUDIO_FILTER, DEBUG_INIT);
+
+static void gst_plugin_template_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_plugin_template_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static gboolean gst_plugin_template_setup (GstAudioFilter * filter,
+ GstRingBufferSpec * spec);
+static GstFlowReturn gst_plugin_template_filter (GstBaseTransform * bt,
+ GstBuffer * outbuf, GstBuffer * inbuf);
+static GstFlowReturn
+gst_plugin_template_filter_inplace (GstBaseTransform * base_transform,
+ GstBuffer * buf);
+
+#define ALLOWED_CAPS_STRING \
+ GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS
+
+/* GObject vmethod implementations */
+
+static void
+gst_plugin_template_base_init (gpointer klass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstAudioFilterClass *audiofilter_class = GST_AUDIO_FILTER_CLASS (klass);
+ GstCaps *caps;
+
+ gst_element_class_set_details_simple (element_class,
+ "Plugin",
+ "Filter/Effect/Audio",
+ "FIXME:Filters audio",
+ "AUTHOR_NAME AUTHOR_EMAIL");
+
+ caps = gst_caps_from_string (ALLOWED_CAPS_STRING);
+ gst_audio_filter_class_add_pad_templates (audiofilter_class, caps);
+ gst_caps_unref (caps);
+}
+
+static void
+gst_plugin_template_class_init (GstPluginTemplateClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstBaseTransformClass *btrans_class;
+ GstAudioFilterClass *audio_filter_class;
+
+ gobject_class = (GObjectClass *) klass;
+ btrans_class = (GstBaseTransformClass *) klass;
+ audio_filter_class = (GstAudioFilterClass *) klass;
+
+#if 0
+ g_object_class_install_property (gobject_class, ARG_METHOD,
+ g_param_spec_enum ("method", "method", "method",
+ GST_TYPE_AUDIOTEMPLATE_METHOD, GST_AUDIOTEMPLATE_METHOD_1,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#endif
+
+ gobject_class->set_property = gst_plugin_template_set_property;
+ gobject_class->get_property = gst_plugin_template_get_property;
+
+ /* this function will be called whenever the format changes */
+ audio_filter_class->setup = gst_plugin_template_setup;
+
+ /* here you set up functions to process data (either in place, or from
+ * one input buffer to another output buffer); only one is required */
+ btrans_class->transform = gst_plugin_template_filter;
+ btrans_class->transform_ip = gst_plugin_template_filter_inplace;
+}
+
+static void
+gst_plugin_template_init (GstPluginTemplate * plugin_template,
+ GstPluginTemplateClass * g_class)
+{
+ GST_DEBUG ("init");
+
+ /* do stuff if you need to */
+}
+
+static void
+gst_plugin_template_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstPluginTemplate *filter = GST_PLUGIN_TEMPLATE (object);
+
+ GST_OBJECT_LOCK (filter);
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+ GST_OBJECT_UNLOCK (filter);
+}
+
+static void
+gst_plugin_template_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstPluginTemplate *filter = GST_PLUGIN_TEMPLATE (object);
+
+ GST_OBJECT_LOCK (filter);
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+ GST_OBJECT_UNLOCK (filter);
+}
+
+static gboolean
+gst_plugin_template_setup (GstAudioFilter * filter,
+ GstRingBufferSpec * spec)
+{
+ GstPluginTemplate *plugin_template;
+
+ plugin_template = GST_PLUGIN_TEMPLATE (filter);
+
+ /* if any setup needs to be done, do it here */
+
+ return TRUE; /* it's all good */
+}
+
+/* You may choose to implement either a copying filter or an
+ * in-place filter (or both). Implementing only one will give
+ * full functionality, however, implementing both will cause
+ * audiofilter to use the optimal function in every situation,
+ * with a minimum of memory copies. */
+
+static GstFlowReturn
+gst_plugin_template_filter (GstBaseTransform * base_transform,
+ GstBuffer * inbuf, GstBuffer * outbuf)
+{
+ GstPluginTemplate *plugin_template;
+ GstAudioFilter *audiofilter;
+
+ audiofilter = GST_AUDIO_FILTER (base_transform);
+ plugin_template = GST_PLUGIN_TEMPLATE (base_transform);
+
+ /* FIXME: do something interesting here. This simply copies the source
+ * to the destination. */
+
+ memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (inbuf),
+ GST_BUFFER_SIZE (inbuf));
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_plugin_template_filter_inplace (GstBaseTransform * base_transform,
+ GstBuffer * buf)
+{
+ GstPluginTemplate *plugin_template;
+ GstAudioFilter *audiofilter;
+
+ audiofilter = GST_AUDIO_FILTER (base_transform);
+ plugin_template = GST_PLUGIN_TEMPLATE (base_transform);
+
+ /* FIXME: do something interesting here. This simply copies the source
+ * to the destination. */
+
+ return GST_FLOW_OK;
+}
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+ return gst_element_register (plugin, "plugin", GST_RANK_NONE,
+ GST_TYPE_PLUGIN_TEMPLATE);
+}
+
+/* gstreamer looks for this structure to register plugins
+ *
+ * FIXME:exchange the string 'Template plugin' with you plugin description
+ */
+GST_PLUGIN_DEFINE (
+ GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "plugin",
+ "Template plugin",
+ plugin_init,
+ VERSION, "LGPL",
+ "GStreamer",
+ "http://gstreamer.net/"
+);
diff --git a/gst-plugin/src/gstplugin.c b/gst-plugin/src/gstplugin.c
index 2a8b23a..443890a 100644
--- a/gst-plugin/src/gstplugin.c
+++ b/gst-plugin/src/gstplugin.c
@@ -46,13 +46,13 @@
/**
* SECTION:element-plugin
*
+ * FIXME:Describe plugin here.
+ *
* <refsect2>
* <title>Example launch line</title>
- * <para>
- * <programlisting>
- * gst-launch -v -m audiotestsrc ! plugin ! fakesink silent=TRUE
- * </programlisting>
- * </para>
+ * |[
+ * gst-launch -v -m fakesrc ! plugin ! fakesink silent=TRUE
+ * ]|
* </refsect2>
*/
@@ -112,19 +112,18 @@ static GstFlowReturn gst_plugin_template_chain (GstPad * pad, GstBuffer * buf);
static void
gst_plugin_template_base_init (gpointer gclass)
{
- static GstElementDetails element_details = {
- "PluginTemplate",
- "Generic/PluginTemplate",
- "Generic Template Element",
- "AUTHOR_NAME AUTHOR_EMAIL"
- };
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
+ gst_element_class_set_details_simple(element_class,
+ "Plugin",
+ "FIXME:Generic",
+ "FIXME:Generic Template Element",
+ "AUTHOR_NAME AUTHOR_EMAIL");
+
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_factory));
- gst_element_class_set_details (element_class, &element_details);
}
/* initialize the plugin's class */
@@ -154,8 +153,6 @@ static void
gst_plugin_template_init (GstPluginTemplate * filter,
GstPluginTemplateClass * gclass)
{
- GstElementClass *klass = GST_ELEMENT_GET_CLASS (filter);
-
filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
gst_pad_set_setcaps_function (filter->sinkpad,
GST_DEBUG_FUNCPTR(gst_plugin_template_set_caps));
diff --git a/gst-plugin/src/gsttransform.c b/gst-plugin/src/gsttransform.c
index b3afd87..6cf223e 100644
--- a/gst-plugin/src/gsttransform.c
+++ b/gst-plugin/src/gsttransform.c
@@ -22,13 +22,13 @@
/**
* SECTION:element-plugin
*
+ * FIXME:Describe plugin here.
+ *
* <refsect2>
* <title>Example launch line</title>
- * <para>
- * <programlisting>
- * gst-launch -v -m audiotestsrc ! plugin ! fakesink silent=TRUE
- * </programlisting>
- * </para>
+ * |[
+ * gst-launch -v -m fakesrc ! plugin ! fakesink silent=TRUE
+ * ]|
* </refsect2>
*/
@@ -60,7 +60,7 @@ enum
/* the capabilities of the inputs and outputs.
*
- * describe the real formats here.
+ * FIXME:describe the real formats here.
*/
static GstStaticPadTemplate sink_template =
GST_STATIC_PAD_TEMPLATE (
@@ -80,7 +80,7 @@ GST_STATIC_PAD_TEMPLATE (
/* debug category for fltering log messages
*
- * exchange the string 'Template plugin' with your description
+ * FIXME:exchange the string 'Template plugin' with your description
*/
#define DEBUG_INIT(bla) \
GST_DEBUG_CATEGORY_INIT (gst_plugin_template_debug, "plugin", 0, "Template plugin");
@@ -101,19 +101,18 @@ static GstFlowReturn gst_plugin_template_transform_ip (GstBaseTransform * base,
static void
gst_plugin_template_base_init (gpointer klass)
{
- static GstElementDetails element_details = {
- "PluginTemplate",
- "Generic/PluginTemplate",
- "Generic Template Element",
- "AUTHOR_NAME AUTHOR_EMAIL"
- };
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ gst_element_class_set_details_simple (element_class,
+ "Plugin",
+ "Generic/Filter",
+ "FIXME:Generic Template Filter",
+ "AUTHOR_NAME AUTHOR_EMAIL");
+
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template));
- gst_element_class_set_details (element_class, &element_details);
}
/* initialize the plugin's class */
@@ -189,6 +188,9 @@ gst_plugin_template_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
if (filter->silent == FALSE)
g_print ("I'm plugged, therefore I'm in.\n");
+
+ /* FIXME: do something interesting here. This simply copies the source
+ * to the destination. */
return GST_FLOW_OK;
}
@@ -210,7 +212,7 @@ plugin_init (GstPlugin * plugin)
/* gstreamer looks for this structure to register plugins
*
- * exchange the string 'Template plugin' with you plugin description
+ * FIXME:exchange the string 'Template plugin' with you plugin description
*/
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
diff --git a/gst-plugin/tools/make_element b/gst-plugin/tools/make_element
index 6b2c07c..ffd2515 100755
--- a/gst-plugin/tools/make_element
+++ b/gst-plugin/tools/make_element
@@ -23,6 +23,7 @@ TEMPLATE=$(echo $Template | tr a-z A-Z)
template=$(echo $Template | tr A-Z a-z)
filename=$(echo $template | tr -d _)
Template=$(echo $Template | tr -d _)
+template_=$(echo $Template | sed "s/\([a-z]\)\([A-Z]\)/\1_\2/g" | tr A-Z a-z)
YEAR=`date "+%Y"`
if [ -z "$REAL_NAME" ]; then
@@ -43,33 +44,37 @@ sed \
-e 's/gstplugin\.c/SOURCEFILE/g' \
-e "s/gstplugin\.h/gst$filename.h/g" \
-e "s/GstPluginTemplate/Gst$Template/g" \
- -e "s/gst_plugin_template/gst_$template/g" \
- -e "s/gst_type_plugin_template/gst_$template/g" \
+ -e "s/gst_plugin_template/gst_$template_/g" \
+ -e "s/gst_type_plugin_template/gst_$template_/g" \
-e "s/GST_PLUGIN_TEMPLATE/GST_$TEMPLATE/g" \
-e "s/GST_TYPE_PLUGIN_TEMPLATE/GST_TYPE_$TEMPLATE/g" \
-e 's/\$I[d]: \([^$]*\)\$/\1/g' \
-e 's/SOURCEFILE/gstobject\.c/g' \
-e "s%MAKEFILTERVERSION%$id%g" \
- -e "s/plugin/$Template/g" \
+ -e "s/plugin/$template/g" \
+ -e "s/Plugin/$Template/g" \
-e "s/YEAR/$YEAR/g" \
-e "s/AUTHOR_NAME/$REAL_NAME/g" \
-e "s/AUTHOR_EMAIL/<$EMAIL_ADDRESS>/g" \
$srcfile >gst$filename.c.tmp && mv gst$filename.c.tmp gst$filename.c
-sed \
+if [ -e $srcfile_h ]; then
+ sed \
-e 's/gstplugin\.c/SOURCEFILE/g' \
-e "s/GstPluginTemplate/Gst$Template/g" \
- -e "s/gst_plugin_template/gst_$template/g" \
- -e "s/gst_type_plugin_template/gst_$template/g" \
+ -e "s/gst_plugin_template/gst_$template_/g" \
+ -e "s/gst_type_plugin_template/gst_$template_/g" \
-e "s/GST_PLUGIN_TEMPLATE/GST_$TEMPLATE/g" \
-e "s/GST_TYPE_PLUGIN_TEMPLATE/GST_TYPE_$TEMPLATE/g" \
-e "s/GST_IS_PLUGIN_TEMPLATE/GST_IS_$TEMPLATE/g" \
-e 's/\$I[d]: \([^$]*\)\$/\1/g' \
-e 's/SOURCEFILE/gstobject\.c/g' \
-e "s%MAKEFILTERVERSION%$id%g" \
- -e "s/plugin/$Template/g" \
+ -e "s/plugin/$template/g" \
+ -e "s/Plugin/$Template/g" \
-e "s/YEAR/$YEAR/g" \
-e "s/AUTHOR_NAME/$REAL_NAME/g" \
-e "s/AUTHOR_EMAIL/<$EMAIL_ADDRESS>/g" \
$srcfile_h >gst$filename.h.tmp && mv gst$filename.h.tmp gst$filename.h
+fi