updates
parent
5b291f4653
commit
42ed493db0
|
@ -0,0 +1 @@
|
|||
../auth/certs/
|
|
@ -1 +0,0 @@
|
|||
../../asm/generated/TeaWeb-Native.js
|
|
@ -0,0 +1 @@
|
|||
../../asm/generated/
|
|
@ -0,0 +1 @@
|
|||
../../../js/workers/WorkerCodec.js
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ class CodecWrapper extends BasicCodec {
|
|||
|
||||
initialise() : Promise<Boolean> {
|
||||
if(this._initializePromise) return this._initializePromise;
|
||||
console.log("INIT!");
|
||||
return this._initializePromise = this.spawnWorker().then(() => new Promise<Boolean>((resolve, reject) => {
|
||||
const token = this.generateToken();
|
||||
this.sendWorkerMessage({
|
||||
|
@ -90,7 +89,6 @@ class CodecWrapper extends BasicCodec {
|
|||
}
|
||||
|
||||
encode(data: AudioBuffer) : Promise<Uint8Array> {
|
||||
console.log(data);
|
||||
let token = this.generateToken();
|
||||
let result = new Promise<Uint8Array>((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<Boolean>((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));
|
||||
});
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "none",
|
||||
"target": "es6",
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"../node_modules",
|
||||
"../js/codec/workers"
|
||||
]
|
||||
}
|
94
js/load.ts
94
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!<br>Message: <code>" + message + "</code>", 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<Boolean>}[] {
|
||||
let result = [];
|
||||
|
@ -52,32 +105,28 @@ function formatPath(path: string | string[]) {
|
|||
} else return "<code>" + path + "</code>";
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
|
@ -54,3 +49,5 @@ function main() {
|
|||
Modals.spawnConnectModal(settings.static("default_connect_url"));
|
||||
}
|
||||
}
|
||||
|
||||
app.loadedListener.push(() => main());
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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":
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -7,7 +7,7 @@ class AudioResampler {
|
|||
}
|
||||
|
||||
resample(buffer: AudioBuffer) : Promise<AudioBuffer> {
|
||||
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<AudioBuffer>(resolve => resolve(buffer));
|
||||
|
||||
|
|
|
@ -7,33 +7,39 @@ class CodecPoolEntry {
|
|||
owner: number;
|
||||
|
||||
last_access: number;
|
||||
|
||||
private _initializePromise: Promise<Boolean>;
|
||||
}
|
||||
|
||||
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 + "<br>" +
|
||||
"Error: <code>" + JSON.stringify(error) + "</code>").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<BasicCodec | undefined> {
|
||||
return new Promise<BasicCodec>((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 => {
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
/// <reference path="CodecWorker.ts" />
|
||||
|
@ -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) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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
|
|
@ -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,CAAC;IAClB,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACvB,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IAEpB,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACnB,KAAK,YAAY;YACb,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,0BAA0B,GAAG,eAAe,CAAC,IAAI,CAAC,IAAuB,CAAC,CAAC,CAAC;YACjG,MAAM,CAAC,CAAC,IAAI,CAAC,IAAuB,CAAC,CAAC,CAAC;gBACnC,KAAK,eAAe,CAAC,WAAW;oBAC5B,aAAa,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;oBAC3G,KAAK,CAAC;gBAEV;oBACI,GAAG,CAAC,OAAO,GAAG,6BAA6B,CAAC;oBAC5C,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;oBAC9C,MAAM,CAAC;YACf,CAAC;YAED,aAAa,CAAC,UAAU,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AAW,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
|
@ -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));
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"OpusCodec.js","sourceRoot":"","sources":["OpusCodec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AAEvC,IAAI,CAAC,QAAQ,CAAC,GAAG,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,WAAW,CAAC,CAAC,CAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9E,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,MAAM,CAAC,sBAAsB,CAAC,GAAG;IAC7B,WAAW,GAAG,IAAI,CAAC;IACnB,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,cAAc,CAAC,CAAC;IAErC,WAAW,CAAC;QACR,KAAK,EAAE,mBAAmB;QAC1B,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,IAAI;KAChB,CAAC,CAAA;AACN,CAAC,CAAC;AAEF,2DAA2D;AAC3D,IAAI,CAAC;IACD,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,sBA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CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QACxH,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;YACb,MAAM,CAAC,4BAA4B,GAAG,MAAM,GAAG,GAAG,CAAC;QACvD,CAAC;QACD,IAAI,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC;QAClG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,KAAK;QACD,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,uBAAuB,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;CACJ"}
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue