From 62adcd40c10e579e2fefc8b12988aea7fbe2bf66 Mon Sep 17 00:00:00 2001 From: Jacob Trimble Date: Fri, 9 Oct 2015 11:51:22 -0700 Subject: [PATCH] Always apply timestamp correction to OPT. Closes #200 Change-Id: I821d7a8336cc66593665dbc2ad794adc3fb55918 --- lib/dash/live_segment_index.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/dash/live_segment_index.js b/lib/dash/live_segment_index.js index 52cd2dcf4..7c0ba79fc 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_); }