From e1cd031625c5a73cc964a8d1b039f9f10f8d52ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Tue, 23 Jan 2024 19:49:38 +0100 Subject: [PATCH] fix: Allow by default variants without pssh in the manifest (#6144) Fixes https://github.com/shaka-project/shaka-player/issues/5176 --- lib/media/drm_engine.js | 9 +++++++++ lib/player.js | 8 ++++++-- test/test/util/fake_drm_engine.js | 7 +++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/media/drm_engine.js b/lib/media/drm_engine.js index fbe56fd4d5..b4f3cb5a1e 100644 --- a/lib/media/drm_engine.js +++ b/lib/media/drm_engine.js @@ -542,6 +542,15 @@ shaka.media.DrmEngine = class { } } + /** + * Returns true if the manifest has init data. + * + * @return {boolean} + */ + hasManifestInitData() { + return !!this.manifestInitData_; + } + /** * Sets the server certificate based on the current DrmInfo. * diff --git a/lib/player.js b/lib/player.js index f8d5f53872..f4e974e14c 100644 --- a/lib/player.js +++ b/lib/player.js @@ -6523,6 +6523,8 @@ shaka.Player = class extends shaka.util.FakeEventTarget { const restrictedStatuses = shaka.Player.restrictedStatuses_; let tracksChanged = false; + goog.asserts.assert(this.drmEngine_, 'drmEngine should be non-null here.'); + // Only filter tracks for keys if we have some key statuses to look at. if (keyIds.length) { for (const variant of this.manifest_.variants) { @@ -6538,8 +6540,10 @@ shaka.Player = class extends shaka.util.FakeEventTarget { for (const keyId of stream.keyIds) { const keyStatus = keyStatusMap[isGlobalStatus ? '00' : keyId]; - variant.allowedByKeySystem = variant.allowedByKeySystem && - !!keyStatus && !restrictedStatuses.includes(keyStatus); + if (keyStatus || this.drmEngine_.hasManifestInitData()) { + variant.allowedByKeySystem = variant.allowedByKeySystem && + !!keyStatus && !restrictedStatuses.includes(keyStatus); + } } } diff --git a/test/test/util/fake_drm_engine.js b/test/test/util/fake_drm_engine.js index 85097bb417..c3c8f1fa00 100644 --- a/test/test/util/fake_drm_engine.js +++ b/test/test/util/fake_drm_engine.js @@ -100,4 +100,11 @@ shaka.test.FakeDrmEngine = class { // Copy the values to break the reference to the input value. this.offlineSessions_ = sessions.map((s) => s); } + + /** + * @override + */ + hasManifestInitData() { + return true; + } };