Skip to content

Commit

Permalink
Always apply timestamp correction to OPT.
Browse files Browse the repository at this point in the history
Closes #200

Change-Id: I821d7a8336cc66593665dbc2ad794adc3fb55918
  • Loading branch information
TheModMaker authored and Gerrit Code Review committed Oct 13, 2015
1 parent 151936c commit 62adcd4
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/dash/live_segment_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}
Expand Down

0 comments on commit 62adcd4

Please sign in to comment.