Commit fe32c1c6 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptative: merge streamformats

only handling them should differ. adds debugging
parent 916065b0
......@@ -367,8 +367,7 @@ libadaptative_dash_SOURCES = \
demux/dash/DASHManager.cpp \
demux/dash/DASHManager.h \
demux/dash/DASHStream.cpp \
demux/dash/DASHStream.hpp \
demux/dash/DASHStreamFormat.hpp
demux/dash/DASHStream.hpp
libadaptative_hls_SOURCES = \
demux/hls/playlist/M3U8.hpp \
......@@ -383,7 +382,6 @@ libadaptative_hls_SOURCES = \
demux/hls/playlist/Tags.cpp \
demux/hls/HLSManager.hpp \
demux/hls/HLSManager.cpp \
demux/hls/HLSStreamFormat.hpp \
demux/hls/HLSStreams.hpp \
demux/hls/HLSStreams.cpp
......@@ -404,7 +402,6 @@ libadaptative_smooth_SOURCES = \
demux/smooth/playlist/SmoothSegment.cpp \
demux/smooth/SmoothManager.hpp \
demux/smooth/SmoothManager.cpp \
demux/smooth/SmoothStreamFormat.hpp \
demux/smooth/SmoothStream.hpp \
demux/smooth/SmoothStream.cpp
libadaptative_smooth_SOURCES += mux/mp4/libmp4mux.c mux/mp4/libmp4mux.h \
......
......@@ -26,6 +26,26 @@ StreamFormat::operator unsigned() const
return formatid;
}
std::string StreamFormat::str() const
{
switch(formatid)
{
case MPEG2TS:
return "TS";
case MP4:
return "MP4";
case WEBVTT:
return "WebVTT";
case TTML:
return "Timed Text";
case PACKEDAAC:
return "Packed AAC";
default:
case UNKNOWN:
return "Unknown";
}
}
StreamFormat::StreamFormat( unsigned formatid_ )
{
formatid = formatid_;
......
......@@ -20,6 +20,8 @@
#ifndef STREAMFORMAT_HPP
#define STREAMFORMAT_HPP
#include <string>
namespace adaptative
{
......@@ -27,10 +29,17 @@ namespace adaptative
{
public:
static const unsigned UNSUPPORTED = 0;
static const unsigned MPEG2TS = 1;
static const unsigned MP4 = 2;
static const unsigned WEBVTT = 3;
static const unsigned TTML = 4;
static const unsigned PACKEDAAC = 5;
static const unsigned UNKNOWN = 0xFF; /* will probe */
StreamFormat( unsigned = UNSUPPORTED );
~StreamFormat();
operator unsigned() const;
std::string str() const;
bool operator==(const StreamFormat &) const;
bool operator!=(const StreamFormat &) const;
......
......@@ -381,8 +381,8 @@ void AbstractStream::trackerEvent(const SegmentTrackerEvent &event)
if(*event.u.format.f != format)
{
/* Format has changed between segments, we need to drain and change demux */
msg_Info(p_realdemux, "Changing stream format %u->%u",
(unsigned)format, (unsigned)*event.u.format.f);
msg_Info(p_realdemux, "Changing stream format %s -> %s",
format.str().c_str(), event.u.format.f->str().c_str());
format = *event.u.format.f;
/* This is an implict discontinuity */
......
......@@ -18,7 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "DASHStream.hpp"
#include "DASHStreamFormat.hpp"
using namespace dash;
......@@ -37,19 +36,19 @@ AbstractDemuxer * DASHStream::createDemux(const StreamFormat &format)
AbstractDemuxer *ret = NULL;
switch((unsigned)format)
{
case DASHStreamFormat::MP4:
case StreamFormat::MP4:
ret = new Demuxer(p_realdemux, "mp4", fakeesout->getEsOut(), demuxersource);
break;
case DASHStreamFormat::MPEG2TS:
case StreamFormat::MPEG2TS:
ret = new Demuxer(p_realdemux, "ts", fakeesout->getEsOut(), demuxersource);
break;
case DASHStreamFormat::WEBVTT:
case StreamFormat::WEBVTT:
ret = new SlaveDemuxer(p_realdemux, "subtitle", fakeesout->getEsOut(), demuxersource);
break;
case DASHStreamFormat::TTML:
case StreamFormat::TTML:
ret = new SlaveDemuxer(p_realdemux, "ttml", fakeesout->getEsOut(), demuxersource);
break;
......
/*
* DASHStreamFormat.hpp
*****************************************************************************
* Copyright (C) 2015 - VideoLAN and VLC 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 DASHSTREAMFORMAT_HPP
#define DASHSTREAMFORMAT_HPP
#include "../adaptative/StreamFormat.hpp"
#include <string>
namespace dash
{
using namespace adaptative;
class DASHStreamFormat : public StreamFormat
{
public:
static const unsigned MPEG2TS = StreamFormat::UNSUPPORTED + 1;
static const unsigned MP4 = StreamFormat::UNSUPPORTED + 2;
static const unsigned WEBVTT = StreamFormat::UNSUPPORTED + 3;
static const unsigned TTML = StreamFormat::UNSUPPORTED + 4;
static StreamFormat mimeToFormat(const std::string &mime)
{
std::string::size_type pos = mime.find("/");
if(pos != std::string::npos)
{
std::string tail = mime.substr(pos + 1);
if(tail == "mp4")
return StreamFormat(DASHStreamFormat::MP4);
else if (tail == "mp2t")
return StreamFormat(DASHStreamFormat::MPEG2TS);
else if (tail == "vtt")
return StreamFormat(DASHStreamFormat::WEBVTT);
else if (tail == "ttml+xml")
return StreamFormat(DASHStreamFormat::TTML);
}
return StreamFormat();
}
};
}
#endif // DASHSTREAMFORMAT_HPP
......@@ -25,7 +25,7 @@
#include "AdaptationSet.h"
#include "Representation.h"
#include "Period.h"
#include "../DASHStreamFormat.hpp"
#include "MPD.h"
using namespace dash::mpd;
......@@ -43,7 +43,7 @@ AdaptationSet::~AdaptationSet()
StreamFormat AdaptationSet::getStreamFormat() const
{
if(!getMimeType().empty())
return DASHStreamFormat::mimeToFormat(getMimeType());
return MPD::mimeToFormat(getMimeType());
else
return BaseAdaptationSet::getStreamFormat();
}
......
......@@ -28,11 +28,13 @@
#include "DASHCommonAttributesElements.h"
#include "ContentDescription.h"
#include "../adaptative/StreamFormat.hpp"
#include <vlc_common.h>
#include <vlc_arrays.h>
using namespace dash::mpd;
using namespace adaptative;
DASHCommonAttributesElements::DASHCommonAttributesElements() :
parX( 1 ),
......
......@@ -62,6 +62,24 @@ Profile MPD::getProfile() const
return profile;
}
StreamFormat MPD::mimeToFormat(const std::string &mime)
{
std::string::size_type pos = mime.find("/");
if(pos != std::string::npos)
{
std::string tail = mime.substr(pos + 1);
if(tail == "mp4")
return StreamFormat(StreamFormat::MP4);
else if (tail == "mp2t")
return StreamFormat(StreamFormat::MPEG2TS);
else if (tail == "vtt")
return StreamFormat(StreamFormat::WEBVTT);
else if (tail == "ttml+xml")
return StreamFormat(StreamFormat::TTML);
}
return StreamFormat();
}
void MPD::debug()
{
msg_Dbg(stream, "MPD profile=%s mediaPresentationDuration=%" PRId64
......
......@@ -26,6 +26,7 @@
#define MPD_H_
#include "../adaptative/playlist/AbstractPlaylist.hpp"
#include "../adaptative/StreamFormat.hpp"
#include "Profile.hpp"
namespace dash
......@@ -33,6 +34,7 @@ namespace dash
namespace mpd
{
using namespace adaptative::playlist;
using namespace adaptative;
class ProgramInformation;
......@@ -46,6 +48,8 @@ namespace dash
virtual bool isLive() const;
virtual void debug();
static StreamFormat mimeToFormat(const std::string &);
Property<ProgramInformation *> programInfo;
private:
......
......@@ -33,7 +33,6 @@
#include "TrickModeType.h"
#include "../adaptative/playlist/SegmentTemplate.h"
#include "../adaptative/playlist/SegmentTimeline.h"
#include "../DASHStreamFormat.hpp"
using namespace dash::mpd;
......@@ -52,9 +51,9 @@ Representation::~Representation ()
StreamFormat Representation::getStreamFormat() const
{
if(getMimeType().empty())
return DASHStreamFormat::mimeToFormat(adaptationSet->getMimeType());
return MPD::mimeToFormat(adaptationSet->getMimeType());
else
return DASHStreamFormat::mimeToFormat(getMimeType());
return MPD::mimeToFormat(getMimeType());
}
TrickModeType* Representation::getTrickModeType () const
......
/*
* HLSStreamFormat.hpp
*****************************************************************************
* Copyright (C) 2015 - VideoLAN and VLC 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 HLSSTREAMFORMAT_HPP
#define HLSSTREAMFORMAT_HPP
#include "../adaptative/StreamFormat.hpp"
#include <string>
namespace hls
{
using namespace adaptative;
class HLSStreamFormat : public StreamFormat
{
public:
static const unsigned UNKNOWN = StreamFormat::UNSUPPORTED + 1; /* will probe */
static const unsigned MPEG2TS = StreamFormat::UNSUPPORTED + 2;
static const unsigned PACKEDAAC = StreamFormat::UNSUPPORTED + 3;
};
}
#endif // HLSSTREAMFORMAT_HPP
......@@ -18,7 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "HLSStreams.hpp"
#include "HLSStreamFormat.hpp"
#include <vlc_demux.h>
using namespace hls;
......@@ -55,15 +54,15 @@ AbstractDemuxer * HLSStream::createDemux(const StreamFormat &format)
AbstractDemuxer *ret = NULL;
switch((unsigned)format)
{
case HLSStreamFormat::UNKNOWN:
case StreamFormat::UNKNOWN:
ret = new Demuxer(p_realdemux, "any", fakeesout->getEsOut(), demuxersource);
break;
case HLSStreamFormat::PACKEDAAC:
case StreamFormat::PACKEDAAC:
ret = new Demuxer(p_realdemux, "avformat", fakeesout->getEsOut(), demuxersource);
break;
case HLSStreamFormat::MPEG2TS:
case StreamFormat::MPEG2TS:
ret = new Demuxer(p_realdemux, "ts", fakeesout->getEsOut(), demuxersource);
break;
......@@ -85,7 +84,7 @@ AbstractDemuxer * HLSStream::createDemux(const StreamFormat &format)
void HLSStream::prepareFormatChange()
{
AbstractStream::prepareFormatChange();
if((unsigned)format == HLSStreamFormat::PACKEDAAC)
if((unsigned)format == StreamFormat::PACKEDAAC)
{
fakeesout->setTimestampOffset( i_aac_offset );
}
......
......@@ -20,7 +20,6 @@
#include "HLSSegment.hpp"
#include "../adaptative/playlist/SegmentChunk.hpp"
#include "../adaptative/playlist/BaseRepresentation.h"
#include "../HLSStreamFormat.hpp"
#include <vlc_common.h>
#include <vlc_block.h>
......
......@@ -29,7 +29,6 @@
#include "../adaptative/playlist/SegmentList.h"
#include "../adaptative/tools/Retrieve.hpp"
#include "../adaptative/tools/Helper.h"
#include "../HLSStreamFormat.hpp"
#include "M3U8.hpp"
#include "Tags.hpp"
......@@ -95,11 +94,11 @@ void M3U8Parser::setFormatFromCodecs(Representation *rep, const std::string code
std::string codec = codecs.front();
transform(codec.begin(), codec.end(), codec.begin(), (int (*)(int))std::tolower);
if(codec == "mp4a")
rep->streamFormat = StreamFormat(HLSStreamFormat::PACKEDAAC);
rep->streamFormat = StreamFormat(StreamFormat::PACKEDAAC);
}
else
{
rep->streamFormat = StreamFormat(HLSStreamFormat::MPEG2TS);
rep->streamFormat = StreamFormat(StreamFormat::MPEG2TS);
}
}
}
......@@ -113,11 +112,11 @@ void M3U8Parser::setFormatFromExtension(Representation *rep, const std::string &
transform(extension.begin(), extension.end(), extension.begin(), (int (*)(int))std::tolower);
if(extension == "aac")
{
rep->streamFormat = StreamFormat(HLSStreamFormat::PACKEDAAC);
rep->streamFormat = StreamFormat(StreamFormat::PACKEDAAC);
}
else if(extension == "ts" || extension == "mp2t" || extension == "mpeg")
{
rep->streamFormat = StreamFormat(HLSStreamFormat::MPEG2TS);
rep->streamFormat = StreamFormat(StreamFormat::MPEG2TS);
}
}
}
......@@ -256,7 +255,7 @@ void M3U8Parser::parseSegments(vlc_object_t *p_obj, Representation *rep, const s
break;
segment->setSourceUrl(uritag->getValue().value);
if((unsigned)rep->getStreamFormat() == HLSStreamFormat::UNKNOWN)
if((unsigned)rep->getStreamFormat() == StreamFormat::UNKNOWN)
setFormatFromExtension(rep, uritag->getValue().value);
if(ctx_extinf)
......@@ -455,7 +454,7 @@ M3U8 * M3U8Parser::parse(stream_t *p_stream, const std::string &playlisturl)
if(pair.second->getAttributeByName("TYPE")->value != "AUDIO" &&
pair.second->getAttributeByName("TYPE")->value != "VIDEO")
{
rep->streamFormat = StreamFormat(HLSStreamFormat::UNSUPPORTED);
rep->streamFormat = StreamFormat(StreamFormat::UNSUPPORTED);
}
if(pair.second->getAttributeByName("LANGUAGE"))
......
......@@ -29,7 +29,6 @@
#include "../adaptative/playlist/BasePeriod.h"
#include "../adaptative/playlist/BaseAdaptationSet.h"
#include "../adaptative/playlist/SegmentList.h"
#include "../HLSStreamFormat.hpp"
#include <ctime>
......@@ -43,7 +42,7 @@ Representation::Representation ( BaseAdaptationSet *set ) :
b_loaded = false;
switchpolicy = SegmentInformation::SWITCH_SEGMENT_ALIGNED; /* FIXME: based on streamformat */
nextPlaylistupdate = 0;
streamFormat = HLSStreamFormat::UNKNOWN;
streamFormat = StreamFormat::UNKNOWN;
}
Representation::~Representation ()
......
......@@ -23,7 +23,7 @@
#include "../adaptative/playlist/BaseRepresentation.h"
#include "../adaptative/tools/Properties.hpp"
#include "../HLSStreamFormat.hpp"
#include "../adaptative/StreamFormat.hpp"
namespace hls
{
......
......@@ -18,7 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "SmoothStream.hpp"
#include "SmoothStreamFormat.hpp"
#include <vlc_demux.h>
using namespace smooth;
......@@ -33,7 +32,7 @@ AbstractDemuxer * SmoothStream::createDemux(const StreamFormat &format)
AbstractDemuxer *ret = NULL;
switch((unsigned)format)
{
case SmoothStreamFormat::MP4:
case StreamFormat::MP4:
ret = new Demuxer(p_realdemux, "mp4", fakeesout->getEsOut(), demuxersource);
break;
......
/*
* SmoothStreamFormat.hpp
*****************************************************************************
* Copyright (C) 2015 - VideoLAN and VLC 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 SMOOTHSTREAMFORMAT_HPP
#define SMOOTHSTREAMFORMAT_HPP
#include "../adaptative/StreamFormat.hpp"
namespace smooth
{
using namespace adaptative;
class SmoothStreamFormat : public StreamFormat
{
public:
static const unsigned MP4 = StreamFormat::UNSUPPORTED + 1;
};
}
#endif // SMOOTHSTREAMFORMAT_HPP
......@@ -22,7 +22,6 @@
#include "../adaptative/playlist/SegmentTemplate.h"
#include "../adaptative/playlist/SegmentTimeline.h"
#include "../adaptative/playlist/BaseAdaptationSet.h"
#include "../SmoothStreamFormat.hpp"
using namespace smooth::playlist;
......@@ -38,7 +37,7 @@ Representation::~Representation ()
StreamFormat Representation::getStreamFormat() const
{
return StreamFormat(SmoothStreamFormat::MP4);
return StreamFormat(StreamFormat::MP4);
}
std::string Representation::contextualize(size_t number, const std::string &component,
......
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