[vlc-commits] demux: adaptive: pass latency to stats

Francois Cartegnie git at videolan.org
Thu Mar 4 15:38:28 UTC 2021


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Mar  3 14:44:10 2021 +0100| [b32c7d9635b6f0445a55d638d3be3445acfd99c1] | committer: Francois Cartegnie

demux: adaptive: pass latency to stats

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

 modules/demux/adaptive/http/Chunk.cpp                       |  6 ++++--
 modules/demux/adaptive/http/HTTPConnectionManager.cpp       | 12 ++++++++++--
 modules/demux/adaptive/http/HTTPConnectionManager.h         |  3 ++-
 modules/demux/adaptive/logic/AbstractAdaptationLogic.cpp    |  3 ++-
 modules/demux/adaptive/logic/AbstractAdaptationLogic.h      |  3 ++-
 modules/demux/adaptive/logic/IDownloadRateObserver.h        |  3 ++-
 modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp |  3 ++-
 modules/demux/adaptive/logic/NearOptimalAdaptationLogic.hpp |  3 ++-
 modules/demux/adaptive/logic/PredictiveAdaptationLogic.cpp  |  3 ++-
 modules/demux/adaptive/logic/PredictiveAdaptationLogic.hpp  |  3 ++-
 modules/demux/adaptive/logic/RateBasedAdaptationLogic.cpp   |  3 ++-
 modules/demux/adaptive/logic/RateBasedAdaptationLogic.h     |  3 ++-
 12 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/modules/demux/adaptive/http/Chunk.cpp b/modules/demux/adaptive/http/Chunk.cpp
index 663d318aaa..4843169eb2 100644
--- a/modules/demux/adaptive/http/Chunk.cpp
+++ b/modules/demux/adaptive/http/Chunk.cpp
@@ -231,7 +231,8 @@ block_t * HTTPChunkSource::read(size_t readsize)
            downloadEndTime > requestStartTime && type == ChunkType::Segment)
         {
             connManager->updateDownloadRate(sourceid, p_block->i_buffer,
-                                            downloadEndTime - requestStartTime);
+                                            downloadEndTime - requestStartTime,
+                                            downloadEndTime - responseTime);
         }
     }
 
@@ -415,7 +416,8 @@ void HTTPChunkBufferedSource::bufferize(size_t readsize)
 
     if(rate.size && rate.time && type == ChunkType::Segment)
     {
-        connManager->updateDownloadRate(sourceid, rate.size, rate.time);
+        connManager->updateDownloadRate(sourceid, rate.size,
+                                        rate.time, rate.latency);
     }
 
     avail.signal();
diff --git a/modules/demux/adaptive/http/HTTPConnectionManager.cpp b/modules/demux/adaptive/http/HTTPConnectionManager.cpp
index 311be1a831..c7672f565d 100644
--- a/modules/demux/adaptive/http/HTTPConnectionManager.cpp
+++ b/modules/demux/adaptive/http/HTTPConnectionManager.cpp
@@ -30,6 +30,7 @@
 #include "ConnectionParams.hpp"
 #include "Transport.hpp"
 #include "Downloader.hpp"
+#include "tools/Debug.hpp"
 #include <vlc_url.h>
 #include <vlc_http.h>
 
@@ -47,10 +48,17 @@ AbstractConnectionManager::~AbstractConnectionManager()
 
 }
 
-void AbstractConnectionManager::updateDownloadRate(const adaptive::ID &sourceid, size_t size, vlc_tick_t time)
+void AbstractConnectionManager::updateDownloadRate(const adaptive::ID &sourceid, size_t size,
+                                                   vlc_tick_t time, vlc_tick_t latency)
 {
     if(rateObserver)
-        rateObserver->updateDownloadRate(sourceid, size, time);
+    {
+        BwDebug(msg_Dbg(p_object,
+                "%" PRId64 "Kbps downloaded %zuKBytes in %" PRId64 "ms latency %" PRId64 "ms [%s]",
+                1000 * size * 8 / (time ? time : 1), size / 1024, MS_FROM_VLC_TICK(time),
+                latency / 1000, sourceid.str().c_str()));
+        rateObserver->updateDownloadRate(sourceid, size, time, latency);
+    }
 }
 
 void AbstractConnectionManager::setDownloadRateObserver(IDownloadRateObserver *obs)
diff --git a/modules/demux/adaptive/http/HTTPConnectionManager.h b/modules/demux/adaptive/http/HTTPConnectionManager.h
index 0bc44f4054..a0cada5483 100644
--- a/modules/demux/adaptive/http/HTTPConnectionManager.h
+++ b/modules/demux/adaptive/http/HTTPConnectionManager.h
@@ -53,7 +53,8 @@ namespace adaptive
                 virtual void start(AbstractChunkSource *) = 0;
                 virtual void cancel(AbstractChunkSource *) = 0;
 
-                virtual void updateDownloadRate(const ID &, size_t, vlc_tick_t) override;
+                virtual void updateDownloadRate(const ID &, size_t,
+                                                vlc_tick_t, vlc_tick_t) override;
                 void setDownloadRateObserver(IDownloadRateObserver *);
 
             protected:
diff --git a/modules/demux/adaptive/logic/AbstractAdaptationLogic.cpp b/modules/demux/adaptive/logic/AbstractAdaptationLogic.cpp
index 22efc19db1..008e24011a 100644
--- a/modules/demux/adaptive/logic/AbstractAdaptationLogic.cpp
+++ b/modules/demux/adaptive/logic/AbstractAdaptationLogic.cpp
@@ -42,7 +42,8 @@ AbstractAdaptationLogic::~AbstractAdaptationLogic   ()
 {
 }
 
-void AbstractAdaptationLogic::updateDownloadRate    (const adaptive::ID &, size_t, vlc_tick_t)
+void AbstractAdaptationLogic::updateDownloadRate    (const adaptive::ID &, size_t,
+                                                     vlc_tick_t, vlc_tick_t)
 {
 }
 
diff --git a/modules/demux/adaptive/logic/AbstractAdaptationLogic.h b/modules/demux/adaptive/logic/AbstractAdaptationLogic.h
index b75bce3051..8f3d033878 100644
--- a/modules/demux/adaptive/logic/AbstractAdaptationLogic.h
+++ b/modules/demux/adaptive/logic/AbstractAdaptationLogic.h
@@ -48,7 +48,8 @@ namespace adaptive
                 virtual ~AbstractAdaptationLogic    ();
 
                 virtual BaseRepresentation* getNextRepresentation(BaseAdaptationSet *, BaseRepresentation *) = 0;
-                virtual void                updateDownloadRate     (const ID &, size_t, vlc_tick_t) override;
+                virtual void                updateDownloadRate     (const ID &, size_t,
+                                                                    vlc_tick_t, vlc_tick_t) override;
                 virtual void                trackerEvent           (const TrackerEvent &) override {}
                 void                        setMaxDeviceResolution (int, int);
 
diff --git a/modules/demux/adaptive/logic/IDownloadRateObserver.h b/modules/demux/adaptive/logic/IDownloadRateObserver.h
index 75c0a217c7..220450ae96 100644
--- a/modules/demux/adaptive/logic/IDownloadRateObserver.h
+++ b/modules/demux/adaptive/logic/IDownloadRateObserver.h
@@ -34,7 +34,8 @@ namespace adaptive
     class IDownloadRateObserver
     {
         public:
-            virtual void updateDownloadRate(const ID &, size_t, vlc_tick_t) = 0;
+            virtual void updateDownloadRate(const ID &, size_t,
+                                            vlc_tick_t, vlc_tick_t) = 0;
             virtual ~IDownloadRateObserver(){}
     };
 }
diff --git a/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp b/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp
index d5e42b2d48..d5fc9ef97c 100644
--- a/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp
+++ b/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp
@@ -181,7 +181,8 @@ unsigned NearOptimalAdaptationLogic::getMaxCurrentBw() const
     return i_max_bitrate;
 }
 
-void NearOptimalAdaptationLogic::updateDownloadRate(const ID &id, size_t dlsize, vlc_tick_t time)
+void NearOptimalAdaptationLogic::updateDownloadRate(const ID &id, size_t dlsize,
+                                                    vlc_tick_t time, vlc_tick_t)
 {
     vlc_mutex_lock(&lock);
     std::map<ID, NearOptimalContext>::iterator it = streams.find(id);
diff --git a/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.hpp b/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.hpp
index ee2cd9815f..f898853b2c 100644
--- a/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.hpp
+++ b/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.hpp
@@ -52,7 +52,8 @@ namespace adaptive
 
                 virtual BaseRepresentation* getNextRepresentation(BaseAdaptationSet *,
                                                                   BaseRepresentation *) override;
-                virtual void                updateDownloadRate     (const ID &, size_t, vlc_tick_t) override;
+                virtual void                updateDownloadRate     (const ID &, size_t,
+                                                                    vlc_tick_t, vlc_tick_t) override;
                 virtual void                trackerEvent           (const TrackerEvent &) override;
 
             private:
diff --git a/modules/demux/adaptive/logic/PredictiveAdaptationLogic.cpp b/modules/demux/adaptive/logic/PredictiveAdaptationLogic.cpp
index 24221c62e5..5733980d6a 100644
--- a/modules/demux/adaptive/logic/PredictiveAdaptationLogic.cpp
+++ b/modules/demux/adaptive/logic/PredictiveAdaptationLogic.cpp
@@ -151,7 +151,8 @@ BaseRepresentation *PredictiveAdaptationLogic::getNextRepresentation(BaseAdaptat
     return rep;
 }
 
-void PredictiveAdaptationLogic::updateDownloadRate(const ID &id, size_t dlsize, vlc_tick_t time)
+void PredictiveAdaptationLogic::updateDownloadRate(const ID &id, size_t dlsize,
+                                                   vlc_tick_t time, vlc_tick_t)
 {
     vlc_mutex_lock(&lock);
     std::map<ID, PredictiveStats>::iterator it = streams.find(id);
diff --git a/modules/demux/adaptive/logic/PredictiveAdaptationLogic.hpp b/modules/demux/adaptive/logic/PredictiveAdaptationLogic.hpp
index cf60162889..fc2b96c3e2 100644
--- a/modules/demux/adaptive/logic/PredictiveAdaptationLogic.hpp
+++ b/modules/demux/adaptive/logic/PredictiveAdaptationLogic.hpp
@@ -53,7 +53,8 @@ namespace adaptive
 
                 virtual BaseRepresentation* getNextRepresentation(BaseAdaptationSet *,
                                                                   BaseRepresentation *) override;
-                virtual void                updateDownloadRate     (const ID &, size_t, vlc_tick_t) override;
+                virtual void                updateDownloadRate     (const ID &, size_t,
+                                                                    vlc_tick_t, vlc_tick_t) override;
                 virtual void                trackerEvent           (const TrackerEvent &) override;
 
             private:
diff --git a/modules/demux/adaptive/logic/RateBasedAdaptationLogic.cpp b/modules/demux/adaptive/logic/RateBasedAdaptationLogic.cpp
index f657bdf8a7..7f0512590f 100644
--- a/modules/demux/adaptive/logic/RateBasedAdaptationLogic.cpp
+++ b/modules/demux/adaptive/logic/RateBasedAdaptationLogic.cpp
@@ -76,7 +76,8 @@ BaseRepresentation *RateBasedAdaptationLogic::getNextRepresentation(BaseAdaptati
     return rep;
 }
 
-void RateBasedAdaptationLogic::updateDownloadRate(const ID &, size_t size, vlc_tick_t time)
+void RateBasedAdaptationLogic::updateDownloadRate(const ID &, size_t size,
+                                                  vlc_tick_t time, vlc_tick_t)
 {
     if(unlikely(time == 0))
         return;
diff --git a/modules/demux/adaptive/logic/RateBasedAdaptationLogic.h b/modules/demux/adaptive/logic/RateBasedAdaptationLogic.h
index 9b94996e54..730a85bf07 100644
--- a/modules/demux/adaptive/logic/RateBasedAdaptationLogic.h
+++ b/modules/demux/adaptive/logic/RateBasedAdaptationLogic.h
@@ -41,7 +41,8 @@ namespace adaptive
 
                 BaseRepresentation *getNextRepresentation(BaseAdaptationSet *,
                                                           BaseRepresentation *) override;
-                virtual void updateDownloadRate(const ID &, size_t, vlc_tick_t) override;
+                virtual void updateDownloadRate(const ID &, size_t,
+                                                vlc_tick_t, vlc_tick_t) override;
                 virtual void trackerEvent(const TrackerEvent &) override;
 
             private:



More information about the vlc-commits mailing list