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

(cherry picked from commit d0e6702)
  • Loading branch information
robwalch committed Jul 14, 2023
1 parent 6b65bf3 commit c1a44d3
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 @@ -291,7 +291,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 @@ -873,7 +873,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 @@ -901,6 +902,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 @@ -1175,7 +1175,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 c1a44d3

Please sign in to comment.