[vlc-commits] adaptive: probing: packed audio starts with ID3
Francois Cartegnie
git at videolan.org
Wed Aug 28 21:09:09 CEST 2019
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Aug 28 14:12:48 2019 +0200| [7ff304b2a1c701403e18c17852808aeed4c10905] | committer: Francois Cartegnie
adaptive: probing: packed audio starts with ID3
regression by a047b31b978e4a3bd86b3c1a8f7dec9281d1a056
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7ff304b2a1c701403e18c17852808aeed4c10905
---
modules/demux/Makefile.am | 8 +++++---
modules/demux/adaptive/StreamFormat.cpp | 32 +++++++++++++++++++++++++++++---
modules/demux/adaptive/StreamFormat.hpp | 2 +-
3 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index 0251da6879..78985041ef 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -401,6 +401,10 @@ libadaptive_plugin_la_SOURCES = \
demux/adaptive/xml/DOMParser.h \
demux/adaptive/xml/Node.cpp \
demux/adaptive/xml/Node.h
+libadaptive_plugin_la_SOURCES += \
+ demux/mp4/libmp4.c \
+ demux/mp4/libmp4.h \
+ meta_engine/ID3Tag.h
libadaptive_dash_SOURCES = \
demux/dash/mpd/AdaptationSet.cpp \
@@ -448,8 +452,7 @@ libadaptive_hls_SOURCES = \
demux/hls/HLSStreams.hpp \
demux/hls/HLSStreams.cpp \
demux/mpeg/timestamps.h
-libadaptive_hls_SOURCES += meta_engine/ID3Tag.h \
- meta_engine/ID3Meta.h
+libadaptive_hls_SOURCES += meta_engine/ID3Meta.h
libadaptive_smooth_SOURCES = \
demux/smooth/mp4/IndexReader.cpp \
@@ -477,7 +480,6 @@ libadaptive_plugin_la_SOURCES += $(libadaptive_hls_SOURCES)
libadaptive_plugin_la_SOURCES += $(libadaptive_dash_SOURCES)
libadaptive_plugin_la_SOURCES += $(libadaptive_smooth_SOURCES)
libadaptive_plugin_la_SOURCES += demux/adaptive/adaptive.cpp
-libadaptive_plugin_la_SOURCES += demux/mp4/libmp4.c demux/mp4/libmp4.h
libadaptive_plugin_la_CXXFLAGS = $(AM_CXXFLAGS) -I$(srcdir)/demux/adaptive
libadaptive_plugin_la_LIBADD = $(SOCKET_LIBS) $(LIBM)
if HAVE_ZLIB
diff --git a/modules/demux/adaptive/StreamFormat.cpp b/modules/demux/adaptive/StreamFormat.cpp
index b8cc33da26..927a8a71a9 100644
--- a/modules/demux/adaptive/StreamFormat.cpp
+++ b/modules/demux/adaptive/StreamFormat.cpp
@@ -25,6 +25,12 @@
#include "StreamFormat.hpp"
#include <vlc_common.h>
+
+extern "C"
+{
+ #include "../../meta_engine/ID3Tag.h"
+}
+
#include <algorithm>
using namespace adaptive;
@@ -87,6 +93,11 @@ StreamFormat::StreamFormat( const std::string &mimetype )
}
}
+static int ID3Callback(uint32_t, const uint8_t *, size_t, void *)
+{
+ return VLC_EGENERIC;
+}
+
StreamFormat::StreamFormat(const void *data_, size_t sz)
{
const uint8_t *data = reinterpret_cast<const uint8_t *>(data_);
@@ -104,9 +115,24 @@ StreamFormat::StreamFormat(const void *data_, size_t sz)
formatid = StreamFormat::WEBVTT;
else if(sz > 4 && !memcmp("\x1A\x45\xDF\xA3", data, 4))
formatid = StreamFormat::WEBM;
- else if(sz > 3 && (!memcmp("\xFF\xF1", data, 2)||
- !memcmp("\xFF\xF9", data, 2)))
- formatid = StreamFormat::PACKEDAAC;
+ else /* Check Packet Audio formats */
+ {
+ /* It MUST have ID3 header, but HLS spec is an oxymoron */
+ if(sz > 10 && ID3TAG_IsTag(data, false))
+ {
+ size_t tagsize = ID3TAG_Parse(data, sz, ID3Callback, this);
+ if(tagsize >= sz)
+ return; /* not enough peek */
+ data += tagsize;
+ sz -= tagsize;
+ }
+ /* Skipped ID3 if any */
+ if(sz > 3 && (!memcmp("\xFF\xF1", data, 2) ||
+ !memcmp("\xFF\xF9", data, 2)))
+ {
+ formatid = StreamFormat::PACKEDAAC;
+ }
+ }
}
StreamFormat::~StreamFormat()
diff --git a/modules/demux/adaptive/StreamFormat.hpp b/modules/demux/adaptive/StreamFormat.hpp
index db70a53753..10d7fba92a 100644
--- a/modules/demux/adaptive/StreamFormat.hpp
+++ b/modules/demux/adaptive/StreamFormat.hpp
@@ -36,7 +36,7 @@ namespace adaptive
static const unsigned PACKEDAAC = 5;
static const unsigned WEBM = 6;
static const unsigned UNKNOWN = 0xFF; /* will probe */
- static const unsigned PEEK_SIZE = 189;
+ static const unsigned PEEK_SIZE = 4096;
StreamFormat( unsigned = UNSUPPORTED );
explicit StreamFormat( const std::string &mime );
More information about the vlc-commits
mailing list