Subido por jorgefix

dashJS understanding

Anuncio
HOW TO PLAY ENCRYPTED CONTENT
1.Initialize the dash.js player
var mediaPlayer = dashjs.MediaPlayer().create();
2.Set protection data using protectionController
var protectionController =
mediaPlayer.getProtectionController();
protectionController.setProtectionData({
'com.widevine.alpha': config
});
Where config isvar config = {
// From manifest
KID: '6e5a1d26-2757-47d7-8046-eaa5d1d34b5a',
audioPssh:
'AAAANHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABQIARIQblodJidXR9eARuq
l0dNLWg==',
videoPssh:
'AAAANHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABQIARIQblodJidXR9eARuq
l0dNLWg==',
// From protData['com.widevine.alpha']
serverURL: 'https://drm-widevine-licensing.axtest.net/
AcquireLicense',
httpRequestHeaders: {
"X-AxDRM-Message":
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2
V5X2lkIjoiNjllNTQwODgtZTllMC00NTMwLThjMWEtMWViNmRjZDBkMTRlIiwibW
Vzc2FnZSI6eyJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsImtleXMiOlt7Im
lkIjoiNmU1YTFkMjYtMjc1Ny00N2Q3LTgwNDYtZWFhNWQxZDM0YjVhIn1dfX0.yF
7PflOPv9qHnu3ZWJNZ12jgkqTabmwXbDWk_47tLNE"
},
audioRobustness: "SW_SECURE_CRYPTO",
videoRobustness: "SW_SECURE_DECODE"
}
PROPERTY
USE
SOURCE
From the
DRM service App
endpoint
consuming
the player
Data needed From the
by the DRM App
service
consuming
endpoint
the player
We write
code to
extract it out
of the
manifest
We write
code to
extract it out
of the
manifest
We write
code to
extract it out
of the
manifest
Consuming
App has to
pass this to
player
Consuming
App has to
pass this to
player
?
?
?
?
?
?
?
?
KID
?
From the
manifest
audioPssh
?
From the
manifest
videoPssh
?
From the
manifest
serverURL
httpRequest
Headers
audioRobust
ness
videoRobust
ness
OWNERSHI
P
MANDATOR
Y(dash.js
needs it to
play the
encrypted
stream)
Yes
Yes
Yes
Yes
Yes
3.Then use initializeForMedia to let dash.js manage playing the encrypted
stream
protectionController.initializeForMedia(videoInfo);
Where videoInfo isvar videoInfo = {
codec: 'video/mp4;codecs="avc1.640015"',
type: 'video',
contentProtection: [{
value: 'Widevine',
schemeIdUri: "urn:uuid:edef8ba9-79d6-4acea3c8-27dcd51d21ed",
pssh: {
__prefix: 'cenc',
__text: config.videoPssh
},
'cenc:default_KID': config.KID
}]
};
codec - where do we get this?
contentProtection : [
{
value: is “Widevine” (with the casing) the only value it will
recognize for Widevine. Also what is the exact value for other DRMs,
schemeIdUri: where do we get this?
pssh: {
__prefix: “cenc” is is always “cenc” for has different value
for different scenarios,
__text: assume it will be always config.videoPssh
},
‘cenc:default_KID’: is this property mandatory always in all
cases?
}
]
4.Then play the media in one of the desired mediaPlayer events
mediaPlayer.initialize(document.querySelector('#vid'),
mssManifestUrl, true);
Why do we exactly close session
In
// Listen for 'keystatuseschange' event to check if license has
been successfully received and stored
mediaPlayer.on(dashjs.MediaPlayer.events.KEY_STATUSES_CHANGED,
function (e) {
console.log('[DASHJS-PROTECTION-PLUGIN]
KEY_STATUSES_CHANGED: ', e);
e.data.session.keyStatuses.forEach(function(status, keyId) {
console.log("[DASHJS-PROTECTION-PLUGIN]
status = " + status + " for session " +
sessionToken.session.sessionId);
switch (status) {
case "expired":
break;
case "output-restricted":
break;
case "usable":
// console.log('[DASHJS-PROTECTIONPLUGIN] SESSION: ', sessionToken.session);
// Now, since license has been
received, close the MediaKeySession to release its resources
protectionController.closeKeySession(sessionToken);
break;
default:
}
});
});
Descargar