should work with avifile too some cleanup ( video/png, ... )
[platform/upstream/gst-plugins-good.git] / ext / libpng / gstpng.c
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * Filter:
5  * Copyright (C) 2000 Donald A. Graft
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  * Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU Library General Public
13  * License along with this library; if not, write to the
14  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
15  * Boston, MA 02111-1307, USA.
16  *
17  */
18
19 #include <string.h>
20 #include <gst/gst.h>
21
22 #include "gstpngenc.h"
23
24 extern GstElementDetails gst_pngenc_details;
25
26 static GstCaps*
27 png_caps_factory (void)
28 {
29   return gst_caps_new ( "png_png", "video/png", NULL);
30 }
31
32
33 static GstCaps*
34 raw_caps_factory (void)
35
36   return gst_caps_new ( "png_raw", 
37                         "video/raw",
38                          gst_props_new (
39                           "format",         GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")),
40                           "bpp",            GST_PROPS_INT (24),
41                           "red_mask",       GST_PROPS_INT (0xff),
42                           "green_mask",     GST_PROPS_INT (0xff00),
43                           "blue_mask",      GST_PROPS_INT (0xff0000),
44                           "width",          GST_PROPS_INT_RANGE (16, 4096),
45                           "height",         GST_PROPS_INT_RANGE (16, 4096),
46                           NULL )
47                      );
48 }
49
50 static gboolean
51 plugin_init (GModule * module, GstPlugin * plugin)
52 {
53   GstElementFactory *png_enc;
54   GstCaps *raw_caps, *png_caps;
55
56   /* create an elementfactory for the jpegdec element */
57   png_enc = gst_element_factory_new("pngenc", GST_TYPE_PNGENC, &gst_pngenc_details);
58   g_return_val_if_fail(png_enc != NULL, FALSE);
59
60   raw_caps = raw_caps_factory ();
61   png_caps = png_caps_factory ();
62
63   /* register sink pads */
64   pngenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
65                                                        GST_PAD_ALWAYS,
66                                                        raw_caps, NULL);
67   gst_element_factory_add_pad_template (png_enc, pngenc_sink_template);
68   
69
70   /* register src pads */
71   pngenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
72                                                      GST_PAD_ALWAYS,
73                                                      png_caps, NULL);
74   gst_element_factory_add_pad_template (png_enc, pngenc_src_template);
75   
76   gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (png_enc));
77   
78   return TRUE;
79 }
80
81 GstPluginDesc plugin_desc = {
82   GST_VERSION_MAJOR,
83   GST_VERSION_MINOR,
84   "png",
85   plugin_init
86 };