Commit 2d35944b authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptive: keep representations ordered by bandwidth

parent a2f8c97c
......@@ -36,6 +36,8 @@
#include "BasePeriod.h"
#include "Inheritables.hpp"
#include <algorithm>
using namespace adaptive;
using namespace adaptive::playlist;
......@@ -78,7 +80,11 @@ BaseRepresentation * BaseAdaptationSet::getRepresentationByID(const ID &id)
void BaseAdaptationSet::addRepresentation(BaseRepresentation *rep)
{
representations.push_back(rep);
representations.insert(std::upper_bound(representations.begin(),
representations.end(),
rep,
BaseRepresentation::bwCompare),
rep);
childs.push_back(rep);
}
......
......@@ -156,6 +156,12 @@ std::string BaseRepresentation::contextualize(size_t, const std::string &compone
return component;
}
bool BaseRepresentation::bwCompare(const BaseRepresentation *a,
const BaseRepresentation *b)
{
return a->getBandwidth() < b->getBandwidth();
}
bool BaseRepresentation::validateCodec(const std::string &) const
{
return true;
......
......@@ -73,6 +73,8 @@ namespace adaptive
virtual std::string contextualize(size_t, const std::string &,
const BaseSegmentTemplate *) const;
static bool bwCompare(const BaseRepresentation *a,
const BaseRepresentation *b);
protected:
virtual bool validateCodec(const std::string &) const;
BaseAdaptationSet *adaptationSet;
......
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