Skip to content

Commit 09dcabc

Browse files
committed
fix(DASH): Fix playback after DASH period eviction (#7603)
Fixes #7516 in a simpler way Reverts 5eff038 Reverts 037193c
1 parent 2a6092e commit 09dcabc

22 files changed

+12
-209
lines changed

externs/shaka/manifest_parser.js

-3
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ shaka.extern.ManifestParser = class {
140140
* getBandwidthEstimate: function():number,
141141
* onMetadata: function(string, number, ?number,
142142
* !Array.<shaka.extern.MetadataFrame>),
143-
* closeSegmentIndex: function(shaka.extern.Stream, function()),
144143
* disableStream: function(!shaka.extern.Stream),
145144
* addFont: function(string, string)
146145
* }}
@@ -187,8 +186,6 @@ shaka.extern.ManifestParser = class {
187186
* @property {function(!shaka.extern.Stream)} disableStream
188187
* Called to temporarily disable a stream i.e. disabling all variant
189188
* containing said stream.
190-
* @property {function(!shaka.extern.Stream, function())} closeSegmentIndex
191-
* Called to close a segment index.
192189
* @property {function(string, string)} addFont
193190
* Called when a new font needs to be added.
194191
* @exportDoc

lib/dash/dash_parser.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,6 @@ shaka.dash.DashParser = class {
239239
this.lowLatencyMode_ = playerInterface.isLowLatencyMode();
240240
this.manifestUris_ = [uri];
241241
this.playerInterface_ = playerInterface;
242-
if (this.periodCombiner_) {
243-
this.periodCombiner_.setPlayerInterface(this.playerInterface_);
244-
}
245242

246243
const updateDelay = await this.requestManifest_();
247244

@@ -684,7 +681,6 @@ shaka.dash.DashParser = class {
684681
}
685682

686683
this.manifestPatchContext_.type = mpdType;
687-
this.cleanStreamMap_();
688684
/** @type {!shaka.media.PresentationTimeline} */
689685
let presentationTimeline;
690686
if (this.manifest_) {
@@ -861,6 +857,8 @@ shaka.dash.DashParser = class {
861857
// after period combining, while we still have a direct reference, so that
862858
// any new streams will appear in the period combiner.
863859
this.playerInterface_.makeTextStreamsForClosedCaptions(this.manifest_);
860+
861+
this.cleanStreamMap_();
864862
}
865863

866864
/**
@@ -1504,13 +1502,21 @@ shaka.dash.DashParser = class {
15041502
return !this.lastManifestUpdatePeriodIds_.includes(pId);
15051503
});
15061504
for (const pId of diffPeriodsIDs) {
1505+
let shouldDeleteIndex = true;
15071506
for (const contextId of this.indexStreamMap_[pId]) {
1507+
const stream = this.streamMap_[contextId];
1508+
if (stream.segmentIndex && !stream.segmentIndex.isEmpty()) {
1509+
shouldDeleteIndex = false;
1510+
continue;
1511+
}
15081512
if (this.periodCombiner_) {
15091513
this.periodCombiner_.deleteStream(this.streamMap_[contextId], pId);
15101514
}
15111515
delete this.streamMap_[contextId];
15121516
}
1513-
delete this.indexStreamMap_[pId];
1517+
if (shouldDeleteIndex) {
1518+
delete this.indexStreamMap_[pId];
1519+
}
15141520
}
15151521
}
15161522

lib/media/streaming_engine.js

-26
Original file line numberDiff line numberDiff line change
@@ -513,32 +513,6 @@ shaka.media.StreamingEngine = class {
513513
}
514514
}
515515

516-
/**
517-
* closeSegmentIndex if the stream is not active
518-
* @param {shaka.extern.Stream} stream
519-
* @param {function()} closeSegmentIndex
520-
*/
521-
closeSegmentIndex(stream, closeSegmentIndex) {
522-
const type = /** @type {!shaka.util.ManifestParserUtils.ContentType} */
523-
(stream.type);
524-
const mediaState = this.mediaStates_.get(type);
525-
if (mediaState) {
526-
/**
527-
* Closes the segmentIndex only if the stream is not active.
528-
* If the stream is active the eviction will be peformed
529-
* by the next onUpdate_().
530-
*/
531-
const matchedStreams = mediaState.stream.matchedStreams;
532-
const found = matchedStreams.find((match) => match.id === stream.id);
533-
if (!found) {
534-
closeSegmentIndex();
535-
}
536-
} else {
537-
// type of stream not active
538-
closeSegmentIndex();
539-
}
540-
}
541-
542516

543517
/**
544518
* Handles deferred releases of old SegmentIndexes for the mediaState's

lib/offline/storage.js

-1
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,6 @@ shaka.offline.Storage = class {
12171217
onManifestUpdated: () => {},
12181218
getBandwidthEstimate: () => config.abr.defaultBandwidthEstimate,
12191219
onMetadata: () => {},
1220-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
12211220
disableStream: (stream) => {},
12221221
addFont: (name, url) => {},
12231222
};

lib/player.js

-7
Original file line numberDiff line numberDiff line change
@@ -2169,13 +2169,6 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
21692169
});
21702170
}
21712171
},
2172-
closeSegmentIndex: (stream, closeSegmentIndex) => {
2173-
if (this.streamingEngine_) {
2174-
this.streamingEngine_.closeSegmentIndex(stream, closeSegmentIndex);
2175-
} else {
2176-
closeSegmentIndex();
2177-
}
2178-
},
21792172
disableStream: (stream) => this.disableStream(
21802173
stream, this.config_.streaming.maxDisabledTime),
21812174
addFont: (name, url) => this.addFont(name, url),

lib/util/periods.js

+1-24
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ shaka.util.PeriodCombiner = class {
4848
/** @private {boolean} */
4949
this.useStreamOnce_ = false;
5050

51-
/** @private {?shaka.extern.ManifestParser.PlayerInterface} */
52-
this.playerInterface_ = null;
53-
5451
/**
5552
* The IDs of the periods we have already used to generate streams.
5653
* This helps us identify the periods which have been added when a live
@@ -83,15 +80,6 @@ shaka.util.PeriodCombiner = class {
8380
this.usedPeriodIds_.clear();
8481
}
8582

86-
/**
87-
* @param {?shaka.extern.ManifestParser.PlayerInterface} playerInterface
88-
*
89-
* @export
90-
*/
91-
setPlayerInterface(playerInterface) {
92-
this.playerInterface_ = playerInterface;
93-
}
94-
9583
/**
9684
* @return {!Array.<shaka.extern.Variant>}
9785
*
@@ -167,19 +155,8 @@ shaka.util.PeriodCombiner = class {
167155
}
168156
}
169157
if (stream.segmentIndex) {
170-
if (this.playerInterface_) {
171-
const closeSegmentIndex = () => {
172-
stream.closeSegmentIndex();
173-
};
174-
175-
this.playerInterface_.closeSegmentIndex(
176-
stream,
177-
closeSegmentIndex);
178-
} else {
179-
stream.closeSegmentIndex();
180-
}
158+
stream.closeSegmentIndex();
181159
}
182-
183160
this.usedPeriodIds_.delete(periodId);
184161
}
185162

test/dash/dash_parser_content_protection_unit.js

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ describe('DashParser ContentProtection', () => {
4747
onManifestUpdated: () => {},
4848
getBandwidthEstimate: () => 1e6,
4949
onMetadata: () => {},
50-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
5150
disableStream: (stream) => {},
5251
addFont: (name, url) => {},
5352
};

test/dash/dash_parser_live_unit.js

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ describe('DashParser Live', () => {
3939
onManifestUpdated: () => {},
4040
getBandwidthEstimate: () => 1e6,
4141
onMetadata: () => {},
42-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
4342
disableStream: (stream) => {},
4443
addFont: (name, url) => {},
4544
};

test/dash/dash_parser_manifest_unit.js

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ describe('DashParser Manifest', () => {
6060
onManifestUpdated: () => {},
6161
getBandwidthEstimate: () => 1e6,
6262
onMetadata: () => {},
63-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
6463
disableStream: (stream) => {},
6564
addFont: shaka.test.Util.spyFunc(addFontSpy),
6665
};

test/dash/dash_parser_patch_unit.js

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ describe('DashParser Patch', () => {
5050
onManifestUpdated: () => {},
5151
getBandwidthEstimate: () => 1e6,
5252
onMetadata: () => {},
53-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
5453
disableStream: (stream) => {},
5554
addFont: (name, url) => {},
5655
};

test/dash/dash_parser_segment_base_unit.js

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ describe('DashParser SegmentBase', () => {
4343
onManifestUpdated: () => {},
4444
getBandwidthEstimate: () => 1e6,
4545
onMetadata: () => {},
46-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
4746
disableStream: (stream) => {},
4847
addFont: (name, url) => {},
4948
};

test/dash/dash_parser_segment_list_unit.js

-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ describe('DashParser SegmentList', () => {
353353
onManifestUpdated: () => {},
354354
getBandwidthEstimate: () => 1e6,
355355
onMetadata: () => {},
356-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
357356
disableStream: (stream) => {},
358357
addFont: (name, url) => {},
359358
};

test/dash/dash_parser_segment_template_unit.js

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ describe('DashParser SegmentTemplate', () => {
5252
onManifestUpdated: () => {},
5353
getBandwidthEstimate: () => 1e6,
5454
onMetadata: () => {},
55-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
5655
disableStream: (stream) => {},
5756
addFont: (name, url) => {},
5857
};

test/hls/hls_live_unit.js

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ describe('HlsParser live', () => {
8282
onManifestUpdated: () => {},
8383
getBandwidthEstimate: () => 1e6,
8484
onMetadata: () => {},
85-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
8685
disableStream: (stream) => {},
8786
addFont: (name, url) => {},
8887
};

test/hls/hls_parser_unit.js

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ describe('HlsParser', () => {
9696
onManifestUpdated: () => {},
9797
getBandwidthEstimate: () => 1e6,
9898
onMetadata: shaka.test.Util.spyFunc(onMetadataSpy),
99-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
10099
disableStream: (stream) => {},
101100
addFont: (name, url) => {},
102101
};

test/media/streaming_engine_integration.js

-2
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,6 @@ describe('StreamingEngine', () => {
271271
onSegmentAppended: () => playhead.notifyOfBufferingChange(),
272272
onInitSegmentAppended: () => {},
273273
beforeAppendSegment: () => Promise.resolve(),
274-
onMetadata: () => {},
275-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
276274
disableStream: (stream, time) => false,
277275
};
278276
streamingEngine = new shaka.media.StreamingEngine(

test/media/streaming_engine_unit.js

-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ describe('StreamingEngine', () => {
467467
onSegmentAppended: Util.spyFunc(onSegmentAppended),
468468
onInitSegmentAppended: () => {},
469469
beforeAppendSegment: Util.spyFunc(beforeAppendSegment),
470-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
471470
disableStream: Util.spyFunc(disableStream),
472471
};
473472
streamingEngine = new shaka.media.StreamingEngine(

test/mss/mss_parser_unit.js

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ describe('MssParser Manifest', () => {
8282
onManifestUpdated: () => {},
8383
getBandwidthEstimate: () => 1e6,
8484
onMetadata: () => {},
85-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
8685
disableStream: (stream) => {},
8786
addFont: (name, url) => {},
8887
};

test/test/util/dash_parser_util.js

-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ shaka.test.Dash = class {
4848
onManifestUpdated: () => {},
4949
getBandwidthEstimate: () => 1e6,
5050
onMetadata: () => {},
51-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
5251
disableStream: (stream) => {},
5352
addFont: (name, url) => {},
5453
};
@@ -99,7 +98,6 @@ shaka.test.Dash = class {
9998
onManifestUpdated: () => {},
10099
getBandwidthEstimate: () => 1e6,
101100
onMetadata: () => {},
102-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
103101
disableStream: (stream) => {},
104102
addFont: (name, url) => {},
105103
};

test/test/util/mss_parser_util.js

-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ shaka.test.Mss = class {
4848
onManifestUpdated: () => {},
4949
getBandwidthEstimate: () => 1e6,
5050
onMetadata: () => {},
51-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
5251
disableStream: (stream) => {},
5352
addFont: (name, url) => {},
5453
};
@@ -90,7 +89,6 @@ shaka.test.Mss = class {
9089
onManifestUpdated: () => {},
9190
getBandwidthEstimate: () => 1e6,
9291
onMetadata: () => {},
93-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
9492
disableStream: (stream) => {},
9593
addFont: (name, url) => {},
9694
};

test/util/content_steering_manager_unit.js

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ describe('ContentSteeringManager', () => {
3030
onManifestUpdated: fail,
3131
getBandwidthEstimate: () => 1e6,
3232
onMetadata: () => {},
33-
closeSegmentIndex: (stream, closeSegmentIndex) => {},
3433
disableStream: (stream) => {},
3534
addFont: (name, url) => {},
3635
};

0 commit comments

Comments
 (0)