[vlc-commits] demux: adaptive: ensure presentation delay is used for live start
Francois Cartegnie
git at videolan.org
Sun May 26 16:58:37 CEST 2019
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun May 26 15:19:54 2019 +0200| [1363e2cba90b6b9641ee8bff77dbc362c4b68ecc] | committer: Francois Cartegnie
demux: adaptive: ensure presentation delay is used for live start
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1363e2cba90b6b9641ee8bff77dbc362c4b68ecc
---
.../demux/adaptive/playlist/SegmentInformation.cpp | 24 +++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/modules/demux/adaptive/playlist/SegmentInformation.cpp b/modules/demux/adaptive/playlist/SegmentInformation.cpp
index 82424e1ffc..6b10af1bb5 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.cpp
@@ -184,13 +184,19 @@ uint64_t SegmentInformation::getLiveStartSegmentNumber(uint64_t def) const
/* Try to never buffer up to really end */
end = end - std::min(end - start, OFFSET_FROM_END);
stime_t endtime, duration;
- timeline->getScaledPlaybackTimeDurationBySegmentNumber( end, &endtime, &duration );
- if( endtime + duration <= timescale.ToScaled( i_max_buffering ) )
+ bool b_ret = timeline->getScaledPlaybackTimeDurationBySegmentNumber( end, &endtime, &duration );
+ if(unlikely(!b_ret)) /* should never happen */
+ {
+ assert(b_ret);
+ return 0;
+ }
+
+ vlc_tick_t fromend = std::max( i_max_buffering, getPlaylist()->suggestedPresentationDelay.Get() );
+ if( endtime + duration <= timescale.ToScaled( fromend ) )
return start;
- uint64_t number = timeline->getElementNumberByScaledPlaybackTime(
- endtime + duration - timescale.ToScaled( i_max_buffering ) );
+ uint64_t number = timeline->getElementNumberByScaledPlaybackTime(endtime - timescale.ToScaled( fromend ));
if( number < start )
number = start;
return number;
@@ -230,7 +236,9 @@ uint64_t SegmentInformation::getLiveStartSegmentNumber(uint64_t def) const
const std::vector<ISegment *> list = segmentList->getSegments();
const ISegment *back = list.back();
- const stime_t bufferingstart = back->startTime.Get() + back->duration.Get() - timescale.ToScaled( i_max_buffering );
+ vlc_tick_t fromend = std::max( i_max_buffering, getPlaylist()->suggestedPresentationDelay.Get() );
+ stime_t bufferingstart = back->startTime.Get() + back->duration.Get() - timescale.ToScaled( fromend );
+
uint64_t number;
if( !segmentList->getSegmentNumberByScaledTime( bufferingstart, &number ) )
return list.front()->getSequenceNumber();
@@ -248,8 +256,9 @@ uint64_t SegmentInformation::getLiveStartSegmentNumber(uint64_t def) const
const Timescale timescale = inheritTimescale();
const ISegment *back = list.back();
+ vlc_tick_t fromend = std::max( i_max_buffering, getPlaylist()->suggestedPresentationDelay.Get() );
const stime_t bufferingstart = back->startTime.Get() -
- (OFFSET_FROM_END * back->duration.Get())- timescale.ToScaled( i_max_buffering );
+ (OFFSET_FROM_END * back->duration.Get())- timescale.ToScaled( fromend );
uint64_t number;
if( !SegmentInfoCommon::getSegmentNumberByScaledTime( list, bufferingstart, &number ) )
return list.front()->getSequenceNumber();
@@ -409,7 +418,8 @@ bool SegmentInformation::getPlaybackTimeDurationBySegmentNumber(uint64_t number,
stime_t stime, sduration;
if(timeline)
{
- timeline->getScaledPlaybackTimeDurationBySegmentNumber(number, &stime, &sduration);
+ if(!timeline->getScaledPlaybackTimeDurationBySegmentNumber(number, &stime, &sduration))
+ return false;
}
else
{
More information about the vlc-commits
mailing list