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 = GST_ELEMENT_DETAILS (
28 "Video Filter Template",
30 "Template for a video filter",
31 "David Schleef <ds@schleef.org>",
34 /* GstVideotemplate signals and args */
45 static void gst_videotemplate_class_init (gpointer g_class);
46 static void gst_videotemplate_class_init (GstVideotemplateClass *klass);
47 static void gst_videotemplate_init (GstVideotemplate *videotemplate);
49 static void gst_videotemplate_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
50 static void gst_videotemplate_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
52 static void gst_videotemplate_planar411(GstVideofilter *videofilter, void *dest, void *src);
53 static void gst_videotemplate_setup(GstVideofilter *videofilter);
55 static GstVideotemplateClass *this_class = NULL;
56 static GstVideofilterClass *parent_class = NULL;
57 static GstElementClass *element_class = NULL;
60 gst_videotemplate_get_type (void)
62 static GType videotemplate_type = 0;
64 if (!videotemplate_type) {
65 static const GTypeInfo videotemplate_info = {
66 sizeof(GstVideotemplateClass),
67 gst_videotemplate_class_init,
69 (GClassInitFunc)gst_videotemplate_class_init,
72 sizeof(GstVideotemplate),
74 (GInstanceInitFunc)gst_videotemplate_init,
76 videotemplate_type = g_type_register_static(GST_TYPE_VIDEOFILTER, "GstVideotemplate", &videotemplate_info, 0);
78 return videotemplate_type;
81 static GstVideofilterFormat gst_videotemplate_formats[] = {
82 { "I420", 12, gst_videotemplate_planar411, },
87 gst_videotemplate_class_init (gpointer g_class)
89 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
91 factory = gst_element_set_details (element_class, &videotemplate_details);
93 gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (gst_videotemplate_sink_template_factory));
94 gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (gst_videotemplate_src_template_factory));
97 gst_videotemplate_class_init (GstVideotemplateClass *klass)
99 GObjectClass *gobject_class;
100 GstElementClass *gstelement_class;
101 GstVideofilterClass *gstvideofilter_class;
104 gobject_class = (GObjectClass*)klass;
105 gstelement_class = (GstElementClass*)klass;
106 gstvideofilter_class = (GstVideofilterClass *)klass;
109 g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_METHOD,
110 g_param_spec_enum("method","method","method",
111 GST_TYPE_VIDEOTEMPLATE_METHOD, GST_VIDEOTEMPLATE_METHOD_90R,
116 parent_class = g_type_class_ref(GST_TYPE_VIDEOFILTER);
117 element_class = g_type_class_ref(GST_TYPE_ELEMENT);
119 gobject_class->set_property = gst_videotemplate_set_property;
120 gobject_class->get_property = gst_videotemplate_get_property;
122 gstvideofilter_class->setup = gst_videotemplate_setup;
124 for(i=0;i<G_N_ELEMENTS(gst_videotemplate_formats);i++){
125 gst_videofilter_class_add_format(gstvideofilter_class,
126 gst_videotemplate_formats + i);
130 static GstCaps *gst_videotemplate_get_capslist(void)
132 GstVideofilterClass *klass;
134 klass = g_type_class_ref(GST_TYPE_VIDEOFILTER);
136 return gst_videofilter_class_get_capslist(klass);
139 static GstPadTemplate *
140 gst_videotemplate_src_template_factory(void)
142 static GstPadTemplate *templ = NULL;
145 GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
146 "width", GST_PROPS_INT_RANGE (1, G_MAXINT),
147 "height", GST_PROPS_INT_RANGE (1, G_MAXINT),
148 "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
150 caps = gst_caps_intersect(caps, gst_videotemplate_get_capslist ());
152 templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
157 static GstPadTemplate *
158 gst_videotemplate_sink_template_factory(void)
160 static GstPadTemplate *templ = NULL;
163 GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
164 "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
165 "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
166 "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
168 caps = gst_caps_intersect(caps, gst_videotemplate_get_capslist ());
170 templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
176 gst_videotemplate_init (GstVideotemplate *videotemplate)
178 GstVideofilter *videofilter;
180 GST_DEBUG("gst_videotemplate_init");
182 videofilter = GST_VIDEOFILTER(videotemplate);
184 videofilter->sinkpad = gst_pad_new_from_template (
185 GST_PAD_TEMPLATE_GET (gst_videotemplate_sink_template_factory),
188 videofilter->srcpad = gst_pad_new_from_template (
189 GST_PAD_TEMPLATE_GET (gst_videotemplate_src_template_factory),
192 gst_videofilter_postinit(GST_VIDEOFILTER(videotemplate));
196 gst_videotemplate_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
198 GstVideotemplate *src;
200 /* it's not null if we got it, but it might not be ours */
201 g_return_if_fail(GST_IS_VIDEOTEMPLATE(object));
202 src = GST_VIDEOTEMPLATE(object);
204 GST_DEBUG("gst_videotemplate_set_property");
208 src->method = g_value_get_enum (value);
217 gst_videotemplate_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
219 GstVideotemplate *src;
221 /* it's not null if we got it, but it might not be ours */
222 g_return_if_fail(GST_IS_VIDEOTEMPLATE(object));
223 src = GST_VIDEOTEMPLATE(object);
228 g_value_set_enum (value, src->method);
232 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
237 static gboolean plugin_init (GstPlugin *plugin)
239 GstElementFactory *factory;
241 if(!gst_library_load("gstvideofilter"))
244 return gst_element_register (plugin, "videotemplate", GST_RANK_NONE, GST_TYPE_VIDEOTEMPLATE);
251 "Template for a video filter",
260 static void gst_videotemplate_setup(GstVideofilter *videofilter)
262 GstVideotemplate *videotemplate;
264 g_return_if_fail(GST_IS_VIDEOTEMPLATE(videofilter));
265 videotemplate = GST_VIDEOTEMPLATE(videofilter);
267 /* if any setup needs to be done, do it here */
271 static void gst_videotemplate_planar411(GstVideofilter *videofilter,
272 void *dest, void *src)
274 GstVideotemplate *videotemplate;
276 g_return_if_fail(GST_IS_VIDEOTEMPLATE(videofilter));
277 videotemplate = GST_VIDEOTEMPLATE(videofilter);
279 /* do something interesting here */