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>
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.
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.
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.
27 #include "gstgdkpixbufdec.h"
30 #include "gstgdkpixbufoverlay.h"
31 #include "gstgdkpixbufsink.h"
36 static void gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore);
38 #define GST_GDK_PIXBUF_TYPE_FIND_SIZE 1024
41 gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore)
44 GdkPixbufLoader *pixbuf_loader;
45 GdkPixbufFormat *format;
47 data = gst_type_find_peek (tf, 0, GST_GDK_PIXBUF_TYPE_FIND_SIZE);
51 GST_DEBUG ("creating new loader");
53 pixbuf_loader = gdk_pixbuf_loader_new ();
55 gdk_pixbuf_loader_write (pixbuf_loader, data, GST_GDK_PIXBUF_TYPE_FIND_SIZE,
58 format = gdk_pixbuf_loader_get_format (pixbuf_loader);
63 gchar **mlist = gdk_pixbuf_format_get_mime_types (format);
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);
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
78 gdk_pixbuf_loader_close (pixbuf_loader, NULL);
79 GST_DEBUG ("closed pixbuf loader");
80 g_object_unref (G_OBJECT (pixbuf_loader));
85 plugin_init (GstPlugin * plugin)
87 if (!gst_element_register (plugin, "gdkpixbufdec", GST_RANK_SECONDARY,
88 GST_TYPE_GDK_PIXBUF_DEC))
92 gst_type_find_register (plugin, "image/*", GST_RANK_MARGINAL,
93 gst_gdk_pixbuf_type_find, NULL, GST_CAPS_ANY, NULL);
97 if (!gst_element_register (plugin, "gdkpixbufoverlay", GST_RANK_NONE,
98 GST_TYPE_GDK_PIXBUF_OVERLAY))
103 if (!gst_element_register (plugin, "gdkpixbufsink", GST_RANK_NONE,
104 GST_TYPE_GDK_PIXBUF_SINK))
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,
117 "GdkPixbuf-based image decoder, overlay and sink",
118 plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)