Skip to content

Commit

Permalink
Prefer unprefixed EME for Safari (#3021)
Browse files Browse the repository at this point in the history
Closes: #2999
  • Loading branch information
Álvaro Velad Galván authored and joeyparrish committed Jan 20, 2021
1 parent 830b483 commit 4e17129
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
10 changes: 9 additions & 1 deletion lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ shaka.media.DrmEngine = class {
// Create a config entry for each key system.
for (const info of allDrmInfo) {
const config = {
// Ignore initDataTypes.
initDataTypes: ['cenc'],
audioCapabilities: [],
videoCapabilities: [],
distinctiveIdentifier: 'optional',
Expand Down Expand Up @@ -749,6 +749,13 @@ shaka.media.DrmEngine = class {
// MediaKeySystemConfiguration
config['drmInfos'].push(info);

if (info.initData && info.initData.length) {
config.initDataTypes = [
...new Set(
info.initData.map((initData) => initData.initDataType)
),
];
}
if (info.distinctiveIdentifierRequired) {
config.distinctiveIdentifier = 'required';
}
Expand Down Expand Up @@ -1544,6 +1551,7 @@ shaka.media.DrmEngine = class {
];

const basicConfig = {
initDataTypes: ['cenc'],
videoCapabilities: basicVideoCapabilities,
};
const offlineConfig = {
Expand Down
13 changes: 7 additions & 6 deletions lib/polyfill/patchedmediakeys_apple.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ goog.require('shaka.util.EventManager');
goog.require('shaka.util.FakeEvent');
goog.require('shaka.util.FakeEventTarget');
goog.require('shaka.util.MediaReadyState');
goog.require('shaka.util.Platform');
goog.require('shaka.util.PublicPromise');
goog.require('shaka.util.StringUtils');

Expand All @@ -33,15 +34,15 @@ shaka.polyfill.PatchedMediaKeysApple = class {
return;
}

// TODO: Prefer unprefixed EME once we know how to use it.
// See: https://bugs.webkit.org/show_bug.cgi?id=197433
/*
// Only tested in Safari 14.
const safariVersion = shaka.util.Platform.safariVersion();
if (navigator.requestMediaKeySystemAccess &&
MediaKeySystemAccess.prototype.getConfiguration) {
// Prefixed EME is preferable.
// eslint-disable-next-line no-restricted-syntax
MediaKeySystemAccess.prototype.getConfiguration &&
safariVersion && safariVersion >= 14) {
// Unprefixed EME is preferable.
return;
}
*/

shaka.log.info('Using Apple-prefixed EME');

Expand Down

0 comments on commit 4e17129

Please sign in to comment.