[vlc-commits] dash: For first segments, don't choose the lowest bitrate.
Hugo Beauzée-Luyssen
git at videolan.org
Fri Jan 6 12:40:39 CET 2012
vlc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Jan 5 15:50:38 2012 +0100| [73b30f553150be24f2fb523d629fba788d18646b] | committer: 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: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=73b30f553150be24f2fb523d629fba788d18646b
---
.../adaptationlogic/AbstractAdaptationLogic.cpp | 2 +-
.../dash/adaptationlogic/AbstractAdaptationLogic.h | 2 +-
.../dash/http/HTTPConnectionManager.cpp | 2 +
modules/stream_filter/dash/mpd/BasicCMManager.cpp | 28 +++++++------------
modules/stream_filter/dash/mpd/BasicCMManager.h | 2 +-
modules/stream_filter/dash/mpd/IMPDManager.h | 2 +-
6 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp b/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
index 5a5c1bc..dab9019 100644
--- a/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
+++ b/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
@@ -34,7 +34,7 @@ using namespace dash::exception;
AbstractAdaptationLogic::AbstractAdaptationLogic (IMPDManager *mpdManager)
{
- this->bpsAvg = 0;
+ this->bpsAvg = -1;
this->bpsLastChunk = 0;
this->mpdManager = mpdManager;
}
diff --git a/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h b/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
index e2fe566..88bf906 100644
--- a/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
+++ b/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
@@ -52,7 +52,7 @@ namespace dash
long getBpsLastChunk ();
private:
- long bpsAvg;
+ int bpsAvg;
long bpsLastChunk;
dash::mpd::IMPDManager *mpdManager;
};
diff --git a/modules/stream_filter/dash/http/HTTPConnectionManager.cpp b/modules/stream_filter/dash/http/HTTPConnectionManager.cpp
index 93c97e4..8dce57b 100644
--- a/modules/stream_filter/dash/http/HTTPConnectionManager.cpp
+++ b/modules/stream_filter/dash/http/HTTPConnectionManager.cpp
@@ -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);
}
diff --git a/modules/stream_filter/dash/mpd/BasicCMManager.cpp b/modules/stream_filter/dash/mpd/BasicCMManager.cpp
index e8b3167..21c86f5 100644
--- a/modules/stream_filter/dash/mpd/BasicCMManager.cpp
+++ b/modules/stream_filter/dash/mpd/BasicCMManager.cpp
@@ -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();
+ std::vector<Group *> groups = period->getGroups();
- Representation *best = NULL;
- int bestDif = -1;
+ Representation *best = NULL;
+ 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 )
+ if ( best == NULL || bitrate == -1 ||
+ ( currentBitrate > best->getBandwidth() &&
+ currentBitrate < bitrate ) )
{
- bestDif = dif;
- best = reps.at(j);
- }
- else
- {
- 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)
diff --git a/modules/stream_filter/dash/mpd/BasicCMManager.h b/modules/stream_filter/dash/mpd/BasicCMManager.h
index f38da3c..b09deae 100644
--- a/modules/stream_filter/dash/mpd/BasicCMManager.h
+++ b/modules/stream_filter/dash/mpd/BasicCMManager.h
@@ -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:
diff --git a/modules/stream_filter/dash/mpd/IMPDManager.h b/modules/stream_filter/dash/mpd/IMPDManager.h
index 16494d7..58068b5 100644
--- a/modules/stream_filter/dash/mpd/IMPDManager.h
+++ b/modules/stream_filter/dash/mpd/IMPDManager.h
@@ -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(){}
};
More information about the vlc-commits
mailing list