[vlc-commits] demux: adaptive: add stream buffering level event

Francois Cartegnie git at videolan.org
Wed Sep 21 18:52:33 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Sep 21 17:24:47 2016 +0200| [3fc5caa902b096e8bd5b10b117c866c180fa6c3b] | committer: Francois Cartegnie

demux: adaptive: add stream buffering level event

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

 modules/demux/adaptive/SegmentTracker.cpp | 13 +++++++++++++
 modules/demux/adaptive/SegmentTracker.hpp |  9 +++++++++
 modules/demux/adaptive/Streams.cpp        |  2 ++
 3 files changed, 24 insertions(+)

diff --git a/modules/demux/adaptive/SegmentTracker.cpp b/modules/demux/adaptive/SegmentTracker.cpp
index 2f03b8b..3146827 100644
--- a/modules/demux/adaptive/SegmentTracker.cpp
+++ b/modules/demux/adaptive/SegmentTracker.cpp
@@ -60,6 +60,14 @@ SegmentTrackerEvent::SegmentTrackerEvent(const ID &id, bool enabled)
     u.buffering.id = &id;
 }
 
+SegmentTrackerEvent::SegmentTrackerEvent(const ID &id, mtime_t current, mtime_t target)
+{
+    type = BUFFERING_LEVEL_CHANGE;
+    u.buffering_level.current = current;
+    u.buffering_level.target = target;
+    u.buffering.id = &id;
+}
+
 SegmentTracker::SegmentTracker(AbstractAdaptationLogic *logic_, BaseAdaptationSet *adaptSet)
 {
     first = true;
@@ -314,6 +322,11 @@ void SegmentTracker::notifyBufferingState(bool enabled) const
     notify(SegmentTrackerEvent(adaptationSet->getID(), enabled));
 }
 
+void SegmentTracker::notifyBufferingLevel(mtime_t current, mtime_t target) const
+{
+    notify(SegmentTrackerEvent(adaptationSet->getID(), current, target));
+}
+
 void SegmentTracker::registerListener(SegmentTrackerListenerInterface *listener)
 {
     listeners.push_back(listener);
diff --git a/modules/demux/adaptive/SegmentTracker.hpp b/modules/demux/adaptive/SegmentTracker.hpp
index bdc0955..fa8e360 100644
--- a/modules/demux/adaptive/SegmentTracker.hpp
+++ b/modules/demux/adaptive/SegmentTracker.hpp
@@ -57,12 +57,14 @@ namespace adaptive
             SegmentTrackerEvent(BaseRepresentation *, BaseRepresentation *);
             SegmentTrackerEvent(const StreamFormat *);
             SegmentTrackerEvent(const ID &, bool);
+            SegmentTrackerEvent(const ID &, mtime_t, mtime_t);
             enum
             {
                 DISCONTINUITY,
                 SWITCHING,
                 FORMATCHANGE,
                 BUFFERING_STATE,
+                BUFFERING_LEVEL_CHANGE,
             } type;
             union
             {
@@ -84,6 +86,12 @@ namespace adaptive
                    const ID *id;
                    bool enabled;
                } buffering;
+               struct
+               {
+                   const ID *id;
+                   mtime_t current;
+                   mtime_t target;
+               } buffering_level;
             } u;
     };
 
@@ -108,6 +116,7 @@ namespace adaptive
             mtime_t getPlaybackTime() const; /* Current segment start time if selected */
             mtime_t getMinAheadTime() const;
             void notifyBufferingState(bool) const;
+            void notifyBufferingLevel(mtime_t, mtime_t) const;
             void registerListener(SegmentTrackerListenerInterface *);
             void updateSelected();
 
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index dcb325b..70de37a 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -329,6 +329,7 @@ AbstractStream::buffering_status AbstractStream::doBufferize(mtime_t nz_deadline
     const int64_t i_total_buffering = i_min_buffering + i_extra_buffering;
 
     mtime_t i_demuxed = commandsqueue->getDemuxedAmount();
+    segmentTracker->notifyBufferingLevel(i_demuxed, i_total_buffering);
     if(i_demuxed < i_total_buffering) /* not already demuxed */
     {
         if(!segmentTracker->segmentsListReady()) /* Live Streams */
@@ -365,6 +366,7 @@ AbstractStream::buffering_status AbstractStream::doBufferize(mtime_t nz_deadline
             return AbstractStream::buffering_end;
         }
         i_demuxed = commandsqueue->getDemuxedAmount();
+        segmentTracker->notifyBufferingLevel(i_demuxed, i_total_buffering);
     }
     vlc_mutex_unlock(&lock);
 



More information about the vlc-commits mailing list