vlc | branch: master | Francois Cartegnie <[email protected]> | Thu Apr 25 18:07:44 2019 +0200| [ce813fa7c9e0b0d6b45ac7d0f5540e159ae47203] | committer: Francois Cartegnie
demux: adaptive: fix bitswitch/segment alignment use > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ce813fa7c9e0b0d6b45ac7d0f5540e159ae47203 --- modules/demux/adaptive/SegmentTracker.cpp | 2 +- .../demux/adaptive/playlist/BaseAdaptationSet.cpp | 23 ++++++++++++++++------ .../demux/adaptive/playlist/BaseAdaptationSet.h | 9 ++++++--- .../demux/adaptive/playlist/SegmentInformation.cpp | 14 ------------- .../demux/adaptive/playlist/SegmentInformation.hpp | 18 ++++++++--------- modules/demux/dash/mpd/IsoffMainParser.cpp | 17 ++++++---------- modules/demux/hls/playlist/Parser.cpp | 1 + modules/demux/hls/playlist/Representation.cpp | 1 - modules/demux/smooth/playlist/Representation.cpp | 1 - 9 files changed, 39 insertions(+), 47 deletions(-) diff --git a/modules/demux/adaptive/SegmentTracker.cpp b/modules/demux/adaptive/SegmentTracker.cpp index 321488a8fb..2d4fcf332f 100644 --- a/modules/demux/adaptive/SegmentTracker.cpp +++ b/modules/demux/adaptive/SegmentTracker.cpp @@ -154,7 +154,7 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed, } if( !switch_allowed || - (curRepresentation && curRepresentation->getSwitchPolicy() == SegmentInformation::SWITCH_UNAVAILABLE) ) + (curRepresentation && !curRepresentation->getAdaptationSet()->isSegmentAligned()) ) rep = curRepresentation; else rep = logic->getNextRepresentation(adaptationSet, curRepresentation); diff --git a/modules/demux/adaptive/playlist/BaseAdaptationSet.cpp b/modules/demux/adaptive/playlist/BaseAdaptationSet.cpp index 8915cbf524..89d87f6834 100644 --- a/modules/demux/adaptive/playlist/BaseAdaptationSet.cpp +++ b/modules/demux/adaptive/playlist/BaseAdaptationSet.cpp @@ -43,9 +43,10 @@ using namespace adaptive::playlist; BaseAdaptationSet::BaseAdaptationSet(BasePeriod *period) : CommonAttributesElements(), - SegmentInformation( period ), - isBitstreamSwitching( false ) + SegmentInformation( period ) { + segmentAligned = TRIBOOL_UNKNOWN; + bitswitchAble = TRIBOOL_UNKNOWN; } BaseAdaptationSet::~BaseAdaptationSet () @@ -88,14 +89,24 @@ void BaseAdaptationSet::addRepresentation(BaseRepresentation *rep) childs.push_back(rep); } -void BaseAdaptationSet::setSwitchPolicy (bool value) +void BaseAdaptationSet::setSegmentAligned(bool b) { - this->isBitstreamSwitching = value; + segmentAligned = b ? TRIBOOL_TRUE : TRIBOOL_FALSE; } -bool BaseAdaptationSet::getBitstreamSwitching () const +void BaseAdaptationSet::setBitswitchAble(bool b) { - return this->isBitstreamSwitching; + bitswitchAble = b ? TRIBOOL_TRUE : TRIBOOL_FALSE; +} + +bool BaseAdaptationSet::isSegmentAligned() const +{ + return segmentAligned != TRIBOOL_FALSE; +} + +bool BaseAdaptationSet::isBitSwitchable() const +{ + return bitswitchAble == TRIBOOL_TRUE; } void BaseAdaptationSet::debug(vlc_object_t *obj, int indent) const diff --git a/modules/demux/adaptive/playlist/BaseAdaptationSet.h b/modules/demux/adaptive/playlist/BaseAdaptationSet.h index c7c7ddfbb4..c1688280f3 100644 --- a/modules/demux/adaptive/playlist/BaseAdaptationSet.h +++ b/modules/demux/adaptive/playlist/BaseAdaptationSet.h @@ -51,15 +51,18 @@ namespace adaptive virtual StreamFormat getStreamFormat() const; /*reimpl*/ std::vector<BaseRepresentation *>& getRepresentations (); BaseRepresentation * getRepresentationByID(const ID &); - void setSwitchPolicy(bool value); - bool getBitstreamSwitching() const; + void setSegmentAligned(bool); + bool isSegmentAligned() const; + void setBitswitchAble(bool); + bool isBitSwitchable() const; void addRepresentation( BaseRepresentation *rep ); void debug(vlc_object_t *,int = 0) const; Property<std::string> description; protected: std::vector<BaseRepresentation *> representations; - bool isBitstreamSwitching; + Tribool segmentAligned; + Tribool bitswitchAble; }; } } diff --git a/modules/demux/adaptive/playlist/SegmentInformation.cpp b/modules/demux/adaptive/playlist/SegmentInformation.cpp index 09740fd6d8..ba5e4e30c7 100644 --- a/modules/demux/adaptive/playlist/SegmentInformation.cpp +++ b/modules/demux/adaptive/playlist/SegmentInformation.cpp @@ -58,7 +58,6 @@ void SegmentInformation::init() segmentBase = NULL; segmentList = NULL; mediaSegmentTemplate = NULL; - switchpolicy = SWITCH_UNKNOWN; } SegmentInformation::~SegmentInformation() @@ -511,14 +510,6 @@ uint64_t SegmentInformation::translateSegmentNumber(uint64_t num, const SegmentI return num; } -SegmentInformation::SwitchPolicy SegmentInformation::getSwitchPolicy() const -{ - if(switchpolicy == SWITCH_UNKNOWN) - return (parent) ? parent->getSwitchPolicy() : SWITCH_UNAVAILABLE; - else - return switchpolicy; -} - vlc_tick_t SegmentInformation::getPeriodStart() const { if(parent) @@ -612,11 +603,6 @@ void SegmentInformation::SplitUsingIndex(std::vector<SplitPoint> &splitlist) } } -void SegmentInformation::setSwitchPolicy(SegmentInformation::SwitchPolicy policy) -{ - switchpolicy = policy; -} - Url SegmentInformation::getUrlSegment() const { if(baseUrl.Get() && baseUrl.Get()->hasScheme()) diff --git a/modules/demux/adaptive/playlist/SegmentInformation.hpp b/modules/demux/adaptive/playlist/SegmentInformation.hpp index 74633b033b..0307d90985 100644 --- a/modules/demux/adaptive/playlist/SegmentInformation.hpp +++ b/modules/demux/adaptive/playlist/SegmentInformation.hpp @@ -37,6 +37,13 @@ namespace adaptive class AbstractPlaylist; class ISegment; + enum Tribool + { + TRIBOOL_UNKNOWN, + TRIBOOL_FALSE, + TRIBOOL_TRUE, + }; + /* common segment elements for period/adaptset/rep 5.3.9.1, * with properties inheritance */ class SegmentInformation : public ICanonicalUrl, @@ -48,14 +55,7 @@ namespace adaptive SegmentInformation( SegmentInformation * = 0 ); explicit SegmentInformation( AbstractPlaylist * ); virtual ~SegmentInformation(); - typedef enum SwitchPolicy - { - SWITCH_UNKNOWN, - SWITCH_UNAVAILABLE, - SWITCH_SEGMENT_ALIGNED, - SWITCH_BITSWITCHEABLE - } SwitchPolicy; - SwitchPolicy getSwitchPolicy() const; + virtual vlc_tick_t getPeriodStart() const; virtual AbstractPlaylist *getPlaylist() const; @@ -93,13 +93,11 @@ namespace adaptive std::vector<SegmentInformation *> childs; SegmentInformation * getChildByID( const ID & ); SegmentInformation *parent; - SwitchPolicy switchpolicy; public: void appendSegmentList(SegmentList *, bool = false); void setSegmentBase(SegmentBase *); void setSegmentTemplate(MediaSegmentTemplate *); - void setSwitchPolicy(SwitchPolicy); virtual Url getUrlSegment() const; /* impl */ Property<Url *> baseUrl; diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp index d378c4e548..f742dd206c 100644 --- a/modules/demux/dash/mpd/IsoffMainParser.cpp +++ b/modules/demux/dash/mpd/IsoffMainParser.cpp @@ -205,17 +205,6 @@ size_t IsoffMainParser::parseSegmentInformation(Node *node, SegmentInformation * total += parseSegmentBase(DOMHelper::getFirstChildElementByName(node, "SegmentBase"), info); total += parseSegmentList(DOMHelper::getFirstChildElementByName(node, "SegmentList"), info); total += parseSegmentTemplate(DOMHelper::getFirstChildElementByName(node, "SegmentTemplate" ), info); - if(node->hasAttribute("bitstreamSwitching") && node->getAttributeValue("bitstreamSwitching") == "true") - { - info->setSwitchPolicy(SegmentInformation::SWITCH_BITSWITCHEABLE); - } - else if(node->hasAttribute("segmentAlignment")) - { - if( node->getAttributeValue("segmentAlignment") == "true" ) - info->setSwitchPolicy(SegmentInformation::SWITCH_SEGMENT_ALIGNED); - else - info->setSwitchPolicy(SegmentInformation::SWITCH_UNAVAILABLE); - } if(node->hasAttribute("timescale")) info->setTimescale(Integer<uint64_t>(node->getAttributeValue("timescale"))); @@ -251,6 +240,12 @@ void IsoffMainParser::parseAdaptationSets (Node *periodNode, Period *period) adaptationSet->addLang(lang); } + if((*it)->hasAttribute("bitstreamSwitching")) + adaptationSet->setBitswitchAble((*it)->getAttributeValue("bitstreamSwitching") == "true"); + + if((*it)->hasAttribute("segmentAlignment")) + adaptationSet->setSegmentAligned((*it)->getAttributeValue("segmentAlignment") == "true"); + Node *baseUrl = DOMHelper::getFirstChildElementByName((*it), "BaseURL"); if(baseUrl) adaptationSet->baseUrl.Set(new Url(baseUrl->getText())); diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp index 5d67e160a2..db4d72bbef 100644 --- a/modules/demux/hls/playlist/Parser.cpp +++ b/modules/demux/hls/playlist/Parser.cpp @@ -430,6 +430,7 @@ M3U8 * M3U8Parser::parse(vlc_object_t *p_object, stream_t *p_stream, const std:: BaseAdaptationSet *adaptSet = new (std::nothrow) BaseAdaptationSet(period); if(adaptSet) { + /* adaptSet->setSegmentAligned(true); FIXME: based on streamformat */ std::list<Tag *> streaminfotags = getTagsFromList(tagslist, AttributesTag::EXTXSTREAMINF); for(it = streaminfotags.begin(); it != streaminfotags.end(); ++it) { diff --git a/modules/demux/hls/playlist/Representation.cpp b/modules/demux/hls/playlist/Representation.cpp index 24722eb26d..10ada80508 100644 --- a/modules/demux/hls/playlist/Representation.cpp +++ b/modules/demux/hls/playlist/Representation.cpp @@ -42,7 +42,6 @@ Representation::Representation ( BaseAdaptationSet *set ) : { b_live = true; b_loaded = false; - switchpolicy = SegmentInformation::SWITCH_SEGMENT_ALIGNED; /* FIXME: based on streamformat */ nextUpdateTime = 0; targetDuration = 0; streamFormat = StreamFormat::UNKNOWN; diff --git a/modules/demux/smooth/playlist/Representation.cpp b/modules/demux/smooth/playlist/Representation.cpp index 98ba66816e..7a14ebc115 100644 --- a/modules/demux/smooth/playlist/Representation.cpp +++ b/modules/demux/smooth/playlist/Representation.cpp @@ -32,7 +32,6 @@ using namespace smooth::playlist; Representation::Representation ( BaseAdaptationSet *set ) : BaseRepresentation( set ) { - switchpolicy = SegmentInformation::SWITCH_SEGMENT_ALIGNED; } Representation::~Representation () _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
