From 173ee367e4c68c0d37af9dce9d1fb1e77b8e5ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 12 Dec 2006 18:45:58 +0000 Subject: [PATCH] gst/: In streaming mode, if the first buffer we get doesn't have an offset, fix it up to be 0, otherwise trimming won... Original commit message from CVS: * gst/apetag/gsttagdemux.c: (gst_tag_demux_chain_parse_tag), (gst_tag_demux_chain): * gst/id3demux/gstid3demux.c: (gst_id3demux_chain): In streaming mode, if the first buffer we get doesn't have an offset, fix it up to be 0, otherwise trimming won't work later on and we'll be typefinding application/x-id3, which may result in decodebin plugging an endless number of id3demux elements as a consequence. Fixes #385031. --- ChangeLog | 11 +++++++++++ gst/apetag/gsttagdemux.c | 10 ++++++++++ gst/id3demux/gstid3demux.c | 15 ++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2b8ec3250c..3c05a34aa3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-12-12 Tim-Philipp Müller + + * gst/apetag/gsttagdemux.c: (gst_tag_demux_chain_parse_tag), + (gst_tag_demux_chain): + * gst/id3demux/gstid3demux.c: (gst_id3demux_chain): + In streaming mode, if the first buffer we get doesn't have an + offset, fix it up to be 0, otherwise trimming won't work later on + and we'll be typefinding application/x-id3, which may result in + decodebin plugging an endless number of id3demux elements as a + consequence. Fixes #385031. + 2006-12-08 Jan Schmidt * sys/sunaudio/gstsunaudiosink.c: (gst_sunaudiosink_prepare): diff --git a/gst/apetag/gsttagdemux.c b/gst/apetag/gsttagdemux.c index 1e52ee2dbf..1615f3f38c 100644 --- a/gst/apetag/gsttagdemux.c +++ b/gst/apetag/gsttagdemux.c @@ -458,6 +458,8 @@ gst_tag_demux_chain_parse_tag (GstTagDemux * demux, GstBuffer * collect) guint tagsize = 0; guint available; + g_assert (gst_buffer_is_metadata_writable (collect)); + klass = GST_TAG_DEMUX_CLASS (G_OBJECT_GET_CLASS (demux)); /* If we receive a buffer that's from the middle of the file, @@ -486,6 +488,12 @@ gst_tag_demux_chain_parse_tag (GstTagDemux * demux, GstBuffer * collect) return; } + /* need to set offset of first buffer to 0 or trimming won't work */ + if (!GST_BUFFER_OFFSET_IS_VALID (collect)) { + GST_WARNING_OBJECT (demux, "Fixing up first buffer without offset"); + GST_BUFFER_OFFSET (collect) = 0; + } + GST_DEBUG_OBJECT (demux, "Identified tag, size = %u bytes", tagsize); do { @@ -550,6 +558,8 @@ gst_tag_demux_chain (GstPad * pad, GstBuffer * buf) switch (demux->priv->state) { case GST_TAG_DEMUX_READ_START_TAG: + demux->priv->collect = + gst_buffer_make_metadata_writable (demux->priv->collect); gst_tag_demux_chain_parse_tag (demux, demux->priv->collect); if (demux->priv->state != GST_TAG_DEMUX_TYPEFINDING) break; diff --git a/gst/id3demux/gstid3demux.c b/gst/id3demux/gstid3demux.c index 9844319356..ef7a4c194a 100644 --- a/gst/id3demux/gstid3demux.c +++ b/gst/id3demux/gstid3demux.c @@ -46,6 +46,7 @@ #include #include #include +#include #include "gstid3demux.h" #include "id3tags.h" @@ -418,9 +419,21 @@ gst_id3demux_chain (GstPad * pad, GstBuffer * buf) switch (id3demux->state) { case GST_ID3DEMUX_READID3V2: + if (GST_BUFFER_SIZE (id3demux->collect) < 3) + break; /* Go get more data first */ + + /* need to set offset of first buffer to 0 or trimming won't work */ + if (!GST_BUFFER_OFFSET_IS_VALID (id3demux->collect) && + memcmp (GST_BUFFER_DATA (id3demux->collect), "ID3", 3) == 0) { + GST_WARNING_OBJECT (id3demux, "Fixing up first buffer without offset"); + id3demux->collect = + gst_buffer_make_metadata_writable (id3demux->collect); + GST_BUFFER_OFFSET (id3demux->collect) = 0; + } + /* If we receive a buffer that's from the middle of the file, * we can't read tags so move to typefinding */ - if (GST_BUFFER_OFFSET_IS_VALID (id3demux->collect) && + if (!GST_BUFFER_OFFSET_IS_VALID (id3demux->collect) || GST_BUFFER_OFFSET (id3demux->collect) != 0) { GST_DEBUG_OBJECT (id3demux, "Received buffer with non-zero offset %" G_GINT64_FORMAT