diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2016-06-30 18:53:07 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2016-07-04 12:47:34 +0200 |
commit | 78b658d204fb3279197b095ba3c4386fca03b28f (patch) | |
tree | f4757743d7477a68b75abf776dd9b35977138e04 | |
parent | a85b7a2b896e948fd2e239b6394fbcea1841297b (diff) | |
download | gstreamer-plugins-base-78b658d204fb3279197b095ba3c4386fca03b28f.tar.gz |
tagdemux: fix handling of very short files in push mode
By default we'll wait for a certain amount of data before
attempting typefinding. However, if the stream is fairly
short, we might get EOS before we ever attempted any
typefinding, so at this point we should force typefinding
and output any pending data if we manage to detect the
type.
https://bugzilla.gnome.org//show_bug.cgi?id=768178
-rw-r--r-- | gst-libs/gst/tag/gsttagdemux.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/gst-libs/gst/tag/gsttagdemux.c b/gst-libs/gst/tag/gsttagdemux.c index f4c7f0e5d..307e871c7 100644 --- a/gst-libs/gst/tag/gsttagdemux.c +++ b/gst-libs/gst/tag/gsttagdemux.c @@ -623,13 +623,11 @@ gst_tag_demux_chain_parse_tag (GstTagDemux * demux) } static GstFlowReturn -gst_tag_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) +gst_tag_demux_chain_buffer (GstTagDemux * demux, GstBuffer * buf, + gboolean at_eos) { - GstTagDemux *demux; gsize size; - demux = GST_TAG_DEMUX (parent); - size = gst_buffer_get_size (buf); /* Update our segment position info */ @@ -661,7 +659,7 @@ gst_tag_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) update_collected (demux); - if (demux->priv->collect_size < + if (!at_eos && demux->priv->collect_size < TYPE_FIND_MIN_SIZE + demux->priv->strip_start) break; /* Go get more data first */ @@ -742,7 +740,7 @@ gst_tag_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) demux->priv->send_tag_event = FALSE; } - GST_LOG_OBJECT (demux, "Pushing buffer %p", outbuf); + GST_LOG_OBJECT (demux, "Pushing buffer %" GST_PTR_FORMAT, outbuf); return gst_pad_push (demux->priv->srcpad, outbuf); } @@ -751,6 +749,12 @@ gst_tag_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) return GST_FLOW_OK; } +static GstFlowReturn +gst_tag_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) +{ + return gst_tag_demux_chain_buffer (GST_TAG_DEMUX (parent), buf, FALSE); +} + static gboolean gst_tag_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) { @@ -762,8 +766,14 @@ gst_tag_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: if (!gst_pad_has_current_caps (demux->priv->srcpad)) { - GST_WARNING_OBJECT (demux, "EOS before we found a type"); - GST_ELEMENT_ERROR (demux, STREAM, TYPE_NOT_FOUND, (NULL), (NULL)); + GST_INFO_OBJECT (demux, "EOS before we found a type"); + + /* push final buffer with eos indication to force typefinding */ + gst_tag_demux_chain_buffer (demux, gst_buffer_new (), TRUE); + + if (!gst_pad_has_current_caps (demux->priv->srcpad)) { + GST_ELEMENT_ERROR (demux, STREAM, TYPE_NOT_FOUND, (NULL), (NULL)); + } } ret = gst_pad_event_default (pad, parent, event); break; |