/*! * FlvPlayer.js v1.1.8 * Github: https://github.com/zhw2590582/FlvPlayer#readme * (c) 2017-2020 Harvey Zack * Released under the MIT License. */ !function(A,I){"object"==typeof exports&&"undefined"!=typeof module?module.exports=I():"function"==typeof define&&define.amd?define(I):(A=A||self).FlvplayerDecoder=I()}(this,(function(){"use strict";var A=function(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")};function I(A,I){for(var B=0;B=1e3&&(A(I/E*1e3),B=Q,I=0)}}var R=function(){function I(B,g){var Q=this;A(this,I),this.flv=B;var E=B.options,C=B.player,i=B.debug;this.ready=!1,this.playing=!1,this.playIndex=0,this.videoframes=[],this.timestamps=[],this.videoInputLength=0,this.videoOutputLength=0,this.decoding=!1,this.byteSize=0,this.loaded=0,this.decoderRate=F((function(A){B.emit("decoderRate",A)})),this.drawRate=F((function(A){B.emit("drawRate",A)})),B.on("destroy",(function(){Q.videoframes=[],Q.timestamps=[],Q.decoderWorker.terminate(),Q.decoderWorker=null,Q.stop()})),B.on("befoerdecoding",(function(A){E.live&&E.hasAudio&&!Q.playing&&Q.timestamps.length>=C.frameRate&&Q.timestamps.shift(),Q.timestamps.push(A),Q.decoding=!0,Q.videoInputLength+=1})),B.on("decoding",(function(A,I){E.live&&E.hasAudio&&!Q.playing&&Q.timestamps.length>=C.frameRate&&Q.videoframes.shift(),Q.videoframes.push(A),Q.byteSize+=I,Q.videoOutputLength+=1,Q.decoding=Q.videoInputLength!==Q.videoOutputLength,Q.loaded=Q.videoOutputLength/C.frameRate,B.emit("videoLoaded",Q.loaded),Q.decoderRate(1),Q.ready||1!==Q.videoOutputLength||(Q.ready=!0,E.live&&(g.currentTime=Q.timestamps[0]/1e3),B.emit("ready"))})),B.on("timeupdate",(function(A){var I=Q.playIndex,C=Q.timestamps[I];if(void 0!==C&&1e3*A>=C)if(Q.draw(I)){var o=Q.getFramesSize(I);(E.live||!E.cache)&&o>=64*E.videoChunk&&Q.videoframes.length-1>I&&Q.timestamps.length-1>I?(Q.playIndex=0,Q.videoframes.splice(0,I+1),Q.timestamps.splice(0,I+1),g.currentTime=Q.timestamps[0]/1e3,i.log("free-video-memory",{total:Q.byteSize,yuv:o,index:I}),B.emit("freeVideoMemory",o,I)):Q.playIndex+=1}else E.live||Q.stop()}))}return B(I,[{key:"draw",value:function(A){var I=this.videoframes[A];return!!I&&(this.renderer.drawFrame(I),this.drawRate(1),!0)}},{key:"play",value:function(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.playing=!0,this.flv.options.live?(this.playIndex=0,this.flv.decoder.currentTime=(this.timestamps[0]||0)/1e3):this.playIndex=this.timestamps.findIndex((function(I){return I>=1e3*A}))}},{key:"stop",value:function(){this.playing=!1,this.flv.options.live&&(this.playIndex=0)}}]),I}();function h(A,I){this.canvasElement=A,I||this.initContextGL(),this.contextGL&&(this.initProgram(),this.initBuffers(),this.initTextures())}h.prototype.isWebGL=function(){return this.contextGL},h.prototype.initContextGL=function(){for(var A=this.canvasElement,I=null,B=["webgl","experimental-webgl","moz-webgl","webkit-3d"],g=0;!I&&g1?Module.thisProgram=process.argv[1].replace(/\\\\/g,"/"):Module.thisProgram="unknown-program"),Module.arguments=process.argv.slice(2),"undefined"!=typeof module&&(module.exports=Module),process.on("uncaughtException",function(A){if(!(A instanceof ExitStatus))throw A}),process.on("unhandledRejection",function(A,I){process.exit(1)}),Module.inspect=function(){return"[Emscripten Module object]"};else if(ENVIRONMENT_IS_SHELL)Module.print||(Module.print=print),"undefined"!=typeof printErr&&(Module.printErr=printErr),"undefined"!=typeof read?Module.read=function(A){return read(A)}:Module.read=function(){throw"no read() available"},Module.readBinary=function(A){var I;return"function"==typeof readbuffer?new Uint8Array(readbuffer(A)):(assert("object"==typeof(I=read(A,"binary"))),I)},"undefined"!=typeof scriptArgs?Module.arguments=scriptArgs:"undefined"!=typeof arguments&&(Module.arguments=arguments),"function"==typeof quit&&(Module.quit=function(A,I){quit(A)});else{if(!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER)throw new Error("Unknown runtime environment. Where are we?");if(Module.read=function(A){var I=new XMLHttpRequest;return I.open("GET",A,!1),I.send(null),I.responseText},ENVIRONMENT_IS_WORKER&&(Module.readBinary=function(A){var I=new XMLHttpRequest;return I.open("GET",A,!1),I.responseType="arraybuffer",I.send(null),new Uint8Array(I.response)}),Module.readAsync=function(A,I,B){var g=new XMLHttpRequest;g.open("GET",A,!0),g.responseType="arraybuffer",g.onload=function(){200==g.status||0==g.status&&g.response?I(g.response):B()},g.onerror=B,g.send(null)},"undefined"!=typeof arguments&&(Module.arguments=arguments),"undefined"!=typeof console)Module.print||(Module.print=function(A){console.log(A)}),Module.printErr||(Module.printErr=function(A){console.warn(A)});else{var TRY_USE_DUMP=!1;Module.print||(Module.print=TRY_USE_DUMP&&"undefined"!=typeof dump?function(A){dump(A)}:function(A){})}void 0===Module.setWindowTitle&&(Module.setWindowTitle=function(A){document.title=A})}for(key in Module.print||(Module.print=function(){}),Module.printErr||(Module.printErr=Module.print),Module.arguments||(Module.arguments=[]),Module.thisProgram||(Module.thisProgram="./this.program"),Module.quit||(Module.quit=function(A,I){throw I}),Module.print=Module.print,Module.printErr=Module.printErr,Module.preRun=[],Module.postRun=[],moduleOverrides)moduleOverrides.hasOwnProperty(key)&&(Module[key]=moduleOverrides[key]);moduleOverrides=void 0;var STACK_ALIGN=16;function staticAlloc(A){assert(!staticSealed);var I=STATICTOP;return STATICTOP=STATICTOP+A+15&-16,I}function alignMemory(A,I){return I||(I=STACK_ALIGN),A=Math.ceil(A/I)*I}function warnOnce(A){warnOnce.shown||(warnOnce.shown={}),warnOnce.shown[A]||(warnOnce.shown[A]=1,Module.printErr(A))}var functionPointers=new Array(0),GLOBAL_BASE=1024,ABORT=0,EXITSTATUS=0;function assert(A,I){A||abort("Assertion failed: "+I)}function getValue(A,I,B){switch("*"===(I=I||"i8").charAt(I.length-1)&&(I="i32"),I){case"i1":case"i8":return HEAP8[A>>0];case"i16":return HEAP16[A>>1];case"i32":case"i64":return HEAP32[A>>2];case"float":return HEAPF32[A>>2];case"double":return HEAPF64[A>>3];default:abort("invalid type for getValue: "+I)}return null}var UTF8Decoder="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,UTF16Decoder="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function demangle(A){return A}function demangleAll(A){return A.replace(/__Z[\\w\\d_]+/g,function(A){var I=demangle(A);return A===I?A:A+" ["+I+"]"})}function jsStackTrace(){var A=new Error;if(!A.stack){try{throw new Error(0)}catch(I){A=I}if(!A.stack)return"(no stack trace available)"}return A.stack.toString()}function stackTrace(){var A=jsStackTrace();return Module.extraStackTrace&&(A+="\\n"+Module.extraStackTrace()),demangleAll(A)}var HEAP,buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64,STATIC_BASE,STATICTOP,staticSealed,STACK_BASE,STACKTOP,STACK_MAX,DYNAMIC_BASE,DYNAMICTOP_PTR,byteLength,WASM_PAGE_SIZE=65536,ASMJS_PAGE_SIZE=16777216,MIN_TOTAL_MEMORY=16777216;function alignUp(A,I){return A%I>0&&(A+=I-A%I),A}function updateGlobalBuffer(A){Module.buffer=buffer=A}function updateGlobalBufferViews(){Module.HEAP8=HEAP8=new Int8Array(buffer),Module.HEAP16=HEAP16=new Int16Array(buffer),Module.HEAP32=HEAP32=new Int32Array(buffer),Module.HEAPU8=HEAPU8=new Uint8Array(buffer),Module.HEAPU16=HEAPU16=new Uint16Array(buffer),Module.HEAPU32=HEAPU32=new Uint32Array(buffer),Module.HEAPF32=HEAPF32=new Float32Array(buffer),Module.HEAPF64=HEAPF64=new Float64Array(buffer)}function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}function enlargeMemory(){var A=Module.usingWasm?WASM_PAGE_SIZE:ASMJS_PAGE_SIZE,I=2147483648-A;if(HEAP32[DYNAMICTOP_PTR>>2]>I)return!1;var B=TOTAL_MEMORY;for(TOTAL_MEMORY=Math.max(TOTAL_MEMORY,MIN_TOTAL_MEMORY);TOTAL_MEMORY>2];)TOTAL_MEMORY=TOTAL_MEMORY<=536870912?alignUp(2*TOTAL_MEMORY,A):Math.min(alignUp((3*TOTAL_MEMORY+2147483648)/4,A),I);var g=Module.reallocBuffer(TOTAL_MEMORY);return g&&g.byteLength==TOTAL_MEMORY?(updateGlobalBuffer(g),updateGlobalBufferViews(),!0):(TOTAL_MEMORY=B,!1)}STATIC_BASE=STATICTOP=STACK_BASE=STACKTOP=STACK_MAX=DYNAMIC_BASE=DYNAMICTOP_PTR=0,staticSealed=!1,Module.reallocBuffer||(Module.reallocBuffer=function(A){var I;try{if(ArrayBuffer.transfer)I=ArrayBuffer.transfer(buffer,A);else{var B=HEAP8;I=new ArrayBuffer(A),new Int8Array(I).set(B)}}catch(A){return!1}return!!_emscripten_replace_memory(I)&&I});try{(byteLength=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get))(new ArrayBuffer(4))}catch(A){byteLength=function(A){return A.byteLength}}var TOTAL_STACK=Module.TOTAL_STACK||5242880,TOTAL_MEMORY=Module.TOTAL_MEMORY||16777216;function getTotalMemory(){return TOTAL_MEMORY}if(TOTAL_MEMORY0;){var I=A.shift();if("function"!=typeof I){var B=I.func;"number"==typeof B?void 0===I.arg?Module.dynCall_v(B):Module.dynCall_vi(B,I.arg):B(void 0===I.arg?null:I.arg)}else I()}}Module.HEAP=HEAP,Module.buffer=buffer,Module.HEAP8=HEAP8,Module.HEAP16=HEAP16,Module.HEAP32=HEAP32,Module.HEAPU8=HEAPU8,Module.HEAPU16=HEAPU16,Module.HEAPU32=HEAPU32,Module.HEAPF32=HEAPF32,Module.HEAPF64=HEAPF64;var __ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATEXIT__=[],__ATPOSTRUN__=[],runtimeInitialized=!1,runtimeExited=!1;function preRun(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){runtimeInitialized||(runtimeInitialized=!0,callRuntimeCallbacks(__ATINIT__))}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__),runtimeExited=!0}function postRun(){if(Module.postRun)for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(A){__ATPRERUN__.unshift(A)}function addOnPostRun(A){__ATPOSTRUN__.unshift(A)}var Math_abs=Math.abs,Math_cos=Math.cos,Math_sin=Math.sin,Math_tan=Math.tan,Math_acos=Math.acos,Math_asin=Math.asin,Math_atan=Math.atan,Math_atan2=Math.atan2,Math_exp=Math.exp,Math_log=Math.log,Math_sqrt=Math.sqrt,Math_ceil=Math.ceil,Math_floor=Math.floor,Math_pow=Math.pow,Math_imul=Math.imul,Math_fround=Math.fround,Math_round=Math.round,Math_min=Math.min,Math_clz32=Math.clz32,Math_trunc=Math.trunc,runDependencies=0,runDependencyWatcher=null,dependenciesFulfilled=null;function addRunDependency(A){runDependencies++,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies)}function removeRunDependency(A){if(runDependencies--,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies),0==runDependencies&&(null!==runDependencyWatcher&&(clearInterval(runDependencyWatcher),runDependencyWatcher=null),dependenciesFulfilled)){var I=dependenciesFulfilled;dependenciesFulfilled=null,I()}}Module.preloadedImages={},Module.preloadedAudios={};var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(A){return String.prototype.startsWith?A.startsWith(dataURIPrefix):0===A.indexOf(dataURIPrefix)}function integrateWasmJS(){var A="TinyH264.wast",I=wasmBinaryFileBase64,B="TinyH264.temp.asm.js";"function"==typeof Module.locateFile&&(isDataURI(A)||(A=Module.locateFile(A)),isDataURI(I)||(I=Module.locateFile(I)),isDataURI(B)||(B=Module.locateFile(B)));var g={global:null,env:null,asm2wasm:{"f64-rem":function(A,I){return A%I},debugger:function(){}},parent:Module},Q=null;function E(){try{if(Module.wasmBinary)return new Uint8Array(Module.wasmBinary);if(Module.readBinary)return Module.readBinary(I);throw"on the web, we need the wasm binary to be preloaded and set on Module[\'wasmBinary\']. emcc.py will do that for you when generating HTML (but not JS)"}catch(A){abort(A)}}function C(A,B,C){if("object"!=typeof WebAssembly)return Module.printErr("no native wasm support detected"),!1;if(!(Module.wasmMemory instanceof WebAssembly.Memory))return Module.printErr("no native wasm Memory in use"),!1;function i(A,I){(Q=A.exports).memory&&function(A){var I=Module.buffer;A.byteLength>2]=A),A}Module.STATIC_BASE=STATIC_BASE,Module.STATIC_BUMP=STATIC_BUMP,STATICTOP+=16,DYNAMICTOP_PTR=staticAlloc(4),DYNAMIC_BASE=alignMemory(STACK_MAX=(STACK_BASE=STACKTOP=alignMemory(STATICTOP))+TOTAL_STACK),HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE,staticSealed=!0,Module.wasmTableSize=0,Module.wasmMaxTableSize=0,Module.asmGlobalArg={},Module.asmLibraryArg={enlargeMemory:enlargeMemory,getTotalMemory:getTotalMemory,abortOnCannotGrowMemory:abortOnCannotGrowMemory,___setErrNo:___setErrNo,_emscripten_memcpy_big:_emscripten_memcpy_big,DYNAMICTOP_PTR:DYNAMICTOP_PTR,STACKTOP:STACKTOP};var asm=Module.asm(Module.asmGlobalArg,Module.asmLibraryArg,buffer);Module.asm=asm;var initialStackTop,_emscripten_get_global_libc=Module._emscripten_get_global_libc=function(){return Module.asm._emscripten_get_global_libc.apply(null,arguments)},_emscripten_replace_memory=Module._emscripten_replace_memory=function(){return Module.asm._emscripten_replace_memory.apply(null,arguments)},_free=Module._free=function(){return Module.asm._free.apply(null,arguments)},_h264bsdAlloc=Module._h264bsdAlloc=function(){return Module.asm._h264bsdAlloc.apply(null,arguments)},_h264bsdDecode=Module._h264bsdDecode=function(){return Module.asm._h264bsdDecode.apply(null,arguments)},_h264bsdFree=Module._h264bsdFree=function(){return Module.asm._h264bsdFree.apply(null,arguments)},_h264bsdInit=Module._h264bsdInit=function(){return Module.asm._h264bsdInit.apply(null,arguments)},_h264bsdShutdown=Module._h264bsdShutdown=function(){return Module.asm._h264bsdShutdown.apply(null,arguments)},_malloc=Module._malloc=function(){return Module.asm._malloc.apply(null,arguments)};function ExitStatus(A){this.name="ExitStatus",this.message="Program terminated with exit("+A+")",this.status=A}Module.asm=asm,Module.getValue=getValue,ExitStatus.prototype=new Error,ExitStatus.prototype.constructor=ExitStatus;var preloadStartTime=null;function run(A){function I(){Module.calledRun||(Module.calledRun=!0,ABORT||(ensureInitRuntime(),preMain(),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),postRun()))}A=A||Module.arguments,null===preloadStartTime&&(preloadStartTime=Date.now()),runDependencies>0||(preRun(),runDependencies>0||Module.calledRun||(Module.setStatus?(Module.setStatus("Running..."),setTimeout(function(){setTimeout(function(){Module.setStatus("")},1),I()},1)):I()))}function exit(A,I){I&&Module.noExitRuntime&&0===A||(Module.noExitRuntime||(ABORT=!0,EXITSTATUS=A,STACKTOP=initialStackTop,exitRuntime(),Module.onExit&&Module.onExit(A)),ENVIRONMENT_IS_NODE&&process.exit(A),Module.quit(A,new ExitStatus(A)))}dependenciesFulfilled=function A(){Module.calledRun||run(),Module.calledRun||(dependenciesFulfilled=A)},Module.run=run,Module.exit=exit;var abortDecorators=[];function abort(A){Module.onAbort&&Module.onAbort(A),void 0!==A?(Module.print(A),Module.printErr(A),A=JSON.stringify(A)):A="",ABORT=!0,EXITSTATUS=1;var I="abort("+A+") at "+stackTrace()+"\\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.";throw abortDecorators&&abortDecorators.forEach(function(B){I=B(I,A)}),I}if(Module.abort=abort,Module.preInit)for("function"==typeof Module.preInit&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();Module.noExitRuntime=!0,run();var decoder=null;function onMessage(A){var I=A.data;switch(I.type){case"decode":decoder&&decoder.decode&&decoder.decode(I.data)}}function onPictureReady(A,I,B){postMessage({type:"pictureReady",width:I,height:B,data:A.buffer},[A.buffer])}addEventListener("message",onMessage);'),g.renderer=new h(E.$canvas),i.proxy(g.decoderWorker,"message",(function(A){var B=A.data;switch(B.type){case"pictureReady":I.emit("decoding",B,B.data.byteLength)}})),I.on("videoData",(function(A,B){g.decoderWorker.postMessage({type:"decode",data:A.buffer},[A.buffer]),I.emit("befoerdecoding",B)})),g}return B(C,[{key:"getFramesSize",value:function(A){for(var I=0,B=0;B