flxdec: improve segment handling

... to send a proper TIME segment downstream.
This commit is contained in:
Mark Nauwelaerts 2012-04-13 16:54:50 +02:00
parent 40cfe6787b
commit 93f61c47b9

View file

@ -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)