[vlc-commits] demux: dash: don't expect new segment on end of timeline

Francois Cartegnie git at videolan.org
Thu Apr 30 20:50:23 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Apr 30 19:06:19 2015 +0200| [7e1aa3a36319d27ed1605603ee3dfa7ba735a197] | committer: Francois Cartegnie

demux: dash: don't expect new segment on end of timeline

static live with template+timeline never ended

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

 modules/demux/adaptative/playlist/SegmentInformation.cpp |    8 +++++---
 modules/demux/adaptative/playlist/SegmentTimeline.cpp    |   11 +++++++++++
 modules/demux/adaptative/playlist/SegmentTimeline.h      |    1 +
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/modules/demux/adaptative/playlist/SegmentInformation.cpp b/modules/demux/adaptative/playlist/SegmentInformation.cpp
index f48b691..4f4ec3a 100644
--- a/modules/demux/adaptative/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptative/playlist/SegmentInformation.cpp
@@ -147,10 +147,12 @@ ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) co
     if( size )
     {
         /* check if that's a template (fixme: find a better way) */
-        BaseSegmentTemplate *templ;
-        if( size == 1 && (templ = dynamic_cast<BaseSegmentTemplate*>(retSegments[0])) )
+        MediaSegmentTemplate *templ;
+        if( size == 1 && (templ = dynamic_cast<MediaSegmentTemplate*>(retSegments[0])) )
         {
-            return templ;
+            if(templ->segmentTimeline.Get() == NULL ||
+               templ->segmentTimeline.Get()->maxElementNumber() > pos)
+                return templ;
         }
         else if( pos < size )
         {
diff --git a/modules/demux/adaptative/playlist/SegmentTimeline.cpp b/modules/demux/adaptative/playlist/SegmentTimeline.cpp
index 5f6ef54..5923fbf 100644
--- a/modules/demux/adaptative/playlist/SegmentTimeline.cpp
+++ b/modules/demux/adaptative/playlist/SegmentTimeline.cpp
@@ -108,6 +108,17 @@ mtime_t SegmentTimeline::getScaledPlaybackTimeByElementNumber(uint64_t number) c
     return totalscaledtime;
 }
 
+size_t SegmentTimeline::maxElementNumber() const
+{
+    size_t count = 0;
+
+    std::list<Element *>::const_iterator it;
+    for(it = elements.begin(); it != elements.end(); it++)
+        count += (*it)->r + 1;
+
+    return pruned + count - 1;
+}
+
 size_t SegmentTimeline::prune(mtime_t time)
 {
     mtime_t scaled = time * inheritTimescale() / CLOCK_FREQ;
diff --git a/modules/demux/adaptative/playlist/SegmentTimeline.h b/modules/demux/adaptative/playlist/SegmentTimeline.h
index 2d06e5f..88806b2 100644
--- a/modules/demux/adaptative/playlist/SegmentTimeline.h
+++ b/modules/demux/adaptative/playlist/SegmentTimeline.h
@@ -46,6 +46,7 @@ namespace adaptative
                 void addElement(mtime_t d, uint64_t r = 0, mtime_t t = 0);
                 uint64_t getElementNumberByScaledPlaybackTime(time_t) const;
                 mtime_t getScaledPlaybackTimeByElementNumber(uint64_t) const;
+                size_t maxElementNumber() const;
                 size_t prune(mtime_t);
                 void mergeWith(SegmentTimeline &);
                 mtime_t start() const;



More information about the vlc-commits mailing list