videojs / videojs-contrib-eme

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

getLicense should pass the event object #67

Open tidemann opened 5 years ago

tidemann commented 5 years ago

I'm making a react app with videojs (7.2.3) with fairplay support using videojs-contrib-eme (3.4.1) and I have some problems with implementing the getLicense function properly

The function is triggered in contrib-eme like this (from fairplay.js):

keySession.addEventListener('webkitkeymessage', function (event) {
    getLicense(options, contentId, event.message,event.target, function (err, license) {...}
}

In order to make a valid request to the license server, I need the event.target (keySession) object (this contains the required sessionid) passed to the getLicense function

In Apple's sample implementation the webkitkeymessage event is handled like this:

waitForEvent('webkitkeymessage', licenseRequestReady, keySession);
function licenseRequestReady(event) 
{
    var session = event.target;
    var message = event.message;
    var request = new XMLHttpRequest();
    var sessionId = event.sessionId;
    request.responseType = 'text';
    request.session = session;
    request.addEventListener('load', licenseRequestLoaded, false);
    request.addEventListener('error', licenseRequestFailed, false);
    var params = 'spc='+base64EncodeUint8Array(message)+'&assetId='+encodeURIComponent(session.contentId);
    request.open('POST', serverProcessSPCPath, true);
    request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    request.send(params);
}

I guess the entire event object should be passed to getLicense and not just event.message?

slasktrat commented 5 years ago

+1

chakrikodali commented 5 years ago

+1

I need access to keySession object to add listener on webkitkeyerror event. I am not able to get handle of HDCP error fired from keySession when some tries to stream playback through HDMI port.

squarebracket commented 5 years ago

@chakrikodali do you have a source for being able to handle HDCP errors? As far as I know, no such event detection is possible in Safari.

chakrikodali commented 5 years ago

@squarebracket i don't have source to handle hdcp errors. But what i have seen is, an error thrown here(https://github.com/videojs/videojs-contrib-eme/blob/master/src/fairplay.js#L97) when i plugin hdmi. Which never gets bubbled up as the promise is already resolved when licensekey got added to keySession(https://github.com/videojs/videojs-contrib-eme/blob/master/src/fairplay.js#L90).

Error - KeySession error: code 6, systemCode 1212433232

chadacious commented 3 years ago

+1