9 lines
168 KiB
JavaScript
9 lines
168 KiB
JavaScript
(function(fe){if(typeof exports=="object"&&typeof module!="undefined")module.exports=fe();else if(typeof define=="function"&&define.amd)define([],fe);else{var de;typeof window!="undefined"?de=window:typeof global!="undefined"?de=global:typeof self!="undefined"?de=self:de=this,de.flvjs=fe()}})(function(){var fe,de,ke;return function L(j,A,R){function F(h,t){if(!A[h]){if(!j[h]){var e=typeof require=="function"&&require;if(!t&&e)return e(h,!0);if(T)return T(h,!0);var n=new Error("Cannot find module '"+h+"'");throw n.code="MODULE_NOT_FOUND",n}var u=A[h]={exports:{}};j[h][0].call(u.exports,function(s){var i=j[h][1][s];return F(i||s)},u,u.exports,L,j,A,R)}return A[h].exports}for(var T=typeof require=="function"&&require,f=0;f<R.length;f++)F(R[f]);return F}({1:[function(L,j,A){(function(R,F){/*!
|
|
* @overview es6-promise - a tiny implementation of Promises/A+.
|
|
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
|
|
* @license Licensed under MIT license
|
|
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
|
|
* @version 4.1.0
|
|
*/(function(T,f){typeof A=="object"&&typeof j!="undefined"?j.exports=f():typeof fe=="function"&&fe.amd?fe(f):T.ES6Promise=f()})(this,function(){"use strict";function T(w){return typeof w=="function"||typeof w=="object"&&w!==null}function f(w){return typeof w=="function"}var h=void 0;Array.isArray?h=Array.isArray:h=function(w){return Object.prototype.toString.call(w)==="[object Array]"};var t=h,e=0,n=void 0,u=void 0,s=function(M,B){k[e]=M,k[e+1]=B,e+=2,e===2&&(u?u(C):m())};function i(w){u=w}function E(w){s=w}var _=typeof window!="undefined"?window:void 0,v=_||{},d=v.MutationObserver||v.WebKitMutationObserver,a=typeof self=="undefined"&&typeof R!="undefined"&&{}.toString.call(R)==="[object process]",r=typeof Uint8ClampedArray!="undefined"&&typeof importScripts!="undefined"&&typeof MessageChannel!="undefined";function c(){return function(){return R.nextTick(C)}}function l(){return typeof n!="undefined"?function(){n(C)}:x()}function g(){var w=0,M=new d(C),B=document.createTextNode("");return M.observe(B,{characterData:!0}),function(){B.data=w=++w%2}}function y(){var w=new MessageChannel;return w.port1.onmessage=C,function(){return w.port2.postMessage(0)}}function x(){var w=setTimeout;return function(){return w(C,1)}}var k=new Array(1e3);function C(){for(var w=0;w<e;w+=2){var M=k[w],B=k[w+1];M(B),k[w]=void 0,k[w+1]=void 0}e=0}function S(){try{var w=L,M=w("vertx");return n=M.runOnLoop||M.runOnContext,l()}catch(B){return x()}}var m=void 0;a?m=c():d?m=g():r?m=y():_===void 0&&typeof L=="function"?m=S():m=x();function o(w,M){var B=arguments,z=this,Q=new this.constructor(O);Q[b]===void 0&&ve(Q);var Z=z._state;return Z?function(){var ae=B[Z-1];s(function(){return ue(Z,Q,ae,z._result)})}():se(z,Q,w,M),Q}function p(w){var M=this;if(w&&typeof w=="object"&&w.constructor===M)return w;var B=new M(O);return X(B,w),B}var b=Math.random().toString(36).substring(16);function O(){}var I=void 0,P=1,G=2,D=new ee;function V(){return new TypeError("You cannot resolve a promise with itself")}function U(){return new TypeError("A promises callback cannot return that same promise.")}function q(w){try{return w.then}catch(M){return D.error=M,D}}function N(w,M,B,z){try{w.call(M,B,z)}catch(Q){return Q}}function J(w,M,B){s(function(z){var Q=!1,Z=N(B,M,function(ae){Q||(Q=!0,M!==ae?X(z,ae):Y(z,ae))},function(ae){Q||(Q=!0,H(z,ae))},"Settle: "+(z._label||" unknown promise"));!Q&&Z&&(Q=!0,H(z,Z))},w)}function $(w,M){M._state===P?Y(w,M._result):M._state===G?H(w,M._result):se(M,void 0,function(B){return X(w,B)},function(B){return H(w,B)})}function W(w,M,B){M.constructor===w.constructor&&B===o&&M.constructor.resolve===p?$(w,M):B===D?(H(w,D.error),D.error=null):B===void 0?Y(w,M):f(B)?J(w,M,B):Y(w,M)}function X(w,M){w===M?H(w,V()):T(M)?W(w,M,q(M)):Y(w,M)}function K(w){w._onerror&&w._onerror(w._result),re(w)}function Y(w,M){w._state===I&&(w._result=M,w._state=P,w._subscribers.length!==0&&s(re,w))}function H(w,M){w._state===I&&(w._state=G,w._result=M,s(K,w))}function se(w,M,B,z){var Q=w._subscribers,Z=Q.length;w._onerror=null,Q[Z]=M,Q[Z+P]=B,Q[Z+G]=z,Z===0&&w._state&&s(re,w)}function re(w){var M=w._subscribers,B=w._state;if(M.length!==0){for(var z=void 0,Q=void 0,Z=w._result,ae=0;ae<M.length;ae+=3)z=M[ae],Q=M[ae+B],z?ue(B,z,Q,Z):Q(Z);w._subscribers.length=0}}function ee(){this.error=null}var ie=new ee;function he(w,M){try{return w(M)}catch(B){return ie.error=B,ie}}function ue(w,M,B,z){var Q=f(B),Z=void 0,ae=void 0,Se=void 0,be=void 0;if(Q){if(Z=he(B,z),Z===ie?(be=!0,ae=Z.error,Z.error=null):Se=!0,M===Z){H(M,U());return}}else Z=z,Se=!0;M._state!==I||(Q&&Se?X(M,Z):be?H(M,ae):w===P?Y(M,Z):w===G&&H(M,Z))}function te(w,M){try{M(function(z){X(w,z)},function(z){H(w,z)})}catch(B){H(w,B)}}var oe=0;function ce(){return oe++}function ve(w){w[b]=oe++,w._state=void 0,w._result=void 0,w._subscribers=[]}function le(w,M){this._instanceConstructor=w,this.promise=new w(O),this.promise[b]||ve(this.promise),t(M)?(this._input=M,this.length=M.length,this._remaining=M.length,this._result=new Array(this.length),this.length===0?Y(this.promise,this._result):(this.length=this.length||0,this._enumerate(),this._remaining===0&&Y(this.promise,this._result))):H(this.promise,_e())}function _e(){return new Error("Array Methods must be provided an Array")}le.prototype._enumerate=function(){for(var w=this.length,M=this._input,B=0;this._state===I&&B<w;B++)this._eachEntry(M[B],B)},le.prototype._eachEntry=function(w,M){var B=this._instanceConstructor,z=B.resolve;if(z===p){var Q=q(w);if(Q===o&&w._state!==I)this._settledAt(w._state,M,w._result);else if(typeof Q!="function")this._remaining--,this._result[M]=w;else if(B===ne){var Z=new B(O);W(Z,w,Q),this._willSettleAt(Z,M)}else this._willSettleAt(new B(function(ae){return ae(w)}),M)}else this._willSettleAt(z(w),M)},le.prototype._settledAt=function(w,M,B){var z=this.promise;z._state===I&&(this._remaining--,w===G?H(z,B):this._result[M]=B),this._remaining===0&&Y(z,this._result)},le.prototype._willSettleAt=function(w,M){var B=this;se(w,void 0,function(z){return B._settledAt(P,M,z)},function(z){return B._settledAt(G,M,z)})};function ge(w){return new le(this,w).promise}function me(w){var M=this;return t(w)?new M(function(B,z){for(var Q=w.length,Z=0;Z<Q;Z++)M.resolve(w[Z]).then(B,z)}):new M(function(B,z){return z(new TypeError("You must pass an array to race."))})}function pe(w){var M=this,B=new M(O);return H(B,w),B}function Ee(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function ye(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function ne(w){this[b]=ce(),this._result=this._state=void 0,this._subscribers=[],O!==w&&(typeof w!="function"&&Ee(),this instanceof ne?te(this,w):ye())}ne.all=ge,ne.race=me,ne.resolve=p,ne.reject=pe,ne._setScheduler=i,ne._setAsap=E,ne._asap=s,ne.prototype={constructor:ne,then:o,catch:function(M){return this.then(null,M)}};function xe(){var w=void 0;if(typeof F!="undefined")w=F;else if(typeof self!="undefined")w=self;else try{w=Function("return this")()}catch(z){throw new Error("polyfill failed because global object is unavailable in this environment")}var M=w.Promise;if(M){var B=null;try{B=Object.prototype.toString.call(M.resolve())}catch(z){}if(B==="[object Promise]"&&!M.cast)return}w.Promise=ne}return ne.polyfill=xe,ne.Promise=ne,ne})}).call(this,L("_process"),typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{_process:3}],2:[function(L,j,A){function R(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}j.exports=R,R.EventEmitter=R,R.prototype._events=void 0,R.prototype._maxListeners=void 0,R.defaultMaxListeners=10,R.prototype.setMaxListeners=function(t){if(!T(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},R.prototype.emit=function(t){var e,n,u,s,i,E;if(this._events||(this._events={}),t==="error"&&(!this._events.error||f(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var _=new Error('Uncaught, unspecified "error" event. ('+e+")");throw _.context=e,_}if(n=this._events[t],h(n))return!1;if(F(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),n.apply(this,s)}else if(f(n))for(s=Array.prototype.slice.call(arguments,1),E=n.slice(),u=E.length,i=0;i<u;i++)E[i].apply(this,s);return!0},R.prototype.addListener=function(t,e){var n;if(!F(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,F(e.listener)?e.listener:e),this._events[t]?f(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,f(this._events[t])&&!this._events[t].warned&&(h(this._maxListeners)?n=R.defaultMaxListeners:n=this._maxListeners,n&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},R.prototype.on=R.prototype.addListener,R.prototype.once=function(t,e){if(!F(e))throw TypeError("listener must be a function");var n=!1;function u(){this.removeListener(t,u),n||(n=!0,e.apply(this,arguments))}return u.listener=e,this.on(t,u),this},R.prototype.removeListener=function(t,e){var n,u,s,i;if(!F(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],s=n.length,u=-1,n===e||F(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(f(n)){for(i=s;i-- >0;)if(n[i]===e||n[i].listener&&n[i].listener===e){u=i;break}if(u<0)return this;n.length===1?(n.length=0,delete this._events[t]):n.splice(u,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},R.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],F(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},R.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:F(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},R.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(F(e))return 1;if(e)return e.length}return 0},R.listenerCount=function(t,e){return t.listenerCount(e)};function F(t){return typeof t=="function"}function T(t){return typeof t=="number"}function f(t){return typeof t=="object"&&t!==null}function h(t){return t===void 0}},{}],3:[function(L,j,A){var R=j.exports={},F,T;function f(){throw new Error("setTimeout has not been defined")}function h(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?F=setTimeout:F=f}catch(a){F=f}try{typeof clearTimeout=="function"?T=clearTimeout:T=h}catch(a){T=h}})();function t(a){if(F===setTimeout)return setTimeout(a,0);if((F===f||!F)&&setTimeout)return F=setTimeout,setTimeout(a,0);try{return F(a,0)}catch(r){try{return F.call(null,a,0)}catch(c){return F.call(this,a,0)}}}function e(a){if(T===clearTimeout)return clearTimeout(a);if((T===h||!T)&&clearTimeout)return T=clearTimeout,clearTimeout(a);try{return T(a)}catch(r){try{return T.call(null,a)}catch(c){return T.call(this,a)}}}var n=[],u=!1,s,i=-1;function E(){!u||!s||(u=!1,s.length?n=s.concat(n):i=-1,n.length&&_())}function _(){if(!u){var a=t(E);u=!0;for(var r=n.length;r;){for(s=n,n=[];++i<r;)s&&s[i].run();i=-1,r=n.length}s=null,u=!1,e(a)}}R.nextTick=function(a){var r=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)r[c-1]=arguments[c];n.push(new v(a,r)),n.length===1&&!u&&t(_)};function v(a,r){this.fun=a,this.array=r}v.prototype.run=function(){this.fun.apply(null,this.array)},R.title="browser",R.browser=!0,R.env={},R.argv=[],R.version="",R.versions={};function d(){}R.on=d,R.addListener=d,R.once=d,R.off=d,R.removeListener=d,R.removeAllListeners=d,R.emit=d,R.prependListener=d,R.prependOnceListener=d,R.listeners=function(a){return[]},R.binding=function(a){throw new Error("process.binding is not supported")},R.cwd=function(){return"/"},R.chdir=function(a){throw new Error("process.chdir is not supported")},R.umask=function(){return 0}},{}],4:[function(L,j,A){var R=arguments[3],F=arguments[4],T=arguments[5],f=JSON.stringify;j.exports=function(h,t){for(var e,n=Object.keys(T),u=0,s=n.length;u<s;u++){var i=n[u],E=T[i].exports;if(E===h||E&&E.default===h){e=i;break}}if(!e){e=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var _={},u=0,s=n.length;u<s;u++){var i=n[u];_[i]=i}F[e]=[Function(["require","module","exports"],"("+h+")(self)"),_]}var v=Math.floor(Math.pow(16,8)*Math.random()).toString(16),d={};d[e]=e,F[v]=[Function(["require"],"var f = require("+f(e)+");(f.default ? f.default : f)(self);"),d];var a={};r(v);function r(k){a[k]=!0;for(var C in F[k][1]){var S=F[k][1][C];a[S]||r(S)}}var c="("+R+")({"+Object.keys(a).map(function(k){return f(k)+":["+F[k][0]+","+f(F[k][1])+"]"}).join(",")+"},{},["+f(v)+"])",l=window.URL||window.webkitURL||window.mozURL||window.msURL,g=new Blob([c],{type:"text/javascript"});if(t&&t.bare)return g;var y=l.createObjectURL(g),x=new Worker(y);return x.objectURL=y,x}},{}],5:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0}),A.createDefaultConfig=F;var R=A.defaultConfig={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:3*60,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:3*60,autoCleanupMinBackwardDuration:2*60,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1};function F(){return Object.assign({},R)}},{}],6:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function n(u,s){for(var i=0;i<s.length;i++){var E=s[i];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(u,E.key,E)}}return function(u,s,i){return s&&n(u.prototype,s),i&&n(u,i),u}}(),F=L("../io/io-controller.js"),T=h(F),f=L("../config.js");function h(n){return n&&n.__esModule?n:{default:n}}function t(n,u){if(!(n instanceof u))throw new TypeError("Cannot call a class as a function")}var e=function(){function n(){t(this,n)}return R(n,null,[{key:"supportMSEH264Playback",value:function(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}},{key:"supportNetworkStreamIO",value:function(){var s=new T.default({},(0,f.createDefaultConfig)()),i=s.loaderType;return s.destroy(),i=="fetch-stream-loader"||i=="xhr-moz-chunked-loader"}},{key:"getNetworkLoaderTypeName",value:function(){var s=new T.default({},(0,f.createDefaultConfig)()),i=s.loaderType;return s.destroy(),i}},{key:"supportNativeMediaPlayback",value:function(s){n.videoElement==null&&(n.videoElement=window.document.createElement("video"));var i=n.videoElement.canPlayType(s);return i==="probably"||i=="maybe"}},{key:"getFeatureList",value:function(){var s={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return s.mseFlvPlayback=n.supportMSEH264Playback(),s.networkStreamIO=n.supportNetworkStreamIO(),s.networkLoaderName=n.getNetworkLoaderTypeName(),s.mseLiveFlvPlayback=s.mseFlvPlayback&&s.networkStreamIO,s.nativeMP4H264Playback=n.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),s.nativeWebmVP8Playback=n.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),s.nativeWebmVP9Playback=n.supportNativeMediaPlayback('video/webm; codecs="vp9"'),s}}]),n}();A.default=e},{"../config.js":5,"../io/io-controller.js":23}],7:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function f(h,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,n.key,n)}}return function(h,t,e){return t&&f(h.prototype,t),e&&f(h,e),h}}();function F(f,h){if(!(f instanceof h))throw new TypeError("Cannot call a class as a function")}var T=function(){function f(){F(this,f),this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}return R(f,[{key:"isComplete",value:function(){var t=this.hasAudio===!1||this.hasAudio===!0&&this.audioCodec!=null&&this.audioSampleRate!=null&&this.audioChannelCount!=null,e=this.hasVideo===!1||this.hasVideo===!0&&this.videoCodec!=null&&this.width!=null&&this.height!=null&&this.fps!=null&&this.profile!=null&&this.level!=null&&this.refFrames!=null&&this.chromaFormat!=null&&this.sarNum!=null&&this.sarDen!=null;return this.mimeType!=null&&this.duration!=null&&this.metadata!=null&&this.hasKeyframesIndex!=null&&t&&e}},{key:"isSeekable",value:function(){return this.hasKeyframesIndex===!0}},{key:"getNearestKeyframe",value:function(t){if(this.keyframesIndex==null)return null;var e=this.keyframesIndex,n=this._search(e.times,t);return{index:n,milliseconds:e.times[n],fileposition:e.filepositions[n]}}},{key:"_search",value:function(t,e){var n=0,u=t.length-1,s=0,i=0,E=u;for(e<t[0]&&(n=0,i=E+1);i<=E;)if(s=i+Math.floor((E-i)/2),s===u||e>=t[s]&&e<t[s+1]){n=s;break}else t[s]<e?i=s+1:E=s-1;return n}}]),f}();A.default=T},{}],8:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function e(n,u){for(var s=0;s<u.length;s++){var i=u[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}}return function(n,u,s){return u&&e(n.prototype,u),s&&e(n,s),n}}();function F(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var T=A.SampleInfo=function e(n,u,s,i,E){F(this,e),this.dts=n,this.pts=u,this.duration=s,this.originalDts=i,this.isSyncPoint=E,this.fileposition=null},f=A.MediaSegmentInfo=function(){function e(){F(this,e),this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}return R(e,[{key:"appendSyncPoint",value:function(u){u.isSyncPoint=!0,this.syncPoints.push(u)}}]),e}(),h=A.IDRSampleList=function(){function e(){F(this,e),this._list=[]}return R(e,[{key:"clear",value:function(){this._list=[]}},{key:"appendArray",value:function(u){var s=this._list;u.length!==0&&(s.length>0&&u[0].originalDts<s[s.length-1].originalDts&&this.clear(),Array.prototype.push.apply(s,u))}},{key:"getLastSyncPointBeforeDts",value:function(u){if(this._list.length==0)return null;var s=this._list,i=0,E=s.length-1,_=0,v=0,d=E;for(u<s[0].dts&&(i=0,v=d+1);v<=d;)if(_=v+Math.floor((d-v)/2),_===E||u>=s[_].dts&&u<s[_+1].dts){i=_;break}else s[_].dts<u?v=_+1:d=_-1;return this._list[i]}}]),e}(),t=A.MediaSegmentInfoList=function(){function e(n){F(this,e),this._type=n,this._list=[],this._lastAppendLocation=-1}return R(e,[{key:"isEmpty",value:function(){return this._list.length===0}},{key:"clear",value:function(){this._list=[],this._lastAppendLocation=-1}},{key:"_searchNearestSegmentBefore",value:function(u){var s=this._list;if(s.length===0)return-2;var i=s.length-1,E=0,_=0,v=i,d=0;if(u<s[0].originalBeginDts)return d=-1,d;for(;_<=v;)if(E=_+Math.floor((v-_)/2),E===i||u>s[E].lastSample.originalDts&&u<s[E+1].originalBeginDts){d=E;break}else s[E].originalBeginDts<u?_=E+1:v=E-1;return d}},{key:"_searchNearestSegmentAfter",value:function(u){return this._searchNearestSegmentBefore(u)+1}},{key:"append",value:function(u){var s=this._list,i=u,E=this._lastAppendLocation,_=0;E!==-1&&E<s.length&&i.originalBeginDts>=s[E].lastSample.originalDts&&(E===s.length-1||E<s.length-1&&i.originalBeginDts<s[E+1].originalBeginDts)?_=E+1:s.length>0&&(_=this._searchNearestSegmentBefore(i.originalBeginDts)+1),this._lastAppendLocation=_,this._list.splice(_,0,i)}},{key:"getLastSegmentBefore",value:function(u){var s=this._searchNearestSegmentBefore(u);return s>=0?this._list[s]:null}},{key:"getLastSampleBefore",value:function(u){var s=this.getLastSegmentBefore(u);return s!=null?s.lastSample:null}},{key:"getLastSyncPointBefore",value:function(u){for(var s=this._searchNearestSegmentBefore(u),i=this._list[s].syncPoints;i.length===0&&s>0;)s--,i=this._list[s].syncPoints;return i.length>0?i[i.length-1]:null}},{key:"type",get:function(){return this._type}},{key:"length",get:function(){return this._list.length}}]),e}()},{}],9:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function d(a,r){for(var c=0;c<r.length;c++){var l=r[c];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(a,l.key,l)}}return function(a,r,c){return r&&d(a.prototype,r),c&&d(a,c),a}}(),F=L("events"),T=E(F),f=L("../utils/logger.js"),h=E(f),t=L("../utils/browser.js"),e=E(t),n=L("./mse-events.js"),u=E(n),s=L("./media-segment-info.js"),i=L("../utils/exception.js");function E(d){return d&&d.__esModule?d:{default:d}}function _(d,a){if(!(d instanceof a))throw new TypeError("Cannot call a class as a function")}var v=function(){function d(a){_(this,d),this.TAG="MSEController",this._config=a,this._emitter=new T.default,this._config.isLive&&this._config.autoCleanupSourceBuffer==null&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new s.IDRSampleList}return R(d,[{key:"destroy",value:function(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null}},{key:"on",value:function(r,c){this._emitter.addListener(r,c)}},{key:"off",value:function(r,c){this._emitter.removeListener(r,c)}},{key:"attachMediaElement",value:function(r){if(this._mediaSource)throw new i.IllegalStateException("MediaSource has been attached to an HTMLMediaElement!");var c=this._mediaSource=new window.MediaSource;c.addEventListener("sourceopen",this.e.onSourceOpen),c.addEventListener("sourceended",this.e.onSourceEnded),c.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=r,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),r.src=this._mediaSourceObjectURL}},{key:"detachMediaElement",value:function(){if(this._mediaSource){var r=this._mediaSource;for(var c in this._sourceBuffers){var l=this._pendingSegments[c];l.splice(0,l.length),this._pendingSegments[c]=null,this._pendingRemoveRanges[c]=null,this._lastInitSegments[c]=null;var g=this._sourceBuffers[c];g&&(r.readyState!=="closed"&&(r.removeSourceBuffer(g),g.removeEventListener("error",this.e.onSourceBufferError),g.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)),this._mimeTypes[c]=null,this._sourceBuffers[c]=null)}if(r.readyState==="open")try{r.endOfStream()}catch(y){h.default.e(this.TAG,y.message)}r.removeEventListener("sourceopen",this.e.onSourceOpen),r.removeEventListener("sourceended",this.e.onSourceEnded),r.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)}},{key:"appendInitSegment",value:function(r,c){if(!this._mediaSource||this._mediaSource.readyState!=="open"){this._pendingSourceBufferInit.push(r),this._pendingSegments[r.type].push(r);return}var l=r,g=""+l.container;l.codec&&l.codec.length>0&&(g+=";codecs="+l.codec);var y=!1;if(h.default.v(this.TAG,"Received Initialization Segment, mimeType: "+g),this._lastInitSegments[l.type]=l,g!==this._mimeTypes[l.type]){if(this._mimeTypes[l.type])h.default.v(this.TAG,"Notice: "+l.type+" mimeType changed, origin: "+this._mimeTypes[l.type]+", target: "+g);else{y=!0;try{var x=this._sourceBuffers[l.type]=this._mediaSource.addSourceBuffer(g);x.addEventListener("error",this.e.onSourceBufferError),x.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(k){h.default.e(this.TAG,k.message),this._emitter.emit(u.default.ERROR,{code:k.code,msg:k.message});return}}this._mimeTypes[l.type]=g}c||this._pendingSegments[l.type].push(l),y||this._sourceBuffers[l.type]&&!this._sourceBuffers[l.type].updating&&this._doAppendSegments(),e.default.safari&&l.container==="audio/mpeg"&&l.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=l.mediaDuration/1e3,this._updateMediaSourceDuration())}},{key:"appendMediaSegment",value:function(r){var c=r;this._pendingSegments[c.type].push(c),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var l=this._sourceBuffers[c.type];l&&!l.updating&&!this._hasPendingRemoveRanges()&&this._doAppendSegments()}},{key:"seek",value:function(r){for(var c in this._sourceBuffers)if(!!this._sourceBuffers[c]){var l=this._sourceBuffers[c];if(this._mediaSource.readyState==="open")try{l.abort()}catch(S){h.default.e(this.TAG,S.message)}this._idrList.clear();var g=this._pendingSegments[c];if(g.splice(0,g.length),this._mediaSource.readyState!=="closed"){for(var y=0;y<l.buffered.length;y++){var x=l.buffered.start(y),k=l.buffered.end(y);this._pendingRemoveRanges[c].push({start:x,end:k})}if(l.updating||this._doRemoveRanges(),e.default.safari){var C=this._lastInitSegments[c];C&&(this._pendingSegments[c].push(C),l.updating||this._doAppendSegments())}}}}},{key:"endOfStream",value:function(){var r=this._mediaSource,c=this._sourceBuffers;if(!r||r.readyState!=="open"){r&&r.readyState==="closed"&&this._hasPendingSegments()&&(this._hasPendingEos=!0);return}c.video&&c.video.updating||c.audio&&c.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,r.endOfStream())}},{key:"getNearestKeyframe",value:function(r){return this._idrList.getLastSyncPointBeforeDts(r)}},{key:"_needCleanupSourceBuffer",value:function(){if(!this._config.autoCleanupSourceBuffer)return!1;var r=this._mediaElement.currentTime;for(var c in this._sourceBuffers){var l=this._sourceBuffers[c];if(l){var g=l.buffered;if(g.length>=1&&r-g.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}},{key:"_doCleanupSourceBuffer",value:function(){var r=this._mediaElement.currentTime;for(var c in this._sourceBuffers){var l=this._sourceBuffers[c];if(l){for(var g=l.buffered,y=!1,x=0;x<g.length;x++){var k=g.start(x),C=g.end(x);if(k<=r&&r<C+3){if(r-k>=this._config.autoCleanupMaxBackwardDuration){y=!0;var S=r-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[c].push({start:k,end:S})}}else C<r&&(y=!0,this._pendingRemoveRanges[c].push({start:k,end:C}))}y&&!l.updating&&this._doRemoveRanges()}}}},{key:"_updateMediaSourceDuration",value:function(){var r=this._sourceBuffers;if(!(this._mediaElement.readyState===0||this._mediaSource.readyState!=="open")&&!(r.video&&r.video.updating||r.audio&&r.audio.updating)){var c=this._mediaSource.duration,l=this._pendingMediaDuration;l>0&&(isNaN(c)||l>c)&&(h.default.v(this.TAG,"Update MediaSource duration from "+c+" to "+l),this._mediaSource.duration=l),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}}},{key:"_doRemoveRanges",value:function(){for(var r in this._pendingRemoveRanges)if(!(!this._sourceBuffers[r]||this._sourceBuffers[r].updating))for(var c=this._sourceBuffers[r],l=this._pendingRemoveRanges[r];l.length&&!c.updating;){var g=l.shift();c.remove(g.start,g.end)}}},{key:"_doAppendSegments",value:function(){var r=this._pendingSegments;for(var c in r)if(!(!this._sourceBuffers[c]||this._sourceBuffers[c].updating)&&r[c].length>0){var l=r[c].shift();if(l.timestampOffset){var g=this._sourceBuffers[c].timestampOffset,y=l.timestampOffset/1e3,x=Math.abs(g-y);x>.1&&(h.default.v(this.TAG,"Update MPEG audio timestampOffset from "+g+" to "+y),this._sourceBuffers[c].timestampOffset=y),delete l.timestampOffset}if(!l.data||l.data.byteLength===0)continue;try{this._sourceBuffers[c].appendBuffer(l.data),this._isBufferFull=!1,c==="video"&&l.hasOwnProperty("info")&&this._idrList.appendArray(l.info.syncPoints)}catch(k){this._pendingSegments[c].unshift(l),k.code===22?(this._isBufferFull||this._emitter.emit(u.default.BUFFER_FULL),this._isBufferFull=!0):(h.default.e(this.TAG,k.message),this._emitter.emit(u.default.ERROR,{code:k.code,msg:k.message}))}}}},{key:"_onSourceOpen",value:function(){if(h.default.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var r=this._pendingSourceBufferInit;r.length;){var c=r.shift();this.appendInitSegment(c,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(u.default.SOURCE_OPEN)}},{key:"_onSourceEnded",value:function(){h.default.v(this.TAG,"MediaSource onSourceEnded")}},{key:"_onSourceClose",value:function(){h.default.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&this.e!=null&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))}},{key:"_hasPendingSegments",value:function(){var r=this._pendingSegments;return r.video.length>0||r.audio.length>0}},{key:"_hasPendingRemoveRanges",value:function(){var r=this._pendingRemoveRanges;return r.video.length>0||r.audio.length>0}},{key:"_onSourceBufferUpdateEnd",value:function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(u.default.UPDATE_END)}},{key:"_onSourceBufferError",value:function(r){h.default.e(this.TAG,"SourceBuffer Error: "+r)}}]),d}();A.default=v},{"../utils/browser.js":39,"../utils/exception.js":40,"../utils/logger.js":41,"./media-segment-info.js":8,"./mse-events.js":10,events:2}],10:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};A.default=R},{}],11:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function l(g,y){for(var x=0;x<y.length;x++){var k=y[x];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(g,k.key,k)}}return function(g,y,x){return y&&l(g.prototype,y),x&&l(g,x),g}}(),F=L("events"),T=a(F),f=L("../utils/logger.js"),h=a(f),t=L("../utils/logging-control.js"),e=a(t),n=L("./transmuxing-controller.js"),u=a(n),s=L("./transmuxing-events.js"),i=a(s),E=L("./transmuxing-worker.js"),_=a(E),v=L("./media-info.js"),d=a(v);function a(l){return l&&l.__esModule?l:{default:l}}function r(l,g){if(!(l instanceof g))throw new TypeError("Cannot call a class as a function")}var c=function(){function l(g,y){if(r(this,l),this.TAG="Transmuxer",this._emitter=new T.default,y.enableWorker&&typeof Worker!="undefined")try{var x=L("webworkify");this._worker=x(_.default),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[g,y]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},e.default.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:e.default.getConfig()})}catch(C){h.default.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new u.default(g,y)}else this._controller=new u.default(g,y);if(this._controller){var k=this._controller;k.on(i.default.IO_ERROR,this._onIOError.bind(this)),k.on(i.default.DEMUX_ERROR,this._onDemuxError.bind(this)),k.on(i.default.INIT_SEGMENT,this._onInitSegment.bind(this)),k.on(i.default.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),k.on(i.default.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),k.on(i.default.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),k.on(i.default.MEDIA_INFO,this._onMediaInfo.bind(this)),k.on(i.default.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),k.on(i.default.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}return R(l,[{key:"destroy",value:function(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),e.default.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null}},{key:"on",value:function(y,x){this._emitter.addListener(y,x)}},{key:"off",value:function(y,x){this._emitter.removeListener(y,x)}},{key:"hasWorker",value:function(){return this._worker!=null}},{key:"open",value:function(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()}},{key:"close",value:function(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()}},{key:"seek",value:function(y){this._worker?this._worker.postMessage({cmd:"seek",param:y}):this._controller.seek(y)}},{key:"pause",value:function(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()}},{key:"resume",value:function(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()}},{key:"_onInitSegment",value:function(y,x){var k=this;Promise.resolve().then(function(){k._emitter.emit(i.default.INIT_SEGMENT,y,x)})}},{key:"_onMediaSegment",value:function(y,x){var k=this;Promise.resolve().then(function(){k._emitter.emit(i.default.MEDIA_SEGMENT,y,x)})}},{key:"_onLoadingComplete",value:function(){var y=this;Promise.resolve().then(function(){y._emitter.emit(i.default.LOADING_COMPLETE)})}},{key:"_onRecoveredEarlyEof",value:function(){var y=this;Promise.resolve().then(function(){y._emitter.emit(i.default.RECOVERED_EARLY_EOF)})}},{key:"_onMediaInfo",value:function(y){var x=this;Promise.resolve().then(function(){x._emitter.emit(i.default.MEDIA_INFO,y)})}},{key:"_onStatisticsInfo",value:function(y){var x=this;Promise.resolve().then(function(){x._emitter.emit(i.default.STATISTICS_INFO,y)})}},{key:"_onIOError",value:function(y,x){var k=this;Promise.resolve().then(function(){k._emitter.emit(i.default.IO_ERROR,y,x)})}},{key:"_onDemuxError",value:function(y,x){var k=this;Promise.resolve().then(function(){k._emitter.emit(i.default.DEMUX_ERROR,y,x)})}},{key:"_onRecommendSeekpoint",value:function(y){var x=this;Promise.resolve().then(function(){x._emitter.emit(i.default.RECOMMEND_SEEKPOINT,y)})}},{key:"_onLoggingConfigChanged",value:function(y){this._worker&&this._worker.postMessage({cmd:"logging_config",param:y})}},{key:"_onWorkerMessage",value:function(y){var x=y.data,k=x.data;if(x.msg==="destroyed"||this._workerDestroying){this._workerDestroying=!1,this._worker.terminate(),this._worker=null;return}switch(x.msg){case i.default.INIT_SEGMENT:case i.default.MEDIA_SEGMENT:this._emitter.emit(x.msg,k.type,k.data);break;case i.default.LOADING_COMPLETE:case i.default.RECOVERED_EARLY_EOF:this._emitter.emit(x.msg);break;case i.default.MEDIA_INFO:Object.setPrototypeOf(k,d.default.prototype),this._emitter.emit(x.msg,k);break;case i.default.STATISTICS_INFO:this._emitter.emit(x.msg,k);break;case i.default.IO_ERROR:case i.default.DEMUX_ERROR:this._emitter.emit(x.msg,k.type,k.info);break;case i.default.RECOMMEND_SEEKPOINT:this._emitter.emit(x.msg,k);break;case"logcat_callback":h.default.emitter.emit("log",k.type,k.logcat);break;default:break}}}]),l}();A.default=c},{"../utils/logger.js":41,"../utils/logging-control.js":42,"./media-info.js":7,"./transmuxing-controller.js":12,"./transmuxing-events.js":13,"./transmuxing-worker.js":14,events:2,webworkify:4}],12:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function C(S,m){for(var o=0;o<m.length;o++){var p=m[o];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(S,p.key,p)}}return function(S,m,o){return m&&C(S.prototype,m),o&&C(S,o),S}}(),F=L("events"),T=y(F),f=L("../utils/logger.js"),h=y(f),t=L("../utils/browser.js"),e=y(t),n=L("./media-info.js"),u=y(n),s=L("../demux/flv-demuxer.js"),i=y(s),E=L("../remux/mp4-remuxer.js"),_=y(E),v=L("../demux/demux-errors.js"),d=y(v),a=L("../io/io-controller.js"),r=y(a),c=L("./transmuxing-events.js"),l=y(c),g=L("../io/loader.js");function y(C){return C&&C.__esModule?C:{default:C}}function x(C,S){if(!(C instanceof S))throw new TypeError("Cannot call a class as a function")}var k=function(){function C(S,m){x(this,C),this.TAG="TransmuxingController",this._emitter=new T.default,this._config=m,S.segments||(S.segments=[{duration:S.duration,filesize:S.filesize,url:S.url}]),typeof S.cors!="boolean"&&(S.cors=!0),typeof S.withCredentials!="boolean"&&(S.withCredentials=!1),this._mediaDataSource=S,this._currentSegmentIndex=0;var o=0;this._mediaDataSource.segments.forEach(function(p){p.timestampBase=o,o+=p.duration,p.cors=S.cors,p.withCredentials=S.withCredentials,m.referrerPolicy&&(p.referrerPolicy=m.referrerPolicy)}),!isNaN(o)&&this._mediaDataSource.duration!==o&&(this._mediaDataSource.duration=o),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}return R(C,[{key:"destroy",value:function(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null}},{key:"on",value:function(m,o){this._emitter.addListener(m,o)}},{key:"off",value:function(m,o){this._emitter.removeListener(m,o)}},{key:"start",value:function(){this._loadSegment(0),this._enableStatisticsReporter()}},{key:"_loadSegment",value:function(m,o){this._currentSegmentIndex=m;var p=this._mediaDataSource.segments[m],b=this._ioctl=new r.default(p,this._config,m);b.onError=this._onIOException.bind(this),b.onSeeked=this._onIOSeeked.bind(this),b.onComplete=this._onIOComplete.bind(this),b.onRedirect=this._onIORedirect.bind(this),b.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),o?this._demuxer.bindDataSource(this._ioctl):b.onDataArrival=this._onInitChunkArrival.bind(this),b.open(o)}},{key:"stop",value:function(){this._internalAbort(),this._disableStatisticsReporter()}},{key:"_internalAbort",value:function(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)}},{key:"pause",value:function(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())}},{key:"resume",value:function(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())}},{key:"seek",value:function(m){if(!(this._mediaInfo==null||!this._mediaInfo.isSeekable())){var o=this._searchSegmentIndexContains(m);if(o===this._currentSegmentIndex){var p=this._mediaInfo.segments[o];if(p==null)this._pendingSeekTime=m;else{var b=p.getNearestKeyframe(m);this._remuxer.seek(b.milliseconds),this._ioctl.seek(b.fileposition),this._pendingResolveSeekPoint=b.milliseconds}}else{var O=this._mediaInfo.segments[o];if(O==null)this._pendingSeekTime=m,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(o);else{var I=O.getNearestKeyframe(m);this._internalAbort(),this._remuxer.seek(m),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[o].timestampBase,this._loadSegment(o,I.fileposition),this._pendingResolveSeekPoint=I.milliseconds,this._reportSegmentMediaInfo(o)}}this._enableStatisticsReporter()}}},{key:"_searchSegmentIndexContains",value:function(m){for(var o=this._mediaDataSource.segments,p=o.length-1,b=0;b<o.length;b++)if(m<o[b].timestampBase){p=b-1;break}return p}},{key:"_onInitChunkArrival",value:function(m,o){var p=this,b=null,O=0;if(o>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,O=this._demuxer.parseChunks(m,o);else if((b=i.default.probe(m)).match){this._demuxer=new i.default(b,this._config),this._remuxer||(this._remuxer=new _.default(this._config));var I=this._mediaDataSource;I.duration!=null&&!isNaN(I.duration)&&(this._demuxer.overridedDuration=I.duration),typeof I.hasAudio=="boolean"&&(this._demuxer.overridedHasAudio=I.hasAudio),typeof I.hasVideo=="boolean"&&(this._demuxer.overridedHasVideo=I.hasVideo),this._demuxer.timestampBase=I.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),O=this._demuxer.parseChunks(m,o)}else b=null,h.default.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(function(){p._internalAbort()}),this._emitter.emit(l.default.DEMUX_ERROR,d.default.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),O=0;return O}},{key:"_onMediaInfo",value:function(m){var o=this;this._mediaInfo==null&&(this._mediaInfo=Object.assign({},m),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,u.default.prototype));var p=Object.assign({},m);Object.setPrototypeOf(p,u.default.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=p,this._reportSegmentMediaInfo(this._currentSegmentIndex),this._pendingSeekTime!=null&&Promise.resolve().then(function(){var b=o._pendingSeekTime;o._pendingSeekTime=null,o.seek(b)})}},{key:"_onIOSeeked",value:function(){this._remuxer.insertDiscontinuity()}},{key:"_onIOComplete",value:function(m){var o=m,p=o+1;p<this._mediaDataSource.segments.length?(this._internalAbort(),this._loadSegment(p)):(this._remuxer.flushStashedSamples(),this._emitter.emit(l.default.LOADING_COMPLETE),this._disableStatisticsReporter())}},{key:"_onIORedirect",value:function(m){var o=this._ioctl.extraData;this._mediaDataSource.segments[o].redirectedURL=m}},{key:"_onIORecoveredEarlyEof",value:function(){this._emitter.emit(l.default.RECOVERED_EARLY_EOF)}},{key:"_onIOException",value:function(m,o){h.default.e(this.TAG,"IOException: type = "+m+", code = "+o.code+", msg = "+o.msg),this._emitter.emit(l.default.IO_ERROR,m,o),this._disableStatisticsReporter()}},{key:"_onDemuxException",value:function(m,o){h.default.e(this.TAG,"DemuxException: type = "+m+", info = "+o),this._emitter.emit(l.default.DEMUX_ERROR,m,o)}},{key:"_onRemuxerInitSegmentArrival",value:function(m,o){this._emitter.emit(l.default.INIT_SEGMENT,m,o)}},{key:"_onRemuxerMediaSegmentArrival",value:function(m,o){if(this._pendingSeekTime==null&&(this._emitter.emit(l.default.MEDIA_SEGMENT,m,o),this._pendingResolveSeekPoint!=null&&m==="video")){var p=o.info.syncPoints,b=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,e.default.safari&&p.length>0&&p[0].originalDts===b&&(b=p[0].pts),this._emitter.emit(l.default.RECOMMEND_SEEKPOINT,b)}}},{key:"_enableStatisticsReporter",value:function(){this._statisticsReporter==null&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))}},{key:"_disableStatisticsReporter",value:function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}},{key:"_reportSegmentMediaInfo",value:function(m){var o=this._mediaInfo.segments[m],p=Object.assign({},o);p.duration=this._mediaInfo.duration,p.segmentCount=this._mediaInfo.segmentCount,delete p.segments,delete p.keyframesIndex,this._emitter.emit(l.default.MEDIA_INFO,p)}},{key:"_reportStatisticsInfo",value:function(){var m={};m.url=this._ioctl.currentURL,m.hasRedirect=this._ioctl.hasRedirect,m.hasRedirect&&(m.redirectedURL=this._ioctl.currentRedirectedURL),m.speed=this._ioctl.currentSpeed,m.loaderType=this._ioctl.loaderType,m.currentSegmentIndex=this._currentSegmentIndex,m.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(l.default.STATISTICS_INFO,m)}}]),C}();A.default=k},{"../demux/demux-errors.js":16,"../demux/flv-demuxer.js":18,"../io/io-controller.js":23,"../io/loader.js":24,"../remux/mp4-remuxer.js":38,"../utils/browser.js":39,"../utils/logger.js":41,"./media-info.js":7,"./transmuxing-events.js":13,events:2}],13:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};A.default=R},{}],14:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=L("../utils/logger.js"),F=i(R),T=L("../utils/logging-control.js"),f=i(T),h=L("../utils/polyfill.js"),t=i(h),e=L("./transmuxing-controller.js"),n=i(e),u=L("./transmuxing-events.js"),s=i(u);function i(_){return _&&_.__esModule?_:{default:_}}var E=function(v){var d="TransmuxingWorker",a=null,r=o.bind(this);t.default.install(),v.addEventListener("message",function(p){switch(p.data.cmd){case"init":a=new n.default(p.data.param[0],p.data.param[1]),a.on(s.default.IO_ERROR,C.bind(this)),a.on(s.default.DEMUX_ERROR,S.bind(this)),a.on(s.default.INIT_SEGMENT,c.bind(this)),a.on(s.default.MEDIA_SEGMENT,l.bind(this)),a.on(s.default.LOADING_COMPLETE,g.bind(this)),a.on(s.default.RECOVERED_EARLY_EOF,y.bind(this)),a.on(s.default.MEDIA_INFO,x.bind(this)),a.on(s.default.STATISTICS_INFO,k.bind(this)),a.on(s.default.RECOMMEND_SEEKPOINT,m.bind(this));break;case"destroy":a&&(a.destroy(),a=null),v.postMessage({msg:"destroyed"});break;case"start":a.start();break;case"stop":a.stop();break;case"seek":a.seek(p.data.param);break;case"pause":a.pause();break;case"resume":a.resume();break;case"logging_config":{var b=p.data.param;f.default.applyConfig(b),b.enableCallback===!0?f.default.addLogListener(r):f.default.removeLogListener(r);break}}});function c(p,b){var O={msg:s.default.INIT_SEGMENT,data:{type:p,data:b}};v.postMessage(O,[b.data])}function l(p,b){var O={msg:s.default.MEDIA_SEGMENT,data:{type:p,data:b}};v.postMessage(O,[b.data])}function g(){var p={msg:s.default.LOADING_COMPLETE};v.postMessage(p)}function y(){var p={msg:s.default.RECOVERED_EARLY_EOF};v.postMessage(p)}function x(p){var b={msg:s.default.MEDIA_INFO,data:p};v.postMessage(b)}function k(p){var b={msg:s.default.STATISTICS_INFO,data:p};v.postMessage(b)}function C(p,b){v.postMessage({msg:s.default.IO_ERROR,data:{type:p,info:b}})}function S(p,b){v.postMessage({msg:s.default.DEMUX_ERROR,data:{type:p,info:b}})}function m(p){v.postMessage({msg:s.default.RECOMMEND_SEEKPOINT,data:p})}function o(p,b){v.postMessage({msg:"logcat_callback",data:{type:p,logcat:b}})}};A.default=E},{"../utils/logger.js":41,"../utils/logging-control.js":42,"../utils/polyfill.js":43,"./transmuxing-controller.js":12,"./transmuxing-events.js":13}],15:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function i(E,_){for(var v=0;v<_.length;v++){var d=_[v];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(E,d.key,d)}}return function(E,_,v){return _&&i(E.prototype,_),v&&i(E,v),E}}(),F=L("../utils/logger.js"),T=e(F),f=L("../utils/utf8-conv.js"),h=e(f),t=L("../utils/exception.js");function e(i){return i&&i.__esModule?i:{default:i}}function n(i,E){if(!(i instanceof E))throw new TypeError("Cannot call a class as a function")}var u=function(){var i=new ArrayBuffer(2);return new DataView(i).setInt16(0,256,!0),new Int16Array(i)[0]===256}(),s=function(){function i(){n(this,i)}return R(i,null,[{key:"parseScriptData",value:function(_,v,d){var a={};try{var r=i.parseValue(_,v,d),c=i.parseValue(_,v+r.size,d-r.size);a[r.data]=c.data}catch(l){T.default.e("AMF",l.toString())}return a}},{key:"parseObject",value:function(_,v,d){if(d<3)throw new t.IllegalStateException("Data not enough when parse ScriptDataObject");var a=i.parseString(_,v,d),r=i.parseValue(_,v+a.size,d-a.size),c=r.objectEnd;return{data:{name:a.data,value:r.data},size:a.size+r.size,objectEnd:c}}},{key:"parseVariable",value:function(_,v,d){return i.parseObject(_,v,d)}},{key:"parseString",value:function(_,v,d){if(d<2)throw new t.IllegalStateException("Data not enough when parse String");var a=new DataView(_,v,d),r=a.getUint16(0,!u),c=void 0;return r>0?c=(0,h.default)(new Uint8Array(_,v+2,r)):c="",{data:c,size:2+r}}},{key:"parseLongString",value:function(_,v,d){if(d<4)throw new t.IllegalStateException("Data not enough when parse LongString");var a=new DataView(_,v,d),r=a.getUint32(0,!u),c=void 0;return r>0?c=(0,h.default)(new Uint8Array(_,v+4,r)):c="",{data:c,size:4+r}}},{key:"parseDate",value:function(_,v,d){if(d<10)throw new t.IllegalStateException("Data size invalid when parse Date");var a=new DataView(_,v,d),r=a.getFloat64(0,!u),c=a.getInt16(8,!u);return r+=c*60*1e3,{data:new Date(r),size:8+2}}},{key:"parseValue",value:function(_,v,d){if(d<1)throw new t.IllegalStateException("Data not enough when parse Value");var a=new DataView(_,v,d),r=1,c=a.getUint8(0),l=void 0,g=!1;try{switch(c){case 0:l=a.getFloat64(1,!u),r+=8;break;case 1:{var y=a.getUint8(1);l=!!y,r+=1;break}case 2:{var x=i.parseString(_,v+1,d-1);l=x.data,r+=x.size;break}case 3:{l={};var k=0;for((a.getUint32(d-4,!u)&16777215)==9&&(k=3);r<d-4;){var C=i.parseObject(_,v+r,d-r-k);if(C.objectEnd)break;l[C.data.name]=C.data.value,r+=C.size}if(r<=d-3){var S=a.getUint32(r-1,!u)&16777215;S===9&&(r+=3)}break}case 8:{l={},r+=4;var m=0;for((a.getUint32(d-4,!u)&16777215)==9&&(m=3);r<d-8;){var o=i.parseVariable(_,v+r,d-r-m);if(o.objectEnd)break;l[o.data.name]=o.data.value,r+=o.size}if(r<=d-3){var p=a.getUint32(r-1,!u)&16777215;p===9&&(r+=3)}break}case 9:l=void 0,r=1,g=!0;break;case 10:{l=[];var b=a.getUint32(1,!u);r+=4;for(var O=0;O<b;O++){var I=i.parseValue(_,v+r,d-r);l.push(I.data),r+=I.size}break}case 11:{var P=i.parseDate(_,v+1,d-1);l=P.data,r+=P.size;break}case 12:{var G=i.parseString(_,v+1,d-1);l=G.data,r+=G.size;break}default:r=d,T.default.w("AMF","Unsupported AMF value type "+c)}}catch(D){T.default.e("AMF",D.toString())}return{data:l,size:r,objectEnd:g}}}]),i}();A.default=s},{"../utils/exception.js":40,"../utils/logger.js":41,"../utils/utf8-conv.js":44}],16:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};A.default=R},{}],17:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function h(t,e){for(var n=0;n<e.length;n++){var u=e[n];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(t,u.key,u)}}return function(t,e,n){return e&&h(t.prototype,e),n&&h(t,n),t}}(),F=L("../utils/exception.js");function T(h,t){if(!(h instanceof t))throw new TypeError("Cannot call a class as a function")}var f=function(){function h(t){T(this,h),this.TAG="ExpGolomb",this._buffer=t,this._buffer_index=0,this._total_bytes=t.byteLength,this._total_bits=t.byteLength*8,this._current_word=0,this._current_word_bits_left=0}return R(h,[{key:"destroy",value:function(){this._buffer=null}},{key:"_fillCurrentWord",value:function(){var e=this._total_bytes-this._buffer_index;if(e<=0)throw new F.IllegalStateException("ExpGolomb: _fillCurrentWord() but no bytes available");var n=Math.min(4,e),u=new Uint8Array(4);u.set(this._buffer.subarray(this._buffer_index,this._buffer_index+n)),this._current_word=new DataView(u.buffer).getUint32(0,!1),this._buffer_index+=n,this._current_word_bits_left=n*8}},{key:"readBits",value:function(e){if(e>32)throw new F.InvalidArgumentException("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){var n=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,n}var u=this._current_word_bits_left?this._current_word:0;u=u>>>32-this._current_word_bits_left;var s=e-this._current_word_bits_left;this._fillCurrentWord();var i=Math.min(s,this._current_word_bits_left),E=this._current_word>>>32-i;return this._current_word<<=i,this._current_word_bits_left-=i,u=u<<i|E,u}},{key:"readBool",value:function(){return this.readBits(1)===1}},{key:"readByte",value:function(){return this.readBits(8)}},{key:"_skipLeadingZero",value:function(){var e=void 0;for(e=0;e<this._current_word_bits_left;e++)if((this._current_word&2147483648>>>e)!=0)return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}},{key:"readUEG",value:function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1}},{key:"readSEG",value:function(){var e=this.readUEG();return e&1?e+1>>>1:-1*(e>>>1)}}]),h}();A.default=f},{"../utils/exception.js":40}],18:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(g){return typeof g}:function(g){return g&&typeof Symbol=="function"&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g},F=function(){function g(y,x){for(var k=0;k<x.length;k++){var C=x[k];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(y,C.key,C)}}return function(y,x,k){return x&&g(y.prototype,x),k&&g(y,k),y}}(),T=L("../utils/logger.js"),f=v(T),h=L("./amf-parser.js"),t=v(h),e=L("./sps-parser.js"),n=v(e),u=L("./demux-errors.js"),s=v(u),i=L("../core/media-info.js"),E=v(i),_=L("../utils/exception.js");function v(g){return g&&g.__esModule?g:{default:g}}function d(g,y){if(!(g instanceof y))throw new TypeError("Cannot call a class as a function")}function a(g){return g>>>8&255|(g&255)<<8}function r(g){return(g&4278190080)>>>24|(g&16711680)>>>8|(g&65280)<<8|(g&255)<<24}function c(g,y){return g[y]<<24|g[y+1]<<16|g[y+2]<<8|g[y+3]}var l=function(){function g(y,x){d(this,g),this.TAG="FLVDemuxer",this._config=x,this._onError=null,this._onMediaInfo=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=y.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=y.hasAudioTrack,this._hasVideo=y.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new E.default,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){var k=new ArrayBuffer(2);return new DataView(k).setInt16(0,256,!0),new Int16Array(k)[0]===256}()}return F(g,[{key:"destroy",value:function(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onTrackMetadata=null,this._onDataAvailable=null}},{key:"bindDataSource",value:function(x){return x.onDataArrival=this.parseChunks.bind(this),this}},{key:"resetMediaInfo",value:function(){this._mediaInfo=new E.default}},{key:"_isInitialMetadataDispatched",value:function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!this._hasAudio&&this._hasVideo?this._videoInitialMetadataDispatched:!1}},{key:"parseChunks",value:function(x,k){if(!this._onError||!this._onMediaInfo||!this._onTrackMetadata||!this._onDataAvailable)throw new _.IllegalStateException("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var C=0,S=this._littleEndian;if(k===0)if(x.byteLength>13){var m=g.probe(x);C=m.dataOffset}else return 0;if(this._firstParse){this._firstParse=!1,k+C!==this._dataOffset&&f.default.w(this.TAG,"First time parsing but chunk byteStart invalid!");var o=new DataView(x,C),p=o.getUint32(0,!S);p!==0&&f.default.w(this.TAG,"PrevTagSize0 !== 0 !!!"),C+=4}for(;C<x.byteLength;){this._dispatch=!0;var b=new DataView(x,C);if(C+11+4>x.byteLength)break;var O=b.getUint8(0),I=b.getUint32(0,!S)&16777215;if(C+11+I+4>x.byteLength)break;if(O!==8&&O!==9&&O!==18){f.default.w(this.TAG,"Unsupported tag type "+O+", skipped"),C+=11+I+4;continue}var P=b.getUint8(4),G=b.getUint8(5),D=b.getUint8(6),V=b.getUint8(7),U=D|G<<8|P<<16|V<<24,q=b.getUint32(7,!S)&16777215;q!==0&&f.default.w(this.TAG,"Meet tag which has StreamID != 0!");var N=C+11;switch(O){case 8:this._parseAudioData(x,N,I,U);break;case 9:this._parseVideoData(x,N,I,U,k+C);break;case 18:this._parseScriptData(x,N,I);break}var J=b.getUint32(11+I,!S);J!==11+I&&f.default.w(this.TAG,"Invalid PrevTagSize "+J),C+=11+I+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),C}},{key:"_parseScriptData",value:function(x,k,C){var S=t.default.parseScriptData(x,k,C);if(S.hasOwnProperty("onMetaData")){if(S.onMetaData==null||R(S.onMetaData)!=="object"){f.default.w(this.TAG,"Invalid onMetaData structure!");return}this._metadata&&f.default.w(this.TAG,"Found another onMetaData tag!"),this._metadata=S;var m=this._metadata.onMetaData;if(typeof m.hasAudio=="boolean"&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=m.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),typeof m.hasVideo=="boolean"&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=m.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),typeof m.audiodatarate=="number"&&(this._mediaInfo.audioDataRate=m.audiodatarate),typeof m.videodatarate=="number"&&(this._mediaInfo.videoDataRate=m.videodatarate),typeof m.width=="number"&&(this._mediaInfo.width=m.width),typeof m.height=="number"&&(this._mediaInfo.height=m.height),typeof m.duration=="number"){if(!this._durationOverrided){var o=Math.floor(m.duration*this._timescale);this._duration=o,this._mediaInfo.duration=o}}else this._mediaInfo.duration=0;if(typeof m.framerate=="number"){var p=Math.floor(m.framerate*1e3);if(p>0){var b=p/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=b,this._referenceFrameRate.fps_num=p,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=b}}if(R(m.keyframes)==="object"){this._mediaInfo.hasKeyframesIndex=!0;var O=m.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(O),m.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=m,f.default.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}}},{key:"_parseKeyframesIndex",value:function(x){for(var k=[],C=[],S=1;S<x.times.length;S++){var m=this._timestampBase+Math.floor(x.times[S]*1e3);k.push(m),C.push(x.filepositions[S])}return{times:k,filepositions:C}}},{key:"_parseAudioData",value:function(x,k,C,S){if(C<=1){f.default.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");return}if(!(this._hasAudioFlagOverrided===!0&&this._hasAudio===!1)){var m=this._littleEndian,o=new DataView(x,k,C),p=o.getUint8(0),b=p>>>4;if(b!==2&&b!==10){this._onError(s.default.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+b);return}var O=0,I=(p&12)>>>2;if(I>=0&&I<=4)O=this._flvSoundRateTable[I];else{this._onError(s.default.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+I);return}var P=(p&2)>>>1,G=p&1,D=this._audioMetadata,V=this._audioTrack;if(D||(this._hasAudio===!1&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),D=this._audioMetadata={},D.type="audio",D.id=V.id,D.timescale=this._timescale,D.duration=this._duration,D.audioSampleRate=O,D.channelCount=G===0?1:2),b===10){var U=this._parseAACAudioData(x,k+1,C-1);if(U==null)return;if(U.packetType===0){D.config&&f.default.w(this.TAG,"Found another AudioSpecificConfig!");var q=U.data;D.audioSampleRate=q.samplingRate,D.channelCount=q.channelCount,D.codec=q.codec,D.originalCodec=q.originalCodec,D.config=q.config,D.refSampleDuration=1024/D.audioSampleRate*D.timescale,f.default.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",D);var N=this._mediaInfo;N.audioCodec=D.originalCodec,N.audioSampleRate=D.audioSampleRate,N.audioChannelCount=D.channelCount,N.hasVideo?N.videoCodec!=null&&(N.mimeType='video/x-flv; codecs="'+N.videoCodec+","+N.audioCodec+'"'):N.mimeType='video/x-flv; codecs="'+N.audioCodec+'"',N.isComplete()&&this._onMediaInfo(N)}else if(U.packetType===1){var J=this._timestampBase+S,$={unit:U.data,length:U.data.byteLength,dts:J,pts:J};V.samples.push($),V.length+=U.data.length}else f.default.e(this.TAG,"Flv: Unsupported AAC data type "+U.packetType)}else if(b===2){if(!D.codec){var W=this._parseMP3AudioData(x,k+1,C-1,!0);if(W==null)return;D.audioSampleRate=W.samplingRate,D.channelCount=W.channelCount,D.codec=W.codec,D.originalCodec=W.originalCodec,D.refSampleDuration=1152/D.audioSampleRate*D.timescale,f.default.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",D);var X=this._mediaInfo;X.audioCodec=D.codec,X.audioSampleRate=D.audioSampleRate,X.audioChannelCount=D.channelCount,X.audioDataRate=W.bitRate,X.hasVideo?X.videoCodec!=null&&(X.mimeType='video/x-flv; codecs="'+X.videoCodec+","+X.audioCodec+'"'):X.mimeType='video/x-flv; codecs="'+X.audioCodec+'"',X.isComplete()&&this._onMediaInfo(X)}var K=this._parseMP3AudioData(x,k+1,C-1,!1);if(K==null)return;var Y=this._timestampBase+S,H={unit:K,length:K.byteLength,dts:Y,pts:Y};V.samples.push(H),V.length+=K.length}}}},{key:"_parseAACAudioData",value:function(x,k,C){if(C<=1){f.default.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");return}var S={},m=new Uint8Array(x,k,C);return S.packetType=m[0],m[0]===0?S.data=this._parseAACAudioSpecificConfig(x,k+1,C-1):S.data=m.subarray(1),S}},{key:"_parseAACAudioSpecificConfig",value:function(x,k,C){var S=new Uint8Array(x,k,C),m=null,o=0,p=0,b=null,O=0,I=null;if(o=p=S[0]>>>3,O=(S[0]&7)<<1|S[1]>>>7,O<0||O>=this._mpegSamplingRates.length){this._onError(s.default.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");return}var P=this._mpegSamplingRates[O],G=(S[1]&120)>>>3;if(G<0||G>=8){this._onError(s.default.FORMAT_ERROR,"Flv: AAC invalid channel configuration");return}o===5&&(I=(S[1]&7)<<1|S[2]>>>7,b=(S[2]&124)>>>2);var D=self.navigator.userAgent.toLowerCase();return D.indexOf("firefox")!==-1?O>=6?(o=5,m=new Array(4),I=O-3):(o=2,m=new Array(2),I=O):D.indexOf("android")!==-1?(o=2,m=new Array(2),I=O):(o=5,I=O,m=new Array(4),O>=6?I=O-3:G===1&&(o=2,m=new Array(2),I=O)),m[0]=o<<3,m[0]|=(O&15)>>>1,m[1]=(O&15)<<7,m[1]|=(G&15)<<3,o===5&&(m[1]|=(I&15)>>>1,m[2]=(I&1)<<7,m[2]|=2<<2,m[3]=0),{config:m,samplingRate:P,channelCount:G,codec:"mp4a.40."+o,originalCodec:"mp4a.40."+p}}},{key:"_parseMP3AudioData",value:function(x,k,C,S){if(C<4){f.default.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");return}var m=this._littleEndian,o=new Uint8Array(x,k,C),p=null;if(S){if(o[0]!==255)return;var b=o[1]>>>3&3,O=(o[1]&6)>>1,I=(o[2]&240)>>>4,P=(o[2]&12)>>>2,G=o[3]>>>6&3,D=G!==3?2:1,V=0,U=0,q=34,N="mp3";switch(b){case 0:V=this._mpegAudioV25SampleRateTable[P];break;case 2:V=this._mpegAudioV20SampleRateTable[P];break;case 3:V=this._mpegAudioV10SampleRateTable[P];break}switch(O){case 1:q=34,I<this._mpegAudioL3BitRateTable.length&&(U=this._mpegAudioL3BitRateTable[I]);break;case 2:q=33,I<this._mpegAudioL2BitRateTable.length&&(U=this._mpegAudioL2BitRateTable[I]);break;case 3:q=32,I<this._mpegAudioL1BitRateTable.length&&(U=this._mpegAudioL1BitRateTable[I]);break}p={bitRate:U,samplingRate:V,channelCount:D,codec:N,originalCodec:N}}else p=o;return p}},{key:"_parseVideoData",value:function(x,k,C,S,m){if(C<=1){f.default.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");return}if(!(this._hasVideoFlagOverrided===!0&&this._hasVideo===!1)){var o=new Uint8Array(x,k,C)[0],p=(o&240)>>>4,b=o&15;if(b!==7){this._onError(s.default.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+b);return}this._parseAVCVideoPacket(x,k+1,C-1,S,m,p)}}},{key:"_parseAVCVideoPacket",value:function(x,k,C,S,m,o){if(C<4){f.default.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");return}var p=this._littleEndian,b=new DataView(x,k,C),O=b.getUint8(0),I=b.getUint32(0,!p)&16777215,P=I<<8>>8;if(O===0)this._parseAVCDecoderConfigurationRecord(x,k+4,C-4);else if(O===1)this._parseAVCVideoData(x,k+4,C-4,S,m,o,P);else if(O!==2){this._onError(s.default.FORMAT_ERROR,"Flv: Invalid video packet type "+O);return}}},{key:"_parseAVCDecoderConfigurationRecord",value:function(x,k,C){if(C<7){f.default.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");return}var S=this._videoMetadata,m=this._videoTrack,o=this._littleEndian,p=new DataView(x,k,C);S?typeof S.avcc!="undefined"&&f.default.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(this._hasVideo===!1&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),S=this._videoMetadata={},S.type="video",S.id=m.id,S.timescale=this._timescale,S.duration=this._duration);var b=p.getUint8(0),O=p.getUint8(1),I=p.getUint8(2),P=p.getUint8(3);if(b!==1||O===0){this._onError(s.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");return}if(this._naluLengthSize=(p.getUint8(4)&3)+1,this._naluLengthSize!==3&&this._naluLengthSize!==4){this._onError(s.default.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));return}var G=p.getUint8(5)&31;if(G===0){this._onError(s.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");return}else G>1&&f.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+G);for(var D=6,V=0;V<G;V++){var U=p.getUint16(D,!o);if(D+=2,U!==0){var q=new Uint8Array(x,k+D,U);D+=U;var N=n.default.parseSPS(q);if(V===0){S.codecWidth=N.codec_size.width,S.codecHeight=N.codec_size.height,S.presentWidth=N.present_size.width,S.presentHeight=N.present_size.height,S.profile=N.profile_string,S.level=N.level_string,S.bitDepth=N.bit_depth,S.chromaFormat=N.chroma_format,S.sarRatio=N.sar_ratio,S.frameRate=N.frame_rate,(N.frame_rate.fixed===!1||N.frame_rate.fps_num===0||N.frame_rate.fps_den===0)&&(S.frameRate=this._referenceFrameRate);var J=S.frameRate.fps_den,$=S.frameRate.fps_num;S.refSampleDuration=S.timescale*(J/$);for(var W=q.subarray(1,4),X="avc1.",K=0;K<3;K++){var Y=W[K].toString(16);Y.length<2&&(Y="0"+Y),X+=Y}S.codec=X;var H=this._mediaInfo;H.width=S.codecWidth,H.height=S.codecHeight,H.fps=S.frameRate.fps,H.profile=S.profile,H.level=S.level,H.refFrames=N.ref_frames,H.chromaFormat=N.chroma_format_string,H.sarNum=S.sarRatio.width,H.sarDen=S.sarRatio.height,H.videoCodec=X,H.hasAudio?H.audioCodec!=null&&(H.mimeType='video/x-flv; codecs="'+H.videoCodec+","+H.audioCodec+'"'):H.mimeType='video/x-flv; codecs="'+H.videoCodec+'"',H.isComplete()&&this._onMediaInfo(H)}}}var se=p.getUint8(D);if(se===0){this._onError(s.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS");return}else se>1&&f.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+se);D++;for(var re=0;re<se;re++){var ee=p.getUint16(D,!o);D+=2,ee!==0&&(D+=ee)}S.avcc=new Uint8Array(C),S.avcc.set(new Uint8Array(x,k,C),0),f.default.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",S)}},{key:"_parseAVCVideoData",value:function(x,k,C,S,m,o,p){for(var b=this._littleEndian,O=new DataView(x,k,C),I=[],P=0,G=0,D=this._naluLengthSize,V=this._timestampBase+S,U=o===1;G<C;){if(G+4>=C){f.default.w(this.TAG,"Malformed Nalu near timestamp "+V+", offset = "+G+", dataSize = "+C);break}var q=O.getUint32(G,!b);if(D===3&&(q>>>=8),q>C-D){f.default.w(this.TAG,"Malformed Nalus near timestamp "+V+", NaluSize > DataSize!");return}var N=O.getUint8(G+D)&31;N===5&&(U=!0);var J=new Uint8Array(x,k+G,D+q),$={type:N,data:J};I.push($),P+=J.byteLength,G+=D+q}if(I.length){var W=this._videoTrack,X={units:I,length:P,isKeyframe:U,dts:V,cts:p,pts:V+p};U&&(X.fileposition=m),W.samples.push(X),W.length+=P}}},{key:"onTrackMetadata",get:function(){return this._onTrackMetadata},set:function(x){this._onTrackMetadata=x}},{key:"onMediaInfo",get:function(){return this._onMediaInfo},set:function(x){this._onMediaInfo=x}},{key:"onError",get:function(){return this._onError},set:function(x){this._onError=x}},{key:"onDataAvailable",get:function(){return this._onDataAvailable},set:function(x){this._onDataAvailable=x}},{key:"timestampBase",get:function(){return this._timestampBase},set:function(x){this._timestampBase=x}},{key:"overridedDuration",get:function(){return this._duration},set:function(x){this._durationOverrided=!0,this._duration=x,this._mediaInfo.duration=x}},{key:"overridedHasAudio",set:function(x){this._hasAudioFlagOverrided=!0,this._hasAudio=x,this._mediaInfo.hasAudio=x}},{key:"overridedHasVideo",set:function(x){this._hasVideoFlagOverrided=!0,this._hasVideo=x,this._mediaInfo.hasVideo=x}}],[{key:"probe",value:function(x){var k=new Uint8Array(x),C={match:!1};if(k[0]!==70||k[1]!==76||k[2]!==86||k[3]!==1)return C;var S=(k[4]&4)>>>2!=0,m=(k[4]&1)!=0,o=c(k,5);return o<9?C:{match:!0,consumed:o,dataOffset:o,hasAudioTrack:S,hasVideoTrack:m}}}]),g}();A.default=l},{"../core/media-info.js":7,"../utils/exception.js":40,"../utils/logger.js":41,"./amf-parser.js":15,"./demux-errors.js":16,"./sps-parser.js":19}],19:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function e(n,u){for(var s=0;s<u.length;s++){var i=u[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}}return function(n,u,s){return u&&e(n.prototype,u),s&&e(n,s),n}}(),F=L("./exp-golomb.js"),T=f(F);function f(e){return e&&e.__esModule?e:{default:e}}function h(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var t=function(){function e(){h(this,e)}return R(e,null,[{key:"_ebsp2rbsp",value:function(u){for(var s=u,i=s.byteLength,E=new Uint8Array(i),_=0,v=0;v<i;v++)v>=2&&s[v]===3&&s[v-1]===0&&s[v-2]===0||(E[_]=s[v],_++);return new Uint8Array(E.buffer,0,_)}},{key:"parseSPS",value:function(u){var s=e._ebsp2rbsp(u),i=new T.default(s);i.readByte();var E=i.readByte();i.readByte();var _=i.readByte();i.readUEG();var v=e.getProfileString(E),d=e.getLevelString(_),a=1,r=420,c=[0,420,422,444],l=8;if((E===100||E===110||E===122||E===244||E===44||E===83||E===86||E===118||E===128||E===138||E===144)&&(a=i.readUEG(),a===3&&i.readBits(1),a<=3&&(r=c[a]),l=i.readUEG()+8,i.readUEG(),i.readBits(1),i.readBool()))for(var g=a!==3?8:12,y=0;y<g;y++)i.readBool()&&(y<6?e._skipScalingList(i,16):e._skipScalingList(i,64));i.readUEG();var x=i.readUEG();if(x===0)i.readUEG();else if(x===1){i.readBits(1),i.readSEG(),i.readSEG();for(var k=i.readUEG(),C=0;C<k;C++)i.readSEG()}var S=i.readUEG();i.readBits(1);var m=i.readUEG(),o=i.readUEG(),p=i.readBits(1);p===0&&i.readBits(1),i.readBits(1);var b=0,O=0,I=0,P=0,G=i.readBool();G&&(b=i.readUEG(),O=i.readUEG(),I=i.readUEG(),P=i.readUEG());var D=1,V=1,U=0,q=!0,N=0,J=0,$=i.readBool();if($){if(i.readBool()){var W=i.readByte(),X=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],K=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];W>0&&W<16?(D=X[W-1],V=K[W-1]):W===255&&(D=i.readByte()<<8|i.readByte(),V=i.readByte()<<8|i.readByte())}if(i.readBool()&&i.readBool(),i.readBool()&&(i.readBits(4),i.readBool()&&i.readBits(24)),i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool()){var Y=i.readBits(32),H=i.readBits(32);q=i.readBool(),N=H,J=Y*2,U=N/J}}var se=1;(D!==1||V!==1)&&(se=D/V);var re=0,ee=0;if(a===0)re=1,ee=2-p;else{var ie=a===3?1:2,he=a===1?2:1;re=ie,ee=he*(2-p)}var ue=(m+1)*16,te=(2-p)*((o+1)*16);ue-=(b+O)*re,te-=(I+P)*ee;var oe=Math.ceil(ue*se);return i.destroy(),i=null,{profile_string:v,level_string:d,bit_depth:l,ref_frames:S,chroma_format:r,chroma_format_string:e.getChromaFormatString(r),frame_rate:{fixed:q,fps:U,fps_den:J,fps_num:N},sar_ratio:{width:D,height:V},codec_size:{width:ue,height:te},present_size:{width:oe,height:te}}}},{key:"_skipScalingList",value:function(u,s){for(var i=8,E=8,_=0,v=0;v<s;v++)E!==0&&(_=u.readSEG(),E=(i+_+256)%256),i=E===0?i:E}},{key:"getProfileString",value:function(u){switch(u){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}}},{key:"getLevelString",value:function(u){return(u/10).toFixed(1)}},{key:"getChromaFormatString",value:function(u){switch(u){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}]),e}();A.default=t},{"./exp-golomb.js":17}],20:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(y){return typeof y}:function(y){return y&&typeof Symbol=="function"&&y.constructor===Symbol&&y!==Symbol.prototype?"symbol":typeof y},F=L("./utils/polyfill.js"),T=a(F),f=L("./core/features.js"),h=a(f),t=L("./player/flv-player.js"),e=a(t),n=L("./player/native-player.js"),u=a(n),s=L("./player/player-events.js"),i=a(s),E=L("./player/player-errors.js"),_=L("./utils/logging-control.js"),v=a(_),d=L("./utils/exception.js");function a(y){return y&&y.__esModule?y:{default:y}}T.default.install();function r(y,x){var k=y;if(k==null||(typeof k=="undefined"?"undefined":R(k))!=="object")throw new d.InvalidArgumentException("MediaDataSource must be an javascript object!");if(!k.hasOwnProperty("type"))throw new d.InvalidArgumentException("MediaDataSource must has type field to indicate video file type!");switch(k.type){case"flv":return new e.default(k,x);default:return new u.default(k,x)}}function c(){return h.default.supportMSEH264Playback()}function l(){return h.default.getFeatureList()}var g={};g.createPlayer=r,g.isSupported=c,g.getFeatureList=l,g.Events=i.default,g.ErrorTypes=E.ErrorTypes,g.ErrorDetails=E.ErrorDetails,g.FlvPlayer=e.default,g.NativePlayer=u.default,g.LoggingControl=v.default,Object.defineProperty(g,"version",{enumerable:!0,get:function(){return"1.4.0"}}),A.default=g},{"./core/features.js":6,"./player/flv-player.js":32,"./player/native-player.js":33,"./player/player-errors.js":34,"./player/player-events.js":35,"./utils/exception.js":40,"./utils/logging-control.js":42,"./utils/polyfill.js":43}],21:[function(L,j,A){"use strict";j.exports=L("./flv.js").default},{"./flv.js":20}],22:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},F=function d(a,r,c){a===null&&(a=Function.prototype);var l=Object.getOwnPropertyDescriptor(a,r);if(l===void 0){var g=Object.getPrototypeOf(a);return g===null?void 0:d(g,r,c)}else{if("value"in l)return l.value;var y=l.get;return y===void 0?void 0:y.call(c)}},T=function(){function d(a,r){for(var c=0;c<r.length;c++){var l=r[c];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(a,l.key,l)}}return function(a,r,c){return r&&d(a.prototype,r),c&&d(a,c),a}}(),f=L("../utils/logger.js"),h=s(f),t=L("../utils/browser.js"),e=s(t),n=L("./loader.js"),u=L("../utils/exception.js");function s(d){return d&&d.__esModule?d:{default:d}}function i(d,a){if(!(d instanceof a))throw new TypeError("Cannot call a class as a function")}function E(d,a){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a&&(typeof a=="object"||typeof a=="function")?a:d}function _(d,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof a);d.prototype=Object.create(a&&a.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),a&&(Object.setPrototypeOf?Object.setPrototypeOf(d,a):d.__proto__=a)}var v=function(d){_(a,d),T(a,null,[{key:"isSupported",value:function(){try{var c=e.default.msedge&&e.default.version.minor>=15048,l=e.default.msedge?c:!0;return self.fetch&&self.ReadableStream&&l}catch(g){return!1}}}]);function a(r,c){i(this,a);var l=E(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,"fetch-stream-loader"));return l.TAG="FetchStreamLoader",l._seekHandler=r,l._config=c,l._needStash=!0,l._requestAbort=!1,l._contentLength=null,l._receivedLength=0,l}return T(a,[{key:"destroy",value:function(){this.isWorking()&&this.abort(),F(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"destroy",this).call(this)}},{key:"open",value:function(c,l){var g=this;this._dataSource=c,this._range=l;var y=c.url;this._config.reuseRedirectedURL&&c.redirectedURL!=null&&(y=c.redirectedURL);var x=this._seekHandler.getConfig(y,l),k=new self.Headers;if(R(x.headers)==="object"){var C=x.headers;for(var S in C)C.hasOwnProperty(S)&&k.append(S,C[S])}var m={method:"GET",headers:k,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};c.cors===!1&&(m.mode="same-origin"),c.withCredentials&&(m.credentials="include"),c.referrerPolicy&&(m.referrerPolicy=c.referrerPolicy),this._status=n.LoaderStatus.kConnecting,self.fetch(x.url,m).then(function(o){if(g._requestAbort){g._requestAbort=!1,g._status=n.LoaderStatus.kIdle;return}if(o.ok&&o.status>=200&&o.status<=299){if(o.url!==x.url&&g._onURLRedirect){var p=g._seekHandler.removeURLParameters(o.url);g._onURLRedirect(p)}var b=o.headers.get("Content-Length");return b!=null&&(g._contentLength=parseInt(b),g._contentLength!==0&&g._onContentLengthKnown&&g._onContentLengthKnown(g._contentLength)),g._pump.call(g,o.body.getReader())}else if(g._status=n.LoaderStatus.kError,g._onError)g._onError(n.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:o.status,msg:o.statusText});else throw new u.RuntimeException("FetchStreamLoader: Http code invalid, "+o.status+" "+o.statusText)}).catch(function(o){if(g._status=n.LoaderStatus.kError,g._onError)g._onError(n.LoaderErrors.EXCEPTION,{code:-1,msg:o.message});else throw o})}},{key:"abort",value:function(){this._requestAbort=!0}},{key:"_pump",value:function(c){var l=this;return c.read().then(function(g){if(g.done)l._status=n.LoaderStatus.kComplete,l._onComplete&&l._onComplete(l._range.from,l._range.from+l._receivedLength-1);else{if(l._requestAbort===!0)return l._requestAbort=!1,l._status=n.LoaderStatus.kComplete,c.cancel();l._status=n.LoaderStatus.kBuffering;var y=g.value.buffer,x=l._range.from+l._receivedLength;l._receivedLength+=y.byteLength,l._onDataArrival&&l._onDataArrival(y,x,l._receivedLength),l._pump(c)}}).catch(function(g){if(!(g.code===11&&e.default.msedge)){l._status=n.LoaderStatus.kError;var y=0,x=null;if((g.code===19||g.message==="network error")&&(l._contentLength===null||l._contentLength!==null&&l._receivedLength<l._contentLength)?(y=n.LoaderErrors.EARLY_EOF,x={code:g.code,msg:"Fetch stream meet Early-EOF"}):(y=n.LoaderErrors.EXCEPTION,x={code:g.code,msg:g.message}),l._onError)l._onError(y,x);else throw new u.RuntimeException(x.msg)}})}}]),a}(n.BaseLoader);A.default=v},{"../utils/browser.js":39,"../utils/exception.js":40,"../utils/logger.js":41,"./loader.js":24}],23:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function S(m,o){for(var p=0;p<o.length;p++){var b=o[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}return function(m,o,p){return o&&S(m.prototype,o),p&&S(m,p),m}}(),F=L("../utils/logger.js"),T=x(F),f=L("./speed-sampler.js"),h=x(f),t=L("./loader.js"),e=L("./fetch-stream-loader.js"),n=x(e),u=L("./xhr-moz-chunked-loader.js"),s=x(u),i=L("./xhr-msstream-loader.js"),E=x(i),_=L("./xhr-range-loader.js"),v=x(_),d=L("./websocket-loader.js"),a=x(d),r=L("./range-seek-handler.js"),c=x(r),l=L("./param-seek-handler.js"),g=x(l),y=L("../utils/exception.js");function x(S){return S&&S.__esModule?S:{default:S}}function k(S,m){if(!(S instanceof m))throw new TypeError("Cannot call a class as a function")}var C=function(){function S(m,o,p){k(this,S),this.TAG="IOController",this._config=o,this._extraData=p,this._stashInitialSize=1024*384,o.stashInitialSize!=null&&o.stashInitialSize>0&&(this._stashInitialSize=o.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=1024*1024*3,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,o.enableStashBuffer===!1&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=m,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(m.url),this._refTotalLength=m.filesize?m.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new h.default,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}return R(S,[{key:"destroy",value:function(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null}},{key:"isWorking",value:function(){return this._loader&&this._loader.isWorking()&&!this._paused}},{key:"isPaused",value:function(){return this._paused}},{key:"_selectSeekHandler",value:function(){var o=this._config;if(o.seekType==="range")this._seekHandler=new c.default(this._config.rangeLoadZeroStart);else if(o.seekType==="param"){var p=o.seekParamStart||"bstart",b=o.seekParamEnd||"bend";this._seekHandler=new g.default(p,b)}else if(o.seekType==="custom"){if(typeof o.customSeekHandler!="function")throw new y.InvalidArgumentException("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new o.customSeekHandler}else throw new y.InvalidArgumentException("Invalid seekType in config: "+o.seekType)}},{key:"_selectLoader",value:function(){if(this._isWebSocketURL)this._loaderClass=a.default;else if(n.default.isSupported())this._loaderClass=n.default;else if(s.default.isSupported())this._loaderClass=s.default;else if(v.default.isSupported())this._loaderClass=v.default;else throw new y.RuntimeException("Your browser doesn't support xhr with arraybuffer responseType!")}},{key:"_createLoader",value:function(){this._loader=new this._loaderClass(this._seekHandler,this._config),this._loader.needStashBuffer===!1&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)}},{key:"open",value:function(o){this._currentRange={from:0,to:-1},o&&(this._currentRange.from=o),this._speedSampler.reset(),o||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))}},{key:"abort",value:function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)}},{key:"pause",value:function(){this.isWorking()&&(this._loader.abort(),this._stashUsed!==0?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)}},{key:"resume",value:function(){if(this._paused){this._paused=!1;var o=this._resumeFrom;this._resumeFrom=0,this._internalSeek(o,!0)}}},{key:"seek",value:function(o){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(o,!0)}},{key:"_internalSeek",value:function(o,p){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(p),this._loader.destroy(),this._loader=null;var b={from:o,to:-1};this._currentRange={from:b.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,b),this._onSeeked&&this._onSeeked()}},{key:"updateUrl",value:function(o){if(!o||typeof o!="string"||o.length===0)throw new y.InvalidArgumentException("Url must be a non-empty string!");this._dataSource.url=o}},{key:"_expandBuffer",value:function(o){for(var p=this._stashSize;p+1024*1024*1<o;)p*=2;if(p+=1024*1024*1,p!==this._bufferSize){var b=new ArrayBuffer(p);if(this._stashUsed>0){var O=new Uint8Array(this._stashBuffer,0,this._stashUsed),I=new Uint8Array(b,0,p);I.set(O,0)}this._stashBuffer=b,this._bufferSize=p}}},{key:"_normalizeSpeed",value:function(o){var p=this._speedNormalizeList,b=p.length-1,O=0,I=0,P=b;if(o<p[0])return p[0];for(;I<=P;){if(O=I+Math.floor((P-I)/2),O===b||o>=p[O]&&o<p[O+1])return p[O];p[O]<o?I=O+1:P=O-1}}},{key:"_adjustStashSize",value:function(o){var p=0;this._config.isLive||o<512?p=o:o>=512&&o<=1024?p=Math.floor(o*1.5):p=o*2,p>8192&&(p=8192);var b=p*1024+1024*1024*1;this._bufferSize<b&&this._expandBuffer(b),this._stashSize=p*1024}},{key:"_dispatchChunks",value:function(o,p){return this._currentRange.to=p+o.byteLength-1,this._onDataArrival(o,p)}},{key:"_onURLRedirect",value:function(o){this._redirectedURL=o,this._onRedirect&&this._onRedirect(o)}},{key:"_onContentLengthKnown",value:function(o){o&&this._fullRequestFlag&&(this._totalLength=o,this._fullRequestFlag=!1)}},{key:"_onLoaderChunkArrival",value:function(o,p,b){if(!this._onDataArrival)throw new y.IllegalStateException("IOController: No existing consumer (onDataArrival) callback!");if(!this._paused){this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(o.byteLength);var O=this._speedSampler.lastSecondKBps;if(O!==0){var I=this._normalizeSpeed(O);this._speedNormalized!==I&&(this._speedNormalized=I,this._adjustStashSize(I))}if(this._enableStash)if(this._stashUsed===0&&this._stashByteStart===0&&(this._stashByteStart=p),this._stashUsed+o.byteLength<=this._stashSize){var N=new Uint8Array(this._stashBuffer,0,this._stashSize);N.set(new Uint8Array(o),this._stashUsed),this._stashUsed+=o.byteLength}else{var J=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(this._stashUsed>0){var $=this._stashBuffer.slice(0,this._stashUsed),W=this._dispatchChunks($,this._stashByteStart);if(W<$.byteLength){if(W>0){var X=new Uint8Array($,W);J.set(X,0),this._stashUsed=X.byteLength,this._stashByteStart+=W}}else this._stashUsed=0,this._stashByteStart+=W;this._stashUsed+o.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+o.byteLength),J=new Uint8Array(this._stashBuffer,0,this._bufferSize)),J.set(new Uint8Array(o),this._stashUsed),this._stashUsed+=o.byteLength}else{var K=this._dispatchChunks(o,p);if(K<o.byteLength){var Y=o.byteLength-K;Y>this._bufferSize&&(this._expandBuffer(Y),J=new Uint8Array(this._stashBuffer,0,this._bufferSize)),J.set(new Uint8Array(o,K),0),this._stashUsed+=Y,this._stashByteStart=p+K}}}else if(this._stashUsed===0){var P=this._dispatchChunks(o,p);if(P<o.byteLength){var G=o.byteLength-P;G>this._bufferSize&&this._expandBuffer(G);var D=new Uint8Array(this._stashBuffer,0,this._bufferSize);D.set(new Uint8Array(o,P),0),this._stashUsed+=G,this._stashByteStart=p+P}}else{this._stashUsed+o.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+o.byteLength);var V=new Uint8Array(this._stashBuffer,0,this._bufferSize);V.set(new Uint8Array(o),this._stashUsed),this._stashUsed+=o.byteLength;var U=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(U<this._stashUsed&&U>0){var q=new Uint8Array(this._stashBuffer,U);V.set(q,0)}this._stashUsed-=U,this._stashByteStart+=U}}}},{key:"_flushStashBuffer",value:function(o){if(this._stashUsed>0){var p=this._stashBuffer.slice(0,this._stashUsed),b=this._dispatchChunks(p,this._stashByteStart),O=p.byteLength-b;if(b<p.byteLength)if(o)T.default.w(this.TAG,O+" bytes unconsumed data remain when flush buffer, dropped");else{if(b>0){var I=new Uint8Array(this._stashBuffer,0,this._bufferSize),P=new Uint8Array(p,b);I.set(P,0),this._stashUsed=P.byteLength,this._stashByteStart+=b}return 0}return this._stashUsed=0,this._stashByteStart=0,O}return 0}},{key:"_onLoaderComplete",value:function(o,p){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}},{key:"_onLoaderError",value:function(o,p){switch(T.default.e(this.TAG,"Loader error, code = "+p.code+", msg = "+p.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,o=t.LoaderErrors.UNRECOVERABLE_EARLY_EOF),o){case t.LoaderErrors.EARLY_EOF:{if(!this._config.isLive&&this._totalLength){var b=this._currentRange.to+1;b<this._totalLength&&(T.default.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(b,!1));return}o=t.LoaderErrors.UNRECOVERABLE_EARLY_EOF;break}case t.LoaderErrors.UNRECOVERABLE_EARLY_EOF:case t.LoaderErrors.CONNECTING_TIMEOUT:case t.LoaderErrors.HTTP_STATUS_CODE_INVALID:case t.LoaderErrors.EXCEPTION:break}if(this._onError)this._onError(o,p);else throw new y.RuntimeException("IOException: "+p.msg)}},{key:"status",get:function(){return this._loader.status}},{key:"extraData",get:function(){return this._extraData},set:function(o){this._extraData=o}},{key:"onDataArrival",get:function(){return this._onDataArrival},set:function(o){this._onDataArrival=o}},{key:"onSeeked",get:function(){return this._onSeeked},set:function(o){this._onSeeked=o}},{key:"onError",get:function(){return this._onError},set:function(o){this._onError=o}},{key:"onComplete",get:function(){return this._onComplete},set:function(o){this._onComplete=o}},{key:"onRedirect",get:function(){return this._onRedirect},set:function(o){this._onRedirect=o}},{key:"onRecoveredEarlyEof",get:function(){return this._onRecoveredEarlyEof},set:function(o){this._onRecoveredEarlyEof=o}},{key:"currentURL",get:function(){return this._dataSource.url}},{key:"hasRedirect",get:function(){return this._redirectedURL!=null||this._dataSource.redirectedURL!=null}},{key:"currentRedirectedURL",get:function(){return this._redirectedURL||this._dataSource.redirectedURL}},{key:"currentSpeed",get:function(){return this._loaderClass===v.default?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}},{key:"loaderType",get:function(){return this._loader.type}}]),S}();A.default=C},{"../utils/exception.js":40,"../utils/logger.js":41,"./fetch-stream-loader.js":22,"./loader.js":24,"./param-seek-handler.js":25,"./range-seek-handler.js":26,"./speed-sampler.js":27,"./websocket-loader.js":28,"./xhr-moz-chunked-loader.js":29,"./xhr-msstream-loader.js":30,"./xhr-range-loader.js":31}],24:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0}),A.BaseLoader=A.LoaderErrors=A.LoaderStatus=void 0;var R=function(){function e(n,u){for(var s=0;s<u.length;s++){var i=u[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}}return function(n,u,s){return u&&e(n.prototype,u),s&&e(n,s),n}}(),F=L("../utils/exception.js");function T(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var f=A.LoaderStatus={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},h=A.LoaderErrors={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"},t=A.BaseLoader=function(){function e(n){T(this,e),this._type=n||"undefined",this._status=f.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}return R(e,[{key:"destroy",value:function(){this._status=f.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}},{key:"isWorking",value:function(){return this._status===f.kConnecting||this._status===f.kBuffering}},{key:"open",value:function(u,s){throw new F.NotImplementedException("Unimplemented abstract function!")}},{key:"abort",value:function(){throw new F.NotImplementedException("Unimplemented abstract function!")}},{key:"type",get:function(){return this._type}},{key:"status",get:function(){return this._status}},{key:"needStashBuffer",get:function(){return this._needStash}},{key:"onContentLengthKnown",get:function(){return this._onContentLengthKnown},set:function(u){this._onContentLengthKnown=u}},{key:"onURLRedirect",get:function(){return this._onURLRedirect},set:function(u){this._onURLRedirect=u}},{key:"onDataArrival",get:function(){return this._onDataArrival},set:function(u){this._onDataArrival=u}},{key:"onError",get:function(){return this._onError},set:function(u){this._onError=u}},{key:"onComplete",get:function(){return this._onComplete},set:function(u){this._onComplete=u}}]),e}()},{"../utils/exception.js":40}],25:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function f(h,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,n.key,n)}}return function(h,t,e){return t&&f(h.prototype,t),e&&f(h,e),h}}();function F(f,h){if(!(f instanceof h))throw new TypeError("Cannot call a class as a function")}var T=function(){function f(h,t){F(this,f),this._startName=h,this._endName=t}return R(f,[{key:"getConfig",value:function(t,e){var n=t;if(e.from!==0||e.to!==-1){var u=!0;n.indexOf("?")===-1&&(n+="?",u=!1),u&&(n+="&"),n+=this._startName+"="+e.from.toString(),e.to!==-1&&(n+="&"+this._endName+"="+e.to.toString())}return{url:n,headers:{}}}},{key:"removeURLParameters",value:function(t){var e=t.split("?")[0],n=void 0,u=t.indexOf("?");u!==-1&&(n=t.substring(u+1));var s="";if(n!=null&&n.length>0)for(var i=n.split("&"),E=0;E<i.length;E++){var _=i[E].split("="),v=E>0;_[0]!==this._startName&&_[0]!==this._endName&&(v&&(s+="&"),s+=i[E])}return s.length===0?e:e+"?"+s}}]),f}();A.default=T},{}],26:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function f(h,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,n.key,n)}}return function(h,t,e){return t&&f(h.prototype,t),e&&f(h,e),h}}();function F(f,h){if(!(f instanceof h))throw new TypeError("Cannot call a class as a function")}var T=function(){function f(h){F(this,f),this._zeroStart=h||!1}return R(f,[{key:"getConfig",value:function(t,e){var n={};if(e.from!==0||e.to!==-1){var u=void 0;e.to!==-1?u="bytes="+e.from.toString()+"-"+e.to.toString():u="bytes="+e.from.toString()+"-",n.Range=u}else this._zeroStart&&(n.Range="bytes=0-");return{url:t,headers:n}}},{key:"removeURLParameters",value:function(t){return t}}]),f}();A.default=T},{}],27:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function f(h,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,n.key,n)}}return function(h,t,e){return t&&f(h.prototype,t),e&&f(h,e),h}}();function F(f,h){if(!(f instanceof h))throw new TypeError("Cannot call a class as a function")}var T=function(){function f(){F(this,f),this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}return R(f,[{key:"reset",value:function(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0}},{key:"addBytes",value:function(t){this._firstCheckpoint===0?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=t,this._totalBytes+=t):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=t,this._totalBytes+=t):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=t,this._totalBytes+=t,this._lastCheckpoint=this._now())}},{key:"currentKBps",get:function(){this.addBytes(0);var t=(this._now()-this._lastCheckpoint)/1e3;return t==0&&(t=1),this._intervalBytes/t/1024}},{key:"lastSecondKBps",get:function(){return this.addBytes(0),this._lastSecondBytes!==0?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0}},{key:"averageKBps",get:function(){var t=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/t/1024}}]),f}();A.default=T},{}],28:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function E(_,v,d){_===null&&(_=Function.prototype);var a=Object.getOwnPropertyDescriptor(_,v);if(a===void 0){var r=Object.getPrototypeOf(_);return r===null?void 0:E(r,v,d)}else{if("value"in a)return a.value;var c=a.get;return c===void 0?void 0:c.call(d)}},F=function(){function E(_,v){for(var d=0;d<v.length;d++){var a=v[d];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(_,a.key,a)}}return function(_,v,d){return v&&E(_.prototype,v),d&&E(_,d),_}}(),T=L("../utils/logger.js"),f=e(T),h=L("./loader.js"),t=L("../utils/exception.js");function e(E){return E&&E.__esModule?E:{default:E}}function n(E,_){if(!(E instanceof _))throw new TypeError("Cannot call a class as a function")}function u(E,_){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return _&&(typeof _=="object"||typeof _=="function")?_:E}function s(E,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof _);E.prototype=Object.create(_&&_.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),_&&(Object.setPrototypeOf?Object.setPrototypeOf(E,_):E.__proto__=_)}var i=function(E){s(_,E),F(_,null,[{key:"isSupported",value:function(){try{return typeof self.WebSocket!="undefined"}catch(d){return!1}}}]);function _(){n(this,_);var v=u(this,(_.__proto__||Object.getPrototypeOf(_)).call(this,"websocket-loader"));return v.TAG="WebSocketLoader",v._needStash=!0,v._ws=null,v._requestAbort=!1,v._receivedLength=0,v}return F(_,[{key:"destroy",value:function(){this._ws&&this.abort(),R(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"destroy",this).call(this)}},{key:"open",value:function(d){try{var a=this._ws=new self.WebSocket(d.url);a.binaryType="arraybuffer",a.onopen=this._onWebSocketOpen.bind(this),a.onclose=this._onWebSocketClose.bind(this),a.onmessage=this._onWebSocketMessage.bind(this),a.onerror=this._onWebSocketError.bind(this),this._status=h.LoaderStatus.kConnecting}catch(c){this._status=h.LoaderStatus.kError;var r={code:c.code,msg:c.message};if(this._onError)this._onError(h.LoaderErrors.EXCEPTION,r);else throw new t.RuntimeException(r.msg)}}},{key:"abort",value:function(){var d=this._ws;d&&(d.readyState===0||d.readyState===1)&&(this._requestAbort=!0,d.close()),this._ws=null,this._status=h.LoaderStatus.kComplete}},{key:"_onWebSocketOpen",value:function(d){this._status=h.LoaderStatus.kBuffering}},{key:"_onWebSocketClose",value:function(d){if(this._requestAbort===!0){this._requestAbort=!1;return}this._status=h.LoaderStatus.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)}},{key:"_onWebSocketMessage",value:function(d){var a=this;if(d.data instanceof ArrayBuffer)this._dispatchArrayBuffer(d.data);else if(d.data instanceof Blob){var r=new FileReader;r.onload=function(){a._dispatchArrayBuffer(r.result)},r.readAsArrayBuffer(d.data)}else{this._status=h.LoaderStatus.kError;var c={code:-1,msg:"Unsupported WebSocket message type: "+d.data.constructor.name};if(this._onError)this._onError(h.LoaderErrors.EXCEPTION,c);else throw new t.RuntimeException(c.msg)}}},{key:"_dispatchArrayBuffer",value:function(d){var a=d,r=this._receivedLength;this._receivedLength+=a.byteLength,this._onDataArrival&&this._onDataArrival(a,r,this._receivedLength)}},{key:"_onWebSocketError",value:function(d){this._status=h.LoaderStatus.kError;var a={code:d.code,msg:d.message};if(this._onError)this._onError(h.LoaderErrors.EXCEPTION,a);else throw new t.RuntimeException(a.msg)}}]),_}(h.BaseLoader);A.default=i},{"../utils/exception.js":40,"../utils/logger.js":41,"./loader.js":24}],29:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},F=function _(v,d,a){v===null&&(v=Function.prototype);var r=Object.getOwnPropertyDescriptor(v,d);if(r===void 0){var c=Object.getPrototypeOf(v);return c===null?void 0:_(c,d,a)}else{if("value"in r)return r.value;var l=r.get;return l===void 0?void 0:l.call(a)}},T=function(){function _(v,d){for(var a=0;a<d.length;a++){var r=d[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(v,r.key,r)}}return function(v,d,a){return d&&_(v.prototype,d),a&&_(v,a),v}}(),f=L("../utils/logger.js"),h=n(f),t=L("./loader.js"),e=L("../utils/exception.js");function n(_){return _&&_.__esModule?_:{default:_}}function u(_,v){if(!(_ instanceof v))throw new TypeError("Cannot call a class as a function")}function s(_,v){if(!_)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:_}function i(_,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);_.prototype=Object.create(v&&v.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(_,v):_.__proto__=v)}var E=function(_){i(v,_),T(v,null,[{key:"isSupported",value:function(){try{var a=new XMLHttpRequest;return a.open("GET","https://example.com",!0),a.responseType="moz-chunked-arraybuffer",a.responseType==="moz-chunked-arraybuffer"}catch(r){return h.default.w("MozChunkedLoader",r.message),!1}}}]);function v(d,a){u(this,v);var r=s(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,"xhr-moz-chunked-loader"));return r.TAG="MozChunkedLoader",r._seekHandler=d,r._config=a,r._needStash=!0,r._xhr=null,r._requestAbort=!1,r._contentLength=null,r._receivedLength=0,r}return T(v,[{key:"destroy",value:function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),F(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"destroy",this).call(this)}},{key:"open",value:function(a,r){this._dataSource=a,this._range=r;var c=a.url;this._config.reuseRedirectedURL&&a.redirectedURL!=null&&(c=a.redirectedURL);var l=this._seekHandler.getConfig(c,r);this._requestURL=l.url;var g=this._xhr=new XMLHttpRequest;if(g.open("GET",l.url,!0),g.responseType="moz-chunked-arraybuffer",g.onreadystatechange=this._onReadyStateChange.bind(this),g.onprogress=this._onProgress.bind(this),g.onloadend=this._onLoadEnd.bind(this),g.onerror=this._onXhrError.bind(this),a.withCredentials&&(g.withCredentials=!0),R(l.headers)==="object"){var y=l.headers;for(var x in y)y.hasOwnProperty(x)&&g.setRequestHeader(x,y[x])}this._status=t.LoaderStatus.kConnecting,g.send()}},{key:"abort",value:function(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=t.LoaderStatus.kComplete}},{key:"_onReadyStateChange",value:function(a){var r=a.target;if(r.readyState===2){if(r.responseURL!=null&&r.responseURL!==this._requestURL&&this._onURLRedirect){var c=this._seekHandler.removeURLParameters(r.responseURL);this._onURLRedirect(c)}if(r.status!==0&&(r.status<200||r.status>299))if(this._status=t.LoaderStatus.kError,this._onError)this._onError(t.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:r.status,msg:r.statusText});else throw new e.RuntimeException("MozChunkedLoader: Http code invalid, "+r.status+" "+r.statusText);else this._status=t.LoaderStatus.kBuffering}}},{key:"_onProgress",value:function(a){if(this._status!==t.LoaderStatus.kError){this._contentLength===null&&a.total!==null&&a.total!==0&&(this._contentLength=a.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var r=a.target.response,c=this._range.from+this._receivedLength;this._receivedLength+=r.byteLength,this._onDataArrival&&this._onDataArrival(r,c,this._receivedLength)}}},{key:"_onLoadEnd",value:function(a){if(this._requestAbort===!0){this._requestAbort=!1;return}else if(this._status===t.LoaderStatus.kError)return;this._status=t.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)}},{key:"_onXhrError",value:function(a){this._status=t.LoaderStatus.kError;var r=0,c=null;if(this._contentLength&&a.loaded<this._contentLength?(r=t.LoaderErrors.EARLY_EOF,c={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(r=t.LoaderErrors.EXCEPTION,c={code:-1,msg:a.constructor.name+" "+a.type}),this._onError)this._onError(r,c);else throw new e.RuntimeException(c.msg)}}]),v}(t.BaseLoader);A.default=E},{"../utils/exception.js":40,"../utils/logger.js":41,"./loader.js":24}],30:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},F=function _(v,d,a){v===null&&(v=Function.prototype);var r=Object.getOwnPropertyDescriptor(v,d);if(r===void 0){var c=Object.getPrototypeOf(v);return c===null?void 0:_(c,d,a)}else{if("value"in r)return r.value;var l=r.get;return l===void 0?void 0:l.call(a)}},T=function(){function _(v,d){for(var a=0;a<d.length;a++){var r=d[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(v,r.key,r)}}return function(v,d,a){return d&&_(v.prototype,d),a&&_(v,a),v}}(),f=L("../utils/logger.js"),h=n(f),t=L("./loader.js"),e=L("../utils/exception.js");function n(_){return _&&_.__esModule?_:{default:_}}function u(_,v){if(!(_ instanceof v))throw new TypeError("Cannot call a class as a function")}function s(_,v){if(!_)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:_}function i(_,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);_.prototype=Object.create(v&&v.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(_,v):_.__proto__=v)}var E=function(_){i(v,_),T(v,null,[{key:"isSupported",value:function(){try{if(typeof self.MSStream=="undefined"||typeof self.MSStreamReader=="undefined")return!1;var a=new XMLHttpRequest;return a.open("GET","https://example.com",!0),a.responseType="ms-stream",a.responseType==="ms-stream"}catch(r){return h.default.w("MSStreamLoader",r.message),!1}}}]);function v(d,a){u(this,v);var r=s(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,"xhr-msstream-loader"));return r.TAG="MSStreamLoader",r._seekHandler=d,r._config=a,r._needStash=!0,r._xhr=null,r._reader=null,r._totalRange=null,r._currentRange=null,r._currentRequestURL=null,r._currentRedirectedURL=null,r._contentLength=null,r._receivedLength=0,r._bufferLimit=16*1024*1024,r._lastTimeBufferSize=0,r._isReconnecting=!1,r}return T(v,[{key:"destroy",value:function(){this.isWorking()&&this.abort(),this._reader&&(this._reader.onprogress=null,this._reader.onload=null,this._reader.onerror=null,this._reader=null),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr=null),F(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"destroy",this).call(this)}},{key:"open",value:function(a,r){this._internalOpen(a,r,!1)}},{key:"_internalOpen",value:function(a,r,c){this._dataSource=a,c?this._currentRange=r:this._totalRange=r;var l=a.url;this._config.reuseRedirectedURL&&(this._currentRedirectedURL!=null?l=this._currentRedirectedURL:a.redirectedURL!=null&&(l=a.redirectedURL));var g=this._seekHandler.getConfig(l,r);this._currentRequestURL=g.url;var y=this._reader=new self.MSStreamReader;y.onprogress=this._msrOnProgress.bind(this),y.onload=this._msrOnLoad.bind(this),y.onerror=this._msrOnError.bind(this);var x=this._xhr=new XMLHttpRequest;if(x.open("GET",g.url,!0),x.responseType="ms-stream",x.onreadystatechange=this._xhrOnReadyStateChange.bind(this),x.onerror=this._xhrOnError.bind(this),a.withCredentials&&(x.withCredentials=!0),R(g.headers)==="object"){var k=g.headers;for(var C in k)k.hasOwnProperty(C)&&x.setRequestHeader(C,k[C])}this._isReconnecting?this._isReconnecting=!1:this._status=t.LoaderStatus.kConnecting,x.send()}},{key:"abort",value:function(){this._internalAbort(),this._status=t.LoaderStatus.kComplete}},{key:"_internalAbort",value:function(){this._reader&&(this._reader.readyState===1&&this._reader.abort(),this._reader.onprogress=null,this._reader.onload=null,this._reader.onerror=null,this._reader=null),this._xhr&&(this._xhr.abort(),this._xhr.onreadystatechange=null,this._xhr=null)}},{key:"_xhrOnReadyStateChange",value:function(a){var r=a.target;if(r.readyState===2)if(r.status>=200&&r.status<=299){if(this._status=t.LoaderStatus.kBuffering,r.responseURL!=null){var c=this._seekHandler.removeURLParameters(r.responseURL);r.responseURL!==this._currentRequestURL&&c!==this._currentRedirectedURL&&(this._currentRedirectedURL=c,this._onURLRedirect&&this._onURLRedirect(c))}var l=r.getResponseHeader("Content-Length");if(l!=null&&this._contentLength==null){var g=parseInt(l);g>0&&(this._contentLength=g,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength))}}else if(this._status=t.LoaderStatus.kError,this._onError)this._onError(t.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:r.status,msg:r.statusText});else throw new e.RuntimeException("MSStreamLoader: Http code invalid, "+r.status+" "+r.statusText);else if(r.readyState===3&&r.status>=200&&r.status<=299){this._status=t.LoaderStatus.kBuffering;var y=r.response;this._reader.readAsArrayBuffer(y)}}},{key:"_xhrOnError",value:function(a){this._status=t.LoaderStatus.kError;var r=t.LoaderErrors.EXCEPTION,c={code:-1,msg:a.constructor.name+" "+a.type};if(this._onError)this._onError(r,c);else throw new e.RuntimeException(c.msg)}},{key:"_msrOnProgress",value:function(a){var r=a.target,c=r.result;if(c==null){this._doReconnectIfNeeded();return}var l=c.slice(this._lastTimeBufferSize);this._lastTimeBufferSize=c.byteLength;var g=this._totalRange.from+this._receivedLength;this._receivedLength+=l.byteLength,this._onDataArrival&&this._onDataArrival(l,g,this._receivedLength),c.byteLength>=this._bufferLimit&&(h.default.v(this.TAG,"MSStream buffer exceeded max size near "+(g+l.byteLength)+", reconnecting..."),this._doReconnectIfNeeded())}},{key:"_doReconnectIfNeeded",value:function(){if(this._contentLength==null||this._receivedLength<this._contentLength){this._isReconnecting=!0,this._lastTimeBufferSize=0,this._internalAbort();var a={from:this._totalRange.from+this._receivedLength,to:-1};this._internalOpen(this._dataSource,a,!0)}}},{key:"_msrOnLoad",value:function(a){this._status=t.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._totalRange.from,this._totalRange.from+this._receivedLength-1)}},{key:"_msrOnError",value:function(a){this._status=t.LoaderStatus.kError;var r=0,c=null;if(this._contentLength&&this._receivedLength<this._contentLength?(r=t.LoaderErrors.EARLY_EOF,c={code:-1,msg:"MSStream meet Early-Eof"}):(r=t.LoaderErrors.EARLY_EOF,c={code:-1,msg:a.constructor.name+" "+a.type}),this._onError)this._onError(r,c);else throw new e.RuntimeException(c.msg)}}]),v}(t.BaseLoader);A.default=E},{"../utils/exception.js":40,"../utils/logger.js":41,"./loader.js":24}],31:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},F=function d(a,r,c){a===null&&(a=Function.prototype);var l=Object.getOwnPropertyDescriptor(a,r);if(l===void 0){var g=Object.getPrototypeOf(a);return g===null?void 0:d(g,r,c)}else{if("value"in l)return l.value;var y=l.get;return y===void 0?void 0:y.call(c)}},T=function(){function d(a,r){for(var c=0;c<r.length;c++){var l=r[c];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(a,l.key,l)}}return function(a,r,c){return r&&d(a.prototype,r),c&&d(a,c),a}}(),f=L("../utils/logger.js"),h=s(f),t=L("./speed-sampler.js"),e=s(t),n=L("./loader.js"),u=L("../utils/exception.js");function s(d){return d&&d.__esModule?d:{default:d}}function i(d,a){if(!(d instanceof a))throw new TypeError("Cannot call a class as a function")}function E(d,a){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a&&(typeof a=="object"||typeof a=="function")?a:d}function _(d,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof a);d.prototype=Object.create(a&&a.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),a&&(Object.setPrototypeOf?Object.setPrototypeOf(d,a):d.__proto__=a)}var v=function(d){_(a,d),T(a,null,[{key:"isSupported",value:function(){try{var c=new XMLHttpRequest;return c.open("GET","https://example.com",!0),c.responseType="arraybuffer",c.responseType==="arraybuffer"}catch(l){return h.default.w("RangeLoader",l.message),!1}}}]);function a(r,c){i(this,a);var l=E(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,"xhr-range-loader"));return l.TAG="RangeLoader",l._seekHandler=r,l._config=c,l._needStash=!1,l._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],l._currentChunkSizeKB=384,l._currentSpeedNormalized=0,l._zeroSpeedChunkCount=0,l._xhr=null,l._speedSampler=new e.default,l._requestAbort=!1,l._waitForTotalLength=!1,l._totalLengthReceived=!1,l._currentRequestURL=null,l._currentRedirectedURL=null,l._currentRequestRange=null,l._totalLength=null,l._contentLength=null,l._receivedLength=0,l._lastTimeLoaded=0,l}return T(a,[{key:"destroy",value:function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),F(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"destroy",this).call(this)}},{key:"open",value:function(c,l){this._dataSource=c,this._range=l,this._status=n.LoaderStatus.kConnecting;var g=!1;this._dataSource.filesize!=null&&this._dataSource.filesize!==0&&(g=!0,this._totalLength=this._dataSource.filesize),!this._totalLengthReceived&&!g?(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1})):this._openSubRange()}},{key:"_openSubRange",value:function(){var c=this._currentChunkSizeKB*1024,l=this._range.from+this._receivedLength,g=l+c;this._contentLength!=null&&g-this._range.from>=this._contentLength&&(g=this._range.from+this._contentLength-1),this._currentRequestRange={from:l,to:g},this._internalOpen(this._dataSource,this._currentRequestRange)}},{key:"_internalOpen",value:function(c,l){this._lastTimeLoaded=0;var g=c.url;this._config.reuseRedirectedURL&&(this._currentRedirectedURL!=null?g=this._currentRedirectedURL:c.redirectedURL!=null&&(g=c.redirectedURL));var y=this._seekHandler.getConfig(g,l);this._currentRequestURL=y.url;var x=this._xhr=new XMLHttpRequest;if(x.open("GET",y.url,!0),x.responseType="arraybuffer",x.onreadystatechange=this._onReadyStateChange.bind(this),x.onprogress=this._onProgress.bind(this),x.onload=this._onLoad.bind(this),x.onerror=this._onXhrError.bind(this),c.withCredentials&&(x.withCredentials=!0),R(y.headers)==="object"){var k=y.headers;for(var C in k)k.hasOwnProperty(C)&&x.setRequestHeader(C,k[C])}x.send()}},{key:"abort",value:function(){this._requestAbort=!0,this._internalAbort(),this._status=n.LoaderStatus.kComplete}},{key:"_internalAbort",value:function(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)}},{key:"_onReadyStateChange",value:function(c){var l=c.target;if(l.readyState===2){if(l.responseURL!=null){var g=this._seekHandler.removeURLParameters(l.responseURL);l.responseURL!==this._currentRequestURL&&g!==this._currentRedirectedURL&&(this._currentRedirectedURL=g,this._onURLRedirect&&this._onURLRedirect(g))}if(l.status>=200&&l.status<=299){if(this._waitForTotalLength)return;this._status=n.LoaderStatus.kBuffering}else if(this._status=n.LoaderStatus.kError,this._onError)this._onError(n.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:l.status,msg:l.statusText});else throw new u.RuntimeException("RangeLoader: Http code invalid, "+l.status+" "+l.statusText)}}},{key:"_onProgress",value:function(c){if(this._status!==n.LoaderStatus.kError){if(this._contentLength===null){var l=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,l=!0;var g=c.total;this._internalAbort(),g!=null&g!==0&&(this._totalLength=g)}if(this._range.to===-1?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,l){this._openSubRange();return}this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var y=c.loaded-this._lastTimeLoaded;this._lastTimeLoaded=c.loaded,this._speedSampler.addBytes(y)}}},{key:"_normalizeSpeed",value:function(c){var l=this._chunkSizeKBList,g=l.length-1,y=0,x=0,k=g;if(c<l[0])return l[0];for(;x<=k;){if(y=x+Math.floor((k-x)/2),y===g||c>=l[y]&&c<l[y+1])return l[y];l[y]<c?x=y+1:k=y-1}}},{key:"_onLoad",value:function(c){if(this._status!==n.LoaderStatus.kError){if(this._waitForTotalLength){this._waitForTotalLength=!1;return}this._lastTimeLoaded=0;var l=this._speedSampler.lastSecondKBps;if(l===0&&(this._zeroSpeedChunkCount++,this._zeroSpeedChunkCount>=3&&(l=this._speedSampler.currentKBps)),l!==0){var g=this._normalizeSpeed(l);this._currentSpeedNormalized!==g&&(this._currentSpeedNormalized=g,this._currentChunkSizeKB=g)}var y=c.target.response,x=this._range.from+this._receivedLength;this._receivedLength+=y.byteLength;var k=!1;this._contentLength!=null&&this._receivedLength<this._contentLength?this._openSubRange():k=!0,this._onDataArrival&&this._onDataArrival(y,x,this._receivedLength),k&&(this._status=n.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}}},{key:"_onXhrError",value:function(c){this._status=n.LoaderStatus.kError;var l=0,g=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(l=n.LoaderErrors.EARLY_EOF,g={code:-1,msg:"RangeLoader meet Early-Eof"}):(l=n.LoaderErrors.EXCEPTION,g={code:-1,msg:c.constructor.name+" "+c.type}),this._onError)this._onError(l,g);else throw new u.RuntimeException(g.msg)}},{key:"currentSpeed",get:function(){return this._speedSampler.lastSecondKBps}}]),a}(n.BaseLoader);A.default=v},{"../utils/exception.js":40,"../utils/logger.js":41,"./loader.js":24,"./speed-sampler.js":27}],32:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(S){return typeof S}:function(S){return S&&typeof Symbol=="function"&&S.constructor===Symbol&&S!==Symbol.prototype?"symbol":typeof S},F=function(){function S(m,o){for(var p=0;p<o.length;p++){var b=o[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}return function(m,o,p){return o&&S(m.prototype,o),p&&S(m,p),m}}(),T=L("events"),f=x(T),h=L("../utils/logger.js"),t=x(h),e=L("../utils/browser.js"),n=x(e),u=L("./player-events.js"),s=x(u),i=L("../core/transmuxer.js"),E=x(i),_=L("../core/transmuxing-events.js"),v=x(_),d=L("../core/mse-controller.js"),a=x(d),r=L("../core/mse-events.js"),c=x(r),l=L("./player-errors.js"),g=L("../config.js"),y=L("../utils/exception.js");function x(S){return S&&S.__esModule?S:{default:S}}function k(S,m){if(!(S instanceof m))throw new TypeError("Cannot call a class as a function")}var C=function(){function S(m,o){if(k(this,S),this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new f.default,this._config=(0,g.createDefaultConfig)(),(typeof o=="undefined"?"undefined":R(o))==="object"&&Object.assign(this._config,o),m.type.toLowerCase()!=="flv")throw new y.InvalidArgumentException("FlvPlayer requires an flv MediaDataSource input!");m.isLive===!0&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=m,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;var p=n.default.chrome&&(n.default.version.major<50||n.default.version.major===50&&n.default.version.build<2661);this._alwaysSeekKeyframe=!!(p||n.default.msedge||n.default.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}return F(S,[{key:"destroy",value:function(){this._progressChecker!=null&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}},{key:"on",value:function(o,p){var b=this;o===s.default.MEDIA_INFO?this._mediaInfo!=null&&Promise.resolve().then(function(){b._emitter.emit(s.default.MEDIA_INFO,b.mediaInfo)}):o===s.default.STATISTICS_INFO&&this._statisticsInfo!=null&&Promise.resolve().then(function(){b._emitter.emit(s.default.STATISTICS_INFO,b.statisticsInfo)}),this._emitter.addListener(o,p)}},{key:"off",value:function(o,p){this._emitter.removeListener(o,p)}},{key:"attachMediaElement",value:function(o){var p=this;if(this._mediaElement=o,o.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),o.addEventListener("seeking",this.e.onvSeeking),o.addEventListener("canplay",this.e.onvCanPlay),o.addEventListener("stalled",this.e.onvStalled),o.addEventListener("progress",this.e.onvProgress),this._msectl=new a.default(this._config),this._msectl.on(c.default.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(c.default.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(c.default.SOURCE_OPEN,function(){p._mseSourceOpened=!0,p._hasPendingLoad&&(p._hasPendingLoad=!1,p.load())}),this._msectl.on(c.default.ERROR,function(b){p._emitter.emit(s.default.ERROR,l.ErrorTypes.MEDIA_ERROR,l.ErrorDetails.MEDIA_MSE_ERROR,b)}),this._msectl.attachMediaElement(o),this._pendingSeekTime!=null)try{o.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(b){}}},{key:"detachMediaElement",value:function(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)}},{key:"load",value:function(){var o=this;if(!this._mediaElement)throw new y.IllegalStateException("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new y.IllegalStateException("FlvPlayer.load() has been called, please call unload() first!");if(!this._hasPendingLoad){if(this._config.deferLoadAfterSourceOpen&&this._mseSourceOpened===!1){this._hasPendingLoad=!0;return}this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new E.default(this._mediaDataSource,this._config),this._transmuxer.on(v.default.INIT_SEGMENT,function(p,b){o._msectl.appendInitSegment(b)}),this._transmuxer.on(v.default.MEDIA_SEGMENT,function(p,b){if(o._msectl.appendMediaSegment(b),o._config.lazyLoad&&!o._config.isLive){var O=o._mediaElement.currentTime;b.info.endDts>=(O+o._config.lazyLoadMaxDuration)*1e3&&o._progressChecker==null&&(t.default.v(o.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),o._suspendTransmuxer())}}),this._transmuxer.on(v.default.LOADING_COMPLETE,function(){o._msectl.endOfStream(),o._emitter.emit(s.default.LOADING_COMPLETE)}),this._transmuxer.on(v.default.RECOVERED_EARLY_EOF,function(){o._emitter.emit(s.default.RECOVERED_EARLY_EOF)}),this._transmuxer.on(v.default.IO_ERROR,function(p,b){o._emitter.emit(s.default.ERROR,l.ErrorTypes.NETWORK_ERROR,p,b)}),this._transmuxer.on(v.default.DEMUX_ERROR,function(p,b){o._emitter.emit(s.default.ERROR,l.ErrorTypes.MEDIA_ERROR,p,{code:-1,msg:b})}),this._transmuxer.on(v.default.MEDIA_INFO,function(p){o._mediaInfo=p,o._emitter.emit(s.default.MEDIA_INFO,Object.assign({},p))}),this._transmuxer.on(v.default.STATISTICS_INFO,function(p){o._statisticsInfo=o._fillStatisticsInfo(p),o._emitter.emit(s.default.STATISTICS_INFO,Object.assign({},o._statisticsInfo))}),this._transmuxer.on(v.default.RECOMMEND_SEEKPOINT,function(p){o._mediaElement&&!o._config.accurateSeek&&(o._requestSetTime=!0,o._mediaElement.currentTime=p/1e3)}),this._transmuxer.open()}}},{key:"unload",value:function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)}},{key:"play",value:function(){return this._mediaElement.play()}},{key:"pause",value:function(){this._mediaElement.pause()}},{key:"_fillStatisticsInfo",value:function(o){if(o.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return o;var p=!0,b=0,O=0;if(this._mediaElement.getVideoPlaybackQuality){var I=this._mediaElement.getVideoPlaybackQuality();b=I.totalVideoFrames,O=I.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(b=this._mediaElement.webkitDecodedFrameCount,O=this._mediaElement.webkitDroppedFrameCount):p=!1;return p&&(o.decodedFrames=b,o.droppedFrames=O),o}},{key:"_onmseUpdateEnd",value:function(){if(!(!this._config.lazyLoad||this._config.isLive)){for(var o=this._mediaElement.buffered,p=this._mediaElement.currentTime,b=0,O=0,I=0;I<o.length;I++){var P=o.start(I),G=o.end(I);if(P<=p&&p<G){b=P,O=G;break}}O>=p+this._config.lazyLoadMaxDuration&&this._progressChecker==null&&(t.default.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}},{key:"_onmseBufferFull",value:function(){t.default.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),this._progressChecker==null&&this._suspendTransmuxer()}},{key:"_suspendTransmuxer",value:function(){this._transmuxer&&(this._transmuxer.pause(),this._progressChecker==null&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))}},{key:"_checkProgressAndResume",value:function(){for(var o=this._mediaElement.currentTime,p=this._mediaElement.buffered,b=!1,O=0;O<p.length;O++){var I=p.start(O),P=p.end(O);if(o>=I&&o<P){o>=P-this._config.lazyLoadRecoverDuration&&(b=!0);break}}b&&(window.clearInterval(this._progressChecker),this._progressChecker=null,b&&(t.default.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}},{key:"_isTimepointBuffered",value:function(o){for(var p=this._mediaElement.buffered,b=0;b<p.length;b++){var O=p.start(b),I=p.end(b);if(o>=O&&o<I)return!0}return!1}},{key:"_internalSeek",value:function(o){var p=this._isTimepointBuffered(o),b=!1,O=0;if(o<1&&this._mediaElement.buffered.length>0){var I=this._mediaElement.buffered.start(0);(I<1&&o<I||n.default.safari)&&(b=!0,O=n.default.safari?.1:I)}if(b)this._requestSetTime=!0,this._mediaElement.currentTime=O;else if(p){if(!this._alwaysSeekKeyframe)this._requestSetTime=!0,this._mediaElement.currentTime=o;else{var P=this._msectl.getNearestKeyframe(Math.floor(o*1e3));this._requestSetTime=!0,P!=null?this._mediaElement.currentTime=P.dts/1e3:this._mediaElement.currentTime=o}this._progressChecker!=null&&this._checkProgressAndResume()}else this._progressChecker!=null&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(o),this._transmuxer.seek(Math.floor(o*1e3)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=o)}},{key:"_checkAndApplyUnbufferedSeekpoint",value:function(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){var o=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(o)||(this._progressChecker!=null&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(o),this._transmuxer.seek(Math.floor(o*1e3)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=o))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}},{key:"_checkAndResumeStuckPlayback",value:function(o){var p=this._mediaElement;if(o||!this._receivedCanPlay||p.readyState<2){var b=p.buffered;b.length>0&&p.currentTime<b.start(0)&&(t.default.w(this.TAG,"Playback seems stuck at "+p.currentTime+", seek to "+b.start(0)),this._requestSetTime=!0,this._mediaElement.currentTime=b.start(0),this._mediaElement.removeEventListener("progress",this.e.onvProgress))}else this._mediaElement.removeEventListener("progress",this.e.onvProgress)}},{key:"_onvLoadedMetadata",value:function(o){this._pendingSeekTime!=null&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)}},{key:"_onvSeeking",value:function(o){var p=this._mediaElement.currentTime,b=this._mediaElement.buffered;if(this._requestSetTime){this._requestSetTime=!1;return}if(p<1&&b.length>0){var O=b.start(0);if(O<1&&p<O||n.default.safari){this._requestSetTime=!0,this._mediaElement.currentTime=n.default.safari?.1:O;return}}if(this._isTimepointBuffered(p)){if(this._alwaysSeekKeyframe){var I=this._msectl.getNearestKeyframe(Math.floor(p*1e3));I!=null&&(this._requestSetTime=!0,this._mediaElement.currentTime=I.dts/1e3)}this._progressChecker!=null&&this._checkProgressAndResume();return}this._seekpointRecord={seekPoint:p,recordTime:this._now()},window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}},{key:"_onvCanPlay",value:function(o){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)}},{key:"_onvStalled",value:function(o){this._checkAndResumeStuckPlayback(!0)}},{key:"_onvProgress",value:function(o){this._checkAndResumeStuckPlayback()}},{key:"type",get:function(){return this._type}},{key:"buffered",get:function(){return this._mediaElement.buffered}},{key:"duration",get:function(){return this._mediaElement.duration}},{key:"volume",get:function(){return this._mediaElement.volume},set:function(o){this._mediaElement.volume=o}},{key:"muted",get:function(){return this._mediaElement.muted},set:function(o){this._mediaElement.muted=o}},{key:"currentTime",get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(o){this._mediaElement?this._internalSeek(o):this._pendingSeekTime=o}},{key:"mediaInfo",get:function(){return Object.assign({},this._mediaInfo)}},{key:"statisticsInfo",get:function(){return this._statisticsInfo==null&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)}}]),S}();A.default=C},{"../config.js":5,"../core/mse-controller.js":9,"../core/mse-events.js":10,"../core/transmuxer.js":11,"../core/transmuxing-events.js":13,"../utils/browser.js":39,"../utils/exception.js":40,"../utils/logger.js":41,"./player-errors.js":34,"./player-events.js":35,events:2}],33:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(E){return typeof E}:function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},F=function(){function E(_,v){for(var d=0;d<v.length;d++){var a=v[d];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(_,a.key,a)}}return function(_,v,d){return v&&E(_.prototype,v),d&&E(_,d),_}}(),T=L("events"),f=u(T),h=L("./player-events.js"),t=u(h),e=L("../config.js"),n=L("../utils/exception.js");function u(E){return E&&E.__esModule?E:{default:E}}function s(E,_){if(!(E instanceof _))throw new TypeError("Cannot call a class as a function")}var i=function(){function E(_,v){if(s(this,E),this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new f.default,this._config=(0,e.createDefaultConfig)(),(typeof v=="undefined"?"undefined":R(v))==="object"&&Object.assign(this._config,v),_.type.toLowerCase()==="flv")throw new n.InvalidArgumentException("NativePlayer does't support flv MediaDataSource input!");if(_.hasOwnProperty("segments"))throw new n.InvalidArgumentException("NativePlayer("+_.type+") doesn't support multipart playback!");this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=_,this._mediaElement=null}return F(E,[{key:"destroy",value:function(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}},{key:"on",value:function(v,d){var a=this;v===t.default.MEDIA_INFO?this._mediaElement!=null&&this._mediaElement.readyState!==0&&Promise.resolve().then(function(){a._emitter.emit(t.default.MEDIA_INFO,a.mediaInfo)}):v===t.default.STATISTICS_INFO&&this._mediaElement!=null&&this._mediaElement.readyState!==0&&Promise.resolve().then(function(){a._emitter.emit(t.default.STATISTICS_INFO,a.statisticsInfo)}),this._emitter.addListener(v,d)}},{key:"off",value:function(v,d){this._emitter.removeListener(v,d)}},{key:"attachMediaElement",value:function(v){if(this._mediaElement=v,v.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._pendingSeekTime!=null)try{v.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(d){}}},{key:"detachMediaElement",value:function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),this._statisticsReporter!=null&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}},{key:"load",value:function(){if(!this._mediaElement)throw new n.IllegalStateException("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)}},{key:"unload",value:function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),this._statisticsReporter!=null&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}},{key:"play",value:function(){return this._mediaElement.play()}},{key:"pause",value:function(){this._mediaElement.pause()}},{key:"_onvLoadedMetadata",value:function(v){this._pendingSeekTime!=null&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(t.default.MEDIA_INFO,this.mediaInfo)}},{key:"_reportStatisticsInfo",value:function(){this._emitter.emit(t.default.STATISTICS_INFO,this.statisticsInfo)}},{key:"type",get:function(){return this._type}},{key:"buffered",get:function(){return this._mediaElement.buffered}},{key:"duration",get:function(){return this._mediaElement.duration}},{key:"volume",get:function(){return this._mediaElement.volume},set:function(v){this._mediaElement.volume=v}},{key:"muted",get:function(){return this._mediaElement.muted},set:function(v){this._mediaElement.muted=v}},{key:"currentTime",get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(v){this._mediaElement?this._mediaElement.currentTime=v:this._pendingSeekTime=v}},{key:"mediaInfo",get:function(){var v=this._mediaElement instanceof HTMLAudioElement?"audio/":"video/",d={mimeType:v+this._mediaDataSource.type};return this._mediaElement&&(d.duration=Math.floor(this._mediaElement.duration*1e3),this._mediaElement instanceof HTMLVideoElement&&(d.width=this._mediaElement.videoWidth,d.height=this._mediaElement.videoHeight)),d}},{key:"statisticsInfo",get:function(){var v={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return v;var d=!0,a=0,r=0;if(this._mediaElement.getVideoPlaybackQuality){var c=this._mediaElement.getVideoPlaybackQuality();a=c.totalVideoFrames,r=c.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(a=this._mediaElement.webkitDecodedFrameCount,r=this._mediaElement.webkitDroppedFrameCount):d=!1;return d&&(v.decodedFrames=a,v.droppedFrames=r),v}}]),E}();A.default=i},{"../config.js":5,"../utils/exception.js":40,"./player-events.js":35,events:2}],34:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0}),A.ErrorDetails=A.ErrorTypes=void 0;var R=L("../io/loader.js"),F=L("../demux/demux-errors.js"),T=f(F);function f(e){return e&&e.__esModule?e:{default:e}}var h=A.ErrorTypes={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},t=A.ErrorDetails={NETWORK_EXCEPTION:R.LoaderErrors.EXCEPTION,NETWORK_STATUS_CODE_INVALID:R.LoaderErrors.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:R.LoaderErrors.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:R.LoaderErrors.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:T.default.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:T.default.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:T.default.CODEC_UNSUPPORTED}},{"../demux/demux-errors.js":16,"../io/loader.js":24}],35:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",STATISTICS_INFO:"statistics_info"};A.default=R},{}],36:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function f(h,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,n.key,n)}}return function(h,t,e){return t&&f(h.prototype,t),e&&f(h,e),h}}();function F(f,h){if(!(f instanceof h))throw new TypeError("Cannot call a class as a function")}var T=function(){function f(){F(this,f)}return R(f,null,[{key:"getSilentFrame",value:function(t,e){if(t==="mp4a.40.2"){if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null}}]),f}();A.default=T},{}],37:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function f(h,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,n.key,n)}}return function(h,t,e){return t&&f(h.prototype,t),e&&f(h,e),h}}();function F(f,h){if(!(f instanceof h))throw new TypeError("Cannot call a class as a function")}var T=function(){function f(){F(this,f)}return R(f,null,[{key:"init",value:function(){f.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]};for(var t in f.types)f.types.hasOwnProperty(t)&&(f.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var e=f.constants={};e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),e.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}},{key:"box",value:function(t){for(var e=8,n=null,u=Array.prototype.slice.call(arguments,1),s=u.length,i=0;i<s;i++)e+=u[i].byteLength;n=new Uint8Array(e),n[0]=e>>>24&255,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=e&255,n.set(t,4);for(var E=8,_=0;_<s;_++)n.set(u[_],E),E+=u[_].byteLength;return n}},{key:"generateInitSegment",value:function(t){var e=f.box(f.types.ftyp,f.constants.FTYP),n=f.moov(t),u=new Uint8Array(e.byteLength+n.byteLength);return u.set(e,0),u.set(n,e.byteLength),u}},{key:"moov",value:function(t){var e=f.mvhd(t.timescale,t.duration),n=f.trak(t),u=f.mvex(t);return f.box(f.types.moov,e,n,u)}},{key:"mvhd",value:function(t,e){return f.box(f.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,t&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}},{key:"trak",value:function(t){return f.box(f.types.trak,f.tkhd(t),f.mdia(t))}},{key:"tkhd",value:function(t){var e=t.id,n=t.duration,u=t.presentWidth,s=t.presentHeight;return f.box(f.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,e&255,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,n&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,u>>>8&255,u&255,0,0,s>>>8&255,s&255,0,0]))}},{key:"mdia",value:function(t){return f.box(f.types.mdia,f.mdhd(t),f.hdlr(t),f.minf(t))}},{key:"mdhd",value:function(t){var e=t.timescale,n=t.duration;return f.box(f.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,e&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,85,196,0,0]))}},{key:"hdlr",value:function(t){var e=null;return t.type==="audio"?e=f.constants.HDLR_AUDIO:e=f.constants.HDLR_VIDEO,f.box(f.types.hdlr,e)}},{key:"minf",value:function(t){var e=null;return t.type==="audio"?e=f.box(f.types.smhd,f.constants.SMHD):e=f.box(f.types.vmhd,f.constants.VMHD),f.box(f.types.minf,e,f.dinf(),f.stbl(t))}},{key:"dinf",value:function(){var t=f.box(f.types.dinf,f.box(f.types.dref,f.constants.DREF));return t}},{key:"stbl",value:function(t){var e=f.box(f.types.stbl,f.stsd(t),f.box(f.types.stts,f.constants.STTS),f.box(f.types.stsc,f.constants.STSC),f.box(f.types.stsz,f.constants.STSZ),f.box(f.types.stco,f.constants.STCO));return e}},{key:"stsd",value:function(t){return t.type==="audio"?t.codec==="mp3"?f.box(f.types.stsd,f.constants.STSD_PREFIX,f.mp3(t)):f.box(f.types.stsd,f.constants.STSD_PREFIX,f.mp4a(t)):f.box(f.types.stsd,f.constants.STSD_PREFIX,f.avc1(t))}},{key:"mp3",value:function(t){var e=t.channelCount,n=t.audioSampleRate,u=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e,0,16,0,0,0,0,n>>>8&255,n&255,0,0]);return f.box(f.types[".mp3"],u)}},{key:"mp4a",value:function(t){var e=t.channelCount,n=t.audioSampleRate,u=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e,0,16,0,0,0,0,n>>>8&255,n&255,0,0]);return f.box(f.types.mp4a,u,f.esds(t))}},{key:"esds",value:function(t){var e=t.config||[],n=e.length,u=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(e).concat([6,1,2]));return f.box(f.types.esds,u)}},{key:"avc1",value:function(t){var e=t.avcc,n=t.codecWidth,u=t.codecHeight,s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,n>>>8&255,n&255,u>>>8&255,u&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return f.box(f.types.avc1,s,f.box(f.types.avcC,e))}},{key:"mvex",value:function(t){return f.box(f.types.mvex,f.trex(t))}},{key:"trex",value:function(t){var e=t.id,n=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return f.box(f.types.trex,n)}},{key:"moof",value:function(t,e){return f.box(f.types.moof,f.mfhd(t.sequenceNumber),f.traf(t,e))}},{key:"mfhd",value:function(t){var e=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,t&255]);return f.box(f.types.mfhd,e)}},{key:"traf",value:function(t,e){var n=t.id,u=f.box(f.types.tfhd,new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,n&255])),s=f.box(f.types.tfdt,new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,e&255])),i=f.sdtp(t),E=f.trun(t,i.byteLength+16+16+8+16+8+8);return f.box(f.types.traf,u,s,E,i)}},{key:"sdtp",value:function(t){for(var e=t.samples||[],n=e.length,u=new Uint8Array(4+n),s=0;s<n;s++){var i=e[s].flags;u[s+4]=i.isLeading<<6|i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy}return f.box(f.types.sdtp,u)}},{key:"trun",value:function(t,e){var n=t.samples||[],u=n.length,s=12+16*u,i=new Uint8Array(s);e+=8+s,i.set([0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,u&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0);for(var E=0;E<u;E++){var _=n[E].duration,v=n[E].size,d=n[E].flags,a=n[E].cts;i.set([_>>>24&255,_>>>16&255,_>>>8&255,_&255,v>>>24&255,v>>>16&255,v>>>8&255,v&255,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.isNonSync,0,0,a>>>24&255,a>>>16&255,a>>>8&255,a&255],12+16*E)}return f.box(f.types.trun,i)}},{key:"mdat",value:function(t){return f.box(f.types.mdat,t)}}]),f}();T.init(),A.default=T},{}],38:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function d(a,r){for(var c=0;c<r.length;c++){var l=r[c];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(a,l.key,l)}}return function(a,r,c){return r&&d(a.prototype,r),c&&d(a,c),a}}(),F=L("../utils/logger.js"),T=E(F),f=L("./mp4-generator.js"),h=E(f),t=L("./aac-silent.js"),e=E(t),n=L("../utils/browser.js"),u=E(n),s=L("../core/media-segment-info.js"),i=L("../utils/exception.js");function E(d){return d&&d.__esModule?d:{default:d}}function _(d,a){if(!(d instanceof a))throw new TypeError("Cannot call a class as a function")}var v=function(){function d(a){_(this,d),this.TAG="MP4Remuxer",this._config=a,this._isLive=a.isLive===!0,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=Infinity,this._videoDtsBase=Infinity,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new s.MediaSegmentInfoList("audio"),this._videoSegmentInfoList=new s.MediaSegmentInfoList("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!!(u.default.chrome&&(u.default.version.major<50||u.default.version.major===50&&u.default.version.build<2661)),this._fillSilentAfterSeek=u.default.msedge||u.default.msie,this._mp3UseMpegAudio=!u.default.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return R(d,[{key:"destroy",value:function(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null}},{key:"bindDataSource",value:function(r){return r.onDataAvailable=this.remux.bind(this),r.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this}},{key:"insertDiscontinuity",value:function(){this._audioNextDts=this._videoNextDts=void 0}},{key:"seek",value:function(r){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()}},{key:"remux",value:function(r,c){if(!this._onMediaSegment)throw new i.IllegalStateException("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(r,c),this._remuxVideo(c),this._remuxAudio(r)}},{key:"_onTrackMetadataReceived",value:function(r,c){var l=null,g="mp4",y=c.codec;if(r==="audio")this._audioMeta=c,c.codec==="mp3"&&this._mp3UseMpegAudio?(g="mpeg",y="",l=new Uint8Array):l=h.default.generateInitSegment(c);else if(r==="video")this._videoMeta=c,l=h.default.generateInitSegment(c);else return;if(!this._onInitSegment)throw new i.IllegalStateException("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(r,{type:r,data:l.buffer,codec:y,container:r+"/"+g,mediaDuration:c.duration})}},{key:"_calculateDtsBase",value:function(r,c){this._dtsBaseInited||(r.samples&&r.samples.length&&(this._audioDtsBase=r.samples[0].dts),c.samples&&c.samples.length&&(this._videoDtsBase=c.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)}},{key:"flushStashedSamples",value:function(){var r=this._videoStashedLastSample,c=this._audioStashedLastSample,l={type:"video",id:1,sequenceNumber:0,samples:[],length:0};r!=null&&(l.samples.push(r),l.length=r.length);var g={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};c!=null&&(g.samples.push(c),g.length=c.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(l,!0),this._remuxAudio(g,!0)}},{key:"_remuxAudio",value:function(r,c){if(this._audioMeta!=null){var l=r,g=l.samples,y=void 0,x=-1,k=-1,C=-1,S=this._audioMeta.refSampleDuration,m=this._audioMeta.codec==="mp3"&&this._mp3UseMpegAudio,o=this._dtsBaseInited&&this._audioNextDts===void 0,p=!1;if(!(!g||g.length===0)&&!(g.length===1&&!c)){var b=0,O=null,I=0;m?(b=0,I=l.length):(b=8,I=8+l.length);var P=null;if(g.length>1&&(P=g.pop(),I-=P.length),this._audioStashedLastSample!=null){var G=this._audioStashedLastSample;this._audioStashedLastSample=null,g.unshift(G),I+=G.length}P!=null&&(this._audioStashedLastSample=P);var D=g[0].dts-this._dtsBase;if(this._audioNextDts)y=D-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())y=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&this._audioMeta.originalCodec!=="mp3"&&(p=!0);else{var V=this._audioSegmentInfoList.getLastSampleBefore(D);if(V!=null){var U=D-(V.originalDts+V.duration);U<=3&&(U=0);var q=V.dts+V.duration+U;y=D-q}else y=0}if(p){var N=D-y,J=this._videoSegmentInfoList.getLastSegmentBefore(D);if(J!=null&&J.beginDts<N){var $=e.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if($){var W=J.beginDts,X=N-J.beginDts;T.default.v(this.TAG,"InsertPrefixSilentAudio: dts: "+W+", duration: "+X),g.unshift({unit:$,dts:W,pts:W}),I+=$.byteLength}}else p=!1}for(var K=[],Y=0;Y<g.length;Y++){var H=g[Y],se=H.unit,re=H.dts-this._dtsBase,ee=re-y;x===-1&&(x=ee);var ie=0;if(Y!==g.length-1){var he=g[Y+1].dts-this._dtsBase-y;ie=he-ee}else if(P!=null){var ue=P.dts-this._dtsBase-y;ie=ue-ee}else K.length>=1?ie=K[K.length-1].duration:ie=Math.floor(S);var te=!1,oe=null;if(ie>S*1.5&&this._audioMeta.codec!=="mp3"&&this._fillAudioTimestampGap&&!u.default.safari){te=!0;var ce=Math.abs(ie-S),ve=Math.ceil(ce/S),le=ee+S;T.default.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.
|
|
`+("dts: "+(ee+ie)+" ms, expected: "+(ee+Math.round(S))+" ms, ")+("delta: "+Math.round(ce)+" ms, generate: "+ve+" frames"));var _e=e.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);_e==null&&(T.default.w(this.TAG,"Unable to generate silent frame for "+(this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame")),_e=se),oe=[];for(var ge=0;ge<ve;ge++){var me=Math.round(le);if(oe.length>0){var pe=oe[oe.length-1];pe.duration=me-pe.dts}var Ee={dts:me,pts:me,cts:0,unit:_e,size:_e.byteLength,duration:0,originalDts:re,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};oe.push(Ee),I+=se.byteLength,le+=S}var ye=oe[oe.length-1];ye.duration=ee+ie-ye.dts,ie=Math.round(S)}K.push({dts:ee,pts:ee,cts:0,unit:H.unit,size:H.unit.byteLength,duration:ie,originalDts:re,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),te&&K.push.apply(K,oe)}m?O=new Uint8Array(I):(O=new Uint8Array(I),O[0]=I>>>24&255,O[1]=I>>>16&255,O[2]=I>>>8&255,O[3]=I&255,O.set(h.default.types.mdat,4));for(var ne=0;ne<K.length;ne++){var xe=K[ne].unit;O.set(xe,b),b+=xe.byteLength}var w=K[K.length-1];k=w.dts+w.duration,this._audioNextDts=k;var M=new s.MediaSegmentInfo;M.beginDts=x,M.endDts=k,M.beginPts=x,M.endPts=k,M.originalBeginDts=K[0].originalDts,M.originalEndDts=w.originalDts+w.duration,M.firstSample=new s.SampleInfo(K[0].dts,K[0].pts,K[0].duration,K[0].originalDts,!1),M.lastSample=new s.SampleInfo(w.dts,w.pts,w.duration,w.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(M),l.samples=K,l.sequenceNumber++;var B=null;m?B=new Uint8Array:B=h.default.moof(l,x),l.samples=[],l.length=0;var z={type:"audio",data:this._mergeBoxes(B,O).buffer,sampleCount:K.length,info:M};m&&o&&(z.timestampOffset=x),this._onMediaSegment("audio",z)}}}},{key:"_remuxVideo",value:function(r,c){if(this._videoMeta!=null){var l=r,g=l.samples,y=void 0,x=-1,k=-1,C=-1,S=-1;if(!(!g||g.length===0)&&!(g.length===1&&!c)){var m=8,o=null,p=8+r.length,b=null;if(g.length>1&&(b=g.pop(),p-=b.length),this._videoStashedLastSample!=null){var O=this._videoStashedLastSample;this._videoStashedLastSample=null,g.unshift(O),p+=O.length}b!=null&&(this._videoStashedLastSample=b);var I=g[0].dts-this._dtsBase;if(this._videoNextDts)y=I-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())y=0;else{var P=this._videoSegmentInfoList.getLastSampleBefore(I);if(P!=null){var G=I-(P.originalDts+P.duration);G<=3&&(G=0);var D=P.dts+P.duration+G;y=I-D}else y=0}for(var V=new s.MediaSegmentInfo,U=[],q=0;q<g.length;q++){var N=g[q],J=N.dts-this._dtsBase,$=N.isKeyframe,W=J-y,X=N.cts,K=W+X;x===-1&&(x=W,C=K);var Y=0;if(q!==g.length-1){var H=g[q+1].dts-this._dtsBase-y;Y=H-W}else if(b!=null){var se=b.dts-this._dtsBase-y;Y=se-W}else U.length>=1?Y=U[U.length-1].duration:Y=Math.floor(this._videoMeta.refSampleDuration);if($){var re=new s.SampleInfo(W,K,Y,N.dts,!0);re.fileposition=N.fileposition,V.appendSyncPoint(re)}U.push({dts:W,pts:K,cts:X,units:N.units,size:N.length,isKeyframe:$,duration:Y,originalDts:J,flags:{isLeading:0,dependsOn:$?2:1,isDependedOn:$?1:0,hasRedundancy:0,isNonSync:$?0:1}})}o=new Uint8Array(p),o[0]=p>>>24&255,o[1]=p>>>16&255,o[2]=p>>>8&255,o[3]=p&255,o.set(h.default.types.mdat,4);for(var ee=0;ee<U.length;ee++)for(var ie=U[ee].units;ie.length;){var he=ie.shift(),ue=he.data;o.set(ue,m),m+=ue.byteLength}var te=U[U.length-1];if(k=te.dts+te.duration,S=te.pts+te.duration,this._videoNextDts=k,V.beginDts=x,V.endDts=k,V.beginPts=C,V.endPts=S,V.originalBeginDts=U[0].originalDts,V.originalEndDts=te.originalDts+te.duration,V.firstSample=new s.SampleInfo(U[0].dts,U[0].pts,U[0].duration,U[0].originalDts,U[0].isKeyframe),V.lastSample=new s.SampleInfo(te.dts,te.pts,te.duration,te.originalDts,te.isKeyframe),this._isLive||this._videoSegmentInfoList.append(V),l.samples=U,l.sequenceNumber++,this._forceFirstIDR){var oe=U[0].flags;oe.dependsOn=2,oe.isNonSync=0}var ce=h.default.moof(l,x);l.samples=[],l.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(ce,o).buffer,sampleCount:U.length,info:V})}}}},{key:"_mergeBoxes",value:function(r,c){var l=new Uint8Array(r.byteLength+c.byteLength);return l.set(r,0),l.set(c,r.byteLength),l}},{key:"onInitSegment",get:function(){return this._onInitSegment},set:function(r){this._onInitSegment=r}},{key:"onMediaSegment",get:function(){return this._onMediaSegment},set:function(r){this._onMediaSegment=r}}]),d}();A.default=v},{"../core/media-segment-info.js":8,"../utils/browser.js":39,"../utils/exception.js":40,"../utils/logger.js":41,"./aac-silent.js":36,"./mp4-generator.js":37}],39:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R={};function F(){var T=self.navigator.userAgent.toLowerCase(),f=/(edge)\/([\w.]+)/.exec(T)||/(opr)[\/]([\w.]+)/.exec(T)||/(chrome)[ \/]([\w.]+)/.exec(T)||/(iemobile)[\/]([\w.]+)/.exec(T)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(T)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(T)||/(webkit)[ \/]([\w.]+)/.exec(T)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(T)||/(msie) ([\w.]+)/.exec(T)||T.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(T)||T.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(T)||[],h=/(ipad)/.exec(T)||/(ipod)/.exec(T)||/(windows phone)/.exec(T)||/(iphone)/.exec(T)||/(kindle)/.exec(T)||/(android)/.exec(T)||/(windows)/.exec(T)||/(mac)/.exec(T)||/(linux)/.exec(T)||/(cros)/.exec(T)||[],t={browser:f[5]||f[3]||f[1]||"",version:f[2]||f[4]||"0",majorVersion:f[4]||f[2]||"0",platform:h[0]||""},e={};if(t.browser){e[t.browser]=!0;var n=t.majorVersion.split(".");e.version={major:parseInt(t.majorVersion,10),string:t.version},n.length>1&&(e.version.minor=parseInt(n[1],10)),n.length>2&&(e.version.build=parseInt(n[2],10))}if(t.platform&&(e[t.platform]=!0),(e.chrome||e.opr||e.safari)&&(e.webkit=!0),e.rv||e.iemobile){e.rv&&delete e.rv;var u="msie";t.browser=u,e[u]=!0}if(e.edge){delete e.edge;var s="msedge";t.browser=s,e[s]=!0}if(e.opr){var i="opera";t.browser=i,e[i]=!0}if(e.safari&&e.android){var E="android";t.browser=E,e[E]=!0}e.name=t.browser,e.platform=t.platform;for(var _ in R)R.hasOwnProperty(_)&&delete R[_];Object.assign(R,e)}F(),A.default=R},{}],40:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function u(s,i){for(var E=0;E<i.length;E++){var _=i[E];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(s,_.key,_)}}return function(s,i,E){return i&&u(s.prototype,i),E&&u(s,E),s}}();function F(u,s){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:u}function T(u,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);u.prototype=Object.create(s&&s.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(u,s):u.__proto__=s)}function f(u,s){if(!(u instanceof s))throw new TypeError("Cannot call a class as a function")}var h=A.RuntimeException=function(){function u(s){f(this,u),this._message=s}return R(u,[{key:"toString",value:function(){return this.name+": "+this.message}},{key:"name",get:function(){return"RuntimeException"}},{key:"message",get:function(){return this._message}}]),u}(),t=A.IllegalStateException=function(u){T(s,u);function s(i){return f(this,s),F(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,i))}return R(s,[{key:"name",get:function(){return"IllegalStateException"}}]),s}(h),e=A.InvalidArgumentException=function(u){T(s,u);function s(i){return f(this,s),F(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,i))}return R(s,[{key:"name",get:function(){return"InvalidArgumentException"}}]),s}(h),n=A.NotImplementedException=function(u){T(s,u);function s(i){return f(this,s),F(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,i))}return R(s,[{key:"name",get:function(){return"NotImplementedException"}}]),s}(h)},{}],41:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function e(n,u){for(var s=0;s<u.length;s++){var i=u[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}}return function(n,u,s){return u&&e(n.prototype,u),s&&e(n,s),n}}(),F=L("events"),T=f(F);function f(e){return e&&e.__esModule?e:{default:e}}function h(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var t=function(){function e(){h(this,e)}return R(e,null,[{key:"e",value:function(u,s){(!u||e.FORCE_GLOBAL_TAG)&&(u=e.GLOBAL_TAG);var i="["+u+"] > "+s;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",i),!!e.ENABLE_ERROR&&(console.error?console.error(i):console.warn?console.warn(i):console.log(i))}},{key:"i",value:function(u,s){(!u||e.FORCE_GLOBAL_TAG)&&(u=e.GLOBAL_TAG);var i="["+u+"] > "+s;e.ENABLE_CALLBACK&&e.emitter.emit("log","info",i),!!e.ENABLE_INFO&&(console.info?console.info(i):console.log(i))}},{key:"w",value:function(u,s){(!u||e.FORCE_GLOBAL_TAG)&&(u=e.GLOBAL_TAG);var i="["+u+"] > "+s;e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",i),!!e.ENABLE_WARN&&(console.warn?console.warn(i):console.log(i))}},{key:"d",value:function(u,s){(!u||e.FORCE_GLOBAL_TAG)&&(u=e.GLOBAL_TAG);var i="["+u+"] > "+s;e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",i),!!e.ENABLE_DEBUG&&(console.debug?console.debug(i):console.log(i))}},{key:"v",value:function(u,s){(!u||e.FORCE_GLOBAL_TAG)&&(u=e.GLOBAL_TAG);var i="["+u+"] > "+s;e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",i),!!e.ENABLE_VERBOSE&&console.log(i)}}]),e}();t.GLOBAL_TAG="flv.js",t.FORCE_GLOBAL_TAG=!1,t.ENABLE_ERROR=!0,t.ENABLE_INFO=!0,t.ENABLE_WARN=!0,t.ENABLE_DEBUG=!0,t.ENABLE_VERBOSE=!0,t.ENABLE_CALLBACK=!1,t.emitter=new T.default,A.default=t},{events:2}],42:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function u(s,i){for(var E=0;E<i.length;E++){var _=i[E];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(s,_.key,_)}}return function(s,i,E){return i&&u(s.prototype,i),E&&u(s,E),s}}(),F=L("events"),T=t(F),f=L("./logger.js"),h=t(f);function t(u){return u&&u.__esModule?u:{default:u}}function e(u,s){if(!(u instanceof s))throw new TypeError("Cannot call a class as a function")}var n=function(){function u(){e(this,u)}return R(u,null,[{key:"getConfig",value:function(){return{globalTag:h.default.GLOBAL_TAG,forceGlobalTag:h.default.FORCE_GLOBAL_TAG,enableVerbose:h.default.ENABLE_VERBOSE,enableDebug:h.default.ENABLE_DEBUG,enableInfo:h.default.ENABLE_INFO,enableWarn:h.default.ENABLE_WARN,enableError:h.default.ENABLE_ERROR,enableCallback:h.default.ENABLE_CALLBACK}}},{key:"applyConfig",value:function(i){h.default.GLOBAL_TAG=i.globalTag,h.default.FORCE_GLOBAL_TAG=i.forceGlobalTag,h.default.ENABLE_VERBOSE=i.enableVerbose,h.default.ENABLE_DEBUG=i.enableDebug,h.default.ENABLE_INFO=i.enableInfo,h.default.ENABLE_WARN=i.enableWarn,h.default.ENABLE_ERROR=i.enableError,h.default.ENABLE_CALLBACK=i.enableCallback}},{key:"_notifyChange",value:function(){var i=u.emitter;if(i.listenerCount("change")>0){var E=u.getConfig();i.emit("change",E)}}},{key:"registerListener",value:function(i){u.emitter.addListener("change",i)}},{key:"removeListener",value:function(i){u.emitter.removeListener("change",i)}},{key:"addLogListener",value:function(i){h.default.emitter.addListener("log",i),h.default.emitter.listenerCount("log")>0&&(h.default.ENABLE_CALLBACK=!0,u._notifyChange())}},{key:"removeLogListener",value:function(i){h.default.emitter.removeListener("log",i),h.default.emitter.listenerCount("log")===0&&(h.default.ENABLE_CALLBACK=!1,u._notifyChange())}},{key:"forceGlobalTag",get:function(){return h.default.FORCE_GLOBAL_TAG},set:function(i){h.default.FORCE_GLOBAL_TAG=i,u._notifyChange()}},{key:"globalTag",get:function(){return h.default.GLOBAL_TAG},set:function(i){h.default.GLOBAL_TAG=i,u._notifyChange()}},{key:"enableAll",get:function(){return h.default.ENABLE_VERBOSE&&h.default.ENABLE_DEBUG&&h.default.ENABLE_INFO&&h.default.ENABLE_WARN&&h.default.ENABLE_ERROR},set:function(i){h.default.ENABLE_VERBOSE=i,h.default.ENABLE_DEBUG=i,h.default.ENABLE_INFO=i,h.default.ENABLE_WARN=i,h.default.ENABLE_ERROR=i,u._notifyChange()}},{key:"enableDebug",get:function(){return h.default.ENABLE_DEBUG},set:function(i){h.default.ENABLE_DEBUG=i,u._notifyChange()}},{key:"enableVerbose",get:function(){return h.default.ENABLE_VERBOSE},set:function(i){h.default.ENABLE_VERBOSE=i,u._notifyChange()}},{key:"enableInfo",get:function(){return h.default.ENABLE_INFO},set:function(i){h.default.ENABLE_INFO=i,u._notifyChange()}},{key:"enableWarn",get:function(){return h.default.ENABLE_WARN},set:function(i){h.default.ENABLE_WARN=i,u._notifyChange()}},{key:"enableError",get:function(){return h.default.ENABLE_ERROR},set:function(i){h.default.ENABLE_ERROR=i,u._notifyChange()}}]),u}();n.emitter=new T.default,A.default=n},{"./logger.js":41,events:2}],43:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function f(h,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,n.key,n)}}return function(h,t,e){return t&&f(h.prototype,t),e&&f(h,e),h}}();function F(f,h){if(!(f instanceof h))throw new TypeError("Cannot call a class as a function")}var T=function(){function f(){F(this,f)}return R(f,null,[{key:"install",value:function(){Object.setPrototypeOf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Object.assign=Object.assign||function(t){if(t==null)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var u=arguments[n];if(u!=null)for(var s in u)u.hasOwnProperty(s)&&(e[s]=u[s])}return e},typeof self.Promise!="function"&&L("es6-promise").polyfill()}}]),f}();T.install(),A.default=T},{"es6-promise":1}],44:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});function R(T,f,h){var t=T;if(f+h<t.length){for(;h--;)if((t[++f]&192)!=128)return!1;return!0}else return!1}function F(T){for(var f=[],h=T,t=0,e=T.length;t<e;){if(h[t]<128){f.push(String.fromCharCode(h[t])),++t;continue}else if(!(h[t]<192)){if(h[t]<224){if(R(h,t,1)){var n=(h[t]&31)<<6|h[t+1]&63;if(n>=128){f.push(String.fromCharCode(n&65535)),t+=2;continue}}}else if(h[t]<240){if(R(h,t,2)){var u=(h[t]&15)<<12|(h[t+1]&63)<<6|h[t+2]&63;if(u>=2048&&(u&63488)!=55296){f.push(String.fromCharCode(u&65535)),t+=3;continue}}}else if(h[t]<248&&R(h,t,3)){var s=(h[t]&7)<<18|(h[t+1]&63)<<12|(h[t+2]&63)<<6|h[t+3]&63;if(s>65536&&s<1114112){s-=65536,f.push(String.fromCharCode(s>>>10|55296)),f.push(String.fromCharCode(s&1023|56320)),t+=4;continue}}}f.push(String.fromCharCode(65533)),++t}return f.join("")}A.default=F},{}]},{},[21])(21)});
|