Skip to content

Commit

Permalink
perf: Improve times of probeSupport (#7889)
Browse files Browse the repository at this point in the history
Fixes to #7449
  • Loading branch information
avelad authored Jan 15, 2025
1 parent 56523e4 commit c4931c1
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 7 deletions.
47 changes: 40 additions & 7 deletions lib/drm/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2062,17 +2062,47 @@ shaka.drm.DrmEngine = class {
support.set(keySystem, null);
}

const checkKeySystem = (keySystem) => {
// Our Polyfill will reject anything apart com.apple.fps key systems.
// It seems the Safari modern EME API will allow to request a
// MediaKeySystemAccess for the ClearKey CDM, create and update a key
// session but playback will never start
// Safari bug: https://bugs.webkit.org/show_bug.cgi?id=231006
if (shaka.drm.DrmUtils.isClearKeySystem(keySystem) &&
shaka.util.Platform.isSafari()) {
return false;
}
// FairPlay is a proprietary DRM from Apple and will never work on
// Windows.
if (shaka.drm.DrmUtils.isFairPlayKeySystem(keySystem) &&
shaka.util.Platform.isWindows()) {
return false;
}
// PlayReady is a proprietary DRM from Microsoft and will never work on
// Apple platforms
if (shaka.drm.DrmUtils.isPlayReadyKeySystem(keySystem) &&
(shaka.util.Platform.isMac() || shaka.util.Platform.isApple())) {
return false;
}
// Mozilla has no intention of supporting PlayReady according to
// comments posted on Bugzilla.
if (shaka.drm.DrmUtils.isPlayReadyKeySystem(keySystem) &&
shaka.util.Platform.isFirefox()) {
return false;
}
// We are sure that WisePlay is not supported on Windows or macOS.
if (shaka.drm.DrmUtils.isWisePlayKeySystem(keySystem) &&
(shaka.util.Platform.isWindows() || shaka.util.Platform.isMac())) {
return false;
}
return true;
};

// Test each key system and encryption scheme.
const tests = [];
for (const encryptionScheme of testEncryptionSchemes) {
for (const keySystem of testKeySystems) {
// Our Polyfill will reject anything apart com.apple.fps key systems.
// It seems the Safari modern EME API will allow to request a
// MediaKeySystemAccess for the ClearKey CDM, create and update a key
// session but playback will never start
// Safari bug: https://bugs.webkit.org/show_bug.cgi?id=231006
if (keySystem === 'org.w3.clearkey' &&
shaka.util.Platform.isSafari()) {
if (!checkKeySystem(keySystem)) {
continue;
}
tests.push(testSystemEme(keySystem, encryptionScheme, '', ''));
Expand All @@ -2082,6 +2112,9 @@ shaka.drm.DrmEngine = class {

for (const keySystem of testKeySystems) {
for (const robustness of (testRobustness[keySystem] || [])) {
if (!checkKeySystem(keySystem)) {
continue;
}
tests.push(testSystemEme(keySystem, null, robustness, ''));
tests.push(testSystemEme(keySystem, null, '', robustness));
tests.push(testSystemMcap(keySystem, null, robustness, ''));
Expand Down
8 changes: 8 additions & 0 deletions lib/drm/drm_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ shaka.drm.DrmUtils = class {
return false;
}

/**
* @param {?string} keySystem
* @return {boolean}
*/
static isWisePlayKeySystem(keySystem) {
return keySystem === 'com.huawei.wiseplay';
}

/**
* A method for generating a key for the MediaKeySystemAccessRequests cache.
*
Expand Down
16 changes: 16 additions & 0 deletions test/drm/drm_utils_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,20 @@ describe('DrmUtils', () => {
'com.abc.playready')).toBe(false);
});
});

describe('isWisePlayKeySystem', () => {
it('should return true for WisePlay', () => {
expect(shaka.drm.DrmUtils.isWisePlayKeySystem(
'com.huawei.wiseplay')).toBe(true);
});

it('should return false for non-WisePlay key systems', () => {
expect(shaka.drm.DrmUtils.isWisePlayKeySystem(
'com.widevine.alpha')).toBe(false);
expect(shaka.drm.DrmUtils.isWisePlayKeySystem(
'com.microsoft.playready')).toBe(false);
expect(shaka.drm.DrmUtils.isWisePlayKeySystem(
'com.apple.fps')).toBe(false);
});
});
});

0 comments on commit c4931c1

Please sign in to comment.