Skip to content

Commit

Permalink
fix: EXT-X-KEY support playready keyformat (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey authored Jun 15, 2021
1 parent ccde054 commit 4e7c9eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,17 @@ export default class Parser extends Stream {
return;
}

if (entry.attributes.KEYFORMAT === 'com.microsoft.playready') {
this.manifest.contentProtection = this.manifest.contentProtection || {};

// TODO: add full support for this.
this.manifest.contentProtection['com.microsoft.playready'] = {
uri: entry.attributes.URI
};

return;
}

// check if the content is encrypted for Widevine
// Widevine/HLS spec: https://storage.googleapis.com/wvdocs/Widevine_DRM_HLS.pdf
if (entry.attributes.KEYFORMAT === widevineUuid) {
Expand Down
5 changes: 3 additions & 2 deletions test/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ QUnit.module('m3u8s', function(hooks) {
);
});

QUnit.test('Can understand widevine/safari drm ext-x-key', function(assert) {
QUnit.test('Can understand widevine/fairplay/playready drm ext-x-key', function(assert) {
this.parser.push([
'#EXT-X-VERSION:3',
'#EXT-X-MEDIA-SEQUENCE:0',
Expand All @@ -843,6 +843,7 @@ QUnit.module('m3u8s', function(hooks) {
'#EXT-X-SERVER-CONTROL:foo=bar',
'#EXT-X-KEY:METHOD=SAMPLE-AES,URI="data:text/plain;base64,foo",KEYID=0x555777,IV=1234567890abcdef1234567890abcdef,KEYFORMATVERSIONS="1",KEYFORMAT="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"',
'#EXT-X-KEY:METHOD=SAMPLE-AES,URI="skd://foo",KEYFORMATVERSIONS="1",KEYFORMAT="com.apple.streamingkeydelivery"',
'#EXT-X-KEY:METHOD=SAMPLE-AES,URI="http://example.com",KEYFORMATVERSIONS="1",KEYFORMAT="com.microsoft.playready"',
'#EXTINF:10,',
'media-00001.ts',
'#EXT-X-ENDLIST'
Expand All @@ -851,7 +852,7 @@ QUnit.module('m3u8s', function(hooks) {

assert.deepEqual(
Object.keys(this.parser.manifest.contentProtection),
['com.widevine.alpha', 'com.apple.fps.1_0'],
['com.widevine.alpha', 'com.apple.fps.1_0', 'com.microsoft.playready'],
'info as expected'
);
});
Expand Down

0 comments on commit 4e7c9eb

Please sign in to comment.