shaka-project / shaka-player

JavaScript player library / DASH & HLS client / MSE-EME player
Apache License 2.0
7.17k stars 1.34k forks source link

CBCS content does not work on WebOS6 since commit ec29f82592fdec9e189fc87a25704fabffb7d404 #7477

Open jakubvojacek opened 1 week ago

jakubvojacek commented 1 week ago

Have you read the FAQ and checked for duplicate open issues? yes

If the problem is related to FairPlay, have you read the tutorial? unrelated

What version of Shaka Player are you using? latest

Can you reproduce the issue with our latest release version? yes

Can you reproduce the issue with the latest code from main? yes

Are you using the demo app or your own custom app? own app

If custom app, can you reproduce the issue using our demo app? its a smarttv, cannot use demo app there

What browser and OS are you using? unrelated

For embedded devices (smart TVs, etc.), what model and firmware version are you using? WebOS6 which uses chrome 79

What are the manifest and license server URIs? Manifest: https://edge1.motv.eu/s1/vods/30/neni-houba-jako-houba-3852/66c72001de232-2635-mp4-cbcs.mpd License server: https://mw.motv.eu/widevine_proxy

What configuration are you using? What is the output of player.getNonDefaultConfiguration()?

{
  "drm": {
    "servers": {
      "com.widevine.alpha": "https://mw.motv.eu/widevine_proxy",
      "com.apple.fps": "https://mw.motv.eu/ksm",
      "com.apple.fps.1_0": "https://mw.motv.eu/ksm"
    },
    "advanced": {
      "com.widevine.alpha": {
        "distinctiveIdentifierRequired": false,
        "persistentStateRequired": false,
        "videoRobustness": "SW_SECURE_CRYPTO",
        "audioRobustness": "",
        "sessionType": "",
        "serverCertificateUri": "",
        "individualizationServer": ""
      },
      "com.apple.fps": {
        "distinctiveIdentifierRequired": false,
        "persistentStateRequired": false,
        "videoRobustness": "",
        "audioRobustness": "",
        "sessionType": "",
        "serverCertificateUri": "https://mw.motv.eu/static/FairPlay.der",
        "individualizationServer": ""
      }
    }
  },
  "manifest": {
    "availabilityWindowOverride": null
  },
  "streaming": {},
  "mediaSource": {
    "forceTransmux": true
  },
  "offline": {},
  "preferredAudioLanguage": "cs"
}

What did you do? I attempted to play Widevine-CBCS encrypted content on webos

What did you expect to happen? For the playback to work

What actually happened? It didn't work, on some versions it fails with 4032 and later on with 6001 shaka player error code

I was able to find the commit that broke the playback by testing and compiling shaka player commit by commit - it was https://github.com/shaka-project/shaka-player/commit/ec29f82592fdec9e189fc87a25704fabffb7d404

If I understand what the commit does, it is trying to detect cbcs encryption support and if not supported, it will remove the tracks. But webos6 does support CBCS and therefore it should play normally. Is there something we can change, configuration-wise in the player to make this work? Or is it an issue with webos and its declaration of supported drms? I tried setting up audioRobustness as well but that didn't help

Are you planning send a PR to fix it? I tried to study the commit in question but I am not sure I fully understand it

jakubvojacek commented 1 week ago

iI was looking again at the commit that broke it and perhaps it was not in shaka code but in the library that was updated, this commit seems like related to cbcs and encryption support https://github.com/shaka-project/eme-encryption-scheme-polyfill/pull/63

jakubvojacek commented 1 week ago

I think here https://github.com/shaka-project/eme-encryption-scheme-polyfill/pull/63/files#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346R619 there should also be something

|| isRecentWebOs()

and the method should return true if its webos and Chrome version in user agent is higher or equal to 68. Not sure how to test this in my environment tho, not that familiar with npm and javascript.

joeyparrish commented 1 week ago

You could send a PR to that project to fix it. You can test in Shaka by checking out source to the polyfill, modifying, building, then copying it over node_modules/... in Shaka.

jakubvojacek commented 4 days ago

@joeyparrish I tried your approach but for some reason, the build of shaka player is refusing to pick up my changed polyfill, instead it reinstalls it

I checked useragent of the TV I got in the office and it was Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36 WebAppManager

Based on the useragent, I believe the following diff is required but didn't manage to test it.

diff --git a/index.js b/index.js
index 6b0bc37..4b280ba 100644
--- a/index.js
+++ b/index.js
@@ -654,6 +654,7 @@ function checkSupportedScheme(scheme, supportedScheme) {

   if (scheme == 'cbcs' || scheme == 'cbcs-1-9') {
     if (EncryptionSchemePolyfills.isRecentFirefox ||
+        EncryptionSchemePolyfills.isRecentWebOs() ||
         EncryptionSchemePolyfills.isChromecast) {
       // Firefox >= 100 supports CBCS, but doesn't support queries yet.
       // Older Chromecast devices are assumed to support CBCS as well.
@@ -718,6 +719,24 @@ EncryptionSchemePolyfills.isChromecast =
 EncryptionSchemePolyfills.isRecentFirefox =
     parseInt(navigator.userAgent.split('Firefox/').pop(), 10) >= 100;

+/**
+ * @const {boolean}
+ */
+EncryptionSchemePolyfills.isRecentWebOs = (() => {
+    const userAgent = navigator.userAgent.toLowerCase();
+    const isWebOs = userAgent.includes('webos');
+
+    if (!isWebOs) return false;
+
+    const chromeVersionMatch = userAgent.match(/chrome\/(\d+)/);
+
+    if (!chromeVersionMatch) return false;
+
+    const chromeVersion = parseInt(chromeVersionMatch[1], 10);
+
+    return chromeVersion >= 79;
+})();
+
 // Support for CommonJS and AMD module formats.
 /** @suppress {undefinedVars} */
 (() => {

The way I am building shaka is python3.9 ./build/build.py --debug --force