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

mpd-parser

Package Overview
Dependencies
Maintainers
14
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.8.1 to 0.8.2-0

5

dist/mpd-parser.min.js

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

/*! @name mpd-parser @version 0.8.1 @license Apache-2.0 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("global/window")):"function"==typeof define&&define.amd?define(["exports","global/window"],t):t(e.mpdParser={},e.window)}(this,function(e,t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;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.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},u="INVALID_NUMBER_OF_PERIOD",o="DASH_EMPTY_MANIFEST",s="DASH_INVALID_XML",d="NO_BASE_URL",c="SEGMENT_TIME_UNSPECIFIED",l="UNSUPPORTED_UTC_TIMING_SCHEME";"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var m,f=(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 d={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(d.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var c=o.path,l=c.substring(0,c.lastIndexOf("/")+1)+a.path;d.path=u.normalizePath(l)}else d.path=o.path,a.params||(d.params=o.params,a.query||(d.query=o.query));return null===d.path&&(d.path=r.alwaysNormalize?u.normalizePath(a.path):a.path),u.buildURLFromParts(d)},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}(m={exports:{}},m.exports),m.exports),p=function(e,r){return/^[a-z]+:/i.test(r)?r:(/\/\//i.test(e)||(e=f.buildAbsoluteURL(t.location.href,e)),f.buildAbsoluteURL(e,r))},v=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,d={uri:i,resolvedUri:p(r||"",i)};if(u||s){var c=(u||s).split("-"),l=parseInt(c[0],10),m=parseInt(c[1],10);d.byterange={length:m-l+1,offset:l}}return d},h={static:function(e){var t=e.duration,r=e.timescale,n=void 0===r?1:r,i=e.sourceDuration;return{start:0,end: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,d=e.minimumUpdatePeriod,c=void 0===d?0:d,l=e.timeShiftBufferDepth,m=void 0===l?1/0:l,f=(t+r)/1e3,p=n+s,v=f+c-p,h=Math.ceil(v*a/u),g=Math.floor((f-p-m)*a/u),b=Math.floor((f-p)*a/u);return{start:Math.max(0,g),end:Math.min(h,b)}}},g=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=h[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 d=s.length-1;s[d].duration=u-n/a*d}return s},b=function(e){var t=e.baseUrl,r=e.initialization,n=void 0===r?{}:r,i=e.sourceDuration,a=e.timescale,u=void 0===a?1:a,o=e.indexRange,s=void 0===o?"":o,c=e.duration;if(!t)throw new Error(d);var l=v({baseUrl:t,source:n.sourceURL,range:n.range}),m=v({baseUrl:t,source:t,indexRange:s});if(m.map=l,c){var f=g(e);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]},U=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,d=t.references.filter(function(e){return 1!==e.referenceType}),c=[],l=o+t.firstOffset,m=0;m<d.length;m++){var f=t.references[m],p=f.referencedSize,v=f.subsegmentDuration,h=b({baseUrl:r,timescale:s,timeline:a,periodIndex:a,duration:v,sourceDuration:i,indexRange:l+"-"+(l+p-1)})[0];n&&(h.map=n),c.push(h),l+=p}return e.segments=c,e},y=function(e){var t;return(t=e.reduce(function(e,t){var r,n=t.attributes.id+(t.attributes.lang||"");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;return 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){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&&U(n,a,n.sidx.resolvedUri)}}var u,o;return e},D=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},w=function(e,t){var r;if(void 0===t&&(t={}),!e.length)return{};var n=e[0].attributes,i=n.sourceDuration,a=n.minimumUpdatePeriod,u=void 0===a?0:a,o=y(e.filter(function(e){var t=e.attributes;return"video/mp4"===t.mimeType||"video"===t.contentType})).map(D),s=y(e.filter(function(e){var t=e.attributes;return"audio/mp4"===t.mimeType||"audio"===t.contentType})),d=e.filter(function(e){var t=e.attributes;return"text/vtt"===t.mimeType||"text"===t.contentType}),c={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:(r={AUDIO:{},VIDEO:{}},r["CLOSED-CAPTIONS"]={},r.SUBTITLES={},r),uri:"",duration:i,playlists:I(o,t),minimumUpdatePeriod:1e3*u};return s.length&&(c.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:(e[u]={language:a,autoselect:!0,default:"main"===i,playlists:I([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}(n)],t),uri:""},void 0===r&&"main"===i&&((r=n).default=!0),e)},{});r||(n[Object.keys(n)[0]].default=!0);return n}(s,t)),d.length&&(c.mediaGroups.SUBTITLES.subs=function(e,t){return void 0===t&&(t={}),e.reduce(function(e,r){var n,i,a,u,o=r.attributes.lang||"text";return e[o]?e:(e[o]={language:o,default:!1,autoselect:!1,playlists:I([(n=r,a=n.attributes,u=n.segments,void 0===u&&(u=[{uri:a.baseUrl,timeline:a.periodIndex,resolvedUri:a.baseUrl||"",duration:a.sourceDuration,number:0}],a.duration=a.sourceDuration),{attributes:(i={NAME:a.id,BANDWIDTH:a.bandwidth},i["PROGRAM-ID"]=1,i),uri:"",endList:"static"===(a.type||"static"),timeline:a.periodIndex,resolvedUri:a.baseUrl||"",targetDuration:a.duration,segments:u,mediaSequence:u.length?u[0].number:1})],t),uri:""},e)},{})}(d,t)),c},x=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,d=void 0===s?0:s,c=e.minimumUpdatePeriod,l=(n+i)/1e3+(void 0===c?0:c)-(a+d);return Math.ceil((l*o-t)/r)},L=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,d=e.timescale,c=void 0===d?1:d,l=e.startNumber,m=void 0===l?1:l,f=e.periodIndex,p=[],v=-1,h=0;h<t.length;h++){var g=t[h],b=g.d,U=g.r||0,y=g.t||0;v<0&&(v=y),y&&y>v&&(v=y);var I=void 0;if(U<0){var D=h+1;I=D===t.length?"dynamic"===n&&a>0&&o.indexOf("$Number$")>0?x(e,v,b):(s*c-v)/b:(t[D].t-v)/b}else I=U+1;for(var w=m+p.length+I,L=m+p.length;L<w;)p.push({number:L,duration:b/c,time:v,timeline:f}),v+=b,L++}return p},R=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,E=function(e,t){return e.replace(R,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))},P=function(e,t){var r={RepresentationID:e.id,Bandwidth:e.bandwidth||0},n=e.initialization,i=void 0===n?{sourceURL:"",range:""}:n,a=v({baseUrl:e.baseUrl,source:E(i.sourceURL,r),range:i.range});return function(e,t){return e.duration||t?e.duration?g(e):L(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=E(e.media||"",r);return{uri:n,timeline:t.timeline,duration:t.duration,resolvedUri:p(e.baseUrl||"",n),map:a,number:t.number}})},T=function(e,t){var r=e.duration,n=e.segmentUrls,i=void 0===n?[]:n;if(!r&&!t||r&&t)throw new Error(c);var a,u=i.map(function(t){return function(e,t){var r=e.baseUrl,n=e.initialization,i=void 0===n?{}:n,a=v({baseUrl:r,source:i.sourceURL,range:i.range}),u=v({baseUrl:r,source:t.media,range:t.mediaRange});return u.map=a,u}(e,t)});return r&&(a=g(e)),t&&(a=L(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})},S=function(e){var t,r,i=e.attributes,a=e.segmentInfo;a.template?(r=P,t=n(i,a.template)):a.base?(r=b,t=n(i,a.base)):a.list&&(r=T,t=n(i,a.list));var u={attributes:i};if(!r)return u;var o=r(t,a.timeline);if(t.duration){var s=t,d=s.duration,c=s.timescale,l=void 0===c?1:c;t.duration=d/l}else o.length?t.duration=o.reduce(function(e,t){return Math.max(e,Math.ceil(t.duration))},0):t.duration=0;return u.attributes=t,u.segments=o,a.base&&t.indexRange&&(u.sidx=o[0],u.segments=[]),u},N=function(e,t){return a(e.childNodes).filter(function(e){return e.tagName===t})},O=function(e){return e.textContent.trim()},A=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)},M={mediaPresentationDuration:function(e){return A(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 A(e)},timeShiftBufferDepth:function(e){return A(e)},start:function(e){return A(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)?A(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}},z=function(e){return e&&e.attributes?a(e.attributes).reduce(function(e,t){var r=M[t.name]||M.DEFAULT;return e[t.name]=r(t.value),e},{}):{}};var B={"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"},C=function(e,t){return t.length?i(e.map(function(e){return t.map(function(t){return p(e,O(t))})})):e},F=function(e){var t=N(e,"SegmentTemplate")[0],r=N(e,"SegmentList")[0],i=r&&N(r,"SegmentURL").map(function(e){return n({tag:"SegmentURL"},z(e))}),a=N(e,"SegmentBase")[0],u=r||t,o=u&&N(u,"SegmentTimeline")[0],s=r||a||t,d=s&&N(s,"Initialization")[0],c=t&&z(t);c&&d?c.initialization=d&&z(d):c&&c.initialization&&(c.initialization={sourceURL:c.initialization});var l={template:c,timeline:o&&N(o,"S").map(function(e){return z(e)}),list:r&&n(z(r),{segmentUrls:i,initialization:z(d)}),base:a&&n(z(a),{initialization:z(d)})};return Object.keys(l).forEach(function(e){l[e]||delete l[e]}),l},_=function(e){return e.reduce(function(e,r){var n=z(r),i=B[n.schemeIdUri];if(i){e[i]={attributes:n};var a=N(r,"cenc:pssh")[0];if(a){var u=O(a),o=u&&function(e){for(var r=t.atob(e),n=new Uint8Array(r.length),i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return n}(u);e[i].pssh=o}}return e},{})},j=function(e,t,r){return function(a){var u=z(a),o=C(t,N(a,"BaseURL")),s=N(a,"Role")[0],d={role:z(s)},c=n(e,u,d),l=_(N(a,"ContentProtection"));Object.keys(l).length&&(c=n(c,{contentProtection:l}));var m=F(a),f=N(a,"Representation"),p=n(r,m);return i(f.map(function(e,t,r){return function(i){var a=N(i,"BaseURL"),u=C(t,a),o=n(e,z(i)),s=F(i);return u.map(function(e){return{segmentInfo:n(r,s),attributes:n(o,{baseUrl:e})}})}}(c,o,p)))}},q=function(e,r){void 0===r&&(r={});var a=r,o=a.manifestUri,s=void 0===o?"":o,d=a.NOW,c=void 0===d?Date.now():d,l=a.clientOffset,m=void 0===l?0:l,f=N(e,"Period");if(!f.length)throw new Error(u);var p=z(e),v=C([s],N(e,"BaseURL"));return p.sourceDuration=p.mediaPresentationDuration||0,p.NOW=c,p.clientOffset=m,i(f.map(function(e,r){return function(a,u){var o=C(r,N(a,"BaseURL")),s=z(a),d=parseInt(s.id,10),c=t.isNaN(d)?u:d,l=n(e,{periodIndex:c}),m=N(a,"AdaptationSet"),f=F(a);return i(m.map(j(l,o,f)))}}(p,v)))},k=function(e){if(""===e)throw new Error(o);var r=(new t.DOMParser).parseFromString(e,"application/xml"),n=r&&"MPD"===r.documentElement.tagName?r.documentElement:null;if(!n||n&&n.getElementsByTagName("parsererror").length>0)throw new Error(s);return n};e.VERSION="0.8.1",e.parse=function(e,t){return void 0===t&&(t={}),w(q(k(e),t).map(S),t.sidxMapping)},e.parseUTCTiming=function(e){return function(e){var t=N(e,"UTCTiming")[0];if(!t)return null;var r=z(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(l)}return r}(k(e))},Object.defineProperty(e,"__esModule",{value:!0})});
/*! @name mpd-parser @version 0.8.2-0 @license Apache-2.0 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("global/window")):"function"==typeof define&&define.amd?define(["exports","global/window"],t):t((e=e||self).mpdParser={},e.window)}(this,function(e,t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;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.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},u="INVALID_NUMBER_OF_PERIOD",o="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){return e(t={exports:{}},t.exports),t.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});
/*! @name @videojs/vhs-utils @version 0.0.0 @license MIT */var f=function(e,r){return/^[a-z]+:/i.test(r)?r:(/\/\//i.test(e)||(e=m.buildAbsoluteURL(t.location.href,e)),m.buildAbsoluteURL(e,r))},p=function(e){for(var r=t.atob(e),n=new Uint8Array(r.length),i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return n},v=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:f(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},h={static:function(e){var t=e.duration,r=e.timescale,n=void 0===r?1:r,i=e.sourceDuration;return{start:0,end: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=(t+r)/1e3,p=n+s,v=f+d-p,h=Math.ceil(v*a/u),g=Math.floor((f-p-m)*a/u),b=Math.floor((f-p)*a/u);return{start:Math.max(0,g),end:Math.min(h,b)}}},g=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=h[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},b=function(e){var t=e.baseUrl,r=e.initialization,n=void 0===r?{}:r,i=e.sourceDuration,a=e.timescale,u=void 0===a?1:a,o=e.indexRange,s=void 0===o?"":o,d=e.duration;if(!t)throw new Error(c);var l=v({baseUrl:t,source:n.sourceURL,range:n.range}),m=v({baseUrl:t,source:t,indexRange:s});if(m.map=l,d){var f=g(e);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]},U=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,v=f.subsegmentDuration,h=b({baseUrl:r,timescale:s,timeline:a,periodIndex:a,duration:v,sourceDuration:i,indexRange:l+"-"+(l+p-1)})[0];n&&(h.map=n),d.push(h),l+=p}return e.segments=d,e},y=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){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&&U(n,a,n.sidx.resolvedUri)}}var u,o;return e},D=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},x=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},L=function(e,t){var r;if(void 0===t&&(t={}),!e.length)return{};var n=e[0].attributes,i=n.sourceDuration,a=n.minimumUpdatePeriod,u=void 0===a?0:a,o=y(e.filter(function(e){var t=e.attributes;return"video/mp4"===t.mimeType||"video"===t.contentType})).map(x),s=y(e.filter(function(e){var t=e.attributes;return"audio/mp4"===t.mimeType||"audio"===t.contentType})),c=e.filter(function(e){var t=e.attributes;return"text/vtt"===t.mimeType||"text"===t.contentType}),d={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:(r={AUDIO:{},VIDEO:{}},r["CLOSED-CAPTIONS"]={},r.SUBTITLES={},r),uri:"",duration:i,playlists:I(o,t),minimumUpdatePeriod:1e3*u};return s.length&&(d.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:(e[u]={language:a,autoselect:!0,default:"main"===i,playlists:I([D(n)],t),uri:""},void 0===r&&"main"===i&&((r=n).default=!0),e)},{});r||(n[Object.keys(n)[0]].default=!0);return n}(s,t)),c.length&&(d.mediaGroups.SUBTITLES.subs=function(e,t){return void 0===t&&(t={}),e.reduce(function(e,r){var n,i,a,u,o=r.attributes.lang||"text";return e[o]?e:(e[o]={language:o,default:!1,autoselect:!1,playlists:I([(n=r,a=n.attributes,u=n.segments,void 0===u&&(u=[{uri:a.baseUrl,timeline:a.periodIndex,resolvedUri:a.baseUrl||"",duration:a.sourceDuration,number:0}],a.duration=a.sourceDuration),{attributes:(i={NAME:a.id,BANDWIDTH:a.bandwidth},i["PROGRAM-ID"]=1,i),uri:"",endList:"static"===(a.type||"static"),timeline:a.periodIndex,resolvedUri:a.baseUrl||"",targetDuration:a.duration,segments:u,mediaSequence:u.length?u[0].number:1})],t),uri:""},e)},{})}(c,t)),d},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)},w=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=[],v=-1,h=0;h<t.length;h++){var g=t[h],b=g.d,U=g.r||0,y=g.t||0;v<0&&(v=y),y&&y>v&&(v=y);var I=void 0;if(U<0){var D=h+1;I=D===t.length?"dynamic"===n&&a>0&&o.indexOf("$Number$")>0?R(e,v,b):(s*d-v)/b:(t[D].t-v)/b}else I=U+1;for(var x=m+p.length+I,L=m+p.length;L<x;)p.push({number:L,duration:b/d,time:v,timeline:f}),v+=b,L++}return p},E=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,P=function(e,t){return e.replace(E,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))},T=function(e,t){var r={RepresentationID:e.id,Bandwidth:e.bandwidth||0},n=e.initialization,i=void 0===n?{sourceURL:"",range:""}:n,a=v({baseUrl:e.baseUrl,source:P(i.sourceURL,r),range:i.range});return function(e,t){return e.duration||t?e.duration?g(e):w(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=P(e.media||"",r);return{uri:n,timeline:t.timeline,duration:t.duration,resolvedUri:f(e.baseUrl||"",n),map:a,number:t.number}})},S=function(e,t){var r=e.duration,n=e.segmentUrls,i=void 0===n?[]:n;if(!r&&!t||r&&t)throw new Error(d);var a,u=i.map(function(t){return function(e,t){var r=e.baseUrl,n=e.initialization,i=void 0===n?{}:n,a=v({baseUrl:r,source:i.sourceURL,range:i.range}),u=v({baseUrl:r,source:t.media,range:t.mediaRange});return u.map=a,u}(e,t)});return r&&(a=g(e)),t&&(a=w(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})},N=function(e){var t,r,i=e.attributes,a=e.segmentInfo;a.template?(r=T,t=n(i,a.template)):a.base?(r=b,t=n(i,a.base)):a.list&&(r=S,t=n(i,a.list));var u={attributes:i};if(!r)return u;var o=r(t,a.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 u.attributes=t,u.segments=o,a.base&&t.indexRange&&(u.sidx=o[0],u.segments=[]),u},O=function(e,t){return a(e.childNodes).filter(function(e){return e.tagName===t})},A=function(e){return e.textContent.trim()},M=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)},z={mediaPresentationDuration:function(e){return M(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 M(e)},timeShiftBufferDepth:function(e){return M(e)},start:function(e){return M(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)?M(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}},B=function(e){return e&&e.attributes?a(e.attributes).reduce(function(e,t){var r=z[t.name]||z.DEFAULT;return e[t.name]=r(t.value),e},{}):{}},C={"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"},F=function(e,t){return t.length?i(e.map(function(e){return t.map(function(t){return f(e,A(t))})})):e},_=function(e){var t=O(e,"SegmentTemplate")[0],r=O(e,"SegmentList")[0],i=r&&O(r,"SegmentURL").map(function(e){return n({tag:"SegmentURL"},B(e))}),a=O(e,"SegmentBase")[0],u=r||t,o=u&&O(u,"SegmentTimeline")[0],s=r||a||t,c=s&&O(s,"Initialization")[0],d=t&&B(t);d&&c?d.initialization=c&&B(c):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});var l={template:d,timeline:o&&O(o,"S").map(function(e){return B(e)}),list:r&&n(B(r),{segmentUrls:i,initialization:B(c)}),base:a&&n(B(a),{initialization:B(c)})};return Object.keys(l).forEach(function(e){l[e]||delete l[e]}),l},j=function(e,t,r){return function(a){var u=B(a),o=F(t,O(a,"BaseURL")),s=O(a,"Role")[0],c={role:B(s)},d=n(e,u,c),l=O(a,"ContentProtection").reduce(function(e,t){var r=B(t),n=C[r.schemeIdUri];if(n){e[n]={attributes:r};var i=O(t,"cenc:pssh")[0];if(i){var a=A(i),u=a&&p(a);e[n].pssh=u}}return e},{});Object.keys(l).length&&(d=n(d,{contentProtection:l}));var m=_(a),f=O(a,"Representation"),v=n(r,m);return i(f.map(function(e,t,r){return function(i){var a=O(i,"BaseURL"),u=F(t,a),o=n(e,B(i)),s=_(i);return u.map(function(e){return{segmentInfo:n(r,s),attributes:n(o,{baseUrl:e})}})}}(d,o,v)))}},q=function(e,r){void 0===r&&(r={});var a=r,o=a.manifestUri,s=void 0===o?"":o,c=a.NOW,d=void 0===c?Date.now():c,l=a.clientOffset,m=void 0===l?0:l,f=O(e,"Period");if(!f.length)throw new Error(u);var p=B(e),v=F([s],O(e,"BaseURL"));return p.sourceDuration=p.mediaPresentationDuration||0,p.NOW=d,p.clientOffset=m,i(f.map(function(e,r){return function(a,u){var o=F(r,O(a,"BaseURL")),s=B(a),c=parseInt(s.id,10),d=t.isNaN(c)?u:c,l=n(e,{periodIndex:d}),m=O(a,"AdaptationSet"),f=_(a);return i(m.map(j(l,o,f)))}}(p,v)))},k=function(e){if(""===e)throw new Error(o);var r=(new t.DOMParser).parseFromString(e,"application/xml"),n=r&&"MPD"===r.documentElement.tagName?r.documentElement:null;if(!n||n&&n.getElementsByTagName("parsererror").length>0)throw new Error(s);return n};e.VERSION="0.8.2-0",e.parse=function(e,t){return void 0===t&&(t={}),L(q(k(e),t).map(N),t.sidxMapping)},e.parseUTCTiming=function(e){return function(e){var t=O(e,"UTCTiming")[0];if(!t)return null;var r=B(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(l)}return r}(k(e))},Object.defineProperty(e,"__esModule",{value:!0})});

68

package.json
{
"name": "mpd-parser",
"version": "0.8.1",
"version": "0.8.2-0",
"description": "mpd parser",

@@ -14,22 +14,18 @@ "main": "dist/mpd-parser.cjs.js",

"netlify": "node scripts/netlify.js",
"prebuild": "npm run clean",
"build": "npm-run-all -p build:*",
"build-test": "cross-env-shell TEST_BUNDLE_ONLY=1 'npm run build'",
"build-prod": "cross-env-shell NO_TEST_BUNDLE=1 'npm run build'",
"build": "npm-run-all -s clean -p build:*",
"build:js": "rollup -c scripts/rollup.config.js",
"clean": "shx rm -rf ./dist ./test/dist",
"postclean": "shx mkdir -p ./dist ./test/dist",
"docs": "npm-run-all docs:*",
"docs:api": "jsdoc src -g plugins/markdown -r -d docs/api",
"docs:toc": "doctoc README.md",
"clean": "shx rm -rf ./dist ./test/dist && shx mkdir -p ./dist ./test/dist",
"lint": "vjsstandard",
"prepublishOnly": "npm-run-all build-prod && vjsverify --verbose",
"start": "npm-run-all -p server watch",
"server": "karma start scripts/karma.conf.js --singleRun=false --auto-watch",
"start": "npm-run-all -p server watch",
"pretest": "npm-run-all lint build",
"test": "karma start scripts/karma.conf.js",
"update-changelog": "conventional-changelog -p videojs -i CHANGELOG.md -s",
"test": "npm-run-all lint build-test && karma start scripts/karma.conf.js",
"posttest": "shx cat test/dist/coverage/text.txt",
"preversion": "npm test",
"version": "is-prerelease || npm run update-changelog && git add CHANGELOG.md",
"update-changelog": "conventional-changelog -p videojs -i CHANGELOG.md -s",
"watch": "npm-run-all -p watch:*",
"watch:js": "npm run build:js -- -w",
"posttest": "shx cat test/dist/coverage/text.txt",
"prepublishOnly": "npm run build && vjsverify"
"watch:js": "npm run build:js -- -w"
},

@@ -58,31 +54,23 @@ "keywords": [

],
"dependencies": {
"@babel/runtime": "^7.5.5",
"@videojs/vhs-utils": "github:videojs/vhs-utils#force-dist",
"global": "^4.3.2"
},
"devDependencies": {
"conventional-changelog-cli": "^2.0.1",
"conventional-changelog-videojs": "^3.0.0",
"doctoc": "^1.3.1",
"husky": "^1.0.0-rc.13",
"jsdoc": "https://github.com/BrandonOCasey/jsdoc#feat/plugin-from-cli",
"karma": "^3.0.0",
"lint-staged": "^7.2.2",
"not-prerelease": "^1.0.1",
"npm-merge-driver-install": "^1.0.0",
"npm-run-all": "^4.1.5",
"pkg-ok": "^2.2.0",
"rollup": "^0.66.0",
"@videojs/generator-helpers": "~1.2.0",
"karma": "^4.0.0",
"postcss-cli": "^6.0.0",
"rollup": "^1.19.4",
"rollup-plugin-string": "^2.0.2",
"shelljs": "~0.8.2",
"shx": "^0.3.2",
"sinon": "^6.1.5",
"videojs-generate-karma-config": "~5.0.1",
"videojs-generate-rollup-config": "~2.3.0",
"videojs-generator-verify": "~1.0.4",
"videojs-standard": "~7.1.0"
"sinon": "^7.2.2",
"videojs-generate-karma-config": "~5.3.0",
"videojs-generate-rollup-config": "~5.0.1",
"videojs-generator-verify": "~1.2.0",
"videojs-languages": "^2.0.0",
"videojs-standard": "^8.0.3"
},
"generator-videojs-plugin": {
"version": "7.3.2"
"version": "7.7.0"
},
"dependencies": {
"global": "^4.3.2",
"url-toolkit": "^2.1.1"
},
"browserslist": [

@@ -98,3 +86,3 @@ "defaults",

"README.md": [
"npm run docs:toc",
"doctoc --notitle",
"git add"

@@ -101,0 +89,0 @@ ]

@@ -17,2 +17,6 @@ const generate = require('videojs-generate-rollup-config');

return defaults;
},
externals(defaults) {
defaults.module.push('@videojs/vhs-utils');
return defaults;
}

@@ -19,0 +23,0 @@ };

@@ -6,5 +6,4 @@ import window from 'global/window';

import { parseAttributes } from './parseAttributes';
import resolveUrl from './utils/resolveUrl';
import errors from './errors';
import decodeB64ToUint8Array from './utils/decodeB64ToUint8Array';
import {decodeB64ToUint8Array, resolveUrl} from '@videojs/vhs-utils';

@@ -33,6 +32,3 @@ const keySystemsMap = {

return flatten(
referenceUrls.map(
reference => baseUrlElements.map(
baseUrlElement => resolveUrl(reference, getContent(baseUrlElement)))));
return flatten(referenceUrls.map(reference => baseUrlElements.map(baseUrlElement => resolveUrl(reference, getContent(baseUrlElement)))));
};

@@ -101,7 +97,7 @@

initialization: parseAttributes(segmentInitialization)
}),
base: segmentBase && merge(
parseAttributes(segmentBase), {
initialization: parseAttributes(segmentInitialization)
})
}
),
base: segmentBase && merge(parseAttributes(segmentBase), {
initialization: parseAttributes(segmentInitialization)
})
};

@@ -227,13 +223,16 @@

const adaptationSetAttributes = parseAttributes(adaptationSet);
const adaptationSetBaseUrls = buildBaseUrls(periodBaseUrls,
findChildren(adaptationSet, 'BaseURL'));
const adaptationSetBaseUrls = buildBaseUrls(
periodBaseUrls,
findChildren(adaptationSet, 'BaseURL')
);
const role = findChildren(adaptationSet, 'Role')[0];
const roleAttributes = { role: parseAttributes(role) };
let attrs = merge(periodAttributes,
let attrs = merge(
periodAttributes,
adaptationSetAttributes,
roleAttributes);
roleAttributes
);
const contentProtection = generateKeySystemInformation(
findChildren(adaptationSet, 'ContentProtection'));
const contentProtection = generateKeySystemInformation(findChildren(adaptationSet, 'ContentProtection'));

@@ -248,4 +247,3 @@ if (Object.keys(contentProtection).length) {

return flatten(representations.map(
inheritBaseUrls(attrs, adaptationSetBaseUrls, adaptationSetSegmentInfo)));
return flatten(representations.map(inheritBaseUrls(attrs, adaptationSetBaseUrls, adaptationSetSegmentInfo)));
};

@@ -288,4 +286,3 @@

return flatten(adaptationSets.map(
toRepresentations(periodAttributes, periodBaseUrls, periodSegmentInfo)));
return flatten(adaptationSets.map(toRepresentations(periodAttributes, periodBaseUrls, periodSegmentInfo)));
};

@@ -292,0 +289,0 @@

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

import resolveUrl from '../utils/resolveUrl';
import {resolveUrl} from '@videojs/vhs-utils';
import urlTypeToSegment from './urlType';

@@ -3,0 +3,0 @@ import { parseByTimeline } from './timelineTimeParser';

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

import resolveUrl from '../utils/resolveUrl';
import {resolveUrl} from '@videojs/vhs-utils';

@@ -3,0 +3,0 @@ /**

@@ -252,5 +252,3 @@ import { values } from './utils/object';

const videoPlaylists = mergeDiscontiguousPlaylists(
dashPlaylists.filter(videoOnly)
).map(formatVideoPlaylist);
const videoPlaylists = mergeDiscontiguousPlaylists(dashPlaylists.filter(videoOnly)).map(formatVideoPlaylist);
const audioPlaylists = mergeDiscontiguousPlaylists(dashPlaylists.filter(audioOnly));

@@ -257,0 +255,0 @@ const vttPlaylists = dashPlaylists.filter(vttOnly);

@@ -32,4 +32,6 @@ import {

assert.deepEqual(buildBaseUrls(reference, node), expected,
'base url for each reference url');
assert.deepEqual(
buildBaseUrls(reference, node), expected,
'base url for each reference url'
);
});

@@ -69,4 +71,6 @@

assert.deepEqual(buildBaseUrls(reference, node), expected,
'absolute url overwrites reference');
assert.deepEqual(
buildBaseUrls(reference, node), expected,
'absolute url overwrites reference'
);
});

@@ -80,4 +84,6 @@

assert.deepEqual(getSegmentInformation(adaptationSet), expected,
'undefined segment info');
assert.deepEqual(
getSegmentInformation(adaptationSet), expected,
'undefined segment info'
);
});

@@ -97,4 +103,6 @@

assert.deepEqual(getSegmentInformation(adaptationSet), expected,
'SegmentTemplate info');
assert.deepEqual(
getSegmentInformation(adaptationSet), expected,
'SegmentTemplate info'
);
});

@@ -118,4 +126,6 @@

assert.deepEqual(getSegmentInformation(adaptationSet), expected,
'SegmentList info');
assert.deepEqual(
getSegmentInformation(adaptationSet), expected,
'SegmentList info'
);
});

@@ -135,4 +145,6 @@

assert.deepEqual(getSegmentInformation(adaptationSet), expected,
'SegmentBase info');
assert.deepEqual(
getSegmentInformation(adaptationSet), expected,
'SegmentBase info'
);
});

@@ -165,4 +177,6 @@

assert.deepEqual(getSegmentInformation(adaptationSet), expected,
'SegmentTemplate and SegmentTimeline info');
assert.deepEqual(
getSegmentInformation(adaptationSet), expected,
'SegmentTemplate and SegmentTimeline info'
);
});

@@ -173,4 +187,6 @@

QUnit.test('needs at least one Period', function(assert) {
assert.throws(() => inheritAttributes(stringToMpdXml('<MPD></MPD>')),
new RegExp(errors.INVALID_NUMBER_OF_PERIOD));
assert.throws(
() => inheritAttributes(stringToMpdXml('<MPD></MPD>')),
new RegExp(errors.INVALID_NUMBER_OF_PERIOD)
);
});

@@ -181,4 +197,3 @@

const actual = inheritAttributes(stringToMpdXml(
`
const actual = inheritAttributes(stringToMpdXml(`
<MPD mediaPresentationDuration="PT30S" >

@@ -205,4 +220,3 @@ <BaseURL>https://www.example.com/base/</BaseURL>

</MPD>
`
), { NOW });
`), { NOW });

@@ -254,4 +268,3 @@ const expected = [{

const actual = inheritAttributes(stringToMpdXml(
`
const actual = inheritAttributes(stringToMpdXml(`
<MPD mediaPresentationDuration="PT30S" >

@@ -281,4 +294,3 @@ <BaseURL>https://www.example.com/base/</BaseURL>

</MPD>
`
), { NOW });
`), { NOW });

@@ -329,4 +341,3 @@ const expected = [{

const NOW = Date.now();
const actual = inheritAttributes(stringToMpdXml(
`
const actual = inheritAttributes(stringToMpdXml(`
<MPD mediaPresentationDuration= "PT30S" >

@@ -356,4 +367,3 @@ <BaseURL>https://www.example.com/base/</BaseURL>

</MPD>
`
), { NOW });
`), { NOW });

@@ -480,7 +490,7 @@ const expected = [{

QUnit.test(' End to End test for checking support of segments in representation',
QUnit.test(
' End to End test for checking support of segments in representation',
function(assert) {
const NOW = Date.now();
const actual = inheritAttributes(stringToMpdXml(
`
const actual = inheritAttributes(stringToMpdXml(`
<MPD mediaPresentationDuration= "PT30S" >

@@ -517,4 +527,3 @@ <BaseURL>https://www.example.com/base/</BaseURL>

</MPD>
`
), { NOW });
`), { NOW });

@@ -590,9 +599,10 @@ const expected = [{

assert.deepEqual(actual, expected);
});
}
);
QUnit.test(' End to End test for checking support of segments in period ',
QUnit.test(
' End to End test for checking support of segments in period ',
function(assert) {
const NOW = Date.now();
const actual = inheritAttributes(stringToMpdXml(
`
const actual = inheritAttributes(stringToMpdXml(`
<MPD mediaPresentationDuration= "PT30S" >

@@ -625,4 +635,3 @@ <BaseURL>https://www.example.com/base/</BaseURL>

</MPD>
`
), { NOW });
`), { NOW });

@@ -706,9 +715,10 @@ const expected = [{

assert.deepEqual(actual, expected);
});
}
);
QUnit.test(' End to End test for checking support of Segments in Adaptation set',
QUnit.test(
' End to End test for checking support of Segments in Adaptation set',
function(assert) {
const NOW = Date.now();
const actual = inheritAttributes(stringToMpdXml(
`
const actual = inheritAttributes(stringToMpdXml(`
<MPD mediaPresentationDuration= "PT30S" >

@@ -741,4 +751,3 @@ <BaseURL>https://www.example.com/base/</BaseURL>

</MPD>
`
), { NOW });
`), { NOW });

@@ -815,3 +824,4 @@ const expected = [{

assert.deepEqual(actual, expected);
});
}
);

@@ -826,4 +836,3 @@ // Although according to the Spec, at most one set of Segment information should be

const NOW = Date.now();
const actual = toPlaylists(inheritAttributes(stringToMpdXml(
`
const actual = toPlaylists(inheritAttributes(stringToMpdXml(`
<MPD mediaPresentationDuration= "PT30S" >

@@ -869,4 +878,3 @@ <BaseURL>https://www.example.com/base</BaseURL>

</MPD>
`
), { NOW }));
`), { NOW }));

@@ -1252,3 +1260,4 @@ const expected = [{

assert.deepEqual(actual, expected);
});
}
);

@@ -1263,4 +1272,3 @@ // Although the Spec states that if SegmentTemplate or SegmentList is present on one

const NOW = Date.now();
const actual = toPlaylists(inheritAttributes(stringToMpdXml(
`
const actual = toPlaylists(inheritAttributes(stringToMpdXml(`
<MPD mediaPresentationDuration= "PT30S" >

@@ -1302,4 +1310,3 @@ <BaseURL>https://www.example.com/base</BaseURL>

</MPD>
`
), { NOW }));
`), { NOW }));

@@ -1495,4 +1502,3 @@ const expected = [{

}]
}
];
}];

@@ -1499,0 +1505,0 @@ assert.equal(actual.length, 1);

@@ -473,4 +473,3 @@ export const parsedManifest = {

number: 19
}
],
}],
mediaSequence: 0,

@@ -709,4 +708,3 @@ contentProtection: {

number: 19
}
],
}],
mediaSequence: 0,

@@ -944,4 +942,3 @@ contentProtection: {

number: 19
}
],
}],
mediaSequence: 0,

@@ -948,0 +945,0 @@ contentProtection: {

@@ -87,3 +87,4 @@ import QUnit from 'qunit';

QUnit.test('truncates if segmentTimeline does not apply for all segments',
QUnit.test(
'truncates if segmentTimeline does not apply for all segments',
function(assert) {

@@ -135,5 +136,7 @@ const inputAttributes = {

}]);
});
}
);
QUnit.test('if segment timeline is too long does not add extra blank segments',
QUnit.test(
'if segment timeline is too long does not add extra blank segments',
function(assert) {

@@ -215,3 +218,4 @@ const inputAttributes = {

}]);
});
}
);

@@ -455,3 +459,4 @@ QUnit.test('uses duration to set segments', function(assert) {

QUnit.test('throws error if more than 1 segment and no duration or timeline',
QUnit.test(
'throws error if more than 1 segment and no duration or timeline',
function(assert) {

@@ -479,5 +484,8 @@ const inputAttributes = {

assert.throws(() => segmentsFromList(inputAttributes, inputTimeline),
new Error(errors.SEGMENT_TIME_UNSPECIFIED));
});
assert.throws(
() => segmentsFromList(inputAttributes, inputTimeline),
new Error(errors.SEGMENT_TIME_UNSPECIFIED)
);
}
);

@@ -499,4 +507,6 @@ QUnit.test('throws error if timeline and duration are both defined', function(assert) {

assert.throws(() => segmentsFromList(inputAttributes),
new Error(errors.SEGMENT_TIME_UNSPECIFIED));
assert.throws(
() => segmentsFromList(inputAttributes),
new Error(errors.SEGMENT_TIME_UNSPECIFIED)
);
});

@@ -503,0 +513,0 @@

@@ -48,4 +48,3 @@ import QUnit from 'qunit';

cases.forEach(test => {
assert.equal(
constructTemplateUrl(test.url, values), test.expected, `constructs ${test.url}`);
assert.equal(constructTemplateUrl(test.url, values), test.expected, `constructs ${test.url}`);
});

@@ -63,5 +62,7 @@ });

Time: 2000
}),
}
),
'$2000$$/Rep1/1000/2-2000-segment-2.mp4',
'correctly replaces multiple identifiers in single url');
'correctly replaces multiple identifiers in single url'
);
});

@@ -76,5 +77,7 @@

Number: 1
}),
}
),
'/$UNKNOWN$/Rep1/$UNKOWN2$/1.mp4',
'ignores unknown identifiers');
'ignores unknown identifiers'
);
});

@@ -86,5 +89,7 @@

'/$Number%03d$/segment.mp4',
{ Number: 7 }),
{ Number: 7 }
),
'/007/segment.mp4',
'correctly adds padding when format tag present');
'correctly adds padding when format tag present'
);
});

@@ -96,5 +101,7 @@

'/$Bandwidth%06d$/segment.mp4',
{ Bandwidth: 999999999 }),
{ Bandwidth: 999999999 }
),
'/999999999/segment.mp4',
'no padding when value longer than format width');
'no padding when value longer than format width'
);
});

@@ -106,5 +113,7 @@

'/$RepresentationID%09d$/$Number%03d$/segment.mp4',
{ RepresentationID: 'Rep1', Number: 7 }),
{ RepresentationID: 'Rep1', Number: 7 }
),
'/Rep1/007/segment.mp4',
'ignores format tag for $RepresentationID$');
'ignores format tag for $RepresentationID$'
);
});

@@ -114,3 +123,4 @@

QUnit.test('one media segment when no @duration attribute or SegmentTimeline element',
QUnit.test(
'one media segment when no @duration attribute or SegmentTimeline element',
function(assert) {

@@ -127,4 +137,6 @@ const attributes = {

[ { number: 3, duration: 42, time: 0, timeline: 1 }],
'creates segment list of one media segment when no @duration attribute or timeline');
});
'creates segment list of one media segment when no @duration attribute or timeline'
);
}
);

@@ -162,3 +174,4 @@ QUnit.test('uses @duration attribute when present', function(assert) {

],
'correctly parses segment durations and start times with @duration attribute');
'correctly parses segment durations and start times with @duration attribute'
);
});

@@ -197,3 +210,4 @@

],
'allows non zero startNumber');
'allows non zero startNumber'
);
});

@@ -230,3 +244,4 @@

],
'uses default startNumber and timescale value of 1');
'uses default startNumber and timescale value of 1'
);
});

@@ -285,3 +300,4 @@

],
'correctly calculates segment durations and start times with SegmentTimeline');
'correctly calculates segment durations and start times with SegmentTimeline'
);
});

@@ -340,3 +356,4 @@

],
'allows non zero startNumber');
'allows non zero startNumber'
);
});

@@ -393,3 +410,4 @@

],
'defaults to 1 for startNumber and timescale');
'defaults to 1 for startNumber and timescale'
);
});

@@ -447,3 +465,4 @@

],
'uses default value of 0');
'uses default value of 0'
);
});

@@ -502,3 +521,4 @@

],
'allows non zero SegmentTimeline.S@t start value');
'allows non zero SegmentTimeline.S@t start value'
);
});

@@ -576,3 +596,4 @@

],
'correctly uses @r repeat attribute');
'correctly uses @r repeat attribute'
);
});

@@ -651,3 +672,4 @@

],
'correctly uses negative @r repeat attribute');
'correctly uses negative @r repeat attribute'
);
});

@@ -701,9 +723,12 @@

],
'correctly uses negative @r repeat attribute for last S');
'correctly uses negative @r repeat attribute for last S'
);
});
QUnit.skip('detects discontinuity when @t time is greater than expected start time',
QUnit.skip(
'detects discontinuity when @t time is greater than expected start time',
function(assert) {
});
}
);

@@ -780,3 +805,4 @@ QUnit.module('segmentTemplate - type ="dynamic"');

}],
'segments correctly with basic settings');
'segments correctly with basic settings'
);

@@ -836,7 +862,10 @@ assert.deepEqual(

}],
'segments adjusted correctly based on @startNumber');
'segments adjusted correctly based on @startNumber'
);
assert.deepEqual(
segmentsFromTemplate(Object.assign({}, basicAttributes,
{ availabilityStartTime: 4 }), []),
segmentsFromTemplate(Object.assign(
{}, basicAttributes,
{ availabilityStartTime: 4 }
), []),
[{

@@ -877,4 +906,6 @@ duration: 2,

assert.deepEqual(
segmentsFromTemplate(Object.assign({}, basicAttributes,
{ availabilityStartTime: 2, start: 4 }), []),
segmentsFromTemplate(Object.assign(
{}, basicAttributes,
{ availabilityStartTime: 2, start: 4 }
), []),
[{

@@ -901,7 +932,10 @@ duration: 2,

}],
'segments correct with @availabilityStartTime and @start set');
'segments correct with @availabilityStartTime and @start set'
);
assert.deepEqual(
segmentsFromTemplate(Object.assign({}, basicAttributes,
{ timeShiftBufferDepth: 4 }, [])),
segmentsFromTemplate(Object.assign(
{}, basicAttributes,
{ timeShiftBufferDepth: 4 }, []
)),
[{

@@ -928,7 +962,10 @@ duration: 2,

}],
'segments correct with @timeShiftBufferDepth set');
'segments correct with @timeShiftBufferDepth set'
);
assert.deepEqual(
segmentsFromTemplate(Object.assign({}, basicAttributes,
{ clientOffset: -2000 }, [])),
segmentsFromTemplate(Object.assign(
{}, basicAttributes,
{ clientOffset: -2000 }, []
)),
[{

@@ -975,3 +1012,4 @@ duration: 2,

}],
'segments correct with given clientOffset');
'segments correct with given clientOffset'
);
});

@@ -1058,7 +1096,7 @@

}],
'segments should fill until current time when r = -1 and @minimumUpdatePeriod > 0');
'segments should fill until current time when r = -1 and @minimumUpdatePeriod > 0'
);
assert.deepEqual(
segmentsFromTemplate(
Object.assign({}, basicAttributes, {clientOffset: -2000}), segmentTimeline),
segmentsFromTemplate(Object.assign({}, basicAttributes, {clientOffset: -2000}), segmentTimeline),
[{

@@ -1105,3 +1143,4 @@ duration: 2,

}],
'segments should fill correctly when taking client offset into account');
'segments should fill correctly when taking client offset into account'
);

@@ -1163,7 +1202,10 @@ const segmentTimelineShifted = [

}],
'segments take into account different time value for first segment');
'segments take into account different time value for first segment'
);
assert.deepEqual(
segmentsFromTemplate(Object.assign({}, basicAttributes, {timescale: 2 }),
segmentTimelineShifted),
segmentsFromTemplate(
Object.assign({}, basicAttributes, {timescale: 2 }),
segmentTimelineShifted
),
[{

@@ -1260,3 +1302,4 @@ duration: 1,

}],
'segments take into account different time value for first segment with timescale');
'segments take into account different time value for first segment with timescale'
);
});

@@ -1317,4 +1360,6 @@

assert.deepEqual(segmentsFromTemplate(attributes, void 0), segments,
'creates segments from template');
assert.deepEqual(
segmentsFromTemplate(attributes, void 0), segments,
'creates segments from template'
);
});

@@ -1386,4 +1431,6 @@

assert.deepEqual(segmentsFromTemplate(attributes, void 0), segments,
'creates segments from template');
assert.deepEqual(
segmentsFromTemplate(attributes, void 0), segments,
'creates segments from template'
);
});

@@ -87,7 +87,9 @@ import QUnit from 'qunit';

QUnit.test('returns correct string representing byterange object', function(assert) {
assert.strictEqual(byteRangeToString({
offset: 0,
length: 100
}),
'0-99');
assert.strictEqual(
byteRangeToString({
offset: 0,
length: 100
}),
'0-99'
);
});

@@ -49,4 +49,6 @@ import { merge, values } from '../src/utils/object';

assert.deepEqual(merge(adaptationSetInfo, representationInfo), expected,
'Merged SegmentBase info');
assert.deepEqual(
merge(adaptationSetInfo, representationInfo), expected,
'Merged SegmentBase info'
);

@@ -77,4 +79,6 @@ });

assert.deepEqual(merge(periodInfo, adaptationSetInfo, representationInfo), expected,
'Merged SegmentBase info');
assert.deepEqual(
merge(periodInfo, adaptationSetInfo, representationInfo), expected,
'Merged SegmentBase info'
);

@@ -81,0 +85,0 @@ });

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

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