Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mpd-parser

Package Overview
Dependencies
Maintainers
15
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mpd-parser - npm Package Compare versions

Comparing version 0.15.2 to 0.15.4

10

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="0.15.4"></a>
## [0.15.4](https://github.com/videojs/mpd-parser/compare/v0.15.3...v0.15.4) (2021-02-24)
<a name="0.15.3"></a>
## [0.15.3](https://github.com/videojs/mpd-parser/compare/v0.15.2...v0.15.3) (2021-02-24)
### Features
* add support for endNumber in template duration parsing ([#120](https://github.com/videojs/mpd-parser/issues/120)) ([0a75d62](https://github.com/videojs/mpd-parser/commit/0a75d62))
<a name="0.15.2"></a>

@@ -2,0 +12,0 @@ ## [0.15.2](https://github.com/videojs/mpd-parser/compare/v0.15.1...v0.15.2) (2021-01-12)

33

dist/mpd-parser.cjs.js

@@ -1,2 +0,2 @@

/*! @name mpd-parser @version 0.15.2 @license Apache-2.0 */
/*! @name mpd-parser @version 0.15.4 @license Apache-2.0 */
'use strict';

@@ -17,3 +17,3 @@

var version = "0.15.2";
var version = "0.15.4";

@@ -162,2 +162,24 @@ var isObject = function isObject(obj) {

/**
* parse the end number attribue that can be a string
* number, or undefined.
*
* @param {string|number|undefined} endNumber
* The end number attribute.
*
* @return {number|null}
* The result of parsing the end number.
*/
var parseEndNumber = function parseEndNumber(endNumber) {
if (endNumber && typeof endNumber !== 'number') {
endNumber = parseInt(endNumber, 10);
}
if (isNaN(endNumber)) {
return null;
}
return endNumber;
};
/**
* Functions for calculating the range of available segments in static and dynamic

@@ -167,2 +189,3 @@ * manifests.

var segmentRange = {

@@ -182,5 +205,6 @@ /**

sourceDuration = attributes.sourceDuration;
var endNumber = parseEndNumber(attributes.endNumber);
return {
start: 0,
end: Math.ceil(sourceDuration / (duration / timescale))
end: typeof endNumber === 'number' ? endNumber : Math.ceil(sourceDuration / (duration / timescale))
};

@@ -210,2 +234,3 @@ },

timeShiftBufferDepth = _attributes$timeShift === void 0 ? Infinity : _attributes$timeShift;
var endNumber = parseEndNumber(attributes.endNumber);
var now = (NOW + clientOffset) / 1000;

@@ -220,3 +245,3 @@ var periodStartWC = availabilityStartTime + start;

start: Math.max(0, availableStart),
end: Math.min(segmentCount, availableEnd)
end: typeof endNumber === 'number' ? endNumber : Math.min(segmentCount, availableEnd)
};

@@ -223,0 +248,0 @@ }

@@ -1,2 +0,2 @@

/*! @name mpd-parser @version 0.15.2 @license Apache-2.0 */
/*! @name mpd-parser @version 0.15.4 @license Apache-2.0 */
import resolveUrl from '@videojs/vhs-utils/es/resolve-url';

@@ -7,3 +7,3 @@ import window from 'global/window';

var version = "0.15.2";
var version = "0.15.4";

@@ -152,2 +152,24 @@ var isObject = function isObject(obj) {

/**
* parse the end number attribue that can be a string
* number, or undefined.
*
* @param {string|number|undefined} endNumber
* The end number attribute.
*
* @return {number|null}
* The result of parsing the end number.
*/
var parseEndNumber = function parseEndNumber(endNumber) {
if (endNumber && typeof endNumber !== 'number') {
endNumber = parseInt(endNumber, 10);
}
if (isNaN(endNumber)) {
return null;
}
return endNumber;
};
/**
* Functions for calculating the range of available segments in static and dynamic

@@ -157,2 +179,3 @@ * manifests.

var segmentRange = {

@@ -172,5 +195,6 @@ /**

sourceDuration = attributes.sourceDuration;
var endNumber = parseEndNumber(attributes.endNumber);
return {
start: 0,
end: Math.ceil(sourceDuration / (duration / timescale))
end: typeof endNumber === 'number' ? endNumber : Math.ceil(sourceDuration / (duration / timescale))
};

@@ -200,2 +224,3 @@ },

timeShiftBufferDepth = _attributes$timeShift === void 0 ? Infinity : _attributes$timeShift;
var endNumber = parseEndNumber(attributes.endNumber);
var now = (NOW + clientOffset) / 1000;

@@ -210,3 +235,3 @@ var periodStartWC = availabilityStartTime + start;

start: Math.max(0, availableStart),
end: Math.min(segmentCount, availableEnd)
end: typeof endNumber === 'number' ? endNumber : Math.min(segmentCount, availableEnd)
};

@@ -213,0 +238,0 @@ }

4

dist/mpd-parser.min.js

@@ -1,2 +0,2 @@

/*! @name mpd-parser @version 0.15.2 @license Apache-2.0 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("global/window"),require("xmldom")):"function"==typeof define&&define.amd?define(["exports","global/window","xmldom"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).mpdParser={},t.window,t.window)}(this,(function(t,e,r){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=n(e),a=function(t){return!!t&&"object"==typeof t},o=function t(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.reduce((function(e,r){return"object"!=typeof r||Object.keys(r).forEach((function(n){Array.isArray(e[n])&&Array.isArray(r[n])?e[n]=e[n].concat(r[n]):a(e[n])&&a(r[n])?e[n]=t(e[n],r[n]):e[n]=r[n]})),e}),{})},u=function(t){return t.reduce((function(t,e){return t.concat(e)}),[])},s=function(t){if(!t.length)return[];for(var e=[],r=0;r<t.length;r++)e.push(t[r]);return e},c="INVALID_NUMBER_OF_PERIOD",d="DASH_EMPTY_MANIFEST",l="DASH_INVALID_XML",m="NO_BASE_URL",f="SEGMENT_TIME_UNSPECIFIED",p="UNSUPPORTED_UTC_TIMING_SCHEME";var h=function(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}((function(t,e){var r,n,i,a,o;r=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#.*)?$/,n=/^([^\/?#]*)(.*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var i=o.parseURL(t);if(!i)throw new Error("Error trying to parse base URL.");return i.path=o.normalizePath(i.path),o.buildURLFromParts(i)}var a=o.parseURL(e);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=o.normalizePath(a.path),o.buildURLFromParts(a)):e;var u=o.parseURL(t);if(!u)throw new Error("Error trying to parse base URL.");if(!u.netLoc&&u.path&&"/"!==u.path[0]){var s=n.exec(u.path);u.netLoc=s[1],u.path=s[2]}u.netLoc&&!u.path&&(u.path="/");var c={scheme:u.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(c.netLoc=u.netLoc,"/"!==a.path[0]))if(a.path){var d=u.path,l=d.substring(0,d.lastIndexOf("/")+1)+a.path;c.path=o.normalizePath(l)}else c.path=u.path,a.params||(c.params=u.params,a.query||(c.query=u.query));return null===c.path&&(c.path=r.alwaysNormalize?o.normalizePath(a.path):a.path),o.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=o})),v=function(t,e){return/^[a-z]+:/i.test(e)?e:(/\/\//i.test(t)||(t=h.buildAbsoluteURL(i.default.location&&i.default.location.href||"",t)),h.buildAbsoluteURL(t,e))},g=function(t){var e=t.baseUrl,r=void 0===e?"":e,n=t.source,i=void 0===n?"":n,a=t.range,o=void 0===a?"":a,u=t.indexRange,s=void 0===u?"":u,c={uri:i,resolvedUri:v(r||"",i)};if(o||s){var d=(o||s).split("-"),l=parseInt(d[0],10),m=parseInt(d[1],10);c.byterange={length:m-l+1,offset:l}}return c},b={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,o=t.duration,u=t.start,s=void 0===u?0:u,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/o),g=Math.floor((f-p-m)*a/o),b=Math.floor((f-p)*a/o);return{start:Math.max(0,g),end:Math.min(v,b)}}},y=function(t){var e=t.type,r=void 0===e?"static":e,n=t.duration,i=t.timescale,a=void 0===i?1:i,o=t.sourceDuration,u=b[r](t),s=function(t,e){for(var r=[],n=t;n<e;n++)r.push(n);return r}(u.start,u.end).map(function(t){return function(e,r){var n=t.duration,i=t.timescale,a=void 0===i?1:i,o=t.periodIndex,u=t.startNumber;return{number:(void 0===u?1:u)+e,duration:n/a,timeline:o,time:r*n}}}(t));if("static"===r){var c=s.length-1;s[c].duration=o-n/a*c}return s},U=function(t){var e=t.baseUrl,r=t.initialization,n=void 0===r?{}:r,i=t.sourceDuration,a=t.indexRange,o=void 0===a?"":a,u=t.duration;if(!e)throw new Error(m);var s=g({baseUrl:e,source:n.sourceURL,range:n.range}),c=g({baseUrl:e,source:e,indexRange:o});if(c.map=s,u){var d=y(t);d.length&&(c.duration=d[0].duration,c.timeline=d[0].timeline)}else i&&(c.duration=i,c.timeline=0);return c.number=0,[c]},I=function(t,e,r){for(var n=t.sidx.map?t.sidx.map:null,i=t.sidx.duration,a=t.timeline||0,o=t.sidx.byterange,u=o.offset+o.length,s=e.timescale,c=e.references.filter((function(t){return 1!==t.referenceType})),d=[],l=u+e.firstOffset,m=0;m<c.length;m++){var f=e.references[m],p=f.referencedSize,h=f.subsegmentDuration,v=U({baseUrl:r,timescale:s,timeline:a,periodIndex:a,duration:h,sourceDuration:i,indexRange:l+"-"+(l+p-1)})[0];n&&(v.map=n),d.push(v),l+=p}return t.segments=d,t},D=function(t){var e;return(e=t.reduce((function(t,e){var r,n=e.attributes.id+(e.attributes.lang||"");return t[n]?(e.segments[0]&&(e.segments[0].discontinuity=!0),(r=t[n].segments).push.apply(r,e.segments),e.attributes.contentProtection&&(t[n].attributes.contentProtection=e.attributes.contentProtection)):t[n]=e,t}),{}),Object.keys(e).map((function(t){return e[t]}))).map((function(t){var e,r;return t.discontinuityStarts=(e=t.segments,r="discontinuity",e.reduce((function(t,e,n){return e[r]&&t.push(n),t}),[])),t}))},x=function(t,e){if(void 0===e&&(e={}),!Object.keys(e).length)return t;for(var r in t){var n=t[r];if(n.sidx){var i=n.sidx.uri+"-"+(o=n.sidx.byterange,u=void 0,u=o.offset+o.length-1,o.offset+"-"+u),a=e[i]&&e[i].sidx;n.sidx&&a&&I(n,a,n.sidx.resolvedUri)}}var o,u;return t},w=function(t){var e,r=t.attributes,n=t.segments,i=t.sidx,a={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&&(a.contentProtection=r.contentProtection),i&&(a.sidx=i),a},L=function(t){var e,r=t.attributes,n=t.segments;void 0===n&&(n=[{uri:r.baseUrl,timeline:r.periodIndex,resolvedUri:r.baseUrl||"",duration:r.sourceDuration,number:0}],r.duration=r.sourceDuration);var i=((e={NAME:r.id,BANDWIDTH:r.bandwidth})["PROGRAM-ID"]=1,e);return r.codecs&&(i.CODECS=r.codecs),{attributes:i,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=function(t){var e,r=t.attributes,n=t.segments,i=t.sidx,a={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&&(a.contentProtection=r.contentProtection),i&&(a.sidx=i),a},T=function(t,e,r){var n;if(void 0===r&&(r={}),!t.length)return{};var i=t[0].attributes,a=i.sourceDuration,o=i.type,u=void 0===o?"static":o,s=i.suggestedPresentationDelay,c=i.minimumUpdatePeriod,d=D(t.filter((function(t){var e=t.attributes;return"video/mp4"===e.mimeType||"video/webm"===e.mimeType||"video"===e.contentType}))).map(E),l=D(t.filter((function(t){var e=t.attributes;return"audio/mp4"===e.mimeType||"audio/webm"===e.mimeType||"audio"===e.contentType}))),m=t.filter((function(t){var e=t.attributes;return"text/vtt"===e.mimeType||"text"===e.contentType})),f={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:(n={AUDIO:{},VIDEO:{}},n["CLOSED-CAPTIONS"]={},n.SUBTITLES={},n),uri:"",duration:a,playlists:x(d,r)};return c>=0&&(f.minimumUpdatePeriod=1e3*c),e&&(f.locations=e),"dynamic"===u&&(f.suggestedPresentationDelay=s),l.length&&(f.mediaGroups.AUDIO.audio=function(t,e){var r;void 0===e&&(e={});var n=t.reduce((function(t,n){var i=n.attributes.role&&n.attributes.role.value||"",a=n.attributes.lang||"",o="main";if(a){var u=i?" ("+i+")":"";o=""+n.attributes.lang+u}return t[o]&&t[o].playlists[0].attributes.BANDWIDTH>n.attributes.bandwidth||(t[o]={language:a,autoselect:!0,default:"main"===i,playlists:x([w(n)],e),uri:""},void 0===r&&"main"===i&&((r=n).default=!0)),t}),{});return r||(n[Object.keys(n)[0]].default=!0),n}(l,r)),m.length&&(f.mediaGroups.SUBTITLES.subs=function(t,e){return void 0===e&&(e={}),t.reduce((function(t,r){var n=r.attributes.lang||"text";return t[n]||(t[n]={language:n,default:!1,autoselect:!1,playlists:x([L(r)],e),uri:""}),t}),{})}(m,r)),f},P=function(t,e,r){var n=t.NOW,i=t.clientOffset,a=t.availabilityStartTime,o=t.timescale,u=void 0===o?1:o,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*u-e)/r)},R=function(t,e){for(var r=t.type,n=void 0===r?"static":r,i=t.minimumUpdatePeriod,a=void 0===i?0:i,o=t.media,u=void 0===o?"":o,s=t.sourceDuration,c=t.timescale,d=void 0===c?1:c,l=t.startNumber,m=void 0===l?1:l,f=t.periodIndex,p=[],h=-1,v=0;v<e.length;v++){var g=e[v],b=g.d,y=g.r||0,U=g.t||0;h<0&&(h=U),U&&U>h&&(h=U);var I=void 0;if(y<0){var D=v+1;I=D===e.length?"dynamic"===n&&a>0&&u.indexOf("$Number$")>0?P(t,h,b):(s*d-h)/b:(e[D].t-h)/b}else I=y+1;for(var x=m+p.length+I,w=m+p.length;w<x;)p.push({number:w,duration:b/d,time:h,timeline:f}),h+=b,w++}return p},S=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,N=function(t,e){return t.replace(S,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))},A=function(t,e){var r={RepresentationID:t.id,Bandwidth:t.bandwidth||0},n=t.initialization,i=void 0===n?{sourceURL:"",range:""}:n,a=g({baseUrl:t.baseUrl,source:N(i.sourceURL,r),range:i.range});return function(t,e){return t.duration||e?t.duration?y(t):R(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=N(t.media||"",r);return{uri:n,timeline:e.timeline,duration:e.duration,resolvedUri:v(t.baseUrl||"",n),map:a,number:e.number}}))},O=function(t,e){var r=t.duration,n=t.segmentUrls,i=void 0===n?[]:n;if(!r&&!e||r&&e)throw new Error(f);var a,o=i.map((function(e){return function(t,e){var r=t.baseUrl,n=t.initialization,i=void 0===n?{}:n,a=g({baseUrl:r,source:i.sourceURL,range:i.range}),o=g({baseUrl:r,source:e.media,range:e.mediaRange});return o.map=a,o}(t,e)}));return r&&(a=y(t)),e&&(a=R(t,e)),a.map((function(t,e){if(o[e]){var r=o[e];return r.timeline=t.timeline,r.duration=t.duration,r.number=t.number,r}})).filter((function(t){return t}))},M=function(t){var e,r,n=t.attributes,i=t.segmentInfo;i.template?(r=A,e=o(n,i.template)):i.base?(r=U,e=o(n,i.base)):i.list&&(r=O,e=o(n,i.list));var a={attributes:n};if(!r)return a;var u=r(e,i.timeline);if(e.duration){var s=e,c=s.duration,d=s.timescale,l=void 0===d?1:d;e.duration=c/l}else u.length?e.duration=u.reduce((function(t,e){return Math.max(t,Math.ceil(e.duration))}),0):e.duration=0;return a.attributes=e,a.segments=u,i.base&&e.indexRange&&(a.sidx=u[0],a.segments=[]),a},z=function(t){return t.map(M)},B=function(t,e){return s(t.childNodes).filter((function(t){return t.tagName===e}))},C=function(t){return t.textContent.trim()},F=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],o=r[3],u=r[4],s=r[5];return 31536e3*parseFloat(n||0)+2592e3*parseFloat(i||0)+86400*parseFloat(a||0)+3600*parseFloat(o||0)+60*parseFloat(u||0)+parseFloat(s||0)},_={mediaPresentationDuration:function(t){return F(t)},availabilityStartTime:function(t){return/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(e=t)&&(e+="Z"),Date.parse(e)/1e3;var e},minimumUpdatePeriod:function(t){return F(t)},suggestedPresentationDelay:function(t){return F(t)},type:function(t){return t},timeShiftBufferDepth:function(t){return F(t)},start:function(t){return F(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)?F(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}},j=function(t){return t&&t.attributes?s(t.attributes).reduce((function(t,e){var r=_[e.name]||_.DEFAULT;return t[e.name]=r(e.value),t}),{}):{}};function q(t){for(var e,r=(e=t,i.default.atob?i.default.atob(e):Buffer.from(e,"base64").toString("binary")),n=new Uint8Array(r.length),a=0;a<r.length;a++)n[a]=r.charCodeAt(a);return n}var k={"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"},$=function(t,e){return e.length?u(t.map((function(t){return e.map((function(e){return v(t,C(e))}))}))):t},G=function(t){var e=B(t,"SegmentTemplate")[0],r=B(t,"SegmentList")[0],n=r&&B(r,"SegmentURL").map((function(t){return o({tag:"SegmentURL"},j(t))})),i=B(t,"SegmentBase")[0],a=r||e,u=a&&B(a,"SegmentTimeline")[0],s=r||i||e,c=s&&B(s,"Initialization")[0],d=e&&j(e);d&&c?d.initialization=c&&j(c):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});var l={template:d,timeline:u&&B(u,"S").map((function(t){return j(t)})),list:r&&o(j(r),{segmentUrls:n,initialization:j(c)}),base:i&&o(j(i),{initialization:j(c)})};return Object.keys(l).forEach((function(t){l[t]||delete l[t]})),l},H=function(t,e,r){return function(n){var i=j(n),a=$(e,B(n,"BaseURL")),s=B(n,"Role")[0],c={role:j(s)},d=o(t,i,c),l=B(n,"ContentProtection").reduce((function(t,e){var r=j(e),n=k[r.schemeIdUri];if(n){t[n]={attributes:r};var i=B(e,"cenc:pssh")[0];if(i){var a=C(i),o=a&&q(a);t[n].pssh=o}}return t}),{});Object.keys(l).length&&(d=o(d,{contentProtection:l}));var m=G(n),f=B(n,"Representation"),p=o(r,m);return u(f.map(function(t,e,r){return function(n){var i=B(n,"BaseURL"),a=$(e,i),u=o(t,j(n)),s=G(n);return a.map((function(t){return{segmentInfo:o(r,s),attributes:o(u,{baseUrl:t})}}))}}(d,a,p)))}},W=function(t,e){return function(r,n){var a=$(e,B(r,"BaseURL")),s=j(r),c=parseInt(s.id,10),d=i.default.isNaN(c)?n:c,l=o(t,{periodIndex:d}),m=B(r,"AdaptationSet"),f=G(r);return u(m.map(H(l,a,f)))}},V=function(t,e){void 0===e&&(e={});var r=e,n=r.manifestUri,i=void 0===n?"":n,a=r.NOW,o=void 0===a?Date.now():a,s=r.clientOffset,d=void 0===s?0:s,l=B(t,"Period");if(!l.length)throw new Error(c);var m=B(t,"Location"),f=j(t),p=$([i],B(t,"BaseURL"));return f.sourceDuration=f.mediaPresentationDuration||0,f.NOW=o,f.clientOffset=d,m.length&&(f.locations=m.map(C)),{locations:f.locations,representationInfo:u(l.map(W(f,p)))}},X=function(t){if(""===t)throw new Error(d);var e,n,i=new r.DOMParser;try{n=(e=i.parseFromString(t,"application/xml"))&&"MPD"===e.documentElement.tagName?e.documentElement:null}catch(t){}if(!n||n&&n.getElementsByTagName("parsererror").length>0)throw new Error(l);return n},Y=I;t.VERSION="0.15.2",t.addSidxSegmentsToPlaylist=Y,t.inheritAttributes=V,t.parse=function(t,e){void 0===e&&(e={});var r=V(X(t),e),n=z(r.representationInfo);return T(n,r.locations,e.sidxMapping)},t.parseUTCTiming=function(t){return function(t){var e=B(t,"UTCTiming")[0];if(!e)return null;var r=j(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(p)}return r}(X(t))},t.stringToMpdXml=X,t.toM3u8=T,t.toPlaylists=z,Object.defineProperty(t,"__esModule",{value:!0})}));
/*! @name mpd-parser @version 0.15.4 @license Apache-2.0 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("global/window"),require("xmldom")):"function"==typeof define&&define.amd?define(["exports","global/window","xmldom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).mpdParser={},e.window,e.window)}(this,(function(e,t,r){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=n(t),a=function(e){return!!e&&"object"==typeof e},u=function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.reduce((function(t,r){return"object"!=typeof r||Object.keys(r).forEach((function(n){Array.isArray(t[n])&&Array.isArray(r[n])?t[n]=t[n].concat(r[n]):a(t[n])&&a(r[n])?t[n]=e(t[n],r[n]):t[n]=r[n]})),t}),{})},o=function(e){return e.reduce((function(e,t){return e.concat(t)}),[])},s=function(e){if(!e.length)return[];for(var t=[],r=0;r<e.length;r++)t.push(e[r]);return t},c="INVALID_NUMBER_OF_PERIOD",d="DASH_EMPTY_MANIFEST",l="DASH_INVALID_XML",m="NO_BASE_URL",f="SEGMENT_TIME_UNSPECIFIED",p="UNSUPPORTED_UTC_TIMING_SCHEME";var h=function(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&r.path)}},r.exports),r.exports}((function(e,t){var r,n,i,a,u;r=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#.*)?$/,n=/^([^\/?#]*)(.*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,u={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=u.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=u.normalizePath(i.path),u.buildURLFromParts(i)}var a=u.parseURL(t);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)):t;var o=u.parseURL(e);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(e){var t=r.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=u})),v=function(e,t){return/^[a-z]+:/i.test(t)?t:(/\/\//i.test(e)||(e=h.buildAbsoluteURL(i.default.location&&i.default.location.href||"",e)),h.buildAbsoluteURL(e,t))},g=function(e){var t=e.baseUrl,r=void 0===t?"":t,n=e.source,i=void 0===n?"":n,a=e.range,u=void 0===a?"":a,o=e.indexRange,s=void 0===o?"":o,c={uri:i,resolvedUri:v(r||"",i)};if(u||s){var d=(u||s).split("-"),l=parseInt(d[0],10),m=parseInt(d[1],10);c.byterange={length:m-l+1,offset:l}}return c},b=function(e){return e&&"number"!=typeof e&&(e=parseInt(e,10)),isNaN(e)?null:e},y={static:function(e){var t=e.duration,r=e.timescale,n=void 0===r?1:r,i=e.sourceDuration,a=b(e.endNumber);return{start:0,end:"number"==typeof a?a:Math.ceil(i/(t/n))}},dynamic:function(e){var t=e.NOW,r=e.clientOffset,n=e.availabilityStartTime,i=e.timescale,a=void 0===i?1:i,u=e.duration,o=e.start,s=void 0===o?0:o,c=e.minimumUpdatePeriod,d=void 0===c?0:c,l=e.timeShiftBufferDepth,m=void 0===l?1/0:l,f=b(e.endNumber),p=(t+r)/1e3,h=n+s,v=p+d-h,g=Math.ceil(v*a/u),y=Math.floor((p-h-m)*a/u),U=Math.floor((p-h)*a/u);return{start:Math.max(0,y),end:"number"==typeof f?f:Math.min(g,U)}}},U=function(e){var t=e.type,r=void 0===t?"static":t,n=e.duration,i=e.timescale,a=void 0===i?1:i,u=e.sourceDuration,o=y[r](e),s=function(e,t){for(var r=[],n=e;n<t;n++)r.push(n);return r}(o.start,o.end).map(function(e){return function(t,r){var n=e.duration,i=e.timescale,a=void 0===i?1:i,u=e.periodIndex,o=e.startNumber;return{number:(void 0===o?1:o)+t,duration:n/a,timeline:u,time:r*n}}}(e));if("static"===r){var c=s.length-1;s[c].duration=u-n/a*c}return s},I=function(e){var t=e.baseUrl,r=e.initialization,n=void 0===r?{}:r,i=e.sourceDuration,a=e.indexRange,u=void 0===a?"":a,o=e.duration;if(!t)throw new Error(m);var s=g({baseUrl:t,source:n.sourceURL,range:n.range}),c=g({baseUrl:t,source:t,indexRange:u});if(c.map=s,o){var d=U(e);d.length&&(c.duration=d[0].duration,c.timeline=d[0].timeline)}else i&&(c.duration=i,c.timeline=0);return c.number=0,[c]},D=function(e,t,r){for(var n=e.sidx.map?e.sidx.map:null,i=e.sidx.duration,a=e.timeline||0,u=e.sidx.byterange,o=u.offset+u.length,s=t.timescale,c=t.references.filter((function(e){return 1!==e.referenceType})),d=[],l=o+t.firstOffset,m=0;m<c.length;m++){var f=t.references[m],p=f.referencedSize,h=f.subsegmentDuration,v=I({baseUrl:r,timescale:s,timeline:a,periodIndex:a,duration:h,sourceDuration:i,indexRange:l+"-"+(l+p-1)})[0];n&&(v.map=n),d.push(v),l+=p}return e.segments=d,e},x=function(e){var t;return(t=e.reduce((function(e,t){var r,n=t.attributes.id+(t.attributes.lang||"");return e[n]?(t.segments[0]&&(t.segments[0].discontinuity=!0),(r=e[n].segments).push.apply(r,t.segments),t.attributes.contentProtection&&(e[n].attributes.contentProtection=t.attributes.contentProtection)):e[n]=t,e}),{}),Object.keys(t).map((function(e){return t[e]}))).map((function(e){var t,r;return e.discontinuityStarts=(t=e.segments,r="discontinuity",t.reduce((function(e,t,n){return t[r]&&e.push(n),e}),[])),e}))},w=function(e,t){if(void 0===t&&(t={}),!Object.keys(t).length)return e;for(var r in e){var n=e[r];if(n.sidx){var i=n.sidx.uri+"-"+(u=n.sidx.byterange,o=void 0,o=u.offset+u.length-1,u.offset+"-"+o),a=t[i]&&t[i].sidx;n.sidx&&a&&D(n,a,n.sidx.resolvedUri)}}var u,o;return e},L=function(e){var t,r=e.attributes,n=e.segments,i=e.sidx,a={attributes:(t={NAME:r.id,BANDWIDTH:r.bandwidth,CODECS:r.codecs},t["PROGRAM-ID"]=1,t),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&&(a.contentProtection=r.contentProtection),i&&(a.sidx=i),a},E=function(e){var t,r=e.attributes,n=e.segments;void 0===n&&(n=[{uri:r.baseUrl,timeline:r.periodIndex,resolvedUri:r.baseUrl||"",duration:r.sourceDuration,number:0}],r.duration=r.sourceDuration);var i=((t={NAME:r.id,BANDWIDTH:r.bandwidth})["PROGRAM-ID"]=1,t);return r.codecs&&(i.CODECS=r.codecs),{attributes:i,uri:"",endList:"static"===(r.type||"static"),timeline:r.periodIndex,resolvedUri:r.baseUrl||"",targetDuration:r.duration,segments:n,mediaSequence:n.length?n[0].number:1}},T=function(e){var t,r=e.attributes,n=e.segments,i=e.sidx,a={attributes:(t={NAME:r.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:r.width,height:r.height},CODECS:r.codecs,BANDWIDTH:r.bandwidth},t["PROGRAM-ID"]=1,t),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&&(a.contentProtection=r.contentProtection),i&&(a.sidx=i),a},P=function(e,t,r){var n;if(void 0===r&&(r={}),!e.length)return{};var i=e[0].attributes,a=i.sourceDuration,u=i.type,o=void 0===u?"static":u,s=i.suggestedPresentationDelay,c=i.minimumUpdatePeriod,d=x(e.filter((function(e){var t=e.attributes;return"video/mp4"===t.mimeType||"video/webm"===t.mimeType||"video"===t.contentType}))).map(T),l=x(e.filter((function(e){var t=e.attributes;return"audio/mp4"===t.mimeType||"audio/webm"===t.mimeType||"audio"===t.contentType}))),m=e.filter((function(e){var t=e.attributes;return"text/vtt"===t.mimeType||"text"===t.contentType})),f={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:(n={AUDIO:{},VIDEO:{}},n["CLOSED-CAPTIONS"]={},n.SUBTITLES={},n),uri:"",duration:a,playlists:w(d,r)};return c>=0&&(f.minimumUpdatePeriod=1e3*c),t&&(f.locations=t),"dynamic"===o&&(f.suggestedPresentationDelay=s),l.length&&(f.mediaGroups.AUDIO.audio=function(e,t){var r;void 0===t&&(t={});var n=e.reduce((function(e,n){var i=n.attributes.role&&n.attributes.role.value||"",a=n.attributes.lang||"",u="main";if(a){var o=i?" ("+i+")":"";u=""+n.attributes.lang+o}return e[u]&&e[u].playlists[0].attributes.BANDWIDTH>n.attributes.bandwidth||(e[u]={language:a,autoselect:!0,default:"main"===i,playlists:w([L(n)],t),uri:""},void 0===r&&"main"===i&&((r=n).default=!0)),e}),{});return r||(n[Object.keys(n)[0]].default=!0),n}(l,r)),m.length&&(f.mediaGroups.SUBTITLES.subs=function(e,t){return void 0===t&&(t={}),e.reduce((function(e,r){var n=r.attributes.lang||"text";return e[n]||(e[n]={language:n,default:!1,autoselect:!1,playlists:w([E(r)],t),uri:""}),e}),{})}(m,r)),f},R=function(e,t,r){var n=e.NOW,i=e.clientOffset,a=e.availabilityStartTime,u=e.timescale,o=void 0===u?1:u,s=e.start,c=void 0===s?0:s,d=e.minimumUpdatePeriod,l=(n+i)/1e3+(void 0===d?0:d)-(a+c);return Math.ceil((l*o-t)/r)},S=function(e,t){for(var r=e.type,n=void 0===r?"static":r,i=e.minimumUpdatePeriod,a=void 0===i?0:i,u=e.media,o=void 0===u?"":u,s=e.sourceDuration,c=e.timescale,d=void 0===c?1:c,l=e.startNumber,m=void 0===l?1:l,f=e.periodIndex,p=[],h=-1,v=0;v<t.length;v++){var g=t[v],b=g.d,y=g.r||0,U=g.t||0;h<0&&(h=U),U&&U>h&&(h=U);var I=void 0;if(y<0){var D=v+1;I=D===t.length?"dynamic"===n&&a>0&&o.indexOf("$Number$")>0?R(e,h,b):(s*d-h)/b:(t[D].t-h)/b}else I=y+1;for(var x=m+p.length+I,w=m+p.length;w<x;)p.push({number:w,duration:b/d,time:h,timeline:f}),h+=b,w++}return p},N=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,A=function(e,t){return e.replace(N,function(e){return function(t,r,n,i){if("$$"===t)return"$";if(void 0===e[r])return t;var a=""+e[r];return"RepresentationID"===r?a:(i=n?parseInt(i,10):1,a.length>=i?a:""+new Array(i-a.length+1).join("0")+a)}}(t))},O=function(e,t){var r={RepresentationID:e.id,Bandwidth:e.bandwidth||0},n=e.initialization,i=void 0===n?{sourceURL:"",range:""}:n,a=g({baseUrl:e.baseUrl,source:A(i.sourceURL,r),range:i.range});return function(e,t){return e.duration||t?e.duration?U(e):S(e,t):[{number:e.startNumber||1,duration:e.sourceDuration,time:0,timeline:e.periodIndex}]}(e,t).map((function(t){r.Number=t.number,r.Time=t.time;var n=A(e.media||"",r);return{uri:n,timeline:t.timeline,duration:t.duration,resolvedUri:v(e.baseUrl||"",n),map:a,number:t.number}}))},M=function(e,t){var r=e.duration,n=e.segmentUrls,i=void 0===n?[]:n;if(!r&&!t||r&&t)throw new Error(f);var a,u=i.map((function(t){return function(e,t){var r=e.baseUrl,n=e.initialization,i=void 0===n?{}:n,a=g({baseUrl:r,source:i.sourceURL,range:i.range}),u=g({baseUrl:r,source:t.media,range:t.mediaRange});return u.map=a,u}(e,t)}));return r&&(a=U(e)),t&&(a=S(e,t)),a.map((function(e,t){if(u[t]){var r=u[t];return r.timeline=e.timeline,r.duration=e.duration,r.number=e.number,r}})).filter((function(e){return e}))},z=function(e){var t,r,n=e.attributes,i=e.segmentInfo;i.template?(r=O,t=u(n,i.template)):i.base?(r=I,t=u(n,i.base)):i.list&&(r=M,t=u(n,i.list));var a={attributes:n};if(!r)return a;var o=r(t,i.timeline);if(t.duration){var s=t,c=s.duration,d=s.timescale,l=void 0===d?1:d;t.duration=c/l}else o.length?t.duration=o.reduce((function(e,t){return Math.max(e,Math.ceil(t.duration))}),0):t.duration=0;return a.attributes=t,a.segments=o,i.base&&t.indexRange&&(a.sidx=o[0],a.segments=[]),a},B=function(e){return e.map(z)},C=function(e,t){return s(e.childNodes).filter((function(e){return e.tagName===t}))},F=function(e){return e.textContent.trim()},_=function(e){var t=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(e);if(!t)return 0;var r=t.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)},j={mediaPresentationDuration:function(e){return _(e)},availabilityStartTime:function(e){return/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(t=e)&&(t+="Z"),Date.parse(t)/1e3;var t},minimumUpdatePeriod:function(e){return _(e)},suggestedPresentationDelay:function(e){return _(e)},type:function(e){return e},timeShiftBufferDepth:function(e){return _(e)},start:function(e){return _(e)},width:function(e){return parseInt(e,10)},height:function(e){return parseInt(e,10)},bandwidth:function(e){return parseInt(e,10)},startNumber:function(e){return parseInt(e,10)},timescale:function(e){return parseInt(e,10)},duration:function(e){var t=parseInt(e,10);return isNaN(t)?_(e):t},d:function(e){return parseInt(e,10)},t:function(e){return parseInt(e,10)},r:function(e){return parseInt(e,10)},DEFAULT:function(e){return e}},q=function(e){return e&&e.attributes?s(e.attributes).reduce((function(e,t){var r=j[t.name]||j.DEFAULT;return e[t.name]=r(t.value),e}),{}):{}};function k(e){for(var t,r=(t=e,i.default.atob?i.default.atob(t):Buffer.from(t,"base64").toString("binary")),n=new Uint8Array(r.length),a=0;a<r.length;a++)n[a]=r.charCodeAt(a);return n}var $={"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"},G=function(e,t){return t.length?o(e.map((function(e){return t.map((function(t){return v(e,F(t))}))}))):e},H=function(e){var t=C(e,"SegmentTemplate")[0],r=C(e,"SegmentList")[0],n=r&&C(r,"SegmentURL").map((function(e){return u({tag:"SegmentURL"},q(e))})),i=C(e,"SegmentBase")[0],a=r||t,o=a&&C(a,"SegmentTimeline")[0],s=r||i||t,c=s&&C(s,"Initialization")[0],d=t&&q(t);d&&c?d.initialization=c&&q(c):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});var l={template:d,timeline:o&&C(o,"S").map((function(e){return q(e)})),list:r&&u(q(r),{segmentUrls:n,initialization:q(c)}),base:i&&u(q(i),{initialization:q(c)})};return Object.keys(l).forEach((function(e){l[e]||delete l[e]})),l},W=function(e,t,r){return function(n){var i=q(n),a=G(t,C(n,"BaseURL")),s=C(n,"Role")[0],c={role:q(s)},d=u(e,i,c),l=C(n,"ContentProtection").reduce((function(e,t){var r=q(t),n=$[r.schemeIdUri];if(n){e[n]={attributes:r};var i=C(t,"cenc:pssh")[0];if(i){var a=F(i),u=a&&k(a);e[n].pssh=u}}return e}),{});Object.keys(l).length&&(d=u(d,{contentProtection:l}));var m=H(n),f=C(n,"Representation"),p=u(r,m);return o(f.map(function(e,t,r){return function(n){var i=C(n,"BaseURL"),a=G(t,i),o=u(e,q(n)),s=H(n);return a.map((function(e){return{segmentInfo:u(r,s),attributes:u(o,{baseUrl:e})}}))}}(d,a,p)))}},V=function(e,t){return function(r,n){var a=G(t,C(r,"BaseURL")),s=q(r),c=parseInt(s.id,10),d=i.default.isNaN(c)?n:c,l=u(e,{periodIndex:d}),m=C(r,"AdaptationSet"),f=H(r);return o(m.map(W(l,a,f)))}},X=function(e,t){void 0===t&&(t={});var r=t,n=r.manifestUri,i=void 0===n?"":n,a=r.NOW,u=void 0===a?Date.now():a,s=r.clientOffset,d=void 0===s?0:s,l=C(e,"Period");if(!l.length)throw new Error(c);var m=C(e,"Location"),f=q(e),p=G([i],C(e,"BaseURL"));return f.sourceDuration=f.mediaPresentationDuration||0,f.NOW=u,f.clientOffset=d,m.length&&(f.locations=m.map(F)),{locations:f.locations,representationInfo:o(l.map(V(f,p)))}},Y=function(e){if(""===e)throw new Error(d);var t,n,i=new r.DOMParser;try{n=(t=i.parseFromString(e,"application/xml"))&&"MPD"===t.documentElement.tagName?t.documentElement:null}catch(e){}if(!n||n&&n.getElementsByTagName("parsererror").length>0)throw new Error(l);return n},Z=D;e.VERSION="0.15.4",e.addSidxSegmentsToPlaylist=Z,e.inheritAttributes=X,e.parse=function(e,t){void 0===t&&(t={});var r=X(Y(e),t),n=B(r.representationInfo);return P(n,r.locations,t.sidxMapping)},e.parseUTCTiming=function(e){return function(e){var t=C(e,"UTCTiming")[0];if(!t)return null;var r=q(t);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(p)}return r}(Y(e))},e.stringToMpdXml=Y,e.toM3u8=P,e.toPlaylists=B,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "mpd-parser",
"version": "0.15.2",
"version": "0.15.4",
"description": "mpd parser",

@@ -5,0 +5,0 @@ "main": "dist/mpd-parser.cjs.js",

import { range } from '../utils/list';
/**
* parse the end number attribue that can be a string
* number, or undefined.
*
* @param {string|number|undefined} endNumber
* The end number attribute.
*
* @return {number|null}
* The result of parsing the end number.
*/
const parseEndNumber = (endNumber) => {
if (endNumber && typeof endNumber !== 'number') {
endNumber = parseInt(endNumber, 10);
}
if (isNaN(endNumber)) {
return null;
}
return endNumber;
};
/**
* Functions for calculating the range of available segments in static and dynamic

@@ -22,6 +44,7 @@ * manifests.

} = attributes;
const endNumber = parseEndNumber(attributes.endNumber);
return {
start: 0,
end: Math.ceil(sourceDuration / (duration / timescale))
end: typeof endNumber === 'number' ? endNumber : Math.ceil(sourceDuration / (duration / timescale))
};

@@ -49,2 +72,3 @@ },

} = attributes;
const endNumber = parseEndNumber(attributes.endNumber);
const now = (NOW + clientOffset) / 1000;

@@ -61,3 +85,3 @@ const periodStartWC = availabilityStartTime + start;

start: Math.max(0, availableStart),
end: Math.min(segmentCount, availableEnd)
end: typeof endNumber === 'number' ? endNumber : Math.min(segmentCount, availableEnd)
};

@@ -64,0 +88,0 @@ }

@@ -238,2 +238,30 @@ import QUnit from 'qunit';

QUnit.test('parseByDuration uses endNumber and has correct duration', function(assert) {
const attributes = {
sourceDuration: 11,
duration: '4',
periodIndex: 1,
endNumber: '2'
};
assert.deepEqual(
parseTemplateInfo(attributes, []),
[
{
number: 1,
duration: 4,
timeline: 1,
time: 0
},
{
number: 2,
duration: 7,
timeline: 1,
time: 4
}
],
'uses default startNumber and timescale value of 1'
);
});
QUnit.test('uses SegmentTimeline info when no @duration attribute', function(assert) {

@@ -991,2 +1019,51 @@ const attributes = {

);
assert.deepEqual(
segmentsFromTemplate(Object.assign(
{}, basicAttributes,
{ endNumber: '4' }, []
)),
[{
duration: 2,
map: {
resolvedUri: 'http://www.example.com/',
uri: ''
},
number: 1,
resolvedUri: 'http://www.example.com/n-1.m4s',
timeline: 1,
uri: 'n-1.m4s'
}, {
duration: 2,
map: {
resolvedUri: 'http://www.example.com/',
uri: ''
},
number: 2,
resolvedUri: 'http://www.example.com/n-2.m4s',
timeline: 1,
uri: 'n-2.m4s'
}, {
duration: 2,
map: {
resolvedUri: 'http://www.example.com/',
uri: ''
},
number: 3,
resolvedUri: 'http://www.example.com/n-3.m4s',
timeline: 1,
uri: 'n-3.m4s'
}, {
duration: 2,
map: {
resolvedUri: 'http://www.example.com/',
uri: ''
},
number: 4,
resolvedUri: 'http://www.example.com/n-4.m4s',
timeline: 1,
uri: 'n-4.m4s'
}],
'segments correct with endNumber'
);
});

@@ -993,0 +1070,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc