Skip to content

Commit

Permalink
feat: Add new error code for missing EME support (#7596)
Browse files Browse the repository at this point in the history
Close #4495
  • Loading branch information
avelad authored Nov 14, 2024
1 parent c1e26ea commit 3a83e76
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 162 deletions.
1 change: 0 additions & 1 deletion build/types/polyfill
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
+../../lib/polyfill/media_capabilities.js
+../../lib/polyfill/orientation.js
+../../lib/polyfill/patchedmediakeys_cert.js
+../../lib/polyfill/patchedmediakeys_nop.js
+../../lib/polyfill/patchedmediakeys_webkit.js
+../../lib/polyfill/pip_webkit.js
+../../lib/polyfill/random_uuid.js
Expand Down
1 change: 0 additions & 1 deletion docs/tutorials/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ __Polyfills__
{@linksource shaka.polyfill.VideoPlaybackQuality}
- prefixed EME implementations:
- {@linksource shaka.polyfill.PatchedMediaKeysWebkit}
- {@linksource shaka.polyfill.PatchedMediaKeysNop}
- variants of VTTCue and TextTrackCue constructors:
{@linksource shaka.polyfill.VTTCue}

Expand Down
17 changes: 14 additions & 3 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,12 @@ shaka.media.DrmEngine = class {
await this.getKeySystemAccessByConfigs_(configsByKeySystem);

if (!mediaKeySystemAccess) {
if (!navigator.requestMediaKeySystemAccess) {
throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,
shaka.util.Error.Code.MISSING_EME_SUPPORT);
}
throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,
Expand Down Expand Up @@ -1711,9 +1717,6 @@ shaka.media.DrmEngine = class {
* @return {!Promise.<!Object.<string, ?shaka.extern.DrmSupportType>>}
*/
static async probeSupport() {
goog.asserts.assert(shaka.util.DrmUtils.isBrowserSupported(),
'Must have basic EME support');

const testKeySystems = [
'org.w3.clearkey',
'com.widevine.alpha',
Expand All @@ -1725,6 +1728,14 @@ shaka.media.DrmEngine = class {
'com.apple.fps',
];

if (!shaka.util.DrmUtils.isBrowserSupported()) {
const result = {};
for (const keySystem of testKeySystems) {
result[keySystem] = null;
}
return result;
}

const widevineRobustness = [
'SW_SECURE_CRYPTO',
'SW_SECURE_DECODE',
Expand Down
8 changes: 0 additions & 8 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1110,14 +1110,6 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
return false;
}

// DRM support is not strictly necessary, but the APIs at least need to be
// there. Our no-op DRM polyfill should handle that.
// TODO(#1017): Consider making even DrmEngine optional.
const drmSupport = shaka.util.DrmUtils.isBrowserSupported();
if (!drmSupport) {
return false;
}

// If we have MediaSource (MSE) support, we should be able to use Shaka.
if (shaka.util.Platform.supportsMediaSource()) {
return true;
Expand Down
148 changes: 0 additions & 148 deletions lib/polyfill/patchedmediakeys_nop.js

This file was deleted.

5 changes: 5 additions & 0 deletions lib/util/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,11 @@ shaka.util.Error.Code = {
*/
'ERROR_CHECKING_HDCP_VERSION': 6019,

/**
* The browser does not support EME APIs, so DRM content cannot be played.
*/
'MISSING_EME_SUPPORT': 6020,


/**
* The call to Player.load() was interrupted by a call to Player.unload()
Expand Down
1 change: 0 additions & 1 deletion shaka-player.uncompiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ goog.require('shaka.polyfill.MediaSource');
goog.require('shaka.polyfill.MediaCapabilities');
goog.require('shaka.polyfill.Orientation');
goog.require('shaka.polyfill.PatchedMediaKeysApple');
goog.require('shaka.polyfill.PatchedMediaKeysNop');
goog.require('shaka.polyfill.PatchedMediaKeysWebkit');
goog.require('shaka.polyfill.PiPWebkit');
goog.require('shaka.polyfill.RandomUUID');
Expand Down

0 comments on commit 3a83e76

Please sign in to comment.