diff options
author | David Schleef <ds@schleef.org> | 2003-10-29 05:40:48 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2003-10-29 05:40:48 +0000 |
commit | c19bc2bfe14372ec31d1886a0a7c9c32264a95d8 (patch) | |
tree | 663fe86d1dd7f338d8b16291cc0e696ee9c1cb82 /ext/gdk_pixbuf/gstgdkpixbuf.c | |
parent | dc555da5f8ff6cdbd07d999a7c35e0ea293faa37 (diff) |
Create type find function for gdk_pixbuf
Original commit message from CVS:
Create type find function for gdk_pixbuf
Diffstat (limited to 'ext/gdk_pixbuf/gstgdkpixbuf.c')
-rw-r--r-- | ext/gdk_pixbuf/gstgdkpixbuf.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ext/gdk_pixbuf/gstgdkpixbuf.c b/ext/gdk_pixbuf/gstgdkpixbuf.c index b5f42bd1..2368769f 100644 --- a/ext/gdk_pixbuf/gstgdkpixbuf.c +++ b/ext/gdk_pixbuf/gstgdkpixbuf.c @@ -107,6 +107,7 @@ static void gst_gdk_pixbuf_get_property(GObject *object, guint prop_id, GParamSpec *pspec); static void gst_gdk_pixbuf_chain (GstPad *pad, GstData *_data); +static void gst_gdk_pixbuf_type_find (GstTypeFind *tf, gpointer ignore); static GstElementClass *parent_class = NULL; @@ -365,6 +366,38 @@ gst_gdk_pixbuf_get_property (GObject *object, guint prop_id, } } +#define GST_GDK_PIXBUF_TYPE_FIND_SIZE 1024 + +static void +gst_gdk_pixbuf_type_find (GstTypeFind *tf, gpointer ignore) +{ + guint8 *data; + GdkPixbufLoader *pixbuf_loader; + GdkPixbufFormat *format; + GError *error = NULL; + + data = gst_type_find_peek (tf, 0, GST_GDK_PIXBUF_TYPE_FIND_SIZE); + if (data == NULL) return; + + GST_DEBUG ("gst_gdk_pixbuf_type_find"); + + pixbuf_loader = gdk_pixbuf_loader_new(); + + gdk_pixbuf_loader_write (pixbuf_loader, data, GST_GDK_PIXBUF_TYPE_FIND_SIZE, + &error); + + format = gdk_pixbuf_loader_get_format (pixbuf_loader); + + if (format != NULL) { + gchar **mlist = gdk_pixbuf_format_get_mime_types(format); + + gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, + gst_caps_new ("gdk_pixbuf_type_find", mlist[0], NULL)); + } + + g_object_unref (G_OBJECT (pixbuf_loader)); +} + /* entry point to initialize the plug-in * initialize the plug-in itself * register the element factories and pad templates @@ -386,6 +419,9 @@ plugin_init (GModule *module, GstPlugin *plugin) gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); + gst_type_find_factory_register (plugin, "image/*", GST_ELEMENT_RANK_MARGINAL, + gst_gdk_pixbuf_type_find, NULL, GST_CAPS_ANY, NULL); + /* plugin initialisation succeeded */ return TRUE; } |