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

demux: adaptative: fix quality switch policies

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