mirror of
https://github.com/iv-org/invidious.git
synced 2024-08-30 18:23:25 +00:00
15 lines
272 KiB
JavaScript
15 lines
272 KiB
JavaScript
|
/**
|
||
|
* @videojs/http-streaming
|
||
|
* @version 1.2.2
|
||
|
* @copyright 2018 Brightcove, Inc
|
||
|
* @license Apache-2.0
|
||
|
*/
|
||
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("video.js")):"function"==typeof define&&define.amd?define(["exports","video.js"],e):e(t.videojsHttpStreaming={},t.videojs)}(this,function(t,e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var i="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,r={},a=Object.freeze({default:r}),s=a&&r||a,o=void 0!==i?i:"undefined"!=typeof window?window:{};"undefined"!=typeof document?n=document:(n=o["__GLOBAL_DOCUMENT_CACHE@4"])||(n=o["__GLOBAL_DOCUMENT_CACHE@4"]=s);var u,d=n,l=(function(t,e){var i,n,r,a,s;i=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/\;?#]*)?(.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,n=/^([^\/;?#]*)(.*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,s={buildAbsoluteURL:function(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;var r=this.parseURL(t);if(!r)throw new Error("Error trying to parse base URL.");return r.path=s.normalizePath(r.path),s.buildURLFromParts(r)}var a=this.parseURL(e);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):e;var o=this.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var u=n.exec(o.path);o.netLoc=u[1],o.path=u[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 l=o.path,c=l.substring(0,l.lastIndexOf("/")+1)+a.path;d.path=s.normalizePath(c)}else d.path=o.path,a.params||(d.params=o.params,a.query||(d.query=o.query));return null===d.path&&(d.path=i.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(d)},parseURL:function(t){var e=i.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(r,"");t.length!==(t=t.replace(a,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},t.exports=s}(u={exports:{}},u.exports),u.exports),c="undefined"!=typeof window?window:void 0!==i?i:"undefined"!=typeof self?self:{},h=function(t,e){return/^[a-z]+:/i.test(e)?e:(/\/\//i.test(t)||(t=l.buildAbsoluteURL(c.location.href,t)),l.buildAbsoluteURL(t,e))},f=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},p=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},m=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},g=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},y=function(){function t(){f(this,t),this.listeners={}}return t.prototype.on=function(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)},t.prototype.off=function(t,e){if(!this.listeners[t])return!1;var i=this.listeners[t].indexOf(e);return this.listeners[t].splice(i,1),i>-1},t.prototype.trigger=function(t){var e=this.listeners[t],i=void 0,n=void 0,r=void 0;if(e)if(2===arguments.length)for(n=e.length,i=0;i<n;++i)e[i].call(this,arguments[1]);else for(r=Array.prototype.slice.call(arguments,1),n=e.length,i=0;i<n;++i)e[i].apply(this,r)},t.prototype.dispose=function(){this.listeners={}},t.prototype.pipe=function(t){this.on("data",function(e){t.push(e)})},t}(),_=function(t){function e(){f(this,e);var i=g(this,t.call(this));return i.buffer="",i}return m(e,t),e.prototype.push=function(t){var e=void 0;for(this.buffer
|
||
|
/**
|
||
|
* mpd-parser
|
||
|
* @version 0.6.1
|
||
|
* @copyright 2018 Brightcove, Inc
|
||
|
* @license Apache-2.0
|
||
|
*/
|
||
|
var te=function(t){var e,i=t.attributes,n=t.segments,r={attributes:(e={NAME:i.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:i.width,height:i.height},CODECS:i.codecs,BANDWIDTH:i.bandwidth},e["PROGRAM-ID"]=1,e),uri:"",endList:"static"===(i.type||"static"),timeline:i.periodIndex,resolvedUri:"",targetDuration:i.duration,segments:n,mediaSequence:n.length?n[0].number:1};return i.contentProtection&&(r.contentProtection=i.contentProtection),r},ee="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ie=function(t){return!!t&&"object"===(void 0===t?"undefined":ee(t))},ne=function t(){for(var e=arguments.length,i=Array(e),n=0;n<e;n++)i[n]=arguments[n];return i.reduce(function(e,i){return Object.keys(i).forEach(function(n){Array.isArray(e[n])&&Array.isArray(i[n])?e[n]=e[n].concat(i[n]):ie(e[n])&&ie(i[n])?e[n]=t(e[n],i[n]):e[n]=i[n]}),e},{})},re=function(t,e){return/^[a-z]+:/i.test(e)?e:(/\/\//i.test(t)||(t=l.buildAbsoluteURL(c.location.href,t)),l.buildAbsoluteURL(t,e))},ae=function(t){var e=t.baseUrl,i=void 0===e?"":e,n=t.source,r=void 0===n?"":n,a=t.range,s=void 0===a?"":a,o={uri:r,resolvedUri:re(i||"",r)};if(s){var u=s.split("-"),d=parseInt(u[0],10),l=parseInt(u[1],10);o.byterange={length:l-d,offset:d}}return o},se=function(t,e,i){var n=t.NOW,r=t.clientOffset,a=t.availabilityStartTime,s=t.timescale,o=void 0===s?1:s,u=t.start,d=void 0===u?0:u,l=t.minimumUpdatePeriod,c=(n+r)/1e3+(void 0===l?0:l)-(a+d);return Math.ceil((c*o-e)/i)},oe=function(t,e){for(var i=t.type,n=void 0===i?"static":i,r=t.minimumUpdatePeriod,a=void 0===r?0:r,s=t.media,o=void 0===s?"":s,u=t.sourceDuration,d=t.timescale,l=void 0===d?1:d,c=t.startNumber,h=void 0===c?1:c,f=t.periodIndex,p=[],m=-1,g=0;g<e.length;g++){var y=e[g],_=y.d,v=y.r||0,b=y.t||0;m<0&&(m=b),b&&b>m&&(m=b);var T=void 0;if(v<0){var S=g+1;T=S===e.length?"dynamic"===n&&a>0&&o.indexOf("$Number$")>0?se(t,m,_):(u*l-m)/_:(e[S].t-m)/_}else T=v+1;for(var k=h+p.length+T,w=h+p.length;w<k;)p.push({number:w,duration:_/l,time:m,timeline:f}),m+=_,w++}return p},ue=function(t){return t.reduce(function(t,e){return t.concat(e)},[])},de=function(t){if(!t.length)return[];for(var e=[],i=0;i<t.length;i++)e.push(t[i]);return e},le={static:function(t){var e=t.duration,i=t.timescale,n=void 0===i?1:i,r=t.sourceDuration;return{start:0,end:Math.ceil(r/(e/n))}},dynamic:function(t){var e=t.NOW,i=t.clientOffset,n=t.availabilityStartTime,r=t.timescale,a=void 0===r?1:r,s=t.duration,o=t.start,u=void 0===o?0:o,d=t.minimumUpdatePeriod,l=void 0===d?0:d,c=t.timeShiftBufferDepth,h=void 0===c?1/0:c,f=(e+i)/1e3,p=n+u,m=f+l-p,g=Math.ceil(m*a/s),y=Math.floor((f-p-h)*a/s),_=Math.floor((f-p)*a/s);return{start:Math.max(0,y),end:Math.min(g,_)}}},ce=function(t){var e=t.type,i=void 0===e?"static":e,n=t.duration,r=t.timescale,a=void 0===r?1:r,s=t.sourceDuration,o=le[i](t),u=function(t,e){for(var i=[],n=t;n<e;n++)i.push(n);return i}(o.start,o.end).map(function(t){return function(e,i){var n=t.duration,r=t.timescale,a=void 0===r?1:r,s=t.periodIndex,o=t.startNumber;return{number:(void 0===o?1:o)+e,duration:n/a,timeline:s,time:i*n}}}(t));if("static"===i){var d=u.length-1;u[d].duration=s-n/a*d}return u},he=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,fe=function(t,e){return t.replace(he,function(t){return function(e,i,n,r){if("$$"===e)return"$";if(void 0===t[i])return e;var a=""+t[i];return"RepresentationID"===i?a:(r=n?parseInt(r,10):1,a.length>=r?a:""+new Array(r-a.length+1).join("0")+a)}}(e))},pe=function(t,e){var i={RepresentationID:t.id,Bandwidth:t.bandwidth||0},n=t.initialization,r=void 0===n?{sourceURL:"",range:""}:n,a=ae({baseUrl:t.baseUrl,source:fe(r.sourceURL,i),range:r.range});return function(t,e){return t.duration||e?t.duration?ce(t):oe(t,e):[{number:t.startNumber||1,duration:t.sourceDuration,time:0,timeline:t.periodIndex}]}(t,e).map(function(e){i.Number=e.number,i.Time=e.time;var n=fe(t.media||"",i);return{uri:n,timeline:e.timeline,duration:e.duration,resolvedUri:re(t.baseUrl||"",n),map:a,number:e.num
|