From 42ed493db0d88b02bf5ba1eb9613bbee2c44b954 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Thu, 19 Apr 2018 18:42:34 +0200 Subject: [PATCH] updates --- enviroment/certs | 1 + enviroment/js/TeaWeb-Native.js | 1 - enviroment/js/assembly | 1 + enviroment/js/workers/WorkerCodec.js | 1 + js/chat.ts | 4 +- js/codec/CodecWrapper.ts | 13 ++-- js/codec/workers/tsconfig_base.json | 11 ---- js/load.ts | 94 ++++++++++++++++++++-------- js/main.ts | 9 +-- js/ui/client.ts | 2 +- js/ui/modal/ModalSettings.ts | 2 +- js/utils/modal.ts | 2 +- js/voice/AudioController.ts | 1 - js/voice/AudioResampler.ts | 2 +- js/voice/VoiceHandler.ts | 64 +++++++++---------- js/voice/VoiceRecorder.ts | 2 +- js/workers/WorkerCodec.js | 31 +++++++-- js/workers/WorkerCodec.js.map | 2 +- js/workers/codec/CodecWorker.js | 9 ++- js/workers/codec/CodecWorker.js.map | 2 +- js/workers/codec/CodecWorker.ts | 11 +++- js/workers/codec/OpusCodec.js | 22 ++++++- js/workers/codec/OpusCodec.js.map | 2 +- js/workers/codec/OpusCodec.ts | 24 +++++-- 24 files changed, 204 insertions(+), 109 deletions(-) create mode 120000 enviroment/certs delete mode 120000 enviroment/js/TeaWeb-Native.js create mode 120000 enviroment/js/assembly create mode 120000 enviroment/js/workers/WorkerCodec.js delete mode 100644 js/codec/workers/tsconfig_base.json diff --git a/enviroment/certs b/enviroment/certs new file mode 120000 index 00000000..41ddb150 --- /dev/null +++ b/enviroment/certs @@ -0,0 +1 @@ +../auth/certs/ \ No newline at end of file diff --git a/enviroment/js/TeaWeb-Native.js b/enviroment/js/TeaWeb-Native.js deleted file mode 120000 index aba02d8b..00000000 --- a/enviroment/js/TeaWeb-Native.js +++ /dev/null @@ -1 +0,0 @@ -../../asm/generated/TeaWeb-Native.js \ No newline at end of file diff --git a/enviroment/js/assembly b/enviroment/js/assembly new file mode 120000 index 00000000..023eba87 --- /dev/null +++ b/enviroment/js/assembly @@ -0,0 +1 @@ +../../asm/generated/ \ No newline at end of file diff --git a/enviroment/js/workers/WorkerCodec.js b/enviroment/js/workers/WorkerCodec.js new file mode 120000 index 00000000..bf84f6b8 --- /dev/null +++ b/enviroment/js/workers/WorkerCodec.js @@ -0,0 +1 @@ +../../../js/workers/WorkerCodec.js \ No newline at end of file diff --git a/js/chat.ts b/js/chat.ts index 3ddd1622..6d46b0a0 100644 --- a/js/chat.ts +++ b/js/chat.ts @@ -1,5 +1,3 @@ -import Key = JQuery.Key; - enum ChatType { GENERAL, SERVER, @@ -253,7 +251,7 @@ class ChatBox { this.htmlTag.find(".input button").click(this.onSend.bind(this)); this.htmlTag.find(".input_box").keypress(event => { - if(event.keyCode == Key.Enter && !event.shiftKey) { + if(event.keyCode == JQuery.Key.Enter && !event.shiftKey) { this.onSend(); return false; } diff --git a/js/codec/CodecWrapper.ts b/js/codec/CodecWrapper.ts index b3d994f4..77120a46 100644 --- a/js/codec/CodecWrapper.ts +++ b/js/codec/CodecWrapper.ts @@ -22,7 +22,6 @@ class CodecWrapper extends BasicCodec { initialise() : Promise { if(this._initializePromise) return this._initializePromise; - console.log("INIT!"); return this._initializePromise = this.spawnWorker().then(() => new Promise((resolve, reject) => { const token = this.generateToken(); this.sendWorkerMessage({ @@ -90,7 +89,6 @@ class CodecWrapper extends BasicCodec { } encode(data: AudioBuffer) : Promise { - console.log(data); let token = this.generateToken(); let result = new Promise((resolve, reject) => { this._workerListener.push( @@ -144,10 +142,12 @@ class CodecWrapper extends BasicCodec { } private sendWorkerMessage(message: any, transfare?: any[]) { + //console.log("Send worker: %o", message); this._worker.postMessage(JSON.stringify(message), transfare); } private onWorkerMessage(message: any) { + //console.log("Worker message: %o", message); if(!message["token"]) { console.error("Invalid worker token!"); return; @@ -155,7 +155,7 @@ class CodecWrapper extends BasicCodec { if(message["token"] == this._workerCallbackToken) { if(message["type"] == "loaded") { - console.log("Got loaded result: %o", message); + console.log("[Codec] Got worker init response: Success: %o Message: %o", message["success"], message["message"]); if(message["success"]) { if(this._workerCallbackResolve) this._workerCallbackResolve(); @@ -163,9 +163,11 @@ class CodecWrapper extends BasicCodec { if(this._workerCallbackReject) this._workerCallbackReject(message["message"]); } - console.log("Worker initialized!"); + this._workerCallbackReject = undefined; + this._workerCallbackResolve = undefined; + return; } - console.log("Callback data!"); + console.log("Costume callback! (%o)", message); return; } @@ -184,6 +186,7 @@ class CodecWrapper extends BasicCodec { return new Promise((resolve, reject) => { this._workerCallbackReject = reject; this._workerCallbackResolve = resolve; + this._worker = new Worker(settings.static("worker_directory", "js/workers/") + "WorkerCodec.js"); this._worker.onmessage = event => this.onWorkerMessage(JSON.parse(event.data)); }); diff --git a/js/codec/workers/tsconfig_base.json b/js/codec/workers/tsconfig_base.json deleted file mode 100644 index d938d42f..00000000 --- a/js/codec/workers/tsconfig_base.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "compilerOptions": { - "module": "none", - "target": "es6", - "sourceMap": true - }, - "exclude": [ - "../node_modules", - "../js/codec/workers" - ] -} \ No newline at end of file diff --git a/js/load.ts b/js/load.ts index 3609df27..70a413d3 100644 --- a/js/load.ts +++ b/js/load.ts @@ -1,12 +1,65 @@ -let moduleInitliaized = false; -let moduleInitliaizeListener: (() => any)[] = []; -if(typeof Module == "undefined") +namespace app { + export enum Type { + UNDEFINED, + RELEASE, + DEBUG + } + + let moduleInitialized: boolean; + let applicationLoaded: boolean; + export let type: Type = Type.UNDEFINED; + export let loadedListener: (() => any)[]; + + export function initialized() : boolean { + return moduleInitialized && applicationLoaded; + } + + export function callbackApp(errorMessage?: string) { + if(errorMessage) { + console.error("Could not load application!"); + } else { + applicationLoaded = true; + testInitialisation(); + } + } + + export function initialize() { + moduleInitialized = false; + applicationLoaded = false; + loadedListener = []; + + Module['onRuntimeInitialized'] = function() { + console.log("Runtime init!"); + moduleInitialized = true; + testInitialisation(); + }; + + Module['onAbort'] = message => { + Module['onAbort'] = undefined; + displayCriticalError("Could not load webassembly files!
Message: " + message + "", false); + }; + + Module['locateFile'] = file => { + console.log(file + "|" + type); + switch (type) { + case Type.RELEASE: + return "js/assembly/" + file; + case Type.DEBUG: + return "asm/generated/" + file; + } + }; + } + + function testInitialisation() { + if(moduleInitialized && applicationLoaded) + for(let l of loadedListener) + l(); + } +} +if(typeof Module === "undefined") this["Module"] = {}; -Module['onRuntimeInitialized'] = function() { - moduleInitliaized = true; - for(let l of moduleInitliaizeListener) - l(); -}; +app.initialize(); + function loadScripts(paths: (string | string[])[]) : {path: string, promise: Promise}[] { let result = []; @@ -52,32 +105,28 @@ function formatPath(path: string | string[]) { } else return "" + path + ""; } -function runApp() { - if(typeof(invokeMain) !== 'undefined') { - invokeMain(); - } else { - console.error("Could not resolve main function!"); - displayCriticalError("Could not resolve main function!"); - } -} - function loadRelease() { + app.type = app.Type.RELEASE; console.log("Load for release!"); awaitLoad(loadScripts([ //Load general API's + ["js/assembly/TeaWeb-Identity.js"], ["js/client.min.js", "js/client.js", "generated/js/client.min.js", "generated/js/client.js"] ])).then(() => { console.log("Loaded successfully all scripts!"); - runApp(); + app.callbackApp(); }).catch((error) => { console.error("Could not load " + error.path); }); } /** Only possible for developers! **/ function loadDebug() { + app.type = app.Type.DEBUG; console.log("Load for debug!"); awaitLoad(loadScripts([ + ["asm/generated/TeaWeb-Identity.js"], + //Load general API's "js/log.js", @@ -127,7 +176,7 @@ function loadDebug() { ])).then(() => { awaitLoad(loadScripts(["js/main.js"])).then(() => { console.log("Loaded successfully all scripts!"); - runApp(); + app.callbackApp(); }); }); } @@ -178,8 +227,6 @@ function loadTemplates() { tags = node.getElementsByTagName("body")[0].children; else tags = node.children; - console.log("Templates:"); - console.log(tags); let root = document.getElementById("templates"); while(tags.length > 0) @@ -198,13 +245,10 @@ function loadSide() { ["vendor/jquery/jquery.min.js", /*"https://code.jquery.com/jquery-latest.min.js"*/], ["https://webrtc.github.io/adapter/adapter-latest.js"] ])).then(() => awaitLoad(loadScripts([ - ["asm/generated/TeaWeb-Identity.js", "js/TeaWeb-Native.js"], ["https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"] ]))).then(() => { //Load the teaweb scripts - loadScript("js/proto.js").then(loadDebug).catch(error => { - loadRelease(); - }); + loadScript("js/proto.js").then(loadDebug).catch(loadRelease); //Load the teaweb templates loadTemplates(); }); diff --git a/js/main.ts b/js/main.ts index cd6d9d85..ab9a48e1 100644 --- a/js/main.ts +++ b/js/main.ts @@ -14,11 +14,6 @@ let chat: ChatBox; let forumIdentity: TeaForumIdentity; -function invokeMain() { - if(moduleInitliaized) main(); - else moduleInitliaizeListener.push(main); -} - function main() { //localhost:63343/Web-Client/index.php?disableUnloadDialog=1&default_connect_type=forum&default_connect_url=localhost AudioController.initializeAudioController(); @@ -53,4 +48,6 @@ function main() { } else Modals.spawnConnectModal(settings.static("default_connect_url")); } -} \ No newline at end of file +} + +app.loadedListener.push(() => main()); \ No newline at end of file diff --git a/js/ui/client.ts b/js/ui/client.ts index fb5ec9a5..755a608e 100644 --- a/js/ui/client.ts +++ b/js/ui/client.ts @@ -481,7 +481,7 @@ class LocalClientEntry extends ClientEntry { _self.renaming = true; elm.keypress(function (e) { - if(e.keyCode == Key.Enter) { + if(e.keyCode == JQuery.Key.Enter) { $(this).trigger("focusout"); return false; } diff --git a/js/ui/modal/ModalSettings.ts b/js/ui/modal/ModalSettings.ts index e342c1f0..094aca9b 100644 --- a/js/ui/modal/ModalSettings.ts +++ b/js/ui/modal/ModalSettings.ts @@ -49,7 +49,7 @@ namespace Modals { switch (this.value) { case "ppt": - let keyCode: number = parseInt(settings.global("vad_ppt_key", Key.T.toString())); + let keyCode: number = parseInt(settings.global("vad_ppt_key", JQuery.Key.T.toString())); tag.find(".vat_ppt_key").text(String.fromCharCode(keyCode)); break; case "vad": diff --git a/js/utils/modal.ts b/js/utils/modal.ts index 76aa2764..236cf660 100644 --- a/js/utils/modal.ts +++ b/js/utils/modal.ts @@ -158,7 +158,7 @@ function createInputModal(headMessage: BodyCreator, question: BodyCreator, valid footer.append(buttonOk); input.on("keydown", function (event) { - if(event.keyCode == Key.Enter) { + if(event.keyCode == JQuery.Key.Enter) { buttonOk.trigger("click"); } }); diff --git a/js/voice/AudioController.ts b/js/voice/AudioController.ts index b78c243c..3c39f607 100644 --- a/js/voice/AudioController.ts +++ b/js/voice/AudioController.ts @@ -105,7 +105,6 @@ class AudioController { if (buffer.sampleRate != this.speakerContext.sampleRate) console.warn("[AudioController] Source sample rate isn't equal to playback sample rate! (" + buffer.sampleRate + " | " + this.speakerContext.sampleRate + ")"); - console.log("%o", buffer); this.applayVolume(buffer); this.audioCache.push(buffer); if(this.playerState == PlayerState.STOPPED || this.playerState == PlayerState.STOPPING) { diff --git a/js/voice/AudioResampler.ts b/js/voice/AudioResampler.ts index d92686e0..3424908e 100644 --- a/js/voice/AudioResampler.ts +++ b/js/voice/AudioResampler.ts @@ -7,7 +7,7 @@ class AudioResampler { } resample(buffer: AudioBuffer) : Promise { - console.log("Encode from %i to %i", buffer.sampleRate, this.targetSampleRate); + //console.log("Encode from %i to %i", buffer.sampleRate, this.targetSampleRate); if(buffer.sampleRate == this.targetSampleRate) return new Promise(resolve => resolve(buffer)); diff --git a/js/voice/VoiceHandler.ts b/js/voice/VoiceHandler.ts index 3c3a7e08..576b9b3e 100644 --- a/js/voice/VoiceHandler.ts +++ b/js/voice/VoiceHandler.ts @@ -7,33 +7,39 @@ class CodecPoolEntry { owner: number; last_access: number; - - private _initializePromise: Promise; } class CodecPool { handle: VoiceConnection; codecIndex: number; + name: string; creator: () => BasicCodec; entries: CodecPoolEntry[] = []; maxInstances: number = 2; + private _supported: boolean = true; + initialize(cached: number) { for(let i = 0; i < cached; i++) this.ownCodec(i + 1).then(codec => { console.log("Release again! (%o)", codec); this.releaseCodec(i + 1); - }).catch(errror => { - console.error(errror); + }).catch(error => { + if(this._supported) { + createErrorModal("Could not load codec driver", "Could not load or initialize codec " + this.name + "
" + + "Error: " + JSON.stringify(error) + "").open(); + } + this._supported = false; + console.error(error); }); } - supported() { return this.creator != undefined; } + supported() { return this.creator != undefined && this._supported; } ownCodec?(clientId: number, create: boolean = true) : Promise { return new Promise((resolve, reject) => { - if(!this.creator) { + if(!this.creator || !this._supported) { reject("unsupported codec!"); return; } @@ -43,13 +49,16 @@ class CodecPool { if(this.entries[index].owner == clientId) { this.entries[index].last_access = new Date().getTime(); if(this.entries[index].instance.initialized()) resolve(this.entries[index].instance); - else resolve(this.entries[index].instance.initialise().catch(error => { - console.error("Could not initialize codec!\nError: %o", error); - reject("Could not initialize codec!"); - }).then((flag) => { - //TODO test success flag - return this.ownCodec(clientId, false); - })); + else { + this.entries[index].instance.initialise().then((flag) => { + //TODO test success flag + console.error(flag); + this.ownCodec(clientId, false).then(resolve).catch(reject); + }).catch(error => { + console.error("Could not initialize codec!\nError: %o", error); + reject("Could not initialize codec!"); + }); + } return; } else if(freeSlot == 0 && this.entries[index].owner == 0) { freeSlot = index; @@ -73,7 +82,7 @@ class CodecPool { if(this.entries[freeSlot].instance.initialized()) this.entries[freeSlot].instance.reset(); else { - resolve(this.ownCodec(clientId, false)); + this.ownCodec(clientId, false).then(resolve).catch(reject); return; } resolve(this.entries[freeSlot].instance); @@ -81,15 +90,15 @@ class CodecPool { } releaseCodec(clientId: number) { - for(let index = 0; index < this.entries.length; index++) { + for(let index = 0; index < this.entries.length; index++) if(this.entries[index].owner == clientId) this.entries[index].owner = 0; - } } - constructor(handle: VoiceConnection, index: number, creator: () => BasicCodec){ + constructor(handle: VoiceConnection, index: number, name: string, creator: () => BasicCodec){ this.creator = creator; this.handle = handle; this.codecIndex = index; + this.name = name; } } @@ -101,14 +110,12 @@ class VoiceConnection { voiceRecorder: VoiceRecorder; private codecPool: CodecPool[] = [ - new CodecPool(this,0,undefined), //Spex - new CodecPool(this,1,undefined), //Spex - new CodecPool(this,2,undefined), //Spex - new CodecPool(this,3,undefined), //CELT Mono - new CodecPool(this,4,() => { return new CodecWrapper(CodecWorkerType.WORKER_OPUS, 1) }), //opus voice - new CodecPool(this,5,() => { return new CodecWrapper(CodecWorkerType.WORKER_OPUS, 2) }) //opus music - - //FIXME Why is it at index 5 currently only 1? + new CodecPool(this,0,"Spex A", undefined), //Spex + new CodecPool(this,1,"Spex B", undefined), //Spex + new CodecPool(this,2,"Spex C", undefined), //Spex + new CodecPool(this,3,"CELT Mono", undefined), //CELT Mono + new CodecPool(this,4,"Opus Voice", () => { return new CodecWrapper(CodecWorkerType.WORKER_OPUS, 1) }), //opus voice + new CodecPool(this,5,"Opus Music", () => { return new CodecWrapper(CodecWorkerType.WORKER_OPUS, 2) }) //opus music ]; private vpacketId: number = 0; @@ -241,13 +248,6 @@ class VoiceConnection { .then(buffer => client.getAudioController().playBuffer(buffer)).catch(error => { console.error("Could not playback client's (" + clientId + ") audio (" + error + ")"); }); - /* - let decoder = codecPool.ownCodec(clientId); - decoder.decodeSamples(client.getAudioController().codecCache(codec), encodedData).then(buffer => { - client.getAudioController().playBuffer(buffer); - }).catch(error => { - }); - */ } } diff --git a/js/voice/VoiceRecorder.ts b/js/voice/VoiceRecorder.ts index be70d4a7..3ba91b1f 100644 --- a/js/voice/VoiceRecorder.ts +++ b/js/voice/VoiceRecorder.ts @@ -93,7 +93,7 @@ class VoiceRecorder { reinitialiseVAD() { let type = settings.global("vad_type", "vad"); if(type == "ppt") { - let keyCode: number = parseInt(settings.global("vad_ppt_key", Key.T.toString())); + let keyCode: number = parseInt(settings.global("vad_ppt_key", JQuery.Key.T.toString())); if(!(this.getVADHandler() instanceof PushToTalkVAD)) this.setVADHander(new PushToTalkVAD(keyCode)); else (this.getVADHandler() as PushToTalkVAD).key = keyCode; diff --git a/js/workers/WorkerCodec.js b/js/workers/WorkerCodec.js index f5518230..65965b39 100644 --- a/js/workers/WorkerCodec.js +++ b/js/workers/WorkerCodec.js @@ -10,6 +10,7 @@ onmessage = function (e) { let res = {}; res.token = data.token; res.success = false; + //console.log(prefix + " Got from main: %o", data); switch (data.command) { case "initialise": console.log(prefix + "Got initialize for type " + CodecWorkerType[data.type]); @@ -22,8 +23,11 @@ onmessage = function (e) { console.error("Could not resolve opus type!"); return; } - codecInstance.initialise(); - res["success"] = true; + let error = codecInstance.initialise(); + if (error) + res["message"] = error; + else + res["success"] = true; break; case "encodeSamples": let encodeArray = new Float32Array(data.dataLength); @@ -63,6 +67,7 @@ onmessage = function (e) { sendMessage(res, e.origin); }; function sendMessage(message, origin) { + //console.log(prefix + " Send to main: %o", message); postMessage(JSON.stringify(message)); } /// @@ -77,15 +82,30 @@ Module['onRuntimeInitialized'] = function () { success: true }); }; -//let Module = typeof Module !== 'undefined' ? Module : {}; +Module['onAbort'] = message => { + Module['onAbort'] = undefined; + sendMessage({ + token: workerCallbackToken, + type: "loaded", + success: false, + message: message + }); +}; try { Module['locateFile'] = file => "../../asm/generated/" + file; importScripts("../../asm/generated/TeaWeb-Worker-Codec-Opus.js"); } catch (e) { - console.error("Could not load native script!"); - console.log(e); + try { + Module['locateFile'] = file => "../assembly/" + file; + importScripts("../assembly/TeaWeb-Worker-Codec-Opus.js"); + } + catch (e) { + console.log(e); + Module['onAbort']("Cloud not load native script!"); + } } +//let Module = typeof Module !== 'undefined' ? Module : {}; var OpusType; (function (OpusType) { OpusType[OpusType["VOIP"] = 2048] = "VOIP"; @@ -112,6 +132,7 @@ class OpusWorker { this.encodeBuffer = new Float32Array(Module.HEAPF32.buffer, this.encodeBufferRaw, this.bufferSize / 4); this.decodeBufferRaw = Module._malloc(this.bufferSize); this.decodeBuffer = new Uint8Array(Module.HEAPU8.buffer, this.decodeBufferRaw, this.bufferSize); + return undefined; } deinitialise() { } //TODO decode(data) { diff --git a/js/workers/WorkerCodec.js.map b/js/workers/WorkerCodec.js.map index d2718eca..0cfca22d 100644 --- a/js/workers/WorkerCodec.js.map +++ b/js/workers/WorkerCodec.js.map @@ -1 +1 @@ -{"version":3,"file":"WorkerCodec.js","sourceRoot":"","sources":["codec/CodecWorker.ts","codec/OpusCodec.ts"],"names":[],"mappings":"AAAA,MAAM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,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;CACJ"} \ No newline at end of file diff --git a/js/workers/codec/CodecWorker.js b/js/workers/codec/CodecWorker.js index ab2bad6b..6fa4c694 100644 --- a/js/workers/codec/CodecWorker.js +++ b/js/workers/codec/CodecWorker.js @@ -10,6 +10,7 @@ onmessage = function (e) { let res = {}; res.token = data.token; res.success = false; + //console.log(prefix + " Got from main: %o", data); switch (data.command) { case "initialise": console.log(prefix + "Got initialize for type " + CodecWorkerType[data.type]); @@ -22,8 +23,11 @@ onmessage = function (e) { console.error("Could not resolve opus type!"); return; } - codecInstance.initialise(); - res["success"] = true; + let error = codecInstance.initialise(); + if (error) + res["message"] = error; + else + res["success"] = true; break; case "encodeSamples": let encodeArray = new Float32Array(data.dataLength); @@ -63,6 +67,7 @@ onmessage = function (e) { sendMessage(res, e.origin); }; function sendMessage(message, origin) { + //console.log(prefix + " Send to main: %o", message); postMessage(JSON.stringify(message)); } //# sourceMappingURL=CodecWorker.js.map \ No newline at end of file diff --git a/js/workers/codec/CodecWorker.js.map b/js/workers/codec/CodecWorker.js.map index d3d11a63..c45edc61 100644 --- a/js/workers/codec/CodecWorker.js.map +++ b/js/workers/codec/CodecWorker.js.map @@ -1 +1 @@ -{"version":3,"file":"CodecWorker.js","sourceRoot":"","sources":["CodecWorker.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,gBAAgB,CAAC;AAChC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAY7C,IAAK,eAEJ;AAFD,WAAK,eAAe;IAChB,mEAAW,CAAA;AACf,CAAC,EAFI,eAAe,KAAf,eAAe,QAEnB;AAED,IAAI,aAA0B,CAAC;AAE/B,SAAS,GAAG,UAAS,CAAC;IAClB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAE9B,IAAI,GAAG,GAAQ,EAAE,CAA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C,WAAW,CAAC,CAAC;YAErD,EAAE,CAAA,CAAC,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC;gBAClC,GAAG,CAAC,OAAO,GAAG,YAAY,CAAC;YAC/B,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;gBACnB,GAAG,CAAC,IAAI,GAAG,YAAY,CAAC;gBACxB,GAAG,CAAC,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC;YACzC,CAAC;YACD,KAAK,CAAC;QACV,KAAK,OAAO;YACR,aAAa,CAAC,KAAK,EAAE,CAAC;YACtB,KAAK,CAAC;QACV;YACI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED,EAAE,CAAA,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC,CAAC;AAGF,qBAAqB,OAAY,EAAE,MAAe;IAC9C,qDAAqD;IACrD,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;AACzC,CAAC"} \ No newline at end of file diff --git a/js/workers/codec/CodecWorker.ts b/js/workers/codec/CodecWorker.ts index 4b93e09a..4bba3b15 100644 --- a/js/workers/codec/CodecWorker.ts +++ b/js/workers/codec/CodecWorker.ts @@ -3,7 +3,7 @@ const workerCallbackToken = "callback_token"; interface CodecWorker { name(); - initialise(); + initialise?() : string; deinitialise(); decode(data: Uint8Array); encode(data: Float32Array) : Uint8Array | string; @@ -24,6 +24,7 @@ onmessage = function(e) { res.token = data.token; res.success = false; + //console.log(prefix + " Got from main: %o", data); switch (data.command) { case "initialise": console.log(prefix + "Got initialize for type " + CodecWorkerType[data.type as CodecWorkerType]); @@ -38,8 +39,11 @@ onmessage = function(e) { return; } - codecInstance.initialise(); - res["success"] = true; + let error = codecInstance.initialise(); + if(error) + res["message"] = error; + else + res["success"] = true; break; case "encodeSamples": let encodeArray = new Float32Array(data.dataLength); @@ -83,5 +87,6 @@ onmessage = function(e) { declare function postMessage(message: any): void; function sendMessage(message: any, origin?: string){ + //console.log(prefix + " Send to main: %o", message); postMessage(JSON.stringify(message)); } \ No newline at end of file diff --git a/js/workers/codec/OpusCodec.js b/js/workers/codec/OpusCodec.js index 43ebcbe0..2d40a900 100644 --- a/js/workers/codec/OpusCodec.js +++ b/js/workers/codec/OpusCodec.js @@ -10,15 +10,30 @@ Module['onRuntimeInitialized'] = function () { success: true }); }; -//let Module = typeof Module !== 'undefined' ? Module : {}; +Module['onAbort'] = message => { + Module['onAbort'] = undefined; + sendMessage({ + token: workerCallbackToken, + type: "loaded", + success: false, + message: message + }); +}; try { Module['locateFile'] = file => "../../asm/generated/" + file; importScripts("../../asm/generated/TeaWeb-Worker-Codec-Opus.js"); } catch (e) { - console.error("Could not load native script!"); - console.log(e); + try { + Module['locateFile'] = file => "../assembly/" + file; + importScripts("../assembly/TeaWeb-Worker-Codec-Opus.js"); + } + catch (e) { + console.log(e); + Module['onAbort']("Cloud not load native script!"); + } } +//let Module = typeof Module !== 'undefined' ? Module : {}; var OpusType; (function (OpusType) { OpusType[OpusType["VOIP"] = 2048] = "VOIP"; @@ -45,6 +60,7 @@ class OpusWorker { this.encodeBuffer = new Float32Array(Module.HEAPF32.buffer, this.encodeBufferRaw, this.bufferSize / 4); this.decodeBufferRaw = Module._malloc(this.bufferSize); this.decodeBuffer = new Uint8Array(Module.HEAPU8.buffer, this.decodeBufferRaw, this.bufferSize); + return undefined; } deinitialise() { } //TODO decode(data) { diff --git a/js/workers/codec/OpusCodec.js.map b/js/workers/codec/OpusCodec.js.map index d1b07bcf..3780dc7c 100644 --- a/js/workers/codec/OpusCodec.js.map +++ b/js/workers/codec/OpusCodec.js.map @@ -1 +1 @@ -{"version":3,"file":"OpusC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644 --- a/js/workers/codec/OpusCodec.ts +++ b/js/workers/codec/OpusCodec.ts @@ -12,15 +12,30 @@ Module['onRuntimeInitialized'] = function() { success: true }) }; +Module['onAbort'] = message => { + Module['onAbort'] = undefined; + + sendMessage({ + token: workerCallbackToken, + type: "loaded", + success: false, + message: message + }); +}; -//let Module = typeof Module !== 'undefined' ? Module : {}; try { Module['locateFile'] = file => "../../asm/generated/" + file; importScripts("../../asm/generated/TeaWeb-Worker-Codec-Opus.js"); } catch (e) { - console.error("Could not load native script!"); - console.log(e); + try { + Module['locateFile'] = file => "../assembly/" + file; + importScripts("../assembly/TeaWeb-Worker-Codec-Opus.js"); + } catch (e) { + console.log(e); + Module['onAbort']("Cloud not load native script!"); + } } +//let Module = typeof Module !== 'undefined' ? Module : {}; enum OpusType { VOIP = 2048, @@ -53,7 +68,7 @@ class OpusWorker implements CodecWorker { return "Opus (Type: " + OpusWorker[this.type] + " Channels: " + this.channelCount + ")"; } - initialise() { + initialise?() : string { this.fn_newHandle = Module.cwrap("codec_opus_createNativeHandle", "pointer", ["number", "number"]); this.fn_decode = Module.cwrap("codec_opus_decode", "number", ["pointer", "pointer", "number", "number"]); /* codec_opus_decode(handle, buffer, length, maxlength) */ @@ -67,6 +82,7 @@ class OpusWorker implements CodecWorker { this.decodeBufferRaw = Module._malloc(this.bufferSize); this.decodeBuffer = new Uint8Array(Module.HEAPU8.buffer, this.decodeBufferRaw, this.bufferSize); + return undefined; } deinitialise() { } //TODO