[vlc-commits] demux: hls: do proper schedule on update

Francois Cartegnie git at videolan.org
Thu May 14 15:30:21 CEST 2020


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed May 13 17:41:00 2020 +0200| [e4183647996b5986c8603cab6c9a370031c62886] | committer: Francois Cartegnie

demux: hls: do proper schedule on update

non playback point based update now appears
since closer to the edge buffering

reverts 390078318d4f62827a5f185bf922e9b03052a19b

refs #24701

(cherry picked from commit 9ddcb1b5f9a83ce1250982c44a6b7df152cfec4c)

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

 modules/demux/adaptive/SegmentTracker.cpp              |  7 +++----
 modules/demux/adaptive/playlist/BaseRepresentation.cpp |  2 +-
 modules/demux/adaptive/playlist/BaseRepresentation.h   |  2 +-
 modules/demux/hls/playlist/Parser.cpp                  |  8 --------
 modules/demux/hls/playlist/Representation.cpp          | 15 +++++++++++----
 modules/demux/hls/playlist/Representation.hpp          |  2 +-
 6 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/modules/demux/adaptive/SegmentTracker.cpp b/modules/demux/adaptive/SegmentTracker.cpp
index 0941bf9d80..2ec4ebedd4 100644
--- a/modules/demux/adaptive/SegmentTracker.cpp
+++ b/modules/demux/adaptive/SegmentTracker.cpp
@@ -227,8 +227,7 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed,
         next = rep->translateSegmentNumber(next, prevRep);
     }
 
-    if(b_updated)
-        curRepresentation->scheduleNextUpdate(next);
+    curRepresentation->scheduleNextUpdate(next, b_updated);
 
     if(rep->getStreamFormat() != format)
     {
@@ -423,8 +422,8 @@ void SegmentTracker::updateSelected()
 {
     if(curRepresentation && curRepresentation->needsUpdate())
     {
-        curRepresentation->runLocalUpdates(resources);
-        curRepresentation->scheduleNextUpdate(curNumber);
+        bool b_updated = curRepresentation->runLocalUpdates(resources);
+        curRepresentation->scheduleNextUpdate(curNumber, b_updated);
     }
 }
 
diff --git a/modules/demux/adaptive/playlist/BaseRepresentation.cpp b/modules/demux/adaptive/playlist/BaseRepresentation.cpp
index e0055f1835..ade8a93710 100644
--- a/modules/demux/adaptive/playlist/BaseRepresentation.cpp
+++ b/modules/demux/adaptive/playlist/BaseRepresentation.cpp
@@ -98,7 +98,7 @@ bool BaseRepresentation::runLocalUpdates(SharedResources *)
     return false;
 }
 
-void BaseRepresentation::scheduleNextUpdate(uint64_t)
+void BaseRepresentation::scheduleNextUpdate(uint64_t, bool)
 {
 
 }
diff --git a/modules/demux/adaptive/playlist/BaseRepresentation.h b/modules/demux/adaptive/playlist/BaseRepresentation.h
index f11373fc4f..0946a40357 100644
--- a/modules/demux/adaptive/playlist/BaseRepresentation.h
+++ b/modules/demux/adaptive/playlist/BaseRepresentation.h
@@ -67,7 +67,7 @@ namespace adaptive
                 virtual mtime_t     getMinAheadTime         (uint64_t) const;
                 virtual bool        needsUpdate             () const;
                 virtual bool        runLocalUpdates         (SharedResources *);
-                virtual void        scheduleNextUpdate      (uint64_t);
+                virtual void        scheduleNextUpdate      (uint64_t, bool);
 
                 virtual void        debug                   (vlc_object_t *,int = 0) const;
 
diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index 2140729cc5..28b1b65d21 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -32,7 +32,6 @@
 #include "../../adaptive/tools/Retrieve.hpp"
 #include "../../adaptive/tools/Helper.h"
 #include "../../adaptive/tools/Conversions.hpp"
-#include "../../adaptive/logic/BufferingLogic.hpp"
 #include "M3U8.hpp"
 #include "Tags.hpp"
 
@@ -146,13 +145,6 @@ void M3U8Parser::createAndFillRepresentation(vlc_object_t *p_obj, BaseAdaptation
     if(rep)
     {
         parseSegments(p_obj, rep, tagslist);
-        if(rep->isLive())
-        {
-            /* avoid update playlist immediately */
-            logic::DefaultBufferingLogic buflogic;
-            uint64_t startseq = buflogic.getStartSegmentNumber(rep);
-            rep->scheduleNextUpdate(startseq);
-        }
         adaptSet->addRepresentation(rep);
     }
 }
diff --git a/modules/demux/hls/playlist/Representation.cpp b/modules/demux/hls/playlist/Representation.cpp
index ea05270157..9f90d97734 100644
--- a/modules/demux/hls/playlist/Representation.cpp
+++ b/modules/demux/hls/playlist/Representation.cpp
@@ -100,13 +100,18 @@ void Representation::debug(vlc_object_t *obj, int indent) const
     }
 }
 
-void Representation::scheduleNextUpdate(uint64_t number)
+void Representation::scheduleNextUpdate(uint64_t number, bool b_updated)
 {
-    const AbstractPlaylist *playlist = getPlaylist();
-    const mtime_t now = mdate();
+    if(!isLive())
+        return;
+
+    if(!b_updated && nextUpdateTime > 0)
+        return;
 
     /* Compute new update time */
     mtime_t minbuffer = getMinAheadTime(number);
+    const AbstractPlaylist *playlist = getPlaylist();
+    const mtime_t now = mdate();
 
     /* Update frequency must always be at least targetDuration (if any)
      * but we need to update before reaching that last segment, thus -1 */
@@ -135,7 +140,9 @@ void Representation::scheduleNextUpdate(uint64_t number)
 
 bool Representation::needsUpdate() const
 {
-    return !b_failed && (!b_loaded || (isLive() && nextUpdateTime < mdate()));
+    return !b_failed && (!b_loaded || (isLive() &&
+                                       nextUpdateTime != 0 &&
+                                       nextUpdateTime < mdate()));
 }
 
 bool Representation::runLocalUpdates(SharedResources *res)
diff --git a/modules/demux/hls/playlist/Representation.hpp b/modules/demux/hls/playlist/Representation.hpp
index 12b7ceedf9..b3460bd2f8 100644
--- a/modules/demux/hls/playlist/Representation.hpp
+++ b/modules/demux/hls/playlist/Representation.hpp
@@ -47,7 +47,7 @@ namespace hls
                 Url getPlaylistUrl() const;
                 bool isLive() const;
                 bool initialized() const;
-                virtual void scheduleNextUpdate(uint64_t); /* reimpl */
+                virtual void scheduleNextUpdate(uint64_t, bool); /* reimpl */
                 virtual bool needsUpdate() const;  /* reimpl */
                 virtual void debug(vlc_object_t *, int) const;  /* reimpl */
                 virtual bool runLocalUpdates(SharedResources *); /* reimpl */



More information about the vlc-commits mailing list