[vlc-commits] demux: adaptive: use bitstream switch information

Francois Cartegnie git at videolan.org
Mon Mar 30 16:15:13 CEST 2020


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Apr 25 20:40:34 2019 +0200| [3c1c8ef2ec80b1a41b0e55b879c464fdefb2835e] | committer: Francois Cartegnie

demux: adaptive: use bitstream switch information

(cherry picked from commit bd6224562fad4d7b5f29ad79761ab278d5e58c68)

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

 modules/demux/adaptive/Streams.cpp          | 8 ++++++--
 modules/demux/adaptive/plumbing/Demuxer.cpp | 8 ++++----
 modules/demux/adaptive/plumbing/Demuxer.hpp | 4 ++--
 modules/demux/hls/HLSStreams.cpp            | 2 +-
 4 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index d5bc81f6b7..d5478ddd2f 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -26,6 +26,7 @@
 #include "logic/AbstractAdaptationLogic.h"
 #include "http/HTTPConnection.hpp"
 #include "http/HTTPConnectionManager.h"
+#include "playlist/BaseAdaptationSet.h"
 #include "playlist/BaseRepresentation.h"
 #include "playlist/SegmentChunk.hpp"
 #include "plumbing/SourceStream.hpp"
@@ -631,9 +632,12 @@ void AbstractStream::trackerEvent(const SegmentTrackerEvent &event)
             break;
 
         case SegmentTrackerEvent::SWITCHING:
-            if(demuxer && demuxer->needsRestartOnSwitch() && !inrestart)
+            if(demuxer && !inrestart)
             {
-                needrestart = true;
+                if(!demuxer->bitstreamSwitchCompatible() ||
+                   (event.u.switching.next &&
+                   !event.u.switching.next->getAdaptationSet()->isBitSwitchable()))
+                    needrestart = true;
             }
             break;
 
diff --git a/modules/demux/adaptive/plumbing/Demuxer.cpp b/modules/demux/adaptive/plumbing/Demuxer.cpp
index 91c5cef175..0d176468b7 100644
--- a/modules/demux/adaptive/plumbing/Demuxer.cpp
+++ b/modules/demux/adaptive/plumbing/Demuxer.cpp
@@ -51,9 +51,9 @@ bool AbstractDemuxer::alwaysStartsFromZero() const
     return b_startsfromzero;
 }
 
-bool AbstractDemuxer::needsRestartOnSwitch() const
+bool AbstractDemuxer::bitstreamSwitchCompatible() const
 {
-    return !b_candetectswitches;
+    return b_candetectswitches;
 }
 
 bool AbstractDemuxer::needsRestartOnEachSegment() const
@@ -61,7 +61,7 @@ bool AbstractDemuxer::needsRestartOnEachSegment() const
     return b_alwaysrestarts;
 }
 
-void AbstractDemuxer::setCanDetectSwitches( bool b )
+void AbstractDemuxer::setBitstreamSwitchCompatible( bool b )
 {
     b_candetectswitches = b;
 }
@@ -126,7 +126,7 @@ bool MimeDemuxer::create()
     b_startsfromzero = demuxer->alwaysStartsFromZero();
     b_reinitsonseek = demuxer->needsRestartOnSeek();
     b_alwaysrestarts = demuxer->needsRestartOnEachSegment();
-    b_candetectswitches = !demuxer->needsRestartOnSwitch();
+    b_candetectswitches = demuxer->bitstreamSwitchCompatible();
 
     return true;
 }
diff --git a/modules/demux/adaptive/plumbing/Demuxer.hpp b/modules/demux/adaptive/plumbing/Demuxer.hpp
index 1560c2af84..84d5b30023 100644
--- a/modules/demux/adaptive/plumbing/Demuxer.hpp
+++ b/modules/demux/adaptive/plumbing/Demuxer.hpp
@@ -40,9 +40,9 @@ namespace adaptive
             virtual void destroy() = 0;
             bool alwaysStartsFromZero() const;
             bool needsRestartOnSeek() const;
-            bool needsRestartOnSwitch() const;
+            bool bitstreamSwitchCompatible() const;
             bool needsRestartOnEachSegment() const;
-            void setCanDetectSwitches(bool);
+            void setBitstreamSwitchCompatible(bool);
             void setRestartsOnEachSegment(bool);
 
         protected:
diff --git a/modules/demux/hls/HLSStreams.cpp b/modules/demux/hls/HLSStreams.cpp
index a65a8061de..6e4f7035a7 100644
--- a/modules/demux/hls/HLSStreams.cpp
+++ b/modules/demux/hls/HLSStreams.cpp
@@ -135,7 +135,7 @@ AbstractDemuxer *HLSStream::newDemux(demux_t *p_realdemux, const StreamFormat &f
         case StreamFormat::MPEG2TS:
             ret = new Demuxer(p_realdemux, "ts", out, source);
             if(ret)
-                ret->setCanDetectSwitches(false); /* HLS and unique PAT/PMT versions */
+                ret->setBitstreamSwitchCompatible(false); /* HLS and unique PAT/PMT versions */
             break;
 
         case StreamFormat::MP4:



More information about the vlc-commits mailing list