Commit 73b30f55 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Jean-Baptiste Kempf

dash: For first segments, don't choose the lowest bitrate.

For some streams, the lowest bitrate is an audio stream only. We will
fall back to a more appropriate stream after a few chunks.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 98a01d40
......@@ -34,7 +34,7 @@ using namespace dash::exception;
AbstractAdaptationLogic::AbstractAdaptationLogic (IMPDManager *mpdManager)
{
this->bpsAvg = 0;
this->bpsAvg = -1;
this->bpsLastChunk = 0;
this->mpdManager = mpdManager;
}
......
......@@ -52,7 +52,7 @@ namespace dash
long getBpsLastChunk ();
private:
long bpsAvg;
int bpsAvg;
long bpsLastChunk;
dash::mpd::IMPDManager *mpdManager;
};
......
......@@ -161,6 +161,8 @@ void HTTPConnectionManager::attach (IDownloadRa
}
void HTTPConnectionManager::notify ()
{
if ( this->bpsAvg <= 0 )
return ;
for(size_t i = 0; i < this->rateObservers.size(); i++)
this->rateObservers.at(i)->downloadRateChanged(this->bpsAvg, this->bpsLastChunk);
}
......@@ -91,38 +91,30 @@ Period* BasicCMManager::getFirstPeriod ()
return periods.at(0);
}
Representation* BasicCMManager::getRepresentation (Period *period, long bitrate)
Representation* BasicCMManager::getRepresentation(Period *period, int bitrate )
{
std::vector<Group *> groups = period->getGroups();
Representation *best = NULL;
int bestDif = -1;
std::cout << "Sarching for best representation with bitrate: " << bitrate << std::endl;
for(size_t i = 0; i < groups.size(); i++)
{
std::vector<Representation *> reps = groups.at(i)->getRepresentations();
for(size_t j = 0; j < reps.size(); j++)
for( size_t j = 0; j < reps.size(); j++ )
{
int currentBitrate = reps.at(j)->getBandwidth();
assert( currentBitrate != -1 );
int dif = bitrate - currentBitrate;
if( bestDif == -1 )
{
bestDif = dif;
best = reps.at(j);
}
else
if ( best == NULL || bitrate == -1 ||
( currentBitrate > best->getBandwidth() &&
currentBitrate < bitrate ) )
{
if ( dif >= 0 && dif < bestDif )
{
bestDif = dif;
best = reps.at(j);
std::cout << "Found a better Representation (#" << j << ") in group #" << i << std::endl;
best = reps.at( j );
}
}
}
}
return best;
}
Period* BasicCMManager::getNextPeriod (Period *period)
......
......@@ -52,7 +52,7 @@ namespace dash
Period* getNextPeriod( Period *period );
Representation* getBestRepresentation( Period *period );
std::vector<const Segment *> getSegments( Representation *rep );
Representation* getRepresentation( Period *period, long bitrate );
Representation* getRepresentation( Period *period, int bitrate );
const MPD* getMPD() const;
private:
......
......@@ -32,7 +32,7 @@ namespace dash
virtual Period* getNextPeriod (Period *period) = 0;
virtual Representation* getBestRepresentation (Period *period) = 0;
virtual std::vector<const Segment *> getSegments (Representation *rep) = 0;
virtual Representation* getRepresentation (Period *period, long bitrate) = 0;
virtual Representation* getRepresentation (Period *period, int bitrate) = 0;
virtual const MPD* getMPD () const = 0;
virtual ~IMPDManager(){}
};
......
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