mpd-parser
Advanced tools
Comparing version 0.19.1 to 0.19.2
@@ -0,1 +1,8 @@ | ||
<a name="0.19.2"></a> | ||
## [0.19.2](https://github.com/videojs/mpd-parser/compare/v0.19.1...v0.19.2) (2021-10-06) | ||
### Bug Fixes | ||
* caption services are allowed not to have a value ([#151](https://github.com/videojs/mpd-parser/issues/151)) ([c9803f1](https://github.com/videojs/mpd-parser/commit/c9803f1)) | ||
<a name="0.19.1"></a> | ||
@@ -2,0 +9,0 @@ ## [0.19.1](https://github.com/videojs/mpd-parser/compare/v0.19.0...v0.19.1) (2021-09-22) |
@@ -1,2 +0,2 @@ | ||
/*! @name mpd-parser @version 0.19.1 @license Apache-2.0 */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@xmldom/xmldom")):"function"==typeof define&&define.amd?define(["exports","@xmldom/xmldom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).mpdParser={},e.window)}(this,(function(e,t){"use strict";var r=function(e){return!!e&&"object"==typeof e},n=function e(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return n.reduce((function(t,n){return"object"!=typeof n||Object.keys(n).forEach((function(i){Array.isArray(t[i])&&Array.isArray(n[i])?t[i]=t[i].concat(n[i]):r(t[i])&&r(n[i])?t[i]=e(t[i],n[i]):t[i]=n[i]})),t}),{})},i=function(e){return e.reduce((function(e,t){return e.concat(t)}),[])},a=function(e){if(!e.length)return[];for(var t=[],r=0;r<e.length;r++)t.push(e[r]);return t},o="INVALID_NUMBER_OF_PERIOD",u="DASH_EMPTY_MANIFEST",s="DASH_INVALID_XML",c="NO_BASE_URL",d="SEGMENT_TIME_UNSPECIFIED",l="UNSUPPORTED_UTC_TIMING_SCHEME";var m=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,o;r=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,n=/^([^\/?#]*)([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=o.parseURL(e);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(t);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)):t;var u=o.parseURL(e);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(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=o})),f="http://example.com",p=function(e,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(e)&&(e=window.location&&window.location.href||"");var r="function"==typeof window.URL,n=/^\/\//.test(e),i=!window.location&&!/\/\//i.test(e);if(r?e=new window.URL(e,window.location||f):/\/\//i.test(e)||(e=m.buildAbsoluteURL(window.location&&window.location.href||"",e)),r){var a=new URL(t,e);return i?a.href.slice(f.length):n?a.href.slice(a.protocol.length):a.href}return m.buildAbsoluteURL(e,t)},h=function(e){var t=e.baseUrl,r=void 0===t?"":t,n=e.source,i=void 0===n?"":n,a=e.range,o=void 0===a?"":a,u=e.indexRange,s=void 0===u?"":u,c={uri:i,resolvedUri:p(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},v=function(e){return e&&"number"!=typeof e&&(e=parseInt(e,10)),isNaN(e)?null:e},b={static:function(e){var t=e.duration,r=e.timescale,n=void 0===r?1:r,i=e.sourceDuration,a=e.periodDuration,o=v(e.endNumber),u=t/n;return"number"==typeof o?{start:0,end:o}:"number"==typeof a?{start:0,end:a/u}:{start:0,end:i/u}},dynamic:function(e){var t=e.NOW,r=e.clientOffset,n=e.availabilityStartTime,i=e.timescale,a=void 0===i?1:i,o=e.duration,u=e.start,s=void 0===u?0:u,c=e.minimumUpdatePeriod,d=void 0===c?0:c,l=e.timeShiftBufferDepth,m=void 0===l?1/0:l,f=v(e.endNumber),p=(t+r)/1e3,h=n+s,b=p+d-h,g=Math.ceil(b*a/o),y=Math.floor((p-h-m)*a/o),U=Math.floor((p-h)*a/o);return{start:Math.max(0,y),end:"number"==typeof f?f:Math.min(g,U)}}},g=function(e){var t=e.type,r=e.duration,n=e.timescale,i=void 0===n?1:n,a=e.periodDuration,o=e.sourceDuration,u=b[t](e),s=function(e,t){for(var r=[],n=e;n<t;n++)r.push(n);return r}(u.start,u.end).map(function(e){return function(t,r){var n=e.duration,i=e.timescale,a=void 0===i?1:i,o=e.periodIndex,u=e.startNumber;return{number:(void 0===u?1:u)+t,duration:n/a,timeline:o,time:r*n}}}(e));if("static"===t){var c=s.length-1,d="number"==typeof a?a:o;s[c].duration=d-r/i*c}return s},y=function(e){var t=e.baseUrl,r=e.initialization,n=void 0===r?{}:r,i=e.sourceDuration,a=e.indexRange,o=void 0===a?"":a,u=e.duration;if(!t)throw new Error(c);var s=h({baseUrl:t,source:n.sourceURL,range:n.range}),d=h({baseUrl:t,source:t,indexRange:o});if(d.map=s,u){var l=g(e);l.length&&(d.duration=l[0].duration,d.timeline=l[0].timeline)}else i&&(d.duration=i,d.timeline=0);return d.number=0,[d]},U=function(e,t,r){for(var n=e.sidx.map?e.sidx.map:null,i=e.sidx.duration,a=e.timeline||0,o=e.sidx.byterange,u=o.offset+o.length,s=t.timescale,c=t.references.filter((function(e){return 1!==e.referenceType})),d=[],l=e.endList?"static":"dynamic",m=u+t.firstOffset,f=0;f<c.length;f++){var p=t.references[f],h=p.referencedSize,v=p.subsegmentDuration,b=y({baseUrl:r,timescale:s,timeline:a,periodIndex:a,duration:v,sourceDuration:i,indexRange:m+"-"+(m+h-1),type:l})[0];n&&(b.map=n),d.push(b),m+=h}return e.segments=d,e},w=function(e){return e&&e.uri+"-"+(t=e.byterange,r=t.offset+t.length-1,t.offset+"-"+r);var t,r},D=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}))},I=function(e,t){var r=w(e.sidx),n=r&&t[r]&&t[r].sidx;return n&&U(e,n,e.sidx.resolvedUri),e},R=function(e,t){if(void 0===t&&(t={}),!Object.keys(t).length)return e;for(var r in e)e[r]=I(e[r],t);return e},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,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(e){var t=e.attributes;return"video/mp4"===t.mimeType||"video/webm"===t.mimeType||"video"===t.contentType},E=function(e){var t=e.attributes;return"audio/mp4"===t.mimeType||"audio/webm"===t.mimeType||"audio"===t.contentType},S=function(e){var t=e.attributes;return"text/vtt"===t.mimeType||"text"===t.contentType},x=function(e,t,r){var n;if(void 0===r&&(r={}),!e.length)return{};var i=e[0].attributes,a=i.sourceDuration,o=i.type,u=i.suggestedPresentationDelay,s=i.minimumUpdatePeriod,c=D(e.filter(L)).map(T),d=D(e.filter(E)),l=e.filter(S),m=e.map((function(e){return e.attributes.captionServices})).filter(Boolean),f={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:(n={AUDIO:{},VIDEO:{}},n["CLOSED-CAPTIONS"]={},n.SUBTITLES={},n),uri:"",duration:a,playlists:R(c,r)};s>=0&&(f.minimumUpdatePeriod=1e3*s),t&&(f.locations=t),"dynamic"===o&&(f.suggestedPresentationDelay=u);var p=0===f.playlists.length;return d.length&&(f.mediaGroups.AUDIO.audio=function(e,t,r){var n;void 0===t&&(t={}),void 0===r&&(r=!1);var i=e.reduce((function(e,i){var a=i.attributes.role&&i.attributes.role.value||"",o=i.attributes.lang||"",u=i.attributes.label||"main";if(o&&!i.attributes.label){var s=a?" ("+a+")":"";u=""+i.attributes.lang+s}e[u]||(e[u]={language:o,autoselect:!0,default:"main"===a,playlists:[],uri:""});var c=I(function(e,t){var r,n=e.attributes,i=e.segments,a=e.sidx,o={attributes:(r={NAME:n.id,BANDWIDTH:n.bandwidth,CODECS:n.codecs},r["PROGRAM-ID"]=1,r),uri:"",endList:"static"===n.type,timeline:n.periodIndex,resolvedUri:"",targetDuration:n.duration,segments:i,mediaSequence:i.length?i[0].number:1};return n.contentProtection&&(o.contentProtection=n.contentProtection),a&&(o.sidx=a),t&&(o.attributes.AUDIO="audio",o.attributes.SUBTITLES="subs"),o}(i,r),t);return e[u].playlists.push(c),void 0===n&&"main"===a&&((n=i).default=!0),e}),{});return n||(i[Object.keys(i)[0]].default=!0),i}(d,r,p)),l.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:[],uri:""}),e[n].playlists.push(I(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,timeline:r.periodIndex,resolvedUri:r.baseUrl||"",targetDuration:r.duration,segments:n,mediaSequence:n.length?n[0].number:1}}(r),t)),e}),{})}(l,r)),m.length&&(f.mediaGroups["CLOSED-CAPTIONS"].cc=m.reduce((function(e,t){return t?(t.forEach((function(t){var r=t.channel,n=t.language;e[n]={autoselect:!1,default:!1,instreamId:r,language:n},t.hasOwnProperty("aspectRatio")&&(e[n].aspectRatio=t.aspectRatio),t.hasOwnProperty("easyReader")&&(e[n].easyReader=t.easyReader),t.hasOwnProperty("3D")&&(e[n]["3D"]=t["3D"])})),e):e}),{})),f},P=function(e,t,r){var n=e.NOW,i=e.clientOffset,a=e.availabilityStartTime,o=e.timescale,u=void 0===o?1:o,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*u-t)/r)},N=function(e,t){for(var r=e.type,n=e.minimumUpdatePeriod,i=void 0===n?0:n,a=e.media,o=void 0===a?"":a,u=e.sourceDuration,s=e.timescale,c=void 0===s?1:s,d=e.startNumber,l=void 0===d?1:d,m=e.periodIndex,f=[],p=-1,h=0;h<t.length;h++){var v=t[h],b=v.d,g=v.r||0,y=v.t||0;p<0&&(p=y),y&&y>p&&(p=y);var U=void 0;if(g<0){var w=h+1;U=w===t.length?"dynamic"===r&&i>0&&o.indexOf("$Number$")>0?P(e,p,b):(u*c-p)/b:(t[w].t-p)/b}else U=g+1;for(var D=l+f.length+U,I=l+f.length;I<D;)f.push({number:I,duration:b/c,time:p,timeline:m}),p+=b,I++}return f},O=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,A=function(e,t){return e.replace(O,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))},M=function(e,t){var r={RepresentationID:e.id,Bandwidth:e.bandwidth||0},n=e.initialization,i=void 0===n?{sourceURL:"",range:""}:n,a=h({baseUrl:e.baseUrl,source:A(i.sourceURL,r),range:i.range}),o=function(e,t){return e.duration||t?e.duration?g(e):N(e,t):[{number:e.startNumber||1,duration:e.sourceDuration,time:0,timeline:e.periodIndex}]}(e,t);return o.map((function(t){r.Number=t.number,r.Time=t.time;var n=A(e.media||"",r),i=e.timescale||1,o=e.presentationTimeOffset||0,u=e.periodStart+(t.time-o)/i;return{uri:n,timeline:t.timeline,duration:t.duration,resolvedUri:p(e.baseUrl||"",n),map:a,number:t.number,presentationTime:u}}))},C=function(e,t){var r=e.duration,n=e.segmentUrls,i=void 0===n?[]:n,a=e.periodStart;if(!r&&!t||r&&t)throw new Error(d);var o,u=i.map((function(t){return function(e,t){var r=e.baseUrl,n=e.initialization,i=void 0===n?{}:n,a=h({baseUrl:r,source:i.sourceURL,range:i.range}),o=h({baseUrl:r,source:t.media,range:t.mediaRange});return o.map=a,o}(e,t)}));return r&&(o=g(e)),t&&(o=N(e,t)),o.map((function(t,r){if(u[r]){var n=u[r],i=e.timescale||1,o=e.presentationTimeOffset||0;return n.timeline=t.timeline,n.duration=t.duration,n.number=t.number,n.presentationTime=a+(t.time-o)/i,n}})).filter((function(e){return e}))},z=function(e){var t,r,i=e.attributes,a=e.segmentInfo;a.template?(r=M,t=n(i,a.template)):a.base?(r=y,t=n(i,a.base)):a.list&&(r=C,t=n(i,a.list));var o={attributes:i};if(!r)return o;var u=r(t,a.segmentTimeline);if(t.duration){var s=t,c=s.duration,d=s.timescale,l=void 0===d?1:d;t.duration=c/l}else u.length?t.duration=u.reduce((function(e,t){return Math.max(e,Math.ceil(t.duration))}),0):t.duration=0;return o.attributes=t,o.segments=u,a.base&&t.indexRange&&(o.sidx=u[0],o.segments=[]),o},B=function(e){return e.map(z)},F=function(e,t){return a(e.childNodes).filter((function(e){return e.tagName===t}))},_=function(e){return e.textContent.trim()},j=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],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)},q={mediaPresentationDuration:function(e){return j(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 j(e)},suggestedPresentationDelay:function(e){return j(e)},type:function(e){return e},timeShiftBufferDepth:function(e){return j(e)},start:function(e){return j(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)},presentationTimeOffset:function(e){return parseInt(e,10)},duration:function(e){var t=parseInt(e,10);return isNaN(t)?j(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}},$=function(e){return e&&e.attributes?a(e.attributes).reduce((function(e,t){var r=q[t.name]||q.DEFAULT;return e[t.name]=r(t.value),e}),{}):{}};function k(e){for(var t,r=(t=e,window.atob?window.atob(t):Buffer.from(t,"base64").toString("binary")),n=new Uint8Array(r.length),i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return n}var G={"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"},H=function(e,t){return t.length?i(e.map((function(e){return t.map((function(t){return p(e,_(t))}))}))):e},W=function(e){var t=F(e,"SegmentTemplate")[0],r=F(e,"SegmentList")[0],i=r&&F(r,"SegmentURL").map((function(e){return n({tag:"SegmentURL"},$(e))})),a=F(e,"SegmentBase")[0],o=r||t,u=o&&F(o,"SegmentTimeline")[0],s=r||a||t,c=s&&F(s,"Initialization")[0],d=t&&$(t);d&&c?d.initialization=c&&$(c):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});var l={template:d,segmentTimeline:u&&F(u,"S").map((function(e){return $(e)})),list:r&&n($(r),{segmentUrls:i,initialization:$(c)}),base:a&&n($(a),{initialization:$(c)})};return Object.keys(l).forEach((function(e){l[e]||delete l[e]})),l},V=function(e,t,r){return function(a){var o,u=$(a),s=H(t,F(a,"BaseURL")),c=F(a,"Role")[0],d={role:$(c)},l=n(e,u,d),m=F(a,"Accessibility")[0],f="urn:scte:dash:cc:cea-608:2015"===(o=$(m)).schemeIdUri?o.value.split(";").map((function(e){var t,r;if(r=e,/^CC\d=/.test(e)){var n=e.split("=");t=n[0],r=n[1]}else/^CC\d$/.test(e)&&(t=e);return{channel:t,language:r}})):"urn:scte:dash:cc:cea-708:2015"===o.schemeIdUri?o.value.split(";").map((function(e){var t={channel:void 0,language:void 0,aspectRatio:1,easyReader:0,"3D":0};if(/=/.test(e)){var r=e.split("="),n=r[0],i=r[1],a=void 0===i?"":i;t.channel=n,t.language=e,a.split(",").forEach((function(e){var r=e.split(":"),n=r[0],i=r[1];"lang"===n?t.language=i:"er"===n?t.easyReader=Number(i):"war"===n?t.aspectRatio=Number(i):"3D"===n&&(t["3D"]=Number(i))}))}else t.language=e;return t.channel&&(t.channel="SERVICE"+t.channel),t})):void 0;f&&(l=n(l,{captionServices:f}));var p=F(a,"Label")[0];if(p&&p.childNodes.length){var h=p.childNodes[0].nodeValue.trim();l=n(l,{label:h})}var v=F(a,"ContentProtection").reduce((function(e,t){var r=$(t),n=G[r.schemeIdUri];if(n){e[n]={attributes:r};var i=F(t,"cenc:pssh")[0];if(i){var a=_(i),o=a&&k(a);e[n].pssh=o}}return e}),{});Object.keys(v).length&&(l=n(l,{contentProtection:v}));var b=W(a),g=F(a,"Representation"),y=n(r,b);return i(g.map(function(e,t,r){return function(i){var a=F(i,"BaseURL"),o=H(t,a),u=n(e,$(i)),s=W(i);return o.map((function(e){return{segmentInfo:n(r,s),attributes:n(u,{baseUrl:e})}}))}}(l,s,y)))}},X=function(e,t){return function(r,a){var o=H(t,F(r.node,"BaseURL")),u=parseInt(r.attributes.id,10),s=window.isNaN(u)?a:u,c=n(e,{periodIndex:s,periodStart:r.attributes.start});"number"==typeof r.attributes.duration&&(c.periodDuration=r.attributes.duration);var d=F(r.node,"AdaptationSet"),l=W(r.node);return i(d.map(V(c,o,l)))}},Y=function(e,t){void 0===t&&(t={});var r=t,n=r.manifestUri,a=void 0===n?"":n,u=r.NOW,s=void 0===u?Date.now():u,c=r.clientOffset,d=void 0===c?0:c,l=F(e,"Period");if(!l.length)throw new Error(o);var m=F(e,"Location"),f=$(e),p=H([a],F(e,"BaseURL"));f.type=f.type||"static",f.sourceDuration=f.mediaPresentationDuration||0,f.NOW=s,f.clientOffset=d,m.length&&(f.locations=m.map(_));var h=[];return l.forEach((function(e,t){var r=$(e),n=h[t-1];r.start=function(e){var t=e.attributes,r=e.priorPeriodAttributes,n=e.mpdType;return"number"==typeof t.start?t.start:r&&"number"==typeof r.start&&"number"==typeof r.duration?r.start+r.duration:r||"static"!==n?null:0}({attributes:r,priorPeriodAttributes:n?n.attributes:null,mpdType:f.type}),h.push({node:e,attributes:r})})),{locations:f.locations,representationInfo:i(h.map(X(f,p)))}},Z=function(e){if(""===e)throw new Error(u);var r,n,i=new t.DOMParser;try{n=(r=i.parseFromString(e,"application/xml"))&&"MPD"===r.documentElement.tagName?r.documentElement:null}catch(e){}if(!n||n&&n.getElementsByTagName("parsererror").length>0)throw new Error(s);return n};e.VERSION="0.19.1",e.addSidxSegmentsToPlaylist=U,e.generateSidxKey=w,e.inheritAttributes=Y,e.parse=function(e,t){void 0===t&&(t={});var r=Y(Z(e),t),n=B(r.representationInfo);return x(n,r.locations,t.sidxMapping)},e.parseUTCTiming=function(e){return function(e){var t=F(e,"UTCTiming")[0];if(!t)return null;var r=$(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;default:throw new Error(l)}return r}(Z(e))},e.stringToMpdXml=Z,e.toM3u8=x,e.toPlaylists=B,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
/*! @name mpd-parser @version 0.19.2 @license Apache-2.0 */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@xmldom/xmldom")):"function"==typeof define&&define.amd?define(["exports","@xmldom/xmldom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).mpdParser={},e.window)}(this,(function(e,t){"use strict";var r=function(e){return!!e&&"object"==typeof e},n=function e(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return n.reduce((function(t,n){return"object"!=typeof n||Object.keys(n).forEach((function(i){Array.isArray(t[i])&&Array.isArray(n[i])?t[i]=t[i].concat(n[i]):r(t[i])&&r(n[i])?t[i]=e(t[i],n[i]):t[i]=n[i]})),t}),{})},i=function(e){return e.reduce((function(e,t){return e.concat(t)}),[])},a=function(e){if(!e.length)return[];for(var t=[],r=0;r<e.length;r++)t.push(e[r]);return t},o="INVALID_NUMBER_OF_PERIOD",u="DASH_EMPTY_MANIFEST",s="DASH_INVALID_XML",c="NO_BASE_URL",d="SEGMENT_TIME_UNSPECIFIED",l="UNSUPPORTED_UTC_TIMING_SCHEME";var m=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,o;r=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,n=/^([^\/?#]*)([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=o.parseURL(e);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(t);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)):t;var u=o.parseURL(e);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(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=o})),f="http://example.com",p=function(e,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(e)&&(e=window.location&&window.location.href||"");var r="function"==typeof window.URL,n=/^\/\//.test(e),i=!window.location&&!/\/\//i.test(e);if(r?e=new window.URL(e,window.location||f):/\/\//i.test(e)||(e=m.buildAbsoluteURL(window.location&&window.location.href||"",e)),r){var a=new URL(t,e);return i?a.href.slice(f.length):n?a.href.slice(a.protocol.length):a.href}return m.buildAbsoluteURL(e,t)},h=function(e){var t=e.baseUrl,r=void 0===t?"":t,n=e.source,i=void 0===n?"":n,a=e.range,o=void 0===a?"":a,u=e.indexRange,s=void 0===u?"":u,c={uri:i,resolvedUri:p(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},v=function(e){return e&&"number"!=typeof e&&(e=parseInt(e,10)),isNaN(e)?null:e},b={static:function(e){var t=e.duration,r=e.timescale,n=void 0===r?1:r,i=e.sourceDuration,a=e.periodDuration,o=v(e.endNumber),u=t/n;return"number"==typeof o?{start:0,end:o}:"number"==typeof a?{start:0,end:a/u}:{start:0,end:i/u}},dynamic:function(e){var t=e.NOW,r=e.clientOffset,n=e.availabilityStartTime,i=e.timescale,a=void 0===i?1:i,o=e.duration,u=e.start,s=void 0===u?0:u,c=e.minimumUpdatePeriod,d=void 0===c?0:c,l=e.timeShiftBufferDepth,m=void 0===l?1/0:l,f=v(e.endNumber),p=(t+r)/1e3,h=n+s,b=p+d-h,g=Math.ceil(b*a/o),y=Math.floor((p-h-m)*a/o),U=Math.floor((p-h)*a/o);return{start:Math.max(0,y),end:"number"==typeof f?f:Math.min(g,U)}}},g=function(e){var t=e.type,r=e.duration,n=e.timescale,i=void 0===n?1:n,a=e.periodDuration,o=e.sourceDuration,u=b[t](e),s=function(e,t){for(var r=[],n=e;n<t;n++)r.push(n);return r}(u.start,u.end).map(function(e){return function(t,r){var n=e.duration,i=e.timescale,a=void 0===i?1:i,o=e.periodIndex,u=e.startNumber;return{number:(void 0===u?1:u)+t,duration:n/a,timeline:o,time:r*n}}}(e));if("static"===t){var c=s.length-1,d="number"==typeof a?a:o;s[c].duration=d-r/i*c}return s},y=function(e){var t=e.baseUrl,r=e.initialization,n=void 0===r?{}:r,i=e.sourceDuration,a=e.indexRange,o=void 0===a?"":a,u=e.duration;if(!t)throw new Error(c);var s=h({baseUrl:t,source:n.sourceURL,range:n.range}),d=h({baseUrl:t,source:t,indexRange:o});if(d.map=s,u){var l=g(e);l.length&&(d.duration=l[0].duration,d.timeline=l[0].timeline)}else i&&(d.duration=i,d.timeline=0);return d.number=0,[d]},U=function(e,t,r){for(var n=e.sidx.map?e.sidx.map:null,i=e.sidx.duration,a=e.timeline||0,o=e.sidx.byterange,u=o.offset+o.length,s=t.timescale,c=t.references.filter((function(e){return 1!==e.referenceType})),d=[],l=e.endList?"static":"dynamic",m=u+t.firstOffset,f=0;f<c.length;f++){var p=t.references[f],h=p.referencedSize,v=p.subsegmentDuration,b=y({baseUrl:r,timescale:s,timeline:a,periodIndex:a,duration:v,sourceDuration:i,indexRange:m+"-"+(m+h-1),type:l})[0];n&&(b.map=n),d.push(b),m+=h}return e.segments=d,e},w=function(e){return e&&e.uri+"-"+(t=e.byterange,r=t.offset+t.length-1,t.offset+"-"+r);var t,r},D=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}))},I=function(e,t){var r=w(e.sidx),n=r&&t[r]&&t[r].sidx;return n&&U(e,n,e.sidx.resolvedUri),e},R=function(e,t){if(void 0===t&&(t={}),!Object.keys(t).length)return e;for(var r in e)e[r]=I(e[r],t);return e},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,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(e){var t=e.attributes;return"video/mp4"===t.mimeType||"video/webm"===t.mimeType||"video"===t.contentType},E=function(e){var t=e.attributes;return"audio/mp4"===t.mimeType||"audio/webm"===t.mimeType||"audio"===t.contentType},S=function(e){var t=e.attributes;return"text/vtt"===t.mimeType||"text"===t.contentType},x=function(e,t,r){var n;if(void 0===r&&(r={}),!e.length)return{};var i=e[0].attributes,a=i.sourceDuration,o=i.type,u=i.suggestedPresentationDelay,s=i.minimumUpdatePeriod,c=D(e.filter(L)).map(T),d=D(e.filter(E)),l=e.filter(S),m=e.map((function(e){return e.attributes.captionServices})).filter(Boolean),f={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:(n={AUDIO:{},VIDEO:{}},n["CLOSED-CAPTIONS"]={},n.SUBTITLES={},n),uri:"",duration:a,playlists:R(c,r)};s>=0&&(f.minimumUpdatePeriod=1e3*s),t&&(f.locations=t),"dynamic"===o&&(f.suggestedPresentationDelay=u);var p=0===f.playlists.length;return d.length&&(f.mediaGroups.AUDIO.audio=function(e,t,r){var n;void 0===t&&(t={}),void 0===r&&(r=!1);var i=e.reduce((function(e,i){var a=i.attributes.role&&i.attributes.role.value||"",o=i.attributes.lang||"",u=i.attributes.label||"main";if(o&&!i.attributes.label){var s=a?" ("+a+")":"";u=""+i.attributes.lang+s}e[u]||(e[u]={language:o,autoselect:!0,default:"main"===a,playlists:[],uri:""});var c=I(function(e,t){var r,n=e.attributes,i=e.segments,a=e.sidx,o={attributes:(r={NAME:n.id,BANDWIDTH:n.bandwidth,CODECS:n.codecs},r["PROGRAM-ID"]=1,r),uri:"",endList:"static"===n.type,timeline:n.periodIndex,resolvedUri:"",targetDuration:n.duration,segments:i,mediaSequence:i.length?i[0].number:1};return n.contentProtection&&(o.contentProtection=n.contentProtection),a&&(o.sidx=a),t&&(o.attributes.AUDIO="audio",o.attributes.SUBTITLES="subs"),o}(i,r),t);return e[u].playlists.push(c),void 0===n&&"main"===a&&((n=i).default=!0),e}),{});return n||(i[Object.keys(i)[0]].default=!0),i}(d,r,p)),l.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:[],uri:""}),e[n].playlists.push(I(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,timeline:r.periodIndex,resolvedUri:r.baseUrl||"",targetDuration:r.duration,segments:n,mediaSequence:n.length?n[0].number:1}}(r),t)),e}),{})}(l,r)),m.length&&(f.mediaGroups["CLOSED-CAPTIONS"].cc=m.reduce((function(e,t){return t?(t.forEach((function(t){var r=t.channel,n=t.language;e[n]={autoselect:!1,default:!1,instreamId:r,language:n},t.hasOwnProperty("aspectRatio")&&(e[n].aspectRatio=t.aspectRatio),t.hasOwnProperty("easyReader")&&(e[n].easyReader=t.easyReader),t.hasOwnProperty("3D")&&(e[n]["3D"]=t["3D"])})),e):e}),{})),f},P=function(e,t,r){var n=e.NOW,i=e.clientOffset,a=e.availabilityStartTime,o=e.timescale,u=void 0===o?1:o,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*u-t)/r)},N=function(e,t){for(var r=e.type,n=e.minimumUpdatePeriod,i=void 0===n?0:n,a=e.media,o=void 0===a?"":a,u=e.sourceDuration,s=e.timescale,c=void 0===s?1:s,d=e.startNumber,l=void 0===d?1:d,m=e.periodIndex,f=[],p=-1,h=0;h<t.length;h++){var v=t[h],b=v.d,g=v.r||0,y=v.t||0;p<0&&(p=y),y&&y>p&&(p=y);var U=void 0;if(g<0){var w=h+1;U=w===t.length?"dynamic"===r&&i>0&&o.indexOf("$Number$")>0?P(e,p,b):(u*c-p)/b:(t[w].t-p)/b}else U=g+1;for(var D=l+f.length+U,I=l+f.length;I<D;)f.push({number:I,duration:b/c,time:p,timeline:m}),p+=b,I++}return f},O=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,A=function(e,t){return e.replace(O,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))},M=function(e,t){var r={RepresentationID:e.id,Bandwidth:e.bandwidth||0},n=e.initialization,i=void 0===n?{sourceURL:"",range:""}:n,a=h({baseUrl:e.baseUrl,source:A(i.sourceURL,r),range:i.range}),o=function(e,t){return e.duration||t?e.duration?g(e):N(e,t):[{number:e.startNumber||1,duration:e.sourceDuration,time:0,timeline:e.periodIndex}]}(e,t);return o.map((function(t){r.Number=t.number,r.Time=t.time;var n=A(e.media||"",r),i=e.timescale||1,o=e.presentationTimeOffset||0,u=e.periodStart+(t.time-o)/i;return{uri:n,timeline:t.timeline,duration:t.duration,resolvedUri:p(e.baseUrl||"",n),map:a,number:t.number,presentationTime:u}}))},C=function(e,t){var r=e.duration,n=e.segmentUrls,i=void 0===n?[]:n,a=e.periodStart;if(!r&&!t||r&&t)throw new Error(d);var o,u=i.map((function(t){return function(e,t){var r=e.baseUrl,n=e.initialization,i=void 0===n?{}:n,a=h({baseUrl:r,source:i.sourceURL,range:i.range}),o=h({baseUrl:r,source:t.media,range:t.mediaRange});return o.map=a,o}(e,t)}));return r&&(o=g(e)),t&&(o=N(e,t)),o.map((function(t,r){if(u[r]){var n=u[r],i=e.timescale||1,o=e.presentationTimeOffset||0;return n.timeline=t.timeline,n.duration=t.duration,n.number=t.number,n.presentationTime=a+(t.time-o)/i,n}})).filter((function(e){return e}))},z=function(e){var t,r,i=e.attributes,a=e.segmentInfo;a.template?(r=M,t=n(i,a.template)):a.base?(r=y,t=n(i,a.base)):a.list&&(r=C,t=n(i,a.list));var o={attributes:i};if(!r)return o;var u=r(t,a.segmentTimeline);if(t.duration){var s=t,c=s.duration,d=s.timescale,l=void 0===d?1:d;t.duration=c/l}else u.length?t.duration=u.reduce((function(e,t){return Math.max(e,Math.ceil(t.duration))}),0):t.duration=0;return o.attributes=t,o.segments=u,a.base&&t.indexRange&&(o.sidx=u[0],o.segments=[]),o},B=function(e){return e.map(z)},F=function(e,t){return a(e.childNodes).filter((function(e){return e.tagName===t}))},_=function(e){return e.textContent.trim()},j=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],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)},q={mediaPresentationDuration:function(e){return j(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 j(e)},suggestedPresentationDelay:function(e){return j(e)},type:function(e){return e},timeShiftBufferDepth:function(e){return j(e)},start:function(e){return j(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)},presentationTimeOffset:function(e){return parseInt(e,10)},duration:function(e){var t=parseInt(e,10);return isNaN(t)?j(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}},$=function(e){return e&&e.attributes?a(e.attributes).reduce((function(e,t){var r=q[t.name]||q.DEFAULT;return e[t.name]=r(t.value),e}),{}):{}};function k(e){for(var t,r=(t=e,window.atob?window.atob(t):Buffer.from(t,"base64").toString("binary")),n=new Uint8Array(r.length),i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return n}var G={"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"},H=function(e,t){return t.length?i(e.map((function(e){return t.map((function(t){return p(e,_(t))}))}))):e},W=function(e){var t=F(e,"SegmentTemplate")[0],r=F(e,"SegmentList")[0],i=r&&F(r,"SegmentURL").map((function(e){return n({tag:"SegmentURL"},$(e))})),a=F(e,"SegmentBase")[0],o=r||t,u=o&&F(o,"SegmentTimeline")[0],s=r||a||t,c=s&&F(s,"Initialization")[0],d=t&&$(t);d&&c?d.initialization=c&&$(c):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});var l={template:d,segmentTimeline:u&&F(u,"S").map((function(e){return $(e)})),list:r&&n($(r),{segmentUrls:i,initialization:$(c)}),base:a&&n($(a),{initialization:$(c)})};return Object.keys(l).forEach((function(e){l[e]||delete l[e]})),l},V=function(e,t,r){return function(a){var o,u=$(a),s=H(t,F(a,"BaseURL")),c=F(a,"Role")[0],d={role:$(c)},l=n(e,u,d),m=F(a,"Accessibility")[0],f="urn:scte:dash:cc:cea-608:2015"===(o=$(m)).schemeIdUri?("string"!=typeof o.value?[]:o.value.split(";")).map((function(e){var t,r;if(r=e,/^CC\d=/.test(e)){var n=e.split("=");t=n[0],r=n[1]}else/^CC\d$/.test(e)&&(t=e);return{channel:t,language:r}})):"urn:scte:dash:cc:cea-708:2015"===o.schemeIdUri?("string"!=typeof o.value?[]:o.value.split(";")).map((function(e){var t={channel:void 0,language:void 0,aspectRatio:1,easyReader:0,"3D":0};if(/=/.test(e)){var r=e.split("="),n=r[0],i=r[1],a=void 0===i?"":i;t.channel=n,t.language=e,a.split(",").forEach((function(e){var r=e.split(":"),n=r[0],i=r[1];"lang"===n?t.language=i:"er"===n?t.easyReader=Number(i):"war"===n?t.aspectRatio=Number(i):"3D"===n&&(t["3D"]=Number(i))}))}else t.language=e;return t.channel&&(t.channel="SERVICE"+t.channel),t})):void 0;f&&(l=n(l,{captionServices:f}));var p=F(a,"Label")[0];if(p&&p.childNodes.length){var h=p.childNodes[0].nodeValue.trim();l=n(l,{label:h})}var v=F(a,"ContentProtection").reduce((function(e,t){var r=$(t),n=G[r.schemeIdUri];if(n){e[n]={attributes:r};var i=F(t,"cenc:pssh")[0];if(i){var a=_(i),o=a&&k(a);e[n].pssh=o}}return e}),{});Object.keys(v).length&&(l=n(l,{contentProtection:v}));var b=W(a),g=F(a,"Representation"),y=n(r,b);return i(g.map(function(e,t,r){return function(i){var a=F(i,"BaseURL"),o=H(t,a),u=n(e,$(i)),s=W(i);return o.map((function(e){return{segmentInfo:n(r,s),attributes:n(u,{baseUrl:e})}}))}}(l,s,y)))}},X=function(e,t){return function(r,a){var o=H(t,F(r.node,"BaseURL")),u=parseInt(r.attributes.id,10),s=window.isNaN(u)?a:u,c=n(e,{periodIndex:s,periodStart:r.attributes.start});"number"==typeof r.attributes.duration&&(c.periodDuration=r.attributes.duration);var d=F(r.node,"AdaptationSet"),l=W(r.node);return i(d.map(V(c,o,l)))}},Y=function(e,t){void 0===t&&(t={});var r=t,n=r.manifestUri,a=void 0===n?"":n,u=r.NOW,s=void 0===u?Date.now():u,c=r.clientOffset,d=void 0===c?0:c,l=F(e,"Period");if(!l.length)throw new Error(o);var m=F(e,"Location"),f=$(e),p=H([a],F(e,"BaseURL"));f.type=f.type||"static",f.sourceDuration=f.mediaPresentationDuration||0,f.NOW=s,f.clientOffset=d,m.length&&(f.locations=m.map(_));var h=[];return l.forEach((function(e,t){var r=$(e),n=h[t-1];r.start=function(e){var t=e.attributes,r=e.priorPeriodAttributes,n=e.mpdType;return"number"==typeof t.start?t.start:r&&"number"==typeof r.start&&"number"==typeof r.duration?r.start+r.duration:r||"static"!==n?null:0}({attributes:r,priorPeriodAttributes:n?n.attributes:null,mpdType:f.type}),h.push({node:e,attributes:r})})),{locations:f.locations,representationInfo:i(h.map(X(f,p)))}},Z=function(e){if(""===e)throw new Error(u);var r,n,i=new t.DOMParser;try{n=(r=i.parseFromString(e,"application/xml"))&&"MPD"===r.documentElement.tagName?r.documentElement:null}catch(e){}if(!n||n&&n.getElementsByTagName("parsererror").length>0)throw new Error(s);return n};e.VERSION="0.19.2",e.addSidxSegmentsToPlaylist=U,e.generateSidxKey=w,e.inheritAttributes=Y,e.parse=function(e,t){void 0===t&&(t={});var r=Y(Z(e),t),n=B(r.representationInfo);return x(n,r.locations,t.sidxMapping)},e.parseUTCTiming=function(e){return function(e){var t=F(e,"UTCTiming")[0];if(!t)return null;var r=$(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;default:throw new Error(l)}return r}(Z(e))},e.stringToMpdXml=Z,e.toM3u8=x,e.toPlaylists=B,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "mpd-parser", | ||
"version": "0.19.1", | ||
"version": "0.19.2", | ||
"description": "mpd parser", | ||
@@ -5,0 +5,0 @@ "main": "dist/mpd-parser.cjs.js", |
@@ -202,3 +202,3 @@ import window from 'global/window'; | ||
if (service.schemeIdUri === 'urn:scte:dash:cc:cea-608:2015') { | ||
const values = service.value.split(';'); | ||
const values = typeof service.value !== 'string' ? [] : service.value.split(';'); | ||
@@ -221,3 +221,3 @@ return values.map((value) => { | ||
} else if (service.schemeIdUri === 'urn:scte:dash:cc:cea-708:2015') { | ||
const values = service.value.split(';'); | ||
const values = typeof service.value !== 'string' ? [] : service.value.split(';'); | ||
@@ -224,0 +224,0 @@ return values.map((value) => { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
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
713546
18889