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: unnecessary parsing of in-band pssh when pssh is in the manifest #5198

Merged
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
15 changes: 9 additions & 6 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ shaka.media.DrmEngine = class {

/** @private {Promise} */
this.mediaKeysAttached_ = null;

/** @private {?shaka.extern.InitDataOverride} */
this.manifestInitData_ = null;
}

/** @override */
Expand Down Expand Up @@ -498,18 +501,18 @@ shaka.media.DrmEngine = class {
() => this.closeOpenSessions_());
}

const manifestInitData = this.currentDrmInfo_ ?
this.currentDrmInfo_.initData.find(
this.manifestInitData_ = this.currentDrmInfo_ ?
(this.currentDrmInfo_.initData.find(
(initDataOverride) => initDataOverride.initData.length > 0,
) : null;
) || null) : null;

/**
* We can attach media keys before the playback actually begins when:
* - If we are not using FairPlay Modern EME
* - Some initData already has been generated (through the manifest)
* - In case of an offline session
*/
if (manifestInitData ||
if (this.manifestInitData_ ||
this.currentDrmInfo_.keySystem !== 'com.apple.fps' ||
this.storedPersistentSessions_.size) {
await this.attachMediaKeys_();
Expand All @@ -525,7 +528,7 @@ shaka.media.DrmEngine = class {
// Also suppress 'encrypted' events when parsing in-band ppsh
// from media segments because that serves the same purpose as the
// 'encrypted' events.
if (!manifestInitData && !this.storedPersistentSessions_.size &&
if (!this.manifestInitData_ && !this.storedPersistentSessions_.size &&
!this.config_.parseInbandPsshEnabled) {
this.eventManager_.listen(
this.video_, 'encrypted', (e) => this.onEncryptedEvent_(e));
Expand Down Expand Up @@ -2496,7 +2499,7 @@ shaka.media.DrmEngine = class {
* @return {!Promise<void>}
*/
parseInbandPssh(contentType, mediaSegment) {
if (!this.config_.parseInbandPsshEnabled) {
if (!this.config_.parseInbandPsshEnabled || this.manifestInitData_) {
return Promise.resolve();
}

Expand Down