From e824a0803ffd4e6fba3b310a491c0ffc2b56536c Mon Sep 17 00:00:00 2001 From: wseymour15 Date: Wed, 16 Aug 2023 16:06:55 -0500 Subject: [PATCH] fix: use manifest uri in base urls --- src/inheritAttributes.js | 2 +- test/inheritAttributes.test.js | 76 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/src/inheritAttributes.js b/src/inheritAttributes.js index 5b82293..84ec1df 100644 --- a/src/inheritAttributes.js +++ b/src/inheritAttributes.js @@ -574,7 +574,7 @@ export const inheritAttributes = (mpd, options = {}) => { const locations = findChildren(mpd, 'Location'); const mpdAttributes = parseAttributes(mpd); - const mpdBaseUrls = buildBaseUrls([ manifestUri ], findChildren(mpd, 'BaseURL')); + const mpdBaseUrls = buildBaseUrls([{ baseUrl: manifestUri }], findChildren(mpd, 'BaseURL')); const contentSteeringNodes = findChildren(mpd, 'ContentSteering'); // See DASH spec section 5.3.1.2, Semantics of MPD element. Default type to 'static'. diff --git a/test/inheritAttributes.test.js b/test/inheritAttributes.test.js index 8b9f514..a489ef7 100644 --- a/test/inheritAttributes.test.js +++ b/test/inheritAttributes.test.js @@ -631,6 +631,82 @@ QUnit.test('end to end - basic', function(assert) { assert.deepEqual(actual, expected); }); +QUnit.test('end to end - basic using manifest uri', function(assert) { + const NOW = Date.now(); + + const actual = inheritAttributes(stringToMpdXml(` + + base/ + + + + + + + + + + en.vtt + + + + + `), { NOW, manifestUri: 'https://www.test.com' }); + + const expected = { + contentSteeringInfo: null, + eventStream: [], + locations: undefined, + representationInfo: [{ + attributes: { + bandwidth: 5000000, + baseUrl: 'https://www.test.com/base/', + codecs: 'avc1.64001e', + height: 404, + id: 'test', + mediaPresentationDuration: 30, + mimeType: 'video/mp4', + periodStart: 0, + role: { + value: 'main' + }, + sourceDuration: 30, + type: 'static', + width: 720, + NOW, + clientOffset: 0 + }, + segmentInfo: { + template: {} + } + }, { + attributes: { + bandwidth: 256, + baseUrl: 'https://www.test.com/base/en.vtt', + id: 'en', + lang: 'en', + mediaPresentationDuration: 30, + mimeType: 'text/vtt', + periodStart: 0, + role: {}, + sourceDuration: 30, + type: 'static', + NOW, + clientOffset: 0 + }, + segmentInfo: {} + }] + }; + + assert.equal(actual.representationInfo.length, 2); + assert.deepEqual(actual, expected); +}); + QUnit.test('end to end - basic dynamic', function(assert) { const NOW = Date.now();