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