From c09b14c931e36c2648a269ac74c9df8eac64981e Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 12 May 2014 13:45:06 +0200 Subject: [PATCH] flvdemux: Skip unknown tags in push-mode We add a new mode (SKIP) in push-mode to skip tags that we don't known about Partially fixes https://bugzilla.gnome.org/show_bug.cgi?id=670712 --- gst/flv/gstflvdemux.c | 31 +++++++++++++++++++++---------- gst/flv/gstflvdemux.h | 1 + 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/gst/flv/gstflvdemux.c b/gst/flv/gstflvdemux.c index c058fda..7d13893 100644 --- a/gst/flv/gstflvdemux.c +++ b/gst/flv/gstflvdemux.c @@ -1683,6 +1683,16 @@ gst_flv_demux_parse_tag_type (GstFlvDemux * demux, GstBuffer * buffer) tag_type = map.data[0]; + /* Tag size is 1 byte of type + 3 bytes of size + 7 bytes + tag data size + + * 4 bytes of previous tag size */ + demux->tag_data_size = GST_READ_UINT24_BE (map.data + 1); + demux->tag_size = demux->tag_data_size + 11; + + GST_LOG_OBJECT (demux, "tag data size is %" G_GUINT64_FORMAT, + demux->tag_data_size); + + gst_buffer_unmap (buffer, &map); + switch (tag_type) { case 9: demux->state = FLV_STATE_TAG_VIDEO; @@ -1697,18 +1707,9 @@ gst_flv_demux_parse_tag_type (GstFlvDemux * demux, GstBuffer * buffer) break; default: GST_WARNING_OBJECT (demux, "unsupported tag type %u", tag_type); + demux->state = FLV_STATE_SKIP; } - /* Tag size is 1 byte of type + 3 bytes of size + 7 bytes + tag data size + - * 4 bytes of previous tag size */ - demux->tag_data_size = GST_READ_UINT24_BE (map.data + 1); - demux->tag_size = demux->tag_data_size + 11; - - GST_LOG_OBJECT (demux, "tag data size is %" G_GUINT64_FORMAT, - demux->tag_data_size); - - gst_buffer_unmap (buffer, &map); - return ret; } @@ -2111,6 +2112,16 @@ parse: demux->state = FLV_STATE_TAG_TYPE; goto beach; } + case FLV_STATE_SKIP: + /* Skip unknown tags (set in _parse_tag_type()) */ + if (gst_adapter_available (demux->adapter) >= demux->tag_size) { + gst_adapter_flush (demux->adapter, demux->tag_size); + demux->offset += demux->tag_size; + demux->state = FLV_STATE_TAG_TYPE; + goto parse; + } else { + goto beach; + } default: GST_DEBUG_OBJECT (demux, "unexpected demuxer state"); } diff --git a/gst/flv/gstflvdemux.h b/gst/flv/gstflvdemux.h index 90953b4..79a8902 100644 --- a/gst/flv/gstflvdemux.h +++ b/gst/flv/gstflvdemux.h @@ -47,6 +47,7 @@ typedef enum FLV_STATE_TAG_SCRIPT, FLV_STATE_SEEK, FLV_STATE_DONE, + FLV_STATE_SKIP, FLV_STATE_NONE } GstFlvDemuxState; -- 2.7.4