Skip to content

Commit

Permalink
fix(DASH): Clear usedPeriodIds when period is removed from the manife…
Browse files Browse the repository at this point in the history
…st (#7305)

Issue #6239
  • Loading branch information
avelad authored and joeyparrish committed Sep 13, 2024
1 parent 0f1b03d commit 650474c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ shaka.dash.DashParser = class {
for (const pId of diffPeriodsIDs) {
for (const contextId of this.indexStreamMap_[pId]) {
if (this.periodCombiner_) {
this.periodCombiner_.deleteStream(this.streamMap_[contextId]);
this.periodCombiner_.deleteStream(this.streamMap_[contextId], pId);
}
delete this.streamMap_[contextId];
}
Expand Down
4 changes: 3 additions & 1 deletion lib/util/periods.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ shaka.util.PeriodCombiner = class {
* Deletes a stream from matchedStreams because it is no longer needed
*
* @param {?shaka.extern.Stream} stream
* @param {string} periodId
*
* @export
*/
deleteStream(stream) {
deleteStream(stream, periodId) {
if (!stream) {
return;
}
Expand Down Expand Up @@ -147,6 +148,7 @@ shaka.util.PeriodCombiner = class {
if (stream.segmentIndex) {
stream.closeSegmentIndex();
}
this.usedPeriodIds_.delete(periodId);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/util/periods_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1259,8 +1259,8 @@ describe('PeriodCombiner', () => {
expect(video2.originalId).toBe('3,4');
expect(video2.matchedStreams.length).toBe(2);

combiner.deleteStream(stream1);
combiner.deleteStream(stream3);
combiner.deleteStream(stream1, '0');
combiner.deleteStream(stream3, '1');

variants = combiner.getVariants();
expect(variants.length).toBe(2);
Expand Down

0 comments on commit 650474c

Please sign in to comment.