[vlc-commits] demux: adaptive: check active streams and don't deselect last

Francois Cartegnie git at videolan.org
Wed Jul 15 09:43:12 CEST 2020


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jul  6 18:41:22 2020 +0200| [14529c484736e23f1e8b380a0c39e5a05a2063c6] | committer: Francois Cartegnie

demux: adaptive: check active streams and don't deselect last

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

 modules/demux/adaptive/PlaylistManager.cpp | 17 ++++++++++++++++-
 modules/demux/adaptive/PlaylistManager.h   |  1 +
 modules/demux/adaptive/Streams.cpp         | 12 ++++++++----
 modules/demux/adaptive/Streams.hpp         |  4 ++--
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index bb1ad764b6..3a268b6351 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -252,7 +252,10 @@ AbstractStream::buffering_status PlaylistManager::bufferize(vlc_tick_t i_nzdeadl
             /* initial */
         }
 
-        AbstractStream::buffering_status i_ret = st->bufferize(i_nzdeadline, i_min_buffering, i_extra_buffering);
+        AbstractStream::buffering_status i_ret = st->bufferize(i_nzdeadline,
+                                                               i_min_buffering,
+                                                               i_extra_buffering,
+                                                               getActiveStreamsCount() <= 1);
         if(i_return != AbstractStream::buffering_ongoing) /* Buffering streams need to keep going */
         {
             if(i_ret > i_return)
@@ -343,6 +346,18 @@ vlc_tick_t PlaylistManager::getFirstDTS() const
     return mindts;
 }
 
+unsigned PlaylistManager::getActiveStreamsCount() const
+{
+    unsigned count = 0;
+    std::vector<AbstractStream *>::const_iterator it;
+    for(it=streams.begin(); it!=streams.end(); ++it)
+    {
+        if((*it)->isValid() && !(*it)->isDisabled())
+            count++;
+    }
+    return count;
+}
+
 bool PlaylistManager::setPosition(vlc_tick_t time)
 {
     bool ret = true;
diff --git a/modules/demux/adaptive/PlaylistManager.h b/modules/demux/adaptive/PlaylistManager.h
index 6d0f6e15c5..b925d38efd 100644
--- a/modules/demux/adaptive/PlaylistManager.h
+++ b/modules/demux/adaptive/PlaylistManager.h
@@ -77,6 +77,7 @@ namespace adaptive
             virtual bool    setPosition(vlc_tick_t);
             vlc_tick_t getResumeTime() const;
             vlc_tick_t getFirstDTS() const;
+            unsigned getActiveStreamsCount() const;
 
             virtual vlc_tick_t getFirstPlaybackTime() const;
             vlc_tick_t getCurrentDemuxTime() const;
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index 6ba934425d..4876894444 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -302,14 +302,18 @@ vlc_tick_t AbstractStream::getDemuxedAmount() const
 }
 
 AbstractStream::buffering_status AbstractStream::bufferize(vlc_tick_t nz_deadline,
-                                                           vlc_tick_t i_min_buffering, vlc_tick_t i_extra_buffering)
+                                                           vlc_tick_t i_min_buffering,
+                                                           vlc_tick_t i_extra_buffering,
+                                                           bool b_keep_alive)
 {
-    last_buffer_status = doBufferize(nz_deadline, i_min_buffering, i_extra_buffering);
+    last_buffer_status = doBufferize(nz_deadline, i_min_buffering, i_extra_buffering, b_keep_alive);
     return last_buffer_status;
 }
 
 AbstractStream::buffering_status AbstractStream::doBufferize(vlc_tick_t nz_deadline,
-                                                             vlc_tick_t i_min_buffering, vlc_tick_t i_extra_buffering)
+                                                             vlc_tick_t i_min_buffering,
+                                                             vlc_tick_t i_extra_buffering,
+                                                             bool b_keep_alive)
 {
     vlc_mutex_lock(&lock);
 
@@ -321,7 +325,7 @@ AbstractStream::buffering_status AbstractStream::doBufferize(vlc_tick_t nz_deadl
     }
 
     /* Disable streams that are not selected (alternate streams) */
-    if(esCount() && !isSelected() && !fakeEsOut()->restarting())
+    if(esCount() && !isSelected() && !fakeEsOut()->restarting() && !b_keep_alive)
     {
         setDisabled(true);
         segmentTracker->reset();
diff --git a/modules/demux/adaptive/Streams.hpp b/modules/demux/adaptive/Streams.hpp
index e942f1dcc7..04c4596931 100644
--- a/modules/demux/adaptive/Streams.hpp
+++ b/modules/demux/adaptive/Streams.hpp
@@ -82,7 +82,7 @@ namespace adaptive
             buffering_ongoing,
             buffering_lessthanmin,
         } buffering_status;
-        buffering_status bufferize(vlc_tick_t, vlc_tick_t, vlc_tick_t);
+        buffering_status bufferize(vlc_tick_t, vlc_tick_t, vlc_tick_t, bool = false);
         buffering_status getLastBufferStatus() const;
         vlc_tick_t getDemuxedAmount() const;
         status dequeue(vlc_tick_t, vlc_tick_t *);
@@ -137,7 +137,7 @@ namespace adaptive
 
     private:
         void declaredCodecs();
-        buffering_status doBufferize(vlc_tick_t, vlc_tick_t, vlc_tick_t);
+        buffering_status doBufferize(vlc_tick_t, vlc_tick_t, vlc_tick_t, bool);
         buffering_status last_buffer_status;
         bool valid;
         bool disabled;



More information about the vlc-commits mailing list