(function(fe){if(typeof exports=="object"&&typeof module!="undefined")module.exports=fe();else if(typeof define=="function"&&define.amd)define([],fe);else{var R;R=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:this,R.flvjs=fe()}})(function(){var fe;return function R(P,T,k){function C(n,e){if(!T[n]){if(!P[n]){var t=typeof require=="function"&&require;if(!e&&t)return t(n,!0);if(I)return I(n,!0);var r=new Error("Cannot find module '"+n+"'");throw r.code="MODULE_NOT_FOUND",r}var s=T[n]={exports:{}};P[n][0].call(s.exports,function(d){var y=P[n][1][d];return C(y||d)},s,s.exports,R,P,T,k)}return T[n].exports}for(var I=typeof require=="function"&&require,a=0;a0&&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,d,y;if(!C(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],d=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(y=d;y-- >0;)if(r[y]===t||r[y].listener&&r[y].listener===t){s=y;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(R,P,T){function k(){throw new Error("setTimeout has not been defined")}function C(){throw new Error("clearTimeout has not been defined")}function I(i){if(s===setTimeout)return setTimeout(i,0);if((s===k||!s)&&setTimeout)return s=setTimeout,setTimeout(i,0);try{return s(i,0)}catch(m){try{return s.call(null,i,0)}catch(o){return s.call(this,i,0)}}}function a(i){if(d===clearTimeout)return clearTimeout(i);if((d===C||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(i);try{return d(i)}catch(m){try{return d.call(null,i)}catch(o){return d.call(this,i)}}}function n(){p&&l&&(p=!1,l.length?c=l.concat(c):f=-1,c.length&&e())}function e(){if(!p){var i=I(n);p=!0;for(var m=c.length;m;){for(l=c,c=[];++f1)for(var o=1;o=n[s]&&e0&&a[0].originalDts=n[r].dts&&an[t].lastSample.originalDts&&a=n[t].lastSample.originalDts&&(t===n.length-1||t0&&(r=this._searchNearestSegmentBefore(e.originalBeginDts)+1),this._lastAppendLocation=r,this._list.splice(r,0,e)}},{key:"getLastSegmentBefore",value:function(a){var n=this._searchNearestSegmentBefore(a);return n>=0?this._list[n]:null}},{key:"getLastSampleBefore",value:function(a){var n=this.getLastSegmentBefore(a);return n!=null?n.lastSample:null}},{key:"getLastSyncPointBefore",value:function(a){for(var n=this._searchNearestSegmentBefore(a),e=this._list[n].syncPoints;e.length===0&&n>0;)n--,e=this._list[n].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(R,P,T){"use strict";function k(f){return f&&f.__esModule?f:{default:f}}function C(f,i){if(!(f instanceof i))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=function(){function f(i,m){for(var o=0;o0&&(u+=";codecs="+o.codec);var E=!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{E=!0;try{var g=this._sourceBuffers[o.type]=this._mediaSource.addSourceBuffer(u);g.addEventListener("error",this.e.onSourceBufferError),g.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(b){return t.default.e(this.TAG,b.message),void this._emitter.emit(y.default.ERROR,{code:b.code,msg:b.message})}}this._mimeTypes[o.type]=u}m||this._pendingSegments[o.type].push(o),E||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(i){var m=i;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(i){for(var m in this._sourceBuffers)if(this._sourceBuffers[m]){var o=this._sourceBuffers[m];if(this._mediaSource.readyState==="open")try{o.abort()}catch(S){t.default.e(this.TAG,S.message)}this._idrList.clear();var u=this._pendingSegments[m];if(u.splice(0,u.length),this._mediaSource.readyState!=="closed"){for(var E=0;E=1&&i-u.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}},{key:"_doCleanupSourceBuffer",value:function(){var i=this._mediaElement.currentTime;for(var m in this._sourceBuffers){var o=this._sourceBuffers[m];if(o){for(var u=o.buffered,E=!1,g=0;g=this._config.autoCleanupMaxBackwardDuration){E=!0;var S=i-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[m].push({start:b,end:S})}}else L0&&(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 i in this._pendingRemoveRanges)if(this._sourceBuffers[i]&&!this._sourceBuffers[i].updating)for(var m=this._sourceBuffers[i],o=this._pendingRemoveRanges[i];o.length&&!m.updating;){var u=o.shift();m.remove(u.start,u.end)}}},{key:"_doAppendSegments",value:function(){var i=this._pendingSegments;for(var m in i)if(this._sourceBuffers[m]&&!this._sourceBuffers[m].updating&&i[m].length>0){var o=i[m].shift();if(o.timestampOffset){var u=this._sourceBuffers[m].timestampOffset,E=o.timestampOffset/1e3,g=Math.abs(u-E);g>.1&&(t.default.v(this.TAG,"Update MPEG audio timestampOffset from "+u+" to "+E),this._sourceBuffers[m].timestampOffset=E),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(y.default.BUFFER_FULL),this._isBufferFull=!0):(t.default.e(this.TAG,b.message),this._emitter.emit(y.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 i=this._pendingSourceBufferInit;i.length;){var m=i.shift();this.appendInitSegment(m,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(y.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 i=this._pendingSegments;return i.video.length>0||i.audio.length>0}},{key:"_hasPendingRemoveRanges",value:function(){var i=this._pendingRemoveRanges;return i.video.length>0||i.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(y.default.UPDATE_END)}},{key:"_onSourceBufferError",value:function(i){t.default.e(this.TAG,"SourceBuffer Error: "+i)}}]),f}();T.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(R,P,T){"use strict";Object.defineProperty(T,"__esModule",{value:!0});var k={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};T.default=k},{}],11:[function(R,P,T){"use strict";function k(u){return u&&u.__esModule?u:{default:u}}function C(u,E){if(!(u instanceof E))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=function(){function u(E,g){for(var b=0;b0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,A=this._demuxer.parseChunks(S,_);else if((v=c.default.probe(S)).match){this._demuxer=new c.default(v,this._config),this._remuxer||(this._remuxer=new f.default(this._config));var w=this._mediaDataSource;w.duration==null||isNaN(w.duration)||(this._demuxer.overridedDuration=w.duration),typeof w.hasAudio=="boolean"&&(this._demuxer.overridedHasAudio=w.hasAudio),typeof w.hasVideo=="boolean"&&(this._demuxer.overridedHasVideo=w.hasVideo),this._demuxer.timestampBase=w.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),A=this._demuxer.parseChunks(S,_)}else v=null,t.default.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(function(){h._internalAbort()}),this._emitter.emit(g.default.DEMUX_ERROR,m.default.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),A=0;return A}},{key:"_onMediaInfo",value:function(S){var _=this;this._mediaInfo==null&&(this._mediaInfo=Object.assign({},S),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,y.default.prototype));var h=Object.assign({},S);Object.setPrototypeOf(h,y.default.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=h,this._reportSegmentMediaInfo(this._currentSegmentIndex),this._pendingSeekTime!=null&&Promise.resolve().then(function(){var v=_._pendingSeekTime;_._pendingSeekTime=null,_.seek(v)})}},{key:"_onMetaDataArrived",value:function(S){this._emitter.emit(g.default.METADATA_ARRIVED,S)}},{key:"_onScriptDataArrived",value:function(S){this._emitter.emit(g.default.SCRIPTDATA_ARRIVED,S)}},{key:"_onIOSeeked",value:function(){this._remuxer.insertDiscontinuity()}},{key:"_onIOComplete",value:function(S){var _=S,h=_+1;h0&&h[0].originalDts===v&&(v=h[0].pts),this._emitter.emit(g.default.RECOMMEND_SEEKPOINT,v)}}},{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(S){var _=this._mediaInfo.segments[S],h=Object.assign({},_);h.duration=this._mediaInfo.duration,h.segmentCount=this._mediaInfo.segmentCount,delete h.segments,delete h.keyframesIndex,this._emitter.emit(g.default.MEDIA_INFO,h)}},{key:"_reportStatisticsInfo",value:function(){var S={};S.url=this._ioctl.currentURL,S.hasRedirect=this._ioctl.hasRedirect,S.hasRedirect&&(S.redirectedURL=this._ioctl.currentRedirectedURL),S.speed=this._ioctl.currentSpeed,S.loaderType=this._ioctl.loaderType,S.currentSegmentIndex=this._currentSegmentIndex,S.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(g.default.STATISTICS_INFO,S)}}]),L}());T.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(R,P,T){"use strict";Object.defineProperty(T,"__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",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};T.default=k},{}],14:[function(R,P,T){"use strict";function k(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(T,"__esModule",{value:!0});var C=R("../utils/logger.js"),I=(k(C),R("../utils/logging-control.js")),a=k(I),n=R("../utils/polyfill.js"),e=k(n),t=R("./transmuxing-controller.js"),r=k(t),s=R("./transmuxing-events.js"),d=k(s),y=function(l){function c(v,A){var w={msg:d.default.INIT_SEGMENT,data:{type:v,data:A}};l.postMessage(w,[A.data])}function p(v,A){var w={msg:d.default.MEDIA_SEGMENT,data:{type:v,data:A}};l.postMessage(w,[A.data])}function f(){var v={msg:d.default.LOADING_COMPLETE};l.postMessage(v)}function i(){var v={msg:d.default.RECOVERED_EARLY_EOF};l.postMessage(v)}function m(v){var A={msg:d.default.MEDIA_INFO,data:v};l.postMessage(A)}function o(v){var A={msg:d.default.METADATA_ARRIVED,data:v};l.postMessage(A)}function u(v){var A={msg:d.default.SCRIPTDATA_ARRIVED,data:v};l.postMessage(A)}function E(v){var A={msg:d.default.STATISTICS_INFO,data:v};l.postMessage(A)}function g(v,A){l.postMessage({msg:d.default.IO_ERROR,data:{type:v,info:A}})}function b(v,A){l.postMessage({msg:d.default.DEMUX_ERROR,data:{type:v,info:A}})}function L(v){l.postMessage({msg:d.default.RECOMMEND_SEEKPOINT,data:v})}function S(v,A){l.postMessage({msg:"logcat_callback",data:{type:v,logcat:A}})}var _=null,h=S.bind(this);e.default.install(),l.addEventListener("message",function(v){switch(v.data.cmd){case"init":_=new r.default(v.data.param[0],v.data.param[1]),_.on(d.default.IO_ERROR,g.bind(this)),_.on(d.default.DEMUX_ERROR,b.bind(this)),_.on(d.default.INIT_SEGMENT,c.bind(this)),_.on(d.default.MEDIA_SEGMENT,p.bind(this)),_.on(d.default.LOADING_COMPLETE,f.bind(this)),_.on(d.default.RECOVERED_EARLY_EOF,i.bind(this)),_.on(d.default.MEDIA_INFO,m.bind(this)),_.on(d.default.METADATA_ARRIVED,o.bind(this)),_.on(d.default.SCRIPTDATA_ARRIVED,u.bind(this)),_.on(d.default.STATISTICS_INFO,E.bind(this)),_.on(d.default.RECOMMEND_SEEKPOINT,L.bind(this));break;case"destroy":_&&(_.destroy(),_=null),l.postMessage({msg:"destroyed"});break;case"start":_.start();break;case"stop":_.stop();break;case"seek":_.seek(v.data.param);break;case"pause":_.pause();break;case"resume":_.resume();break;case"logging_config":var A=v.data.param;a.default.applyConfig(A),A.enableCallback===!0?a.default.addLogListener(h):a.default.removeLogListener(h)}})};T.default=y},{"../utils/logger.js":41,"../utils/logging-control.js":42,"../utils/polyfill.js":43,"./transmuxing-controller.js":12,"./transmuxing-events.js":13}],15:[function(R,P,T){"use strict";function k(y){return y&&y.__esModule?y:{default:y}}function C(y,l){if(!(y instanceof l))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=function(){function y(l,c){for(var p=0;p0?(0,t.default)(new Uint8Array(l,c+2,i)):"",{data:m,size:2+i}}},{key:"parseLongString",value:function(l,c,p){if(p<4)throw new r.IllegalStateException("Data not enough when parse LongString");var f=new DataView(l,c,p),i=f.getUint32(0,!s),m=void 0;return m=i>0?(0,t.default)(new Uint8Array(l,c+4,i)):"",{data:m,size:4+i}}},{key:"parseDate",value:function(l,c,p){if(p<10)throw new r.IllegalStateException("Data size invalid when parse Date");var f=new DataView(l,c,p),i=f.getFloat64(0,!s);return i+=60*f.getInt16(8,!s)*1e3,{data:new Date(i),size:10}}},{key:"parseValue",value:function(l,c,p){if(p<1)throw new r.IllegalStateException("Data not enough when parse Value");var f=new DataView(l,c,p),i=1,m=f.getUint8(0),o=void 0,u=!1;try{switch(m){case 0:o=f.getFloat64(1,!s),i+=8;break;case 1:o=!!f.getUint8(1),i+=1;break;case 2:var E=y.parseString(l,c+1,p-1);o=E.data,i+=E.size;break;case 3:o={};var g=0;for((16777215&f.getUint32(p-4,!s))==9&&(g=3);i32)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 d=Math.min(s,this._current_word_bits_left),y=this._current_word>>>32-d;return this._current_word<<=d,this._current_word_bits_left-=d,r=r<>>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)}}]),n}();T.default=a},{"../utils/exception.js":40}],18:[function(R,P,T){"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(T,"__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},n=function(){function o(u,E){for(var g=0;g13))return 0;g=o.probe(u).dataOffset}for(this._firstParse&&(this._firstParse=!1,E+g!==this._dataOffset&&t.default.w(this.TAG,"First time parsing but chunk byteStart invalid!"),new DataView(u,g).getUint32(0,!b)!==0&&t.default.w(this.TAG,"PrevTagSize0 !== 0 !!!"),g+=4);gu.byteLength)break;var S=L.getUint8(0),_=16777215&L.getUint32(0,!b);if(g+11+_+4>u.byteLength)break;if(S===8||S===9||S===18){var h=L.getUint8(4),v=L.getUint8(5),A=L.getUint8(6),w=L.getUint8(7),M=A|v<<8|h<<16|w<<24;(16777215&L.getUint32(7,!b))!=0&&t.default.w(this.TAG,"Meet tag which has StreamID != 0!");var B=g+11;switch(S){case 8:this._parseAudioData(u,B,_,M);break;case 9:this._parseVideoData(u,B,_,M,E+g);break;case 18:this._parseScriptData(u,B,_)}var G=L.getUint32(11+_,!b);G!==11+_&&t.default.w(this.TAG,"Invalid PrevTagSize "+G),g+=11+_+4}else t.default.w(this.TAG,"Unsupported tag type "+S+", skipped"),g+=11+_+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),g}},{key:"_parseScriptData",value:function(u,E,g){var b=s.default.parseScriptData(u,E,g);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 L=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},L)),typeof L.hasAudio=="boolean"&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=L.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),typeof L.hasVideo=="boolean"&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=L.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),typeof L.audiodatarate=="number"&&(this._mediaInfo.audioDataRate=L.audiodatarate),typeof L.videodatarate=="number"&&(this._mediaInfo.videoDataRate=L.videodatarate),typeof L.width=="number"&&(this._mediaInfo.width=L.width),typeof L.height=="number"&&(this._mediaInfo.height=L.height),typeof L.duration=="number"){if(!this._durationOverrided){var S=Math.floor(L.duration*this._timescale);this._duration=S,this._mediaInfo.duration=S}}else this._mediaInfo.duration=0;if(typeof L.framerate=="number"){var _=Math.floor(1e3*L.framerate);if(_>0){var h=_/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=h,this._referenceFrameRate.fps_num=_,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=h}}if(a(L.keyframes)==="object"){this._mediaInfo.hasKeyframesIndex=!0;var v=L.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(v),L.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=L,t.default.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(b).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},b))}},{key:"_parseKeyframesIndex",value:function(u){for(var E=[],g=[],b=1;b>>4;if(_!==2&&_!==10)return void this._onError(c.default.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+_);var h=0,v=(12&S)>>>2;if(!(v>=0&&v<=4))return void this._onError(c.default.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+v);h=this._flvSoundRateTable[v];var A=1&S,w=this._audioMetadata,M=this._audioTrack;if(w||(this._hasAudio===!1&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),w=this._audioMetadata={},w.type="audio",w.id=M.id,w.timescale=this._timescale,w.duration=this._duration,w.audioSampleRate=h,w.channelCount=A===0?1:2),_===10){var B=this._parseAACAudioData(u,E+1,g-1);if(B==null)return;if(B.packetType===0){w.config&&t.default.w(this.TAG,"Found another AudioSpecificConfig!");var G=B.data;w.audioSampleRate=G.samplingRate,w.channelCount=G.channelCount,w.codec=G.codec,w.originalCodec=G.originalCodec,w.config=G.config,w.refSampleDuration=1024/w.audioSampleRate*w.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",w);var U=this._mediaInfo;U.audioCodec=w.originalCodec,U.audioSampleRate=w.audioSampleRate,U.audioChannelCount=w.channelCount,U.hasVideo?U.videoCodec!=null&&(U.mimeType='video/x-flv; codecs="'+U.videoCodec+","+U.audioCodec+'"'):U.mimeType='video/x-flv; codecs="'+U.audioCodec+'"',U.isComplete()&&this._onMediaInfo(U)}else if(B.packetType===1){var K=this._timestampBase+b,z={unit:B.data,length:B.data.byteLength,dts:K,pts:K};M.samples.push(z),M.length+=B.data.length}else t.default.e(this.TAG,"Flv: Unsupported AAC data type "+B.packetType)}else if(_===2){if(!w.codec){var W=this._parseMP3AudioData(u,E+1,g-1,!0);if(W==null)return;w.audioSampleRate=W.samplingRate,w.channelCount=W.channelCount,w.codec=W.codec,w.originalCodec=W.originalCodec,w.refSampleDuration=1152/w.audioSampleRate*w.timescale,t.default.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",w);var F=this._mediaInfo;F.audioCodec=w.codec,F.audioSampleRate=w.audioSampleRate,F.audioChannelCount=w.channelCount,F.audioDataRate=W.bitRate,F.hasVideo?F.videoCodec!=null&&(F.mimeType='video/x-flv; codecs="'+F.videoCodec+","+F.audioCodec+'"'):F.mimeType='video/x-flv; codecs="'+F.audioCodec+'"',F.isComplete()&&this._onMediaInfo(F)}var X=this._parseMP3AudioData(u,E+1,g-1,!1);if(X==null)return;var Y=this._timestampBase+b,V={unit:X,length:X.byteLength,dts:Y,pts:Y};M.samples.push(V),M.length+=X.length}}}},{key:"_parseAACAudioData",value:function(u,E,g){if(g<=1)return void t.default.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");var b={},L=new Uint8Array(u,E,g);return b.packetType=L[0],L[0]===0?b.data=this._parseAACAudioSpecificConfig(u,E+1,g-1):b.data=L.subarray(1),b}},{key:"_parseAACAudioSpecificConfig",value:function(u,E,g){var b=new Uint8Array(u,E,g),L=null,S=0,_=0,h=0,v=null;if(S=_=b[0]>>>3,(h=(7&b[0])<<1|b[1]>>>7)<0||h>=this._mpegSamplingRates.length)return void this._onError(c.default.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");var A=this._mpegSamplingRates[h],w=(120&b[1])>>>3;if(w<0||w>=8)return void this._onError(c.default.FORMAT_ERROR,"Flv: AAC invalid channel configuration");S===5&&(v=(7&b[1])<<1|b[2]>>>7,b[2]);var M=self.navigator.userAgent.toLowerCase();return M.indexOf("firefox")!==-1?h>=6?(S=5,L=new Array(4),v=h-3):(S=2,L=new Array(2),v=h):M.indexOf("android")!==-1?(S=2,L=new Array(2),v=h):(S=5,v=h,L=new Array(4),h>=6?v=h-3:w===1&&(S=2,L=new Array(2),v=h)),L[0]=S<<3,L[0]|=(15&h)>>>1,L[1]=(15&h)<<7,L[1]|=(15&w)<<3,S===5&&(L[1]|=(15&v)>>>1,L[2]=(1&v)<<7,L[2]|=8,L[3]=0),{config:L,samplingRate:A,channelCount:w,codec:"mp4a.40."+S,originalCodec:"mp4a.40."+_}}},{key:"_parseMP3AudioData",value:function(u,E,g,b){if(g<4)return void t.default.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");var L=(this._littleEndian,new Uint8Array(u,E,g)),S=null;if(b){if(L[0]!==255)return;var _=L[1]>>>3&3,h=(6&L[1])>>1,v=(240&L[2])>>>4,A=(12&L[2])>>>2,w=L[3]>>>6&3,M=w!==3?2:1,B=0,G=0;switch(_){case 0:B=this._mpegAudioV25SampleRateTable[A];break;case 2:B=this._mpegAudioV20SampleRateTable[A];break;case 3:B=this._mpegAudioV10SampleRateTable[A]}switch(h){case 1:v>>4,h=15&S;if(h!==7)return void this._onError(c.default.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+h);this._parseAVCVideoPacket(u,E+1,g-1,b,L,_)}}},{key:"_parseAVCVideoPacket",value:function(u,E,g,b,L,S){if(g<4)return void t.default.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");var _=this._littleEndian,h=new DataView(u,E,g),v=h.getUint8(0),A=16777215&h.getUint32(0,!_),w=A<<8>>8;if(v===0)this._parseAVCDecoderConfigurationRecord(u,E+4,g-4);else if(v===1)this._parseAVCVideoData(u,E+4,g-4,b,L,S,w);else if(v!==2)return void this._onError(c.default.FORMAT_ERROR,"Flv: Invalid video packet type "+v)}},{key:"_parseAVCDecoderConfigurationRecord",value:function(u,E,g){if(g<7)return void t.default.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");var b=this._videoMetadata,L=this._videoTrack,S=this._littleEndian,_=new DataView(u,E,g);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=L.id,b.timescale=this._timescale,b.duration=this._duration);var h=_.getUint8(0),v=_.getUint8(1);if(_.getUint8(2),_.getUint8(3),h!==1||v===0)return void this._onError(c.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");if(this._naluLengthSize=1+(3&_.getUint8(4)),this._naluLengthSize!==3&&this._naluLengthSize!==4)return void this._onError(c.default.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));var A=31&_.getUint8(5);if(A===0)return void this._onError(c.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");A>1&&t.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+A);for(var w=6,M=0;M1&&t.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+H),w++;for(var Q=0;Q=g){t.default.w(this.TAG,"Malformed Nalu near timestamp "+G+", offset = "+M+", dataSize = "+g);break}var K=v.getUint32(M,!h);if(B===3&&(K>>>=8),K>g-B)return void t.default.w(this.TAG,"Malformed Nalus near timestamp "+G+", NaluSize > DataSize!");var z=31&v.getUint8(M+B);z===5&&(U=!0);var W=new Uint8Array(u,E+M,B+K),F={type:z,data:W};A.push(F),w+=W.byteLength,M+=B+K}if(A.length){var X=this._videoTrack,Y={units:A,length:w,isKeyframe:U,dts:G,cts:_,pts:G+_};U&&(Y.fileposition=L),X.samples.push(Y),X.length+=w}}},{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:"onMetaDataArrived",get:function(){return this._onMetaDataArrived},set:function(u){this._onMetaDataArrived=u}},{key:"onScriptDataArrived",get:function(){return this._onScriptDataArrived},set:function(u){this._onScriptDataArrived=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 E=new Uint8Array(u),g={match:!1};if(E[0]!==70||E[1]!==76||E[2]!==86||E[3]!==1)return g;var b=(4&E[4])>>>2!=0,L=(1&E[4])!=0,S=I(E,5);return S<9?g:{match:!0,consumed:S,dataOffset:S,hasAudioTrack:b,hasVideoTrack:L}}}]),o}();T.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(R,P,T){"use strict";function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function e(t,r){for(var s=0;s=2&&r[l]===3&&r[l-1]===0&&r[l-2]===0||(d[y]=r[l],y++);return new Uint8Array(d.buffer,0,y)}},{key:"parseSPS",value:function(t){var r=e._ebsp2rbsp(t),s=new a.default(r);s.readByte();var d=s.readByte();s.readByte();var y=s.readByte();s.readUEG();var l=e.getProfileString(d),c=e.getLevelString(y),p=1,f=420,i=[0,420,422,444],m=8;if((d===100||d===110||d===122||d===244||d===44||d===83||d===86||d===118||d===128||d===138||d===144)&&(p=s.readUEG(),p===3&&s.readBits(1),p<=3&&(f=i[p]),m=s.readUEG()+8,s.readUEG(),s.readBits(1),s.readBool()))for(var o=p!==3?8:12,u=0;u0&&F<16?(B=X[F-1],G=Y[F-1]):F===255&&(B=s.readByte()<<8|s.readByte(),G=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 V=s.readBits(32),H=s.readBits(32);K=s.readBool(),z=H,W=2*V,U=z/W}}var Q=1;B===1&&G===1||(Q=B/G);var Z=0,ue=0;if(p===0)Z=1,ue=2-h;else{var re=p===3?1:2,ee=p===1?2:1;Z=re,ue=ee*(2-h)}var te=16*(S+1),de=16*(_+1)*(2-h);te-=(v+A)*Z,de-=(w+M)*ue;var ne=Math.ceil(te*Q);return s.destroy(),s=null,{profile_string:l,level_string:c,bit_depth:m,ref_frames:L,chroma_format:f,chroma_format_string:e.getChromaFormatString(f),frame_rate:{fixed:K,fps:U,fps_den:W,fps_num:z},sar_ratio:{width:B,height:G},codec_size:{width:te,height:de},present_size:{width:ne,height:de}}}},{key:"_skipScalingList",value:function(t,r){for(var s=8,d=8,y=0,l=0;l=15048,m=!d.default.msedge||i;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(i,m){var o=this;this._dataSource=i,this._range=m;var u=i.url;this._config.reuseRedirectedURL&&i.redirectedURL!=null&&(u=i.redirectedURL);var E=this._seekHandler.getConfig(u,m),g=new self.Headers;if(n(E.headers)==="object"){var b=E.headers;for(var L in b)b.hasOwnProperty(L)&&g.append(L,b[L])}var S={method:"GET",headers:g,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if(n(this._config.headers)==="object")for(var _ in this._config.headers)g.append(_,this._config.headers[_]);i.cors===!1&&(S.mode="same-origin"),i.withCredentials&&(S.credentials="include"),i.referrerPolicy&&(S.referrerPolicy=i.referrerPolicy),this._status=y.LoaderStatus.kConnecting,self.fetch(E.url,S).then(function(h){if(o._requestAbort)return o._requestAbort=!1,void(o._status=y.LoaderStatus.kIdle);if(h.ok&&h.status>=200&&h.status<=299){if(h.url!==E.url&&o._onURLRedirect){var v=o._seekHandler.removeURLParameters(h.url);o._onURLRedirect(v)}var A=h.headers.get("Content-Length");return A!=null&&(o._contentLength=parseInt(A),o._contentLength!==0&&o._onContentLengthKnown&&o._onContentLengthKnown(o._contentLength)),o._pump.call(o,h.body.getReader())}if(o._status=y.LoaderStatus.kError,!o._onError)throw new l.RuntimeException("FetchStreamLoader: Http code invalid, "+h.status+" "+h.statusText);o._onError(y.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:h.status,msg:h.statusText})}).catch(function(h){if(o._status=y.LoaderStatus.kError,!o._onError)throw h;o._onError(y.LoaderErrors.EXCEPTION,{code:-1,msg:h.message})})}},{key:"abort",value:function(){this._requestAbort=!0}},{key:"_pump",value:function(i){var m=this;return i.read().then(function(o){if(o.done)if(m._contentLength!==null&&m._receivedLength0&&(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=_,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(_.url),this._refTotalLength=_.filesize?_.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(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 _=this._config;if(_.seekType==="range")this._seekHandler=new u.default(this._config.rangeLoadZeroStart);else if(_.seekType==="param"){var h=_.seekParamStart||"bstart",v=_.seekParamEnd||"bend";this._seekHandler=new g.default(h,v)}else{if(_.seekType!=="custom")throw new b.InvalidArgumentException("Invalid seekType in config: "+_.seekType);if(typeof _.customSeekHandler!="function")throw new b.InvalidArgumentException("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new _.customSeekHandler}}},{key:"_selectLoader",value:function(){if(this._config.customLoader!=null)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=m.default;else if(d.default.isSupported())this._loaderClass=d.default;else if(l.default.isSupported())this._loaderClass=l.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(_){this._currentRange={from:0,to:-1},_&&(this._currentRange.from=_),this._speedSampler.reset(),_||(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 _=this._resumeFrom;this._resumeFrom=0,this._internalSeek(_,!0)}}},{key:"seek",value:function(_){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(_,!0)}},{key:"_internalSeek",value:function(_,h){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(h),this._loader.destroy(),this._loader=null;var v={from:_,to:-1};this._currentRange={from:v.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,v),this._onSeeked&&this._onSeeked()}},{key:"updateUrl",value:function(_){if(!_||typeof _!="string"||_.length===0)throw new b.InvalidArgumentException("Url must be a non-empty string!");this._dataSource.url=_}},{key:"_expandBuffer",value:function(_){for(var h=this._stashSize;h+1048576<_;)h*=2;if((h+=1048576)!==this._bufferSize){var v=new ArrayBuffer(h);if(this._stashUsed>0){var A=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(v,0,h).set(A,0)}this._stashBuffer=v,this._bufferSize=h}}},{key:"_normalizeSpeed",value:function(_){var h=this._speedNormalizeList,v=h.length-1,A=0,w=0,M=v;if(_=h[A]&&_=512&&_<=1024?Math.floor(1.5*_):2*_)>8192&&(h=8192);var v=1024*h+1048576;this._bufferSize0){var G=this._stashBuffer.slice(0,this._stashUsed),U=this._dispatchChunks(G,this._stashByteStart);if(U0){var K=new Uint8Array(G,U);B.set(K,0),this._stashUsed=K.byteLength,this._stashByteStart+=U}}else this._stashUsed=0,this._stashByteStart+=U;this._stashUsed+_.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+_.byteLength),B=new Uint8Array(this._stashBuffer,0,this._bufferSize)),B.set(new Uint8Array(_),this._stashUsed),this._stashUsed+=_.byteLength}else{var z=this._dispatchChunks(_,h);if(z<_.byteLength){var W=_.byteLength-z;W>this._bufferSize&&(this._expandBuffer(W),B=new Uint8Array(this._stashBuffer,0,this._bufferSize)),B.set(new Uint8Array(_,z),0),this._stashUsed+=W,this._stashByteStart=h+z}}}else if(this._stashUsed===0){var F=this._dispatchChunks(_,h);if(F<_.byteLength){var X=_.byteLength-F;X>this._bufferSize&&this._expandBuffer(X);var Y=new Uint8Array(this._stashBuffer,0,this._bufferSize);Y.set(new Uint8Array(_,F),0),this._stashUsed+=X,this._stashByteStart=h+F}}else{this._stashUsed+_.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+_.byteLength);var V=new Uint8Array(this._stashBuffer,0,this._bufferSize);V.set(new Uint8Array(_),this._stashUsed),this._stashUsed+=_.byteLength;var H=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(H0){var Q=new Uint8Array(this._stashBuffer,H);V.set(Q,0)}this._stashUsed-=H,this._stashByteStart+=H}}}},{key:"_flushStashBuffer",value:function(_){if(this._stashUsed>0){var h=this._stashBuffer.slice(0,this._stashUsed),v=this._dispatchChunks(h,this._stashByteStart),A=h.byteLength-v;if(v0){var w=new Uint8Array(this._stashBuffer,0,this._bufferSize),M=new Uint8Array(h,v);w.set(M,0),this._stashUsed=M.byteLength,this._stashByteStart+=v}return 0}n.default.w(this.TAG,A+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,A}return 0}},{key:"_onLoaderComplete",value:function(_,h){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}},{key:"_onLoaderError",value:function(_,h){switch(n.default.e(this.TAG,"Loader error, code = "+h.code+", msg = "+h.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,_=r.LoaderErrors.UNRECOVERABLE_EARLY_EOF),_){case r.LoaderErrors.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var v=this._currentRange.to+1;return void(v0)for(var d=t.split("&"),y=0;y0;l[0]!==this._startName&&l[0]!==this._endName&&(c&&(s+="&"),s+=d[y])}return s.length===0?e:e+"?"+s}}]),a}();T.default=I},{}],26:[function(R,P,T){"use strict";function k(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function a(n,e){for(var t=0;t=500?this.currentKBps:0}},{key:"averageKBps",get:function(){var n=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/n/1024}}]),a}();T.default=I},{}],28:[function(R,P,T){"use strict";function k(d,y){if(!(d instanceof y))throw new TypeError("Cannot call a class as a function")}function C(d,y){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!y||typeof y!="object"&&typeof y!="function"?d:y}function I(d,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);d.prototype=Object.create(y&&y.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(d,y):d.__proto__=y)}Object.defineProperty(T,"__esModule",{value:!0});var a=function d(y,l,c){y===null&&(y=Function.prototype);var p=Object.getOwnPropertyDescriptor(y,l);if(p===void 0){var f=Object.getPrototypeOf(y);return f===null?void 0:d(f,l,c)}if("value"in p)return p.value;var i=p.get;if(i!==void 0)return i.call(c)},n=function(){function d(y,l){for(var c=0;c299)){if(this._status=s.LoaderStatus.kError,!this._onError)throw new d.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,i=this._range.from+this._receivedLength;this._receivedLength+=f.byteLength,this._onDataArrival&&this._onDataArrival(f,i,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,i=null;if(this._contentLength&&p.loaded=200&&f.status<=299){if(this._status=s.LoaderStatus.kBuffering,f.responseURL!=null){var i=this._seekHandler.removeURLParameters(f.responseURL);f.responseURL!==this._currentRequestURL&&i!==this._currentRedirectedURL&&(this._currentRedirectedURL=i,this._onURLRedirect&&this._onURLRedirect(i))}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 d.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,i={code:-1,msg:p.constructor.name+" "+p.type};if(!this._onError)throw new d.RuntimeException(i.msg);this._onError(f,i)}},{key:"_msrOnProgress",value:function(p){var f=p.target,i=f.result;if(i==null)return void this._doReconnectIfNeeded();var m=i.slice(this._lastTimeBufferSize);this._lastTimeBufferSize=i.byteLength;var o=this._totalRange.from+this._receivedLength;this._receivedLength+=m.byteLength,this._onDataArrival&&this._onDataArrival(m,o,this._receivedLength),i.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&&(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 E=this._seekHandler.getConfig(u,o);this._currentRequestURL=E.url;var g=this._xhr=new XMLHttpRequest;if(g.open("GET",E.url,!0),g.responseType="arraybuffer",g.onreadystatechange=this._onReadyStateChange.bind(this),g.onprogress=this._onProgress.bind(this),g.onload=this._onLoad.bind(this),g.onerror=this._onXhrError.bind(this),m.withCredentials&&(g.withCredentials=!0),n(E.headers)==="object"){var b=E.headers;for(var L in b)b.hasOwnProperty(L)&&g.setRequestHeader(L,b[L])}if(n(this._config.headers)==="object"){var S=this._config.headers;for(var _ in S)S.hasOwnProperty(_)&&g.setRequestHeader(_,S[_])}g.send()}},{key:"abort",value:function(){this._requestAbort=!0,this._internalAbort(),this._status=l.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=l.LoaderStatus.kBuffering}else{if(this._status=l.LoaderStatus.kError,!this._onError)throw new c.RuntimeException("RangeLoader: Http code invalid, "+o.status+" "+o.statusText);this._onError(l.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:o.status,msg:o.statusText})}}}},{key:"_onProgress",value:function(m){if(this._status!==l.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 E=m.loaded-this._lastTimeLoaded;this._lastTimeLoaded=m.loaded,this._speedSampler.addBytes(E)}}},{key:"_normalizeSpeed",value:function(m){var o=this._chunkSizeKBList,u=o.length-1,E=0,g=0,b=u;if(m=o[E]&&m=3&&(o=this._speedSampler.currentKBps),o!==0){var u=this._normalizeSpeed(o);this._currentSpeedNormalized!==u&&(this._currentSpeedNormalized=u,this._currentChunkSizeKB=u)}var E=m.target.response,g=this._range.from+this._receivedLength;this._receivedLength+=E.byteLength;var b=!1;this._contentLength!=null&&this._receivedLength0&&this._receivedLength0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new p.default(this._mediaDataSource,this._config),this._transmuxer.on(i.default.INIT_SEGMENT,function(v,A){h._msectl.appendInitSegment(A)}),this._transmuxer.on(i.default.MEDIA_SEGMENT,function(v,A){if(h._msectl.appendMediaSegment(A),h._config.lazyLoad&&!h._config.isLive){var w=h._mediaElement.currentTime;A.info.endDts>=1e3*(w+h._config.lazyLoadMaxDuration)&&h._progressChecker==null&&(r.default.v(h.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),h._suspendTransmuxer())}}),this._transmuxer.on(i.default.LOADING_COMPLETE,function(){h._msectl.endOfStream(),h._emitter.emit(l.default.LOADING_COMPLETE)}),this._transmuxer.on(i.default.RECOVERED_EARLY_EOF,function(){h._emitter.emit(l.default.RECOVERED_EARLY_EOF)}),this._transmuxer.on(i.default.IO_ERROR,function(v,A){h._emitter.emit(l.default.ERROR,g.ErrorTypes.NETWORK_ERROR,v,A)}),this._transmuxer.on(i.default.DEMUX_ERROR,function(v,A){h._emitter.emit(l.default.ERROR,g.ErrorTypes.MEDIA_ERROR,v,{code:-1,msg:A})}),this._transmuxer.on(i.default.MEDIA_INFO,function(v){h._mediaInfo=v,h._emitter.emit(l.default.MEDIA_INFO,Object.assign({},v))}),this._transmuxer.on(i.default.METADATA_ARRIVED,function(v){h._emitter.emit(l.default.METADATA_ARRIVED,v)}),this._transmuxer.on(i.default.SCRIPTDATA_ARRIVED,function(v){h._emitter.emit(l.default.SCRIPTDATA_ARRIVED,v)}),this._transmuxer.on(i.default.STATISTICS_INFO,function(v){h._statisticsInfo=h._fillStatisticsInfo(v),h._emitter.emit(l.default.STATISTICS_INFO,Object.assign({},h._statisticsInfo))}),this._transmuxer.on(i.default.RECOMMEND_SEEKPOINT,function(v){h._mediaElement&&!h._config.accurateSeek&&(h._requestSetTime=!0,h._mediaElement.currentTime=v/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(){console.log(this),this._mediaElement.pause()}},{key:"_fillStatisticsInfo",value:function(h){if(h.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return h;var v=!0,A=0,w=0;if(this._mediaElement.getVideoPlaybackQuality){var M=this._mediaElement.getVideoPlaybackQuality();A=M.totalVideoFrames,w=M.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(A=this._mediaElement.webkitDecodedFrameCount,w=this._mediaElement.webkitDroppedFrameCount):v=!1;return v&&(h.decodedFrames=A,h.droppedFrames=w),h}},{key:"_onmseUpdateEnd",value:function(){if(this._config.lazyLoad&&!this._config.isLive){for(var h=this._mediaElement.buffered,v=this._mediaElement.currentTime,A=0,w=0;w=v+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,v=this._mediaElement.buffered,A=!1,w=0;w=M&&h=B-this._config.lazyLoadRecoverDuration&&(A=!0);break}}A&&(window.clearInterval(this._progressChecker),this._progressChecker=null,A&&(r.default.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}},{key:"_isTimepointBuffered",value:function(h){for(var v=this._mediaElement.buffered,A=0;A=w&&h0){var M=this._mediaElement.buffered.start(0);(M<1&&h0&&v.currentTime0){var w=A.start(0);if(w<1&&v0&&(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(c){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(c){this._mediaElement.volume=c}},{key:"muted",get:function(){return this._mediaElement.muted},set:function(c){this._mediaElement.muted=c}},{key:"currentTime",get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(c){this._mediaElement?this._mediaElement.currentTime=c:this._pendingSeekTime=c}},{key:"mediaInfo",get:function(){var c=this._mediaElement instanceof HTMLAudioElement?"audio/":"video/",p={mimeType:c+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 c={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return c;var p=!0,f=0,i=0;if(this._mediaElement.getVideoPlaybackQuality){var m=this._mediaElement.getVideoPlaybackQuality();f=m.totalVideoFrames,i=m.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(f=this._mediaElement.webkitDecodedFrameCount,i=this._mediaElement.webkitDroppedFrameCount):p=!1;return p&&(c.decodedFrames=f,c.droppedFrames=i),c}}]),l}();T.default=y},{"../config.js":5,"../utils/exception.js":40,"./player-events.js":35,events:2}],34:[function(R,P,T){"use strict";Object.defineProperty(T,"__esModule",{value:!0}),T.ErrorDetails=T.ErrorTypes=void 0;var k=R("../io/loader.js"),C=R("../demux/demux-errors.js"),I=function(a){return a&&a.__esModule?a:{default:a}}(C);T.ErrorTypes={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},T.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(R,P,T){"use strict";Object.defineProperty(T,"__esModule",{value:!0});var k={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info"};T.default=k},{}],36:[function(R,P,T){"use strict";function k(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function a(n,e){for(var t=0;t>>24&255,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=255&e,t.set(n,4);for(var y=8,l=0;l>>24&255,n>>>16&255,n>>>8&255,255&n,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(n){return a.box(a.types.trak,a.tkhd(n),a.mdia(n))}},{key:"tkhd",value:function(n){var e=n.id,t=n.duration,r=n.presentWidth,s=n.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(n){return a.box(a.types.mdia,a.mdhd(n),a.hdlr(n),a.minf(n))}},{key:"mdhd",value:function(n){var e=n.timescale,t=n.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(n){var e=null;return e=n.type==="audio"?a.constants.HDLR_AUDIO:a.constants.HDLR_VIDEO,a.box(a.types.hdlr,e)}},{key:"minf",value:function(n){var e=null;return e=n.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(n))}},{key:"dinf",value:function(){return a.box(a.types.dinf,a.box(a.types.dref,a.constants.DREF))}},{key:"stbl",value:function(n){return a.box(a.types.stbl,a.stsd(n),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(n){return n.type==="audio"?n.codec==="mp3"?a.box(a.types.stsd,a.constants.STSD_PREFIX,a.mp3(n)):a.box(a.types.stsd,a.constants.STSD_PREFIX,a.mp4a(n)):a.box(a.types.stsd,a.constants.STSD_PREFIX,a.avc1(n))}},{key:"mp3",value:function(n){var e=n.channelCount,t=n.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(n){var e=n.channelCount,t=n.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(n))}},{key:"esds",value:function(n){var e=n.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(n){var e=n.avcc,t=n.codecWidth,r=n.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(n){return a.box(a.types.mvex,a.trex(n))}},{key:"trex",value:function(n){var e=n.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(n,e){return a.box(a.types.moof,a.mfhd(n.sequenceNumber),a.traf(n,e))}},{key:"mfhd",value:function(n){var e=new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n]);return a.box(a.types.mfhd,e)}},{key:"traf",value:function(n,e){var t=n.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])),d=a.sdtp(n),y=a.trun(n,d.byteLength+16+16+8+16+8+8);return a.box(a.types.traf,r,s,y,d)}},{key:"sdtp",value:function(n){for(var e=n.samples||[],t=e.length,r=new Uint8Array(4+t),s=0;s>>24&255,r>>>16&255,r>>>8&255,255&r,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0);for(var y=0;y>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,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*y)}return a.box(a.types.trun,d)}},{key:"mdat",value:function(n){return a.box(a.types.mdat,n)}}]),a}();I.init(),T.default=I},{}],38:[function(R,P,T){"use strict";function k(f){return f&&f.__esModule?f:{default:f}}function C(f,i){if(!(f instanceof i))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=function(){function f(i,m){for(var o=0;o1&&(M=u.pop(),w-=M.length),this._audioStashedLastSample!=null){var B=this._audioStashedLastSample;this._audioStashedLastSample=null,u.unshift(B),w+=B.length}M!=null&&(this._audioStashedLastSample=M);var G=u[0].dts-this._dtsBase;if(this._audioNextDts)E=G-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())E=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&this._audioMeta.originalCodec!=="mp3"&&(h=!0);else{var U=this._audioSegmentInfoList.getLastSampleBefore(G);if(U!=null){var K=G-(U.originalDts+U.duration);K<=3&&(K=0);var z=U.dts+U.duration+K;E=G-z}else E=0}if(h){var W=G-E,F=this._videoSegmentInfoList.getLastSegmentBefore(G);if(F!=null&&F.beginDts=1?H[H.length-1].duration:Math.floor(L);var ne=!1,$=null;if(te>1.5*L&&this._audioMeta.codec!=="mp3"&&this._fillAudioTimestampGap&&!y.default.safari){ne=!0;var le=Math.abs(te-L),se=Math.ceil(le/L),he=ee+L;n.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+te)+" ms, expected: "+(ee+Math.round(L))+" ms, delta: "+Math.round(le)+" ms, generate: "+se+" frames");var ae=s.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);ae==null&&(n.default.w(this.TAG,"Unable to generate silent frame for "+this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame"),ae=ue),$=[];for(var oe=0;oe0){var me=$[$.length-1];me.duration=ce-me.dts}var ie={dts:ce,pts:ce,cts:0,unit:ae,size:ae.byteLength,duration:0,originalDts:re,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};$.push(ie),w+=ie.size,he+=L}var O=$[$.length-1];O.duration=ee+te-O.dts,te=Math.round(L)}H.push({dts:ee,pts:ee,cts:0,unit:Z.unit,size:Z.unit.byteLength,duration:te,originalDts:re,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),ne&&H.push.apply(H,$)}S?A=new Uint8Array(w):(A=new Uint8Array(w),A[0]=w>>>24&255,A[1]=w>>>16&255,A[2]=w>>>8&255,A[3]=255&w,A.set(t.default.types.mdat,4));for(var D=0;D1&&(A=u.pop(),v-=A.length),this._videoStashedLastSample!=null){var w=this._videoStashedLastSample;this._videoStashedLastSample=null,u.unshift(w),v+=w.length}A!=null&&(this._videoStashedLastSample=A);var M=u[0].dts-this._dtsBase;if(this._videoNextDts)E=M-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())E=0;else{var B=this._videoSegmentInfoList.getLastSampleBefore(M);if(B!=null){var G=M-(B.originalDts+B.duration);G<=3&&(G=0);var U=B.dts+B.duration+G;E=M-U}else E=0}for(var K=new l.MediaSegmentInfo,z=[],W=0;W=1?z[z.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(Y){var re=new l.SampleInfo(V,Q,Z,F.dts,!0);re.fileposition=F.fileposition,K.appendSyncPoint(re)}z.push({dts:V,pts:Q,cts:H,units:F.units,size:F.length,isKeyframe:Y,duration:Z,originalDts:X,flags:{isLeading:0,dependsOn:Y?2:1,isDependedOn:Y?1:0,hasRedundancy:0,isNonSync:Y?0:1}})}h=new Uint8Array(v),h[0]=v>>>24&255,h[1]=v>>>16&255,h[2]=v>>>8&255,h[3]=255&v,h.set(t.default.types.mdat,4);for(var ee=0;ee=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)||[],n={browser:I[5]||I[3]||I[1]||"",version:I[2]||I[4]||"0",majorVersion:I[4]||I[2]||"0",platform:a[0]||""},e={};if(n.browser){e[n.browser]=!0;var t=n.majorVersion.split(".");e.version={major:parseInt(n.majorVersion,10),string:n.version},t.length>1&&(e.version.minor=parseInt(t[1],10)),t.length>2&&(e.version.build=parseInt(t[2],10))}n.platform&&(e[n.platform]=!0),(e.chrome||e.opr||e.safari)&&(e.webkit=!0),(e.rv||e.iemobile)&&(e.rv&&delete e.rv,n.browser="msie",e.msie=!0),e.edge&&(delete e.edge,n.browser="msedge",e.msedge=!0),e.opr&&(n.browser="opera",e.opera=!0),e.safari&&e.android&&(n.browser="android",e.android=!0),e.name=n.browser,e.platform=n.platform;for(var r in k)k.hasOwnProperty(r)&&delete k[r];Object.assign(k,e)})(),T.default=k},{}],40:[function(R,P,T){"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(T,"__esModule",{value:!0});var a=function(){function e(t,r){for(var s=0;s "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",s),e.ENABLE_ERROR&&(console.error?console.error(s):console.warn?console.warn(s):console.log(s))}},{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&&(console.info?console.info(s):console.log(s))}},{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&&(console.warn?console.warn(s):console.log(s))}},{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}();n.GLOBAL_TAG="flv.js",n.FORCE_GLOBAL_TAG=!1,n.ENABLE_ERROR=!0,n.ENABLE_INFO=!0,n.ENABLE_WARN=!0,n.ENABLE_DEBUG=!0,n.ENABLE_VERBOSE=!0,n.ENABLE_CALLBACK=!1,n.emitter=new a.default,T.default=n},{events:2}],42:[function(R,P,T){"use strict";function k(s){return s&&s.__esModule?s:{default:s}}function C(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=function(){function s(d,y){for(var l=0;l0){var y=s.getConfig();d.emit("change",y)}}},{key:"registerListener",value:function(d){s.emitter.addListener("change",d)}},{key:"removeListener",value:function(d){s.emitter.removeListener("change",d)}},{key:"addLogListener",value:function(d){t.default.emitter.addListener("log",d),t.default.emitter.listenerCount("log")>0&&(t.default.ENABLE_CALLBACK=!0,s._notifyChange())}},{key:"removeLogListener",value:function(d){t.default.emitter.removeListener("log",d),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(d){t.default.FORCE_GLOBAL_TAG=d,s._notifyChange()}},{key:"globalTag",get:function(){return t.default.GLOBAL_TAG},set:function(d){t.default.GLOBAL_TAG=d,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(d){t.default.ENABLE_VERBOSE=d,t.default.ENABLE_DEBUG=d,t.default.ENABLE_INFO=d,t.default.ENABLE_WARN=d,t.default.ENABLE_ERROR=d,s._notifyChange()}},{key:"enableDebug",get:function(){return t.default.ENABLE_DEBUG},set:function(d){t.default.ENABLE_DEBUG=d,s._notifyChange()}},{key:"enableVerbose",get:function(){return t.default.ENABLE_VERBOSE},set:function(d){t.default.ENABLE_VERBOSE=d,s._notifyChange()}},{key:"enableInfo",get:function(){return t.default.ENABLE_INFO},set:function(d){t.default.ENABLE_INFO=d,s._notifyChange()}},{key:"enableWarn",get:function(){return t.default.ENABLE_WARN},set:function(d){t.default.ENABLE_WARN=d,s._notifyChange()}},{key:"enableError",get:function(){return t.default.ENABLE_ERROR},set:function(d){t.default.ENABLE_ERROR=d,s._notifyChange()}}]),s}();r.emitter=new n.default,T.default=r},{"./logger.js":41,events:2}],43:[function(R,P,T){"use strict";function k(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function a(n,e){for(var t=0;t=128){a.push(String.fromCharCode(65535&r)),e+=2;continue}}}else if(n[e]<240){if(k(n,e,2)){var s=(15&n[e])<<12|(63&n[e+1])<<6|63&n[e+2];if(s>=2048&&(63488&s)!=55296){a.push(String.fromCharCode(65535&s)),e+=3;continue}}}else if(n[e]<248&&k(n,e,3)){var d=(7&n[e])<<18|(63&n[e+1])<<12|(63&n[e+2])<<6|63&n[e+3];if(d>65536&&d<1114112){d-=65536,a.push(String.fromCharCode(d>>>10|55296)),a.push(String.fromCharCode(1023&d|56320)),e+=4;continue}}}a.push(String.fromCharCode(65533)),++e}return a.join("")}Object.defineProperty(T,"__esModule",{value:!0}),T.default=C},{}]},{},[21])(21)});