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 "gstgdkpixbufelements.h"
28
29 #if 0
30 static void gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore);
31
32 #define GST_GDK_PIXBUF_TYPE_FIND_SIZE 1024
33
34 static void
35 gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore)
36 {
37 guint8 *data;
38 GdkPixbufLoader *pixbuf_loader;
39 GdkPixbufFormat *format;
40
41 data = gst_type_find_peek (tf, 0, GST_GDK_PIXBUF_TYPE_FIND_SIZE);
42 if (data == NULL)
43 return;
44
45 GST_DEBUG ("creating new loader");
46
47 pixbuf_loader = gdk_pixbuf_loader_new ();
48
49 gdk_pixbuf_loader_write (pixbuf_loader, data, GST_GDK_PIXBUF_TYPE_FIND_SIZE,
50 NULL);
51
52 format = gdk_pixbuf_loader_get_format (pixbuf_loader);
53
54 if (format != NULL) {
55 GstCaps *caps;
56 gchar **p;
57 gchar **mlist = gdk_pixbuf_format_get_mime_types (format);
58
59 for (p = mlist; *p; ++p) {
60 GST_DEBUG ("suggesting mime type %s", *p);
61 caps = gst_caps_new_simple (*p, NULL);
62 gst_type_find_suggest (tf, GST_TYPE_FIND_MINIMUM, caps);
63 gst_caps_free (caps);
64 }
65 g_strfreev (mlist);
66 }
67
68 GST_DEBUG ("closing pixbuf loader, hope it doesn't hang ...");
69 /* librsvg 2.4.x has a bug where it triggers an endless loop in trying
70 to close a gzip that's not an svg; fixed upstream but no good way
71 to work around it */
72 gdk_pixbuf_loader_close (pixbuf_loader, NULL);
73 GST_DEBUG ("closed pixbuf loader");
74 g_object_unref (G_OBJECT (pixbuf_loader));
75 }
76 #endif
77
78 void
gdk_pixbuf_element_init(GstPlugin * plugin)79 gdk_pixbuf_element_init (GstPlugin * plugin)
80 {
81 static gsize res = FALSE;
82 if (g_once_init_enter (&res)) {
83 #if 0
84 gst_type_find_register (plugin, "image/*", GST_RANK_MARGINAL,
85 gst_gdk_pixbuf_type_find, NULL, GST_CAPS_ANY, NULL);
86 #endif
87 g_once_init_leave (&res, TRUE);
88 }
89 }
90