Some cleanups ported the über cool warp plugin.
[platform/upstream/gst-plugins-good.git] / gst / effectv / gsteffectv.c
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * EffecTV:
5  * Copyright (C) 2001 FUKUCHI Kentarou
6  *
7  * EffecTV is free software. We release this product under the terms of the
8  * GNU General Public License version 2. The license is included in the file
9  * COPYING.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13  * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14  */
15
16 #include <string.h>
17 #include <gst/gst.h>
18 #include "gsteffectv.h"
19
20
21 struct _elements_entry {
22   gchar *name;
23   GType (*type) (void);
24   GstElementDetails *details;
25   gboolean (*factoryinit) (GstElementFactory *factory);
26 };
27
28 static struct _elements_entry _elements[] = {
29   { "edgeTV",  gst_edgetv_get_type,  &gst_edgetv_details,  NULL },
30   { "agingTV", gst_agingtv_get_type, &gst_agingtv_details, NULL },
31   { "diceTV",  gst_dicetv_get_type,  &gst_dicetv_details,  NULL },
32   { "warpTV",  gst_warptv_get_type,  &gst_warptv_details,  NULL },
33   { NULL, 0 },
34 };
35
36
37 GstPadTemplate* 
38 gst_effectv_src_factory (void)
39 {
40   static GstPadTemplate *templ = NULL;
41   if (!templ) {
42     templ = GST_PAD_TEMPLATE_NEW ( 
43                 "src",
44                 GST_PAD_SRC,
45                 GST_PAD_ALWAYS,
46                 GST_CAPS_NEW (
47                   "effectv_src",
48                   "video/raw",
49                     "format",         GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")),
50                     "bpp",            GST_PROPS_INT (32),
51                     "depth",          GST_PROPS_INT (32),
52                     "endianness",     GST_PROPS_INT (G_BYTE_ORDER),
53                     "red_mask",       GST_PROPS_INT (0xff0000),
54                     "green_mask",     GST_PROPS_INT (0xff00),
55                     "blue_mask",      GST_PROPS_INT (0xff),
56                     "width",          GST_PROPS_INT_RANGE (16, 4096),
57                     "height",         GST_PROPS_INT_RANGE (16, 4096)
58                 )
59              );
60   }
61   return templ;
62 }
63
64 GstPadTemplate* 
65 gst_effectv_sink_factory (void)
66 {
67   static GstPadTemplate *templ = NULL;
68   if (!templ) {
69     templ = GST_PAD_TEMPLATE_NEW ( 
70                 "sink",
71                 GST_PAD_SINK,
72                 GST_PAD_ALWAYS,
73                 GST_CAPS_NEW (
74                   "effectv_sink",
75                   "video/raw",
76                     "format",         GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")),
77                     "bpp",            GST_PROPS_INT (32),
78                     "depth",          GST_PROPS_INT (32),
79                     "endianness",     GST_PROPS_INT (G_BYTE_ORDER),
80                     "red_mask",       GST_PROPS_INT (0xff0000),
81                     "green_mask",     GST_PROPS_INT (0xff00),
82                     "blue_mask",      GST_PROPS_INT (0xff),
83                     "width",          GST_PROPS_INT_RANGE (16, 4096),
84                     "height",         GST_PROPS_INT_RANGE (16, 4096)
85                 )
86              );
87   }
88   return templ;
89 }
90
91 static gboolean
92 plugin_init (GModule * module, GstPlugin * plugin)
93 {
94   GstElementFactory *factory;
95   gint i = 0;
96
97   while (_elements[i].name) {
98     factory = gst_element_factory_new (_elements[i].name,
99                                       (_elements[i].type) (),
100                                        _elements[i].details);
101
102     if (!factory) {
103       g_warning ("gst_effecttv_new failed for `%s'",
104                  _elements[i].name);
105       continue;
106     }
107     gst_element_factory_add_pad_template (factory, gst_effectv_src_factory ());
108     gst_element_factory_add_pad_template (factory, gst_effectv_sink_factory ());
109
110     gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
111     if (_elements[i].factoryinit) {
112       _elements[i].factoryinit (factory);
113     }
114     i++;
115   }
116
117   return TRUE;
118 }
119
120 GstPluginDesc plugin_desc = {
121   GST_VERSION_MAJOR,
122   GST_VERSION_MINOR,
123   "effectv",
124   plugin_init
125 };