[vlc-commits] demux: adaptive: prioritize steams buffering

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


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Sep 18 16:58:22 2016 +0200| [9a982e29db9111b1e7c35555e4d51e62fff79cd7] | committer: Francois Cartegnie

demux: adaptive: prioritize steams buffering

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

 modules/demux/adaptive/PlaylistManager.cpp | 20 +++++++++++++++++++-
 modules/demux/adaptive/Streams.cpp         |  5 +++++
 modules/demux/adaptive/Streams.hpp         |  1 +
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index 39c7dc5..8aaf36e 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -180,13 +180,31 @@ void PlaylistManager::stop()
     }
 }
 
+static bool streamCompare(AbstractStream *a,  AbstractStream *b)
+{
+    AbstractStream::buffering_status ba = a->getLastBufferStatus();
+    AbstractStream::buffering_status bb = b->getLastBufferStatus();
+    if( ba >= bb ) /* Highest prio is higer value in enum */
+    {
+        if ( ba == bb ) /* Highest prio is lowest buffering */
+           return a->getDemuxedAmount() < b->getDemuxedAmount();
+        else
+            return true;
+    }
+    return false;
+}
+
 AbstractStream::buffering_status PlaylistManager::bufferize(mtime_t i_nzdeadline,
                                                             unsigned i_min_buffering, unsigned i_extra_buffering)
 {
     AbstractStream::buffering_status i_return = AbstractStream::buffering_end;
 
+    /* First reorder by status >> buffering level */
+    std::vector<AbstractStream *> prioritized_streams(streams);
+    std::sort(prioritized_streams.begin(), prioritized_streams.end(), streamCompare);
+
     std::vector<AbstractStream *>::iterator it;
-    for(it=streams.begin(); it!=streams.end(); ++it)
+    for(it=prioritized_streams.begin(); it!=prioritized_streams.end(); ++it)
     {
         AbstractStream *st = *it;
 
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index 9cbedd6..be2da33 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -257,6 +257,11 @@ AbstractStream::buffering_status AbstractStream::getLastBufferStatus() const
     return last_buffer_status;
 }
 
+mtime_t AbstractStream::getDemuxedAmount() const
+{
+    return commandsqueue->getDemuxedAmount();
+}
+
 AbstractStream::buffering_status AbstractStream::bufferize(mtime_t nz_deadline,
                                                            unsigned i_min_buffering, unsigned i_extra_buffering)
 {
diff --git a/modules/demux/adaptive/Streams.hpp b/modules/demux/adaptive/Streams.hpp
index df30361..964e12e 100644
--- a/modules/demux/adaptive/Streams.hpp
+++ b/modules/demux/adaptive/Streams.hpp
@@ -84,6 +84,7 @@ namespace adaptive
         } buffering_status;
         buffering_status bufferize(mtime_t, unsigned, unsigned);
         buffering_status getLastBufferStatus() const;
+        mtime_t getDemuxedAmount() const;
         status dequeue(mtime_t, mtime_t *);
         bool drain();
         virtual bool setPosition(mtime_t, bool);



More information about the vlc-commits mailing list