[vlc-commits] demux: dash: add fixed rate adaptation policy

Francois Cartegnie git at videolan.org
Thu Dec 18 22:39:59 CET 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Dec 18 21:44:25 2014 +0100| [6ba79d21b2fa7e80059f46a71ac0322269fbb6d7] | committer: Francois Cartegnie

demux: dash: add fixed rate adaptation policy

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6ba79d21b2fa7e80059f46a71ac0322269fbb6d7
---

 .../adaptationlogic/AdaptationLogicFactory.cpp     |    3 ++-
 .../dash/adaptationlogic/IAdaptationLogic.h        |    3 ++-
 .../adaptationlogic/RateBasedAdaptationLogic.cpp   |   22 ++++++++++++++++++++
 .../adaptationlogic/RateBasedAdaptationLogic.h     |   11 ++++++++++
 modules/stream_filter/dash/dash.cpp                |    6 +++++-
 5 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp b/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp
index 2858c36..aef3416 100644
--- a/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp
+++ b/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp
@@ -39,9 +39,10 @@ IAdaptationLogic* AdaptationLogicFactory::create ( IAdaptationLogic::LogicType l
     switch(logic)
     {
         case IAdaptationLogic::AlwaysBest:      return new AlwaysBestAdaptationLogic    (mpd);
-        case IAdaptationLogic::RateBased:       return new RateBasedAdaptationLogic     (mpd);
         case IAdaptationLogic::AlwaysLowest:    return new AlwaysLowestAdaptationLogic  (mpd);
+        case IAdaptationLogic::FixedRate:       return new FixedRateAdaptationLogic     (mpd);
         case IAdaptationLogic::Default:
+        case IAdaptationLogic::RateBased:       return new RateBasedAdaptationLogic     (mpd);
         default:
             return NULL;
     }
diff --git a/modules/stream_filter/dash/adaptationlogic/IAdaptationLogic.h b/modules/stream_filter/dash/adaptationlogic/IAdaptationLogic.h
index e712291..a08e784 100644
--- a/modules/stream_filter/dash/adaptationlogic/IAdaptationLogic.h
+++ b/modules/stream_filter/dash/adaptationlogic/IAdaptationLogic.h
@@ -44,7 +44,8 @@ namespace dash
                     Default,
                     AlwaysBest,
                     AlwaysLowest,
-                    RateBased
+                    RateBased,
+                    FixedRate
                 };
 
                 virtual dash::http::Chunk*                  getNextChunk            (Streams::Type) = 0;
diff --git a/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.cpp b/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.cpp
index e831522..8851190 100644
--- a/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.cpp
+++ b/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.cpp
@@ -76,3 +76,25 @@ void RateBasedAdaptationLogic::updateDownloadRate(size_t size, mtime_t time)
     if(bpsSamplecount % 5 == 0)
         currentBps = bpsAvg;
 }
+
+FixedRateAdaptationLogic::FixedRateAdaptationLogic(mpd::MPD *mpd) :
+    AbstractAdaptationLogic(mpd)
+{
+    currentBps = var_InheritInteger( mpd->getVLCObject(), "dash-prefbw" ) * 8192;
+}
+
+Representation *FixedRateAdaptationLogic::getCurrentRepresentation(Streams::Type type) const
+{
+    if(currentPeriod == NULL)
+        return NULL;
+
+    RepresentationSelector selector;
+    Representation *rep = selector.select(currentPeriod, type, currentBps);
+    if ( rep == NULL )
+    {
+        rep = selector.select(currentPeriod, type);
+        if ( rep == NULL )
+            return NULL;
+    }
+    return rep;
+}
diff --git a/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.h b/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.h
index a962be4..105069a 100644
--- a/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.h
+++ b/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.h
@@ -48,6 +48,17 @@ namespace dash
                 size_t                  bpsSamplecount;
                 size_t                  currentBps;
         };
+
+        class FixedRateAdaptationLogic : public AbstractAdaptationLogic
+        {
+            public:
+                FixedRateAdaptationLogic(mpd::MPD *mpd);
+
+                dash::mpd::Representation *getCurrentRepresentation(Streams::Type) const;
+
+            private:
+                size_t                  currentBps;
+        };
     }
 }
 
diff --git a/modules/stream_filter/dash/dash.cpp b/modules/stream_filter/dash/dash.cpp
index e3b7485..74971a2 100644
--- a/modules/stream_filter/dash/dash.cpp
+++ b/modules/stream_filter/dash/dash.cpp
@@ -55,6 +55,9 @@ static void Close   (vlc_object_t *);
 #define DASH_HEIGHT_TEXT N_("Preferred Height")
 #define DASH_HEIGHT_LONGTEXT N_("Preferred Height")
 
+#define DASH_BW_TEXT N_("Fixed Bandwidth in KiB/s")
+#define DASH_BW_LONGTEXT N_("Preferred bandwidth for non adaptative streams")
+
 vlc_module_begin ()
         set_shortname( N_("DASH"))
         set_description( N_("Dynamic Adaptive Streaming over HTTP") )
@@ -63,6 +66,7 @@ vlc_module_begin ()
         set_subcategory( SUBCAT_INPUT_DEMUX )
         add_integer( "dash-prefwidth",  480, DASH_WIDTH_TEXT,  DASH_WIDTH_LONGTEXT,  true )
         add_integer( "dash-prefheight", 360, DASH_HEIGHT_TEXT, DASH_HEIGHT_LONGTEXT, true )
+        add_integer( "dash-prefbw",     250, DASH_BW_TEXT,     DASH_BW_LONGTEXT,     false )
         set_callbacks( Open, Close )
 vlc_module_end ()
 
@@ -105,7 +109,7 @@ static int Open(vlc_object_t *p_obj)
 
     p_sys->p_mpd = mpd;
     dash::DASHManager*p_dashManager = new dash::DASHManager(p_sys->p_mpd,
-                                          dash::logic::IAdaptationLogic::AlwaysLowest,
+                                          dash::logic::IAdaptationLogic::Default,
                                           p_demux->s);
 
     dash::mpd::Period *period = mpd->getFirstPeriod();



More information about the vlc-commits mailing list