Commit bfe02ea6 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: fix quality switch policies

parent 0771fb4b
...@@ -62,7 +62,7 @@ Chunk * SegmentTracker::getNextChunk(StreamType type) ...@@ -62,7 +62,7 @@ Chunk * SegmentTracker::getNextChunk(StreamType type)
if(!currentPeriod) if(!currentPeriod)
return NULL; return NULL;
if(prevRepresentation && !prevRepresentation->canBitswitch()) if(prevRepresentation && prevRepresentation->getSwitchPolicy() == SegmentInformation::SWITCH_UNAVAILABLE)
rep = prevRepresentation; rep = prevRepresentation;
else else
rep = logic->getCurrentRepresentation(type, currentPeriod); rep = logic->getCurrentRepresentation(type, currentPeriod);
......
...@@ -69,7 +69,7 @@ void BaseAdaptationSet::addRepresentation(BaseRepresentation *rep) ...@@ -69,7 +69,7 @@ void BaseAdaptationSet::addRepresentation(BaseRepresentation *rep)
childs.push_back(rep); childs.push_back(rep);
} }
void BaseAdaptationSet::setBitstreamSwitching (bool value) void BaseAdaptationSet::setSwitchPolicy (bool value)
{ {
this->isBitstreamSwitching = value; this->isBitstreamSwitching = value;
} }
......
...@@ -47,7 +47,7 @@ namespace adaptative ...@@ -47,7 +47,7 @@ namespace adaptative
virtual const std::string& getMimeType() const; /*reimpl*/ virtual const std::string& getMimeType() const; /*reimpl*/
std::vector<BaseRepresentation *>& getRepresentations (); std::vector<BaseRepresentation *>& getRepresentations ();
void setBitstreamSwitching(bool value); void setSwitchPolicy(bool value);
bool getBitstreamSwitching() const; bool getBitstreamSwitching() const;
void addRepresentation( BaseRepresentation *rep ); void addRepresentation( BaseRepresentation *rep );
void debug(vlc_object_t *,int = 0) const; void debug(vlc_object_t *,int = 0) const;
......
...@@ -51,7 +51,7 @@ void SegmentInformation::init() ...@@ -51,7 +51,7 @@ void SegmentInformation::init()
segmentBase = NULL; segmentBase = NULL;
segmentList = NULL; segmentList = NULL;
mediaSegmentTemplate = NULL; mediaSegmentTemplate = NULL;
bitswitch_policy = BITSWITCH_INHERIT; switchpolicy = SWITCH_UNKNOWN;
} }
SegmentInformation::~SegmentInformation() SegmentInformation::~SegmentInformation()
...@@ -306,12 +306,12 @@ void SegmentInformation::pruneBySegmentNumber(uint64_t num) ...@@ -306,12 +306,12 @@ void SegmentInformation::pruneBySegmentNumber(uint64_t num)
childs.at(i)->pruneBySegmentNumber(num); childs.at(i)->pruneBySegmentNumber(num);
} }
bool SegmentInformation::canBitswitch() const SegmentInformation::SwitchPolicy SegmentInformation::getSwitchPolicy() const
{ {
if(bitswitch_policy == BITSWITCH_INHERIT) if(switchpolicy == SWITCH_UNKNOWN)
return (parent) ? parent->canBitswitch() : false; return (parent) ? parent->getSwitchPolicy() : SWITCH_UNAVAILABLE;
else else
return (bitswitch_policy == BITSWITCH_YES); return switchpolicy;
} }
mtime_t SegmentInformation::getPeriodStart() const mtime_t SegmentInformation::getPeriodStart() const
...@@ -385,9 +385,9 @@ void SegmentInformation::SplitUsingIndex(std::vector<SplitPoint> &splitlist) ...@@ -385,9 +385,9 @@ void SegmentInformation::SplitUsingIndex(std::vector<SplitPoint> &splitlist)
} }
} }
void SegmentInformation::setBitstreamSwitching(bool bitswitch) void SegmentInformation::setSwitchPolicy(SegmentInformation::SwitchPolicy policy)
{ {
bitswitch_policy = (bitswitch) ? BITSWITCH_YES : BITSWITCH_NO; switchpolicy = policy;
} }
Url SegmentInformation::getUrlSegment() const Url SegmentInformation::getUrlSegment() const
......
...@@ -54,7 +54,14 @@ namespace adaptative ...@@ -54,7 +54,14 @@ namespace adaptative
SegmentInformation( SegmentInformation * = 0 ); SegmentInformation( SegmentInformation * = 0 );
explicit SegmentInformation( AbstractPlaylist * ); explicit SegmentInformation( AbstractPlaylist * );
virtual ~SegmentInformation(); virtual ~SegmentInformation();
bool canBitswitch() const; typedef enum SwitchPolicy
{
SWITCH_UNKNOWN,
SWITCH_UNAVAILABLE,
SWITCH_SEGMENT_ALIGNED,
SWITCH_BITSWITCHEABLE
} SwitchPolicy;
SwitchPolicy getSwitchPolicy() const;
virtual mtime_t getPeriodStart() const; virtual mtime_t getPeriodStart() const;
virtual AbstractPlaylist *getPlaylist() const; virtual AbstractPlaylist *getPlaylist() const;
...@@ -87,12 +94,13 @@ namespace adaptative ...@@ -87,12 +94,13 @@ namespace adaptative
std::size_t getSegments(SegmentInfoType, std::vector<ISegment *>&, std::size_t * = NULL) const; std::size_t getSegments(SegmentInfoType, std::vector<ISegment *>&, std::size_t * = NULL) const;
std::vector<SegmentInformation *> childs; std::vector<SegmentInformation *> childs;
SegmentInformation *parent; SegmentInformation *parent;
SwitchPolicy switchpolicy;
public: public:
void setSegmentList(SegmentList *); void setSegmentList(SegmentList *);
void setSegmentBase(SegmentBase *); void setSegmentBase(SegmentBase *);
void setSegmentTemplate(MediaSegmentTemplate *); void setSegmentTemplate(MediaSegmentTemplate *);
void setBitstreamSwitching(bool); void setSwitchPolicy(SwitchPolicy);
virtual Url getUrlSegment() const; /* impl */ virtual Url getUrlSegment() const; /* impl */
Property<Url *> baseUrl; Property<Url *> baseUrl;
...@@ -105,13 +113,6 @@ namespace adaptative ...@@ -105,13 +113,6 @@ namespace adaptative
SegmentBase *segmentBase; SegmentBase *segmentBase;
SegmentList *segmentList; SegmentList *segmentList;
MediaSegmentTemplate *mediaSegmentTemplate; MediaSegmentTemplate *mediaSegmentTemplate;
enum BitswitchPolicy
{
BITSWITCH_INHERIT,
BITSWITCH_YES,
BITSWITCH_NO
} bitswitch_policy;
}; };
} }
} }
......
...@@ -196,8 +196,17 @@ size_t IsoffMainParser::parseSegmentInformation(Node *node, SegmentInformation * ...@@ -196,8 +196,17 @@ size_t IsoffMainParser::parseSegmentInformation(Node *node, SegmentInformation *
total += parseSegmentBase(DOMHelper::getFirstChildElementByName(node, "SegmentBase"), info); total += parseSegmentBase(DOMHelper::getFirstChildElementByName(node, "SegmentBase"), info);
total += parseSegmentList(DOMHelper::getFirstChildElementByName(node, "SegmentList"), info); total += parseSegmentList(DOMHelper::getFirstChildElementByName(node, "SegmentList"), info);
total += parseSegmentTemplate(DOMHelper::getFirstChildElementByName(node, "SegmentTemplate" ), info); total += parseSegmentTemplate(DOMHelper::getFirstChildElementByName(node, "SegmentTemplate" ), info);
if(node->hasAttribute("bitstreamSwitching")) if(node->hasAttribute("bitstreamSwitching") && node->getAttributeValue("bitstreamSwitching") == "true")
info->setBitstreamSwitching(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")) if(node->hasAttribute("timescale"))
info->timescale.Set(Integer<uint64_t>(node->getAttributeValue("timescale"))); info->timescale.Set(Integer<uint64_t>(node->getAttributeValue("timescale")));
return total; return total;
......
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