[vlc-commits] demux: adaptative: first timeline number

Francois Cartegnie git at videolan.org
Tue Oct 27 19:13:54 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Oct 24 16:46:48 2015 +0200| [a1c9926d42720443ece7e637fdf1d741928c0c5e] | committer: Francois Cartegnie

demux: adaptative: first timeline number

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

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

diff --git a/modules/demux/adaptative/playlist/SegmentInformation.cpp b/modules/demux/adaptative/playlist/SegmentInformation.cpp
index 14566ea..889774c 100644
--- a/modules/demux/adaptative/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptative/playlist/SegmentInformation.cpp
@@ -174,10 +174,19 @@ ISegment * SegmentInformation::getNextSegment(SegmentInfoType type, uint64_t i_p
             {
                 /* Check if we don't exceed timeline */
                 MediaSegmentTemplate *templ = dynamic_cast<MediaSegmentTemplate*>(retSegments[0]);
-                if(templ && templ->segmentTimeline.Get() &&
-                   templ->segmentTimeline.Get()->maxElementNumber() < i_pos)
-                    return NULL;
-                *pi_newpos = std::max(seg->getSequenceNumber(), i_pos);
+                SegmentTimeline *timeline = (templ) ? templ->segmentTimeline.Get() : NULL;
+                if(timeline)
+                {
+                    *pi_newpos = std::max(timeline->minElementNumber(), i_pos);
+                    if(timeline->maxElementNumber() < i_pos)
+                        return NULL;
+                }
+                else
+                {
+                    *pi_newpos = i_pos;
+                    /* start number */
+                    *pi_newpos = std::max(templ->startNumber.Get(), i_pos);
+                }
                 return seg;
             }
             else if(seg->getSequenceNumber() >= i_pos)
diff --git a/modules/demux/adaptative/playlist/SegmentTimeline.cpp b/modules/demux/adaptative/playlist/SegmentTimeline.cpp
index 312c6a8..37d0b7b 100644
--- a/modules/demux/adaptative/playlist/SegmentTimeline.cpp
+++ b/modules/demux/adaptative/playlist/SegmentTimeline.cpp
@@ -115,6 +115,13 @@ uint64_t SegmentTimeline::maxElementNumber() const
     return e->number + e->r;
 }
 
+uint64_t SegmentTimeline::minElementNumber() const
+{
+    if(elements.empty())
+        return 0;
+    return elements.front()->number;
+}
+
 size_t SegmentTimeline::prune(mtime_t time)
 {
     stime_t scaled = time * inheritTimescale() / CLOCK_FREQ;
diff --git a/modules/demux/adaptative/playlist/SegmentTimeline.h b/modules/demux/adaptative/playlist/SegmentTimeline.h
index ca0a363..a6ed99c 100644
--- a/modules/demux/adaptative/playlist/SegmentTimeline.h
+++ b/modules/demux/adaptative/playlist/SegmentTimeline.h
@@ -47,6 +47,7 @@ namespace adaptative
                 uint64_t getElementNumberByScaledPlaybackTime(stime_t) const;
                 stime_t getScaledPlaybackTimeByElementNumber(uint64_t) const;
                 uint64_t maxElementNumber() const;
+                uint64_t minElementNumber() const;
                 size_t prune(mtime_t);
                 void mergeWith(SegmentTimeline &);
                 mtime_t start() const;



More information about the vlc-commits mailing list