diff options
author | Thiago Santos <thiagoss@osg.samsung.com> | 2015-02-19 02:58:15 +0300 |
---|---|---|
committer | Thiago Santos <thiagoss@osg.samsung.com> | 2015-02-19 03:08:05 +0300 |
commit | 1bed71c622c66fa47fd6137ec283b73ae7b7cec7 (patch) | |
tree | c1eb58dd7256ef5e7232ca0eeae0e940c76a8311 | |
parent | 094f90c4c55da9017decb80b922e48cda77a93c6 (diff) |
tagdemux: ensure tags have been fetched before pulling data
Otherwise upstream can get confused about offsets as there will
be a jump once the tags have been parsed due to the stripped area.
If upstream pulls from 0 to 100, and then tagdemux does the
tag reading and finds out that the first 200 bytes are the tag, the
next pull from upstream will have an offset of 200 bytes. So
upstream will get the following data:
0 - 100, 300 - (EOS), as it will continue requesting from where
it has last stopped, but tagdemux will add an offset to skip the
tags.
This patch makes sure that the tags have been parsed and skipped
since the first pull range call.
https://bugzilla.gnome.org/show_bug.cgi?id=744580
-rw-r--r-- | gst-libs/gst/tag/gsttagdemux.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/gst-libs/gst/tag/gsttagdemux.c b/gst-libs/gst/tag/gsttagdemux.c index c36a75d0a..ef9ed42a2 100644 --- a/gst-libs/gst/tag/gsttagdemux.c +++ b/gst-libs/gst/tag/gsttagdemux.c @@ -1614,6 +1614,20 @@ gst_tag_demux_src_activate_mode (GstPad * pad, GstObject * parent, return res; } +static inline GstFlowReturn +gst_tag_demux_ensure_tags (GstTagDemux * demux) +{ + GstFlowReturn flow = GST_FLOW_OK; + + if (G_UNLIKELY (demux->priv->state == GST_TAG_DEMUX_READ_START_TAG && + GST_PAD_MODE (demux->priv->srcpad) == GST_PAD_MODE_PULL)) { + + flow = gst_tag_demux_element_find (demux); + GST_INFO_OBJECT (demux, "pulled tags: %s", gst_flow_get_name (flow)); + } + return flow; +} + static GstFlowReturn gst_tag_demux_read_range (GstTagDemux * demux, GstObject * parent, guint64 offset, guint length, GstBuffer ** buffer) @@ -1625,6 +1639,12 @@ gst_tag_demux_read_range (GstTagDemux * demux, GstObject * parent, g_return_val_if_fail (buffer != NULL, GST_FLOW_ERROR); + /* Ensure we already have computed our tags to properly use the offsets + * below */ + ret = gst_tag_demux_ensure_tags (demux); + if (ret != GST_FLOW_OK) + return ret; + /* Adjust offset and length of the request to trim off tag information. * For the returned buffer, adjust the output offset to match what downstream * should see */ @@ -1741,13 +1761,7 @@ gst_tag_demux_pad_query (GstPad * pad, GstObject * parent, GstQuery * query) * filesrc ! id3demux ! xyzparse ! .., read tags here, since we don't * have a streaming thread of our own to do that. We do it here and * not in get_range(), so we can return the right size in bytes.. */ - if (demux->priv->state == GST_TAG_DEMUX_READ_START_TAG && - GST_PAD_MODE (demux->priv->srcpad) == GST_PAD_MODE_PULL) { - GstFlowReturn flow G_GNUC_UNUSED; - - flow = gst_tag_demux_element_find (demux); - GST_INFO_OBJECT (demux, "pulled tags: %s", gst_flow_get_name (flow)); - } + gst_tag_demux_ensure_tags (demux); result -= demux->priv->strip_start + demux->priv->strip_end; if (result < 0) result = 0; |