gst-plugins-good: flxdec: improve segment handling
Mark Nauwelaerts
mnauw at kemper.freedesktop.org
Fri Apr 13 08:31:33 PDT 2012
Module: gst-plugins-good
Branch: master
Commit: 93f61c47b95a38d74aff42233b92c3166b744ddb
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=93f61c47b95a38d74aff42233b92c3166b744ddb
Author: Mark Nauwelaerts <mark.nauwelaerts at collabora.co.uk>
Date: Fri Apr 13 16:54:50 2012 +0200
flxdec: improve segment handling
... to send a proper TIME segment downstream.
---
gst/flx/gstflxdec.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c
index e22641e..bd16952 100644
--- a/gst/flx/gstflxdec.c
+++ b/gst/flx/gstflxdec.c
@@ -62,6 +62,8 @@ static void gst_flxdec_dispose (GstFlxDec * flxdec);
static GstFlowReturn gst_flxdec_chain (GstPad * pad, GstObject * parent,
GstBuffer * buf);
+static gboolean gst_flxdec_sink_event_handler (GstPad * pad,
+ GstObject * parent, GstEvent * event);
static GstStateChangeReturn gst_flxdec_change_state (GstElement * element,
GstStateChange transition);
@@ -113,6 +115,8 @@ gst_flxdec_init (GstFlxDec * flxdec)
gst_element_add_pad (GST_ELEMENT (flxdec), flxdec->sinkpad);
gst_pad_set_chain_function (flxdec->sinkpad,
GST_DEBUG_FUNCPTR (gst_flxdec_chain));
+ gst_pad_set_event_function (flxdec->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_flxdec_sink_event_handler));
flxdec->srcpad = gst_pad_new_from_static_template (&src_video_factory, "src");
gst_element_add_pad (GST_ELEMENT (flxdec), flxdec->srcpad);
@@ -166,6 +170,37 @@ done:
return ret;
}
+static gboolean
+gst_flxdec_sink_event_handler (GstPad * pad, GstObject * parent,
+ GstEvent * event)
+{
+ GstFlxDec *flxdec;
+ gboolean ret;
+
+ flxdec = GST_FLXDEC (parent);
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_SEGMENT:
+ {
+ GstSegment segment;
+
+ gst_event_copy_segment (event, &segment);
+ if (segment.format != GST_FORMAT_TIME) {
+ GST_DEBUG_OBJECT (flxdec, "generating TIME segment");
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ gst_event_unref (event);
+ event = gst_event_new_segment (&segment);
+ }
+ /* fall-through */
+ }
+ default:
+ ret = gst_pad_event_default (pad, parent, event);
+ break;
+ }
+
+ return ret;
+}
+
static void
flx_decode_chunks (GstFlxDec * flxdec, gulong count, guchar * data,
guchar * dest)
More information about the gstreamer-commits
mailing list