Skip to content

Commit

Permalink
Fix rounding issues with multi-Period content.
Browse files Browse the repository at this point in the history
Closes #882
Closes #909
Closes #911

Change-Id: Id31567137860b6bd683169b5b68ca83d6f14473d
  • Loading branch information
TheModMaker committed Jul 5, 2017
1 parent 5315542 commit 310e48f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,10 @@ shaka.dash.DashParser.prototype.parsePeriods_ = function(
periodDuration = presentationDuration - start;
}

if (periodDuration && givenDuration && periodDuration != givenDuration) {
var threshold =
shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS;
if (periodDuration && givenDuration &&
Math.abs(periodDuration - givenDuration) > threshold) {
shaka.log.warning('There is a gap/overlap between Periods', elem);
}
// Only use the @duration in the MPD if we can't calculate it. We should
Expand Down
5 changes: 4 additions & 1 deletion lib/util/stream_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,12 @@ shaka.util.StreamUtils.getFullMimeType = function(mimeType, opt_codecs) {
* @return {number}
*/
shaka.util.StreamUtils.findPeriodContainingTime = function(manifest, time) {
var threshold = shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS;
for (var i = manifest.periods.length - 1; i > 0; --i) {
var period = manifest.periods[i];
if (time >= period.startTime)
// The last segment may end right before the end of the Period because of
// rounding issues.
if (time + threshold >= period.startTime)
return i;
}
return 0;
Expand Down

0 comments on commit 310e48f

Please sign in to comment.