vlc | branch: master | Francois Cartegnie <fcvlc...@free.fr> | Sun Nov 23 14:20:09 2014 +0100| [0b80d62097623b46a7f1abb1b9c8180a002b3606] | committer: Francois Cartegnie
stream_filter: dash: add subsegments We'll need to split single file, ranged chunks > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0b80d62097623b46a7f1abb1b9c8180a002b3606 --- .../adaptationlogic/AlwaysBestAdaptationLogic.cpp | 2 +- modules/stream_filter/dash/mpd/Segment.cpp | 136 +++++++++++++++----- modules/stream_filter/dash/mpd/Segment.h | 56 ++++++-- 3 files changed, 150 insertions(+), 44 deletions(-) diff --git a/modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp b/modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp index 568174d..c35ea2b 100644 --- a/modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp +++ b/modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp @@ -58,7 +58,7 @@ Chunk* AlwaysBestAdaptationLogic::getNextChunk() const Representation *AlwaysBestAdaptationLogic::getCurrentRepresentation() const { if ( this->count < this->schedule.size() ) - return this->schedule.at( this->count )->getParentRepresentation(); + return this->schedule.at( this->count )->getRepresentation(); return NULL; } diff --git a/modules/stream_filter/dash/mpd/Segment.cpp b/modules/stream_filter/dash/mpd/Segment.cpp index 1649108..93d87b2 100644 --- a/modules/stream_filter/dash/mpd/Segment.cpp +++ b/modules/stream_filter/dash/mpd/Segment.cpp @@ -33,12 +33,56 @@ using namespace dash::mpd; using namespace dash::http; -Segment::Segment(const Representation *parent, bool isinit) : - ICanonicalUrl( parent ), - startByte (0), - endByte (0), +ISegment::ISegment(const ICanonicalUrl *parent): + ICanonicalUrl( parent ), + startByte (0), + endByte (0) +{ + +} + +dash::http::Chunk* ISegment::toChunk() const +{ + Chunk *chunk = new Chunk(); + if (!chunk) + return NULL; + + if(startByte != endByte) + { + chunk->setStartByte(startByte); + chunk->setEndByte(endByte); + } + + chunk->setUrl(getUrlSegment()); + + return chunk; +} + +bool ISegment::isSingleShot() const +{ + return true; +} +void ISegment::done() +{ + //Only used for a SegmentTemplate. +} + +void ISegment::setByteRange(size_t start, size_t end) +{ + startByte = start; + endByte = end; +} + +std::string ISegment::toString() const +{ + return std::string(" Segment url=").append(getUrlSegment()); +} + +Segment::Segment(Representation *parent, bool isinit, bool tosplit) : + ISegment(parent), parentRepresentation( parent ), - init( isinit ) + init( isinit ), + needssplit( tosplit ) { assert( parent != NULL ); if ( parent->getSegmentInfo() != NULL && parent->getSegmentInfo()->getDuration() >= 0 ) @@ -47,57 +91,89 @@ Segment::Segment(const Representation *parent, bool isinit) : this->size = -1; } +Segment::~Segment() +{ + std::vector<SubSegment*>::iterator it; + for(it=subsegments.begin();it!=subsegments.end();it++) + delete *it; +} + void Segment::setSourceUrl ( const std::string &url ) { if ( url.empty() == false ) this->sourceUrl = url; } -bool Segment::isSingleShot () const + +bool Segment::needsSplit() const { - return true; + return needssplit; } -void Segment::done () + +Representation *Segment::getRepresentation() const { - //Only used for a SegmentTemplate. + return parentRepresentation; } -void Segment::setByteRange (int start, int end) +std::string Segment::getUrlSegment() const { - this->startByte = start; - this->endByte = end; + std::string ret = getParentUrlSegment(); + if (!sourceUrl.empty()) + ret.append(sourceUrl); + return ret; } -dash::http::Chunk* Segment::toChunk () +dash::http::Chunk* Segment::toChunk() const { - Chunk *chunk = new Chunk(); + Chunk *chunk = ISegment::toChunk(); + if (chunk) + chunk->setBitrate(parentRepresentation->getBandwidth()); + return chunk; +} - if(startByte != endByte) +std::vector<ISegment*> Segment::subSegments() +{ + std::vector<ISegment*> list; + if(!subsegments.empty()) { - chunk->setStartByte(startByte); - chunk->setEndByte(endByte); + std::vector<SubSegment*>::iterator it; + for(it=subsegments.begin();it!=subsegments.end();it++) + list.push_back(*it); } + else + { + list.push_back(this); + } + return list; +} - chunk->setUrl( getUrlSegment() ); - - chunk->setBitrate(this->parentRepresentation->getBandwidth()); +std::string Segment::toString() const +{ + if (init) + return std::string(" InitSeg url=") + .append(getUrlSegment()); + else + return ISegment::toString(); +} - return chunk; +SubSegment::SubSegment(Segment *main, size_t start, size_t end) : + ISegment(main), parent(main) +{ + setByteRange(start, end); } -const Representation *Segment::getParentRepresentation() const +std::string SubSegment::getUrlSegment() const { - return this->parentRepresentation; + return getParentUrlSegment(); } -std::string Segment::getUrlSegment() const +std::vector<ISegment*> SubSegment::subSegments() { - std::string ret = getParentUrlSegment(); - if (!sourceUrl.empty()) - ret.append(sourceUrl); - return ret; + std::vector<ISegment*> list; + list.push_back(this); + return list; } -bool Segment::isInit() const +Representation *SubSegment::getRepresentation() const { - return init; + return parent->getRepresentation(); } diff --git a/modules/stream_filter/dash/mpd/Segment.h b/modules/stream_filter/dash/mpd/Segment.h index 65b8164..29edae9 100644 --- a/modules/stream_filter/dash/mpd/Segment.h +++ b/modules/stream_filter/dash/mpd/Segment.h @@ -37,32 +37,62 @@ namespace dash namespace mpd { class Representation; - class Segment : public ICanonicalUrl + class SubSegment; + + class ISegment : public ICanonicalUrl { public: - Segment( const Representation *parent, bool isinit = false ); - virtual ~Segment(){} - virtual void setSourceUrl( const std::string &url ); + ISegment(const ICanonicalUrl *parent); + virtual ~ISegment(){} /** * @return true if the segment should be dropped after being read. * That is basically true when using an Url, and false * when using an UrlTemplate */ virtual bool isSingleShot () const; - virtual bool isInit () const; virtual void done (); - virtual void setByteRange (int start, int end); - virtual dash::http::Chunk* toChunk (); - const Representation* getParentRepresentation() const; - virtual std::string getUrlSegment () const; /* impl */ + virtual dash::http::Chunk* toChunk () const; + virtual void setByteRange (size_t start, size_t end); + virtual std::vector<ISegment*> subSegments () = 0; + virtual std::string toString () const; + virtual Representation* getRepresentation() const = 0; protected: - std::string sourceUrl; size_t startByte; size_t endByte; - const Representation* parentRepresentation; - int size; - bool init; + }; + + class Segment : public ISegment + { + public: + Segment( Representation *parent, bool isinit = false, bool tosplit = false ); + ~Segment(); + virtual void setSourceUrl( const std::string &url ); + virtual bool needsSplit() const; + virtual std::string getUrlSegment() const; /* impl */ + virtual dash::http::Chunk* toChunk() const; + virtual std::vector<ISegment*> subSegments(); + virtual std::string toString() const; + virtual Representation* getRepresentation() const; + + protected: + Representation* parentRepresentation; + bool init; + bool needssplit; + std::vector<SubSegment *> subsegments; + std::string sourceUrl; + int size; + }; + + class SubSegment : public ISegment + { + public: + SubSegment(Segment *, size_t start, size_t end); + virtual std::string getUrlSegment() const; /* impl */ + virtual std::vector<ISegment*> subSegments(); + virtual Representation* getRepresentation() const; + private: + Segment *parent; }; } } _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits