Skip to content

Commit

Permalink
feat!: Remove support for Safari 12 and support modern EME in Safari 13
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro Velad committed Apr 11, 2022
1 parent 57c7324 commit 9233f32
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 834 deletions.
30 changes: 29 additions & 1 deletion .github/workflows/build-and-test.yaml
Expand Up @@ -32,16 +32,20 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
browser: ["Chrome", "Firefox", "Edge", "Safari", "Safari-14"]
browser: ["Chrome", "Firefox", "Edge", "Safari", "Safari-13", "Safari-14"]
exclude:
- os: ubuntu-latest
browser: Edge
- os: windows-latest
browser: Safari
- os: windows-latest
browser: Safari-13
- os: windows-latest
browser: Safari-14
- os: ubuntu-latest
browser: Safari
- os: ubuntu-latest
browser: Safari-13
- os: ubuntu-latest
browser: Safari-14
include:
Expand Down Expand Up @@ -69,6 +73,24 @@ jobs:
with:
ref: ${{ github.event.inputs.ref || github.ref }}

# Safari 13 can be installed, but not to the root, and it can't replace
# the standard version, at least not on GitHub's VMs. If you try to
# install directly to the root with sudo, it will appear to succeed, but
# will have no effect. If you try to script it explicitly with rm -rf
# and cp, this will fail. Safari may be on a read-only filesystem.
- name: Install Safari 13 to home directory
if: matrix.os == 'macos-latest' && matrix.browser == 'Safari-13'
run: |
# Download Safari 13
# See also https://www.macupdate.com/app/mac/15675/apple-safari/old-versions
curl -Lv https://www.macupdate.com/action/download/62945 > safari-13.1.2.pkg
# Install Safari 13 to homedir specifically.
installer -pkg safari-13.1.2.pkg -target CurrentUserHomeDirectory
# Install a launcher that can execute a shell script to launch this
npm install karma-script-launcher --save-dev
# Safari 14 can be installed, but not to the root, and it can't replace
# the standard version, at least not on GitHub's VMs. If you try to
# install directly to the root with sudo, it will appear to succeed, but
Expand All @@ -95,6 +117,12 @@ jobs:
run: |
browser=${{ matrix.browser }}
if [[ "$browser" == "Safari-13" ]]; then
# Replace the browser name with a script that can launch this
# browser from the command line.
browser="$PWD/.github/workflows/safari-homedir-launcher.sh"
fi
if [[ "$browser" == "Safari-14" ]]; then
# Replace the browser name with a script that can launch this
# browser from the command line.
Expand Down
1 change: 0 additions & 1 deletion build/types/polyfill
Expand Up @@ -8,7 +8,6 @@
+../../lib/polyfill/mediasource.js
+../../lib/polyfill/media_capabilities.js
+../../lib/polyfill/orientation.js
+../../lib/polyfill/patchedmediakeys_apple.js
+../../lib/polyfill/patchedmediakeys_ms.js
+../../lib/polyfill/patchedmediakeys_nop.js
+../../lib/polyfill/patchedmediakeys_webkit.js
Expand Down
21 changes: 0 additions & 21 deletions docs/tutorials/fairplay.md
Expand Up @@ -22,27 +22,6 @@ player.configure('drm.advanced.com\\.apple\\.fps\\.serverCertificateUri',
'https://example.com/cert.der');
```

## Content ID

Note: This only applies when legacy Apple Media Keys is used.

Some FairPlay content use custom signaling for the content ID. The content ID
is used by the browser to generate the license request. If you don't use the
default content ID derivation, you need to specify a custom init data transform:

```js
player.configure('drm.initDataTransform', (initData, initDataType) => {
if (initDataType != 'skd')
return initData;

// 'initData' is a buffer containing an 'skd://' URL as a UTF-8 string.
const skdUri = shaka.util.StringUtils.fromBytesAutoDetect(initData);
const contentId = getMyContentId(skdUri);
const cert = player.drmInfo().serverCertificate;
return shaka.util.FairPlayUtils.initDataTransform(initData, contentId, cert);
});
```

## License wrapping

Some FairPlay servers need to accept the license request in a different format
Expand Down
11 changes: 0 additions & 11 deletions externs/shaka/player.js
Expand Up @@ -618,9 +618,6 @@ shaka.extern.AdvancedDrmConfiguration;
* clearKeys: !Object.<string, string>,
* delayLicenseRequestUntilPlayed: boolean,
* advanced: Object.<string, shaka.extern.AdvancedDrmConfiguration>,
* initDataTransform:
* ((function(!Uint8Array, string, ?shaka.extern.DrmInfo):!Uint8Array)|
* undefined),
* logLicenseExchange: boolean,
* updateExpirationTime: number,
* preferredKeySystems: !Array.<string>
Expand All @@ -644,14 +641,6 @@ shaka.extern.AdvancedDrmConfiguration;
* <i>Optional.</i> <br>
* A dictionary which maps key system IDs to advanced DRM configuration for
* those key systems.
* @property
* {((function(!Uint8Array, string, ?shaka.extern.DrmInfo):!Uint8Array)|
* undefined)}
* initDataTransform
* <i>Optional.</i><br>
* If given, this function is called with the init data from the
* manifest/media and should return the (possibly transformed) init data to
* pass to the browser.
* @property {boolean} logLicenseExchange
* <i>Optional.</i><br>
* If set to <code>true</code>, prints logs containing the license exchange.
Expand Down
8 changes: 0 additions & 8 deletions lib/hls/hls_parser.js
Expand Up @@ -2454,14 +2454,6 @@ shaka.hls.HlsParser = class {
shaka.util.Error.Code.HLS_MSE_ENCRYPTED_MP2T_NOT_SUPPORTED);
}

if (shaka.util.Platform.isMediaKeysPolyfilled()) {
throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code
.HLS_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED);
}

/*
* Even if we're not able to construct initData through the HLS tag, adding
* a DRMInfo will allow DRM Engine to request a media key system access
Expand Down
40 changes: 0 additions & 40 deletions lib/media/drm_engine.js
Expand Up @@ -14,7 +14,6 @@ goog.require('shaka.util.BufferUtils');
goog.require('shaka.util.Destroyer');
goog.require('shaka.util.Error');
goog.require('shaka.util.EventManager');
goog.require('shaka.util.FairPlayUtils');
goog.require('shaka.util.FakeEvent');
goog.require('shaka.util.IDestroyable');
goog.require('shaka.util.Iterables');
Expand Down Expand Up @@ -1254,28 +1253,6 @@ shaka.media.DrmEngine = class {
};
this.activeSessions_.set(session, metadata);

/**
* initDataTransform is only necessary when using legacy protection
* APIs, so prevent doing any transform when using the EME HTML5 spec
*/
if (shaka.util.Platform.isMediaKeysPolyfilled()) {
try {
initData = this.config_.initDataTransform(
initData, initDataType, this.currentDrmInfo_);
} catch (error) {
let shakaError = error;
if (!(error instanceof shaka.util.Error)) {
shakaError = new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,
shaka.util.Error.Code.INIT_DATA_TRANSFORM_ERROR,
error);
}
this.onError_(shakaError);
return;
}
}

if (this.config_.logLicenseExchange) {
const str = shaka.util.Uint8ArrayUtils.toBase64(initData);
shaka.log.info('EME init data: type=', initDataType, 'data=', str);
Expand Down Expand Up @@ -1310,23 +1287,6 @@ shaka.media.DrmEngine = class {
});
}

/**
* @param {!Uint8Array} initData
* @param {string} initDataType
* @param {?shaka.extern.DrmInfo} drmInfo
* @return {!Uint8Array}
*/
static defaultInitDataTransform(initData, initDataType, drmInfo) {
if (initDataType == 'skd') {
const cert = drmInfo.serverCertificate;
const contentId =
shaka.util.FairPlayUtils.defaultGetContentId(initData);
initData = shaka.util.FairPlayUtils.initDataTransform(
initData, contentId, cert);
}
return initData;
}

/**
* @param {!MediaKeyMessageEvent} event
* @private
Expand Down
6 changes: 3 additions & 3 deletions lib/player.js
Expand Up @@ -847,10 +847,10 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
return false;
}

// We do not support iOS 9, 10, or 11, nor those same versions of desktop
// Safari.
// We do not support iOS 9, 10, 11 or 12, nor those same versions of
// desktop Safari.
const safariVersion = shaka.util.Platform.safariVersion();
if (safariVersion && safariVersion < 12) {
if (safariVersion && safariVersion < 13) {
return false;
}

Expand Down

0 comments on commit 9233f32

Please sign in to comment.