Skip to content

Commit 08019ed

Browse files
aveladjoeyparrish
authored andcommitted
perf: Improve times of probeSupport (#7889)
Fixes to #7449 Backported to v4.9.x
1 parent 170caf8 commit 08019ed

File tree

3 files changed

+64
-7
lines changed

3 files changed

+64
-7
lines changed

lib/media/drm_engine.js

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,17 +1947,47 @@ shaka.media.DrmEngine = class {
19471947
support.set(keySystem, null);
19481948
}
19491949

1950+
const checkKeySystem = (keySystem) => {
1951+
// Our Polyfill will reject anything apart com.apple.fps key systems.
1952+
// It seems the Safari modern EME API will allow to request a
1953+
// MediaKeySystemAccess for the ClearKey CDM, create and update a key
1954+
// session but playback will never start
1955+
// Safari bug: https://bugs.webkit.org/show_bug.cgi?id=231006
1956+
if (shaka.util.DrmUtils.isClearKeySystem(keySystem) &&
1957+
shaka.util.Platform.isSafari()) {
1958+
return false;
1959+
}
1960+
// FairPlay is a proprietary DRM from Apple and will never work on
1961+
// Windows.
1962+
if (shaka.util.DrmUtils.isFairPlayKeySystem(keySystem) &&
1963+
shaka.util.Platform.isWindows()) {
1964+
return false;
1965+
}
1966+
// PlayReady is a proprietary DRM from Microsoft and will never work on
1967+
// Apple platforms
1968+
if (shaka.util.DrmUtils.isPlayReadyKeySystem(keySystem) &&
1969+
(shaka.util.Platform.isMac() || shaka.util.Platform.isApple())) {
1970+
return false;
1971+
}
1972+
// Mozilla has no intention of supporting PlayReady according to
1973+
// comments posted on Bugzilla.
1974+
if (shaka.util.DrmUtils.isPlayReadyKeySystem(keySystem) &&
1975+
shaka.util.Platform.isFirefox()) {
1976+
return false;
1977+
}
1978+
// We are sure that WisePlay is not supported on Windows or macOS.
1979+
if (shaka.util.DrmUtils.isWisePlayKeySystem(keySystem) &&
1980+
(shaka.util.Platform.isWindows() || shaka.util.Platform.isMac())) {
1981+
return false;
1982+
}
1983+
return true;
1984+
};
1985+
19501986
// Test each key system and encryption scheme.
19511987
const tests = [];
19521988
for (const encryptionScheme of testEncryptionSchemes) {
19531989
for (const keySystem of testKeySystems) {
1954-
// Our Polyfill will reject anything apart com.apple.fps key systems.
1955-
// It seems the Safari modern EME API will allow to request a
1956-
// MediaKeySystemAccess for the ClearKey CDM, create and update a key
1957-
// session but playback will never start
1958-
// Safari bug: https://bugs.webkit.org/show_bug.cgi?id=231006
1959-
if (keySystem === 'org.w3.clearkey' &&
1960-
shaka.util.Platform.isSafari()) {
1990+
if (!checkKeySystem(keySystem)) {
19611991
continue;
19621992
}
19631993
tests.push(testSystemEme(keySystem, encryptionScheme, '', ''));
@@ -1967,6 +1997,9 @@ shaka.media.DrmEngine = class {
19671997

19681998
for (const keySystem of testKeySystems) {
19691999
for (const robustness of (testRobustness[keySystem] || [])) {
2000+
if (!checkKeySystem(keySystem)) {
2001+
continue;
2002+
}
19702003
tests.push(testSystemEme(keySystem, null, robustness, ''));
19712004
tests.push(testSystemEme(keySystem, null, '', robustness));
19722005
tests.push(testSystemMcap(keySystem, null, robustness, ''));

lib/util/drm_utils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ shaka.util.DrmUtils = class {
157157
return false;
158158
}
159159

160+
/**
161+
* @param {?string} keySystem
162+
* @return {boolean}
163+
*/
164+
static isWisePlayKeySystem(keySystem) {
165+
return keySystem === 'com.huawei.wiseplay';
166+
}
167+
160168
/**
161169
* A method for generating a key for the MediaKeySystemAccessRequests cache.
162170
*

test/util/drm_utils_unit.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,20 @@ describe('DrmUtils', () => {
212212
'com.abc.playready')).toBe(false);
213213
});
214214
});
215+
216+
describe('isWisePlayKeySystem', () => {
217+
it('should return true for WisePlay', () => {
218+
expect(shaka.util.DrmUtils.isWisePlayKeySystem(
219+
'com.huawei.wiseplay')).toBe(true);
220+
});
221+
222+
it('should return false for non-WisePlay key systems', () => {
223+
expect(shaka.util.DrmUtils.isWisePlayKeySystem(
224+
'com.widevine.alpha')).toBe(false);
225+
expect(shaka.util.DrmUtils.isWisePlayKeySystem(
226+
'com.microsoft.playready')).toBe(false);
227+
expect(shaka.util.DrmUtils.isWisePlayKeySystem(
228+
'com.apple.fps')).toBe(false);
229+
});
230+
});
215231
});

0 commit comments

Comments
 (0)