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