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