From ac6c4edd0d7b91e14930da0a1901ecda333b5d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Wed, 7 Dec 2022 20:52:28 +0100 Subject: [PATCH] fix: Correct default initDataTransform for legacy Apple Media Keys (#4797) --- build/types/core | 1 + build/types/fairplay | 3 +-- lib/util/player_configuration.js | 13 ++++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/build/types/core b/build/types/core index 4cb896d72f..f9f4554860 100644 --- a/build/types/core +++ b/build/types/core @@ -72,6 +72,7 @@ +../../lib/util/ebml_parser.js +../../lib/util/error.js +../../lib/util/event_manager.js ++../../lib/util/fairplay_utils.js +../../lib/util/fake_event.js +../../lib/util/fake_event_target.js +../../lib/util/functional.js diff --git a/build/types/fairplay b/build/types/fairplay index 6fbbd0b4ec..6cc0e6e69b 100644 --- a/build/types/fairplay +++ b/build/types/fairplay @@ -1,4 +1,3 @@ # FairPlay -+../../lib/polyfill/patchedmediakeys_apple.js -+../../lib/util/fairplay_utils.js \ No newline at end of file ++../../lib/polyfill/patchedmediakeys_apple.js \ No newline at end of file diff --git a/lib/util/player_configuration.js b/lib/util/player_configuration.js index 2cfc433b17..403723b77b 100644 --- a/lib/util/player_configuration.js +++ b/lib/util/player_configuration.js @@ -12,6 +12,7 @@ goog.require('shaka.config.AutoShowText'); goog.require('shaka.log'); goog.require('shaka.net.NetworkingEngine'); goog.require('shaka.util.ConfigUtils'); +goog.require('shaka.util.FairPlayUtils'); goog.require('shaka.util.LanguageUtils'); goog.require('shaka.util.ManifestParserUtils'); goog.require('shaka.util.Platform'); @@ -68,9 +69,15 @@ shaka.util.PlayerConfiguration = class { advanced: {}, // key is arbitrary key system ID, value is a record type delayLicenseRequestUntilPlayed: false, initDataTransform: (initData, initDataType, drmInfo) => { - return shaka.util.ConfigUtils.referenceParametersAndReturn( - [initData, initDataType, drmInfo], - initData); + const keySystem = drmInfo.keySystem; + if (keySystem == 'com.apple.fps.1_0' && initDataType == 'skd') { + const cert = drmInfo.serverCertificate; + const contentId = + shaka.util.FairPlayUtils.defaultGetContentId(initData); + initData = shaka.util.FairPlayUtils.initDataTransform( + initData, contentId, cert); + } + return initData; }, logLicenseExchange: false, updateExpirationTime: 1,