2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) <2003> David Schleef <ds@schleef.org>
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 /*#define DEBUG_ENABLED */
23 #include <gstvideotemplate.h>
26 /* elementfactory information */
27 static GstElementDetails videotemplate_details = {
28 "Video Filter Template",
31 "Template for a video filter",
33 "David Schleef <ds@schleef.org>",
37 /* GstVideotemplate signals and args */
48 static void gst_videotemplate_class_init (GstVideotemplateClass *klass);
49 static void gst_videotemplate_init (GstVideotemplate *videotemplate);
51 static void gst_videotemplate_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
52 static void gst_videotemplate_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
54 static void gst_videotemplate_planar411(GstVideofilter *videofilter, void *dest, void *src);
55 static void gst_videotemplate_setup(GstVideofilter *videofilter);
57 static GstVideotemplateClass *this_class = NULL;
58 static GstVideofilterClass *parent_class = NULL;
59 static GstElementClass *element_class = NULL;
62 gst_videotemplate_get_type (void)
64 static GType videotemplate_type = 0;
66 if (!videotemplate_type) {
67 static const GTypeInfo videotemplate_info = {
68 sizeof(GstVideotemplateClass), NULL,
70 (GClassInitFunc)gst_videotemplate_class_init,
73 sizeof(GstVideotemplate),
75 (GInstanceInitFunc)gst_videotemplate_init,
77 videotemplate_type = g_type_register_static(GST_TYPE_VIDEOFILTER, "GstVideotemplate", &videotemplate_info, 0);
79 return videotemplate_type;
82 static GstVideofilterFormat gst_videotemplate_formats[] = {
83 { "I420", 12, gst_videotemplate_planar411, },
87 gst_videotemplate_class_init (GstVideotemplateClass *klass)
89 GObjectClass *gobject_class;
90 GstElementClass *gstelement_class;
91 GstVideofilterClass *gstvideofilter_class;
94 gobject_class = (GObjectClass*)klass;
95 gstelement_class = (GstElementClass*)klass;
96 gstvideofilter_class = (GstVideofilterClass *)klass;
99 g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_METHOD,
100 g_param_spec_enum("method","method","method",
101 GST_TYPE_VIDEOTEMPLATE_METHOD, GST_VIDEOTEMPLATE_METHOD_90R,
106 parent_class = g_type_class_ref(GST_TYPE_VIDEOFILTER);
107 element_class = g_type_class_ref(GST_TYPE_ELEMENT);
109 gobject_class->set_property = gst_videotemplate_set_property;
110 gobject_class->get_property = gst_videotemplate_get_property;
112 gstvideofilter_class->setup = gst_videotemplate_setup;
114 for(i=0;i<G_N_ELEMENTS(gst_videotemplate_formats);i++){
115 gst_videofilter_class_add_format(gstvideofilter_class,
116 gst_videotemplate_formats + i);
120 static GstCaps *gst_videotemplate_get_capslist(void)
122 GstVideofilterClass *klass;
124 klass = g_type_class_ref(GST_TYPE_VIDEOFILTER);
126 return gst_videofilter_class_get_capslist(klass);
129 static GstPadTemplate *
130 gst_videotemplate_src_template_factory(void)
132 static GstPadTemplate *templ = NULL;
135 GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
136 "width", GST_PROPS_INT_RANGE (1, G_MAXINT),
137 "height", GST_PROPS_INT_RANGE (1, G_MAXINT),
138 "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
140 caps = gst_caps_intersect(caps, gst_videotemplate_get_capslist ());
142 templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
147 static GstPadTemplate *
148 gst_videotemplate_sink_template_factory(void)
150 static GstPadTemplate *templ = NULL;
153 GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
154 "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
155 "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
156 "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
158 caps = gst_caps_intersect(caps, gst_videotemplate_get_capslist ());
160 templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
166 gst_videotemplate_init (GstVideotemplate *videotemplate)
168 GstVideofilter *videofilter;
170 GST_DEBUG("gst_videotemplate_init");
172 videofilter = GST_VIDEOFILTER(videotemplate);
174 videofilter->sinkpad = gst_pad_new_from_template (
175 GST_PAD_TEMPLATE_GET (gst_videotemplate_sink_template_factory),
178 videofilter->srcpad = gst_pad_new_from_template (
179 GST_PAD_TEMPLATE_GET (gst_videotemplate_src_template_factory),
182 gst_videofilter_postinit(GST_VIDEOFILTER(videotemplate));
186 gst_videotemplate_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
188 GstVideotemplate *src;
190 /* it's not null if we got it, but it might not be ours */
191 g_return_if_fail(GST_IS_VIDEOTEMPLATE(object));
192 src = GST_VIDEOTEMPLATE(object);
194 GST_DEBUG("gst_videotemplate_set_property");
198 src->method = g_value_get_enum (value);
207 gst_videotemplate_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
209 GstVideotemplate *src;
211 /* it's not null if we got it, but it might not be ours */
212 g_return_if_fail(GST_IS_VIDEOTEMPLATE(object));
213 src = GST_VIDEOTEMPLATE(object);
218 g_value_set_enum (value, src->method);
222 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
227 static gboolean plugin_init (GModule *module, GstPlugin *plugin)
229 GstElementFactory *factory;
231 if(!gst_library_load("gstvideofilter"))
234 /* create an elementfactory for the videotemplate element */
235 factory = gst_element_factory_new("videotemplate",GST_TYPE_VIDEOTEMPLATE,
236 &videotemplate_details);
237 g_return_val_if_fail(factory != NULL, FALSE);
239 gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (gst_videotemplate_sink_template_factory));
240 gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (gst_videotemplate_src_template_factory));
242 gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
247 GstPluginDesc plugin_desc = {
254 static void gst_videotemplate_setup(GstVideofilter *videofilter)
256 GstVideotemplate *videotemplate;
258 g_return_if_fail(GST_IS_VIDEOTEMPLATE(videofilter));
259 videotemplate = GST_VIDEOTEMPLATE(videofilter);
261 /* if any setup needs to be done, do it here */
265 static void gst_videotemplate_planar411(GstVideofilter *videofilter,
266 void *dest, void *src)
268 GstVideotemplate *videotemplate;
270 g_return_if_fail(GST_IS_VIDEOTEMPLATE(videofilter));
271 videotemplate = GST_VIDEOTEMPLATE(videofilter);
273 /* do something interesting here */