From 967e5e6dd5ffdaa78033b7da1222a64563fed625 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Wed, 12 Aug 2020 16:44:19 -0400 Subject: [PATCH] feat: parse out Location elements (#102) --- src/index.js | 8 +- src/inheritAttributes.js | 11 +- src/toM3u8.js | 6 +- test/index.test.js | 16 + test/inheritAttributes.test.js | 772 +++++++++++++++++---------------- test/manifests/location.js | 53 +++ test/manifests/location.mpd | 17 + test/manifests/locations.js | 54 +++ test/manifests/locations.mpd | 18 + test/toM3u8.test.js | 2 +- 10 files changed, 575 insertions(+), 382 deletions(-) create mode 100644 test/manifests/location.js create mode 100644 test/manifests/location.mpd create mode 100644 test/manifests/locations.js create mode 100644 test/manifests/locations.mpd diff --git a/src/index.js b/src/index.js index 9a6fa961..da88f00e 100644 --- a/src/index.js +++ b/src/index.js @@ -7,8 +7,12 @@ import { parseUTCTimingScheme } from './parseUTCTimingScheme'; const VERSION = version; -const parse = (manifestString, options = {}) => - toM3u8(toPlaylists(inheritAttributes(stringToMpdXml(manifestString), options)), options.sidxMapping); +const parse = (manifestString, options = {}) => { + const parsedManifestInfo = inheritAttributes(stringToMpdXml(manifestString), options); + const playlists = toPlaylists(parsedManifestInfo.representationInfo); + + return toM3u8(playlists, parsedManifestInfo.locations, options.sidxMapping); +}; /** * Parses the manifest for a UTCTiming node, returning the nodes attributes if found diff --git a/src/inheritAttributes.js b/src/inheritAttributes.js index 661ffdb5..dd033640 100644 --- a/src/inheritAttributes.js +++ b/src/inheritAttributes.js @@ -315,6 +315,8 @@ export const inheritAttributes = (mpd, options = {}) => { throw new Error(errors.INVALID_NUMBER_OF_PERIOD); } + const locations = findChildren(mpd, 'Location'); + const mpdAttributes = parseAttributes(mpd); const mpdBaseUrls = buildBaseUrls([ manifestUri ], findChildren(mpd, 'BaseURL')); @@ -322,5 +324,12 @@ export const inheritAttributes = (mpd, options = {}) => { mpdAttributes.NOW = NOW; mpdAttributes.clientOffset = clientOffset; - return flatten(periods.map(toAdaptationSets(mpdAttributes, mpdBaseUrls))); + if (locations.length) { + mpdAttributes.locations = locations.map(getContent); + } + + return { + locations: mpdAttributes.locations, + representationInfo: flatten(periods.map(toAdaptationSets(mpdAttributes, mpdBaseUrls))) + }; }; diff --git a/src/toM3u8.js b/src/toM3u8.js index a5aeacc8..766b94e2 100644 --- a/src/toM3u8.js +++ b/src/toM3u8.js @@ -231,7 +231,7 @@ export const formatVideoPlaylist = ({ attributes, segments, sidx }) => { return playlist; }; -export const toM3u8 = (dashPlaylists, sidxMapping = {}) => { +export const toM3u8 = (dashPlaylists, locations, sidxMapping = {}) => { if (!dashPlaylists.length) { return {}; } @@ -272,6 +272,10 @@ export const toM3u8 = (dashPlaylists, sidxMapping = {}) => { minimumUpdatePeriod: minimumUpdatePeriod * 1000 }; + if (locations) { + master.locations = locations; + } + if (type === 'dynamic') { master.suggestedPresentationDelay = suggestedPresentationDelay; } diff --git a/test/index.test.js b/test/index.test.js index 8f03eb0e..58598815 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -5,6 +5,8 @@ import QUnit from 'qunit'; import maatVttSegmentTemplate from './manifests/maat_vtt_segmentTemplate.mpd'; import segmentBaseTemplate from './manifests/segmentBase.mpd'; import segmentListTemplate from './manifests/segmentList.mpd'; +import locationTemplate from './manifests/location.mpd'; +import locationsTemplate from './manifests/locations.mpd'; import multiperiod from './manifests/multiperiod.mpd'; import multiperiodDynamic from './manifests/multiperiod-dynamic.mpd'; import { @@ -22,6 +24,12 @@ import { import { parsedManifest as multiperiodDynamicManifest } from './manifests/multiperiod-dynamic.js'; +import { + parsedManifest as locationManifest +} from './manifests/location.js'; +import { + parsedManifest as locationsManifest +} from './manifests/locations.js'; QUnit.module('mpd-parser'); @@ -53,6 +61,14 @@ QUnit.test('has parse', function(assert) { name: 'multiperiod_dynamic', input: multiperiodDynamic, expected: multiperiodDynamicManifest +}, { + name: 'location', + input: locationTemplate, + expected: locationManifest +}, { + name: 'locations', + input: locationsTemplate, + expected: locationsManifest }].forEach(({ name, input, expected }) => { QUnit.test(`${name} test manifest`, function(assert) { const actual = parse(input); diff --git a/test/inheritAttributes.test.js b/test/inheritAttributes.test.js index 30d7d530..9668471e 100644 --- a/test/inheritAttributes.test.js +++ b/test/inheritAttributes.test.js @@ -210,45 +210,48 @@ QUnit.test('end to end - basic', function(assert) { `), { NOW }); - const expected = [{ - attributes: { - bandwidth: 5000000, - baseUrl: 'https://www.example.com/base/', - codecs: 'avc1.64001e', - height: 404, - id: 'test', - mediaPresentationDuration: 30, - mimeType: 'video/mp4', - periodIndex: 0, - role: { - value: 'main' + const expected = { + locations: undefined, + representationInfo: [{ + attributes: { + bandwidth: 5000000, + baseUrl: 'https://www.example.com/base/', + codecs: 'avc1.64001e', + height: 404, + id: 'test', + mediaPresentationDuration: 30, + mimeType: 'video/mp4', + periodIndex: 0, + role: { + value: 'main' + }, + sourceDuration: 30, + width: 720, + NOW, + clientOffset: 0 }, - sourceDuration: 30, - width: 720, - NOW, - clientOffset: 0 - }, - segmentInfo: { - template: {} - } - }, { - attributes: { - bandwidth: 256, - baseUrl: 'https://example.com/en.vtt', - id: 'en', - lang: 'en', - mediaPresentationDuration: 30, - mimeType: 'text/vtt', - periodIndex: 0, - role: {}, - sourceDuration: 30, - NOW, - clientOffset: 0 - }, - segmentInfo: {} - }]; + segmentInfo: { + template: {} + } + }, { + attributes: { + bandwidth: 256, + baseUrl: 'https://example.com/en.vtt', + id: 'en', + lang: 'en', + mediaPresentationDuration: 30, + mimeType: 'text/vtt', + periodIndex: 0, + role: {}, + sourceDuration: 30, + NOW, + clientOffset: 0 + }, + segmentInfo: {} + }] + }; - assert.equal(actual.length, 2); + assert.equal(actual.representationInfo.length, 2); assert.deepEqual(actual, expected); }); @@ -282,45 +285,48 @@ QUnit.test('end to end - inherits BaseURL from all levels', function(assert) { `), { NOW }); - const expected = [{ - attributes: { - bandwidth: 5000000, - baseUrl: 'https://www.example.com/base/foo/bar/buzz/', - codecs: 'avc1.64001e', - height: 404, - id: 'test', - mediaPresentationDuration: 30, - mimeType: 'video/mp4', - periodIndex: 0, - role: { - value: 'main' + const expected = { + locations: undefined, + representationInfo: [{ + attributes: { + bandwidth: 5000000, + baseUrl: 'https://www.example.com/base/foo/bar/buzz/', + clientOffset: 0, + codecs: 'avc1.64001e', + height: 404, + id: 'test', + mediaPresentationDuration: 30, + mimeType: 'video/mp4', + periodIndex: 0, + role: { + value: 'main' + }, + sourceDuration: 30, + width: 720, + NOW }, - sourceDuration: 30, - width: 720, - NOW, - clientOffset: 0 - }, - segmentInfo: { - template: {} - } - }, { - attributes: { - bandwidth: 256, - baseUrl: 'https://example.com/en.vtt', - id: 'en', - lang: 'en', - mediaPresentationDuration: 30, - mimeType: 'text/vtt', - periodIndex: 0, - role: {}, - sourceDuration: 30, - NOW, - clientOffset: 0 - }, - segmentInfo: { } - }]; + segmentInfo: { + template: {} + } + }, { + attributes: { + bandwidth: 256, + baseUrl: 'https://example.com/en.vtt', + id: 'en', + lang: 'en', + mediaPresentationDuration: 30, + mimeType: 'text/vtt', + periodIndex: 0, + role: {}, + sourceDuration: 30, + NOW, + clientOffset: 0 + }, + segmentInfo: { } + }] + }; - assert.equal(actual.length, 2); + assert.equal(actual.representationInfo.length, 2); assert.deepEqual(actual, expected); }); @@ -353,123 +359,126 @@ QUnit.test('end to end - alternate BaseURLs', function(assert) { `), { NOW }); - const expected = [{ - attributes: { - bandwidth: 5000000, - baseUrl: 'https://www.example.com/base/segments/', - codecs: 'avc1.64001e', - height: 404, - id: 'test', - mediaPresentationDuration: 30, - mimeType: 'video/mp4', - periodIndex: 0, - role: { - value: 'main' + const expected = { + locations: undefined, + representationInfo: [{ + attributes: { + bandwidth: 5000000, + baseUrl: 'https://www.example.com/base/segments/', + codecs: 'avc1.64001e', + height: 404, + id: 'test', + mediaPresentationDuration: 30, + mimeType: 'video/mp4', + periodIndex: 0, + role: { + value: 'main' + }, + sourceDuration: 30, + width: 720, + NOW, + clientOffset: 0 }, - sourceDuration: 30, - width: 720, - NOW, - clientOffset: 0 - }, - segmentInfo: { - template: {} - } - }, { - attributes: { - bandwidth: 5000000, - baseUrl: 'https://www.example.com/base/media/', - codecs: 'avc1.64001e', - height: 404, - id: 'test', - mediaPresentationDuration: 30, - mimeType: 'video/mp4', - periodIndex: 0, - role: { - value: 'main' + segmentInfo: { + template: {} + } + }, { + attributes: { + bandwidth: 5000000, + baseUrl: 'https://www.example.com/base/media/', + codecs: 'avc1.64001e', + height: 404, + id: 'test', + mediaPresentationDuration: 30, + mimeType: 'video/mp4', + periodIndex: 0, + role: { + value: 'main' + }, + sourceDuration: 30, + width: 720, + NOW, + clientOffset: 0 }, - sourceDuration: 30, - width: 720, - NOW, - clientOffset: 0 - }, - segmentInfo: { - template: {} - } - }, { - attributes: { - bandwidth: 5000000, - baseUrl: 'https://www.test.com/base/segments/', - codecs: 'avc1.64001e', - height: 404, - id: 'test', - mediaPresentationDuration: 30, - mimeType: 'video/mp4', - periodIndex: 0, - role: { - value: 'main' + segmentInfo: { + template: {} + } + }, { + attributes: { + bandwidth: 5000000, + baseUrl: 'https://www.test.com/base/segments/', + codecs: 'avc1.64001e', + height: 404, + id: 'test', + mediaPresentationDuration: 30, + mimeType: 'video/mp4', + periodIndex: 0, + role: { + value: 'main' + }, + sourceDuration: 30, + width: 720, + NOW, + clientOffset: 0 }, - sourceDuration: 30, - width: 720, - NOW, - clientOffset: 0 - }, - segmentInfo: { - template: {} - } - }, { - attributes: { - bandwidth: 5000000, - baseUrl: 'https://www.test.com/base/media/', - codecs: 'avc1.64001e', - height: 404, - id: 'test', - mediaPresentationDuration: 30, - mimeType: 'video/mp4', - periodIndex: 0, - role: { - value: 'main' + segmentInfo: { + template: {} + } + }, { + attributes: { + bandwidth: 5000000, + baseUrl: 'https://www.test.com/base/media/', + codecs: 'avc1.64001e', + height: 404, + id: 'test', + mediaPresentationDuration: 30, + mimeType: 'video/mp4', + periodIndex: 0, + role: { + value: 'main' + }, + sourceDuration: 30, + width: 720, + NOW, + clientOffset: 0 }, - sourceDuration: 30, - width: 720, - NOW, - clientOffset: 0 - }, - segmentInfo: { - template: {} - } - }, { - attributes: { - bandwidth: 256, - baseUrl: 'https://example.com/en.vtt', - id: 'en', - lang: 'en', - mediaPresentationDuration: 30, - mimeType: 'text/vtt', - periodIndex: 0, - role: {}, - sourceDuration: 30, - NOW, - clientOffset: 0 - }, - segmentInfo: {} - }, { - attributes: { - bandwidth: 256, - baseUrl: 'https://example.com/en.vtt', - id: 'en', - lang: 'en', - mediaPresentationDuration: 30, - mimeType: 'text/vtt', - periodIndex: 0, - role: {}, - sourceDuration: 30, - NOW, - clientOffset: 0 - }, - segmentInfo: {} - }]; + segmentInfo: { + template: {} + } + }, { + attributes: { + bandwidth: 256, + baseUrl: 'https://example.com/en.vtt', + id: 'en', + lang: 'en', + mediaPresentationDuration: 30, + mimeType: 'text/vtt', + periodIndex: 0, + role: {}, + sourceDuration: 30, + NOW, + clientOffset: 0 + }, + segmentInfo: {} + }, { + attributes: { + bandwidth: 256, + baseUrl: 'https://example.com/en.vtt', + id: 'en', + lang: 'en', + mediaPresentationDuration: 30, + mimeType: 'text/vtt', + periodIndex: 0, + role: {}, + sourceDuration: 30, + NOW, + clientOffset: 0 + }, + segmentInfo: {} + }] + }; - assert.equal(actual.length, 6); + assert.equal(actual.representationInfo.length, 6); assert.deepEqual(actual, expected); }); @@ -511,74 +520,77 @@ QUnit.test( `), { NOW }); - const expected = [{ - attributes: { - bandwidth: 5000000, - baseUrl: 'https://www.example.com/base/', - codecs: 'avc1.64001e', - height: 404, - id: 'test', - mediaPresentationDuration: 30, - mimeType: 'video/mp6', - periodIndex: 0, - role: { - value: 'main' + const expected = { + locations: undefined, + representationInfo: [{ + attributes: { + bandwidth: 5000000, + baseUrl: 'https://www.example.com/base/', + codecs: 'avc1.64001e', + height: 404, + id: 'test', + mediaPresentationDuration: 30, + mimeType: 'video/mp6', + periodIndex: 0, + role: { + value: 'main' + }, + sourceDuration: 30, + width: 720, + NOW, + clientOffset: 0 }, - sourceDuration: 30, - width: 720, - NOW, - clientOffset: 0 - }, - segmentInfo: { - base: { - indexRange: '820-2087', - indexRangeExact: 'true', - initialization: { - range: '0-567' + segmentInfo: { + base: { + indexRange: '820-2087', + indexRangeExact: 'true', + initialization: { + range: '0-567' + } } } - } - }, { - attributes: { - baseUrl: 'https://www.example.com/base/', - mediaPresentationDuration: 30, - mimeType: 'video/mp4', - periodIndex: 0, - height: 545, - role: { - value: 'main' + }, { + attributes: { + baseUrl: 'https://www.example.com/base/', + mediaPresentationDuration: 30, + mimeType: 'video/mp4', + periodIndex: 0, + height: 545, + role: { + value: 'main' + }, + sourceDuration: 30, + NOW, + clientOffset: 0 }, - sourceDuration: 30, - NOW, - clientOffset: 0 - }, - segmentInfo: { - base: { - indexRange: '820-2087', - indexRangeExact: 'true', - initialization: { - range: '0-987' + segmentInfo: { + base: { + indexRange: '820-2087', + indexRangeExact: 'true', + initialization: { + range: '0-987' + } } } - } - }, { - attributes: { - bandwidth: 256, - baseUrl: 'https://example.com/en.vtt', - id: 'en', - lang: 'en', - mediaPresentationDuration: 30, - mimeType: 'text/vtt', - periodIndex: 0, - role: {}, - sourceDuration: 30, - NOW, - clientOffset: 0 - }, - segmentInfo: {} - }]; + }, { + attributes: { + bandwidth: 256, + baseUrl: 'https://example.com/en.vtt', + id: 'en', + lang: 'en', + mediaPresentationDuration: 30, + mimeType: 'text/vtt', + periodIndex: 0, + role: {}, + sourceDuration: 30, + NOW, + clientOffset: 0 + }, + segmentInfo: {} + }] + }; - assert.equal(actual.length, 3); + assert.equal(actual.representationInfo.length, 3); assert.deepEqual(actual, expected); } ); @@ -617,82 +629,85 @@ QUnit.test( `), { NOW }); - const expected = [{ - attributes: { - bandwidth: 5000000, - baseUrl: 'https://www.example.com/base/', - codecs: 'avc1.64001e', - height: 404, - id: 'test', - mediaPresentationDuration: 30, - mimeType: 'video/mp6', - periodIndex: 0, - role: { - value: 'main' + const expected = { + locations: undefined, + representationInfo: [{ + attributes: { + bandwidth: 5000000, + baseUrl: 'https://www.example.com/base/', + codecs: 'avc1.64001e', + height: 404, + id: 'test', + mediaPresentationDuration: 30, + mimeType: 'video/mp6', + periodIndex: 0, + role: { + value: 'main' + }, + sourceDuration: 30, + width: 720, + NOW, + clientOffset: 0 }, - sourceDuration: 30, - width: 720, - NOW, - clientOffset: 0 - }, - segmentInfo: { - base: { - indexRange: '9999', - indexRangeExact: 'false', - initialization: { - range: '0-1111' + segmentInfo: { + base: { + indexRange: '9999', + indexRangeExact: 'false', + initialization: { + range: '0-1111' + } } } - } - }, { - attributes: { - baseUrl: 'https://www.example.com/base/', - mediaPresentationDuration: 30, - mimeType: 'video/mp4', - periodIndex: 0, - height: 545, - role: { - value: 'main' + }, { + attributes: { + baseUrl: 'https://www.example.com/base/', + mediaPresentationDuration: 30, + mimeType: 'video/mp4', + periodIndex: 0, + height: 545, + role: { + value: 'main' + }, + sourceDuration: 30, + NOW, + clientOffset: 0 }, - sourceDuration: 30, - NOW, - clientOffset: 0 - }, - segmentInfo: { - base: { - indexRange: '9999', - indexRangeExact: 'false', - initialization: { - range: '0-1111' + segmentInfo: { + base: { + indexRange: '9999', + indexRangeExact: 'false', + initialization: { + range: '0-1111' + } } } - } - }, { - attributes: { - bandwidth: 256, - baseUrl: 'https://example.com/en.vtt', - id: 'en', - lang: 'en', - mediaPresentationDuration: 30, - mimeType: 'text/vtt', - periodIndex: 0, - role: {}, - sourceDuration: 30, - NOW, - clientOffset: 0 - }, - segmentInfo: { - base: { - indexRange: '9999', - indexRangeExact: 'false', - initialization: { - range: '0-1111' + }, { + attributes: { + bandwidth: 256, + baseUrl: 'https://example.com/en.vtt', + id: 'en', + lang: 'en', + mediaPresentationDuration: 30, + mimeType: 'text/vtt', + periodIndex: 0, + role: {}, + sourceDuration: 30, + NOW, + clientOffset: 0 + }, + segmentInfo: { + base: { + indexRange: '9999', + indexRangeExact: 'false', + initialization: { + range: '0-1111' + } } } - } - }]; + }] + }; - assert.equal(actual.length, 3); + assert.equal(actual.representationInfo.length, 3); assert.deepEqual(actual, expected); } ); @@ -731,75 +746,78 @@ QUnit.test( `), { NOW }); - const expected = [{ - attributes: { - bandwidth: 5000000, - baseUrl: 'https://www.example.com/base/', - codecs: 'avc1.64001e', - height: 404, - id: 'test', - mediaPresentationDuration: 30, - mimeType: 'video/mp6', - periodIndex: 0, - role: { - value: 'main' + const expected = { + locations: undefined, + representationInfo: [{ + attributes: { + bandwidth: 5000000, + baseUrl: 'https://www.example.com/base/', + codecs: 'avc1.64001e', + height: 404, + id: 'test', + mediaPresentationDuration: 30, + mimeType: 'video/mp6', + periodIndex: 0, + role: { + value: 'main' + }, + sourceDuration: 30, + width: 720, + NOW, + clientOffset: 0 }, - sourceDuration: 30, - width: 720, - NOW, - clientOffset: 0 - }, - segmentInfo: { - base: { - indexRange: '1212', - indexRangeExact: 'true', - initialization: { - range: '0-8888' + segmentInfo: { + base: { + indexRange: '1212', + indexRangeExact: 'true', + initialization: { + range: '0-8888' + } } } - } - }, { - attributes: { - baseUrl: 'https://www.example.com/base/', - mediaPresentationDuration: 30, - mimeType: 'video/mp4', - periodIndex: 0, - height: 545, - role: { - value: 'main' + }, { + attributes: { + baseUrl: 'https://www.example.com/base/', + mediaPresentationDuration: 30, + mimeType: 'video/mp4', + periodIndex: 0, + height: 545, + role: { + value: 'main' + }, + sourceDuration: 30, + NOW, + clientOffset: 0 }, - sourceDuration: 30, - NOW, - clientOffset: 0 - }, - segmentInfo: { - base: { - indexRange: '1212', - indexRangeExact: 'true', - initialization: { - range: '0-8888' + segmentInfo: { + base: { + indexRange: '1212', + indexRangeExact: 'true', + initialization: { + range: '0-8888' + } } } - } - }, { - attributes: { - bandwidth: 256, - baseUrl: 'https://example.com/en.vtt', - id: 'en', - lang: 'en', - mediaPresentationDuration: 30, - mimeType: 'text/vtt', - periodIndex: 0, - role: {}, - sourceDuration: 30, - NOW, - clientOffset: 0 - }, - segmentInfo: {} - }]; + }, { + attributes: { + bandwidth: 256, + baseUrl: 'https://example.com/en.vtt', + id: 'en', + lang: 'en', + mediaPresentationDuration: 30, + mimeType: 'text/vtt', + periodIndex: 0, + role: {}, + sourceDuration: 30, + NOW, + clientOffset: 0 + }, + segmentInfo: {} + }] + }; - assert.equal(actual.length, 3); + assert.equal(actual.representationInfo.length, 3); assert.deepEqual(actual, expected); } ); @@ -853,7 +871,7 @@ QUnit.test( - `), { NOW })); + `), { NOW }).representationInfo); const expected = [{ attributes: { @@ -1282,7 +1300,7 @@ QUnit.test('Test to check use of either Segment Template or Segment List when bo - `), { NOW })); + `), { NOW }).representationInfo); const expected = [{ attributes: { diff --git a/test/manifests/location.js b/test/manifests/location.js new file mode 100644 index 00000000..b79943a0 --- /dev/null +++ b/test/manifests/location.js @@ -0,0 +1,53 @@ +export const parsedManifest = { + locations: [ + 'https://www.example.com/updates' + ], + allowCache: true, + discontinuityStarts: [], + duration: 6, + endList: true, + minimumUpdatePeriod: 0, + mediaGroups: { + 'AUDIO': {}, + 'CLOSED-CAPTIONS': {}, + 'SUBTITLES': {}, + 'VIDEO': {} + }, + playlists: [ + { + attributes: { + 'AUDIO': 'audio', + 'BANDWIDTH': 449000, + 'CODECS': 'avc1.420015', + 'NAME': '482', + 'PROGRAM-ID': 1, + 'RESOLUTION': { + height: 270, + width: 482 + }, + 'SUBTITLES': 'subs' + }, + endList: true, + resolvedUri: '', + targetDuration: 6, + mediaSequence: 0, + segments: [ + { + duration: 6, + timeline: 0, + number: 0, + map: { + uri: '', + resolvedUri: 'https://www.example.com/1080p.ts' + }, + resolvedUri: 'https://www.example.com/1080p.ts', + uri: 'https://www.example.com/1080p.ts' + } + ], + timeline: 0, + uri: '' + } + ], + segments: [], + uri: '' +}; diff --git a/test/manifests/location.mpd b/test/manifests/location.mpd new file mode 100644 index 00000000..d686b6fb --- /dev/null +++ b/test/manifests/location.mpd @@ -0,0 +1,17 @@ + + + https://www.example.com/base + https://www.example.com/updates + + + + + + + 1080p.ts + + + + + + diff --git a/test/manifests/locations.js b/test/manifests/locations.js new file mode 100644 index 00000000..7303dba1 --- /dev/null +++ b/test/manifests/locations.js @@ -0,0 +1,54 @@ +export const parsedManifest = { + locations: [ + 'https://www.example.com/updates', + 'https://www.example.com/updates2' + ], + allowCache: true, + discontinuityStarts: [], + duration: 6, + endList: true, + minimumUpdatePeriod: 0, + mediaGroups: { + 'AUDIO': {}, + 'CLOSED-CAPTIONS': {}, + 'SUBTITLES': {}, + 'VIDEO': {} + }, + playlists: [ + { + attributes: { + 'AUDIO': 'audio', + 'BANDWIDTH': 449000, + 'CODECS': 'avc1.420015', + 'NAME': '482', + 'PROGRAM-ID': 1, + 'RESOLUTION': { + height: 270, + width: 482 + }, + 'SUBTITLES': 'subs' + }, + endList: true, + resolvedUri: '', + targetDuration: 6, + mediaSequence: 0, + segments: [ + { + duration: 6, + timeline: 0, + number: 0, + map: { + uri: '', + resolvedUri: 'https://www.example.com/1080p.ts' + }, + resolvedUri: 'https://www.example.com/1080p.ts', + uri: 'https://www.example.com/1080p.ts' + } + ], + timeline: 0, + uri: '' + } + ], + segments: [], + uri: '' +}; diff --git a/test/manifests/locations.mpd b/test/manifests/locations.mpd new file mode 100644 index 00000000..9bd635fb --- /dev/null +++ b/test/manifests/locations.mpd @@ -0,0 +1,18 @@ + + + https://www.example.com/base + https://www.example.com/updates + https://www.example.com/updates2 + + + + + + + 1080p.ts + + + + + + diff --git a/test/toM3u8.test.js b/test/toM3u8.test.js index 66c2abc5..eb25b564 100644 --- a/test/toM3u8.test.js +++ b/test/toM3u8.test.js @@ -544,7 +544,7 @@ QUnit.test('playlists with sidx and sidxMapping', function(assert) { resolvedUri: '' }]; - assert.deepEqual(toM3u8(input, mapping).playlists, expected); + assert.deepEqual(toM3u8(input, null, mapping).playlists, expected); }); QUnit.test('no playlists', function(assert) {