Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression in dev with CEA608 parser setup #5986

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/controller/timeline-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ export class TimelineController implements ComponentAPI {
hls.off(Events.SUBTITLE_TRACKS_CLEARED, this.onSubtitleTracksCleared, this);
hls.off(Events.BUFFER_FLUSHING, this.onBufferFlushing, this);
// @ts-ignore
this.hls = this.config = this.cea608Parser1 = this.cea608Parser2 = null;
this.hls = this.config = null;
this.cea608Parser1 = this.cea608Parser2 = undefined;
}

private lazyInit608() {
private initCea608Parsers() {
if (
this.config.enableCEA708Captions &&
(!this.cea608Parser1 || !this.cea608Parser2)
Expand Down Expand Up @@ -467,9 +468,10 @@ export class TimelineController implements ComponentAPI {
}

private onFragLoading(event: Events.FRAG_LOADING, data: FragLoadingData) {
this.initCea608Parsers();
const { cea608Parser1, cea608Parser2, lastCc, lastSn, lastPartIndex } =
this;
if (!this.enabled || !(cea608Parser1 && cea608Parser2)) {
if (!this.enabled || !cea608Parser1 || !cea608Parser2) {
return;
}
// if this frag isn't contiguous, clear the parser so cues with bad start/end times aren't added to the textTrack
Expand Down Expand Up @@ -667,7 +669,9 @@ export class TimelineController implements ComponentAPI {
event: Events.FRAG_PARSING_USERDATA,
data: FragParsingUserdataData,
) {
if (!this.enabled) {
this.initCea608Parsers();
const { cea608Parser1, cea608Parser2 } = this;
if (!this.enabled || !cea608Parser1 || !cea608Parser2) {
return;
}
const { frag, samples } = data;
Expand All @@ -677,11 +681,6 @@ export class TimelineController implements ComponentAPI {
) {
return;
}
this.lazyInit608();
const { cea608Parser1, cea608Parser2 } = this;
if (!cea608Parser1 || !cea608Parser2) {
return;
}
// If the event contains captions (found in the bytes property), push all bytes into the parser immediately
// It will create the proper timestamps based on the PTS value
for (let i = 0; i < samples.length; i++) {
Expand Down