[vlc-commits] demux: dash: fix dead start segment with small availability windows

Francois Cartegnie git at videolan.org
Thu Sep 6 18:30:25 CEST 2018


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Sep  5 17:30:28 2018 +0200| [fb38da60ff7129aaeab44432d8f0714889c7fcc9] | committer: Francois Cartegnie

demux: dash: fix dead start segment with small availability windows

(cherry picked from commit 560ce4616e3409630a3eaad1a312553102329f3d)

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

 modules/demux/adaptive/playlist/SegmentInformation.cpp | 7 +++++--
 modules/demux/adaptive/playlist/SegmentTemplate.cpp    | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/modules/demux/adaptive/playlist/SegmentInformation.cpp b/modules/demux/adaptive/playlist/SegmentInformation.cpp
index 8d5a7fe3ae..a3da758792 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.cpp
@@ -215,8 +215,11 @@ uint64_t SegmentInformation::getLiveStartSegmentNumber(uint64_t def) const
             else
                 start = end - count;
 
-            const uint64_t bufcount = ( OFFSET_FROM_END + timescale.ToScaled(i_max_buffering) /
-                                        mediaSegmentTemplate->duration.Get() );
+            uint64_t bufcount = ( OFFSET_FROM_END + timescale.ToScaled(i_max_buffering) /
+                                  mediaSegmentTemplate->duration.Get() );
+            /* Ensure we always pick > start # of availability window as this segment might no longer be avail */
+            if( end - start <= bufcount )
+                bufcount = end - start - 1;
 
             return ( end - start > bufcount ) ? end - bufcount : start;
         }
diff --git a/modules/demux/adaptive/playlist/SegmentTemplate.cpp b/modules/demux/adaptive/playlist/SegmentTemplate.cpp
index b9e78bbf50..9b93366e98 100644
--- a/modules/demux/adaptive/playlist/SegmentTemplate.cpp
+++ b/modules/demux/adaptive/playlist/SegmentTemplate.cpp
@@ -90,7 +90,7 @@ uint64_t MediaSegmentTemplate::getCurrentLiveTemplateNumber() const
         time_t streamstart = parentSegmentInformation->getPlaylist()->availabilityStartTime.Get();
         streamstart += parentSegmentInformation->getPeriodStart();
         stime_t elapsed = timescale.ToScaled(CLOCK_FREQ * (playbacktime - streamstart));
-        number += elapsed / dur - 2;
+        number += elapsed / dur;
     }
 
     return number;



More information about the vlc-commits mailing list