From: Sebastian Dröge Date: Mon, 28 Nov 2016 10:22:49 +0000 (+0200) Subject: multipartdemux: Post an error message on the bus if we got EOS without having added... X-Git-Tag: 1.19.3~509^2~2379 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f48fef2f77a67e13bbddd0e789b1d642565473d2;p=platform%2Fupstream%2Fgstreamer.git multipartdemux: Post an error message on the bus if we got EOS without having added any pads --- diff --git a/gst/multipart/multipartdemux.c b/gst/multipart/multipartdemux.c index afbc42a..23e67c2 100644 --- a/gst/multipart/multipartdemux.c +++ b/gst/multipart/multipartdemux.c @@ -106,6 +106,8 @@ static const GstNamesMap gstnames[] = { static GstFlowReturn gst_multipart_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf); +static gboolean gst_multipart_demux_event (GstPad * pad, + GstObject * parent, GstEvent * event); static GstStateChangeReturn gst_multipart_demux_change_state (GstElement * element, GstStateChange transition); @@ -179,6 +181,8 @@ gst_multipart_demux_init (GstMultipartDemux * multipart) gst_element_add_pad (GST_ELEMENT_CAST (multipart), multipart->sinkpad); gst_pad_set_chain_function (multipart->sinkpad, GST_DEBUG_FUNCPTR (gst_multipart_demux_chain)); + gst_pad_set_event_function (multipart->sinkpad, + GST_DEBUG_FUNCPTR (gst_multipart_demux_event)); multipart->adapter = gst_adapter_new (); multipart->boundary = DEFAULT_BOUNDARY; @@ -571,6 +575,30 @@ multipart_find_boundary (GstMultipartDemux * multipart, gint * datalen) return MULTIPART_NEED_MORE_DATA; } +static gboolean +gst_multipart_demux_event (GstPad * pad, GstObject * parent, GstEvent * event) +{ + GstMultipartDemux *multipart; + + multipart = GST_MULTIPART_DEMUX (parent); + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_EOS: + if (!multipart->srcpads) { + GST_ELEMENT_ERROR (multipart, STREAM, WRONG_TYPE, + ("This stream contains no valid streams."), + ("Got EOS before adding any pads")); + gst_event_unref (event); + return FALSE; + } else { + return gst_pad_event_default (pad, parent, event); + } + break; + default: + return gst_pad_event_default (pad, parent, event); + } +} + static GstFlowReturn gst_multipart_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) {