diff --git a/lib/dash/live_segment_index.js b/lib/dash/live_segment_index.js index 52cd2dcf4f..7c0ba79fc1 100644 --- a/lib/dash/live_segment_index.js +++ b/lib/dash/live_segment_index.js @@ -255,23 +255,27 @@ shaka.dash.LiveSegmentIndex.prototype.correct = function(timestampCorrection) { var delta = shaka.media.SegmentIndex.prototype.correct.call( this, timestampCorrection); + var max = Math.min.apply(null, + this.references + .filter(function(a) { return a.endTime != null; }) + .map(function(a) { return a.endTime - a.startTime; })); + if (Math.abs(delta) > max) { + // A timestamp correction should be less than the duration of any one + // segment in the stream. + shaka.log.warning( + 'Timestamp correction (' + timestampCorrection + ')', + 'is unreasonably large for live content.', + 'The content may have errors in it.'); + } + if (this.originalPresentationTime_ != null) { shaka.asserts.assert(this.originalLiveEdge_ != null); shaka.asserts.assert(this.seekStartTime_ != null); this.originalLiveEdge_ += delta; this.seekStartTime_ += delta; + this.originalPresentationTime_ += delta; - if (this.originalLiveEdge_ > this.originalPresentationTime_) { - // A timestamp correction should be less than the duration of any one - // segment in the stream. So, the live-edge should not surpass the - // current presentation time, but if it does then try to recover. - shaka.log.warning( - 'Timestamp correction (' + timestampCorrection + ')', - 'is unreasonably large for live content.', - 'The content may have errors in it.'); - this.originalPresentationTime_ += delta; - } shaka.asserts.assert(this.originalLiveEdge_ <= this.originalPresentationTime_); }