From a98812d2bd7c47b7acff261befb05f4fec13bf45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Fri, 3 Nov 2023 12:50:12 +0100 Subject: [PATCH] feat: Add config to ignore duplicate init data --- demo/config.js | 4 +++- externs/shaka/player.js | 10 ++++++++-- lib/media/drm_engine.js | 5 +---- lib/util/player_configuration.js | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/demo/config.js b/demo/config.js index c52c04a43d..61e851bb4f 100644 --- a/demo/config.js +++ b/demo/config.js @@ -128,7 +128,9 @@ shakaDemo.Config = class { /* canBeUnset= */ true) .addBoolInput_('Parse inband "pssh" from media segments', 'drm.parseInbandPsshEnabled') - .addTextInput_('Min HDCP version', 'drm.minHdcpVersion'); + .addTextInput_('Min HDCP version', 'drm.minHdcpVersion') + .addBoolInput_('Ignore duplicate init data', + 'drm.ignoreDuplicateInitData'); const advanced = shakaDemoMain.getConfiguration().drm.advanced || {}; const addDRMAdvancedField = (name, valueName, suggestions) => { // All advanced fields of a given type are set at once. diff --git a/externs/shaka/player.js b/externs/shaka/player.js index f947ef3f44..29f3d5653f 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -757,7 +757,8 @@ shaka.extern.PersistentSessionMetadata; * preferredKeySystems: !Array., * keySystemsMapping: !Object., * parseInbandPsshEnabled: boolean, - * minHdcpVersion: string + * minHdcpVersion: string, + * ignoreDuplicateInitData: boolean * }} * * @property {shaka.extern.RetryParameters} retryParameters @@ -813,7 +814,12 @@ shaka.extern.PersistentSessionMetadata; * By default (''), do not check the HDCP version.
* Indicates the minimum version of HDCP to start the playback of encrypted * streams. May be ignored if not supported by the device. - * + * @property {boolean} ignoreDuplicateInitData + * Defaults to false on Tizen 2, and true for all other browsers.
+ * When true indicate that the player doesn't ignore duplicate init data. + * Note: Tizen 2015 and 2016 models will send multiple webkitneedkey events + * with the same init data. If the duplicates are supressed, playback + * will stall without errors. * @exportDoc */ shaka.extern.DrmConfiguration; diff --git a/lib/media/drm_engine.js b/lib/media/drm_engine.js index 27a865a582..4af760327d 100644 --- a/lib/media/drm_engine.js +++ b/lib/media/drm_engine.js @@ -715,11 +715,8 @@ shaka.media.DrmEngine = class { const metadatas = this.activeSessions_.values(); for (const metadata of metadatas) { - // Tizen 2015 and 2016 models will send multiple webkitneedkey events - // with the same init data. If the duplicates are supressed, playback - // will stall without errors. if (shaka.util.BufferUtils.equal(initData, metadata.initData) && - !shaka.util.Platform.isTizen2()) { + this.config_.ignoreDuplicateInitData) { shaka.log.debug('Ignoring duplicate init data.'); return; } diff --git a/lib/util/player_configuration.js b/lib/util/player_configuration.js index 2c1f707fc7..72c0cab630 100644 --- a/lib/util/player_configuration.js +++ b/lib/util/player_configuration.js @@ -91,6 +91,7 @@ shaka.util.PlayerConfiguration = class { // segments to detect key changes. parseInbandPsshEnabled: shaka.util.Platform.isXboxOne(), minHdcpVersion: '', + ignoreDuplicateInitData: !shaka.util.Platform.isTizen2(), }; const manifest = {