From 64e537367a569750d7a0d210521c77b288890ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?/z=C9=92=CC=83ge/?= Date: Wed, 26 Apr 2023 00:30:33 +0200 Subject: [PATCH] docs: update `config.drm.initDataTransform` documentation (#5170) --- docs/tutorials/fairplay.md | 4 ++-- externs/shaka/player.js | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/docs/tutorials/fairplay.md b/docs/tutorials/fairplay.md index 7ca3f7439c..dac5b29c0b 100644 --- a/docs/tutorials/fairplay.md +++ b/docs/tutorials/fairplay.md @@ -25,14 +25,14 @@ is used by the browser to generate the license request. If you don't use the default content ID derivation, you need to specify a custom init data transform: ```js -player.configure('drm.initDataTransform', (initData, initDataType) => { +player.configure('drm.initDataTransform', (initData, initDataType, drmInfo) => { if (initDataType != 'skd') return initData; // 'initData' is a buffer containing an 'skd://' URL as a UTF-8 string. const skdUri = shaka.util.StringUtils.fromBytesAutoDetect(initData); const contentId = getMyContentId(skdUri); - const cert = player.drmInfo().serverCertificate; + const cert = drmInfo.serverCertificate; return shaka.util.FairPlayUtils.initDataTransform(initData, contentId, cert); }); ``` diff --git a/externs/shaka/player.js b/externs/shaka/player.js index 2f06c9907d..93350fdd46 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -613,9 +613,7 @@ shaka.extern.AdvancedDrmConfiguration; * clearKeys: !Object., * delayLicenseRequestUntilPlayed: boolean, * advanced: Object., - * initDataTransform: - * ((function(!Uint8Array, string, ?shaka.extern.DrmInfo):!Uint8Array)| - * undefined), + * initDataTransform:(shaka.extern.InitDataTransform|undefined), * logLicenseExchange: boolean, * updateExpirationTime: number, * preferredKeySystems: !Array. @@ -639,10 +637,7 @@ shaka.extern.AdvancedDrmConfiguration; * Optional.
* A dictionary which maps key system IDs to advanced DRM configuration for * those key systems. - * @property - * {((function(!Uint8Array, string, ?shaka.extern.DrmInfo):!Uint8Array)| - * undefined)} - * initDataTransform + * @property {shaka.extern.InitDataTransform|undefined} initDataTransform * Optional.
* If given, this function is called with the init data from the * manifest/media and should return the (possibly transformed) init data to @@ -664,6 +659,17 @@ shaka.extern.AdvancedDrmConfiguration; */ shaka.extern.DrmConfiguration; +/** + * @typedef {function(!Uint8Array, string, ?shaka.extern.DrmInfo):!Uint8Array} + * + * @description + * A callback function to handle custom content ID signaling for FairPlay + * content. + * + * @exportDoc + */ +shaka.extern.InitDataTransform; + /** * @typedef {{