Skip to content

Commit

Permalink
Fix: Discard only invalid overlapping periods
Browse files Browse the repository at this point in the history
Discard only invalid and/or overlapping periods to fulfil the requirements
  • Loading branch information
echoy-harmonicinc committed Aug 25, 2021
1 parent e248db4 commit 1c64e20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/dash/dash_parser.js
Expand Up @@ -101,6 +101,12 @@ shaka.dash.DashParser = class {
*/
this.largestPeriodStartTime_ = null;

/**
* Period IDs that have seen before.
* @private {!Array.<number>}
*/
this.seenPeriodIds_ = [];

/**
* The minimum of the availabilityTimeOffset values among the adaptation
* sets.
Expand Down Expand Up @@ -581,11 +587,15 @@ shaka.dash.DashParser = class {
// the last period in manifest
if (this.largestPeriodStartTime_ !== null && start !== null &&
start < this.largestPeriodStartTime_ &&
!this.seenPeriodIds_.includes(start) &&
i + 1 != periodNodes.length) {
shaka.log.debug(
'Skipping Period', i + 1, ' as its start time is smaller than ' +
'the largest period start time that has been seen.');
`Skipping Period ${i+1} as its start time is smaller than ` +
'the largest period start time that has been seen, and start ' +
'time is unseen before');
continue;
} else if (!this.seenPeriodIds_.includes(start)) {
this.seenPeriodIds_.push(start);
}

// Save maximum period start time if it is the last period
Expand Down
3 changes: 2 additions & 1 deletion test/dash/dash_parser_manifest_unit.js
Expand Up @@ -2198,7 +2198,8 @@ describe('DashParser Manifest', () => {
it('skip periods that are earlier than max period start time', async () => {
const sources = [
buildManifestWithPeriodStartTime([5, 15]),
buildManifestWithPeriodStartTime([4, 15]), // simulate out-of-sync of -1s
buildManifestWithPeriodStartTime([6, 15]), // simulate out-of-sync of -1s
buildManifestWithPeriodStartTime([4, 15]), // simulate out-of-sync of +1s
];
const segments = [];

Expand Down

0 comments on commit 1c64e20

Please sign in to comment.