Skip to content

Commit

Permalink
Merge pull request #2474 from Orange-OpenSource/addMEDIA_KEYERR_EXPIRED
Browse files Browse the repository at this point in the history
Management of DRM license with an expiration value
  • Loading branch information
epiclabsDASH committed Mar 19, 2018
2 parents ad3a3de + da2cbb7 commit ceeb494
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
13 changes: 13 additions & 0 deletions samples/dash-if-reference-player/app/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,19 @@
{
"name": "Axinom Test Content (modern)",
"submenu": [
{
"name": "1080p with Widevine DRM, license expired after 60s",
"url": "https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p.mpd",
"protData": {
"com.widevine.alpha": {
"serverURL": "https://drm-widevine-licensing.axtest.net/AcquireLicense",
"httpRequestHeaders": {
"X-AxDRM-Message": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2V5X2lkIjoiYjMzNjRlYjUtNTFmNi00YWUzLThjOTgtMzNjZWQ1ZTMxYzc4IiwibWVzc2FnZSI6eyJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsImZpcnN0X3BsYXlfZXhwaXJhdGlvbiI6NjAsInBsYXlyZWFkeSI6eyJyZWFsX3RpbWVfZXhwaXJhdGlvbiI6dHJ1ZX0sImtleXMiOlt7ImlkIjoiOWViNDA1MGQtZTQ0Yi00ODAyLTkzMmUtMjdkNzUwODNlMjY2IiwiZW5jcnlwdGVkX2tleSI6ImxLM09qSExZVzI0Y3Iya3RSNzRmbnc9PSJ9XX19.FAbIiPxX8BHi9RwfzD7Yn-wugU19ghrkBFKsaCPrZmU"
}
}
},
"moreInfo": "https://github.com/Axinom/dash-test-vectors"
},
{
"name": "1080p with PlayReady and Widevine DRM, single key",
"url": "https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p.mpd",
Expand Down
2 changes: 2 additions & 0 deletions src/streaming/Stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function Stream(config) {
eventBus.on(Events.LICENSE_REQUEST_COMPLETE, onProtectionError, instance);
eventBus.on(Events.KEY_SYSTEM_SELECTED, onProtectionError, instance);
eventBus.on(Events.KEY_SESSION_CREATED, onProtectionError, instance);
eventBus.on(Events.KEY_STATUSES_CHANGED, onProtectionError, instance);
}
}

Expand Down Expand Up @@ -181,6 +182,7 @@ function Stream(config) {
eventBus.off(Events.LICENSE_REQUEST_COMPLETE, onProtectionError, instance);
eventBus.off(Events.KEY_SYSTEM_SELECTED, onProtectionError, instance);
eventBus.off(Events.KEY_SESSION_CREATED, onProtectionError, instance);
eventBus.off(Events.KEY_STATUSES_CHANGED, onProtectionError, instance);
}

function getDuration() {
Expand Down
7 changes: 6 additions & 1 deletion src/streaming/protection/ProtectionEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ class ProtectionEvents extends EventsBase {
*/
this.INTERNAL_KEY_SYSTEM_SELECTED = 'internalKeySystemSelected';

/**
* Event ID for events delivered when the status of one decryption keys has changed
* @ignore
*/
this.INTERNAL_KEY_STATUS_CHANGED = 'internalkeyStatusChanged';

/**
* Event ID for events delivered when a new key has been added
*
Expand Down Expand Up @@ -102,7 +108,6 @@ class ProtectionEvents extends EventsBase {
*/
this.KEY_SESSION_REMOVED = 'public_keySessionRemoved';


/**
* Event ID for events delivered when the status of one or more
* decryption keys has changed
Expand Down
10 changes: 10 additions & 0 deletions src/streaming/protection/controllers/ProtectionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function ProtectionController(config) {
// Once Keysystem is selected and before creating the session, we will do that check
// so we create the strictly necessary DRM sessions
eventBus.on(events.INTERNAL_KEY_MESSAGE, onKeyMessage, this);
eventBus.on(events.INTERNAL_KEY_STATUS_CHANGED, onKeyStatusChanged, this);

mediaInfoArr.push(mediaInfo);

Expand Down Expand Up @@ -286,6 +287,7 @@ function ProtectionController(config) {
function reset() {

eventBus.off(events.INTERNAL_KEY_MESSAGE, onKeyMessage, this);
eventBus.off(events.INTERNAL_KEY_STATUS_CHANGED, onKeyStatusChanged, this);

setMediaElement(null);

Expand Down Expand Up @@ -436,6 +438,14 @@ function ProtectionController(config) {
eventBus.trigger(events.LICENSE_REQUEST_COMPLETE, {data: data, error: error});
}

function onKeyStatusChanged(e) {
if (e.error) {
eventBus.trigger(events.KEY_STATUSES_CHANGED, {data: null, error: 'DRM: KeyStatusChange error! -- ' + e.error});
} else {
log('DRM: key status = ' + e.status);
}
}

function onKeyMessage(e) {
log('DRM: onKeyMessage');
if (e.error) {
Expand Down
29 changes: 29 additions & 0 deletions src/streaming/protection/models/ProtectionModel_21Jan2015.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,35 @@ function ProtectionModel_21Jan2015(config) {
switch (event.type) {
case 'keystatuseschange':
eventBus.trigger(events.KEY_STATUSES_CHANGED, {data: this});
event.target.keyStatuses.forEach(function () {
// Edge and Chrome implement different version of keystatues, param are not on same order
let status, keyId;
if (arguments && arguments.length > 0) {
if (arguments[0]) {
if (typeof arguments[0] === 'string') {
status = arguments[0];
} else {
keyId = arguments[0];
}
}

if (arguments[1]) {
if (typeof arguments[1] === 'string') {
status = arguments[1];
} else {
keyId = arguments[1];
}
}
}
switch (status) {
case 'expired':
eventBus.trigger(events.INTERNAL_KEY_STATUS_CHANGED, {error: 'License has expired'});
break;
default:
eventBus.trigger(events.INTERNAL_KEY_STATUS_CHANGED, {status: status, keyId: keyId});
break;
}
});
break;

case 'message':
Expand Down

0 comments on commit ceeb494

Please sign in to comment.