[vlc-commits] demux: adaptive: check vod template limit
Francois Cartegnie
git at videolan.org
Thu May 28 12:38:18 CEST 2020
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon May 25 14:04:18 2020 +0200| [fd51779a22721bfbb063a1db964cec8bce28123c] | committer: Francois Cartegnie
demux: adaptive: check vod template limit
(cherry picked from commit 808e99328dc49b24827384ef9022c38410cdf498)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=fd51779a22721bfbb063a1db964cec8bce28123c
---
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 93f4121741..76abcb30ba 100644
--- a/modules/demux/adaptive/playlist/BasePeriod.cpp
+++ b/modules/demux/adaptive/playlist/BasePeriod.cpp
@@ -99,3 +99,8 @@ mtime_t BasePeriod::getPeriodStart() const
{
return startTime.Get();
}
+
+mtime_t BasePeriod::getPeriodDuration() const
+{
+ return duration.Get();
+}
diff --git a/modules/demux/adaptive/playlist/BasePeriod.h b/modules/demux/adaptive/playlist/BasePeriod.h
index 6fe64f047c..9b047f509b 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 mtime_t getPeriodStart() const; /* reimpl */
+ virtual mtime_t getPeriodDuration() const;
virtual AbstractPlaylist *getPlaylist() const; /* reimpl */
Property<mtime_t> duration;
diff --git a/modules/demux/adaptive/playlist/SegmentInformation.cpp b/modules/demux/adaptive/playlist/SegmentInformation.cpp
index 898e5870ca..a5af675ee9 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();
+ mtime_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 @@ mtime_t SegmentInformation::getPeriodStart() const
return 0;
}
+mtime_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 2da244ffb7..f95c90b9cf 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.hpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.hpp
@@ -52,6 +52,7 @@ namespace adaptive
virtual ~SegmentInformation();
virtual mtime_t getPeriodStart() const;
+ virtual mtime_t getPeriodDuration() const;
virtual AbstractPlaylist *getPlaylist() const;
class SplitPoint
More information about the vlc-commits
mailing list