Commit 9875cd9a authored by François Cartegnie's avatar François Cartegnie 🤞

demux: hls: handle packed audio ID3 time offset

parent d5ddecc8
......@@ -374,6 +374,8 @@ libhls_plugin_la_SOURCES = \
demux/hls/HLSManager.hpp \
demux/hls/HLSManager.cpp \
demux/hls/HLSStreamFormat.hpp \
demux/hls/HLSStreams.hpp \
demux/hls/HLSStreams.cpp \
demux/hls/hls.cpp \
demux/hls/hls.hpp
......
......@@ -23,7 +23,6 @@
#endif
#include "HLSManager.hpp"
#include "HLSStreamFormat.hpp"
#include "../adaptative/logic/RateBasedAdaptationLogic.h"
#include "../adaptative/tools/Retrieve.hpp"
#include "playlist/Parser.hpp"
......@@ -35,23 +34,6 @@ using namespace adaptative::logic;
using namespace hls;
using namespace hls::playlist;
AbstractStreamOutput *HLSStreamOutputFactory::create(demux_t *demux, const StreamFormat &format) const
{
unsigned fmt = format;
switch(fmt)
{
case HLSStreamFormat::PACKEDAAC:
return new BaseStreamOutput(demux, format, "any");
break;
default:
case HLSStreamFormat::UNKNOWN:
case HLSStreamFormat::MPEG2TS:
return new BaseStreamOutput(demux, format, "ts");
}
return NULL;
}
HLSManager::HLSManager(M3U8 *playlist,
AbstractStreamOutputFactory *factory,
AbstractAdaptationLogic::LogicType type, stream_t *stream) :
......
......@@ -28,12 +28,6 @@ namespace hls
{
using namespace adaptative;
class HLSStreamOutputFactory : public AbstractStreamOutputFactory
{
public:
virtual AbstractStreamOutput *create(demux_t*, const StreamFormat &) const;
};
class HLSManager : public PlaylistManager
{
public:
......
/*
* HLSStreams.cpp
*****************************************************************************
* Copyright (C) 2015 - VideoLAN authors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "HLSStreams.hpp"
#include "HLSStreamFormat.hpp"
#include <vlc_demux.h>
using namespace hls;
AbstractStreamOutput *HLSStreamOutputFactory::create(demux_t *demux, const StreamFormat &format) const
{
unsigned fmt = format;
switch(fmt)
{
case HLSStreamFormat::PACKEDAAC:
return new HLSPackedStreamOutput(demux, format, "any");
break;
default:
case HLSStreamFormat::UNKNOWN:
case HLSStreamFormat::MPEG2TS:
return new BaseStreamOutput(demux, format, "ts");
}
return NULL;
}
HLSPackedStreamOutput::HLSPackedStreamOutput(demux_t *demux, const StreamFormat &format, const std::string &name) :
BaseStreamOutput(demux, format, name)
{
}
void HLSPackedStreamOutput::pushBlock(block_t *p_block, bool b_first)
{
if(b_first && p_block && p_block->i_buffer >= 10 && !memcmp(p_block->p_buffer, "ID3", 3))
{
uint32_t size = GetDWBE(&p_block->p_buffer[6]) + 10;
size = __MIN(p_block->i_buffer, size);
if(size >= 73 && timestamps_offset == VLC_TS_INVALID)
{
if(!memcmp(&p_block->p_buffer[10], "PRIV", 4) &&
!memcmp(&p_block->p_buffer[20], "com.apple.streaming.transportStreamTimestamp", 45))
{
setTimestampOffset( GetQWBE(&p_block->p_buffer[65]) * 100 / 9 );
}
}
/* Skip ID3 for demuxer */
p_block->p_buffer += size;
p_block->i_buffer -= size;
}
BaseStreamOutput::pushBlock(p_block, b_first);
}
void HLSPackedStreamOutput::setPosition(mtime_t nztime)
{
BaseStreamOutput::setPosition(nztime);
/* Should be correct, has a restarted demux shouldn't have been fed with data yet */
setTimestampOffset(VLC_TS_INVALID - VLC_TS_0);
}
/*
* HLSStreams.hpp
*****************************************************************************
* Copyright (C) 2015 - VideoLAN authors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef HLSSTREAM_HPP
#define HLSSTREAM_HPP
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "../adaptative/Streams.hpp"
namespace hls
{
using namespace adaptative;
class HLSStreamOutputFactory : public AbstractStreamOutputFactory
{
public:
virtual AbstractStreamOutput *create(demux_t*, const StreamFormat &) const;
};
class HLSPackedStreamOutput : public BaseStreamOutput
{
public:
HLSPackedStreamOutput(demux_t *, const StreamFormat &, const std::string &);
virtual void pushBlock(block_t *, bool); /* reimpl */
virtual void setPosition(mtime_t); /* reimpl */
};
}
#endif // HLSSTREAMS_HPP
......@@ -37,6 +37,7 @@
#include "../adaptative/logic/AbstractAdaptationLogic.h"
#include "HLSManager.hpp"
#include "HLSStreams.hpp"
#include "playlist/Parser.hpp"
#include "playlist/M3U8.hpp"
......
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