mpd-parser
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -0,1 +1,8 @@ | ||
<a name="0.6.1"></a> | ||
## [0.6.1](https://github.com/videojs/mpd-parser/compare/v0.6.0...v0.6.1) (2018-05-17) | ||
### Bug Fixes | ||
* babel es module ([#25](https://github.com/videojs/mpd-parser/issues/25)) ([9a84461](https://github.com/videojs/mpd-parser/commit/9a84461)) | ||
<a name="0.6.0"></a> | ||
@@ -2,0 +9,0 @@ # [0.6.0](https://github.com/videojs/mpd-parser/compare/v0.5.0...v0.6.0) (2018-03-30) |
/** | ||
* mpd-parser | ||
* @version 0.6.0 | ||
* @version 0.6.1 | ||
* @copyright 2018 Brightcove, Inc | ||
@@ -14,3 +14,3 @@ * @license Apache-2.0 | ||
var version = "0.6.0"; | ||
var version = "0.6.1"; | ||
@@ -17,0 +17,0 @@ var formatAudioPlaylist = function formatAudioPlaylist(_ref) { |
/** | ||
* mpd-parser | ||
* @version 0.6.0 | ||
* @version 0.6.1 | ||
* @copyright 2018 Brightcove, Inc | ||
@@ -10,12 +10,16 @@ * @license Apache-2.0 | ||
const version = "0.6.0"; | ||
var version = "0.6.1"; | ||
const formatAudioPlaylist = ({ attributes, segments }) => { | ||
const playlist = { | ||
attributes: { | ||
var formatAudioPlaylist = function formatAudioPlaylist(_ref) { | ||
var _attributes; | ||
var attributes = _ref.attributes, | ||
segments = _ref.segments; | ||
var playlist = { | ||
attributes: (_attributes = { | ||
NAME: attributes.id, | ||
BANDWIDTH: attributes.bandwidth, | ||
CODECS: attributes.codecs, | ||
['PROGRAM-ID']: 1 | ||
}, | ||
CODECS: attributes.codecs | ||
}, _attributes['PROGRAM-ID'] = 1, _attributes), | ||
uri: '', | ||
@@ -26,3 +30,3 @@ endList: (attributes.type || 'static') === 'static', | ||
targetDuration: attributes.duration, | ||
segments, | ||
segments: segments, | ||
mediaSequence: segments.length ? segments[0].number : 1 | ||
@@ -38,3 +42,8 @@ }; | ||
const formatVttPlaylist = ({ attributes, segments }) => { | ||
var formatVttPlaylist = function formatVttPlaylist(_ref2) { | ||
var _attributes2; | ||
var attributes = _ref2.attributes, | ||
segments = _ref2.segments; | ||
if (typeof segments === 'undefined') { | ||
@@ -53,7 +62,6 @@ // vtt tracks may use single file in BaseURL | ||
return { | ||
attributes: { | ||
attributes: (_attributes2 = { | ||
NAME: attributes.id, | ||
BANDWIDTH: attributes.bandwidth, | ||
['PROGRAM-ID']: 1 | ||
}, | ||
BANDWIDTH: attributes.bandwidth | ||
}, _attributes2['PROGRAM-ID'] = 1, _attributes2), | ||
uri: '', | ||
@@ -64,3 +72,3 @@ endList: (attributes.type || 'static') === 'static', | ||
targetDuration: attributes.duration, | ||
segments, | ||
segments: segments, | ||
mediaSequence: segments.length ? segments[0].number : 1 | ||
@@ -70,18 +78,15 @@ }; | ||
const organizeAudioPlaylists = playlists => { | ||
return playlists.reduce((a, playlist) => { | ||
const role = playlist.attributes.role && | ||
playlist.attributes.role.value || 'main'; | ||
const language = playlist.attributes.lang || ''; | ||
var organizeAudioPlaylists = function organizeAudioPlaylists(playlists) { | ||
return playlists.reduce(function (a, playlist) { | ||
var role = playlist.attributes.role && playlist.attributes.role.value || 'main'; | ||
var language = playlist.attributes.lang || ''; | ||
let label = 'main'; | ||
var label = 'main'; | ||
if (language) { | ||
label = `${playlist.attributes.lang} (${role})`; | ||
label = playlist.attributes.lang + ' (' + role + ')'; | ||
} | ||
// skip if we already have the highest quality audio for a language | ||
if (a[label] && | ||
a[label].playlists[0].attributes.BANDWIDTH > | ||
playlist.attributes.bandwidth) { | ||
if (a[label] && a[label].playlists[0].attributes.BANDWIDTH > playlist.attributes.bandwidth) { | ||
return a; | ||
@@ -91,5 +96,5 @@ } | ||
a[label] = { | ||
language, | ||
language: language, | ||
autoselect: true, | ||
default: role === 'main', | ||
'default': role === 'main', | ||
playlists: [formatAudioPlaylist(playlist)], | ||
@@ -103,5 +108,5 @@ uri: '' | ||
const organizeVttPlaylists = playlists => { | ||
return playlists.reduce((a, playlist) => { | ||
const label = playlist.attributes.lang || 'text'; | ||
var organizeVttPlaylists = function organizeVttPlaylists(playlists) { | ||
return playlists.reduce(function (a, playlist) { | ||
var label = playlist.attributes.lang || 'text'; | ||
@@ -115,3 +120,3 @@ // skip if we already have subtitles | ||
language: label, | ||
default: false, | ||
'default': false, | ||
autoselect: false, | ||
@@ -126,5 +131,10 @@ playlists: [formatVttPlaylist(playlist)], | ||
const formatVideoPlaylist = ({ attributes, segments }) => { | ||
const playlist = { | ||
attributes: { | ||
var formatVideoPlaylist = function formatVideoPlaylist(_ref3) { | ||
var _attributes3; | ||
var attributes = _ref3.attributes, | ||
segments = _ref3.segments; | ||
var playlist = { | ||
attributes: (_attributes3 = { | ||
NAME: attributes.id, | ||
@@ -138,5 +148,4 @@ AUDIO: 'audio', | ||
CODECS: attributes.codecs, | ||
BANDWIDTH: attributes.bandwidth, | ||
['PROGRAM-ID']: 1 | ||
}, | ||
BANDWIDTH: attributes.bandwidth | ||
}, _attributes3['PROGRAM-ID'] = 1, _attributes3), | ||
uri: '', | ||
@@ -147,3 +156,3 @@ endList: (attributes.type || 'static') === 'static', | ||
targetDuration: attributes.duration, | ||
segments, | ||
segments: segments, | ||
mediaSequence: segments.length ? segments[0].number : 1 | ||
@@ -159,3 +168,5 @@ }; | ||
const toM3u8 = dashPlaylists => { | ||
var toM3u8 = function toM3u8(dashPlaylists) { | ||
var _mediaGroups; | ||
if (!dashPlaylists.length) { | ||
@@ -166,19 +177,26 @@ return {}; | ||
// grab all master attributes | ||
const { | ||
sourceDuration: duration, | ||
minimumUpdatePeriod = 0 | ||
} = dashPlaylists[0].attributes; | ||
var _dashPlaylists$0$attr = dashPlaylists[0].attributes, | ||
duration = _dashPlaylists$0$attr.sourceDuration, | ||
_dashPlaylists$0$attr2 = _dashPlaylists$0$attr.minimumUpdatePeriod, | ||
minimumUpdatePeriod = _dashPlaylists$0$attr2 === undefined ? 0 : _dashPlaylists$0$attr2; | ||
const videoOnly = ({ attributes }) => | ||
attributes.mimeType === 'video/mp4' || attributes.contentType === 'video'; | ||
const audioOnly = ({ attributes }) => | ||
attributes.mimeType === 'audio/mp4' || attributes.contentType === 'audio'; | ||
const vttOnly = ({ attributes }) => | ||
attributes.mimeType === 'text/vtt' || attributes.contentType === 'text'; | ||
const videoPlaylists = dashPlaylists.filter(videoOnly).map(formatVideoPlaylist); | ||
const audioPlaylists = dashPlaylists.filter(audioOnly); | ||
const vttPlaylists = dashPlaylists.filter(vttOnly); | ||
var videoOnly = function videoOnly(_ref4) { | ||
var attributes = _ref4.attributes; | ||
return attributes.mimeType === 'video/mp4' || attributes.contentType === 'video'; | ||
}; | ||
var audioOnly = function audioOnly(_ref5) { | ||
var attributes = _ref5.attributes; | ||
return attributes.mimeType === 'audio/mp4' || attributes.contentType === 'audio'; | ||
}; | ||
var vttOnly = function vttOnly(_ref6) { | ||
var attributes = _ref6.attributes; | ||
return attributes.mimeType === 'text/vtt' || attributes.contentType === 'text'; | ||
}; | ||
const master = { | ||
var videoPlaylists = dashPlaylists.filter(videoOnly).map(formatVideoPlaylist); | ||
var audioPlaylists = dashPlaylists.filter(audioOnly); | ||
var vttPlaylists = dashPlaylists.filter(vttOnly); | ||
var master = { | ||
allowCache: true, | ||
@@ -188,10 +206,8 @@ discontinuityStarts: [], | ||
endList: true, | ||
mediaGroups: { | ||
mediaGroups: (_mediaGroups = { | ||
AUDIO: {}, | ||
VIDEO: {}, | ||
['CLOSED-CAPTIONS']: {}, | ||
SUBTITLES: {} | ||
}, | ||
VIDEO: {} | ||
}, _mediaGroups['CLOSED-CAPTIONS'] = {}, _mediaGroups.SUBTITLES = {}, _mediaGroups), | ||
uri: '', | ||
duration, | ||
duration: duration, | ||
playlists: videoPlaylists, | ||
@@ -212,12 +228,21 @@ minimumUpdatePeriod: minimumUpdatePeriod * 1000 | ||
const isObject = (obj) => { | ||
return !!obj && typeof obj === 'object'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
const merge = (...objects) => { | ||
var isObject = function isObject(obj) { | ||
return !!obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object'; | ||
}; | ||
return objects.reduce((result, source) => { | ||
var merge = function merge() { | ||
for (var _len = arguments.length, objects = Array(_len), _key = 0; _key < _len; _key++) { | ||
objects[_key] = arguments[_key]; | ||
} | ||
Object.keys(source).forEach(key => { | ||
return objects.reduce(function (result, source) { | ||
Object.keys(source).forEach(function (key) { | ||
if (Array.isArray(result[key]) && Array.isArray(source[key])) { | ||
@@ -235,5 +260,5 @@ result[key] = result[key].concat(source[key]); | ||
const resolveUrl = (baseUrl, relativeUrl) => { | ||
var resolveUrl = function resolveUrl(baseUrl, relativeUrl) { | ||
// return early if we don't need to resolve | ||
if ((/^[a-z]+:/i).test(relativeUrl)) { | ||
if (/^[a-z]+:/i.test(relativeUrl)) { | ||
return relativeUrl; | ||
@@ -243,3 +268,3 @@ } | ||
// if the base URL is relative then combine with the current location | ||
if (!(/\/\//i).test(baseUrl)) { | ||
if (!/\/\//i.test(baseUrl)) { | ||
baseUrl = URLToolkit.buildAbsoluteURL(window.location.href, baseUrl); | ||
@@ -275,4 +300,11 @@ } | ||
*/ | ||
const urlTypeToSegment = ({ baseUrl = '', source = '', range = '' }) => { | ||
const init = { | ||
var urlTypeToSegment = function urlTypeToSegment(_ref) { | ||
var _ref$baseUrl = _ref.baseUrl, | ||
baseUrl = _ref$baseUrl === undefined ? '' : _ref$baseUrl, | ||
_ref$source = _ref.source, | ||
source = _ref$source === undefined ? '' : _ref$source, | ||
_ref$range = _ref.range, | ||
range = _ref$range === undefined ? '' : _ref$range; | ||
var init = { | ||
uri: source, | ||
@@ -283,5 +315,5 @@ resolvedUri: resolveUrl(baseUrl || '', source) | ||
if (range) { | ||
const ranges = range.split('-'); | ||
const startRange = parseInt(ranges[0], 10); | ||
const endRange = parseInt(ranges[1], 10); | ||
var ranges = range.split('-'); | ||
var startRange = parseInt(ranges[0], 10); | ||
var endRange = parseInt(ranges[1], 10); | ||
@@ -312,17 +344,19 @@ init.byterange = { | ||
*/ | ||
const getLiveRValue = (attributes, time, duration) => { | ||
const { | ||
NOW, | ||
clientOffset, | ||
availabilityStartTime, | ||
timescale = 1, | ||
start = 0, | ||
minimumUpdatePeriod = 0 | ||
} = attributes; | ||
const now = (NOW + clientOffset) / 1000; | ||
const periodStartWC = availabilityStartTime + start; | ||
const periodEndWC = now + minimumUpdatePeriod; | ||
const periodDuration = periodEndWC - periodStartWC; | ||
var getLiveRValue = function getLiveRValue(attributes, time, duration) { | ||
var NOW = attributes.NOW, | ||
clientOffset = attributes.clientOffset, | ||
availabilityStartTime = attributes.availabilityStartTime, | ||
_attributes$timescale = attributes.timescale, | ||
timescale = _attributes$timescale === undefined ? 1 : _attributes$timescale, | ||
_attributes$start = attributes.start, | ||
start = _attributes$start === undefined ? 0 : _attributes$start, | ||
_attributes$minimumUp = attributes.minimumUpdatePeriod, | ||
minimumUpdatePeriod = _attributes$minimumUp === undefined ? 0 : _attributes$minimumUp; | ||
return Math.ceil(((periodDuration * timescale) - time) / duration); | ||
var now = (NOW + clientOffset) / 1000; | ||
var periodStartWC = availabilityStartTime + start; | ||
var periodEndWC = now + minimumUpdatePeriod; | ||
var periodDuration = periodEndWC - periodStartWC; | ||
return Math.ceil((periodDuration * timescale - time) / duration); | ||
}; | ||
@@ -343,21 +377,25 @@ | ||
*/ | ||
const parseByTimeline = (attributes, segmentTimeline) => { | ||
const { | ||
type = 'static', | ||
minimumUpdatePeriod = 0, | ||
media = '', | ||
sourceDuration, | ||
timescale = 1, | ||
startNumber = 1, | ||
periodIndex: timeline | ||
} = attributes; | ||
const segments = []; | ||
let time = -1; | ||
var parseByTimeline = function parseByTimeline(attributes, segmentTimeline) { | ||
var _attributes$type = attributes.type, | ||
type = _attributes$type === undefined ? 'static' : _attributes$type, | ||
_attributes$minimumUp2 = attributes.minimumUpdatePeriod, | ||
minimumUpdatePeriod = _attributes$minimumUp2 === undefined ? 0 : _attributes$minimumUp2, | ||
_attributes$media = attributes.media, | ||
media = _attributes$media === undefined ? '' : _attributes$media, | ||
sourceDuration = attributes.sourceDuration, | ||
_attributes$timescale2 = attributes.timescale, | ||
timescale = _attributes$timescale2 === undefined ? 1 : _attributes$timescale2, | ||
_attributes$startNumb = attributes.startNumber, | ||
startNumber = _attributes$startNumb === undefined ? 1 : _attributes$startNumb, | ||
timeline = attributes.periodIndex; | ||
for (let sIndex = 0; sIndex < segmentTimeline.length; sIndex++) { | ||
const S = segmentTimeline[sIndex]; | ||
const duration = S.d; | ||
const repeat = S.r || 0; | ||
const segmentTime = S.t || 0; | ||
var segments = []; | ||
var time = -1; | ||
for (var sIndex = 0; sIndex < segmentTimeline.length; sIndex++) { | ||
var S = segmentTimeline[sIndex]; | ||
var duration = S.d; | ||
var repeat = S.r || 0; | ||
var segmentTime = S.t || 0; | ||
if (time < 0) { | ||
@@ -394,16 +432,14 @@ // first segment | ||
let count; | ||
var count = void 0; | ||
if (repeat < 0) { | ||
const nextS = sIndex + 1; | ||
var nextS = sIndex + 1; | ||
if (nextS === segmentTimeline.length) { | ||
// last segment | ||
if (type === 'dynamic' && | ||
minimumUpdatePeriod > 0 && | ||
media.indexOf('$Number$') > 0) { | ||
if (type === 'dynamic' && minimumUpdatePeriod > 0 && media.indexOf('$Number$') > 0) { | ||
count = getLiveRValue(attributes, time, duration); | ||
} else { | ||
// TODO: This may be incorrect depending on conclusion of TODO above | ||
count = ((sourceDuration * timescale) - time) / duration; | ||
count = (sourceDuration * timescale - time) / duration; | ||
} | ||
@@ -417,7 +453,7 @@ } else { | ||
const end = startNumber + segments.length + count; | ||
let number = startNumber + segments.length; | ||
var end = startNumber + segments.length + count; | ||
var number = startNumber + segments.length; | ||
while (number < end) { | ||
segments.push({ number, duration: duration / timescale, time, timeline }); | ||
segments.push({ number: number, duration: duration / timescale, time: time, timeline: timeline }); | ||
time += duration; | ||
@@ -431,6 +467,6 @@ number++; | ||
const range = (start, end) => { | ||
const result = []; | ||
var range = function range(start, end) { | ||
var result = []; | ||
for (let i = start; i < end; i++) { | ||
for (var i = start; i < end; i++) { | ||
result.push(i); | ||
@@ -442,5 +478,9 @@ } | ||
const flatten = lists => lists.reduce((x, y) => x.concat(y), []); | ||
var flatten = function flatten(lists) { | ||
return lists.reduce(function (x, y) { | ||
return x.concat(y); | ||
}, []); | ||
}; | ||
const from = list => { | ||
var from = function from(list) { | ||
if (!list.length) { | ||
@@ -450,5 +490,5 @@ return []; | ||
const result = []; | ||
var result = []; | ||
for (let i = 0; i < list.length; i++) { | ||
for (var i = 0; i < list.length; i++) { | ||
result.push(list[i]); | ||
@@ -464,3 +504,3 @@ } | ||
*/ | ||
const segmentRange = { | ||
var segmentRange = { | ||
/** | ||
@@ -474,9 +514,9 @@ * Returns the entire range of available segments for a static MPD | ||
*/ | ||
static(attributes) { | ||
const { | ||
duration, | ||
timescale = 1, | ||
sourceDuration | ||
} = attributes; | ||
'static': function _static(attributes) { | ||
var duration = attributes.duration, | ||
_attributes$timescale = attributes.timescale, | ||
timescale = _attributes$timescale === undefined ? 1 : _attributes$timescale, | ||
sourceDuration = attributes.sourceDuration; | ||
return { | ||
@@ -488,2 +528,3 @@ start: 0, | ||
/** | ||
@@ -497,22 +538,24 @@ * Returns the current live window range of available segments for a dynamic MPD | ||
*/ | ||
dynamic(attributes) { | ||
const { | ||
NOW, | ||
clientOffset, | ||
availabilityStartTime, | ||
timescale = 1, | ||
duration, | ||
start = 0, | ||
minimumUpdatePeriod = 0, | ||
timeShiftBufferDepth = Infinity | ||
} = attributes; | ||
const now = (NOW + clientOffset) / 1000; | ||
const periodStartWC = availabilityStartTime + start; | ||
const periodEndWC = now + minimumUpdatePeriod; | ||
const periodDuration = periodEndWC - periodStartWC; | ||
const segmentCount = Math.ceil(periodDuration * timescale / duration); | ||
const availableStart = | ||
Math.floor((now - periodStartWC - timeShiftBufferDepth) * timescale / duration); | ||
const availableEnd = Math.floor((now - periodStartWC) * timescale / duration); | ||
dynamic: function dynamic(attributes) { | ||
var NOW = attributes.NOW, | ||
clientOffset = attributes.clientOffset, | ||
availabilityStartTime = attributes.availabilityStartTime, | ||
_attributes$timescale2 = attributes.timescale, | ||
timescale = _attributes$timescale2 === undefined ? 1 : _attributes$timescale2, | ||
duration = attributes.duration, | ||
_attributes$start = attributes.start, | ||
start = _attributes$start === undefined ? 0 : _attributes$start, | ||
_attributes$minimumUp = attributes.minimumUpdatePeriod, | ||
minimumUpdatePeriod = _attributes$minimumUp === undefined ? 0 : _attributes$minimumUp, | ||
_attributes$timeShift = attributes.timeShiftBufferDepth, | ||
timeShiftBufferDepth = _attributes$timeShift === undefined ? Infinity : _attributes$timeShift; | ||
var now = (NOW + clientOffset) / 1000; | ||
var periodStartWC = availabilityStartTime + start; | ||
var periodEndWC = now + minimumUpdatePeriod; | ||
var periodDuration = periodEndWC - periodStartWC; | ||
var segmentCount = Math.ceil(periodDuration * timescale / duration); | ||
var availableStart = Math.floor((now - periodStartWC - timeShiftBufferDepth) * timescale / duration); | ||
var availableEnd = Math.floor((now - periodStartWC) * timescale / duration); | ||
return { | ||
@@ -548,15 +591,18 @@ start: Math.max(0, availableStart), | ||
*/ | ||
const toSegments = (attributes) => (number, index) => { | ||
const { | ||
duration, | ||
timescale = 1, | ||
periodIndex, | ||
startNumber = 1 | ||
} = attributes; | ||
var toSegments = function toSegments(attributes) { | ||
return function (number, index) { | ||
var duration = attributes.duration, | ||
_attributes$timescale3 = attributes.timescale, | ||
timescale = _attributes$timescale3 === undefined ? 1 : _attributes$timescale3, | ||
periodIndex = attributes.periodIndex, | ||
_attributes$startNumb = attributes.startNumber, | ||
startNumber = _attributes$startNumb === undefined ? 1 : _attributes$startNumb; | ||
return { | ||
number: startNumber + number, | ||
duration: duration / timescale, | ||
timeline: periodIndex, | ||
time: index * duration | ||
return { | ||
number: startNumber + number, | ||
duration: duration / timescale, | ||
timeline: periodIndex, | ||
time: index * duration | ||
}; | ||
}; | ||
@@ -575,18 +621,21 @@ }; | ||
*/ | ||
const parseByDuration = (attributes) => { | ||
const { | ||
type = 'static', | ||
duration, | ||
timescale = 1, | ||
sourceDuration | ||
} = attributes; | ||
var parseByDuration = function parseByDuration(attributes) { | ||
var _attributes$type = attributes.type, | ||
type = _attributes$type === undefined ? 'static' : _attributes$type, | ||
duration = attributes.duration, | ||
_attributes$timescale4 = attributes.timescale, | ||
timescale = _attributes$timescale4 === undefined ? 1 : _attributes$timescale4, | ||
sourceDuration = attributes.sourceDuration; | ||
const { start, end } = segmentRange[type](attributes); | ||
const segments = range(start, end).map(toSegments(attributes)); | ||
var _segmentRange$type = segmentRange[type](attributes), | ||
start = _segmentRange$type.start, | ||
end = _segmentRange$type.end; | ||
var segments = range(start, end).map(toSegments(attributes)); | ||
if (type === 'static') { | ||
const index = segments.length - 1; | ||
var index = segments.length - 1; | ||
// final segment may be less than full segment duration | ||
segments[index].duration = sourceDuration - (duration / timescale * index); | ||
segments[index].duration = sourceDuration - duration / timescale * index; | ||
} | ||
@@ -597,3 +646,3 @@ | ||
const identifierPattern = /\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g; | ||
var identifierPattern = /\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g; | ||
@@ -636,30 +685,32 @@ /** | ||
*/ | ||
const identifierReplacement = (values) => (match, identifier, format, width) => { | ||
if (match === '$$') { | ||
// escape sequence | ||
return '$'; | ||
} | ||
var identifierReplacement = function identifierReplacement(values) { | ||
return function (match, identifier, format, width) { | ||
if (match === '$$') { | ||
// escape sequence | ||
return '$'; | ||
} | ||
if (typeof values[identifier] === 'undefined') { | ||
return match; | ||
} | ||
if (typeof values[identifier] === 'undefined') { | ||
return match; | ||
} | ||
const value = '' + values[identifier]; | ||
var value = '' + values[identifier]; | ||
if (identifier === 'RepresentationID') { | ||
// Format tag shall not be present with RepresentationID | ||
return value; | ||
} | ||
if (identifier === 'RepresentationID') { | ||
// Format tag shall not be present with RepresentationID | ||
return value; | ||
} | ||
if (!format) { | ||
width = 1; | ||
} else { | ||
width = parseInt(width, 10); | ||
} | ||
if (!format) { | ||
width = 1; | ||
} else { | ||
width = parseInt(width, 10); | ||
} | ||
if (value.length >= width) { | ||
return value; | ||
} | ||
if (value.length >= width) { | ||
return value; | ||
} | ||
return `${(new Array(width - value.length + 1)).join('0')}${value}`; | ||
return '' + new Array(width - value.length + 1).join('0') + value; | ||
}; | ||
}; | ||
@@ -685,4 +736,5 @@ | ||
*/ | ||
const constructTemplateUrl = (url, values) => | ||
url.replace(identifierPattern, identifierReplacement(values)); | ||
var constructTemplateUrl = function constructTemplateUrl(url, values) { | ||
return url.replace(identifierPattern, identifierReplacement(values)); | ||
}; | ||
@@ -702,3 +754,3 @@ /** | ||
*/ | ||
const parseTemplateInfo = (attributes, segmentTimeline) => { | ||
var parseTemplateInfo = function parseTemplateInfo(attributes, segmentTimeline) { | ||
if (!attributes.duration && !segmentTimeline) { | ||
@@ -734,4 +786,4 @@ // if neither @duration or SegmentTimeline are present, then there shall be exactly | ||
*/ | ||
const segmentsFromTemplate = (attributes, segmentTimeline) => { | ||
const templateValues = { | ||
var segmentsFromTemplate = function segmentsFromTemplate(attributes, segmentTimeline) { | ||
var templateValues = { | ||
RepresentationID: attributes.id, | ||
@@ -741,5 +793,7 @@ Bandwidth: attributes.bandwidth || 0 | ||
const { initialization = { sourceURL: '', range: '' } } = attributes; | ||
var _attributes$initializ = attributes.initialization, | ||
initialization = _attributes$initializ === undefined ? { sourceURL: '', range: '' } : _attributes$initializ; | ||
const mapSegment = urlTypeToSegment({ | ||
var mapSegment = urlTypeToSegment({ | ||
baseUrl: attributes.baseUrl, | ||
@@ -750,12 +804,12 @@ source: constructTemplateUrl(initialization.sourceURL, templateValues), | ||
const segments = parseTemplateInfo(attributes, segmentTimeline); | ||
var segments = parseTemplateInfo(attributes, segmentTimeline); | ||
return segments.map(segment => { | ||
return segments.map(function (segment) { | ||
templateValues.Number = segment.number; | ||
templateValues.Time = segment.time; | ||
const uri = constructTemplateUrl(attributes.media || '', templateValues); | ||
var uri = constructTemplateUrl(attributes.media || '', templateValues); | ||
return { | ||
uri, | ||
uri: uri, | ||
timeline: segment.timeline, | ||
@@ -791,7 +845,10 @@ duration: segment.duration, | ||
*/ | ||
const SegmentURLToSegmentObject = (attributes, segmentUrl) => { | ||
const { baseUrl, initialization = {} } = attributes; | ||
var SegmentURLToSegmentObject = function SegmentURLToSegmentObject(attributes, segmentUrl) { | ||
var baseUrl = attributes.baseUrl, | ||
_attributes$initializ = attributes.initialization, | ||
initialization = _attributes$initializ === undefined ? {} : _attributes$initializ; | ||
const initSegment = urlTypeToSegment({ | ||
baseUrl, | ||
var initSegment = urlTypeToSegment({ | ||
baseUrl: baseUrl, | ||
source: initialization.sourceURL, | ||
@@ -801,4 +858,4 @@ range: initialization.range | ||
const segment = urlTypeToSegment({ | ||
baseUrl, | ||
var segment = urlTypeToSegment({ | ||
baseUrl: baseUrl, | ||
source: segmentUrl.media, | ||
@@ -826,18 +883,18 @@ range: segmentUrl.mediaRange | ||
*/ | ||
const segmentsFromList = (attributes, segmentTimeline) => { | ||
const { | ||
duration, | ||
segmentUrls = [] | ||
} = attributes; | ||
var segmentsFromList = function segmentsFromList(attributes, segmentTimeline) { | ||
var duration = attributes.duration, | ||
_attributes$segmentUr = attributes.segmentUrls, | ||
segmentUrls = _attributes$segmentUr === undefined ? [] : _attributes$segmentUr; | ||
// Per spec (5.3.9.2.1) no way to determine segment duration OR | ||
// if both SegmentTimeline and @duration are defined, it is outside of spec. | ||
if ((!duration && !segmentTimeline) || | ||
(duration && segmentTimeline)) { | ||
if (!duration && !segmentTimeline || duration && segmentTimeline) { | ||
throw new Error(errors.SEGMENT_TIME_UNSPECIFIED); | ||
} | ||
const segmentUrlMap = segmentUrls.map(segmentUrlObject => | ||
SegmentURLToSegmentObject(attributes, segmentUrlObject)); | ||
let segmentTimeInfo; | ||
var segmentUrlMap = segmentUrls.map(function (segmentUrlObject) { | ||
return SegmentURLToSegmentObject(attributes, segmentUrlObject); | ||
}); | ||
var segmentTimeInfo = void 0; | ||
@@ -852,5 +909,5 @@ if (duration) { | ||
const segments = segmentTimeInfo.map((segmentTime, index) => { | ||
var segments = segmentTimeInfo.map(function (segmentTime, index) { | ||
if (segmentUrlMap[index]) { | ||
const segment = segmentUrlMap[index]; | ||
var segment = segmentUrlMap[index]; | ||
@@ -865,3 +922,5 @@ segment.timeline = segmentTime.timeline; | ||
// SegmentURLs for). | ||
}).filter(segment => segment); | ||
}).filter(function (segment) { | ||
return segment; | ||
}); | ||
@@ -881,13 +940,15 @@ return segments; | ||
*/ | ||
const segmentsFromBase = (attributes) => { | ||
const { | ||
baseUrl, | ||
initialization = {}, | ||
sourceDuration, | ||
timescale = 1, | ||
indexRange = '', | ||
duration | ||
} = attributes; | ||
var segmentsFromBase = function segmentsFromBase(attributes) { | ||
var baseUrl = attributes.baseUrl, | ||
_attributes$initializ = attributes.initialization, | ||
initialization = _attributes$initializ === undefined ? {} : _attributes$initializ, | ||
sourceDuration = attributes.sourceDuration, | ||
_attributes$timescale = attributes.timescale, | ||
timescale = _attributes$timescale === undefined ? 1 : _attributes$timescale, | ||
_attributes$indexRang = attributes.indexRange, | ||
indexRange = _attributes$indexRang === undefined ? '' : _attributes$indexRang, | ||
duration = attributes.duration; | ||
// base url is required for SegmentBase to work, per spec (Section 5.3.9.2.1) | ||
if (!baseUrl) { | ||
@@ -897,8 +958,8 @@ throw new Error(errors.NO_BASE_URL); | ||
const initSegment = urlTypeToSegment({ | ||
baseUrl, | ||
var initSegment = urlTypeToSegment({ | ||
baseUrl: baseUrl, | ||
source: initialization.sourceURL, | ||
range: initialization.range | ||
}); | ||
const segment = urlTypeToSegment({ baseUrl, source: baseUrl, range: indexRange }); | ||
var segment = urlTypeToSegment({ baseUrl: baseUrl, source: baseUrl, range: indexRange }); | ||
@@ -910,3 +971,3 @@ segment.map = initSegment; | ||
if (duration) { | ||
const segmentTimeInfo = parseByDuration(attributes); | ||
var segmentTimeInfo = parseByDuration(attributes); | ||
@@ -918,3 +979,3 @@ if (segmentTimeInfo.length) { | ||
} else if (sourceDuration) { | ||
segment.duration = (sourceDuration / timescale); | ||
segment.duration = sourceDuration / timescale; | ||
segment.timeline = 0; | ||
@@ -929,6 +990,9 @@ } | ||
const generateSegments = ({ attributes, segmentInfo }) => { | ||
let segmentAttributes; | ||
let segmentsFn; | ||
var generateSegments = function generateSegments(_ref) { | ||
var attributes = _ref.attributes, | ||
segmentInfo = _ref.segmentInfo; | ||
var segmentAttributes = void 0; | ||
var segmentsFn = void 0; | ||
if (segmentInfo.template) { | ||
@@ -946,6 +1010,6 @@ segmentsFn = segmentsFromTemplate; | ||
if (!segmentsFn) { | ||
return { attributes }; | ||
return { attributes: attributes }; | ||
} | ||
const segments = segmentsFn(segmentAttributes, segmentInfo.timeline); | ||
var segments = segmentsFn(segmentAttributes, segmentInfo.timeline); | ||
@@ -956,4 +1020,8 @@ // The @duration attribute will be used to determin the playlist's targetDuration which | ||
if (segmentAttributes.duration) { | ||
const { duration, timescale = 1 } = segmentAttributes; | ||
var _segmentAttributes = segmentAttributes, | ||
duration = _segmentAttributes.duration, | ||
_segmentAttributes$ti = _segmentAttributes.timescale, | ||
timescale = _segmentAttributes$ti === undefined ? 1 : _segmentAttributes$ti; | ||
segmentAttributes.duration = duration / timescale; | ||
@@ -963,3 +1031,3 @@ } else if (segments.length) { | ||
// as target duration | ||
segmentAttributes.duration = segments.reduce((max, segment) => { | ||
segmentAttributes.duration = segments.reduce(function (max, segment) { | ||
return Math.max(max, Math.ceil(segment.duration)); | ||
@@ -973,24 +1041,31 @@ }, 0); | ||
attributes: segmentAttributes, | ||
segments | ||
segments: segments | ||
}; | ||
}; | ||
const toPlaylists = (representations) => representations.map(generateSegments); | ||
var toPlaylists = function toPlaylists(representations) { | ||
return representations.map(generateSegments); | ||
}; | ||
const findChildren = (element, name) => | ||
from(element.childNodes).filter(({tagName}) => tagName === name); | ||
var findChildren = function findChildren(element, name) { | ||
return from(element.childNodes).filter(function (_ref) { | ||
var tagName = _ref.tagName; | ||
return tagName === name; | ||
}); | ||
}; | ||
const getContent = element => element.textContent.trim(); | ||
var getContent = function getContent(element) { | ||
return element.textContent.trim(); | ||
}; | ||
const parseDuration = (str) => { | ||
const SECONDS_IN_YEAR = 365 * 24 * 60 * 60; | ||
const SECONDS_IN_MONTH = 30 * 24 * 60 * 60; | ||
const SECONDS_IN_DAY = 24 * 60 * 60; | ||
const SECONDS_IN_HOUR = 60 * 60; | ||
const SECONDS_IN_MIN = 60; | ||
var parseDuration = function parseDuration(str) { | ||
var SECONDS_IN_YEAR = 365 * 24 * 60 * 60; | ||
var SECONDS_IN_MONTH = 30 * 24 * 60 * 60; | ||
var SECONDS_IN_DAY = 24 * 60 * 60; | ||
var SECONDS_IN_HOUR = 60 * 60; | ||
var SECONDS_IN_MIN = 60; | ||
// P10Y10M10DT10H10M10.1S | ||
const durationRegex = | ||
/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/; | ||
const match = durationRegex.exec(str); | ||
var durationRegex = /P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/; | ||
var match = durationRegex.exec(str); | ||
@@ -1001,16 +1076,17 @@ if (!match) { | ||
const [year, month, day, hour, minute, second] = match.slice(1); | ||
var _match$slice = match.slice(1), | ||
year = _match$slice[0], | ||
month = _match$slice[1], | ||
day = _match$slice[2], | ||
hour = _match$slice[3], | ||
minute = _match$slice[4], | ||
second = _match$slice[5]; | ||
return (parseFloat(year || 0) * SECONDS_IN_YEAR + | ||
parseFloat(month || 0) * SECONDS_IN_MONTH + | ||
parseFloat(day || 0) * SECONDS_IN_DAY + | ||
parseFloat(hour || 0) * SECONDS_IN_HOUR + | ||
parseFloat(minute || 0) * SECONDS_IN_MIN + | ||
parseFloat(second || 0)); | ||
return parseFloat(year || 0) * SECONDS_IN_YEAR + parseFloat(month || 0) * SECONDS_IN_MONTH + parseFloat(day || 0) * SECONDS_IN_DAY + parseFloat(hour || 0) * SECONDS_IN_HOUR + parseFloat(minute || 0) * SECONDS_IN_MIN + parseFloat(second || 0); | ||
}; | ||
const parseDate = (str) => { | ||
var parseDate = function parseDate(str) { | ||
// Date format without timezone according to ISO 8601 | ||
// YYY-MM-DDThh:mm:ss.ssssss | ||
const dateRegex = /^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/; | ||
var dateRegex = /^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/; | ||
@@ -1027,3 +1103,3 @@ // If the date string does not specifiy a timezone, we must specifiy UTC. This is | ||
// TODO: maybe order these in some way that makes it easy to find specific attributes | ||
const parsers = { | ||
var parsers = { | ||
/** | ||
@@ -1038,6 +1114,7 @@ * Specifies the duration of the entire Media Presentation. Format is a duration string | ||
*/ | ||
mediaPresentationDuration(value) { | ||
mediaPresentationDuration: function mediaPresentationDuration(value) { | ||
return parseDuration(value); | ||
}, | ||
/** | ||
@@ -1053,6 +1130,7 @@ * Specifies the Segment availability start time for all Segments referred to in this | ||
*/ | ||
availabilityStartTime(value) { | ||
availabilityStartTime: function availabilityStartTime(value) { | ||
return parseDate(value) / 1000; | ||
}, | ||
/** | ||
@@ -1067,6 +1145,7 @@ * Specifies the smallest period between potential changes to the MPD. Format is a | ||
*/ | ||
minimumUpdatePeriod(value) { | ||
minimumUpdatePeriod: function minimumUpdatePeriod(value) { | ||
return parseDuration(value); | ||
}, | ||
/** | ||
@@ -1081,6 +1160,7 @@ * Specifies the duration of the smallest time shifting buffer for any Representation | ||
*/ | ||
timeShiftBufferDepth(value) { | ||
timeShiftBufferDepth: function timeShiftBufferDepth(value) { | ||
return parseDuration(value); | ||
}, | ||
/** | ||
@@ -1095,6 +1175,7 @@ * Specifies the PeriodStart time of the Period relative to the availabilityStarttime. | ||
*/ | ||
start(value) { | ||
start: function start(value) { | ||
return parseDuration(value); | ||
}, | ||
/** | ||
@@ -1108,6 +1189,7 @@ * Specifies the width of the visual presentation | ||
*/ | ||
width(value) { | ||
width: function width(value) { | ||
return parseInt(value, 10); | ||
}, | ||
/** | ||
@@ -1121,6 +1203,7 @@ * Specifies the height of the visual presentation | ||
*/ | ||
height(value) { | ||
height: function height(value) { | ||
return parseInt(value, 10); | ||
}, | ||
/** | ||
@@ -1134,6 +1217,7 @@ * Specifies the bitrate of the representation | ||
*/ | ||
bandwidth(value) { | ||
bandwidth: function bandwidth(value) { | ||
return parseInt(value, 10); | ||
}, | ||
/** | ||
@@ -1147,6 +1231,7 @@ * Specifies the number of the first Media Segment in this Representation in the Period | ||
*/ | ||
startNumber(value) { | ||
startNumber: function startNumber(value) { | ||
return parseInt(value, 10); | ||
}, | ||
/** | ||
@@ -1160,6 +1245,7 @@ * Specifies the timescale in units per seconds | ||
*/ | ||
timescale(value) { | ||
timescale: function timescale(value) { | ||
return parseInt(value, 10); | ||
}, | ||
/** | ||
@@ -1177,4 +1263,4 @@ * Specifies the constant approximate Segment duration | ||
*/ | ||
duration(value) { | ||
const parsedValue = parseInt(value, 10); | ||
duration: function duration(value) { | ||
var parsedValue = parseInt(value, 10); | ||
@@ -1188,2 +1274,3 @@ if (isNaN(parsedValue)) { | ||
/** | ||
@@ -1197,6 +1284,7 @@ * Specifies the Segment duration, in units of the value of the @timescale. | ||
*/ | ||
d(value) { | ||
d: function d(value) { | ||
return parseInt(value, 10); | ||
}, | ||
/** | ||
@@ -1211,6 +1299,7 @@ * Specifies the MPD start time, in @timescale units, the first Segment in the series | ||
*/ | ||
t(value) { | ||
t: function t(value) { | ||
return parseInt(value, 10); | ||
}, | ||
/** | ||
@@ -1225,6 +1314,7 @@ * Specifies the repeat count of the number of following contiguous Segments with the | ||
*/ | ||
r(value) { | ||
r: function r(value) { | ||
return parseInt(value, 10); | ||
}, | ||
/** | ||
@@ -1239,3 +1329,3 @@ * Default parser for all other attributes. Acts as a no-op and just returns the value | ||
*/ | ||
DEFAULT(value) { | ||
DEFAULT: function DEFAULT(value) { | ||
return value; | ||
@@ -1254,3 +1344,3 @@ } | ||
*/ | ||
const parseAttributes = (el) => { | ||
var parseAttributes = function parseAttributes(el) { | ||
if (!(el && el.attributes)) { | ||
@@ -1260,17 +1350,16 @@ return {}; | ||
return from(el.attributes) | ||
.reduce((a, e) => { | ||
const parseFn = parsers[e.name] || parsers.DEFAULT; | ||
return from(el.attributes).reduce(function (a, e) { | ||
var parseFn = parsers[e.name] || parsers.DEFAULT; | ||
a[e.name] = parseFn(e.value); | ||
a[e.name] = parseFn(e.value); | ||
return a; | ||
}, {}); | ||
return a; | ||
}, {}); | ||
}; | ||
function decodeB64ToUint8Array(b64Text) { | ||
const decodedString = window.atob(b64Text); | ||
const array = new Uint8Array(decodedString.length); | ||
var decodedString = window.atob(b64Text); | ||
var array = new Uint8Array(decodedString.length); | ||
for (let i = 0; i < decodedString.length; i++) { | ||
for (var i = 0; i < decodedString.length; i++) { | ||
array[i] = decodedString.charCodeAt(i); | ||
@@ -1281,3 +1370,3 @@ } | ||
const keySystemsMap = { | ||
var keySystemsMap = { | ||
'urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b': 'org.w3.clearkey', | ||
@@ -1299,3 +1388,3 @@ 'urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed': 'com.widevine.alpha', | ||
*/ | ||
const buildBaseUrls = (referenceUrls, baseUrlElements) => { | ||
var buildBaseUrls = function buildBaseUrls(referenceUrls, baseUrlElements) { | ||
if (!baseUrlElements.length) { | ||
@@ -1305,6 +1394,7 @@ return referenceUrls; | ||
return flatten( | ||
referenceUrls.map( | ||
reference => baseUrlElements.map( | ||
baseUrlElement => resolveUrl(reference, getContent(baseUrlElement))))); | ||
return flatten(referenceUrls.map(function (reference) { | ||
return baseUrlElements.map(function (baseUrlElement) { | ||
return resolveUrl(reference, getContent(baseUrlElement)); | ||
}); | ||
})); | ||
}; | ||
@@ -1334,14 +1424,13 @@ | ||
*/ | ||
const getSegmentInformation = (adaptationSet) => { | ||
const segmentTemplate = findChildren(adaptationSet, 'SegmentTemplate')[0]; | ||
const segmentList = findChildren(adaptationSet, 'SegmentList')[0]; | ||
const segmentUrls = segmentList && findChildren(segmentList, 'SegmentURL') | ||
.map(s => merge({ tag: 'SegmentURL' }, parseAttributes(s))); | ||
const segmentBase = findChildren(adaptationSet, 'SegmentBase')[0]; | ||
const segmentTimelineParentNode = segmentList || segmentTemplate; | ||
const segmentTimeline = segmentTimelineParentNode && | ||
findChildren(segmentTimelineParentNode, 'SegmentTimeline')[0]; | ||
const segmentInitializationParentNode = segmentList || segmentBase || segmentTemplate; | ||
const segmentInitialization = segmentInitializationParentNode && | ||
findChildren(segmentInitializationParentNode, 'Initialization')[0]; | ||
var getSegmentInformation = function getSegmentInformation(adaptationSet) { | ||
var segmentTemplate = findChildren(adaptationSet, 'SegmentTemplate')[0]; | ||
var segmentList = findChildren(adaptationSet, 'SegmentList')[0]; | ||
var segmentUrls = segmentList && findChildren(segmentList, 'SegmentURL').map(function (s) { | ||
return merge({ tag: 'SegmentURL' }, parseAttributes(s)); | ||
}); | ||
var segmentBase = findChildren(adaptationSet, 'SegmentBase')[0]; | ||
var segmentTimelineParentNode = segmentList || segmentTemplate; | ||
var segmentTimeline = segmentTimelineParentNode && findChildren(segmentTimelineParentNode, 'SegmentTimeline')[0]; | ||
var segmentInitializationParentNode = segmentList || segmentBase || segmentTemplate; | ||
var segmentInitialization = segmentInitializationParentNode && findChildren(segmentInitializationParentNode, 'Initialization')[0]; | ||
@@ -1353,7 +1442,6 @@ // SegmentTemplate is handled slightly differently, since it can have both | ||
// the node, as this interaction is not defined in the spec. | ||
const template = segmentTemplate && parseAttributes(segmentTemplate); | ||
var template = segmentTemplate && parseAttributes(segmentTemplate); | ||
if (template && segmentInitialization) { | ||
template.initialization = | ||
(segmentInitialization && parseAttributes(segmentInitialization)); | ||
template.initialization = segmentInitialization && parseAttributes(segmentInitialization); | ||
} else if (template && template.initialization) { | ||
@@ -1366,19 +1454,17 @@ // If it is @initialization we convert it to an object since this is the format that | ||
const segmentInfo = { | ||
template, | ||
timeline: segmentTimeline && | ||
findChildren(segmentTimeline, 'S').map(s => parseAttributes(s)), | ||
list: segmentList && merge( | ||
parseAttributes(segmentList), | ||
{ | ||
segmentUrls, | ||
initialization: parseAttributes(segmentInitialization) | ||
}), | ||
base: segmentBase && merge( | ||
parseAttributes(segmentBase), { | ||
initialization: parseAttributes(segmentInitialization) | ||
}) | ||
var segmentInfo = { | ||
template: template, | ||
timeline: segmentTimeline && findChildren(segmentTimeline, 'S').map(function (s) { | ||
return parseAttributes(s); | ||
}), | ||
list: segmentList && merge(parseAttributes(segmentList), { | ||
segmentUrls: segmentUrls, | ||
initialization: parseAttributes(segmentInitialization) | ||
}), | ||
base: segmentBase && merge(parseAttributes(segmentBase), { | ||
initialization: parseAttributes(segmentInitialization) | ||
}) | ||
}; | ||
Object.keys(segmentInfo).forEach(key => { | ||
Object.keys(segmentInfo).forEach(function (key) { | ||
if (!segmentInfo[key]) { | ||
@@ -1427,16 +1513,16 @@ delete segmentInfo[key]; | ||
*/ | ||
const inheritBaseUrls = | ||
(adaptationSetAttributes, adaptationSetBaseUrls, adaptationSetSegmentInfo) => | ||
(representation) => { | ||
const repBaseUrlElements = findChildren(representation, 'BaseURL'); | ||
const repBaseUrls = buildBaseUrls(adaptationSetBaseUrls, repBaseUrlElements); | ||
const attributes = merge(adaptationSetAttributes, parseAttributes(representation)); | ||
const representationSegmentInfo = getSegmentInformation(representation); | ||
var inheritBaseUrls = function inheritBaseUrls(adaptationSetAttributes, adaptationSetBaseUrls, adaptationSetSegmentInfo) { | ||
return function (representation) { | ||
var repBaseUrlElements = findChildren(representation, 'BaseURL'); | ||
var repBaseUrls = buildBaseUrls(adaptationSetBaseUrls, repBaseUrlElements); | ||
var attributes = merge(adaptationSetAttributes, parseAttributes(representation)); | ||
var representationSegmentInfo = getSegmentInformation(representation); | ||
return repBaseUrls.map(baseUrl => { | ||
return { | ||
segmentInfo: merge(adaptationSetSegmentInfo, representationSegmentInfo), | ||
attributes: merge(attributes, { baseUrl }) | ||
}; | ||
}); | ||
return repBaseUrls.map(function (baseUrl) { | ||
return { | ||
segmentInfo: merge(adaptationSetSegmentInfo, representationSegmentInfo), | ||
attributes: merge(attributes, { baseUrl: baseUrl }) | ||
}; | ||
}); | ||
}; | ||
}; | ||
@@ -1453,15 +1539,15 @@ | ||
*/ | ||
const generateKeySystemInformation = (contentProtectionNodes) => { | ||
return contentProtectionNodes.reduce((acc, node) => { | ||
const attributes = parseAttributes(node); | ||
const keySystem = keySystemsMap[attributes.schemeIdUri]; | ||
var generateKeySystemInformation = function generateKeySystemInformation(contentProtectionNodes) { | ||
return contentProtectionNodes.reduce(function (acc, node) { | ||
var attributes = parseAttributes(node); | ||
var keySystem = keySystemsMap[attributes.schemeIdUri]; | ||
if (keySystem) { | ||
acc[keySystem] = { attributes }; | ||
acc[keySystem] = { attributes: attributes }; | ||
const psshNode = findChildren(node, 'cenc:pssh')[0]; | ||
var psshNode = findChildren(node, 'cenc:pssh')[0]; | ||
if (psshNode) { | ||
const pssh = getContent(psshNode); | ||
const psshBuffer = pssh && decodeB64ToUint8Array(pssh); | ||
var pssh = getContent(psshNode); | ||
var psshBuffer = pssh && decodeB64ToUint8Array(pssh); | ||
@@ -1500,27 +1586,23 @@ acc[keySystem].pssh = psshBuffer; | ||
*/ | ||
const toRepresentations = | ||
(periodAttributes, periodBaseUrls, periodSegmentInfo) => (adaptationSet) => { | ||
const adaptationSetAttributes = parseAttributes(adaptationSet); | ||
const adaptationSetBaseUrls = buildBaseUrls(periodBaseUrls, | ||
findChildren(adaptationSet, 'BaseURL')); | ||
const role = findChildren(adaptationSet, 'Role')[0]; | ||
const roleAttributes = { role: parseAttributes(role) }; | ||
var toRepresentations = function toRepresentations(periodAttributes, periodBaseUrls, periodSegmentInfo) { | ||
return function (adaptationSet) { | ||
var adaptationSetAttributes = parseAttributes(adaptationSet); | ||
var adaptationSetBaseUrls = buildBaseUrls(periodBaseUrls, findChildren(adaptationSet, 'BaseURL')); | ||
var role = findChildren(adaptationSet, 'Role')[0]; | ||
var roleAttributes = { role: parseAttributes(role) }; | ||
let attrs = merge(periodAttributes, | ||
adaptationSetAttributes, | ||
roleAttributes); | ||
var attrs = merge(periodAttributes, adaptationSetAttributes, roleAttributes); | ||
const contentProtection = generateKeySystemInformation( | ||
findChildren(adaptationSet, 'ContentProtection')); | ||
var contentProtection = generateKeySystemInformation(findChildren(adaptationSet, 'ContentProtection')); | ||
if (Object.keys(contentProtection).length) { | ||
attrs = merge(attrs, { contentProtection }); | ||
} | ||
if (Object.keys(contentProtection).length) { | ||
attrs = merge(attrs, { contentProtection: contentProtection }); | ||
} | ||
const segmentInfo = getSegmentInformation(adaptationSet); | ||
const representations = findChildren(adaptationSet, 'Representation'); | ||
const adaptationSetSegmentInfo = merge(periodSegmentInfo, segmentInfo); | ||
var segmentInfo = getSegmentInformation(adaptationSet); | ||
var representations = findChildren(adaptationSet, 'Representation'); | ||
var adaptationSetSegmentInfo = merge(periodSegmentInfo, segmentInfo); | ||
return flatten(representations.map( | ||
inheritBaseUrls(attrs, adaptationSetBaseUrls, adaptationSetSegmentInfo))); | ||
return flatten(representations.map(inheritBaseUrls(attrs, adaptationSetBaseUrls, adaptationSetSegmentInfo))); | ||
}; | ||
}; | ||
@@ -1553,11 +1635,12 @@ | ||
*/ | ||
const toAdaptationSets = (mpdAttributes, mpdBaseUrls) => (period, periodIndex) => { | ||
const periodBaseUrls = buildBaseUrls(mpdBaseUrls, findChildren(period, 'BaseURL')); | ||
const periodAtt = parseAttributes(period); | ||
const periodAttributes = merge(mpdAttributes, periodAtt, { periodIndex }); | ||
const adaptationSets = findChildren(period, 'AdaptationSet'); | ||
const periodSegmentInfo = getSegmentInformation(period); | ||
var toAdaptationSets = function toAdaptationSets(mpdAttributes, mpdBaseUrls) { | ||
return function (period, periodIndex) { | ||
var periodBaseUrls = buildBaseUrls(mpdBaseUrls, findChildren(period, 'BaseURL')); | ||
var periodAtt = parseAttributes(period); | ||
var periodAttributes = merge(mpdAttributes, periodAtt, { periodIndex: periodIndex }); | ||
var adaptationSets = findChildren(period, 'AdaptationSet'); | ||
var periodSegmentInfo = getSegmentInformation(period); | ||
return flatten(adaptationSets.map( | ||
toRepresentations(periodAttributes, periodBaseUrls, periodSegmentInfo))); | ||
return flatten(adaptationSets.map(toRepresentations(periodAttributes, periodBaseUrls, periodSegmentInfo))); | ||
}; | ||
}; | ||
@@ -1582,10 +1665,13 @@ | ||
*/ | ||
const inheritAttributes = (mpd, options = {}) => { | ||
const { | ||
manifestUri = '', | ||
NOW = Date.now(), | ||
clientOffset = 0 | ||
} = options; | ||
const periods = findChildren(mpd, 'Period'); | ||
var inheritAttributes = function inheritAttributes(mpd) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var _options$manifestUri = options.manifestUri, | ||
manifestUri = _options$manifestUri === undefined ? '' : _options$manifestUri, | ||
_options$NOW = options.NOW, | ||
NOW = _options$NOW === undefined ? Date.now() : _options$NOW, | ||
_options$clientOffset = options.clientOffset, | ||
clientOffset = _options$clientOffset === undefined ? 0 : _options$clientOffset; | ||
var periods = findChildren(mpd, 'Period'); | ||
if (periods.length !== 1) { | ||
@@ -1596,4 +1682,4 @@ // TODO add support for multiperiod | ||
const mpdAttributes = parseAttributes(mpd); | ||
const mpdBaseUrls = buildBaseUrls([ manifestUri ], findChildren(mpd, 'BaseURL')); | ||
var mpdAttributes = parseAttributes(mpd); | ||
var mpdBaseUrls = buildBaseUrls([manifestUri], findChildren(mpd, 'BaseURL')); | ||
@@ -1607,3 +1693,3 @@ mpdAttributes.sourceDuration = mpdAttributes.mediaPresentationDuration || 0; | ||
const stringToMpdXml = (manifestString) => { | ||
var stringToMpdXml = function stringToMpdXml(manifestString) { | ||
if (manifestString === '') { | ||
@@ -1613,9 +1699,7 @@ throw new Error(errors.DASH_EMPTY_MANIFEST); | ||
const parser = new window.DOMParser(); | ||
const xml = parser.parseFromString(manifestString, 'application/xml'); | ||
const mpd = xml && xml.documentElement.tagName === 'MPD' ? | ||
xml.documentElement : null; | ||
var parser = new window.DOMParser(); | ||
var xml = parser.parseFromString(manifestString, 'application/xml'); | ||
var mpd = xml && xml.documentElement.tagName === 'MPD' ? xml.documentElement : null; | ||
if (!mpd || mpd && | ||
mpd.getElementsByTagName('parsererror').length > 0) { | ||
if (!mpd || mpd && mpd.getElementsByTagName('parsererror').length > 0) { | ||
throw new Error(errors.DASH_INVALID_XML); | ||
@@ -1635,4 +1719,4 @@ } | ||
*/ | ||
const parseUTCTimingScheme = (mpd) => { | ||
const UTCTimingNode = findChildren(mpd, 'UTCTiming')[0]; | ||
var parseUTCTimingScheme = function parseUTCTimingScheme(mpd) { | ||
var UTCTimingNode = findChildren(mpd, 'UTCTiming')[0]; | ||
@@ -1643,25 +1727,25 @@ if (!UTCTimingNode) { | ||
const attributes = parseAttributes(UTCTimingNode); | ||
var attributes = parseAttributes(UTCTimingNode); | ||
switch (attributes.schemeIdUri) { | ||
case 'urn:mpeg:dash:utc:http-head:2014': | ||
case 'urn:mpeg:dash:utc:http-head:2012': | ||
attributes.method = 'HEAD'; | ||
break; | ||
case 'urn:mpeg:dash:utc:http-xsdate:2014': | ||
case 'urn:mpeg:dash:utc:http-iso:2014': | ||
case 'urn:mpeg:dash:utc:http-xsdate:2012': | ||
case 'urn:mpeg:dash:utc:http-iso:2012': | ||
attributes.method = 'GET'; | ||
break; | ||
case 'urn:mpeg:dash:utc:direct:2014': | ||
case 'urn:mpeg:dash:utc:direct:2012': | ||
attributes.method = 'DIRECT'; | ||
attributes.value = Date.parse(attributes.value); | ||
break; | ||
case 'urn:mpeg:dash:utc:http-ntp:2014': | ||
case 'urn:mpeg:dash:utc:ntp:2014': | ||
case 'urn:mpeg:dash:utc:sntp:2014': | ||
default: | ||
throw new Error(errors.UNSUPPORTED_UTC_TIMING_SCHEME); | ||
case 'urn:mpeg:dash:utc:http-head:2014': | ||
case 'urn:mpeg:dash:utc:http-head:2012': | ||
attributes.method = 'HEAD'; | ||
break; | ||
case 'urn:mpeg:dash:utc:http-xsdate:2014': | ||
case 'urn:mpeg:dash:utc:http-iso:2014': | ||
case 'urn:mpeg:dash:utc:http-xsdate:2012': | ||
case 'urn:mpeg:dash:utc:http-iso:2012': | ||
attributes.method = 'GET'; | ||
break; | ||
case 'urn:mpeg:dash:utc:direct:2014': | ||
case 'urn:mpeg:dash:utc:direct:2012': | ||
attributes.method = 'DIRECT'; | ||
attributes.value = Date.parse(attributes.value); | ||
break; | ||
case 'urn:mpeg:dash:utc:http-ntp:2014': | ||
case 'urn:mpeg:dash:utc:ntp:2014': | ||
case 'urn:mpeg:dash:utc:sntp:2014': | ||
default: | ||
throw new Error(errors.UNSUPPORTED_UTC_TIMING_SCHEME); | ||
} | ||
@@ -1672,6 +1756,7 @@ | ||
const VERSION = version; | ||
var VERSION = version; | ||
const parse = (manifestString, options) => | ||
toM3u8(toPlaylists(inheritAttributes(stringToMpdXml(manifestString), options))); | ||
var parse = function parse(manifestString, options) { | ||
return toM3u8(toPlaylists(inheritAttributes(stringToMpdXml(manifestString), options))); | ||
}; | ||
@@ -1686,5 +1771,6 @@ /** | ||
*/ | ||
const parseUTCTiming = (manifestString) => | ||
parseUTCTimingScheme(stringToMpdXml(manifestString)); | ||
var parseUTCTiming = function parseUTCTiming(manifestString) { | ||
return parseUTCTimingScheme(stringToMpdXml(manifestString)); | ||
}; | ||
export { VERSION, parse, parseUTCTiming }; |
/** | ||
* mpd-parser | ||
* @version 0.6.0 | ||
* @version 0.6.1 | ||
* @copyright 2018 Brightcove, Inc | ||
@@ -13,3 +13,3 @@ * @license Apache-2.0 | ||
var version = "0.6.0"; | ||
var version = "0.6.1"; | ||
@@ -16,0 +16,0 @@ var formatAudioPlaylist = function formatAudioPlaylist(_ref) { |
/** | ||
* mpd-parser | ||
* @version 0.6.0 | ||
* @version 0.6.1 | ||
* @copyright 2018 Brightcove, Inc | ||
* @license Apache-2.0 | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.mpdParser={})}(this,function(t){"use strict";var e=function(t){var e,r=t.attributes,n=t.segments,i={attributes:(e={NAME:r.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:r.width,height:r.height},CODECS:r.codecs,BANDWIDTH:r.bandwidth},e["PROGRAM-ID"]=1,e),uri:"",endList:"static"===(r.type||"static"),timeline:r.periodIndex,resolvedUri:"",targetDuration:r.duration,segments:n,mediaSequence:n.length?n[0].number:1};return r.contentProtection&&(i.contentProtection=r.contentProtection),i},r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n=function(t){return!!t&&"object"===(void 0===t?"undefined":r(t))},i=function t(){for(var e=arguments.length,r=Array(e),i=0;i<e;i++)r[i]=arguments[i];return r.reduce(function(e,r){return Object.keys(r).forEach(function(i){Array.isArray(e[i])&&Array.isArray(r[i])?e[i]=e[i].concat(r[i]):n(e[i])&&n(r[i])?e[i]=t(e[i],r[i]):e[i]=r[i]}),e},{})},a="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},u=function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t,e){!function(e){var r=/^((?:[^\/;?#]+:)?)(\/\/[^\/\;?#]*)?(.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,n=/^([^\/;?#]*)(.*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,u={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var i=this.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");return i.path=u.normalizePath(i.path),u.buildURLFromParts(i)}var a=this.parseURL(e);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=u.normalizePath(a.path),u.buildURLFromParts(a)):e;var o=this.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var s=n.exec(o.path);o.netLoc=s[1],o.path=s[2]}o.netLoc&&!o.path&&(o.path="/");var c={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(c.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var d=o.path,l=d.substring(0,d.lastIndexOf("/")+1)+a.path;c.path=u.normalizePath(l)}else c.path=o.path,a.params||(c.params=o.params,a.query||(c.query=o.query));return null===c.path&&(c.path=r.alwaysNormalize?u.normalizePath(a.path):a.path),u.buildURLFromParts(c)},parseURL:function(t){var e=r.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(i,"");t.length!==(t=t.replace(a,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}};t.exports=u}()}),o="undefined"!=typeof window?window:void 0!==a?a:"undefined"!=typeof self?self:{},s=function(t,e){return/^[a-z]+:/i.test(e)?e:(/\/\//i.test(t)||(t=u.buildAbsoluteURL(o.location.href,t)),u.buildAbsoluteURL(t,e))},c=function(t){var e=t.baseUrl,r=void 0===e?"":e,n=t.source,i=void 0===n?"":n,a=t.range,u=void 0===a?"":a,o={uri:i,resolvedUri:s(r||"",i)};if(u){var c=u.split("-"),d=parseInt(c[0],10),l=parseInt(c[1],10);o.byterange={length:l-d,offset:d}}return o},d=function(t,e,r){var n=t.NOW,i=t.clientOffset,a=t.availabilityStartTime,u=t.timescale,o=void 0===u?1:u,s=t.start,c=void 0===s?0:s,d=t.minimumUpdatePeriod,l=(n+i)/1e3+(void 0===d?0:d)-(a+c);return Math.ceil((l*o-e)/r)},l=function(t,e){for(var r=t.type,n=void 0===r?"static":r,i=t.minimumUpdatePeriod,a=void 0===i?0:i,u=t.media,o=void 0===u?"":u,s=t.sourceDuration,c=t.timescale,l=void 0===c?1:c,m=t.startNumber,f=void 0===m?1:m,p=t.periodIndex,h=[],v=-1,b=0;b<e.length;b++){var g=e[b],U=g.d,y=g.r||0,I=g.t||0;v<0&&(v=I),I&&I>v&&(v=I);var D=void 0;if(y<0){var L=b+1;D=L===e.length?"dynamic"===n&&a>0&&o.indexOf("$Number$")>0?d(t,v,U):(s*l-v)/U:(e[L].t-v)/U}else D=y+1;for(var w=f+h.length+D,E=f+h.length;E<w;)h.push({number:E,duration:U/l,time:v,timeline:p}),v+=U,E++}return h},m=function(t){return t.reduce(function(t,e){return t.concat(e)},[])},f=function(t){if(!t.length)return[];for(var e=[],r=0;r<t.length;r++)e.push(t[r]);return e},p={static:function(t){var e=t.duration,r=t.timescale,n=void 0===r?1:r,i=t.sourceDuration;return{start:0,end:Math.ceil(i/(e/n))}},dynamic:function(t){var e=t.NOW,r=t.clientOffset,n=t.availabilityStartTime,i=t.timescale,a=void 0===i?1:i,u=t.duration,o=t.start,s=void 0===o?0:o,c=t.minimumUpdatePeriod,d=void 0===c?0:c,l=t.timeShiftBufferDepth,m=void 0===l?1/0:l,f=(e+r)/1e3,p=n+s,h=f+d-p,v=Math.ceil(h*a/u),b=Math.floor((f-p-m)*a/u),g=Math.floor((f-p)*a/u);return{start:Math.max(0,b),end:Math.min(v,g)}}},h=function(t){var e=t.type,r=void 0===e?"static":e,n=t.duration,i=t.timescale,a=void 0===i?1:i,u=t.sourceDuration,o=p[r](t),s=function(t,e){for(var r=[],n=t;n<e;n++)r.push(n);return r}(o.start,o.end).map(function(t){return function(e,r){var n=t.duration,i=t.timescale,a=void 0===i?1:i,u=t.periodIndex,o=t.startNumber;return{number:(void 0===o?1:o)+e,duration:n/a,timeline:u,time:r*n}}}(t));if("static"===r){var c=s.length-1;s[c].duration=u-n/a*c}return s},v=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,b=function(t,e){return t.replace(v,function(t){return function(e,r,n,i){if("$$"===e)return"$";if(void 0===t[r])return e;var a=""+t[r];return"RepresentationID"===r?a:(i=n?parseInt(i,10):1,a.length>=i?a:""+new Array(i-a.length+1).join("0")+a)}}(e))},g=function(t,e){var r={RepresentationID:t.id,Bandwidth:t.bandwidth||0},n=t.initialization,i=void 0===n?{sourceURL:"",range:""}:n,a=c({baseUrl:t.baseUrl,source:b(i.sourceURL,r),range:i.range});return function(t,e){return t.duration||e?t.duration?h(t):l(t,e):[{number:t.startNumber||1,duration:t.sourceDuration,time:0,timeline:t.periodIndex}]}(t,e).map(function(e){r.Number=e.number,r.Time=e.time;var n=b(t.media||"",r);return{uri:n,timeline:e.timeline,duration:e.duration,resolvedUri:s(t.baseUrl||"",n),map:a,number:e.number}})},U="INVALID_NUMBER_OF_PERIOD",y="DASH_EMPTY_MANIFEST",I="DASH_INVALID_XML",D="NO_BASE_URL",L="SEGMENT_TIME_UNSPECIFIED",w="UNSUPPORTED_UTC_TIMING_SCHEME",E=function(t,e){var r=t.duration,n=t.segmentUrls,i=void 0===n?[]:n;if(!r&&!e||r&&e)throw new Error(L);var a=i.map(function(e){return function(t,e){var r=t.baseUrl,n=t.initialization,i=void 0===n?{}:n,a=c({baseUrl:r,source:i.sourceURL,range:i.range}),u=c({baseUrl:r,source:e.media,range:e.mediaRange});return u.map=a,u}(t,e)}),u=void 0;r&&(u=h(t)),e&&(u=l(t,e));return u.map(function(t,e){if(a[e]){var r=a[e];return r.timeline=t.timeline,r.duration=t.duration,r.number=t.number,r}}).filter(function(t){return t})},R=function(t){var e=t.baseUrl,r=t.initialization,n=void 0===r?{}:r,i=t.sourceDuration,a=t.timescale,u=void 0===a?1:a,o=t.indexRange,s=void 0===o?"":o,d=t.duration;if(!e)throw new Error(D);var l=c({baseUrl:e,source:n.sourceURL,range:n.range}),m=c({baseUrl:e,source:e,range:s});if(m.map=l,d){var f=h(t);f.length&&(m.duration=f[0].duration,m.timeline=f[0].timeline)}else i&&(m.duration=i/u,m.timeline=0);return m.number=0,[m]},S=function(t){var e=t.attributes,r=t.segmentInfo,n=void 0,a=void 0;if(r.template?(a=g,n=i(e,r.template)):r.base?(a=R,n=i(e,r.base)):r.list&&(a=E,n=i(e,r.list)),!a)return{attributes:e};var u=a(n,r.timeline);if(n.duration){var o=n,s=o.duration,c=o.timescale,d=void 0===c?1:c;n.duration=s/d}else u.length?n.duration=u.reduce(function(t,e){return Math.max(t,Math.ceil(e.duration))},0):n.duration=0;return{attributes:n,segments:u}},T=function(t,e){return f(t.childNodes).filter(function(t){return t.tagName===e})},P=function(t){return t.textContent.trim()},N=function(t){var e=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(t);if(!e)return 0;var r=e.slice(1),n=r[0],i=r[1],a=r[2],u=r[3],o=r[4],s=r[5];return 31536e3*parseFloat(n||0)+2592e3*parseFloat(i||0)+86400*parseFloat(a||0)+3600*parseFloat(u||0)+60*parseFloat(o||0)+parseFloat(s||0)},A={mediaPresentationDuration:function(t){return N(t)},availabilityStartTime:function(t){return function(t){return/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(t)&&(t+="Z"),Date.parse(t)}(t)/1e3},minimumUpdatePeriod:function(t){return N(t)},timeShiftBufferDepth:function(t){return N(t)},start:function(t){return N(t)},width:function(t){return parseInt(t,10)},height:function(t){return parseInt(t,10)},bandwidth:function(t){return parseInt(t,10)},startNumber:function(t){return parseInt(t,10)},timescale:function(t){return parseInt(t,10)},duration:function(t){var e=parseInt(t,10);return isNaN(e)?N(t):e},d:function(t){return parseInt(t,10)},t:function(t){return parseInt(t,10)},r:function(t){return parseInt(t,10)},DEFAULT:function(t){return t}},O=function(t){return t&&t.attributes?f(t.attributes).reduce(function(t,e){var r=A[e.name]||A.DEFAULT;return t[e.name]=r(e.value),t},{}):{}},x={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime"},M=function(t,e){return e.length?m(t.map(function(t){return e.map(function(e){return s(t,P(e))})})):t},z=function(t){var e=T(t,"SegmentTemplate")[0],r=T(t,"SegmentList")[0],n=r&&T(r,"SegmentURL").map(function(t){return i({tag:"SegmentURL"},O(t))}),a=T(t,"SegmentBase")[0],u=r||e,o=u&&T(u,"SegmentTimeline")[0],s=r||a||e,c=s&&T(s,"Initialization")[0],d=e&&O(e);d&&c?d.initialization=c&&O(c):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});var l={template:d,timeline:o&&T(o,"S").map(function(t){return O(t)}),list:r&&i(O(r),{segmentUrls:n,initialization:O(c)}),base:a&&i(O(a),{initialization:O(c)})};return Object.keys(l).forEach(function(t){l[t]||delete l[t]}),l},B=function(t){return t.reduce(function(t,e){var r=O(e),n=x[r.schemeIdUri];if(n){t[n]={attributes:r};var i=T(e,"cenc:pssh")[0];if(i){var a=P(i),u=a&&function(t){for(var e=o.atob(t),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}(a);t[n].pssh=u}}return t},{})},C=function(t,e,r){return function(n){var a=O(n),u=M(e,T(n,"BaseURL")),o=T(n,"Role")[0],s={role:O(o)},c=i(t,a,s),d=B(T(n,"ContentProtection"));Object.keys(d).length&&(c=i(c,{contentProtection:d}));var l=z(n),f=T(n,"Representation"),p=i(r,l);return m(f.map(function(t,e,r){return function(n){var a=T(n,"BaseURL"),u=M(e,a),o=i(t,O(n)),s=z(n);return u.map(function(t){return{segmentInfo:i(r,s),attributes:i(o,{baseUrl:t})}})}}(c,u,p)))}},F=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.manifestUri,n=void 0===r?"":r,a=e.NOW,u=void 0===a?Date.now():a,o=e.clientOffset,s=void 0===o?0:o,c=T(t,"Period");if(1!==c.length)throw new Error(U);var d=O(t),l=M([n],T(t,"BaseURL"));return d.sourceDuration=d.mediaPresentationDuration||0,d.NOW=u,d.clientOffset=s,m(c.map(function(t,e){return function(r,n){var a=M(e,T(r,"BaseURL")),u=O(r),o=i(t,u,{periodIndex:n}),s=T(r,"AdaptationSet"),c=z(r);return m(s.map(C(o,a,c)))}}(d,l)))},_=function(t){if(""===t)throw new Error(y);var e=(new o.DOMParser).parseFromString(t,"application/xml"),r=e&&"MPD"===e.documentElement.tagName?e.documentElement:null;if(!r||r&&r.getElementsByTagName("parsererror").length>0)throw new Error(I);return r};t.VERSION="0.6.0",t.parse=function(t,r){return function(t){var r;if(!t.length)return{};var n=t[0].attributes,i=n.sourceDuration,a=n.minimumUpdatePeriod,u=void 0===a?0:a,o=t.filter(function(t){var e=t.attributes;return"video/mp4"===e.mimeType||"video"===e.contentType}).map(e),s=t.filter(function(t){var e=t.attributes;return"audio/mp4"===e.mimeType||"audio"===e.contentType}),c=t.filter(function(t){var e=t.attributes;return"text/vtt"===e.mimeType||"text"===e.contentType}),d={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:(r={AUDIO:{},VIDEO:{}},r["CLOSED-CAPTIONS"]={},r.SUBTITLES={},r),uri:"",duration:i,playlists:o,minimumUpdatePeriod:1e3*u};return s.length&&(d.mediaGroups.AUDIO.audio=function(t){return t.reduce(function(t,e){var r=e.attributes.role&&e.attributes.role.value||"main",n=e.attributes.lang||"",i="main";return n&&(i=e.attributes.lang+" ("+r+")"),t[i]&&t[i].playlists[0].attributes.BANDWIDTH>e.attributes.bandwidth?t:(t[i]={language:n,autoselect:!0,default:"main"===r,playlists:[function(t){var e,r=t.attributes,n=t.segments,i={attributes:(e={NAME:r.id,BANDWIDTH:r.bandwidth,CODECS:r.codecs},e["PROGRAM-ID"]=1,e),uri:"",endList:"static"===(r.type||"static"),timeline:r.periodIndex,resolvedUri:"",targetDuration:r.duration,segments:n,mediaSequence:n.length?n[0].number:1};return r.contentProtection&&(i.contentProtection=r.contentProtection),i}(e)],uri:""},t)},{})}(s)),c.length&&(d.mediaGroups.SUBTITLES.subs=function(t){return t.reduce(function(t,e){var r=e.attributes.lang||"text";return t[r]?t:(t[r]={language:r,default:!1,autoselect:!1,playlists:[function(t){var e,r=t.attributes,n=t.segments;return void 0===n&&(n=[{uri:r.baseUrl,timeline:r.periodIndex,resolvedUri:r.baseUrl||"",duration:r.sourceDuration,number:0}],r.duration=r.sourceDuration),{attributes:(e={NAME:r.id,BANDWIDTH:r.bandwidth},e["PROGRAM-ID"]=1,e),uri:"",endList:"static"===(r.type||"static"),timeline:r.periodIndex,resolvedUri:r.baseUrl||"",targetDuration:r.duration,segments:n,mediaSequence:n.length?n[0].number:1}}(e)],uri:""},t)},{})}(c)),d}(function(t){return t.map(S)}(F(_(t),r)))},t.parseUTCTiming=function(t){return function(t){var e=T(t,"UTCTiming")[0];if(!e)return null;var r=O(e);switch(r.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":r.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":r.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":r.method="DIRECT",r.value=Date.parse(r.value);break;case"urn:mpeg:dash:utc:http-ntp:2014":case"urn:mpeg:dash:utc:ntp:2014":case"urn:mpeg:dash:utc:sntp:2014":default:throw new Error(w)}return r}(_(t))}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.mpdParser={})}(this,function(t){"use strict";var e=function(t){var e,r=t.attributes,n=t.segments,i={attributes:(e={NAME:r.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:r.width,height:r.height},CODECS:r.codecs,BANDWIDTH:r.bandwidth},e["PROGRAM-ID"]=1,e),uri:"",endList:"static"===(r.type||"static"),timeline:r.periodIndex,resolvedUri:"",targetDuration:r.duration,segments:n,mediaSequence:n.length?n[0].number:1};return r.contentProtection&&(i.contentProtection=r.contentProtection),i},r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n=function(t){return!!t&&"object"===(void 0===t?"undefined":r(t))},i=function t(){for(var e=arguments.length,r=Array(e),i=0;i<e;i++)r[i]=arguments[i];return r.reduce(function(e,r){return Object.keys(r).forEach(function(i){Array.isArray(e[i])&&Array.isArray(r[i])?e[i]=e[i].concat(r[i]):n(e[i])&&n(r[i])?e[i]=t(e[i],r[i]):e[i]=r[i]}),e},{})},a="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},u=function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t,e){!function(e){var r=/^((?:[^\/;?#]+:)?)(\/\/[^\/\;?#]*)?(.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,n=/^([^\/;?#]*)(.*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,u={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var i=this.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");return i.path=u.normalizePath(i.path),u.buildURLFromParts(i)}var a=this.parseURL(e);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=u.normalizePath(a.path),u.buildURLFromParts(a)):e;var o=this.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var s=n.exec(o.path);o.netLoc=s[1],o.path=s[2]}o.netLoc&&!o.path&&(o.path="/");var c={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(c.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var d=o.path,l=d.substring(0,d.lastIndexOf("/")+1)+a.path;c.path=u.normalizePath(l)}else c.path=o.path,a.params||(c.params=o.params,a.query||(c.query=o.query));return null===c.path&&(c.path=r.alwaysNormalize?u.normalizePath(a.path):a.path),u.buildURLFromParts(c)},parseURL:function(t){var e=r.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(i,"");t.length!==(t=t.replace(a,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}};t.exports=u}()}),o="undefined"!=typeof window?window:void 0!==a?a:"undefined"!=typeof self?self:{},s=function(t,e){return/^[a-z]+:/i.test(e)?e:(/\/\//i.test(t)||(t=u.buildAbsoluteURL(o.location.href,t)),u.buildAbsoluteURL(t,e))},c=function(t){var e=t.baseUrl,r=void 0===e?"":e,n=t.source,i=void 0===n?"":n,a=t.range,u=void 0===a?"":a,o={uri:i,resolvedUri:s(r||"",i)};if(u){var c=u.split("-"),d=parseInt(c[0],10),l=parseInt(c[1],10);o.byterange={length:l-d,offset:d}}return o},d=function(t,e,r){var n=t.NOW,i=t.clientOffset,a=t.availabilityStartTime,u=t.timescale,o=void 0===u?1:u,s=t.start,c=void 0===s?0:s,d=t.minimumUpdatePeriod,l=(n+i)/1e3+(void 0===d?0:d)-(a+c);return Math.ceil((l*o-e)/r)},l=function(t,e){for(var r=t.type,n=void 0===r?"static":r,i=t.minimumUpdatePeriod,a=void 0===i?0:i,u=t.media,o=void 0===u?"":u,s=t.sourceDuration,c=t.timescale,l=void 0===c?1:c,m=t.startNumber,f=void 0===m?1:m,p=t.periodIndex,h=[],v=-1,b=0;b<e.length;b++){var g=e[b],U=g.d,y=g.r||0,I=g.t||0;v<0&&(v=I),I&&I>v&&(v=I);var D=void 0;if(y<0){var L=b+1;D=L===e.length?"dynamic"===n&&a>0&&o.indexOf("$Number$")>0?d(t,v,U):(s*l-v)/U:(e[L].t-v)/U}else D=y+1;for(var w=f+h.length+D,E=f+h.length;E<w;)h.push({number:E,duration:U/l,time:v,timeline:p}),v+=U,E++}return h},m=function(t){return t.reduce(function(t,e){return t.concat(e)},[])},f=function(t){if(!t.length)return[];for(var e=[],r=0;r<t.length;r++)e.push(t[r]);return e},p={static:function(t){var e=t.duration,r=t.timescale,n=void 0===r?1:r,i=t.sourceDuration;return{start:0,end:Math.ceil(i/(e/n))}},dynamic:function(t){var e=t.NOW,r=t.clientOffset,n=t.availabilityStartTime,i=t.timescale,a=void 0===i?1:i,u=t.duration,o=t.start,s=void 0===o?0:o,c=t.minimumUpdatePeriod,d=void 0===c?0:c,l=t.timeShiftBufferDepth,m=void 0===l?1/0:l,f=(e+r)/1e3,p=n+s,h=f+d-p,v=Math.ceil(h*a/u),b=Math.floor((f-p-m)*a/u),g=Math.floor((f-p)*a/u);return{start:Math.max(0,b),end:Math.min(v,g)}}},h=function(t){var e=t.type,r=void 0===e?"static":e,n=t.duration,i=t.timescale,a=void 0===i?1:i,u=t.sourceDuration,o=p[r](t),s=function(t,e){for(var r=[],n=t;n<e;n++)r.push(n);return r}(o.start,o.end).map(function(t){return function(e,r){var n=t.duration,i=t.timescale,a=void 0===i?1:i,u=t.periodIndex,o=t.startNumber;return{number:(void 0===o?1:o)+e,duration:n/a,timeline:u,time:r*n}}}(t));if("static"===r){var c=s.length-1;s[c].duration=u-n/a*c}return s},v=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,b=function(t,e){return t.replace(v,function(t){return function(e,r,n,i){if("$$"===e)return"$";if(void 0===t[r])return e;var a=""+t[r];return"RepresentationID"===r?a:(i=n?parseInt(i,10):1,a.length>=i?a:""+new Array(i-a.length+1).join("0")+a)}}(e))},g=function(t,e){var r={RepresentationID:t.id,Bandwidth:t.bandwidth||0},n=t.initialization,i=void 0===n?{sourceURL:"",range:""}:n,a=c({baseUrl:t.baseUrl,source:b(i.sourceURL,r),range:i.range});return function(t,e){return t.duration||e?t.duration?h(t):l(t,e):[{number:t.startNumber||1,duration:t.sourceDuration,time:0,timeline:t.periodIndex}]}(t,e).map(function(e){r.Number=e.number,r.Time=e.time;var n=b(t.media||"",r);return{uri:n,timeline:e.timeline,duration:e.duration,resolvedUri:s(t.baseUrl||"",n),map:a,number:e.number}})},U="INVALID_NUMBER_OF_PERIOD",y="DASH_EMPTY_MANIFEST",I="DASH_INVALID_XML",D="NO_BASE_URL",L="SEGMENT_TIME_UNSPECIFIED",w="UNSUPPORTED_UTC_TIMING_SCHEME",E=function(t,e){var r=t.duration,n=t.segmentUrls,i=void 0===n?[]:n;if(!r&&!e||r&&e)throw new Error(L);var a=i.map(function(e){return function(t,e){var r=t.baseUrl,n=t.initialization,i=void 0===n?{}:n,a=c({baseUrl:r,source:i.sourceURL,range:i.range}),u=c({baseUrl:r,source:e.media,range:e.mediaRange});return u.map=a,u}(t,e)}),u=void 0;r&&(u=h(t)),e&&(u=l(t,e));return u.map(function(t,e){if(a[e]){var r=a[e];return r.timeline=t.timeline,r.duration=t.duration,r.number=t.number,r}}).filter(function(t){return t})},R=function(t){var e=t.baseUrl,r=t.initialization,n=void 0===r?{}:r,i=t.sourceDuration,a=t.timescale,u=void 0===a?1:a,o=t.indexRange,s=void 0===o?"":o,d=t.duration;if(!e)throw new Error(D);var l=c({baseUrl:e,source:n.sourceURL,range:n.range}),m=c({baseUrl:e,source:e,range:s});if(m.map=l,d){var f=h(t);f.length&&(m.duration=f[0].duration,m.timeline=f[0].timeline)}else i&&(m.duration=i/u,m.timeline=0);return m.number=0,[m]},S=function(t){var e=t.attributes,r=t.segmentInfo,n=void 0,a=void 0;if(r.template?(a=g,n=i(e,r.template)):r.base?(a=R,n=i(e,r.base)):r.list&&(a=E,n=i(e,r.list)),!a)return{attributes:e};var u=a(n,r.timeline);if(n.duration){var o=n,s=o.duration,c=o.timescale,d=void 0===c?1:c;n.duration=s/d}else u.length?n.duration=u.reduce(function(t,e){return Math.max(t,Math.ceil(e.duration))},0):n.duration=0;return{attributes:n,segments:u}},T=function(t,e){return f(t.childNodes).filter(function(t){return t.tagName===e})},P=function(t){return t.textContent.trim()},N=function(t){var e=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(t);if(!e)return 0;var r=e.slice(1),n=r[0],i=r[1],a=r[2],u=r[3],o=r[4],s=r[5];return 31536e3*parseFloat(n||0)+2592e3*parseFloat(i||0)+86400*parseFloat(a||0)+3600*parseFloat(u||0)+60*parseFloat(o||0)+parseFloat(s||0)},A={mediaPresentationDuration:function(t){return N(t)},availabilityStartTime:function(t){return function(t){return/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(t)&&(t+="Z"),Date.parse(t)}(t)/1e3},minimumUpdatePeriod:function(t){return N(t)},timeShiftBufferDepth:function(t){return N(t)},start:function(t){return N(t)},width:function(t){return parseInt(t,10)},height:function(t){return parseInt(t,10)},bandwidth:function(t){return parseInt(t,10)},startNumber:function(t){return parseInt(t,10)},timescale:function(t){return parseInt(t,10)},duration:function(t){var e=parseInt(t,10);return isNaN(e)?N(t):e},d:function(t){return parseInt(t,10)},t:function(t){return parseInt(t,10)},r:function(t){return parseInt(t,10)},DEFAULT:function(t){return t}},O=function(t){return t&&t.attributes?f(t.attributes).reduce(function(t,e){var r=A[e.name]||A.DEFAULT;return t[e.name]=r(e.value),t},{}):{}},x={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime"},M=function(t,e){return e.length?m(t.map(function(t){return e.map(function(e){return s(t,P(e))})})):t},z=function(t){var e=T(t,"SegmentTemplate")[0],r=T(t,"SegmentList")[0],n=r&&T(r,"SegmentURL").map(function(t){return i({tag:"SegmentURL"},O(t))}),a=T(t,"SegmentBase")[0],u=r||e,o=u&&T(u,"SegmentTimeline")[0],s=r||a||e,c=s&&T(s,"Initialization")[0],d=e&&O(e);d&&c?d.initialization=c&&O(c):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});var l={template:d,timeline:o&&T(o,"S").map(function(t){return O(t)}),list:r&&i(O(r),{segmentUrls:n,initialization:O(c)}),base:a&&i(O(a),{initialization:O(c)})};return Object.keys(l).forEach(function(t){l[t]||delete l[t]}),l},B=function(t){return t.reduce(function(t,e){var r=O(e),n=x[r.schemeIdUri];if(n){t[n]={attributes:r};var i=T(e,"cenc:pssh")[0];if(i){var a=P(i),u=a&&function(t){for(var e=o.atob(t),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}(a);t[n].pssh=u}}return t},{})},C=function(t,e,r){return function(n){var a=O(n),u=M(e,T(n,"BaseURL")),o=T(n,"Role")[0],s={role:O(o)},c=i(t,a,s),d=B(T(n,"ContentProtection"));Object.keys(d).length&&(c=i(c,{contentProtection:d}));var l=z(n),f=T(n,"Representation"),p=i(r,l);return m(f.map(function(t,e,r){return function(n){var a=T(n,"BaseURL"),u=M(e,a),o=i(t,O(n)),s=z(n);return u.map(function(t){return{segmentInfo:i(r,s),attributes:i(o,{baseUrl:t})}})}}(c,u,p)))}},F=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.manifestUri,n=void 0===r?"":r,a=e.NOW,u=void 0===a?Date.now():a,o=e.clientOffset,s=void 0===o?0:o,c=T(t,"Period");if(1!==c.length)throw new Error(U);var d=O(t),l=M([n],T(t,"BaseURL"));return d.sourceDuration=d.mediaPresentationDuration||0,d.NOW=u,d.clientOffset=s,m(c.map(function(t,e){return function(r,n){var a=M(e,T(r,"BaseURL")),u=O(r),o=i(t,u,{periodIndex:n}),s=T(r,"AdaptationSet"),c=z(r);return m(s.map(C(o,a,c)))}}(d,l)))},_=function(t){if(""===t)throw new Error(y);var e=(new o.DOMParser).parseFromString(t,"application/xml"),r=e&&"MPD"===e.documentElement.tagName?e.documentElement:null;if(!r||r&&r.getElementsByTagName("parsererror").length>0)throw new Error(I);return r};t.VERSION="0.6.1",t.parse=function(t,r){return function(t){var r;if(!t.length)return{};var n=t[0].attributes,i=n.sourceDuration,a=n.minimumUpdatePeriod,u=void 0===a?0:a,o=t.filter(function(t){var e=t.attributes;return"video/mp4"===e.mimeType||"video"===e.contentType}).map(e),s=t.filter(function(t){var e=t.attributes;return"audio/mp4"===e.mimeType||"audio"===e.contentType}),c=t.filter(function(t){var e=t.attributes;return"text/vtt"===e.mimeType||"text"===e.contentType}),d={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:(r={AUDIO:{},VIDEO:{}},r["CLOSED-CAPTIONS"]={},r.SUBTITLES={},r),uri:"",duration:i,playlists:o,minimumUpdatePeriod:1e3*u};return s.length&&(d.mediaGroups.AUDIO.audio=function(t){return t.reduce(function(t,e){var r=e.attributes.role&&e.attributes.role.value||"main",n=e.attributes.lang||"",i="main";return n&&(i=e.attributes.lang+" ("+r+")"),t[i]&&t[i].playlists[0].attributes.BANDWIDTH>e.attributes.bandwidth?t:(t[i]={language:n,autoselect:!0,default:"main"===r,playlists:[function(t){var e,r=t.attributes,n=t.segments,i={attributes:(e={NAME:r.id,BANDWIDTH:r.bandwidth,CODECS:r.codecs},e["PROGRAM-ID"]=1,e),uri:"",endList:"static"===(r.type||"static"),timeline:r.periodIndex,resolvedUri:"",targetDuration:r.duration,segments:n,mediaSequence:n.length?n[0].number:1};return r.contentProtection&&(i.contentProtection=r.contentProtection),i}(e)],uri:""},t)},{})}(s)),c.length&&(d.mediaGroups.SUBTITLES.subs=function(t){return t.reduce(function(t,e){var r=e.attributes.lang||"text";return t[r]?t:(t[r]={language:r,default:!1,autoselect:!1,playlists:[function(t){var e,r=t.attributes,n=t.segments;return void 0===n&&(n=[{uri:r.baseUrl,timeline:r.periodIndex,resolvedUri:r.baseUrl||"",duration:r.sourceDuration,number:0}],r.duration=r.sourceDuration),{attributes:(e={NAME:r.id,BANDWIDTH:r.bandwidth},e["PROGRAM-ID"]=1,e),uri:"",endList:"static"===(r.type||"static"),timeline:r.periodIndex,resolvedUri:r.baseUrl||"",targetDuration:r.duration,segments:n,mediaSequence:n.length?n[0].number:1}}(e)],uri:""},t)},{})}(c)),d}(function(t){return t.map(S)}(F(_(t),r)))},t.parseUTCTiming=function(t){return function(t){var e=T(t,"UTCTiming")[0];if(!e)return null;var r=O(e);switch(r.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":r.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":r.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":r.method="DIRECT",r.value=Date.parse(r.value);break;case"urn:mpeg:dash:utc:http-ntp:2014":case"urn:mpeg:dash:utc:ntp:2014":case"urn:mpeg:dash:utc:sntp:2014":default:throw new Error(w)}return r}(_(t))}}); |
{ | ||
"name": "mpd-parser", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "mpd parser", | ||
@@ -5,0 +5,0 @@ "main": "dist/mpd-parser.cjs.js", |
@@ -79,3 +79,6 @@ import babel from 'rollup-plugin-babel'; | ||
external: ['global/window', 'url-toolkit'], | ||
plugins: [ json({ preferConst: true }) ], | ||
plugins: [ | ||
json({ preferConst: true }), | ||
babel({ exclude: 'node_modules/**' }) | ||
], | ||
output: [ | ||
@@ -82,0 +85,0 @@ {file: 'dist/mpd-parser.es.js', format: 'es'} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
251287
6084
2