Skip to content

Commit

Permalink
wip3
Browse files Browse the repository at this point in the history
  • Loading branch information
peaBerberian committed Oct 29, 2024
1 parent 39e4df9 commit fc67ea9
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions src/main_thread/decrypt/content_decryptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
state: ContentDecryptorState.ReadyForContent,
isMediaKeysAttached: MediaKeyAttachmentStatus.Attached,
isInitDataQueueLocked: false,
data: { mediaKeysData: mediaKeysInfo, isFull: false, isPending: false },
data: { mediaKeysData: mediaKeysInfo },
};
if (prevState !== ContentDecryptorState.ReadyForContent) {
this.trigger("stateChange", ContentDecryptorState.ReadyForContent);
Expand Down Expand Up @@ -649,7 +649,7 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
}

// We unlock the init data queue first, to avoid weird states.
this._tryUnlockInitDataQueue();
this._unlockInitDataQueue();
if (this._isStopped()) {
return;
}
Expand Down Expand Up @@ -734,7 +734,7 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
}

// Make sure to disable the processing log if not already done
this._tryUnlockInitDataQueue();
this._unlockInitDataQueue();
},
onWarning: (value: IPlayerError): void => {
this.trigger("warning", value);
Expand All @@ -759,7 +759,7 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
log.warn("DRM: failed to close expired session", closeError);
})
.then(() => {
this._tryUnlockInitDataQueue();
this._unlockInitDataQueue();
})
.catch((retryError) => this._onFatalError(retryError));

Expand All @@ -780,7 +780,7 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
this.trigger("blackListProtectionData", initializationData);
}

this._tryUnlockInitDataQueue();
this._unlockInitDataQueue();

// TODO warning for blacklisted session?
},
Expand All @@ -792,7 +792,7 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
options.singleLicensePer === undefined ||
options.singleLicensePer === "init-data"
) {
this._tryUnlockInitDataQueue();
this._unlockInitDataQueue();
}

if (sessionRes.type === MediaKeySessionLoadingType.Created) {
Expand Down Expand Up @@ -1074,12 +1074,6 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
* an impact on the handling of other initialization data.
*/
private _lockInitDataQueue(): void {
if (this._stateData.isMediaKeysAttached === MediaKeyAttachmentStatus.Attached) {
this._stateData.data.isPending = true;
} else {
log.error("DRM: Processing init data without a MediaKeys attached.");
}

if (this._stateData.isInitDataQueueLocked === false) {
this._stateData.isInitDataQueueLocked = true;
}
Expand All @@ -1090,14 +1084,9 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
*
* Should have no effect if the `_initDataQueue` was not locked.
*/
private _tryUnlockInitDataQueue(): void {
if (this._stateData.isMediaKeysAttached === MediaKeyAttachmentStatus.Attached) {
this._stateData.data.isPending = false;
if (this._stateData.data.isFull) {
return;
}
} else {
log.error("DRM: Processing init data without a MediaKeys attached.");
private _unlockInitDataQueue(): void {
if (this._stateData.isMediaKeysAttached !== MediaKeyAttachmentStatus.Attached) {
log.error("DRM: Trying to unlock in the wrong state");
return;
}
this._stateData.isInitDataQueueLocked = false;
Expand Down Expand Up @@ -1494,8 +1483,6 @@ type IReadyForContentStateDataAttached = IContentDecryptorStateBase<
* Initialized state (@see ContentDecryptorState).
*/
mediaKeysData: IAttachedMediaKeysData;
isFull: boolean;
isPending: boolean;
}
>;

Expand Down

0 comments on commit fc67ea9

Please sign in to comment.