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