gdkpixbuf: re-enable already-ported gdkpixbuf element as gdkpixbufdec
[platform/upstream/gstreamer.git] / ext / gdk_pixbuf / gstgdkpixbufplugin.c
1 /* GStreamer GdkPixbuf plugin
2  * Copyright (C) 1999-2001 Erik Walthinsen <omega@cse.ogi.edu>
3  * Copyright (C) 2003 David A. 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 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include <gst/gst.h>
26
27 #include "gstgdkpixbufdec.h"
28
29 #if 0
30 #include "gstgdkpixbufoverlay.h"
31 #include "gstgdkpixbufsink.h"
32 #endif
33
34
35 #if 0
36 static void gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore);
37
38 #define GST_GDK_PIXBUF_TYPE_FIND_SIZE 1024
39
40 static void
41 gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore)
42 {
43   guint8 *data;
44   GdkPixbufLoader *pixbuf_loader;
45   GdkPixbufFormat *format;
46
47   data = gst_type_find_peek (tf, 0, GST_GDK_PIXBUF_TYPE_FIND_SIZE);
48   if (data == NULL)
49     return;
50
51   GST_DEBUG ("creating new loader");
52
53   pixbuf_loader = gdk_pixbuf_loader_new ();
54
55   gdk_pixbuf_loader_write (pixbuf_loader, data, GST_GDK_PIXBUF_TYPE_FIND_SIZE,
56       NULL);
57
58   format = gdk_pixbuf_loader_get_format (pixbuf_loader);
59
60   if (format != NULL) {
61     GstCaps *caps;
62     gchar **p;
63     gchar **mlist = gdk_pixbuf_format_get_mime_types (format);
64
65     for (p = mlist; *p; ++p) {
66       GST_DEBUG ("suggesting mime type %s", *p);
67       caps = gst_caps_new_simple (*p, NULL);
68       gst_type_find_suggest (tf, GST_TYPE_FIND_MINIMUM, caps);
69       gst_caps_free (caps);
70     }
71     g_strfreev (mlist);
72   }
73
74   GST_DEBUG ("closing pixbuf loader, hope it doesn't hang ...");
75   /* librsvg 2.4.x has a bug where it triggers an endless loop in trying
76      to close a gzip that's not an svg; fixed upstream but no good way
77      to work around it */
78   gdk_pixbuf_loader_close (pixbuf_loader, NULL);
79   GST_DEBUG ("closed pixbuf loader");
80   g_object_unref (G_OBJECT (pixbuf_loader));
81 }
82 #endif
83
84 static gboolean
85 plugin_init (GstPlugin * plugin)
86 {
87   if (!gst_element_register (plugin, "gdkpixbufdec", GST_RANK_SECONDARY,
88           GST_TYPE_GDK_PIXBUF_DEC))
89     return FALSE;
90
91 #if 0
92   gst_type_find_register (plugin, "image/*", GST_RANK_MARGINAL,
93       gst_gdk_pixbuf_type_find, NULL, GST_CAPS_ANY, NULL);
94 #endif
95
96 #if 0
97   if (!gst_element_register (plugin, "gdkpixbufoverlay", GST_RANK_NONE,
98           GST_TYPE_GDK_PIXBUF_OVERLAY))
99     return FALSE;
100 #endif
101
102 #if 0
103   if (!gst_element_register (plugin, "gdkpixbufsink", GST_RANK_NONE,
104           GST_TYPE_GDK_PIXBUF_SINK))
105     return FALSE;
106 #endif
107
108   return TRUE;
109 }
110
111
112 /* this is the structure that gst-register looks for
113  * so keep the name plugin_desc, or you cannot get your plug-in registered */
114 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
115     GST_VERSION_MINOR,
116     gdkpixbuf,
117     "GdkPixbuf-based image decoder, overlay and sink",
118     plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)