Commit 7ff304b2 authored by François Cartegnie's avatar François Cartegnie 🤞
Browse files

adaptive: probing: packed audio starts with ID3

regression by a047b31b
parent 244f8f73
......@@ -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
......
......@@ -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()
......
......@@ -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 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment