mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-26 17:46:26 +03:00
7116a34ec2
## Background: The native DOM Parser can perform poorly on some older devices, this approach is faster on newer devices but is considerably better on older devices. This PR replaces the usage of the DOM Parser for DASH, MSS, VTT and TTML. The draw back of this approach that it does not include any validation at the cost of better performance.
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
/*! @license
|
|
* Shaka Player
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
// Test DRM-related parsing.
|
|
describe('MssParser ContentProtection', () => {
|
|
const ContentProtection = shaka.mss.ContentProtection;
|
|
|
|
const strToXml = (str) => {
|
|
return shaka.util.TXml.parseXmlString(str);
|
|
};
|
|
|
|
it('getPlayReadyLicenseURL', () => {
|
|
const laurl = [
|
|
'<WRMHEADER>',
|
|
' <DATA>',
|
|
' <LA_URL>www.example.com</LA_URL>',
|
|
' </DATA>',
|
|
'</WRMHEADER>',
|
|
].join('\n');
|
|
const laurlCodes = laurl.split('').map((c) => {
|
|
return c.charCodeAt();
|
|
});
|
|
const prBytes = new Uint16Array([
|
|
// pr object size (in num bytes).
|
|
// + 10 for PRO size, count, and type
|
|
laurl.length * 2 + 10, 0,
|
|
// record count
|
|
1,
|
|
// type
|
|
ContentProtection.PLAYREADY_RECORD_TYPES.RIGHTS_MANAGEMENT,
|
|
// record size (in num bytes)
|
|
laurl.length * 2,
|
|
// value
|
|
].concat(laurlCodes));
|
|
|
|
const encodedPrObject = shaka.util.Uint8ArrayUtils.toBase64(prBytes);
|
|
const input = strToXml([
|
|
'<ProtectionHeader SystemID="9a04f079-9840-4286-ab92-e65be0885f95">',
|
|
encodedPrObject,
|
|
'</ProtectionHeader>',
|
|
].join('\n'));
|
|
const actual = ContentProtection.getPlayReadyLicenseUrl(input);
|
|
expect(actual).toBe('www.example.com');
|
|
});
|
|
});
|