2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4 * This library is distributed in the hope that it will be useful,
5 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7 * Library General Public License for more details.
9 * You should have received a copy of the GNU Library General Public
10 * License along with this library; if not, write to the
11 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
12 * Boston, MA 02111-1307, USA.
20 #include "gstpngdec.h"
23 #include <gst/video/video.h>
24 #include <gst/gst-i18n-plugin.h>
26 static const GstElementDetails gst_pngdec_details =
27 GST_ELEMENT_DETAILS ("PNG image decoder",
28 "Codec/Decoder/Image",
29 "Decode a png video frame to a raw image",
30 "Wim Taymans <wim@fluendo.com>");
32 GST_DEBUG_CATEGORY_STATIC (pngdec_debug);
33 #define GST_CAT_DEFAULT pngdec_debug
35 static void gst_pngdec_base_init (gpointer g_class);
36 static void gst_pngdec_class_init (GstPngDecClass * klass);
37 static void gst_pngdec_init (GstPngDec * pngdec);
39 static gboolean gst_pngdec_libpng_init (GstPngDec * pngdec);
40 static gboolean gst_pngdec_libpng_clear (GstPngDec * pngdec);
42 static GstStateChangeReturn gst_pngdec_change_state (GstElement * element,
43 GstStateChange transition);
45 static gboolean gst_pngdec_sink_activate_push (GstPad * sinkpad,
47 static gboolean gst_pngdec_sink_activate_pull (GstPad * sinkpad,
49 static gboolean gst_pngdec_sink_activate (GstPad * sinkpad);
51 static GstFlowReturn gst_pngdec_caps_create_and_set (GstPngDec * pngdec);
53 static void gst_pngdec_task (GstPad * pad);
54 static GstFlowReturn gst_pngdec_chain (GstPad * pad, GstBuffer * buffer);
55 static gboolean gst_pngdec_sink_event (GstPad * pad, GstEvent * event);
56 static gboolean gst_pngdec_sink_setcaps (GstPad * pad, GstCaps * caps);
58 static GstElementClass *parent_class = NULL;
61 gst_pngdec_get_type (void)
63 static GType pngdec_type = 0;
66 static const GTypeInfo pngdec_info = {
67 sizeof (GstPngDecClass),
70 (GClassInitFunc) gst_pngdec_class_init,
75 (GInstanceInitFunc) gst_pngdec_init,
78 pngdec_type = g_type_register_static (GST_TYPE_ELEMENT, "GstPngDec",
84 static GstStaticPadTemplate gst_pngdec_src_pad_template =
85 GST_STATIC_PAD_TEMPLATE ("src",
88 GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_RGB)
91 static GstStaticPadTemplate gst_pngdec_sink_pad_template =
92 GST_STATIC_PAD_TEMPLATE ("sink",
95 GST_STATIC_CAPS ("image/png")
99 gst_pngdec_base_init (gpointer g_class)
101 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
103 gst_element_class_add_pad_template (element_class,
104 gst_static_pad_template_get (&gst_pngdec_src_pad_template));
105 gst_element_class_add_pad_template (element_class,
106 gst_static_pad_template_get (&gst_pngdec_sink_pad_template));
107 gst_element_class_set_details (element_class, &gst_pngdec_details);
111 gst_pngdec_class_init (GstPngDecClass * klass)
113 GObjectClass *gobject_class;
114 GstElementClass *gstelement_class;
116 gobject_class = (GObjectClass *) klass;
117 gstelement_class = (GstElementClass *) klass;
119 parent_class = g_type_class_peek_parent (klass);
121 gstelement_class->change_state = gst_pngdec_change_state;
123 GST_DEBUG_CATEGORY_INIT (pngdec_debug, "pngdec", 0, "PNG image decoder");
127 gst_pngdec_init (GstPngDec * pngdec)
130 gst_pad_new_from_static_template (&gst_pngdec_sink_pad_template, "sink");
131 gst_pad_set_activate_function (pngdec->sinkpad, gst_pngdec_sink_activate);
132 gst_pad_set_activatepush_function (pngdec->sinkpad,
133 gst_pngdec_sink_activate_push);
134 gst_pad_set_activatepull_function (pngdec->sinkpad,
135 gst_pngdec_sink_activate_pull);
136 gst_pad_set_chain_function (pngdec->sinkpad, gst_pngdec_chain);
137 gst_pad_set_event_function (pngdec->sinkpad, gst_pngdec_sink_event);
138 gst_pad_set_setcaps_function (pngdec->sinkpad, gst_pngdec_sink_setcaps);
139 gst_element_add_pad (GST_ELEMENT (pngdec), pngdec->sinkpad);
142 gst_pad_new_from_static_template (&gst_pngdec_src_pad_template, "src");
143 gst_pad_use_fixed_caps (pngdec->srcpad);
144 gst_element_add_pad (GST_ELEMENT (pngdec), pngdec->srcpad);
146 pngdec->buffer_out = NULL;
149 pngdec->endinfo = NULL;
150 pngdec->setup = FALSE;
152 pngdec->color_type = -1;
159 pngdec->in_timestamp = GST_CLOCK_TIME_NONE;
160 pngdec->in_duration = GST_CLOCK_TIME_NONE;
162 pngdec->segment = gst_segment_new ();
166 user_error_fn (png_structp png_ptr, png_const_charp error_msg)
168 GST_ERROR ("%s", error_msg);
172 user_warning_fn (png_structp png_ptr, png_const_charp warning_msg)
174 GST_WARNING ("%s", warning_msg);
178 user_info_callback (png_structp png_ptr, png_infop info)
180 GstPngDec *pngdec = NULL;
181 GstFlowReturn ret = GST_FLOW_OK;
183 GstBuffer *buffer = NULL;
185 pngdec = GST_PNGDEC (png_ptr->io_ptr);
187 GST_LOG ("info ready");
189 /* Generate the caps and configure */
190 ret = gst_pngdec_caps_create_and_set (pngdec);
191 if (ret != GST_FLOW_OK) {
195 /* Allocate output buffer */
196 pngdec->rowbytes = png_get_rowbytes (pngdec->png, pngdec->info);
197 buffer_size = pngdec->height * GST_ROUND_UP_4 (pngdec->rowbytes);
199 gst_pad_alloc_buffer_and_set_caps (pngdec->srcpad, GST_BUFFER_OFFSET_NONE,
200 buffer_size, GST_PAD_CAPS (pngdec->srcpad), &buffer);
201 if (ret != GST_FLOW_OK) {
205 pngdec->buffer_out = buffer;
212 user_endrow_callback (png_structp png_ptr, png_bytep new_row,
213 png_uint_32 row_num, int pass)
215 GstPngDec *pngdec = NULL;
217 pngdec = GST_PNGDEC (png_ptr->io_ptr);
219 /* FIXME: implement interlaced pictures */
221 if (GST_IS_BUFFER (pngdec->buffer_out)) {
222 size_t offset = row_num * GST_ROUND_UP_4 (pngdec->rowbytes);
224 GST_LOG ("got row %d, copying in buffer %p at offset %d", row_num,
225 pngdec->buffer_out, offset);
226 memcpy (GST_BUFFER_DATA (pngdec->buffer_out) + offset, new_row,
228 pngdec->ret = GST_FLOW_OK;
230 GST_LOG ("we don't have any output buffer to write this row !");
231 pngdec->ret = GST_FLOW_ERROR;
236 buffer_clip (GstPngDec * dec, GstBuffer * buffer)
239 gint64 cstart, cstop;
241 if ((!GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buffer))) ||
242 (!GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer))) ||
243 (dec->segment->format != GST_FORMAT_TIME))
246 if ((res = gst_segment_clip (dec->segment, GST_FORMAT_TIME,
247 GST_BUFFER_TIMESTAMP (buffer),
248 GST_BUFFER_TIMESTAMP (buffer) + GST_BUFFER_DURATION (buffer),
250 GST_BUFFER_TIMESTAMP (buffer) = cstart;
251 GST_BUFFER_DURATION (buffer) = cstop - cstart;
259 user_end_callback (png_structp png_ptr, png_infop info)
261 GstPngDec *pngdec = NULL;
263 pngdec = GST_PNGDEC (png_ptr->io_ptr);
265 GST_LOG_OBJECT (pngdec, "and we are done reading this image");
267 if (!pngdec->buffer_out)
270 if (GST_CLOCK_TIME_IS_VALID (pngdec->in_timestamp))
271 GST_BUFFER_TIMESTAMP (pngdec->buffer_out) = pngdec->in_timestamp;
272 if (GST_CLOCK_TIME_IS_VALID (pngdec->in_duration))
273 GST_BUFFER_DURATION (pngdec->buffer_out) = pngdec->in_duration;
275 /* buffer clipping */
276 if (buffer_clip (pngdec, pngdec->buffer_out)) {
277 /* Push our buffer and then EOS if needed */
278 GST_LOG_OBJECT (pngdec, "pushing buffer with ts=%" GST_TIME_FORMAT,
279 GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (pngdec->buffer_out)));
281 pngdec->ret = gst_pad_push (pngdec->srcpad, pngdec->buffer_out);
283 GST_LOG_OBJECT (pngdec, "dropped decoded buffer");
284 gst_buffer_unref (pngdec->buffer_out);
286 pngdec->buffer_out = NULL;
288 if (pngdec->framed) {
289 /* Reset ourselves for the next frame */
290 gst_pngdec_libpng_clear (pngdec);
291 gst_pngdec_libpng_init (pngdec);
292 GST_LOG_OBJECT (pngdec, "setting up callbacks for next frame");
293 png_set_progressive_read_fn (pngdec->png, pngdec,
294 user_info_callback, user_endrow_callback, user_end_callback);
296 GST_LOG_OBJECT (pngdec, "sending EOS");
297 pngdec->ret = gst_pad_push_event (pngdec->srcpad, gst_event_new_eos ());
302 user_read_data (png_structp png_ptr, png_bytep data, png_size_t length)
306 GstFlowReturn ret = GST_FLOW_OK;
308 pngdec = GST_PNGDEC (png_ptr->io_ptr);
310 GST_LOG ("reading %d bytes of data at offset %d", length, pngdec->offset);
312 ret = gst_pad_pull_range (pngdec->sinkpad, pngdec->offset, length, &buffer);
313 if ((ret != GST_FLOW_OK) || (GST_BUFFER_SIZE (buffer) != length))
316 memcpy (data, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
318 gst_buffer_unref (buffer);
320 pngdec->offset += length;
325 GST_LOG_OBJECT (pngdec, "pausing task, reason %s", gst_flow_get_name (ret));
326 gst_pad_pause_task (pngdec->sinkpad);
327 if (GST_FLOW_IS_FATAL (ret)) {
328 gst_pad_push_event (pngdec->srcpad, gst_event_new_eos ());
329 GST_ELEMENT_ERROR (pngdec, STREAM, FAILED,
330 (_("Internal data stream error.")),
331 ("stream stopped, reason %s", gst_flow_get_name (ret)));
336 gst_pngdec_caps_create_and_set (GstPngDec * pngdec)
338 GstFlowReturn ret = GST_FLOW_OK;
339 GstCaps *caps = NULL, *res = NULL;
340 GstPadTemplate *templ = NULL;
341 gint bpc = 0, color_type;
342 png_uint_32 width, height;
344 g_return_val_if_fail (GST_IS_PNGDEC (pngdec), GST_FLOW_ERROR);
346 /* Get bits per channel */
347 bpc = png_get_bit_depth (pngdec->png, pngdec->info);
349 /* We don't handle 16 bits per color, strip down to 8 */
351 GST_LOG_OBJECT (pngdec,
352 "this is a 16 bits per channel PNG image, strip down to 8 bits");
353 png_set_strip_16 (pngdec->png);
357 color_type = png_get_color_type (pngdec->png, pngdec->info);
359 /* HACK: The doc states that it's RGBA but apparently it's not... */
360 if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
361 png_set_bgr (pngdec->png);
363 /* Gray scale converted to RGB and upscaled to 8 bits */
364 if ((color_type == PNG_COLOR_TYPE_GRAY_ALPHA) ||
365 (color_type == PNG_COLOR_TYPE_GRAY)) {
366 GST_LOG_OBJECT (pngdec, "converting grayscale png to RGB");
367 png_set_gray_to_rgb (pngdec->png);
368 if (bpc < 8) { /* Convert to 8 bits */
369 GST_LOG_OBJECT (pngdec, "converting grayscale image to 8 bits");
370 png_set_gray_1_2_4_to_8 (pngdec->png);
374 /* Palette converted to RGB */
375 if (color_type == PNG_COLOR_TYPE_PALETTE) {
376 GST_LOG_OBJECT (pngdec, "converting palette png to RGB");
377 png_set_palette_to_rgb (pngdec->png);
380 /* Update the info structure */
381 png_read_update_info (pngdec->png, pngdec->info);
383 /* Get IHDR header again after transformation settings */
385 png_get_IHDR (pngdec->png, pngdec->info, &width, &height,
386 &bpc, &pngdec->color_type, NULL, NULL, NULL);
388 pngdec->width = width;
389 pngdec->height = height;
391 GST_LOG_OBJECT (pngdec, "this is a %dx%d PNG image", pngdec->width,
394 switch (pngdec->color_type) {
395 case PNG_COLOR_TYPE_RGB:
396 GST_LOG_OBJECT (pngdec, "we have no alpha channel, depth is 24 bits");
399 case PNG_COLOR_TYPE_RGB_ALPHA:
400 GST_LOG_OBJECT (pngdec, "we have an alpha channel, depth is 32 bits");
404 GST_ELEMENT_ERROR (pngdec, STREAM, NOT_IMPLEMENTED, (NULL),
405 ("pngdec does not support this color type"));
406 ret = GST_FLOW_ERROR;
410 caps = gst_caps_new_simple ("video/x-raw-rgb",
411 "width", G_TYPE_INT, pngdec->width,
412 "height", G_TYPE_INT, pngdec->height,
413 "bpp", G_TYPE_INT, pngdec->bpp,
414 "framerate", GST_TYPE_FRACTION, pngdec->fps_n, pngdec->fps_d, NULL);
416 templ = gst_static_pad_template_get (&gst_pngdec_src_pad_template);
418 res = gst_caps_intersect (caps, gst_pad_template_get_caps (templ));
420 gst_caps_unref (caps);
421 gst_object_unref (templ);
423 if (!gst_pad_set_caps (pngdec->srcpad, res)) {
424 ret = GST_FLOW_ERROR;
427 GST_DEBUG_OBJECT (pngdec, "our caps %" GST_PTR_FORMAT, res);
429 gst_caps_unref (res);
431 /* Push a newsegment event */
432 if (pngdec->need_newsegment) {
433 gst_pad_push_event (pngdec->srcpad,
434 gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1, 0));
435 pngdec->need_newsegment = FALSE;
443 gst_pngdec_task (GstPad * pad)
446 GstBuffer *buffer = NULL;
447 size_t buffer_size = 0;
449 png_bytep *rows, inp;
450 png_uint_32 rowbytes;
451 GstFlowReturn ret = GST_FLOW_OK;
453 pngdec = GST_PNGDEC (GST_OBJECT_PARENT (pad));
455 /* Let libpng come back here on error */
456 if (setjmp (png_jmpbuf (pngdec->png))) {
457 ret = GST_FLOW_ERROR;
461 /* Set reading callback */
462 png_set_read_fn (pngdec->png, pngdec, user_read_data);
465 png_read_info (pngdec->png, pngdec->info);
467 /* Generate the caps and configure */
468 ret = gst_pngdec_caps_create_and_set (pngdec);
469 if (ret != GST_FLOW_OK) {
473 /* Allocate output buffer */
474 rowbytes = png_get_rowbytes (pngdec->png, pngdec->info);
475 buffer_size = pngdec->height * GST_ROUND_UP_4 (rowbytes);
477 gst_pad_alloc_buffer_and_set_caps (pngdec->srcpad, GST_BUFFER_OFFSET_NONE,
478 buffer_size, GST_PAD_CAPS (pngdec->srcpad), &buffer);
479 if (ret != GST_FLOW_OK) {
483 rows = (png_bytep *) g_malloc (sizeof (png_bytep) * pngdec->height);
485 inp = GST_BUFFER_DATA (buffer);
487 for (i = 0; i < pngdec->height; i++) {
489 inp += GST_ROUND_UP_4 (rowbytes);
492 /* Read the actual picture */
493 png_read_image (pngdec->png, rows);
496 /* Push the raw RGB frame */
497 ret = gst_pad_push (pngdec->srcpad, buffer);
498 if (ret != GST_FLOW_OK) {
502 /* And we are done */
503 gst_pad_pause_task (pngdec->sinkpad);
504 gst_pad_push_event (pngdec->srcpad, gst_event_new_eos ());
508 GST_LOG_OBJECT (pngdec, "pausing task, reason %s", gst_flow_get_name (ret));
509 gst_pad_pause_task (pngdec->sinkpad);
510 if (GST_FLOW_IS_FATAL (ret)) {
511 gst_pad_push_event (pngdec->srcpad, gst_event_new_eos ());
512 GST_ELEMENT_ERROR (pngdec, STREAM, FAILED,
513 (_("Internal data stream error.")),
514 ("stream stopped, reason %s", gst_flow_get_name (ret)));
519 gst_pngdec_chain (GstPad * pad, GstBuffer * buffer)
522 GstFlowReturn ret = GST_FLOW_OK;
524 pngdec = GST_PNGDEC (GST_OBJECT_PARENT (pad));
526 GST_LOG_OBJECT (pngdec, "Got buffer, size=%u", GST_BUFFER_SIZE (buffer));
528 if (!pngdec->setup) {
529 GST_LOG ("we are not configured yet");
530 ret = GST_FLOW_WRONG_STATE;
534 /* Something is going wrong in our callbacks */
535 if (pngdec->ret != GST_FLOW_OK) {
540 /* Let libpng come back here on error */
541 if (setjmp (png_jmpbuf (pngdec->png))) {
542 GST_WARNING ("error during decoding");
543 ret = GST_FLOW_ERROR;
547 pngdec->in_timestamp = GST_BUFFER_TIMESTAMP (buffer);
548 pngdec->in_duration = GST_BUFFER_DURATION (buffer);
550 /* Progressive loading of the PNG image */
551 png_process_data (pngdec->png, pngdec->info, GST_BUFFER_DATA (buffer),
552 GST_BUFFER_SIZE (buffer));
555 /* And release the buffer */
556 gst_buffer_unref (buffer);
563 gst_pngdec_sink_setcaps (GstPad * pad, GstCaps * caps)
569 pngdec = GST_PNGDEC (gst_pad_get_parent (pad));
571 s = gst_caps_get_structure (caps, 0);
572 if (gst_structure_get_fraction (s, "framerate", &num, &denom)) {
573 GST_DEBUG_OBJECT (pngdec, "framed input");
574 pngdec->framed = TRUE;
576 pngdec->fps_d = denom;
578 pngdec->framed = FALSE;
583 gst_object_unref (pngdec);
588 gst_pngdec_sink_event (GstPad * pad, GstEvent * event)
593 pngdec = GST_PNGDEC (gst_pad_get_parent (pad));
595 switch (GST_EVENT_TYPE (event)) {
596 case GST_EVENT_NEWSEGMENT:{
599 gint64 start, stop, position;
602 gst_event_parse_new_segment (event, &update, &rate, &fmt, &start, &stop,
604 gst_segment_set_newsegment (pngdec->segment, update, rate, fmt, start,
606 GST_LOG_OBJECT (pngdec, "NEWSEGMENT (%s)", gst_format_get_name (fmt));
607 if (fmt == GST_FORMAT_TIME) {
608 pngdec->need_newsegment = FALSE;
609 res = gst_pad_event_default (pad, event);
611 gst_event_unref (event);
616 case GST_EVENT_FLUSH_START:
617 gst_pngdec_libpng_clear (pngdec);
618 res = gst_pad_event_default (pad, event);
620 case GST_EVENT_FLUSH_STOP:
621 gst_pngdec_libpng_init (pngdec);
622 res = gst_pad_event_default (pad, event);
625 GST_LOG_OBJECT (pngdec, "EOS");
626 gst_pngdec_libpng_clear (pngdec);
627 res = gst_pad_event_default (pad, event);
630 res = gst_pad_event_default (pad, event);
634 gst_object_unref (pngdec);
639 /* Clean up the libpng structures */
641 gst_pngdec_libpng_clear (GstPngDec * pngdec)
643 png_infopp info = NULL, endinfo = NULL;
645 g_return_val_if_fail (GST_IS_PNGDEC (pngdec), FALSE);
647 GST_LOG ("cleaning up libpng structures");
650 info = &pngdec->info;
653 if (pngdec->endinfo) {
654 endinfo = &pngdec->endinfo;
658 png_destroy_read_struct (&(pngdec->png), info, endinfo);
661 pngdec->endinfo = NULL;
664 pngdec->bpp = pngdec->color_type = pngdec->height = pngdec->width = -1;
666 pngdec->rowbytes = 0;
667 pngdec->buffer_out = NULL;
669 pngdec->setup = FALSE;
671 pngdec->in_timestamp = GST_CLOCK_TIME_NONE;
672 pngdec->in_duration = GST_CLOCK_TIME_NONE;
678 gst_pngdec_libpng_init (GstPngDec * pngdec)
680 g_return_val_if_fail (GST_IS_PNGDEC (pngdec), FALSE);
686 /* initialize png struct stuff */
687 pngdec->png = png_create_read_struct (PNG_LIBPNG_VER_STRING,
688 (png_voidp) NULL, user_error_fn, user_warning_fn);
690 if (pngdec->png == NULL) {
691 GST_ELEMENT_ERROR (pngdec, LIBRARY, INIT, (NULL),
692 ("Failed to initialize png structure"));
696 pngdec->info = png_create_info_struct (pngdec->png);
697 if (pngdec->info == NULL) {
698 gst_pngdec_libpng_clear (pngdec);
699 GST_ELEMENT_ERROR (pngdec, LIBRARY, INIT, (NULL),
700 ("Failed to initialize info structure"));
704 pngdec->endinfo = png_create_info_struct (pngdec->png);
705 if (pngdec->endinfo == NULL) {
706 gst_pngdec_libpng_clear (pngdec);
707 GST_ELEMENT_ERROR (pngdec, LIBRARY, INIT, (NULL),
708 ("Failed to initialize endinfo structure"));
712 pngdec->setup = TRUE;
715 return pngdec->setup;
718 static GstStateChangeReturn
719 gst_pngdec_change_state (GstElement * element, GstStateChange transition)
721 GstStateChangeReturn ret;
724 pngdec = GST_PNGDEC (element);
726 switch (transition) {
727 case GST_STATE_CHANGE_READY_TO_PAUSED:
728 gst_pngdec_libpng_init (pngdec);
729 pngdec->need_newsegment = TRUE;
730 pngdec->framed = FALSE;
731 pngdec->segment = gst_segment_new ();
732 gst_segment_init (pngdec->segment, GST_FORMAT_UNDEFINED);
738 ret = parent_class->change_state (element, transition);
739 if (ret != GST_STATE_CHANGE_SUCCESS)
742 switch (transition) {
743 case GST_STATE_CHANGE_PAUSED_TO_READY:
744 gst_pngdec_libpng_clear (pngdec);
745 if (pngdec->segment) {
746 gst_segment_free (pngdec->segment);
747 pngdec->segment = NULL;
757 /* this function gets called when we activate ourselves in push mode. */
759 gst_pngdec_sink_activate_push (GstPad * sinkpad, gboolean active)
763 pngdec = GST_PNGDEC (GST_OBJECT_PARENT (sinkpad));
765 pngdec->ret = GST_FLOW_OK;
768 /* Let libpng come back here on error */
769 if (setjmp (png_jmpbuf (pngdec->png))) {
770 GST_LOG ("failed setting up libpng jumb");
771 gst_pngdec_libpng_clear (pngdec);
775 GST_LOG ("setting up progressive loading callbacks");
776 png_set_progressive_read_fn (pngdec->png, pngdec,
777 user_info_callback, user_endrow_callback, user_end_callback);
783 /* this function gets called when we activate ourselves in pull mode.
784 * We can perform random access to the resource and we start a task
785 * to start reading */
787 gst_pngdec_sink_activate_pull (GstPad * sinkpad, gboolean active)
791 pngdec = GST_PNGDEC (GST_OBJECT_PARENT (sinkpad));
794 return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_pngdec_task,
797 return gst_pad_stop_task (sinkpad);
801 /* this function is called when the pad is activated and should start
804 * We check if we can do random access to decide if we work push or
808 gst_pngdec_sink_activate (GstPad * sinkpad)
810 if (gst_pad_check_pull_range (sinkpad)) {
811 return gst_pad_activate_pull (sinkpad, TRUE);
813 return gst_pad_activate_push (sinkpad, TRUE);