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

Prefer unprefixed EME for Safari #2999

Closed
avelad opened this issue Nov 19, 2020 · 6 comments · Fixed by #3021 or #3776
Closed

Prefer unprefixed EME for Safari #2999

avelad opened this issue Nov 19, 2020 · 6 comments · Fixed by #3021 or #3776
Assignees
Labels
component: EME The issue involves the Encrypted Media Extensions web API priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: enhancement New feature or request
Milestone

Comments

@avelad
Copy link
Collaborator

avelad commented Nov 19, 2020

I would like that as this is very old, the support for the newest api can be investigated.
https://github.com/google/shaka-player/blob/master/lib/polyfill/patchedmediakeys_apple.js#L36-L44

@TheModMaker
Copy link
Contributor

It looks like the latest Safari does support the modern requestMediaKeySystemAccess and does support cenc; so we may be able to use that now.

@TheModMaker TheModMaker added component: EME The issue involves the Encrypted Media Extensions web API type: enhancement New feature or request and removed needs triage labels Nov 19, 2020
@TheModMaker TheModMaker added this to the Backlog milestone Nov 19, 2020
@joeyparrish
Copy link
Member

joeyparrish commented Nov 23, 2020

@avelad, I found a commented out section at the top of lib/polyfill/patchedmediakeys_apple.js which is responsible.

I don't have immediate access to a Mac or an iOS device. If you can, would you please try the following patch and let us know if FairPlay is working correctly for you on desktop Safari and iOS? If so, we could easily enable this in our next release.

diff --git a/lib/polyfill/patchedmediakeys_apple.js b/lib/polyfill/patchedmediakeys_apple.js
index 98fd2e6d..885f1fc4 100644
--- a/lib/polyfill/patchedmediakeys_apple.js
+++ b/lib/polyfill/patchedmediakeys_apple.js
@@ -33,15 +33,12 @@ 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
-    /*
     if (navigator.requestMediaKeySystemAccess &&
+        // eslint-disable-next-line no-restricted-syntax
         MediaKeySystemAccess.prototype.getConfiguration) {
-      // Prefixed EME is preferable.
+      // Unprefixed EME is preferable.
       return;
     }
-    */
 
     shaka.log.info('Using Apple-prefixed EME');
 

@avelad
Copy link
Collaborator Author

avelad commented Nov 24, 2020

@joeyparrish I have tested and it works by making the following change:

diff --git a/lib/media/drm_engine.js b/lib/media/drm_engine.js
index 80219f08..c05d1b47 100644
--- a/lib/media/drm_engine.js
+++ b/lib/media/drm_engine.js
@@ -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',
@@ -1544,6 +1544,7 @@ shaka.media.DrmEngine = class {
     ];
 
     const basicConfig = {
+      initDataTypes: ['cenc'],
       videoCapabilities: basicVideoCapabilities,
     };
     const offlineConfig = {
diff --git a/lib/polyfill/patchedmediakeys_apple.js b/lib/polyfill/patchedmediakeys_apple.js
index 98fd2e6d..885f1fc4 100644
--- a/lib/polyfill/patchedmediakeys_apple.js
+++ b/lib/polyfill/patchedmediakeys_apple.js
@@ -33,15 +33,12 @@ 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
-    /*
     if (navigator.requestMediaKeySystemAccess &&
+        // eslint-disable-next-line no-restricted-syntax
         MediaKeySystemAccess.prototype.getConfiguration) {
-      // Prefixed EME is preferable.
+      // Unprefixed EME is preferable.
       return;
     }
-    */
 
     shaka.log.info('Using Apple-prefixed EME');
 

I have tested in Safari 14 on macOS 10.15.7 and on iOS 14.2

It is necessary to always pass the initDataTypes field in requestMediaKeySystemAccess or it does not work, but this raises questions for me because in HLS-TS we should use SNIF, but I have tried with CENC and it works ...

@avelad
Copy link
Collaborator Author

avelad commented Nov 24, 2020

Note: in safari 12 is not working but it works in safari 14. I don’t have access to safari 13.

joeyparrish pushed a commit that referenced this issue Jan 19, 2021
joeyparrish pushed a commit that referenced this issue Jan 25, 2021
@joeyparrish joeyparrish reopened this Jan 25, 2021
shaka-bot pushed a commit that referenced this issue Jan 25, 2021
@avelad reported that PR #3021 caused a regression.  Rather than
revert the entire thing, we are disabling one part of that change to
make it easier to re-enable once the issue is fixed.  We will also
reopen issue #2999 until this is resolved.

Change-Id: I65d93da903d90668bb19e5248658eb458e8bb5c4
joeyparrish added a commit that referenced this issue Jan 25, 2021
@avelad reported that PR #3021 caused a regression.  Rather than
revert the entire thing, we are disabling one part of that change to
make it easier to re-enable once the issue is fixed.  We will also
reopen issue #2999 until this is resolved.

Change-Id: I65d93da903d90668bb19e5248658eb458e8bb5c4
This was referenced Apr 19, 2021
@joeyparrish joeyparrish added the priority: P2 Smaller impact or easy workaround label Oct 4, 2021
@avelad
Copy link
Collaborator Author

avelad commented Feb 7, 2022

@joeyparrish Resolved with 6d76a13

@joeyparrish
Copy link
Member

Good catch. Closing thanks to #2999.

@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Apr 8, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2022
@avelad avelad modified the milestones: Backlog, v4.0 May 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: EME The issue involves the Encrypted Media Extensions web API priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: enhancement New feature or request
Projects
None yet
4 participants