Skip to content

Commit

Permalink
Bugfix - encrypted vtt subtitles not rendered
Browse files Browse the repository at this point in the history
Fixes #4182 #4293
  • Loading branch information
mtoczko authored and robwalch committed Feb 10, 2022
1 parent 116e7cd commit 25df020
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/controller/subtitle-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,7 @@ export class SubtitleStreamController
}

if (foundFrag?.encrypted) {
logger.log(`Loading key for ${foundFrag.sn}`);
this.state = State.KEY_LOADING;
this.hls.trigger(Events.KEY_LOADING, { frag: foundFrag });
this.loadKey(foundFrag, trackDetails);
} else if (
foundFrag &&
this.fragmentTracker.getState(foundFrag) === FragmentState.NOT_LOADED
Expand Down
10 changes: 8 additions & 2 deletions src/controller/timeline-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,10 @@ export class TimelineController implements ComponentAPI {
}
}

private onFragLoaded(event: Events.FRAG_LOADED, data: FragLoadedData) {
private onFragLoaded(
event: Events.FRAG_LOADED,
data: FragDecryptedData | FragLoadedData
) {
const { frag, payload } = data;
const { initPTS, unparsedVttFrags } = this;
if (frag.type === PlaylistLevelType.SUBTITLE) {
Expand All @@ -464,11 +467,14 @@ export class TimelineController implements ComponentAPI {
}

const decryptData = frag.decryptdata;
// fragment after decryption has a stats object
const decrypted = 'stats' in data;
// If the subtitles are not encrypted, parse VTTs now. Otherwise, we need to wait.
if (
decryptData == null ||
decryptData.key == null ||
decryptData.method !== 'AES-128'
decryptData.method !== 'AES-128' ||
decrypted
) {
const trackPlaylistMedia = this.tracks[frag.level];
const vttCCs = this.vttCCs;
Expand Down

0 comments on commit 25df020

Please sign in to comment.