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., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, 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 #include "gstgdkpixbufoverlay.h"
29 #include "gstgdkpixbufsink.h"
30
31
32 #if 0
33 static void gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore);
34
35 #define GST_GDK_PIXBUF_TYPE_FIND_SIZE 1024
36
37 static void
38 gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore)
39 {
40 guint8 *data;
41 GdkPixbufLoader *pixbuf_loader;
42 GdkPixbufFormat *format;
43
44 data = gst_type_find_peek (tf, 0, GST_GDK_PIXBUF_TYPE_FIND_SIZE);
45 if (data == NULL)
46 return;
47
48 GST_DEBUG ("creating new loader");
49
50 pixbuf_loader = gdk_pixbuf_loader_new ();
51
52 gdk_pixbuf_loader_write (pixbuf_loader, data, GST_GDK_PIXBUF_TYPE_FIND_SIZE,
53 NULL);
54
55 format = gdk_pixbuf_loader_get_format (pixbuf_loader);
56
57 if (format != NULL) {
58 GstCaps *caps;
59 gchar **p;
60 gchar **mlist = gdk_pixbuf_format_get_mime_types (format);
61
62 for (p = mlist; *p; ++p) {
63 GST_DEBUG ("suggesting mime type %s", *p);
64 caps = gst_caps_new_simple (*p, NULL);
65 gst_type_find_suggest (tf, GST_TYPE_FIND_MINIMUM, caps);
66 gst_caps_free (caps);
67 }
68 g_strfreev (mlist);
69 }
70
71 GST_DEBUG ("closing pixbuf loader, hope it doesn't hang ...");
72 /* librsvg 2.4.x has a bug where it triggers an endless loop in trying
73 to close a gzip that's not an svg; fixed upstream but no good way
74 to work around it */
75 gdk_pixbuf_loader_close (pixbuf_loader, NULL);
76 GST_DEBUG ("closed pixbuf loader");
77 g_object_unref (G_OBJECT (pixbuf_loader));
78 }
79 #endif
80
81 static gboolean
plugin_init(GstPlugin * plugin)82 plugin_init (GstPlugin * plugin)
83 {
84 if (!gst_element_register (plugin, "gdkpixbufdec", GST_RANK_SECONDARY,
85 GST_TYPE_GDK_PIXBUF_DEC))
86 return FALSE;
87
88 #if 0
89 gst_type_find_register (plugin, "image/*", GST_RANK_MARGINAL,
90 gst_gdk_pixbuf_type_find, NULL, GST_CAPS_ANY, NULL);
91 #endif
92
93 if (!gst_element_register (plugin, "gdkpixbufoverlay", GST_RANK_NONE,
94 GST_TYPE_GDK_PIXBUF_OVERLAY))
95 return FALSE;
96
97 if (!gst_element_register (plugin, "gdkpixbufsink", GST_RANK_NONE,
98 GST_TYPE_GDK_PIXBUF_SINK))
99 return FALSE;
100
101 return TRUE;
102 }
103
104 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
105 GST_VERSION_MINOR,
106 gdkpixbuf,
107 "GdkPixbuf-based image decoder, overlay and sink",
108 plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
109