mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-12-15 03:59:04 +08:00
47 lines
11 KiB
JavaScript
47 lines
11 KiB
JavaScript
|
|
||
|
var OGVDemuxerWebMW = (() => {
|
||
|
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||
|
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
||
|
return (
|
||
|
function(OGVDemuxerWebMW) {
|
||
|
OGVDemuxerWebMW = OGVDemuxerWebMW || {};
|
||
|
|
||
|
|
||
|
var a;a||(a=typeof OGVDemuxerWebMW !== 'undefined' ? OGVDemuxerWebMW : {});var h=Object.assign,k,l;a.ready=new Promise(function(b,c){k=b;l=c});var m=h({},a),n="object"===typeof window,q="function"===typeof importScripts,r="",t,u,v,fs,w,A;
|
||
|
if("object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node)r=q?require("path").dirname(r)+"/":__dirname+"/",A=function(){w||(fs=require("fs"),w=require("path"))},t=function(b,c){A();b=w.normalize(b);return fs.readFileSync(b,c?null:"utf8")},v=function(b){b=t(b,!0);b.buffer||(b=new Uint8Array(b));return b},u=function(b,c,d){A();b=w.normalize(b);fs.readFile(b,function(e,f){e?d(e):c(f.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),
|
||
|
process.on("unhandledRejection",function(b){throw b;}),a.inspect=function(){return"[Emscripten Module object]"};else if(n||q)q?r=self.location.href:"undefined"!==typeof document&&document.currentScript&&(r=document.currentScript.src),_scriptDir&&(r=_scriptDir),0!==r.indexOf("blob:")?r=r.substr(0,r.replace(/[?#].*/,"").lastIndexOf("/")+1):r="",t=function(b){var c=new XMLHttpRequest;c.open("GET",b,!1);c.send(null);return c.responseText},q&&(v=function(b){var c=new XMLHttpRequest;c.open("GET",b,!1);
|
||
|
c.responseType="arraybuffer";c.send(null);return new Uint8Array(c.response)}),u=function(b,c,d){var e=new XMLHttpRequest;e.open("GET",b,!0);e.responseType="arraybuffer";e.onload=function(){200==e.status||0==e.status&&e.response?c(e.response):d()};e.onerror=d;e.send(null)};var aa=a.print||console.log.bind(console),B=a.printErr||console.warn.bind(console);h(a,m);m=null;var C;a.wasmBinary&&(C=a.wasmBinary);var noExitRuntime=a.noExitRuntime||!0;"object"!==typeof WebAssembly&&D("no native wasm support detected");
|
||
|
var E,F=!1,H="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
|
||
|
function I(b,c,d){var e=c+d;for(d=c;b[d]&&!(d>=e);)++d;if(16<d-c&&b.subarray&&H)return H.decode(b.subarray(c,d));for(e="";c<d;){var f=b[c++];if(f&128){var g=b[c++]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|g);else{var p=b[c++]&63;f=224==(f&240)?(f&15)<<12|g<<6|p:(f&7)<<18|g<<12|p<<6|b[c++]&63;65536>f?e+=String.fromCharCode(f):(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else e+=String.fromCharCode(f)}return e}function J(b){return b?I(K,b,void 0):""}var L,K,M;
|
||
|
function N(){var b=E.buffer;L=b;a.HEAP8=new Int8Array(b);a.HEAP16=new Int16Array(b);a.HEAP32=M=new Int32Array(b);a.HEAPU8=K=new Uint8Array(b);a.HEAPU16=new Uint16Array(b);a.HEAPU32=new Uint32Array(b);a.HEAPF32=new Float32Array(b);a.HEAPF64=new Float64Array(b)}var ba,ca=[],da=[],ea=[];function fa(){var b=a.preRun.shift();ca.unshift(b)}var O=0,P=null,Q=null;a.preloadedImages={};a.preloadedAudios={};
|
||
|
function D(b){if(a.onAbort)a.onAbort(b);b="Aborted("+b+")";B(b);F=!0;b=new WebAssembly.RuntimeError(b+". Build with -s ASSERTIONS=1 for more info.");l(b);throw b;}function ha(){return R.startsWith("data:application/octet-stream;base64,")}var R;R="ogv-demuxer-webm-wasm.wasm";if(!ha()){var ia=R;R=a.locateFile?a.locateFile(ia,r):r+ia}function ja(){var b=R;try{if(b==R&&C)return new Uint8Array(C);if(v)return v(b);throw"both async and sync fetching of the wasm failed";}catch(c){D(c)}}
|
||
|
function ka(){if(!C&&(n||q)){if("function"===typeof fetch&&!R.startsWith("file://"))return fetch(R,{credentials:"same-origin"}).then(function(b){if(!b.ok)throw"failed to load wasm binary file at '"+R+"'";return b.arrayBuffer()}).catch(function(){return ja()});if(u)return new Promise(function(b,c){u(R,function(d){b(new Uint8Array(d))},c)})}return Promise.resolve().then(function(){return ja()})}
|
||
|
function S(b){for(;0<b.length;){var c=b.shift();if("function"==typeof c)c(a);else{var d=c.B;"number"===typeof d?void 0===c.A?la(d)():la(d)(c.A):d(void 0===c.A?null:c.A)}}}var T=[];function la(b){var c=T[b];c||(b>=T.length&&(T.length=b+1),T[b]=c=ba.get(b));return c}
|
||
|
var ma=[null,[],[]],na={a:function(b,c,d,e){D("Assertion failed: "+J(b)+", at: "+[c?J(c):"unknown filename",d,e?J(e):"unknown function"])},f:function(){D("")},d:function(b,c,d){K.copyWithin(b,c,c+d)},e:function(b){var c=K.length;b>>>=0;if(2147483648<b)return!1;for(var d=1;4>=d;d*=2){var e=c*(1+.2/d);e=Math.min(e,b+100663296);e=Math.max(b,e);0<e%65536&&(e+=65536-e%65536);a:{try{E.grow(Math.min(2147483648,e)-L.byteLength+65535>>>16);N();var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},b:function(b,
|
||
|
c,d,e){for(var f=0,g=0;g<d;g++){var p=M[c>>2],G=M[c+4>>2];c+=8;for(var x=0;x<G;x++){var y=K[p+x],z=ma[b];0===y||10===y?((1===b?aa:B)(I(z,0)),z.length=0):z.push(y)}f+=G}M[e>>2]=f;return 0},c:function(b,c,d,e){var f=E.buffer;a.audioPackets.push({data:f.slice?f.slice(b,b+c):(new Uint8Array(new Uint8Array(f,b,c))).buffer,timestamp:d,discardPadding:e})},j:function(b,c,d,e,f,g,p,G,x,y,z){a.videoFormat={width:b,height:c,chromaWidth:d,chromaHeight:e,cropLeft:G,cropTop:x,cropWidth:g,cropHeight:p,displayWidth:y,
|
||
|
displayHeight:z,fps:f}},h:function(b,c){function d(e){for(var f="",g=new Uint8Array(E.buffer);0!=g[e];e++)f+=String.fromCharCode(g[e]);return f}b&&(a.videoCodec=d(b));c&&(a.audioCodec=d(c));b=a._ogv_demuxer_media_duration();a.duration=0<=b?b:NaN;a.loadedMetadata=!0},i:function(b,c){if(a.onseek)a.onseek(b+4294967296*c)},g:function(b,c,d,e,f){var g=E.buffer;a.videoPackets.push({data:g.slice?g.slice(b,b+c):(new Uint8Array(new Uint8Array(g,b,c))).buffer,timestamp:d,keyframeTimestamp:e,isKeyframe:!!f})}};
|
||
|
(function(){function b(f){a.asm=f.exports;E=a.asm.k;N();ba=a.asm.w;da.unshift(a.asm.l);O--;a.monitorRunDependencies&&a.monitorRunDependencies(O);0==O&&(null!==P&&(clearInterval(P),P=null),Q&&(f=Q,Q=null,f()))}function c(f){b(f.instance)}function d(f){return ka().then(function(g){return WebAssembly.instantiate(g,e)}).then(function(g){return g}).then(f,function(g){B("failed to asynchronously prepare wasm: "+g);D(g)})}var e={a:na};O++;a.monitorRunDependencies&&a.monitorRunDependencies(O);if(a.instantiateWasm)try{return a.instantiateWasm(e,
|
||
|
b)}catch(f){return B("Module.instantiateWasm callback failed with error: "+f),!1}(function(){return C||"function"!==typeof WebAssembly.instantiateStreaming||ha()||R.startsWith("file://")||"function"!==typeof fetch?d(c):fetch(R,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(c,function(g){B("wasm streaming compile failed: "+g);B("falling back to ArrayBuffer instantiation");return d(c)})})})().catch(l);return{}})();
|
||
|
a.___wasm_call_ctors=function(){return(a.___wasm_call_ctors=a.asm.l).apply(null,arguments)};a._ogv_demuxer_init=function(){return(a._ogv_demuxer_init=a.asm.m).apply(null,arguments)};a._ogv_demuxer_receive_input=function(){return(a._ogv_demuxer_receive_input=a.asm.n).apply(null,arguments)};a._ogv_demuxer_process=function(){return(a._ogv_demuxer_process=a.asm.o).apply(null,arguments)};a._ogv_demuxer_destroy=function(){return(a._ogv_demuxer_destroy=a.asm.p).apply(null,arguments)};
|
||
|
a._ogv_demuxer_flush=function(){return(a._ogv_demuxer_flush=a.asm.q).apply(null,arguments)};a._ogv_demuxer_media_length=function(){return(a._ogv_demuxer_media_length=a.asm.r).apply(null,arguments)};a._ogv_demuxer_media_duration=function(){return(a._ogv_demuxer_media_duration=a.asm.s).apply(null,arguments)};a._ogv_demuxer_seekable=function(){return(a._ogv_demuxer_seekable=a.asm.t).apply(null,arguments)};
|
||
|
a._ogv_demuxer_keypoint_offset=function(){return(a._ogv_demuxer_keypoint_offset=a.asm.u).apply(null,arguments)};a._ogv_demuxer_seek_to_keypoint=function(){return(a._ogv_demuxer_seek_to_keypoint=a.asm.v).apply(null,arguments)};a._malloc=function(){return(a._malloc=a.asm.x).apply(null,arguments)};a._free=function(){return(a._free=a.asm.y).apply(null,arguments)};var U;Q=function oa(){U||V();U||(Q=oa)};
|
||
|
function V(){function b(){if(!U&&(U=!0,a.calledRun=!0,!F)){S(da);k(a);if(a.onRuntimeInitialized)a.onRuntimeInitialized();if(a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;){var c=a.postRun.shift();ea.unshift(c)}S(ea)}}if(!(0<O)){if(a.preRun)for("function"==typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)fa();S(ca);0<O||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1);b()},1)):b())}}a.run=V;
|
||
|
if(a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);0<a.preInit.length;)a.preInit.pop()();V();var W,X,Y;"undefined"===typeof performance||"undefined"===typeof performance.now?Y=Date.now:Y=performance.now.bind(performance);function Z(b){var c=Y();b=b();c=Y()-c;a.cpuTime+=c;return b}a.loadedMetadata=!1;a.videoCodec=null;a.audioCodec=null;a.duration=NaN;a.onseek=null;a.cpuTime=0;a.audioPackets=[];Object.defineProperty(a,"hasAudio",{get:function(){return a.loadedMetadata&&a.audioCodec}});
|
||
|
Object.defineProperty(a,"audioReady",{get:function(){return 0<a.audioPackets.length}});Object.defineProperty(a,"audioTimestamp",{get:function(){return 0<a.audioPackets.length?a.audioPackets[0].timestamp:-1}});a.videoPackets=[];Object.defineProperty(a,"hasVideo",{get:function(){return a.loadedMetadata&&a.videoCodec}});Object.defineProperty(a,"frameReady",{get:function(){return 0<a.videoPackets.length}});
|
||
|
Object.defineProperty(a,"frameTimestamp",{get:function(){return 0<a.videoPackets.length?a.videoPackets[0].timestamp:-1}});Object.defineProperty(a,"keyframeTimestamp",{get:function(){return 0<a.videoPackets.length?a.videoPackets[0].keyframeTimestamp:-1}});Object.defineProperty(a,"nextKeyframeTimestamp",{get:function(){for(var b=0;b<a.videoPackets.length;b++){var c=a.videoPackets[b];if(c.isKeyframe)return c.timestamp}return-1}});Object.defineProperty(a,"processing",{get:function(){return!1}});
|
||
|
Object.defineProperty(a,"seekable",{get:function(){return!!a._ogv_demuxer_seekable()}});a.init=function(b){Z(function(){a._ogv_demuxer_init()});b()};a.receiveInput=function(b,c){Z(function(){var d=b.byteLength;W&&X>=d||(W&&a._free(W),X=d,W=a._malloc(X));var e=W;(new Uint8Array(E.buffer,e,d)).set(new Uint8Array(b));a._ogv_demuxer_receive_input(e,d)});c()};a.process=function(b){var c=Z(function(){return a._ogv_demuxer_process()});b(!!c)};
|
||
|
a.dequeueVideoPacket=function(b){if(a.videoPackets.length){var c=a.videoPackets.shift().data;b(c)}else b(null)};a.dequeueAudioPacket=function(b){if(a.audioPackets.length){var c=a.audioPackets.shift();b(c.data,c.discardPadding)}else b(null)};a.getKeypointOffset=function(b,c){var d=Z(function(){return a._ogv_demuxer_keypoint_offset(1E3*b)});c(d)};
|
||
|
a.seekToKeypoint=function(b,c){var d=Z(function(){return a._ogv_demuxer_seek_to_keypoint(1E3*b)});d&&(a.audioPackets.splice(0,a.audioPackets.length),a.videoPackets.splice(0,a.videoPackets.length));c(!!d)};a.flush=function(b){Z(function(){a.audioPackets.splice(0,a.audioPackets.length);a.videoPackets.splice(0,a.videoPackets.length);a._ogv_demuxer_flush()});b()};a.close=function(){};
|
||
|
|
||
|
|
||
|
return OGVDemuxerWebMW.ready
|
||
|
}
|
||
|
);
|
||
|
})();
|
||
|
if (typeof exports === 'object' && typeof module === 'object')
|
||
|
module.exports = OGVDemuxerWebMW;
|
||
|
else if (typeof define === 'function' && define['amd'])
|
||
|
define([], function() { return OGVDemuxerWebMW; });
|
||
|
else if (typeof exports === 'object')
|
||
|
exports["OGVDemuxerWebMW"] = OGVDemuxerWebMW;
|