[vlc-commits] demux: adaptive: check vod template limit

Francois Cartegnie git at videolan.org
Mon May 25 15:11:23 CEST 2020


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon May 25 14:04:18 2020 +0200| [808e99328dc49b24827384ef9022c38410cdf498] | committer: Francois Cartegnie

demux: adaptive: check vod template limit

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

 modules/demux/adaptive/playlist/BasePeriod.cpp     |  5 ++++
 modules/demux/adaptive/playlist/BasePeriod.h       |  1 +
 .../demux/adaptive/playlist/SegmentInformation.cpp | 27 ++++++++++++++++++++++
 .../demux/adaptive/playlist/SegmentInformation.hpp |  1 +
 4 files changed, 34 insertions(+)

diff --git a/modules/demux/adaptive/playlist/BasePeriod.cpp b/modules/demux/adaptive/playlist/BasePeriod.cpp
index 971851c611..94295ff51d 100644
--- a/modules/demux/adaptive/playlist/BasePeriod.cpp
+++ b/modules/demux/adaptive/playlist/BasePeriod.cpp
@@ -99,3 +99,8 @@ vlc_tick_t BasePeriod::getPeriodStart() const
 {
     return startTime.Get();
 }
+
+vlc_tick_t BasePeriod::getPeriodDuration() const
+{
+    return duration.Get();
+}
diff --git a/modules/demux/adaptive/playlist/BasePeriod.h b/modules/demux/adaptive/playlist/BasePeriod.h
index b57a75d610..814b41db9e 100644
--- a/modules/demux/adaptive/playlist/BasePeriod.h
+++ b/modules/demux/adaptive/playlist/BasePeriod.h
@@ -46,6 +46,7 @@ namespace adaptive
                 void                                debug               (vlc_object_t *,int = 0) const;
 
                 virtual vlc_tick_t getPeriodStart() const; /* reimpl */
+                virtual vlc_tick_t getPeriodDuration() const;
                 virtual AbstractPlaylist *getPlaylist() const; /* reimpl */
 
                 Property<vlc_tick_t> duration;
diff --git a/modules/demux/adaptive/playlist/SegmentInformation.cpp b/modules/demux/adaptive/playlist/SegmentInformation.cpp
index ad82fa53c1..27a433627e 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.cpp
@@ -258,6 +258,25 @@ ISegment * SegmentInformation::getNextSegment(SegmentInfoType type, uint64_t i_p
                 }
                 else
                 {
+                    /* check template upper bound */
+                    if(!getPlaylist()->isLive())
+                    {
+                        const Timescale timescale = templ->inheritTimescale();
+                        const stime_t segmentduration = templ->inheritDuration();
+                        vlc_tick_t totalduration = getPeriodDuration();
+                        if(totalduration == 0)
+                            totalduration = getPlaylist()->duration.Get();
+                        if(totalduration && segmentduration)
+                        {
+                            uint64_t endnum = templ->inheritStartNumber() +
+                                    (timescale.ToScaled(totalduration) + segmentduration - 1) / segmentduration;
+                            if(i_pos >= endnum)
+                            {
+                                *pi_newpos = i_pos;
+                                return NULL;
+                            }
+                        }
+                    }
                     *pi_newpos = i_pos;
                     /* start number */
                     *pi_newpos = std::max(templ->inheritStartNumber(), i_pos);
@@ -517,6 +536,14 @@ vlc_tick_t SegmentInformation::getPeriodStart() const
         return 0;
 }
 
+vlc_tick_t SegmentInformation::getPeriodDuration() const
+{
+    if(parent)
+        return parent->getPeriodDuration();
+    else
+        return 0;
+}
+
 void SegmentInformation::updateSegmentList(SegmentList *list, bool restamp)
 {
     if(segmentList && restamp)
diff --git a/modules/demux/adaptive/playlist/SegmentInformation.hpp b/modules/demux/adaptive/playlist/SegmentInformation.hpp
index 48d6e9c227..7b763eb4c3 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.hpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.hpp
@@ -52,6 +52,7 @@ namespace adaptive
                 virtual ~SegmentInformation();
 
                 virtual vlc_tick_t getPeriodStart() const;
+                virtual vlc_tick_t getPeriodDuration() const;
                 virtual AbstractPlaylist *getPlaylist() const;
 
                 class SplitPoint



More information about the vlc-commits mailing list