Commit 78b1c032 authored by Francois Cartegnie's avatar Francois Cartegnie

stream_filter: dash: return lowest representation if none match bw

parent 2a852751
...@@ -46,7 +46,11 @@ Representation * RepresentationSelector::select(Period *period, uint64_t bitrate ...@@ -46,7 +46,11 @@ Representation * RepresentationSelector::select(Period *period, uint64_t bitrate
std::vector<Representation *> reps = (*adaptIt)->getRepresentations(); std::vector<Representation *> reps = (*adaptIt)->getRepresentations();
Representation *candidate = select(reps, (best)?best->getBandwidth():0, bitrate); Representation *candidate = select(reps, (best)?best->getBandwidth():0, bitrate);
if (candidate) if (candidate)
{
if (candidate->getBandwidth() > bitrate) /* none matched, returned lowest */
return candidate;
best = candidate; best = candidate;
}
} }
return best; return best;
} }
...@@ -82,10 +86,13 @@ Representation * RepresentationSelector::select(Period *period, uint64_t bitrate ...@@ -82,10 +86,13 @@ Representation * RepresentationSelector::select(Period *period, uint64_t bitrate
Representation * RepresentationSelector::select(std::vector<Representation *>& reps, Representation * RepresentationSelector::select(std::vector<Representation *>& reps,
uint64_t minbitrate, uint64_t maxbitrate) const uint64_t minbitrate, uint64_t maxbitrate) const
{ {
Representation *candidate = NULL; Representation *candidate = NULL, *lowest = NULL;
std::vector<Representation *>::const_iterator repIt; std::vector<Representation *>::const_iterator repIt;
for(repIt=reps.begin(); repIt!=reps.end(); repIt++) for(repIt=reps.begin(); repIt!=reps.end(); repIt++)
{ {
if ( !lowest || (*repIt)->getBandwidth() < lowest->getBandwidth())
lowest = *repIt;
if ( (*repIt)->getBandwidth() < maxbitrate && if ( (*repIt)->getBandwidth() < maxbitrate &&
(*repIt)->getBandwidth() > minbitrate ) (*repIt)->getBandwidth() > minbitrate )
{ {
...@@ -93,5 +100,9 @@ Representation * RepresentationSelector::select(std::vector<Representation *>& r ...@@ -93,5 +100,9 @@ Representation * RepresentationSelector::select(std::vector<Representation *>& r
minbitrate = (*repIt)->getBandwidth(); minbitrate = (*repIt)->getBandwidth();
} }
} }
if (!candidate)
return candidate = lowest;
return candidate; return candidate;
} }
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