2006-04-18 18:04:48 +00:00
|
|
|
/* GStreamer GdkPixbuf-based image decoder
|
2003-06-25 03:17:35 +00:00
|
|
|
* Copyright (C) 1999-2001 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* Copyright (C) 2003 David A. Schleef <ds@schleef.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2003-06-25 03:17:35 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2003-12-22 01:47:09 +00:00
|
|
|
#include <gst/video/video.h>
|
2003-06-25 03:17:35 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "gstgdkpixbuf.h"
|
|
|
|
|
2004-02-18 16:44:51 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_gdk_pixbuf_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_gdk_pixbuf_debug
|
|
|
|
|
2006-04-18 18:04:48 +00:00
|
|
|
static const GstElementDetails plugin_details =
|
2006-03-30 15:37:05 +00:00
|
|
|
GST_ELEMENT_DETAILS ("GdkPixbuf image decoder",
|
|
|
|
"Codec/Decoder/Image",
|
|
|
|
"Decodes images in a video stream using GdkPixbuf",
|
|
|
|
"David A. Schleef <ds@schleef.org>, Renato Filho <renato.filho@indt.org.br>");
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-06-25 03:17:35 +00:00
|
|
|
ARG_0,
|
2006-04-18 17:29:42 +00:00
|
|
|
ARG_SILENT /* FIXME 0.11: remove */
|
2003-06-25 03:17:35 +00:00
|
|
|
};
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate gst_gdk_pixbuf_sink_template =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("image/png; "
|
2006-04-18 18:14:34 +00:00
|
|
|
/* "image/jpeg; " disabled because we can't handle MJPEG */
|
2004-03-15 19:32:27 +00:00
|
|
|
"image/gif; "
|
|
|
|
"image/x-icon; "
|
|
|
|
"application/x-navi-animation; "
|
|
|
|
"image/x-cmu-raster; "
|
|
|
|
"image/x-sun-raster; "
|
|
|
|
"image/x-pixmap; "
|
|
|
|
"image/tiff; "
|
|
|
|
"image/x-portable-anymap; "
|
|
|
|
"image/x-portable-bitmap; "
|
|
|
|
"image/x-portable-graymap; "
|
|
|
|
"image/x-portable-pixmap; "
|
|
|
|
"image/bmp; "
|
|
|
|
"image/x-bmp; "
|
|
|
|
"image/x-MS-bmp; "
|
2004-07-12 13:49:35 +00:00
|
|
|
"image/vnd.wap.wbmp; " "image/x-bitmap; " "image/x-tga; "
|
|
|
|
"image/x-pcx; image/svg; image/svg+xml")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate gst_gdk_pixbuf_src_template =
|
2006-04-12 09:42:10 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2006-04-12 09:42:10 +00:00
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB "; " GST_VIDEO_CAPS_RGBA)
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
|
|
|
|
2004-05-15 12:09:12 +00:00
|
|
|
gboolean pixbufscale_init (GstPlugin * plugin);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_gdk_pixbuf_base_init (gpointer g_class);
|
|
|
|
static void gst_gdk_pixbuf_class_init (GstGdkPixbufClass * klass);
|
2006-02-24 19:51:29 +00:00
|
|
|
static void gst_gdk_pixbuf_init (GstGdkPixbuf * filter,
|
|
|
|
GstGdkPixbufClass * klass);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
static void gst_gdk_pixbuf_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_gdk_pixbuf_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
static GstFlowReturn gst_gdk_pixbuf_chain (GstPad * pad, GstBuffer * buffer);
|
2006-04-12 09:42:10 +00:00
|
|
|
static gboolean gst_gdk_pixbuf_sink_event (GstPad * pad, GstEvent * event);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-02-19 02:55:21 +00:00
|
|
|
#ifdef enable_typefind
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore);
|
2004-02-19 02:55:21 +00:00
|
|
|
#endif
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2006-04-18 18:04:48 +00:00
|
|
|
GST_BOILERPLATE (GstGdkPixbuf, gst_gdk_pixbuf, GstElement, GST_TYPE_ELEMENT);
|
2006-02-24 19:51:29 +00:00
|
|
|
|
2006-04-18 18:04:48 +00:00
|
|
|
static gboolean
|
|
|
|
gst_gdk_pixbuf_sink_setcaps (GstPad * pad, GstCaps * caps)
|
2003-06-25 03:17:35 +00:00
|
|
|
{
|
|
|
|
GstGdkPixbuf *filter;
|
2006-02-24 19:51:29 +00:00
|
|
|
const GValue *framerate;
|
|
|
|
GstStructure *s;
|
2003-06-25 03:17:35 +00:00
|
|
|
|
|
|
|
filter = GST_GDK_PIXBUF (gst_pad_get_parent (pad));
|
2006-02-24 19:51:29 +00:00
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
filter->framerate_numerator = 0;
|
|
|
|
filter->framerate_denominator = 1;
|
|
|
|
if ((framerate = gst_structure_get_value (s, "framerate")) != NULL) {
|
|
|
|
filter->framerate_numerator = gst_value_get_fraction_numerator (framerate);
|
|
|
|
filter->framerate_denominator =
|
|
|
|
gst_value_get_fraction_denominator (framerate);
|
|
|
|
GST_DEBUG ("got framerate of %d/%d fps => packetized mode",
|
|
|
|
filter->framerate_numerator, filter->framerate_denominator);
|
|
|
|
}
|
close #333784 unref the result of gst_pad_get_parent() by: Christophe Fergeau.
Original commit message from CVS:
* ext/cairo/gsttextoverlay.c: (gst_text_overlay_setcaps):
* ext/esd/esdmon.c: (gst_esdmon_get):
* ext/flac/gstflactag.c: (gst_flac_tag_chain):
* ext/gdk_pixbuf/gstgdkpixbuf.c: (gst_gdk_pixbuf_sink_setcaps),
(gst_gdk_pixbuf_sink_getcaps):
* ext/jpeg/gstjpegenc.c: (gst_jpegenc_getcaps),
(gst_jpegenc_setcaps):
* ext/jpeg/gstsmokedec.c: (gst_smokedec_chain):
* ext/jpeg/gstsmokeenc.c: (gst_smokeenc_getcaps),
(gst_smokeenc_setcaps):
* ext/libmng/gstmngdec.c: (gst_mngdec_sinklink),
(gst_mngdec_src_getcaps):
* ext/libmng/gstmngenc.c: (gst_mngenc_sinklink),
(gst_mngenc_chain):
* ext/libpng/gstpngenc.c: (gst_pngenc_setcaps):
* ext/mikmod/gstmikmod.c: (gst_mikmod_srclink):
* ext/speex/gstspeexdec.c: (speex_dec_convert),
(speex_dec_src_event), (speex_dec_chain):
* gst/avi/gstavimux.c: (gst_avimux_vidsinkconnect),
(gst_avimux_audsinkconnect), (gst_avimux_handle_event):
* gst/debug/negotiation.c: (gst_negotiation_getcaps),
(gst_negotiation_pad_link), (gst_negotiation_chain):
* gst/flx/gstflxdec.c: (gst_flxdec_src_query_handler),
(gst_flxdec_chain):
* gst/interleave/deinterleave.c: (deinterleave_sink_link),
(deinterleave_chain):
* gst/law/mulaw-encode.c: (mulawenc_setcaps):
* gst/median/gstmedian.c: (gst_median_link):
* gst/monoscope/gstmonoscope.c: (gst_monoscope_srcconnect),
(gst_monoscope_chain):
* gst/rtp/gstrtpL16pay.c: (gst_rtpL16pay_sinkconnect):
* gst/wavenc/gstwavenc.c: (gst_wavenc_sink_setcaps):
* sys/osxaudio/gstosxaudiosink.c: (gst_osxaudiosink_chain):
* sys/osxaudio/gstosxaudiosrc.c: (gst_osxaudiosrc_get):
close #333784 unref the result of gst_pad_get_parent()
by: Christophe Fergeau.
2006-03-13 15:49:08 +00:00
|
|
|
gst_object_unref (filter);
|
2006-04-12 09:42:10 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
return TRUE;
|
2003-06-25 03:17:35 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_gdk_pixbuf_get_capslist (void)
|
2003-06-25 03:17:35 +00:00
|
|
|
{
|
|
|
|
GSList *slist;
|
|
|
|
GSList *slist0;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstCaps *capslist = NULL;
|
2004-07-12 13:49:35 +00:00
|
|
|
GstCaps *return_caps = NULL;
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
capslist = gst_caps_new_empty ();
|
2004-03-14 22:34:33 +00:00
|
|
|
slist0 = gdk_pixbuf_get_formats ();
|
2003-12-22 01:47:09 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
for (slist = slist0; slist; slist = g_slist_next (slist)) {
|
2006-04-12 09:42:10 +00:00
|
|
|
GdkPixbufFormat *pixbuf_format;
|
|
|
|
char **mimetypes;
|
|
|
|
char **mimetype;
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
pixbuf_format = slist->data;
|
2004-03-14 22:34:33 +00:00
|
|
|
mimetypes = gdk_pixbuf_format_get_mime_types (pixbuf_format);
|
2006-04-12 09:42:10 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
for (mimetype = mimetypes; *mimetype; mimetype++) {
|
|
|
|
gst_caps_append_structure (capslist, gst_structure_new (*mimetype, NULL));
|
2003-12-22 01:47:09 +00:00
|
|
|
}
|
2006-04-12 09:42:10 +00:00
|
|
|
g_strfreev (mimetypes);
|
2003-06-25 03:17:35 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
g_slist_free (slist0);
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2004-07-12 13:49:35 +00:00
|
|
|
return_caps = gst_caps_intersect (capslist,
|
|
|
|
gst_static_caps_get (&gst_gdk_pixbuf_sink_template.static_caps));
|
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
gst_caps_unref (capslist);
|
2004-07-12 13:49:35 +00:00
|
|
|
return return_caps;
|
2003-06-25 03:17:35 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_gdk_pixbuf_sink_getcaps (GstPad * pad)
|
2003-06-25 03:17:35 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
return gst_gdk_pixbuf_get_capslist ();
|
2003-06-25 03:17:35 +00:00
|
|
|
}
|
|
|
|
|
2003-11-01 16:18:43 +00:00
|
|
|
static void
|
|
|
|
gst_gdk_pixbuf_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_static_pad_template_get (&gst_gdk_pixbuf_src_template));
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_static_pad_template_get (&gst_gdk_pixbuf_sink_template));
|
2003-11-01 16:18:43 +00:00
|
|
|
gst_element_class_set_details (element_class, &plugin_details);
|
|
|
|
}
|
|
|
|
|
2003-06-25 03:17:35 +00:00
|
|
|
/* initialize the plugin's class */
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_gdk_pixbuf_class_init (GstGdkPixbufClass * klass)
|
2003-06-25 03:17:35 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
gobject_class->set_property = gst_gdk_pixbuf_set_property;
|
|
|
|
gobject_class->get_property = gst_gdk_pixbuf_get_property;
|
|
|
|
|
2003-06-25 03:17:35 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_SILENT,
|
2006-04-12 09:42:10 +00:00
|
|
|
g_param_spec_boolean ("silent", "Silent",
|
|
|
|
"Produce verbose output ? (deprecated)", FALSE, G_PARAM_READWRITE));
|
2003-06-25 03:17:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-02-24 19:51:29 +00:00
|
|
|
gst_gdk_pixbuf_init (GstGdkPixbuf * filter, GstGdkPixbufClass * klass)
|
2003-06-25 03:17:35 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
filter->sinkpad =
|
2006-03-15 16:17:12 +00:00
|
|
|
gst_pad_new_from_static_template (&gst_gdk_pixbuf_sink_template, "sink");
|
2006-04-18 18:04:48 +00:00
|
|
|
gst_pad_set_setcaps_function (filter->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_gdk_pixbuf_sink_setcaps));
|
|
|
|
gst_pad_set_getcaps_function (filter->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_gdk_pixbuf_sink_getcaps));
|
|
|
|
gst_pad_set_chain_function (filter->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_gdk_pixbuf_chain));
|
|
|
|
gst_pad_set_event_function (filter->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_gdk_pixbuf_sink_event));
|
2003-06-25 03:17:35 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
|
2006-02-24 19:51:29 +00:00
|
|
|
|
2006-03-15 16:17:12 +00:00
|
|
|
filter->srcpad =
|
|
|
|
gst_pad_new_from_static_template (&gst_gdk_pixbuf_src_template, "src");
|
2006-02-24 19:51:29 +00:00
|
|
|
gst_pad_use_fixed_caps (filter->srcpad);
|
2003-06-25 03:17:35 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
|
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
filter->last_timestamp = GST_CLOCK_TIME_NONE;
|
|
|
|
filter->pixbuf_loader = NULL;
|
2003-06-25 03:17:35 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_gdk_pixbuf_flush (GstGdkPixbuf * filter)
|
2003-06-25 03:17:35 +00:00
|
|
|
{
|
2006-02-24 19:51:29 +00:00
|
|
|
GstBuffer *outbuf;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
int y;
|
|
|
|
guint8 *out_pix;
|
|
|
|
guint8 *in_pix;
|
|
|
|
int in_rowstride;
|
|
|
|
GstFlowReturn ret;
|
|
|
|
GstCaps *caps = NULL;
|
2006-04-12 09:42:10 +00:00
|
|
|
gint n_channels;
|
2006-02-24 19:51:29 +00:00
|
|
|
|
|
|
|
pixbuf = gdk_pixbuf_loader_get_pixbuf (filter->pixbuf_loader);
|
2006-04-12 09:42:10 +00:00
|
|
|
if (pixbuf == NULL)
|
|
|
|
goto no_pixbuf;
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
if (filter->image_size == 0) {
|
|
|
|
filter->width = gdk_pixbuf_get_width (pixbuf);
|
|
|
|
filter->height = gdk_pixbuf_get_height (pixbuf);
|
|
|
|
filter->rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
|
|
|
filter->image_size = filter->rowstride * filter->height;
|
|
|
|
|
2006-04-12 09:42:10 +00:00
|
|
|
n_channels = gdk_pixbuf_get_n_channels (pixbuf);
|
|
|
|
switch (n_channels) {
|
|
|
|
case 3:
|
|
|
|
caps = gst_caps_from_string (GST_VIDEO_CAPS_RGB);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
caps = gst_caps_from_string (GST_VIDEO_CAPS_RGBA);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto channels_not_supported;
|
2004-01-12 03:21:40 +00:00
|
|
|
}
|
2006-04-12 09:42:10 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
gst_caps_set_simple (caps,
|
|
|
|
"width", G_TYPE_INT, filter->width,
|
|
|
|
"height", G_TYPE_INT, filter->height,
|
|
|
|
"framerate", GST_TYPE_FRACTION, filter->framerate_numerator,
|
|
|
|
filter->framerate_denominator, NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Set size to %dx%d", filter->width, filter->height);
|
|
|
|
gst_pad_set_caps (filter->srcpad, caps);
|
|
|
|
gst_caps_unref (caps);
|
2004-01-12 03:21:40 +00:00
|
|
|
}
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
ret = gst_pad_alloc_buffer_and_set_caps (filter->srcpad,
|
|
|
|
GST_BUFFER_OFFSET_NONE,
|
|
|
|
filter->image_size, GST_PAD_CAPS (filter->srcpad), &outbuf);
|
|
|
|
|
2006-04-12 09:42:10 +00:00
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto no_buffer;
|
2004-01-12 03:21:40 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = filter->last_timestamp;
|
|
|
|
GST_BUFFER_DURATION (outbuf) = GST_CLOCK_TIME_NONE;
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
in_pix = gdk_pixbuf_get_pixels (pixbuf);
|
|
|
|
in_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
|
|
|
out_pix = GST_BUFFER_DATA (outbuf);
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2006-04-12 09:42:10 +00:00
|
|
|
/* FIXME, last line might not have rowstride pixels */
|
2006-02-24 19:51:29 +00:00
|
|
|
for (y = 0; y < filter->height; y++) {
|
|
|
|
memcpy (out_pix, in_pix, filter->rowstride);
|
|
|
|
in_pix += in_rowstride;
|
|
|
|
out_pix += filter->rowstride;
|
|
|
|
}
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
GST_DEBUG ("pushing... %d bytes", GST_BUFFER_SIZE (outbuf));
|
|
|
|
return gst_pad_push (filter->srcpad, outbuf);
|
2006-04-12 09:42:10 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_pixbuf:
|
|
|
|
{
|
2006-04-18 18:04:48 +00:00
|
|
|
GST_ELEMENT_ERROR (filter, STREAM, DECODE, (NULL), ("error geting pixbuf"));
|
2006-04-12 09:42:10 +00:00
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
channels_not_supported:
|
|
|
|
{
|
2006-04-18 18:04:48 +00:00
|
|
|
GST_ELEMENT_ERROR (filter, STREAM, DECODE, (NULL),
|
2006-04-12 09:42:10 +00:00
|
|
|
("%d channels not supported", n_channels));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
no_buffer:
|
|
|
|
{
|
|
|
|
GST_DEBUG ("Failed to create outbuffer - %s", gst_flow_get_name (ret));
|
|
|
|
return ret;
|
|
|
|
}
|
2006-02-24 19:51:29 +00:00
|
|
|
}
|
2004-01-12 03:21:40 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
static gboolean
|
2006-04-12 09:42:10 +00:00
|
|
|
gst_gdk_pixbuf_sink_event (GstPad * pad, GstEvent * event)
|
2006-02-24 19:51:29 +00:00
|
|
|
{
|
|
|
|
GstFlowReturn res = GST_FLOW_OK;
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
GstGdkPixbuf *pixbuf;
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
pixbuf = GST_GDK_PIXBUF (gst_pad_get_parent (pad));
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
2006-04-12 09:42:10 +00:00
|
|
|
if (pixbuf->pixbuf_loader != NULL) {
|
|
|
|
gdk_pixbuf_loader_close (pixbuf->pixbuf_loader, NULL);
|
|
|
|
res = gst_gdk_pixbuf_flush (pixbuf);
|
|
|
|
g_object_unref (G_OBJECT (pixbuf->pixbuf_loader));
|
|
|
|
pixbuf->pixbuf_loader = NULL;
|
|
|
|
}
|
2006-02-24 19:51:29 +00:00
|
|
|
break;
|
|
|
|
case GST_EVENT_NEWSEGMENT:
|
|
|
|
case GST_EVENT_FLUSH_STOP:
|
|
|
|
if (pixbuf->pixbuf_loader != NULL) {
|
|
|
|
gdk_pixbuf_loader_close (pixbuf->pixbuf_loader, NULL);
|
|
|
|
g_object_unref (G_OBJECT (pixbuf->pixbuf_loader));
|
|
|
|
pixbuf->pixbuf_loader = NULL;
|
2004-07-12 13:49:35 +00:00
|
|
|
}
|
2006-02-24 19:51:29 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-01-12 03:21:40 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
if (res == GST_FLOW_OK) {
|
|
|
|
ret = gst_pad_event_default (pad, event);
|
|
|
|
} else {
|
|
|
|
ret = FALSE;
|
2004-01-12 03:21:40 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
gst_object_unref (pixbuf);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_gdk_pixbuf_chain (GstPad * pad, GstBuffer * buf)
|
|
|
|
{
|
|
|
|
GstGdkPixbuf *filter;
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
GError *error = NULL;
|
|
|
|
GstClockTime timestamp;
|
2006-04-12 09:42:10 +00:00
|
|
|
guint8 *data;
|
|
|
|
guint size;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
filter = GST_GDK_PIXBUF (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
|
|
|
|
2006-04-12 09:42:10 +00:00
|
|
|
if (GST_CLOCK_TIME_IS_VALID (timestamp))
|
2006-02-24 19:51:29 +00:00
|
|
|
filter->last_timestamp = timestamp;
|
2004-01-12 03:21:40 +00:00
|
|
|
|
2006-04-18 18:04:48 +00:00
|
|
|
GST_LOG_OBJECT (filter, "buffer with ts: %" GST_TIME_FORMAT,
|
2006-04-12 09:42:10 +00:00
|
|
|
GST_TIME_ARGS (timestamp));
|
|
|
|
|
|
|
|
if (filter->pixbuf_loader == NULL)
|
2006-02-24 19:51:29 +00:00
|
|
|
filter->pixbuf_loader = gdk_pixbuf_loader_new ();
|
|
|
|
|
2006-04-12 09:42:10 +00:00
|
|
|
data = GST_BUFFER_DATA (buf);
|
|
|
|
size = GST_BUFFER_SIZE (buf);
|
2006-02-24 19:51:29 +00:00
|
|
|
|
2006-04-18 18:04:48 +00:00
|
|
|
GST_LOG_OBJECT (filter, "Writing buffer size %d", size);
|
2006-04-12 09:42:10 +00:00
|
|
|
if (!gdk_pixbuf_loader_write (filter->pixbuf_loader, data, size, &error))
|
|
|
|
goto error;
|
|
|
|
|
2006-04-18 18:04:48 +00:00
|
|
|
/* packetised mode? */
|
|
|
|
if (filter->framerate_numerator != 0) {
|
|
|
|
gdk_pixbuf_loader_close (filter->pixbuf_loader, NULL);
|
|
|
|
ret = gst_gdk_pixbuf_flush (filter);
|
|
|
|
g_object_unref (filter->pixbuf_loader);
|
|
|
|
filter->pixbuf_loader = NULL;
|
|
|
|
}
|
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
gst_object_unref (filter);
|
2006-04-12 09:42:10 +00:00
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
return ret;
|
2006-04-12 09:42:10 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
error:
|
|
|
|
{
|
2006-04-18 18:04:48 +00:00
|
|
|
GST_ELEMENT_ERROR (filter, STREAM, DECODE, (NULL),
|
|
|
|
("gdk_pixbuf_loader_write error: %s", error->message));
|
2006-04-12 09:42:10 +00:00
|
|
|
g_error_free (error);
|
2006-04-18 18:04:48 +00:00
|
|
|
gst_object_unref (filter);
|
|
|
|
return GST_FLOW_ERROR;
|
2006-04-12 09:42:10 +00:00
|
|
|
}
|
2003-06-25 03:17:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_gdk_pixbuf_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2003-06-25 03:17:35 +00:00
|
|
|
{
|
|
|
|
GstGdkPixbuf *filter;
|
|
|
|
|
|
|
|
filter = GST_GDK_PIXBUF (object);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_SILENT:
|
2006-02-24 19:51:29 +00:00
|
|
|
/* filter->silent = g_value_get_boolean (value); */
|
2004-03-14 22:34:33 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2003-06-25 03:17:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_gdk_pixbuf_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
2003-06-25 03:17:35 +00:00
|
|
|
{
|
|
|
|
GstGdkPixbuf *filter;
|
|
|
|
|
|
|
|
filter = GST_GDK_PIXBUF (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2004-03-14 22:34:33 +00:00
|
|
|
case ARG_SILENT:
|
2006-02-24 19:51:29 +00:00
|
|
|
/* g_value_set_boolean (value, filter->silent); */
|
2004-03-14 22:34:33 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2003-06-25 03:17:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-29 05:40:48 +00:00
|
|
|
#define GST_GDK_PIXBUF_TYPE_FIND_SIZE 1024
|
|
|
|
|
2004-02-19 02:55:21 +00:00
|
|
|
#ifdef enable_typefind
|
2003-10-29 05:40:48 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore)
|
2003-10-29 05:40:48 +00:00
|
|
|
{
|
|
|
|
guint8 *data;
|
|
|
|
GdkPixbufLoader *pixbuf_loader;
|
|
|
|
GdkPixbufFormat *format;
|
|
|
|
|
|
|
|
data = gst_type_find_peek (tf, 0, GST_GDK_PIXBUF_TYPE_FIND_SIZE);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (data == NULL)
|
|
|
|
return;
|
2003-10-29 05:40:48 +00:00
|
|
|
|
2004-02-17 18:09:15 +00:00
|
|
|
GST_DEBUG ("creating new loader");
|
2003-10-29 05:40:48 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
pixbuf_loader = gdk_pixbuf_loader_new ();
|
|
|
|
|
2003-10-29 05:40:48 +00:00
|
|
|
gdk_pixbuf_loader_write (pixbuf_loader, data, GST_GDK_PIXBUF_TYPE_FIND_SIZE,
|
2003-11-05 03:24:54 +00:00
|
|
|
NULL);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-29 05:40:48 +00:00
|
|
|
format = gdk_pixbuf_loader_get_format (pixbuf_loader);
|
|
|
|
|
|
|
|
if (format != NULL) {
|
2004-02-03 22:51:34 +00:00
|
|
|
GstCaps *caps;
|
2004-02-17 18:09:15 +00:00
|
|
|
gchar **p;
|
|
|
|
gchar **mlist = gdk_pixbuf_format_get_mime_types (format);
|
2003-10-29 05:40:48 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
for (p = mlist; *p; ++p) {
|
2004-02-17 18:09:15 +00:00
|
|
|
GST_DEBUG ("suggesting mime type %s", *p);
|
|
|
|
caps = gst_caps_new_simple (*p, NULL);
|
|
|
|
gst_type_find_suggest (tf, GST_TYPE_FIND_MINIMUM, caps);
|
|
|
|
gst_caps_free (caps);
|
|
|
|
}
|
2004-02-03 22:51:34 +00:00
|
|
|
g_strfreev (mlist);
|
2003-10-29 05:40:48 +00:00
|
|
|
}
|
|
|
|
|
2004-02-17 18:09:15 +00:00
|
|
|
GST_DEBUG ("closing pixbuf loader, hope it doesn't hang ...");
|
|
|
|
/* librsvg 2.4.x has a bug where it triggers an endless loop in trying
|
|
|
|
to close a gzip that's not an svg; fixed upstream but no good way
|
|
|
|
to work around it */
|
2003-11-05 03:24:54 +00:00
|
|
|
gdk_pixbuf_loader_close (pixbuf_loader, NULL);
|
2004-02-17 18:09:15 +00:00
|
|
|
GST_DEBUG ("closed pixbuf loader");
|
2003-10-29 05:40:48 +00:00
|
|
|
g_object_unref (G_OBJECT (pixbuf_loader));
|
|
|
|
}
|
2004-02-19 02:55:21 +00:00
|
|
|
#endif
|
2003-10-29 05:40:48 +00:00
|
|
|
|
2003-06-25 03:17:35 +00:00
|
|
|
/* entry point to initialize the plug-in
|
|
|
|
* initialize the plug-in itself
|
|
|
|
* register the element factories and pad templates
|
|
|
|
* register the features
|
|
|
|
*/
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2003-06-25 03:17:35 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_gdk_pixbuf_debug, "gdkpixbuf", 0,
|
|
|
|
"gdk pixbuf loader");
|
2004-02-18 16:44:51 +00:00
|
|
|
|
2004-05-12 10:19:19 +00:00
|
|
|
if (!gst_element_register (plugin, "gdkpixbufdec", GST_RANK_MARGINAL,
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_TYPE_GDK_PIXBUF))
|
2003-11-01 16:18:43 +00:00
|
|
|
return FALSE;
|
2003-06-25 03:17:35 +00:00
|
|
|
|
2004-02-19 02:55:21 +00:00
|
|
|
#ifdef enable_typefind
|
2003-11-01 16:18:43 +00:00
|
|
|
gst_type_find_register (plugin, "image/*", GST_RANK_MARGINAL,
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_gdk_pixbuf_type_find, NULL, GST_CAPS_ANY, NULL);
|
2004-02-19 02:55:21 +00:00
|
|
|
#endif
|
2003-10-29 05:40:48 +00:00
|
|
|
|
2004-05-15 12:09:12 +00:00
|
|
|
if (!pixbufscale_init (plugin))
|
|
|
|
return FALSE;
|
|
|
|
|
2003-06-25 03:17:35 +00:00
|
|
|
/* plugin initialisation succeeded */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-24 19:51:29 +00:00
|
|
|
|
2003-06-25 03:17:35 +00:00
|
|
|
/* this is the structure that gst-register looks for
|
|
|
|
* so keep the name plugin_desc, or you cannot get your plug-in registered */
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"gdkpixbuf",
|
2006-02-24 19:51:29 +00:00
|
|
|
"GDK Pixbuf decoder & scaler",
|
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|