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.
22 * SECTION:element-plugin
25 * <title>Example launch line</title>
28 * gst-launch -v -m audiotestsrc ! plugin ! fakesink silent=TRUE
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 */
58 static GstStaticPadTemplate sink_template
=
59 GST_STATIC_PAD_TEMPLATE (
63 GST_STATIC_CAPS ("ANY")
66 static GstStaticPadTemplate src_template
=
67 GST_STATIC_PAD_TEMPLATE (
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
,
88 /* GObject vmethod implementations */
91 gst_plugin_template_base_init (gpointer klass
)
93 static GstElementDetails element_details
= {
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
);
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
);
126 gst_plugin_template_init (GstPluginTemplate
*filter
, GstPluginTemplateClass
* klass
)
128 filter
->silent
= FALSE
;
132 gst_plugin_template_set_property (GObject
* object
, guint prop_id
,
133 const GValue
* value
, GParamSpec
* pspec
)
135 GstPluginTemplate
*filter
= GST_PLUGIN_TEMPLATE (object
);
139 filter
->silent
= g_value_get_boolean (value
);
142 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
148 gst_plugin_template_get_property (GObject
* object
, guint prop_id
,
149 GValue
* value
, GParamSpec
* pspec
)
151 GstPluginTemplate
*filter
= GST_PLUGIN_TEMPLATE (object
);
155 g_value_set_boolean (value
, filter
->silent
);
158 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
163 /* GstBaseTransform vmethod implementations */
165 /* this function does the actual processing
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");
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
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
208 "Generic Template Plugin",
213 "http://gstreamer.net/"