Skip to content

Commit

Permalink
fix: exclude playlists on DRM key status of output-restricted (#1171)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Jul 28, 2021
1 parent 5f60612 commit de5baa7
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 0 deletions.
44 changes: 44 additions & 0 deletions scripts/sources.json
Expand Up @@ -393,5 +393,49 @@
"uri": "https://d2zihajmogu5jn.cloudfront.net/first-pmt-only/index.m3u8",
"mimetype": "application/x-mpegurl",
"features": []
},
{
"name": "HDCP v1.0 DRM dash",
"uri": "https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd#1",
"mimetype": "application/dash+xml",
"features": [],
"keySystems": {
"com.widevine.alpha": {
"url": "https://proxy.uat.widevine.com/proxy?video_id=GTS_SW_SECURE_CRYPTO_HDCP_V1&provider=widevine_test"
}
}
},
{
"name": "HDCP v2.0 DRM dash",
"uri": "https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd#2",
"mimetype": "application/dash+xml",
"features": [],
"keySystems": {
"com.widevine.alpha": {
"url": "https://proxy.uat.widevine.com/proxy?video_id=GTS_SW_SECURE_CRYPTO_HDCP_V2&provider=widevine_test"
}
}
},
{
"name": "HDCP v2.1 DRM dash",
"uri": "https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd@21",
"mimetype": "application/dash+xml",
"features": [],
"keySystems": {
"com.widevine.alpha": {
"url": "https://proxy.uat.widevine.com/proxy?video_id=GTS_SW_SECURE_CRYPTO_HDCP_V2_1&provider=widevine_test"
}
}
},
{
"name": "HDCP v2.2 DRM dash",
"uri": "https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd#22",
"mimetype": "application/dash+xml",
"features": [],
"keySystems": {
"com.widevine.alpha": {
"url": "https://proxy.uat.widevine.com/proxy?video_id=GTS_SW_SECURE_CRYPTO_HDCP_V2_2&provider=widevine_test"
}
}
}
]
10 changes: 10 additions & 0 deletions src/videojs-http-streaming.js
Expand Up @@ -1001,6 +1001,16 @@ class VhsHandler extends Component {
audioMedia: audioPlaylistLoader && audioPlaylistLoader.media()
});

this.player_.tech_.on('keystatuschange', (e) => {
if (e.status === 'output-restricted') {
this.masterPlaylistController_.blacklistCurrentPlaylist({
playlist: this.masterPlaylistController_.media(),
message: `DRM keystatus changed to ${e.status}. Playlist will fail to play. Check for HDCP content.`,
blacklistDuration: Infinity
});
}
});

// In IE11 this is too early to initialize media keys, and IE11 does not support
// promises.
if (videojs.browser.IE_VERSION === 11 || !didSetupEmeOptions) {
Expand Down
96 changes: 96 additions & 0 deletions test/videojs-http-streaming.test.js
Expand Up @@ -4503,6 +4503,102 @@ QUnit.test('configures eme for HLS on source buffer creation', function(assert)
}, 'set source eme options');
});

QUnit.test('eme handles keystatuschange where status is output-restricted', function(assert) {
this.player.eme = {
options: {
previousSetting: 1
}
};
this.player.src({
src: 'manifest/master.m3u8',
type: 'application/x-mpegURL',
keySystems: {
keySystem1: {
url: 'url1'
}
}
});

this.clock.tick(1);

const media = {
attributes: {
CODECS: 'avc1.420015, mp4a.40.2c'
},
contentProtection: {
keySystem1: {
pssh: 'test'
}
}
};

this.player.tech_.vhs.playlists = {
master: { playlists: [media] },
media: () => media
};

const excludes = [];

this.player.tech_.vhs.masterPlaylistController_.blacklistCurrentPlaylist = (exclude) => {
excludes.push(exclude);
};

this.player.tech_.vhs.masterPlaylistController_.sourceUpdater_.trigger('createdsourcebuffers');
this.player.tech_.trigger({type: 'keystatuschange', status: 'output-restricted'});

assert.deepEqual(excludes, [{
blacklistDuration: Infinity,
message: 'DRM keystatus changed to output-restricted. Playlist will fail to play. Check for HDCP content.',
playlist: undefined
}], 'excluded playlist');
});

QUnit.test('eme handles keystatuschange where status is usable', function(assert) {
this.player.eme = {
options: {
previousSetting: 1
}
};
this.player.src({
src: 'manifest/master.m3u8',
type: 'application/x-mpegURL',
keySystems: {
keySystem1: {
url: 'url1'
}
}
});

this.clock.tick(1);

const media = {
attributes: {
CODECS: 'avc1.420015, mp4a.40.2c'
},
contentProtection: {
keySystem1: {
pssh: 'test'
}
}
};

this.player.tech_.vhs.playlists = {
master: { playlists: [media] },
media: () => media
};

const excludes = [];

this.player.tech_.vhs.masterPlaylistController_.blacklistCurrentPlaylist = (exclude) => {
excludes.push(exclude);
};

this.player.tech_.vhs.masterPlaylistController_.sourceUpdater_.trigger('createdsourcebuffers');
this.player.tech_.trigger({type: 'keystatuschange', status: 'usable'});

assert.deepEqual(excludes, [], 'did not exclude anything');
});

QUnit.test('integration: configures eme for DASH on source buffer creation', function(assert) {
assert.timeout(3000);
const done = assert.async();
Expand Down

0 comments on commit de5baa7

Please sign in to comment.