Skip to content

Commit 6d5cdb6

Browse files
authored
fix: Add support to crossBoundaryStrategy when using HLS (#8343)
Related to #8335
1 parent 82da6b1 commit 6d5cdb6

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/hls/hls_parser.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4277,6 +4277,10 @@ shaka.hls.HlsParser = class {
42774277
item.tags, 'EXT-X-DISCONTINUITY');
42784278
if (discontinuityTag) {
42794279
discontinuitySequence++;
4280+
4281+
if (previousReference && previousReference.initSegmentReference) {
4282+
previousReference.initSegmentReference.boundaryEnd = startTime;
4283+
}
42804284
}
42814285

42824286
// Apply new AES tags as you see them, keeping a running total.

lib/media/streaming_engine.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3045,17 +3045,26 @@ shaka.media.StreamingEngine = class {
30453045
const mediaState = this.mediaStates_.get(ContentType.VIDEO) ||
30463046
this.mediaStates_.get(ContentType.AUDIO);
30473047

3048-
if (!mediaState || !mediaState.lastAppendWindowEnd ||
3049-
mediaState.clearingBuffer) {
3048+
if (!mediaState || mediaState.clearingBuffer) {
30503049
return;
30513050
}
30523051

3052+
const lastInitRef = mediaState.lastInitSegmentReference;
3053+
if (!lastInitRef) {
3054+
return;
3055+
}
3056+
3057+
const boundaryEnd = lastInitRef.boundaryEnd;
3058+
if (boundaryEnd == null) {
3059+
return;
3060+
}
30533061
const threshold = shaka.media.StreamingEngine.CROSS_BOUNDARY_END_THRESHOLD_;
3054-
const fromEnd = mediaState.lastAppendWindowEnd - presentationTime;
3062+
const fromEnd = boundaryEnd - presentationTime;
30553063
// Check if greater than 0 to eliminate a backwards seek.
30563064
if (fromEnd > 0 && fromEnd < threshold) {
30573065
// Set the intended time to seek to in order to cross the boundary.
3058-
this.boundaryTime_ = mediaState.lastAppendWindowEnd;
3066+
this.boundaryTime_ = boundaryEnd +
3067+
shaka.media.StreamingEngine.APPEND_WINDOW_END_FUDGE_;
30593068

30603069
if (immediate) {
30613070
this.crossBoundaryTimer_.tickNow();

0 commit comments

Comments
 (0)