initial import from CVS gstreamer/gst-template/gst-plugin
[gst-scaletempo-rj.git] / src / gsttransform.c
blob4cfcb8d452f4fba89ab96f6eca86147c4471cd59
1 /*
2 * GStreamer
3 * Copyright (C) 2006 Stefan Kost <ensonic@users.sf.net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 /**
22 * SECTION:element-plugin
24 * <refsect2>
25 * <title>Example launch line</title>
26 * <para>
27 * <programlisting>
28 * gst-launch -v -m audiotestsrc ! plugin ! fakesink silent=TRUE
29 * </programlisting>
30 * </para>
31 * </refsect2>
34 #ifdef HAVE_CONFIG_H
35 #include "config.h"
36 #endif
38 #include <gst/gst.h>
39 #include <gst/base/gstbasetransform.h>
40 #include <gst/controller/gstcontroller.h>
42 #include "gsttransform.h"
44 GST_DEBUG_CATEGORY_STATIC (gst_plugin_template_debug);
45 #define GST_CAT_DEFAULT gst_plugin_template_debug
47 /* Filter signals and args */
48 enum {
49 /* FILL ME */
50 LAST_SIGNAL
53 enum {
54 PROP_0,
55 PROP_SILENT,
58 static GstStaticPadTemplate sink_template =
59 GST_STATIC_PAD_TEMPLATE (
60 "sink",
61 GST_PAD_SINK,
62 GST_PAD_ALWAYS,
63 GST_STATIC_CAPS ("ANY")
66 static GstStaticPadTemplate src_template =
67 GST_STATIC_PAD_TEMPLATE (
68 "src",
69 GST_PAD_SRC,
70 GST_PAD_ALWAYS,
71 GST_STATIC_CAPS ("ANY")
74 #define DEBUG_INIT(bla) \
75 GST_DEBUG_CATEGORY_INIT (gst_plugin_template_debug, "plugin_template", 0, "transformer template plugin");
77 GST_BOILERPLATE_FULL (GstPluginTemplate, gst_plugin_template, GstBaseTransform,
78 GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
80 static void gst_plugin_template_set_property (GObject * object, guint prop_id,
81 const GValue * value, GParamSpec * pspec);
82 static void gst_plugin_template_get_property (GObject * object, guint prop_id,
83 GValue * value, GParamSpec * pspec);
85 static GstFlowReturn gst_plugin_template_transform_ip (GstBaseTransform * base,
86 GstBuffer * outbuf);
88 /* GObject vmethod implementations */
90 static void
91 gst_plugin_template_base_init (gpointer klass)
93 static GstElementDetails element_details = {
94 "PluginTemplate",
95 "Generic/PluginTemplate",
96 "Generic Template Element",
97 "Stefan Kost <ensonic@users.sf.net>"
99 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
101 gst_element_class_add_pad_template (element_class,
102 gst_static_pad_template_get (&src_template));
103 gst_element_class_add_pad_template (element_class,
104 gst_static_pad_template_get (&sink_template));
105 gst_element_class_set_details (element_class, &element_details);
108 static void
109 gst_plugin_template_class_init (GstPluginTemplateClass * klass)
111 GObjectClass *gobject_class;
113 gobject_class = (GObjectClass *) klass;
114 gobject_class->set_property = gst_plugin_template_set_property;
115 gobject_class->get_property = gst_plugin_template_get_property;
117 g_object_class_install_property (gobject_class, PROP_SILENT,
118 g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
119 FALSE, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
121 GST_BASE_TRANSFORM_CLASS (klass)->transform_ip =
122 GST_DEBUG_FUNCPTR (gst_plugin_template_transform_ip);
125 static void
126 gst_plugin_template_init (GstPluginTemplate *filter, GstPluginTemplateClass * klass)
128 filter->silent = FALSE;
131 static void
132 gst_plugin_template_set_property (GObject * object, guint prop_id,
133 const GValue * value, GParamSpec * pspec)
135 GstPluginTemplate *filter = GST_PLUGIN_TEMPLATE (object);
137 switch (prop_id) {
138 case PROP_SILENT:
139 filter->silent = g_value_get_boolean (value);
140 break;
141 default:
142 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
143 break;
147 static void
148 gst_plugin_template_get_property (GObject * object, guint prop_id,
149 GValue * value, GParamSpec * pspec)
151 GstPluginTemplate *filter = GST_PLUGIN_TEMPLATE (object);
153 switch (prop_id) {
154 case PROP_SILENT:
155 g_value_set_boolean (value, filter->silent);
156 break;
157 default:
158 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
159 break;
163 /* GstBaseTransform vmethod implementations */
165 /* this function does the actual processing
167 static GstFlowReturn
168 gst_plugin_template_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
170 GstPluginTemplate *filter = GST_PLUGIN_TEMPLATE (base);
172 if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (outbuf)))
173 gst_object_sync_values (G_OBJECT (filter), GST_BUFFER_TIMESTAMP (outbuf));
175 if (filter->silent == FALSE)
176 g_print ("I'm plugged, therefore I'm in.\n");
178 return GST_FLOW_OK;
182 /* entry point to initialize the plug-in
183 * initialize the plug-in itself
184 * register the element factories and pad templates
185 * register the features
187 * exchange the string 'plugin' with your elemnt name
189 static gboolean
190 plugin_init (GstPlugin * plugin)
192 /* initialize gst controller library */
193 gst_controller_init(NULL, NULL);
195 return gst_element_register (plugin, "plugin", GST_RANK_NONE,
196 GST_TYPE_PLUGIN_TEMPLATE);
199 /* this is the structure that gstreamer looks for to register plugins
201 * exchange the strings 'plugin' and 'Template plugin' with you plugin name and
202 * description
204 GST_PLUGIN_DEFINE (
205 GST_VERSION_MAJOR,
206 GST_VERSION_MINOR,
207 "plugin",
208 "Generic Template Plugin",
209 plugin_init,
210 VERSION,
211 "LGPL",
212 "GStreamer",
213 "http://gstreamer.net/"