From 129b0683857716847ca429cf4283dbdc2ca3931f Mon Sep 17 00:00:00 2001 From: Michelle Zhuo Date: Mon, 22 Mar 2021 21:14:47 -0700 Subject: [PATCH] feat(MediaCap): Add config for using MediaCapabilities The developers should be able to set the config to use MediaCapabilities. If set to true, we'll use mediaCapabilities.decodingInfo() to get the variants' decodingInfo. If set to false, we'll fallback to use MediaSource.isTypeSupported() and navigator.requestMediaKeyAccess(). Issue #1391 Change-Id: I1acbfb12780291e998d56a91156ae2c47a87c7ae --- demo/common/message_ids.js | 1 + demo/config.js | 4 +++- demo/locales/en.json | 1 + demo/locales/source.json | 4 ++++ externs/shaka/player.js | 6 +++++- lib/util/player_configuration.js | 1 + 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/demo/common/message_ids.js b/demo/common/message_ids.js index ebe6f649fe..ef8b6d2778 100644 --- a/demo/common/message_ids.js +++ b/demo/common/message_ids.js @@ -225,6 +225,7 @@ shakaDemo.MessageIds = { TRICK_PLAY_CONTROLS_WARNING: 'DEMO_TRICK_PLAY_CONTROLS_WARNING', UI_LOCALE: 'DEMO_UI_LOCALE', UPDATE_EXPIRATION_TIME: 'DEMO_UPDATE_EXPIRATION_TIME', + USE_MEDIA_CAPABILITIES: 'DEMO_USE_MEDIA_CAPABILITIES', USE_NATIVE_HLS_SAFARI: 'DEMO_USE_NATIVE_HLS_SAFARI', USE_PERSISTENT_LICENSES: 'DEMO_USE_PERSISTENT_LICENSES', VIDEO_ROBUSTNESS: 'DEMO_VIDEO_ROBUSTNESS', diff --git a/demo/config.js b/demo/config.js index 1c5e674fa9..cb0be5fa9f 100644 --- a/demo/config.js +++ b/demo/config.js @@ -334,7 +334,9 @@ shakaDemo.Config = class { .addBoolInput_(MessageIds.FORCE_HTTPS, 'streaming.forceHTTPS') .addBoolInput_(MessageIds.PREFER_NATIVE_HLS, - 'streaming.preferNativeHls'); + 'streaming.preferNativeHls') + .addBoolInput_(MessageIds.USE_MEDIA_CAPABILITIES, + 'useMediaCapabilities'); if (!shakaDemoMain.getNativeControlsEnabled()) { this.addBoolInput_(MessageIds.ALWAYS_STREAM_TEXT, diff --git a/demo/locales/en.json b/demo/locales/en.json index 4513e00f21..eff08d008c 100644 --- a/demo/locales/en.json +++ b/demo/locales/en.json @@ -125,6 +125,7 @@ "DEMO_MAX_PIXELS": "Max Pixels", "DEMO_MAX_SMALL_GAP_SIZE": "Maximum Small Gap Size", "DEMO_MAX_WIDTH": "Max Width", + "DEMO_USE_MEDIA_CAPABILITIES": "Use MediaCapabilities", "DEMO_MICROSOFT": "Microsoft", "DEMO_MIN_BANDWIDTH": "Min Bandwidth", "DEMO_MIN_FRAMERATE": "Min Framerate", diff --git a/demo/locales/source.json b/demo/locales/source.json index 402318bf10..16aea1d167 100644 --- a/demo/locales/source.json +++ b/demo/locales/source.json @@ -503,6 +503,10 @@ "description": "The name of a configuration value.", "message": "Max Width" }, + "DEMO_USE_MEDIA_CAPABILITIES": { + "description": "The name of a configuration value.", + "message": "Use [JARGON:MediaCapabilities]" + }, "DEMO_MICROSOFT": { "description": "Text that describes an asset that comes from the Microsoft.", "message": "[PROPER_NAME:Microsoft]" diff --git a/externs/shaka/player.js b/externs/shaka/player.js index 4f9a88d81a..37b872e500 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -967,7 +967,8 @@ shaka.extern.OfflineConfiguration; * restrictions: shaka.extern.Restrictions, * playRangeStart: number, * playRangeEnd: number, - * textDisplayFactory: shaka.extern.TextDisplayer.Factory + * textDisplayFactory: shaka.extern.TextDisplayer.Factory, + * useMediaCapabilities: boolean * }} * * @property {shaka.extern.DrmConfiguration} drm @@ -1016,6 +1017,9 @@ shaka.extern.OfflineConfiguration; * @property {shaka.extern.TextDisplayer.Factory} textDisplayFactory * A factory to construct a text displayer. Note that, if this is changed * during playback, it will cause the text tracks to be reloaded. + * @property {boolean} useMediaCapabilities + * If true, use MediaCapabilities.decodingInfo() to filter the manifest, and + * get MediaKeys information for encrypted content. Default to false. * @exportDoc */ shaka.extern.PlayerConfiguration; diff --git a/lib/util/player_configuration.js b/lib/util/player_configuration.js index d97030af90..279d4ee34d 100644 --- a/lib/util/player_configuration.js +++ b/lib/util/player_configuration.js @@ -245,6 +245,7 @@ shaka.util.PlayerConfiguration = class { }, playRangeStart: 0, playRangeEnd: Infinity, + useMediaCapabilities: false, textDisplayFactory: () => null, };