]> git.sesse.net Git - vlc/commitdiff
dash: For first segments, don't choose the lowest bitrate.
authorHugo Beauzée-Luyssen <beauze.h@gmail.com>
Thu, 5 Jan 2012 14:50:38 +0000 (15:50 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 6 Jan 2012 11:40:39 +0000 (12:40 +0100)
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@videolan.org>
modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
modules/stream_filter/dash/http/HTTPConnectionManager.cpp
modules/stream_filter/dash/mpd/BasicCMManager.cpp
modules/stream_filter/dash/mpd/BasicCMManager.h
modules/stream_filter/dash/mpd/IMPDManager.h

index 5a5c1bc3a3e1e6ab0fd6307bc3e2757f78ea6b17..dab90191cb6ce9155b82feda1b38cdf7fb0121b1 100644 (file)
@@ -34,7 +34,7 @@ using namespace dash::exception;
 
 AbstractAdaptationLogic::AbstractAdaptationLogic    (IMPDManager *mpdManager)
 {
-    this->bpsAvg        = 0;
+    this->bpsAvg        = -1;
     this->bpsLastChunk  = 0;
     this->mpdManager    = mpdManager;
 }
index e2fe566e6ce9d803b077b032a49c5c4205080848..88bf9069118b48a2a49c9d0db1ef50854bd33d6d 100644 (file)
@@ -52,7 +52,7 @@ namespace dash
                 long                        getBpsLastChunk         ();
 
             private:
-                long                    bpsAvg;
+                int                     bpsAvg;
                 long                    bpsLastChunk;
                 dash::mpd::IMPDManager  *mpdManager;
         };
index 93c97e4c8b50c86df9ff36ff3a9dea657e4b6e91..8dce57b40af2a70eac665ff22d714337cfad2369 100644 (file)
@@ -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);
 }
index e8b316736bf50ef3849732a10a063bd2072a75ef..21c86f5ce1c7c72574b5810b17d4a276caa6b225 100644 (file)
@@ -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)
index f38da3c6675557a6bfd1f0b481199f02eabeff4d..b09deaee12605736c7b4092408cfefe46944818e 100644 (file)
@@ -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:
index 16494d750d37eb68459d1ba94a36c829a86c1f49..58068b539d974f1f54b927945d8deff02cd463bb 100644 (file)
@@ -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(){}
         };