Commit 8bc4eab8 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>
(cherry picked from commit 73b30f553150be24f2fb523d629fba788d18646b)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 694ae8e7
...@@ -34,7 +34,7 @@ using namespace dash::exception; ...@@ -34,7 +34,7 @@ using namespace dash::exception;
AbstractAdaptationLogic::AbstractAdaptationLogic (IMPDManager *mpdManager) AbstractAdaptationLogic::AbstractAdaptationLogic (IMPDManager *mpdManager)
{ {
this->bpsAvg = 0; this->bpsAvg = -1;
this->bpsLastChunk = 0; this->bpsLastChunk = 0;
this->mpdManager = mpdManager; this->mpdManager = mpdManager;
} }
......
...@@ -52,7 +52,7 @@ namespace dash ...@@ -52,7 +52,7 @@ namespace dash
long getBpsLastChunk (); long getBpsLastChunk ();
private: private:
long bpsAvg; int bpsAvg;
long bpsLastChunk; long bpsLastChunk;
dash::mpd::IMPDManager *mpdManager; dash::mpd::IMPDManager *mpdManager;
}; };
......
...@@ -161,6 +161,8 @@ void HTTPConnectionManager::attach (IDownloadRa ...@@ -161,6 +161,8 @@ void HTTPConnectionManager::attach (IDownloadRa
} }
void HTTPConnectionManager::notify () void HTTPConnectionManager::notify ()
{ {
if ( this->bpsAvg <= 0 )
return ;
for(size_t i = 0; i < this->rateObservers.size(); i++) for(size_t i = 0; i < this->rateObservers.size(); i++)
this->rateObservers.at(i)->downloadRateChanged(this->bpsAvg, this->bpsLastChunk); this->rateObservers.at(i)->downloadRateChanged(this->bpsAvg, this->bpsLastChunk);
} }
...@@ -91,38 +91,30 @@ Period* BasicCMManager::getFirstPeriod () ...@@ -91,38 +91,30 @@ Period* BasicCMManager::getFirstPeriod ()
return periods.at(0); return periods.at(0);
} }
Representation* BasicCMManager::getRepresentation (Period *period, long bitrate) Representation* BasicCMManager::getRepresentation(Period *period, int bitrate )
{ {
std::vector<Group *> groups = period->getGroups(); std::vector<Group *> groups = period->getGroups();
Representation *best = NULL; 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++) for(size_t i = 0; i < groups.size(); i++)
{ {
std::vector<Representation *> reps = groups.at(i)->getRepresentations(); 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(); int currentBitrate = reps.at(j)->getBandwidth();
assert( currentBitrate != -1 ); assert( currentBitrate != -1 );
int dif = bitrate - currentBitrate;
if( bestDif == -1 ) if ( best == NULL || bitrate == -1 ||
( currentBitrate > best->getBandwidth() &&
currentBitrate < bitrate ) )
{ {
bestDif = dif; std::cout << "Found a better Representation (#" << j << ") in group #" << i << std::endl;
best = reps.at(j); best = reps.at( j );
}
else
{
if ( dif >= 0 && dif < bestDif )
{
bestDif = dif;
best = reps.at(j);
}
} }
} }
} }
return best; return best;
} }
Period* BasicCMManager::getNextPeriod (Period *period) Period* BasicCMManager::getNextPeriod (Period *period)
......
...@@ -52,7 +52,7 @@ namespace dash ...@@ -52,7 +52,7 @@ namespace dash
Period* getNextPeriod( Period *period ); Period* getNextPeriod( Period *period );
Representation* getBestRepresentation( Period *period ); Representation* getBestRepresentation( Period *period );
std::vector<const Segment *> getSegments( Representation *rep ); std::vector<const Segment *> getSegments( Representation *rep );
Representation* getRepresentation( Period *period, long bitrate ); Representation* getRepresentation( Period *period, int bitrate );
const MPD* getMPD() const; const MPD* getMPD() const;
private: private:
......
...@@ -32,7 +32,7 @@ namespace dash ...@@ -32,7 +32,7 @@ namespace dash
virtual Period* getNextPeriod (Period *period) = 0; virtual Period* getNextPeriod (Period *period) = 0;
virtual Representation* getBestRepresentation (Period *period) = 0; virtual Representation* getBestRepresentation (Period *period) = 0;
virtual std::vector<const Segment *> getSegments (Representation *rep) = 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 const MPD* getMPD () const = 0;
virtual ~IMPDManager(){} 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