From 3138e1657f2299ed1328cc014ee65eb8d67b9541 Mon Sep 17 00:00:00 2001 From: Daniel Silhavy Date: Tue, 16 Apr 2024 13:04:01 +0200 Subject: [PATCH] Account for lower case laUrl in MPDs (#4460) --- src/dash/constants/DashConstants.js | 1 + src/dash/vo/ContentProtection.js | 3 +- .../test/dash/dash.vo.ContentProtection.js | 138 ++++++++++++++++++ 3 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 test/unit/test/dash/dash.vo.ContentProtection.js diff --git a/src/dash/constants/DashConstants.js b/src/dash/constants/DashConstants.js index f61aa343f0..d927d097a1 100644 --- a/src/dash/constants/DashConstants.js +++ b/src/dash/constants/DashConstants.js @@ -95,6 +95,7 @@ export default { INITIALIZATION: 'Initialization', INITIALIZATION_MINUS: 'initialization', LA_URL: 'Laurl', + LA_URL_LOWER_CASE: 'laurl', LABEL: 'Label', LANG: 'lang', LOCATION: 'Location', diff --git a/src/dash/vo/ContentProtection.js b/src/dash/vo/ContentProtection.js index bfaefc155f..f1c4f7e8a4 100644 --- a/src/dash/vo/ContentProtection.js +++ b/src/dash/vo/ContentProtection.js @@ -43,6 +43,7 @@ class ContentProtection extends DescriptorType { this.refId = null; this.robustness = null; this.keyId = null; + this.cencDefaultKid = null; this.pssh = null; this.pro = null; this.laUrl = null; @@ -58,7 +59,7 @@ class ContentProtection extends DescriptorType { this.cencDefaultKid = data.hasOwnProperty(DashConstants.CENC_DEFAULT_KID) ? data[DashConstants.CENC_DEFAULT_KID] : null; this.pssh = data.hasOwnProperty(DashConstants.PSSH) ? data[DashConstants.PSSH] : null; this.pro = data.hasOwnProperty(DashConstants.PRO) ? data[DashConstants.PRO] : null; - this.laUrl = data.hasOwnProperty(DashConstants.LA_URL) ? data[DashConstants.LA_URL] : null; + this.laUrl = data.hasOwnProperty(DashConstants.LA_URL) ? data[DashConstants.LA_URL] : data.hasOwnProperty(DashConstants.LA_URL_LOWER_CASE) ? data[DashConstants.LA_URL_LOWER_CASE] : null; } } diff --git a/test/unit/test/dash/dash.vo.ContentProtection.js b/test/unit/test/dash/dash.vo.ContentProtection.js new file mode 100644 index 0000000000..4a1f5cb49d --- /dev/null +++ b/test/unit/test/dash/dash.vo.ContentProtection.js @@ -0,0 +1,138 @@ +import {expect} from 'chai'; +import ContentProtection from '../../../../src/dash/vo/ContentProtection.js'; + +describe('Content Protection', () => { + + it('should be constructed with null values', () => { + const contentProtection = new ContentProtection(); + expect(contentProtection).to.deep.equal({ + schemeIdUri: null, + value: null, + id: null, + ref: null, + refId: null, + robustness: null, + keyId: null, + cencDefaultKid: null, + pssh: null, + pro: null, + laUrl: null, + }); + }); + + it('should initialise with correct base values', () => { + const contentProtection = new ContentProtection(); + contentProtection.init({ + schemeIdUri: 'testScheme', + value: '1', + }); + expect(contentProtection).to.deep.equal({ + schemeIdUri: 'testScheme', + value: '1', + id: null, + ref: null, + refId: null, + robustness: null, + keyId: null, + cencDefaultKid: null, + pssh: null, + pro: null, + laUrl: null + }); + }); + + it('should initialise with correct complete values', () => { + const contentProtection = new ContentProtection(); + contentProtection.init({ + schemeIdUri: 'testScheme', + value: '1', + ref: 'ref', + refId: 'refId', + robustness: 'robustness', + keyId: null, + 'cenc:default_KID': 'keyId', + pssh: 'pssh', + pro: 'pro', + Laurl: 'laUrl' + }); + expect(contentProtection).to.deep.equal({ + schemeIdUri: 'testScheme', + value: '1', + id: null, + ref: 'ref', + refId: 'refId', + robustness: 'robustness', + keyId: null, + cencDefaultKid: 'keyId', + pssh: 'pssh', + pro: 'pro', + laUrl: 'laUrl' + }); + }); + + it('should handle lowercase laurl', () => { + const contentProtection = new ContentProtection(); + contentProtection.init({ + schemeIdUri: 'testScheme', + value: '1', + ref: 'ref', + refId: 'refId', + robustness: 'robustness', + 'cenc:default_KID': 'keyId', + pssh: 'pssh', + pro: 'pro', + laurl: 'laUrl' + }); + expect(contentProtection).to.deep.equal({ + schemeIdUri: 'testScheme', + value: '1', + id: null, + ref: 'ref', + refId: 'refId', + robustness: 'robustness', + keyId: null, + cencDefaultKid: 'keyId', + pssh: 'pssh', + pro: 'pro', + laUrl: 'laUrl' + }); + }); + + it('merge attributes from reference', () => { + const contentProtection = new ContentProtection(); + contentProtection.init({ + schemeIdUri: 'testScheme', + ref: 'ref', + refId: 'refId', + pssh: 'pssh', + pro: 'pro', + laurl: 'laUrl' + }); + contentProtection.mergeAttributesFromReference({ + schemeIdUri: 'scheme-new', + value: 'value-new', + id: 'id-new', + robustness: 'robustness-new', + cencDefaultKid: 'keyId-new', + pssh: 'pssh-new', + pro: 'pro-new', + laUrl: 'laUrl-new', + ref: 'ref-new' + }) + console.log(contentProtection) + expect(contentProtection).to.deep.equal({ + schemeIdUri: 'testScheme', + value: 'value-new', + id: 'id-new', + robustness: 'robustness-new', + cencDefaultKid: 'keyId-new', + keyId: null, + pssh: 'pssh', + pro: 'pro', + laUrl: 'laUrl', + ref: 'ref', + refId: 'refId', + }); + }); + +});