Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FairPlay DRM updates #3347

Merged
merged 11 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ shakaDemo.Main = class {
shakaDemo.Main.commonDrmSystems = [
'com.widevine.alpha',
'com.microsoft.playready',
'com.apple.fps.1_0',
'com.apple.fps',
'com.adobe.primetime',
'org.w3.clearkey',
];
Expand Down
22 changes: 19 additions & 3 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,17 @@ shaka.media.DrmEngine = class {
return false;
}

/**
* @param {?string} keySystem
* @return {boolean} */
static isFairPlayKeySystem(keySystem) {
if (keySystem) {
return !!keySystem.match(/^com\.apple\.fps/);
}

return false;
}

/**
* Check if DrmEngine (as initialized) will likely be able to support the
* given content type.
Expand Down Expand Up @@ -800,6 +811,14 @@ shaka.media.DrmEngine = class {
config.sessionTypes = [info.sessionType];
}

// FairPlay does not support distinctiveIdentifier, persistentState
// and also only supports temporary sessions.
if (shaka.media.DrmEngine.isFairPlayKeySystem(info.keySystem)) {
config.distinctiveIdentifier = 'not-allowed';
config.persistentState = 'not-allowed';
avelad marked this conversation as resolved.
Show resolved Hide resolved
config.sessionTypes = ['temporary'];
avelad marked this conversation as resolved.
Show resolved Hide resolved
}

const robustness = (stream.type == ContentType.AUDIO) ?
info.audioRobustness : info.videoRobustness;

Expand Down Expand Up @@ -1631,9 +1650,6 @@ shaka.media.DrmEngine = class {
'com.widevine.alpha',
'com.microsoft.playready',
'com.microsoft.playready.recommendation',
'com.apple.fps.3_0',
'com.apple.fps.2_0',
'com.apple.fps.1_0',
avelad marked this conversation as resolved.
Show resolved Hide resolved
'com.apple.fps',
'com.adobe.primetime',
];
Expand Down
2 changes: 1 addition & 1 deletion lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
originalId: null,
createSegmentIndex: () => Promise.resolve(),
segmentIndex: null,
mimeType: 'video/mp4',
mimeType: 'application/vnd.apple.mpegurl',
avelad marked this conversation as resolved.
Show resolved Hide resolved
codecs: '',
encrypted: true,
drmInfos: [], // Filled in by DrmEngine config.
Expand Down
9 changes: 1 addition & 8 deletions lib/polyfill/patchedmediakeys_apple.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,12 @@ shaka.polyfill.PatchedMediaKeysApple = class {
return;
}

/* Unprefixed EME disabled. See:
https://github.com/google/shaka-player/pull/3021#issuecomment-766999811

// Only tested in Safari 14.
const safariVersion = shaka.util.Platform.safariVersion();
if (navigator.requestMediaKeySystemAccess &&
// eslint-disable-next-line no-restricted-syntax
MediaKeySystemAccess.prototype.getConfiguration &&
safariVersion && safariVersion >= 14) {
MediaKeySystemAccess.prototype.getConfiguration) {
// Unprefixed EME is preferable.
return;
}
*/

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

Expand Down
20 changes: 20 additions & 0 deletions test/media/drm_engine_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,26 @@ function testDrmEngine(useMediaCapabilities) {
});
});

describe('isFairPlayKeySystem', () => {
it('should return true for FairPlay', () => {
expect(shaka.media.DrmEngine.isFairPlayKeySystem(
'com.apple.fps')).toBe(true);
expect(shaka.media.DrmEngine.isFairPlayKeySystem(
'com.apple.fps.1_0g')).toBe(true);
avelad marked this conversation as resolved.
Show resolved Hide resolved
expect(shaka.media.DrmEngine.isFairPlayKeySystem(
'com.apple.fps.2_0')).toBe(true);
expect(shaka.media.DrmEngine.isFairPlayKeySystem(
'com.apple.fps.3_0')).toBe(true);
});

it('should return false for non-FairPlay key systems', () => {
expect(shaka.media.DrmEngine.isFairPlayKeySystem(
'com.widevine.alpha')).toBe(false);
expect(shaka.media.DrmEngine.isFairPlayKeySystem(
'com.abc.playready')).toBe(false);
});
});

describe('getDrmInfo', () => {
it('includes correct info', async () => {
// Leave only one drmInfo
Expand Down