mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-19 11:57:54 +08:00
146 lines
575 KiB
JavaScript
146 lines
575 KiB
JavaScript
!function e(t,i,a){function r(s,o){if(!i[s]){if(!t[s]){var _="function"==typeof require&&require;if(!o&&_)return _(s,!0);if(n)return n(s,!0);var d=new Error("Cannot find module '"+s+"'");throw d.code="MODULE_NOT_FOUND",d}var l=i[s]={exports:{}};t[s][0].call(l.exports,(function(e){return r(t[s][1][e]||e)}),l,l.exports,e,t,i,a)}return i[s].exports}for(var n="function"==typeof require&&require,s=0;s<a.length;s++)r(a[s]);return r}({1:[function(e,t,i){var a,r,n=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function _(e){if(a===setTimeout)return setTimeout(e,0);if((a===s||!a)&&setTimeout)return a=setTimeout,setTimeout(e,0);try{return a(e,0)}catch(t){try{return a.call(null,e,0)}catch(t){return a.call(this,e,0)}}}!function(){try{a="function"==typeof setTimeout?setTimeout:s}catch(e){a=s}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var d,l=[],u=!1,c=-1;function h(){u&&d&&(u=!1,d.length?l=d.concat(l):c=-1,l.length&&f())}function f(){if(!u){var e=_(h);u=!0;for(var t=l.length;t;){for(d=l,l=[];++c<t;)d&&d[c].run();c=-1,t=l.length}d=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function m(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];l.push(new p(e,t)),1!==l.length||u||_(f)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=m,n.addListener=m,n.once=m,n.off=m,n.removeListener=m,n.removeAllListeners=m,n.emit=m,n.prependListener=m,n.prependOnceListener=m,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},{}],2:[function(e,t,i){const a=window.AudioContext||window.webkitAudioContext,r=e("../consts"),n=e("../av-common");function s(){if(!window.__YL_AUDIO_UNLOCK_STATE__){const e={contexts:new Set,gestureUnlocked:!1,handlerBound:!1,handler:(null,()=>{e.gestureUnlocked=!0,e.contexts.forEach((e=>{e&&"function"==typeof e.resume&&"running"!==e.state&&e.resume().then((()=>{e.state})).catch((e=>{}))}))})};window.__YL_AUDIO_UNLOCK_STATE__=e}return window.__YL_AUDIO_UNLOCK_STATE__}function o(e){if(!e)return;const t=s();t.contexts.add(e),function(){const e=s();e.handlerBound||(["click","touchend","pointerdown","keydown"].forEach((t=>{window.addEventListener(t,e.handler,!1)})),e.handlerBound=!0)}(),t.gestureUnlocked&&"function"==typeof e.resume&&"running"!==e.state&&e.resume().then((()=>{e.state})).catch((e=>{}))}t.exports=class{constructor(e={}){this.options={sampleRate:e.sampleRate||r.DEFAULT_SAMPLERATE,appendType:e.appendType||r.APPEND_TYPE_STREAM,playMode:e.playMode||r.AUDIO_MODE_SWAP},this.sourceChannel=-1,this.audioCtx=new a({latencyHint:"interactive",sampleRate:e.sampleRate}),o(this.audioCtx),this.gainNode=null,this.sourceList=[],this.startStatus=!1,this.sampleQueue=[],this.nextBuffer=null,this.playTimestamp=0,this.playTimestampDurMs=0,this.playStartTime=0,this.durationMs=-1,this._player_playbackRate=1,this.buffer_interval=null,this.isLIVE=!1,this.voice=1,this.onLoadCache=null,this.onPlayCallback=null,this.startupMinSampleLen=Math.max(1,Math.min(r.DEFAULT_CONSU_SAMPLE_LEN,e.startupMinSampleLen||r.DEFAULT_CONSU_SAMPLE_LEN)),this.staleDropThresholdMs=Math.max(0,e.staleDropThresholdMs||0),this.staleDropMaxCount=Number.isFinite(e.staleDropMaxCount)?Math.max(1,e.staleDropMaxCount):Number.MAX_SAFE_INTEGER,this.staleDropKeepQueueMin=Number.isFinite(e.staleDropKeepQueueMin)?Math.max(0,e.staleDropKeepQueueMin):0,this.smoothGainMs=Number.isFinite(e.smoothGainMs)?Math.max(0,e.smoothGainMs):0,this._startupPrimed=!1}resumeAudioContext(e="play"){return this.audioCtx&&"function"==typeof this.audioCtx.resume?"running"===this.audioCtx.state?Promise.resolve(!0):this.audioCtx.resume().then((()=>(this.audioCtx.state,!0))).catch((e=>!1)):Promise.resolve(!1)}_createSourceNode(e=-1,t=-1){const i=this.audioCtx.createBufferSource();return i._started=!1,i._connected=!1,i.playbackRate&&(i.playbackRate.value=this._player_playbackRate),i.onended=()=>{i._started=!1,this.swapSource(e,t)},i}_safeConnectSource(e){e&&this.gainNode&&!e._connected&&(e.connect(this.gainNode),e._connected=!0)}_safeDisconnectSource(e){if(e&&e._connected){try{e.disconnect(this.gainNode)}catch(e){console.error("[DEFINE ERROR] disconnect source error happened!",e)}e._connected=!1}}_safeStopSource(e){if(e&&e._started){try{e.stop()}catch(e){console.error("[DEFINE ERROR] stop source error happened!",e)}e._started=!1}}build(){let e=this;this.sourceList.push(this._createSourceNode(0,1)),this.sourceList.push(this._createSourceNode(1,0)),this.sourceList.forEach((t=>{t&&t.playbackRate&&(t.playbackRate.value,e._player_playbackRate,t.playbackRate.value=e._player_playbackRate)})),this.gainNode=this.audioCtx.createGain(),this.gainNode.gain.value=this.voice,this.gainNode.connect(this.audioCtx.destination),this._player_playbackRate=1,this.options,this.runNextBuffer()}resetStartParam(){this.playTimestamp=0,this.playStartTime=0,this._player_playbackRate=1}setOnLoadCache(e){this.onLoadCache=e}setDurationMs(e=-1){this.durationMs=e}setPlaybackRate(e=1){this._player_playbackRate=e,this.gainNode&&this._player_playbackRate>0&&(this._player_playbackRate,this.sourceList,this.sourceList.forEach((e=>{e&&e.playbackRate&&(e.playbackRate.value,this._player_playbackRate,e.playbackRate.value=this._player_playbackRate)})))}setVoice(e=1){if(this.voice=e,this.gainNode){if(this.smoothGainMs>0&&this.audioCtx){const t=this.audioCtx.currentTime||0;try{return this.gainNode.gain.cancelScheduledValues(t),this.gainNode.gain.setValueAtTime(this.gainNode.gain.value,t),void this.gainNode.gain.linearRampToValueAtTime(e,t+this.smoothGainMs/1e3)}catch(e){}}this.gainNode.gain.value=e}}getAlignVPTS(){return this.playTimestamp+(n.GetMsTime()-this.playStartTime)/1e3}getTimestamp(){return this.playTimestamp}getTimestampMs(){return 1e3*this.playTimestamp}getTimestampDurMs(){return this.playTimestampDurMs}check_with_video_pts_ms(e=-1){let t=-1,i=0;const a=this.staleDropThresholdMs>0||this.staleDropKeepQueueMin>0||this.staleDropMaxCount<Number.MAX_SAFE_INTEGER;for(;this.sampleQueue.length>0;)if(t=1e3*this.sampleQueue[0].pts,!a&&t<e){let e=this.sampleQueue.shift();e.data=null,e=null,i++}else{if(!(a&&this.sampleQueue.length>this.staleDropKeepQueueMin&&i<this.staleDropMaxCount&&t<e-this.staleDropThresholdMs))break;{let e=this.sampleQueue.shift();e.data=null,e=null,i++}}return!0}align_start_with_video_pts_ms(e=-1,t=180,i=2){if(e<0||this.sampleQueue.length<=0)return 0;let a=-1,r=0;const n=Math.max(0,i);for(;this.sampleQueue.length>n&&(a=1e3*this.sampleQueue[0].pts,a<e-t);){let e=this.sampleQueue.shift();e.data=null,e=null,r++}return r}swapSource(e=-1,t=-1){if(0==this.startStatus)return-1;if(e<0||e>=this.sourceList.length)return-1;if(t<0||t>=this.sourceList.length)return-1;this.sourceChannel===e&&null!==this.sourceList[e]&&(this._safeDisconnectSource(this.sourceList[e]),this.sourceList[e]=null),this.sourceChannel=t;let i=this.decodeSample(t,e);return-2==i&&this.isLIVE&&(this.getAlignVPTS()>=this.durationMs/1e3-.04?this.pause():null!==this.onLoadCache&&this.onLoadCache()),i}addSample(e=null){return!(null==e||!e||null==e)&&(0==this.sampleQueue.length&&(this.seekPos=e.pts),this.sampleQueue.push(e),!0)}getSampleQueueLen(){return this.sampleQueue.length}runNextBuffer(){let e=this;this.buffer_interval&&(clearInterval(this.buffer_interval),buffer_interval=null),this.buffer_interval=window.setInterval((()=>{const t=e._startupPrimed||!1!==e.startStatus?r.DEFAULT_CONSU_SAMPLE_LEN:e.startupMinSampleLen;if(null!=e.nextBuffer||e.sampleQueue.length<t)return;e.nextBuffer={data:null,pts:-1,duration_ms:-1};let i=null;const a=Math.min(e.sampleQueue.length,t);for(let t=0;t<a;t++){i=e.sampleQueue.shift();let n=null;if(n=e.options.appendType==r.APPEND_TYPE_STREAM?i:i.data,0===t?e.nextBuffer.pts=i.pts:t===a-1&&(e.nextBuffer.duration_ms=Math.round((i.pts-e.nextBuffer.pts)*(a/(a-1))*1e3)),null==e.nextBuffer.data)e.nextBuffer.data=new Uint8Array(n);else{let t=new Uint8Array(n.length+e.nextBuffer.data.length);t.set(e.nextBuffer.data,0),t.set(n,e.nextBuffer.data.length),e.nextBuffer.data=t}if(e.sampleQueue.length<=0)break;i=null}e._startupPrimed=!0}),10)}decodeSample(e=-1,t=-1){let i=this;if(e<0||e>=this.sourceList.length)return-1;if(null!=this.sourceList[e]&&null!=this.sourceList[e]&&this.sourceList[e]||(this.sourceList[e]=this._createSourceNode(e,t),this.sourceList.forEach((e=>{e&&e.playbackRate&&(e.playbackRate.value=i._player_playbackRate)}))),0==this.sampleQueue.length)return this.isLIVE?1:-2;if(this.sourceList[e].buffer)return this.swapSource(e,t),0;if(null==this.nextBuffer||this.nextBuffer.data.length<1)return 1;const a=this.nextBuffer.data.buffer;this.playTimestamp=this.nextBuffer.pts,this.playTimestampDurMs=this.nextBuffer.duration_ms,this.onPlayCallback(this.playTimestamp),this.playStartTime=n.GetMsTime();const r=new Uint8Array(a.slice(0,10));try{this.audioCtx.decodeAudioData(a,(function(t){null!==i.sourceList[e]&&(i.sourceList[e].buffer=t,i._safeConnectSource(i.sourceList[e]),i.sourceList[e]._started||(i.sourceList[e].start(),i.sourceList[e]._started=!0))}),(function(e){console.error("Error this with decoding audio data",e),console.error("Audio header error(HEX):",Array.from(r).map((e=>e.toString(16).padStart(2,"0"))).join(" ")),(255!==r[0]||240&~r[1])&&console.error(" Audio header error! Might caused by wrong adts header bytes data")}))}catch(e){return i.nextBuffer=null,-3}return this.nextBuffer=null,0}decodeWholeSamples(e=-1){let t=this;if(this.sourceChannel=e,e<0||e>=this.sourceList.length)return-1;if(null!=this.sourceList[e]&&null!=this.sourceList[e]&&this.sourceList[e]||(this.sourceList[e]=this._createSourceNode(e,e),this.sourceList.forEach((e=>{e&&e.playbackRate&&(e.playbackRate.value,t._player_playbackRate,e.playbackRate.value=t._player_playbackRate)}))),0==this.sampleQueue.length)return-2;let i=null,a=null;for(let e=0;e<this.sampleQueue.length;e++){a=this.sampleQueue.shift();let e=null;if(e=this.options.appendType==r.APPEND_TYPE_STREAM?a:a.data,null==i)i=new Uint8Array(e);else{let t=new Uint8Array(e.length+i.length);t.set(i,0),t.set(e,i.length),i=t}if(this.sampleQueue.length<=0)break;a=null}let n=i;if(null==n||n.length<1)return 1;let s=n.buffer;try{this.audioCtx.decodeAudioData(s,(function(i){t.sourceList[e].state,t.sourceList[e].buffer=i,t._safeConnectSource(t.sourceList[e]),t.sourceList[e]._started||(t.sourceList[e].start(),t.sourceList[e]._started=!0),t.sourceList[e].state}),(function(e){e.err}))}catch(e){return console.error("Crash[brower]! Please refresh your page"),-3}return 0}play(){if(this.startStatus,this.options.playMode,r.AUDIO_MODE_ONCE,this.resumeAudioContext("play"),0==this.startStatus){this.startStatus=!0;let e=0;e=this.options.playMode==r.AUDIO_MODE_ONCE?this.decodeWholeSamples(0):this.swapSource(0,1),-2==e&&this.pause()}}pause(){this.startStatus=!1,this._startupPrimed=!1;for(let e=0;e<this.sourceList.length;e++)if(void 0!==this.sourceList[e]&&null!==this.sourceList[e]){this.sourceList[e],this.gainNode;try{this._safeStopSource(this.sourceList[e]),this._safeDisconnectSource(this.sourceList[e]),this.sourceList[e]=null}catch(e){console.error("audio pause error ",e)}}}stop(){this.pause(),this.buffer_interval&&(clearInterval(this.buffer_interval),this.buffer_interval=null),this.cleanQueue(),this.nextBuffer=null,this.sourceChannel=-1,function(e){if(!e||!window.__YL_AUDIO_UNLOCK_STATE__)return;const t=window.__YL_AUDIO_UNLOCK_STATE__;t.contexts.delete(e),0===t.contexts.size&&t.handlerBound&&(["click","touchend","pointerdown","keydown"].forEach((e=>{window.removeEventListener(e,t.handler,!1)})),t.handlerBound=!1)}(this.audioCtx)}cleanQueue(){this.sampleQueue.length=0,this._startupPrimed=!1;for(let e=0;e<this.sourceList.length;e++)try{this._safeStopSource(this.sourceList[e]),this._safeDisconnectSource(this.sourceList[e]),this.sourceList[e]=null}catch(e){}}}},{"../av-common":4,"../consts":5}],3:[function(e,t,i){const a=window.AudioContext||window.webkitAudioContext,r=e("../consts"),n=e("../av-common");t.exports=()=>{let e={options:{sampleRate:r.DEFAULT_SAMPLERATE,appendType:r.APPEND_TYPE_FRAME,playMode:r.AUDIO_MODE_SWAP},sourceChannel:-1,audioCtx:new a({latencyHint:"interactive",sampleRate:r.DEFAULT_SAMPLERATE}),gainNode:null,sourceList:[],startStatus:!1,sampleQueue:[],nextBuffer:null,playTimestamp:0,playTimestampDurMs:0,playStartTime:0,durationMs:-1,isLIVE:!1,voice:1,onLoadCache:null,resetStartParam:()=>{e.playTimestamp=0,e.playStartTime=0},setOnLoadCache:t=>{e.onLoadCache=t},setDurationMs:(t=-1)=>{e.durationMs=t},setVoice:(t=1)=>{e.voice=t,e.gainNode.gain.value=t},getAlignVPTS:()=>e.playTimestamp+(n.GetMsTime()-e.playStartTime)/1e3,swapSource:(t=-1,i=-1)=>{if(0==e.startStatus)return null;if(t<0||t>=e.sourceList.length)return null;if(i<0||i>=e.sourceList.length)return null;try{e.sourceChannel===t&&null!==e.sourceList[t]&&(e.sourceList[t].disconnect(e.gainNode),e.sourceList[t]=null)}catch(e){console.error("[DEFINE ERROR] audioPcmModule disconnect source Index:"+t+" error happened!",e)}e.sourceChannel=i;let a=e.decodeSample(i,t);-2==a&&e.isLIVE&&(e.getAlignVPTS()>=e.durationMs/1e3-.04?e.pause():null!==e.onLoadCache&&e.onLoadCache())},addSample:(t=null)=>!(null==t||!t||null==t)&&(0==e.sampleQueue.length&&(e.seekPos=t.pts),e.sampleQueue.push(t),e.sampleQueue.length,!0),getTimestamp:()=>e.playTimestamp,getTimestampMs:()=>1e3*e.playTimestamp,getTimestampDurMs:()=>e.playTimestampDurMs,getSampleQueueLen:()=>e.sampleQueue.length,check_with_video_pts_ms:(t=-1)=>{let i=-1;for(;e.sampleQueue.length>0&&(i=1e3*e.sampleQueue[0].pts,i<t);){let t=e.sampleQueue.shift();t.data=null,t=null}return!0},runNextBuffer:()=>{window.setInterval((()=>{if(null!=e.nextBuffer&&e.nextBuffer.duration_ms>=r.DEFAULT_CONSU_SAMPLE_DUR)return;e.nextBuffer={data:null,pts:-1,duration_ms:0};let t=null,i=0;for(null!=e.nextBuffer&&(i=e.nextBuffer.duration_ms);i<r.DEFAULT_CONSU_SAMPLE_DUR&&(t=e.sampleQueue.shift(),null!=t);){let a=null;if(a=e.options.appendType==r.APPEND_TYPE_STREAM?new Float32Array(t.buffer):new Float32Array(t.data.buffer),e.nextBuffer.pts<0&&(e.nextBuffer.pts=t.pts),null==e.nextBuffer.data)e.nextBuffer.data=a;else{let t=new Float32Array(a.length+e.nextBuffer.data.length);t.set(e.nextBuffer.data,0),t.set(a,e.nextBuffer.data.length),e.nextBuffer.data=t}if(e.nextBuffer.duration_ms=e.nextBuffer.data.length/44100,i=e.nextBuffer.duration_ms,e.sampleQueue.length<=0)break;t=null}if(e.nextBuffer&&e.nextBuffer.data){e.nextBuffer.data.length}}),10)},decodeSample:(t=-1,i=-1)=>{if(t<0||t>=e.sourceList.length)return-1;if(null!=e.sourceList[t]&&null!=e.sourceList[t]&&e.sourceList[t]||(e.sourceList[t]=e.audioCtx.createBufferSource(),e.sourceList[t].onended=function(){e.swapSource(t,i)}),0==e.sampleQueue.length)return e.isLIVE?(e.sourceList[t].connect(e.gainNode),e.sourceList[t].start(),e.sourceList[t].onended=function(){e.swapSource(t,i)},e.sourceList[t].stop(),0):-2;if(e.sourceList[t].buffer)return e.swapSource(t,i),0;if(!e.nextBuffer||!e.nextBuffer.data||e.nextBuffer.data.length<1)return e.sourceList[t].connect(e.gainNode),e.sourceList[t].start(),e.sourceList[t].startState=!0,e.sourceList[t].stop(),1;const a=e.nextBuffer.data;e.playTimestamp=e.nextBuffer.pts,e.playTimestampDurMs=e.nextBuffer.duration_ms,e.playStartTime=n.GetMsTime(),e.nextBuffer.data,e.playTimestamp;try{const i=e.audioCtx.createBuffer(1,a.length,e.options.sampleRate);i.copyToChannel(a,0),null!==e.sourceList[t]&&(e.sourceList[t].buffer=i,e.sourceList[t].connect(e.gainNode),e.sourceList[t].start(),e.sourceList[t].startState=!0)}catch(t){return e.nextBuffer=null,-3}return e.nextBuffer=null,0},decodeWholeSamples:(t=-1)=>{if(e.sourceChannel=t,t<0||t>=e.sourceList.length)return-1;if(null!=e.sourceList[t]&&null!=e.sourceList[t]&&e.sourceList[t]||(e.sourceList[t]=e.audioCtx.createBufferSource(),e.sourceList[t].onended=function(){}),0==e.sampleQueue.length)return-2;let i=null,a=null;for(let t=0;t<e.sampleQueue.length;t++){a=e.sampleQueue.shift();let t=null;if(t=e.options.appendType==r.APPEND_TYPE_STREAM?a:a.data,null==i)i=new Uint8Array(t);else{let e=new Uint8Array(t.length+i.length);e.set(i,0),e.set(t,i.length),i=e}if(e.sampleQueue.length<=0)break;a=null}let n=i;if(null==n||n.length<1)return e.sourceList[t].connect(e.gainNode),e.sourceList[t].start(),e.sourceList[t].stop(),1;let s=n.buffer;try{const i=e.audioCtx.createBuffer(1,s.byteLength,e.options.sampleRate);i.copyToChannel(s,0),e.sourceList[t].buffer=i,e.sourceList[t].connect(e.gainNode),e.sourceList[t].start(),e.sourceList[t].startState=!0}catch(e){return console.error("Crash[brower]! Please refresh your page"),-3}return 0},play:()=>{if(0==e.startStatus){e.startStatus=!0;let t=0;t=e.options.playMode==r.AUDIO_MODE_ONCE?e.decodeWholeSamples(0):e.swapSource(0,1),-2==t&&e.pause()}},pause:()=>{e.startStatus=!1;for(let t=0;t<e.sourceList.length;t++)if(void 0!==e.sourceList[t]&&null!==e.sourceList[t]){e.sourceList[t],e.gainNode;try{void 0!==e.sourceList[t].buffer&&null!==e.sourceList[t].buffer&&(e.sourceList[t].stop(),e.sourceList[t].disconnect(e.gainNode)),e.sourceList[t]=null}catch(e){console.error("audio pause error ",e)}}},stop:()=>{e.pause(),e.cleanQueue(),e.nextBuffer=null,e.sourceChannel=-1},cleanQueue:()=>{e.sampleQueue.length=0;for(let t=0;t<e.sourceList.length;t++)try{void 0!==e.sourceList[t].buffer&&null!==e.sourceList[t].buffer&&(e.sourceList[t].stop(),e.sourceList[t].disconnect(e.gainNode)),e.sourceList[t]=null}catch(e){}}};return e.sourceList.push(e.audioCtx.createBufferSource()),e.sourceList.push(e.audioCtx.createBufferSource()),e.sourceList[0].onended=function(){e.swapSource(0,1)},e.sourceList[1].onended=function(){e.swapSource(1,0)},e.gainNode=e.audioCtx.createGain(),e.gainNode.gain.value=e.voice,e.gainNode.connect(e.audioCtx.destination),e.options,e.runNextBuffer(),e}},{"../av-common":4,"../consts":5}],4:[function(e,t,i){const a=e("./consts"),r=[{format:"mp4",value:"mp4",core:a.PLAYER_CORE_TYPE_CNATIVE},{format:"mov",value:"mp4",core:a.PLAYER_CORE_TYPE_CNATIVE},{format:"mkv",value:"mp4",core:a.PLAYER_CORE_TYPE_CNATIVE},{format:"flv",value:"flv",core:a.PLAYER_CORE_TYPE_CNATIVE},{format:"m3u8",value:"hls",core:a.PLAYER_CORE_TYPE_DEFAULT},{format:"m3u",value:"hls",core:a.PLAYER_CORE_TYPE_DEFAULT},{format:"ts",value:"ts",core:a.PLAYER_CORE_TYPE_DEFAULT},{format:"ps",value:"ts",core:a.PLAYER_CORE_TYPE_DEFAULT},{format:"mpegts",value:"ts",core:a.PLAYER_CORE_TYPE_DEFAULT},{format:"hevc",value:"raw265",core:a.PLAYER_CORE_TYPE_DEFAULT},{format:"h265",value:"raw265",core:a.PLAYER_CORE_TYPE_DEFAULT},{format:"265",value:"raw265",core:a.PLAYER_CORE_TYPE_DEFAULT}],n=[{format:a.URI_PROTOCOL_HTTP,value:a.URI_PROTOCOL_HTTP_DESC},{format:a.URI_PROTOCOL_WEBSOCKET,value:a.URI_PROTOCOL_WEBSOCKET_DESC}];function s(e,t=null){if(null==e)return e;if("string"!=typeof e)return e;const i=e.trim();if(!i)return i;const a="undefined"!=typeof window&&window.location&&window.location.href?window.location.href:"";let r=a;if(t)try{r=new URL(t,a).toString()}catch(e){r=a}try{return r?new URL(i,r).toString():i}catch(t){return e}}t.exports={frameDataAlignCrop:function(e,t,i,a,r,n,s,o){if(0==e-a)return[n,s,o];{let _=a*r,d=_/4,l=new Uint8Array(_),u=new Uint8Array(d),c=new Uint8Array(d),h=a,f=a/2;for(let t=0;t<r;t++)l.set(n.subarray(t*e,h),t*r);for(let e=0;e<r/2;e++)u.set(s.subarray(e*t,f),e*r/2);for(let e=0;e<r/2;e++)c.set(o.subarray(e*i,f),e*r/2);return[l,u,c]}},GetUriFormat:function(e){if(null!=e)for(let t=0;t<r.length;t++){const i=r[t];let a="."+i.format;if(e.search(a)>=0)return i.value,i.value.toLowerCase()}return r[0].value,r[0].value.toLowerCase()},GetFormatPlayCore:function(e){if(null!=e)for(let t=0;t<r.length;t++){const i=r[t];if(i.value===e)return i.core}return r[0].core},GetUriProtocol:function(e){if(null!=e)for(let t=0;t<n.length;t++){const i=n[t];let a=i.format+"[s]{0,}://";if(e.search(a)>=0)return i.value}return n[0].value},GetMsTime:function(){return(new Date).getTime()},GetScriptPath:function(e){let t=[e.toString().match(/^\s*function\s*\(\s*\)\s*\{(([\s\S](?!\}$))*[\s\S])/)[1]];return window.URL.createObjectURL(new Blob(t,{type:"text/javascript"}))},BrowserJudge:function(){let e=window.document,t=window.navigator.userAgent.toLowerCase(),i=e.documentMode,a=window.chrome||!1,r={agent:t,isIE:/msie/.test(t),isGecko:t.indexOf("gecko")>0&&t.indexOf("like gecko")<0,isWebkit:t.indexOf("webkit")>0,isStrict:"CSS1Compat"===e.compatMode,supportSubTitle:function(){return"track"in e.createElement("track")},supportScope:function(){return"scoped"in e.createElement("style")},ieVersion:function(){try{return t.match(/msie ([\d.]+)/)[1]||0}catch(e){return i}},operaVersion:function(){try{if(window.opera)return t.match(/opera.([\d.]+)/)[1];if(t.indexOf("opr")>0)return t.match(/opr\/([\d.]+)/)[1]}catch(e){return 0}},versionFilter:function(){if(1===arguments.length&&"string"==typeof arguments[0]){let e=arguments[0],t=e.indexOf(".");if(t>0){let i=e.indexOf(".",t+1);if(-1!==i)return e.substr(0,i)}return e}return 1===arguments.length?arguments[0]:0}};try{r.type=r.isIE?"IE":window.opera||t.indexOf("opr")>0?"Opera":t.indexOf("chrome")>0?"Chrome":t.indexOf("safari")>0||window.openDatabase?"Safari":t.indexOf("firefox")>0?"Firefox":"unknow",r.version="IE"===r.type?r.ieVersion():"Firefox"===r.type?t.match(/firefox\/([\d.]+)/)[1]:"Chrome"===r.type?t.match(/chrome\/([\d.]+)/)[1]:"Opera"===r.type?r.operaVersion():"Safari"===r.type?t.match(/version\/([\d.]+)/)[1]:"0",r.shell=function(){if(t.indexOf("maxthon")>0)return r.version=t.match(/maxthon\/([\d.]+)/)[1]||r.version,"傲游浏览器";if(t.indexOf("qqbrowser")>0)return r.version=t.match(/qqbrowser\/([\d.]+)/)[1]||r.version,"QQ浏览器";if(t.indexOf("se 2.x")>0)return"搜狗浏览器";if(a&&"Opera"!==r.type){let e=window.external,i=window.clientInformation.languages;if(e&&"LiebaoGetVersion"in e)return"猎豹浏览器";if(t.indexOf("bidubrowser")>0)return r.version=t.match(/bidubrowser\/([\d.]+)/)[1]||t.match(/chrome\/([\d.]+)/)[1],"百度浏览器";if(r.supportSubTitle()&&void 0===i){let e=Object.keys(a.webstore).length;window;return e>1?"360极速浏览器":"360安全浏览器"}return"Chrome"}return r.type},r.name=r.shell(),r.version=r.versionFilter(r.version)}catch(e){}return[r.type,r.version]},ParseGetMediaURL:function(e,t="http"){if("http"!==t&&"ws"!==t&&"wss"!==t&&(e.indexOf("ws")>=0||e.indexOf("wss")>=0)&&(t="ws"),"ws"===t||"wss"===t)return e;let i=e;if(e.indexOf(t)>=0)i=e;else if("/"===e[0])i="/"===e[1]?t+":"+e:window.location.origin+e;else if(":"===e[0])i=t+e;else{let t=window.location.href.split("/");i=window.location.href.replace(t[t.length-1],e)}return i},ResolveURL:s,NormalizeSDKResourceConfig:function(e={}){const t=Object.assign({},e),i="undefined"!=typeof window&&window.location&&window.location.href?window.location.href:"",a=e.base_url&&s(e.base_url,i)||i;return["wasm_js_uri","wasm_wasm_uri","ext_src_js_uri","ext_wasm_js_uri"].forEach((e=>{t[e]&&(t[e]=s(t[e],a))})),t},NormalizeSDKMediaUrl:function(e,t=null){return s(e,t)}}},{"./consts":5}],5:[function(e,t,i){t.exports={H265WEBJS_COMPILE_MULTI_THREAD_SHAREDBUFFER:0,DEFAULT_PLAYERE_LOAD_TIMEOUT:20,DEFAILT_WEBGL_PLAY_ID:"glplayer",PLAYER_IN_TYPE_MP4:"mp4",PLAYER_IN_TYPE_FLV:"flv",PLAYER_IN_TYPE_HTTPFLV:"httpflv",PLAYER_IN_TYPE_RAW_265:"raw265",PLAYER_IN_TYPE_TS:"ts",PLAYER_IN_TYPE_MPEGTS:"mpegts",PLAYER_IN_TYPE_M3U8:"hls",PLAYER_IN_TYPE_M3U8_VOD:"m3u8",PLAYER_IN_TYPE_M3U8_LIVE:"hls",APPEND_TYPE_STREAM:0,APPEND_TYPE_FRAME:1,APPEND_TYPE_SEQUENCE:2,DEFAULT_WIDTH:600,DEFAULT_HEIGHT:600,DEFAULT_FPS:30,DEFAULT_FRAME_DUR:40,DEFAULT_FIXED:!1,DEFAULT_SAMPLERATE:44100,DEFAULT_CHANNELS:2,DEFAULT_CONSU_SAMPLE_LEN:20,DEFAULT_CONSU_SAMPLE_DUR:.4,PLAYER_MODE_VOD:"vod",PLAYER_MODE_NOTIME_LIVE:"live",AUDIO_MODE_ONCE:"ONCE",AUDIO_MODE_SWAP:"SWAP",DEFAULT_STRING_LIVE:"LIVE",CODEC_H265:0,CODEC_H264:1,PLAYER_CORE_TYPE_DEFAULT:0,PLAYER_CORE_TYPE_CNATIVE:1,PLAYER_CNATIVE_VOD_RETRY_MAX:7,URI_PROTOCOL_WEBSOCKET:"ws",URI_PROTOCOL_WEBSOCKET_DESC:"websocket",URI_PROTOCOL_HTTP:"http",URI_PROTOCOL_HTTP_DESC:"http",FETCH_FIRST_MAX_TIMES:5,FETCH_HTTP_FLV_TIMEOUT_MS:7e3,V_CODEC_NAME_HEVC:265,V_CODEC_NAME_AVC:264,V_CODEC_NAME_UNKN:500,A_CODEC_NAME_AAC:112,A_CODEC_NAME_MP3:113,A_CODEC_NAME_UNKN:500,CACHE_NO_LOADCACHE:1001,CACHE_WITH_PLAY_SIGN:1002,CACHE_WITH_NOPLAY_SIGN:1003,V_CODEC_AVC_DEFAULT_FPS:25}},{}],6:[function(e,t,i){(function(e){(function(){var a,r;a=self,r=function(){return function(){var t={"./node_modules/es6-promise/dist/es6-promise.js":
|
|
/*!******************************************************!*\
|
|
!*** ./node_modules/es6-promise/dist/es6-promise.js ***!
|
|
\******************************************************/function(t,i,a){
|
|
/*!
|
|
* @overview es6-promise - a tiny implementation of Promises/A+.
|
|
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
|
|
* @license Licensed under MIT license
|
|
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
|
|
* @version v4.2.8+1e68dce6
|
|
*/
|
|
t.exports=function(){"use strict";function t(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}function i(e){return"function"==typeof e}var r=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},n=0,s=void 0,o=void 0,_=function(e,t){E[n]=e,E[n+1]=t,2===(n+=2)&&(o?o(S):w())};function d(e){o=e}function l(e){_=e}var u="undefined"!=typeof window?window:void 0,c=u||{},h=c.MutationObserver||c.WebKitMutationObserver,f="undefined"==typeof self&&void 0!==e&&"[object process]"==={}.toString.call(e),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function m(){return function(){return e.nextTick(S)}}function g(){return void 0!==s?function(){s(S)}:b()}function y(){var e=0,t=new h(S),i=document.createTextNode("");return t.observe(i,{characterData:!0}),function(){i.data=e=++e%2}}function v(){var e=new MessageChannel;return e.port1.onmessage=S,function(){return e.port2.postMessage(0)}}function b(){var e=setTimeout;return function(){return e(S,1)}}var E=new Array(1e3);function S(){for(var e=0;e<n;e+=2)(0,E[e])(E[e+1]),E[e]=void 0,E[e+1]=void 0;n=0}function A(){try{var e=Function("return this")().require("vertx");return s=e.runOnLoop||e.runOnContext,g()}catch(e){return b()}}var w=void 0;function k(e,t){var i=this,a=new this.constructor(R);void 0===a[L]&&K(a);var r=i._state;if(r){var n=arguments[r-1];_((function(){return z(r,a,n,i._result)}))}else G(i,a,e,t);return a}function T(e){var t=this;if(e&&"object"==typeof e&&e.constructor===t)return e;var i=new t(R);return N(i,e),i}w=f?m():h?y():p?v():void 0===u?A():b();var L=Math.random().toString(36).substring(2);function R(){}var C=void 0,x=1,M=2;function D(){return new TypeError("You cannot resolve a promise with itself")}function O(){return new TypeError("A promises callback cannot return that same promise.")}function I(e,t,i,a){try{e.call(t,i,a)}catch(e){return e}}function P(e,t,i){_((function(e){var a=!1,r=I(i,t,(function(i){a||(a=!0,t!==i?N(e,i):V(e,i))}),(function(t){a||(a=!0,j(e,t))}),"Settle: "+(e._label||" unknown promise"));!a&&r&&(a=!0,j(e,r))}),e)}function B(e,t){t._state===x?V(e,t._result):t._state===M?j(e,t._result):G(t,void 0,(function(t){return N(e,t)}),(function(t){return j(e,t)}))}function U(e,t,a){t.constructor===e.constructor&&a===k&&t.constructor.resolve===T?B(e,t):void 0===a?V(e,t):i(a)?P(e,t,a):V(e,t)}function N(e,i){if(e===i)j(e,D());else if(t(i)){var a=void 0;try{a=i.then}catch(t){return void j(e,t)}U(e,i,a)}else V(e,i)}function F(e){e._onerror&&e._onerror(e._result),H(e)}function V(e,t){e._state===C&&(e._result=t,e._state=x,0!==e._subscribers.length&&_(H,e))}function j(e,t){e._state===C&&(e._state=M,e._result=t,_(F,e))}function G(e,t,i,a){var r=e._subscribers,n=r.length;e._onerror=null,r[n]=t,r[n+x]=i,r[n+M]=a,0===n&&e._state&&_(H,e)}function H(e){var t=e._subscribers,i=e._state;if(0!==t.length){for(var a=void 0,r=void 0,n=e._result,s=0;s<t.length;s+=3)a=t[s],r=t[s+i],a?z(i,a,r,n):r(n);e._subscribers.length=0}}function z(e,t,a,r){var n=i(a),s=void 0,o=void 0,_=!0;if(n){try{s=a(r)}catch(e){_=!1,o=e}if(t===s)return void j(t,O())}else s=r;t._state!==C||(n&&_?N(t,s):!1===_?j(t,o):e===x?V(t,s):e===M&&j(t,s))}function W(e,t){try{t((function(t){N(e,t)}),(function(t){j(e,t)}))}catch(t){j(e,t)}}var q=0;function Y(){return q++}function K(e){e[L]=q++,e._state=void 0,e._result=void 0,e._subscribers=[]}function X(){return new Error("Array Methods must be provided an Array")}var Q=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(R),this.promise[L]||K(this.promise),r(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?V(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&V(this.promise,this._result))):j(this.promise,X())}return e.prototype._enumerate=function(e){for(var t=0;this._state===C&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(e,t){var i=this._instanceConstructor,a=i.resolve;if(a===T){var r=void 0,n=void 0,s=!1;try{r=e.then}catch(e){s=!0,n=e}if(r===k&&e._state!==C)this._settledAt(e._state,t,e._result);else if("function"!=typeof r)this._remaining--,this._result[t]=e;else if(i===ie){var o=new i(R);s?j(o,n):U(o,e,r),this._willSettleAt(o,t)}else this._willSettleAt(new i((function(t){return t(e)})),t)}else this._willSettleAt(a(e),t)},e.prototype._settledAt=function(e,t,i){var a=this.promise;a._state===C&&(this._remaining--,e===M?j(a,i):this._result[t]=i),0===this._remaining&&V(a,this._result)},e.prototype._willSettleAt=function(e,t){var i=this;G(e,void 0,(function(e){return i._settledAt(x,t,e)}),(function(e){return i._settledAt(M,t,e)}))},e}();function J(e){return new Q(this,e).promise}function Z(e){var t=this;return r(e)?new t((function(i,a){for(var r=e.length,n=0;n<r;n++)t.resolve(e[n]).then(i,a)})):new t((function(e,t){return t(new TypeError("You must pass an array to race."))}))}function $(e){var t=new this(R);return j(t,e),t}function ee(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function te(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}var ie=function(){function e(t){this[L]=Y(),this._result=this._state=void 0,this._subscribers=[],R!==t&&("function"!=typeof t&&ee(),this instanceof e?W(this,t):te())}return e.prototype.catch=function(e){return this.then(null,e)},e.prototype.finally=function(e){var t=this,a=t.constructor;return i(e)?t.then((function(t){return a.resolve(e()).then((function(){return t}))}),(function(t){return a.resolve(e()).then((function(){throw t}))})):t.then(e,e)},e}();function ae(){var e=void 0;if(void 0!==a.g)e=a.g;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var i=null;try{i=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===i&&!t.cast)return}e.Promise=ie}return ie.prototype.then=k,ie.all=J,ie.race=Z,ie.resolve=T,ie.reject=$,ie._setScheduler=d,ie._setAsap=l,ie._asap=_,ie.polyfill=ae,ie.Promise=ie,ie}()},"./node_modules/events/events.js":
|
|
/*!***************************************!*\
|
|
!*** ./node_modules/events/events.js ***!
|
|
\***************************************/function(e){"use strict";var t,i="object"==typeof Reflect?Reflect:null,a=i&&"function"==typeof i.apply?i.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};t=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function n(){n.init.call(this)}e.exports=n,e.exports.once=function(e,t){return new Promise((function(i,a){function r(i){e.removeListener(t,n),a(i)}function n(){"function"==typeof e.removeListener&&e.removeListener("error",r),i([].slice.call(arguments))}p(e,t,n,{once:!0}),"error"!==t&&function(e,t,i){"function"==typeof e.on&&p(e,"error",t,i)}(e,r,{once:!0})}))},n.EventEmitter=n,n.prototype._events=void 0,n.prototype._eventsCount=0,n.prototype._maxListeners=void 0;var s=10;function o(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function _(e){return void 0===e._maxListeners?n.defaultMaxListeners:e._maxListeners}function d(e,t,i,a){var r,n,s;if(o(i),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),n=e._events),s=n[t]),void 0===s)s=n[t]=i,++e._eventsCount;else if("function"==typeof s?s=n[t]=a?[i,s]:[s,i]:a?s.unshift(i):s.push(i),(r=_(e))>0&&s.length>r&&!s.warned){s.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=s.length,console&&console.warn}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(e,t,i){var a={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=l.bind(a);return r.listener=i,a.wrapFn=r,r}function c(e,t,i){var a=e._events;if(void 0===a)return[];var r=a[t];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(r):f(r,r.length)}function h(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function f(e,t){for(var i=new Array(t),a=0;a<t;++a)i[a]=e[a];return i}function p(e,t,i,a){if("function"==typeof e.on)a.once?e.once(t,i):e.on(t,i);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function r(n){a.once&&e.removeEventListener(t,r),i(n)}))}}Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),n.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},n.prototype.getMaxListeners=function(){return _(this)},n.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r="error"===e,n=this._events;if(void 0!==n)r=r&&void 0===n.error;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var _=n[e];if(void 0===_)return!1;if("function"==typeof _)a(_,this,t);else{var d=_.length,l=f(_,d);for(i=0;i<d;++i)a(l[i],this,t)}return!0},n.prototype.addListener=function(e,t){return d(this,e,t,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(e,t){return d(this,e,t,!0)},n.prototype.once=function(e,t){return o(t),this.on(e,u(this,e,t)),this},n.prototype.prependOnceListener=function(e,t){return o(t),this.prependListener(e,u(this,e,t)),this},n.prototype.removeListener=function(e,t){var i,a,r,n,s;if(o(t),void 0===(a=this._events))return this;if(void 0===(i=a[e]))return this;if(i===t||i.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete a[e],a.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(r=-1,n=i.length-1;n>=0;n--)if(i[n]===t||i[n].listener===t){s=i[n].listener,r=n;break}if(r<0)return this;0===r?i.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(i,r),1===i.length&&(a[e]=i[0]),void 0!==a.removeListener&&this.emit("removeListener",e,s||t)}return this},n.prototype.off=n.prototype.removeListener,n.prototype.removeAllListeners=function(e){var t,i,a;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var r,n=Object.keys(i);for(a=0;a<n.length;++a)"removeListener"!==(r=n[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(void 0!==t)for(a=t.length-1;a>=0;a--)this.removeListener(e,t[a]);return this},n.prototype.listeners=function(e){return c(this,e,!0)},n.prototype.rawListeners=function(e){return c(this,e,!1)},n.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},n.prototype.listenerCount=h,n.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},"./node_modules/webworkify-webpack/index.js":
|
|
/*!**************************************************!*\
|
|
!*** ./node_modules/webworkify-webpack/index.js ***!
|
|
\**************************************************/function(e,t,i){function a(e){var t={};function i(a){if(t[a])return t[a].exports;var r=t[a]={i:a,l:!1,exports:{}};return e[a].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=e,i.c=t,i.i=function(e){return e},i.d=function(e,t,a){i.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:a})},i.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/",i.oe=function(e){throw console.error(e),e};var a=i(i.s=ENTRY_MODULE);return a.default||a}var r="[\\.|\\-|\\+|\\w|/|@]+",n="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+r+").*?\\)";function s(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(e,t,a){var o={};o[a]=[];var _=t.toString(),d=_.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!d)return o;for(var l,u=d[1],c=new RegExp("(\\\\n|\\W)"+s(u)+n,"g");l=c.exec(_);)"dll-reference"!==l[3]&&o[a].push(l[3]);for(c=new RegExp("\\("+s(u)+'\\("(dll-reference\\s('+r+'))"\\)\\)'+n,"g");l=c.exec(_);)e[l[2]]||(o[a].push(l[1]),e[l[2]]=i(l[1]).m),o[l[2]]=o[l[2]]||[],o[l[2]].push(l[4]);for(var h,f=Object.keys(o),p=0;p<f.length;p++)for(var m=0;m<o[f[p]].length;m++)h=o[f[p]][m],isNaN(1*h)||(o[f[p]][m]=1*o[f[p]][m]);return o}function _(e){return Object.keys(e).reduce((function(t,i){return t||e[i].length>0}),!1)}e.exports=function(e,t){t=t||{};var r={main:i.m},n=t.all?{main:Object.keys(r.main)}:function(e,t){for(var i={main:[t]},a={main:[]},r={main:{}};_(i);)for(var n=Object.keys(i),s=0;s<n.length;s++){var d=n[s],l=i[d].pop();if(r[d]=r[d]||{},!r[d][l]&&e[d][l]){r[d][l]=!0,a[d]=a[d]||[],a[d].push(l);for(var u=o(e,e[d][l],d),c=Object.keys(u),h=0;h<c.length;h++)i[c[h]]=i[c[h]]||[],i[c[h]]=i[c[h]].concat(u[c[h]])}}return a}(r,e),s="";Object.keys(n).filter((function(e){return"main"!==e})).forEach((function(e){for(var t=0;n[e][t];)t++;n[e].push(t),r[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",s=s+"var "+e+" = ("+a.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+n[e].map((function(t){return JSON.stringify(t)+": "+r[e][t].toString()})).join(",")+"});\n"})),s=s+"new (("+a.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+n.main.map((function(e){return JSON.stringify(e)+": "+r.main[e].toString()})).join(",")+"}))(self);";var d=new window.Blob([s],{type:"text/javascript"});if(t.bare)return d;var l=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(d),u=new window.Worker(l);return u.objectURL=l,u}},"./src/config.js":
|
|
/*!***********************!*\
|
|
!*** ./src/config.js ***!
|
|
\***********************/function(e,t,i){"use strict";i.r(t),i.d(t,{defaultConfig:function(){return a},createDefaultConfig:function(){return r}});var a={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:180,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0};function r(){return Object.assign({},a)}},"./src/core/features.js":
|
|
/*!******************************!*\
|
|
!*** ./src/core/features.js ***!
|
|
\******************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! ../io/io-controller.js */"./src/io/io-controller.js"),r=i(/*! ../config.js */"./src/config.js"),n=function(){function e(){}return e.supportMSEH264Playback=function(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')},e.supportNetworkStreamIO=function(){var e=new a.default({},(0,r.createDefaultConfig)()),t=e.loaderType;return e.destroy(),"fetch-stream-loader"==t||"xhr-moz-chunked-loader"==t},e.getNetworkLoaderTypeName=function(){var e=new a.default({},(0,r.createDefaultConfig)()),t=e.loaderType;return e.destroy(),t},e.supportNativeMediaPlayback=function(t){null==e.videoElement&&(e.videoElement=window.document.createElement("video"));var i=e.videoElement.canPlayType(t);return"probably"===i||"maybe"==i},e.getFeatureList=function(){var t={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeMP4H265Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return t.mseFlvPlayback=e.supportMSEH264Playback(),t.networkStreamIO=e.supportNetworkStreamIO(),t.networkLoaderName=e.getNetworkLoaderTypeName(),t.mseLiveFlvPlayback=t.mseFlvPlayback&&t.networkStreamIO,t.nativeMP4H264Playback=e.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),t.nativeMP4H265Playback=e.supportNativeMediaPlayback('video/mp4; codecs="hvc1.1.6.L93.B0"'),t.nativeWebmVP8Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),t.nativeWebmVP9Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp9"'),t},e}();t.default=n},"./src/core/media-info.js":
|
|
/*!********************************!*\
|
|
!*** ./src/core/media-info.js ***!
|
|
\********************************/function(e,t,i){"use strict";i.r(t);var a=function(){function e(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}return e.prototype.isComplete=function(){var e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=this.videoCodec&&null!=this.width&&null!=this.height&&null!=this.fps&&null!=this.profile&&null!=this.level&&null!=this.refFrames&&null!=this.chromaFormat&&null!=this.sarNum&&null!=this.sarDen;return null!=this.mimeType&&null!=this.duration&&null!=this.metadata&&null!=this.hasKeyframesIndex&&e&&t},e.prototype.isSeekable=function(){return!0===this.hasKeyframesIndex},e.prototype.getNearestKeyframe=function(e){if(null==this.keyframesIndex)return null;var t=this.keyframesIndex,i=this._search(t.times,e);return{index:i,milliseconds:t.times[i],fileposition:t.filepositions[i]}},e.prototype._search=function(e,t){var i=0,a=e.length-1,r=0,n=0,s=a;for(t<e[0]&&(i=0,n=s+1);n<=s;){if((r=n+Math.floor((s-n)/2))===a||t>=e[r]&&t<e[r+1]){i=r;break}e[r]<t?n=r+1:s=r-1}return i},e}();t.default=a},"./src/core/media-segment-info.js":
|
|
/*!****************************************!*\
|
|
!*** ./src/core/media-segment-info.js ***!
|
|
\****************************************/function(e,t,i){"use strict";i.r(t),i.d(t,{SampleInfo:function(){return a},MediaSegmentInfo:function(){return r},IDRSampleList:function(){return n},MediaSegmentInfoList:function(){return s}});var a=function(e,t,i,a,r){this.dts=e,this.pts=t,this.duration=i,this.originalDts=a,this.isSyncPoint=r,this.fileposition=null},r=function(){function e(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}return e.prototype.appendSyncPoint=function(e){e.isSyncPoint=!0,this.syncPoints.push(e)},e}(),n=function(){function e(){this._list=[]}return e.prototype.clear=function(){this._list=[]},e.prototype.appendArray=function(e){var t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts<t[t.length-1].originalDts&&this.clear(),Array.prototype.push.apply(t,e))},e.prototype.getLastSyncPointBeforeDts=function(e){if(0==this._list.length)return null;var t=this._list,i=0,a=t.length-1,r=0,n=0,s=a;for(e<t[0].dts&&(i=0,n=s+1);n<=s;){if((r=n+Math.floor((s-n)/2))===a||e>=t[r].dts&&e<t[r+1].dts){i=r;break}t[r].dts<e?n=r+1:s=r-1}return this._list[i]},e}(),s=function(){function e(e){this._type=e,this._list=[],this._lastAppendLocation=-1}return Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._list.length},enumerable:!1,configurable:!0}),e.prototype.isEmpty=function(){return 0===this._list.length},e.prototype.clear=function(){this._list=[],this._lastAppendLocation=-1},e.prototype._searchNearestSegmentBefore=function(e){var t=this._list;if(0===t.length)return-2;var i=t.length-1,a=0,r=0,n=i,s=0;if(e<t[0].originalBeginDts)return s=-1;for(;r<=n;){if((a=r+Math.floor((n-r)/2))===i||e>t[a].lastSample.originalDts&&e<t[a+1].originalBeginDts){s=a;break}t[a].originalBeginDts<e?r=a+1:n=a-1}return s},e.prototype._searchNearestSegmentAfter=function(e){return this._searchNearestSegmentBefore(e)+1},e.prototype.append=function(e){var t=this._list,i=e,a=this._lastAppendLocation,r=0;-1!==a&&a<t.length&&i.originalBeginDts>=t[a].lastSample.originalDts&&(a===t.length-1||a<t.length-1&&i.originalBeginDts<t[a+1].originalBeginDts)?r=a+1:t.length>0&&(r=this._searchNearestSegmentBefore(i.originalBeginDts)+1),this._lastAppendLocation=r,this._list.splice(r,0,i)},e.prototype.getLastSegmentBefore=function(e){var t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null},e.prototype.getLastSampleBefore=function(e){var t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null},e.prototype.getLastSyncPointBefore=function(e){for(var t=this._searchNearestSegmentBefore(e),i=this._list[t].syncPoints;0===i.length&&t>0;)t--,i=this._list[t].syncPoints;return i.length>0?i[i.length-1]:null},e}()},"./src/core/mse-controller.js":
|
|
/*!************************************!*\
|
|
!*** ./src/core/mse-controller.js ***!
|
|
\************************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! events */"./node_modules/events/events.js"),r=i.n(a),n=i(/*! ../utils/logger.js */"./src/utils/logger.js"),s=i(/*! ../utils/browser.js */"./src/utils/browser.js"),o=i(/*! ./mse-events.js */"./src/core/mse-events.js"),_=i(/*! ./media-segment-info.js */"./src/core/media-segment-info.js"),d=i(/*! ../utils/exception.js */"./src/utils/exception.js"),l=function(){function e(e){this.TAG="MSEController",this._config=e,this._emitter=new(r()),this._config.isLive&&null==this._config.autoCleanupSourceBuffer&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new _.IDRSampleList}return e.prototype.destroy=function(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){if(this._mediaSource)throw new d.IllegalStateException("MediaSource has been attached to an HTMLMediaElement!");var t=this._mediaSource=new window.MediaSource;t.addEventListener("sourceopen",this.e.onSourceOpen),t.addEventListener("sourceended",this.e.onSourceEnded),t.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=e,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),e.src=this._mediaSourceObjectURL},e.prototype.detachMediaElement=function(){if(this._mediaSource){var e=this._mediaSource;for(var t in this._sourceBuffers){var i=this._pendingSegments[t];i.splice(0,i.length),this._pendingSegments[t]=null,this._pendingRemoveRanges[t]=null,this._lastInitSegments[t]=null;var a=this._sourceBuffers[t];if(a){if("closed"!==e.readyState){try{e.removeSourceBuffer(a)}catch(e){n.default.e(this.TAG,e.message)}a.removeEventListener("error",this.e.onSourceBufferError),a.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[t]=null,this._sourceBuffers[t]=null}}if("open"===e.readyState)try{e.endOfStream()}catch(e){n.default.e(this.TAG,e.message)}e.removeEventListener("sourceopen",this.e.onSourceOpen),e.removeEventListener("sourceended",this.e.onSourceEnded),e.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)},e.prototype.appendInitSegment=function(e,t){if(!this._mediaSource||"open"!==this._mediaSource.readyState)return this._pendingSourceBufferInit.push(e),void this._pendingSegments[e.type].push(e);var i=e,a=""+i.container;i.codec&&i.codec.length>0&&(a+=";codecs="+i.codec);var r=!1;if(n.default.v(this.TAG,"Received Initialization Segment, mimeType: "+a),this._lastInitSegments[i.type]=i,a!==this._mimeTypes[i.type]){if(this._mimeTypes[i.type])n.default.v(this.TAG,"Notice: "+i.type+" mimeType changed, origin: "+this._mimeTypes[i.type]+", target: "+a);else{r=!0;try{var _=this._sourceBuffers[i.type]=this._mediaSource.addSourceBuffer(a);_.addEventListener("error",this.e.onSourceBufferError),_.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return n.default.e(this.TAG,e.message),void this._emitter.emit(o.default.ERROR,{code:e.code,msg:e.message})}}this._mimeTypes[i.type]=a}t||this._pendingSegments[i.type].push(i),r||this._sourceBuffers[i.type]&&!this._sourceBuffers[i.type].updating&&this._doAppendSegments(),s.default.safari&&"audio/mpeg"===i.container&&i.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=i.mediaDuration/1e3,this._updateMediaSourceDuration())},e.prototype.appendMediaSegment=function(e){var t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var i=this._sourceBuffers[t.type];!i||i.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()},e.prototype.seek=function(e){for(var t in this._sourceBuffers)if(this._sourceBuffers[t]){var i=this._sourceBuffers[t];if("open"===this._mediaSource.readyState)try{i.abort()}catch(e){n.default.e(this.TAG,e.message)}this._idrList.clear();var a=this._pendingSegments[t];if(a.splice(0,a.length),"closed"!==this._mediaSource.readyState){for(var r=0;r<i.buffered.length;r++){var o=i.buffered.start(r),_=i.buffered.end(r);this._pendingRemoveRanges[t].push({start:o,end:_})}if(i.updating||this._doRemoveRanges(),s.default.safari){var d=this._lastInitSegments[t];d&&(this._pendingSegments[t].push(d),i.updating||this._doAppendSegments())}}}},e.prototype.endOfStream=function(){var e=this._mediaSource,t=this._sourceBuffers;e&&"open"===e.readyState?t.video&&t.video.updating||t.audio&&t.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,e.endOfStream()):e&&"closed"===e.readyState&&this._hasPendingSegments()&&(this._hasPendingEos=!0)},e.prototype.getNearestKeyframe=function(e){return this._idrList.getLastSyncPointBeforeDts(e)},e.prototype._needCleanupSourceBuffer=function(){if(!this._config.autoCleanupSourceBuffer)return!1;var e=this._mediaElement.currentTime;for(var t in this._sourceBuffers){var i=this._sourceBuffers[t];if(i){var a=i.buffered;if(a.length>=1&&e-a.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1},e.prototype._doCleanupSourceBuffer=function(){var e=this._mediaElement.currentTime;for(var t in this._sourceBuffers){var i=this._sourceBuffers[t];if(i){for(var a=i.buffered,r=!1,n=0;n<a.length;n++){var s=a.start(n),o=a.end(n);if(s<=e&&e<o+3){if(e-s>=this._config.autoCleanupMaxBackwardDuration){r=!0;var _=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:s,end:_})}}else o<e&&(r=!0,this._pendingRemoveRanges[t].push({start:s,end:o}))}r&&!i.updating&&this._doRemoveRanges()}}},e.prototype._updateMediaSourceDuration=function(){var e=this._sourceBuffers;if(0!==this._mediaElement.readyState&&"open"===this._mediaSource.readyState&&!(e.video&&e.video.updating||e.audio&&e.audio.updating)){var t=this._mediaSource.duration,i=this._pendingMediaDuration;i>0&&(isNaN(t)||i>t)&&(n.default.v(this.TAG,"Update MediaSource duration from "+t+" to "+i),this._mediaSource.duration=i),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}},e.prototype._doRemoveRanges=function(){for(var e in this._pendingRemoveRanges)if(this._sourceBuffers[e]&&!this._sourceBuffers[e].updating)for(var t=this._sourceBuffers[e],i=this._pendingRemoveRanges[e];i.length&&!t.updating;){var a=i.shift();t.remove(a.start,a.end)}},e.prototype._doAppendSegments=function(){var e=this._pendingSegments;for(var t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){var i=e[t].shift();if(i.timestampOffset){var a=this._sourceBuffers[t].timestampOffset,r=i.timestampOffset/1e3;Math.abs(a-r)>.1&&(n.default.v(this.TAG,"Update MPEG audio timestampOffset from "+a+" to "+r),this._sourceBuffers[t].timestampOffset=r),delete i.timestampOffset}if(!i.data||0===i.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(i.data),this._isBufferFull=!1,"video"===t&&i.hasOwnProperty("info")&&this._idrList.appendArray(i.info.syncPoints)}catch(e){this._pendingSegments[t].unshift(i),22===e.code?(this._isBufferFull||this._emitter.emit(o.default.BUFFER_FULL),this._isBufferFull=!0):(n.default.e(this.TAG,t,e.message),this._emitter.emit(o.default.ERROR,{code:e.code,msg:e.message}))}}},e.prototype._onSourceOpen=function(){if(n.default.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var e=this._pendingSourceBufferInit;e.length;){var t=e.shift();this.appendInitSegment(t,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(o.default.SOURCE_OPEN)},e.prototype._onSourceEnded=function(){n.default.v(this.TAG,"MediaSource onSourceEnded")},e.prototype._onSourceClose=function(){n.default.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))},e.prototype._hasPendingSegments=function(){var e=this._pendingSegments;return(e.video&&e.video.length)>0||e.audio&&e.audio.length>0},e.prototype._hasPendingRemoveRanges=function(){var e=this._pendingRemoveRanges;return(e.video&&e.video.length)>0||e.audio&&e.audio.length>0},e.prototype._onSourceBufferUpdateEnd=function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(o.default.UPDATE_END)},e.prototype._onSourceBufferError=function(e){n.default.e(this.TAG,"SourceBuffer Error: "+e)},e}();t.default=l},"./src/core/mse-events.js":
|
|
/*!********************************!*\
|
|
!*** ./src/core/mse-events.js ***!
|
|
\********************************/function(e,t,i){"use strict";i.r(t),t.default={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"}},"./src/core/transmuxer.js":
|
|
/*!********************************!*\
|
|
!*** ./src/core/transmuxer.js ***!
|
|
\********************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! events */"./node_modules/events/events.js"),r=i.n(a),n=i(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js"),s=i.n(n),o=i(/*! ../utils/logger.js */"./src/utils/logger.js"),_=i(/*! ../utils/logging-control.js */"./src/utils/logging-control.js"),d=i(/*! ./transmuxing-controller.js */"./src/core/transmuxing-controller.js"),l=i(/*! ./transmuxing-events.js */"./src/core/transmuxing-events.js"),u=i(/*! ./media-info.js */"./src/core/media-info.js"),c=function(){function e(e,t){if(this.TAG="Transmuxer",this._emitter=new(r()),t.enableWorker&&"undefined"!=typeof Worker)try{this._worker=s()(/*! ./transmuxing-worker */"./src/core/transmuxing-worker.js"),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[e,t]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},_.default.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:_.default.getConfig()})}catch(i){o.default.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new d.default(e,t)}else this._controller=new d.default(e,t);if(this._controller){var i=this._controller;i.on(l.default.IO_ERROR,this._onIOError.bind(this)),i.on(l.default.DEMUX_ERROR,this._onDemuxError.bind(this)),i.on(l.default.INIT_SEGMENT,this._onInitSegment.bind(this)),i.on(l.default.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),i.on(l.default.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),i.on(l.default.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),i.on(l.default.MEDIA_INFO,this._onMediaInfo.bind(this)),i.on(l.default.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),i.on(l.default.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),i.on(l.default.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),i.on(l.default.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}return e.prototype.destroy=function(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),_.default.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.hasWorker=function(){return null!=this._worker},e.prototype.open=function(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()},e.prototype.close=function(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()},e.prototype.seek=function(e){this._worker?this._worker.postMessage({cmd:"seek",param:e}):this._controller.seek(e)},e.prototype.pause=function(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()},e.prototype.resume=function(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()},e.prototype._onInitSegment=function(e,t){var i=this;Promise.resolve().then((function(){i._emitter.emit(l.default.INIT_SEGMENT,e,t)}))},e.prototype._onMediaSegment=function(e,t){var i=this;Promise.resolve().then((function(){i._emitter.emit(l.default.MEDIA_SEGMENT,e,t)}))},e.prototype._onLoadingComplete=function(){var e=this;Promise.resolve().then((function(){e._emitter.emit(l.default.LOADING_COMPLETE)}))},e.prototype._onRecoveredEarlyEof=function(){var e=this;Promise.resolve().then((function(){e._emitter.emit(l.default.RECOVERED_EARLY_EOF)}))},e.prototype._onMediaInfo=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.default.MEDIA_INFO,e)}))},e.prototype._onMetaDataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.default.METADATA_ARRIVED,e)}))},e.prototype._onScriptDataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.default.SCRIPTDATA_ARRIVED,e)}))},e.prototype._onStatisticsInfo=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.default.STATISTICS_INFO,e)}))},e.prototype._onIOError=function(e,t){var i=this;Promise.resolve().then((function(){i._emitter.emit(l.default.IO_ERROR,e,t)}))},e.prototype._onDemuxError=function(e,t){var i=this;Promise.resolve().then((function(){i._emitter.emit(l.default.DEMUX_ERROR,e,t)}))},e.prototype._onRecommendSeekpoint=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.default.RECOMMEND_SEEKPOINT,e)}))},e.prototype._onLoggingConfigChanged=function(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})},e.prototype._onWorkerMessage=function(e){var t=e.data,i=t.data;if("destroyed"===t.msg||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(t.msg){case l.default.INIT_SEGMENT:case l.default.MEDIA_SEGMENT:this._emitter.emit(t.msg,i.type,i.data);break;case l.default.LOADING_COMPLETE:case l.default.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case l.default.MEDIA_INFO:Object.setPrototypeOf(i,u.default.prototype),this._emitter.emit(t.msg,i);break;case l.default.METADATA_ARRIVED:case l.default.SCRIPTDATA_ARRIVED:case l.default.STATISTICS_INFO:this._emitter.emit(t.msg,i);break;case l.default.IO_ERROR:case l.default.DEMUX_ERROR:this._emitter.emit(t.msg,i.type,i.info);break;case l.default.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,i);break;case"logcat_callback":o.default.emitter.emit("log",i.type,i.logcat)}},e}();t.default=c},"./src/core/transmuxing-controller.js":
|
|
/*!********************************************!*\
|
|
!*** ./src/core/transmuxing-controller.js ***!
|
|
\********************************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! events */"./node_modules/events/events.js"),r=i.n(a),n=i(/*! ../utils/logger.js */"./src/utils/logger.js"),s=i(/*! ../utils/browser.js */"./src/utils/browser.js"),o=i(/*! ./media-info.js */"./src/core/media-info.js"),_=i(/*! ../demux/flv-demuxer.js */"./src/demux/flv-demuxer.js"),d=i(/*! ../remux/mp4-remuxer.js */"./src/remux/mp4-remuxer.js"),l=i(/*! ../demux/demux-errors.js */"./src/demux/demux-errors.js"),u=i(/*! ../io/io-controller.js */"./src/io/io-controller.js"),c=i(/*! ./transmuxing-events.js */"./src/core/transmuxing-events.js"),h=function(){function e(e,t){this.TAG="TransmuxingController",this._emitter=new(r()),this._config=t,e.segments||(e.segments=[{duration:e.duration,filesize:e.filesize,url:e.url}]),"boolean"!=typeof e.cors&&(e.cors=!0),"boolean"!=typeof e.withCredentials&&(e.withCredentials=!1),this._mediaDataSource=e,this._currentSegmentIndex=0;var i=0;this._mediaDataSource.segments.forEach((function(a){a.timestampBase=i,i+=a.duration,a.cors=e.cors,a.withCredentials=e.withCredentials,t.referrerPolicy&&(a.referrerPolicy=t.referrerPolicy)})),isNaN(i)||this._mediaDataSource.duration===i||(this._mediaDataSource.duration=i),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}return e.prototype.destroy=function(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.start=function(){this._loadSegment(0),this._enableStatisticsReporter()},e.prototype._loadSegment=function(e,t){this._currentSegmentIndex=e;var i=this._mediaDataSource.segments[e],a=this._ioctl=new u.default(i,this._config,e);a.onError=this._onIOException.bind(this),a.onSeeked=this._onIOSeeked.bind(this),a.onComplete=this._onIOComplete.bind(this),a.onRedirect=this._onIORedirect.bind(this),a.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),t?this._demuxer.bindDataSource(this._ioctl):a.onDataArrival=this._onInitChunkArrival.bind(this),a.open(t)},e.prototype.stop=function(){this._internalAbort(),this._disableStatisticsReporter()},e.prototype._internalAbort=function(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)},e.prototype.pause=function(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())},e.prototype.resume=function(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())},e.prototype.seek=function(e){if(null!=this._mediaInfo&&this._mediaInfo.isSeekable()){var t=this._searchSegmentIndexContains(e);if(t===this._currentSegmentIndex){var i=this._mediaInfo.segments[t];if(null==i)this._pendingSeekTime=e;else{var a=i.getNearestKeyframe(e);this._remuxer.seek(a.milliseconds),this._ioctl.seek(a.fileposition),this._pendingResolveSeekPoint=a.milliseconds}}else{var r=this._mediaInfo.segments[t];null==r?(this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t)):(a=r.getNearestKeyframe(e),this._internalAbort(),this._remuxer.seek(e),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[t].timestampBase,this._loadSegment(t,a.fileposition),this._pendingResolveSeekPoint=a.milliseconds,this._reportSegmentMediaInfo(t))}this._enableStatisticsReporter()}},e.prototype._searchSegmentIndexContains=function(e){for(var t=this._mediaDataSource.segments,i=t.length-1,a=0;a<t.length;a++)if(e<t[a].timestampBase){i=a-1;break}return i},e.prototype._onInitChunkArrival=function(e,t){var i=this,a=null,r=0;if(t>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,r=this._demuxer.parseChunks(e,t);else if((a=_.default.probe(e)).match){this._demuxer=new _.default(a,this._config),this._remuxer||(this._remuxer=new d.default(this._config));var s=this._mediaDataSource;null==s.duration||isNaN(s.duration)||(this._demuxer.overridedDuration=s.duration),"boolean"==typeof s.hasAudio&&(this._demuxer.overridedHasAudio=s.hasAudio),"boolean"==typeof s.hasVideo&&(this._demuxer.overridedHasVideo=s.hasVideo),this._demuxer.timestampBase=s.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),r=this._demuxer.parseChunks(e,t)}else a=null,n.default.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then((function(){i._internalAbort()})),this._emitter.emit(c.default.DEMUX_ERROR,l.default.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),r=0;return r},e.prototype._onMediaInfo=function(e){var t=this;null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,o.default.prototype));var i=Object.assign({},e);Object.setPrototypeOf(i,o.default.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=i,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then((function(){var e=t._pendingSeekTime;t._pendingSeekTime=null,t.seek(e)}))},e.prototype._onMetaDataArrived=function(e){this._emitter.emit(c.default.METADATA_ARRIVED,e)},e.prototype._onScriptDataArrived=function(e){this._emitter.emit(c.default.SCRIPTDATA_ARRIVED,e)},e.prototype._onIOSeeked=function(){this._remuxer.insertDiscontinuity()},e.prototype._onIOComplete=function(e){var t=e+1;t<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer.flushStashedSamples(),this._loadSegment(t)):(this._remuxer.flushStashedSamples(),this._emitter.emit(c.default.LOADING_COMPLETE),this._disableStatisticsReporter())},e.prototype._onIORedirect=function(e){var t=this._ioctl.extraData;this._mediaDataSource.segments[t].redirectedURL=e},e.prototype._onIORecoveredEarlyEof=function(){this._emitter.emit(c.default.RECOVERED_EARLY_EOF)},e.prototype._onIOException=function(e,t){n.default.e(this.TAG,"IOException: type = "+e+", code = "+t.code+", msg = "+t.msg),this._emitter.emit(c.default.IO_ERROR,e,t),this._disableStatisticsReporter()},e.prototype._onDemuxException=function(e,t){n.default.e(this.TAG,"DemuxException: type = "+e+", info = "+t),this._emitter.emit(c.default.DEMUX_ERROR,e,t)},e.prototype._onRemuxerInitSegmentArrival=function(e,t){this._emitter.emit(c.default.INIT_SEGMENT,e,t)},e.prototype._onRemuxerMediaSegmentArrival=function(e,t){if(null==this._pendingSeekTime&&(this._emitter.emit(c.default.MEDIA_SEGMENT,e,t),null!=this._pendingResolveSeekPoint&&"video"===e)){var i=t.info.syncPoints,a=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,s.default.safari&&i.length>0&&i[0].originalDts===a&&(a=i[0].pts),this._emitter.emit(c.default.RECOMMEND_SEEKPOINT,a)}},e.prototype._enableStatisticsReporter=function(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))},e.prototype._disableStatisticsReporter=function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype._reportSegmentMediaInfo=function(e){var t=this._mediaInfo.segments[e],i=Object.assign({},t);i.duration=this._mediaInfo.duration,i.segmentCount=this._mediaInfo.segmentCount,delete i.segments,delete i.keyframesIndex,this._emitter.emit(c.default.MEDIA_INFO,i)},e.prototype._reportStatisticsInfo=function(){var e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(c.default.STATISTICS_INFO,e)},e}();t.default=h},"./src/core/transmuxing-events.js":
|
|
/*!****************************************!*\
|
|
!*** ./src/core/transmuxing-events.js ***!
|
|
\****************************************/function(e,t,i){"use strict";i.r(t),t.default={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"}},"./src/core/transmuxing-worker.js":
|
|
/*!****************************************!*\
|
|
!*** ./src/core/transmuxing-worker.js ***!
|
|
\****************************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! ../utils/logging-control.js */"./src/utils/logging-control.js"),r=i(/*! ../utils/polyfill.js */"./src/utils/polyfill.js"),n=i(/*! ./transmuxing-controller.js */"./src/core/transmuxing-controller.js"),s=i(/*! ./transmuxing-events.js */"./src/core/transmuxing-events.js");t.default=function(e){var t=null,i=function(t,i){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:i}})}.bind(this);function o(t,i){var a={msg:s.default.INIT_SEGMENT,data:{type:t,data:i}};e.postMessage(a,[i.data])}function _(t,i){var a={msg:s.default.MEDIA_SEGMENT,data:{type:t,data:i}};e.postMessage(a,[i.data])}function d(){var t={msg:s.default.LOADING_COMPLETE};e.postMessage(t)}function l(){var t={msg:s.default.RECOVERED_EARLY_EOF};e.postMessage(t)}function u(t){var i={msg:s.default.MEDIA_INFO,data:t};e.postMessage(i)}function c(t){var i={msg:s.default.METADATA_ARRIVED,data:t};e.postMessage(i)}function h(t){var i={msg:s.default.SCRIPTDATA_ARRIVED,data:t};e.postMessage(i)}function f(t){var i={msg:s.default.STATISTICS_INFO,data:t};e.postMessage(i)}function p(t,i){e.postMessage({msg:s.default.IO_ERROR,data:{type:t,info:i}})}function m(t,i){e.postMessage({msg:s.default.DEMUX_ERROR,data:{type:t,info:i}})}function g(t){e.postMessage({msg:s.default.RECOMMEND_SEEKPOINT,data:t})}r.default.install(),e.addEventListener("message",(function(r){switch(r.data.cmd){case"init":(t=new n.default(r.data.param[0],r.data.param[1])).on(s.default.IO_ERROR,p.bind(this)),t.on(s.default.DEMUX_ERROR,m.bind(this)),t.on(s.default.INIT_SEGMENT,o.bind(this)),t.on(s.default.MEDIA_SEGMENT,_.bind(this)),t.on(s.default.LOADING_COMPLETE,d.bind(this)),t.on(s.default.RECOVERED_EARLY_EOF,l.bind(this)),t.on(s.default.MEDIA_INFO,u.bind(this)),t.on(s.default.METADATA_ARRIVED,c.bind(this)),t.on(s.default.SCRIPTDATA_ARRIVED,h.bind(this)),t.on(s.default.STATISTICS_INFO,f.bind(this)),t.on(s.default.RECOMMEND_SEEKPOINT,g.bind(this));break;case"destroy":t&&(t.destroy(),t=null),e.postMessage({msg:"destroyed"});break;case"start":t.start();break;case"stop":t.stop();break;case"seek":t.seek(r.data.param);break;case"pause":t.pause();break;case"resume":t.resume();break;case"logging_config":var y=r.data.param;a.default.applyConfig(y),!0===y.enableCallback?a.default.addLogListener(i):a.default.removeLogListener(i)}}))}},"./src/demux/amf-parser.js":
|
|
/*!*********************************!*\
|
|
!*** ./src/demux/amf-parser.js ***!
|
|
\*********************************/function(e,t,i){"use strict";i.r(t);var a,r=i(/*! ../utils/logger.js */"./src/utils/logger.js"),n=i(/*! ../utils/utf8-conv.js */"./src/utils/utf8-conv.js"),s=i(/*! ../utils/exception.js */"./src/utils/exception.js"),o=(a=new ArrayBuffer(2),new DataView(a).setInt16(0,256,!0),256===new Int16Array(a)[0]),_=function(){function e(){}return e.parseScriptData=function(t,i,a){var n={};try{var s=e.parseValue(t,i,a),o=e.parseValue(t,i+s.size,a-s.size);n[s.data]=o.data}catch(e){r.default.e("AMF",e.toString())}return n},e.parseObject=function(t,i,a){if(a<3)throw new s.IllegalStateException("Data not enough when parse ScriptDataObject");var r=e.parseString(t,i,a),n=e.parseValue(t,i+r.size,a-r.size),o=n.objectEnd;return{data:{name:r.data,value:n.data},size:r.size+n.size,objectEnd:o}},e.parseVariable=function(t,i,a){return e.parseObject(t,i,a)},e.parseString=function(e,t,i){if(i<2)throw new s.IllegalStateException("Data not enough when parse String");var a=new DataView(e,t,i).getUint16(0,!o);return{data:a>0?(0,n.default)(new Uint8Array(e,t+2,a)):"",size:2+a}},e.parseLongString=function(e,t,i){if(i<4)throw new s.IllegalStateException("Data not enough when parse LongString");var a=new DataView(e,t,i).getUint32(0,!o);return{data:a>0?(0,n.default)(new Uint8Array(e,t+4,a)):"",size:4+a}},e.parseDate=function(e,t,i){if(i<10)throw new s.IllegalStateException("Data size invalid when parse Date");var a=new DataView(e,t,i),r=a.getFloat64(0,!o),n=a.getInt16(8,!o);return{data:new Date(r+=60*n*1e3),size:10}},e.parseValue=function(t,i,a){if(a<1)throw new s.IllegalStateException("Data not enough when parse Value");var n,_=new DataView(t,i,a),d=1,l=_.getUint8(0),u=!1;try{switch(l){case 0:n=_.getFloat64(1,!o),d+=8;break;case 1:n=!!_.getUint8(1),d+=1;break;case 2:var c=e.parseString(t,i+1,a-1);n=c.data,d+=c.size;break;case 3:n={};var h=0;for(9==(16777215&_.getUint32(a-4,!o))&&(h=3);d<a-4;){var f=e.parseObject(t,i+d,a-d-h);if(f.objectEnd)break;n[f.data.name]=f.data.value,d+=f.size}d<=a-3&&9==(16777215&_.getUint32(d-1,!o))&&(d+=3);break;case 8:for(n={},d+=4,h=0,9==(16777215&_.getUint32(a-4,!o))&&(h=3);d<a-8;){var p=e.parseVariable(t,i+d,a-d-h);if(p.objectEnd)break;n[p.data.name]=p.data.value,d+=p.size}d<=a-3&&9==(16777215&_.getUint32(d-1,!o))&&(d+=3);break;case 9:n=void 0,d=1,u=!0;break;case 10:n=[];var m=_.getUint32(1,!o);d+=4;for(var g=0;g<m;g++){var y=e.parseValue(t,i+d,a-d);n.push(y.data),d+=y.size}break;case 11:var v=e.parseDate(t,i+1,a-1);n=v.data,d+=v.size;break;case 12:var b=e.parseString(t,i+1,a-1);n=b.data,d+=b.size;break;default:d=a,r.default.w("AMF","Unsupported AMF value type "+l)}}catch(e){r.default.e("AMF",e.toString())}return{data:n,size:d,objectEnd:u}},e}();t.default=_},"./src/demux/demux-errors.js":
|
|
/*!***********************************!*\
|
|
!*** ./src/demux/demux-errors.js ***!
|
|
\***********************************/function(e,t,i){"use strict";i.r(t),t.default={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"}},"./src/demux/exp-golomb.js":
|
|
/*!*********************************!*\
|
|
!*** ./src/demux/exp-golomb.js ***!
|
|
\*********************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! ../utils/exception.js */"./src/utils/exception.js"),r=function(){function e(e){this.TAG="ExpGolomb",this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}return e.prototype.destroy=function(){this._buffer=null},e.prototype._fillCurrentWord=function(){var e=this._total_bytes-this._buffer_index;if(e<=0)throw new a.IllegalStateException("ExpGolomb: _fillCurrentWord() but no bytes available");var t=Math.min(4,e),i=new Uint8Array(4);i.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(i.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t},e.prototype.readBits=function(e){if(e>32)throw new a.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 i=this._current_word_bits_left?this._current_word:0;i>>>=32-this._current_word_bits_left;var r=e-this._current_word_bits_left;this._fillCurrentWord();var n=Math.min(r,this._current_word_bits_left),s=this._current_word>>>32-n;return this._current_word<<=n,this._current_word_bits_left-=n,i=i<<n|s},e.prototype.readBool=function(){return 1===this.readBits(1)},e.prototype.readByte=function(){return this.readBits(8)},e.prototype._skipLeadingZero=function(){var e;for(e=0;e<this._current_word_bits_left;e++)if(this._current_word&2147483648>>>e)return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()},e.prototype.readUEG=function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1},e.prototype.readSEG=function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)},e}();t.default=r},"./src/demux/flv-demuxer.js":
|
|
/*!**********************************!*\
|
|
!*** ./src/demux/flv-demuxer.js ***!
|
|
\**********************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! ../utils/logger.js */"./src/utils/logger.js"),r=i(/*! ./amf-parser.js */"./src/demux/amf-parser.js"),n=i(/*! ./sps-parser.js */"./src/demux/sps-parser.js"),s=i(/*! ./hevc-sps-parser.js */"./src/demux/hevc-sps-parser.js"),o=i(/*! ./demux-errors.js */"./src/demux/demux-errors.js"),_=i(/*! ../core/media-info.js */"./src/core/media-info.js"),d=i(/*! ../utils/exception.js */"./src/utils/exception.js"),l=function(){function e(e,t){var i;this.TAG="FLVDemuxer",this._config=t,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=e.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=e.hasAudioTrack,this._hasVideo=e.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new _.default,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=(i=new ArrayBuffer(2),new DataView(i).setInt16(0,256,!0),256===new Int16Array(i)[0])}return e.prototype.destroy=function(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null},e.probe=function(e){var t=new Uint8Array(e),i={match:!1};if(70!==t[0]||76!==t[1]||86!==t[2]||1!==t[3])return i;var a,r,n=(4&t[4])>>>2!=0,s=!!(1&t[4]),o=(a=t)[r=5]<<24|a[r+1]<<16|a[r+2]<<8|a[r+3];return o<9?i:{match:!0,consumed:o,dataOffset:o,hasAudioTrack:n,hasVideoTrack:s}},e.prototype.bindDataSource=function(e){return e.onDataArrival=this.parseChunks.bind(this),this},Object.defineProperty(e.prototype,"onTrackMetadata",{get:function(){return this._onTrackMetadata},set:function(e){this._onTrackMetadata=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaInfo",{get:function(){return this._onMediaInfo},set:function(e){this._onMediaInfo=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMetaDataArrived",{get:function(){return this._onMetaDataArrived},set:function(e){this._onMetaDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onScriptDataArrived",{get:function(){return this._onScriptDataArrived},set:function(e){this._onScriptDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataAvailable",{get:function(){return this._onDataAvailable},set:function(e){this._onDataAvailable=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timestampBase",{get:function(){return this._timestampBase},set:function(e){this._timestampBase=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedDuration",{get:function(){return this._duration},set:function(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasAudio",{set:function(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasVideo",{set:function(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e},enumerable:!1,configurable:!0}),e.prototype.resetMediaInfo=function(){this._mediaInfo=new _.default},e.prototype._isInitialMetadataDispatched=function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched},e.prototype.parseChunks=function(t,i){if(!(this._onError&&this._onMediaInfo&&this._onTrackMetadata&&this._onDataAvailable))throw new d.IllegalStateException("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var r=0,n=this._littleEndian;if(0===i){if(!(t.byteLength>13))return 0;r=e.probe(t).dataOffset}for(this._firstParse&&(this._firstParse=!1,i+r!==this._dataOffset&&a.default.w(this.TAG,"First time parsing but chunk byteStart invalid!"),0!==(s=new DataView(t,r)).getUint32(0,!n)&&a.default.w(this.TAG,"PrevTagSize0 !== 0 !!!"),r+=4);r<t.byteLength;){this._dispatch=!0;var s=new DataView(t,r);if(r+11+4>t.byteLength)break;var o=s.getUint8(0),_=16777215&s.getUint32(0,!n);if(r+11+_+4>t.byteLength)break;if(8===o||9===o||18===o){var l=s.getUint8(4),u=s.getUint8(5),c=s.getUint8(6)|u<<8|l<<16|s.getUint8(7)<<24;16777215&s.getUint32(7,!n)&&a.default.w(this.TAG,"Meet tag which has StreamID != 0!");var h=r+11;switch(o){case 8:this._parseAudioData(t,h,_,c);break;case 9:this._parseVideoData(t,h,_,c,i+r);break;case 18:this._parseScriptData(t,h,_)}var f=s.getUint32(11+_,!n);f!==11+_&&a.default.w(this.TAG,"Invalid PrevTagSize "+f),r+=11+_+4}else a.default.w(this.TAG,"Unsupported tag type "+o+", skipped"),r+=11+_+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),r},e.prototype._parseScriptData=function(e,t,i){var n=r.default.parseScriptData(e,t,i);if(n.hasOwnProperty("onMetaData")){if(null==n.onMetaData||"object"!=typeof n.onMetaData)return void a.default.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&a.default.w(this.TAG,"Found another onMetaData tag!"),this._metadata=n;var s=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},s)),"boolean"==typeof s.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=s.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"==typeof s.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=s.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"==typeof s.audiodatarate&&(this._mediaInfo.audioDataRate=s.audiodatarate),"number"==typeof s.videodatarate&&(this._mediaInfo.videoDataRate=s.videodatarate),"number"==typeof s.width&&(this._mediaInfo.width=s.width),"number"==typeof s.height&&(this._mediaInfo.height=s.height),"number"==typeof s.duration){if(!this._durationOverrided){var o=Math.floor(s.duration*this._timescale);this._duration=o,this._mediaInfo.duration=o}}else this._mediaInfo.duration=0;if("number"==typeof s.framerate){var _=Math.floor(1e3*s.framerate);if(_>0){var d=_/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=d,this._referenceFrameRate.fps_num=_,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=d}}if("object"==typeof s.keyframes){this._mediaInfo.hasKeyframesIndex=!0;var l=s.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(l),s.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=s,a.default.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(n).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},n))},e.prototype._parseKeyframesIndex=function(e){for(var t=[],i=[],a=1;a<e.times.length;a++){var r=this._timestampBase+Math.floor(1e3*e.times[a]);t.push(r),i.push(e.filepositions[a])}return{times:t,filepositions:i}},e.prototype._parseAudioData=function(e,t,i,r){if(i<=1)a.default.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");else if(!0!==this._hasAudioFlagOverrided||!1!==this._hasAudio){this._littleEndian;var n=new DataView(e,t,i).getUint8(0),s=n>>>4;if(2===s||10===s){var _=0,d=(12&n)>>>2;if(d>=0&&d<=4){_=this._flvSoundRateTable[d];var l=1&n,u=this._audioMetadata,c=this._audioTrack;if(u||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),(u=this._audioMetadata={}).type="audio",u.id=c.id,u.timescale=this._timescale,u.duration=this._duration,u.audioSampleRate=_,u.channelCount=0===l?1:2),10===s){var h=this._parseAACAudioData(e,t+1,i-1);if(null==h)return;if(0===h.packetType){u.config&&a.default.w(this.TAG,"Found another AudioSpecificConfig!");var f=h.data;u.audioSampleRate=f.samplingRate,u.channelCount=f.channelCount,u.codec=f.codec,u.originalCodec=f.originalCodec,u.config=f.config,u.refSampleDuration=1024/u.audioSampleRate*u.timescale,a.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",u),(g=this._mediaInfo).audioCodec=u.originalCodec,g.audioSampleRate=u.audioSampleRate,g.audioChannelCount=u.channelCount,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}else if(1===h.packetType){var p=this._timestampBase+r,m={unit:h.data,length:h.data.byteLength,dts:p,pts:p};c.samples.push(m),c.length+=h.data.length}else a.default.e(this.TAG,"Flv: Unsupported AAC data type "+h.packetType)}else if(2===s){if(!u.codec){var g;if(null==(f=this._parseMP3AudioData(e,t+1,i-1,!0)))return;u.audioSampleRate=f.samplingRate,u.channelCount=f.channelCount,u.codec=f.codec,u.originalCodec=f.originalCodec,u.refSampleDuration=1152/u.audioSampleRate*u.timescale,a.default.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",u),(g=this._mediaInfo).audioCodec=u.codec,g.audioSampleRate=u.audioSampleRate,g.audioChannelCount=u.channelCount,g.audioDataRate=f.bitRate,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}var y=this._parseMP3AudioData(e,t+1,i-1,!1);if(null==y)return;p=this._timestampBase+r;var v={unit:y,length:y.byteLength,dts:p,pts:p};c.samples.push(v),c.length+=y.length}}else this._onError(o.default.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+d)}else this._onError(o.default.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+s)}},e.prototype._parseAACAudioData=function(e,t,i){if(!(i<=1)){var r={},n=new Uint8Array(e,t,i);return r.packetType=n[0],0===n[0]?r.data=this._parseAACAudioSpecificConfig(e,t+1,i-1):r.data=n.subarray(1),r}a.default.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!")},e.prototype._parseAACAudioSpecificConfig=function(e,t,i){var a,r,n=new Uint8Array(e,t,i),s=null,_=0,d=null;if(_=a=n[0]>>>3,(r=(7&n[0])<<1|n[1]>>>7)<0||r>=this._mpegSamplingRates.length)this._onError(o.default.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");else{var l=this._mpegSamplingRates[r],u=(120&n[1])>>>3;if(!(u<0||u>=8)){5===_&&(d=(7&n[1])<<1|n[2]>>>7,n[2]);var c=self.navigator.userAgent.toLowerCase();return-1!==c.indexOf("firefox")?r>=6?(_=5,s=new Array(4),d=r-3):(_=2,s=new Array(2),d=r):-1!==c.indexOf("android")?(_=2,s=new Array(2),d=r):(_=5,d=r,s=new Array(4),r>=6?d=r-3:1===u&&(_=2,s=new Array(2),d=r)),s[0]=_<<3,s[0]|=(15&r)>>>1,s[1]=(15&r)<<7,s[1]|=(15&u)<<3,5===_&&(s[1]|=(15&d)>>>1,s[2]=(1&d)<<7,s[2]|=8,s[3]=0),{config:s,samplingRate:l,channelCount:u,codec:"mp4a.40."+_,originalCodec:"mp4a.40."+a}}this._onError(o.default.FORMAT_ERROR,"Flv: AAC invalid channel configuration")}},e.prototype._parseMP3AudioData=function(e,t,i,r){if(!(i<4)){this._littleEndian;var n=new Uint8Array(e,t,i),s=null;if(r){if(255!==n[0])return;var o=n[1]>>>3&3,_=(6&n[1])>>1,d=(240&n[2])>>>4,l=(12&n[2])>>>2,u=3&~(n[3]>>>6)?2:1,c=0,h=0;switch(o){case 0:c=this._mpegAudioV25SampleRateTable[l];break;case 2:c=this._mpegAudioV20SampleRateTable[l];break;case 3:c=this._mpegAudioV10SampleRateTable[l]}switch(_){case 1:d<this._mpegAudioL3BitRateTable.length&&(h=this._mpegAudioL3BitRateTable[d]);break;case 2:d<this._mpegAudioL2BitRateTable.length&&(h=this._mpegAudioL2BitRateTable[d]);break;case 3:d<this._mpegAudioL1BitRateTable.length&&(h=this._mpegAudioL1BitRateTable[d])}s={bitRate:h,samplingRate:c,channelCount:u,codec:"mp3",originalCodec:"mp3"}}else s=n;return s}a.default.w(this.TAG,"Flv: Invalid MP3 packet, header missing!")},e.prototype._parseVideoData=function(e,t,i,r,n){if(i<=1)a.default.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");else if(!0!==this._hasVideoFlagOverrided||!1!==this._hasVideo){var s=new Uint8Array(e,t,i)[0],_=(240&s)>>>4,d=15&s;7===d||12===d?7===d?this._parseAVCVideoPacket(e,t+1,i-1,r,n,_):12===d&&this._parseHVCVideoPacket(e,t+1,i-1,r,n,_):this._onError(o.default.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+d)}},e.prototype._parseAVCVideoPacket=function(e,t,i,r,n,s){if(i<4)a.default.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");else{var _=this._littleEndian,d=new DataView(e,t,i),l=d.getUint8(0),u=(16777215&d.getUint32(0,!_))<<8>>8;if(0===l)this._parseAVCDecoderConfigurationRecord(e,t+4,i-4);else if(1===l)this._parseAVCVideoData(e,t+4,i-4,r,n,s,u);else if(2!==l)return void this._onError(o.default.FORMAT_ERROR,"Flv: Invalid video packet type "+l)}},e.prototype._parseAVCDecoderConfigurationRecord=function(e,t,i){if(i<7)a.default.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");else{var r=this._videoMetadata,s=this._videoTrack,_=this._littleEndian,d=new DataView(e,t,i);r?void 0!==r.avcc&&a.default.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),(r=this._videoMetadata={}).type="video",r.id=s.id,r.timescale=this._timescale,r.duration=this._duration);var l=d.getUint8(0),u=d.getUint8(1);if(d.getUint8(2),d.getUint8(3),1===l&&0!==u)if(this._naluLengthSize=1+(3&d.getUint8(4)),3===this._naluLengthSize||4===this._naluLengthSize){var c=31&d.getUint8(5);if(0!==c){c>1&&a.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+c);for(var h=6,f=0;f<c;f++){var p=d.getUint16(h,!_);if(h+=2,0!==p){var m=new Uint8Array(e,t+h,p);h+=p;var g=n.default.parseSPS(m);if(0===f){r.codecWidth=g.codec_size.width,r.codecHeight=g.codec_size.height,r.presentWidth=g.present_size.width,r.presentHeight=g.present_size.height,r.profile=g.profile_string,r.level=g.level_string,r.bitDepth=g.bit_depth,r.chromaFormat=g.chroma_format,r.sarRatio=g.sar_ratio,r.frameRate=g.frame_rate,!1!==g.frame_rate.fixed&&0!==g.frame_rate.fps_num&&0!==g.frame_rate.fps_den||(r.frameRate=this._referenceFrameRate);var y=r.frameRate.fps_den,v=r.frameRate.fps_num;r.refSampleDuration=r.timescale*(y/v);for(var b=m.subarray(1,4),E="avc1.",S=0;S<3;S++){var A=b[S].toString(16);A.length<2&&(A="0"+A),E+=A}r.codec=E;var w=this._mediaInfo;w.width=r.codecWidth,w.height=r.codecHeight,w.fps=r.frameRate.fps,w.profile=r.profile,w.level=r.level,w.refFrames=g.ref_frames,w.chromaFormat=g.chroma_format_string,w.sarNum=r.sarRatio.width,w.sarDen=r.sarRatio.height,w.videoCodec=E,w.hasAudio?null!=w.audioCodec&&(w.mimeType='video/x-flv; codecs="'+w.videoCodec+","+w.audioCodec+'"'):w.mimeType='video/x-flv; codecs="'+w.videoCodec+'"',w.isComplete()&&this._onMediaInfo(w)}}}var k=d.getUint8(h);if(0!==k){for(k>1&&a.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+k),h++,f=0;f<k;f++)p=d.getUint16(h,!_),h+=2,0!==p&&(h+=p);r.avcc=new Uint8Array(i),r.avcc.set(new Uint8Array(e,t,i),0),a.default.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",r)}else this._onError(o.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS")}else this._onError(o.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS")}else this._onError(o.default.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));else this._onError(o.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord")}},e.prototype._parseAVCVideoData=function(e,t,i,r,n,s,o){for(var _=this._littleEndian,d=new DataView(e,t,i),l=[],u=0,c=0,h=this._naluLengthSize,f=this._timestampBase+r,p=1===s;c<i;){if(c+4>=i){a.default.w(this.TAG,"Malformed Nalu near timestamp "+f+", offset = "+c+", dataSize = "+i);break}var m=d.getUint32(c,!_);if(3===h&&(m>>>=8),m>i-h)return void a.default.w(this.TAG,"Malformed Nalus near timestamp "+f+", NaluSize > DataSize!");var g=31&d.getUint8(c+h);5===g&&(p=!0);var y=new Uint8Array(e,t+c,h+m),v={type:g,data:y};l.push(v),u+=y.byteLength,c+=h+m}if(l.length){var b=this._videoTrack,E={units:l,length:u,isKeyframe:p,dts:f,cts:o,pts:f+o};p&&(E.fileposition=n),b.samples.push(E),b.length+=u}},e.prototype._parseHVCVideoPacket=function(e,t,i,r,n,s){if(i<4)a.default.w(this.TAG,"Flv: Invalid HVC packet, missing HVCPacketType or/and CompositionTime");else{var _=this._littleEndian,d=new DataView(e,t,i),l=d.getUint8(0),u=(16777215&d.getUint32(0,!_))<<8>>8;if(0===l)this._parseHVCDecoderConfigurationRecord(e,t+4,i-4);else if(1===l)this._parseHVCVideoData(e,t+4,i-4,r,n,s,u);else if(2!==l)return void this._onError(o.default.FORMAT_ERROR,"Flv: Invalid video packet type "+l)}},e.prototype._parseHVCDecoderConfigurationRecord=function(e,t,i){if(i<23)a.default.w(this.TAG,"Flv: Invalid HVCDecoderConfigurationRecord, lack of data!");else{var r=this._videoMetadata,n=this._videoTrack,_=this._littleEndian,d=new DataView(e,t,i);if(r?void 0!==r.avcc&&a.default.w(this.TAG,"Found another HVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),(r=this._videoMetadata={}).type="video",r.id=n.id,r.timescale=this._timescale,r.duration=this._duration),1===d.getUint8(0))if(this._naluLengthSize=1+(3&d.getUint8(21)),3===this._naluLengthSize||4===this._naluLengthSize){for(var l,u,c,h=d.getUint8(22),f=23,p=[],m=0;m<h;m++){var g=63&d.getUint8(f++),y=d.getUint16(f,!_);if(f+=2,0!==y){switch(g){case 32:l+=y;break;case 33:u+=y;break;case 34:c+=y}for(var v=0;v<y;v++){var b=d.getUint16(f,!_);if(f+=2,0!==b){if(33===g){var E=new Uint8Array(e,t+f,b);p.push(E)}f+=b}}}}if(0!==l)if(l>1&&a.default.w(this.TAG,"Flv: Strange HVCDecoderConfigurationRecord: VPS Count = "+l),0!==u)if(u>1&&a.default.w(this.TAG,"Flv: Strange HVCDecoderConfigurationRecord: SPS Count = "+u),0!==c){c>1&&a.default.w(this.TAG,"Flv: Strange HVCDecoderConfigurationRecord: PPS Count = "+u);var S=p[0],A=s.default.parseSPS(S);r.codecWidth=A.codec_size.width,r.codecHeight=A.codec_size.height,r.presentWidth=A.present_size.width,r.presentHeight=A.present_size.height,r.profile=A.profile_string,r.level=A.level_string,r.profile_idc=A.profile_idc,r.level_idc=A.level_idc,r.bitDepth=A.bit_depth,r.chromaFormat=A.chroma_format,r.sarRatio=A.sar_ratio,r.frameRate=A.frame_rate,!1!==A.frame_rate.fixed&&0!==A.frame_rate.fps_num&&0!==A.frame_rate.fps_den||(r.frameRate=this._referenceFrameRate);var w=r.frameRate.fps_den,k=r.frameRate.fps_num;r.refSampleDuration=r.timescale*(w/k);var T="hvc1."+r.profile_idc+".1.L"+r.level_idc+".B0";r.codec=T;var L=this._mediaInfo;L.width=r.codecWidth,L.height=r.codecHeight,L.fps=r.frameRate.fps,L.profile=r.profile,L.level=r.level,L.refFrames=A.ref_frames,L.chromaFormat=A.chroma_format_string,L.sarNum=r.sarRatio.width,L.sarDen=r.sarRatio.height,L.videoCodec=T,L.hasAudio?null!=L.audioCodec&&(L.mimeType='video/x-flv; codecs="'+L.videoCodec+","+L.audioCodec+'"'):L.mimeType='video/x-flv; codecs="'+L.videoCodec+'"',L.isComplete()&&this._onMediaInfo(L),r.avcc=new Uint8Array(i),r.avcc.set(new Uint8Array(e,t,i),0),a.default.v(this.TAG,"Parsed HVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",r)}else this._onError(o.default.FORMAT_ERROR,"Flv: Invalid HVCDecoderConfigurationRecord: No PPS");else this._onError(o.default.FORMAT_ERROR,"Flv: Invalid HVCDecoderConfigurationRecord: No SPS");else this._onError(o.default.FORMAT_ERROR,"Flv: Invalid HVCDecoderConfigurationRecord: No VPS")}else this._onError(o.default.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));else this._onError(o.default.FORMAT_ERROR,"Flv: Invalid HVCDecoderConfigurationRecord")}},e.prototype._parseHVCVideoData=function(e,t,i,r,n,s,o){for(var _=this._littleEndian,d=new DataView(e,t,i),l=[],u=0,c=0,h=this._naluLengthSize,f=this._timestampBase+r,p=1===s;c<i;){if(c+4>=i){a.default.w(this.TAG,"Malformed Nalu near timestamp "+f+", offset = "+c+", dataSize = "+i);break}var m=d.getUint32(c,!_);if(3===h&&(m>>>=8),m>i-h)return void a.default.w(this.TAG,"Malformed Nalus near timestamp "+f+", NaluSize > DataSize!");var g=d.getUint8(c+h)>>1&63;g>=16&&g<=23&&(p=!0);var y=new Uint8Array(e,t+c,h+m),v={type:g,data:y};l.push(v),u+=y.byteLength,c+=h+m}if(l.length){var b=this._videoTrack,E={units:l,length:u,isKeyframe:p,dts:f,cts:o,pts:f+o};p&&(E.fileposition=n),b.samples.push(E),b.length+=u}},e}();t.default=l},"./src/demux/hevc-sps-parser.js":
|
|
/*!**************************************!*\
|
|
!*** ./src/demux/hevc-sps-parser.js ***!
|
|
\**************************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! ./exp-golomb.js */"./src/demux/exp-golomb.js"),r=i(/*! ./sps-parser.js */"./src/demux/sps-parser.js"),n=function(){function e(){}return e.parseSPS=function(t){var i=r.default._ebsp2rbsp(t),n=new a.default(i),s={};n.readBits(16),n.readBits(4);var o=n.readBits(3);n.readBits(1),e._hvcc_parse_ptl(n,s,o),n.readUEG();var _=0,d=n.readUEG();3==d&&(_=n.readBits(1)),s.sar_width=s.sar_height=1,s.conf_win_left_offset=s.conf_win_right_offset=s.conf_win_top_offset=s.conf_win_bottom_offset=0,s.def_disp_win_left_offset=s.def_disp_win_right_offset=s.def_disp_win_top_offset=s.def_disp_win_bottom_offset=0;var l=n.readUEG(),u=n.readUEG();n.readBits(1)&&(s.conf_win_left_offset=n.readUEG(),s.conf_win_right_offset=n.readUEG(),s.conf_win_top_offset=n.readUEG(),s.conf_win_bottom_offset=n.readUEG(),1===s.default_display_window_flag&&(s.conf_win_left_offset,s.def_disp_win_left_offset,s.conf_win_right_offset,s.def_disp_win_right_offset,s.conf_win_top_offset,s.def_disp_win_top_offset,s.conf_win_bottom_offset,s.def_disp_win_bottom_offset));var c=n.readUEG()+8;n.readUEG();for(var h=n.readUEG(),f=n.readBits(1)?0:o;f<=o;f++)e._skip_sub_layer_ordering_info(n);n.readUEG(),n.readUEG(),n.readUEG(),n.readUEG(),n.readUEG(),n.readUEG(),n.readBits(1)&&n.readBits(1)&&e._skip_scaling_list_data(n),n.readBits(1),n.readBits(1),n.readBits(1)&&(n.readBits(4),n.readBits(4),n.readUEG(),n.readUEG(),n.readBits(1));var p=[],m=n.readUEG();for(f=0;f<m;f++){var g=e._parse_rps(n,f,m,p);if(g<0)return g}if(n.readBits(1)){var y=n.readUEG();for(f=0;f<y;f++){var v=Math.min(h+4,16);if(v>32){for(var b=v/32,E=v%32,S=0;S<b;S++)n.readBits(32);n.readBits(E)}else n.readBits(v);n.readBits(1)}}n.readBits(1),n.readBits(1),n.readBits(1)&&e._hvcc_parse_vui(n,s,o);var A=e.getProfileString(s.profile_idc),w=e.getLevelString(s.level_idc),k=1;1===s.sar_width&&1===s.sar_height||(k=s.sar_width/s.sar_height);var T=l,L=u,R=1===d&&0===_?2:1;T-=(1!==d&&2!=d||0!==_?1:2)*(s.conf_win_left_offset+s.conf_win_right_offset),L-=R*(s.conf_win_top_offset+s.conf_win_bottom_offset);var C=Math.ceil(T*k);return n.destroy(),n=null,{profile_string:A,level_string:w,profile_idc:s.profile_idc,level_idc:s.level_idc,bit_depth:c,ref_frames:1,chroma_format:d,chroma_format_string:e.getChromaFormatString(d),frame_rate:{fixed:s.fps_fixed,fps:s.fps,fps_den:s.fps_den,fps_num:s.fps_num},sar_ratio:{width:s.sar_width,height:s.sar_height},codec_size:{width:T,height:L},present_size:{width:C,height:L}}},e._hvcc_parse_ptl=function(e,t,i){e.readBits(2);var a=e.readBits(1),r=e.readBits(5);e.readBits(32),e.readBits(32),e.readBits(16);var n=e.readByte();void 0===t.tier_flag||void 0===t.level_idc||t.tier_flag<a?t.level_idc=n:t.level_idc=Math.max(t.level_idc,n),t.profile_idc=Math.max(void 0===t.profile_idc?0:t.profile_idc,r);for(var s=[],o=[],_=0;_<i;_++)s.push(e.readBits(1)),o.push(e.readBits(1));if(i>0)for(_=i;_<8;_++)e.readBits(2);for(_=0;_<i;_++)s[_]&&(e.readBits(32),e.readBits(32),e.readBits(24)),o[_]&&e.readByte()},e._parse_rps=function(e,t,i,a){if(t&&e.readBits(1)){if(t>=i)return-1;e.readBits(1),e.readUEG(),a[t]=0;for(var r=0;r<=a[t-1];r++){var n=0,s=e.readBits(1);s||(n=e.readBits(1)),(s||n)&&a[t]++}}else{var o=e.readUEG(),_=e.readUEG();for(a[t]=o+_,r=0;r<o;r++)e.readUEG(),e.readBits(1);for(r=0;r<_;r++)e.readUEG(),e.readBits(1)}return 0},e._hvcc_parse_vui=function(t,i,a){t.readBits(1)&&255==t.readByte()&&(i.sar_width=t.readBits(16),i.sar_height=t.readBits(16)),t.readBits(1)&&t.readBits(1),t.readBits(1)&&(t.readBits(4),t.readBits(1)&&t.readBits(24)),t.readBits(1)&&(t.readUEG(),t.readUEG()),t.readBits(3),i.default_display_window_flag=t.readBits(1),i.default_display_window_flag&&(i.def_disp_win_left_offset=t.readUEG(),i.def_disp_win_right_offset=t.readUEG(),i.def_disp_win_top_offset=t.readUEG(),i.def_disp_win_bottom_offset=t.readUEG()),t.readBits(1)&&(e._skip_timing_info(t,i),t.readBits(1)&&e._skip_hrd_parameters(t,i,1,a)),t.readBits(1)&&(t.readBits(3),t.readUEG(),t.readUEG(),t.readUEG(),t.readUEG(),t.readUEG())},e._skip_sub_layer_ordering_info=function(e,t){e.readUEG(),e.readUEG(),e.readUEG()},e._skip_scaling_list_data=function(e){for(var t=0;t<4;t++)for(var i=0;i<(3==t?2:6);i++)if(e.readBits(1)){var a=Math.min(64,1<<4+(t<<1));t>1&&e.readSEG();for(var r=0;r<a;r++)e.readSEG()}else e.readUEG()},e._skip_sub_layer_hrd_parameters=function(e,t,i){for(var a=0;a<=t;a++)e.readUEG(),e.readUEG(),i&&(e.readUEG(),e.readUEG()),e.readBits(1)},e._skip_timing_info=function(e,t){t.fps_den=e.readBits(32),t.fps_num=e.readBits(32),t.fps_den>0&&(t.fps=t.fps_num/t.fps_den);var i=0;e.readBits(1)&&(i=e.readUEG())>=0&&(t.fps/=i+1)},e._skip_hrd_parameters=function(t,i,a){var r=0,n=0;if(i&&(r=t.readBits(1),n=t.readBits(1),r||n)){var s=t.readBits(1);s&&t.readBits(19),t.readByte(),s&&t.readBits(4),t.readBits(15)}for(var o=0;o<=a;o++){var _=0,d=0,l=0,u=t.readBits(1);hvcc.fps_fixed=u,u||(l=t.readBits(1)),l?t.readUEG():d=t.readBits(1),d||(_=t.readUEG(t)),r&&e._skip_sub_layer_hrd_parameters(t,_,0),n&&e._skip_sub_layer_hrd_parameters(t,_,0)}},e.getProfileString=function(e){switch(e){case 1:return"Main";case 2:return"Main10";case 3:return"MainSP";case 4:return"Rext";case 9:return"SCC";default:return"Unknown"}},e.getLevelString=function(e){return(e/30).toFixed(1)},e.getChromaFormatString=function(e){switch(e){case 0:return"4:0:0";case 1:return"4:2:0";case 2:return"4:2:2";case 3:return"4:4:4";default:return"Unknown"}},e}();t.default=n},"./src/demux/sps-parser.js":
|
|
/*!*********************************!*\
|
|
!*** ./src/demux/sps-parser.js ***!
|
|
\*********************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! ./exp-golomb.js */"./src/demux/exp-golomb.js"),r=function(){function e(){}return e._ebsp2rbsp=function(e){for(var t=e,i=t.byteLength,a=new Uint8Array(i),r=0,n=0;n<i;n++)n>=2&&3===t[n]&&0===t[n-1]&&0===t[n-2]||(a[r]=t[n],r++);return new Uint8Array(a.buffer,0,r)},e.parseSPS=function(t){var i=e._ebsp2rbsp(t),r=new a.default(i);r.readByte();var n=r.readByte();r.readByte();var s=r.readByte();r.readUEG();var o=e.getProfileString(n),_=e.getLevelString(s),d=1,l=420,u=8;if((100===n||110===n||122===n||244===n||44===n||83===n||86===n||118===n||128===n||138===n||144===n)&&(3===(d=r.readUEG())&&r.readBits(1),d<=3&&(l=[0,420,422,444][d]),u=r.readUEG()+8,r.readUEG(),r.readBits(1),r.readBool()))for(var c=3!==d?8:12,h=0;h<c;h++)r.readBool()&&(h<6?e._skipScalingList(r,16):e._skipScalingList(r,64));r.readUEG();var f=r.readUEG();if(0===f)r.readUEG();else if(1===f){r.readBits(1),r.readSEG(),r.readSEG();var p=r.readUEG();for(h=0;h<p;h++)r.readSEG()}var m=r.readUEG();r.readBits(1);var g=r.readUEG(),y=r.readUEG(),v=r.readBits(1);0===v&&r.readBits(1),r.readBits(1);var b=0,E=0,S=0,A=0;r.readBool()&&(b=r.readUEG(),E=r.readUEG(),S=r.readUEG(),A=r.readUEG());var w=1,k=1,T=0,L=!0,R=0,C=0;if(r.readBool()){if(r.readBool()){var x=r.readByte();x>0&&x<16?(w=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][x-1],k=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][x-1]):255===x&&(w=r.readByte()<<8|r.readByte(),k=r.readByte()<<8|r.readByte())}if(r.readBool()&&r.readBool(),r.readBool()&&(r.readBits(4),r.readBool()&&r.readBits(24)),r.readBool()&&(r.readUEG(),r.readUEG()),r.readBool()){var M=r.readBits(32),D=r.readBits(32);L=r.readBool(),T=(R=D)/(C=2*M)}}var O=1;1===w&&1===k||(O=w/k);var I=0,P=0;0===d?(I=1,P=2-v):(I=3===d?1:2,P=(1===d?2:1)*(2-v));var B=16*(g+1),U=16*(y+1)*(2-v);B-=(b+E)*I,U-=(S+A)*P;var N=Math.ceil(B*O);return r.destroy(),r=null,{profile_string:o,level_string:_,bit_depth:u,ref_frames:m,chroma_format:l,chroma_format_string:e.getChromaFormatString(l),frame_rate:{fixed:L,fps:T,fps_den:C,fps_num:R},sar_ratio:{width:w,height:k},codec_size:{width:B,height:U},present_size:{width:N,height:U}}},e._skipScalingList=function(e,t){for(var i=8,a=8,r=0;r<t;r++)0!==a&&(a=(i+e.readSEG()+256)%256),i=0===a?i:a},e.getProfileString=function(e){switch(e){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}},e.getLevelString=function(e){return(e/10).toFixed(1)},e.getChromaFormatString=function(e){switch(e){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}},e}();t.default=r},"./src/flv.js":
|
|
/*!********************!*\
|
|
!*** ./src/flv.js ***!
|
|
\********************/function(e,t,i){"use strict";i.r(t);var a=i(/*! ./utils/polyfill.js */"./src/utils/polyfill.js"),r=i(/*! ./core/features.js */"./src/core/features.js"),n=i(/*! ./io/loader.js */"./src/io/loader.js"),s=i(/*! ./player/flv-player.js */"./src/player/flv-player.js"),o=i(/*! ./player/native-player.js */"./src/player/native-player.js"),_=i(/*! ./player/player-events.js */"./src/player/player-events.js"),d=i(/*! ./player/player-errors.js */"./src/player/player-errors.js"),l=i(/*! ./utils/logging-control.js */"./src/utils/logging-control.js"),u=i(/*! ./utils/exception.js */"./src/utils/exception.js");a.default.install();var c={createPlayer:function(e,t){var i=e;if(null==i||"object"!=typeof i)throw new u.InvalidArgumentException("MediaDataSource must be an javascript object!");if(!i.hasOwnProperty("type"))throw new u.InvalidArgumentException("MediaDataSource must has type field to indicate video file type!");return"flv"===i.type?new s.default(i,t):new o.default(i,t)},isSupported:function(){return r.default.supportMSEH264Playback()},getFeatureList:function(){return r.default.getFeatureList()}};c.BaseLoader=n.BaseLoader,c.LoaderStatus=n.LoaderStatus,c.LoaderErrors=n.LoaderErrors,c.Events=_.default,c.ErrorTypes=d.ErrorTypes,c.ErrorDetails=d.ErrorDetails,c.FlvPlayer=s.default,c.NativePlayer=o.default,c.LoggingControl=l.default,Object.defineProperty(c,"version",{enumerable:!0,get:function(){return"1.7.0"}}),t.default=c},"./src/index.js":
|
|
/*!**********************!*\
|
|
!*** ./src/index.js ***!
|
|
\**********************/function(e,t,i){e.exports=i(/*! ./flv.js */"./src/flv.js").default},"./src/io/fetch-stream-loader.js":
|
|
/*!***************************************!*\
|
|
!*** ./src/io/fetch-stream-loader.js ***!
|
|
\***************************************/function(e,t,i){"use strict";i.r(t);var a,r=i(/*! ../utils/browser.js */"./src/utils/browser.js"),n=i(/*! ./loader.js */"./src/io/loader.js"),s=i(/*! ../utils/exception.js */"./src/utils/exception.js"),o=(a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},a(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),_=function(e){function t(t,i){var a=e.call(this,"fetch-stream-loader")||this;return a.TAG="FetchStreamLoader",a._seekHandler=t,a._config=i,a._needStash=!0,a._requestAbort=!1,a._contentLength=null,a._receivedLength=0,a}return o(t,e),t.isSupported=function(){try{var e=r.default.msedge&&r.default.version.minor>=15048,t=!r.default.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(e){return!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),e.prototype.destroy.call(this)},t.prototype.open=function(e,t){var i=this;this._dataSource=e,this._range=t;var a=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(a=e.redirectedURL);var r=this._seekHandler.getConfig(a,t),o=new self.Headers;if("object"==typeof r.headers){var _=r.headers;for(var d in _)_.hasOwnProperty(d)&&o.append(d,_[d])}var l={method:"GET",headers:o,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"==typeof this._config.headers)for(var d in this._config.headers)o.append(d,this._config.headers[d]);!1===e.cors&&(l.mode="same-origin"),e.withCredentials&&(l.credentials="include"),e.referrerPolicy&&(l.referrerPolicy=e.referrerPolicy),self.AbortController&&(this._abortController=new self.AbortController,l.signal=this._abortController.signal),this._status=n.LoaderStatus.kConnecting,self.fetch(r.url,l).then((function(e){if(i._requestAbort)return i._status=n.LoaderStatus.kIdle,void e.body.cancel();if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==r.url&&i._onURLRedirect){var t=i._seekHandler.removeURLParameters(e.url);i._onURLRedirect(t)}var a=e.headers.get("Content-Length");return null!=a&&(i._contentLength=parseInt(a),0!==i._contentLength&&i._onContentLengthKnown&&i._onContentLengthKnown(i._contentLength)),i._pump.call(i,e.body.getReader())}if(i._status=n.LoaderStatus.kError,!i._onError)throw new s.RuntimeException("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);i._onError(n.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})})).catch((function(e){if(!i._abortController||!i._abortController.signal.aborted){if(i._status=n.LoaderStatus.kError,!i._onError)throw e;i._onError(n.LoaderErrors.EXCEPTION,{code:-1,msg:e.message})}}))},t.prototype.abort=function(){if(this._requestAbort=!0,(this._status!==n.LoaderStatus.kBuffering||!r.default.chrome)&&this._abortController)try{this._abortController.abort()}catch(e){}},t.prototype._pump=function(e){var t=this;return e.read().then((function(i){if(i.done)if(null!==t._contentLength&&t._receivedLength<t._contentLength){t._status=n.LoaderStatus.kError;var a=n.LoaderErrors.EARLY_EOF,r={code:-1,msg:"Fetch stream meet Early-EOF"};if(!t._onError)throw new s.RuntimeException(r.msg);t._onError(a,r)}else t._status=n.LoaderStatus.kComplete,t._onComplete&&t._onComplete(t._range.from,t._range.from+t._receivedLength-1);else{if(t._abortController&&t._abortController.signal.aborted)return void(t._status=n.LoaderStatus.kComplete);if(!0===t._requestAbort)return t._status=n.LoaderStatus.kComplete,e.cancel();t._status=n.LoaderStatus.kBuffering;var o=i.value.buffer,_=t._range.from+t._receivedLength;t._receivedLength+=o.byteLength,t._onDataArrival&&t._onDataArrival(o,_,t._receivedLength),t._pump(e)}})).catch((function(e){if(t._abortController&&t._abortController.signal.aborted)t._status=n.LoaderStatus.kComplete;else if(11!==e.code||!r.default.msedge){t._status=n.LoaderStatus.kError;var i=0,a=null;if(19!==e.code&&"network error"!==e.message||!(null===t._contentLength||null!==t._contentLength&&t._receivedLength<t._contentLength)?(i=n.LoaderErrors.EXCEPTION,a={code:e.code,msg:e.message}):(i=n.LoaderErrors.EARLY_EOF,a={code:e.code,msg:"Fetch stream meet Early-EOF"}),!t._onError)throw new s.RuntimeException(a.msg);t._onError(i,a)}}))},t}(n.BaseLoader);t.default=_},"./src/io/io-controller.js":
|
|
/*!*********************************!*\
|
|
!*** ./src/io/io-controller.js ***!
|
|
\*********************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! ../utils/logger.js */"./src/utils/logger.js"),r=i(/*! ./speed-sampler.js */"./src/io/speed-sampler.js"),n=i(/*! ./loader.js */"./src/io/loader.js"),s=i(/*! ./fetch-stream-loader.js */"./src/io/fetch-stream-loader.js"),o=i(/*! ./xhr-moz-chunked-loader.js */"./src/io/xhr-moz-chunked-loader.js"),_=i(/*! ./xhr-range-loader.js */"./src/io/xhr-range-loader.js"),d=i(/*! ./websocket-loader.js */"./src/io/websocket-loader.js"),l=i(/*! ./range-seek-handler.js */"./src/io/range-seek-handler.js"),u=i(/*! ./param-seek-handler.js */"./src/io/param-seek-handler.js"),c=i(/*! ../utils/exception.js */"./src/utils/exception.js"),h=function(){function e(e,t,i){this.TAG="IOController",this._config=t,this._extraData=i,this._stashInitialSize=393216,null!=t.stashInitialSize&&t.stashInitialSize>0&&(this._stashInitialSize=t.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===t.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new r.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 e.prototype.destroy=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},e.prototype.isWorking=function(){return this._loader&&this._loader.isWorking()&&!this._paused},e.prototype.isPaused=function(){return this._paused},Object.defineProperty(e.prototype,"status",{get:function(){return this._loader.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"extraData",{get:function(){return this._extraData},set:function(e){this._extraData=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onSeeked",{get:function(){return this._onSeeked},set:function(e){this._onSeeked=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRedirect",{get:function(){return this._onRedirect},set:function(e){this._onRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRecoveredEarlyEof",{get:function(){return this._onRecoveredEarlyEof},set:function(e){this._onRecoveredEarlyEof=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentURL",{get:function(){return this._dataSource.url},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRedirect",{get:function(){return null!=this._redirectedURL||null!=this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentRedirectedURL",{get:function(){return this._redirectedURL||this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentSpeed",{get:function(){return this._loaderClass===_.default?this._loader.currentSpeed:this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loaderType",{get:function(){return this._loader.type},enumerable:!1,configurable:!0}),e.prototype._selectSeekHandler=function(){var e=this._config;if("range"===e.seekType)this._seekHandler=new l.default(this._config.rangeLoadZeroStart);else if("param"===e.seekType){var t=e.seekParamStart||"bstart",i=e.seekParamEnd||"bend";this._seekHandler=new u.default(t,i)}else{if("custom"!==e.seekType)throw new c.InvalidArgumentException("Invalid seekType in config: "+e.seekType);if("function"!=typeof e.customSeekHandler)throw new c.InvalidArgumentException("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}},e.prototype._selectLoader=function(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=d.default;else if(s.default.isSupported())this._loaderClass=s.default;else if(o.default.isSupported())this._loaderClass=o.default;else{if(!_.default.isSupported())throw new c.RuntimeException("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=_.default}},e.prototype._createLoader=function(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(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)},e.prototype.open=function(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))},e.prototype.abort=function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)},e.prototype.pause=function(){this.isWorking()&&(this._loader.abort(),0!==this._stashUsed?(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)},e.prototype.resume=function(){if(this._paused){this._paused=!1;var e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}},e.prototype.seek=function(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)},e.prototype._internalSeek=function(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;var i={from:e,to:-1};this._currentRange={from:i.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,i),this._onSeeked&&this._onSeeked()},e.prototype.updateUrl=function(e){if(!e||"string"!=typeof e||0===e.length)throw new c.InvalidArgumentException("Url must be a non-empty string!");this._dataSource.url=e},e.prototype._expandBuffer=function(e){for(var t=this._stashSize;t+1048576<e;)t*=2;if((t+=1048576)!==this._bufferSize){var i=new ArrayBuffer(t);if(this._stashUsed>0){var a=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(i,0,t).set(a,0)}this._stashBuffer=i,this._bufferSize=t}},e.prototype._normalizeSpeed=function(e){var t=this._speedNormalizeList,i=t.length-1,a=0,r=0,n=i;if(e<t[0])return t[0];for(;r<=n;){if((a=r+Math.floor((n-r)/2))===i||e>=t[a]&&e<t[a+1])return t[a];t[a]<e?r=a+1:n=a-1}},e.prototype._adjustStashSize=function(e){var t=0;(t=this._config.isLive||e<512?e:e>=512&&e<=1024?Math.floor(1.5*e):2*e)>8192&&(t=8192);var i=1024*t+1048576;this._bufferSize<i&&this._expandBuffer(i),this._stashSize=1024*t},e.prototype._dispatchChunks=function(e,t){return this._currentRange.to=t+e.byteLength-1,this._onDataArrival(e,t)},e.prototype._onURLRedirect=function(e){this._redirectedURL=e,this._onRedirect&&this._onRedirect(e)},e.prototype._onContentLengthKnown=function(e){e&&this._fullRequestFlag&&(this._totalLength=e,this._fullRequestFlag=!1)},e.prototype._onLoaderChunkArrival=function(e,t,i){if(!this._onDataArrival)throw new c.IllegalStateException("IOController: No existing consumer (onDataArrival) callback!");if(!this._paused){this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(e.byteLength);var a=this._speedSampler.lastSecondKBps;if(0!==a){var r=this._normalizeSpeed(a);this._speedNormalized!==r&&(this._speedNormalized=r,this._adjustStashSize(r))}if(this._enableStash)if(0===this._stashUsed&&0===this._stashByteStart&&(this._stashByteStart=t),this._stashUsed+e.byteLength<=this._stashSize)(o=new Uint8Array(this._stashBuffer,0,this._stashSize)).set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength;else if(o=new Uint8Array(this._stashBuffer,0,this._bufferSize),this._stashUsed>0){var n=this._stashBuffer.slice(0,this._stashUsed);(_=this._dispatchChunks(n,this._stashByteStart))<n.byteLength?_>0&&(d=new Uint8Array(n,_),o.set(d,0),this._stashUsed=d.byteLength,this._stashByteStart+=_):(this._stashUsed=0,this._stashByteStart+=_),this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),o=new Uint8Array(this._stashBuffer,0,this._bufferSize)),o.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else(_=this._dispatchChunks(e,t))<e.byteLength&&((s=e.byteLength-_)>this._bufferSize&&(this._expandBuffer(s),o=new Uint8Array(this._stashBuffer,0,this._bufferSize)),o.set(new Uint8Array(e,_),0),this._stashUsed+=s,this._stashByteStart=t+_);else if(0===this._stashUsed){var s;(_=this._dispatchChunks(e,t))<e.byteLength&&((s=e.byteLength-_)>this._bufferSize&&this._expandBuffer(s),(o=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(e,_),0),this._stashUsed+=s,this._stashByteStart=t+_)}else{var o,_;if(this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength),(o=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength,(_=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart))<this._stashUsed&&_>0){var d=new Uint8Array(this._stashBuffer,_);o.set(d,0)}this._stashUsed-=_,this._stashByteStart+=_}}},e.prototype._flushStashBuffer=function(e){if(this._stashUsed>0){var t=this._stashBuffer.slice(0,this._stashUsed),i=this._dispatchChunks(t,this._stashByteStart),r=t.byteLength-i;if(i<t.byteLength){if(!e){if(i>0){var n=new Uint8Array(this._stashBuffer,0,this._bufferSize),s=new Uint8Array(t,i);n.set(s,0),this._stashUsed=s.byteLength,this._stashByteStart+=i}return 0}a.default.w(this.TAG,r+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,r}return 0},e.prototype._onLoaderComplete=function(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)},e.prototype._onLoaderError=function(e,t){switch(a.default.e(this.TAG,"Loader error, code = "+t.code+", msg = "+t.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=n.LoaderErrors.UNRECOVERABLE_EARLY_EOF),e){case n.LoaderErrors.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var i=this._currentRange.to+1;return void(i<this._totalLength&&(a.default.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(i,!1)))}e=n.LoaderErrors.UNRECOVERABLE_EARLY_EOF;case n.LoaderErrors.UNRECOVERABLE_EARLY_EOF:case n.LoaderErrors.CONNECTING_TIMEOUT:case n.LoaderErrors.HTTP_STATUS_CODE_INVALID:case n.LoaderErrors.EXCEPTION:}if(!this._onError)throw new c.RuntimeException("IOException: "+t.msg);this._onError(e,t)},e}();t.default=h},"./src/io/loader.js":
|
|
/*!**************************!*\
|
|
!*** ./src/io/loader.js ***!
|
|
\**************************/function(e,t,i){"use strict";i.r(t),i.d(t,{LoaderStatus:function(){return r},LoaderErrors:function(){return n},BaseLoader:function(){return s}});var a=i(/*! ../utils/exception.js */"./src/utils/exception.js"),r={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},n={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"},s=function(){function e(e){this._type=e||"undefined",this._status=r.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}return e.prototype.destroy=function(){this._status=r.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null},e.prototype.isWorking=function(){return this._status===r.kConnecting||this._status===r.kBuffering},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needStashBuffer",{get:function(){return this._needStash},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onContentLengthKnown",{get:function(){return this._onContentLengthKnown},set:function(e){this._onContentLengthKnown=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onURLRedirect",{get:function(){return this._onURLRedirect},set:function(e){this._onURLRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),e.prototype.open=function(e,t){throw new a.NotImplementedException("Unimplemented abstract function!")},e.prototype.abort=function(){throw new a.NotImplementedException("Unimplemented abstract function!")},e}()},"./src/io/param-seek-handler.js":
|
|
/*!**************************************!*\
|
|
!*** ./src/io/param-seek-handler.js ***!
|
|
\**************************************/function(e,t,i){"use strict";i.r(t);var a=function(){function e(e,t){this._startName=e,this._endName=t}return e.prototype.getConfig=function(e,t){var i=e;if(0!==t.from||-1!==t.to){var a=!0;-1===i.indexOf("?")&&(i+="?",a=!1),a&&(i+="&"),i+=this._startName+"="+t.from.toString(),-1!==t.to&&(i+="&"+this._endName+"="+t.to.toString())}return{url:i,headers:{}}},e.prototype.removeURLParameters=function(e){var t=e.split("?")[0],i=void 0,a=e.indexOf("?");-1!==a&&(i=e.substring(a+1));var r="";if(null!=i&&i.length>0)for(var n=i.split("&"),s=0;s<n.length;s++){var o=n[s].split("="),_=s>0;o[0]!==this._startName&&o[0]!==this._endName&&(_&&(r+="&"),r+=n[s])}return 0===r.length?t:t+"?"+r},e}();t.default=a},"./src/io/range-seek-handler.js":
|
|
/*!**************************************!*\
|
|
!*** ./src/io/range-seek-handler.js ***!
|
|
\**************************************/function(e,t,i){"use strict";i.r(t);var a=function(){function e(e){this._zeroStart=e||!1}return e.prototype.getConfig=function(e,t){var i={};if(0!==t.from||-1!==t.to){var a=void 0;a=-1!==t.to?"bytes="+t.from.toString()+"-"+t.to.toString():"bytes="+t.from.toString()+"-",i.Range=a}else this._zeroStart&&(i.Range="bytes=0-");return{url:e,headers:i}},e.prototype.removeURLParameters=function(e){return e},e}();t.default=a},"./src/io/speed-sampler.js":
|
|
/*!*********************************!*\
|
|
!*** ./src/io/speed-sampler.js ***!
|
|
\*********************************/function(e,t,i){"use strict";i.r(t);var a=function(){function e(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}return e.prototype.reset=function(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0},e.prototype.addBytes=function(e){0===this._firstCheckpoint?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=e,this._totalBytes+=e):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=e,this._totalBytes+=e):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=e,this._totalBytes+=e,this._lastCheckpoint=this._now())},Object.defineProperty(e.prototype,"currentKBps",{get:function(){this.addBytes(0);var e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastSecondKBps",{get:function(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageKBps",{get:function(){var e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024},enumerable:!1,configurable:!0}),e}();t.default=a},"./src/io/websocket-loader.js":
|
|
/*!************************************!*\
|
|
!*** ./src/io/websocket-loader.js ***!
|
|
\************************************/function(e,t,i){"use strict";i.r(t);var a,r=i(/*! ./loader.js */"./src/io/loader.js"),n=i(/*! ../utils/exception.js */"./src/utils/exception.js"),s=(a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},a(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),o=function(e){function t(){var t=e.call(this,"websocket-loader")||this;return t.TAG="WebSocketLoader",t._needStash=!0,t._ws=null,t._requestAbort=!1,t._receivedLength=0,t}return s(t,e),t.isSupported=function(){try{return void 0!==self.WebSocket}catch(e){return!1}},t.prototype.destroy=function(){this._ws&&this.abort(),e.prototype.destroy.call(this)},t.prototype.open=function(e){try{var t=this._ws=new self.WebSocket(e.url);t.binaryType="arraybuffer",t.onopen=this._onWebSocketOpen.bind(this),t.onclose=this._onWebSocketClose.bind(this),t.onmessage=this._onWebSocketMessage.bind(this),t.onerror=this._onWebSocketError.bind(this),this._status=r.LoaderStatus.kConnecting}catch(e){this._status=r.LoaderStatus.kError;var i={code:e.code,msg:e.message};if(!this._onError)throw new n.RuntimeException(i.msg);this._onError(r.LoaderErrors.EXCEPTION,i)}},t.prototype.abort=function(){var e=this._ws;!e||0!==e.readyState&&1!==e.readyState||(this._requestAbort=!0,e.close()),this._ws=null,this._status=r.LoaderStatus.kComplete},t.prototype._onWebSocketOpen=function(e){this._status=r.LoaderStatus.kBuffering},t.prototype._onWebSocketClose=function(e){!0!==this._requestAbort?(this._status=r.LoaderStatus.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)):this._requestAbort=!1},t.prototype._onWebSocketMessage=function(e){var t=this;if(e.data instanceof ArrayBuffer)this._dispatchArrayBuffer(e.data);else if(e.data instanceof Blob){var i=new FileReader;i.onload=function(){t._dispatchArrayBuffer(i.result)},i.readAsArrayBuffer(e.data)}else{this._status=r.LoaderStatus.kError;var a={code:-1,msg:"Unsupported WebSocket message type: "+e.data.constructor.name};if(!this._onError)throw new n.RuntimeException(a.msg);this._onError(r.LoaderErrors.EXCEPTION,a)}},t.prototype._dispatchArrayBuffer=function(e){var t=e,i=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)},t.prototype._onWebSocketError=function(e){this._status=r.LoaderStatus.kError;var t={code:e.code,msg:e.message};if(!this._onError)throw new n.RuntimeException(t.msg);this._onError(r.LoaderErrors.EXCEPTION,t)},t}(r.BaseLoader);t.default=o},"./src/io/xhr-moz-chunked-loader.js":
|
|
/*!******************************************!*\
|
|
!*** ./src/io/xhr-moz-chunked-loader.js ***!
|
|
\******************************************/function(e,t,i){"use strict";i.r(t);var a,r=i(/*! ../utils/logger.js */"./src/utils/logger.js"),n=i(/*! ./loader.js */"./src/io/loader.js"),s=i(/*! ../utils/exception.js */"./src/utils/exception.js"),o=(a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},a(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),_=function(e){function t(t,i){var a=e.call(this,"xhr-moz-chunked-loader")||this;return a.TAG="MozChunkedLoader",a._seekHandler=t,a._config=i,a._needStash=!0,a._xhr=null,a._requestAbort=!1,a._contentLength=null,a._receivedLength=0,a}return o(t,e),t.isSupported=function(){try{var e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="moz-chunked-arraybuffer","moz-chunked-arraybuffer"===e.responseType}catch(e){return r.default.w("MozChunkedLoader",e.message),!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),e.prototype.destroy.call(this)},t.prototype.open=function(e,t){this._dataSource=e,this._range=t;var i=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(i=e.redirectedURL);var a=this._seekHandler.getConfig(i,t);this._requestURL=a.url;var r=this._xhr=new XMLHttpRequest;if(r.open("GET",a.url,!0),r.responseType="moz-chunked-arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onloadend=this._onLoadEnd.bind(this),r.onerror=this._onXhrError.bind(this),e.withCredentials&&(r.withCredentials=!0),"object"==typeof a.headers){var s=a.headers;for(var o in s)s.hasOwnProperty(o)&&r.setRequestHeader(o,s[o])}if("object"==typeof this._config.headers)for(var o in s=this._config.headers)s.hasOwnProperty(o)&&r.setRequestHeader(o,s[o]);this._status=n.LoaderStatus.kConnecting,r.send()},t.prototype.abort=function(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=n.LoaderStatus.kComplete},t.prototype._onReadyStateChange=function(e){var t=e.target;if(2===t.readyState){if(null!=t.responseURL&&t.responseURL!==this._requestURL&&this._onURLRedirect){var i=this._seekHandler.removeURLParameters(t.responseURL);this._onURLRedirect(i)}if(0!==t.status&&(t.status<200||t.status>299)){if(this._status=n.LoaderStatus.kError,!this._onError)throw new s.RuntimeException("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(n.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=n.LoaderStatus.kBuffering}},t.prototype._onProgress=function(e){if(this._status!==n.LoaderStatus.kError){null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var t=e.target.response,i=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}},t.prototype._onLoadEnd=function(e){!0!==this._requestAbort?this._status!==n.LoaderStatus.kError&&(this._status=n.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1},t.prototype._onXhrError=function(e){this._status=n.LoaderStatus.kError;var t=0,i=null;if(this._contentLength&&e.loaded<this._contentLength?(t=n.LoaderErrors.EARLY_EOF,i={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(t=n.LoaderErrors.EXCEPTION,i={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new s.RuntimeException(i.msg);this._onError(t,i)},t}(n.BaseLoader);t.default=_},"./src/io/xhr-range-loader.js":
|
|
/*!************************************!*\
|
|
!*** ./src/io/xhr-range-loader.js ***!
|
|
\************************************/function(e,t,i){"use strict";i.r(t);var a,r=i(/*! ../utils/logger.js */"./src/utils/logger.js"),n=i(/*! ./speed-sampler.js */"./src/io/speed-sampler.js"),s=i(/*! ./loader.js */"./src/io/loader.js"),o=i(/*! ../utils/exception.js */"./src/utils/exception.js"),_=(a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},a(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),d=function(e){function t(t,i){var a=e.call(this,"xhr-range-loader")||this;return a.TAG="RangeLoader",a._seekHandler=t,a._config=i,a._needStash=!1,a._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],a._currentChunkSizeKB=384,a._currentSpeedNormalized=0,a._zeroSpeedChunkCount=0,a._xhr=null,a._speedSampler=new n.default,a._requestAbort=!1,a._waitForTotalLength=!1,a._totalLengthReceived=!1,a._currentRequestURL=null,a._currentRedirectedURL=null,a._currentRequestRange=null,a._totalLength=null,a._contentLength=null,a._receivedLength=0,a._lastTimeLoaded=0,a}return _(t,e),t.isSupported=function(){try{var e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="arraybuffer","arraybuffer"===e.responseType}catch(e){return r.default.w("RangeLoader",e.message),!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),e.prototype.destroy.call(this)},Object.defineProperty(t.prototype,"currentSpeed",{get:function(){return this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),t.prototype.open=function(e,t){this._dataSource=e,this._range=t,this._status=s.LoaderStatus.kConnecting;var i=!1;null!=this._dataSource.filesize&&0!==this._dataSource.filesize&&(i=!0,this._totalLength=this._dataSource.filesize),this._totalLengthReceived||i?this._openSubRange():(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1}))},t.prototype._openSubRange=function(){var e=1024*this._currentChunkSizeKB,t=this._range.from+this._receivedLength,i=t+e;null!=this._contentLength&&i-this._range.from>=this._contentLength&&(i=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:i},this._internalOpen(this._dataSource,this._currentRequestRange)},t.prototype._internalOpen=function(e,t){this._lastTimeLoaded=0;var i=e.url;this._config.reuseRedirectedURL&&(null!=this._currentRedirectedURL?i=this._currentRedirectedURL:null!=e.redirectedURL&&(i=e.redirectedURL));var a=this._seekHandler.getConfig(i,t);this._currentRequestURL=a.url;var r=this._xhr=new XMLHttpRequest;if(r.open("GET",a.url,!0),r.responseType="arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onload=this._onLoad.bind(this),r.onerror=this._onXhrError.bind(this),e.withCredentials&&(r.withCredentials=!0),"object"==typeof a.headers){var n=a.headers;for(var s in n)n.hasOwnProperty(s)&&r.setRequestHeader(s,n[s])}if("object"==typeof this._config.headers)for(var s in n=this._config.headers)n.hasOwnProperty(s)&&r.setRequestHeader(s,n[s]);r.send()},t.prototype.abort=function(){this._requestAbort=!0,this._internalAbort(),this._status=s.LoaderStatus.kComplete},t.prototype._internalAbort=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)},t.prototype._onReadyStateChange=function(e){var t=e.target;if(2===t.readyState){if(null!=t.responseURL){var i=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&i!==this._currentRedirectedURL&&(this._currentRedirectedURL=i,this._onURLRedirect&&this._onURLRedirect(i))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=s.LoaderStatus.kBuffering}else{if(this._status=s.LoaderStatus.kError,!this._onError)throw new o.RuntimeException("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(s.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}},t.prototype._onProgress=function(e){if(this._status!==s.LoaderStatus.kError){if(null===this._contentLength){var t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;var i=e.total;this._internalAbort(),null!=i&0!==i&&(this._totalLength=i)}if(-1===this._range.to?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,t)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var a=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(a)}},t.prototype._normalizeSpeed=function(e){var t=this._chunkSizeKBList,i=t.length-1,a=0,r=0,n=i;if(e<t[0])return t[0];for(;r<=n;){if((a=r+Math.floor((n-r)/2))===i||e>=t[a]&&e<t[a+1])return t[a];t[a]<e?r=a+1:n=a-1}},t.prototype._onLoad=function(e){if(this._status!==s.LoaderStatus.kError)if(this._waitForTotalLength)this._waitForTotalLength=!1;else{this._lastTimeLoaded=0;var t=this._speedSampler.lastSecondKBps;if(0===t&&(this._zeroSpeedChunkCount++,this._zeroSpeedChunkCount>=3&&(t=this._speedSampler.currentKBps)),0!==t){var i=this._normalizeSpeed(t);this._currentSpeedNormalized!==i&&(this._currentSpeedNormalized=i,this._currentChunkSizeKB=i)}var a=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=a.byteLength;var n=!1;null!=this._contentLength&&this._receivedLength<this._contentLength?this._openSubRange():n=!0,this._onDataArrival&&this._onDataArrival(a,r,this._receivedLength),n&&(this._status=s.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}},t.prototype._onXhrError=function(e){this._status=s.LoaderStatus.kError;var t=0,i=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(t=s.LoaderErrors.EARLY_EOF,i={code:-1,msg:"RangeLoader meet Early-Eof"}):(t=s.LoaderErrors.EXCEPTION,i={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new o.RuntimeException(i.msg);this._onError(t,i)},t}(s.BaseLoader);t.default=d},"./src/player/flv-player.js":
|
|
/*!**********************************!*\
|
|
!*** ./src/player/flv-player.js ***!
|
|
\**********************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! events */"./node_modules/events/events.js"),r=i.n(a),n=i(/*! ../utils/logger.js */"./src/utils/logger.js"),s=i(/*! ../utils/browser.js */"./src/utils/browser.js"),o=i(/*! ./player-events.js */"./src/player/player-events.js"),_=i(/*! ../core/transmuxer.js */"./src/core/transmuxer.js"),d=i(/*! ../core/transmuxing-events.js */"./src/core/transmuxing-events.js"),l=i(/*! ../core/mse-controller.js */"./src/core/mse-controller.js"),u=i(/*! ../core/mse-events.js */"./src/core/mse-events.js"),c=i(/*! ./player-errors.js */"./src/player/player-errors.js"),h=i(/*! ../config.js */"./src/config.js"),f=i(/*! ../utils/exception.js */"./src/utils/exception.js"),p=function(){function e(e,t){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new(r()),this._config=(0,h.createDefaultConfig)(),"object"==typeof t&&Object.assign(this._config,t),"flv"!==e.type.toLowerCase())throw new f.InvalidArgumentException("FlvPlayer requires an flv MediaDataSource input!");!0===e.isLive&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=e,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;var i=s.default.chrome&&(s.default.version.major<50||50===s.default.version.major&&s.default.version.build<2661);this._alwaysSeekKeyframe=!!(i||s.default.msedge||s.default.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}return e.prototype.destroy=function(){null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){var i=this;e===o.default.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then((function(){i._emitter.emit(o.default.MEDIA_INFO,i.mediaInfo)})):e===o.default.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then((function(){i._emitter.emit(o.default.STATISTICS_INFO,i.statisticsInfo)})),this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){var t=this;if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),e.addEventListener("seeking",this.e.onvSeeking),e.addEventListener("canplay",this.e.onvCanPlay),e.addEventListener("stalled",this.e.onvStalled),e.addEventListener("progress",this.e.onvProgress),this._msectl=new l.default(this._config),this._msectl.on(u.default.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(u.default.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(u.default.SOURCE_OPEN,(function(){t._mseSourceOpened=!0,t._hasPendingLoad&&(t._hasPendingLoad=!1,t.load())})),this._msectl.on(u.default.ERROR,(function(e){t._emitter.emit(o.default.ERROR,c.ErrorTypes.MEDIA_ERROR,c.ErrorDetails.MEDIA_MSE_ERROR,e)})),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}},e.prototype.detachMediaElement=function(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)},e.prototype.load=function(){var e=this;if(!this._mediaElement)throw new f.IllegalStateException("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new f.IllegalStateException("FlvPlayer.load() has been called, please call unload() first!");this._hasPendingLoad||(this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened?this._hasPendingLoad=!0:(this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new _.default(this._mediaDataSource,this._config),this._transmuxer.on(d.default.INIT_SEGMENT,(function(t,i){e._msectl.appendInitSegment(i)})),this._transmuxer.on(d.default.MEDIA_SEGMENT,(function(t,i){if(e._msectl.appendMediaSegment(i),e._config.lazyLoad&&!e._config.isLive){var a=e._mediaElement.currentTime;i.info.endDts>=1e3*(a+e._config.lazyLoadMaxDuration)&&null==e._progressChecker&&(n.default.v(e.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),e._suspendTransmuxer())}})),this._transmuxer.on(d.default.LOADING_COMPLETE,(function(){e._msectl.endOfStream(),e._emitter.emit(o.default.LOADING_COMPLETE)})),this._transmuxer.on(d.default.RECOVERED_EARLY_EOF,(function(){e._emitter.emit(o.default.RECOVERED_EARLY_EOF)})),this._transmuxer.on(d.default.IO_ERROR,(function(t,i){e._emitter.emit(o.default.ERROR,c.ErrorTypes.NETWORK_ERROR,t,i)})),this._transmuxer.on(d.default.DEMUX_ERROR,(function(t,i){e._emitter.emit(o.default.ERROR,c.ErrorTypes.MEDIA_ERROR,t,{code:-1,msg:i})})),this._transmuxer.on(d.default.MEDIA_INFO,(function(t){e._mediaInfo=t,e._emitter.emit(o.default.MEDIA_INFO,Object.assign({},t))})),this._transmuxer.on(d.default.METADATA_ARRIVED,(function(t){e._emitter.emit(o.default.METADATA_ARRIVED,t)})),this._transmuxer.on(d.default.SCRIPTDATA_ARRIVED,(function(t){e._emitter.emit(o.default.SCRIPTDATA_ARRIVED,t)})),this._transmuxer.on(d.default.STATISTICS_INFO,(function(t){e._statisticsInfo=e._fillStatisticsInfo(t),e._emitter.emit(o.default.STATISTICS_INFO,Object.assign({},e._statisticsInfo))})),this._transmuxer.on(d.default.RECOMMEND_SEEKPOINT,(function(t){e._mediaElement&&!e._config.accurateSeek&&(e._requestSetTime=!0,e._mediaElement.currentTime=t/1e3)})),this._transmuxer.open()))},e.prototype.unload=function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)},e.prototype.seekStart=function(){var e=this._mediaElement.buffered;this._mediaElement.currentTime=e.start(0)},e.prototype.test1=function(){this._mediaElement.buffered.start(0)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._internalSeek(e):this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){return Object.assign({},this._mediaInfo)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){return null==this._statisticsInfo&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)},enumerable:!1,configurable:!0}),e.prototype._fillStatisticsInfo=function(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,i=0,a=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();i=r.totalVideoFrames,a=r.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,a=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=a),e},e.prototype._onmseUpdateEnd=function(){if(this._config.lazyLoad&&!this._config.isLive){for(var e=this._mediaElement.buffered,t=this._mediaElement.currentTime,i=0,a=0;a<e.length;a++){var r=e.start(a),s=e.end(a);if(r<=t&&t<s){i=s;break}}i>=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(n.default.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}},e.prototype._onmseBufferFull=function(){n.default.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()},e.prototype._suspendTransmuxer=function(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))},e.prototype._checkProgressAndResume=function(){for(var e=this._mediaElement.currentTime,t=this._mediaElement.buffered,i=!1,a=0;a<t.length;a++){var r=t.start(a),s=t.end(a);if(e>=r&&e<s){e>=s-this._config.lazyLoadRecoverDuration&&(i=!0);break}}i&&(window.clearInterval(this._progressChecker),this._progressChecker=null,i&&(n.default.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))},e.prototype._isTimepointBuffered=function(e){for(var t=this._mediaElement.buffered,i=0;i<t.length;i++){var a=t.start(i),r=t.end(i);if(e>=a&&e<r)return!0}return!1},e.prototype._internalSeek=function(e){var t=this._isTimepointBuffered(e),i=!1,a=0;if(e<1&&this._mediaElement.buffered.length>0){var r=this._mediaElement.buffered.start(0);(r<1&&e<r||s.default.safari)&&(i=!0,a=s.default.safari?.1:r)}if(i)this._requestSetTime=!0,this._mediaElement.currentTime=a;else if(t){if(this._alwaysSeekKeyframe){var n=this._msectl.getNearestKeyframe(Math.floor(1e3*e));this._requestSetTime=!0,this._mediaElement.currentTime=null!=n?n.dts/1e3:e}else this._requestSetTime=!0,this._mediaElement.currentTime=e;null!=this._progressChecker&&this._checkProgressAndResume()}else null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e)},e.prototype._checkAndApplyUnbufferedSeekpoint=function(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){var e=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(e)||(null!=this._progressChecker&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)},e.prototype._checkAndResumeStuckPlayback=function(e){var t=this._mediaElement;if(e||!this._receivedCanPlay||t.readyState<2){var i=t.buffered;i.length>0&&t.currentTime<i.start(0)&&(n.default.w(this.TAG,"Playback seems stuck at "+t.currentTime+", seek to "+i.start(0)),this._requestSetTime=!0,this._mediaElement.currentTime=i.start(0),this._mediaElement.removeEventListener("progress",this.e.onvProgress))}else this._mediaElement.removeEventListener("progress",this.e.onvProgress)},e.prototype._onvLoadedMetadata=function(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)},e.prototype._onvSeeking=function(e){var t=this._mediaElement.currentTime,i=this._mediaElement.buffered;if(this._requestSetTime)this._requestSetTime=!1;else{if(t<1&&i.length>0){var a=i.start(0);if(a<1&&t<a||s.default.safari)return this._requestSetTime=!0,void(this._mediaElement.currentTime=s.default.safari?.1:a)}if(this._isTimepointBuffered(t)){if(this._alwaysSeekKeyframe){var r=this._msectl.getNearestKeyframe(Math.floor(1e3*t));null!=r&&(this._requestSetTime=!0,this._mediaElement.currentTime=r.dts/1e3)}null!=this._progressChecker&&this._checkProgressAndResume()}else this._seekpointRecord={seekPoint:t,recordTime:this._now()},window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}},e.prototype._onvCanPlay=function(e){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)},e.prototype._onvStalled=function(e){this._checkAndResumeStuckPlayback(!0)},e.prototype._onvProgress=function(e){this._checkAndResumeStuckPlayback()},e}();t.default=p},"./src/player/native-player.js":
|
|
/*!*************************************!*\
|
|
!*** ./src/player/native-player.js ***!
|
|
\*************************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! events */"./node_modules/events/events.js"),r=i.n(a),n=i(/*! ./player-events.js */"./src/player/player-events.js"),s=i(/*! ../config.js */"./src/config.js"),o=i(/*! ../utils/exception.js */"./src/utils/exception.js"),_=function(){function e(e,t){if(this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new(r()),this._config=(0,s.createDefaultConfig)(),"object"==typeof t&&Object.assign(this._config,t),"flv"===e.type.toLowerCase())throw new o.InvalidArgumentException("NativePlayer does't support flv MediaDataSource input!");if(e.hasOwnProperty("segments"))throw new o.InvalidArgumentException("NativePlayer("+e.type+") doesn't support multipart playback!");this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=e,this._mediaElement=null}return e.prototype.destroy=function(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){var i=this;e===n.default.MEDIA_INFO?null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then((function(){i._emitter.emit(n.default.MEDIA_INFO,i.mediaInfo)})):e===n.default.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then((function(){i._emitter.emit(n.default.STATISTICS_INFO,i.statisticsInfo)})),this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}},e.prototype.detachMediaElement=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype.load=function(){if(!this._mediaElement)throw new o.IllegalStateException("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)},e.prototype.unload=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){var e={mimeType:(this._mediaElement instanceof HTMLAudioElement?"audio/":"video/")+this._mediaDataSource.type};return this._mediaElement&&(e.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(e.width=this._mediaElement.videoWidth,e.height=this._mediaElement.videoHeight)),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){var e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,i=0,a=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();i=r.totalVideoFrames,a=r.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,a=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=a),e},enumerable:!1,configurable:!0}),e.prototype._onvLoadedMetadata=function(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(n.default.MEDIA_INFO,this.mediaInfo)},e.prototype._reportStatisticsInfo=function(){this._emitter.emit(n.default.STATISTICS_INFO,this.statisticsInfo)},e}();t.default=_},"./src/player/player-errors.js":
|
|
/*!*************************************!*\
|
|
!*** ./src/player/player-errors.js ***!
|
|
\*************************************/function(e,t,i){"use strict";i.r(t),i.d(t,{ErrorTypes:function(){return n},ErrorDetails:function(){return s}});var a=i(/*! ../io/loader.js */"./src/io/loader.js"),r=i(/*! ../demux/demux-errors.js */"./src/demux/demux-errors.js"),n={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},s={NETWORK_EXCEPTION:a.LoaderErrors.EXCEPTION,NETWORK_STATUS_CODE_INVALID:a.LoaderErrors.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:a.LoaderErrors.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:a.LoaderErrors.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:r.default.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:r.default.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:r.default.CODEC_UNSUPPORTED}},"./src/player/player-events.js":
|
|
/*!*************************************!*\
|
|
!*** ./src/player/player-events.js ***!
|
|
\*************************************/function(e,t,i){"use strict";i.r(t),t.default={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"}},"./src/remux/aac-silent.js":
|
|
/*!*********************************!*\
|
|
!*** ./src/remux/aac-silent.js ***!
|
|
\*********************************/function(e,t,i){"use strict";i.r(t);var a=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null},e}();t.default=a},"./src/remux/mp4-generator.js":
|
|
/*!************************************!*\
|
|
!*** ./src/remux/mp4-generator.js ***!
|
|
\************************************/function(e,t,i){"use strict";i.r(t);var a=function(){function e(){}return e.init=function(){for(var t in e.types={hvc1:[],hvcC:[],avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],pasp:[],".mp3":[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=e.constants={};i.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),i.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),i.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSC=i.STCO=i.STTS,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),i.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])},e.box=function(e){for(var t=8,i=null,a=Array.prototype.slice.call(arguments,1),r=a.length,n=0;n<r;n++)t+=a[n].byteLength;(i=new Uint8Array(t))[0]=t>>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i.set(e,4);var s=8;for(n=0;n<r;n++)i.set(a[n],s),s+=a[n].byteLength;return i},e.generateInitSegment=function(t){var i=e.box(e.types.ftyp,e.constants.FTYP),a=e.moov(t),r=new Uint8Array(i.byteLength+a.byteLength);return r.set(i,0),r.set(a,i.byteLength),r},e.moov=function(t){var i=e.mvhd(t.timescale,t.duration),a=e.trak(t),r=e.mvex(t);return e.box(e.types.moov,i,a,r)},e.mvhd=function(t,i){return e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,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]))},e.trak=function(t){return e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.tkhd=function(t){var i=t.id,a=t.duration,r=t.presentWidth,n=t.presentHeight;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,255&a,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,n>>>8&255,255&n,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t),e.hdlr(t),e.minf(t))},e.mdhd=function(t){var i=t.timescale,a=t.duration;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,85,196,0,0]))},e.hdlr=function(t){var i=null;return i="audio"===t.type?e.constants.HDLR_AUDIO:e.constants.HDLR_VIDEO,e.box(e.types.hdlr,i)},e.minf=function(t){var i=null;return i="audio"===t.type?e.box(e.types.smhd,e.constants.SMHD):e.box(e.types.vmhd,e.constants.VMHD),e.box(e.types.minf,i,e.dinf(),e.stbl(t))},e.dinf=function(){return e.box(e.types.dinf,e.box(e.types.dref,e.constants.DREF))},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.constants.STTS),e.box(e.types.stsc,e.constants.STSC),e.box(e.types.stsz,e.constants.STSZ),e.box(e.types.stco,e.constants.STCO))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp3(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp4a(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.avc1(t))},e.mp3=function(t){var i=t.channelCount,a=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,a>>>8&255,255&a,0,0]);return e.box(e.types[".mp3"],r)},e.mp4a=function(t){var i=t.channelCount,a=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,a>>>8&255,255&a,0,0]);return e.box(e.types.mp4a,r,e.esds(t))},e.esds=function(t){var i=t.config||[],a=i.length,r=new Uint8Array([0,0,0,0,3,23+a,0,1,0,4,15+a,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([a]).concat(i).concat([6,1,2]));return e.box(e.types.esds,r)},e.avc1=function(t){var i=t.avcc,a=t.codecWidth,r=t.codecHeight,n=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,a>>>8&255,255&a,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 t.codec.indexOf("avc1")>=0?e.box(e.types.avc1,n,e.box(e.types.avcC,i)):e.box(e.types.hvc1,n,e.box(e.types.hvcC,i))},e.mvex=function(t){return e.box(e.types.mvex,e.trex(t))},e.trex=function(t){var i=t.id,a=new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.box(e.types.trex,a)},e.moof=function(t,i){return e.box(e.types.moof,e.mfhd(t.sequenceNumber),e.traf(t,i))},e.mfhd=function(t){var i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]);return e.box(e.types.mfhd,i)},e.traf=function(t,i){var a=t.id,r=e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,255&a])),n=e.box(e.types.tfdt,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),s=e.sdtp(t),o=e.trun(t,s.byteLength+16+16+8+16+8+8);return e.box(e.types.traf,r,n,o,s)},e.sdtp=function(t){for(var i=t.samples||[],a=i.length,r=new Uint8Array(4+a),n=0;n<a;n++){var s=i[n].flags;r[n+4]=s.isLeading<<6|s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy}return e.box(e.types.sdtp,r)},e.trun=function(t,i){var a=t.samples||[],r=a.length,n=12+16*r,s=new Uint8Array(n);i+=8+n,s.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0);for(var o=0;o<r;o++){var _=a[o].duration,d=a[o].size,l=a[o].flags,u=a[o].cts;s.set([_>>>24&255,_>>>16&255,_>>>8&255,255&_,d>>>24&255,d>>>16&255,d>>>8&255,255&d,l.isLeading<<2|l.dependsOn,l.isDependedOn<<6|l.hasRedundancy<<4|l.isNonSync,0,0,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*o)}return e.box(e.types.trun,s)},e.mdat=function(t){return e.box(e.types.mdat,t)},e}();a.init(),t.default=a},"./src/remux/mp4-remuxer.js":
|
|
/*!**********************************!*\
|
|
!*** ./src/remux/mp4-remuxer.js ***!
|
|
\**********************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! ../utils/logger.js */"./src/utils/logger.js"),r=i(/*! ./mp4-generator.js */"./src/remux/mp4-generator.js"),n=i(/*! ./aac-silent.js */"./src/remux/aac-silent.js"),s=i(/*! ../utils/browser.js */"./src/utils/browser.js"),o=i(/*! ../core/media-segment-info.js */"./src/core/media-segment-info.js"),_=i(/*! ../utils/exception.js */"./src/utils/exception.js"),d=function(){function e(e){this.TAG="MP4Remuxer",this._config=e,this._isLive=!0===e.isLive,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new o.MediaSegmentInfoList("audio"),this._videoSegmentInfoList=new o.MediaSegmentInfoList("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!s.default.chrome||!(s.default.version.major<50||50===s.default.version.major&&s.default.version.build<2661)),this._fillSilentAfterSeek=s.default.msedge||s.default.msie,this._mp3UseMpegAudio=!s.default.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return e.prototype.destroy=function(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null},e.prototype.bindDataSource=function(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this},Object.defineProperty(e.prototype,"onInitSegment",{get:function(){return this._onInitSegment},set:function(e){this._onInitSegment=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaSegment",{get:function(){return this._onMediaSegment},set:function(e){this._onMediaSegment=e},enumerable:!1,configurable:!0}),e.prototype.insertDiscontinuity=function(){this._audioNextDts=this._videoNextDts=void 0},e.prototype.seek=function(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()},e.prototype.remux=function(e,t){if(!this._onMediaSegment)throw new _.IllegalStateException("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),this._remuxVideo(t),this._remuxAudio(e)},e.prototype._onTrackMetadataReceived=function(e,t){var i=null,a="mp4",n=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(a="mpeg",n="",i=new Uint8Array):i=r.default.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,i=r.default.generateInitSegment(t)}if(!this._onInitSegment)throw new _.IllegalStateException("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:i.buffer,codec:n,container:e+"/"+a,mediaDuration:t.duration})},e.prototype._calculateDtsBase=function(e,t){this._dtsBaseInited||(e.samples&&e.samples.length&&(this._audioDtsBase=e.samples[0].dts),t.samples&&t.samples.length&&(this._videoDtsBase=t.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)},e.prototype.flushStashedSamples=function(){var e=this._videoStashedLastSample,t=this._audioStashedLastSample,i={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(i.samples.push(e),i.length=e.length);var a={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(a.samples.push(t),a.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(i,!0),this._remuxAudio(a,!0)},e.prototype._remuxAudio=function(e,t){if(null!=this._audioMeta){var i,_=e,d=_.samples,l=void 0,u=-1,c=this._audioMeta.refSampleDuration,h="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,f=this._dtsBaseInited&&void 0===this._audioNextDts,p=!1;if(d&&0!==d.length&&(1!==d.length||t)){var m=0,g=null,y=0;h?(m=0,y=_.length):(m=8,y=8+_.length);var v=null;if(d.length>1&&(y-=(v=d.pop()).length),null!=this._audioStashedLastSample){var b=this._audioStashedLastSample;this._audioStashedLastSample=null,d.unshift(b),y+=b.length}null!=v&&(this._audioStashedLastSample=v);var E=d[0].dts-this._dtsBase;if(this._audioNextDts)l=E-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())l=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(p=!0);else{var S=this._audioSegmentInfoList.getLastSampleBefore(E);if(null!=S){var A=E-(S.originalDts+S.duration);A<=3&&(A=0),l=E-(S.dts+S.duration+A)}else l=0}if(p){var w=E-l,k=this._videoSegmentInfoList.getLastSegmentBefore(E);if(null!=k&&k.beginDts<w){if(B=n.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount)){var T=k.beginDts,L=w-k.beginDts;a.default.v(this.TAG,"InsertPrefixSilentAudio: dts: "+T+", duration: "+L),d.unshift({unit:B,dts:T,pts:T}),y+=B.byteLength}}else p=!1}for(var R=[],C=0;C<d.length;C++){var x=(b=d[C]).unit,M=b.dts-this._dtsBase,D=(T=M,!1),O=null,I=0;if(!(M<-.001)){if("mp3"!==this._audioMeta.codec){var P=M;if(this._audioNextDts&&(P=this._audioNextDts),(l=M-P)<=-3*c){a.default.w(this.TAG,"Dropping 1 audio frame (originalDts: "+M+" ms ,curRefDts: "+P+" ms) due to dtsCorrection: "+l+" ms overlap.");continue}if(l>=3*c&&this._fillAudioTimestampGap&&!s.default.safari){D=!0;var B,U=Math.floor(l/c);a.default.w(this.TAG,"Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\noriginalDts: "+M+" ms, curRefDts: "+P+" ms, dtsCorrection: "+Math.round(l)+" ms, generate: "+U+" frames"),T=Math.floor(P),I=Math.floor(P+c)-T,null==(B=n.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount))&&(a.default.w(this.TAG,"Unable to generate silent frame for "+this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame"),B=x),O=[];for(var N=0;N<U;N++){P+=c;var F=Math.floor(P),V=Math.floor(P+c)-F,j={dts:F,pts:F,cts:0,unit:B,size:B.byteLength,duration:V,originalDts:M,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};O.push(j),y+=j.size}this._audioNextDts=P+c}else T=Math.floor(P),I=Math.floor(P+c)-T,this._audioNextDts=P+c}else T=M-l,I=C!==d.length-1?d[C+1].dts-this._dtsBase-l-T:null!=v?v.dts-this._dtsBase-l-T:R.length>=1?R[R.length-1].duration:Math.floor(c),this._audioNextDts=T+I;-1===u&&(u=T),R.push({dts:T,pts:T,cts:0,unit:b.unit,size:b.unit.byteLength,duration:I,originalDts:M,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),D&&R.push.apply(R,O)}}if(0===R.length)return _.samples=[],void(_.length=0);for(h?g=new Uint8Array(y):((g=new Uint8Array(y))[0]=y>>>24&255,g[1]=y>>>16&255,g[2]=y>>>8&255,g[3]=255&y,g.set(r.default.types.mdat,4)),C=0;C<R.length;C++)x=R[C].unit,g.set(x,m),m+=x.byteLength;var G=R[R.length-1];i=G.dts+G.duration;var H=new o.MediaSegmentInfo;H.beginDts=u,H.endDts=i,H.beginPts=u,H.endPts=i,H.originalBeginDts=R[0].originalDts,H.originalEndDts=G.originalDts+G.duration,H.firstSample=new o.SampleInfo(R[0].dts,R[0].pts,R[0].duration,R[0].originalDts,!1),H.lastSample=new o.SampleInfo(G.dts,G.pts,G.duration,G.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(H),_.samples=R,_.sequenceNumber++;var z=null;z=h?new Uint8Array:r.default.moof(_,u),_.samples=[],_.length=0;var W={type:"audio",data:this._mergeBoxes(z,g).buffer,sampleCount:R.length,info:H};h&&f&&(W.timestampOffset=u),this._onMediaSegment("audio",W)}}},e.prototype._remuxVideo=function(e,t){if(null!=this._videoMeta){var i,a,n=e,s=n.samples,_=void 0,d=-1,l=-1;if(s&&0!==s.length&&(1!==s.length||t)){var u=8,c=null,h=8+e.length,f=null;if(s.length>1&&(h-=(f=s.pop()).length),null!=this._videoStashedLastSample){var p=this._videoStashedLastSample;this._videoStashedLastSample=null,s.unshift(p),h+=p.length}null!=f&&(this._videoStashedLastSample=f);var m=s[0].dts-this._dtsBase;if(this._videoNextDts)_=m-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())_=0;else{var g=this._videoSegmentInfoList.getLastSampleBefore(m);if(null!=g){var y=m-(g.originalDts+g.duration);y<=3&&(y=0),_=m-(g.dts+g.duration+y)}else _=0}for(var v=new o.MediaSegmentInfo,b=[],E=0;E<s.length;E++){var S=(p=s[E]).dts-this._dtsBase,A=p.isKeyframe,w=S-_,k=p.cts,T=w+k;-1===d&&(d=w,l=T);var L=0;if(L=E!==s.length-1?s[E+1].dts-this._dtsBase-_-w:null!=f?f.dts-this._dtsBase-_-w:b.length>=1?b[b.length-1].duration:Math.floor(this._videoMeta.refSampleDuration),A){var R=new o.SampleInfo(w,T,L,p.dts,!0);R.fileposition=p.fileposition,v.appendSyncPoint(R)}b.push({dts:w,pts:T,cts:k,units:p.units,size:p.length,isKeyframe:A,duration:L,originalDts:S,flags:{isLeading:0,dependsOn:A?2:1,isDependedOn:A?1:0,hasRedundancy:0,isNonSync:A?0:1}})}for((c=new Uint8Array(h))[0]=h>>>24&255,c[1]=h>>>16&255,c[2]=h>>>8&255,c[3]=255&h,c.set(r.default.types.mdat,4),E=0;E<b.length;E++)for(var C=b[E].units;C.length;){var x=C.shift().data;c.set(x,u),u+=x.byteLength}var M=b[b.length-1];if(i=M.dts+M.duration,a=M.pts+M.duration,this._videoNextDts=i,v.beginDts=d,v.endDts=i,v.beginPts=l,v.endPts=a,v.originalBeginDts=b[0].originalDts,v.originalEndDts=M.originalDts+M.duration,v.firstSample=new o.SampleInfo(b[0].dts,b[0].pts,b[0].duration,b[0].originalDts,b[0].isKeyframe),v.lastSample=new o.SampleInfo(M.dts,M.pts,M.duration,M.originalDts,M.isKeyframe),this._isLive||this._videoSegmentInfoList.append(v),n.samples=b,n.sequenceNumber++,this._forceFirstIDR){var D=b[0].flags;D.dependsOn=2,D.isNonSync=0}var O=r.default.moof(n,d);n.samples=[],n.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(O,c).buffer,sampleCount:b.length,info:v})}}},e.prototype._mergeBoxes=function(e,t){var i=new Uint8Array(e.byteLength+t.byteLength);return i.set(e,0),i.set(t,e.byteLength),i},e}();t.default=d},"./src/utils/browser.js":
|
|
/*!******************************!*\
|
|
!*** ./src/utils/browser.js ***!
|
|
\******************************/function(e,t,i){"use strict";i.r(t);var a={};!function(){var e=self.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(iemobile)[\/]([\w.]+)/.exec(e)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],i=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],r={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:i[0]||""},n={};if(r.browser){n[r.browser]=!0;var s=r.majorVersion.split(".");n.version={major:parseInt(r.majorVersion,10),string:r.version},s.length>1&&(n.version.minor=parseInt(s[1],10)),s.length>2&&(n.version.build=parseInt(s[2],10))}if(r.platform&&(n[r.platform]=!0),(n.chrome||n.opr||n.safari)&&(n.webkit=!0),n.rv||n.iemobile){n.rv&&delete n.rv;var o="msie";r.browser=o,n[o]=!0}if(n.edge){delete n.edge;var _="msedge";r.browser=_,n[_]=!0}if(n.opr){var d="opera";r.browser=d,n[d]=!0}if(n.safari&&n.android){var l="android";r.browser=l,n[l]=!0}for(var u in n.name=r.browser,n.platform=r.platform,a)a.hasOwnProperty(u)&&delete a[u];Object.assign(a,n)}(),t.default=a},"./src/utils/exception.js":
|
|
/*!********************************!*\
|
|
!*** ./src/utils/exception.js ***!
|
|
\********************************/function(e,t,i){"use strict";i.r(t),i.d(t,{RuntimeException:function(){return n},IllegalStateException:function(){return s},InvalidArgumentException:function(){return o},NotImplementedException:function(){return _}});var a,r=(a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},a(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),n=function(){function e(e){this._message=e}return Object.defineProperty(e.prototype,"name",{get:function(){return"RuntimeException"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"message",{get:function(){return this._message},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this.name+": "+this.message},e}(),s=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"IllegalStateException"},enumerable:!1,configurable:!0}),t}(n),o=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"InvalidArgumentException"},enumerable:!1,configurable:!0}),t}(n),_=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"NotImplementedException"},enumerable:!1,configurable:!0}),t}(n)},"./src/utils/logger.js":
|
|
/*!*****************************!*\
|
|
!*** ./src/utils/logger.js ***!
|
|
\*****************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! events */"./node_modules/events/events.js"),r=i.n(a),n=function(){function e(){}return e.e=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var a="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",a),e.ENABLE_ERROR&&(console.error?console.error(a):console.warn)},e.i=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var a="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","info",a),e.ENABLE_INFO&&console.info&&console.info(a)},e.w=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var a="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",a),e.ENABLE_WARN&&console.warn},e.d=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var a="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",a),e.ENABLE_DEBUG&&console.debug&&console.debug(a)},e.v=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var a="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",a),e.ENABLE_VERBOSE},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(r()),t.default=n},"./src/utils/logging-control.js":
|
|
/*!**************************************!*\
|
|
!*** ./src/utils/logging-control.js ***!
|
|
\**************************************/function(e,t,i){"use strict";i.r(t);var a=i(/*! events */"./node_modules/events/events.js"),r=i.n(a),n=i(/*! ./logger.js */"./src/utils/logger.js"),s=function(){function e(){}return Object.defineProperty(e,"forceGlobalTag",{get:function(){return n.default.FORCE_GLOBAL_TAG},set:function(t){n.default.FORCE_GLOBAL_TAG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"globalTag",{get:function(){return n.default.GLOBAL_TAG},set:function(t){n.default.GLOBAL_TAG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableAll",{get:function(){return n.default.ENABLE_VERBOSE&&n.default.ENABLE_DEBUG&&n.default.ENABLE_INFO&&n.default.ENABLE_WARN&&n.default.ENABLE_ERROR},set:function(t){n.default.ENABLE_VERBOSE=t,n.default.ENABLE_DEBUG=t,n.default.ENABLE_INFO=t,n.default.ENABLE_WARN=t,n.default.ENABLE_ERROR=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableDebug",{get:function(){return n.default.ENABLE_DEBUG},set:function(t){n.default.ENABLE_DEBUG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableVerbose",{get:function(){return n.default.ENABLE_VERBOSE},set:function(t){n.default.ENABLE_VERBOSE=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableInfo",{get:function(){return n.default.ENABLE_INFO},set:function(t){n.default.ENABLE_INFO=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableWarn",{get:function(){return n.default.ENABLE_WARN},set:function(t){n.default.ENABLE_WARN=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableError",{get:function(){return n.default.ENABLE_ERROR},set:function(t){n.default.ENABLE_ERROR=t,e._notifyChange()},enumerable:!1,configurable:!0}),e.getConfig=function(){return{globalTag:n.default.GLOBAL_TAG,forceGlobalTag:n.default.FORCE_GLOBAL_TAG,enableVerbose:n.default.ENABLE_VERBOSE,enableDebug:n.default.ENABLE_DEBUG,enableInfo:n.default.ENABLE_INFO,enableWarn:n.default.ENABLE_WARN,enableError:n.default.ENABLE_ERROR,enableCallback:n.default.ENABLE_CALLBACK}},e.applyConfig=function(e){n.default.GLOBAL_TAG=e.globalTag,n.default.FORCE_GLOBAL_TAG=e.forceGlobalTag,n.default.ENABLE_VERBOSE=e.enableVerbose,n.default.ENABLE_DEBUG=e.enableDebug,n.default.ENABLE_INFO=e.enableInfo,n.default.ENABLE_WARN=e.enableWarn,n.default.ENABLE_ERROR=e.enableError,n.default.ENABLE_CALLBACK=e.enableCallback},e._notifyChange=function(){var t=e.emitter;if(t.listenerCount("change")>0){var i=e.getConfig();t.emit("change",i)}},e.registerListener=function(t){e.emitter.addListener("change",t)},e.removeListener=function(t){e.emitter.removeListener("change",t)},e.addLogListener=function(t){n.default.emitter.addListener("log",t),n.default.emitter.listenerCount("log")>0&&(n.default.ENABLE_CALLBACK=!0,e._notifyChange())},e.removeLogListener=function(t){n.default.emitter.removeListener("log",t),0===n.default.emitter.listenerCount("log")&&(n.default.ENABLE_CALLBACK=!1,e._notifyChange())},e}();s.emitter=new(r()),t.default=s},"./src/utils/polyfill.js":
|
|
/*!*******************************!*\
|
|
!*** ./src/utils/polyfill.js ***!
|
|
\*******************************/function(e,t,i){"use strict";i.r(t);var a=function(){function e(){}return e.install=function(){Object.setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Object.assign=Object.assign||function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i<arguments.length;i++){var a=arguments[i];if(null!=a)for(var r in a)a.hasOwnProperty(r)&&(t[r]=a[r])}return t},"function"!=typeof self.Promise&&i(/*! es6-promise */"./node_modules/es6-promise/dist/es6-promise.js").polyfill()},e}();a.install(),t.default=a},"./src/utils/utf8-conv.js":
|
|
/*!********************************!*\
|
|
!*** ./src/utils/utf8-conv.js ***!
|
|
\********************************/function(e,t,i){"use strict";function a(e,t,i){var a=e;if(t+i<a.length){for(;i--;)if(128!=(192&a[++t]))return!1;return!0}return!1}i.r(t),t.default=function(e){for(var t=[],i=e,r=0,n=e.length;r<n;)if(i[r]<128)t.push(String.fromCharCode(i[r])),++r;else{if(i[r]<192);else if(i[r]<224){if(a(i,r,1)&&(s=(31&i[r])<<6|63&i[r+1])>=128){t.push(String.fromCharCode(65535&s)),r+=2;continue}}else if(i[r]<240){if(a(i,r,2)&&(s=(15&i[r])<<12|(63&i[r+1])<<6|63&i[r+2])>=2048&&55296!=(63488&s)){t.push(String.fromCharCode(65535&s)),r+=3;continue}}else if(i[r]<248){var s;if(a(i,r,3)&&(s=(7&i[r])<<18|(63&i[r+1])<<12|(63&i[r+2])<<6|63&i[r+3])>65536&&s<1114112){s-=65536,t.push(String.fromCharCode(s>>>10|55296)),t.push(String.fromCharCode(1023&s|56320)),r+=4;continue}}t.push(String.fromCharCode(65533)),++r}return t.join("")}}},i={};function a(e){var r=i[e];if(void 0!==r)return r.exports;var n=i[e]={exports:{}};return t[e].call(n.exports,n,n.exports,a),n.exports}return a.m=t,a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,{a:t}),t},a.d=function(e,t){for(var i in t)a.o(t,i)&&!a.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a("./src/index.js")}()},"object"==typeof i&&"object"==typeof t?t.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof i?i.flvjshevc=r():a.flvjshevc=r()}).call(this)}).call(this,e("_process"))},{_process:1}],7:[function(e,t,i){const a=e("../consts");i.Mp4Player=class{constructor(e){this.configFormat={width:e.width||a.DEFAULT_WIDTH,height:e.height||a.DEFAULT_HEIGHT,fps:e.fps||a.DEFAULT_FPS,fixed:e.fixed||a.DEFAULT_FIXED,sampleRate:e.sampleRate||a.DEFAULT_SAMPLERATE,appendHevcType:e.appendHevcType||a.APPEND_TYPE_STREAM,frameDurMs:e.frameDur||a.DEFAULT_FRAME_DUR,playerId:e.playerId||a.DEFAILT_WEBGL_PLAY_ID,audioNone:e.audioNone||!1,token:e.token||null,videoCodec:e.videoCodec||a.CODEC_H265,autoPlay:e.autoPlay||!1},this.videoTag=null,this.isPlaying=!1,this.duration=-1,this.seekTarget=-1,this.bufferInterval=null,this._resumeAudioClickHandler=null,this.onLoadFinish=null,this.onPlayingTime=null,this.onPlayingFinish=null,this.onPlayState=null,this.onCacheProcess=null,this.onSeekStart=null,this.onSeekFinish=null}makeIt(e){let t=this,i=document.querySelector("div#"+this.configFormat.playerId);this.videoTag=document.createElement("video"),!0===this.configFormat.autoPlay&&(this.videoTag.muted="muted",this.videoTag.autoplay="autoplay",this._detachResumeAudioClickHandler(),this._resumeAudioClickHandler=function(){t.videoTag&&(t.videoTag.muted=!1,t.isPlayingState(),t._detachResumeAudioClickHandler())},window.addEventListener("click",this._resumeAudioClickHandler,{once:!0})),this.videoTag.addEventListener("seeking",(()=>{t.onSeekStart&&t.onSeekStart(t.seekTarget)})),this.videoTag.addEventListener("seeked",(()=>{t.videoTag.currentTime,t.onSeekFinish&&t.onSeekFinish(t.videoTag.currentTime)})),this.videoTag.onplay=function(){const e=t.isPlayingState();t.onPlayState&&t.onPlayState(e)},this.videoTag.onpause=function(){const e=t.isPlayingState();t.onPlayState&&t.onPlayState(e)},this.videoTag.ontimeupdate=()=>{t.onPlayingTime&&t.onPlayingTime(t.videoTag.currentTime)},this.videoTag.onended=()=>{t.onPlayingFinish&&t.onPlayingFinish()},this.videoTag.onloadedmetadata=e=>{t.duration=t.videoTag.duration,t.onLoadFinish&&t.onLoadFinish(),null!==t.bufferInterval&&(window.clearInterval(t.bufferInterval),t.bufferInterval=null),t.bufferInterval=window.setInterval((function(){const e=t.videoTag.buffered.end(0);if(e>=t.duration-.04)return t.onCacheProcess&&t.onCacheProcess(t.duration),void window.clearInterval(t.bufferInterval);t.onCacheProcess&&t.onCacheProcess(e)}),200)},this.videoTag.src=e,this.videoTag.style.width="100%",this.videoTag.style.height="100%",i.appendChild(this.videoTag)}setPlaybackRate(e=1){return!(e<=0||null==this.videoTag||null===this.videoTag)&&(this.videoTag.playbackRate=e,!0)}getPlaybackRate(){return null==this.videoTag||null===this.videoTag?0:this.videoTag.playbackRate}getSize(){return{width:this.videoTag.videoWidth>0?this.videoTag.videoWidth:this.configFormat.width,height:this.videoTag.videoHeight>0?this.videoTag.videoHeight:this.configFormat.height}}play(){this.videoTag.play()}seek(e){this.seekTarget=e,this.videoTag.currentTime=e}pause(){this.videoTag.pause()}setVoice(e){this.videoTag.volume=e}isPlayingState(){return this.videoTag&&!this.videoTag.paused}_detachResumeAudioClickHandler(){this._resumeAudioClickHandler&&(window.removeEventListener("click",this._resumeAudioClickHandler),this._resumeAudioClickHandler=null)}release(){this._detachResumeAudioClickHandler(),this.videoTag&&this.videoTag.remove(),this.videoTag=null,this.onLoadFinish=null,this.onPlayingTime=null,this.onPlayingFinish=null,this.onPlayState=null,this.onSeekStart=null,this.onSeekFinish=null,null!==this.bufferInterval&&(window.clearInterval(this.bufferInterval),this.bufferInterval=null)}nativeNextFrame(){void 0!==this.videoTag&&null!==this.videoTag&&(this.videoTag.currentTime+=1/this.configFormat.fps)}}},{"../consts":5}],8:[function(e,t,i){const a=e("../consts"),r=e("./flv-hevc/flv-hevc.js"),n=e("../av-common");i.NvFlvjsCore=class{constructor(e){this.configFormat={width:e.width||a.DEFAULT_WIDTH,height:e.height||a.DEFAULT_HEIGHT,playerId:e.playerId||a.DEFAILT_WEBGL_PLAY_ID,ignoreAudio:e.ignoreAudio,duration:e.duration,autoPlay:e.autoPlay||!1,audioNone:e.audioNone},this.audioVoice=1,this.myPlayerID=this.configFormat.playerId+"-flv-hevc",this.myPlayer=null,this.videoContaner=null,this.videoTag=null,this.duration=-1,this.width=-1,this.height=-1,this.isPlaying=!1,this.vCodecID=a.V_CODEC_NAME_AVC,this.audioNone=!1,this.showScreen=!1,this.playPTS=0,this.vCachePTS=0,this.aCachePTS=0,this.isInitDecodeFrames=!1,this.lastDecodedFrame=0,this.lastDecodedFrameTime=-1,this.checkStartIntervalCount=0,this.checkStartInterval=null,this.checkPicBlockInterval=null,this.bufferInterval=null,this._resumeAudioClickHandler=null,this.onPlayState=null,this.onLoadFinish=null,this.onPlayingTime=null,this.onPlayingFinish=null,this.onSeekStart=null,this.onSeekFinish=null,this.onReadyShowDone=null,this.onCacheProcess=null}_reBuildFlvjs(e){this._releaseFlvjs(),this.makeIt(e)}_checkPicBlock(e){let t=this;this.checkPicBlockInterval=window.setInterval((function(){if(t.lastDecodedFrameTime>0&&n.GetMsTime()-t.lastDecodedFrameTime>1e4)return window.clearInterval(t.checkPicBlockInterval),t.checkPicBlockInterval=null,void t._reBuildFlvjs(e)}),1e3)}_checkLoadState(e){let t=this;this.checkStartIntervalCount=0,this.checkStartInterval=window.setInterval((function(){return t.lastDecodedFrame,t.isInitDecodeFrames,t.checkStartIntervalCount,!1!==t.isInitDecodeFrames?(t.checkStartIntervalCount=0,window.clearInterval(t.checkStartInterval),void(t.checkStartInterval=null)):(t.checkStartIntervalCount+=1,t.checkStartIntervalCount>20?(window.clearInterval(t.checkStartInterval),t.checkStartIntervalCount=0,t.checkStartInterval=null,void(!1===t.isInitDecodeFrames&&t._reBuildFlvjs(e))):void 0)}),500)}makeIt(e){let t=this;if(r.isSupported()){let i=document.querySelector("#"+this.configFormat.playerId);this.videoTag=document.createElement("video"),this.videoTag.id=this.myPlayerID,this.videoTag.style.width=this.configFormat.width+"px",this.videoTag.style.height=this.configFormat.height+"px",i.appendChild(this.videoTag),!0===this.configFormat.autoPlay&&(this.videoTag.muted="muted",this.videoTag.autoplay="autoplay",this._detachResumeAudioClickHandler(),this._resumeAudioClickHandler=function(){t.videoTag&&(t.videoTag.muted=!1,t.isPlayingState(),t._detachResumeAudioClickHandler())},window.addEventListener("click",this._resumeAudioClickHandler,{once:!0})),this.videoTag.onplay=function(){const e=t.isPlayingState();t.onPlayState&&t.onPlayState(e)},this.videoTag.onpause=function(){const e=t.isPlayingState();t.onPlayState&&t.onPlayState(e)},this.videoTag.addEventListener("seeking",(()=>{t.onSeekStart&&t.onSeekStart(t.seekTarget)})),this.videoTag.addEventListener("seeked",(()=>{t.videoTag.currentTime,t.onSeekFinish&&t.onSeekFinish(t.videoTag.currentTime)}));let a={hasVideo:!0,hasAudio:!(!0===this.configFormat.audioNone),type:"flv",url:e,isLive:this.configFormat.duration<=0,withCredentials:!1};this.myPlayer=r.createPlayer(a),this.myPlayer.attachMediaElement(this.videoTag),this.myPlayer.on(r.Events.MEDIA_INFO,(function(e){t.videoTag.videoWidth,!1===t.isInitDecodeFrames&&(t.isInitDecodeFrames=!0,t.width=Math.max(t.videoTag.videoWidth,e.width),t.height=Math.max(t.videoTag.videoHeight,e.height),t.duration=t.videoTag.duration,t.duration,t.onLoadFinish&&t.onLoadFinish(),t.onReadyShowDone&&t.onReadyShowDone(),t._loopBufferState(),t.isPlayingState(),t.videoTag.ontimeupdate=()=>{t.onPlayingTime&&t.onPlayingTime(t.videoTag.currentTime)},t.duration!==1/0&&t.duration>0&&(t.videoTag.onended=()=>{t.onPlayingFinish&&t.onPlayingFinish()}))})),this.myPlayer.on(r.Events.STATISTICS_INFO,(function(e){t.videoTag.videoWidth,t.videoTag.videoHeight,t.videoTag.duration,!1===t.isInitDecodeFrames&&t.videoTag.videoWidth>0&&t.videoTag.videoHeight>0&&(t.isInitDecodeFrames=!0,t.width=t.videoTag.videoWidth,t.height=t.videoTag.videoHeight,t.duration=t.videoTag.duration,t.duration,t.onLoadFinish&&t.onLoadFinish(),t.onReadyShowDone&&t.onReadyShowDone(),t._loopBufferState(),t.isPlayingState(),t.videoTag.ontimeupdate=()=>{t.onPlayingTime&&t.onPlayingTime(t.videoTag.currentTime)},t.duration!==1/0&&(t.videoTag.onended=()=>{t.onPlayingFinish&&t.onPlayingFinish()})),t.lastDecodedFrame=e.decodedFrames,t.lastDecodedFrameTime=n.GetMsTime()})),this.myPlayer.on(r.Events.SCRIPTDATA_ARRIVED,(function(e){})),this.myPlayer.on(r.Events.METADATA_ARRIVED,(function(e){!1===t.isInitDecodeFrames&&e.width&&e.width>0&&(t.isInitDecodeFrames=!0,t.duration=e.duration,t.width=e.width,t.height=e.height,t.duration,t.onLoadFinish&&t.onLoadFinish(),t.onReadyShowDone&&t.onReadyShowDone(),t._loopBufferState(),t.isPlayingState(),t.videoTag.ontimeupdate=()=>{t.onPlayingTime&&t.onPlayingTime(t.videoTag.currentTime)},t.duration!==1/0&&(t.videoTag.onended=()=>{t.onPlayingFinish&&t.onPlayingFinish()}))})),this.myPlayer.on(r.Events.ERROR,(function(i,a,r){t.myPlayer&&t._reBuildFlvjs(e)})),this.myPlayer.load(),this._checkLoadState(e),this._checkPicBlock(e)}else console.error("FLV is AVC/H.264, But your brower do not support mse!")}setPlaybackRate(e=1){return!(e<=0||null==this.videoTag||null===this.videoTag)&&(this.videoTag.playbackRate=e,!0)}getPlaybackRate(){return null==this.videoTag||null===this.videoTag?0:this.videoTag.playbackRate}getSize(){return{width:this.videoTag.videoWidth>0?this.videoTag.videoWidth:this.width,height:this.videoTag.videoHeight>0?this.videoTag.videoHeight:this.height}}play(){this.myPlayer.play()}seek(e){this.myPlayer.test1(),e<=0?this.myPlayer.seekStart():this.myPlayer.currentTime=e}pause(){this.myPlayer.pause()}setVoice(e){this.myPlayer.volume=e}isPlayingState(){return!this.videoTag.paused}_detachResumeAudioClickHandler(){this._resumeAudioClickHandler&&(window.removeEventListener("click",this._resumeAudioClickHandler),this._resumeAudioClickHandler=null)}_loopBufferState(){let e=this;e.duration<=0&&(e.duration=e.videoTag.duration),null!==e.bufferInterval&&(window.clearInterval(e.bufferInterval),e.bufferInterval=null),e.bufferInterval=window.setInterval((function(){if(!e.duration||e.duration<0)return void window.clearInterval(e.bufferInterval);const t=e.videoTag.buffered.end(0);if(t>=e.duration-.04)return e.onCacheProcess&&e.onCacheProcess(e.duration),void window.clearInterval(e.bufferInterval);e.onCacheProcess&&e.onCacheProcess(t)}),200)}_releaseFlvjs(){this.myPlayer,this.myPlayer.pause(),this.myPlayer.unload(),this.myPlayer.detachMediaElement(),this.myPlayer.destroy(),this.myPlayer=null,this.videoTag.remove(),this.videoTag=null,null!==this.checkStartInterval&&(this.checkStartIntervalCount=0,window.clearInterval(this.checkStartInterval),this.checkStartInterval=null),null!==this.checkPicBlockInterval&&(window.clearInterval(this.checkPicBlockInterval),this.checkPicBlockInterval=null),this.isInitDecodeFrames=!1,this.lastDecodedFrame=0,this.lastDecodedFrameTime=-1}release(){this._detachResumeAudioClickHandler(),null!==this.checkStartInterval&&(this.checkStartIntervalCount=0,window.clearInterval(this.checkStartInterval),this.checkStartInterval=null),null!==this.checkPicBlockInterval&&(window.clearInterval(this.checkPicBlockInterval),this.checkPicBlockInterval=null),null!==this.bufferInterval&&(window.clearInterval(this.bufferInterval),this.bufferInterval=null),this._releaseFlvjs(),this.myPlayerID=null,this.videoContaner=null,this.onLoadFinish=null,this.onPlayingTime=null,this.onPlayingFinish=null,this.onSeekStart=null,this.onSeekFinish=null,this.onReadyShowDone=null,this.onPlayState=null}}},{"../av-common":4,"../consts":5,"./flv-hevc/flv-hevc.js":6}],9:[function(e,t,i){const a=e("../consts"),r=e("mpegts.js"),n=e("../av-common");i.NvMpegTsCore=class{constructor(e){this.configFormat={width:e.width||a.DEFAULT_WIDTH,height:e.height||a.DEFAULT_HEIGHT,playerId:e.playerId||a.DEFAILT_WEBGL_PLAY_ID,ignoreAudio:e.ignoreAudio,duration:e.duration,autoPlay:e.autoPlay||!1,audioNone:e.audioNone},this.audioVoice=1,this.myPlayerID=this.configFormat.playerId+"-jsmpegts",this.myPlayer=null,this.videoContaner=null,this.videoTag=null,this.duration=-1,this.width=-1,this.height=-1,this.isPlaying=!1,this.vCodecID=a.V_CODEC_NAME_AVC,this.audioNone=!1,this.showScreen=!1,this.playPTS=0,this.vCachePTS=0,this.aCachePTS=0,this.seekTarget=-1,this.isInitDecodeFrames=!1,this.lastDecodedFrame=0,this.lastDecodedFrameTime=-1,this.checkStartIntervalCount=0,this.checkStartInterval=null,this.checkPicBlockInterval=null,this.bufferInterval=null,this._resumeAudioClickHandler=null,this.onPlayState=null,this.onLoadFinish=null,this.onPlayingTime=null,this.onPlayingFinish=null,this.onSeekStart=null,this.onSeekFinish=null,this.onReadyShowDone=null,this.onCacheProcess=null}_reBuildMpegTsjs(e){this._releaseMpegTsjs(),this.makeIt(e)}_checkPicBlock(e){let t=this;this.checkPicBlockInterval=window.setInterval((function(){if(t.lastDecodedFrameTime>0&&n.GetMsTime()-t.lastDecodedFrameTime>1e4)return window.clearInterval(t.checkPicBlockInterval),t.checkPicBlockInterval=null,void t._reBuildMpegTsjs(e)}),1e3)}_checkLoadState(e){let t=this;this.checkStartIntervalCount=0,this.checkStartInterval=window.setInterval((function(){return t.lastDecodedFrame,t.isInitDecodeFrames,t.checkStartIntervalCount,!1!==t.isInitDecodeFrames?(t.checkStartIntervalCount=0,window.clearInterval(t.checkStartInterval),void(t.checkStartInterval=null)):(t.checkStartIntervalCount+=1,t.checkStartIntervalCount>20?(window.clearInterval(t.checkStartInterval),t.checkStartIntervalCount=0,t.checkStartInterval=null,void(!1===t.isInitDecodeFrames&&t._reBuildMpegTsjs(e))):void 0)}),500)}makeIt(e){let t=this;if(r.isSupported()){let i=document.querySelector("#"+this.configFormat.playerId);this.videoTag=document.createElement("video"),this.videoTag.id=this.myPlayerID,this.videoTag.style.width=this.configFormat.width+"px",this.videoTag.style.height=this.configFormat.height+"px",i.appendChild(this.videoTag),!0===this.configFormat.autoPlay&&(this.videoTag.muted="muted",this.videoTag.autoplay="autoplay",this._detachResumeAudioClickHandler(),this._resumeAudioClickHandler=function(){t.videoTag&&(t.videoTag.muted=!1,t.isPlayingState(),t._detachResumeAudioClickHandler())},window.addEventListener("click",this._resumeAudioClickHandler,{once:!0})),this.videoTag.onplay=function(){const e=t.isPlayingState();t.onPlayState&&t.onPlayState(e)},this.videoTag.onpause=function(){const e=t.isPlayingState();t.onPlayState&&t.onPlayState(e)},this.videoTag.addEventListener("seeking",(()=>{t.onSeekStart&&t.onSeekStart(t.seekTarget)})),this.videoTag.addEventListener("seeked",(()=>{t.videoTag.currentTime,t.onSeekFinish&&t.onSeekFinish(t.videoTag.currentTime)}));let a={hasVideo:!0,hasAudio:!(!0===this.configFormat.audioNone),type:"mse",url:e,isLive:this.configFormat.duration<=0,withCredentials:!1};this.myPlayer=r.createPlayer(a),this.myPlayer.attachMediaElement(this.videoTag),this.myPlayer.on(r.Events.MEDIA_INFO,(function(e){t.videoTag.videoWidth,!1===t.isInitDecodeFrames&&(t.isInitDecodeFrames=!0,t.width=Math.max(t.videoTag.videoWidth,e.width),t.height=Math.max(t.videoTag.videoHeight,e.height),t.videoTag.duration&&e.duration?t.videoTag.duration?t.duration=t.videoTag.duration:e.duration&&(t.duration=e.duration):t.duration=t.configFormat.duration/1e3,t.onLoadFinish&&t.onLoadFinish(),t.onReadyShowDone&&t.onReadyShowDone(),t._loopBufferState(),t.isPlayingState(),t.videoTag.ontimeupdate=()=>{t.onPlayingTime&&t.onPlayingTime(t.videoTag.currentTime)},t.duration!==1/0&&t.duration>0&&(t.videoTag.onended=()=>{t.onPlayingFinish&&t.onPlayingFinish()}))})),this.myPlayer.on(r.Events.SCRIPTDATA_ARRIVED,(function(e){})),this.myPlayer.on(r.Events.ERROR,(function(i,a,r){t.myPlayer&&t._reBuildMpegTsjs(e)})),this.myPlayer.load(),this._checkLoadState(e),this._checkPicBlock(e)}else console.error("MPEGTS is AVC/H.264, but current browser does not support mpegts.js MSE playback!")}setPlaybackRate(e=1){return!(e<=0||null==this.videoTag||null===this.videoTag)&&(this.videoTag.playbackRate=e,!0)}getPlaybackRate(){return null==this.videoTag||null===this.videoTag?0:this.videoTag.playbackRate}getSize(){return{width:this.videoTag.videoWidth>0?this.videoTag.videoWidth:this.width,height:this.videoTag.videoHeight>0?this.videoTag.videoHeight:this.height}}play(){this.videoTag,this.videoTag.play()}seek(e){this.seekTarget=e,this.videoTag.currentTime=e}pause(){this.videoTag.pause()}setVoice(e){this.videoTag.volume=e}isPlayingState(){return!this.videoTag.paused}_detachResumeAudioClickHandler(){this._resumeAudioClickHandler&&(window.removeEventListener("click",this._resumeAudioClickHandler),this._resumeAudioClickHandler=null)}_loopBufferState(){let e=this;e.duration<=0&&e.videoTag.duration&&(e.duration=e.videoTag.duration),null!==e.bufferInterval&&(window.clearInterval(e.bufferInterval),e.bufferInterval=null),e.bufferInterval=window.setInterval((function(){if(e.configFormat.duration<=0)return void window.clearInterval(e.bufferInterval);const t=e.videoTag.buffered.end(0);if(t>=e.duration-.04)return e.onCacheProcess&&e.onCacheProcess(e.duration),void window.clearInterval(e.bufferInterval);e.onCacheProcess&&e.onCacheProcess(t)}),200)}_releaseMpegTsjs(){this.myPlayer,null!==this.bufferInterval&&(window.clearInterval(this.bufferInterval),this.bufferInterval=null),this.myPlayer&&(this.myPlayer.pause(),this.myPlayer.unload(),this.myPlayer.detachMediaElement(),this.myPlayer.destroy()),this.myPlayer=null,this.videoTag&&this.videoTag.remove(),this.videoTag=null,null!==this.checkStartInterval&&(this.checkStartIntervalCount=0,window.clearInterval(this.checkStartInterval),this.checkStartInterval=null),null!==this.checkPicBlockInterval&&(window.clearInterval(this.checkPicBlockInterval),this.checkPicBlockInterval=null),this.isInitDecodeFrames=!1,this.lastDecodedFrame=0,this.lastDecodedFrameTime=-1,this.seekTarget=-1}release(){this._detachResumeAudioClickHandler(),null!==this.checkStartInterval&&(this.checkStartIntervalCount=0,window.clearInterval(this.checkStartInterval),this.checkStartInterval=null),null!==this.checkPicBlockInterval&&(window.clearInterval(this.checkPicBlockInterval),this.checkPicBlockInterval=null),null!==this.bufferInterval&&(window.clearInterval(this.bufferInterval),this.bufferInterval=null),this._releaseMpegTsjs(),this.myPlayerID=null,this.videoContaner=null,this.onLoadFinish=null,this.onPlayingTime=null,this.onPlayingFinish=null,this.onSeekStart=null,this.onSeekFinish=null,this.onReadyShowDone=null,this.onPlayState=null,this.onCacheProcess=null}}},{"../av-common":4,"../consts":5,"mpegts.js":16}],10:[function(e,t,i){e("../consts"),e("../av-common");t.exports=class{constructor(e){this._wasm_main_thread_exports=e,this._width=0,this._height=0,this._win_w=0,this._win_h=0,this._canvas_id="",this._play_state=!1,this.av_align_doing_status=!1,this.av_align_doing_info={slow_down_count:-1,adjusted_duration:-1},this.av_align_audio_time_ms=-1,this.av_align_audio_duration_ms=-1,this.av_playback_rate=1,this.av_ignore_audio=!1,this._render_play_interval=null,this._align_av_interval=null,this.event_data_callback=null}init(e,t,i,a,r){if(this._wasm_main_thread_exports.ccall("init_cylopengl_ctx","number",[]),this._width=e,this._height=t,this._canvas_id=r,this._win_w=i,this._win_h=a,this._wasm_main_thread_exports){const n=this._wasm_main_thread_exports.ccall("cylopengl_create_context","number",["number","number","number","number","string"],[this._width,this._height,i,a,r]);if(0!=n)return console.error("cylopengl_create_context failed"),-1;return this._wasm_main_thread_exports.ccall("cylopengl_create_shader_algorithm","number",["number","number","number","number"],[e,t,0,0])<0?(console.error("cylopengl_create_shader_algorithm failed"),-1):n}return-1}append_yuv420p_texture(e,t,i,a,r,n,s,o,_){let d=-1;if(a>0&&r>0&&(this._width=a,this._height=r),this._wasm_main_thread_exports){const l=this._wasm_main_thread_exports._malloc(e.byteLength);this._wasm_main_thread_exports.HEAPU8.set(e,l);const u=this._wasm_main_thread_exports._malloc(t.byteLength);this._wasm_main_thread_exports.HEAPU8.set(t,u);const c=this._wasm_main_thread_exports._malloc(i.byteLength);this._wasm_main_thread_exports.HEAPU8.set(i,c),d=this._wasm_main_thread_exports.ccall("cylopengl_append_cache_yuv420p","number",["number","number","number","number","number","number","number","number","number"],[l,u,c,a,r,n,s,o,_]),this._wasm_main_thread_exports._free(l),this._wasm_main_thread_exports._free(u),this._wasm_main_thread_exports._free(c)}return d}get_yuv420p_cache_length(){return this._wasm_main_thread_exports?this._wasm_main_thread_exports.ccall("cylopengl_get_cache_yuv_length","number",[]):-1}clean_cache_queue(){return this._wasm_main_thread_exports?this._wasm_main_thread_exports.ccall("cylopengl_clean_cache_queue","number",[]):-1}change_viewport(e,t){return this._wasm_main_thread_exports?e>0&&t>0?(this._width=e,this._height=t,this._win_w=e,this._win_h=t,this._wasm_main_thread_exports.ccall("cylopengl_change_viewport","number",["number","number"],[e,t])):-2:-1}check_with_audio_pts_ms(e,t){let i=this;return e<0?-2:(this._align_av_interval&&(clearInterval(this._align_av_interval),this._align_av_interval=null),this._wasm_main_thread_exports&&(this._align_av_interval&&(clearInterval(this._align_av_interval),this._align_av_interval=null),this._align_av_interval=setInterval((()=>{let a=i._wasm_main_thread_exports.ccall("cylopengl_first_cache_pts_ms","number",[],[]);if(a<0)return console.error("cylopengl check_with_audio_pts_ms INTERVAL cylopengl_first_cache_pts_ms failed"),clearInterval(i._align_av_interval),i._align_av_interval=null,-3;if(e>a){const e=i._wasm_main_thread_exports.ccall("cylopengl_pop_cache_yuv420p","number",[]);if(e<0)return console.error("cylopengl check_with_audio_pts_ms INTERVAL cylopengl_pop_cache_yuv420p failed"),clearInterval(i._align_av_interval),i._align_av_interval=null,-4;i.event_data_callback&&i.event_data_callback({type:"set_cache_size",payload:{cache_size:e}})}else clearInterval(i._align_av_interval),i._align_av_interval=null,t&&t()}),5)),-1)}render_yuv420p_texture(){let e=this;if(this._wasm_main_thread_exports){const t=this._wasm_main_thread_exports.ccall("cylopengl_render_cache_yuv420p","number",[]);return this.event_data_callback&&this.event_data_callback({type:"render_progress",payload:{pts:t,width:this._width,height:this._height,cache_size:e.get_yuv420p_cache_length()}}),t}return console.error("render_yuv420p_texture _wasm_main_thread_exports is null"),-1}audio_play_info(e,t){this._wasm_main_thread_exports&&(this.av_align_audio_time_ms=e,this.av_align_audio_duration_ms=t)}set_playback_rate(e=1){this.av_playback_rate=e||1}render_play(e,t,i=!1){let a=this;this.av_ignore_audio=i||!1,this._render_play_interval&&(cancelAnimationFrame(this._render_play_interval),this._render_play_interval=null);let r=t;r=t/this.av_playback_rate;let n=performance.now()+r;if(this._play_state=!0,this.av_ignore_audio){const e=()=>{if(this._play_state){if(performance.now()>=n){const e=a.render_yuv420p_texture();e>=0&&(a._wasm_main_thread_exports.av_align_video_play_ms=e),n+=r}r=t/a.av_playback_rate,a._render_play_interval=requestAnimationFrame(e)}};a._render_play_interval=requestAnimationFrame(e)}else{const e=()=>{if(this._play_state){if(performance.now()>=n){const e=a.render_yuv420p_texture();if(e>=0&&(a._wasm_main_thread_exports.av_align_video_play_ms=e),n+=r,!a.av_align_doing_status&&a.av_align_audio_time_ms>0&&a.av_align_audio_duration_ms>0&&a._wasm_main_thread_exports.av_align_video_play_ms>0){a.av_align_doing_status=!0;const t=a.av_align_audio_time_ms-e,i=Math.abs(t);if(i>(a.av_align_audio_duration_ms||15*r)){if(a.av_align_doing_info.slow_down_count=Math.ceil(i/r),a.av_align_doing_info.adjusted_duration=Math.min(1.2*r,r+7)-r,t<0){if(console.error("gl render audio is Slower than video, slow_down_count:",a.av_align_doing_info.slow_down_count,"adjusted_duration:",a.av_align_doing_info.adjusted_duration),i>1e3)return void(a.event_data_callback&&this.event_data_callback({type:"av_align_audio_slower_too_much",payload:i}))}else if(a.av_align_doing_info.adjusted_duration=-1*a.av_align_doing_info.adjusted_duration,console.error("gl render audio is Faster than video, slow_down_count:",a.av_align_doing_info.slow_down_count,"adjusted_duration:",a.av_align_doing_info.adjusted_duration),i>1e3)return void(a.event_data_callback&&this.event_data_callback({type:"av_align_audio_faster_too_much",payload:i}));n+=a.av_align_doing_info.adjusted_duration,a.av_align_doing_info.slow_down_count--}}else n+=a.av_align_doing_info.adjusted_duration,a.av_align_doing_info.slow_down_count--,a.av_align_doing_info.slow_down_count<=0&&(a.av_align_doing_status=!1,a.av_align_doing_info.slow_down_count=-1,a.av_align_doing_info.adjusted_duration=-1)}r=t/a.av_playback_rate,a._render_play_interval=requestAnimationFrame(e)}};a._render_play_interval=requestAnimationFrame(e)}}is_playing(){return!!this._render_play_interval}render_pause(){this._play_state=!1,this._render_play_interval&&(cancelAnimationFrame(this._render_play_interval),this._render_play_interval=null),this._align_av_interval&&(clearInterval(this._align_av_interval),this._align_av_interval=null)}release(){return render_pause(),this.event_data_callback=null,this._wasm_main_thread_exports&&this._wasm_main_thread_exports.ccall("cylopengl_release_renderer_source","number",[]),0}}},{"../av-common":4,"../consts":5}],11:[function(e,t,i){function a(){const e=[{code:"1",name:"Main"},{code:"2",name:"Main 10"},{code:"3",name:"Main Still Picture"}],t=["B","A"],i=["93","120","123","150","153","156"],a=[];for(const r of e)for(const e of t)for(const t of i)a.push(`hvc1.${r.code}.${t}.${e}0`),a.push(`hev1.${r.code}.${t}.${e}0`),a.push(`hvc1.${r.code}.${t}.${e}`),a.push(`hev1.${r.code}.${t}.${e}`);a.push("hvc1.1.6.L93.B0"),a.push("hev1.1.6.L93.B0");const r={supported:!1,supportedCodecs:[],unsupportedCodecs:[]};return a.forEach((e=>{const t=`video/mp4;codecs="${e}"`;MediaSource.isTypeSupported(t)?(r.supported=!0,r.supportedCodecs.push(e)):r.unsupportedCodecs.push(e)})),r.supportedCodecs,r.unsupportedCodecs,console.groupEnd(),r.supported}function r(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0]));return!0}}catch(e){}return!1}async function n(e=""){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))return!1;const t=["hvc1.1.6.L93.B0","hev1.1.6.L93.B0","hvc1.1.6.L93.0","hev1.1.6.L93.0","hvc1.1.6.L93","hev1.1.6.L93","hvc1.1.6.L90","hev1.1.6.L90","hvc1.1.6.L90.0","hev1.1.6.L90.0","hvc1.1.6.L80","hev1.1.6.L80","hvc1.1.6.L80.0","hev1.1.6.L80.0","hvc1.1.6.L70","hev1.1.6.L70","hvc1.1.6.L70.0","hev1.1.6.L70.0","hvc1.1.6.L60","hev1.1.6.L60","hvc1.1.6.L60.0","hev1.1.6.L60.0","hvc1.1.6.L50","hev1.1.6.L50","hvc1.1.6.L50.0","hev1.1.6.L50.0","hvc1.1.6.L40","hev1.1.6.L40","hvc1.1.6.L40.0","hev1.1.6.L40.0","hvc1.1.6.L30","hev1.1.6.L30","hvc1.1.6.L30.0","hev1.1.6.L93"];return await async function(){for(const i of t)try{const t={codec:i,width:1280,height:720,description:e.buffer},a=await VideoDecoder.isConfigSupported(t);if(a.supported,a.supported)return!0}catch(e){}return!1}()}t.exports={testSupportMseHEVC:a,testWebCodecSupportHEVC:n,testWebAssemblySupport:r,testCheckAllSupport:async function(){const e={mse_hevc:null,wasm_hevc:null,webcodec_hevc:null};return e.mse_hevc=a(),e.wasm_hevc=r(),e.webcodec_hevc=await n(),e},CORE_TYPE_WEBCODEC_HEVC:"webcodec_hevc",CORE_TYPE_WASM_HEVC:"wasm_hevc",CORE_TYPE_MSE_HEVC:"mse_hevc",CORE_TYPE_MSE_MP4:"mse_mp4",CORE_TYPE_MSE_VIDEOJS:"mse_videojs",CORE_TYPE_MSE_FLVJS:"mse_flvjs",CORE_TYPE_MSE_MPEGTS:"mse_mpegts",CORE_TYPE_EXT_H265WEB:"ext_h265web",PLAYER_MODE_NOTIME_LIVE:"live",PLAYER_MODE_VOD:"vod"}},{}],12:[function(e,t,i){e("../consts");const a=e("../av-common");create_worker_decoder=function(){return new Worker(a.GetScriptPath((function(){let e=!1,t=[],i=null,a=null,r=null,n=!1,s={slow_down_count:-1,adjusted_duration:-1},o=-1,_=-1,d=100;let l=-1,u=1,c=!1,h=!1,f=0,p=0,m=-1,g=-1,y=null,v=null,b=-1,E=-1;function S(){n=!1,s.slow_down_count=-1,s.adjusted_duration=-1,o=-1,_=-1,v&&(clearInterval(v),v=null)}function A(){b=-1,E=-1}function w(e,r){if(!i||!a)return;Number(i.av_align_video_play_ms||-1),performance.now(),i.ccall("wcodec_get_frame_queue_length","number",["number"],[a]);t.length}function k(){l=-1,S(),A(),r&&(clearInterval(r),r=null),t.forEach((e=>{e.data=null})),t=[],t.length=0}function T(){r&&(clearInterval(r),r=null);let e=0;r=setInterval((()=>{if(!i)return void console.error("decode worker wasm is null");if(i.decoder_error_wait)return void console.error("decoder info:wasmCodecExports.decoder_error_wait");let r=i.ccall("wcodec_get_frame_queue_length","number",["number"],[a]);if(r<=0&&1!==e?(t.length,f>0&&Date.now(),e=1,self.postMessage({type:"on_load_cache"})):r>0&&2!==e&&(t.length,e=2,self.postMessage({type:"on_finish_cache",payload:{store_length:r}})),r>=d)return;const n=Math.max(4,Math.floor(25)),s=Date.now();if(t.length<n&&(!h||s-f>150)&&(p+=1,h=!0,f=s,t.length,self.postMessage({type:"request_demux",payload:{recv_v_count:100,recv_a_count:200}})),t.length<1)return;const o=t.shift();if(!o)return;const _=i._malloc(o.data.byteLength);i.HEAPU8.set(o.data,_),i.ccall("wcodec_feed_data","",["number","number","number","number","number"],[a,_,o.data.byteLength,BigInt(Math.floor(Number(1e3*o.pts))),o.isKey]),i._free(_)}),10)}async function L(e,t){if("undefined"==typeof WebAssembly)return self.postMessage({type:"error",payload:"当前浏览器不支持WebAssembly"}),!1;try{importScripts(e);const r=t;if(i=await new Promise((e=>{const t=WasmModule({locateFile:e=>r,onRuntimeInitialized:()=>{e(t)}})})),!i)return console.error("decoder info:WebAssembly module initialized wasmCodecExports: False"),!1;i._main(),Object.keys(i);i?(a=i.ccall("init_webcodec_ctx","number",[],[]),i.decoder_ctx_ptr=a):console.error("decoder info:initDecoder: wasmCodecExports is NULL");self.postMessage({type:"ready"})}catch(e){return console.error("decoder info:worker-decoder.js Failed to initialize WebAssembly:",e),self.postMessage({type:"error",payload:e.message}),!1}return!0}async function R(e,t=1920,a=1080){const r=await async function(e,t,i){const a=["hvc1.1.6.L93.B0","hev1.1.6.L93.B0","hvc1.1.6.L93.0","hev1.1.6.L93.0","hvc1.1.6.L93","hev1.1.6.L93","hvc1.1.6.L90","hev1.1.6.L90","hvc1.1.6.L90.0","hev1.1.6.L90.0","hvc1.1.6.L80","hev1.1.6.L80","hvc1.1.6.L80.0","hev1.1.6.L80.0","hvc1.1.6.L70","hev1.1.6.L70","hvc1.1.6.L70.0","hev1.1.6.L70.0","hvc1.1.6.L60","hev1.1.6.L60","hvc1.1.6.L60.0","hev1.1.6.L60.0","hvc1.1.6.L50","hev1.1.6.L50","hvc1.1.6.L50.0","hev1.1.6.L50.0","hvc1.1.6.L40","hev1.1.6.L40","hvc1.1.6.L40.0","hev1.1.6.L40.0","hvc1.1.6.L30","hev1.1.6.L30","hvc1.1.6.L30.0","hev1.1.6.L93"],r=await async function(){const r=[];for(const n of a)try{const a={codec:n,width:t,height:i,description:e.buffer},s=await VideoDecoder.isConfigSupported(a);s.supported,s.supported&&r.push(s.config.codec)}catch(e){}return r}();return r}(e,t,a);if(r.length<=0)return console.error("decoder info:not support codec"),!1;const n={codec:r[0],width:t,height:a,optimizeForLatency:!0,latencyMode:"realtime",description:e.buffer};Array.from(new Uint8Array(e.slice(0,4))),Array.from(new Uint8Array(e.slice(4,8))),Array.from(new Uint8Array(e.slice(8,12)));try{const e=await VideoDecoder.isConfigSupported(n);if(!e.supported)return void console.error("brower not support codec");i.decoder_conf=n,i.decoder.configure(i.decoder_conf)}catch(e){return void console.error("brower codec decode failed:",e)}}self.onmessage=async function(r){if("init"===r.data.type)return c=r.data.payload.ignore_audio||!1,r.data,r.data.payload.wasm_js_path,r.data.payload.wasm_wasm_path,void await L(r.data.payload.wasm_js_uri,r.data.payload.wasm_wasm_uri);if("canvas"===r.data.type){r.data,i.canvas=r.data.payload.offscreen,i.canvas_id=r.data.payload.canvas_id;const e=r.data.payload.width,t=r.data.payload.height,n=i.canvas.getContext("webgl2",{antialias:!1,powerPreference:"high-performance"});if(i.gl=n,i.ccall("wcodec_init_gl_cb","",["number","string"],[a,i.canvas_id]),i.decoder){const i=new Uint8Array(r.data.payload.extra_data);i.buffer,await R(i,e,t)}else console.error("wasmCodecExports decoder is null")}else if("demuxer_extradata_cb"===r.data.type){if(r.data,i.decoder){const e=new Uint8Array(r.data.payload.extra_data);e.buffer,await R(e)}}else if("demuxer_nalu_cb"===r.data.type){r.data;const e=r.data.payload.pts,i=r.data.payload.dts,a=r.data.payload.w,n=r.data.payload.h,s=r.data.payload.isKey,o={data:r.data.payload.nalu,pts:e,dts:i,width:a,height:n,isKey:s};t.push(o),m=o.pts,g=o.dts,h=!1,f=0,t.length,o.pts,o.dts,o.isKey}else if("get_nalu_len"===r.data.type){const e=t.length;self.postMessage({type:"get_nalu_len_result",payload:e})}else if("cache_tex"===r.data.type){if(t.length<1)return;let e=i.ccall("wcodec_get_frame_queue_length","number",["number"],[a]);const n=r.data.payload.recv_v_count,s=e+n;for(let r=0;r<n;r++){if(r>=n&&(e=i.ccall("wcodec_get_frame_queue_length","number",["number"],[a]),e>=s))return;const o=t.shift();if(!o)return;const _=i._malloc(o.data.byteLength);i.HEAPU8.set(o.data,_),i.ccall("wcodec_feed_data","",["number","number","number","number","number"],[a,_,o.data.byteLength,BigInt(Math.floor(Number(1e3*o.pts))),o.isKey]),i._free_buffer(_)}}else if("get_tex_len"===r.data.type){const e=i.ccall("wcodec_get_frame_queue_length","number",["number"],[a]);self.postMessage({type:"get_tex_len_result",payload:e})}else if("clean_cache_queue"===r.data.type)k(),i.ccall("wcodec_clean_tex_queue","",["number"],[a]);else if("seek_decode"===r.data.type)r.data.payload,S(),l=BigInt(Math.floor(1e3*Number(r.data.payload.seekTime))),i.webcodec_seek_target_pts=l,T();else if("render_tex"===r.data.type){i.ccall("wcodec_render_frame_from_queue","number",["number"],[a])}else if("set_playback_rate"===r.data.type)r.data.payload,u=r.data.payload.playback_rate||1;else if("render_play"===r.data.type){y&&(cancelAnimationFrame(y),y=null),A(),v&&(clearInterval(v),v=null);const e=r.data.payload.frame_duraiton;let t=e/u;r.data.payload.fps;let d=performance.now()+t;if(c){const r=()=>{if(performance.now()>=d){const r=performance.now(),n=i.ccall("wcodec_render_frame_from_queue","number",["number"],[a]);if(n>0){const a=Number(i.av_align_video_play_ms||-1),n=E>=0&&a>=0?a-E:e;a>=0&&(n<=0||n>1.5*e||(b>=0?r-b:t)>2.5*t)&&w(),E=a,b=r}else if(n<0&&b>=0){r-b>2.5*t&&w()}d+=t}t=e/u,y=requestAnimationFrame(r)};y=requestAnimationFrame(r)}else{const r=Math.min(4,Math.max(1,.12*t)),l=3,c=()=>{const h=()=>{const l=performance.now(),u=i.ccall("wcodec_render_frame_from_queue","number",["number"],[a]);if(u>0){const a=Number(i.av_align_video_play_ms||-1),r=E>=0&&a>=0?a-E:e;a>=0&&(r<=0||r>1.5*e||(b>=0?l-b:t)>2.5*t)&&w(),E=a,b=l}else if(u<0&&b>=0){l-b>2.5*t&&w()}if(d+=t-r,!n&&o>0&&_>0&&i.av_align_video_play_ms>0){const e=i.av_align_video_play_ms;n=!0;const a=o-e,r=Math.abs(a);if(r>(_||15*t)){if(s.slow_down_count=Math.ceil(r/t),s.adjusted_duration=Math.min(1.2*t,t+7)-t,a<0){if(s.slow_down_count,s.adjusted_duration,r>1e3)return self.postMessage({type:"av_align_audio_slower_too_much",payload:r}),u}else if(s.adjusted_duration=-1*s.adjusted_duration,s.slow_down_count,s.adjusted_duration,r>1e3)return self.postMessage({type:"av_align_audio_faster_too_much",payload:r}),function(e=-1){e<0||(v&&(clearInterval(v),v=null),v=setInterval((()=>{let t=i.av_align_video_play_ms;if(t<0)return console.error("align_av_timestamp INTERVAL first cache pts ms failed"),clearInterval(v),v=null,-3;if(e>t){if(i.ccall("cylopengl_pop_cache_yuv420p","number",[])<0)return console.error("align_av_timestamp INTERVAL cylopengl_pop_cache_yuv420p failed"),clearInterval(v),v=null,-4}else clearInterval(v),v=null,y&&self.postMessage({type:"av_align_finished"})}),50))}(o),u;d+=s.adjusted_duration,s.slow_down_count--}}else d+=s.adjusted_duration,s.slow_down_count--,s.slow_down_count<=0&&(n=!1,s.slow_down_count=-1,s.adjusted_duration=-1);return u};if(performance.now()>=d){let e=0;for(;performance.now()>=d&&e<l;){if(e++,h()<=0)break}}t=e/u,y=requestAnimationFrame(c)};y=requestAnimationFrame(c)}}else if("render_pause"===r.data.type)y&&(cancelAnimationFrame(y),y=null),A();else if("gpu_memory_info"===r.data.type){const e=i.ccall("wcodec_gpu_memory_info","number",["number"],[a]);self.postMessage({type:"gpu_memory_info_result",payload:e})}else if("probe_ok"===r.data.type)e=!0,d=!r.data.payload.w||!r.data.payload.h||r.data.payload.w<=0||r.data.payload.h<=0?100:function(e,t){const[i,a]=e>t?[e,t]:[t,e],r=4096,n=8192,s=24576,o=i*a*4*1.1/1048576;return{resolution:`${i}x${a}`,frameSizeMB:o.toFixed(2),capacities:{integrated:Math.floor(r/o),mainstream:Math.floor(n/o),flagship:Math.floor(s/o)},currentDevice:{estimated:Math.floor(4096/o/5)}}}(r.data.payload.w,r.data.payload.h).currentDevice.estimated,T();else if("audio_play_info"===r.data.type){if(l>=0){const e=Number(l),t=Number(r.data.payload.pts);if(Number.isFinite(e)&&Number.isFinite(t)&&t+1e3<e)return;Number.isFinite(e)&&Number.isFinite(t)&&t>=e-500&&(l=-1,i.webcodec_seek_target_pts=-1)}o=r.data.payload.pts,_=r.data.payload.duration}else"release"===r.data.type&&(i?a?(i.ccall("release_webcodec_ctx","number",["number"],[a]),a=null,i.decoder_ctx_ptr=null,i&&(i.webcodec_seek_target_pts=-1,i._free&&i._free(),i=null),y&&(cancelAnimationFrame(y),y=null),k()):console.error("decoder info:releaseDecoder: decoder_ctx_ptr is NULL"):console.error("decoder info:releaseDecoder: wasmCodecExports is NULL"),self.close())}})))},t.exports=create_worker_decoder},{"../av-common":4,"../consts":5}],13:[function(e,t,i){const a=e("../av-common");create_worker_demuxer=function(){return new Worker(a.GetScriptPath((function(){class e{constructor(e,t,i,a){this.pts=e,this.dts=e,this.isKey=t,this.data=i,this.video=a}setFrame(e,t,i,a){this.pts=e,this.isKey=t,this.data=i,this.video=a}}const t="live",i="vod";let a=null,r=null,n=null,s=new AbortController,o=s.signal,_=null,d=null,l=-1,u=!1,c=null,h=!1,f=t,p=0,m=0,g=0,y=!1,v=null,b=null,E=null,S=!1,A=0,w=0,k=(()=>{let t={videoBuffer:[],audioBuffer:[],idrIdxBuffer:[],appendFrame:(i,a,r=!0,n=!1)=>{let s=new e(i,n,a,r),o=parseInt(i);return r?(t.videoBuffer.length-1>=o?t.videoBuffer[o].push(s):t.videoBuffer.push([s]),n&&!t.idrIdxBuffer.includes(i)&&t.idrIdxBuffer.push(i)):t.audioBuffer.length-1>=o&&null!=t.audioBuffer[o]&&null!=t.audioBuffer[o]?t.audioBuffer[o]&&t.audioBuffer[o].push(s):t.audioBuffer.push([s]),!0}};return t.appendFrameWithDts=(i,a,r,n=!0,s=!1)=>{let o=((t,i,a,r,n)=>{let s=new e(t,a,r,n);return s.dts=i,s})(i,a,s,r,n),_=parseInt(a);return n?(t.videoBuffer.length-1>=_?t.videoBuffer[_].push(o):t.videoBuffer.push([o]),s&&!t.idrIdxBuffer.includes(a)&&t.idrIdxBuffer.push(a)):t.audioBuffer.length-1>=_&&null!=t.audioBuffer[_]&&null!=t.audioBuffer[_]?t.audioBuffer[_]&&t.audioBuffer[_].push(o):t.audioBuffer.push([o]),!0},t.appendFrameByBufferFrame=e=>{let i=e.pts,a=parseInt(i);return e.video?(t.videoBuffer.length-1>=a?t.videoBuffer[a].push(e):t.videoBuffer.push([e]),isKey&&!t.idrIdxBuffer.includes(i)&&t.idrIdxBuffer.push(i)):t.audioBuffer.length-1>=a?t.audioBuffer[a].push(e):t.audioBuffer.push([e]),!0},t.cleanPipeline=()=>{t.idrIdxBuffer.length=0;for(let e=0;e<t.videoBuffer.length;e++){for(let i=0;i<t.videoBuffer[e].length;i++)t.videoBuffer[e][i].data=null;t.videoBuffer[e].length=0}t.videoBuffer.length=0;for(let e=0;e<t.audioBuffer.length;e++){for(let i=0;i<t.audioBuffer[e].length;i++)t.audioBuffer[e][i].data=null;t.audioBuffer[e].length=0}t.audioBuffer.length=0},t.vFrame=(e=-1)=>{if(!(e<0||e>t.videoBuffer.length-1))return t.videoBuffer[e]},t.aFrame=(e=-1)=>{if(!(e<0||e>t.audioBuffer.length-1))return t.audioBuffer[e]},t.seekIDR=(e=-1)=>{if(e=Number(e),t.idrIdxBuffer,t.videoBuffer,e<0)return null;if(t.idrIdxBuffer.includes(e)){const i=t.idrIdxBuffer.indexOf(e);return i-1>=0?t.idrIdxBuffer[i-1]:e}for(let i=0;i<t.idrIdxBuffer.length;i++)if(t.idrIdxBuffer[i],t.idrIdxBuffer[i+1],i===t.idrIdxBuffer.length-1||t.idrIdxBuffer[i]<e&&t.idrIdxBuffer[i+1]>e||0===i&&t.idrIdxBuffer[i]>=e){for(let e=1;e>=0;e--){let a=i-e;if(a>=0)return t.idrIdxBuffer[a],t.idrIdxBuffer[a]}return t.idrIdxBuffer[i],j,t.idrIdxBuffer[i]}},t})(),T=-1,L=-1,R={video_count:0,audio_count:0},C=!1,x=null,M=null,D=null,O=null,I=null,P=null,B=null;const U=2097152,N=1048576;let F=null;function V(){return function(){s&&s.abort(),c&&(h=!0,c.close());c=null,function(){v&&(clearInterval(v),v=null);b&&(clearInterval(b),b=null);E&&(clearInterval(E),E=null)}()}(),S=!1,L=0,T=0,F&&(F=null),a&&r?(a.ccall("release_demuxer_ctx","number",["number"],[r]),r=null,x&&a.removeFunction(x),M&&a.removeFunction(M),D&&a.removeFunction(D),O&&a.removeFunction(O),I&&a.removeFunction(I),P&&a.removeFunction(P),B&&a.removeFunction(B),x=null,M=null,D=null,O=null,I=null,P=null,B=null,a&&(a._free&&a._free(),a=null),k.cleanPipeline(),y=!1,!0):(console.error("release: ctx_ptr is NULL"),!1)}function G(e=1,t=1){if(!a||!r)return console.error("demux: ctx_ptr is NULL"),!1;const i=function(e,t){let i=e,a=t;q()&&(i=Math.min(i,12),a=Math.min(a,24));return{video_count:i,audio_count:a}}(e,t);i.video_count===e&&i.audio_count===t||(i.video_count,i.audio_count);let n=a.ccall("demuxer_video_pkt","number",["number","number","number"],[r,i.video_count,i.audio_count]);return n<=0&&(i.video_count,i.audio_count),n}function H(){b||(b=setInterval((function(){if(R.video_count>0){let e=T<0?0:Number(Math.floor(T)),t=0;for(;k.videoBuffer[e]&&!(k.videoBuffer[e].length<=0);){if(t>k.videoBuffer[e].length-1){if(k.videoBuffer[e+1]&&k.videoBuffer[e+1].length>0){e++,t=0;continue}break}const i=k.videoBuffer[e][t];if(t++,!(T>0&&i.dts<=T)&&(self.postMessage({type:"demuxer_nalu_cb",payload:{pts:i.pts,dts:i.dts,isKey:i.isKey,nalu:i.data,w:p,h:m}}),T=i.dts,R.video_count--,R.video_count<=0))break}}}),50)),E||(E=setInterval((function(){if(R.audio_count>0){let e=L<0?0:Number(Math.floor(L)),t=0;for(;k.audioBuffer[e]&&!(k.audioBuffer[e].length<=0);){if(t>k.audioBuffer[e].length-1){if(k.audioBuffer[e+1]&&k.audioBuffer[e+1].length>0){t=0,e++;continue}break}const i=k.audioBuffer[e][t];if(t++,!(L>0&&i.pts<=L)&&(self.postMessage({type:"demuxer_aac_cb",payload:{pts:i.pts,nalu:i.data,len:i.data.byteLength,ch:g}}),L=i.pts,R.audio_count--,R.audio_count<=0))break}}}),50))}function z(e,t){const i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function W(){if(d)return function(e){if(!e)return"";const t=String(e).toLowerCase();return-1!==["mpegts","m2ts","transportstream"].indexOf(t)?"ts":t}(d);if(!n)return"";const e=n.split("?")[0].toLowerCase();return e.endsWith(".ts")||e.endsWith(".m2ts")?"ts":""}function q(){const e=String(_||"").toLowerCase();return f===t&&"flv"===W()&&-1!==["ws","wss","websocket"].indexOf(e)}function Y(){if(!a||!r)return;const e=function(){switch(W()){case"mp4":return 0;case"flv":return 1;case"mkv":return 2;case"hls":case"m3u8":return 3;case"ts":return 4;default:return 100}}();100!==e&&a.ccall("ffdemuxer_set_format_hint",null,["number","number"],[r,e])}function K(){return f===i&&!1===y&&"ts"===W()}function X(){return f===t&&!1===y&&"ts"===W()}function Q(e){return!(!F||F.length<=0)&&((!K()||!1!==u)&&(f===i?!K()||F.length>=Math.max(e,U):X()?F.length>=Math.max(e,N):q()?F.length>=Math.max(e,32768):F.length>=e))}function J(e=4096,t=!1){if(!a||!r||!F||F.length<=0)return!1;const i=F;F=null;const n=a._malloc(i.length);a.HEAPU8.set(i,n);try{i.length;a.ccall("push_buffer","number",["number","number","number","number"],[r,n,i.length,e]);i.length}finally{a._free(n)}let s="";if(t?s="force_after_flush":K()&&i.length>=U?s="ts_vod_preroll":X()&&i.length>=N&&(s="ts_live_progressive"),!y&&s){i.length;a.ccall("push_probe","number",["number","number"],[r,e])}return!0}function Z(e,d=!1){n=e,u=!1;let p=4096;if(!a||!r)return void console.error("release: ctx_ptr is NULL");if(-1!==["ws","wss","websocket"].indexOf(_))try{return Y(),function(e,i=!1){c&&(h=!0,c.close()),c=null,c=new WebSocket(e),c.binaryType="arraybuffer";let s=4096;c.onopen=function(e){i&&self.postMessage({type:"fetch-retry-response-ok",payload:{url:n,msg:"fetch-retry-response-ok"}}),f=t,a&&r&&(a.ccall("ffdemuxer_set_read_frame_multiple_times","number",["number","number"],[r,l>0?l:2]),a.ccall("ffdemuxer_set_mode_live","number",["number"],[r]))},c.onmessage=function(e){if(e.data instanceof ArrayBuffer){var t=e.data;if(F){const e=new Uint8Array(t);F=z(F,e)}else F=new Uint8Array(t);y&&(s=4096),t.byteLength>0&&Q(s)&&J(4096)}},c.onclose=function(e){h?h=!1:(F&&(F=null),self.postMessage({type:"fetch-done",payload:{url:n,msg:"fetch-done",is_vod:!1,is_complete:!1}}))}}(e,d)}catch(e){return void console.error("WebSocket link err:",e)}s||(s=new AbortController,o=s.signal),Y();let m=0;fetch(e,{demuxer_fetch_signal:o}).then((e=>{if(!e.ok)return F&&(F=null),void self.postMessage({type:"fetch-response-error",payload:{url:n,msg:"fetch-response-error"}});e.status,e.statusText,d&&self.postMessage({type:"fetch-retry-response-ok",payload:{url:n,msg:"fetch-retry-response-ok"}});const s=e.headers.get("Content-Length");s&&s>0?(f=i,a.ccall("ffdemuxer_set_read_frame_multiple_times","number",["number","number"],[r,l>0?l:3])):(f=t,a&&r&&(a.ccall("ffdemuxer_set_read_frame_multiple_times","number",["number","number"],[r,l>0?l:2]),a.ccall("ffdemuxer_set_mode_live","number",["number"],[r])));const o=e.body.getReader();return o.read().then((function e({done:t,value:_}){if(t){if(u=!0,a&&a.ccall("fetch_done_buffer","number",["number"],[r]),F)K()&&F.length,J(4096,!0);else if(a&&!y&&a){a.ccall("push_probe","number",["number","number"],[r,4096])}return f===i&&m===parseInt(s)?void self.postMessage({type:"fetch-done",payload:{url:n,msg:"fetch-done",is_vod:!0,is_complete:!0}}):void self.postMessage({type:"fetch-done",payload:{url:n,msg:"fetch-done",is_vod:f===i}})}if(_&&(m+=_.byteLength),F){const e=new Uint8Array(_);F=z(F,e)}else F=new Uint8Array(_);return y&&(p=4096),Q(p)&&J(4096),o.read().then(e)}))})).catch((function(e){if(F&&(F=null),!e.toString().includes("user aborted")){const t=" httplive request error:"+e+" start to retry";console.error("fetch error:",t),self.postMessage({type:"fetch-error",payload:t})}}))}async function $(e,n){if("undefined"==typeof WebAssembly)return self.postMessage({type:"error",payload:"当前浏览器不支持WebAssembly"}),!1;try{importScripts(e);const s=n;if(a=await new Promise((e=>{const t=WasmModule({locateFile:e=>s,onRuntimeInitialized:()=>{e(t)}})})),!a)return console.error("initialized wasm ptr: False"),!1;a._main(),Object.keys(a);a?r=a.ccall("init_demuxer_ctx","number",[],[]):console.error("ctx_ptr is NULL");const o={test:"v",probe:"vidiidiiiiiiii",extra:"vii",yuv:"viiiiiiiidi",nalu:"viiiiidd",pcm:"viid",aac:"viiid"};if(!a)return void console.error("ctx_ptr is NULL");x=a.addFunction((()=>{}),o.test),M=a.addFunction(((e,r,n,s,o,_,d,l,u,c,h,b,E)=>{if(!a)return void console.error("ctx_ptr is NULL");const k=a.UTF8ToString(c),T=((e=100)=>{let t="UNKNOWN";switch(e){case 0:default:t="MP4";break;case 1:t="FLV";break;case 2:t="MKV";break;case 3:t="HLS";break;case 4:t="TS"}return t.toLowerCase()})(h);y=!0;const L=new Uint8Array(b);L.set(new Uint8Array(a.HEAPU8.buffer,E,b)),L.buffer,f=r>0?i:t,p=n,m=s,g=l,self.postMessage({type:"demuxer_probe_cb",payload:{needSwr:e,duration:r,demuxer_media_type:f,w:n,h:s,fps:o,audioIndex:_,sampleRate:d,channel:l,codec:u,fmt:k,media_fmt:T,extra_data:L.buffer,extra_size:b}},[L.buffer]),f==i&&(v||(v=setInterval((function(){100==G(100,200)&&(S=!0,self.postMessage({type:"demuxer_vod_nalu_done",payload:{v_last_dts_sec:A,a_last_dts_sec:w,v_last_dts:1e3*A,a_last_dts:1e3*w}}),clearInterval(v),v=null)}),100)),H())}),o.probe),D=a.addFunction(((e,t)=>{}),o.extra),O=a.addFunction(((e,t,i,a,r,n,s,o,_,d)=>{}),o.yuv),I=a.addFunction(((e,t,r,n,s,o,_)=>{if(A=Math.max(A,_),!a)return void console.error("ctx_ptr is NULL");const d=new Uint8Array(t);d.set(a.HEAPU8.subarray(e,e+t)),f===i?k.appendFrameWithDts(o,_,d,!0,r):self.postMessage({type:"demuxer_nalu_cb",payload:{nalu:d,pts:o,dts:_,isKey:r,w:n,h:s}})}),o.nalu),P=a.addFunction(((e,t,r)=>{if(w=Math.max(w,r),!a)return void console.error("ctx_ptr is NULL");const n=new Uint8Array(t);n.set(a.HEAPU8.subarray(e,e+t)),f===i?k.appendFrame(r,n,!1,!0):self.postMessage({type:"demuxer_aac_cb",payload:{nalu:n,len:t,pts:r,ch:1}})}),o.pcm),B=a.addFunction(((e,t,r,n)=>{if(w=Math.max(w,n),!a)return void console.error("ctx_ptr is NULL");const s=new Uint8Array(t);s.set(a.HEAPU8.subarray(e,e+t)),f===i?k.appendFrame(n,s,!1,!0):self.postMessage({type:"demuxer_aac_cb",payload:{nalu:s,len:t,pts:n,ch:r}})}),o.aac);a.ccall("bind_demuxer_callback","number",["number","number","number","number","number","number","number","number","number","number"],[r,x,M,D,O,I,P,B,C?1:0,30])}catch(e){return console.error("worker.js Failed to initialize WebAssembly:",e),self.postMessage({type:"error",payload:e.message}),!1}return self.postMessage({type:"ready"}),!0}onmessage=async function(e){if("init"===e.data.type)return e.data,e.data.payload.wasm_js_path,e.data.payload.wasm_wasm_path,C=e.data.payload.ignore_audio||!1,await $(e.data.payload.wasm_js_uri,e.data.payload.wasm_wasm_uri),a?(_=e.data.payload.protocol,d=e.data.payload.format_type||null,l=e.data.payload.readframe_multi_times||-1,void(e.data.payload.media_uri&&Z(e.data.payload.media_uri))):void console.error("wasm not initialized");if("loadMedia"===e.data.type){e.data.payload;const t=Date.now(),i=1e4,r=setInterval((()=>{a?(clearInterval(r),clearTimeout(n),_=e.data.payload.protocol,d=e.data.payload.format_type||null,Z(e.data.payload.media_uri)):Date.now()-t>i&&(clearInterval(r),console.error("WASM load timeout 10s"),self.postMessage({type:"error",payload:"WASM模块初始化超时"}))}),100),n=setTimeout((()=>{clearInterval(r)}),i)}else if("retry_load_media"===e.data.type){if(!a)return void console.error("wasm not initialized");a&&r&&(s&&s.abort(),s=null,o=null,s=new AbortController,o=s.signal,setTimeout((function(){Z(n,!0)}),3e3))}else if("demux"===e.data.type){if(!a)return void console.error("wasm not initialized");const t=e.data.payload.recv_v_count||1,r=e.data.payload.recv_a_count||1;f==i?0!==R.video_count&&0!==R.audio_count||(R.video_count=t,R.audio_count=r):G(t,r)}else if("seek_demux"===e.data.type){seekTime=e.data.payload.seekTime;let t=k.seekIDR(seekTime);seekTime,T=t,L=seekTime,H(),self.postMessage({type:"ready_seek_demux",payload:{seekTime:seekTime}})}else if("test2"===e.data.type)for(;;)await new Promise((e=>setTimeout(e,0)));else if("release"===e.data.type)e.data,a&&(V(),a=null),self.close();else if("stop_cache_pkt_to_decoder"===e.data.type)b&&(clearInterval(b),b=null),E&&(clearInterval(E),E=null),R.video_count=0,R.audio_count=0;else if("restart_cache_pkt_to_decoder"===e.data.type);else if("test1"===e.data.type)for(;;)await new Promise((e=>setTimeout(e,0)))}})))},t.exports=create_worker_demuxer},{"../av-common":4}],14:[function(e,t,i){e("../consts");const a=e("../av-common");create_worker_ffdecoder=function(){return new Worker(a.GetScriptPath((function(){let e=!1,t=[],i=null,a=null,r=null,n=0,s=-1,o=0,_=0,d=!1,l=!1,u=0,c=null,h=null,f=!1;function p(e,t){return t+3<e.length&&0===e[t]&&0===e[t+1]&&1===e[t+2]||t+4<e.length&&0===e[t]&&0===e[t+1]&&0===e[t+2]&&1===e[t+3]}let m=100;function g(){s=-1,r&&(clearInterval(r),r=null),t.forEach((e=>{e.data=null})),t=[],t.length=0,o=0,_=0,f=!1}function y(){r&&(clearInterval(r),r=null);let e=0;r=setInterval((()=>{if(!i)return;if(i.decoder_error_wait)return void console.error("cyl debug wasmFFDecodeExports.decoder_error_wait");const r=n;if(r<=0&&1!==e?(e=1,self.postMessage({type:"on_load_cache"})):r>0&&2!==e&&(e=2,self.postMessage({type:"on_finish_cache",payload:{store_length:r}})),r>=m)return;const s=Math.max(4,Math.floor(25)),o=Date.now();if(t.length<s&&(!l||o-u>150)&&(l=!0,u=o,self.postMessage({type:"request_demux",payload:{recv_v_count:100,recv_a_count:200}})),t.length<1)return;const _=t.shift();if(!_)return void console.error("cyl debug cache_tex !naluData");const d=!!_.isKey||function(e){const t=e&&e.data;if(!t||t.length<6)return!1;for(let e=0;e<t.length-5;e++){if(!p(t,e))continue;const i=1===t[e+2]?e+3:e+4;if(i>=t.length)break;const a=t[i]>>1&63;if(a>=16&&a<=21)return!0}return!1}(_);if(f&&!d)return;f&&d&&(i.ccall("ffdecoder_seek_set","number",["number","number"],[a,-1]),f=!1);let c=i._malloc(_.data.byteLength);i.HEAPU8.set(_.data,c);const h=i.ccall("ffdecoder_decode_video_frame","number",["number","number","number","number","number","number"],[a,c,_.data.length,_.pts,_.dts,d?1:0]);h<0&&-2!==h&&(f=!0),i._free(c),c=null}),10)}self.onmessage=async function(r){if("init"!==r.data.type)if("set_video_decoder"===r.data.type){if(!i)return void console.error("cyl debug releaseDecoder: wasmFFDecodeExports is NULL");if(!a)return void console.error("cyl debug releaseDecoder: ffdecoder_ctx_ptr is NULL");let e=new Uint8Array(r.data.payload.extra_data);e.buffer;let t=i._malloc(e.byteLength);i.HEAPU8.set(e,t);const n=r.data.payload.codec;i.ccall("ffdecoder_set_video_decoder_with_extra","number",["number","number","number","number","number","number"],[a,n,r.data.payload.width,r.data.payload.height,t,e.byteLength]);i._free(t),t=null,e=null}else if("set_audio_decoder"===r.data.type){if(!i)return void console.error("cyl debug releaseDecoder: wasmFFDecodeExports is NULL");if(!a)return void console.error("cyl debug releaseDecoder: ffdecoder_ctx_ptr is NULL");const e=r.data.payload.codec,t=r.data.payload.timebase;i.ccall("ffdecoder_set_audio_decoder","number",["number","number","number"],[a,e,t])}else if("demuxer_nalu_cb"===r.data.type){r.data;const e=r.data.payload.pts,i=r.data.payload.dts,a=r.data.payload.w,n=r.data.payload.h,s=r.data.payload.isKey,o={data:r.data.payload.nalu,pts:Math.floor(Number(1e3*e)),dts:Math.floor(Number(1e3*i)),width:a,height:n,isKey:s};t.push(o),l=!1,u=0,t.length}else if("demuxer_vod_nalu_done"===r.data.type)o=r.data.payload.v_last_dts,_=r.data.payload.a_last_dts;else if("get_nalu_len"===r.data.type){const e=t.length;self.postMessage({type:"get_nalu_len_result",payload:e})}else"probe_ok"===r.data.type?(e=!0,m=!r.data.payload.w||!r.data.payload.h||r.data.payload.w<=0||r.data.payload.h<=0?100:function(e,t){const[i,a]=e>t?[e,t]:[t,e],r=4096,n=8192,s=24576,o=i*a*4*1.1/1048576;return{resolution:`${i}x${a}`,frameSizeMB:o.toFixed(2),capacities:{integrated:Math.floor(r/o),mainstream:Math.floor(n/o),flagship:Math.floor(s/o)},currentDevice:{estimated:Math.floor(4096/o/5)}}}(r.data.payload.w,r.data.payload.h).currentDevice.estimated,y()):"audio_play_info"===r.data.type?(av_align_audio_time_ms=r.data.payload.pts,av_align_audio_duration_ms=r.data.payload.duration):"clean_cache_queue"===r.data.type?g():"release"===r.data.type?(i?a?(i.ccall("release_ffdecoder_ctx","number",["number"],[a]),a=null,a&&i.removeFunction(c),c=null,a&&i.removeFunction(h),h=null,i.ffdecoder_ctx_ptr=null,i&&(i._free&&i._free(),i=null),g()):console.error("cyl debug releaseDecoder: ffdecoder_ctx_ptr is NULL"):console.error("cyl debug releaseDecoder: wasmFFDecodeExports is NULL"),self.close()):"seek_decode"===r.data.type?(r.data.payload,s=parseInt(Math.floor(1e3*Number(r.data.payload.seekTime))),i.ccall("ffdecoder_seek_set","",["number","number"],[a,s]),y()):"set_cache_size"===r.data.type&&(n=r.data.payload.cache_size);else{if(r.data,r.data.payload.wasm_js_uri,r.data.payload.wasm_wasm_uri,d=r.data.payload.ignore_audio||!1,!await async function(e,t){if("undefined"==typeof WebAssembly)return self.postMessage({type:"error",payload:"当前浏览器不支持WebAssembly"}),!1;try{importScripts(e);const a=t;if(i=await new Promise((e=>{const t=WasmModule({locateFile:e=>a,onRuntimeInitialized:()=>{e(t)}})})),!i)return console.error("cyl debug WebAssembly module initialized wasmFFDecodeExports: False"),!1;i._main(),Object.keys(i)}catch(e){return console.error("cyl debug worker-decoder.js Failed to initialize WebAssembly:",e),self.postMessage({type:"error",payload:e.message}),!1}return!0}(r.data.payload.wasm_js_uri,r.data.payload.wasm_wasm_uri))return;i.canvas_id=r.data.payload.canvas_id;(function(){if(!i)return console.error("cyl debug initDecoderObject: wasmFFDecodeExports is NULL"),!1;a=i.ccall("init_ffdecoder_ctx","number",[],[]),i.ffdecoder_ctx_ptr=a;const e="viiiiiiiiiii",t="viiiii";c=i.addFunction(((e,t,a,r,n,o,_,d,l,u,c)=>{const h=new Uint8Array(o*n);h.set(i.HEAPU8.subarray(e,e+o*n));const f=new Uint8Array(_*n);f.set(i.HEAPU8.subarray(t,t+_*n));const p=new Uint8Array(d*n);p.set(i.HEAPU8.subarray(a,a+d*n)),self.postMessage({type:"decode_video_progress",payload:{y_data:h,u_data:f,v_data:p,width:r,height:n,y_linesize:o,u_linesize:_,v_linesize:d,pts:l,dts:u,tag:c}}),s>=0&&l>=s&&(self.postMessage({type:"seek_success_target",payload:{width:r,height:n,pts:l,target_pts:s}}),s=-1)}),e),ffdecoder_ccallback_pcm_ptr=i.addFunction(((e,t,i,a,r)=>{pcm}),t),i.ccall("ffdecoder_bind_callback","number",["ffdecoder_ctx_ptr","number","number"],[a,c,ffdecoder_ccallback_pcm_ptr])})();self.postMessage({type:"ready"})}}})))},t.exports=create_worker_ffdecoder},{"../av-common":4,"../consts":5}],15:[function(e,t,i){(function(i){(function(){const a=e("./consts"),r=e("./av-common"),n=e("./probe"),s=e("./audio/audio-aac-core"),o=e("./audio/audio-pcm-core"),_=e("./worker/create-worker-demuxer"),d=e("./worker/create-worker-decoder"),l=e("./worker/create_worker_ffdecoder"),u=e("./opengl/cylopengl"),c=e("./native/mp4-player"),h=e("./native/nv-flvjs-core");class f{constructor(){let e=this;this._audioAACCtx=null,this._demuxer_worker=null,this._decoder_worker=null,this._video_render_pts=-1,this._player_id=null,this._player_box=null,this._canvas=null,this._canvas_id=null,this._player_width=0,this._player_height=0,this._player_video_core=null,this._play_url=null,this._base_url=null,this._wasm_js_uri=null,this._wasm_wasm_uri=null,this._wasm_main_thread_exports=null,this._opengl_render=null,this._ext_src_js_uri=null,this._ext_wasm_js_uri=null,this._ext_h265webjs_core=null,this._ext_h265webjs_loaded=!1,this._enable_play_button=!1,this._play_button_id=null,this._play_button=null,this._play_icon=null,this._pause_icon=null,this._native_core=null,this._first_frame_render=!1,this._expect_play=!1,this._cache_pause_timer=null,this._webcodec_render_running=!1,this._audio_resume_allowed=!1,this._live_http_flv_audio_realign_pending=!1,this._decoder_seek_pending=!1,this._media_info={needSwr:0,duration:-1,demuxer_media_type:n.PLAYER_MODE_VOD,w:-1,h:-1,fps:-1,audioIndex:-1,sampleRate:-1,channel:-1,codec:-1,fmt:"",extra_data:null,extra_size:0},this._player_vlast_dts=-1,this._player_alast_dts=-1,this._player_playbackRate=1,this._player_voice=1,this._format_type=null,this._workerFetch=null,this._workerParse=null,this._wait_init_interval=null,this._on_inited=!1,this.gpu_info_callback=null,this.video_probe_callback=null,this.video_nalu_callback=null,this.video_frame_callback=null,this.audio_frame_callback=null,this.video_render_callback=null,this.audio_render_callback=null,this.av_sync_callback=null,this.nalu_length_callback=null,this.tex_length_callback=null,this.request_pkt_callback=null,this.on_ready_show_done_callback=null,this.on_load_caching_callback=null,this.on_play_time=null,this.on_play_finished=null,this.on_finish_cache_callback=null,this.on_release_done_callback=null,this.on_seek_start_callback=null,this.on_seek_done_callback=null,this.on_cache_process_callback=null,this.auto_screen_close=!0,this.on_open_fullscreen=null,this.on_close_fullscreen=null,this.on_error_callback=null,this.screenW=window.screen.width,this.screenH=window.screen.height,this._fullscreen_listener_bound=!1,this._fullscreen_handler=t=>{e._isFullScreen()?e.on_open_fullscreen&&e.on_open_fullscreen():(!0===e.auto_screen_close&&e.closeFullScreen(!0),e.on_close_fullscreen&&e.on_close_fullscreen())}}_checkScreenDisplaySize(e,t,i,a){let r=i/e>a/t,n=(e/i).toFixed(2),s=(t/a).toFixed(2),o=r?n:s,_=this.fixed?e:parseInt(i*o),d=this.fixed?t:parseInt(a*o);return[parseInt((t-d)/2),parseInt((e-_)/2),_,d]}_isFullScreen(){let e=document.fullscreenElement||document.mozFullscreenElement||document.webkitFullscreenElement;document.fullscreenEnabled||document.mozFullscreenEnabled||document.webkitFullscreenEnabled;return null!=e}_is_vod_finish_reliable(){if(this._player_vlast_dts<=0)return!1;if(!this._media_info||this._media_info.duration<=0)return!0;const e=1e3*this._media_info.duration,t=Math.max(1e3,.7*e);return this._player_vlast_dts>=t}_requestFullScreen(e){e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen?e.msRequestFullscreen():e.webkitRequestFullscreen&&e.webkitRequestFullScreen()}_exitFull(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen()}_full_canvas_screen(e){this._player_box.style.width=this.screenW+"px",this._player_box.style.height=this.screenH+"px";let t=this._checkScreenDisplaySize(this.screenW,this.screenH,this._media_info.w,this._media_info.h);e.style.marginTop=t[0]+"px",e.style.marginLeft=t[1]+"px",e.style.width=t[2]+"px",e.style.height=t[3]+"px",this._requestFullScreen(this._player_box)}fullScreen(){if(this.autoScreenClose=!0,this._media_info.codec,this._player_video_core,-1!==[n.CORE_TYPE_WEBCODEC_HEVC,n.CORE_TYPE_WASM_HEVC].indexOf(this._player_video_core)){let e=this._player_box.getElementsByTagName("canvas")[0];if(!e)return void console.error("fullScreen Canvas is null");this._full_canvas_screen(e)}else{let e=this._player_box.getElementsByTagName("video")[0];if(e)this._requestFullScreen(e);else{if(e=this._player_box.getElementsByTagName("canvas")[0],!e)return void console.error("fullScreen Video is null");this._full_canvas_screen(e)}}}closeFullScreen(e=!1){!1===e&&(this.autoScreenClose=!1,this._exitFull());let t=this._player_box.getElementsByTagName("canvas")[0];if(!t)return;this._player_box.style.width=this._player_width+"px",this._player_box.style.height=this._player_height+"px";let i=this._checkScreenDisplaySize(this._player_width,this._player_height,this._media_info.w,this._media_info.h);t.style.marginTop=i[0]+"px",t.style.marginLeft=i[1]+"px",t.style.width=i[2]+"px",t.style.height=i[3]+"px"}screenshot(e){const t=document.getElementById(e);if(t)if(-1!==[n.CORE_TYPE_WEBCODEC_HEVC,n.CORE_TYPE_WASM_HEVC].indexOf(this._player_video_core)){let e=this._player_box.getElementsByTagName("canvas")[0];if(!e)return void console.error("screenshot canvas is null");const i=e.toDataURL("image/png");t.src=i}else{let e=this._player_box.getElementsByTagName("video")[0];if(!e)return void console.error("screenshot Video is null");let i=document.createElement("canvas");i.width=e.videoWidth||e.width,i.height=e.videoHeight||e.height;let a=i.getContext("2d");a.drawImage(e,0,0,i.width,i.height),t.src=i.toDataURL("image/png"),i.width=1,i.height=1,i.remove(),i=null,a=null}else console.error("screenshot img is null")}next_frame(){if(-1!==[n.CORE_TYPE_WEBCODEC_HEVC,n.CORE_TYPE_WASM_HEVC].indexOf(this._player_video_core))this.render_tex();else{let e=this._player_box.getElementsByTagName("video")[0];if(!e)return void console.error("next_frame Video is null");const t=this._media_info.fps>0?this._media_info.fps:25;e.currentTime+=1/t}}resize(e,t){let i=this;if(!(e&&t&&i._media_info.w&&i._media_info.h))return console.error("resize width or height is null"),!1;const a=i._media_info.w,r=i._media_info.h;if(this._player_box.style.width=e+"px",this._player_box.style.height=t+"px",-1!==[n.CORE_TYPE_WEBCODEC_HEVC,n.CORE_TYPE_WASM_HEVC].indexOf(this._player_video_core)){let i=(e,t)=>{let i=a/e>r/t,n=(e/a).toFixed(2),s=(t/r).toFixed(2),o=i?n:s,_=parseInt(a*o,10),d=parseInt(r*o,10);return[parseInt((t-d)/2,10),parseInt((e-_)/2,10),_,d]},n=this._player_box.getElementsByTagName("canvas")[0],s=i(e,t);n.style.marginTop=s[0]+"px",n.style.marginLeft=s[1]+"px",n.style.width=s[2]+"px",n.style.height=s[3]+"px"}else{let i=this._player_box.getElementsByTagName("video")[0];i.style.width=e+"px",i.style.height=t+"px"}return!0}build(e={}){let t=this;if(!(e=r.NormalizeSDKResourceConfig(e)).wasm_js_uri||!e.wasm_wasm_uri)return console.error("wasm_js_uri or wasm_wasm_uri is null"),!1;if(this._player_id=e.player_id||"h265web.js",!this._player_id)return console.error("canvas_id is null",this._player_id),!1;if(this._wasm_js_uri=e.wasm_js_uri||null,this._wasm_wasm_uri=e.wasm_wasm_uri||null,this._ext_src_js_uri=e.ext_src_js_uri||null,this._ext_wasm_js_uri=e.ext_wasm_js_uri||null,this._base_url=e.base_url||("undefined"!=typeof window&&window.location&&window.location.href?window.location.href:null),this._player_box=document.getElementById(t._player_id)||null,!this._player_box)return console.error("box is null"),!1;this._fullscreen_listener_bound||(document.addEventListener("fullscreenchange",this._fullscreen_handler),this._fullscreen_listener_bound=!0),this._player_box.ondblclick=()=>{if(t._first_frame_render)try{t._isFullScreen()?t.closeFullScreen():t.fullScreen()}catch(e){console.error("full screen error:",e)}},this._player_color=e.color||"black",this._player_color&&(this._player_box.style.backgroundColor=this._player_color),this._player_width="string"==typeof e.width&&"100%"===e.width?t._player_box.parentElement.offsetWidth:e.width||640,this._player_height="string"==typeof e.height&&"100%"===e.height?t._player_box.parentElement.offsetHeight:e.height||360,this._player_wanted_core=e.core||null,this._player_ignore_audio=e.ignore_audio||!1,this._format_type=e.format_type||null,this._protocol_type=e.protocol||null,this._wasm_demuxer_readframe_multi_times=e.readframe_multi_times||-1,this._enable_play_button=e.enable_play_button||!1,this._enable_play_button&&(this._play_button_id=this._player_id+"_play_button"),this._play_url=e.media_uri?r.NormalizeSDKMediaUrl(e.media_uri,this._base_url):null,this._auto_play=e.auto_play||!1,this._format_type||this._play_url&&(this._format_type=r.GetUriFormat(this._play_url),this._protocol_type=r.GetUriProtocol(this._play_url)),this._init_canvas_dom(),this._player_box.style.width=this._player_width+"px",this._player_box.style.height=this._player_height+"px";const i=()=>{if(t._player_wanted_core!==n.CORE_TYPE_WEBCODEC_HEVC||t._check_is_webcodec()||(t._player_wanted_core=null),t._player_wanted_core!==n.CORE_TYPE_WASM_HEVC||t._check_is_wasm()||(t._player_wanted_core=null),t._play_url&&t._try_start_direct_media_core())return t._format_type,void t._play_url;window.YLPlayerSupport,!0===window.YLPlayerSupport.wasm_hevc?(t._init_demuxer_worker(),t._demuxer_worker.postMessage({type:"init",payload:{wasm_js_uri:t._wasm_js_uri,wasm_wasm_uri:t._wasm_wasm_uri,media_uri:t._play_url,ignore_audio:t._player_ignore_audio,format_type:t._format_type,protocol:t._protocol_type,readframe_multi_times:t._wasm_demuxer_readframe_multi_times}}),t._init_main_thread_wasm()):console.error("unsupport webassembly")};return window.YLPlayerSupport?i():n.testCheckAllSupport().then((e=>{window.YLPlayerSupport=e,i()})),!0}_init_play_button(){let e=this;this._enable_play_button&&this._player_box&&(this._play_button=document.createElement("div"),this._play_button.id=this._play_button_id,this._play_button.style.position="absolute",this._play_button.style.left="50%",this._play_button.style.top="50%",this._play_button.style.transform="translate(-50%, -50%)",this._play_button.style.width="80px",this._play_button.style.height="80px",this._play_button.style.backgroundColor="rgba(0, 0, 0, 0.7)",this._play_button.style.borderRadius="15%",this._play_button.style.cursor="pointer",this._play_button.style.transition="all 0.3s",this._play_button.onmouseover=()=>{e._play_button.style.backgroundColor="rgba(0, 0, 0, 0.9)",e._play_button.style.transform="translate(-50%, -50%) scale(1.1)"},this._play_button.onmouseout=()=>{e._play_button.style.backgroundColor="rgba(0, 0, 0, 0.7)",e._play_button.style.transform="translate(-50%, -50%)"},this._player_box.style.position="relative",this._player_box.appendChild(this._play_button),this._play_icon=document.createElement("div"),this._play_icon.style.position="absolute",this._play_icon.style.left="50%",this._play_icon.style.top="50%",this._play_icon.style.transform="translate(-40%, -50%)",this._play_icon.style.width="0",this._play_icon.style.height="0",this._play_icon.style.borderTop="20px solid transparent",this._play_icon.style.borderBottom="20px solid transparent",this._play_icon.style.borderLeft="30px solid #fff",this._play_icon.style.display="none",this._play_icon.onclick=t=>{e.play()},this._play_button.appendChild(this._play_icon),this._pause_icon=document.createElement("div"),this._pause_icon.style.position="absolute",this._pause_icon.style.left="46%",this._pause_icon.style.top="50%",this._pause_icon.style.transform="translate(-40%, -50%)",this._pause_icon.style.width="30%",this._pause_icon.style.height="50%",this._pause_icon.style.borderLeft="4px solid #e9e9e9",this._pause_icon.style.borderRight="4px solid #e9e9e9",this._pause_icon.style.display="none",this._pause_icon.onclick=t=>{e.pause()},this._play_button.appendChild(this._pause_icon),this._auto_play?(this._play_button.style.display="none",this._player_box.onmouseleave=()=>{e._play_button.style.display="none"},this._player_box.onmouseover=()=>{e._play_button.style.display="block"}):(this._play_button.style.display="block",this._play_icon.style.display="block"))}_remove_play_button(){this._play_button_id&&this._player_box&&this._play_button&&(this._player_box.removeChild(this._play_button),this._play_button=null,this._play_icon=null,this._pause_icon=null)}_init_canvas_dom(){this._canvas_id=this._player_id+"_canvas",this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.id=this._canvas_id,this._canvas.width=this._player_width,this._canvas.height=this._player_height,this._player_box.appendChild(this._canvas))}_remove_canvas_dom(){this._canvas&&this._player_box&&(this._player_box.removeChild(this._canvas),this._canvas=null)}async _init_main_thread_wasm(){let e=this;if("undefined"==typeof WebAssembly)return console.error("main thread WebAssembly is not supported"),!1;try{await new Promise((t=>{const i=document.createElement("script");i.src=e._wasm_js_uri,i.onload=()=>{t()},document.head.appendChild(i)}));const t=e._wasm_wasm_uri;if(e._wasm_main_thread_exports=await new Promise((e=>{const i=WasmModule({locateFile:e=>t,onRuntimeInitialized:()=>{e(i)}})})),!e._wasm_main_thread_exports)return console.error("main thread WebAssembly module initialized _this._wasm_main_thread_exports: False"),!1;e._wasm_main_thread_exports._main(),Object.keys(e._wasm_main_thread_exports)}catch(e){return console.error("main thread Failed to initialize WebAssembly:",e),!1}return!0}async load_past_core(e){let t=this;if("undefined"==typeof WebAssembly)return console.error("main thread WebAssembly is not supported"),!1;if(!t._ext_src_js_uri||!t._ext_wasm_js_uri)return console.error("main thread ext_src_js_uri or ext_wasm_js_uri is null"),!1;if(t._ext_h265webjs_loaded||window.STATIC_MEM_wasmDecoderState>0)return t._remove_canvas_dom(),e&&e(),!0;t._remove_canvas_dom();try{if(window)window.addEventListener("h265webjsWasmLoaded",(function(i){window.STATIC_MEM_wasmDecoderState=1,t._ext_h265webjs_loaded=!0,e&&e()}));else{if(!i)return console.error("main thread window or global is not defined"),!1;i.h265webjsWasmLoaded=()=>{event,i.STATIC_MEM_wasmDecoderState=1,t._ext_h265webjs_loaded=!0,e&&e()}}await new Promise((e=>{const i=document.createElement("script");i.src=t._ext_src_js_uri,i.onload=()=>{e()},document.head.appendChild(i)})),await new Promise((e=>{const i=document.createElement("script");i.src=t._ext_wasm_js_uri,i.onload=()=>{e()},document.head.appendChild(i)}))}catch(e){return console.error("main thread Failed to initialize WebAssembly:",e),!1}}change_media(e){let t=this;if(!(e=r.NormalizeSDKMediaUrl(e,this._base_url)))return console.error("media_uri is null"),!1;this._play_url=null;const i={player_id:t._player_id,base_url:t._base_url,wasm_js_uri:t._wasm_js_uri,wasm_wasm_uri:t._wasm_wasm_uri,ext_src_js_uri:t._ext_src_js_uri,ext_wasm_js_uri:t._ext_wasm_js_uri,width:t._player_width,height:t._player_height,color:t._player_color,media_uri:null,core:t._player_wanted_core,ignore_audio:t._player_ignore_audio,format_type:t._format_type,protocol:t._protocol_type};return this.release((()=>{if(!t.build(i))return console.error("build failed"),!1;t.load_media(e)})),!0}rebuild(e=!1){let t=this;const i={player_id:t._player_id,base_url:t._base_url,wasm_js_uri:t._wasm_js_uri,wasm_wasm_uri:t._wasm_wasm_uri,ext_src_js_uri:t._ext_src_js_uri,ext_wasm_js_uri:t._ext_wasm_js_uri,width:t._player_width,height:t._player_height,color:t._player_color,media_uri:e?t._play_url:null,core:t._player_wanted_core,ignore_audio:t._player_ignore_audio,format_type:t._format_type,protocol:t._protocol_type,readframe_multi_times:t._wasm_demuxer_readframe_multi_times};return this.release((()=>{if(!t.build(i))return console.error("build failed"),!1})),!0}_release_demuxer(e){let t=this;this._wait_init_interval&&(clearInterval(this._wait_init_interval),this._wait_init_interval=null,this._on_inited=!1),this._demuxer_worker&&(this._demuxer_worker.onmessage=function(i){if("release_done"===i.data.type)t._demuxer_worker.terminate(),t._demuxer_worker=null,null===t._decoder_worker&&e&&e()},this._demuxer_worker.postMessage({type:"release"}))}release(e=null){let t=this;this.pause(),this._remove_play_button(),this._audio_resume_allowed=!1,this._live_http_flv_audio_realign_pending=!1,this._decoder_seek_pending=!1,this._fullscreen_listener_bound&&(document.removeEventListener("fullscreenchange",this._fullscreen_handler),this._fullscreen_listener_bound=!1),this._player_box&&(this._player_box.ondblclick=null,this._player_box.onmouseover=null,this._player_box.onmouseleave=null),this._demuxer_worker,this._release_demuxer(e),this._decoder_worker,this._decoder_worker&&(this._decoder_worker.onmessage=function(i){if("release_done"===i.data.type)t._decoder_worker.terminate(),t._decoder_worker=null,null===t._demuxer_worker&&e&&e()},this._decoder_worker.postMessage({type:"release"})),this._workerFetch,void 0!==this._workerFetch&&null!==this._workerFetch&&(this._workerFetch.postMessage({cmd:"stop",params:"",type:this.mediaExtProtocol}),this._workerFetch.onmessage=null),this._workerParse,void 0!==this._workerParse&&null!==this._workerParse&&(this._workerParse.postMessage({cmd:"stop",params:""}),this._workerParse.onmessage=null),this._workerFetch=null,this._workerParse=null,this._audioAACCtx,this._audioAACCtx&&(this._audioAACCtx.pause(),this._audioAACCtx.stop(),this._audioAACCtx=null),this._audioWAVCtx,this._ext_h265webjs_core&&(this._ext_h265webjs_core.release(),this._ext_h265webjs_core=null,e&&e()),this._native_core,this._native_core&&(this._native_core.release(),this._native_core=null,e&&e()),this._canvas,this._remove_canvas_dom(),this._player_box=null,this._first_frame_render=!1,this._player_video_core=null,this._expect_play=!1,this._media_info={needSwr:0,duration:-1,demuxer_media_type:n.PLAYER_MODE_VOD,w:-1,h:-1,fps:-1,audioIndex:-1,sampleRate:-1,channel:-1,codec:-1,fmt:"",extra_data:null,extra_size:0},this._player_vlast_dts=-1,this._player_alast_dts=-1,this._player_playbackRate=1,this._player_voice=1,setTimeout((()=>{t.on_release_done_callback&&t.on_release_done_callback()}),500)}gpu_memory_info(){if(!this._decoder_worker)return console.error("gpu_memory_info _decoder_worker is null"),!1;this._decoder_worker.postMessage({type:"gpu_memory_info"})}_makeNativePlayer(){let e=this;e._remove_canvas_dom(),this._native_core=new c.Mp4Player({width:e._player_width,height:e._player_height,fixed:!1,playerId:e._player_id,audioNone:e._player_ignore_audio,autoPlay:e._auto_play}),this._native_core.makeIt(this._play_url),this._native_core.onPlayingTime=t=>{e._video_render_pts=1e3*t,e.on_play_time&&e.on_play_time(t)},this._native_core.onPlayingFinish=()=>{e.pause(),e.on_play_finished&&e.on_play_finished()},this._native_core.onLoadFinish=()=>{e._media_info.duration=1e3*e._native_core.duration;const t=e._native_core.getSize();e._media_info.w=t.width,e._media_info.h=t.height,e._media_info.demuxer_media_type=n.PLAYER_MODE_VOD,e.video_probe_callback&&e.video_probe_callback(e._media_info),e._first_frame_render=!0,e.on_ready_show_done_callback&&e.on_ready_show_done_callback(),e._init_play_button()},this._native_core.onPlayState=e=>{this._enable_play_button&&(this._play_button&&this._play_icon&&this._pause_icon?e?(this._play_icon.style.display="none",this._pause_icon.style.display="block"):(this._play_icon.style.display="block",this._pause_icon.style.display="none"):this._remove_play_button())},this._native_core.onCacheProcess=t=>{e.on_cache_process_callback&&e.on_cache_process_callback(t)},this._native_core.onSeekStart=t=>{e.on_seek_start_callback&&e.on_seek_start_callback(t)},this._native_core.onSeekFinish=t=>{e.on_seek_done_callback&&e.on_seek_done_callback(t),e._expect_play&&e._native_core.play()}}_flvJsPlayer(e=-1,t=!1){let i=this;i._remove_canvas_dom();let a={width:i._player_width,height:i._player_height,playerId:i._player_id,ignoreAudio:i._player_ignore_audio?1:0,duration:e,autoPlay:i._auto_play,audioNone:i._player_ignore_audio?1:0};this._native_core=new h.NvFlvjsCore(a),this._native_core.onLoadFinish=()=>{!i._native_core.duration||NaN===i._native_core.duration||i._native_core.duration===1/0||i._native_core.duration<0?(i._media_info.duration=-1,i._media_info.demuxer_media_type=n.PLAYER_MODE_NOTIME_LIVE):(i._media_info.duration=1e3*i._native_core.duration,i._media_info.demuxer_media_type=n.PLAYER_MODE_VOD);const e=i._native_core.getSize();i._media_info.w=e.width,i._media_info.h=e.height,i.video_probe_callback&&i.video_probe_callback(i._media_info)},this._native_core.onReadyShowDone=()=>{i._first_frame_render=!0,i.on_ready_show_done_callback&&i.on_ready_show_done_callback(),i._init_play_button()},this._native_core.onPlayingTime=e=>{i._video_render_pts=1e3*e,i.on_play_time&&i.on_play_time(e)},this._native_core.onPlayingFinish=()=>{i.pause(),i.on_play_finished&&i.on_play_finished()},this._native_core.onPlayState=e=>{this._enable_play_button&&(this._play_button&&this._play_icon&&this._pause_icon?e?(this._play_icon.style.display="none",this._pause_icon.style.display="block"):(this._play_icon.style.display="block",this._pause_icon.style.display="none"):this._remove_play_button())},this._native_core.onCacheProcess=e=>{i.on_cache_process_callback&&i.on_cache_process_callback(e)},this._native_core.onSeekStart=e=>{i.on_seek_start_callback&&i.on_seek_start_callback(e)},this._native_core.onSeekFinish=e=>{i.on_seek_done_callback&&i.on_seek_done_callback(e),i._expect_play&&i._native_core.play()},this._native_core.makeIt(this._play_url)}_mpegTsJsPlayer(t=-1){let i=this;const a=e("./native/nv-mpegts-core");i._remove_canvas_dom();let r={width:i._player_width,height:i._player_height,playerId:i._player_id,ignoreAudio:i._player_ignore_audio?1:0,duration:t,autoPlay:i._auto_play,audioNone:i._player_ignore_audio?1:0};this._native_core=new a.NvMpegTsCore(r),this._native_core.onLoadFinish=()=>{!i._native_core.duration||NaN===i._native_core.duration||i._native_core.duration===1/0||i._native_core.duration<0?(i._media_info.duration=-1,i._media_info.demuxer_media_type=n.PLAYER_MODE_NOTIME_LIVE):(i._media_info.duration=1e3*i._native_core.duration,i._media_info.demuxer_media_type=n.PLAYER_MODE_VOD);const e=i._native_core.getSize();i._media_info.w=e.width,i._media_info.h=e.height,i.video_probe_callback&&i.video_probe_callback(i._media_info)},this._native_core.onReadyShowDone=()=>{i._first_frame_render=!0,i.on_ready_show_done_callback&&i.on_ready_show_done_callback(),i._init_play_button()},this._native_core.onPlayingTime=e=>{i._video_render_pts=1e3*e,i.on_play_time&&i.on_play_time(e)},this._native_core.onPlayingFinish=()=>{i.pause(),i.on_play_finished&&i.on_play_finished()},this._native_core.onPlayState=e=>{this._enable_play_button&&(this._play_button&&this._play_icon&&this._pause_icon?e?(this._play_icon.style.display="none",this._pause_icon.style.display="block"):(this._play_icon.style.display="block",this._pause_icon.style.display="none"):this._remove_play_button())},this._native_core.onCacheProcess=e=>{i.on_cache_process_callback&&i.on_cache_process_callback(e)},this._native_core.onSeekStart=e=>{i.on_seek_start_callback&&i.on_seek_start_callback(e)},this._native_core.onSeekFinish=e=>{i.on_seek_done_callback&&i.on_seek_done_callback(e),i._expect_play&&i._native_core.play()},this._native_core.makeIt(this._play_url)}_check_already_load_media(){if(!this._player_box){if(!document.getElementById(this._player_id))return console.error("player_box is null"),!1;this._player_box=document.getElementById(this._player_id)}if(-1!==[n.CORE_TYPE_WEBCODEC_HEVC,n.CORE_TYPE_WASM_HEVC].indexOf(this._player_video_core)){return!!this._player_box.getElementsByTagName("canvas")[0]&&this._first_frame_render}return!!this._player_box.getElementsByTagName("video")[0]}_is_native_mse_core(){return-1!==[n.CORE_TYPE_MSE_MP4,n.CORE_TYPE_MSE_FLVJS,n.CORE_TYPE_MSE_MPEGTS].indexOf(this._player_video_core)}_get_mpegts_module(){if("undefined"!=typeof window&&window.mpegts)return window.mpegts;try{return e("mpegts.js")}catch(e){return console.error("load mpegts.js failed",e),null}}_try_start_direct_media_core(){let e=this;return-1===["flv"].indexOf(e._format_type)||e._check_is_webcodec()||e._check_is_wasm()?-1!==["mp4"].indexOf(e._format_type)&&e._check_is_mse()?(setTimeout((()=>{e._release_demuxer(),e._player_video_core=n.CORE_TYPE_MSE_MP4,e._makeNativePlayer()}),500),!0):-1!==["m3u8","hls"].indexOf(e._format_type)&&(setTimeout((()=>{e._release_demuxer(),e._player_video_core=n.CORE_TYPE_EXT_H265WEB,e.load_past_core((()=>{e.do_ext_h265web_media()}))}),500),!0):(setTimeout((()=>{e._release_demuxer(),e._player_video_core=n.CORE_TYPE_MSE_FLVJS,e._flvJsPlayer()}),500),!0)}load_media(e){let t=this;if(!(e=r.NormalizeSDKMediaUrl(e,this._base_url)))return console.error("media_uri is null"),!1;if(this._check_already_load_media())return console.error("load_media already load media, release first"),this.change_media(e),!0;this._play_url=e,this._format_type||this._play_url&&(this._format_type=r.GetUriFormat(this._play_url),this._protocol_type=r.GetUriProtocol(this._play_url)),this._format_type,this._protocol_type;const i=function(){if(t._try_start_direct_media_core())return!0;-1!==["raw265"].indexOf(t._format_type)?(t._player_wanted_core=n.CORE_TYPE_WASM_HEVC,t._player_ignore_audio=!0,t._format_type,t._protocol_type,t._player_wanted_core,t._demuxer_worker||(console.error("demux _demuxer_worker is null"),t._init_demuxer_worker()),t._demuxer_worker.postMessage({type:"loadMedia",payload:{media_uri:e,format_type:t._format_type,protocol:t._protocol_type}})):(t._demuxer_worker||(console.error("demux _demuxer_worker is null"),t._init_demuxer_worker()),t._demuxer_worker.postMessage({type:"loadMedia",payload:{media_uri:e,format_type:t._format_type,protocol:t._protocol_type}}))};if(t._on_inited)i();else{let e=0;t._wait_init_interval=setInterval((()=>t._on_inited?(i(),clearInterval(t._wait_init_interval),void(t._wait_init_interval=null)):(e+=1,e>1500?(console.error("wait init WebAssembly interval timeout"),clearInterval(t._wait_init_interval),void(t._wait_init_interval=null)):void 0)),200)}return!0}do_ext_h265web_media(){let e=this;const t={player:e._player_id,width:e._player_width,height:e._player_height,token:"base64:QXV0aG9yOmNoYW5neWFubG9uZ3xudW1iZXJ3b2xmLEdpdGh1YjpodHRwczovL2dpdGh1Yi5jb20vbnVtYmVyd29sZixFbWFpbDpwb3JzY2hlZ3QyM0Bmb3htYWlsLmNvbSxRUTo1MzEzNjU4NzIsSG9tZVBhZ2U6aHR0cDovL3h2aWRlby52aWRlbyxEaXNjb3JkOm51bWJlcndvbGYjODY5NCx3ZWNoYXI6bnVtYmVyd29sZjExLEJlaWppbmcsV29ya0luOkJhaWR1",extInfo:{probeSize:8192,ignoreAudio:e._player_ignore_audio?1:0,coreProbePart:.1,autoPlay:e._auto_play,cacheLength:50,rawFps:24}};e._ext_h265webjs_core&&(e._ext_h265webjs_core.release(),e._ext_h265webjs_core=null),e._ext_h265webjs_core=window.new265webjs(e._play_url,t),e._ext_h265webjs_core.onSeekStart=t=>{e.on_seek_start_callback&&e.on_seek_start_callback(t)},e._ext_h265webjs_core.onSeekFinish=()=>{e.on_seek_done_callback&&e.on_seek_done_callback()},e._ext_h265webjs_core.onPlayFinish=()=>{e.on_play_finished&&e.on_play_finished()},e._ext_h265webjs_core.on_open_fullscreen=()=>{},e._ext_h265webjs_core.on_close_fullscreen=()=>{},e._ext_h265webjs_core.onLoadCache=()=>{e.on_load_caching_callback&&e.on_load_caching_callback()},e._ext_h265webjs_core.onLoadCacheFinshed=()=>{e.on_finish_cache_callback&&e.on_finish_cache_callback()},e._ext_h265webjs_core.onReadyShowDone=()=>{e._first_frame_render=!0,e.on_ready_show_done_callback&&e.on_ready_show_done_callback(),e._init_play_button()},e._ext_h265webjs_core.onLoadFinish=()=>{e._ext_h265webjs_core.setVoice(1);const t=e._ext_h265webjs_core.mediaInfo();let i=a.V_CODEC_NAME_HEVC;!1===t.meta.isHEVC&&(i=a.V_CODEC_NAME_AVC),e._media_info.codec=i,e._media_info.fps=t.meta.fps||-1,e._media_info.w=t.meta.size.width||-1,e._media_info.h=t.meta.size.height||-1,e._media_info.sampleRate=t.meta.sampleRate||-1,e._format_type||e._play_url&&(e._format_type=r.GetUriFormat(e._play_url),e._protocol_type=r.GetUriProtocol(e._play_url)),e._media_info.media_fmt=e._format_type,e._media_info.duration=t.meta.durationMs/1e3||-1,"vod"==t.videoType?e._media_info.demuxer_media_type=n.PLAYER_MODE_VOD:e._media_info.demuxer_media_type=n.PLAYER_MODE_LIVE,e._media_info,e.video_probe_callback&&e.video_probe_callback(e._media_info)},e._ext_h265webjs_core.onCacheProcess=t=>{e.on_cache_process&&e.on_cache_process(t)},e._ext_h265webjs_core.onPlayTime=t=>{e.on_play_time&&e.on_play_time(t)},e._ext_h265webjs_core.do()}cache_demux(e=1,t=1){if(-1!==["raw265"].indexOf(this._format_type));else{if(!this._demuxer_worker)return!1;this._demuxer_worker.postMessage({type:"demux",payload:{recv_v_count:e,recv_a_count:t}})}return!0}get_nalu_len(){if(!this._decoder_worker)return console.error("get_tex_len _decoder_worker is null"),!1;this._decoder_worker.postMessage({type:"get_nalu_len"})}get_tex_len(){if(!this._decoder_worker)return console.error("get_tex_len _decoder_worker is null"),!1;this._decoder_worker.postMessage({type:"get_tex_len"})}render_tex(){this._player_video_core,this._player_video_core===n.CORE_TYPE_WEBCODEC_HEVC?this._decoder_worker&&this._decoder_worker.postMessage({type:"render_tex"}):this._player_video_core===n.CORE_TYPE_WASM_HEVC?this._opengl_render&&this._opengl_render.render_yuv420p_texture():this._decoder_worker&&this._decoder_worker.postMessage({type:"render_tex"})}audio_play(){return!!this._player_ignore_audio||(this._audioAACCtx?(this._audioAACCtx.resumeAudioContext&&this._audioAACCtx.resumeAudioContext("ylplayer.audio_play"),this._audioAACCtx.play(),!0):(console.error("audio ctx is null"),!1))}notify_user_gesture(){return this._audio_resume_allowed=!0,this._player_ignore_audio||!this._audioAACCtx||this._audioAACCtx.resumeAudioContext&&this._audioAACCtx.resumeAudioContext("ylplayer.notify_user_gesture"),!0}audio_pause(){return!!this._player_ignore_audio||(this._audioAACCtx?(this._audioAACCtx.pause(),!0):(console.error("audio ctx is null"),!1))}get_audio_pts(){return this._player_ignore_audio?-1:this._audioAACCtx?{pts:this._audioAACCtx.getTimestamp(),duration:this._audioAACCtx.getTimestampDurMs()}:(console.error("get_audio_pts _audioAACCtx is null"),-2)}set_mute(){this.set_voice(0)}set_voice(e=1){if(this._player_voice=e,!this._is_native_mse_core())return this._player_video_core===n.CORE_TYPE_EXT_H265WEB?(this._ext_h265webjs_core&&this._ext_h265webjs_core.setVoice(e),0):void(this._player_video_core===n.CORE_TYPE_WASM_HEVC||this._player_video_core===n.CORE_TYPE_WEBCODEC_HEVC?this._audioAACCtx&&this._audioAACCtx.setVoice(e):(this._player_video_core,n.CORE_TYPE_MSE_HEVC));this._native_core&&this._native_core.setVoice(e)}set_playback_rate(e=1){if(this._player_playbackRate=e,this._is_native_mse_core())this._native_core&&this._native_core.setPlaybackRate(e);else{if(this._player_video_core===n.CORE_TYPE_EXT_H265WEB)return this._ext_h265webjs_core&&this._ext_h265webjs_core.setPlaybackRate(e),0;this._player_video_core===n.CORE_TYPE_WEBCODEC_HEVC?this._decoder_worker&&this._decoder_worker.postMessage({type:"set_playback_rate",payload:{playback_rate:e}}):this._player_video_core===n.CORE_TYPE_WASM_HEVC?this._opengl_render&&this._opengl_render.set_playback_rate(e):this._player_video_core===n.CORE_TYPE_MSE_HEVC||this._decoder_worker&&this._decoder_worker.postMessage({type:"set_playback_rate",payload:{playback_rate:e}}),this._audioAACCtx&&this._audioAACCtx.setPlaybackRate(this._player_playbackRate)}}play(e=!0){let t=this;if(this.chase_frame_count=0,this._expect_play=e,this._clear_cache_pause_timer(),this._enable_play_button&&(this._play_button&&this._play_icon&&this._pause_icon?(this._play_icon.style.display="none",this._pause_icon.style.display="block",this._player_box.onmouseleave=()=>{t._play_button.style.display="none"},this._player_box.onmouseover=()=>{t._play_button.style.display="block"}):this._remove_play_button()),this._is_native_mse_core())return void(this._video_render_pts>=this._media_info.duration-100?this._native_core&&this._native_core.seek(0):this._native_core&&this._native_core.play());if(this._player_video_core===n.CORE_TYPE_EXT_H265WEB)return void(this._ext_h265webjs_core&&this._ext_h265webjs_core.play());if(t._media_info.demuxer_media_type==n.PLAYER_MODE_VOD&&t._player_vlast_dts>0&&t._player_vlast_dts<=t._video_render_pts)return t._player_vlast_dts,t._video_render_pts,t._video_render_pts=0,void t.seek(0);const i=Number(t._media_info.fps),a=Number.isFinite(i)&&i>0&&i<=240?i:30,r=Math.max(1,Math.floor(1e3/a));if(this._audioAACCtx&&(this._is_live_http_flv()?this._consume_live_http_flv_audio_realign(this._video_render_pts,"play"):this._audioAACCtx.check_with_video_pts_ms(this._video_render_pts)),t._player_video_core===n.CORE_TYPE_WEBCODEC_HEVC){if(this._webcodec_render_running)return void this.audio_play();this.audio_play(),this._decoder_worker&&this._decoder_worker.postMessage({type:"render_play",payload:{fps:a,frame_duraiton:r}}),this._webcodec_render_running=!0}else if(this._player_video_core===n.CORE_TYPE_WASM_HEVC){if(this._opengl_render.is_playing())return;this.audio_play(),this._opengl_render&&this._opengl_render.render_play(a,r,t._player_ignore_audio)}else this._player_video_core===n.CORE_TYPE_MSE_HEVC||(this.audio_play(),this._decoder_worker&&this._decoder_worker.postMessage({type:"render_play",payload:{fps:a,frame_duraiton:r}}))}pause(){this._clear_cache_pause_timer(),this._expect_play=!1,this._is_live_http_flv()&&(this._live_http_flv_audio_realign_pending=!0),this._enable_play_button&&(this._play_button&&this._play_icon&&this._pause_icon?(this._play_button.style.display="block",this._play_icon.style.display="block",this._pause_icon.style.display="none",this._player_box.onmouseleave=()=>{},this._player_box.onmouseover=()=>{}):this._remove_play_button()),this._is_native_mse_core()?this._native_core&&this._native_core.pause():this._player_video_core!==n.CORE_TYPE_EXT_H265WEB?this.av_pause():this._ext_h265webjs_core&&this._ext_h265webjs_core.pause()}seek(e=-1){return this._media_info.demuxer_media_type===n.PLAYER_MODE_NOTIME_LIVE?(console.error("ylplayer seek live media type not support"),-1):e<0?-1:this._is_native_mse_core()?(this._native_core,this._native_core&&this._native_core.seek(e),0):this._player_video_core===n.CORE_TYPE_EXT_H265WEB?(this._ext_h265webjs_core&&this._ext_h265webjs_core.seek(e),0):(this.on_seek_start_callback&&this.on_seek_start_callback(e),this.av_pause(),this._clear_cache_pause_timer(),this.stop_and_clean_cache(),this._mark_decoder_seek_pending("seek"),this._demuxer_worker.postMessage({type:"seek_demux",payload:{seekTime:e}}),0)}stop_and_clean_cache(){this._demuxer_worker?(this._demuxer_worker.postMessage({type:"stop_cache_pkt_to_decoder"}),this._audioAACCtx&&this._audioAACCtx.cleanQueue(),this._player_video_core===n.CORE_TYPE_WEBCODEC_HEVC?this._decoder_worker&&this._decoder_worker.postMessage({type:"clean_cache_queue"}):this._player_video_core===n.CORE_TYPE_WASM_HEVC?(this._decoder_worker&&this._decoder_worker.postMessage({type:"clean_cache_queue"}),this._decoder_worker&&this._decoder_worker.postMessage({type:"set_cache_size",payload:{cache_size:0}}),this._opengl_render&&this._opengl_render.clean_cache_queue()):(this._player_video_core,n.CORE_TYPE_MSE_HEVC)):console.error("stop_and_clean_cache _demuxer_worker is null")}av_pause(){if(this.audio_pause(),this._player_video_core===n.CORE_TYPE_WEBCODEC_HEVC){if(!this._decoder_worker)return console.error("render decoder_worker is null"),!1;this._webcodec_render_running=!1,this._decoder_worker.postMessage({type:"render_pause"})}else this._player_video_core===n.CORE_TYPE_WASM_HEVC?this._opengl_render&&this._opengl_render.render_pause():(this._player_video_core,n.CORE_TYPE_MSE_HEVC)}_clear_cache_pause_timer(){this._cache_pause_timer&&(clearTimeout(this._cache_pause_timer),this._cache_pause_timer=null)}_should_skip_cache_pause(e="cache_empty"){const t=String(this._protocol_type||"").toLowerCase(),i=String(this._media_info&&this._media_info.media_fmt||this._format_type||"").toLowerCase(),a=this._media_info&&this._media_info.demuxer_media_type===n.PLAYER_MODE_NOTIME_LIVE;return"webcodec_on_load_cache"===e&&this._player_video_core===n.CORE_TYPE_WEBCODEC_HEVC&&a&&"flv"===i&&-1!==["ws","wss","websocket"].indexOf(t)}_is_live_http_flv(){const e=String(this._protocol_type||"").toLowerCase(),t=String(this._media_info&&this._media_info.media_fmt||this._format_type||"").toLowerCase();return this._media_info&&this._media_info.demuxer_media_type===n.PLAYER_MODE_NOTIME_LIVE&&"flv"===t&&-1!==["http","https"].indexOf(e)}_mark_live_http_flv_audio_realign_pending(e="play"){return!!this._is_live_http_flv()&&(this._live_http_flv_audio_realign_pending=!0,this._video_render_pts,!0)}_consume_live_http_flv_audio_realign(e=-1,t="play"){return!!(this._is_live_http_flv()&&this._live_http_flv_audio_realign_pending&&this._audioAACCtx&&this._audioAACCtx.align_start_with_video_pts_ms)&&(!(!Number.isFinite(e)||e<0)&&(this._audioAACCtx.align_start_with_video_pts_ms(e,180,4),this._live_http_flv_audio_realign_pending=!1,!0))}_is_vod_flv_webcodec(){const e=String(this._media_info&&this._media_info.media_fmt||this._format_type||"").toLowerCase();return this._player_video_core===n.CORE_TYPE_WEBCODEC_HEVC&&this._media_info&&this._media_info.demuxer_media_type===n.PLAYER_MODE_VOD&&"flv"===e}_supports_decoder_seek_guard(){return this._player_video_core===n.CORE_TYPE_WEBCODEC_HEVC||this._player_video_core===n.CORE_TYPE_WASM_HEVC}_mark_decoder_seek_pending(e="seek"){return!!this._supports_decoder_seek_guard()&&(!(!this._media_info||this._media_info.demuxer_media_type!==n.PLAYER_MODE_VOD)&&(this._decoder_seek_pending=!0,this._video_render_pts,!0))}_clear_decoder_seek_pending(e="seek_success_target"){return!!this._decoder_seek_pending&&(this._decoder_seek_pending=!1,this._video_render_pts,!0)}_should_hold_seek_finish_cache_play(e="on_finish_cache"){return!!this._supports_decoder_seek_guard()&&(!!this._decoder_seek_pending&&(this._video_render_pts,!0))}_schedule_cache_pause(e="cache_empty"){if(this._clear_cache_pause_timer(),!this._expect_play)return;if(this._decoder_seek_pending&&this._media_info&&this._media_info.demuxer_media_type===n.PLAYER_MODE_VOD&&-1!==["webcodec_on_load_cache","ffdecoder_on_load_cache"].indexOf(e))return void this._video_render_pts;if(this._should_skip_cache_pause(e))return void this._video_render_pts;let t=300;this._media_info&&this._media_info.demuxer_media_type===n.PLAYER_MODE_NOTIME_LIVE&&(t=900),this._cache_pause_timer=setTimeout((()=>{this._cache_pause_timer=null,this._expect_play&&(this._video_render_pts,this.av_pause())}),t)}_init_audio_aac_ctx(e=44100,t=a.APPEND_TYPE_FRAME){let i=this;if(i._player_ignore_audio)return!1;if(this._audioAACCtx)return!1;if(i._media_info,i._media_info.needSwr)i._audioAACCtx=o(),i._audioAACCtx.isLIVE=!0;else{const a={sampleRate:e<=0?44100:e,appendType:t};i._audioAACCtx=new s({...a}),i._audioAACCtx.isLIVE=!0,i._audioAACCtx.build()}return i._audioAACCtx.setVoice&&i._audioAACCtx.setVoice(i._player_voice),i._audio_resume_allowed&&!i._player_ignore_audio&&i._audioAACCtx.resumeAudioContext&&i._audioAACCtx.resumeAudioContext("ylplayer.init_audio_aac_ctx"),this._audioAACCtx,i._audioAACCtx.onPlayCallback=function(e){const t=1e3*e;i.audio_render_callback&&i.audio_render_callback(t),i._player_video_core===n.CORE_TYPE_WEBCODEC_HEVC?i._decoder_worker.postMessage({type:"audio_play_info",payload:{pts:t,duration:i._audioAACCtx.getTimestampDurMs()}}):i._player_video_core===n.CORE_TYPE_WASM_HEVC?i._opengl_render&&i._opengl_render.audio_play_info(t,i._audioAACCtx.getTimestampDurMs()):(i._player_video_core,n.CORE_TYPE_MSE_HEVC)},!0}_checkScreenDisplayAspectSize(e,t,i,a){let r=i/e>a/t,n=(e/i).toFixed(2),s=(t/a).toFixed(2),o=r?n:s,_=this.fixed?e:parseInt(i*o),d=this.fixed?t:parseInt(a*o);return[parseInt((t-d)/2),parseInt((e-_)/2),_,d]}_auto_adaptive_screen(e,t,i,a){let r=this;r._canvas||(console.error("_auto_adaptive_screen _canvas is null"),this._init_canvas_dom()),r._canvas.width=i,r._canvas.height=a;let n=this._checkScreenDisplayAspectSize(e,t,i,a);return r._canvas.style.marginTop=n[0]+"px",r._canvas.style.marginLeft=n[1]+"px",r._canvas.style.width=n[2]+"px",r._canvas.style.height=n[3]+"px",!0}_get_decoder_init_size(){return{width:this._media_info&&this._media_info.w>0?this._media_info.w:this._player_width>0?this._player_width:a.DEFAULT_WIDTH,height:this._media_info&&this._media_info.h>0?this._media_info.h:this._player_height>0?this._player_height:a.DEFAULT_HEIGHT}}_apply_decoded_video_size(e,t){if(!e||!t||e<=0||t<=0)return;this._media_info||(this._media_info={});const i=this._media_info.w!==e||this._media_info.h!==t;if(this._media_info.w=e,this._media_info.h=t,i&&(this._auto_adaptive_screen(this._player_width,this._player_height,e,t),this._player_video_core===n.CORE_TYPE_WASM_HEVC&&this._opengl_render)){const i=this._opengl_render.change_viewport(e,t);0!==i&&console.error("ylplayer change wasm viewport failed",i,e,t)}}_check_is_mse(){let e=this;return!e._player_wanted_core&&!0===window.YLPlayerSupport.mse_hevc||null===window.YLPlayerSupport.mse_hevc||e._player_wanted_core&&e._player_wanted_core===n.CORE_TYPE_MSE_HEVC}_check_is_native_mse(e=!1){const t=this._get_mpegts_module();if(!t||"function"!=typeof t.getFeatureList)return!1;const i=t.getFeatureList();if(!i||!i.msePlayback)return!1;return(!(this._media_info&&this._media_info.demuxer_media_type===n.PLAYER_MODE_NOTIME_LIVE)||!1!==i.mseLivePlayback)&&(!e||!1!==i.networkStreamIO)}_check_is_wasm(){let e=this;return!1!==window.YLPlayerSupport.wasm_hevc&&(!e._player_wanted_core&&!0===window.YLPlayerSupport.wasm_hevc||null===window.YLPlayerSupport.wasm_hevc||e._player_wanted_core&&e._player_wanted_core===n.CORE_TYPE_WASM_HEVC)}_check_is_webcodec(){let e=this;return!1!==window.YLPlayerSupport.webcodec_hevc&&(!e._player_wanted_core&&!0===window.YLPlayerSupport.webcodec_hevc||null===window.YLPlayerSupport.webcodec_hevc||e._player_wanted_core&&e._player_wanted_core===n.CORE_TYPE_WEBCODEC_HEVC)}_should_force_wasm_for_hevc_ts(e=""){const t=(e||this._format_type||"").toLowerCase();return this._media_info.codec===a.V_CODEC_NAME_HEVC&&(-1!==["ts","mpegts"].indexOf(t)&&this._check_is_wasm())}_init_demuxer_worker(){let e=this;if(this._demuxer_worker)return;this._demuxer_worker=_();let t=0,i=0;this._player_vlast_dts=-1,this._player_alast_dts=-1,this._demuxer_worker.onmessage=function(r){switch(r.data.type){case"ready":e._on_inited=!0;break;case"reload_page":location.reload();break;case"alert_page":r.data.payload;break;case"demuxer_probe_cb":r.data.payload,e._player_wanted_core,e._media_info=r.data.payload;const s=Number(e._media_info.fps);!Number.isFinite(s)||s<=0||s>240?e._media_info.fps=25:e._media_info.fps=s;const o=Number(e._media_info.duration);!Number.isFinite(o)||o<0?e._media_info.duration=0:e._media_info.duration=o;const _=(r.data.payload.media_fmt||e._format_type||"").toLowerCase();if(_&&(e._format_type=_),e._media_info.codec==a.V_CODEC_NAME_AVC){if(console.error("unsupport codec 264, to mse"),-1!==["flv"].indexOf(_))return e._release_demuxer(),e._player_video_core=n.CORE_TYPE_MSE_FLVJS,e._flvJsPlayer(),!0;if(-1!==["mp4"].indexOf(_)&&e._check_is_native_mse())return e._release_demuxer(),e._player_video_core=n.CORE_TYPE_MSE_MP4,e._makeNativePlayer(),!0;if(-1!==["ts","mpegts"].indexOf(_)){const t=-1!==[a.URI_PROTOCOL_HTTP_DESC,a.URI_PROTOCOL_WEBSOCKET_DESC].indexOf(e._protocol_type);if(e._check_is_native_mse(t))return e._release_demuxer(),e._player_video_core=n.CORE_TYPE_MSE_MPEGTS,e._mpegTsJsPlayer(),!0;console.error("unsupport avc ts/mpegts playback on current browser")}return}const d=r.data.payload.sampleRate;if(d<=0||""==e._media_info.fmt||r.data.payload.channel<=0?e._player_ignore_audio=!0:e._init_audio_aac_ctx(d,a.APPEND_TYPE_FRAME),e._media_info.w>0&&e._media_info.h>0&&e._auto_adaptive_screen(e._player_width,e._player_height,e._media_info.w,e._media_info.h),e._should_force_wasm_for_hevc_ts(_))e._player_video_core=n.CORE_TYPE_WASM_HEVC,e._player_wanted_core=n.CORE_TYPE_WASM_HEVC,e._init_ffdecoder_worker(),e._decoder_worker.postMessage({type:"init",payload:{wasm_js_uri:e._wasm_js_uri,wasm_wasm_uri:e._wasm_wasm_uri,ignore_audio:e._player_ignore_audio}}),e.video_probe_callback&&e.video_probe_callback(r.data.payload),e._decoder_worker.postMessage({type:"probe_ok",payload:r.data.payload});else if(e._check_is_webcodec())e._player_video_core=n.CORE_TYPE_WEBCODEC_HEVC,e._init_decoder_worker(),e._decoder_worker.postMessage({type:"init",payload:{wasm_js_uri:e._wasm_js_uri,wasm_wasm_uri:e._wasm_wasm_uri,ignore_audio:e._player_ignore_audio}}),e.video_probe_callback&&e.video_probe_callback(r.data.payload),e._decoder_worker.postMessage({type:"probe_ok",payload:r.data.payload});else if(e._check_is_wasm())e._player_video_core=n.CORE_TYPE_WASM_HEVC,e._init_ffdecoder_worker(),e._decoder_worker.postMessage({type:"init",payload:{wasm_js_uri:e._wasm_js_uri,wasm_wasm_uri:e._wasm_wasm_uri,ignore_audio:e._player_ignore_audio}}),e.video_probe_callback&&e.video_probe_callback(r.data.payload),-1!==["raw265"].indexOf(e._format_type)?(e._raw265Entry(),e._release_demuxer()):e._decoder_worker.postMessage({type:"probe_ok",payload:r.data.payload});else{if(!e._check_is_mse())return void console.error("the media can not support play",r.data.payload);e._player_video_core=n.CORE_TYPE_MSE_HEVC}break;case"demuxer_nalu_cb":r.data.payload.nalu,r.data.payload.pts,r.data.payload.dts,e._decoder_worker.postMessage({type:"demuxer_nalu_cb",payload:r.data.payload}),e.video_nalu_callback&&e.video_nalu_callback(r.data.payload.pts,r.data.payload.dts),e.on_cache_process_callback&&e.on_cache_process_callback(r.data.payload.dts);break;case"demuxer_aac_cb":if(e._audioAACCtx){const t={pts:r.data.payload.pts,data:r.data.payload.nalu};e._audioAACCtx.addSample(t),e.audio_frame_callback&&e.audio_frame_callback(r.data.payload.pts,e._audioAACCtx.getSampleQueueLen())}break;case"demuxer_extradata_cb":break;case"demuxer_vod_nalu_done":const l=r.data.payload.v_last_dts,u=r.data.payload.a_last_dts;e._player_vlast_dts=l,e._player_alast_dts=u;break;case"fetch-done":if(r.data.payload&&r.data.payload.is_complete)return r.data.payload.is_complete,t=0,void(e._player_video_core!==n.CORE_TYPE_WASM_HEVC&&e._player_video_core!==n.CORE_TYPE_WEBCODEC_HEVC||e._decoder_worker.postMessage({type:"fetch-done",payload:{}}));e.av_pause(),t<10?(e._demuxer_worker.postMessage({type:"retry_load_media"}),t++):t=0;break;case"fetch-error":console.error("Worker fetch-error, but not support yet"),t<10?(e.av_pause(),e._demuxer_worker.postMessage({type:"retry_load_media"}),t++):t=0;break;case"fetch-response-error":console.error("Worker fetch-response-error, but not support yet"),t<10?(e.av_pause(),e._demuxer_worker.postMessage({type:"retry_load_media"}),t++):t=0;break;case"fetch-retry-response-ok":e._clear_cache_pause_timer(),!0===e._expect_play&&e.play();break;case"restart-load-media":i<10?(e.change_media(e._play_url),i++):(e.rebuild(),i=0);break;case"ready_seek_demux":const c=r.data.payload.seekTime;e._player_video_core===n.CORE_TYPE_WEBCODEC_HEVC||e._player_video_core===n.CORE_TYPE_WASM_HEVC?e._decoder_worker&&e._decoder_worker.postMessage({type:"seek_decode",payload:{seekTime:c}}):e._player_video_core===n.CORE_TYPE_MSE_HEVC||e._decoder_worker&&e._decoder_worker.postMessage({type:"seek_decode",payload:{seekTime:c}});break;case"error":console.error("Worker error:",r.data.payload)}}}_init_decoder_worker(){let e=this;this._decoder_worker||(this._decoder_worker=d(),this._decoder_worker.onmessage=function(t){switch(t.data.type){case"ready":e._canvas_id,e._init_canvas_dom();const i=e._get_decoder_init_size(),a=e._canvas.transferControlToOffscreen();e._decoder_worker.postMessage({type:"canvas",payload:{offscreen:a,canvas_id:e._canvas_id,extra_data:e._media_info.extra_data,extra_size:e._media_info.extra_size,width:i.width,height:i.height}},[a]);break;case"reload_page":location.reload();break;case"alert_page":t.data.payload;break;case"error":console.error("decoder worker error:",t.data.payload);break;case"decode_video_progress":e._apply_decoded_video_size(t.data.payload.width,t.data.payload.height),e._first_frame_render||(e.render_tex(),e._first_frame_render=!0,e.on_ready_show_done_callback&&e.on_ready_show_done_callback(),e._init_play_button(),e._audioAACCtx&&(e._is_live_http_flv()?e._mark_live_http_flv_audio_realign_pending("first_frame"):e._audioAACCtx.check_with_video_pts_ms(t.data.payload.pts)),e._auto_play&&(e.set_mute(),setTimeout((()=>{e.play()}),30))),e.video_frame_callback&&e.video_frame_callback(t.data.payload.pts,t.data.payload.width,t.data.payload.height,t.data.payload.cache_size),e._clear_cache_pause_timer();break;case"render_progress":t.data.payload.pts,t.data.payload.width,t.data.payload.height,e._clear_cache_pause_timer(),e._video_render_pts=t.data.payload.pts,e._clear_decoder_seek_pending("webcodec_render_progress_after_seek"),e.video_render_callback&&e.video_render_callback(e._video_render_pts,t.data.payload.width,t.data.payload.height),e.on_play_time&&(e._audioAACCtx?e.on_play_time(Math.max(e._video_render_pts,e._audioAACCtx?e._audioAACCtx.getTimestampMs():0)/1e3):e.on_play_time(e._video_render_pts/1e3)),e._media_info.demuxer_media_type==n.PLAYER_MODE_VOD&&e._is_vod_finish_reliable()&&e._player_vlast_dts<=e._video_render_pts&&(e._player_vlast_dts,e._video_render_pts,e.pause(),e.on_play_finished&&e.on_play_finished());break;case"request_demux":e.cache_demux(t.data.payload.recv_v_count,t.data.payload.recv_a_count),e.request_pkt_callback&&e.request_pkt_callback(t.data.payload.recv_v_count,t.data.payload.recv_a_count);break;case"get_nalu_len_result":e.nalu_length_callback&&e.nalu_length_callback(t.data.payload);break;case"get_tex_len_result":e.tex_length_callback&&e.tex_length_callback(t.data.payload);break;case"gpu_memory_info_result":t.data.payload,e.gpu_info_callback&&e.gpu_info_callback(t.data.payload);break;case"on_load_cache":e.on_load_caching_callback&&e.on_load_caching_callback(t.data.payload),e._schedule_cache_pause("webcodec_on_load_cache");break;case"on_finish_cache":e.on_finish_cache_callback&&e.on_finish_cache_callback(t.data.payload),e._clear_cache_pause_timer(),e._expect_play&&!e._should_hold_seek_finish_cache_play("webcodec_on_finish_cache")&&e.play();break;case"av_align_audio_slower_too_much":e._audioAACCtx&&(e.av_pause(),e._is_live_http_flv()?e._mark_live_http_flv_audio_realign_pending("av_align_audio_slower_too_much"):e._audioAACCtx.check_with_video_pts_ms(e._video_render_pts),e.play());break;case"av_align_audio_faster_too_much":if(e._audioAACCtx){if(e._is_vod_flv_webcodec()){t.data.payload,e._video_render_pts;break}e.av_pause()}break;case"av_align_finished":e._expect_play&&e.play();break;case"seek_success_target":t.data.payload,e._expect_play,t.data.payload&&Number.isFinite(t.data.payload.pts)&&t.data.payload.pts>=0&&(e._video_render_pts=t.data.payload.pts),e.on_seek_done_callback&&e.on_seek_done_callback(t.data.payload),e._expect_play?e.play():e.render_tex()}})}_init_ffdecoder_worker(){let e=this;if(this._decoder_worker)return;this._decoder_worker=l();const t=function(t){switch(t.type){case"render_progress":t.payload,e._clear_cache_pause_timer();const i=t.payload.pts;e._video_render_pts=i,e._clear_decoder_seek_pending("ffdecoder_render_progress_after_seek"),e.video_render_callback&&e.video_render_callback(i,t.payload.width,t.payload.height),e.on_play_time&&(e._audioAACCtx?e.on_play_time(Math.max(e._video_render_pts,e._audioAACCtx?e._audioAACCtx.getTimestampMs():0)/1e3):e.on_play_time(e._video_render_pts/1e3)),e._media_info.demuxer_media_type==n.PLAYER_MODE_VOD&&e._is_vod_finish_reliable()&&e._player_vlast_dts<=e._video_render_pts&&(e._player_vlast_dts,e._video_render_pts,e.pause(),e.on_play_finished&&e.on_play_finished()),e._decoder_worker.postMessage({type:"set_cache_size",payload:{cache_size:t.payload.cache_size}});break;case"set_cache_size":e._decoder_worker.postMessage({type:"set_cache_size",payload:{cache_size:t.payload.cache_size}});break;case"av_align_audio_slower_too_much":e._audioAACCtx&&(e.av_pause(),e._is_live_http_flv()?e._mark_live_http_flv_audio_realign_pending("av_align_audio_slower_too_much"):e._audioAACCtx.check_with_video_pts_ms(e._video_render_pts),e.play());break;case"av_align_audio_faster_too_much":e._audioAACCtx&&(e.av_pause(),e._opengl_render&&e._opengl_render.check_with_audio_pts_ms(e._audioAACCtx.getTimestampMs(),(()=>{e.play()})))}};this._decoder_worker.onmessage=function(i){switch(i.data.type){case"ready":const a=e._get_decoder_init_size();e._decoder_worker.postMessage({type:"set_video_decoder",payload:{codec:e._media_info.codec,width:a.width,height:a.height,extra_data:e._media_info.extra_data,extra_size:e._media_info.extra_size}}),e._init_canvas_dom(),e._opengl_render=new u(e._wasm_main_thread_exports),e._opengl_render.event_data_callback=t,e._opengl_render.init(a.width,a.height,a.width,a.height,e._canvas_id);break;case"reload_page":location.reload();break;case"alert_page":i.data.payload;break;case"error":console.error("decoder_worker error:",i.data.payload);break;case"decode_video_progress":e._apply_decoded_video_size(i.data.payload.width,i.data.payload.height);const r=e._opengl_render.append_yuv420p_texture(i.data.payload.y_data,i.data.payload.u_data,i.data.payload.v_data,i.data.payload.width,i.data.payload.height,i.data.payload.y_linesize,i.data.payload.u_linesize,i.data.payload.v_linesize,i.data.payload.pts);r>0&&e._decoder_worker.postMessage({type:"set_cache_size",payload:{cache_size:r}}),e._first_frame_render||(e.render_tex(),e._first_frame_render=!0,e.on_ready_show_done_callback&&e.on_ready_show_done_callback(),e._init_play_button(),e._audioAACCtx&&(e._is_live_http_flv()?e._mark_live_http_flv_audio_realign_pending("first_frame"):e._audioAACCtx.check_with_video_pts_ms(i.data.payload.pts)),e._auto_play&&(e.set_mute(),setTimeout((()=>{e.play()}),30))),e.video_frame_callback&&e.video_frame_callback(i.data.payload.pts,i.data.payload.width,i.data.payload.height,r),e._clear_cache_pause_timer();break;case"request_demux":e.cache_demux(i.data.payload.recv_v_count,i.data.payload.recv_a_count),e.request_pkt_callback&&e.request_pkt_callback(i.data.payload.recv_v_count,i.data.payload.recv_a_count);break;case"get_nalu_len_result":e.nalu_length_callback&&e.nalu_length_callback(i.data.payload);break;case"get_tex_len_result":e.tex_length_callback&&e.tex_length_callback(i.data.payload);break;case"gpu_memory_info_result":i.data.payload,e.gpu_info_callback&&e.gpu_info_callback(i.data.payload);break;case"on_load_cache":e.on_load_caching_callback&&e.on_load_caching_callback(i.data.payload),e._schedule_cache_pause("ffdecoder_on_load_cache");break;case"on_finish_cache":e.on_finish_cache_callback&&e.on_finish_cache_callback(i.data.payload),e._clear_cache_pause_timer(),e._expect_play&&!e._should_hold_seek_finish_cache_play("ffdecoder_on_finish_cache")&&e.play();break;case"seek_success_target":i.data.payload,i.data.payload&&Number.isFinite(i.data.payload.pts)&&i.data.payload.pts>=0&&(e._video_render_pts=i.data.payload.pts),e.on_seek_done_callback&&e.on_seek_done_callback(i.data.payload),e._expect_play?e.play():e.render_tex()}}}append265NaluFrame(e,t){this._decoder_worker&&this._decoder_worker.postMessage({type:"demuxer_nalu_cb",payload:{nalu:e,pts:t,dts:t,w:this._media_info.w,h:this._media_info.h,isKey:!0}})}_raw265Entry(){let e=this;this.videoURL,e._decoder_worker&&e._decoder_worker.postMessage({type:"probe_ok",payload:{w:e._media_info.w,h:e._media_info.h}});let t=0,i=parseInt(1/e._media_info.fps*1e3),a=function(){setTimeout((()=>{e._workerParse.postMessage({cmd:"get-nalu",data:null,msg:"get-nalu"}),e._workerParse.parseEmpty,e._workerFetch.onMsgFetchFinished,!0===e._workerFetch.onMsgFetchFinished&&!0===e._workerParse.frameListEmpty&&!1===e._workerParse.streamEmpty&&e._workerParse.postMessage({cmd:"last-nalu",data:null,msg:"last-nalu"}),!0===e._workerParse.parseEmpty&&(e._workerParse.stopNaluInterval=!0),!0!==e._workerParse.stopNaluInterval&&a()}),1e3)};e._workerFetch=new Worker(r.GetScriptPath((function(){let e=new AbortController,t=e.signal,i=null;onmessage=a=>{let r=a.data,n=null;switch(n=void 0===r.cmd||null===r.cmd?"":r.cmd,n){case"start":let a=r.url;"http"===r.type?function(e){let i=!1,a=!1;a||(a=!0,fetch(e,{signal:t}).then((function(e){let t=function(e){return e.read().then((function(a){if(a.done)return i=!0,void postMessage({cmd:"fetch-fin",data:null,msg:"fetch-fin"});let r=a.value;return postMessage({cmd:"fetch-chunk",data:r,msg:"fetch-chunk"}),t(e)}))};return t(e.body.getReader())})).catch((function(e){})))}(a):"websocket"===r.type&&(i=new WebSocket(a),i.binaryType="arraybuffer",i.onopen=function(e){i.send("Hello WebSockets!")},i.onmessage=function(e){if(e.data instanceof ArrayBuffer){var t=e.data;t.byteLength>0&&postMessage({cmd:"fetch-chunk",data:new Uint8Array(t),msg:"fetch-chunk"})}},i.onclose=function(e){postMessage({cmd:"fetch-fin",data:null,msg:"fetch-fin"})}),postMessage({cmd:"default",data:"WORKER STARTED",msg:"default"});break;case"stop":"http"===r.type?e.abort():"websocket"===r.type&&i&&i.close(),close()}}}))),e._workerFetch.onMsgFetchFinished=!1,e._workerFetch.onmessage=function(t){let i=t.data,r=null;switch(r=void 0===i.cmd||null===i.cmd?"":i.cmd,r){case"fetch-chunk":let t=i.data;e._workerParse.postMessage({cmd:"append-chunk",data:t,msg:"append-chunk"});break;case"fetch-fin":e._workerFetch.onMsgFetchFinished=!0,a()}},e._workerParse=new Worker(r.GetScriptPath((function(){let e=function(){let e=new Object;return e.frameList=[],e.stream=null,e.frameListEmpty=function(){return e.frameList.length<=0},e.streamEmpty=function(){return null===e.stream||e.stream.length<=0},e.checkEmpty=function(){return!0===e.streamEmpty()&&!0===e.frameListEmpty()||(e.stream,e.frameList,!1)},e.pushFrameRet=function(t){return!(!t||null==t||null==t||(e.frameList&&null!=e.frameList&&null!=e.frameList||(e.frameList=[]),e.frameList.push(t),0))},e.nextFrame=function(){return!e.frameList&&null==e.frameList||null==e.frameList&&e.frameList.length<1?null:e.frameList.shift()},e.clearFrameRet=function(){e.frameList=null},e.setStreamRet=function(t){e.stream=t},e.getStreamRet=function(){return e.stream},e.appendStreamRet=function(t){if(!t||void 0===t||null==t)return!1;if(!e.stream||void 0===e.stream||null==e.stream)return e.stream=t,!0;let i=e.stream.length,a=t.length,r=new Uint8Array(i+a);r.set(e.stream,0),r.set(t,i),e.stream=r;for(let t=0;t<9999;t++){let t=e.nextNalu();if(!1===t||null==t)break;e.frameList.push(t)}return!0},e.subBuf=function(t,i){let a=new Uint8Array(e.stream.subarray(t,i+1));return e.stream=new Uint8Array(e.stream.subarray(i+1)),a},e.lastNalu=function(){const t=e.subBuf(0,e.stream.length);e.frameList.push(t)},e.nextNalu=function(t=1){if(null==e.stream||e.stream.length<=4)return!1;let i=-1,a=null;for(let r=0;r<e.stream.length;r++){if(r+5>=e.stream.length)return!1;if(0==e.stream[r]&&0==e.stream[r+1]&&1==e.stream[r+2]||0==e.stream[r]&&0==e.stream[r+1]&&0==e.stream[r+2]&&1==e.stream[r+3]){let n=r;if(r+=3,-1==i)i=n;else{if(t<=1)return a=e.subBuf(i,n-1),a;t-=1}}}return!1},e.nextNalu2=function(t=1){if(null==e.stream||e.stream.length<=4)return!1;let i=-1,a=null;for(let r=0;r<e.stream.length;r++){if(r+5>=e.stream.length)return-1!=i&&(a=e.subBuf(i,e.stream.length-1),a);let n="0 0 1"==e.stream.slice(r,r+3).join(" "),s="0 0 0 1"==e.stream.slice(r,r+4).join(" ");if(n||s){let n=r;if(r+=3,-1==i)i=n;else{if(t<=1)return a=e.subBuf(i,n-1),a;t-=1}}}return!1},e}();onmessage=t=>{let i=t.data,a=null;switch(a=void 0===i.cmd||null===i.cmd?"":i.cmd,a){case"append-chunk":let t=i.data;e.appendStreamRet(t);let a=e.nextFrame();postMessage({cmd:"return-nalu",data:a,msg:"return-nalu",parseEmpty:e.checkEmpty(),streamEmpty:e.streamEmpty(),frameListEmpty:e.frameListEmpty()});break;case"get-nalu":let r=e.nextFrame();postMessage({cmd:"return-nalu",data:r,msg:"return-nalu",parseEmpty:e.checkEmpty(),streamEmpty:e.streamEmpty(),frameListEmpty:e.frameListEmpty()});break;case"last-nalu":let n=e.lastNalu();postMessage({cmd:"return-nalu",data:n,msg:"return-nalu",parseEmpty:e.checkEmpty(),streamEmpty:e.streamEmpty(),frameListEmpty:e.frameListEmpty()});break;case"stop":postMessage("parse - WORKER STOPPED: "+i),close()}}}))),e._workerParse.stopNaluInterval=!1,e._workerParse.parseEmpty=!1,e._workerParse.streamEmpty=!1,e._workerParse.frameListEmpty=!1,e._workerParse.onmessage=a=>{let r=a.data,n=null;if(n=void 0===r.cmd||null===r.cmd?"":r.cmd,"return-nalu"===n){let a=r.data,n=r.parseEmpty,s=r.streamEmpty,o=r.frameListEmpty;e._workerParse.parseEmpty=n,e._workerParse.streamEmpty=s,e._workerParse.frameListEmpty=o,!1===a||null==a?!0===e._workerFetch.onMsgFetchFinished&&!0===n&&(e._workerParse.stopNaluInterval=!0):(e.append265NaluFrame(a,t),t+=i,e._workerParse.postMessage({cmd:"get-nalu",data:null,msg:"get-nalu"}))}},this._workerFetch.postMessage({cmd:"start",url:this._play_url,type:this._protocol_type,msg:"start"})}}t.exports=f,window.H265webjsPlayer=i.H265webjsPlayer=()=>new f,n.testCheckAllSupport().then((e=>{window.YLPlayerSupport=e}))}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./audio/audio-aac-core":2,"./audio/audio-pcm-core":3,"./av-common":4,"./consts":5,"./native/mp4-player":7,"./native/nv-flvjs-core":8,"./native/nv-mpegts-core":9,"./opengl/cylopengl":10,"./probe":11,"./worker/create-worker-decoder":12,"./worker/create-worker-demuxer":13,"./worker/create_worker_ffdecoder":14,"mpegts.js":16}],16:[function(e,t,i){var a,r;a=window,r=function(){return function(e){var t={};function i(a){if(t[a])return t[a].exports;var r=t[a]={i:a,l:!1,exports:{}};return e[a].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,a){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(i.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(a,r,function(t){return e[t]}.bind(null,r));return a},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=20)}([function(e,t,i){"use strict";var a=i(9),r=i.n(a),n=function(){function e(){}return e.e=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var a="[".concat(t,"] > ").concat(i);e.ENABLE_CALLBACK&&e.emitter.emit("log","error",a),e.ENABLE_ERROR&&(console.error?console.error(a):console.warn)},e.i=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var a="[".concat(t,"] > ").concat(i);e.ENABLE_CALLBACK&&e.emitter.emit("log","info",a),e.ENABLE_INFO&&console.info&&console.info(a)},e.w=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var a="[".concat(t,"] > ").concat(i);e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",a),e.ENABLE_WARN&&console.warn},e.d=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var a="[".concat(t,"] > ").concat(i);e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",a),e.ENABLE_DEBUG&&console.debug&&console.debug(a)},e.v=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var a="[".concat(t,"] > ").concat(i);e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",a),e.ENABLE_VERBOSE},e}();n.GLOBAL_TAG="mpegts.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 r.a,t.a=n},function(e,t,i){"use strict";var a;!function(e){e.IO_ERROR="io_error",e.DEMUX_ERROR="demux_error",e.INIT_SEGMENT="init_segment",e.MEDIA_SEGMENT="media_segment",e.LOADING_COMPLETE="loading_complete",e.RECOVERED_EARLY_EOF="recovered_early_eof",e.MEDIA_INFO="media_info",e.METADATA_ARRIVED="metadata_arrived",e.SCRIPTDATA_ARRIVED="scriptdata_arrived",e.TIMED_ID3_METADATA_ARRIVED="timed_id3_metadata_arrived",e.SYNCHRONOUS_KLV_METADATA_ARRIVED="synchronous_klv_metadata_arrived",e.ASYNCHRONOUS_KLV_METADATA_ARRIVED="asynchronous_klv_metadata_arrived",e.SMPTE2038_METADATA_ARRIVED="smpte2038_metadata_arrived",e.SCTE35_METADATA_ARRIVED="scte35_metadata_arrived",e.PES_PRIVATE_DATA_DESCRIPTOR="pes_private_data_descriptor",e.PES_PRIVATE_DATA_ARRIVED="pes_private_data_arrived",e.STATISTICS_INFO="statistics_info",e.RECOMMEND_SEEKPOINT="recommend_seekpoint"}(a||(a={})),t.a=a},function(e,t,i){"use strict";i.d(t,"c",(function(){return r})),i.d(t,"b",(function(){return n})),i.d(t,"a",(function(){return s}));var a=i(3),r={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},n={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"},s=function(){function e(e){this._type=e||"undefined",this._status=r.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}return e.prototype.destroy=function(){this._status=r.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null},e.prototype.isWorking=function(){return this._status===r.kConnecting||this._status===r.kBuffering},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needStashBuffer",{get:function(){return this._needStash},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onContentLengthKnown",{get:function(){return this._onContentLengthKnown},set:function(e){this._onContentLengthKnown=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onURLRedirect",{get:function(){return this._onURLRedirect},set:function(e){this._onURLRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),e.prototype.open=function(e,t){throw new a.c("Unimplemented abstract function!")},e.prototype.abort=function(){throw new a.c("Unimplemented abstract function!")},e}()},function(e,t,i){"use strict";i.d(t,"d",(function(){return n})),i.d(t,"a",(function(){return s})),i.d(t,"b",(function(){return o})),i.d(t,"c",(function(){return _}));var a,r=(a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),n=function(){function e(e){this._message=e}return Object.defineProperty(e.prototype,"name",{get:function(){return"RuntimeException"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"message",{get:function(){return this._message},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this.name+": "+this.message},e}(),s=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"IllegalStateException"},enumerable:!1,configurable:!0}),t}(n),o=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"InvalidArgumentException"},enumerable:!1,configurable:!0}),t}(n),_=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"NotImplementedException"},enumerable:!1,configurable:!0}),t}(n)},function(e,t,i){"use strict";var a;!function(e){e.ERROR="error",e.LOADING_COMPLETE="loading_complete",e.RECOVERED_EARLY_EOF="recovered_early_eof",e.MEDIA_INFO="media_info",e.METADATA_ARRIVED="metadata_arrived",e.SCRIPTDATA_ARRIVED="scriptdata_arrived",e.TIMED_ID3_METADATA_ARRIVED="timed_id3_metadata_arrived",e.SYNCHRONOUS_KLV_METADATA_ARRIVED="synchronous_klv_metadata_arrived",e.ASYNCHRONOUS_KLV_METADATA_ARRIVED="asynchronous_klv_metadata_arrived",e.SMPTE2038_METADATA_ARRIVED="smpte2038_metadata_arrived",e.SCTE35_METADATA_ARRIVED="scte35_metadata_arrived",e.PES_PRIVATE_DATA_DESCRIPTOR="pes_private_data_descriptor",e.PES_PRIVATE_DATA_ARRIVED="pes_private_data_arrived",e.STATISTICS_INFO="statistics_info",e.DESTROYING="destroying"}(a||(a={})),t.a=a},function(e,t,i){"use strict";var a={};!function(){var e=self.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(iemobile)[\/]([\w.]+)/.exec(e)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],i=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],r={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:i[0]||""},n={};if(r.browser){n[r.browser]=!0;var s=r.majorVersion.split(".");n.version={major:parseInt(r.majorVersion,10),string:r.version},s.length>1&&(n.version.minor=parseInt(s[1],10)),s.length>2&&(n.version.build=parseInt(s[2],10))}for(var o in r.platform&&(n[r.platform]=!0),(n.chrome||n.opr||n.safari)&&(n.webkit=!0),(n.rv||n.iemobile)&&(n.rv&&delete n.rv,r.browser="msie",n.msie=!0),n.edge&&(delete n.edge,r.browser="msedge",n.msedge=!0),n.opr&&(r.browser="opera",n.opera=!0),n.safari&&n.android&&(r.browser="android",n.android=!0),n.name=r.browser,n.platform=r.platform,a)a.hasOwnProperty(o)&&delete a[o];Object.assign(a,n)}(),t.a=a},function(e,t,i){"use strict";t.a={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"}},function(e,t,i){"use strict";var a;!function(e){e.ERROR="error",e.SOURCE_OPEN="source_open",e.UPDATE_END="update_end",e.BUFFER_FULL="buffer_full",e.START_STREAMING="start_streaming",e.END_STREAMING="end_streaming"}(a||(a={})),t.a=a},function(e,t,i){"use strict";var a=i(9),r=i.n(a),n=i(0),s=function(){function e(){}return Object.defineProperty(e,"forceGlobalTag",{get:function(){return n.a.FORCE_GLOBAL_TAG},set:function(t){n.a.FORCE_GLOBAL_TAG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"globalTag",{get:function(){return n.a.GLOBAL_TAG},set:function(t){n.a.GLOBAL_TAG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableAll",{get:function(){return n.a.ENABLE_VERBOSE&&n.a.ENABLE_DEBUG&&n.a.ENABLE_INFO&&n.a.ENABLE_WARN&&n.a.ENABLE_ERROR},set:function(t){n.a.ENABLE_VERBOSE=t,n.a.ENABLE_DEBUG=t,n.a.ENABLE_INFO=t,n.a.ENABLE_WARN=t,n.a.ENABLE_ERROR=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableDebug",{get:function(){return n.a.ENABLE_DEBUG},set:function(t){n.a.ENABLE_DEBUG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableVerbose",{get:function(){return n.a.ENABLE_VERBOSE},set:function(t){n.a.ENABLE_VERBOSE=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableInfo",{get:function(){return n.a.ENABLE_INFO},set:function(t){n.a.ENABLE_INFO=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableWarn",{get:function(){return n.a.ENABLE_WARN},set:function(t){n.a.ENABLE_WARN=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableError",{get:function(){return n.a.ENABLE_ERROR},set:function(t){n.a.ENABLE_ERROR=t,e._notifyChange()},enumerable:!1,configurable:!0}),e.getConfig=function(){return{globalTag:n.a.GLOBAL_TAG,forceGlobalTag:n.a.FORCE_GLOBAL_TAG,enableVerbose:n.a.ENABLE_VERBOSE,enableDebug:n.a.ENABLE_DEBUG,enableInfo:n.a.ENABLE_INFO,enableWarn:n.a.ENABLE_WARN,enableError:n.a.ENABLE_ERROR,enableCallback:n.a.ENABLE_CALLBACK}},e.applyConfig=function(e){n.a.GLOBAL_TAG=e.globalTag,n.a.FORCE_GLOBAL_TAG=e.forceGlobalTag,n.a.ENABLE_VERBOSE=e.enableVerbose,n.a.ENABLE_DEBUG=e.enableDebug,n.a.ENABLE_INFO=e.enableInfo,n.a.ENABLE_WARN=e.enableWarn,n.a.ENABLE_ERROR=e.enableError,n.a.ENABLE_CALLBACK=e.enableCallback},e._notifyChange=function(){var t=e.emitter;if(t.listenerCount("change")>0){var i=e.getConfig();t.emit("change",i)}},e.registerListener=function(t){e.emitter.addListener("change",t)},e.removeListener=function(t){e.emitter.removeListener("change",t)},e.addLogListener=function(t){n.a.emitter.addListener("log",t),n.a.emitter.listenerCount("log")>0&&(n.a.ENABLE_CALLBACK=!0,e._notifyChange())},e.removeLogListener=function(t){n.a.emitter.removeListener("log",t),0===n.a.emitter.listenerCount("log")&&(n.a.ENABLE_CALLBACK=!1,e._notifyChange())},e}();s.emitter=new r.a,t.a=s},function(e,t,i){"use strict";var a,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};a=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(i,a){function r(i){e.removeListener(t,n),a(i)}function n(){"function"==typeof e.removeListener&&e.removeListener("error",r),i([].slice.call(arguments))}g(e,t,n,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&g(e,"error",t,{once:!0})}(e,r)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var _=10;function d(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,i,a){var r,n,s;if(d(i),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),n=e._events),s=n[t]),void 0===s)s=n[t]=i,++e._eventsCount;else if("function"==typeof s?s=n[t]=a?[i,s]:[s,i]:a?s.unshift(i):s.push(i),(r=l(e))>0&&s.length>r&&!s.warned){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=e,o.type=t,o.count=s.length,console&&console.warn}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,i){var a={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=c.bind(a);return r.listener=i,a.wrapFn=r,r}function f(e,t,i){var a=e._events;if(void 0===a)return[];var r=a[t];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(r):m(r,r.length)}function p(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function m(e,t){for(var i=new Array(t),a=0;a<t;++a)i[a]=e[a];return i}function g(e,t,i,a){if("function"==typeof e.on)a.once?e.once(t,i):e.on(t,i);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function r(n){a.once&&e.removeEventListener(t,r),i(n)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return _},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");_=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return l(this)},o.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var a="error"===e,r=this._events;if(void 0!==r)a=a&&void 0===r.error;else if(!a)return!1;if(a){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var _=r[e];if(void 0===_)return!1;if("function"==typeof _)n(_,this,t);else{var d=_.length,l=m(_,d);for(i=0;i<d;++i)n(l[i],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return d(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return d(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var i,a,r,n,s;if(d(t),void 0===(a=this._events))return this;if(void 0===(i=a[e]))return this;if(i===t||i.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete a[e],a.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(r=-1,n=i.length-1;n>=0;n--)if(i[n]===t||i[n].listener===t){s=i[n].listener,r=n;break}if(r<0)return this;0===r?i.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(i,r),1===i.length&&(a[e]=i[0]),void 0!==a.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,i,a;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var r,n=Object.keys(i);for(a=0;a<n.length;++a)"removeListener"!==(r=n[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(void 0!==t)for(a=t.length-1;a>=0;a--)this.removeListener(e,t[a]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?a(this._events):[]}},function(e,t,i){"use strict";i.d(t,"b",(function(){return n})),i.d(t,"a",(function(){return s}));var a=i(2),r=i(6),n={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},s={NETWORK_EXCEPTION:a.b.EXCEPTION,NETWORK_STATUS_CODE_INVALID:a.b.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:a.b.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:a.b.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:r.a.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:r.a.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:r.a.CODEC_UNSUPPORTED}},function(e,t,i){"use strict";i.d(t,"d",(function(){return a})),i.d(t,"b",(function(){return r})),i.d(t,"a",(function(){return n})),i.d(t,"c",(function(){return s}));var a=function(e,t,i,a,r){this.dts=e,this.pts=t,this.duration=i,this.originalDts=a,this.isSyncPoint=r,this.fileposition=null},r=function(){function e(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}return e.prototype.appendSyncPoint=function(e){e.isSyncPoint=!0,this.syncPoints.push(e)},e}(),n=function(){function e(){this._list=[]}return e.prototype.clear=function(){this._list=[]},e.prototype.appendArray=function(e){var t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts<t[t.length-1].originalDts&&this.clear(),Array.prototype.push.apply(t,e))},e.prototype.getLastSyncPointBeforeDts=function(e){if(0==this._list.length)return null;var t=this._list,i=0,a=t.length-1,r=0,n=0,s=a;for(e<t[0].dts&&(i=0,n=s+1);n<=s;){if((r=n+Math.floor((s-n)/2))===a||e>=t[r].dts&&e<t[r+1].dts){i=r;break}t[r].dts<e?n=r+1:s=r-1}return this._list[i]},e}(),s=function(){function e(e){this._type=e,this._list=[],this._lastAppendLocation=-1}return Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._list.length},enumerable:!1,configurable:!0}),e.prototype.isEmpty=function(){return 0===this._list.length},e.prototype.clear=function(){this._list=[],this._lastAppendLocation=-1},e.prototype._searchNearestSegmentBefore=function(e){var t=this._list;if(0===t.length)return-2;var i=t.length-1,a=0,r=0,n=i,s=0;if(e<t[0].originalBeginDts)return-1;for(;r<=n;){if((a=r+Math.floor((n-r)/2))===i||e>t[a].lastSample.originalDts&&e<t[a+1].originalBeginDts){s=a;break}t[a].originalBeginDts<e?r=a+1:n=a-1}return s},e.prototype._searchNearestSegmentAfter=function(e){return this._searchNearestSegmentBefore(e)+1},e.prototype.append=function(e){var t=this._list,i=e,a=this._lastAppendLocation,r=0;-1!==a&&a<t.length&&i.originalBeginDts>=t[a].lastSample.originalDts&&(a===t.length-1||a<t.length-1&&i.originalBeginDts<t[a+1].originalBeginDts)?r=a+1:t.length>0&&(r=this._searchNearestSegmentBefore(i.originalBeginDts)+1),this._lastAppendLocation=r,this._list.splice(r,0,i)},e.prototype.getLastSegmentBefore=function(e){var t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null},e.prototype.getLastSampleBefore=function(e){var t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null},e.prototype.getLastSyncPointBefore=function(e){for(var t=this._searchNearestSegmentBefore(e),i=this._list[t].syncPoints;0===i.length&&t>0;)t--,i=this._list[t].syncPoints;return i.length>0?i[i.length-1]:null},e}()},function(e,t,i){"use strict";var a=function(){function e(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}return e.prototype.isComplete=function(){var e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=this.videoCodec&&null!=this.width&&null!=this.height&&null!=this.fps&&null!=this.profile&&null!=this.level&&null!=this.refFrames&&null!=this.chromaFormat&&null!=this.sarNum&&null!=this.sarDen;return null!=this.mimeType&&e&&t},e.prototype.isSeekable=function(){return!0===this.hasKeyframesIndex},e.prototype.getNearestKeyframe=function(e){if(null==this.keyframesIndex)return null;var t=this.keyframesIndex,i=this._search(t.times,e);return{index:i,milliseconds:t.times[i],fileposition:t.filepositions[i]}},e.prototype._search=function(e,t){var i=0,a=e.length-1,r=0,n=0,s=a;for(t<e[0]&&(i=0,n=s+1);n<=s;){if((r=n+Math.floor((s-n)/2))===a||t>=e[r]&&t<e[r+1]){i=r;break}e[r]<t?n=r+1:s=r-1}return i},e}();t.a=a},function(e,t,i){"use strict";var a=i(9),r=i.n(a),n=i(0),s=i(5),o=i(12);function _(e,t,i){var a=e;if(t+i<a.length){for(;i--;)if(128!=(192&a[++t]))return!1;return!0}return!1}var d,l=function(e){for(var t=[],i=e,a=0,r=e.length;a<r;)if(i[a]<128)t.push(String.fromCharCode(i[a])),++a;else{if(i[a]<192);else if(i[a]<224){if(_(i,a,1)&&(n=(31&i[a])<<6|63&i[a+1])>=128){t.push(String.fromCharCode(65535&n)),a+=2;continue}}else if(i[a]<240){if(_(i,a,2)&&(n=(15&i[a])<<12|(63&i[a+1])<<6|63&i[a+2])>=2048&&55296!=(63488&n)){t.push(String.fromCharCode(65535&n)),a+=3;continue}}else if(i[a]<248){var n;if(_(i,a,3)&&(n=(7&i[a])<<18|(63&i[a+1])<<12|(63&i[a+2])<<6|63&i[a+3])>65536&&n<1114112){n-=65536,t.push(String.fromCharCode(n>>>10|55296)),t.push(String.fromCharCode(1023&n|56320)),a+=4;continue}}t.push(String.fromCharCode(65533)),++a}return t.join("")},u=i(3),c=(d=new ArrayBuffer(2),new DataView(d).setInt16(0,256,!0),256===new Int16Array(d)[0]),h=function(){function e(){}return e.parseScriptData=function(t,i,a){var r={};try{var s=e.parseValue(t,i,a),o=e.parseValue(t,i+s.size,a-s.size);r[s.data]=o.data}catch(e){n.a.e("AMF",e.toString())}return r},e.parseObject=function(t,i,a){if(a<3)throw new u.a("Data not enough when parse ScriptDataObject");var r=e.parseString(t,i,a),n=e.parseValue(t,i+r.size,a-r.size),s=n.objectEnd;return{data:{name:r.data,value:n.data},size:r.size+n.size,objectEnd:s}},e.parseVariable=function(t,i,a){return e.parseObject(t,i,a)},e.parseString=function(e,t,i){if(i<2)throw new u.a("Data not enough when parse String");var a=new DataView(e,t,i).getUint16(0,!c);return{data:a>0?l(new Uint8Array(e,t+2,a)):"",size:2+a}},e.parseLongString=function(e,t,i){if(i<4)throw new u.a("Data not enough when parse LongString");var a=new DataView(e,t,i).getUint32(0,!c);return{data:a>0?l(new Uint8Array(e,t+4,a)):"",size:4+a}},e.parseDate=function(e,t,i){if(i<10)throw new u.a("Data size invalid when parse Date");var a=new DataView(e,t,i),r=a.getFloat64(0,!c),n=a.getInt16(8,!c);return{data:new Date(r+=60*n*1e3),size:10}},e.parseValue=function(t,i,a){if(a<1)throw new u.a("Data not enough when parse Value");var r,s=new DataView(t,i,a),o=1,_=s.getUint8(0),d=!1;try{switch(_){case 0:r=s.getFloat64(1,!c),o+=8;break;case 1:r=!!s.getUint8(1),o+=1;break;case 2:var l=e.parseString(t,i+1,a-1);r=l.data,o+=l.size;break;case 3:r={};var h=0;for(9==(16777215&s.getUint32(a-4,!c))&&(h=3);o<a-4;){var f=e.parseObject(t,i+o,a-o-h);if(f.objectEnd)break;r[f.data.name]=f.data.value,o+=f.size}o<=a-3&&9==(16777215&s.getUint32(o-1,!c))&&(o+=3);break;case 8:for(r={},o+=4,h=0,9==(16777215&s.getUint32(a-4,!c))&&(h=3);o<a-8;){var p=e.parseVariable(t,i+o,a-o-h);if(p.objectEnd)break;r[p.data.name]=p.data.value,o+=p.size}o<=a-3&&9==(16777215&s.getUint32(o-1,!c))&&(o+=3);break;case 9:r=void 0,o=1,d=!0;break;case 10:r=[];var m=s.getUint32(1,!c);o+=4;for(var g=0;g<m;g++){var y=e.parseValue(t,i+o,a-o);r.push(y.data),o+=y.size}break;case 11:var v=e.parseDate(t,i+1,a-1);r=v.data,o+=v.size;break;case 12:var b=e.parseString(t,i+1,a-1);r=b.data,o+=b.size;break;default:o=a,n.a.w("AMF","Unsupported AMF value type "+_)}}catch(e){n.a.e("AMF",e.toString())}return{data:r,size:o,objectEnd:d}},e}(),f=function(){function e(e){this.TAG="ExpGolomb",this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}return e.prototype.destroy=function(){this._buffer=null},e.prototype._fillCurrentWord=function(){var e=this._total_bytes-this._buffer_index;if(e<=0)throw new u.a("ExpGolomb: _fillCurrentWord() but no bytes available");var t=Math.min(4,e),i=new Uint8Array(4);i.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(i.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t},e.prototype.readBits=function(e){if(e>32)throw new u.b("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 i=this._current_word_bits_left?this._current_word:0;i>>>=32-this._current_word_bits_left;var a=e-this._current_word_bits_left;this._fillCurrentWord();var r=Math.min(a,this._current_word_bits_left),n=this._current_word>>>32-r;return this._current_word<<=r,this._current_word_bits_left-=r,i<<r|n},e.prototype.readBool=function(){return 1===this.readBits(1)},e.prototype.readByte=function(){return this.readBits(8)},e.prototype._skipLeadingZero=function(){var e;for(e=0;e<this._current_word_bits_left;e++)if(this._current_word&2147483648>>>e)return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()},e.prototype.readUEG=function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1},e.prototype.readSEG=function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)},e}(),p=function(){function e(){}return e._ebsp2rbsp=function(e){for(var t=e,i=t.byteLength,a=new Uint8Array(i),r=0,n=0;n<i;n++)n>=2&&3===t[n]&&0===t[n-1]&&0===t[n-2]||(a[r]=t[n],r++);return new Uint8Array(a.buffer,0,r)},e.parseSPS=function(t){for(var i=t.subarray(1,4),a="avc1.",r=0;r<3;r++){var n=i[r].toString(16);n.length<2&&(n="0"+n),a+=n}var s=e._ebsp2rbsp(t),o=new f(s);o.readByte();var _=o.readByte();o.readByte();var d=o.readByte();o.readUEG();var l=e.getProfileString(_),u=e.getLevelString(d),c=1,h=420,p=8,m=8;if((100===_||110===_||122===_||244===_||44===_||83===_||86===_||118===_||128===_||138===_||144===_)&&(3===(c=o.readUEG())&&o.readBits(1),c<=3&&(h=[0,420,422,444][c]),p=o.readUEG()+8,m=o.readUEG()+8,o.readBits(1),o.readBool()))for(var g=3!==c?8:12,y=0;y<g;y++)o.readBool()&&(y<6?e._skipScalingList(o,16):e._skipScalingList(o,64));o.readUEG();var v=o.readUEG();if(0===v)o.readUEG();else if(1===v){o.readBits(1),o.readSEG(),o.readSEG();var b=o.readUEG();for(y=0;y<b;y++)o.readSEG()}var E=o.readUEG();o.readBits(1);var S=o.readUEG(),A=o.readUEG(),w=o.readBits(1);0===w&&o.readBits(1),o.readBits(1);var k=0,T=0,L=0,R=0;o.readBool()&&(k=o.readUEG(),T=o.readUEG(),L=o.readUEG(),R=o.readUEG());var C=1,x=1,M=0,D=!0,O=0,I=0;if(o.readBool()){if(o.readBool()){var P=o.readByte();P>0&&P<16?(C=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][P-1],x=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][P-1]):255===P&&(C=o.readByte()<<8|o.readByte(),x=o.readByte()<<8|o.readByte())}if(o.readBool()&&o.readBool(),o.readBool()&&(o.readBits(4),o.readBool()&&o.readBits(24)),o.readBool()&&(o.readUEG(),o.readUEG()),o.readBool()){var B=o.readBits(32),U=o.readBits(32);D=o.readBool(),M=(O=U)/(I=2*B)}}var N=1;1===C&&1===x||(N=C/x);var F=0,V=0;0===c?(F=1,V=2-w):(F=3===c?1:2,V=(1===c?2:1)*(2-w));var j=16*(S+1),G=16*(A+1)*(2-w);j-=(k+T)*F,G-=(L+R)*V;var H=Math.ceil(j*N);return o.destroy(),o=null,{codec_mimetype:a,profile_idc:_,level_idc:d,profile_string:l,level_string:u,chroma_format_idc:c,bit_depth:p,bit_depth_luma:p,bit_depth_chroma:m,ref_frames:E,chroma_format:h,chroma_format_string:e.getChromaFormatString(h),frame_rate:{fixed:D,fps:M,fps_den:I,fps_num:O},sar_ratio:{width:C,height:x},codec_size:{width:j,height:G},present_size:{width:H,height:G}}},e._skipScalingList=function(e,t){for(var i=8,a=8,r=0;r<t;r++)0!==a&&(a=(i+e.readSEG()+256)%256),i=0===a?i:a},e.getProfileString=function(e){switch(e){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}},e.getLevelString=function(e){return(e/10).toFixed(1)},e.getChromaFormatString=function(e){switch(e){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}},e}(),m=i(6),g=function(){function e(){}return e._ebsp2rbsp=function(e){for(var t=e,i=t.byteLength,a=new Uint8Array(i),r=0,n=0;n<i;n++)n>=2&&3===t[n]&&0===t[n-1]&&0===t[n-2]||(a[r]=t[n],r++);return new Uint8Array(a.buffer,0,r)},e.parseVPS=function(t){var i=e._ebsp2rbsp(t),a=new f(i);return a.readByte(),a.readByte(),a.readBits(4),a.readBits(2),a.readBits(6),{num_temporal_layers:a.readBits(3)+1,temporal_id_nested:a.readBool()}},e.parseSPS=function(t){var i=e._ebsp2rbsp(t),a=new f(i);a.readByte(),a.readByte();for(var r=0,n=0,s=0,o=0,_=(a.readBits(4),a.readBits(3)),d=(a.readBool(),a.readBits(2)),l=a.readBool(),u=a.readBits(5),c=a.readByte(),h=a.readByte(),p=a.readByte(),m=a.readByte(),g=a.readByte(),y=a.readByte(),v=a.readByte(),b=a.readByte(),E=a.readByte(),S=a.readByte(),A=a.readByte(),w=[],k=[],T=0;T<_;T++)w.push(a.readBool()),k.push(a.readBool());if(_>0)for(T=_;T<8;T++)a.readBits(2);for(T=0;T<_;T++)w[T]&&(a.readByte(),a.readByte(),a.readByte(),a.readByte(),a.readByte(),a.readByte(),a.readByte(),a.readByte(),a.readByte(),a.readByte(),a.readByte()),k[T]&&a.readByte();a.readUEG();var L=a.readUEG();3==L&&a.readBits(1);var R=a.readUEG(),C=a.readUEG();a.readBool()&&(r+=a.readUEG(),n+=a.readUEG(),s+=a.readUEG(),o+=a.readUEG());var x=a.readUEG(),M=a.readUEG(),D=a.readUEG();for(T=a.readBool()?0:_;T<=_;T++)a.readUEG(),a.readUEG(),a.readUEG();if(a.readUEG(),a.readUEG(),a.readUEG(),a.readUEG(),a.readUEG(),a.readUEG(),a.readBool()&&a.readBool())for(var O=0;O<4;O++)for(var I=0;I<(3===O?2:6);I++)if(a.readBool()){var P=Math.min(64,1<<4+(O<<1));for(O>1&&a.readSEG(),T=0;T<P;T++)a.readSEG()}else a.readUEG();a.readBool(),a.readBool(),a.readBool()&&(a.readByte(),a.readUEG(),a.readUEG(),a.readBool());var B=a.readUEG(),U=0;for(T=0;T<B;T++){var N=!1;if(0!==T&&(N=a.readBool()),N){T===B&&a.readUEG(),a.readBool(),a.readUEG();for(var F=0,V=0;V<=U;V++){var j=a.readBool(),G=!1;j||(G=a.readBool()),(j||G)&&F++}U=F}else{var H=a.readUEG(),z=a.readUEG();for(U=H+z,V=0;V<H;V++)a.readUEG(),a.readBool();for(V=0;V<z;V++)a.readUEG(),a.readBool()}}if(a.readBool()){var W=a.readUEG();for(T=0;T<W;T++){for(V=0;V<D+4;V++)a.readBits(1);a.readBits(1)}}var q=0,Y=1,K=1,X=!1,Q=1,J=1;if(a.readBool(),a.readBool(),a.readBool()){if(a.readBool()){var Z=a.readByte();Z>0&&Z<=16?(Y=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][Z-1],K=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][Z-1]):255===Z&&(Y=a.readBits(16),K=a.readBits(16))}if(a.readBool()&&a.readBool(),a.readBool()&&(a.readBits(3),a.readBool(),a.readBool()&&(a.readByte(),a.readByte(),a.readByte())),a.readBool()&&(a.readUEG(),a.readUEG()),a.readBool(),a.readBool(),a.readBool(),a.readBool()&&(a.readUEG(),a.readUEG(),a.readUEG(),a.readUEG()),a.readBool()&&(Q=a.readBits(32),J=a.readBits(32),a.readBool()&&a.readUEG(),a.readBool())){var $,ee,te=!1;for($=a.readBool(),ee=a.readBool(),($||ee)&&((te=a.readBool())&&(a.readByte(),a.readBits(5),a.readBool(),a.readBits(5)),a.readBits(4),a.readBits(4),te&&a.readBits(4),a.readBits(5),a.readBits(5),a.readBits(5)),T=0;T<=_;T++){var ie=a.readBool();X=ie;var ae=!0,re=1;ie||(ae=a.readBool());var ne=!1;if(ae?a.readUEG():ne=a.readBool(),ne||(re=a.readUEG()+1),$){for(V=0;V<re;V++)a.readUEG(),a.readUEG(),te&&(a.readUEG(),a.readUEG());a.readBool()}if(ee){for(V=0;V<re;V++)a.readUEG(),a.readUEG(),te&&(a.readUEG(),a.readUEG());a.readBool()}}}a.readBool()&&(a.readBool(),a.readBool(),a.readBool(),q=a.readUEG(),a.readUEG(),a.readUEG(),a.readUEG(),a.readUEG())}a.readBool();var se="hvc1.".concat(u,".1.L").concat(A,".B0"),oe=R-(r+n)*(1===L||2===L?2:1),_e=C-(s+o)*(1===L?2:1),de=1;return 1!==Y&&1!==K&&(de=Y/K),a.destroy(),a=null,{codec_mimetype:se,profile_string:e.getProfileString(u),level_string:e.getLevelString(A),profile_idc:u,bit_depth:x+8,ref_frames:1,chroma_format:L,chroma_format_string:e.getChromaFormatString(L),general_level_idc:A,general_profile_space:d,general_tier_flag:l,general_profile_idc:u,general_profile_compatibility_flags_1:c,general_profile_compatibility_flags_2:h,general_profile_compatibility_flags_3:p,general_profile_compatibility_flags_4:m,general_constraint_indicator_flags_1:g,general_constraint_indicator_flags_2:y,general_constraint_indicator_flags_3:v,general_constraint_indicator_flags_4:b,general_constraint_indicator_flags_5:E,general_constraint_indicator_flags_6:S,min_spatial_segmentation_idc:q,constant_frame_rate:0,chroma_format_idc:L,bit_depth_luma_minus8:x,bit_depth_chroma_minus8:M,frame_rate:{fixed:X,fps:J/Q,fps_den:Q,fps_num:J},sar_ratio:{width:Y,height:K},codec_size:{width:oe,height:_e},present_size:{width:oe*de,height:_e}}},e.parsePPS=function(t){var i=e._ebsp2rbsp(t),a=new f(i);a.readByte(),a.readByte(),a.readUEG(),a.readUEG(),a.readBool(),a.readBool(),a.readBits(3),a.readBool(),a.readBool(),a.readUEG(),a.readUEG(),a.readSEG(),a.readBool(),a.readBool(),a.readBool()&&a.readUEG(),a.readSEG(),a.readSEG(),a.readBool(),a.readBool(),a.readBool(),a.readBool();var r=a.readBool(),n=a.readBool(),s=1;return n&&r?s=0:n?s=3:r&&(s=2),{parallelismType:s}},e.getChromaFormatString=function(e){switch(e){case 0:return"4:0:0";case 1:return"4:2:0";case 2:return"4:2:2";case 3:return"4:4:4";default:return"Unknown"}},e.getProfileString=function(e){switch(e){case 1:return"Main";case 2:return"Main10";case 3:return"MainSP";case 4:return"Rext";case 9:return"SCC";default:return"Unknown"}},e.getLevelString=function(e){return(e/30).toFixed(1)},e}();function y(e){return e.byteOffset%2==0&&e.byteLength%2==0}function v(e){return e.byteOffset%4==0&&e.byteLength%4==0}function b(e,t){for(var i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}var E,S=function(e,t){return e.byteLength===t.byteLength&&(v(e)&&v(t)?function(e,t){return b(new Uint32Array(e.buffer,e.byteOffset,e.byteLength/4),new Uint32Array(t.buffer,t.byteOffset,t.byteLength/4))}(e,t):y(e)&&y(t)?function(e,t){return b(new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2))}(e,t):function(e,t){return b(e,t)}(e,t))},A=function(){return(A=Object.assign||function(e){for(var t,i=1,a=arguments.length;i<a;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},w=function(){function e(){}return e.parseOBUs=function(t,i){for(var a=0;a<t.byteLength;){var r=a,n=(t[a],(120&t[a])>>3),s=!!(4&t[a]),o=!!(2&t[a]);t[a],a+=1,s&&(a+=1);var _=Number.POSITIVE_INFINITY;if(o){_=0;for(var d=0;;d++){var l=t[a++];if(_|=(127&l)<<7*d,!(128&l))break}}1===n?i=A(A({},e.parseSeuqneceHeader(t.subarray(a,a+_))),{sequence_header_data:t.subarray(r,a+_)}):(3==n&&i||6==n&&i)&&(i=e.parseOBUFrameHeader(t.subarray(a,a+_),0,0,i)),a+=_}return i},e.parseSeuqneceHeader=function(t){var i=new f(t),a=i.readBits(3),r=(i.readBool(),i.readBool()),n=!0,s=0,o=1,_=void 0,d=[];if(r)d.push({operating_point_idc:0,level:i.readBits(5),tier:0});else{if(i.readBool()){var l=i.readBits(32),u=i.readBits(32),c=i.readBool();if(c){for(var h=0;0===i.readBits(1);)h+=1;h>=32||i.readBits(h)}s=u,o=l,n=c,i.readBool()&&(i.readBits(5),i.readBits(32),_=i.readBits(5),i.readBits(5))}for(var p=i.readBool(),m=i.readBits(5),g=0;g<=m;g++){var y=i.readBits(12),v=i.readBits(5),b=v>7?i.readBits(1):0;d.push({operating_point_idc:y,level:v,tier:b}),p&&i.readBool()&&i.readBits(4)}}var E=d[0],S=E.level,A=E.tier,w=i.readBits(4),k=i.readBits(4),T=i.readBits(w+1)+1,L=i.readBits(k+1)+1,R=!1;r||(R=i.readBool()),R&&(i.readBits(4),i.readBits(4)),i.readBool(),i.readBool(),i.readBool();var C=!1,x=2,M=2,D=0;r||(i.readBool(),i.readBool(),i.readBool(),i.readBool(),(C=i.readBool())&&(i.readBool(),i.readBool()),M=(x=i.readBool()?2:i.readBits(1))?i.readBool()?2:i.readBits(1):2,D=C?i.readBits(3)+1:0);var O=i.readBool(),I=(i.readBool(),i.readBool(),i.readBool()),P=8;P=2===a&&I?i.readBool()?12:10:I?10:8;var B=!1;1!==a&&(B=i.readBool()),i.readBool()&&(i.readBits(8),i.readBits(8),i.readBits(8));var U=1,N=1;return B?(i.readBits(1),U=1,N=1):(i.readBits(1),0==a?(U=1,N=1):1==a?(U=0,N=0):12==P?i.readBits(1)&&i.readBits(1):(U=1,N=0),U&&N&&i.readBits(2),i.readBits(1)),i.readBool(),i.destroy(),i=null,{codec_mimetype:"av01.".concat(a,".").concat(e.getLevelString(S,A),".").concat(P.toString(10).padStart(2,"0")),level:S,tier:A,level_string:e.getLevelString(S,A),profile_idc:a,profile_string:"".concat(a),bit_depth:P,ref_frames:1,chroma_format:e.getChromaFormat(B,U,N),chroma_format_string:e.getChromaFormatString(B,U,N),sequence_header:{frame_id_numbers_present_flag:R,additional_frame_id_length_minus_1:void 0,delta_frame_id_length_minus_2:void 0,reduced_still_picture_header:r,decoder_model_info_present_flag:!1,operating_points:d,buffer_removal_time_length_minus_1:_,equal_picture_interval:n,seq_force_screen_content_tools:x,seq_force_integer_mv:M,enable_order_hint:C,order_hint_bits:D,enable_superres:O,frame_width_bit:w+1,frame_height_bit:k+1,max_frame_width:T,max_frame_height:L},keyframe:void 0,frame_rate:{fixed:n,fps:s/o,fps_den:o,fps_num:s}}},e.parseOBUFrameHeader=function(t,i,a,r){var n=r.sequence_header,s=new f(t),o=(n.max_frame_width,n.max_frame_height,0);n.frame_id_numbers_present_flag&&(o=n.additional_frame_id_length_minus_1+n.delta_frame_id_length_minus_2+3);var _=0,d=!0,l=!0,u=!1;if(!n.reduced_still_picture_header){if(s.readBool())return r;d=2===(_=s.readBits(2))||0===_,(l=s.readBool())&&n.decoder_model_info_present_flag&&n.equal_picture_interval,l&&s.readBool(),u=!!(3===_||0===_&&l)||s.readBool()}r.keyframe=d,s.readBool();var c,h=n.seq_force_screen_content_tools;if(2===n.seq_force_screen_content_tools&&(h=s.readBits(1)),h&&(n.seq_force_integer_mv,2==n.seq_force_integer_mv&&s.readBits(1)),n.frame_id_numbers_present_flag&&s.readBits(o),c=3==_||!n.reduced_still_picture_header&&s.readBool(),s.readBits(n.order_hint_bits),d||u||s.readBits(3),n.decoder_model_info_present_flag&&s.readBool())for(var p=0;p<=n.operating_points_cnt_minus_1;p++)if(n.operating_points[p].decoder_model_present_for_this_op[p]){var m=n.operating_points[p].operating_point_idc;(0===m||m>>i&1&&m>>a+8&1)&&s.readBits(n.buffer_removal_time_length_minus_1+1)}var g=255;if(3===_||0==_&&l||(g=s.readBits(8)),(d||255!==g)&&u&&n.enable_order_hint)for(var y=0;y<8;y++)s.readBits(n.order_hint_bits);if(d){var v=e.frameSizeAndRenderSize(s,c,n);r.codec_size={width:v.FrameWidth,height:v.FrameHeight},r.present_size={width:v.RenderWidth,height:v.RenderHeight},r.sar_ratio={width:v.RenderWidth/v.FrameWidth,height:v.RenderHeight/v.FrameHeight}}return s.destroy(),s=null,r},e.frameSizeAndRenderSize=function(e,t,i){var a=i.max_frame_width,r=i.max_frame_height;t&&(a=e.readBits(i.frame_width_bit)+1,r=e.readBits(i.frame_height_bit)+1);var n=!1;i.enable_superres&&(n=e.readBool());var s=8;n&&(s=e.readBits(3)+9);var o=a;a=Math.floor((8*o+s/2)/s);var _=o,d=r;if(e.readBool()){var l=e.readBits(16)+1,u=e.readBits(16)+1;_=e.readBits(l)+1,d=e.readBits(u)+1}return{UpscaledWidth:o,FrameWidth:a,FrameHeight:r,RenderWidth:_,RenderHeight:d}},e.getLevelString=function(e,t){return"".concat(e.toString(10).padStart(2,"0")).concat(0===t?"M":"H")},e.getChromaFormat=function(e,t,i){return e?0:0===t&&0===i?3:1===t&&0===i?2:1===t&&1===i?1:Number.NaN},e.getChromaFormatString=function(e,t,i){return e?"4:0:0":0===t&&0===i?"4:4:4":1===t&&0===i?"4:2:2":1===t&&1===i?"4:2:0":"Unknown"},e}(),k=function(){function e(e,t){this.TAG="FLVDemuxer",this._config=t,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=e.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=e.hasAudioTrack,this._hasVideo=e.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new o.a,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){var e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}()}return e.prototype.destroy=function(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null},e.probe=function(e){var t=new Uint8Array(e);if(t.byteLength<9)return{needMoreData:!0};var i={match:!1};if(70!==t[0]||76!==t[1]||86!==t[2]||1!==t[3])return i;var a,r=(4&t[4])>>>2!=0,n=!!(1&t[4]),s=(a=t)[5]<<24|a[6]<<16|a[7]<<8|a[8];return s<9?i:{match:!0,consumed:s,dataOffset:s,hasAudioTrack:r,hasVideoTrack:n}},e.prototype.bindDataSource=function(e){return e.onDataArrival=this.parseChunks.bind(this),this},Object.defineProperty(e.prototype,"onTrackMetadata",{get:function(){return this._onTrackMetadata},set:function(e){this._onTrackMetadata=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaInfo",{get:function(){return this._onMediaInfo},set:function(e){this._onMediaInfo=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMetaDataArrived",{get:function(){return this._onMetaDataArrived},set:function(e){this._onMetaDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onScriptDataArrived",{get:function(){return this._onScriptDataArrived},set:function(e){this._onScriptDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataAvailable",{get:function(){return this._onDataAvailable},set:function(e){this._onDataAvailable=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timestampBase",{get:function(){return this._timestampBase},set:function(e){this._timestampBase=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedDuration",{get:function(){return this._duration},set:function(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasAudio",{set:function(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasVideo",{set:function(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e},enumerable:!1,configurable:!0}),e.prototype.resetMediaInfo=function(){this._mediaInfo=new o.a},e.prototype._isInitialMetadataDispatched=function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched},e.prototype.parseChunks=function(t,i){if(!(this._onError&&this._onMediaInfo&&this._onTrackMetadata&&this._onDataAvailable))throw new u.a("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var a=0,r=this._littleEndian;if(0===i){if(!(t.byteLength>13))return 0;a=e.probe(t).dataOffset}for(this._firstParse&&(this._firstParse=!1,i+a!==this._dataOffset&&n.a.w(this.TAG,"First time parsing but chunk byteStart invalid!"),0!==(s=new DataView(t,a)).getUint32(0,!r)&&n.a.w(this.TAG,"PrevTagSize0 !== 0 !!!"),a+=4);a<t.byteLength;){this._dispatch=!0;var s=new DataView(t,a);if(a+11+4>t.byteLength)break;var o=s.getUint8(0),_=16777215&s.getUint32(0,!r);if(a+11+_+4>t.byteLength)break;if(8===o||9===o||18===o){var d=s.getUint8(4),l=s.getUint8(5),c=s.getUint8(6)|l<<8|d<<16|s.getUint8(7)<<24;16777215&s.getUint32(7,!r)&&n.a.w(this.TAG,"Meet tag which has StreamID != 0!");var h=a+11;switch(o){case 8:this._parseAudioData(t,h,_,c);break;case 9:this._parseVideoData(t,h,_,c,i+a);break;case 18:this._parseScriptData(t,h,_)}var f=s.getUint32(11+_,!r);f!==11+_&&n.a.w(this.TAG,"Invalid PrevTagSize ".concat(f)),a+=11+_+4}else n.a.w(this.TAG,"Unsupported tag type ".concat(o,", skipped")),a+=11+_+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),a},e.prototype._parseScriptData=function(e,t,i){var a=h.parseScriptData(e,t,i);if(a.hasOwnProperty("onMetaData")){if(null==a.onMetaData||"object"!=typeof a.onMetaData)return void n.a.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&n.a.w(this.TAG,"Found another onMetaData tag!"),this._metadata=a;var r=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},r)),"boolean"==typeof r.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=r.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"==typeof r.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=r.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"==typeof r.audiodatarate&&(this._mediaInfo.audioDataRate=r.audiodatarate),"number"==typeof r.videodatarate&&(this._mediaInfo.videoDataRate=r.videodatarate),"number"==typeof r.width&&(this._mediaInfo.width=r.width),"number"==typeof r.height&&(this._mediaInfo.height=r.height),"number"==typeof r.duration){if(!this._durationOverrided){var s=Math.floor(r.duration*this._timescale);this._duration=s,this._mediaInfo.duration=s}}else this._mediaInfo.duration=0;if("number"==typeof r.framerate){var o=Math.floor(1e3*r.framerate);if(o>0){var _=o/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=_,this._referenceFrameRate.fps_num=o,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=_}}if("object"==typeof r.keyframes){this._mediaInfo.hasKeyframesIndex=!0;var d=r.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(d),r.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=r,n.a.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(a).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},a))},e.prototype._parseKeyframesIndex=function(e){for(var t=[],i=[],a=1;a<e.times.length;a++){var r=this._timestampBase+Math.floor(1e3*e.times[a]);t.push(r),i.push(e.filepositions[a])}return{times:t,filepositions:i}},e.prototype._parseAudioData=function(e,t,i,a){if(i<=1)n.a.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");else if(!0!==this._hasAudioFlagOverrided||!1!==this._hasAudio){this._littleEndian;var r=new DataView(e,t,i).getUint8(0),s=r>>>4;if(9!==s)if(2===s||10===s){var o=0,_=(12&r)>>>2;if(_>=0&&_<=4){o=this._flvSoundRateTable[_];var d=1&r,l=this._audioMetadata,u=this._audioTrack;if(l||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),(l=this._audioMetadata={}).type="audio",l.id=u.id,l.timescale=this._timescale,l.duration=this._duration,l.audioSampleRate=o,l.channelCount=0===d?1:2),10===s){var c=this._parseAACAudioData(e,t+1,i-1);if(null==c)return;if(0===c.packetType){if(l.config){if(S(c.data.config,l.config))return;n.a.w(this.TAG,"AudioSpecificConfig has been changed, re-generate initialization segment")}var h=c.data;l.audioSampleRate=h.samplingRate,l.channelCount=h.channelCount,l.codec=h.codec,l.originalCodec=h.originalCodec,l.config=h.config,l.refSampleDuration=1024/l.audioSampleRate*l.timescale,n.a.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",l),(g=this._mediaInfo).audioCodec=l.originalCodec,g.audioSampleRate=l.audioSampleRate,g.audioChannelCount=l.channelCount,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}else if(1===c.packetType){var f=this._timestampBase+a,p={unit:c.data,length:c.data.byteLength,dts:f,pts:f};u.samples.push(p),u.length+=c.data.length}else n.a.e(this.TAG,"Flv: Unsupported AAC data type ".concat(c.packetType))}else if(2===s){if(!l.codec){var g;if(null==(h=this._parseMP3AudioData(e,t+1,i-1,!0)))return;l.audioSampleRate=h.samplingRate,l.channelCount=h.channelCount,l.codec=h.codec,l.originalCodec=h.originalCodec,l.refSampleDuration=1152/l.audioSampleRate*l.timescale,n.a.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",l),(g=this._mediaInfo).audioCodec=l.codec,g.audioSampleRate=l.audioSampleRate,g.audioChannelCount=l.channelCount,g.audioDataRate=h.bitRate,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}var y=this._parseMP3AudioData(e,t+1,i-1,!1);if(null==y)return;f=this._timestampBase+a;var v={unit:y,length:y.byteLength,dts:f,pts:f};u.samples.push(v),u.length+=y.length}}else this._onError(m.a.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+_)}else this._onError(m.a.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+s);else{if(i<=5)return void n.a.w(this.TAG,"Flv: Invalid audio packet, missing AudioFourCC in Ehnanced FLV payload!");var b=15&r,E=String.fromCharCode.apply(String,new Uint8Array(e,t,i).slice(1,5));switch(E){case"Opus":this._parseOpusAudioPacket(e,t+5,i-5,a,b);break;case"fLaC":this._parseFlacAudioPacket(e,t+5,i-5,a,b);break;default:this._onError(m.a.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec: "+E)}}}},e.prototype._parseAACAudioData=function(e,t,i){if(!(i<=1)){var a={},r=new Uint8Array(e,t,i);return a.packetType=r[0],0===r[0]?a.data=this._parseAACAudioSpecificConfig(e,t+1,i-1):a.data=r.subarray(1),a}n.a.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!")},e.prototype._parseAACAudioSpecificConfig=function(e,t,i){var a,r,n=new Uint8Array(e,t,i),s=null,o=0,_=null;if(o=a=n[0]>>>3,(r=(7&n[0])<<1|n[1]>>>7)<0||r>=this._mpegSamplingRates.length)this._onError(m.a.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");else{var d=this._mpegSamplingRates[r],l=(120&n[1])>>>3;if(!(l<0||l>=8)){5===o&&(_=(7&n[1])<<1|n[2]>>>7,n[2]);var u=self.navigator.userAgent.toLowerCase();return-1!==u.indexOf("firefox")?r>=6?(o=5,s=new Array(4),_=r-3):(o=2,s=new Array(2),_=r):-1!==u.indexOf("android")?(o=2,s=new Array(2),_=r):(o=5,_=r,s=new Array(4),r>=6?_=r-3:1===l&&(o=2,s=new Array(2),_=r)),s[0]=o<<3,s[0]|=(15&r)>>>1,s[1]=(15&r)<<7,s[1]|=(15&l)<<3,5===o&&(s[1]|=(15&_)>>>1,s[2]=(1&_)<<7,s[2]|=8,s[3]=0),{config:s,samplingRate:d,channelCount:l,codec:"mp4a.40."+o,originalCodec:"mp4a.40."+a}}this._onError(m.a.FORMAT_ERROR,"Flv: AAC invalid channel configuration")}},e.prototype._parseMP3AudioData=function(e,t,i,a){if(!(i<4)){this._littleEndian;var r=new Uint8Array(e,t,i),s=null;if(a){if(255!==r[0])return;var o=r[1]>>>3&3,_=(6&r[1])>>1,d=(240&r[2])>>>4,l=(12&r[2])>>>2,u=3&~(r[3]>>>6)?2:1,c=0,h=0;switch(o){case 0:c=this._mpegAudioV25SampleRateTable[l];break;case 2:c=this._mpegAudioV20SampleRateTable[l];break;case 3:c=this._mpegAudioV10SampleRateTable[l]}switch(_){case 1:d<this._mpegAudioL3BitRateTable.length&&(h=this._mpegAudioL3BitRateTable[d]);break;case 2:d<this._mpegAudioL2BitRateTable.length&&(h=this._mpegAudioL2BitRateTable[d]);break;case 3:d<this._mpegAudioL1BitRateTable.length&&(h=this._mpegAudioL1BitRateTable[d])}s={bitRate:h,samplingRate:c,channelCount:u,codec:"mp3",originalCodec:"mp3"}}else s=r;return s}n.a.w(this.TAG,"Flv: Invalid MP3 packet, header missing!")},e.prototype._parseOpusAudioPacket=function(e,t,i,a,r){if(0===r)this._parseOpusSequenceHeader(e,t,i);else if(1===r)this._parseOpusAudioData(e,t,i,a);else if(2!==r)return void this._onError(m.a.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(r))},e.prototype._parseOpusSequenceHeader=function(e,t,i){if(i<=16)n.a.w(this.TAG,"Flv: Invalid OpusSequenceHeader, lack of data!");else{var a=this._audioMetadata,r=this._audioTrack;a||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),(a=this._audioMetadata={}).type="audio",a.id=r.id,a.timescale=this._timescale,a.duration=this._duration);var s=new DataView(e,t,i);s.setUint8(8,0);var o=s.getUint8(9);s.setUint16(10,s.getUint16(10,!0),!1);var _=s.getUint32(12,!0);s.setUint32(12,s.getUint32(12,!0),!1);var d={config:new Uint8Array(e,t+8,i-8),channelCount:o,samplingFrequence:_,codec:"opus",originalCodec:"opus"};if(a.config){if(S(d.config,a.config))return;n.a.w(this.TAG,"OpusSequenceHeader has been changed, re-generate initialization segment")}a.audioSampleRate=d.samplingFrequence,a.channelCount=d.channelCount,a.codec=d.codec,a.originalCodec=d.originalCodec,a.config=d.config,a.refSampleDuration=20,n.a.v(this.TAG,"Parsed OpusSequenceHeader"),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 l=this._mediaInfo;l.audioCodec=a.originalCodec,l.audioSampleRate=a.audioSampleRate,l.audioChannelCount=a.channelCount,l.hasVideo?null!=l.videoCodec&&(l.mimeType='video/x-flv; codecs="'+l.videoCodec+","+l.audioCodec+'"'):l.mimeType='video/x-flv; codecs="'+l.audioCodec+'"',l.isComplete()&&this._onMediaInfo(l)}},e.prototype._parseOpusAudioData=function(e,t,i,a){var r=this._audioTrack,n=new Uint8Array(e,t,i),s=this._timestampBase+a,o={unit:n,length:n.byteLength,dts:s,pts:s};r.samples.push(o),r.length+=n.length},e.prototype._parseFlacAudioPacket=function(e,t,i,a,r){if(0===r)this._parseFlacSequenceHeader(e,t,i);else if(1===r)this._parseFlacAudioData(e,t,i,a);else if(2!==r)return void this._onError(m.a.FORMAT_ERROR,"Flv: Invalid Flac audio packet type ".concat(r))},e.prototype._parseFlacSequenceHeader=function(e,t,i){var a=this._audioMetadata,r=this._audioTrack;a||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),(a=this._audioMetadata={}).type="audio",a.id=r.id,a.timescale=this._timescale,a.duration=this._duration);var s=new Uint8Array(e,t+4,i-4),o=new f(s),_=o.readBits(16),d=o.readBits(16),l=d===_?d:null;o.readBits(24),o.readBits(24);var u=o.readBits(20),c=o.readBits(3)+1,h=o.readBits(5)+1;o.destroy();var p=new Uint8Array(s.byteLength+4);p.set(s,4),p[0]=128,p[1]=s.byteLength>>>16&255,p[2]=s.byteLength>>>8&255,p[3]=s.byteLength>>>0&255;var m={config:p,channelCount:c,samplingFrequence:u,sampleSize:h,codec:"flac",originalCodec:"flac"};if(a.config){if(S(m.config,a.config))return;n.a.w(this.TAG,"FlacSequenceHeader has been changed, re-generate initialization segment")}a.audioSampleRate=m.samplingFrequence,a.channelCount=m.channelCount,a.sampleSize=m.sampleSize,a.codec=m.codec,a.originalCodec=m.originalCodec,a.config=m.config,a.refSampleDuration=null!=l?1e3*l/m.samplingFrequence:null,n.a.v(this.TAG,"Parsed FlacSequenceHeader"),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 g=this._mediaInfo;g.audioCodec=a.originalCodec,g.audioSampleRate=a.audioSampleRate,g.audioChannelCount=a.channelCount,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)},e.prototype._parseFlacAudioData=function(e,t,i,a){var r=this._audioTrack,n=new Uint8Array(e,t,i),s=this._timestampBase+a,o={unit:n,length:n.byteLength,dts:s,pts:s};r.samples.push(o),r.length+=n.length},e.prototype._parseVideoData=function(e,t,i,a,r){if(i<=1)n.a.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");else if(!0!==this._hasVideoFlagOverrided||!1!==this._hasVideo){var s=new Uint8Array(e,t,i)[0],o=(112&s)>>>4;if(128&s){var _=15&s,d=String.fromCharCode.apply(String,new Uint8Array(e,t,i).slice(1,5));if("hvc1"===d)this._parseEnhancedHEVCVideoPacket(e,t+5,i-5,a,r,o,_);else{if("av01"!==d)return void this._onError(m.a.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: ".concat(d));this._parseEnhancedAV1VideoPacket(e,t+5,i-5,a,r,o,_)}}else{var l=15&s;if(7===l)this._parseAVCVideoPacket(e,t+1,i-1,a,r,o);else{if(12!==l)return void this._onError(m.a.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: ".concat(l));this._parseHEVCVideoPacket(e,t+1,i-1,a,r,o)}}}},e.prototype._parseAVCVideoPacket=function(e,t,i,a,r,s){if(i<4)n.a.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");else{var o=this._littleEndian,_=new DataView(e,t,i),d=_.getUint8(0),l=(16777215&_.getUint32(0,!o))<<8>>8;if(0===d)this._parseAVCDecoderConfigurationRecord(e,t+4,i-4);else if(1===d)this._parseAVCVideoData(e,t+4,i-4,a,r,s,l);else if(2!==d)return void this._onError(m.a.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(d))}},e.prototype._parseHEVCVideoPacket=function(e,t,i,a,r,s){if(i<4)n.a.w(this.TAG,"Flv: Invalid HEVC packet, missing HEVCPacketType or/and CompositionTime");else{var o=this._littleEndian,_=new DataView(e,t,i),d=_.getUint8(0),l=(16777215&_.getUint32(0,!o))<<8>>8;if(0===d)this._parseHEVCDecoderConfigurationRecord(e,t+4,i-4);else if(1===d)this._parseHEVCVideoData(e,t+4,i-4,a,r,s,l);else if(2!==d)return void this._onError(m.a.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(d))}},e.prototype._parseEnhancedHEVCVideoPacket=function(e,t,i,a,r,n,s){var o=this._littleEndian,_=new DataView(e,t,i);if(0===s)this._parseHEVCDecoderConfigurationRecord(e,t,i);else if(1===s){var d=(4294967040&_.getUint32(0,!o))>>8;this._parseHEVCVideoData(e,t+3,i-3,a,r,n,d)}else if(3===s)this._parseHEVCVideoData(e,t,i,a,r,n,0);else if(2!==s)return void this._onError(m.a.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(s))},e.prototype._parseEnhancedAV1VideoPacket=function(e,t,i,a,r,n,s){if(this._littleEndian,new DataView(e,t,i),0===s)this._parseAV1CodecConfigurationRecord(e,t,i);else if(1===s)this._parseAV1VideoData(e,t,i,a,r,n,0);else{if(5===s)return void this._onError(m.a.FORMAT_ERROR,"Flv: Not Supported MP2T AV1 video packet type ".concat(s));if(2!==s)return void this._onError(m.a.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(s))}},e.prototype._parseAVCDecoderConfigurationRecord=function(e,t,i){if(i<7)n.a.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");else{var a=this._videoMetadata,r=this._videoTrack,s=this._littleEndian,o=new DataView(e,t,i);if(a){if(void 0!==a.avcc){var _=new Uint8Array(e,t,i);if(S(_,a.avcc))return;n.a.w(this.TAG,"AVCDecoderConfigurationRecord has been changed, re-generate initialization segment")}}else!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),(a=this._videoMetadata={}).type="video",a.id=r.id,a.timescale=this._timescale,a.duration=this._duration;var d=o.getUint8(0),l=o.getUint8(1);if(o.getUint8(2),o.getUint8(3),1===d&&0!==l)if(this._naluLengthSize=1+(3&o.getUint8(4)),3===this._naluLengthSize||4===this._naluLengthSize){var u=31&o.getUint8(5);if(0!==u){u>1&&n.a.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = ".concat(u));for(var c=6,h=0;h<u;h++){var f=o.getUint16(c,!s);if(c+=2,0!==f){var g=new Uint8Array(e,t+c,f);c+=f;var y=p.parseSPS(g);if(0===h){a.codecWidth=y.codec_size.width,a.codecHeight=y.codec_size.height,a.presentWidth=y.present_size.width,a.presentHeight=y.present_size.height,a.profile=y.profile_string,a.level=y.level_string,a.bitDepth=y.bit_depth,a.chromaFormat=y.chroma_format,a.sarRatio=y.sar_ratio,a.frameRate=y.frame_rate,!1!==y.frame_rate.fixed&&0!==y.frame_rate.fps_num&&0!==y.frame_rate.fps_den||(a.frameRate=this._referenceFrameRate);var v=a.frameRate.fps_den,b=a.frameRate.fps_num;a.refSampleDuration=a.timescale*(v/b);for(var E=g.subarray(1,4),A="avc1.",w=0;w<3;w++){var k=E[w].toString(16);k.length<2&&(k="0"+k),A+=k}a.codec=A;var T=this._mediaInfo;T.width=a.codecWidth,T.height=a.codecHeight,T.fps=a.frameRate.fps,T.profile=a.profile,T.level=a.level,T.refFrames=y.ref_frames,T.chromaFormat=y.chroma_format_string,T.sarNum=a.sarRatio.width,T.sarDen=a.sarRatio.height,T.videoCodec=A,T.hasAudio?null!=T.audioCodec&&(T.mimeType='video/x-flv; codecs="'+T.videoCodec+","+T.audioCodec+'"'):T.mimeType='video/x-flv; codecs="'+T.videoCodec+'"',T.isComplete()&&this._onMediaInfo(T)}}}var L=o.getUint8(c);if(0!==L){for(L>1&&n.a.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = ".concat(L)),c++,h=0;h<L;h++)f=o.getUint16(c,!s),c+=2,0!==f&&(c+=f);a.avcc=new Uint8Array(i),a.avcc.set(new Uint8Array(e,t,i),0),n.a.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",a)}else this._onError(m.a.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS")}else this._onError(m.a.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS")}else this._onError(m.a.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: ".concat(this._naluLengthSize-1));else this._onError(m.a.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord")}},e.prototype._parseHEVCDecoderConfigurationRecord=function(e,t,i){if(i<22)n.a.w(this.TAG,"Flv: Invalid HEVCDecoderConfigurationRecord, lack of data!");else{var a=this._videoMetadata,r=this._videoTrack,s=this._littleEndian,o=new DataView(e,t,i);if(a){if(void 0!==a.hvcc){var _=new Uint8Array(e,t,i);if(S(_,a.hvcc))return;n.a.w(this.TAG,"HEVCDecoderConfigurationRecord has been changed, re-generate initialization segment")}}else!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),(a=this._videoMetadata={}).type="video",a.id=r.id,a.timescale=this._timescale,a.duration=this._duration;var d=o.getUint8(0),l=31&o.getUint8(1);if(0!==d&&1!==d||0===l)this._onError(m.a.FORMAT_ERROR,"Flv: Invalid HEVCDecoderConfigurationRecord");else if(this._naluLengthSize=1+(3&o.getUint8(21)),3===this._naluLengthSize||4===this._naluLengthSize){for(var u=o.getUint8(22),c=0,h=23;c<u;c++){var f=63&o.getUint8(h+0),p=o.getUint16(h+1,!s);h+=3;for(var y=0;y<p;y++){var v=o.getUint16(h+0,!s);if(0===y)if(33===f){h+=2;var b=new Uint8Array(e,t+h,v),E=g.parseSPS(b);a.codecWidth=E.codec_size.width,a.codecHeight=E.codec_size.height,a.presentWidth=E.present_size.width,a.presentHeight=E.present_size.height,a.profile=E.profile_string,a.level=E.level_string,a.bitDepth=E.bit_depth,a.chromaFormat=E.chroma_format,a.sarRatio=E.sar_ratio,a.frameRate=E.frame_rate,!1!==E.frame_rate.fixed&&0!==E.frame_rate.fps_num&&0!==E.frame_rate.fps_den||(a.frameRate=this._referenceFrameRate);var A=a.frameRate.fps_den,w=a.frameRate.fps_num;a.refSampleDuration=a.timescale*(A/w),a.codec=E.codec_mimetype;var k=this._mediaInfo;k.width=a.codecWidth,k.height=a.codecHeight,k.fps=a.frameRate.fps,k.profile=a.profile,k.level=a.level,k.refFrames=E.ref_frames,k.chromaFormat=E.chroma_format_string,k.sarNum=a.sarRatio.width,k.sarDen=a.sarRatio.height,k.videoCodec=E.codec_mimetype,k.hasAudio?null!=k.audioCodec&&(k.mimeType='video/x-flv; codecs="'+k.videoCodec+","+k.audioCodec+'"'):k.mimeType='video/x-flv; codecs="'+k.videoCodec+'"',k.isComplete()&&this._onMediaInfo(k),h+=v}else h+=2+v;else h+=2+v}}a.hvcc=new Uint8Array(i),a.hvcc.set(new Uint8Array(e,t,i),0),n.a.v(this.TAG,"Parsed HEVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",a)}else this._onError(m.a.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: ".concat(this._naluLengthSize-1))}},e.prototype._parseAV1CodecConfigurationRecord=function(e,t,i){if(i<4)n.a.w(this.TAG,"Flv: Invalid AV1CodecConfigurationRecord, lack of data!");else{var a=this._videoMetadata,r=this._videoTrack,s=(this._littleEndian,new DataView(e,t,i));a?void 0!==a.av1c&&n.a.w(this.TAG,"Found another AV1CodecConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),(a=this._videoMetadata={}).type="video",a.id=r.id,a.timescale=this._timescale,a.duration=this._duration);var o=127&s.getUint8(0);if(s.getUint8(1),s.getUint8(1),s.getUint8(2),1===o){var _=w.parseOBUs(new Uint8Array(e,t+4,i-4));if(null!=_){a.profile=_.profile_string,a.level=_.level_string,a.bitDepth=_.bit_depth,a.chromaFormat=_.chroma_format,a.frameRate=_.frame_rate,!1!==_.frame_rate.fixed&&0!==_.frame_rate.fps_num&&0!==_.frame_rate.fps_den||(a.frameRate=this._referenceFrameRate);var d=a.frameRate.fps_den,l=a.frameRate.fps_num;a.refSampleDuration=a.timescale*(d/l),a.codec=_.codec_mimetype,a.extra=_;var u=this._mediaInfo;u.fps=a.frameRate.fps,u.profile=a.profile,u.level=a.level,u.refFrames=_.ref_frames,u.chromaFormat=_.chroma_format_string,u.videoCodec=_.codec_mimetype,u.hasAudio?null!=u.audioCodec&&(u.mimeType='video/x-flv; codecs="'+u.videoCodec+","+u.audioCodec+'"'):u.mimeType='video/x-flv; codecs="'+u.videoCodec+'"',u.isComplete()&&this._onMediaInfo(u),a.av1c=new Uint8Array(i),a.av1c.set(new Uint8Array(e,t,i),0),n.a.v(this.TAG,"Preparing AV1CodecConfigurationRecord")}else this._onError(m.a.FORMAT_ERROR,"Flv: Invalid AV1CodecConfigurationRecord")}else this._onError(m.a.FORMAT_ERROR,"Flv: Invalid AV1CodecConfigurationRecord")}},e.prototype._parseAVCVideoData=function(e,t,i,a,r,s,o){for(var _=this._littleEndian,d=new DataView(e,t,i),l=[],u=0,c=0,h=this._naluLengthSize,f=this._timestampBase+a,p=1===s;c<i;){if(c+4>=i){n.a.w(this.TAG,"Malformed Nalu near timestamp ".concat(f,", offset = ").concat(c,", dataSize = ").concat(i));break}var m=d.getUint32(c,!_);if(3===h&&(m>>>=8),m>i-h)return void n.a.w(this.TAG,"Malformed Nalus near timestamp ".concat(f,", NaluSize > DataSize!"));var g=31&d.getUint8(c+h);5===g&&(p=!0);var y=new Uint8Array(e,t+c,h+m),v={type:g,data:y};l.push(v),u+=y.byteLength,c+=h+m}if(l.length){var b=this._videoTrack,E={units:l,length:u,isKeyframe:p,dts:f,cts:o,pts:f+o};p&&(E.fileposition=r),b.samples.push(E),b.length+=u}},e.prototype._parseHEVCVideoData=function(e,t,i,a,r,s,o){for(var _=this._littleEndian,d=new DataView(e,t,i),l=[],u=0,c=0,h=this._naluLengthSize,f=this._timestampBase+a,p=1===s;c<i;){if(c+4>=i){n.a.w(this.TAG,"Malformed Nalu near timestamp ".concat(f,", offset = ").concat(c,", dataSize = ").concat(i));break}var m=d.getUint32(c,!_);if(3===h&&(m>>>=8),m>i-h)return void n.a.w(this.TAG,"Malformed Nalus near timestamp ".concat(f,", NaluSize > DataSize!"));var g=d.getUint8(c+h)>>1&63;19!==g&&20!==g&&21!==g||(p=!0);var y=new Uint8Array(e,t+c,h+m),v={type:g,data:y};l.push(v),u+=y.byteLength,c+=h+m}if(l.length){var b=this._videoTrack,E={units:l,length:u,isKeyframe:p,dts:f,cts:o,pts:f+o};p&&(E.fileposition=r),b.samples.push(E),b.length+=u}},e.prototype._parseAV1VideoData=function(e,t,i,a,r,s,o){this._littleEndian,new DataView(e,t,i);var _,d=[],l=this._timestampBase+a,u=1===s;if(u){var c=this._videoMetadata,h=w.parseOBUs(new Uint8Array(e,t,i),c.extra);if(null==h)return void this._onError(m.a.FORMAT_ERROR,"Flv: Invalid AV1 VideoData");c.codecWidth=h.codec_size.width,c.codecHeight=h.codec_size.height,c.presentWidth=h.present_size.width,c.presentHeight=h.present_size.height,c.sarRatio=h.sar_ratio;var f=this._mediaInfo;f.width=c.codecWidth,f.height=c.codecHeight,f.sarNum=c.sarRatio.width,f.sarDen=c.sarRatio.height,n.a.v(this.TAG,"Parsed AV1DecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",c)}if(_=i,d.push({unitType:0,data:new Uint8Array(e,t+0,i)}),d.length){var p=this._videoTrack,g={units:d,length:_,isKeyframe:u,dts:l,cts:o,pts:l+o};u&&(g.fileposition=r),p.samples.push(g),p.length+=_}},e}(),T=function(){function e(){}return e.prototype.destroy=function(){this.onError=null,this.onMediaInfo=null,this.onMetaDataArrived=null,this.onTrackMetadata=null,this.onDataAvailable=null,this.onTimedID3Metadata=null,this.onSynchronousKLVMetadata=null,this.onAsynchronousKLVMetadata=null,this.onSMPTE2038Metadata=null,this.onSCTE35Metadata=null,this.onPESPrivateData=null,this.onPESPrivateDataDescriptor=null},e}(),L=function(){this.program_pmt_pid={}};!function(e){e[e.kMPEG1Audio=3]="kMPEG1Audio",e[e.kMPEG2Audio=4]="kMPEG2Audio",e[e.kPESPrivateData=6]="kPESPrivateData",e[e.kADTSAAC=15]="kADTSAAC",e[e.kLOASAAC=17]="kLOASAAC",e[e.kAC3=129]="kAC3",e[e.kEAC3=135]="kEAC3",e[e.kMetadata=21]="kMetadata",e[e.kSCTE35=134]="kSCTE35",e[e.kH264=27]="kH264",e[e.kH265=36]="kH265"}(E||(E={}));var R,C=function(){this.pid_stream_type={},this.common_pids={h264:void 0,h265:void 0,av1:void 0,adts_aac:void 0,loas_aac:void 0,opus:void 0,ac3:void 0,eac3:void 0,mp3:void 0},this.pes_private_data_pids={},this.timed_id3_pids={},this.synchronous_klv_pids={},this.asynchronous_klv_pids={},this.scte_35_pids={},this.smpte2038_pids={}},x=function(){},M=function(){},D=function(){this.slices=[],this.total_length=0,this.expected_length=0,this.file_position=0};!function(e){e[e.kUnspecified=0]="kUnspecified",e[e.kSliceNonIDR=1]="kSliceNonIDR",e[e.kSliceDPA=2]="kSliceDPA",e[e.kSliceDPB=3]="kSliceDPB",e[e.kSliceDPC=4]="kSliceDPC",e[e.kSliceIDR=5]="kSliceIDR",e[e.kSliceSEI=6]="kSliceSEI",e[e.kSliceSPS=7]="kSliceSPS",e[e.kSlicePPS=8]="kSlicePPS",e[e.kSliceAUD=9]="kSliceAUD",e[e.kEndOfSequence=10]="kEndOfSequence",e[e.kEndOfStream=11]="kEndOfStream",e[e.kFiller=12]="kFiller",e[e.kSPSExt=13]="kSPSExt",e[e.kReserved0=14]="kReserved0"}(R||(R={}));var O,I,P=function(){},B=function(e){var t=e.data.byteLength;this.type=e.type,this.data=new Uint8Array(4+t),new DataView(this.data.buffer).setUint32(0,t),this.data.set(e.data,4)},U=function(){function e(e){this.TAG="H264AnnexBParser",this.current_startcode_offset_=0,this.eof_flag_=!1,this.data_=e,this.current_startcode_offset_=this.findNextStartCodeOffset(0),this.eof_flag_&&n.a.e(this.TAG,"Could not find H264 startcode until payload end!")}return e.prototype.findNextStartCodeOffset=function(e){for(var t=e,i=this.data_;;){if(t+3>=i.byteLength)return this.eof_flag_=!0,i.byteLength;var a=i[t+0]<<24|i[t+1]<<16|i[t+2]<<8|i[t+3],r=i[t+0]<<16|i[t+1]<<8|i[t+2];if(1===a||1===r)return t;t++}},e.prototype.readNextNaluPayload=function(){for(var e=this.data_,t=null;null==t&&!this.eof_flag_;){var i=this.current_startcode_offset_,a=31&e[i+=1==(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3])?4:3],r=(128&e[i])>>>7,n=this.findNextStartCodeOffset(i);if(this.current_startcode_offset_=n,!(a>=R.kReserved0)&&0===r){var s=e.subarray(i,n);(t=new P).type=a,t.data=s}}return t},e}(),N=function(){function e(e,t,i){var a=8+e.byteLength+1+2+t.byteLength,r=!1;66!==e[3]&&77!==e[3]&&88!==e[3]&&(r=!0,a+=4);var n=this.data=new Uint8Array(a);n[0]=1,n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=255,n[5]=225;var s=e.byteLength;n[6]=s>>>8,n[7]=255&s;var o=8;n.set(e,8),n[o+=s]=1;var _=t.byteLength;n[o+1]=_>>>8,n[o+2]=255&_,n.set(t,o+3),o+=3+_,r&&(n[o]=252|i.chroma_format_idc,n[o+1]=248|i.bit_depth_luma-8,n[o+2]=248|i.bit_depth_chroma-8,n[o+3]=0,o+=4)}return e.prototype.getData=function(){return this.data},e}();!function(e){e[e.kNull=0]="kNull",e[e.kAACMain=1]="kAACMain",e[e.kAAC_LC=2]="kAAC_LC",e[e.kAAC_SSR=3]="kAAC_SSR",e[e.kAAC_LTP=4]="kAAC_LTP",e[e.kAAC_SBR=5]="kAAC_SBR",e[e.kAAC_Scalable=6]="kAAC_Scalable",e[e.kLayer1=32]="kLayer1",e[e.kLayer2=33]="kLayer2",e[e.kLayer3=34]="kLayer3"}(O||(O={})),function(e){e[e.k96000Hz=0]="k96000Hz",e[e.k88200Hz=1]="k88200Hz",e[e.k64000Hz=2]="k64000Hz",e[e.k48000Hz=3]="k48000Hz",e[e.k44100Hz=4]="k44100Hz",e[e.k32000Hz=5]="k32000Hz",e[e.k24000Hz=6]="k24000Hz",e[e.k22050Hz=7]="k22050Hz",e[e.k16000Hz=8]="k16000Hz",e[e.k12000Hz=9]="k12000Hz",e[e.k11025Hz=10]="k11025Hz",e[e.k8000Hz=11]="k8000Hz",e[e.k7350Hz=12]="k7350Hz"}(I||(I={}));var F,V,j=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],G=(F=function(e,t){return(F=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}F(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),H=function(){},z=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return G(t,e),t}(H),W=function(){function e(e){this.TAG="AACADTSParser",this.data_=e,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&n.a.e(this.TAG,"Could not found ADTS syncword until payload end")}return e.prototype.findNextSyncwordOffset=function(e){for(var t=e,i=this.data_;;){if(t+7>=i.byteLength)return this.eof_flag_=!0,i.byteLength;if(4095==(i[t+0]<<8|i[t+1])>>>4)return t;t++}},e.prototype.readNextAACFrame=function(){for(var e=this.data_,t=null;null==t&&!this.eof_flag_;){var i=this.current_syncword_offset_,a=(8&e[i+1])>>>3,r=(6&e[i+1])>>>1,n=1&e[i+1],s=(192&e[i+2])>>>6,o=(60&e[i+2])>>>2,_=(1&e[i+2])<<2|(192&e[i+3])>>>6,d=(3&e[i+3])<<11|e[i+4]<<3|(224&e[i+5])>>>5;if(e[i+6],i+d>this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var l=1===n?7:9,u=d-l;i+=l;var c=this.findNextSyncwordOffset(i+u);if(this.current_syncword_offset_=c,(0===a||1===a)&&0===r){var h=e.subarray(i,i+u);(t=new H).audio_object_type=s+1,t.sampling_freq_index=o,t.sampling_frequency=j[o],t.channel_config=_,t.data=h}}return t},e.prototype.hasIncompleteData=function(){return this.has_last_incomplete_data},e.prototype.getIncompleteData=function(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null},e}(),q=function(){function e(e){this.TAG="AACLOASParser",this.data_=e,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&n.a.e(this.TAG,"Could not found LOAS syncword until payload end")}return e.prototype.findNextSyncwordOffset=function(e){for(var t=e,i=this.data_;;){if(t+1>=i.byteLength)return this.eof_flag_=!0,i.byteLength;if(695==(i[t+0]<<3|i[t+1]>>>5))return t;t++}},e.prototype.getLATMValue=function(e){for(var t=e.readBits(2),i=0,a=0;a<=t;a++)i<<=8,i|=e.readByte();return i},e.prototype.readNextAACFrame=function(e){for(var t=this.data_,i=null;null==i&&!this.eof_flag_;){var a=this.current_syncword_offset_,r=(31&t[a+1])<<8|t[a+2];if(a+3+r>=this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var s=new f(t.subarray(a+3,a+3+r)),o=null;if(s.readBool()){if(null==e){n.a.w(this.TAG,"StreamMuxConfig Missing"),this.current_syncword_offset_=this.findNextSyncwordOffset(a+3+r),s.destroy();continue}o=e}else{var _=s.readBool();if(_&&s.readBool()){n.a.e(this.TAG,"audioMuxVersionA is Not Supported"),s.destroy();break}if(_&&this.getLATMValue(s),!s.readBool()){n.a.e(this.TAG,"allStreamsSameTimeFraming zero is Not Supported"),s.destroy();break}if(0!==s.readBits(6)){n.a.e(this.TAG,"more than 2 numSubFrames Not Supported"),s.destroy();break}if(0!==s.readBits(4)){n.a.e(this.TAG,"more than 2 numProgram Not Supported"),s.destroy();break}if(0!==s.readBits(3)){n.a.e(this.TAG,"more than 2 numLayer Not Supported"),s.destroy();break}var d=_?this.getLATMValue(s):0,l=s.readBits(5);d-=5;var u=s.readBits(4);d-=4;var c=s.readBits(4);d-=4,s.readBits(3),(d-=3)>0&&s.readBits(d);var h=s.readBits(3);if(0!==h){n.a.e(this.TAG,"frameLengthType = ".concat(h,". Only frameLengthType = 0 Supported")),s.destroy();break}s.readByte();var p=s.readBool();if(p)if(_)this.getLATMValue(s);else for(;;){var m=s.readBool();if(s.readByte(),!m)break}s.readBool()&&s.readByte(),(o=new z).audio_object_type=l,o.sampling_freq_index=u,o.sampling_frequency=j[o.sampling_freq_index],o.channel_config=c,o.other_data_present=p}for(var g=0;;){var y=s.readByte();if(g+=y,255!==y)break}for(var v=new Uint8Array(g),b=0;b<g;b++)v[b]=s.readByte();(i=new z).audio_object_type=o.audio_object_type,i.sampling_freq_index=o.sampling_freq_index,i.sampling_frequency=j[o.sampling_freq_index],i.channel_config=o.channel_config,i.other_data_present=o.other_data_present,i.data=v,this.current_syncword_offset_=this.findNextSyncwordOffset(a+3+r)}return i},e.prototype.hasIncompleteData=function(){return this.has_last_incomplete_data},e.prototype.getIncompleteData=function(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null},e}(),Y=function(e){var t=null,i=e.audio_object_type,a=e.audio_object_type,r=e.sampling_freq_index,n=e.channel_config,s=0,o=navigator.userAgent.toLowerCase();-1!==o.indexOf("firefox")?r>=6?(a=5,t=new Array(4),s=r-3):(a=2,t=new Array(2),s=r):-1!==o.indexOf("android")?(a=2,t=new Array(2),s=r):(a=5,s=r,t=new Array(4),r>=6?s=r-3:1===n&&(a=2,t=new Array(2),s=r)),t[0]=a<<3,t[0]|=(15&r)>>>1,t[1]=(15&r)<<7,t[1]|=(15&n)<<3,5===a&&(t[1]|=(15&s)>>>1,t[2]=(1&s)<<7,t[2]|=8,t[3]=0),this.config=t,this.sampling_rate=j[r],this.channel_count=n,this.codec_mimetype="mp4a.40."+a,this.original_codec_mimetype="mp4a.40."+i},K=function(){},X=function(){};!function(e){e[e.kSpliceNull=0]="kSpliceNull",e[e.kSpliceSchedule=4]="kSpliceSchedule",e[e.kSpliceInsert=5]="kSpliceInsert",e[e.kTimeSignal=6]="kTimeSignal",e[e.kBandwidthReservation=7]="kBandwidthReservation",e[e.kPrivateCommand=255]="kPrivateCommand"}(V||(V={}));var Q,J=function(e){var t=e.readBool();return t?(e.readBits(6),{time_specified_flag:t,pts_time:4*e.readBits(31)+e.readBits(2)}):(e.readBits(7),{time_specified_flag:t})},Z=function(e){var t=e.readBool();return e.readBits(6),{auto_return:t,duration:4*e.readBits(31)+e.readBits(2)}},$=function(e,t){var i=t.readBits(8);return e?{component_tag:i}:{component_tag:i,splice_time:J(t)}},ee=function(e){return{component_tag:e.readBits(8),utc_splice_time:e.readBits(32)}},te=function(e){var t=e.readBits(32),i=e.readBool();e.readBits(7);var a={splice_event_id:t,splice_event_cancel_indicator:i};if(i)return a;if(a.out_of_network_indicator=e.readBool(),a.program_splice_flag=e.readBool(),a.duration_flag=e.readBool(),e.readBits(5),a.program_splice_flag)a.utc_splice_time=e.readBits(32);else{a.component_count=e.readBits(8),a.components=[];for(var r=0;r<a.component_count;r++)a.components.push(ee(e))}return a.duration_flag&&(a.break_duration=Z(e)),a.unique_program_id=e.readBits(16),a.avail_num=e.readBits(8),a.avails_expected=e.readBits(8),a},ie=function(e,t,i,a){return{descriptor_tag:e,descriptor_length:t,identifier:i,provider_avail_id:a.readBits(32)}},ae=function(e,t,i,a){var r=a.readBits(8),n=a.readBits(3);a.readBits(5);for(var s="",o=0;o<n;o++)s+=String.fromCharCode(a.readBits(8));return{descriptor_tag:e,descriptor_length:t,identifier:i,preroll:r,dtmf_count:n,DTMF_char:s}},re=function(e){var t=e.readBits(8);return e.readBits(7),{component_tag:t,pts_offset:4*e.readBits(31)+e.readBits(2)}},ne=function(e,t,i,a){var r=a.readBits(32),n=a.readBool();a.readBits(7);var s={descriptor_tag:e,descriptor_length:t,identifier:i,segmentation_event_id:r,segmentation_event_cancel_indicator:n};if(n)return s;if(s.program_segmentation_flag=a.readBool(),s.segmentation_duration_flag=a.readBool(),s.delivery_not_restricted_flag=a.readBool(),s.delivery_not_restricted_flag?a.readBits(5):(s.web_delivery_allowed_flag=a.readBool(),s.no_regional_blackout_flag=a.readBool(),s.archive_allowed_flag=a.readBool(),s.device_restrictions=a.readBits(2)),!s.program_segmentation_flag){s.component_count=a.readBits(8),s.components=[];for(var o=0;o<s.component_count;o++)s.components.push(re(a))}s.segmentation_duration_flag&&(s.segmentation_duration=a.readBits(40)),s.segmentation_upid_type=a.readBits(8),s.segmentation_upid_length=a.readBits(8);var _=new Uint8Array(s.segmentation_upid_length);for(o=0;o<s.segmentation_upid_length;o++)_[o]=a.readBits(8);return s.segmentation_upid=_.buffer,s.segmentation_type_id=a.readBits(8),s.segment_num=a.readBits(8),s.segments_expected=a.readBits(8),52!==s.segmentation_type_id&&54!==s.segmentation_type_id&&56!==s.segmentation_type_id&&58!==s.segmentation_type_id||(s.sub_segment_num=a.readBits(8),s.sub_segments_expected=a.readBits(8)),s},se=function(e,t,i,a){return{descriptor_tag:e,descriptor_length:t,identifier:i,TAI_seconds:a.readBits(48),TAI_ns:a.readBits(32),UTC_offset:a.readBits(16)}},oe=function(e){return{component_tag:e.readBits(8),ISO_code:String.fromCharCode(e.readBits(8),e.readBits(8),e.readBits(8)),Bit_Stream_Mode:e.readBits(3),Num_Channels:e.readBits(4),Full_Srvc_Audio:e.readBool()}},_e=function(e,t,i,a){for(var r=a.readBits(4),n=[],s=0;s<r;s++)n.push(oe(a));return{descriptor_tag:e,descriptor_length:t,identifier:i,audio_count:r,components:n}};!function(e){e[e.kSliceIDR_W_RADL=19]="kSliceIDR_W_RADL",e[e.kSliceIDR_N_LP=20]="kSliceIDR_N_LP",e[e.kSliceCRA_NUT=21]="kSliceCRA_NUT",e[e.kSliceVPS=32]="kSliceVPS",e[e.kSliceSPS=33]="kSliceSPS",e[e.kSlicePPS=34]="kSlicePPS",e[e.kSliceAUD=35]="kSliceAUD"}(Q||(Q={}));var de=function(){},le=function(e){var t=e.data.byteLength;this.type=e.type,this.data=new Uint8Array(4+t),new DataView(this.data.buffer).setUint32(0,t),this.data.set(e.data,4)},ue=function(){function e(e){this.TAG="H265AnnexBParser",this.current_startcode_offset_=0,this.eof_flag_=!1,this.data_=e,this.current_startcode_offset_=this.findNextStartCodeOffset(0),this.eof_flag_&&n.a.e(this.TAG,"Could not find H265 startcode until payload end!")}return e.prototype.findNextStartCodeOffset=function(e){for(var t=e,i=this.data_;;){if(t+3>=i.byteLength)return this.eof_flag_=!0,i.byteLength;var a=i[t+0]<<24|i[t+1]<<16|i[t+2]<<8|i[t+3],r=i[t+0]<<16|i[t+1]<<8|i[t+2];if(1===a||1===r)return t;t++}},e.prototype.readNextNaluPayload=function(){for(var e=this.data_,t=null;null==t&&!this.eof_flag_;){var i=this.current_startcode_offset_,a=e[i+=1==(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3])?4:3]>>1&63,r=(128&e[i])>>>7,n=this.findNextStartCodeOffset(i);if(this.current_startcode_offset_=n,0===r){var s=e.subarray(i,n);(t=new de).type=a,t.data=s}}return t},e}(),ce=function(){function e(e,t,i,a){var r=23+(5+e.byteLength)+(5+t.byteLength)+(5+i.byteLength),n=this.data=new Uint8Array(r);n[0]=1,n[1]=(3&a.general_profile_space)<<6|(a.general_tier_flag?1:0)<<5|31&a.general_profile_idc,n[2]=a.general_profile_compatibility_flags_1,n[3]=a.general_profile_compatibility_flags_2,n[4]=a.general_profile_compatibility_flags_3,n[5]=a.general_profile_compatibility_flags_4,n[6]=a.general_constraint_indicator_flags_1,n[7]=a.general_constraint_indicator_flags_2,n[8]=a.general_constraint_indicator_flags_3,n[9]=a.general_constraint_indicator_flags_4,n[10]=a.general_constraint_indicator_flags_5,n[11]=a.general_constraint_indicator_flags_6,n[12]=a.general_level_idc,n[13]=240|(3840&a.min_spatial_segmentation_idc)>>8,n[14]=255&a.min_spatial_segmentation_idc,n[15]=252|3&a.parallelismType,n[16]=252|3&a.chroma_format_idc,n[17]=248|7&a.bit_depth_luma_minus8,n[18]=248|7&a.bit_depth_chroma_minus8,n[19]=0,n[20]=0,n[21]=(3&a.constant_frame_rate)<<6|(7&a.num_temporal_layers)<<3|(a.temporal_id_nested?1:0)<<2|3,n[22]=3,n[23]=128|Q.kSliceVPS,n[24]=0,n[25]=1,n[26]=(65280&e.byteLength)>>8,n[27]=255&e.byteLength,n.set(e,28),n[23+(5+e.byteLength)+0]=128|Q.kSliceSPS,n[23+(5+e.byteLength)+1]=0,n[23+(5+e.byteLength)+2]=1,n[23+(5+e.byteLength)+3]=(65280&t.byteLength)>>8,n[23+(5+e.byteLength)+4]=255&t.byteLength,n.set(t,23+(5+e.byteLength)+5),n[23+(5+e.byteLength+5+t.byteLength)+0]=128|Q.kSlicePPS,n[23+(5+e.byteLength+5+t.byteLength)+1]=0,n[23+(5+e.byteLength+5+t.byteLength)+2]=1,n[23+(5+e.byteLength+5+t.byteLength)+3]=(65280&i.byteLength)>>8,n[23+(5+e.byteLength+5+t.byteLength)+4]=255&i.byteLength,n.set(i,23+(5+e.byteLength+5+t.byteLength)+5)}return e.prototype.getData=function(){return this.data},e}(),he=function(){},fe=function(){},pe=function(){},me=[[64,64,80,80,96,96,112,112,128,128,160,160,192,192,224,224,256,256,320,320,384,384,448,448,512,512,640,640,768,768,896,896,1024,1024,1152,1152,1280,1280],[69,70,87,88,104,105,121,122,139,140,174,175,208,209,243,244,278,279,348,349,417,418,487,488,557,558,696,697,835,836,975,976,1114,1115,1253,1254,1393,1394],[96,96,120,120,144,144,168,168,192,192,240,240,288,288,336,336,384,384,480,480,576,576,672,672,768,768,960,960,1152,1152,1344,1344,1536,1536,1728,1728,1920,1920]],ge=function(){function e(e){this.TAG="AC3Parser",this.data_=e,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&n.a.e(this.TAG,"Could not found AC3 syncword until payload end")}return e.prototype.findNextSyncwordOffset=function(e){for(var t=e,i=this.data_;;){if(t+7>=i.byteLength)return this.eof_flag_=!0,i.byteLength;if(2935==(i[t+0]<<8|i[t+1]))return t;t++}},e.prototype.readNextAC3Frame=function(){for(var e=this.data_,t=null;null==t&&!this.eof_flag_;){var i=this.current_syncword_offset_,a=e[i+4]>>6,r=[48e3,44200,33e3][a],n=63&e[i+4],s=2*me[a][n];if(isNaN(s)||i+s>this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var o=this.findNextSyncwordOffset(i+s);this.current_syncword_offset_=o;var _=e[i+5]>>3,d=7&e[i+5],l=e[i+6]>>5,u=0;!!(1&l)&&1!==l&&(u+=2),!!(4&l)&&(u+=2),2===l&&(u+=2);var c=(e[i+6]<<8|e[i+7])>>12-u&1,h=[2,1,2,3,3,4,4,5][l]+c;(t=new pe).sampling_frequency=r,t.channel_count=h,t.channel_mode=l,t.bit_stream_identification=_,t.low_frequency_effects_channel_on=c,t.bit_stream_mode=d,t.frame_size_code=n,t.data=e.subarray(i,i+s)}return t},e.prototype.hasIncompleteData=function(){return this.has_last_incomplete_data},e.prototype.getIncompleteData=function(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null},e}(),ye=function(e){var t;t=[e.sampling_rate_code<<6|e.bit_stream_identification<<1|e.bit_stream_mode>>2,(3&e.bit_stream_mode)<<6|e.channel_mode<<3|e.low_frequency_effects_channel_on<<2|e.frame_size_code>>4,e.frame_size_code<<4&224],this.config=t,this.sampling_rate=e.sampling_frequency,this.bit_stream_identification=e.bit_stream_identification,this.bit_stream_mode=e.bit_stream_mode,this.low_frequency_effects_channel_on=e.low_frequency_effects_channel_on,this.channel_count=e.channel_count,this.channel_mode=e.channel_mode,this.codec_mimetype="ac-3",this.original_codec_mimetype="ac-3"},ve=function(){},be=function(){function e(e){this.TAG="EAC3Parser",this.data_=e,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&n.a.e(this.TAG,"Could not found AC3 syncword until payload end")}return e.prototype.findNextSyncwordOffset=function(e){for(var t=e,i=this.data_;;){if(t+7>=i.byteLength)return this.eof_flag_=!0,i.byteLength;if(2935==(i[t+0]<<8|i[t+1]))return t;t++}},e.prototype.readNextEAC3Frame=function(){for(var e=this.data_,t=null;null==t&&!this.eof_flag_;){var i=this.current_syncword_offset_,a=new f(e.subarray(i+2)),r=(a.readBits(2),a.readBits(3),a.readBits(11)+1<<1),n=a.readBits(2),s=null,o=null;3===n?(s=[24e3,22060,16e3][n=a.readBits(2)],o=3):(s=[48e3,44100,32e3][n],o=a.readBits(2));var _=a.readBits(3),d=a.readBits(1),l=a.readBits(5);if(i+r>this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var u=this.findNextSyncwordOffset(i+r);this.current_syncword_offset_=u;var c=[2,1,2,3,3,4,4,5][_]+d;a.destroy(),(t=new ve).sampling_frequency=s,t.channel_count=c,t.channel_mode=_,t.bit_stream_identification=l,t.low_frequency_effects_channel_on=d,t.frame_size=r,t.num_blks=[1,2,3,6][o],t.data=e.subarray(i,i+r)}return t},e.prototype.hasIncompleteData=function(){return this.has_last_incomplete_data},e.prototype.getIncompleteData=function(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null},e}(),Ee=function(e){var t,i=Math.floor(e.frame_size*e.sampling_frequency/(16*e.num_blks));t=[255&i,248&i,e.sampling_rate_code<<6|e.bit_stream_identification<<1,e.channel_mode<<1|e.low_frequency_effects_channel_on,0],this.config=t,this.sampling_rate=e.sampling_frequency,this.bit_stream_identification=e.bit_stream_identification,this.num_blks=e.num_blks,this.low_frequency_effects_channel_on=e.low_frequency_effects_channel_on,this.channel_count=e.channel_count,this.channel_mode=e.channel_mode,this.codec_mimetype="ec-3",this.original_codec_mimetype="ec-3"},Se=function(){},Ae=function(){function e(e){this.TAG="AV1OBUInMpegTsParser",this.current_startcode_offset_=0,this.eof_flag_=!1,this.data_=e,this.current_startcode_offset_=this.findNextStartCodeOffset(0),this.eof_flag_&&n.a.e(this.TAG,"Could not find AV1 startcode until payload end!")}return e._ebsp2rbsp=function(e){for(var t=e,i=t.byteLength,a=new Uint8Array(i),r=0,n=0;n<i;n++)n>=2&&3===t[n]&&0===t[n-1]&&0===t[n-2]||(a[r]=t[n],r++);return new Uint8Array(a.buffer,0,r)},e.prototype.findNextStartCodeOffset=function(e){for(var t=e,i=this.data_;;){if(t+2>=i.byteLength)return this.eof_flag_=!0,i.byteLength;if(1==(i[t+0]<<16|i[t+1]<<8|i[t+2]))return t;t++}},e.prototype.readNextOBUPayload=function(){for(var t=this.data_,i=null;null==i&&!this.eof_flag_;){var a=this.current_startcode_offset_+3,r=this.findNextStartCodeOffset(a);this.current_startcode_offset_=r,i=e._ebsp2rbsp(t.subarray(a,r))}return i},e}(),we=function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function a(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(a.prototype=i.prototype,new a)}}(),ke=function(){return(ke=Object.assign||function(e){for(var t,i=1,a=arguments.length;i<a;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},Te=function(e){function t(t,i){var a=e.call(this)||this;return a.TAG="TSDemuxer",a.first_parse_=!0,a.media_info_=new o.a,a.timescale_=90,a.duration_=0,a.current_pmt_pid_=-1,a.program_pmt_map_={},a.pes_slice_queues_={},a.section_slice_queues_={},a.video_metadata_={vps:void 0,sps:void 0,pps:void 0,av1c:void 0,details:void 0},a.audio_metadata_={codec:void 0,audio_object_type:void 0,sampling_freq_index:void 0,sampling_frequency:void 0,channel_config:void 0},a.last_pcr_base_=NaN,a.timestamp_offset_=0,a.audio_last_sample_pts_=void 0,a.aac_last_incomplete_data_=null,a.has_video_=!1,a.has_audio_=!1,a.video_init_segment_dispatched_=!1,a.audio_init_segment_dispatched_=!1,a.video_metadata_changed_=!1,a.audio_metadata_changed_=!1,a.loas_previous_frame=null,a.video_track_={type:"video",id:1,sequenceNumber:0,samples:[],length:0},a.audio_track_={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},a.ts_packet_size_=t.ts_packet_size,a.sync_offset_=t.sync_offset,a.config_=i,a}return we(t,e),t.prototype.destroy=function(){this.media_info_=null,this.pes_slice_queues_=null,this.section_slice_queues_=null,this.video_metadata_=null,this.audio_metadata_=null,this.aac_last_incomplete_data_=null,this.video_track_=null,this.audio_track_=null,e.prototype.destroy.call(this)},t.probe=function(e){var t=new Uint8Array(e),i=-1,a=188;if(t.byteLength<=3*a)return{needMoreData:!0};for(;-1===i;){for(var r=Math.min(1e3,t.byteLength-3*a),s=0;s<r;){if(71===t[s]&&71===t[s+a]&&71===t[s+2*a]){i=s;break}s++}if(-1===i)if(188===a)a=192;else{if(192!==a)break;a=204}}return-1===i?{match:!1}:(192===a&&i>=4?(n.a.v("TSDemuxer","ts_packet_size = 192, m2ts mode"),i-=4):204===a&&n.a.v("TSDemuxer","ts_packet_size = 204, RS encoded MPEG2-TS stream"),{match:!0,consumed:0,ts_packet_size:a,sync_offset:i})},t.prototype.bindDataSource=function(e){return e.onDataArrival=this.parseChunks.bind(this),this},t.prototype.resetMediaInfo=function(){this.media_info_=new o.a},t.prototype.parseChunks=function(e,t){if(!(this.onError&&this.onMediaInfo&&this.onTrackMetadata&&this.onDataAvailable))throw new u.a("onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var i=0;for(this.first_parse_&&(this.first_parse_=!1,i=this.sync_offset_);i+this.ts_packet_size_<=e.byteLength;){var a=t+i;192===this.ts_packet_size_&&(i+=4);var r=new Uint8Array(e,i,188),s=r[0];if(71!==s){n.a.e(this.TAG,"sync_byte = ".concat(s,", not 0x47"));break}var o=(64&r[1])>>>6,_=(r[1],(31&r[1])<<8|r[2]),d=(48&r[3])>>>4,l=15&r[3],c=!(!this.pmt_||this.pmt_.pcr_pid!==_),h={},f=4;if(2==d||3==d){var p=r[4];if(p>0&&(c||3==d)&&(h.discontinuity_indicator=(128&r[5])>>>7,h.random_access_indicator=(64&r[5])>>>6,h.elementary_stream_priority_indicator=(32&r[5])>>>5,(16&r[5])>>>4)){var m=300*this.getPcrBase(r)+((1&r[10])<<8|r[11]);this.last_pcr_=m}if(2==d||5+p===188){i+=188,204===this.ts_packet_size_&&(i+=16);continue}f=5+p}if(1==d||3==d)if(0===_||_===this.current_pmt_pid_||null!=this.pmt_&&this.pmt_.pid_stream_type[_]===E.kSCTE35){var g=188-f;this.handleSectionSlice(e,i+f,g,{pid:_,file_position:a,payload_unit_start_indicator:o,continuity_conunter:l,random_access_indicator:h.random_access_indicator})}else if(null!=this.pmt_&&null!=this.pmt_.pid_stream_type[_]){g=188-f;var y=this.pmt_.pid_stream_type[_];_!==this.pmt_.common_pids.h264&&_!==this.pmt_.common_pids.h265&&_!==this.pmt_.common_pids.av1&&_!==this.pmt_.common_pids.adts_aac&&_!==this.pmt_.common_pids.loas_aac&&_!==this.pmt_.common_pids.ac3&&_!==this.pmt_.common_pids.eac3&&_!==this.pmt_.common_pids.opus&&_!==this.pmt_.common_pids.mp3&&!0!==this.pmt_.pes_private_data_pids[_]&&!0!==this.pmt_.timed_id3_pids[_]&&!0!==this.pmt_.synchronous_klv_pids[_]&&!0!==this.pmt_.asynchronous_klv_pids[_]||this.handlePESSlice(e,i+f,g,{pid:_,stream_type:y,file_position:a,payload_unit_start_indicator:o,continuity_conunter:l,random_access_indicator:h.random_access_indicator})}i+=188,204===this.ts_packet_size_&&(i+=16)}return this.dispatchAudioVideoMediaSegment(),i},t.prototype.handleSectionSlice=function(e,t,i,a){var r=new Uint8Array(e,t,i),n=this.section_slice_queues_[a.pid];if(a.payload_unit_start_indicator){var s=r[0];if(null!=n&&0!==n.total_length){var o=new Uint8Array(e,t+1,Math.min(i,s));n.slices.push(o),n.total_length+=o.byteLength,n.total_length===n.expected_length?this.emitSectionSlices(n,a):this.clearSlices(n,a)}for(var _=1+s;_<r.byteLength&&255!==r[_+0];){var d=(15&r[_+1])<<8|r[_+2];this.section_slice_queues_[a.pid]=new D,(n=this.section_slice_queues_[a.pid]).expected_length=d+3,n.file_position=a.file_position,n.random_access_indicator=a.random_access_indicator,o=new Uint8Array(e,t+_,Math.min(i-_,n.expected_length-n.total_length)),n.slices.push(o),n.total_length+=o.byteLength,n.total_length===n.expected_length?this.emitSectionSlices(n,a):n.total_length>=n.expected_length&&this.clearSlices(n,a),_+=o.byteLength}}else null!=n&&0!==n.total_length&&(o=new Uint8Array(e,t,Math.min(i,n.expected_length-n.total_length)),n.slices.push(o),n.total_length+=o.byteLength,n.total_length===n.expected_length?this.emitSectionSlices(n,a):n.total_length>=n.expected_length&&this.clearSlices(n,a))},t.prototype.handlePESSlice=function(e,t,i,a){var r=new Uint8Array(e,t,i),s=r[0]<<16|r[1]<<8|r[2],o=(r[3],r[4]<<8|r[5]);if(a.payload_unit_start_indicator){if(1!==s)return void n.a.e(this.TAG,"handlePESSlice: packet_start_code_prefix should be 1 but with value ".concat(s));var _=this.pes_slice_queues_[a.pid];_&&(0===_.expected_length||_.expected_length===_.total_length?this.emitPESSlices(_,a):this.clearSlices(_,a)),this.pes_slice_queues_[a.pid]=new D,this.pes_slice_queues_[a.pid].file_position=a.file_position,this.pes_slice_queues_[a.pid].random_access_indicator=a.random_access_indicator}if(null!=this.pes_slice_queues_[a.pid]){var d=this.pes_slice_queues_[a.pid];d.slices.push(r),a.payload_unit_start_indicator&&(d.expected_length=0===o?0:o+6),d.total_length+=r.byteLength,d.expected_length>0&&d.expected_length===d.total_length?this.emitPESSlices(d,a):d.expected_length>0&&d.expected_length<d.total_length&&this.clearSlices(d,a)}},t.prototype.emitSectionSlices=function(e,t){for(var i=new Uint8Array(e.total_length),a=0,r=0;a<e.slices.length;a++){var n=e.slices[a];i.set(n,r),r+=n.byteLength}e.slices=[],e.expected_length=-1,e.total_length=0;var s=new M;s.pid=t.pid,s.data=i,s.file_position=e.file_position,s.random_access_indicator=e.random_access_indicator,this.parseSection(s)},t.prototype.emitPESSlices=function(e,t){for(var i=new Uint8Array(e.total_length),a=0,r=0;a<e.slices.length;a++){var n=e.slices[a];i.set(n,r),r+=n.byteLength}e.slices=[],e.expected_length=-1,e.total_length=0;var s=new x;s.pid=t.pid,s.data=i,s.stream_type=t.stream_type,s.file_position=e.file_position,s.random_access_indicator=e.random_access_indicator,this.parsePES(s)},t.prototype.clearSlices=function(e,t){e.slices=[],e.expected_length=-1,e.total_length=0},t.prototype.parseSection=function(e){var t=e.data,i=e.pid;0===i?this.parsePAT(t):i===this.current_pmt_pid_?this.parsePMT(t):null!=this.pmt_&&this.pmt_.scte_35_pids[i]&&this.parseSCTE35(t)},t.prototype.parsePES=function(e){var t=e.data,i=t[0]<<16|t[1]<<8|t[2],a=t[3],r=t[4]<<8|t[5];if(1===i)if(188!==a&&190!==a&&191!==a&&240!==a&&241!==a&&255!==a&&242!==a&&248!==a){t[6];var s=(192&t[7])>>>6,o=t[8],_=void 0,d=void 0;2!==s&&3!==s||(_=this.getTimestamp(t,9),d=3===s?this.getTimestamp(t,14):_);var l=9+o,u=void 0;if(0!==r){if(r<3+o)return void n.a.v(this.TAG,"Malformed PES: PES_packet_length < 3 + PES_header_data_length");u=r-3-o}else u=t.byteLength-l;var c=t.subarray(l,l+u);switch(e.stream_type){case E.kMPEG1Audio:case E.kMPEG2Audio:this.parseMP3Payload(c,_);break;case E.kPESPrivateData:this.pmt_.common_pids.av1===e.pid?this.parseAV1Payload(c,_,d,e.file_position,e.random_access_indicator):this.pmt_.common_pids.opus===e.pid?this.parseOpusPayload(c,_):this.pmt_.common_pids.ac3===e.pid?this.parseAC3Payload(c,_):this.pmt_.common_pids.eac3===e.pid?this.parseEAC3Payload(c,_):this.pmt_.asynchronous_klv_pids[e.pid]?this.parseAsynchronousKLVMetadataPayload(c,e.pid,a):this.pmt_.smpte2038_pids[e.pid]?this.parseSMPTE2038MetadataPayload(c,_,d,e.pid,a):this.parsePESPrivateDataPayload(c,_,d,e.pid,a);break;case E.kADTSAAC:this.parseADTSAACPayload(c,_);break;case E.kLOASAAC:this.parseLOASAACPayload(c,_);break;case E.kAC3:this.parseAC3Payload(c,_);break;case E.kEAC3:this.parseEAC3Payload(c,_);break;case E.kMetadata:this.pmt_.timed_id3_pids[e.pid]?this.parseTimedID3MetadataPayload(c,_,d,e.pid,a):this.pmt_.synchronous_klv_pids[e.pid]&&this.parseSynchronousKLVMetadataPayload(c,_,d,e.pid,a);break;case E.kH264:this.parseH264Payload(c,_,d,e.file_position,e.random_access_indicator);break;case E.kH265:this.parseH265Payload(c,_,d,e.file_position,e.random_access_indicator)}}else 188!==a&&191!==a&&240!==a&&241!==a&&255!==a&&242!==a&&248!==a||e.stream_type!==E.kPESPrivateData||(l=6,u=void 0,u=0!==r?r:t.byteLength-l,c=t.subarray(l,l+u),this.parsePESPrivateDataPayload(c,void 0,void 0,e.pid,a));else n.a.e(this.TAG,"parsePES: packet_start_code_prefix should be 1 but with value ".concat(i))},t.prototype.parsePAT=function(e){var t=e[0];if(0===t){var i=(15&e[1])<<8|e[2],a=(e[3],e[4],(62&e[5])>>>1),r=1&e[5],s=e[6],o=(e[7],null);if(1===r&&0===s)(o=new L).version_number=a;else if(null==(o=this.pat_))return;for(var _=i-5-4,d=-1,l=-1,u=8;u<8+_;u+=4){var c=e[u]<<8|e[u+1],h=(31&e[u+2])<<8|e[u+3];0===c?o.network_pid=h:(o.program_pmt_pid[c]=h,-1===d&&(d=c),-1===l&&(l=h))}1===r&&0===s&&(null==this.pat_&&n.a.v(this.TAG,"Parsed first PAT: ".concat(JSON.stringify(o))),this.pat_=o,this.current_program_=d,this.current_pmt_pid_=l)}else n.a.e(this.TAG,"parsePAT: table_id ".concat(t," is not corresponded to PAT!"))},t.prototype.parsePMT=function(e){var t=e[0];if(2===t){var i=(15&e[1])<<8|e[2],a=e[3]<<8|e[4],r=(62&e[5])>>>1,s=1&e[5],o=e[6],_=(e[7],null);if(1===s&&0===o)(_=new C).program_number=a,_.version_number=r,this.program_pmt_map_[a]=_;else if(null==(_=this.program_pmt_map_[a]))return;_.pcr_pid=(31&e[8])<<8|e[9];for(var d=(15&e[10])<<8|e[11],l=12+d,u=i-9-d-4,c=l;c<l+u;){var h=e[c],f=(31&e[c+1])<<8|e[c+2],p=(15&e[c+3])<<8|e[c+4];_.pid_stream_type[f]=h;var m=_.common_pids.h264||_.common_pids.h265,g=_.common_pids.adts_aac||_.common_pids.loas_aac||_.common_pids.ac3||_.common_pids.eac3||_.common_pids.opus||_.common_pids.mp3;if(h!==E.kH264||m)if(h!==E.kH265||m)if(h!==E.kADTSAAC||g)if(h!==E.kLOASAAC||g)if(h!==E.kAC3||g)if(h!==E.kEAC3||g)if(h!==E.kMPEG1Audio&&h!==E.kMPEG2Audio||g)if(h===E.kPESPrivateData){if(_.pes_private_data_pids[f]=!0,p>0){for(var y=c+5;y<c+5+p;){var v=e[y+0],b=e[y+1];if(5===v){var S=String.fromCharCode.apply(String,Array.from(e.subarray(y+2,y+2+b)));"VANC"===S?_.smpte2038_pids[f]=!0:"AV01"===S?_.common_pids.av1=f:"Opus"===S?_.common_pids.opus=f:"KLVA"===S&&(_.asynchronous_klv_pids[f]=!0)}else if(127===v){if(f===_.common_pids.opus){var A=null;if(128===e[y+2]&&(A=e[y+3]),null==A){n.a.e(this.TAG,"Not Supported Opus channel count.");continue}var w={codec:"opus",channel_count:15&A?15&A:2,channel_config_code:A,sample_rate:48e3},k={codec:"opus",meta:w};0==this.audio_init_segment_dispatched_?(this.audio_metadata_=w,this.dispatchAudioInitSegment(k)):this.detectAudioMetadataChange(k)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(k))}}else 128===v&&f===_.common_pids.av1&&(this.video_metadata_.av1c=e.subarray(y+2,y+2+b));y+=2+b}var T=e.subarray(c+5,c+5+p);this.dispatchPESPrivateDataDescriptor(f,h,T)}}else if(h===E.kMetadata){if(p>0)for(y=c+5;y<c+5+p;){v=e[y+0];var L=e[y+1];if(38===v){var R=e[y+2]<<8|e[y+3],x=null;65535===R&&(x=String.fromCharCode.apply(String,Array.from(e.subarray(y+4,y+4+4))));var M=null;if(255===e[y+4+(65535===R?4:0)]){var D=4+(65535===R?4:0)+1;M=String.fromCharCode.apply(String,Array.from(e.subarray(y+D,y+D+4)))}"ID3 "===x&&"ID3 "===M?_.timed_id3_pids[f]=!0:"KLVA"===M&&(_.synchronous_klv_pids[f]=!0)}y+=2+L}}else h===E.kSCTE35&&(_.scte_35_pids[f]=!0);else _.common_pids.mp3=f;else _.common_pids.eac3=f;else _.common_pids.ac3=f;else _.common_pids.loas_aac=f;else _.common_pids.adts_aac=f;else _.common_pids.h265=f;else _.common_pids.h264=f;c+=5+p}a===this.current_program_&&(null==this.pmt_&&n.a.v(this.TAG,"Parsed first PMT: ".concat(JSON.stringify(_))),this.pmt_=_,(_.common_pids.h264||_.common_pids.h265||_.common_pids.av1)&&(this.has_video_=!0),(_.common_pids.adts_aac||_.common_pids.loas_aac||_.common_pids.ac3||_.common_pids.opus||_.common_pids.mp3)&&(this.has_audio_=!0))}else n.a.e(this.TAG,"parsePMT: table_id ".concat(t," is not corresponded to PMT!"))},t.prototype.parseSCTE35=function(e){var t=function(e){var t=new f(e),i=t.readBits(8),a=t.readBool(),r=t.readBool();t.readBits(2);var n=t.readBits(12),s=t.readBits(8),o=t.readBool(),_=t.readBits(6),d=4*t.readBits(31)+t.readBits(2),l=t.readBits(8),u=t.readBits(12),c=t.readBits(12),h=t.readBits(8),p=null;h===V.kSpliceNull?p={}:h===V.kSpliceSchedule?p=function(e){for(var t=e.readBits(8),i=[],a=0;a<t;a++)i.push(te(e));return{splice_count:t,events:i}}(t):h===V.kSpliceInsert?p=function(e){var t=e.readBits(32),i=e.readBool();e.readBits(7);var a={splice_event_id:t,splice_event_cancel_indicator:i};if(i)return a;if(a.out_of_network_indicator=e.readBool(),a.program_splice_flag=e.readBool(),a.duration_flag=e.readBool(),a.splice_immediate_flag=e.readBool(),e.readBits(4),a.program_splice_flag&&!a.splice_immediate_flag&&(a.splice_time=J(e)),!a.program_splice_flag){a.component_count=e.readBits(8),a.components=[];for(var r=0;r<a.component_count;r++)a.components.push($(a.splice_immediate_flag,e))}return a.duration_flag&&(a.break_duration=Z(e)),a.unique_program_id=e.readBits(16),a.avail_num=e.readBits(8),a.avails_expected=e.readBits(8),a}(t):h===V.kTimeSignal?p=function(e){return{splice_time:J(e)}}(t):h===V.kBandwidthReservation?p={}:h===V.kPrivateCommand?p=function(e,t){for(var i=String.fromCharCode(t.readBits(8),t.readBits(8),t.readBits(8),t.readBits(8)),a=new Uint8Array(e-4),r=0;r<e-4;r++)a[r]=t.readBits(8);return{identifier:i,private_data:a.buffer}}(c,t):t.readBits(8*c);for(var m=[],g=t.readBits(16),y=0;y<g;){var v=t.readBits(8),b=t.readBits(8),E=String.fromCharCode(t.readBits(8),t.readBits(8),t.readBits(8),t.readBits(8));0===v?m.push(ie(v,b,E,t)):1===v?m.push(ae(v,b,E,t)):2===v?m.push(ne(v,b,E,t)):3===v?m.push(se(v,b,E,t)):4===v?m.push(_e(v,b,E,t)):t.readBits(8*(b-4)),y+=2+b}var S={table_id:i,section_syntax_indicator:a,private_indicator:r,section_length:n,protocol_version:s,encrypted_packet:o,encryption_algorithm:_,pts_adjustment:d,cw_index:l,tier:u,splice_command_length:c,splice_command_type:h,splice_command:p,descriptor_loop_length:g,splice_descriptors:m,E_CRC32:o?t.readBits(32):void 0,CRC32:t.readBits(32)};if(h===V.kSpliceInsert){var A=p;if(A.splice_event_cancel_indicator)return{splice_command_type:h,detail:S,data:e};if(A.program_splice_flag&&!A.splice_immediate_flag){var w=A.duration_flag?A.break_duration.auto_return:void 0,k=A.duration_flag?A.break_duration.duration/90:void 0;return A.splice_time.time_specified_flag?{splice_command_type:h,pts:(d+A.splice_time.pts_time)%Math.pow(2,33),auto_return:w,duraiton:k,detail:S,data:e}:{splice_command_type:h,auto_return:w,duraiton:k,detail:S,data:e}}return{splice_command_type:h,auto_return:w=A.duration_flag?A.break_duration.auto_return:void 0,duraiton:k=A.duration_flag?A.break_duration.duration/90:void 0,detail:S,data:e}}if(h===V.kTimeSignal){var T=p;return T.splice_time.time_specified_flag?{splice_command_type:h,pts:(d+T.splice_time.pts_time)%Math.pow(2,33),detail:S,data:e}:{splice_command_type:h,detail:S,data:e}}return{splice_command_type:h,detail:S,data:e}}(e);if(null!=t.pts){var i=Math.floor(t.pts/this.timescale_);t.pts=i}else t.nearest_pts=this.getNearestTimestampMilliseconds();this.onSCTE35Metadata&&this.onSCTE35Metadata(t)},t.prototype.parseAV1Payload=function(e,t,i,a,r){for(var n=new Ae(e),s=null,o=[],_=0,d=!1,l=null;null!=(s=n.readNextOBUPayload());){if((l=w.parseOBUs(s,this.video_metadata_.details))&&!0===l.keyframe)if(this.video_init_segment_dispatched_){var u;!0===this.detectVideoMetadataChange(null,l)&&(this.video_metadata_changed_=!0,this.dispatchVideoMediaSegment(),(u=new Uint8Array(new ArrayBuffer(this.video_metadata_.av1c.byteLength+l.sequence_header_data.byteLength))).set(this.video_metadata_.av1c,0),u.set(l.sequence_header_data,this.video_metadata_.av1c.byteLength),l.av1c=u,this.dispatchVideoInitSegment())}else(u=new Uint8Array(new ArrayBuffer(this.video_metadata_.av1c.byteLength+l.sequence_header_data.byteLength))).set(this.video_metadata_.av1c,0),u.set(l.sequence_header_data,this.video_metadata_.av1c.byteLength),l.av1c=u,this.video_metadata_.details=l,this.dispatchVideoInitSegment();this.video_metadata_.details=l,d||(d=l.keyframe),o.push({data:s}),_+=s.byteLength}var c=Math.floor(t/this.timescale_),h=Math.floor(i/this.timescale_);if(o.length){var f=this.video_track_,p={units:o,length:_,isKeyframe:d,dts:h,pts:c,cts:c-h,file_position:a};f.samples.push(p),f.length+=_}},t.prototype.parseH264Payload=function(e,t,i,a,r){for(var s=new U(e),o=null,_=[],d=0,l=!1;null!=(o=s.readNextNaluPayload());){var u=new B(o);if(u.type===R.kSliceSPS){var c=p.parseSPS(o.data);this.video_init_segment_dispatched_?!0===this.detectVideoMetadataChange(u,c)&&(n.a.v(this.TAG,"H264: Critical h264 metadata has been changed, attempt to re-generate InitSegment"),this.video_metadata_changed_=!0,this.video_metadata_={vps:void 0,sps:u,pps:void 0,av1c:void 0,details:c}):(this.video_metadata_.sps=u,this.video_metadata_.details=c)}else u.type===R.kSlicePPS?this.video_init_segment_dispatched_&&!this.video_metadata_changed_||(this.video_metadata_.pps=u,this.video_metadata_.sps&&this.video_metadata_.pps&&(this.video_metadata_changed_&&this.dispatchVideoMediaSegment(),this.dispatchVideoInitSegment())):(u.type===R.kSliceIDR||u.type===R.kSliceNonIDR&&1===r)&&(l=!0);this.video_init_segment_dispatched_&&(_.push(u),d+=u.data.byteLength)}var h=Math.floor(t/this.timescale_),f=Math.floor(i/this.timescale_);if(_.length){var m=this.video_track_,g={units:_,length:d,isKeyframe:l,dts:f,pts:h,cts:h-f,file_position:a};m.samples.push(g),m.length+=d}},t.prototype.parseH265Payload=function(e,t,i,a,r){for(var s=new ue(e),o=null,_=[],d=0,l=!1;null!=(o=s.readNextNaluPayload());){var u=new le(o);if(u.type===Q.kSliceVPS){if(!this.video_init_segment_dispatched_){var c=g.parseVPS(o.data);this.video_metadata_.vps=u,this.video_metadata_.details=ke(ke({},this.video_metadata_.details),c)}}else u.type===Q.kSliceSPS?(c=g.parseSPS(o.data),this.video_init_segment_dispatched_?!0===this.detectVideoMetadataChange(u,c)&&(n.a.v(this.TAG,"H265: Critical h265 metadata has been changed, attempt to re-generate InitSegment"),this.video_metadata_changed_=!0,this.video_metadata_={vps:void 0,sps:u,pps:void 0,av1c:void 0,details:c}):(this.video_metadata_.sps=u,this.video_metadata_.details=ke(ke({},this.video_metadata_.details),c))):u.type===Q.kSlicePPS?this.video_init_segment_dispatched_&&!this.video_metadata_changed_||(c=g.parsePPS(o.data),this.video_metadata_.pps=u,this.video_metadata_.details=ke(ke({},this.video_metadata_.details),c),this.video_metadata_.vps&&this.video_metadata_.sps&&this.video_metadata_.pps&&(this.video_metadata_changed_&&this.dispatchVideoMediaSegment(),this.dispatchVideoInitSegment())):u.type!==Q.kSliceIDR_W_RADL&&u.type!==Q.kSliceIDR_N_LP&&u.type!==Q.kSliceCRA_NUT||(l=!0);this.video_init_segment_dispatched_&&(_.push(u),d+=u.data.byteLength)}var h=Math.floor(t/this.timescale_),f=Math.floor(i/this.timescale_);if(_.length){var p=this.video_track_,m={units:_,length:d,isKeyframe:l,dts:f,pts:h,cts:h-f,file_position:a};p.samples.push(m),p.length+=d}},t.prototype.detectVideoMetadataChange=function(e,t){if(t.codec_mimetype!==this.video_metadata_.details.codec_mimetype)return n.a.v(this.TAG,"Video: Codec mimeType changed from "+"".concat(this.video_metadata_.details.codec_mimetype," to ").concat(t.codec_mimetype)),!0;if(t.codec_size.width!==this.video_metadata_.details.codec_size.width||t.codec_size.height!==this.video_metadata_.details.codec_size.height){var i=this.video_metadata_.details.codec_size,a=t.codec_size;return n.a.v(this.TAG,"Video: Coded Resolution changed from "+"".concat(i.width,"x").concat(i.height," to ").concat(a.width,"x").concat(a.height)),!0}return t.present_size.width!==this.video_metadata_.details.present_size.width&&(n.a.v(this.TAG,"Video: Present resolution width changed from "+"".concat(this.video_metadata_.details.present_size.width," to ").concat(t.present_size.width)),!0)},t.prototype.isInitSegmentDispatched=function(){return this.has_video_&&this.has_audio_?this.video_init_segment_dispatched_&&this.audio_init_segment_dispatched_:this.has_video_&&!this.has_audio_?this.video_init_segment_dispatched_:!(this.has_video_||!this.has_audio_)&&this.audio_init_segment_dispatched_},t.prototype.dispatchVideoInitSegment=function(){var e=this.video_metadata_.details,t={type:"video"};t.id=this.video_track_.id,t.timescale=1e3,t.duration=this.duration_,t.codecWidth=e.codec_size.width,t.codecHeight=e.codec_size.height,t.presentWidth=e.present_size.width,t.presentHeight=e.present_size.height,t.profile=e.profile_string,t.level=e.level_string,t.bitDepth=e.bit_depth,t.chromaFormat=e.chroma_format,t.sarRatio=e.sar_ratio,t.frameRate=e.frame_rate;var i=t.frameRate.fps_den,a=t.frameRate.fps_num;if(t.refSampleDuration=i/a*1e3,t.codec=e.codec_mimetype,this.video_metadata_.av1c)t.av1c=this.video_metadata_.av1c,0==this.video_init_segment_dispatched_&&n.a.v(this.TAG,"Generated first AV1 for mimeType: ".concat(t.codec));else if(this.video_metadata_.vps){var r=this.video_metadata_.vps.data.subarray(4),s=this.video_metadata_.sps.data.subarray(4),o=this.video_metadata_.pps.data.subarray(4),_=new ce(r,s,o,e);t.hvcc=_.getData(),0==this.video_init_segment_dispatched_&&n.a.v(this.TAG,"Generated first HEVCDecoderConfigurationRecord for mimeType: ".concat(t.codec))}else{s=this.video_metadata_.sps.data.subarray(4),o=this.video_metadata_.pps.data.subarray(4);var d=new N(s,o,e);t.avcc=d.getData(),0==this.video_init_segment_dispatched_&&n.a.v(this.TAG,"Generated first AVCDecoderConfigurationRecord for mimeType: ".concat(t.codec))}this.onTrackMetadata("video",t),this.video_init_segment_dispatched_=!0,this.video_metadata_changed_=!1;var l=this.media_info_;l.hasVideo=!0,l.width=t.codecWidth,l.height=t.codecHeight,l.fps=t.frameRate.fps,l.profile=t.profile,l.level=t.level,l.refFrames=e.ref_frames,l.chromaFormat=e.chroma_format_string,l.sarNum=t.sarRatio.width,l.sarDen=t.sarRatio.height,l.videoCodec=t.codec,l.hasAudio&&l.audioCodec?l.mimeType='video/mp2t; codecs="'.concat(l.videoCodec,",").concat(l.audioCodec,'"'):l.mimeType='video/mp2t; codecs="'.concat(l.videoCodec,'"'),l.isComplete()&&this.onMediaInfo(l)},t.prototype.dispatchVideoMediaSegment=function(){this.isInitSegmentDispatched()&&this.video_track_.length&&this.onDataAvailable(null,this.video_track_)},t.prototype.dispatchAudioMediaSegment=function(){this.isInitSegmentDispatched()&&this.audio_track_.length&&this.onDataAvailable(this.audio_track_,null)},t.prototype.dispatchAudioVideoMediaSegment=function(){this.isInitSegmentDispatched()&&(this.audio_track_.length||this.video_track_.length)&&this.onDataAvailable(this.audio_track_,this.video_track_)},t.prototype.parseADTSAACPayload=function(e,t){if(!this.has_video_||this.video_init_segment_dispatched_){if(this.aac_last_incomplete_data_){var i=new Uint8Array(e.byteLength+this.aac_last_incomplete_data_.byteLength);i.set(this.aac_last_incomplete_data_,0),i.set(e,this.aac_last_incomplete_data_.byteLength),e=i}var a,r;if(null!=t&&(r=t/this.timescale_),"aac"===this.audio_metadata_.codec){if(null==t&&null!=this.audio_last_sample_pts_)a=1024/this.audio_metadata_.sampling_frequency*1e3,r=this.audio_last_sample_pts_+a;else if(null==t)return void n.a.w(this.TAG,"AAC: Unknown pts");if(this.aac_last_incomplete_data_&&this.audio_last_sample_pts_){a=1024/this.audio_metadata_.sampling_frequency*1e3;var s=this.audio_last_sample_pts_+a;Math.abs(s-r)>1&&(n.a.w(this.TAG,"AAC: Detected pts overlapped, "+"expected: ".concat(s,"ms, PES pts: ").concat(r,"ms")),r=s)}}for(var o,_=new W(e),d=null,l=r;null!=(d=_.readNextAACFrame());){a=1024/d.sampling_frequency*1e3;var u={codec:"aac",data:d};0==this.audio_init_segment_dispatched_?(this.audio_metadata_={codec:"aac",audio_object_type:d.audio_object_type,sampling_freq_index:d.sampling_freq_index,sampling_frequency:d.sampling_frequency,channel_config:d.channel_config},this.dispatchAudioInitSegment(u)):this.detectAudioMetadataChange(u)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(u)),o=l;var c=Math.floor(l),h={unit:d.data,length:d.data.byteLength,pts:c,dts:c};this.audio_track_.samples.push(h),this.audio_track_.length+=d.data.byteLength,l+=a}_.hasIncompleteData()&&(this.aac_last_incomplete_data_=_.getIncompleteData()),o&&(this.audio_last_sample_pts_=o)}},t.prototype.parseLOASAACPayload=function(e,t){var i;if(!this.has_video_||this.video_init_segment_dispatched_){if(this.aac_last_incomplete_data_){var a=new Uint8Array(e.byteLength+this.aac_last_incomplete_data_.byteLength);a.set(this.aac_last_incomplete_data_,0),a.set(e,this.aac_last_incomplete_data_.byteLength),e=a}var r,s;if(null!=t&&(s=t/this.timescale_),"aac"===this.audio_metadata_.codec){if(null==t&&null!=this.audio_last_sample_pts_)r=1024/this.audio_metadata_.sampling_frequency*1e3,s=this.audio_last_sample_pts_+r;else if(null==t)return void n.a.w(this.TAG,"AAC: Unknown pts");if(this.aac_last_incomplete_data_&&this.audio_last_sample_pts_){r=1024/this.audio_metadata_.sampling_frequency*1e3;var o=this.audio_last_sample_pts_+r;Math.abs(o-s)>1&&(n.a.w(this.TAG,"AAC: Detected pts overlapped, "+"expected: ".concat(o,"ms, PES pts: ").concat(s,"ms")),s=o)}}for(var _,d=new q(e),l=null,u=s;null!=(l=d.readNextAACFrame(null!==(i=this.loas_previous_frame)&&void 0!==i?i:void 0));){this.loas_previous_frame=l,r=1024/l.sampling_frequency*1e3;var c={codec:"aac",data:l};0==this.audio_init_segment_dispatched_?(this.audio_metadata_={codec:"aac",audio_object_type:l.audio_object_type,sampling_freq_index:l.sampling_freq_index,sampling_frequency:l.sampling_frequency,channel_config:l.channel_config},this.dispatchAudioInitSegment(c)):this.detectAudioMetadataChange(c)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(c)),_=u;var h=Math.floor(u),f={unit:l.data,length:l.data.byteLength,pts:h,dts:h};this.audio_track_.samples.push(f),this.audio_track_.length+=l.data.byteLength,u+=r}d.hasIncompleteData()&&(this.aac_last_incomplete_data_=d.getIncompleteData()),_&&(this.audio_last_sample_pts_=_)}},t.prototype.parseAC3Payload=function(e,t){if(!this.has_video_||this.video_init_segment_dispatched_){var i,a;if(null!=t&&(a=t/this.timescale_),"ac-3"===this.audio_metadata_.codec)if(null==t&&null!=this.audio_last_sample_pts_)i=1536/this.audio_metadata_.sampling_frequency*1e3,a=this.audio_last_sample_pts_+i;else if(null==t)return void n.a.w(this.TAG,"AC3: Unknown pts");for(var r,s=new ge(e),o=null,_=a;null!=(o=s.readNextAC3Frame());){i=1536/o.sampling_frequency*1e3;var d={codec:"ac-3",data:o};0==this.audio_init_segment_dispatched_?(this.audio_metadata_={codec:"ac-3",sampling_frequency:o.sampling_frequency,bit_stream_identification:o.bit_stream_identification,bit_stream_mode:o.bit_stream_mode,low_frequency_effects_channel_on:o.low_frequency_effects_channel_on,channel_mode:o.channel_mode},this.dispatchAudioInitSegment(d)):this.detectAudioMetadataChange(d)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(d)),r=_;var l=Math.floor(_),u={unit:o.data,length:o.data.byteLength,pts:l,dts:l};this.audio_track_.samples.push(u),this.audio_track_.length+=o.data.byteLength,_+=i}r&&(this.audio_last_sample_pts_=r)}},t.prototype.parseEAC3Payload=function(e,t){if(!this.has_video_||this.video_init_segment_dispatched_){var i,a;if(null!=t&&(a=t/this.timescale_),"ec-3"===this.audio_metadata_.codec)if(null==t&&null!=this.audio_last_sample_pts_)i=256*this.audio_metadata_.num_blks/this.audio_metadata_.sampling_frequency*1e3,a=this.audio_last_sample_pts_+i;else if(null==t)return void n.a.w(this.TAG,"EAC3: Unknown pts");for(var r,s=new be(e),o=null,_=a;null!=(o=s.readNextEAC3Frame());){i=1536/o.sampling_frequency*1e3;var d={codec:"ec-3",data:o};0==this.audio_init_segment_dispatched_?(this.audio_metadata_={codec:"ec-3",sampling_frequency:o.sampling_frequency,bit_stream_identification:o.bit_stream_identification,low_frequency_effects_channel_on:o.low_frequency_effects_channel_on,num_blks:o.num_blks,channel_mode:o.channel_mode},this.dispatchAudioInitSegment(d)):this.detectAudioMetadataChange(d)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(d)),r=_;var l=Math.floor(_),u={unit:o.data,length:o.data.byteLength,pts:l,dts:l};this.audio_track_.samples.push(u),this.audio_track_.length+=o.data.byteLength,_+=i}r&&(this.audio_last_sample_pts_=r)}},t.prototype.parseOpusPayload=function(e,t){if(!this.has_video_||this.video_init_segment_dispatched_){var i,a;if(null!=t&&(a=t/this.timescale_),"opus"===this.audio_metadata_.codec)if(null==t&&null!=this.audio_last_sample_pts_)i=20,a=this.audio_last_sample_pts_+i;else if(null==t)return void n.a.w(this.TAG,"Opus: Unknown pts");for(var r,s=a,o=0;o<e.length;){i=20;for(var _=!!(16&e[o+1]),d=!!(8&e[o+1]),l=o+2,u=0;255===e[l];)u+=255,l+=1;u+=e[l],l+=1,l+=_?2:0,l+=d?2:0,r=s;var c=Math.floor(s),h=e.slice(l,l+u),f={unit:h,length:h.byteLength,pts:c,dts:c};this.audio_track_.samples.push(f),this.audio_track_.length+=h.byteLength,s+=i,o=l+u}r&&(this.audio_last_sample_pts_=r)}},t.prototype.parseMP3Payload=function(e,t){if(!this.has_video_||this.video_init_segment_dispatched_){var i=e[1]>>>3&3,a=(6&e[1])>>1,r=(e[2],(12&e[2])>>>2),n=3&~(e[3]>>>6)?2:1,s=0,o=34;switch(i){case 0:s=[11025,12e3,8e3,0][r];break;case 2:s=[22050,24e3,16e3,0][r];break;case 3:s=[44100,48e3,32e3,0][r]}switch(a){case 1:o=34;break;case 2:o=33;break;case 3:o=32}var _=new fe;_.object_type=o,_.sample_rate=s,_.channel_count=n,_.data=e;var d={codec:"mp3",data:_};0==this.audio_init_segment_dispatched_?(this.audio_metadata_={codec:"mp3",object_type:o,sample_rate:s,channel_count:n},this.dispatchAudioInitSegment(d)):this.detectAudioMetadataChange(d)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(d));var l={unit:e,length:e.byteLength,pts:t/this.timescale_,dts:t/this.timescale_};this.audio_track_.samples.push(l),this.audio_track_.length+=e.byteLength}},t.prototype.detectAudioMetadataChange=function(e){if(e.codec!==this.audio_metadata_.codec)return n.a.v(this.TAG,"Audio: Audio Codecs changed from "+"".concat(this.audio_metadata_.codec," to ").concat(e.codec)),!0;if("aac"===e.codec&&"aac"===this.audio_metadata_.codec){if((t=e.data).audio_object_type!==this.audio_metadata_.audio_object_type)return n.a.v(this.TAG,"AAC: AudioObjectType changed from "+"".concat(this.audio_metadata_.audio_object_type," to ").concat(t.audio_object_type)),!0;if(t.sampling_freq_index!==this.audio_metadata_.sampling_freq_index)return n.a.v(this.TAG,"AAC: SamplingFrequencyIndex changed from "+"".concat(this.audio_metadata_.sampling_freq_index," to ").concat(t.sampling_freq_index)),!0;if(t.channel_config!==this.audio_metadata_.channel_config)return n.a.v(this.TAG,"AAC: Channel configuration changed from "+"".concat(this.audio_metadata_.channel_config," to ").concat(t.channel_config)),!0}else if("ac-3"===e.codec&&"ac-3"===this.audio_metadata_.codec){var t;if((t=e.data).sampling_frequency!==this.audio_metadata_.sampling_frequency)return n.a.v(this.TAG,"AC3: Sampling Frequency changed from "+"".concat(this.audio_metadata_.sampling_frequency," to ").concat(t.sampling_frequency)),!0;if(t.bit_stream_identification!==this.audio_metadata_.bit_stream_identification)return n.a.v(this.TAG,"AC3: Bit Stream Identification changed from "+"".concat(this.audio_metadata_.bit_stream_identification," to ").concat(t.bit_stream_identification)),!0;if(t.bit_stream_mode!==this.audio_metadata_.bit_stream_mode)return n.a.v(this.TAG,"AC3: BitStream Mode changed from "+"".concat(this.audio_metadata_.bit_stream_mode," to ").concat(t.bit_stream_mode)),!0;if(t.channel_mode!==this.audio_metadata_.channel_mode)return n.a.v(this.TAG,"AC3: Channel Mode changed from "+"".concat(this.audio_metadata_.channel_mode," to ").concat(t.channel_mode)),!0;if(t.low_frequency_effects_channel_on!==this.audio_metadata_.low_frequency_effects_channel_on)return n.a.v(this.TAG,"AC3: Low Frequency Effects Channel On changed from "+"".concat(this.audio_metadata_.low_frequency_effects_channel_on," to ").concat(t.low_frequency_effects_channel_on)),!0}else if("opus"===e.codec&&"opus"===this.audio_metadata_.codec){if((i=e.meta).sample_rate!==this.audio_metadata_.sample_rate)return n.a.v(this.TAG,"Opus: SamplingFrequencyIndex changed from "+"".concat(this.audio_metadata_.sample_rate," to ").concat(i.sample_rate)),!0;if(i.channel_count!==this.audio_metadata_.channel_count)return n.a.v(this.TAG,"Opus: Channel count changed from "+"".concat(this.audio_metadata_.channel_count," to ").concat(i.channel_count)),!0}else if("mp3"===e.codec&&"mp3"===this.audio_metadata_.codec){var i;if((i=e.data).object_type!==this.audio_metadata_.object_type)return n.a.v(this.TAG,"MP3: AudioObjectType changed from "+"".concat(this.audio_metadata_.object_type," to ").concat(i.object_type)),!0;if(i.sample_rate!==this.audio_metadata_.sample_rate)return n.a.v(this.TAG,"MP3: SamplingFrequencyIndex changed from "+"".concat(this.audio_metadata_.sample_rate," to ").concat(i.sample_rate)),!0;if(i.channel_count!==this.audio_metadata_.channel_count)return n.a.v(this.TAG,"MP3: Channel count changed from "+"".concat(this.audio_metadata_.channel_count," to ").concat(i.channel_count)),!0}return!1},t.prototype.dispatchAudioInitSegment=function(e){var t={type:"audio"};if(t.id=this.audio_track_.id,t.timescale=1e3,t.duration=this.duration_,"aac"===this.audio_metadata_.codec){var i="aac"===e.codec?e.data:null,a=new Y(i);t.audioSampleRate=a.sampling_rate,t.channelCount=a.channel_count,t.codec=a.codec_mimetype,t.originalCodec=a.original_codec_mimetype,t.config=a.config,t.refSampleDuration=1024/t.audioSampleRate*t.timescale}else if("ac-3"===this.audio_metadata_.codec){var r="ac-3"===e.codec?e.data:null,s=new ye(r);t.audioSampleRate=s.sampling_rate,t.channelCount=s.channel_count,t.codec=s.codec_mimetype,t.originalCodec=s.original_codec_mimetype,t.config=s.config,t.refSampleDuration=1536/t.audioSampleRate*t.timescale}else if("ec-3"===this.audio_metadata_.codec){var o="ec-3"===e.codec?e.data:null,_=new Ee(o);t.audioSampleRate=_.sampling_rate,t.channelCount=_.channel_count,t.codec=_.codec_mimetype,t.originalCodec=_.original_codec_mimetype,t.config=_.config,t.refSampleDuration=256*_.num_blks/t.audioSampleRate*t.timescale}else"opus"===this.audio_metadata_.codec?(t.audioSampleRate=this.audio_metadata_.sample_rate,t.channelCount=this.audio_metadata_.channel_count,t.channelConfigCode=this.audio_metadata_.channel_config_code,t.codec="opus",t.originalCodec="opus",t.config=void 0,t.refSampleDuration=20):"mp3"===this.audio_metadata_.codec&&(t.audioSampleRate=this.audio_metadata_.sample_rate,t.channelCount=this.audio_metadata_.channel_count,t.codec="mp3",t.originalCodec="mp3",t.config=void 0);0==this.audio_init_segment_dispatched_&&n.a.v(this.TAG,"Generated first AudioSpecificConfig for mimeType: ".concat(t.codec)),this.onTrackMetadata("audio",t),this.audio_init_segment_dispatched_=!0,this.video_metadata_changed_=!1;var d=this.media_info_;d.hasAudio=!0,d.audioCodec=t.originalCodec,d.audioSampleRate=t.audioSampleRate,d.audioChannelCount=t.channelCount,d.hasVideo&&d.videoCodec?d.mimeType='video/mp2t; codecs="'.concat(d.videoCodec,",").concat(d.audioCodec,'"'):d.mimeType='video/mp2t; codecs="'.concat(d.audioCodec,'"'),d.isComplete()&&this.onMediaInfo(d)},t.prototype.dispatchPESPrivateDataDescriptor=function(e,t,i){var a=new X;a.pid=e,a.stream_type=t,a.descriptor=i,this.onPESPrivateDataDescriptor&&this.onPESPrivateDataDescriptor(a)},t.prototype.parsePESPrivateDataPayload=function(e,t,i,a,r){var n=new K;if(n.pid=a,n.stream_id=r,n.len=e.byteLength,n.data=e,null!=t){var s=Math.floor(t/this.timescale_);n.pts=s}else n.nearest_pts=this.getNearestTimestampMilliseconds();if(null!=i){var o=Math.floor(i/this.timescale_);n.dts=o}this.onPESPrivateData&&this.onPESPrivateData(n)},t.prototype.parseTimedID3MetadataPayload=function(e,t,i,a,r){var n=new K;if(n.pid=a,n.stream_id=r,n.len=e.byteLength,n.data=e,null!=t){var s=Math.floor(t/this.timescale_);n.pts=s}if(null!=i){var o=Math.floor(i/this.timescale_);n.dts=o}this.onTimedID3Metadata&&this.onTimedID3Metadata(n)},t.prototype.parseSynchronousKLVMetadataPayload=function(e,t,i,a,r){var n=new Se;if(n.pid=a,n.stream_id=r,n.len=e.byteLength,n.data=e,null!=t){var s=Math.floor(t/this.timescale_);n.pts=s}if(null!=i){var o=Math.floor(i/this.timescale_);n.dts=o}n.access_units=function(e){for(var t=[],i=0;i+5<e.byteLength;){var a=e[i+0],r=e[i+1],n=e[i+2],s=e[i+3]<<8|e[i+4],o=e.slice(i+5,i+5+s);t.push({service_id:a,sequence_number:r,flags:n,data:o}),i+=5+s}return t}(e),this.onSynchronousKLVMetadata&&this.onSynchronousKLVMetadata(n)},t.prototype.parseAsynchronousKLVMetadataPayload=function(e,t,i){var a=new K;a.pid=t,a.stream_id=i,a.len=e.byteLength,a.data=e,this.onAsynchronousKLVMetadata&&this.onAsynchronousKLVMetadata(a)},t.prototype.parseSMPTE2038MetadataPayload=function(e,t,i,a,r){var n=new he;if(n.pid=a,n.stream_id=r,n.len=e.byteLength,n.data=e,null!=t){var s=Math.floor(t/this.timescale_);n.pts=s}if(n.nearest_pts=this.getNearestTimestampMilliseconds(),null!=i){var o=Math.floor(i/this.timescale_);n.dts=o}n.ancillaries=function(e){for(var t=new f(e),i=0,a=[];i+=6,0===t.readBits(6);){var r=t.readBool();i+=1;var n=t.readBits(11);i+=11;var s=t.readBits(12);i+=12;var o=255&t.readBits(10);i+=10;var _=255&t.readBits(10);i+=10;var d=255&t.readBits(10);i+=10;for(var l=new Uint8Array(d),u=0;u<d;u++){var c=255&t.readBits(10);i+=10,l[u]=c}t.readBits(10),i+=10;var h="User Defined";65===o?7===_&&(h="SCTE-104"):95===o?220===_?h="ARIB STD-B37 (1SEG)":221===_?h="ARIB STD-B37 (ANALOG)":222===_?h="ARIB STD-B37 (SD)":223===_&&(h="ARIB STD-B37 (HD)"):97===o&&(1===_?h="EIA-708":2===_&&(h="EIA-608")),a.push({yc_indicator:r,line_number:n,horizontal_offset:s,did:o,sdid:_,user_data:l,description:h,information:{}}),t.readBits(8-(i-Math.floor(i/8))%8),i+=(8-(i-Math.floor(i/8)))%8}return t.destroy(),t=null,a}(e),this.onSMPTE2038Metadata&&this.onSMPTE2038Metadata(n)},t.prototype.getNearestTimestampMilliseconds=function(){return null!=this.audio_last_sample_pts_?Math.floor(this.audio_last_sample_pts_):null!=this.last_pcr_?Math.floor(this.last_pcr_/300/this.timescale_):void 0},t.prototype.getPcrBase=function(e){var t=33554432*e[6]+131072*e[7]+512*e[8]+2*e[9]+(128&e[10])/128+this.timestamp_offset_;return t+4294967296<this.last_pcr_base_&&(t+=8589934592,this.timestamp_offset_+=8589934592),this.last_pcr_base_=t,t},t.prototype.getTimestamp=function(e,t){var i=536870912*(14&e[t])+4194304*(255&e[t+1])+16384*(254&e[t+2])+128*(255&e[t+3])+(254&e[t+4])/2+this.timestamp_offset_;return i+4294967296<this.last_pcr_base_&&(i+=8589934592),i},t}(T),Le=function(e,t,i){if(i||2===arguments.length)for(var a,r=0,n=t.length;r<n;r++)!a&&r in t||(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},Re=function(){function e(){}return e.init=function(){for(var t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],hvc1:[],hvcC:[],av01:[],av1C:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[],Opus:[],dOps:[],"ac-3":[],dac3:[],"ec-3":[],dec3:[],fLaC:[],dfLa:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=e.constants={};i.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),i.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),i.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSC=i.STCO=i.STTS,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),i.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])},e.box=function(e){for(var t=8,i=null,a=Array.prototype.slice.call(arguments,1),r=a.length,n=0;n<r;n++)t+=a[n].byteLength;(i=new Uint8Array(t))[0]=t>>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i.set(e,4);var s=8;for(n=0;n<r;n++)i.set(a[n],s),s+=a[n].byteLength;return i},e.generateInitSegment=function(t){var i=e.box(e.types.ftyp,e.constants.FTYP),a=e.moov(t),r=new Uint8Array(i.byteLength+a.byteLength);return r.set(i,0),r.set(a,i.byteLength),r},e.moov=function(t){var i=e.mvhd(t.timescale,t.duration),a=e.trak(t),r=e.mvex(t);return e.box(e.types.moov,i,a,r)},e.mvhd=function(t,i){return e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,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]))},e.trak=function(t){return e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.tkhd=function(t){var i=t.id,a=t.duration,r=t.presentWidth,n=t.presentHeight;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,255&a,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,n>>>8&255,255&n,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t),e.hdlr(t),e.minf(t))},e.mdhd=function(t){var i=t.timescale,a=t.duration;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,85,196,0,0]))},e.hdlr=function(t){var i;return i="audio"===t.type?e.constants.HDLR_AUDIO:e.constants.HDLR_VIDEO,e.box(e.types.hdlr,i)},e.minf=function(t){var i;return i="audio"===t.type?e.box(e.types.smhd,e.constants.SMHD):e.box(e.types.vmhd,e.constants.VMHD),e.box(e.types.minf,i,e.dinf(),e.stbl(t))},e.dinf=function(){return e.box(e.types.dinf,e.box(e.types.dref,e.constants.DREF))},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.constants.STTS),e.box(e.types.stsc,e.constants.STSC),e.box(e.types.stsz,e.constants.STSZ),e.box(e.types.stco,e.constants.STCO))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp3(t)):"ac-3"===t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.ac3(t)):"ec-3"===t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.ec3(t)):"opus"===t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.Opus(t)):"flac"==t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.fLaC(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp4a(t)):"video"===t.type&&t.codec.startsWith("hvc1")?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.hvc1(t)):"video"===t.type&&t.codec.startsWith("av01")?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.av01(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.avc1(t))},e.mp3=function(t){var i=t.channelCount,a=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,a>>>8&255,255&a,0,0]);return e.box(e.types[".mp3"],r)},e.mp4a=function(t){var i=t.channelCount,a=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,a>>>8&255,255&a,0,0]);return e.box(e.types.mp4a,r,e.esds(t))},e.ac3=function(t){var i=t.channelCount,a=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,a>>>8&255,255&a,0,0]);return e.box(e.types["ac-3"],r,e.box(e.types.dac3,new Uint8Array(t.config)))},e.ec3=function(t){var i=t.channelCount,a=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,a>>>8&255,255&a,0,0]);return e.box(e.types["ec-3"],r,e.box(e.types.dec3,new Uint8Array(t.config)))},e.esds=function(t){var i=t.config||[],a=i.length,r=new Uint8Array([0,0,0,0,3,23+a,0,1,0,4,15+a,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([a]).concat(i).concat([6,1,2]));return e.box(e.types.esds,r)},e.Opus=function(t){var i=t.channelCount,a=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,a>>>8&255,255&a,0,0]);return e.box(e.types.Opus,r,e.dOps(t))},e.dOps=function(t){var i=t.channelCount,a=t.channelConfigCode,r=t.audioSampleRate;if(t.config)return e.box(e.types.dOps,t.config);var n=[];switch(a){case 1:case 2:n=[0];break;case 0:n=[255,1,1,0,1];break;case 128:n=[255,2,0,0,1];break;case 3:n=[1,2,1,0,2,1];break;case 4:n=[1,2,2,0,1,2,3];break;case 5:n=[1,3,2,0,4,1,2,3];break;case 6:n=[1,4,2,0,4,1,2,3,5];break;case 7:n=[1,4,2,0,4,1,2,3,5,6];break;case 8:n=[1,5,3,0,6,1,2,3,4,5,7];break;case 130:n=[1,1,2,0,1];break;case 131:n=[1,1,3,0,1,2];break;case 132:n=[1,1,4,0,1,2,3];break;case 133:n=[1,1,5,0,1,2,3,4];break;case 134:n=[1,1,6,0,1,2,3,4,5];break;case 135:n=[1,1,7,0,1,2,3,4,5,6];break;case 136:n=[1,1,8,0,1,2,3,4,5,6,7]}var s=new Uint8Array(Le([0,i,0,0,r>>>24&255,r>>>17&255,r>>>8&255,r>>>0&255,0,0],n,!0));return e.box(e.types.dOps,s)},e.fLaC=function(t){var i=t.channelCount,a=Math.min(t.audioSampleRate,65535),r=t.sampleSize,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,r,0,0,0,0,a>>>8&255,255&a,0,0]);return e.box(e.types.fLaC,n,e.dfLa(t))},e.dfLa=function(t){var i=new Uint8Array(Le([0,0,0,0],t.config,!0));return e.box(e.types.dfLa,i)},e.avc1=function(t){var i=t.avcc,a=t.codecWidth,r=t.codecHeight,n=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,a>>>8&255,255&a,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 e.box(e.types.avc1,n,e.box(e.types.avcC,i))},e.hvc1=function(t){var i=t.hvcc,a=t.codecWidth,r=t.codecHeight,n=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,a>>>8&255,255&a,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 e.box(e.types.hvc1,n,e.box(e.types.hvcC,i))},e.av01=function(t){var i=t.av1c,a=t.codecWidth||192,r=t.codecHeight||108,n=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,a>>>8&255,255&a,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 e.box(e.types.av01,n,e.box(e.types.av1C,i))},e.mvex=function(t){return e.box(e.types.mvex,e.trex(t))},e.trex=function(t){var i=t.id,a=new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.box(e.types.trex,a)},e.moof=function(t,i){return e.box(e.types.moof,e.mfhd(t.sequenceNumber),e.traf(t,i))},e.mfhd=function(t){var i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]);return e.box(e.types.mfhd,i)},e.traf=function(t,i){var a=t.id,r=e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,255&a])),n=e.box(e.types.tfdt,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),s=e.sdtp(t),o=e.trun(t,s.byteLength+16+16+8+16+8+8);return e.box(e.types.traf,r,n,o,s)},e.sdtp=function(t){for(var i=t.samples||[],a=i.length,r=new Uint8Array(4+a),n=0;n<a;n++){var s=i[n].flags;r[n+4]=s.isLeading<<6|s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy}return e.box(e.types.sdtp,r)},e.trun=function(t,i){var a=t.samples||[],r=a.length,n=12+16*r,s=new Uint8Array(n);i+=8+n,s.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0);for(var o=0;o<r;o++){var _=a[o].duration,d=a[o].size,l=a[o].flags,u=a[o].cts;s.set([_>>>24&255,_>>>16&255,_>>>8&255,255&_,d>>>24&255,d>>>16&255,d>>>8&255,255&d,l.isLeading<<2|l.dependsOn,l.isDependedOn<<6|l.hasRedundancy<<4|l.isNonSync,0,0,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*o)}return e.box(e.types.trun,s)},e.mdat=function(t){return e.box(e.types.mdat,t)},e}();Re.init();var Ce=Re,xe=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null},e}(),Me=i(11),De=function(){function e(e){this.TAG="MP4Remuxer",this._config=e,this._isLive=!0===e.isLive,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new Me.c("audio"),this._videoSegmentInfoList=new Me.c("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!s.a.chrome||!(s.a.version.major<50||50===s.a.version.major&&s.a.version.build<2661)),this._fillSilentAfterSeek=s.a.msedge||s.a.msie,this._mp3UseMpegAudio=!s.a.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return e.prototype.destroy=function(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null},e.prototype.bindDataSource=function(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this},Object.defineProperty(e.prototype,"onInitSegment",{get:function(){return this._onInitSegment},set:function(e){this._onInitSegment=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaSegment",{get:function(){return this._onMediaSegment},set:function(e){this._onMediaSegment=e},enumerable:!1,configurable:!0}),e.prototype.insertDiscontinuity=function(){this._audioNextDts=this._videoNextDts=void 0},e.prototype.seek=function(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()},e.prototype.remux=function(e,t){if(!this._onMediaSegment)throw new u.a("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),t&&this._remuxVideo(t),e&&this._remuxAudio(e)},e.prototype._onTrackMetadataReceived=function(e,t){var i=null,a="mp4",r=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(a="mpeg",r="",i=new Uint8Array):i=Ce.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,i=Ce.generateInitSegment(t)}if(!this._onInitSegment)throw new u.a("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:i.buffer,codec:r,container:"".concat(e,"/").concat(a),mediaDuration:t.duration})},e.prototype._calculateDtsBase=function(e,t){this._dtsBaseInited||(e&&e.samples&&e.samples.length&&(this._audioDtsBase=e.samples[0].dts),t&&t.samples&&t.samples.length&&(this._videoDtsBase=t.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)},e.prototype.getTimestampBase=function(){if(this._dtsBaseInited)return this._dtsBase},e.prototype.flushStashedSamples=function(){var e=this._videoStashedLastSample,t=this._audioStashedLastSample,i={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(i.samples.push(e),i.length=e.length);var a={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(a.samples.push(t),a.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(i,!0),this._remuxAudio(a,!0)},e.prototype._remuxAudio=function(e,t){if(null!=this._audioMeta){var i,a=e,r=a.samples,o=void 0,_=-1,d=this._audioMeta.refSampleDuration,l="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,u=this._dtsBaseInited&&void 0===this._audioNextDts,c=!1;if(r&&0!==r.length&&(1!==r.length||t)){var h=0,f=null,p=0;l?(h=0,p=a.length):(h=8,p=8+a.length);var m=null;if(r.length>1&&(p-=(m=r.pop()).length),null!=this._audioStashedLastSample){var g=this._audioStashedLastSample;this._audioStashedLastSample=null,r.unshift(g),p+=g.length}null!=m&&(this._audioStashedLastSample=m);var y=r[0].dts-this._dtsBase;if(this._audioNextDts)o=y-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())o=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(c=!0);else{var v=this._audioSegmentInfoList.getLastSampleBefore(y);if(null!=v){var b=y-(v.originalDts+v.duration);b<=3&&(b=0),o=y-(v.dts+v.duration+b)}else o=0}if(c){var E=y-o,S=this._videoSegmentInfoList.getLastSegmentBefore(y);if(null!=S&&S.beginDts<E){if(O=xe.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount)){var A=S.beginDts,w=E-S.beginDts;n.a.v(this.TAG,"InsertPrefixSilentAudio: dts: ".concat(A,", duration: ").concat(w)),r.unshift({unit:O,dts:A,pts:A}),p+=O.byteLength}}else c=!1}for(var k=[],T=0;T<r.length;T++){var L=(g=r[T]).unit,R=g.dts-this._dtsBase,C=(A=R,!1),x=null,M=0;if(!(R<-.001)){if("mp3"!==this._audioMeta.codec&&null!=d){var D=R;if(this._audioNextDts&&(D=this._audioNextDts),(o=R-D)<=-3*d){n.a.w(this.TAG,"Dropping 1 audio frame (originalDts: ".concat(R," ms ,curRefDts: ").concat(D," ms) due to dtsCorrection: ").concat(o," ms overlap."));continue}if(o>=3*d&&this._fillAudioTimestampGap&&!s.a.safari){C=!0;var O,I=Math.floor(o/d);n.a.w(this.TAG,"Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\n"+"originalDts: ".concat(R," ms, curRefDts: ").concat(D," ms, ")+"dtsCorrection: ".concat(Math.round(o)," ms, generate: ").concat(I," frames")),A=Math.floor(D),M=Math.floor(D+d)-A,null==(O=xe.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount))&&(n.a.w(this.TAG,"Unable to generate silent frame for "+"".concat(this._audioMeta.originalCodec," with ").concat(this._audioMeta.channelCount," channels, repeat last frame")),O=L),x=[];for(var P=0;P<I;P++){D+=d;var B=Math.floor(D),U=Math.floor(D+d)-B,N={dts:B,pts:B,cts:0,unit:O,size:O.byteLength,duration:U,originalDts:R,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};x.push(N),p+=N.size}this._audioNextDts=D+d}else A=Math.floor(D),M=Math.floor(D+d)-A,this._audioNextDts=D+d}else A=R-o,M=T!==r.length-1?r[T+1].dts-this._dtsBase-o-A:null!=m?m.dts-this._dtsBase-o-A:k.length>=1?k[k.length-1].duration:Math.floor(d),this._audioNextDts=A+M;-1===_&&(_=A),k.push({dts:A,pts:A,cts:0,unit:g.unit,size:g.unit.byteLength,duration:M,originalDts:R,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),C&&k.push.apply(k,x)}}if(0===k.length)return a.samples=[],void(a.length=0);for(l?f=new Uint8Array(p):((f=new Uint8Array(p))[0]=p>>>24&255,f[1]=p>>>16&255,f[2]=p>>>8&255,f[3]=255&p,f.set(Ce.types.mdat,4)),T=0;T<k.length;T++)L=k[T].unit,f.set(L,h),h+=L.byteLength;var F=k[k.length-1];i=F.dts+F.duration;var V,j=new Me.b;j.beginDts=_,j.endDts=i,j.beginPts=_,j.endPts=i,j.originalBeginDts=k[0].originalDts,j.originalEndDts=F.originalDts+F.duration,j.firstSample=new Me.d(k[0].dts,k[0].pts,k[0].duration,k[0].originalDts,!1),j.lastSample=new Me.d(F.dts,F.pts,F.duration,F.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(j),a.samples=k,a.sequenceNumber++,V=l?new Uint8Array:Ce.moof(a,_),a.samples=[],a.length=0;var G={type:"audio",data:this._mergeBoxes(V,f).buffer,sampleCount:k.length,info:j};l&&u&&(G.timestampOffset=_),this._onMediaSegment("audio",G)}}},e.prototype._remuxVideo=function(e,t){if(null!=this._videoMeta){var i,a,r=e,n=r.samples,s=void 0,o=-1,_=-1;if(n&&0!==n.length&&(1!==n.length||t)){var d=8,l=null,u=8+e.length,c=null;if(n.length>1&&(u-=(c=n.pop()).length),null!=this._videoStashedLastSample){var h=this._videoStashedLastSample;this._videoStashedLastSample=null,n.unshift(h),u+=h.length}null!=c&&(this._videoStashedLastSample=c);var f=n[0].dts-this._dtsBase;if(this._videoNextDts)s=f-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())s=0;else{var p=this._videoSegmentInfoList.getLastSampleBefore(f);if(null!=p){var m=f-(p.originalDts+p.duration);m<=3&&(m=0),s=f-(p.dts+p.duration+m)}else s=0}for(var g=new Me.b,y=[],v=0;v<n.length;v++){var b=(h=n[v]).dts-this._dtsBase,E=h.isKeyframe,S=b-s,A=h.cts,w=S+A;-1===o&&(o=S,_=w);var k=0;if(k=v!==n.length-1?n[v+1].dts-this._dtsBase-s-S:null!=c?c.dts-this._dtsBase-s-S:y.length>=1?y[y.length-1].duration:Math.floor(this._videoMeta.refSampleDuration),E){var T=new Me.d(S,w,k,h.dts,!0);T.fileposition=h.fileposition,g.appendSyncPoint(T)}y.push({dts:S,pts:w,cts:A,units:h.units,size:h.length,isKeyframe:E,duration:k,originalDts:b,flags:{isLeading:0,dependsOn:E?2:1,isDependedOn:E?1:0,hasRedundancy:0,isNonSync:E?0:1}})}for((l=new Uint8Array(u))[0]=u>>>24&255,l[1]=u>>>16&255,l[2]=u>>>8&255,l[3]=255&u,l.set(Ce.types.mdat,4),v=0;v<y.length;v++)for(var L=y[v].units;L.length;){var R=L.shift().data;l.set(R,d),d+=R.byteLength}var C=y[y.length-1];if(i=C.dts+C.duration,a=C.pts+C.duration,this._videoNextDts=i,g.beginDts=o,g.endDts=i,g.beginPts=_,g.endPts=a,g.originalBeginDts=y[0].originalDts,g.originalEndDts=C.originalDts+C.duration,g.firstSample=new Me.d(y[0].dts,y[0].pts,y[0].duration,y[0].originalDts,y[0].isKeyframe),g.lastSample=new Me.d(C.dts,C.pts,C.duration,C.originalDts,C.isKeyframe),this._isLive||this._videoSegmentInfoList.append(g),r.samples=y,r.sequenceNumber++,this._forceFirstIDR){var x=y[0].flags;x.dependsOn=2,x.isNonSync=0}var M=Ce.moof(r,o);r.samples=[],r.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(M,l).buffer,sampleCount:y.length,info:g})}}},e.prototype._mergeBoxes=function(e,t){var i=new Uint8Array(e.byteLength+t.byteLength);return i.set(e,0),i.set(t,e.byteLength),i},e}(),Oe=i(14),Ie=i(1),Pe=(i(2),function(){function e(e,t){this.TAG="TransmuxingController",this._emitter=new r.a,this._config=t,e.segments||(e.segments=[{duration:e.duration,filesize:e.filesize,url:e.url}]),"boolean"!=typeof e.cors&&(e.cors=!0),"boolean"!=typeof e.withCredentials&&(e.withCredentials=!1),this._mediaDataSource=e,this._currentSegmentIndex=0;var i=0;this._mediaDataSource.segments.forEach((function(a){a.timestampBase=i,i+=a.duration,a.cors=e.cors,a.withCredentials=e.withCredentials,t.referrerPolicy&&(a.referrerPolicy=t.referrerPolicy)})),isNaN(i)||this._mediaDataSource.duration===i||(this._mediaDataSource.duration=i),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}return e.prototype.destroy=function(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.start=function(){this._loadSegment(0),this._enableStatisticsReporter()},e.prototype._loadSegment=function(e,t){this._currentSegmentIndex=e;var i=this._mediaDataSource.segments[e],a=this._ioctl=new Oe.a(i,this._config,e);a.onError=this._onIOException.bind(this),a.onSeeked=this._onIOSeeked.bind(this),a.onComplete=this._onIOComplete.bind(this),a.onRedirect=this._onIORedirect.bind(this),a.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),t?this._demuxer.bindDataSource(this._ioctl):a.onDataArrival=this._onInitChunkArrival.bind(this),a.open(t)},e.prototype.stop=function(){this._internalAbort(),this._disableStatisticsReporter()},e.prototype._internalAbort=function(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)},e.prototype.pause=function(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())},e.prototype.resume=function(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())},e.prototype.seek=function(e){if(null!=this._mediaInfo&&this._mediaInfo.isSeekable()){var t=this._searchSegmentIndexContains(e);if(t===this._currentSegmentIndex){var i=this._mediaInfo.segments[t];if(null==i)this._pendingSeekTime=e;else{var a=i.getNearestKeyframe(e);this._remuxer.seek(a.milliseconds),this._ioctl.seek(a.fileposition),this._pendingResolveSeekPoint=a.milliseconds}}else{var r=this._mediaInfo.segments[t];null==r?(this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t)):(a=r.getNearestKeyframe(e),this._internalAbort(),this._remuxer.seek(e),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[t].timestampBase,this._loadSegment(t,a.fileposition),this._pendingResolveSeekPoint=a.milliseconds,this._reportSegmentMediaInfo(t))}this._enableStatisticsReporter()}},e.prototype._searchSegmentIndexContains=function(e){for(var t=this._mediaDataSource.segments,i=t.length-1,a=0;a<t.length;a++)if(e<t[a].timestampBase){i=a-1;break}return i},e.prototype._onInitChunkArrival=function(e,t){var i=this,a=0;if(t>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,a=this._demuxer.parseChunks(e,t);else{var r=null;(r=k.probe(e)).match&&(this._setupFLVDemuxerRemuxer(r),a=this._demuxer.parseChunks(e,t)),r.match||r.needMoreData||(r=Te.probe(e)).match&&(this._setupTSDemuxerRemuxer(r),a=this._demuxer.parseChunks(e,t)),r.match||r.needMoreData||(r=null,n.a.e(this.TAG,"Non MPEG-TS/FLV, Unsupported media type!"),Promise.resolve().then((function(){i._internalAbort()})),this._emitter.emit(Ie.a.DEMUX_ERROR,m.a.FORMAT_UNSUPPORTED,"Non MPEG-TS/FLV, Unsupported media type!"))}return a},e.prototype._setupFLVDemuxerRemuxer=function(e){this._demuxer=new k(e,this._config),this._remuxer||(this._remuxer=new De(this._config));var t=this._mediaDataSource;null==t.duration||isNaN(t.duration)||(this._demuxer.overridedDuration=t.duration),"boolean"==typeof t.hasAudio&&(this._demuxer.overridedHasAudio=t.hasAudio),"boolean"==typeof t.hasVideo&&(this._demuxer.overridedHasVideo=t.hasVideo),this._demuxer.timestampBase=t.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)},e.prototype._setupTSDemuxerRemuxer=function(e){var t=this._demuxer=new Te(e,this._config);this._remuxer||(this._remuxer=new De(this._config)),t.onError=this._onDemuxException.bind(this),t.onMediaInfo=this._onMediaInfo.bind(this),t.onMetaDataArrived=this._onMetaDataArrived.bind(this),t.onTimedID3Metadata=this._onTimedID3Metadata.bind(this),t.onSynchronousKLVMetadata=this._onSynchronousKLVMetadata.bind(this),t.onAsynchronousKLVMetadata=this._onAsynchronousKLVMetadata.bind(this),t.onSMPTE2038Metadata=this._onSMPTE2038Metadata.bind(this),t.onSCTE35Metadata=this._onSCTE35Metadata.bind(this),t.onPESPrivateDataDescriptor=this._onPESPrivateDataDescriptor.bind(this),t.onPESPrivateData=this._onPESPrivateData.bind(this),this._remuxer.bindDataSource(this._demuxer),this._demuxer.bindDataSource(this._ioctl),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this)},e.prototype._onMediaInfo=function(e){var t=this;null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,o.a.prototype));var i=Object.assign({},e);Object.setPrototypeOf(i,o.a.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=i,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then((function(){var e=t._pendingSeekTime;t._pendingSeekTime=null,t.seek(e)}))},e.prototype._onMetaDataArrived=function(e){this._emitter.emit(Ie.a.METADATA_ARRIVED,e)},e.prototype._onScriptDataArrived=function(e){this._emitter.emit(Ie.a.SCRIPTDATA_ARRIVED,e)},e.prototype._onTimedID3Metadata=function(e){var t=this._remuxer.getTimestampBase();null!=t&&(null!=e.pts&&(e.pts-=t),null!=e.dts&&(e.dts-=t),this._emitter.emit(Ie.a.TIMED_ID3_METADATA_ARRIVED,e))},e.prototype._onSynchronousKLVMetadata=function(e){var t=this._remuxer.getTimestampBase();null!=t&&(null!=e.pts&&(e.pts-=t),null!=e.dts&&(e.dts-=t),this._emitter.emit(Ie.a.SYNCHRONOUS_KLV_METADATA_ARRIVED,e))},e.prototype._onAsynchronousKLVMetadata=function(e){this._emitter.emit(Ie.a.ASYNCHRONOUS_KLV_METADATA_ARRIVED,e)},e.prototype._onSMPTE2038Metadata=function(e){var t=this._remuxer.getTimestampBase();null!=t&&(null!=e.pts&&(e.pts-=t),null!=e.dts&&(e.dts-=t),null!=e.nearest_pts&&(e.nearest_pts-=t),this._emitter.emit(Ie.a.SMPTE2038_METADATA_ARRIVED,e))},e.prototype._onSCTE35Metadata=function(e){var t=this._remuxer.getTimestampBase();null!=t&&(null!=e.pts&&(e.pts-=t),null!=e.nearest_pts&&(e.nearest_pts-=t),this._emitter.emit(Ie.a.SCTE35_METADATA_ARRIVED,e))},e.prototype._onPESPrivateDataDescriptor=function(e){this._emitter.emit(Ie.a.PES_PRIVATE_DATA_DESCRIPTOR,e)},e.prototype._onPESPrivateData=function(e){var t=this._remuxer.getTimestampBase();null!=t&&(null!=e.pts&&(e.pts-=t),null!=e.nearest_pts&&(e.nearest_pts-=t),null!=e.dts&&(e.dts-=t),this._emitter.emit(Ie.a.PES_PRIVATE_DATA_ARRIVED,e))},e.prototype._onIOSeeked=function(){this._remuxer.insertDiscontinuity()},e.prototype._onIOComplete=function(e){var t=e+1;t<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer&&this._remuxer.flushStashedSamples(),this._loadSegment(t)):(this._remuxer&&this._remuxer.flushStashedSamples(),this._emitter.emit(Ie.a.LOADING_COMPLETE),this._disableStatisticsReporter())},e.prototype._onIORedirect=function(e){var t=this._ioctl.extraData;this._mediaDataSource.segments[t].redirectedURL=e},e.prototype._onIORecoveredEarlyEof=function(){this._emitter.emit(Ie.a.RECOVERED_EARLY_EOF)},e.prototype._onIOException=function(e,t){n.a.e(this.TAG,"IOException: type = ".concat(e,", code = ").concat(t.code,", msg = ").concat(t.msg)),this._emitter.emit(Ie.a.IO_ERROR,e,t),this._disableStatisticsReporter()},e.prototype._onDemuxException=function(e,t){n.a.e(this.TAG,"DemuxException: type = ".concat(e,", info = ").concat(t)),this._emitter.emit(Ie.a.DEMUX_ERROR,e,t)},e.prototype._onRemuxerInitSegmentArrival=function(e,t){this._emitter.emit(Ie.a.INIT_SEGMENT,e,t)},e.prototype._onRemuxerMediaSegmentArrival=function(e,t){if(null==this._pendingSeekTime&&(this._emitter.emit(Ie.a.MEDIA_SEGMENT,e,t),null!=this._pendingResolveSeekPoint&&"video"===e)){var i=t.info.syncPoints,a=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,s.a.safari&&i.length>0&&i[0].originalDts===a&&(a=i[0].pts),this._emitter.emit(Ie.a.RECOMMEND_SEEKPOINT,a)}},e.prototype._enableStatisticsReporter=function(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))},e.prototype._disableStatisticsReporter=function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype._reportSegmentMediaInfo=function(e){var t=this._mediaInfo.segments[e],i=Object.assign({},t);i.duration=this._mediaInfo.duration,i.segmentCount=this._mediaInfo.segmentCount,delete i.segments,delete i.keyframesIndex,this._emitter.emit(Ie.a.MEDIA_INFO,i)},e.prototype._reportStatisticsInfo=function(){var e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(Ie.a.STATISTICS_INFO,e)},e}());t.a=Pe},function(e,t,i){"use strict";var a,r=i(0),n=function(){function e(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}return e.prototype.reset=function(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0},e.prototype.addBytes=function(e){0===this._firstCheckpoint?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=e,this._totalBytes+=e):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=e,this._totalBytes+=e):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=e,this._totalBytes+=e,this._lastCheckpoint=this._now())},Object.defineProperty(e.prototype,"currentKBps",{get:function(){this.addBytes(0);var e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastSecondKBps",{get:function(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageKBps",{get:function(){var e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024},enumerable:!1,configurable:!0}),e}(),s=i(2),o=i(5),_=i(3),d=(a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),l=function(e){function t(t,i){var a=e.call(this,"fetch-stream-loader")||this;return a.TAG="FetchStreamLoader",a._seekHandler=t,a._config=i,a._needStash=!0,a._requestAbort=!1,a._abortController=null,a._contentLength=null,a._receivedLength=0,a}return d(t,e),t.isSupported=function(){try{var e=o.a.msedge&&o.a.version.minor>=15048,t=!o.a.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(e){return!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),e.prototype.destroy.call(this)},t.prototype.open=function(e,t){var i=this;this._dataSource=e,this._range=t;var a=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(a=e.redirectedURL);var r=this._seekHandler.getConfig(a,t),n=new self.Headers;if("object"==typeof r.headers){var o=r.headers;for(var d in o)o.hasOwnProperty(d)&&n.append(d,o[d])}var l={method:"GET",headers:n,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"==typeof this._config.headers)for(var d in this._config.headers)n.append(d,this._config.headers[d]);!1===e.cors&&(l.mode="same-origin"),e.withCredentials&&(l.credentials="include"),e.referrerPolicy&&(l.referrerPolicy=e.referrerPolicy),self.AbortController&&(this._abortController=new self.AbortController,l.signal=this._abortController.signal),this._status=s.c.kConnecting,self.fetch(r.url,l).then((function(e){if(i._requestAbort)return i._status=s.c.kIdle,void e.body.cancel();if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==r.url&&i._onURLRedirect){var t=i._seekHandler.removeURLParameters(e.url);i._onURLRedirect(t)}var a=e.headers.get("Content-Length");return null!=a&&(i._contentLength=parseInt(a),0!==i._contentLength&&i._onContentLengthKnown&&i._onContentLengthKnown(i._contentLength)),i._pump.call(i,e.body.getReader())}if(i._status=s.c.kError,!i._onError)throw new _.d("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);i._onError(s.b.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})})).catch((function(e){if(!i._abortController||!i._abortController.signal.aborted){if(i._status=s.c.kError,!i._onError)throw e;i._onError(s.b.EXCEPTION,{code:-1,msg:e.message})}}))},t.prototype.abort=function(){if(this._requestAbort=!0,(this._status!==s.c.kBuffering||!o.a.chrome)&&this._abortController)try{this._abortController.abort()}catch(e){}},t.prototype._pump=function(e){var t=this;return e.read().then((function(i){if(i.done)if(null!==t._contentLength&&t._receivedLength<t._contentLength){t._status=s.c.kError;var a=s.b.EARLY_EOF,r={code:-1,msg:"Fetch stream meet Early-EOF"};if(!t._onError)throw new _.d(r.msg);t._onError(a,r)}else t._status=s.c.kComplete,t._onComplete&&t._onComplete(t._range.from,t._range.from+t._receivedLength-1);else{if(t._abortController&&t._abortController.signal.aborted)return void(t._status=s.c.kComplete);if(!0===t._requestAbort)return t._status=s.c.kComplete,e.cancel();t._status=s.c.kBuffering;var n=i.value.buffer,o=t._range.from+t._receivedLength;t._receivedLength+=n.byteLength,t._onDataArrival&&t._onDataArrival(n,o,t._receivedLength),t._pump(e)}})).catch((function(e){if(t._abortController&&t._abortController.signal.aborted)t._status=s.c.kComplete;else if(11!==e.code||!o.a.msedge){t._status=s.c.kError;var i=0,a=null;if(19!==e.code&&"network error"!==e.message||!(null===t._contentLength||null!==t._contentLength&&t._receivedLength<t._contentLength)?(i=s.b.EXCEPTION,a={code:e.code,msg:e.message}):(i=s.b.EARLY_EOF,a={code:e.code,msg:"Fetch stream meet Early-EOF"}),!t._onError)throw new _.d(a.msg);t._onError(i,a)}}))},t}(s.a),u=function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function a(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(a.prototype=i.prototype,new a)}}(),c=function(e){function t(t,i){var a=e.call(this,"xhr-moz-chunked-loader")||this;return a.TAG="MozChunkedLoader",a._seekHandler=t,a._config=i,a._needStash=!0,a._xhr=null,a._requestAbort=!1,a._contentLength=null,a._receivedLength=0,a}return u(t,e),t.isSupported=function(){try{var e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="moz-chunked-arraybuffer","moz-chunked-arraybuffer"===e.responseType}catch(e){return r.a.w("MozChunkedLoader",e.message),!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),e.prototype.destroy.call(this)},t.prototype.open=function(e,t){this._dataSource=e,this._range=t;var i=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(i=e.redirectedURL);var a=this._seekHandler.getConfig(i,t);this._requestURL=a.url;var r=this._xhr=new XMLHttpRequest;if(r.open("GET",a.url,!0),r.responseType="moz-chunked-arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onloadend=this._onLoadEnd.bind(this),r.onerror=this._onXhrError.bind(this),e.withCredentials&&(r.withCredentials=!0),"object"==typeof a.headers){var n=a.headers;for(var o in n)n.hasOwnProperty(o)&&r.setRequestHeader(o,n[o])}if("object"==typeof this._config.headers)for(var o in n=this._config.headers)n.hasOwnProperty(o)&&r.setRequestHeader(o,n[o]);this._status=s.c.kConnecting,r.send()},t.prototype.abort=function(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=s.c.kComplete},t.prototype._onReadyStateChange=function(e){var t=e.target;if(2===t.readyState){if(null!=t.responseURL&&t.responseURL!==this._requestURL&&this._onURLRedirect){var i=this._seekHandler.removeURLParameters(t.responseURL);this._onURLRedirect(i)}if(0!==t.status&&(t.status<200||t.status>299)){if(this._status=s.c.kError,!this._onError)throw new _.d("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(s.b.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=s.c.kBuffering}},t.prototype._onProgress=function(e){if(this._status!==s.c.kError){null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var t=e.target.response,i=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}},t.prototype._onLoadEnd=function(e){!0!==this._requestAbort?this._status!==s.c.kError&&(this._status=s.c.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1},t.prototype._onXhrError=function(e){this._status=s.c.kError;var t=0,i=null;if(this._contentLength&&e.loaded<this._contentLength?(t=s.b.EARLY_EOF,i={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(t=s.b.EXCEPTION,i={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new _.d(i.msg);this._onError(t,i)},t}(s.a),h=function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function a(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(a.prototype=i.prototype,new a)}}(),f=(function(e){function t(t,i){var a=e.call(this,"xhr-msstream-loader")||this;return a.TAG="MSStreamLoader",a._seekHandler=t,a._config=i,a._needStash=!0,a._xhr=null,a._reader=null,a._totalRange=null,a._currentRange=null,a._currentRequestURL=null,a._currentRedirectedURL=null,a._contentLength=null,a._receivedLength=0,a._bufferLimit=16777216,a._lastTimeBufferSize=0,a._isReconnecting=!1,a}h(t,e),t.isSupported=function(){try{if(void 0===self.MSStream||void 0===self.MSStreamReader)return!1;var e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="ms-stream","ms-stream"===e.responseType}catch(e){return r.a.w("MSStreamLoader",e.message),!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),this._reader&&(this._reader.onprogress=null,this._reader.onload=null,this._reader.onerror=null,this._reader=null),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr=null),e.prototype.destroy.call(this)},t.prototype.open=function(e,t){this._internalOpen(e,t,!1)},t.prototype._internalOpen=function(e,t,i){this._dataSource=e,i?this._currentRange=t:this._totalRange=t;var a=e.url;this._config.reuseRedirectedURL&&(null!=this._currentRedirectedURL?a=this._currentRedirectedURL:null!=e.redirectedURL&&(a=e.redirectedURL));var r=this._seekHandler.getConfig(a,t);this._currentRequestURL=r.url;var n=this._reader=new self.MSStreamReader;n.onprogress=this._msrOnProgress.bind(this),n.onload=this._msrOnLoad.bind(this),n.onerror=this._msrOnError.bind(this);var o=this._xhr=new XMLHttpRequest;if(o.open("GET",r.url,!0),o.responseType="ms-stream",o.onreadystatechange=this._xhrOnReadyStateChange.bind(this),o.onerror=this._xhrOnError.bind(this),e.withCredentials&&(o.withCredentials=!0),"object"==typeof r.headers){var _=r.headers;for(var d in _)_.hasOwnProperty(d)&&o.setRequestHeader(d,_[d])}if("object"==typeof this._config.headers)for(var d in _=this._config.headers)_.hasOwnProperty(d)&&o.setRequestHeader(d,_[d]);this._isReconnecting?this._isReconnecting=!1:this._status=s.c.kConnecting,o.send()},t.prototype.abort=function(){this._internalAbort(),this._status=s.c.kComplete},t.prototype._internalAbort=function(){this._reader&&(1===this._reader.readyState&&this._reader.abort(),this._reader.onprogress=null,this._reader.onload=null,this._reader.onerror=null,this._reader=null),this._xhr&&(this._xhr.abort(),this._xhr.onreadystatechange=null,this._xhr=null)},t.prototype._xhrOnReadyStateChange=function(e){var t=e.target;if(2===t.readyState)if(t.status>=200&&t.status<=299){if(this._status=s.c.kBuffering,null!=t.responseURL){var i=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&i!==this._currentRedirectedURL&&(this._currentRedirectedURL=i,this._onURLRedirect&&this._onURLRedirect(i))}var a=t.getResponseHeader("Content-Length");if(null!=a&&null==this._contentLength){var r=parseInt(a);r>0&&(this._contentLength=r,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength))}}else{if(this._status=s.c.kError,!this._onError)throw new _.d("MSStreamLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(s.b.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else if(3===t.readyState&&t.status>=200&&t.status<=299){this._status=s.c.kBuffering;var n=t.response;this._reader.readAsArrayBuffer(n)}},t.prototype._xhrOnError=function(e){this._status=s.c.kError;var t=s.b.EXCEPTION,i={code:-1,msg:e.constructor.name+" "+e.type};if(!this._onError)throw new _.d(i.msg);this._onError(t,i)},t.prototype._msrOnProgress=function(e){var t=e.target.result;if(null!=t){var i=t.slice(this._lastTimeBufferSize);this._lastTimeBufferSize=t.byteLength;var a=this._totalRange.from+this._receivedLength;this._receivedLength+=i.byteLength,this._onDataArrival&&this._onDataArrival(i,a,this._receivedLength),t.byteLength>=this._bufferLimit&&(r.a.v(this.TAG,"MSStream buffer exceeded max size near ".concat(a+i.byteLength,", reconnecting...")),this._doReconnectIfNeeded())}else this._doReconnectIfNeeded()},t.prototype._doReconnectIfNeeded=function(){if(null==this._contentLength||this._receivedLength<this._contentLength){this._isReconnecting=!0,this._lastTimeBufferSize=0,this._internalAbort();var e={from:this._totalRange.from+this._receivedLength,to:-1};this._internalOpen(this._dataSource,e,!0)}},t.prototype._msrOnLoad=function(e){this._status=s.c.kComplete,this._onComplete&&this._onComplete(this._totalRange.from,this._totalRange.from+this._receivedLength-1)},t.prototype._msrOnError=function(e){this._status=s.c.kError;var t=0,i=null;if(this._contentLength&&this._receivedLength<this._contentLength?(t=s.b.EARLY_EOF,i={code:-1,msg:"MSStream meet Early-Eof"}):(t=s.b.EARLY_EOF,i={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new _.d(i.msg);this._onError(t,i)}}(s.a),function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function a(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(a.prototype=i.prototype,new a)}}()),p=function(e){function t(t,i){var a=e.call(this,"xhr-range-loader")||this;return a.TAG="RangeLoader",a._seekHandler=t,a._config=i,a._needStash=!1,a._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],a._currentChunkSizeKB=384,a._currentSpeedNormalized=0,a._zeroSpeedChunkCount=0,a._xhr=null,a._speedSampler=new n,a._requestAbort=!1,a._waitForTotalLength=!1,a._totalLengthReceived=!1,a._currentRequestURL=null,a._currentRedirectedURL=null,a._currentRequestRange=null,a._totalLength=null,a._contentLength=null,a._receivedLength=0,a._lastTimeLoaded=0,a}return f(t,e),t.isSupported=function(){try{var e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="arraybuffer","arraybuffer"===e.responseType}catch(e){return r.a.w("RangeLoader",e.message),!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),e.prototype.destroy.call(this)},Object.defineProperty(t.prototype,"currentSpeed",{get:function(){return this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),t.prototype.open=function(e,t){this._dataSource=e,this._range=t,this._status=s.c.kConnecting;var i=!1;null!=this._dataSource.filesize&&0!==this._dataSource.filesize&&(i=!0,this._totalLength=this._dataSource.filesize),this._totalLengthReceived||i?this._openSubRange():(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1}))},t.prototype._openSubRange=function(){var e=1024*this._currentChunkSizeKB,t=this._range.from+this._receivedLength,i=t+e;null!=this._contentLength&&i-this._range.from>=this._contentLength&&(i=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:i},this._internalOpen(this._dataSource,this._currentRequestRange)},t.prototype._internalOpen=function(e,t){this._lastTimeLoaded=0;var i=e.url;this._config.reuseRedirectedURL&&(null!=this._currentRedirectedURL?i=this._currentRedirectedURL:null!=e.redirectedURL&&(i=e.redirectedURL));var a=this._seekHandler.getConfig(i,t);this._currentRequestURL=a.url;var r=this._xhr=new XMLHttpRequest;if(r.open("GET",a.url,!0),r.responseType="arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onload=this._onLoad.bind(this),r.onerror=this._onXhrError.bind(this),e.withCredentials&&(r.withCredentials=!0),"object"==typeof a.headers){var n=a.headers;for(var s in n)n.hasOwnProperty(s)&&r.setRequestHeader(s,n[s])}if("object"==typeof this._config.headers)for(var s in n=this._config.headers)n.hasOwnProperty(s)&&r.setRequestHeader(s,n[s]);r.send()},t.prototype.abort=function(){this._requestAbort=!0,this._internalAbort(),this._status=s.c.kComplete},t.prototype._internalAbort=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)},t.prototype._onReadyStateChange=function(e){var t=e.target;if(2===t.readyState){if(null!=t.responseURL){var i=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&i!==this._currentRedirectedURL&&(this._currentRedirectedURL=i,this._onURLRedirect&&this._onURLRedirect(i))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=s.c.kBuffering}else{if(this._status=s.c.kError,!this._onError)throw new _.d("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(s.b.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}},t.prototype._onProgress=function(e){if(this._status!==s.c.kError){if(null===this._contentLength){var t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;var i=e.total;this._internalAbort(),null!=i&0!==i&&(this._totalLength=i)}if(-1===this._range.to?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,t)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var a=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(a)}},t.prototype._normalizeSpeed=function(e){var t=this._chunkSizeKBList,i=t.length-1,a=0,r=0,n=i;if(e<t[0])return t[0];for(;r<=n;){if((a=r+Math.floor((n-r)/2))===i||e>=t[a]&&e<t[a+1])return t[a];t[a]<e?r=a+1:n=a-1}},t.prototype._onLoad=function(e){if(this._status!==s.c.kError)if(this._waitForTotalLength)this._waitForTotalLength=!1;else{this._lastTimeLoaded=0;var t=this._speedSampler.lastSecondKBps;if(0===t&&(this._zeroSpeedChunkCount++,this._zeroSpeedChunkCount>=3&&(t=this._speedSampler.currentKBps)),0!==t){var i=this._normalizeSpeed(t);this._currentSpeedNormalized!==i&&(this._currentSpeedNormalized=i,this._currentChunkSizeKB=i)}var a=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=a.byteLength;var n=!1;null!=this._contentLength&&this._receivedLength<this._contentLength?this._openSubRange():n=!0,this._onDataArrival&&this._onDataArrival(a,r,this._receivedLength),n&&(this._status=s.c.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}},t.prototype._onXhrError=function(e){this._status=s.c.kError;var t=0,i=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(t=s.b.EARLY_EOF,i={code:-1,msg:"RangeLoader meet Early-Eof"}):(t=s.b.EXCEPTION,i={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new _.d(i.msg);this._onError(t,i)},t}(s.a),m=function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function a(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(a.prototype=i.prototype,new a)}}(),g=function(e){function t(){var t=e.call(this,"websocket-loader")||this;return t.TAG="WebSocketLoader",t._needStash=!0,t._ws=null,t._requestAbort=!1,t._receivedLength=0,t}return m(t,e),t.isSupported=function(){try{return void 0!==self.WebSocket}catch(e){return!1}},t.prototype.destroy=function(){this._ws&&this.abort(),e.prototype.destroy.call(this)},t.prototype.open=function(e){try{var t=this._ws=new self.WebSocket(e.url);t.binaryType="arraybuffer",t.onopen=this._onWebSocketOpen.bind(this),t.onclose=this._onWebSocketClose.bind(this),t.onmessage=this._onWebSocketMessage.bind(this),t.onerror=this._onWebSocketError.bind(this),this._status=s.c.kConnecting}catch(e){this._status=s.c.kError;var i={code:e.code,msg:e.message};if(!this._onError)throw new _.d(i.msg);this._onError(s.b.EXCEPTION,i)}},t.prototype.abort=function(){var e=this._ws;!e||0!==e.readyState&&1!==e.readyState||(this._requestAbort=!0,e.close()),this._ws=null,this._status=s.c.kComplete},t.prototype._onWebSocketOpen=function(e){this._status=s.c.kBuffering},t.prototype._onWebSocketClose=function(e){!0!==this._requestAbort?(this._status=s.c.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)):this._requestAbort=!1},t.prototype._onWebSocketMessage=function(e){var t=this;if(e.data instanceof ArrayBuffer)this._dispatchArrayBuffer(e.data);else if(e.data instanceof Blob){var i=new FileReader;i.onload=function(){t._dispatchArrayBuffer(i.result)},i.readAsArrayBuffer(e.data)}else{this._status=s.c.kError;var a={code:-1,msg:"Unsupported WebSocket message type: "+e.data.constructor.name};if(!this._onError)throw new _.d(a.msg);this._onError(s.b.EXCEPTION,a)}},t.prototype._dispatchArrayBuffer=function(e){var t=e,i=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)},t.prototype._onWebSocketError=function(e){this._status=s.c.kError;var t={code:e.code,msg:e.message};if(!this._onError)throw new _.d(t.msg);this._onError(s.b.EXCEPTION,t)},t}(s.a),y=function(){function e(e){this._zeroStart=e||!1}return e.prototype.getConfig=function(e,t){var i,a={};0!==t.from||-1!==t.to?(i=-1!==t.to?"bytes=".concat(t.from.toString(),"-").concat(t.to.toString()):"bytes=".concat(t.from.toString(),"-"),a.Range=i):this._zeroStart&&(a.Range="bytes=0-");return{url:e,headers:a}},e.prototype.removeURLParameters=function(e){return e},e}(),v=function(){function e(e,t){this._startName=e,this._endName=t}return e.prototype.getConfig=function(e,t){var i=e;if(0!==t.from||-1!==t.to){var a=!0;-1===i.indexOf("?")&&(i+="?",a=!1),a&&(i+="&"),i+="".concat(this._startName,"=").concat(t.from.toString()),-1!==t.to&&(i+="&".concat(this._endName,"=").concat(t.to.toString()))}return{url:i,headers:{}}},e.prototype.removeURLParameters=function(e){var t=e.split("?")[0],i=void 0,a=e.indexOf("?");-1!==a&&(i=e.substring(a+1));var r="";if(null!=i&&i.length>0)for(var n=i.split("&"),s=0;s<n.length;s++){var o=n[s].split("="),_=s>0;o[0]!==this._startName&&o[0]!==this._endName&&(_&&(r+="&"),r+=n[s])}return 0===r.length?t:t+"?"+r},e}(),b=function(){function e(e,t,i){this.TAG="IOController",this._config=t,this._extraData=i,this._stashInitialSize=65536,null!=t.stashInitialSize&&t.stashInitialSize>0&&(this._stashInitialSize=t.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=Math.max(this._stashSize,3145728),this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===t.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new n,this._speedNormalizeList=[32,64,96,128,192,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 e.prototype.destroy=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},e.prototype.isWorking=function(){return this._loader&&this._loader.isWorking()&&!this._paused},e.prototype.isPaused=function(){return this._paused},Object.defineProperty(e.prototype,"status",{get:function(){return this._loader.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"extraData",{get:function(){return this._extraData},set:function(e){this._extraData=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onSeeked",{get:function(){return this._onSeeked},set:function(e){this._onSeeked=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRedirect",{get:function(){return this._onRedirect},set:function(e){this._onRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRecoveredEarlyEof",{get:function(){return this._onRecoveredEarlyEof},set:function(e){this._onRecoveredEarlyEof=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentURL",{get:function(){return this._dataSource.url},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRedirect",{get:function(){return null!=this._redirectedURL||null!=this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentRedirectedURL",{get:function(){return this._redirectedURL||this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentSpeed",{get:function(){return this._loaderClass===p?this._loader.currentSpeed:this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loaderType",{get:function(){return this._loader.type},enumerable:!1,configurable:!0}),e.prototype._selectSeekHandler=function(){var e=this._config;if("range"===e.seekType)this._seekHandler=new y(this._config.rangeLoadZeroStart);else if("param"===e.seekType){var t=e.seekParamStart||"bstart",i=e.seekParamEnd||"bend";this._seekHandler=new v(t,i)}else{if("custom"!==e.seekType)throw new _.b("Invalid seekType in config: ".concat(e.seekType));if("function"!=typeof e.customSeekHandler)throw new _.b("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}},e.prototype._selectLoader=function(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=g;else if(l.isSupported())this._loaderClass=l;else if(c.isSupported())this._loaderClass=c;else{if(!p.isSupported())throw new _.d("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=p}},e.prototype._createLoader=function(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(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)},e.prototype.open=function(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))},e.prototype.abort=function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)},e.prototype.pause=function(){this.isWorking()&&(this._loader.abort(),0!==this._stashUsed?(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)},e.prototype.resume=function(){if(this._paused){this._paused=!1;var e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}},e.prototype.seek=function(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)},e.prototype._internalSeek=function(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;var i={from:e,to:-1};this._currentRange={from:i.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,i),this._onSeeked&&this._onSeeked()},e.prototype.updateUrl=function(e){if(!e||"string"!=typeof e||0===e.length)throw new _.b("Url must be a non-empty string!");this._dataSource.url=e},e.prototype._expandBuffer=function(e){for(var t=this._stashSize;t+1048576<e;)t*=2;if((t+=1048576)!==this._bufferSize){var i=new ArrayBuffer(t);if(this._stashUsed>0){var a=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(i,0,t).set(a,0)}this._stashBuffer=i,this._bufferSize=t}},e.prototype._normalizeSpeed=function(e){var t=this._speedNormalizeList,i=t.length-1,a=0,r=0,n=i;if(e<t[0])return t[0];for(;r<=n;){if((a=r+Math.floor((n-r)/2))===i||e>=t[a]&&e<t[a+1])return t[a];t[a]<e?r=a+1:n=a-1}},e.prototype._adjustStashSize=function(e){var t=0;(t=this._config.isLive?e/8:e<512?e:e>=512&&e<=1024?Math.floor(1.5*e):2*e)>8192&&(t=8192);var i=1024*t+1048576;this._bufferSize<i&&this._expandBuffer(i),this._stashSize=1024*t},e.prototype._dispatchChunks=function(e,t){return this._currentRange.to=t+e.byteLength-1,this._onDataArrival(e,t)},e.prototype._onURLRedirect=function(e){this._redirectedURL=e,this._onRedirect&&this._onRedirect(e)},e.prototype._onContentLengthKnown=function(e){e&&this._fullRequestFlag&&(this._totalLength=e,this._fullRequestFlag=!1)},e.prototype._onLoaderChunkArrival=function(e,t,i){if(!this._onDataArrival)throw new _.a("IOController: No existing consumer (onDataArrival) callback!");if(!this._paused){this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(e.byteLength);var a=this._speedSampler.lastSecondKBps;if(0!==a){var r=this._normalizeSpeed(a);this._speedNormalized!==r&&(this._speedNormalized=r,this._adjustStashSize(r))}if(this._enableStash)if(0===this._stashUsed&&0===this._stashByteStart&&(this._stashByteStart=t),this._stashUsed+e.byteLength<=this._stashSize)(o=new Uint8Array(this._stashBuffer,0,this._stashSize)).set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength;else if(o=new Uint8Array(this._stashBuffer,0,this._bufferSize),this._stashUsed>0){var n=this._stashBuffer.slice(0,this._stashUsed);(d=this._dispatchChunks(n,this._stashByteStart))<n.byteLength?d>0&&(l=new Uint8Array(n,d),o.set(l,0),this._stashUsed=l.byteLength,this._stashByteStart+=d):(this._stashUsed=0,this._stashByteStart+=d),this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),o=new Uint8Array(this._stashBuffer,0,this._bufferSize)),o.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else(d=this._dispatchChunks(e,t))<e.byteLength&&((s=e.byteLength-d)>this._bufferSize&&(this._expandBuffer(s),o=new Uint8Array(this._stashBuffer,0,this._bufferSize)),o.set(new Uint8Array(e,d),0),this._stashUsed+=s,this._stashByteStart=t+d);else if(0===this._stashUsed){var s;(d=this._dispatchChunks(e,t))<e.byteLength&&((s=e.byteLength-d)>this._bufferSize&&this._expandBuffer(s),(o=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(e,d),0),this._stashUsed+=s,this._stashByteStart=t+d)}else{var o,d;if(this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength),(o=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength,(d=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart))<this._stashUsed&&d>0){var l=new Uint8Array(this._stashBuffer,d);o.set(l,0)}this._stashUsed-=d,this._stashByteStart+=d}}},e.prototype._flushStashBuffer=function(e){if(this._stashUsed>0){var t=this._stashBuffer.slice(0,this._stashUsed),i=this._dispatchChunks(t,this._stashByteStart),a=t.byteLength-i;if(i<t.byteLength){if(!e){if(i>0){var n=new Uint8Array(this._stashBuffer,0,this._bufferSize),s=new Uint8Array(t,i);n.set(s,0),this._stashUsed=s.byteLength,this._stashByteStart+=i}return 0}r.a.w(this.TAG,"".concat(a," bytes unconsumed data remain when flush buffer, dropped"))}return this._stashUsed=0,this._stashByteStart=0,a}return 0},e.prototype._onLoaderComplete=function(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)},e.prototype._onLoaderError=function(e,t){switch(r.a.e(this.TAG,"Loader error, code = ".concat(t.code,", msg = ").concat(t.msg)),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=s.b.UNRECOVERABLE_EARLY_EOF),e){case s.b.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var i=this._currentRange.to+1;return void(i<this._totalLength&&(r.a.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(i,!1)))}e=s.b.UNRECOVERABLE_EARLY_EOF;case s.b.UNRECOVERABLE_EARLY_EOF:case s.b.CONNECTING_TIMEOUT:case s.b.HTTP_STATUS_CODE_INVALID:case s.b.EXCEPTION:}if(!this._onError)throw new _.d("IOException: "+t.msg);this._onError(e,t)},e}();t.a=b},function(e,t,i){"use strict";var a=function(){function e(){}return e.install=function(){Object.setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Object.assign=Object.assign||function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i<arguments.length;i++){var a=arguments[i];if(null!=a)for(var r in a)a.hasOwnProperty(r)&&(t[r]=a[r])}return t},String.prototype.startsWith||Object.defineProperty(String.prototype,"startsWith",{value:function(e,t){var i=t>0?0|t:0;return this.substring(i,i+e.length)===e}}),"function"!=typeof self.Promise&&i(21).polyfill()},e}();a.install(),t.a=a},function(e,t,i){"use strict";var a=i(9),r=i.n(a),n=i(0),s=i(5),o=i(7),_=i(3),d=function(){function e(e){this.TAG="MSEController",this._config=e,this._emitter=new r.a,this._config.isLive&&null==this._config.autoCleanupSourceBuffer&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onStartStreaming:this._onStartStreaming.bind(this),onEndStreaming:this._onEndStreaming.bind(this),onQualityChange:this._onQualityChange.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._useManagedMediaSource="ManagedMediaSource"in self&&!("MediaSource"in self),this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElementProxy=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]}}return e.prototype.destroy=function(){this._mediaSource&&this.shutdown(),this._mediaSourceObjectURL&&this.revokeObjectURL(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.initialize=function(e){if(this._mediaSource)throw new _.a("MediaSource has been attached to an HTMLMediaElement!");this._useManagedMediaSource&&n.a.v(this.TAG,"Using ManagedMediaSource");var t=this._mediaSource=this._useManagedMediaSource?new self.ManagedMediaSource:new self.MediaSource;t.addEventListener("sourceopen",this.e.onSourceOpen),t.addEventListener("sourceended",this.e.onSourceEnded),t.addEventListener("sourceclose",this.e.onSourceClose),this._useManagedMediaSource&&(t.addEventListener("startstreaming",this.e.onStartStreaming),t.addEventListener("endstreaming",this.e.onEndStreaming),t.addEventListener("qualitychange",this.e.onQualityChange)),this._mediaElementProxy=e},e.prototype.shutdown=function(){if(this._mediaSource){var e=this._mediaSource;for(var t in this._sourceBuffers){var i=this._pendingSegments[t];i.splice(0,i.length),this._pendingSegments[t]=null,this._pendingRemoveRanges[t]=null,this._lastInitSegments[t]=null;var a=this._sourceBuffers[t];if(a){if("closed"!==e.readyState){try{e.removeSourceBuffer(a)}catch(e){n.a.e(this.TAG,e.message)}a.removeEventListener("error",this.e.onSourceBufferError),a.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[t]=null,this._sourceBuffers[t]=null}}if("open"===e.readyState)try{e.endOfStream()}catch(e){n.a.e(this.TAG,e.message)}this._mediaElementProxy=null,e.removeEventListener("sourceopen",this.e.onSourceOpen),e.removeEventListener("sourceended",this.e.onSourceEnded),e.removeEventListener("sourceclose",this.e.onSourceClose),this._useManagedMediaSource&&(e.removeEventListener("startstreaming",this.e.onStartStreaming),e.removeEventListener("endstreaming",this.e.onEndStreaming),e.removeEventListener("qualitychange",this.e.onQualityChange)),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._mediaSource=null}},e.prototype.isManagedMediaSource=function(){return this._useManagedMediaSource},e.prototype.getObject=function(){if(!this._mediaSource)throw new _.a("MediaSource has not been initialized yet!");return this._mediaSource},e.prototype.getHandle=function(){if(!this._mediaSource)throw new _.a("MediaSource has not been initialized yet!");return this._mediaSource.handle},e.prototype.getObjectURL=function(){if(!this._mediaSource)throw new _.a("MediaSource has not been initialized yet!");return null==this._mediaSourceObjectURL&&(this._mediaSourceObjectURL=URL.createObjectURL(this._mediaSource)),this._mediaSourceObjectURL},e.prototype.revokeObjectURL=function(){this._mediaSourceObjectURL&&(URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)},e.prototype.appendInitSegment=function(e,t){if(void 0===t&&(t=void 0),!this._mediaSource||"open"!==this._mediaSource.readyState||!1===this._mediaSource.streaming)return this._pendingSourceBufferInit.push(e),void this._pendingSegments[e.type].push(e);var i=e,a="".concat(i.container);i.codec&&i.codec.length>0&&("opus"===i.codec&&s.a.safari&&(i.codec="Opus"),a+=";codecs=".concat(i.codec));var r=!1;if(n.a.v(this.TAG,"Received Initialization Segment, mimeType: "+a),this._lastInitSegments[i.type]=i,a!==this._mimeTypes[i.type]){if(this._mimeTypes[i.type])n.a.v(this.TAG,"Notice: ".concat(i.type," mimeType changed, origin: ").concat(this._mimeTypes[i.type],", target: ").concat(a));else{r=!0;try{var _=this._sourceBuffers[i.type]=this._mediaSource.addSourceBuffer(a);_.addEventListener("error",this.e.onSourceBufferError),_.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return n.a.e(this.TAG,e.message),void this._emitter.emit(o.a.ERROR,{code:e.code,msg:e.message})}}this._mimeTypes[i.type]=a}t||this._pendingSegments[i.type].push(i),r||this._sourceBuffers[i.type]&&!this._sourceBuffers[i.type].updating&&this._doAppendSegments(),s.a.safari&&"audio/mpeg"===i.container&&i.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=i.mediaDuration/1e3,this._updateMediaSourceDuration())},e.prototype.appendMediaSegment=function(e){var t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var i=this._sourceBuffers[t.type];!i||i.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()},e.prototype.flush=function(){for(var e in this._sourceBuffers)if(this._sourceBuffers[e]){var t=this._sourceBuffers[e];if("open"===this._mediaSource.readyState)try{t.abort()}catch(e){n.a.e(this.TAG,e.message)}var i=this._pendingSegments[e];if(i.splice(0,i.length),"closed"!==this._mediaSource.readyState){for(var a=0;a<t.buffered.length;a++){var r=t.buffered.start(a),o=t.buffered.end(a);this._pendingRemoveRanges[e].push({start:r,end:o})}if(t.updating||this._doRemoveRanges(),s.a.safari){var _=this._lastInitSegments[e];_&&(this._pendingSegments[e].push(_),t.updating||this._doAppendSegments())}}}},e.prototype.endOfStream=function(){var e=this._mediaSource,t=this._sourceBuffers;e&&"open"===e.readyState?t.video&&t.video.updating||t.audio&&t.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,e.endOfStream()):e&&"closed"===e.readyState&&this._hasPendingSegments()&&(this._hasPendingEos=!0)},e.prototype._needCleanupSourceBuffer=function(){if(!this._config.autoCleanupSourceBuffer)return!1;var e=this._mediaElementProxy.getCurrentTime();for(var t in this._sourceBuffers){var i=this._sourceBuffers[t];if(i){var a=i.buffered;if(a.length>=1&&e-a.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1},e.prototype._doCleanupSourceBuffer=function(){var e=this._mediaElementProxy.getCurrentTime();for(var t in this._sourceBuffers){var i=this._sourceBuffers[t];if(i){for(var a=i.buffered,r=!1,n=0;n<a.length;n++){var s=a.start(n),o=a.end(n);if(s<=e&&e<o+3){if(e-s>=this._config.autoCleanupMaxBackwardDuration){r=!0;var _=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:s,end:_})}}else o<e&&(r=!0,this._pendingRemoveRanges[t].push({start:s,end:o}))}r&&!i.updating&&this._doRemoveRanges()}}},e.prototype._updateMediaSourceDuration=function(){var e=this._sourceBuffers;if(0!==this._mediaElementProxy.getReadyState()&&"open"===this._mediaSource.readyState&&!(e.video&&e.video.updating||e.audio&&e.audio.updating)){var t=this._mediaSource.duration,i=this._pendingMediaDuration;i>0&&(isNaN(t)||i>t)&&(n.a.v(this.TAG,"Update MediaSource duration from ".concat(t," to ").concat(i)),this._mediaSource.duration=i),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}},e.prototype._doRemoveRanges=function(){for(var e in this._pendingRemoveRanges)if(this._sourceBuffers[e]&&!this._sourceBuffers[e].updating)for(var t=this._sourceBuffers[e],i=this._pendingRemoveRanges[e];i.length&&!t.updating;){var a=i.shift();t.remove(a.start,a.end)}},e.prototype._doAppendSegments=function(){var e=this._pendingSegments;for(var t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&!1!==this._mediaSource.streaming&&e[t].length>0){var i=e[t].shift();if("number"==typeof i.timestampOffset&&isFinite(i.timestampOffset)){var a=this._sourceBuffers[t].timestampOffset,r=i.timestampOffset/1e3;Math.abs(a-r)>.1&&(n.a.v(this.TAG,"Update MPEG audio timestampOffset from ".concat(a," to ").concat(r)),this._sourceBuffers[t].timestampOffset=r),delete i.timestampOffset}if(!i.data||0===i.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(i.data),this._isBufferFull=!1}catch(e){this._pendingSegments[t].unshift(i),22===e.code?(this._isBufferFull||this._emitter.emit(o.a.BUFFER_FULL),this._isBufferFull=!0):(n.a.e(this.TAG,e.message),this._emitter.emit(o.a.ERROR,{code:e.code,msg:e.message}))}}},e.prototype._onSourceOpen=function(){if(n.a.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var e=this._pendingSourceBufferInit;e.length;){var t=e.shift();this.appendInitSegment(t,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(o.a.SOURCE_OPEN)},e.prototype._onStartStreaming=function(){n.a.v(this.TAG,"ManagedMediaSource onStartStreaming"),this._emitter.emit(o.a.START_STREAMING)},e.prototype._onEndStreaming=function(){n.a.v(this.TAG,"ManagedMediaSource onEndStreaming"),this._emitter.emit(o.a.END_STREAMING)},e.prototype._onQualityChange=function(){n.a.v(this.TAG,"ManagedMediaSource onQualityChange")},e.prototype._onSourceEnded=function(){n.a.v(this.TAG,"MediaSource onSourceEnded")},e.prototype._onSourceClose=function(){n.a.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose),this._useManagedMediaSource&&(this._mediaSource.removeEventListener("startstreaming",this.e.onStartStreaming),this._mediaSource.removeEventListener("endstreaming",this.e.onEndStreaming),this._mediaSource.removeEventListener("qualitychange",this.e.onQualityChange)))},e.prototype._hasPendingSegments=function(){var e=this._pendingSegments;return e.video.length>0||e.audio.length>0},e.prototype._hasPendingRemoveRanges=function(){var e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0},e.prototype._onSourceBufferUpdateEnd=function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(o.a.UPDATE_END)},e.prototype._onSourceBufferError=function(e){n.a.e(this.TAG,"SourceBuffer Error: ".concat(e))},e}();t.a=d},function(e,t,i){"use strict";var a=i(9),r=i.n(a),n=i(18),s=i.n(n),o=i(0),_=i(8),d=i(13),l=i(1),u=(i(19),i(12)),c=function(){function e(e,t){if(this.TAG="Transmuxer",this._emitter=new r.a,t.enableWorker&&"undefined"!=typeof Worker)try{this._worker=s()(19),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[e,t]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},_.a.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:_.a.getConfig()})}catch(i){o.a.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new d.a(e,t)}else this._controller=new d.a(e,t);if(this._controller){var i=this._controller;i.on(l.a.IO_ERROR,this._onIOError.bind(this)),i.on(l.a.DEMUX_ERROR,this._onDemuxError.bind(this)),i.on(l.a.INIT_SEGMENT,this._onInitSegment.bind(this)),i.on(l.a.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),i.on(l.a.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),i.on(l.a.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),i.on(l.a.MEDIA_INFO,this._onMediaInfo.bind(this)),i.on(l.a.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),i.on(l.a.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),i.on(l.a.TIMED_ID3_METADATA_ARRIVED,this._onTimedID3MetadataArrived.bind(this)),i.on(l.a.SYNCHRONOUS_KLV_METADATA_ARRIVED,this._onSynchronousKLVMetadataArrived.bind(this)),i.on(l.a.ASYNCHRONOUS_KLV_METADATA_ARRIVED,this._onAsynchronousKLVMetadataArrived.bind(this)),i.on(l.a.SMPTE2038_METADATA_ARRIVED,this._onSMPTE2038MetadataArrived.bind(this)),i.on(l.a.SCTE35_METADATA_ARRIVED,this._onSCTE35MetadataArrived.bind(this)),i.on(l.a.PES_PRIVATE_DATA_DESCRIPTOR,this._onPESPrivateDataDescriptor.bind(this)),i.on(l.a.PES_PRIVATE_DATA_ARRIVED,this._onPESPrivateDataArrived.bind(this)),i.on(l.a.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),i.on(l.a.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}return e.prototype.destroy=function(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),_.a.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.hasWorker=function(){return null!=this._worker},e.prototype.open=function(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()},e.prototype.close=function(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()},e.prototype.seek=function(e){this._worker?this._worker.postMessage({cmd:"seek",param:e}):this._controller.seek(e)},e.prototype.pause=function(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()},e.prototype.resume=function(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()},e.prototype._onInitSegment=function(e,t){var i=this;Promise.resolve().then((function(){i._emitter.emit(l.a.INIT_SEGMENT,e,t)}))},e.prototype._onMediaSegment=function(e,t){var i=this;Promise.resolve().then((function(){i._emitter.emit(l.a.MEDIA_SEGMENT,e,t)}))},e.prototype._onLoadingComplete=function(){var e=this;Promise.resolve().then((function(){e._emitter.emit(l.a.LOADING_COMPLETE)}))},e.prototype._onRecoveredEarlyEof=function(){var e=this;Promise.resolve().then((function(){e._emitter.emit(l.a.RECOVERED_EARLY_EOF)}))},e.prototype._onMediaInfo=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.a.MEDIA_INFO,e)}))},e.prototype._onMetaDataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.a.METADATA_ARRIVED,e)}))},e.prototype._onScriptDataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.a.SCRIPTDATA_ARRIVED,e)}))},e.prototype._onTimedID3MetadataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.a.TIMED_ID3_METADATA_ARRIVED,e)}))},e.prototype._onSynchronousKLVMetadataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.a.SYNCHRONOUS_KLV_METADATA_ARRIVED,e)}))},e.prototype._onAsynchronousKLVMetadataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.a.ASYNCHRONOUS_KLV_METADATA_ARRIVED,e)}))},e.prototype._onSMPTE2038MetadataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.a.SMPTE2038_METADATA_ARRIVED,e)}))},e.prototype._onSCTE35MetadataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.a.SCTE35_METADATA_ARRIVED,e)}))},e.prototype._onPESPrivateDataDescriptor=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.a.PES_PRIVATE_DATA_DESCRIPTOR,e)}))},e.prototype._onPESPrivateDataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.a.PES_PRIVATE_DATA_ARRIVED,e)}))},e.prototype._onStatisticsInfo=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.a.STATISTICS_INFO,e)}))},e.prototype._onIOError=function(e,t){var i=this;Promise.resolve().then((function(){i._emitter.emit(l.a.IO_ERROR,e,t)}))},e.prototype._onDemuxError=function(e,t){var i=this;Promise.resolve().then((function(){i._emitter.emit(l.a.DEMUX_ERROR,e,t)}))},e.prototype._onRecommendSeekpoint=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(l.a.RECOMMEND_SEEKPOINT,e)}))},e.prototype._onLoggingConfigChanged=function(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})},e.prototype._onWorkerMessage=function(e){var t=e.data,i=t.data;if("destroyed"===t.msg||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(t.msg){case l.a.INIT_SEGMENT:case l.a.MEDIA_SEGMENT:this._emitter.emit(t.msg,i.type,i.data);break;case l.a.LOADING_COMPLETE:case l.a.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case l.a.MEDIA_INFO:Object.setPrototypeOf(i,u.a.prototype),this._emitter.emit(t.msg,i);break;case l.a.METADATA_ARRIVED:case l.a.SCRIPTDATA_ARRIVED:case l.a.TIMED_ID3_METADATA_ARRIVED:case l.a.SYNCHRONOUS_KLV_METADATA_ARRIVED:case l.a.ASYNCHRONOUS_KLV_METADATA_ARRIVED:case l.a.SMPTE2038_METADATA_ARRIVED:case l.a.SCTE35_METADATA_ARRIVED:case l.a.PES_PRIVATE_DATA_DESCRIPTOR:case l.a.PES_PRIVATE_DATA_ARRIVED:case l.a.STATISTICS_INFO:this._emitter.emit(t.msg,i);break;case l.a.IO_ERROR:case l.a.DEMUX_ERROR:this._emitter.emit(t.msg,i.type,i.info);break;case l.a.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,i);break;case"logcat_callback":o.a.emitter.emit("log",i.type,i.logcat)}},e}();t.a=c},function(e,t,i){function a(e){var t={};function i(a){if(t[a])return t[a].exports;var r=t[a]={i:a,l:!1,exports:{}};return e[a].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=e,i.c=t,i.i=function(e){return e},i.d=function(e,t,a){i.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:a})},i.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/",i.oe=function(e){throw console.error(e),e};var a=i(i.s=ENTRY_MODULE);return a.default||a}function r(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function n(e,t,a){var n={};n[a]=[];var s=t.toString(),o=s.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!o)return n;for(var _,d=o[1],l=new RegExp("(\\\\n|\\W)"+r(d)+"\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");_=l.exec(s);)"dll-reference"!==_[3]&&n[a].push(_[3]);for(l=new RegExp("\\("+r(d)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)',"g");_=l.exec(s);)e[_[2]]||(n[a].push(_[1]),e[_[2]]=i(_[1]).m),n[_[2]]=n[_[2]]||[],n[_[2]].push(_[4]);for(var u,c=Object.keys(n),h=0;h<c.length;h++)for(var f=0;f<n[c[h]].length;f++)u=n[c[h]][f],isNaN(1*u)||(n[c[h]][f]=1*n[c[h]][f]);return n}function s(e){return Object.keys(e).reduce((function(t,i){return t||e[i].length>0}),!1)}e.exports=function(e,t){t=t||{};var r={main:i.m},o=t.all?{main:Object.keys(r.main)}:function(e,t){for(var i={main:[t]},a={main:[]},r={main:{}};s(i);)for(var o=Object.keys(i),_=0;_<o.length;_++){var d=o[_],l=i[d].pop();if(r[d]=r[d]||{},!r[d][l]&&e[d][l]){r[d][l]=!0,a[d]=a[d]||[],a[d].push(l);for(var u=n(e,e[d][l],d),c=Object.keys(u),h=0;h<c.length;h++)i[c[h]]=i[c[h]]||[],i[c[h]]=i[c[h]].concat(u[c[h]])}}return a}(r,e),_="";Object.keys(o).filter((function(e){return"main"!==e})).forEach((function(e){for(var t=0;o[e][t];)t++;o[e].push(t),r[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",_=_+"var "+e+" = ("+a.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+o[e].map((function(t){return JSON.stringify(t)+": "+r[e][t].toString()})).join(",")+"});\n"})),_=_+"new (("+a.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+o.main.map((function(e){return JSON.stringify(e)+": "+r.main[e].toString()})).join(",")+"}))(self);";var d=new self.Blob([_],{type:"text/javascript"});if(t.bare)return d;var l=(self.URL||self.webkitURL||self.mozURL||self.msURL).createObjectURL(d),u=new self.Worker(l);return u.objectURL=l,u}},function(e,t,i){"use strict";i.r(t),i(0);var a=i(8),r=i(15),n=i(13),s=i(1);t.default=function(e){var t=null,i=function(t,i){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:i}})}.bind(this);function o(t,i){var a={msg:s.a.INIT_SEGMENT,data:{type:t,data:i}};e.postMessage(a,[i.data])}function _(t,i){var a={msg:s.a.MEDIA_SEGMENT,data:{type:t,data:i}};e.postMessage(a,[i.data])}function d(){var t={msg:s.a.LOADING_COMPLETE};e.postMessage(t)}function l(){var t={msg:s.a.RECOVERED_EARLY_EOF};e.postMessage(t)}function u(t){var i={msg:s.a.MEDIA_INFO,data:t};e.postMessage(i)}function c(t){var i={msg:s.a.METADATA_ARRIVED,data:t};e.postMessage(i)}function h(t){var i={msg:s.a.SCRIPTDATA_ARRIVED,data:t};e.postMessage(i)}function f(t){var i={msg:s.a.TIMED_ID3_METADATA_ARRIVED,data:t};e.postMessage(i)}function p(t){var i={msg:s.a.SYNCHRONOUS_KLV_METADATA_ARRIVED,data:t};e.postMessage(i)}function m(t){var i={msg:s.a.ASYNCHRONOUS_KLV_METADATA_ARRIVED,data:t};e.postMessage(i)}function g(t){var i={msg:s.a.SMPTE2038_METADATA_ARRIVED,data:t};e.postMessage(i)}function y(t){var i={msg:s.a.SCTE35_METADATA_ARRIVED,data:t};e.postMessage(i)}function v(t){var i={msg:s.a.PES_PRIVATE_DATA_DESCRIPTOR,data:t};e.postMessage(i)}function b(t){var i={msg:s.a.PES_PRIVATE_DATA_ARRIVED,data:t};e.postMessage(i)}function E(t){var i={msg:s.a.STATISTICS_INFO,data:t};e.postMessage(i)}function S(t,i){e.postMessage({msg:s.a.IO_ERROR,data:{type:t,info:i}})}function A(t,i){e.postMessage({msg:s.a.DEMUX_ERROR,data:{type:t,info:i}})}function w(t){e.postMessage({msg:s.a.RECOMMEND_SEEKPOINT,data:t})}r.a.install(),e.addEventListener("message",(function(r){switch(r.data.cmd){case"init":(t=new n.a(r.data.param[0],r.data.param[1])).on(s.a.IO_ERROR,S.bind(this)),t.on(s.a.DEMUX_ERROR,A.bind(this)),t.on(s.a.INIT_SEGMENT,o.bind(this)),t.on(s.a.MEDIA_SEGMENT,_.bind(this)),t.on(s.a.LOADING_COMPLETE,d.bind(this)),t.on(s.a.RECOVERED_EARLY_EOF,l.bind(this)),t.on(s.a.MEDIA_INFO,u.bind(this)),t.on(s.a.METADATA_ARRIVED,c.bind(this)),t.on(s.a.SCRIPTDATA_ARRIVED,h.bind(this)),t.on(s.a.TIMED_ID3_METADATA_ARRIVED,f.bind(this)),t.on(s.a.SYNCHRONOUS_KLV_METADATA_ARRIVED,p.bind(this)),t.on(s.a.ASYNCHRONOUS_KLV_METADATA_ARRIVED,m.bind(this)),t.on(s.a.SMPTE2038_METADATA_ARRIVED,g.bind(this)),t.on(s.a.SCTE35_METADATA_ARRIVED,y.bind(this)),t.on(s.a.PES_PRIVATE_DATA_DESCRIPTOR,v.bind(this)),t.on(s.a.PES_PRIVATE_DATA_ARRIVED,b.bind(this)),t.on(s.a.STATISTICS_INFO,E.bind(this)),t.on(s.a.RECOMMEND_SEEKPOINT,w.bind(this));break;case"destroy":t&&(t.destroy(),t=null),e.postMessage({msg:"destroyed"});break;case"start":t.start();break;case"stop":t.stop();break;case"seek":t.seek(r.data.param);break;case"pause":t.pause();break;case"resume":t.resume();break;case"logging_config":var k=r.data.param;a.a.applyConfig(k),!0===k.enableCallback?a.a.addLogListener(i):a.a.removeLogListener(i)}}))}},function(e,t,i){e.exports=i(25).default},function(e,t,i){(function(t,i){
|
|
/*!
|
|
* @overview es6-promise - a tiny implementation of Promises/A+.
|
|
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
|
|
* @license Licensed under MIT license
|
|
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
|
|
* @version v4.2.8+1e68dce6
|
|
*/
|
|
var a;a=function(){"use strict";function e(e){return"function"==typeof e}var a=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r=0,n=void 0,s=void 0,o=function(e,t){f[r]=e,f[r+1]=t,2===(r+=2)&&(s?s(p):b())},_="undefined"!=typeof window?window:void 0,d=_||{},l=d.MutationObserver||d.WebKitMutationObserver,u="undefined"==typeof self&&void 0!==t&&"[object process]"==={}.toString.call(t),c="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function h(){var e=setTimeout;return function(){return e(p,1)}}var f=new Array(1e3);function p(){for(var e=0;e<r;e+=2)(0,f[e])(f[e+1]),f[e]=void 0,f[e+1]=void 0;r=0}var m,g,y,v,b=void 0;function E(e,t){var i=this,a=new this.constructor(w);void 0===a[A]&&I(a);var r=i._state;if(r){var n=arguments[r-1];o((function(){return D(r,a,n,i._result)}))}else x(i,a,e,t);return a}function S(e){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(w);return T(t,e),t}u?b=function(){return t.nextTick(p)}:l?(g=0,y=new l(p),v=document.createTextNode(""),y.observe(v,{characterData:!0}),b=function(){v.data=g=++g%2}):c?((m=new MessageChannel).port1.onmessage=p,b=function(){return m.port2.postMessage(0)}):b=void 0===_?function(){try{var e=Function("return this")().require("vertx");return void 0!==(n=e.runOnLoop||e.runOnContext)?function(){n(p)}:h()}catch(e){return h()}}():h();var A=Math.random().toString(36).substring(2);function w(){}function k(t,i,a){i.constructor===t.constructor&&a===E&&i.constructor.resolve===S?function(e,t){1===t._state?R(e,t._result):2===t._state?C(e,t._result):x(t,void 0,(function(t){return T(e,t)}),(function(t){return C(e,t)}))}(t,i):void 0===a?R(t,i):e(a)?function(e,t,i){o((function(e){var a=!1,r=function(e,t,i,a){try{e.call(t,i,a)}catch(e){return e}}(i,t,(function(i){a||(a=!0,t!==i?T(e,i):R(e,i))}),(function(t){a||(a=!0,C(e,t))}),e._label);!a&&r&&(a=!0,C(e,r))}),e)}(t,i,a):R(t,i)}function T(e,t){if(e===t)C(e,new TypeError("You cannot resolve a promise with itself"));else if(r=typeof(a=t),null===a||"object"!==r&&"function"!==r)R(e,t);else{var i=void 0;try{i=t.then}catch(t){return void C(e,t)}k(e,t,i)}var a,r}function L(e){e._onerror&&e._onerror(e._result),M(e)}function R(e,t){void 0===e._state&&(e._result=t,e._state=1,0!==e._subscribers.length&&o(M,e))}function C(e,t){void 0===e._state&&(e._state=2,e._result=t,o(L,e))}function x(e,t,i,a){var r=e._subscribers,n=r.length;e._onerror=null,r[n]=t,r[n+1]=i,r[n+2]=a,0===n&&e._state&&o(M,e)}function M(e){var t=e._subscribers,i=e._state;if(0!==t.length){for(var a=void 0,r=void 0,n=e._result,s=0;s<t.length;s+=3)a=t[s],r=t[s+i],a?D(i,a,r,n):r(n);e._subscribers.length=0}}function D(t,i,a,r){var n=e(a),s=void 0,o=void 0,_=!0;if(n){try{s=a(r)}catch(e){_=!1,o=e}if(i===s)return void C(i,new TypeError("A promises callback cannot return that same promise."))}else s=r;void 0!==i._state||(n&&_?T(i,s):!1===_?C(i,o):1===t?R(i,s):2===t&&C(i,s))}var O=0;function I(e){e[A]=O++,e._state=void 0,e._result=void 0,e._subscribers=[]}var P=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(w),this.promise[A]||I(this.promise),a(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?R(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&R(this.promise,this._result))):C(this.promise,new Error("Array Methods must be provided an Array"))}return e.prototype._enumerate=function(e){for(var t=0;void 0===this._state&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(e,t){var i=this._instanceConstructor,a=i.resolve;if(a===S){var r=void 0,n=void 0,s=!1;try{r=e.then}catch(e){s=!0,n=e}if(r===E&&void 0!==e._state)this._settledAt(e._state,t,e._result);else if("function"!=typeof r)this._remaining--,this._result[t]=e;else if(i===B){var o=new i(w);s?C(o,n):k(o,e,r),this._willSettleAt(o,t)}else this._willSettleAt(new i((function(t){return t(e)})),t)}else this._willSettleAt(a(e),t)},e.prototype._settledAt=function(e,t,i){var a=this.promise;void 0===a._state&&(this._remaining--,2===e?C(a,i):this._result[t]=i),0===this._remaining&&R(a,this._result)},e.prototype._willSettleAt=function(e,t){var i=this;x(e,void 0,(function(e){return i._settledAt(1,t,e)}),(function(e){return i._settledAt(2,t,e)}))},e}(),B=function(){function t(e){this[A]=O++,this._result=this._state=void 0,this._subscribers=[],w!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof t?function(e,t){try{t((function(t){T(e,t)}),(function(t){C(e,t)}))}catch(t){C(e,t)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return t.prototype.catch=function(e){return this.then(null,e)},t.prototype.finally=function(t){var i=this.constructor;return e(t)?this.then((function(e){return i.resolve(t()).then((function(){return e}))}),(function(e){return i.resolve(t()).then((function(){throw e}))})):this.then(t,t)},t}();return B.prototype.then=E,B.all=function(e){return new P(this,e).promise},B.race=function(e){var t=this;return a(e)?new t((function(i,a){for(var r=e.length,n=0;n<r;n++)t.resolve(e[n]).then(i,a)})):new t((function(e,t){return t(new TypeError("You must pass an array to race."))}))},B.resolve=S,B.reject=function(e){var t=new this(w);return C(t,e),t},B._setScheduler=function(e){s=e},B._setAsap=function(e){o=e},B._asap=o,B.polyfill=function(){var e=void 0;if(void 0!==i)e=i;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var a=null;try{a=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===a&&!t.cast)return}e.Promise=B},B.Promise=B,B},e.exports=a()}).call(this,i(22),i(23))},function(e,t){var i,a,r=e.exports={};function n(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(e){if(i===setTimeout)return setTimeout(e,0);if((i===n||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:n}catch(e){i=n}try{a="function"==typeof clearTimeout?clearTimeout:s}catch(e){a=s}}();var _,d=[],l=!1,u=-1;function c(){l&&_&&(l=!1,_.length?d=_.concat(d):u=-1,d.length&&h())}function h(){if(!l){var e=o(c);l=!0;for(var t=d.length;t;){for(_=d,d=[];++u<t;)_&&_[u].run();u=-1,t=d.length}_=null,l=!1,function(e){if(a===clearTimeout)return clearTimeout(e);if((a===s||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function p(){}r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];d.push(new f(e,t)),1!==d.length||l||o(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=p,r.addListener=p,r.once=p,r.off=p,r.removeListener=p,r.removeAllListeners=p,r.emit=p,r.prependListener=p,r.prependOnceListener=p,r.listeners=function(e){return[]},r.binding=function(e){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},function(e,t){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t,i){"use strict";i.r(t);var a=i(0),r=i(8),n=i(3),s=i(7),o=i(16),_=i(17),d=i(1),l=i(4),u=i(10);t.default=function(e){var t="PlayerEngineWorker",i=function(t,i){e.postMessage({msg:"logcat_callback",type:t,logcat:i})}.bind(void 0),c=null,h=null,f=null,p=null,m=!1,g=!1,y=0,v=0,b=!1;function E(){f&&(f.shutdown(),f.destroy(),f=null)}function S(){if(null==c||null==h)throw new n.a("Worker not initialized");if(p)throw new n.a("Transmuxer has been initialized");g||(!h.deferLoadAfterSourceOpen||m?((p=new _.a(c,h)).on(d.a.INIT_SEGMENT,(function(e,t){f.appendInitSegment(t)})),p.on(d.a.MEDIA_SEGMENT,(function(t,i){f.appendMediaSegment(i),e.postMessage({msg:"buffered_position_changed",buffered_position_milliseconds:i.info.endDts})})),p.on(d.a.LOADING_COMPLETE,(function(){f.endOfStream(),e.postMessage({msg:"player_event",event:l.a.LOADING_COMPLETE})})),p.on(d.a.RECOVERED_EARLY_EOF,(function(){e.postMessage({msg:"player_event",event:l.a.RECOVERED_EARLY_EOF})})),p.on(d.a.IO_ERROR,(function(t,i){e.postMessage({msg:"player_event",event:l.a.ERROR,error_type:u.b.NETWORK_ERROR,error_detail:t,info:i})})),p.on(d.a.DEMUX_ERROR,(function(t,i){e.postMessage({msg:"player_event",event:l.a.ERROR,error_type:u.b.MEDIA_ERROR,error_detail:t,info:i})})),p.on(d.a.MEDIA_INFO,(function(e){R(d.a.MEDIA_INFO,e)})),p.on(d.a.STATISTICS_INFO,(function(e){R(d.a.STATISTICS_INFO,e)})),p.on(d.a.RECOMMEND_SEEKPOINT,(function(t){!function(t){e.postMessage({msg:"transmuxing_event",event:d.a.RECOMMEND_SEEKPOINT,milliseconds:t})}(t)})),p.on(d.a.METADATA_ARRIVED,(function(e){C(l.a.METADATA_ARRIVED,e)})),p.on(d.a.SCRIPTDATA_ARRIVED,(function(e){C(l.a.SCRIPTDATA_ARRIVED,e)})),p.on(d.a.TIMED_ID3_METADATA_ARRIVED,(function(e){C(l.a.TIMED_ID3_METADATA_ARRIVED,e)})),p.on(d.a.SYNCHRONOUS_KLV_METADATA_ARRIVED,(function(e){C(l.a.SYNCHRONOUS_KLV_METADATA_ARRIVED,e)})),p.on(d.a.ASYNCHRONOUS_KLV_METADATA_ARRIVED,(function(e){C(l.a.ASYNCHRONOUS_KLV_METADATA_ARRIVED,e)})),p.on(d.a.SMPTE2038_METADATA_ARRIVED,(function(e){C(l.a.SMPTE2038_METADATA_ARRIVED,e)})),p.on(d.a.SCTE35_METADATA_ARRIVED,(function(e){C(l.a.SCTE35_METADATA_ARRIVED,e)})),p.on(d.a.PES_PRIVATE_DATA_DESCRIPTOR,(function(e){C(l.a.PES_PRIVATE_DATA_DESCRIPTOR,e)})),p.on(d.a.PES_PRIVATE_DATA_ARRIVED,(function(e){C(l.a.PES_PRIVATE_DATA_ARRIVED,e)})),p.open()):g=!0)}function A(){f&&f.flush(),p&&(p.close(),p.destroy(),p=null)}function w(){m=!0,g&&(g=!1,S())}function k(){e.postMessage({msg:"mse_event",event:s.a.UPDATE_END})}function T(){a.a.v(t,"MSE SourceBuffer is full, report to main thread"),e.postMessage({msg:"mse_event",event:s.a.BUFFER_FULL})}function L(t){e.postMessage({msg:"player_event",event:l.a.ERROR,error_type:u.b.MEDIA_ERROR,error_detail:u.b.MEDIA_MSE_ERROR,info:t})}function R(t,i){e.postMessage({msg:"transmuxing_event",event:t,info:i})}function C(t,i){e.postMessage({msg:"player_event",event:t,extraData:i})}e.addEventListener("message",(function(n){if(!b){var _=n.data;switch(_.cmd){case"logging_config":var d=_;r.a.applyConfig(d.logging_config),!0===d.logging_config.enableCallback?r.a.addLogListener(i):r.a.removeLogListener(i);break;case"init":c=(d=_).media_data_source,h=d.config;break;case"destroy":p&&A(),f&&E(),b=!0,e.postMessage({msg:"destroyed"});break;case"initialize_mse":!function(){a.a.v(t,"Initializing MediaSource in DedicatedWorker"),(f=new o.a(h)).on(s.a.SOURCE_OPEN,w.bind(this)),f.on(s.a.UPDATE_END,k.bind(this)),f.on(s.a.BUFFER_FULL,T.bind(this)),f.on(s.a.ERROR,L.bind(this)),f.initialize({getCurrentTime:function(){return y},getReadyState:function(){return v}});var i=f.getHandle();e.postMessage({msg:"mse_init",handle:i},[i])}();break;case"shutdown_mse":E();break;case"load":S();break;case"unload":A();break;case"unbuffered_seek":d=_,f.flush(),p.seek(d.milliseconds);break;case"timeupdate":y=(d=_).current_time;break;case"readystatechange":v=(d=_).ready_state;break;case"pause_transmuxer":p.pause();break;case"resume_transmuxer":p.resume()}}}))}},function(e,t,i){"use strict";i.r(t);var a=i(15),r=i(14),n={enableWorker:!1,enableWorkerForMSE:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,liveBufferLatencyChasing:!1,liveBufferLatencyChasingOnPaused:!1,liveBufferLatencyMaxLatency:1.5,liveBufferLatencyMinRemain:.5,liveSync:!1,liveSyncMaxLatency:1.2,liveSyncTargetLatency:.8,liveSyncPlaybackRate:1.2,lazyLoad:!0,lazyLoadMaxDuration:180,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0};function s(){return Object.assign({},n)}var o=function(){function e(){}return e.supportMSEH264Playback=function(){var e=self.MediaSource&&self.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),t=self.ManagedMediaSource&&self.ManagedMediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"');return e||t},e.supportMSEH265Playback=function(){var e=self.MediaSource&&self.MediaSource.isTypeSupported('video/mp4; codecs="hvc1.1.6.L93.B0"'),t=self.ManagedMediaSource&&self.ManagedMediaSource.isTypeSupported('video/mp4; codecs="hvc1.1.6.L93.B0"');return e||t},e.supportNetworkStreamIO=function(){var e=new r.a({},s()),t=e.loaderType;return e.destroy(),"fetch-stream-loader"==t||"xhr-moz-chunked-loader"==t},e.getNetworkLoaderTypeName=function(){var e=new r.a({},s()),t=e.loaderType;return e.destroy(),t},e.supportNativeMediaPlayback=function(t){null==e.videoElement&&(e.videoElement=window.document.createElement("video"));var i=e.videoElement.canPlayType(t);return"probably"===i||"maybe"==i},e.getFeatureList=function(){var t={msePlayback:!1,mseLivePlayback:!1,mseH265Playback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeMP4H265Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return t.msePlayback=e.supportMSEH264Playback(),t.networkStreamIO=e.supportNetworkStreamIO(),t.networkLoaderName=e.getNetworkLoaderTypeName(),t.mseLivePlayback=t.msePlayback&&t.networkStreamIO,t.mseH265Playback=e.supportMSEH265Playback(),t.nativeMP4H264Playback=e.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),t.nativeMP4H265Playback=e.supportNativeMediaPlayback('video/mp4; codecs="hvc1.1.6.L93.B0"'),t.nativeWebmVP8Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),t.nativeWebmVP9Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp9"'),t},e}(),_=i(2),d=i(0),l=i(9),u=i.n(l),c=i(16),h=i(4),f=i(17),p=i(7),m=i(10),g=i(3),y=i(1),v=i(5),b=i(11),E=function(){function e(e,t,i){this.TAG="SeekingHandler",this._config=null,this._media_element=null,this._always_seek_keyframe=!1,this._on_unbuffered_seek=null,this._request_set_current_time=!1,this._seek_request_record_clocktime=null,this._idr_sample_list=new b.a,this.e=null,this._config=e,this._media_element=t,this._on_unbuffered_seek=i,this.e={onMediaSeeking:this._onMediaSeeking.bind(this)};var a=v.a.chrome&&(v.a.version.major<50||50===v.a.version.major&&v.a.version.build<2661);this._always_seek_keyframe=!!(a||v.a.msedge||v.a.msie),this._always_seek_keyframe&&(this._config.accurateSeek=!1),this._media_element.addEventListener("seeking",this.e.onMediaSeeking)}return e.prototype.destroy=function(){this._idr_sample_list.clear(),this._idr_sample_list=null,this._media_element.removeEventListener("seeking",this.e.onMediaSeeking),this._media_element=null,this._on_unbuffered_seek=null},e.prototype.seek=function(e){var t=this._isPositionBuffered(e),i=!1;if(e<1&&this._media_element.buffered.length>0){var a=this._media_element.buffered.start(0);(a<1&&e<a||v.a.safari)&&(i=!0,e=v.a.safari?.1:a)}if(i)this.directSeek(e);else if(t)if(this._always_seek_keyframe){var r=this._getNearestKeyframe(Math.floor(1e3*e));null!=r&&(e=r.dts/1e3),this.directSeek(e)}else this.directSeek(e);else this._idr_sample_list.clear(),this._on_unbuffered_seek(Math.floor(1e3*e)),this._config.accurateSeek&&this.directSeek(e)},e.prototype.directSeek=function(e){this._request_set_current_time=!0,this._media_element.currentTime=e},e.prototype.appendSyncPoints=function(e){this._idr_sample_list.appendArray(e)},e.prototype._onMediaSeeking=function(t){if(this._request_set_current_time)this._request_set_current_time=!1;else{var i=this._media_element.currentTime,a=this._media_element.buffered;if(i<1&&a.length>0){var r=a.start(0);if(r<1&&i<r||v.a.safari){var n=v.a.safari?.1:r;return void this.directSeek(n)}}if(this._isPositionBuffered(i)){if(this._always_seek_keyframe){var s=this._getNearestKeyframe(Math.floor(1e3*i));null!=s&&(i=s.dts/1e3,this.directSeek(i))}}else this._seek_request_record_clocktime=e._getClockTime(),window.setTimeout(this._pollAndApplyUnbufferedSeek.bind(this),50)}},e.prototype._pollAndApplyUnbufferedSeek=function(){if(null!=this._seek_request_record_clocktime)if(this._seek_request_record_clocktime<=e._getClockTime()-100){var t=this._media_element.currentTime;this._seek_request_record_clocktime=null,this._isPositionBuffered(t)||(this._idr_sample_list.clear(),this._on_unbuffered_seek(Math.floor(1e3*t)),this._config.accurateSeek&&this.directSeek(t))}else window.setTimeout(this._pollAndApplyUnbufferedSeek.bind(this),50)},e.prototype._isPositionBuffered=function(e){for(var t=this._media_element.buffered,i=0;i<t.length;i++){var a=t.start(i),r=t.end(i);if(e>=a&&e<r)return!0}return!1},e.prototype._getNearestKeyframe=function(e){return this._idr_sample_list.getLastSyncPointBeforeDts(e)},e._getClockTime=function(){return self.performance&&self.performance.now?self.performance.now():Date.now()},e}(),S=function(){function e(e,t,i,a){this.TAG="LoadingController",this._config=null,this._media_element=null,this._on_pause_transmuxer=null,this._on_resume_transmuxer=null,this._paused=!1,this.e=null,this._config=e,this._media_element=t,this._on_pause_transmuxer=i,this._on_resume_transmuxer=a,this.e={onMediaTimeUpdate:this._onMediaTimeUpdate.bind(this)}}return e.prototype.destroy=function(){this._media_element.removeEventListener("timeupdate",this.e.onMediaTimeUpdate),this.e=null,this._media_element=null,this._config=null,this._on_pause_transmuxer=null,this._on_resume_transmuxer=null},e.prototype.notifyBufferedPositionChanged=function(e){!this._config.isLive&&this._config.lazyLoad&&(null==e?this._suspendTransmuxerIfNeeded():this._suspendTransmuxerIfBufferedPositionExceeded(e))},e.prototype._onMediaTimeUpdate=function(e){this._paused&&this._resumeTransmuxerIfNeeded()},e.prototype._suspendTransmuxerIfNeeded=function(){for(var e=this._media_element.buffered,t=this._media_element.currentTime,i=0,a=0;a<e.length;a++){var r=e.start(a),n=e.end(a);if(r<=t&&t<n){i=n;break}}i>0&&this._suspendTransmuxerIfBufferedPositionExceeded(i)},e.prototype._suspendTransmuxerIfBufferedPositionExceeded=function(e){e>=this._media_element.currentTime+this._config.lazyLoadMaxDuration&&!this._paused&&(d.a.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this.suspendTransmuxer(),this._media_element.addEventListener("timeupdate",this.e.onMediaTimeUpdate))},e.prototype.suspendTransmuxer=function(){this._paused=!0,this._on_pause_transmuxer()},e.prototype._resumeTransmuxerIfNeeded=function(){for(var e=this._media_element.buffered,t=this._media_element.currentTime,i=this._config.lazyLoadRecoverDuration,a=!1,r=0;r<e.length;r++){var n=e.start(r),s=e.end(r);if(t>=n&&t<s){t>=s-i&&(a=!0);break}}a&&(d.a.v(this.TAG,"Continue loading from paused position"),this.resumeTransmuxer(),this._media_element.removeEventListener("timeupdate",this.e.onMediaTimeUpdate))},e.prototype.resumeTransmuxer=function(){this._paused=!1,this._on_resume_transmuxer()},e}(),A=function(){function e(e,t){this.TAG="StartupStallJumper",this._media_element=null,this._on_direct_seek=null,this._canplay_received=!1,this.e=null,this._media_element=e,this._on_direct_seek=t,this.e={onMediaCanPlay:this._onMediaCanPlay.bind(this),onMediaStalled:this._onMediaStalled.bind(this),onMediaProgress:this._onMediaProgress.bind(this)},this._media_element.addEventListener("canplay",this.e.onMediaCanPlay),this._media_element.addEventListener("stalled",this.e.onMediaStalled),this._media_element.addEventListener("progress",this.e.onMediaProgress)}return e.prototype.destroy=function(){this._media_element.removeEventListener("canplay",this.e.onMediaCanPlay),this._media_element.removeEventListener("stalled",this.e.onMediaStalled),this._media_element.removeEventListener("progress",this.e.onMediaProgress),this._media_element=null,this._on_direct_seek=null},e.prototype._onMediaCanPlay=function(e){this._canplay_received=!0,this._media_element.removeEventListener("canplay",this.e.onMediaCanPlay)},e.prototype._onMediaStalled=function(e){this._detectAndFixStuckPlayback(!0)},e.prototype._onMediaProgress=function(e){this._detectAndFixStuckPlayback()},e.prototype._detectAndFixStuckPlayback=function(e){var t=this._media_element,i=t.buffered;e||!this._canplay_received||t.readyState<2?i.length>0&&t.currentTime<i.start(0)&&(d.a.w(this.TAG,"Playback seems stuck at ".concat(t.currentTime,", seek to ").concat(i.start(0))),this._on_direct_seek(i.start(0)),this._media_element.removeEventListener("progress",this.e.onMediaProgress)):this._media_element.removeEventListener("progress",this.e.onMediaProgress)},e}(),w=function(){function e(e,t,i){this._config=null,this._media_element=null,this._on_direct_seek=null,this._config=e,this._media_element=t,this._on_direct_seek=i}return e.prototype.destroy=function(){this._on_direct_seek=null,this._media_element=null,this._config=null},e.prototype.notifyBufferedRangeUpdate=function(){this._chaseLiveLatency()},e.prototype._chaseLiveLatency=function(){var e=this._media_element.buffered,t=this._media_element.currentTime,i=this._media_element.paused;if(this._config.isLive&&this._config.liveBufferLatencyChasing&&0!=e.length&&(this._config.liveBufferLatencyChasingOnPaused||!i)){var a=e.end(e.length-1);if(a>this._config.liveBufferLatencyMaxLatency&&a-t>this._config.liveBufferLatencyMaxLatency){var r=a-this._config.liveBufferLatencyMinRemain;this._on_direct_seek(r)}}},e}(),k=function(){function e(e,t){this._config=null,this._media_element=null,this.e=null,this._config=e,this._media_element=t,this.e={onMediaTimeUpdate:this._onMediaTimeUpdate.bind(this)},this._media_element.addEventListener("timeupdate",this.e.onMediaTimeUpdate)}return e.prototype.destroy=function(){this._media_element.removeEventListener("timeupdate",this.e.onMediaTimeUpdate),this._media_element=null,this._config=null},e.prototype._onMediaTimeUpdate=function(e){if(this._config.isLive&&this._config.liveSync){var t=this._getCurrentLatency();if(t>this._config.liveSyncMaxLatency){var i=Math.min(2,Math.max(1,this._config.liveSyncPlaybackRate));this._media_element.playbackRate=i}else t>this._config.liveSyncTargetLatency||1!==this._media_element.playbackRate&&0!==this._media_element.playbackRate&&(this._media_element.playbackRate=1)}},e.prototype._getCurrentLatency=function(){if(!this._media_element)return 0;var e=this._media_element.buffered,t=this._media_element.currentTime;return 0==e.length?0:e.end(e.length-1)-t},e}(),T=function(){function e(e,t){this.TAG="PlayerEngineMainThread",this._emitter=new l,this._media_element=null,this._mse_controller=null,this._transmuxer=null,this._pending_seek_time=null,this._seeking_handler=null,this._loading_controller=null,this._startup_stall_jumper=null,this._live_latency_chaser=null,this._live_latency_synchronizer=null,this._mse_source_opened=!1,this._has_pending_load=!1,this._loaded_metadata_received=!1,this._media_info=null,this._statistics_info=null,this.e=null,this._media_data_source=e,this._config=s(),"object"==typeof t&&Object.assign(this._config,t),!0===e.isLive&&(this._config.isLive=!0),this.e={onMediaLoadedMetadata:this._onMediaLoadedMetadata.bind(this)}}return e.prototype.destroy=function(){this._emitter.emit(h.a.DESTROYING),this._transmuxer&&this.unload(),this._media_element&&this.detachMediaElement(),this.e=null,this._media_data_source=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){var i=this;this._emitter.addListener(e,t),e===h.a.MEDIA_INFO&&this._media_info?Promise.resolve().then((function(){return i._emitter.emit(h.a.MEDIA_INFO,i.mediaInfo)})):e==h.a.STATISTICS_INFO&&this._statistics_info&&Promise.resolve().then((function(){return i._emitter.emit(h.a.STATISTICS_INFO,i.statisticsInfo)}))},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){var t=this;this._media_element=e,e.src="",e.removeAttribute("src"),e.srcObject=null,e.load(),e.addEventListener("loadedmetadata",this.e.onMediaLoadedMetadata),this._mse_controller=new c.a(this._config),this._mse_controller.on(p.a.UPDATE_END,this._onMSEUpdateEnd.bind(this)),this._mse_controller.on(p.a.BUFFER_FULL,this._onMSEBufferFull.bind(this)),this._mse_controller.on(p.a.SOURCE_OPEN,this._onMSESourceOpen.bind(this)),this._mse_controller.on(p.a.ERROR,this._onMSEError.bind(this)),this._mse_controller.on(p.a.START_STREAMING,this._onMSEStartStreaming.bind(this)),this._mse_controller.on(p.a.END_STREAMING,this._onMSEEndStreaming.bind(this)),this._mse_controller.initialize({getCurrentTime:function(){return t._media_element.currentTime},getReadyState:function(){return t._media_element.readyState}}),this._mse_controller.isManagedMediaSource()?(e.disableRemotePlayback=!0,e.srcObject=this._mse_controller.getObject()):e.src=this._mse_controller.getObjectURL()},e.prototype.detachMediaElement=function(){this._media_element&&(this._mse_controller.shutdown(),this._media_element.removeEventListener("loadedmetadata",this.e.onMediaLoadedMetadata),this._media_element.src="",this._media_element.removeAttribute("src"),this._media_element.srcObject=null,this._media_element.load(),this._media_element=null,this._mse_controller.revokeObjectURL()),this._mse_controller&&(this._mse_controller.destroy(),this._mse_controller=null)},e.prototype.load=function(){var e=this;if(!this._media_element)throw new g.a("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new g.a("load() has been called, please call unload() first!");this._has_pending_load||(!this._config.deferLoadAfterSourceOpen||this._mse_source_opened?(this._transmuxer=new f.a(this._media_data_source,this._config),this._transmuxer.on(y.a.INIT_SEGMENT,(function(t,i){e._mse_controller.appendInitSegment(i)})),this._transmuxer.on(y.a.MEDIA_SEGMENT,(function(t,i){e._mse_controller.appendMediaSegment(i),!e._config.isLive&&"video"===t&&i.data&&i.data.byteLength>0&&"info"in i&&e._seeking_handler.appendSyncPoints(i.info.syncPoints),e._loading_controller.notifyBufferedPositionChanged(i.info.endDts/1e3)})),this._transmuxer.on(y.a.LOADING_COMPLETE,(function(){e._mse_controller.endOfStream(),e._emitter.emit(h.a.LOADING_COMPLETE)})),this._transmuxer.on(y.a.RECOVERED_EARLY_EOF,(function(){e._emitter.emit(h.a.RECOVERED_EARLY_EOF)})),this._transmuxer.on(y.a.IO_ERROR,(function(t,i){e._emitter.emit(h.a.ERROR,m.b.NETWORK_ERROR,t,i)})),this._transmuxer.on(y.a.DEMUX_ERROR,(function(t,i){e._emitter.emit(h.a.ERROR,m.b.MEDIA_ERROR,t,i)})),this._transmuxer.on(y.a.MEDIA_INFO,(function(t){e._media_info=t,e._emitter.emit(h.a.MEDIA_INFO,Object.assign({},t))})),this._transmuxer.on(y.a.STATISTICS_INFO,(function(t){e._statistics_info=e._fillStatisticsInfo(t),e._emitter.emit(h.a.STATISTICS_INFO,Object.assign({},t))})),this._transmuxer.on(y.a.RECOMMEND_SEEKPOINT,(function(t){e._media_element&&!e._config.accurateSeek&&e._seeking_handler.directSeek(t/1e3)})),this._transmuxer.on(y.a.METADATA_ARRIVED,(function(t){e._emitter.emit(h.a.METADATA_ARRIVED,t)})),this._transmuxer.on(y.a.SCRIPTDATA_ARRIVED,(function(t){e._emitter.emit(h.a.SCRIPTDATA_ARRIVED,t)})),this._transmuxer.on(y.a.TIMED_ID3_METADATA_ARRIVED,(function(t){e._emitter.emit(h.a.TIMED_ID3_METADATA_ARRIVED,t)})),this._transmuxer.on(y.a.SYNCHRONOUS_KLV_METADATA_ARRIVED,(function(t){e._emitter.emit(h.a.SYNCHRONOUS_KLV_METADATA_ARRIVED,t)})),this._transmuxer.on(y.a.ASYNCHRONOUS_KLV_METADATA_ARRIVED,(function(t){e._emitter.emit(h.a.ASYNCHRONOUS_KLV_METADATA_ARRIVED,t)})),this._transmuxer.on(y.a.SMPTE2038_METADATA_ARRIVED,(function(t){e._emitter.emit(h.a.SMPTE2038_METADATA_ARRIVED,t)})),this._transmuxer.on(y.a.SCTE35_METADATA_ARRIVED,(function(t){e._emitter.emit(h.a.SCTE35_METADATA_ARRIVED,t)})),this._transmuxer.on(y.a.PES_PRIVATE_DATA_DESCRIPTOR,(function(t){e._emitter.emit(h.a.PES_PRIVATE_DATA_DESCRIPTOR,t)})),this._transmuxer.on(y.a.PES_PRIVATE_DATA_ARRIVED,(function(t){e._emitter.emit(h.a.PES_PRIVATE_DATA_ARRIVED,t)})),this._seeking_handler=new E(this._config,this._media_element,this._onRequiredUnbufferedSeek.bind(this)),this._loading_controller=new S(this._config,this._media_element,this._onRequestPauseTransmuxer.bind(this),this._onRequestResumeTransmuxer.bind(this)),this._startup_stall_jumper=new A(this._media_element,this._onRequestDirectSeek.bind(this)),this._config.isLive&&this._config.liveBufferLatencyChasing&&(this._live_latency_chaser=new w(this._config,this._media_element,this._onRequestDirectSeek.bind(this))),this._config.isLive&&this._config.liveSync&&(this._live_latency_synchronizer=new k(this._config,this._media_element)),this._media_element.readyState>0&&this._seeking_handler.directSeek(0),this._transmuxer.open()):this._has_pending_load=!0)},e.prototype.unload=function(){var e,t,i,a,r,n,s,o,_;null===(e=this._media_element)||void 0===e||e.pause(),null===(t=this._live_latency_synchronizer)||void 0===t||t.destroy(),this._live_latency_synchronizer=null,null===(i=this._live_latency_chaser)||void 0===i||i.destroy(),this._live_latency_chaser=null,null===(a=this._startup_stall_jumper)||void 0===a||a.destroy(),this._startup_stall_jumper=null,null===(r=this._loading_controller)||void 0===r||r.destroy(),this._loading_controller=null,null===(n=this._seeking_handler)||void 0===n||n.destroy(),this._seeking_handler=null,null===(s=this._mse_controller)||void 0===s||s.flush(),null===(o=this._transmuxer)||void 0===o||o.close(),null===(_=this._transmuxer)||void 0===_||_.destroy(),this._transmuxer=null},e.prototype.play=function(){return this._media_element.play()},e.prototype.pause=function(){this._media_element.pause()},e.prototype.seek=function(e){this._media_element&&this._seeking_handler?this._seeking_handler.seek(e):this._pending_seek_time=e},Object.defineProperty(e.prototype,"mediaInfo",{get:function(){return Object.assign({},this._media_info)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){return Object.assign({},this._statistics_info)},enumerable:!1,configurable:!0}),e.prototype._onMSESourceOpen=function(){this._mse_source_opened=!0,this._has_pending_load&&(this._has_pending_load=!1,this.load())},e.prototype._onMSEUpdateEnd=function(){this._config.isLive&&this._config.liveBufferLatencyChasing&&this._live_latency_chaser&&this._live_latency_chaser.notifyBufferedRangeUpdate(),this._loading_controller.notifyBufferedPositionChanged()},e.prototype._onMSEBufferFull=function(){d.a.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),this._loading_controller.suspendTransmuxer()},e.prototype._onMSEError=function(e){this._emitter.emit(h.a.ERROR,m.b.MEDIA_ERROR,m.a.MEDIA_MSE_ERROR,e)},e.prototype._onMSEStartStreaming=function(){this._loaded_metadata_received&&(this._config.isLive||(d.a.v(this.TAG,"Resume transmuxing task due to ManagedMediaSource onStartStreaming"),this._loading_controller.resumeTransmuxer()))},e.prototype._onMSEEndStreaming=function(){this._config.isLive||(d.a.v(this.TAG,"Suspend transmuxing task due to ManagedMediaSource onEndStreaming"),this._loading_controller.suspendTransmuxer())},e.prototype._onMediaLoadedMetadata=function(e){this._loaded_metadata_received=!0,null!=this._pending_seek_time&&(this._seeking_handler.seek(this._pending_seek_time),this._pending_seek_time=null)},e.prototype._onRequestDirectSeek=function(e){this._seeking_handler.directSeek(e)},e.prototype._onRequiredUnbufferedSeek=function(e){this._mse_controller.flush(),this._transmuxer.seek(e)},e.prototype._onRequestPauseTransmuxer=function(){this._transmuxer.pause()},e.prototype._onRequestResumeTransmuxer=function(){this._transmuxer.resume()},e.prototype._fillStatisticsInfo=function(e){if(e.playerType="MSEPlayer",!(this._media_element instanceof HTMLVideoElement))return e;var t=!0,i=0,a=0;if(this._media_element.getVideoPlaybackQuality){var r=this._media_element.getVideoPlaybackQuality();i=r.totalVideoFrames,a=r.droppedVideoFrames}else null!=this._media_element.webkitDecodedFrameCount?(i=this._media_element.webkitDecodedFrameCount,a=this._media_element.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=a),e},e}(),L=i(18),R=i(8),C=function(){function e(e,t){this.TAG="PlayerEngineDedicatedThread",this._emitter=new l,this._media_element=null,this._worker_destroying=!1,this._seeking_handler=null,this._loading_controller=null,this._startup_stall_jumper=null,this._live_latency_chaser=null,this._live_latency_synchronizer=null,this._pending_seek_time=null,this._media_info=null,this._statistics_info=null,this.e=null,this._media_data_source=e,this._config=s(),"object"==typeof t&&Object.assign(this._config,t),!0===e.isLive&&(this._config.isLive=!0),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this),onMediaLoadedMetadata:this._onMediaLoadedMetadata.bind(this),onMediaTimeUpdate:this._onMediaTimeUpdate.bind(this),onMediaReadyStateChanged:this._onMediaReadyStateChange.bind(this)},R.a.registerListener(this.e.onLoggingConfigChanged),this._worker=L(24,{all:!0}),this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",media_data_source:this._media_data_source,config:this._config}),this._worker.postMessage({cmd:"logging_config",logging_config:R.a.getConfig()})}return e.isSupported=function(){return!(!self.Worker||!(self.MediaSource&&"canConstructInDedicatedWorker"in self.MediaSource&&!0===self.MediaSource.canConstructInDedicatedWorker||self.ManagedMediaSource&&"canConstructInDedicatedWorker"in self.ManagedMediaSource&&!0===self.ManagedMediaSource.canConstructInDedicatedWorker))},e.prototype.destroy=function(){this._emitter.emit(h.a.DESTROYING),this.unload(),this.detachMediaElement(),this._worker_destroying=!0,this._worker.postMessage({cmd:"destroy"}),R.a.removeListener(this.e.onLoggingConfigChanged),this.e=null,this._media_data_source=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){var i=this;this._emitter.addListener(e,t),e===h.a.MEDIA_INFO&&this._media_info?Promise.resolve().then((function(){return i._emitter.emit(h.a.MEDIA_INFO,i.mediaInfo)})):e==h.a.STATISTICS_INFO&&this._statistics_info&&Promise.resolve().then((function(){return i._emitter.emit(h.a.STATISTICS_INFO,i.statisticsInfo)}))},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){this._media_element=e,this._media_element.src="",this._media_element.removeAttribute("src"),this._media_element.srcObject=null,this._media_element.load(),this._media_element.addEventListener("loadedmetadata",this.e.onMediaLoadedMetadata),this._media_element.addEventListener("timeupdate",this.e.onMediaTimeUpdate),this._media_element.addEventListener("readystatechange",this.e.onMediaReadyStateChanged),this._worker.postMessage({cmd:"initialize_mse"})},e.prototype.detachMediaElement=function(){this._worker.postMessage({cmd:"shutdown_mse"}),this._media_element&&(this._media_element.removeEventListener("loadedmetadata",this.e.onMediaLoadedMetadata),this._media_element.removeEventListener("timeupdate",this.e.onMediaTimeUpdate),this._media_element.removeEventListener("readystatechange",this.e.onMediaReadyStateChanged),this._media_element.src="",this._media_element.removeAttribute("src"),this._media_element.srcObject=null,this._media_element.load(),this._media_element=null)},e.prototype.load=function(){this._worker.postMessage({cmd:"load"}),this._seeking_handler=new E(this._config,this._media_element,this._onRequiredUnbufferedSeek.bind(this)),this._loading_controller=new S(this._config,this._media_element,this._onRequestPauseTransmuxer.bind(this),this._onRequestResumeTransmuxer.bind(this)),this._startup_stall_jumper=new A(this._media_element,this._onRequestDirectSeek.bind(this)),this._config.isLive&&this._config.liveBufferLatencyChasing&&(this._live_latency_chaser=new w(this._config,this._media_element,this._onRequestDirectSeek.bind(this))),this._config.isLive&&this._config.liveSync&&(this._live_latency_synchronizer=new k(this._config,this._media_element)),this._media_element.readyState>0&&this._seeking_handler.directSeek(0)},e.prototype.unload=function(){var e,t,i,a,r,n;null===(e=this._media_element)||void 0===e||e.pause(),this._worker.postMessage({cmd:"unload"}),null===(t=this._live_latency_synchronizer)||void 0===t||t.destroy(),this._live_latency_synchronizer=null,null===(i=this._live_latency_chaser)||void 0===i||i.destroy(),this._live_latency_chaser=null,null===(a=this._startup_stall_jumper)||void 0===a||a.destroy(),this._startup_stall_jumper=null,null===(r=this._loading_controller)||void 0===r||r.destroy(),this._loading_controller=null,null===(n=this._seeking_handler)||void 0===n||n.destroy(),this._seeking_handler=null},e.prototype.play=function(){return this._media_element.play()},e.prototype.pause=function(){this._media_element.pause()},e.prototype.seek=function(e){this._media_element&&this._seeking_handler?this._seeking_handler.seek(e):this._pending_seek_time=e},Object.defineProperty(e.prototype,"mediaInfo",{get:function(){return Object.assign({},this._media_info)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){return Object.assign({},this._statistics_info)},enumerable:!1,configurable:!0}),e.prototype._onLoggingConfigChanged=function(e){var t;null===(t=this._worker)||void 0===t||t.postMessage({cmd:"logging_config",logging_config:e})},e.prototype._onMSEUpdateEnd=function(){this._config.isLive&&this._config.liveBufferLatencyChasing&&this._live_latency_chaser&&this._live_latency_chaser.notifyBufferedRangeUpdate(),this._loading_controller.notifyBufferedPositionChanged()},e.prototype._onMSEBufferFull=function(){d.a.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),this._loading_controller.suspendTransmuxer()},e.prototype._onMediaLoadedMetadata=function(e){null!=this._pending_seek_time&&(this._seeking_handler.seek(this._pending_seek_time),this._pending_seek_time=null)},e.prototype._onRequestDirectSeek=function(e){this._seeking_handler.directSeek(e)},e.prototype._onRequiredUnbufferedSeek=function(e){this._worker.postMessage({cmd:"unbuffered_seek",milliseconds:e})},e.prototype._onRequestPauseTransmuxer=function(){this._worker.postMessage({cmd:"pause_transmuxer"})},e.prototype._onRequestResumeTransmuxer=function(){this._worker.postMessage({cmd:"resume_transmuxer"})},e.prototype._onMediaTimeUpdate=function(e){this._worker.postMessage({cmd:"timeupdate",current_time:e.target.currentTime})},e.prototype._onMediaReadyStateChange=function(e){this._worker.postMessage({cmd:"readystatechange",ready_state:e.target.readyState})},e.prototype._onWorkerMessage=function(e){var t,i=e.data,a=i.msg;if("destroyed"==a||this._worker_destroying)return this._worker_destroying=!1,null===(t=this._worker)||void 0===t||t.terminate(),void(this._worker=null);switch(a){case"mse_init":var r=i;"ManagedMediaSource"in self&&!("MediaSource"in self)&&(this._media_element.disableRemotePlayback=!0),this._media_element.srcObject=r.handle;break;case"mse_event":(r=i).event==p.a.UPDATE_END?this._onMSEUpdateEnd():r.event==p.a.BUFFER_FULL&&this._onMSEBufferFull();break;case"transmuxing_event":if((r=i).event==y.a.MEDIA_INFO){var n=i;this._media_info=n.info,this._emitter.emit(h.a.MEDIA_INFO,Object.assign({},n.info))}else if(r.event==y.a.STATISTICS_INFO){var s=i;this._statistics_info=this._fillStatisticsInfo(s.info),this._emitter.emit(h.a.STATISTICS_INFO,Object.assign({},s.info))}else if(r.event==y.a.RECOMMEND_SEEKPOINT){var o=i;this._media_element&&!this._config.accurateSeek&&this._seeking_handler.directSeek(o.milliseconds/1e3)}break;case"player_event":if((r=i).event==h.a.ERROR){var _=i;this._emitter.emit(h.a.ERROR,_.error_type,_.error_detail,_.info)}else if("extraData"in r){var l=i;this._emitter.emit(l.event,l.extraData)}break;case"logcat_callback":r=i,d.a.emitter.emit("log",r.type,r.logcat);break;case"buffered_position_changed":r=i,this._loading_controller.notifyBufferedPositionChanged(r.buffered_position_milliseconds/1e3)}},e.prototype._fillStatisticsInfo=function(e){if(e.playerType="MSEPlayer",!(this._media_element instanceof HTMLVideoElement))return e;var t=!0,i=0,a=0;if(this._media_element.getVideoPlaybackQuality){var r=this._media_element.getVideoPlaybackQuality();i=r.totalVideoFrames,a=r.droppedVideoFrames}else null!=this._media_element.webkitDecodedFrameCount?(i=this._media_element.webkitDecodedFrameCount,a=this._media_element.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=a),e},e}(),x=function(){function e(e,t){this.TAG="MSEPlayer",this._type="MSEPlayer",this._media_element=null,this._player_engine=null;var i=e.type.toLowerCase();if("mse"!==i&&"mpegts"!==i&&"m2ts"!==i&&"flv"!==i)throw new g.b("MSEPlayer requires an mpegts/m2ts/flv MediaDataSource input!");if(t&&t.enableWorkerForMSE&&C.isSupported())try{this._player_engine=new C(e,t)}catch(i){d.a.e(this.TAG,"Error while initializing PlayerEngineDedicatedThread, fallback to PlayerEngineMainThread"),this._player_engine=new T(e,t)}else this._player_engine=new T(e,t)}return e.prototype.destroy=function(){this._player_engine.destroy(),this._player_engine=null,this._media_element=null},e.prototype.on=function(e,t){this._player_engine.on(e,t)},e.prototype.off=function(e,t){this._player_engine.off(e,t)},e.prototype.attachMediaElement=function(e){this._media_element=e,this._player_engine.attachMediaElement(e)},e.prototype.detachMediaElement=function(){this._media_element=null,this._player_engine.detachMediaElement()},e.prototype.load=function(){this._player_engine.load()},e.prototype.unload=function(){this._player_engine.unload()},e.prototype.play=function(){return this._player_engine.play()},e.prototype.pause=function(){this._player_engine.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._media_element.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._media_element.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._media_element.volume},set:function(e){this._media_element.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._media_element.muted},set:function(e){this._media_element.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._media_element?this._media_element.currentTime:0},set:function(e){this._player_engine.seek(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){return this._player_engine.mediaInfo},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){return this._player_engine.statisticsInfo},enumerable:!1,configurable:!0}),e}(),M=function(){function e(e,t){this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new u.a,this._config=s(),"object"==typeof t&&Object.assign(this._config,t);var i=e.type.toLowerCase();if("mse"===i||"mpegts"===i||"m2ts"===i||"flv"===i)throw new g.b("NativePlayer does't support mse/mpegts/m2ts/flv MediaDataSource input!");if(e.hasOwnProperty("segments"))throw new g.b("NativePlayer(".concat(e.type,") doesn't support multipart playback!"));this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=e,this._mediaElement=null}return e.prototype.destroy=function(){this._emitter.emit(h.a.DESTROYING),this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){var i=this;e===h.a.MEDIA_INFO?null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then((function(){i._emitter.emit(h.a.MEDIA_INFO,i.mediaInfo)})):e===h.a.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then((function(){i._emitter.emit(h.a.STATISTICS_INFO,i.statisticsInfo)})),this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}},e.prototype.detachMediaElement=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype.load=function(){if(!this._mediaElement)throw new g.a("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)},e.prototype.unload=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){var e={mimeType:(this._mediaElement instanceof HTMLAudioElement?"audio/":"video/")+this._mediaDataSource.type};return this._mediaElement&&(e.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(e.width=this._mediaElement.videoWidth,e.height=this._mediaElement.videoHeight)),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){var e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,i=0,a=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();i=r.totalVideoFrames,a=r.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,a=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=a),e},enumerable:!1,configurable:!0}),e.prototype._onvLoadedMetadata=function(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(h.a.MEDIA_INFO,this.mediaInfo)},e.prototype._reportStatisticsInfo=function(){this._emitter.emit(h.a.STATISTICS_INFO,this.statisticsInfo)},e}();a.a.install();var D={createPlayer:function(e,t){var i=e;if(null==i||"object"!=typeof i)throw new g.b("MediaDataSource must be an javascript object!");if(!i.hasOwnProperty("type"))throw new g.b("MediaDataSource must has type field to indicate video file type!");switch(i.type){case"mse":case"mpegts":case"m2ts":case"flv":return new x(i,t);default:return new M(i,t)}},isSupported:function(){return o.supportMSEH264Playback()},getFeatureList:function(){return o.getFeatureList()}};D.BaseLoader=_.a,D.LoaderStatus=_.c,D.LoaderErrors=_.b,D.Events=h.a,D.ErrorTypes=m.b,D.ErrorDetails=m.a,D.MSEPlayer=x,D.NativePlayer=M,D.LoggingControl=R.a,Object.defineProperty(D,"version",{enumerable:!0,get:function(){return"1.8.0"}}),t.default=D}])},"object"==typeof i&&"object"==typeof t?t.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof i?i.mpegts=r():a.mpegts=r()},{}]},{},[15]); |