[vlc-commits] demux: adaptative: add bandwith debugging

Francois Cartegnie git at videolan.org
Wed Nov 18 11:51:21 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Nov 10 17:01:59 2015 +0100| [5f1dec1a174965aff5f6c7c1221a2e9fb39da181] | committer: Francois Cartegnie

demux: adaptative: add bandwith debugging

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

 modules/demux/adaptative/PlaylistManager.cpp                |    3 ++-
 modules/demux/adaptative/logic/RateBasedAdaptationLogic.cpp |   10 +++++++++-
 modules/demux/adaptative/logic/RateBasedAdaptationLogic.h   |    5 ++---
 modules/demux/adaptative/tools/Debug.hpp                    |    7 +++++++
 4 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/modules/demux/adaptative/PlaylistManager.cpp b/modules/demux/adaptative/PlaylistManager.cpp
index befe17e..0651905 100644
--- a/modules/demux/adaptative/PlaylistManager.cpp
+++ b/modules/demux/adaptative/PlaylistManager.cpp
@@ -411,7 +411,8 @@ AbstractAdaptationLogic *PlaylistManager::createLogic(AbstractAdaptationLogic::L
         {
             int width = var_InheritInteger(p_demux, "adaptative-width");
             int height = var_InheritInteger(p_demux, "adaptative-height");
-            RateBasedAdaptationLogic *logic = new (std::nothrow) RateBasedAdaptationLogic(width, height);
+            RateBasedAdaptationLogic *logic =
+                    new (std::nothrow) RateBasedAdaptationLogic(VLC_OBJECT(p_demux), width, height);
             conn->setDownloadRateObserver(logic);
             return logic;
         }
diff --git a/modules/demux/adaptative/logic/RateBasedAdaptationLogic.cpp b/modules/demux/adaptative/logic/RateBasedAdaptationLogic.cpp
index 8f0856e..09d51ff 100644
--- a/modules/demux/adaptative/logic/RateBasedAdaptationLogic.cpp
+++ b/modules/demux/adaptative/logic/RateBasedAdaptationLogic.cpp
@@ -31,10 +31,11 @@
 #include "../playlist/BaseRepresentation.h"
 #include "../playlist/BasePeriod.h"
 #include "../http/Chunk.h"
+#include "../tools/Debug.hpp"
 
 using namespace adaptative::logic;
 
-RateBasedAdaptationLogic::RateBasedAdaptationLogic  (int w, int h) :
+RateBasedAdaptationLogic::RateBasedAdaptationLogic  (vlc_object_t *p_obj_, int w, int h) :
                           AbstractAdaptationLogic   (),
                           bpsAvg(0), bpsRemainder(0), bpsSamplecount(0),
                           currentBps(0)
@@ -42,6 +43,7 @@ RateBasedAdaptationLogic::RateBasedAdaptationLogic  (int w, int h) :
     width  = w;
     height = h;
     usedBps = 0;
+    p_obj = p_obj_;
 }
 
 BaseRepresentation *RateBasedAdaptationLogic::getNextRepresentation(BaseAdaptationSet *adaptSet, BaseRepresentation *currep) const
@@ -86,6 +88,9 @@ void RateBasedAdaptationLogic::updateDownloadRate(size_t size, mtime_t time)
     }
 
     currentBps = bpsAvg * 3/4;
+
+    BwDebug(msg_Info(p_obj, "Current bandwidth %zu KiB/s using %u%%",
+                    (bpsAvg / 8192), (bpsAvg) ? (unsigned)(usedBps * 100.0 / bpsAvg) : 0 ));
 }
 
 void RateBasedAdaptationLogic::trackerEvent(const SegmentTrackerEvent &event)
@@ -96,6 +101,9 @@ void RateBasedAdaptationLogic::trackerEvent(const SegmentTrackerEvent &event)
             usedBps -= event.u.switching.prev->getBandwidth();
         if(event.u.switching.next)
             usedBps += event.u.switching.next->getBandwidth();
+
+        BwDebug(msg_Info(p_obj, "New bandwidth usage %zu KiB/s %u%%",
+                        (usedBps / 8192), (bpsAvg) ? (unsigned)(usedBps * 100.0 / bpsAvg) : 0 ));
     }
 }
 
diff --git a/modules/demux/adaptative/logic/RateBasedAdaptationLogic.h b/modules/demux/adaptative/logic/RateBasedAdaptationLogic.h
index 166db2f..417c4df 100644
--- a/modules/demux/adaptative/logic/RateBasedAdaptationLogic.h
+++ b/modules/demux/adaptative/logic/RateBasedAdaptationLogic.h
@@ -27,8 +27,6 @@
 
 #include "AbstractAdaptationLogic.h"
 
-#define MINBUFFER 30
-
 namespace adaptative
 {
     namespace logic
@@ -37,7 +35,7 @@ namespace adaptative
         class RateBasedAdaptationLogic : public AbstractAdaptationLogic
         {
             public:
-                RateBasedAdaptationLogic            (int, int);
+                RateBasedAdaptationLogic            (vlc_object_t *, int, int);
 
                 BaseRepresentation *getNextRepresentation(BaseAdaptationSet *, BaseRepresentation *) const;
                 virtual void updateDownloadRate(size_t, mtime_t); /* reimpl */
@@ -51,6 +49,7 @@ namespace adaptative
                 size_t                  bpsSamplecount;
                 size_t                  currentBps;
                 size_t                  usedBps;
+                vlc_object_t *          p_obj;
         };
 
         class FixedRateAdaptationLogic : public AbstractAdaptationLogic
diff --git a/modules/demux/adaptative/tools/Debug.hpp b/modules/demux/adaptative/tools/Debug.hpp
index 81eba8d..a326d43 100644
--- a/modules/demux/adaptative/tools/Debug.hpp
+++ b/modules/demux/adaptative/tools/Debug.hpp
@@ -21,6 +21,7 @@
 #define DEBUG_HPP
 
 //#define ADAPTATIVE_ADVANCED_DEBUG 0
+//#define ADAPTATIVE_BW_DEBUG 0
 
 #ifdef ADAPTATIVE_ADVANCED_DEBUG
   #define AdvDebug(code) code
@@ -28,5 +29,11 @@
   #define AdvDebug(code)
 #endif
 
+#ifdef ADAPTATIVE_BW_DEBUG
+  #define BwDebug(code) code
+#else
+  #define BwDebug(code)
+#endif
+
 #endif // DEBUG_HPP
 



More information about the vlc-commits mailing list