Skip to content

Commit

Permalink
feat: Check minHdcpVersion in probeSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Dec 26, 2024
1 parent 8764169 commit a83b435
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
7 changes: 6 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ shaka.extern.Restrictions;
* persistentState: boolean,
* encryptionSchemes: !Array<string|null>,
* videoRobustnessLevels: !Array<string>,
* audioRobustnessLevels: !Array<string>
* audioRobustnessLevels: !Array<string>,
* minHdcpVersions: !Array<string>
* }}
*
* @property {boolean} persistentState
Expand All @@ -512,6 +513,10 @@ shaka.extern.Restrictions;
* An array of audio robustness levels that are reported to work. An empty
* array indicates that none were tested. Not all key systems have a list of
* known robustness levels built into probeSupport().
* @property {!Array<string>} minHdcpVersions
* An array of min HDCP levels that are reported to work. An empty
* array indicates that none were tested. Not all key systems have support to
* check min HDCP levels.
* @exportDoc
*/
shaka.extern.DrmSupportType;
Expand Down
41 changes: 40 additions & 1 deletion lib/drm/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,18 @@ shaka.drm.DrmEngine = class {
return result;
}

const hdcpVersions = [
'1.0',
'1.1',
'1.2',
'1.3',
'1.4',
'2.0',
'2.1',
'2.2',
'2.3',
];

const widevineRobustness = [
'SW_SECURE_CRYPTO',
'SW_SECURE_DECODE',
Expand Down Expand Up @@ -1870,8 +1882,9 @@ shaka.drm.DrmEngine = class {
* @return {!Promise}
*/
const processMediaKeySystemAccess = async (keySystem, access) => {
let mediaKeys;
try {
await access.createMediaKeys();
mediaKeys = await access.createMediaKeys();
} catch (error) {
// In some cases, we can get a successful access object but fail to
// create a MediaKeys instance. When this happens, don't update the
Expand Down Expand Up @@ -1901,6 +1914,7 @@ shaka.drm.DrmEngine = class {
encryptionSchemes: [],
videoRobustnessLevels: [],
audioRobustnessLevels: [],
minHdcpVersions: [],
};
if (support.has(keySystem) && support.get(keySystem)) {
// Update the existing non-null value.
Expand Down Expand Up @@ -1930,6 +1944,31 @@ shaka.drm.DrmEngine = class {
!supportValue.audioRobustnessLevels.includes(audioRobustness)) {
supportValue.audioRobustnessLevels.push(audioRobustness);
}

if ('getStatusForPolicy' in mediaKeys) {
for (const hdcpVersion of hdcpVersions) {
if (supportValue.minHdcpVersions.includes(hdcpVersion)) {
continue;
}
try {
// eslint-disable-next-line no-await-in-loop
const status = await mediaKeys.getStatusForPolicy({
minHdcpVersion: hdcpVersion,
});
if (status == 'usable') {
if (!supportValue.minHdcpVersions.includes(hdcpVersion)) {
supportValue.minHdcpVersions.push(hdcpVersion);
}
} else if (status == 'output-restricted') {
// Since we test levels incrementally, if a low level already
// fails with output restricted, we avoid testing the rest.
break;
}
} catch (error) {
// Ignore error.
}
}
}
};

const testSystemEme = async (keySystem, encryptionScheme,
Expand Down

0 comments on commit a83b435

Please sign in to comment.