videojs / videojs-contrib-eme

Supports Encrypted Media Extensions for playback of encrypted content in Video.js
Other
200 stars 71 forks source link

KeySession error: code 6, systemCode 4294955460 #186

Closed type-a-developer closed 1 year ago

type-a-developer commented 1 year ago

I am receiving error KeySession error: code 6, systemCode 4294955460 when trying to view HLS playback from Sarfari 14.1.2 and later versions using the following libraries: Videojs 7.10.2 Videojs-contrib-eme 3.11.0

I'm using the two libraries in its simplest form from the example you have provided from your GitHub page: { keySystems: { 'com.apple.fps.1_0': { certificateUri: '<CERTIFICATE_URL>', licenseUri: '<LICENSE_URL>' } } } This same example has been working when I was able to use the then latest version of the videojs-contrib-eme @5.0.1. I've consulted my DRM provider and they informed that the FairPlay cert that is now being sent with the request isn't correct. Before using version 3.11.0 I sent the FairPlay cert as is from our server, no base64 encoding and was unaware of the need to return an arraybuffer for the cert request as pointed out in your GitHub documentation.

I'm using a PHP backend and wondering if I am able to still use the simple implementation of the library above and what format should the FairPlay cert be returned to the certficateUri request? If I'm unable to use the basic example can you please provide a better example of the three override function usage, getCertificate, getContentId, and getLicense?

This is an example of what is being received by my DRM for the FairPlay cert.

image001

type-a-developer commented 1 year ago

I was able to fix this issue by combining both implementation examples from the docs. I started with this:

keySystems: {
    'com.apple.fps.1_0': {
        certificateUri: 'CERT URL',
        licenseUri: 'DRM URL'
   }
}

This has worked in the past using 5.0.0 but broke once I had to starting using 3.11.0. Somewhere along the process this breaks and throws the KeySession error so what I did was only add the getContentId function to the keySystems object to see where it was failing, the hybrid:

keySystems: {
    'com.apple.fps.1_0': {
        certificateUri: 'CERT URL',
        licenseUri: 'DRM URL',
        getContentId: function(emeOptions, initData) {
            console.log(initData)
            console.log(new TextDecoder('utf-8').decode(initData))
            const contentData = new TextDecoder('utf-8').decode(initData)
            const contentId = contentData.split(';')
            console.log(contentId[1].replace(/([^a-z0-9-]+)/gi, ''))
            return contentId[1].replace(/([^a-z0-9-]+)/gi, '')
      }
  }
}

What I found out is that the initData (arrayBuffer) had invalid characters, \ufffd, in the contentId string. I decode the array and remove all characters not in my regex pattern, returning a sanitized string for the DRM license request. Our team has tested this pretty well and is currently working with 7.20.X videojs and 3.11.0 videojs-contrib-eme.