gst-indent
[platform/upstream/gst-plugins-good.git] / gst / videofilter / gstvideotemplate.c
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  * Copyright (C) <2003> David Schleef <ds@schleef.org>
4  *
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.
9  *
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.
14  *
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.
19  */
20
21 /*
22  * This file was (probably) generated from
23  * $Id$
24  * and
25  * MAKEFILTERVERSION
26  */
27
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31
32 #include <gst/gst.h>
33 #include <gstvideofilter.h>
34 #include <string.h>
35
36 #define GST_TYPE_VIDEOTEMPLATE \
37   (gst_videotemplate_get_type())
38 #define GST_VIDEOTEMPLATE(obj) \
39   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEOTEMPLATE,GstVideotemplate))
40 #define GST_VIDEOTEMPLATE_CLASS(klass) \
41   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEOTEMPLATE,GstVideotemplateClass))
42 #define GST_IS_VIDEOTEMPLATE(obj) \
43   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEOTEMPLATE))
44 #define GST_IS_VIDEOTEMPLATE_CLASS(obj) \
45   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEOTEMPLATE))
46
47 typedef struct _GstVideotemplate GstVideotemplate;
48 typedef struct _GstVideotemplateClass GstVideotemplateClass;
49
50 struct _GstVideotemplate
51 {
52   GstVideofilter videofilter;
53
54 };
55
56 struct _GstVideotemplateClass
57 {
58   GstVideofilterClass parent_class;
59 };
60
61
62 /* GstVideotemplate signals and args */
63 enum
64 {
65   /* FILL ME */
66   LAST_SIGNAL
67 };
68
69 enum
70 {
71   ARG_0,
72   /* FILL ME */
73 };
74
75 static void gst_videotemplate_base_init (gpointer g_class);
76 static void gst_videotemplate_class_init (gpointer g_class,
77     gpointer class_data);
78 static void gst_videotemplate_init (GTypeInstance * instance, gpointer g_class);
79
80 static void gst_videotemplate_set_property (GObject * object, guint prop_id,
81     const GValue * value, GParamSpec * pspec);
82 static void gst_videotemplate_get_property (GObject * object, guint prop_id,
83     GValue * value, GParamSpec * pspec);
84
85 static void gst_videotemplate_planar411 (GstVideofilter * videofilter,
86     void *dest, void *src);
87 static void gst_videotemplate_setup (GstVideofilter * videofilter);
88
89 GType
90 gst_videotemplate_get_type (void)
91 {
92   static GType videotemplate_type = 0;
93
94   if (!videotemplate_type) {
95     static const GTypeInfo videotemplate_info = {
96       sizeof (GstVideotemplateClass),
97       gst_videotemplate_base_init,
98       NULL,
99       gst_videotemplate_class_init,
100       NULL,
101       NULL,
102       sizeof (GstVideotemplate),
103       0,
104       gst_videotemplate_init,
105     };
106     videotemplate_type = g_type_register_static (GST_TYPE_VIDEOFILTER,
107         "GstVideotemplate", &videotemplate_info, 0);
108   }
109   return videotemplate_type;
110 }
111
112 static GstVideofilterFormat gst_videotemplate_formats[] = {
113   {"I420", 12, gst_videotemplate_planar411,},
114 };
115
116
117 static void
118 gst_videotemplate_base_init (gpointer g_class)
119 {
120   static GstElementDetails videotemplate_details =
121       GST_ELEMENT_DETAILS ("Video Filter Template",
122       "Filter/Effect/Video",
123       "Template for a video filter",
124       "David Schleef <ds@schleef.org>");
125   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
126   GstVideofilterClass *videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
127   int i;
128
129   gst_element_class_set_details (element_class, &videotemplate_details);
130
131   for (i = 0; i < G_N_ELEMENTS (gst_videotemplate_formats); i++) {
132     gst_videofilter_class_add_format (videofilter_class,
133         gst_videotemplate_formats + i);
134   }
135
136   gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
137 }
138
139 static void
140 gst_videotemplate_class_init (gpointer g_class, gpointer class_data)
141 {
142   GObjectClass *gobject_class;
143   GstVideofilterClass *videofilter_class;
144
145   gobject_class = G_OBJECT_CLASS (g_class);
146   videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
147
148 #if 0
149   g_object_class_install_property (gobject_class, ARG_METHOD,
150       g_param_spec_enum ("method", "method", "method",
151           GST_TYPE_VIDEOTEMPLATE_METHOD, GST_VIDEOTEMPLATE_METHOD_1,
152           G_PARAM_READWRITE));
153 #endif
154
155   gobject_class->set_property = gst_videotemplate_set_property;
156   gobject_class->get_property = gst_videotemplate_get_property;
157
158   videofilter_class->setup = gst_videotemplate_setup;
159 }
160
161 static void
162 gst_videotemplate_init (GTypeInstance * instance, gpointer g_class)
163 {
164   GstVideotemplate *videotemplate = GST_VIDEOTEMPLATE (instance);
165   GstVideofilter *videofilter;
166
167   GST_DEBUG ("gst_videotemplate_init");
168
169   videofilter = GST_VIDEOFILTER (videotemplate);
170
171   /* do stuff */
172 }
173
174 static void
175 gst_videotemplate_set_property (GObject * object, guint prop_id,
176     const GValue * value, GParamSpec * pspec)
177 {
178   GstVideotemplate *src;
179
180   /* it's not null if we got it, but it might not be ours */
181   g_return_if_fail (GST_IS_VIDEOTEMPLATE (object));
182   src = GST_VIDEOTEMPLATE (object);
183
184   GST_DEBUG ("gst_videotemplate_set_property");
185   switch (prop_id) {
186 #if 0
187     case ARG_METHOD:
188       src->method = g_value_get_enum (value);
189       break;
190 #endif
191     default:
192       break;
193   }
194 }
195
196 static void
197 gst_videotemplate_get_property (GObject * object, guint prop_id, GValue * value,
198     GParamSpec * pspec)
199 {
200   GstVideotemplate *src;
201
202   /* it's not null if we got it, but it might not be ours */
203   g_return_if_fail (GST_IS_VIDEOTEMPLATE (object));
204   src = GST_VIDEOTEMPLATE (object);
205
206   switch (prop_id) {
207 #if 0
208     case ARG_METHOD:
209       g_value_set_enum (value, src->method);
210       break;
211 #endif
212     default:
213       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
214       break;
215   }
216 }
217
218 static gboolean
219 plugin_init (GstPlugin * plugin)
220 {
221   if (!gst_library_load ("gstvideofilter"))
222     return FALSE;
223
224   return gst_element_register (plugin, "videotemplate", GST_RANK_NONE,
225       GST_TYPE_VIDEOTEMPLATE);
226 }
227
228 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
229     GST_VERSION_MINOR,
230     "videotemplate",
231     "Template for a video filter",
232     plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
233
234      static void gst_videotemplate_setup (GstVideofilter * videofilter)
235 {
236   GstVideotemplate *videotemplate;
237
238   g_return_if_fail (GST_IS_VIDEOTEMPLATE (videofilter));
239   videotemplate = GST_VIDEOTEMPLATE (videofilter);
240
241   /* if any setup needs to be done, do it here */
242
243 }
244
245 static void
246 gst_videotemplate_planar411 (GstVideofilter * videofilter,
247     void *dest, void *src)
248 {
249   GstVideotemplate *videotemplate;
250   int width = gst_videofilter_get_input_width (videofilter);
251   int height = gst_videofilter_get_input_height (videofilter);
252
253   g_return_if_fail (GST_IS_VIDEOTEMPLATE (videofilter));
254   videotemplate = GST_VIDEOTEMPLATE (videofilter);
255
256   /* do something interesting here.  This simply copies the source
257    * to the destination. */
258   memcpy (dest, src, width * height + (width / 2) * (height / 2) * 2);
259 }