hls.js
hls.js copied to clipboard
feat: add support for com.apple.fps keySystem
This PR will...
Add support for com.apple.streamingkeydelivery
KEYFORMAT with MSE (some copy/paste from #2630)
It brings several changes that would need be separated in other PRs (but to have a MVP, I chose to make it inside one PR)
- licenseXhrSetup can return a Promise (backward-compatible with before)
- Pass current
keySystem
to licenseXhrSetup & licenseResponseCallback to allow developers to do different treatment to xhr and data depending on the used keySystem - drmSystems configuration for any supported keySytem (backward-compatible with
widevineLicenseUrl
- fetch and set serverCertificate when the URL is specified inside drmSystems
- Specific error when
session.update
rejects
To make it work with my own DRMProvider, I had to write that configuration on my app, hope this helps developers when integrating fps keySystem (maybe add it somewhere it the configuration ?)
{
licenseResponseCallback: (xhr, url, keySystem) => {
if (keySytem === 'com.apple.fps') {
const utf8decoder = new TextDecoder();
const base64 = utf8decoder.decode(xhr.response);
const decoded = window.atob(base64);
const result = new Uint8Array(decoded.length);
for (let i = 0; i < decoded.length; i++) {
result[i] = decoded.charCodeAt(i);
}
return result;
}
return xhr.response;
},
licenseXhrSetup: async (xhr, url) => {
const { token: { handler: fetchToken } = {} } = this.options.drm;
const token = await fetchToken();
xhr.open('POST', url, true);
xhr.setRequestHeader('x-dt-auth-token', token.value);
},
}
⚠️ com.apple.fps
keySystem correctly works with MSE when using fMP4 (or CMAF). It won't work properly when using mp2t with MSE, directly or when using mux.js (it might be different with the hls.js transmuxer, but I didn't took the opportunity to test it). See https://github.com/google/shaka-player/pull/3776 for more information.
Still to be done and I might need tips to go faster 😄 :
- https://github.com/video-dev/hls.js/pull/4474/files#diff-77475850c023ed8d210fa4c336636cebd71004c6fb06b4552026b5942f8779cfR365
- https://github.com/video-dev/hls.js/pull/4474/files#diff-c186c3e34fe7140dfa14f550159924ed16b8f79e334b727950b47e8e12636d9aR836
- ... and unit tests
Why is this Pull Request needed?
Because it allows to quit Safari's streaming black-box and use MSE/EME to play content
Are there any points in the code the reviewer needs to double check?
- While this PR is in draft mode please don't take care of the files listed below, I had to add them to test it on my app, for unknown reasons
yarn link
doesn't work properly with hls.js- dist/*
- .gitignore
- package.json
- demo/index.html
- Widevine DRM decryption should still work as expected
Resolves issues:
Checklist
- [ ] changes have been done against master branch, and PR does not conflict
- [ ] new unit / functional tests have been added (whenever applicable)
- [ ] API or design changes are documented in API.md
Hi @valotvince,
Would you be able to resolve the conflicts in the PR? I know it's been a while. I'll be putting together a working branch for DRM work soon, and think these changes (minus the working files (dist/*)) provide a really nice and baseline for a future release with multi-DRM support.
Hi @robwalch Sure will do next week :)
👋 @robwalch The branch is rebased, still two things left to do but I'll wait for your input before going further