(function(fe){if(typeof exports=="object"&&typeof module!="undefined")module.exports=fe();else if(typeof define=="function"&&define.amd)define([],fe);else{var de;typeof window!="undefined"?de=window:typeof global!="undefined"?de=global:typeof self!="undefined"?de=self:de=this,de.flvjs=fe()}})(function(){var fe,de,ke;return function L(j,A,R){function F(h,t){if(!A[h]){if(!j[h]){var e=typeof require=="function"&&require;if(!t&&e)return e(h,!0);if(T)return T(h,!0);var n=new Error("Cannot find module '"+h+"'");throw n.code="MODULE_NOT_FOUND",n}var u=A[h]={exports:{}};j[h][0].call(u.exports,function(s){var i=j[h][1][s];return F(i||s)},u,u.exports,L,j,A,R)}return A[h].exports}for(var T=typeof require=="function"&&require,f=0;f0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},R.prototype.on=R.prototype.addListener,R.prototype.once=function(t,e){if(!F(e))throw TypeError("listener must be a function");var n=!1;function u(){this.removeListener(t,u),n||(n=!0,e.apply(this,arguments))}return u.listener=e,this.on(t,u),this},R.prototype.removeListener=function(t,e){var n,u,s,i;if(!F(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],s=n.length,u=-1,n===e||F(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(f(n)){for(i=s;i-- >0;)if(n[i]===e||n[i].listener&&n[i].listener===e){u=i;break}if(u<0)return this;n.length===1?(n.length=0,delete this._events[t]):n.splice(u,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},R.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],F(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},R.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:F(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},R.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(F(e))return 1;if(e)return e.length}return 0},R.listenerCount=function(t,e){return t.listenerCount(e)};function F(t){return typeof t=="function"}function T(t){return typeof t=="number"}function f(t){return typeof t=="object"&&t!==null}function h(t){return t===void 0}},{}],3:[function(L,j,A){var R=j.exports={},F,T;function f(){throw new Error("setTimeout has not been defined")}function h(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?F=setTimeout:F=f}catch(a){F=f}try{typeof clearTimeout=="function"?T=clearTimeout:T=h}catch(a){T=h}})();function t(a){if(F===setTimeout)return setTimeout(a,0);if((F===f||!F)&&setTimeout)return F=setTimeout,setTimeout(a,0);try{return F(a,0)}catch(r){try{return F.call(null,a,0)}catch(c){return F.call(this,a,0)}}}function e(a){if(T===clearTimeout)return clearTimeout(a);if((T===h||!T)&&clearTimeout)return T=clearTimeout,clearTimeout(a);try{return T(a)}catch(r){try{return T.call(null,a)}catch(c){return T.call(this,a)}}}var n=[],u=!1,s,i=-1;function E(){!u||!s||(u=!1,s.length?n=s.concat(n):i=-1,n.length&&_())}function _(){if(!u){var a=t(E);u=!0;for(var r=n.length;r;){for(s=n,n=[];++i1)for(var c=1;c=t[s]&&e0&&u[0].originalDts=s[_].dts&&us[E].lastSample.originalDts&&u=s[E].lastSample.originalDts&&(E===s.length-1||E0&&(_=this._searchNearestSegmentBefore(i.originalBeginDts)+1),this._lastAppendLocation=_,this._list.splice(_,0,i)}},{key:"getLastSegmentBefore",value:function(u){var s=this._searchNearestSegmentBefore(u);return s>=0?this._list[s]:null}},{key:"getLastSampleBefore",value:function(u){var s=this.getLastSegmentBefore(u);return s!=null?s.lastSample:null}},{key:"getLastSyncPointBefore",value:function(u){for(var s=this._searchNearestSegmentBefore(u),i=this._list[s].syncPoints;i.length===0&&s>0;)s--,i=this._list[s].syncPoints;return i.length>0?i[i.length-1]:null}},{key:"type",get:function(){return this._type}},{key:"length",get:function(){return this._list.length}}]),e}()},{}],9:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function d(a,r){for(var c=0;c0&&(g+=";codecs="+l.codec);var y=!1;if(h.default.v(this.TAG,"Received Initialization Segment, mimeType: "+g),this._lastInitSegments[l.type]=l,g!==this._mimeTypes[l.type]){if(this._mimeTypes[l.type])h.default.v(this.TAG,"Notice: "+l.type+" mimeType changed, origin: "+this._mimeTypes[l.type]+", target: "+g);else{y=!0;try{var x=this._sourceBuffers[l.type]=this._mediaSource.addSourceBuffer(g);x.addEventListener("error",this.e.onSourceBufferError),x.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(k){h.default.e(this.TAG,k.message),this._emitter.emit(u.default.ERROR,{code:k.code,msg:k.message});return}}this._mimeTypes[l.type]=g}c||this._pendingSegments[l.type].push(l),y||this._sourceBuffers[l.type]&&!this._sourceBuffers[l.type].updating&&this._doAppendSegments(),e.default.safari&&l.container==="audio/mpeg"&&l.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=l.mediaDuration/1e3,this._updateMediaSourceDuration())}},{key:"appendMediaSegment",value:function(r){var c=r;this._pendingSegments[c.type].push(c),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var l=this._sourceBuffers[c.type];l&&!l.updating&&!this._hasPendingRemoveRanges()&&this._doAppendSegments()}},{key:"seek",value:function(r){for(var c in this._sourceBuffers)if(!!this._sourceBuffers[c]){var l=this._sourceBuffers[c];if(this._mediaSource.readyState==="open")try{l.abort()}catch(S){h.default.e(this.TAG,S.message)}this._idrList.clear();var g=this._pendingSegments[c];if(g.splice(0,g.length),this._mediaSource.readyState!=="closed"){for(var y=0;y=1&&r-g.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}},{key:"_doCleanupSourceBuffer",value:function(){var r=this._mediaElement.currentTime;for(var c in this._sourceBuffers){var l=this._sourceBuffers[c];if(l){for(var g=l.buffered,y=!1,x=0;x=this._config.autoCleanupMaxBackwardDuration){y=!0;var S=r-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[c].push({start:k,end:S})}}else C0&&(isNaN(c)||l>c)&&(h.default.v(this.TAG,"Update MediaSource duration from "+c+" to "+l),this._mediaSource.duration=l),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}}},{key:"_doRemoveRanges",value:function(){for(var r in this._pendingRemoveRanges)if(!(!this._sourceBuffers[r]||this._sourceBuffers[r].updating))for(var c=this._sourceBuffers[r],l=this._pendingRemoveRanges[r];l.length&&!c.updating;){var g=l.shift();c.remove(g.start,g.end)}}},{key:"_doAppendSegments",value:function(){var r=this._pendingSegments;for(var c in r)if(!(!this._sourceBuffers[c]||this._sourceBuffers[c].updating)&&r[c].length>0){var l=r[c].shift();if(l.timestampOffset){var g=this._sourceBuffers[c].timestampOffset,y=l.timestampOffset/1e3,x=Math.abs(g-y);x>.1&&(h.default.v(this.TAG,"Update MPEG audio timestampOffset from "+g+" to "+y),this._sourceBuffers[c].timestampOffset=y),delete l.timestampOffset}if(!l.data||l.data.byteLength===0)continue;try{this._sourceBuffers[c].appendBuffer(l.data),this._isBufferFull=!1,c==="video"&&l.hasOwnProperty("info")&&this._idrList.appendArray(l.info.syncPoints)}catch(k){this._pendingSegments[c].unshift(l),k.code===22?(this._isBufferFull||this._emitter.emit(u.default.BUFFER_FULL),this._isBufferFull=!0):(h.default.e(this.TAG,k.message),this._emitter.emit(u.default.ERROR,{code:k.code,msg:k.message}))}}}},{key:"_onSourceOpen",value:function(){if(h.default.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var r=this._pendingSourceBufferInit;r.length;){var c=r.shift();this.appendInitSegment(c,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(u.default.SOURCE_OPEN)}},{key:"_onSourceEnded",value:function(){h.default.v(this.TAG,"MediaSource onSourceEnded")}},{key:"_onSourceClose",value:function(){h.default.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&this.e!=null&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))}},{key:"_hasPendingSegments",value:function(){var r=this._pendingSegments;return r.video.length>0||r.audio.length>0}},{key:"_hasPendingRemoveRanges",value:function(){var r=this._pendingRemoveRanges;return r.video.length>0||r.audio.length>0}},{key:"_onSourceBufferUpdateEnd",value:function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(u.default.UPDATE_END)}},{key:"_onSourceBufferError",value:function(r){h.default.e(this.TAG,"SourceBuffer Error: "+r)}}]),d}();A.default=v},{"../utils/browser.js":39,"../utils/exception.js":40,"../utils/logger.js":41,"./media-segment-info.js":8,"./mse-events.js":10,events:2}],10:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};A.default=R},{}],11:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function l(g,y){for(var x=0;x0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,O=this._demuxer.parseChunks(m,o);else if((b=i.default.probe(m)).match){this._demuxer=new i.default(b,this._config),this._remuxer||(this._remuxer=new _.default(this._config));var I=this._mediaDataSource;I.duration!=null&&!isNaN(I.duration)&&(this._demuxer.overridedDuration=I.duration),typeof I.hasAudio=="boolean"&&(this._demuxer.overridedHasAudio=I.hasAudio),typeof I.hasVideo=="boolean"&&(this._demuxer.overridedHasVideo=I.hasVideo),this._demuxer.timestampBase=I.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),O=this._demuxer.parseChunks(m,o)}else b=null,h.default.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(function(){p._internalAbort()}),this._emitter.emit(l.default.DEMUX_ERROR,d.default.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),O=0;return O}},{key:"_onMediaInfo",value:function(m){var o=this;this._mediaInfo==null&&(this._mediaInfo=Object.assign({},m),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,u.default.prototype));var p=Object.assign({},m);Object.setPrototypeOf(p,u.default.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=p,this._reportSegmentMediaInfo(this._currentSegmentIndex),this._pendingSeekTime!=null&&Promise.resolve().then(function(){var b=o._pendingSeekTime;o._pendingSeekTime=null,o.seek(b)})}},{key:"_onIOSeeked",value:function(){this._remuxer.insertDiscontinuity()}},{key:"_onIOComplete",value:function(m){var o=m,p=o+1;p0&&p[0].originalDts===b&&(b=p[0].pts),this._emitter.emit(l.default.RECOMMEND_SEEKPOINT,b)}}},{key:"_enableStatisticsReporter",value:function(){this._statisticsReporter==null&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))}},{key:"_disableStatisticsReporter",value:function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}},{key:"_reportSegmentMediaInfo",value:function(m){var o=this._mediaInfo.segments[m],p=Object.assign({},o);p.duration=this._mediaInfo.duration,p.segmentCount=this._mediaInfo.segmentCount,delete p.segments,delete p.keyframesIndex,this._emitter.emit(l.default.MEDIA_INFO,p)}},{key:"_reportStatisticsInfo",value:function(){var m={};m.url=this._ioctl.currentURL,m.hasRedirect=this._ioctl.hasRedirect,m.hasRedirect&&(m.redirectedURL=this._ioctl.currentRedirectedURL),m.speed=this._ioctl.currentSpeed,m.loaderType=this._ioctl.loaderType,m.currentSegmentIndex=this._currentSegmentIndex,m.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(l.default.STATISTICS_INFO,m)}}]),C}();A.default=k},{"../demux/demux-errors.js":16,"../demux/flv-demuxer.js":18,"../io/io-controller.js":23,"../io/loader.js":24,"../remux/mp4-remuxer.js":38,"../utils/browser.js":39,"../utils/logger.js":41,"./media-info.js":7,"./transmuxing-events.js":13,events:2}],13:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};A.default=R},{}],14:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=L("../utils/logger.js"),F=i(R),T=L("../utils/logging-control.js"),f=i(T),h=L("../utils/polyfill.js"),t=i(h),e=L("./transmuxing-controller.js"),n=i(e),u=L("./transmuxing-events.js"),s=i(u);function i(_){return _&&_.__esModule?_:{default:_}}var E=function(v){var d="TransmuxingWorker",a=null,r=o.bind(this);t.default.install(),v.addEventListener("message",function(p){switch(p.data.cmd){case"init":a=new n.default(p.data.param[0],p.data.param[1]),a.on(s.default.IO_ERROR,C.bind(this)),a.on(s.default.DEMUX_ERROR,S.bind(this)),a.on(s.default.INIT_SEGMENT,c.bind(this)),a.on(s.default.MEDIA_SEGMENT,l.bind(this)),a.on(s.default.LOADING_COMPLETE,g.bind(this)),a.on(s.default.RECOVERED_EARLY_EOF,y.bind(this)),a.on(s.default.MEDIA_INFO,x.bind(this)),a.on(s.default.STATISTICS_INFO,k.bind(this)),a.on(s.default.RECOMMEND_SEEKPOINT,m.bind(this));break;case"destroy":a&&(a.destroy(),a=null),v.postMessage({msg:"destroyed"});break;case"start":a.start();break;case"stop":a.stop();break;case"seek":a.seek(p.data.param);break;case"pause":a.pause();break;case"resume":a.resume();break;case"logging_config":{var b=p.data.param;f.default.applyConfig(b),b.enableCallback===!0?f.default.addLogListener(r):f.default.removeLogListener(r);break}}});function c(p,b){var O={msg:s.default.INIT_SEGMENT,data:{type:p,data:b}};v.postMessage(O,[b.data])}function l(p,b){var O={msg:s.default.MEDIA_SEGMENT,data:{type:p,data:b}};v.postMessage(O,[b.data])}function g(){var p={msg:s.default.LOADING_COMPLETE};v.postMessage(p)}function y(){var p={msg:s.default.RECOVERED_EARLY_EOF};v.postMessage(p)}function x(p){var b={msg:s.default.MEDIA_INFO,data:p};v.postMessage(b)}function k(p){var b={msg:s.default.STATISTICS_INFO,data:p};v.postMessage(b)}function C(p,b){v.postMessage({msg:s.default.IO_ERROR,data:{type:p,info:b}})}function S(p,b){v.postMessage({msg:s.default.DEMUX_ERROR,data:{type:p,info:b}})}function m(p){v.postMessage({msg:s.default.RECOMMEND_SEEKPOINT,data:p})}function o(p,b){v.postMessage({msg:"logcat_callback",data:{type:p,logcat:b}})}};A.default=E},{"../utils/logger.js":41,"../utils/logging-control.js":42,"../utils/polyfill.js":43,"./transmuxing-controller.js":12,"./transmuxing-events.js":13}],15:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function i(E,_){for(var v=0;v<_.length;v++){var d=_[v];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(E,d.key,d)}}return function(E,_,v){return _&&i(E.prototype,_),v&&i(E,v),E}}(),F=L("../utils/logger.js"),T=e(F),f=L("../utils/utf8-conv.js"),h=e(f),t=L("../utils/exception.js");function e(i){return i&&i.__esModule?i:{default:i}}function n(i,E){if(!(i instanceof E))throw new TypeError("Cannot call a class as a function")}var u=function(){var i=new ArrayBuffer(2);return new DataView(i).setInt16(0,256,!0),new Int16Array(i)[0]===256}(),s=function(){function i(){n(this,i)}return R(i,null,[{key:"parseScriptData",value:function(_,v,d){var a={};try{var r=i.parseValue(_,v,d),c=i.parseValue(_,v+r.size,d-r.size);a[r.data]=c.data}catch(l){T.default.e("AMF",l.toString())}return a}},{key:"parseObject",value:function(_,v,d){if(d<3)throw new t.IllegalStateException("Data not enough when parse ScriptDataObject");var a=i.parseString(_,v,d),r=i.parseValue(_,v+a.size,d-a.size),c=r.objectEnd;return{data:{name:a.data,value:r.data},size:a.size+r.size,objectEnd:c}}},{key:"parseVariable",value:function(_,v,d){return i.parseObject(_,v,d)}},{key:"parseString",value:function(_,v,d){if(d<2)throw new t.IllegalStateException("Data not enough when parse String");var a=new DataView(_,v,d),r=a.getUint16(0,!u),c=void 0;return r>0?c=(0,h.default)(new Uint8Array(_,v+2,r)):c="",{data:c,size:2+r}}},{key:"parseLongString",value:function(_,v,d){if(d<4)throw new t.IllegalStateException("Data not enough when parse LongString");var a=new DataView(_,v,d),r=a.getUint32(0,!u),c=void 0;return r>0?c=(0,h.default)(new Uint8Array(_,v+4,r)):c="",{data:c,size:4+r}}},{key:"parseDate",value:function(_,v,d){if(d<10)throw new t.IllegalStateException("Data size invalid when parse Date");var a=new DataView(_,v,d),r=a.getFloat64(0,!u),c=a.getInt16(8,!u);return r+=c*60*1e3,{data:new Date(r),size:8+2}}},{key:"parseValue",value:function(_,v,d){if(d<1)throw new t.IllegalStateException("Data not enough when parse Value");var a=new DataView(_,v,d),r=1,c=a.getUint8(0),l=void 0,g=!1;try{switch(c){case 0:l=a.getFloat64(1,!u),r+=8;break;case 1:{var y=a.getUint8(1);l=!!y,r+=1;break}case 2:{var x=i.parseString(_,v+1,d-1);l=x.data,r+=x.size;break}case 3:{l={};var k=0;for((a.getUint32(d-4,!u)&16777215)==9&&(k=3);r32)throw new F.InvalidArgumentException("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){var n=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,n}var u=this._current_word_bits_left?this._current_word:0;u=u>>>32-this._current_word_bits_left;var s=e-this._current_word_bits_left;this._fillCurrentWord();var i=Math.min(s,this._current_word_bits_left),E=this._current_word>>>32-i;return this._current_word<<=i,this._current_word_bits_left-=i,u=u<>>e)!=0)return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}},{key:"readUEG",value:function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1}},{key:"readSEG",value:function(){var e=this.readUEG();return e&1?e+1>>>1:-1*(e>>>1)}}]),h}();A.default=f},{"../utils/exception.js":40}],18:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(g){return typeof g}:function(g){return g&&typeof Symbol=="function"&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g},F=function(){function g(y,x){for(var k=0;k>>8&255|(g&255)<<8}function r(g){return(g&4278190080)>>>24|(g&16711680)>>>8|(g&65280)<<8|(g&255)<<24}function c(g,y){return g[y]<<24|g[y+1]<<16|g[y+2]<<8|g[y+3]}var l=function(){function g(y,x){d(this,g),this.TAG="FLVDemuxer",this._config=x,this._onError=null,this._onMediaInfo=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=y.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=y.hasAudioTrack,this._hasVideo=y.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new E.default,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){var k=new ArrayBuffer(2);return new DataView(k).setInt16(0,256,!0),new Int16Array(k)[0]===256}()}return F(g,[{key:"destroy",value:function(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onTrackMetadata=null,this._onDataAvailable=null}},{key:"bindDataSource",value:function(x){return x.onDataArrival=this.parseChunks.bind(this),this}},{key:"resetMediaInfo",value:function(){this._mediaInfo=new E.default}},{key:"_isInitialMetadataDispatched",value:function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!this._hasAudio&&this._hasVideo?this._videoInitialMetadataDispatched:!1}},{key:"parseChunks",value:function(x,k){if(!this._onError||!this._onMediaInfo||!this._onTrackMetadata||!this._onDataAvailable)throw new _.IllegalStateException("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var C=0,S=this._littleEndian;if(k===0)if(x.byteLength>13){var m=g.probe(x);C=m.dataOffset}else return 0;if(this._firstParse){this._firstParse=!1,k+C!==this._dataOffset&&f.default.w(this.TAG,"First time parsing but chunk byteStart invalid!");var o=new DataView(x,C),p=o.getUint32(0,!S);p!==0&&f.default.w(this.TAG,"PrevTagSize0 !== 0 !!!"),C+=4}for(;Cx.byteLength)break;var O=b.getUint8(0),I=b.getUint32(0,!S)&16777215;if(C+11+I+4>x.byteLength)break;if(O!==8&&O!==9&&O!==18){f.default.w(this.TAG,"Unsupported tag type "+O+", skipped"),C+=11+I+4;continue}var P=b.getUint8(4),G=b.getUint8(5),D=b.getUint8(6),V=b.getUint8(7),U=D|G<<8|P<<16|V<<24,q=b.getUint32(7,!S)&16777215;q!==0&&f.default.w(this.TAG,"Meet tag which has StreamID != 0!");var N=C+11;switch(O){case 8:this._parseAudioData(x,N,I,U);break;case 9:this._parseVideoData(x,N,I,U,k+C);break;case 18:this._parseScriptData(x,N,I);break}var J=b.getUint32(11+I,!S);J!==11+I&&f.default.w(this.TAG,"Invalid PrevTagSize "+J),C+=11+I+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),C}},{key:"_parseScriptData",value:function(x,k,C){var S=t.default.parseScriptData(x,k,C);if(S.hasOwnProperty("onMetaData")){if(S.onMetaData==null||R(S.onMetaData)!=="object"){f.default.w(this.TAG,"Invalid onMetaData structure!");return}this._metadata&&f.default.w(this.TAG,"Found another onMetaData tag!"),this._metadata=S;var m=this._metadata.onMetaData;if(typeof m.hasAudio=="boolean"&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=m.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),typeof m.hasVideo=="boolean"&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=m.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),typeof m.audiodatarate=="number"&&(this._mediaInfo.audioDataRate=m.audiodatarate),typeof m.videodatarate=="number"&&(this._mediaInfo.videoDataRate=m.videodatarate),typeof m.width=="number"&&(this._mediaInfo.width=m.width),typeof m.height=="number"&&(this._mediaInfo.height=m.height),typeof m.duration=="number"){if(!this._durationOverrided){var o=Math.floor(m.duration*this._timescale);this._duration=o,this._mediaInfo.duration=o}}else this._mediaInfo.duration=0;if(typeof m.framerate=="number"){var p=Math.floor(m.framerate*1e3);if(p>0){var b=p/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=b,this._referenceFrameRate.fps_num=p,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=b}}if(R(m.keyframes)==="object"){this._mediaInfo.hasKeyframesIndex=!0;var O=m.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(O),m.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=m,f.default.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}}},{key:"_parseKeyframesIndex",value:function(x){for(var k=[],C=[],S=1;S>>4;if(b!==2&&b!==10){this._onError(s.default.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+b);return}var O=0,I=(p&12)>>>2;if(I>=0&&I<=4)O=this._flvSoundRateTable[I];else{this._onError(s.default.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+I);return}var P=(p&2)>>>1,G=p&1,D=this._audioMetadata,V=this._audioTrack;if(D||(this._hasAudio===!1&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),D=this._audioMetadata={},D.type="audio",D.id=V.id,D.timescale=this._timescale,D.duration=this._duration,D.audioSampleRate=O,D.channelCount=G===0?1:2),b===10){var U=this._parseAACAudioData(x,k+1,C-1);if(U==null)return;if(U.packetType===0){D.config&&f.default.w(this.TAG,"Found another AudioSpecificConfig!");var q=U.data;D.audioSampleRate=q.samplingRate,D.channelCount=q.channelCount,D.codec=q.codec,D.originalCodec=q.originalCodec,D.config=q.config,D.refSampleDuration=1024/D.audioSampleRate*D.timescale,f.default.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",D);var N=this._mediaInfo;N.audioCodec=D.originalCodec,N.audioSampleRate=D.audioSampleRate,N.audioChannelCount=D.channelCount,N.hasVideo?N.videoCodec!=null&&(N.mimeType='video/x-flv; codecs="'+N.videoCodec+","+N.audioCodec+'"'):N.mimeType='video/x-flv; codecs="'+N.audioCodec+'"',N.isComplete()&&this._onMediaInfo(N)}else if(U.packetType===1){var J=this._timestampBase+S,$={unit:U.data,length:U.data.byteLength,dts:J,pts:J};V.samples.push($),V.length+=U.data.length}else f.default.e(this.TAG,"Flv: Unsupported AAC data type "+U.packetType)}else if(b===2){if(!D.codec){var W=this._parseMP3AudioData(x,k+1,C-1,!0);if(W==null)return;D.audioSampleRate=W.samplingRate,D.channelCount=W.channelCount,D.codec=W.codec,D.originalCodec=W.originalCodec,D.refSampleDuration=1152/D.audioSampleRate*D.timescale,f.default.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",D);var X=this._mediaInfo;X.audioCodec=D.codec,X.audioSampleRate=D.audioSampleRate,X.audioChannelCount=D.channelCount,X.audioDataRate=W.bitRate,X.hasVideo?X.videoCodec!=null&&(X.mimeType='video/x-flv; codecs="'+X.videoCodec+","+X.audioCodec+'"'):X.mimeType='video/x-flv; codecs="'+X.audioCodec+'"',X.isComplete()&&this._onMediaInfo(X)}var K=this._parseMP3AudioData(x,k+1,C-1,!1);if(K==null)return;var Y=this._timestampBase+S,H={unit:K,length:K.byteLength,dts:Y,pts:Y};V.samples.push(H),V.length+=K.length}}}},{key:"_parseAACAudioData",value:function(x,k,C){if(C<=1){f.default.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");return}var S={},m=new Uint8Array(x,k,C);return S.packetType=m[0],m[0]===0?S.data=this._parseAACAudioSpecificConfig(x,k+1,C-1):S.data=m.subarray(1),S}},{key:"_parseAACAudioSpecificConfig",value:function(x,k,C){var S=new Uint8Array(x,k,C),m=null,o=0,p=0,b=null,O=0,I=null;if(o=p=S[0]>>>3,O=(S[0]&7)<<1|S[1]>>>7,O<0||O>=this._mpegSamplingRates.length){this._onError(s.default.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");return}var P=this._mpegSamplingRates[O],G=(S[1]&120)>>>3;if(G<0||G>=8){this._onError(s.default.FORMAT_ERROR,"Flv: AAC invalid channel configuration");return}o===5&&(I=(S[1]&7)<<1|S[2]>>>7,b=(S[2]&124)>>>2);var D=self.navigator.userAgent.toLowerCase();return D.indexOf("firefox")!==-1?O>=6?(o=5,m=new Array(4),I=O-3):(o=2,m=new Array(2),I=O):D.indexOf("android")!==-1?(o=2,m=new Array(2),I=O):(o=5,I=O,m=new Array(4),O>=6?I=O-3:G===1&&(o=2,m=new Array(2),I=O)),m[0]=o<<3,m[0]|=(O&15)>>>1,m[1]=(O&15)<<7,m[1]|=(G&15)<<3,o===5&&(m[1]|=(I&15)>>>1,m[2]=(I&1)<<7,m[2]|=2<<2,m[3]=0),{config:m,samplingRate:P,channelCount:G,codec:"mp4a.40."+o,originalCodec:"mp4a.40."+p}}},{key:"_parseMP3AudioData",value:function(x,k,C,S){if(C<4){f.default.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");return}var m=this._littleEndian,o=new Uint8Array(x,k,C),p=null;if(S){if(o[0]!==255)return;var b=o[1]>>>3&3,O=(o[1]&6)>>1,I=(o[2]&240)>>>4,P=(o[2]&12)>>>2,G=o[3]>>>6&3,D=G!==3?2:1,V=0,U=0,q=34,N="mp3";switch(b){case 0:V=this._mpegAudioV25SampleRateTable[P];break;case 2:V=this._mpegAudioV20SampleRateTable[P];break;case 3:V=this._mpegAudioV10SampleRateTable[P];break}switch(O){case 1:q=34,I>>4,b=o&15;if(b!==7){this._onError(s.default.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+b);return}this._parseAVCVideoPacket(x,k+1,C-1,S,m,p)}}},{key:"_parseAVCVideoPacket",value:function(x,k,C,S,m,o){if(C<4){f.default.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");return}var p=this._littleEndian,b=new DataView(x,k,C),O=b.getUint8(0),I=b.getUint32(0,!p)&16777215,P=I<<8>>8;if(O===0)this._parseAVCDecoderConfigurationRecord(x,k+4,C-4);else if(O===1)this._parseAVCVideoData(x,k+4,C-4,S,m,o,P);else if(O!==2){this._onError(s.default.FORMAT_ERROR,"Flv: Invalid video packet type "+O);return}}},{key:"_parseAVCDecoderConfigurationRecord",value:function(x,k,C){if(C<7){f.default.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");return}var S=this._videoMetadata,m=this._videoTrack,o=this._littleEndian,p=new DataView(x,k,C);S?typeof S.avcc!="undefined"&&f.default.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(this._hasVideo===!1&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),S=this._videoMetadata={},S.type="video",S.id=m.id,S.timescale=this._timescale,S.duration=this._duration);var b=p.getUint8(0),O=p.getUint8(1),I=p.getUint8(2),P=p.getUint8(3);if(b!==1||O===0){this._onError(s.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");return}if(this._naluLengthSize=(p.getUint8(4)&3)+1,this._naluLengthSize!==3&&this._naluLengthSize!==4){this._onError(s.default.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));return}var G=p.getUint8(5)&31;if(G===0){this._onError(s.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");return}else G>1&&f.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+G);for(var D=6,V=0;V1&&f.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+se);D++;for(var re=0;re=C){f.default.w(this.TAG,"Malformed Nalu near timestamp "+V+", offset = "+G+", dataSize = "+C);break}var q=O.getUint32(G,!b);if(D===3&&(q>>>=8),q>C-D){f.default.w(this.TAG,"Malformed Nalus near timestamp "+V+", NaluSize > DataSize!");return}var N=O.getUint8(G+D)&31;N===5&&(U=!0);var J=new Uint8Array(x,k+G,D+q),$={type:N,data:J};I.push($),P+=J.byteLength,G+=D+q}if(I.length){var W=this._videoTrack,X={units:I,length:P,isKeyframe:U,dts:V,cts:p,pts:V+p};U&&(X.fileposition=m),W.samples.push(X),W.length+=P}}},{key:"onTrackMetadata",get:function(){return this._onTrackMetadata},set:function(x){this._onTrackMetadata=x}},{key:"onMediaInfo",get:function(){return this._onMediaInfo},set:function(x){this._onMediaInfo=x}},{key:"onError",get:function(){return this._onError},set:function(x){this._onError=x}},{key:"onDataAvailable",get:function(){return this._onDataAvailable},set:function(x){this._onDataAvailable=x}},{key:"timestampBase",get:function(){return this._timestampBase},set:function(x){this._timestampBase=x}},{key:"overridedDuration",get:function(){return this._duration},set:function(x){this._durationOverrided=!0,this._duration=x,this._mediaInfo.duration=x}},{key:"overridedHasAudio",set:function(x){this._hasAudioFlagOverrided=!0,this._hasAudio=x,this._mediaInfo.hasAudio=x}},{key:"overridedHasVideo",set:function(x){this._hasVideoFlagOverrided=!0,this._hasVideo=x,this._mediaInfo.hasVideo=x}}],[{key:"probe",value:function(x){var k=new Uint8Array(x),C={match:!1};if(k[0]!==70||k[1]!==76||k[2]!==86||k[3]!==1)return C;var S=(k[4]&4)>>>2!=0,m=(k[4]&1)!=0,o=c(k,5);return o<9?C:{match:!0,consumed:o,dataOffset:o,hasAudioTrack:S,hasVideoTrack:m}}}]),g}();A.default=l},{"../core/media-info.js":7,"../utils/exception.js":40,"../utils/logger.js":41,"./amf-parser.js":15,"./demux-errors.js":16,"./sps-parser.js":19}],19:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function e(n,u){for(var s=0;s=2&&s[v]===3&&s[v-1]===0&&s[v-2]===0||(E[_]=s[v],_++);return new Uint8Array(E.buffer,0,_)}},{key:"parseSPS",value:function(u){var s=e._ebsp2rbsp(u),i=new T.default(s);i.readByte();var E=i.readByte();i.readByte();var _=i.readByte();i.readUEG();var v=e.getProfileString(E),d=e.getLevelString(_),a=1,r=420,c=[0,420,422,444],l=8;if((E===100||E===110||E===122||E===244||E===44||E===83||E===86||E===118||E===128||E===138||E===144)&&(a=i.readUEG(),a===3&&i.readBits(1),a<=3&&(r=c[a]),l=i.readUEG()+8,i.readUEG(),i.readBits(1),i.readBool()))for(var g=a!==3?8:12,y=0;y0&&W<16?(D=X[W-1],V=K[W-1]):W===255&&(D=i.readByte()<<8|i.readByte(),V=i.readByte()<<8|i.readByte())}if(i.readBool()&&i.readBool(),i.readBool()&&(i.readBits(4),i.readBool()&&i.readBits(24)),i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool()){var Y=i.readBits(32),H=i.readBits(32);q=i.readBool(),N=H,J=Y*2,U=N/J}}var se=1;(D!==1||V!==1)&&(se=D/V);var re=0,ee=0;if(a===0)re=1,ee=2-p;else{var ie=a===3?1:2,he=a===1?2:1;re=ie,ee=he*(2-p)}var ue=(m+1)*16,te=(2-p)*((o+1)*16);ue-=(b+O)*re,te-=(I+P)*ee;var oe=Math.ceil(ue*se);return i.destroy(),i=null,{profile_string:v,level_string:d,bit_depth:l,ref_frames:S,chroma_format:r,chroma_format_string:e.getChromaFormatString(r),frame_rate:{fixed:q,fps:U,fps_den:J,fps_num:N},sar_ratio:{width:D,height:V},codec_size:{width:ue,height:te},present_size:{width:oe,height:te}}}},{key:"_skipScalingList",value:function(u,s){for(var i=8,E=8,_=0,v=0;v=15048,l=e.default.msedge?c:!0;return self.fetch&&self.ReadableStream&&l}catch(g){return!1}}}]);function a(r,c){i(this,a);var l=E(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,"fetch-stream-loader"));return l.TAG="FetchStreamLoader",l._seekHandler=r,l._config=c,l._needStash=!0,l._requestAbort=!1,l._contentLength=null,l._receivedLength=0,l}return T(a,[{key:"destroy",value:function(){this.isWorking()&&this.abort(),F(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"destroy",this).call(this)}},{key:"open",value:function(c,l){var g=this;this._dataSource=c,this._range=l;var y=c.url;this._config.reuseRedirectedURL&&c.redirectedURL!=null&&(y=c.redirectedURL);var x=this._seekHandler.getConfig(y,l),k=new self.Headers;if(R(x.headers)==="object"){var C=x.headers;for(var S in C)C.hasOwnProperty(S)&&k.append(S,C[S])}var m={method:"GET",headers:k,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};c.cors===!1&&(m.mode="same-origin"),c.withCredentials&&(m.credentials="include"),c.referrerPolicy&&(m.referrerPolicy=c.referrerPolicy),this._status=n.LoaderStatus.kConnecting,self.fetch(x.url,m).then(function(o){if(g._requestAbort){g._requestAbort=!1,g._status=n.LoaderStatus.kIdle;return}if(o.ok&&o.status>=200&&o.status<=299){if(o.url!==x.url&&g._onURLRedirect){var p=g._seekHandler.removeURLParameters(o.url);g._onURLRedirect(p)}var b=o.headers.get("Content-Length");return b!=null&&(g._contentLength=parseInt(b),g._contentLength!==0&&g._onContentLengthKnown&&g._onContentLengthKnown(g._contentLength)),g._pump.call(g,o.body.getReader())}else if(g._status=n.LoaderStatus.kError,g._onError)g._onError(n.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:o.status,msg:o.statusText});else throw new u.RuntimeException("FetchStreamLoader: Http code invalid, "+o.status+" "+o.statusText)}).catch(function(o){if(g._status=n.LoaderStatus.kError,g._onError)g._onError(n.LoaderErrors.EXCEPTION,{code:-1,msg:o.message});else throw o})}},{key:"abort",value:function(){this._requestAbort=!0}},{key:"_pump",value:function(c){var l=this;return c.read().then(function(g){if(g.done)l._status=n.LoaderStatus.kComplete,l._onComplete&&l._onComplete(l._range.from,l._range.from+l._receivedLength-1);else{if(l._requestAbort===!0)return l._requestAbort=!1,l._status=n.LoaderStatus.kComplete,c.cancel();l._status=n.LoaderStatus.kBuffering;var y=g.value.buffer,x=l._range.from+l._receivedLength;l._receivedLength+=y.byteLength,l._onDataArrival&&l._onDataArrival(y,x,l._receivedLength),l._pump(c)}}).catch(function(g){if(!(g.code===11&&e.default.msedge)){l._status=n.LoaderStatus.kError;var y=0,x=null;if((g.code===19||g.message==="network error")&&(l._contentLength===null||l._contentLength!==null&&l._receivedLength0&&(this._stashInitialSize=o.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=1024*1024*3,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,o.enableStashBuffer===!1&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=m,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(m.url),this._refTotalLength=m.filesize?m.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new h.default,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}return R(S,[{key:"destroy",value:function(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null}},{key:"isWorking",value:function(){return this._loader&&this._loader.isWorking()&&!this._paused}},{key:"isPaused",value:function(){return this._paused}},{key:"_selectSeekHandler",value:function(){var o=this._config;if(o.seekType==="range")this._seekHandler=new c.default(this._config.rangeLoadZeroStart);else if(o.seekType==="param"){var p=o.seekParamStart||"bstart",b=o.seekParamEnd||"bend";this._seekHandler=new g.default(p,b)}else if(o.seekType==="custom"){if(typeof o.customSeekHandler!="function")throw new y.InvalidArgumentException("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new o.customSeekHandler}else throw new y.InvalidArgumentException("Invalid seekType in config: "+o.seekType)}},{key:"_selectLoader",value:function(){if(this._isWebSocketURL)this._loaderClass=a.default;else if(n.default.isSupported())this._loaderClass=n.default;else if(s.default.isSupported())this._loaderClass=s.default;else if(v.default.isSupported())this._loaderClass=v.default;else throw new y.RuntimeException("Your browser doesn't support xhr with arraybuffer responseType!")}},{key:"_createLoader",value:function(){this._loader=new this._loaderClass(this._seekHandler,this._config),this._loader.needStashBuffer===!1&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)}},{key:"open",value:function(o){this._currentRange={from:0,to:-1},o&&(this._currentRange.from=o),this._speedSampler.reset(),o||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))}},{key:"abort",value:function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)}},{key:"pause",value:function(){this.isWorking()&&(this._loader.abort(),this._stashUsed!==0?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)}},{key:"resume",value:function(){if(this._paused){this._paused=!1;var o=this._resumeFrom;this._resumeFrom=0,this._internalSeek(o,!0)}}},{key:"seek",value:function(o){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(o,!0)}},{key:"_internalSeek",value:function(o,p){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(p),this._loader.destroy(),this._loader=null;var b={from:o,to:-1};this._currentRange={from:b.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,b),this._onSeeked&&this._onSeeked()}},{key:"updateUrl",value:function(o){if(!o||typeof o!="string"||o.length===0)throw new y.InvalidArgumentException("Url must be a non-empty string!");this._dataSource.url=o}},{key:"_expandBuffer",value:function(o){for(var p=this._stashSize;p+1024*1024*10){var O=new Uint8Array(this._stashBuffer,0,this._stashUsed),I=new Uint8Array(b,0,p);I.set(O,0)}this._stashBuffer=b,this._bufferSize=p}}},{key:"_normalizeSpeed",value:function(o){var p=this._speedNormalizeList,b=p.length-1,O=0,I=0,P=b;if(o=p[O]&&o=512&&o<=1024?p=Math.floor(o*1.5):p=o*2,p>8192&&(p=8192);var b=p*1024+1024*1024*1;this._bufferSize0){var $=this._stashBuffer.slice(0,this._stashUsed),W=this._dispatchChunks($,this._stashByteStart);if(W<$.byteLength){if(W>0){var X=new Uint8Array($,W);J.set(X,0),this._stashUsed=X.byteLength,this._stashByteStart+=W}}else this._stashUsed=0,this._stashByteStart+=W;this._stashUsed+o.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+o.byteLength),J=new Uint8Array(this._stashBuffer,0,this._bufferSize)),J.set(new Uint8Array(o),this._stashUsed),this._stashUsed+=o.byteLength}else{var K=this._dispatchChunks(o,p);if(Kthis._bufferSize&&(this._expandBuffer(Y),J=new Uint8Array(this._stashBuffer,0,this._bufferSize)),J.set(new Uint8Array(o,K),0),this._stashUsed+=Y,this._stashByteStart=p+K}}}else if(this._stashUsed===0){var P=this._dispatchChunks(o,p);if(Pthis._bufferSize&&this._expandBuffer(G);var D=new Uint8Array(this._stashBuffer,0,this._bufferSize);D.set(new Uint8Array(o,P),0),this._stashUsed+=G,this._stashByteStart=p+P}}else{this._stashUsed+o.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+o.byteLength);var V=new Uint8Array(this._stashBuffer,0,this._bufferSize);V.set(new Uint8Array(o),this._stashUsed),this._stashUsed+=o.byteLength;var U=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(U0){var q=new Uint8Array(this._stashBuffer,U);V.set(q,0)}this._stashUsed-=U,this._stashByteStart+=U}}}},{key:"_flushStashBuffer",value:function(o){if(this._stashUsed>0){var p=this._stashBuffer.slice(0,this._stashUsed),b=this._dispatchChunks(p,this._stashByteStart),O=p.byteLength-b;if(b0){var I=new Uint8Array(this._stashBuffer,0,this._bufferSize),P=new Uint8Array(p,b);I.set(P,0),this._stashUsed=P.byteLength,this._stashByteStart+=b}return 0}return this._stashUsed=0,this._stashByteStart=0,O}return 0}},{key:"_onLoaderComplete",value:function(o,p){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}},{key:"_onLoaderError",value:function(o,p){switch(T.default.e(this.TAG,"Loader error, code = "+p.code+", msg = "+p.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,o=t.LoaderErrors.UNRECOVERABLE_EARLY_EOF),o){case t.LoaderErrors.EARLY_EOF:{if(!this._config.isLive&&this._totalLength){var b=this._currentRange.to+1;b0)for(var i=n.split("&"),E=0;E0;_[0]!==this._startName&&_[0]!==this._endName&&(v&&(s+="&"),s+=i[E])}return s.length===0?e:e+"?"+s}}]),f}();A.default=T},{}],26:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function f(h,t){for(var e=0;e=500?this.currentKBps:0}},{key:"averageKBps",get:function(){var t=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/t/1024}}]),f}();A.default=T},{}],28:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function E(_,v,d){_===null&&(_=Function.prototype);var a=Object.getOwnPropertyDescriptor(_,v);if(a===void 0){var r=Object.getPrototypeOf(_);return r===null?void 0:E(r,v,d)}else{if("value"in a)return a.value;var c=a.get;return c===void 0?void 0:c.call(d)}},F=function(){function E(_,v){for(var d=0;d299))if(this._status=t.LoaderStatus.kError,this._onError)this._onError(t.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:r.status,msg:r.statusText});else throw new e.RuntimeException("MozChunkedLoader: Http code invalid, "+r.status+" "+r.statusText);else this._status=t.LoaderStatus.kBuffering}}},{key:"_onProgress",value:function(a){if(this._status!==t.LoaderStatus.kError){this._contentLength===null&&a.total!==null&&a.total!==0&&(this._contentLength=a.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var r=a.target.response,c=this._range.from+this._receivedLength;this._receivedLength+=r.byteLength,this._onDataArrival&&this._onDataArrival(r,c,this._receivedLength)}}},{key:"_onLoadEnd",value:function(a){if(this._requestAbort===!0){this._requestAbort=!1;return}else if(this._status===t.LoaderStatus.kError)return;this._status=t.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)}},{key:"_onXhrError",value:function(a){this._status=t.LoaderStatus.kError;var r=0,c=null;if(this._contentLength&&a.loaded=200&&r.status<=299){if(this._status=t.LoaderStatus.kBuffering,r.responseURL!=null){var c=this._seekHandler.removeURLParameters(r.responseURL);r.responseURL!==this._currentRequestURL&&c!==this._currentRedirectedURL&&(this._currentRedirectedURL=c,this._onURLRedirect&&this._onURLRedirect(c))}var l=r.getResponseHeader("Content-Length");if(l!=null&&this._contentLength==null){var g=parseInt(l);g>0&&(this._contentLength=g,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength))}}else if(this._status=t.LoaderStatus.kError,this._onError)this._onError(t.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:r.status,msg:r.statusText});else throw new e.RuntimeException("MSStreamLoader: Http code invalid, "+r.status+" "+r.statusText);else if(r.readyState===3&&r.status>=200&&r.status<=299){this._status=t.LoaderStatus.kBuffering;var y=r.response;this._reader.readAsArrayBuffer(y)}}},{key:"_xhrOnError",value:function(a){this._status=t.LoaderStatus.kError;var r=t.LoaderErrors.EXCEPTION,c={code:-1,msg:a.constructor.name+" "+a.type};if(this._onError)this._onError(r,c);else throw new e.RuntimeException(c.msg)}},{key:"_msrOnProgress",value:function(a){var r=a.target,c=r.result;if(c==null){this._doReconnectIfNeeded();return}var l=c.slice(this._lastTimeBufferSize);this._lastTimeBufferSize=c.byteLength;var g=this._totalRange.from+this._receivedLength;this._receivedLength+=l.byteLength,this._onDataArrival&&this._onDataArrival(l,g,this._receivedLength),c.byteLength>=this._bufferLimit&&(h.default.v(this.TAG,"MSStream buffer exceeded max size near "+(g+l.byteLength)+", reconnecting..."),this._doReconnectIfNeeded())}},{key:"_doReconnectIfNeeded",value:function(){if(this._contentLength==null||this._receivedLength=this._contentLength&&(g=this._range.from+this._contentLength-1),this._currentRequestRange={from:l,to:g},this._internalOpen(this._dataSource,this._currentRequestRange)}},{key:"_internalOpen",value:function(c,l){this._lastTimeLoaded=0;var g=c.url;this._config.reuseRedirectedURL&&(this._currentRedirectedURL!=null?g=this._currentRedirectedURL:c.redirectedURL!=null&&(g=c.redirectedURL));var y=this._seekHandler.getConfig(g,l);this._currentRequestURL=y.url;var x=this._xhr=new XMLHttpRequest;if(x.open("GET",y.url,!0),x.responseType="arraybuffer",x.onreadystatechange=this._onReadyStateChange.bind(this),x.onprogress=this._onProgress.bind(this),x.onload=this._onLoad.bind(this),x.onerror=this._onXhrError.bind(this),c.withCredentials&&(x.withCredentials=!0),R(y.headers)==="object"){var k=y.headers;for(var C in k)k.hasOwnProperty(C)&&x.setRequestHeader(C,k[C])}x.send()}},{key:"abort",value:function(){this._requestAbort=!0,this._internalAbort(),this._status=n.LoaderStatus.kComplete}},{key:"_internalAbort",value:function(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)}},{key:"_onReadyStateChange",value:function(c){var l=c.target;if(l.readyState===2){if(l.responseURL!=null){var g=this._seekHandler.removeURLParameters(l.responseURL);l.responseURL!==this._currentRequestURL&&g!==this._currentRedirectedURL&&(this._currentRedirectedURL=g,this._onURLRedirect&&this._onURLRedirect(g))}if(l.status>=200&&l.status<=299){if(this._waitForTotalLength)return;this._status=n.LoaderStatus.kBuffering}else if(this._status=n.LoaderStatus.kError,this._onError)this._onError(n.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:l.status,msg:l.statusText});else throw new u.RuntimeException("RangeLoader: Http code invalid, "+l.status+" "+l.statusText)}}},{key:"_onProgress",value:function(c){if(this._status!==n.LoaderStatus.kError){if(this._contentLength===null){var l=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,l=!0;var g=c.total;this._internalAbort(),g!=null&g!==0&&(this._totalLength=g)}if(this._range.to===-1?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,l){this._openSubRange();return}this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var y=c.loaded-this._lastTimeLoaded;this._lastTimeLoaded=c.loaded,this._speedSampler.addBytes(y)}}},{key:"_normalizeSpeed",value:function(c){var l=this._chunkSizeKBList,g=l.length-1,y=0,x=0,k=g;if(c=l[y]&&c=3&&(l=this._speedSampler.currentKBps)),l!==0){var g=this._normalizeSpeed(l);this._currentSpeedNormalized!==g&&(this._currentSpeedNormalized=g,this._currentChunkSizeKB=g)}var y=c.target.response,x=this._range.from+this._receivedLength;this._receivedLength+=y.byteLength;var k=!1;this._contentLength!=null&&this._receivedLength0&&this._receivedLength0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new E.default(this._mediaDataSource,this._config),this._transmuxer.on(v.default.INIT_SEGMENT,function(p,b){o._msectl.appendInitSegment(b)}),this._transmuxer.on(v.default.MEDIA_SEGMENT,function(p,b){if(o._msectl.appendMediaSegment(b),o._config.lazyLoad&&!o._config.isLive){var O=o._mediaElement.currentTime;b.info.endDts>=(O+o._config.lazyLoadMaxDuration)*1e3&&o._progressChecker==null&&(t.default.v(o.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),o._suspendTransmuxer())}}),this._transmuxer.on(v.default.LOADING_COMPLETE,function(){o._msectl.endOfStream(),o._emitter.emit(s.default.LOADING_COMPLETE)}),this._transmuxer.on(v.default.RECOVERED_EARLY_EOF,function(){o._emitter.emit(s.default.RECOVERED_EARLY_EOF)}),this._transmuxer.on(v.default.IO_ERROR,function(p,b){o._emitter.emit(s.default.ERROR,l.ErrorTypes.NETWORK_ERROR,p,b)}),this._transmuxer.on(v.default.DEMUX_ERROR,function(p,b){o._emitter.emit(s.default.ERROR,l.ErrorTypes.MEDIA_ERROR,p,{code:-1,msg:b})}),this._transmuxer.on(v.default.MEDIA_INFO,function(p){o._mediaInfo=p,o._emitter.emit(s.default.MEDIA_INFO,Object.assign({},p))}),this._transmuxer.on(v.default.STATISTICS_INFO,function(p){o._statisticsInfo=o._fillStatisticsInfo(p),o._emitter.emit(s.default.STATISTICS_INFO,Object.assign({},o._statisticsInfo))}),this._transmuxer.on(v.default.RECOMMEND_SEEKPOINT,function(p){o._mediaElement&&!o._config.accurateSeek&&(o._requestSetTime=!0,o._mediaElement.currentTime=p/1e3)}),this._transmuxer.open()}}},{key:"unload",value:function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)}},{key:"play",value:function(){return this._mediaElement.play()}},{key:"pause",value:function(){this._mediaElement.pause()}},{key:"_fillStatisticsInfo",value:function(o){if(o.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return o;var p=!0,b=0,O=0;if(this._mediaElement.getVideoPlaybackQuality){var I=this._mediaElement.getVideoPlaybackQuality();b=I.totalVideoFrames,O=I.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(b=this._mediaElement.webkitDecodedFrameCount,O=this._mediaElement.webkitDroppedFrameCount):p=!1;return p&&(o.decodedFrames=b,o.droppedFrames=O),o}},{key:"_onmseUpdateEnd",value:function(){if(!(!this._config.lazyLoad||this._config.isLive)){for(var o=this._mediaElement.buffered,p=this._mediaElement.currentTime,b=0,O=0,I=0;I=p+this._config.lazyLoadMaxDuration&&this._progressChecker==null&&(t.default.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}},{key:"_onmseBufferFull",value:function(){t.default.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),this._progressChecker==null&&this._suspendTransmuxer()}},{key:"_suspendTransmuxer",value:function(){this._transmuxer&&(this._transmuxer.pause(),this._progressChecker==null&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))}},{key:"_checkProgressAndResume",value:function(){for(var o=this._mediaElement.currentTime,p=this._mediaElement.buffered,b=!1,O=0;O=I&&o=P-this._config.lazyLoadRecoverDuration&&(b=!0);break}}b&&(window.clearInterval(this._progressChecker),this._progressChecker=null,b&&(t.default.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}},{key:"_isTimepointBuffered",value:function(o){for(var p=this._mediaElement.buffered,b=0;b=O&&o0){var I=this._mediaElement.buffered.start(0);(I<1&&o0&&p.currentTime0){var O=b.start(0);if(O<1&&p0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)}},{key:"unload",value:function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),this._statisticsReporter!=null&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}},{key:"play",value:function(){return this._mediaElement.play()}},{key:"pause",value:function(){this._mediaElement.pause()}},{key:"_onvLoadedMetadata",value:function(v){this._pendingSeekTime!=null&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(t.default.MEDIA_INFO,this.mediaInfo)}},{key:"_reportStatisticsInfo",value:function(){this._emitter.emit(t.default.STATISTICS_INFO,this.statisticsInfo)}},{key:"type",get:function(){return this._type}},{key:"buffered",get:function(){return this._mediaElement.buffered}},{key:"duration",get:function(){return this._mediaElement.duration}},{key:"volume",get:function(){return this._mediaElement.volume},set:function(v){this._mediaElement.volume=v}},{key:"muted",get:function(){return this._mediaElement.muted},set:function(v){this._mediaElement.muted=v}},{key:"currentTime",get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(v){this._mediaElement?this._mediaElement.currentTime=v:this._pendingSeekTime=v}},{key:"mediaInfo",get:function(){var v=this._mediaElement instanceof HTMLAudioElement?"audio/":"video/",d={mimeType:v+this._mediaDataSource.type};return this._mediaElement&&(d.duration=Math.floor(this._mediaElement.duration*1e3),this._mediaElement instanceof HTMLVideoElement&&(d.width=this._mediaElement.videoWidth,d.height=this._mediaElement.videoHeight)),d}},{key:"statisticsInfo",get:function(){var v={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return v;var d=!0,a=0,r=0;if(this._mediaElement.getVideoPlaybackQuality){var c=this._mediaElement.getVideoPlaybackQuality();a=c.totalVideoFrames,r=c.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(a=this._mediaElement.webkitDecodedFrameCount,r=this._mediaElement.webkitDroppedFrameCount):d=!1;return d&&(v.decodedFrames=a,v.droppedFrames=r),v}}]),E}();A.default=i},{"../config.js":5,"../utils/exception.js":40,"./player-events.js":35,events:2}],34:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0}),A.ErrorDetails=A.ErrorTypes=void 0;var R=L("../io/loader.js"),F=L("../demux/demux-errors.js"),T=f(F);function f(e){return e&&e.__esModule?e:{default:e}}var h=A.ErrorTypes={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},t=A.ErrorDetails={NETWORK_EXCEPTION:R.LoaderErrors.EXCEPTION,NETWORK_STATUS_CODE_INVALID:R.LoaderErrors.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:R.LoaderErrors.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:R.LoaderErrors.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:T.default.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:T.default.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:T.default.CODEC_UNSUPPORTED}},{"../demux/demux-errors.js":16,"../io/loader.js":24}],35:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",STATISTICS_INFO:"statistics_info"};A.default=R},{}],36:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function f(h,t){for(var e=0;e>>24&255,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=e&255,n.set(t,4);for(var E=8,_=0;_>>24&255,t>>>16&255,t>>>8&255,t&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}},{key:"trak",value:function(t){return f.box(f.types.trak,f.tkhd(t),f.mdia(t))}},{key:"tkhd",value:function(t){var e=t.id,n=t.duration,u=t.presentWidth,s=t.presentHeight;return f.box(f.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,e&255,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,n&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,u>>>8&255,u&255,0,0,s>>>8&255,s&255,0,0]))}},{key:"mdia",value:function(t){return f.box(f.types.mdia,f.mdhd(t),f.hdlr(t),f.minf(t))}},{key:"mdhd",value:function(t){var e=t.timescale,n=t.duration;return f.box(f.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,e&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,85,196,0,0]))}},{key:"hdlr",value:function(t){var e=null;return t.type==="audio"?e=f.constants.HDLR_AUDIO:e=f.constants.HDLR_VIDEO,f.box(f.types.hdlr,e)}},{key:"minf",value:function(t){var e=null;return t.type==="audio"?e=f.box(f.types.smhd,f.constants.SMHD):e=f.box(f.types.vmhd,f.constants.VMHD),f.box(f.types.minf,e,f.dinf(),f.stbl(t))}},{key:"dinf",value:function(){var t=f.box(f.types.dinf,f.box(f.types.dref,f.constants.DREF));return t}},{key:"stbl",value:function(t){var e=f.box(f.types.stbl,f.stsd(t),f.box(f.types.stts,f.constants.STTS),f.box(f.types.stsc,f.constants.STSC),f.box(f.types.stsz,f.constants.STSZ),f.box(f.types.stco,f.constants.STCO));return e}},{key:"stsd",value:function(t){return t.type==="audio"?t.codec==="mp3"?f.box(f.types.stsd,f.constants.STSD_PREFIX,f.mp3(t)):f.box(f.types.stsd,f.constants.STSD_PREFIX,f.mp4a(t)):f.box(f.types.stsd,f.constants.STSD_PREFIX,f.avc1(t))}},{key:"mp3",value:function(t){var e=t.channelCount,n=t.audioSampleRate,u=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e,0,16,0,0,0,0,n>>>8&255,n&255,0,0]);return f.box(f.types[".mp3"],u)}},{key:"mp4a",value:function(t){var e=t.channelCount,n=t.audioSampleRate,u=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e,0,16,0,0,0,0,n>>>8&255,n&255,0,0]);return f.box(f.types.mp4a,u,f.esds(t))}},{key:"esds",value:function(t){var e=t.config||[],n=e.length,u=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(e).concat([6,1,2]));return f.box(f.types.esds,u)}},{key:"avc1",value:function(t){var e=t.avcc,n=t.codecWidth,u=t.codecHeight,s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,n>>>8&255,n&255,u>>>8&255,u&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return f.box(f.types.avc1,s,f.box(f.types.avcC,e))}},{key:"mvex",value:function(t){return f.box(f.types.mvex,f.trex(t))}},{key:"trex",value:function(t){var e=t.id,n=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return f.box(f.types.trex,n)}},{key:"moof",value:function(t,e){return f.box(f.types.moof,f.mfhd(t.sequenceNumber),f.traf(t,e))}},{key:"mfhd",value:function(t){var e=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,t&255]);return f.box(f.types.mfhd,e)}},{key:"traf",value:function(t,e){var n=t.id,u=f.box(f.types.tfhd,new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,n&255])),s=f.box(f.types.tfdt,new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,e&255])),i=f.sdtp(t),E=f.trun(t,i.byteLength+16+16+8+16+8+8);return f.box(f.types.traf,u,s,E,i)}},{key:"sdtp",value:function(t){for(var e=t.samples||[],n=e.length,u=new Uint8Array(4+n),s=0;s>>24&255,u>>>16&255,u>>>8&255,u&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0);for(var E=0;E>>24&255,_>>>16&255,_>>>8&255,_&255,v>>>24&255,v>>>16&255,v>>>8&255,v&255,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.isNonSync,0,0,a>>>24&255,a>>>16&255,a>>>8&255,a&255],12+16*E)}return f.box(f.types.trun,i)}},{key:"mdat",value:function(t){return f.box(f.types.mdat,t)}}]),f}();T.init(),A.default=T},{}],38:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function d(a,r){for(var c=0;c1&&(P=g.pop(),I-=P.length),this._audioStashedLastSample!=null){var G=this._audioStashedLastSample;this._audioStashedLastSample=null,g.unshift(G),I+=G.length}P!=null&&(this._audioStashedLastSample=P);var D=g[0].dts-this._dtsBase;if(this._audioNextDts)y=D-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())y=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&this._audioMeta.originalCodec!=="mp3"&&(p=!0);else{var V=this._audioSegmentInfoList.getLastSampleBefore(D);if(V!=null){var U=D-(V.originalDts+V.duration);U<=3&&(U=0);var q=V.dts+V.duration+U;y=D-q}else y=0}if(p){var N=D-y,J=this._videoSegmentInfoList.getLastSegmentBefore(D);if(J!=null&&J.beginDts=1?ie=K[K.length-1].duration:ie=Math.floor(S);var te=!1,oe=null;if(ie>S*1.5&&this._audioMeta.codec!=="mp3"&&this._fillAudioTimestampGap&&!u.default.safari){te=!0;var ce=Math.abs(ie-S),ve=Math.ceil(ce/S),le=ee+S;T.default.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync. `+("dts: "+(ee+ie)+" ms, expected: "+(ee+Math.round(S))+" ms, ")+("delta: "+Math.round(ce)+" ms, generate: "+ve+" frames"));var _e=e.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);_e==null&&(T.default.w(this.TAG,"Unable to generate silent frame for "+(this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame")),_e=se),oe=[];for(var ge=0;ge0){var pe=oe[oe.length-1];pe.duration=me-pe.dts}var Ee={dts:me,pts:me,cts:0,unit:_e,size:_e.byteLength,duration:0,originalDts:re,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};oe.push(Ee),I+=se.byteLength,le+=S}var ye=oe[oe.length-1];ye.duration=ee+ie-ye.dts,ie=Math.round(S)}K.push({dts:ee,pts:ee,cts:0,unit:H.unit,size:H.unit.byteLength,duration:ie,originalDts:re,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),te&&K.push.apply(K,oe)}m?O=new Uint8Array(I):(O=new Uint8Array(I),O[0]=I>>>24&255,O[1]=I>>>16&255,O[2]=I>>>8&255,O[3]=I&255,O.set(h.default.types.mdat,4));for(var ne=0;ne1&&(b=g.pop(),p-=b.length),this._videoStashedLastSample!=null){var O=this._videoStashedLastSample;this._videoStashedLastSample=null,g.unshift(O),p+=O.length}b!=null&&(this._videoStashedLastSample=b);var I=g[0].dts-this._dtsBase;if(this._videoNextDts)y=I-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())y=0;else{var P=this._videoSegmentInfoList.getLastSampleBefore(I);if(P!=null){var G=I-(P.originalDts+P.duration);G<=3&&(G=0);var D=P.dts+P.duration+G;y=I-D}else y=0}for(var V=new s.MediaSegmentInfo,U=[],q=0;q=1?Y=U[U.length-1].duration:Y=Math.floor(this._videoMeta.refSampleDuration);if($){var re=new s.SampleInfo(W,K,Y,N.dts,!0);re.fileposition=N.fileposition,V.appendSyncPoint(re)}U.push({dts:W,pts:K,cts:X,units:N.units,size:N.length,isKeyframe:$,duration:Y,originalDts:J,flags:{isLeading:0,dependsOn:$?2:1,isDependedOn:$?1:0,hasRedundancy:0,isNonSync:$?0:1}})}o=new Uint8Array(p),o[0]=p>>>24&255,o[1]=p>>>16&255,o[2]=p>>>8&255,o[3]=p&255,o.set(h.default.types.mdat,4);for(var ee=0;ee=0&&/(rv)(?::| )([\w.]+)/.exec(T)||T.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(T)||[],h=/(ipad)/.exec(T)||/(ipod)/.exec(T)||/(windows phone)/.exec(T)||/(iphone)/.exec(T)||/(kindle)/.exec(T)||/(android)/.exec(T)||/(windows)/.exec(T)||/(mac)/.exec(T)||/(linux)/.exec(T)||/(cros)/.exec(T)||[],t={browser:f[5]||f[3]||f[1]||"",version:f[2]||f[4]||"0",majorVersion:f[4]||f[2]||"0",platform:h[0]||""},e={};if(t.browser){e[t.browser]=!0;var n=t.majorVersion.split(".");e.version={major:parseInt(t.majorVersion,10),string:t.version},n.length>1&&(e.version.minor=parseInt(n[1],10)),n.length>2&&(e.version.build=parseInt(n[2],10))}if(t.platform&&(e[t.platform]=!0),(e.chrome||e.opr||e.safari)&&(e.webkit=!0),e.rv||e.iemobile){e.rv&&delete e.rv;var u="msie";t.browser=u,e[u]=!0}if(e.edge){delete e.edge;var s="msedge";t.browser=s,e[s]=!0}if(e.opr){var i="opera";t.browser=i,e[i]=!0}if(e.safari&&e.android){var E="android";t.browser=E,e[E]=!0}e.name=t.browser,e.platform=t.platform;for(var _ in R)R.hasOwnProperty(_)&&delete R[_];Object.assign(R,e)}F(),A.default=R},{}],40:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function u(s,i){for(var E=0;E "+s;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",i),!!e.ENABLE_ERROR&&(console.error?console.error(i):console.warn?console.warn(i):console.log(i))}},{key:"i",value:function(u,s){(!u||e.FORCE_GLOBAL_TAG)&&(u=e.GLOBAL_TAG);var i="["+u+"] > "+s;e.ENABLE_CALLBACK&&e.emitter.emit("log","info",i),!!e.ENABLE_INFO&&(console.info?console.info(i):console.log(i))}},{key:"w",value:function(u,s){(!u||e.FORCE_GLOBAL_TAG)&&(u=e.GLOBAL_TAG);var i="["+u+"] > "+s;e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",i),!!e.ENABLE_WARN&&(console.warn?console.warn(i):console.log(i))}},{key:"d",value:function(u,s){(!u||e.FORCE_GLOBAL_TAG)&&(u=e.GLOBAL_TAG);var i="["+u+"] > "+s;e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",i),!!e.ENABLE_DEBUG&&(console.debug?console.debug(i):console.log(i))}},{key:"v",value:function(u,s){(!u||e.FORCE_GLOBAL_TAG)&&(u=e.GLOBAL_TAG);var i="["+u+"] > "+s;e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",i),!!e.ENABLE_VERBOSE&&console.log(i)}}]),e}();t.GLOBAL_TAG="flv.js",t.FORCE_GLOBAL_TAG=!1,t.ENABLE_ERROR=!0,t.ENABLE_INFO=!0,t.ENABLE_WARN=!0,t.ENABLE_DEBUG=!0,t.ENABLE_VERBOSE=!0,t.ENABLE_CALLBACK=!1,t.emitter=new T.default,A.default=t},{events:2}],42:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function u(s,i){for(var E=0;E0){var E=u.getConfig();i.emit("change",E)}}},{key:"registerListener",value:function(i){u.emitter.addListener("change",i)}},{key:"removeListener",value:function(i){u.emitter.removeListener("change",i)}},{key:"addLogListener",value:function(i){h.default.emitter.addListener("log",i),h.default.emitter.listenerCount("log")>0&&(h.default.ENABLE_CALLBACK=!0,u._notifyChange())}},{key:"removeLogListener",value:function(i){h.default.emitter.removeListener("log",i),h.default.emitter.listenerCount("log")===0&&(h.default.ENABLE_CALLBACK=!1,u._notifyChange())}},{key:"forceGlobalTag",get:function(){return h.default.FORCE_GLOBAL_TAG},set:function(i){h.default.FORCE_GLOBAL_TAG=i,u._notifyChange()}},{key:"globalTag",get:function(){return h.default.GLOBAL_TAG},set:function(i){h.default.GLOBAL_TAG=i,u._notifyChange()}},{key:"enableAll",get:function(){return h.default.ENABLE_VERBOSE&&h.default.ENABLE_DEBUG&&h.default.ENABLE_INFO&&h.default.ENABLE_WARN&&h.default.ENABLE_ERROR},set:function(i){h.default.ENABLE_VERBOSE=i,h.default.ENABLE_DEBUG=i,h.default.ENABLE_INFO=i,h.default.ENABLE_WARN=i,h.default.ENABLE_ERROR=i,u._notifyChange()}},{key:"enableDebug",get:function(){return h.default.ENABLE_DEBUG},set:function(i){h.default.ENABLE_DEBUG=i,u._notifyChange()}},{key:"enableVerbose",get:function(){return h.default.ENABLE_VERBOSE},set:function(i){h.default.ENABLE_VERBOSE=i,u._notifyChange()}},{key:"enableInfo",get:function(){return h.default.ENABLE_INFO},set:function(i){h.default.ENABLE_INFO=i,u._notifyChange()}},{key:"enableWarn",get:function(){return h.default.ENABLE_WARN},set:function(i){h.default.ENABLE_WARN=i,u._notifyChange()}},{key:"enableError",get:function(){return h.default.ENABLE_ERROR},set:function(i){h.default.ENABLE_ERROR=i,u._notifyChange()}}]),u}();n.emitter=new T.default,A.default=n},{"./logger.js":41,events:2}],43:[function(L,j,A){"use strict";Object.defineProperty(A,"__esModule",{value:!0});var R=function(){function f(h,t){for(var e=0;e=128){f.push(String.fromCharCode(n&65535)),t+=2;continue}}}else if(h[t]<240){if(R(h,t,2)){var u=(h[t]&15)<<12|(h[t+1]&63)<<6|h[t+2]&63;if(u>=2048&&(u&63488)!=55296){f.push(String.fromCharCode(u&65535)),t+=3;continue}}}else if(h[t]<248&&R(h,t,3)){var s=(h[t]&7)<<18|(h[t+1]&63)<<12|(h[t+2]&63)<<6|h[t+3]&63;if(s>65536&&s<1114112){s-=65536,f.push(String.fromCharCode(s>>>10|55296)),f.push(String.fromCharCode(s&1023|56320)),t+=4;continue}}}f.push(String.fromCharCode(65533)),++t}return f.join("")}A.default=F},{}]},{},[21])(21)});