Skip to content

Commit

Permalink
Do not perform backtrack flushing before first segment of discontinuity
Browse files Browse the repository at this point in the history
Follow up to #5659
  • Loading branch information
robwalch committed Jul 14, 2023
1 parent 32eac50 commit d0e6702
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api-extractor/report/hls.js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export class BaseStreamController extends TaskLoop implements NetworkComponentAP
// Warning: (ae-forgotten-export) The symbol "RemuxedTrack" needs to be exported by the entry point hls.d.ts
//
// (undocumented)
protected bufferFragmentData(data: RemuxedTrack, frag: Fragment, part: Part | null, chunkMeta: ChunkMetadata): void;
protected bufferFragmentData(data: RemuxedTrack, frag: Fragment, part: Part | null, chunkMeta: ChunkMetadata, noBacktracking?: boolean): void;
// (undocumented)
protected clearTrackerIfNeeded(frag: Fragment): void;
// (undocumented)
Expand Down
6 changes: 5 additions & 1 deletion src/controller/base-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,8 @@ export default class BaseStreamController
data: RemuxedTrack,
frag: Fragment,
part: Part | null,
chunkMeta: ChunkMetadata
chunkMeta: ChunkMetadata,
noBacktracking?: boolean
) {
if (!data || this.state !== State.PARSING) {
return;
Expand Down Expand Up @@ -911,6 +912,9 @@ export default class BaseStreamController
this.hls.trigger(Events.BUFFER_APPENDING, segment);

if (data.dropped && data.independent && !part) {
if (noBacktracking) {
return;
}
// Clear buffer so that we reload previous segments sequentially if required
this.flushBufferGap(frag);
}
Expand Down
8 changes: 7 additions & 1 deletion src/controller/stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,13 @@ export default class StreamController
if (this.backtrackFragment) {
this.backtrackFragment = frag;
}
this.bufferFragmentData(video, frag, part, chunkMeta);
this.bufferFragmentData(
video,
frag,
part,
chunkMeta,
isFirstFragment || isFirstInDiscontinuity
);
} else if (isFirstFragment || isFirstInDiscontinuity) {
// Mark segment with a gap to avoid loop loading
frag.gap = true;
Expand Down

0 comments on commit d0e6702

Please sign in to comment.