Skip to content

Commit

Permalink
feat: make drm sessionType configurable in advanced DRM config (shaka…
Browse files Browse the repository at this point in the history
…-project#3301)

Prerequisite for issue shaka-project#1495 (com.microsoft.playready.recommendation key system)
  • Loading branch information
valotvince committed Apr 1, 2021
1 parent 9f54c41 commit 4574a5d
Show file tree
Hide file tree
Showing 16 changed files with 211 additions and 35 deletions.
3 changes: 2 additions & 1 deletion demo/common/asset.js
Expand Up @@ -357,13 +357,14 @@ const ShakaDemoAssetInfo = class {
*/
getConfiguration() {
const config = /** @type {shaka.extern.PlayerConfiguration} */(
{drm: {}, manifest: {dash: {}}});
{drm: {advanced: {}}, manifest: {dash: {}}});
if (this.licenseServers.size) {
config.drm.servers = {};
this.licenseServers.forEach((value, key) => {
config.drm.servers[key] = value;
});
}

if (this.clearKeys.size) {
config.drm.clearKeys = {};
this.clearKeys.forEach((value, key) => {
Expand Down
1 change: 1 addition & 0 deletions demo/common/message_ids.js
Expand Up @@ -162,6 +162,7 @@ shakaDemo.MessageIds = {
DISABLE_XLINK_PROCESSING: 'DEMO_DISABLE_XLINK_PROCESSING',
DRM_RETRY_SECTION_HEADER: 'DEMO_DRM_RETRY_SECTION_HEADER',
DRM_SECTION_HEADER: 'DEMO_DRM_SECTION_HEADER',
DRM_SESSION_TYPE: 'DEMO_DRM_SESSION_TYPE',
DURATION_BACKOFF: 'DEMO_DURATION_BACKOFF',
ENABLED: 'DEMO_ENABLED',
FORCE_HTTPS: 'DEMO_FORCE_HTTPS',
Expand Down
46 changes: 32 additions & 14 deletions demo/config.js
Expand Up @@ -133,16 +133,9 @@ shakaDemo.Config = class {
/* canBeZero= */ false,
/* canBeUnset= */ true);
const advanced = shakaDemoMain.getConfiguration().drm.advanced || {};
const robustnessSuggestions = [
'SW_SECURE_CRYPTO',
'SW_SECURE_DECODE',
'HW_SECURE_CRYPTO',
'HW_SECURE_DECODE',
'HW_SECURE_ALL',
];
const addRobustnessField = (name, valueName) => {
// All robustness fields of a given type are set at once.
this.addDatalistInput_(name, robustnessSuggestions, (input) => {
const addDRMAdvancedField = (name, valueName, suggestions) => {
// All advanced fields of a given type are set at once.
this.addDatalistInput_(name, suggestions, (input) => {
// Add in any common drmSystem not currently in advanced.
for (const drmSystem of shakaDemo.Main.commonDrmSystems) {
if (!(drmSystem in advanced)) {
Expand All @@ -158,12 +151,37 @@ shakaDemo.Config = class {
});
const keySystem = Object.keys(advanced)[0];
if (keySystem) {
const currentRobustness = advanced[keySystem][valueName];
this.latestInput_.input().value = currentRobustness;
const currentValue = advanced[keySystem][valueName];
this.latestInput_.input().value = currentValue;
}
};
addRobustnessField(MessageIds.VIDEO_ROBUSTNESS, 'videoRobustness');
addRobustnessField(MessageIds.AUDIO_ROBUSTNESS, 'audioRobustness');

const robustnessSuggestions = [
'SW_SECURE_CRYPTO',
'SW_SECURE_DECODE',
'HW_SECURE_CRYPTO',
'HW_SECURE_DECODE',
'HW_SECURE_ALL',
'150',
'2000',
'3000',
];

const sessionTypeSuggestions = ['temporary', 'persistent-license'];

addDRMAdvancedField(
MessageIds.VIDEO_ROBUSTNESS,
'videoRobustness',
robustnessSuggestions);
addDRMAdvancedField(
MessageIds.AUDIO_ROBUSTNESS,
'audioRobustness',
robustnessSuggestions);
addDRMAdvancedField(
MessageIds.DRM_SESSION_TYPE,
'sessionType',
sessionTypeSuggestions);

this.addRetrySection_('drm', MessageIds.DRM_RETRY_SECTION_HEADER);
}

Expand Down
1 change: 1 addition & 0 deletions demo/locales/en.json
Expand Up @@ -62,6 +62,7 @@
"DEMO_DRM_SECTION_HEADER": "DRM",
"DEMO_DRM_SYSTEM": "Custom DRM System",
"DEMO_DRM_TAB": "Drm",
"DEMO_DRM_SESSION_TYPE": "Session Type",
"DEMO_DURATION_BACKOFF": "Duration Backoff",
"DEMO_EDIT_CUSTOM": "Edit",
"DEMO_ENABLED": "Enabled",
Expand Down
4 changes: 4 additions & 0 deletions demo/locales/source.json
Expand Up @@ -243,6 +243,10 @@
"description": "The header for a section of configuration values.",
"message": "[JARGON:DRM]"
},
"DEMO_DRM_SESSION_TYPE": {
"description": "The name of a configuration value.",
"message": "Session Type"
},
"DEMO_DRM_SYSTEM": {
"description": "The label on a field that allows users to provide a Digital Rights Management (DRM) system identifier for a custom asset.",
"message": "Custom [JARGON:DRM] System"
Expand Down
1 change: 1 addition & 0 deletions demo/main.js
Expand Up @@ -1726,6 +1726,7 @@ shakaDemo.Main = class {
persistentStateRequired: false,
videoRobustness: '',
audioRobustness: '',
sessionType: '',
serverCertificate: new Uint8Array(0),
individualizationServer: '',
};
Expand Down
23 changes: 19 additions & 4 deletions docs/tutorials/drm-config.md
Expand Up @@ -145,18 +145,33 @@ playback. Passing in a higher security level than can be supported will cause
default is the empty string, which is the lowest security level supported by the
key system.

Each key system has their own values for robustness. The values for Widevine
are well-known (see the [Chromium sources][]) and listed below, but
values for other key systems are not known to us at this time.
Each key system has their own values for robustness.

[Chromium sources]: https://cs.chromium.org/chromium/src/components/cdm/renderer/widevine_key_system_properties.h?q=SW_SECURE_CRYPTO&l=22
##### Widevine

Chromium sources: https://cs.chromium.org/chromium/src/components/cdm/renderer/widevine_key_system_properties.h?q=SW_SECURE_CRYPTO&l=22

- `SW_SECURE_CRYPTO`
- `SW_SECURE_DECODE`
- `HW_SECURE_CRYPTO`
- `HW_SECURE_DECODE`
- `HW_SECURE_ALL`

##### PlayReady

Microsoft Documentation: https://docs.microsoft.com/en-us/playready/overview/security-level

- `3000`
- `2000`

`com.microsoft.playready` key system ignores given robustness and stays at a
`2000` decryption level.

NB: Audio Hardware DRM is not supported (PlayReady limitation)

##### Other key-systems

Values for other key systems are not known to us at this time.

#### Continue the Tutorials

Expand Down
4 changes: 4 additions & 0 deletions externs/shaka/manifest.js
Expand Up @@ -111,6 +111,7 @@ shaka.extern.InitDataOverride;
* audioRobustness: string,
* videoRobustness: string,
* serverCertificate: Uint8Array,
* sessionType: string,
* initData: Array.<!shaka.extern.InitDataOverride>,
* keyIds: Set.<string>
* }}
Expand All @@ -132,6 +133,9 @@ shaka.extern.InitDataOverride;
* <i>Defaults to false. Can be filled in by advanced DRM config.</i> <br>
* True if the application requires the key system to support persistent
* state, e.g., for persistent license storage.
* @property {string} sessionType
* <i>Defaults to 'temporary' if Shaka wasn't initiated for storage.
* Can be filled in by advanced DRM config sessionType parameter.</i> <br>
* @property {string} audioRobustness
* <i>Defaults to '', e.g., no specific robustness required. Can be filled in
* by advanced DRM config.</i> <br>
Expand Down
7 changes: 6 additions & 1 deletion externs/shaka/player.js
Expand Up @@ -516,7 +516,8 @@ shaka.extern.EmsgInfo;
* videoRobustness: string,
* audioRobustness: string,
* serverCertificate: Uint8Array,
* individualizationServer: string
* individualizationServer: string,
* sessionType: string
* }}
*
* @property {boolean} distinctiveIdentifierRequired
Expand Down Expand Up @@ -547,6 +548,10 @@ shaka.extern.EmsgInfo;
* @property {string} individualizationServer
* The server that handles an <code>'individualiation-request'</code>. If the
* server isn't given, it will default to the license server.
* @property {string} sessionType
* <i>Defaults to <code>'temporary'</code> for streaming.</i> <br>
* The MediaKey session type to create streaming licenses with. This doesn't
* affect offline storage.
*
* @exportDoc
*/
Expand Down

0 comments on commit 4574a5d

Please sign in to comment.