@4players/odin-plugin-web 1.0.0-alpha.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4players/odin-plugin-web",
3
- "version": "1.0.0-alpha.8",
3
+ "version": "1.0.0",
4
4
  "description": "A backend plugin providing the custom WebAssembly audio processing module for ODIN web clients",
5
5
  "homepage": "https://www.4players.io",
6
6
  "repository": {
@@ -8,40 +8,49 @@
8
8
  "url": "https://github.com/4Players/odin-sdk-web.git"
9
9
  },
10
10
  "license": "UNLICENSED",
11
- "main": "lib/plugin/index.js",
12
- "types": "lib/plugin/index.d.ts",
11
+ "main": "./lib/plugin/index.js",
12
+ "types": "./lib/plugin/index.d.ts",
13
13
  "scripts": {
14
- "clean": "rm -rf build lib",
15
- "configure": "emcmake cmake -B build -S .",
16
- "build": "npm-run-all -s configure build:wasm build:plugin build:worker",
17
- "build:plugin": "tsc",
18
- "build:wasm": "emmake make -C build",
19
- "build:worker": "ts-node src/build.ts && tsc -b ./tsconfig.worker.json",
20
- "lint": "eslint . --ext .ts",
21
- "test": "npm --prefix test run serve"
14
+ "clean": "rimraf .cache build lib dist",
15
+ "configure": "npm-run-all configure:*",
16
+ "configure:shared": "emcmake cmake -B build/shared -DCMAKE_BUILD_TYPE=Release -DSHARED_MEMORY=1 -S .",
17
+ "configure:unshared": "emcmake cmake -B build/unshared -DCMAKE_BUILD_TYPE=Release -S .",
18
+ "build": "npm-run-all -s configure build:genversion build:wasm build:bundle build:types",
19
+ "bundle": "npm run build && tsx ./esbuild.config.ts",
20
+ "build:genversion": "genversion -se src/common/version.ts",
21
+ "build:wasm": "npm-run-all -pl build:wasm:*",
22
+ "build:wasm:shared": "emmake cmake --build build/shared -j 8",
23
+ "build:wasm:unshared": "emmake cmake --build build/unshared -j 8",
24
+ "build:bundle": "ts-node src/bundle.ts",
25
+ "build:types": "dts-bundle-generator --fail-on-class --no-banner -o lib/plugin/index.d.ts src/plugin/index.ts",
26
+ "test": "npm-run-all -s test:*",
27
+ "test:install": "npm --prefix test install",
28
+ "test:start": "npm --prefix test start",
29
+ "format": "prettier 'src/**/*.ts' --write",
30
+ "lint": "eslint . --ext .ts"
22
31
  },
23
32
  "dependencies": {
24
- "@4players/odin-common": "~1.3.0",
25
- "@msgpack/msgpack": "~3.0.0-beta2",
26
- "uuid": "~9.0.0",
27
- "zod": "~3.22.0"
33
+ "@4players/odin-common": "~7.3.0",
34
+ "@4players/voice-filter": "~1.2.0",
35
+ "@msgpack/msgpack": "~3.1.0"
28
36
  },
29
37
  "devDependencies": {
30
- "@types/node": "~20.10.0",
31
- "@types/uuid": "~9.0.0",
32
- "@typescript-eslint/eslint-plugin": "~6.18.0",
33
- "@typescript-eslint/parser": "~6.18.0",
34
- "esbuild": "~0.19.0",
35
- "eslint": "~8.56.0",
38
+ "@types/node": "~22.16.0",
39
+ "@typescript-eslint/eslint-plugin": "~8.36.0",
40
+ "@typescript-eslint/parser": "~8.36.0",
41
+ "dts-bundle-generator": "~9.5.0",
42
+ "esbuild": "~0.25.0",
43
+ "eslint": "~8.57.0",
36
44
  "eslint-config-semistandard": "~17.0.0",
37
- "eslint-plugin-import": "~2.29.0",
45
+ "eslint-plugin-import": "~2.32.0",
38
46
  "eslint-plugin-node": "~11.1.0",
39
- "eslint-plugin-promise": "~6.1.0",
40
- "npm-run-all2": "~6.1.0",
47
+ "eslint-plugin-promise": "~6.6.0",
48
+ "genversion": "~3.2.0",
49
+ "npm-run-all2": "~8.0.0",
50
+ "prettier": "~3.6.0",
51
+ "rimraf": "~6.0.0",
41
52
  "ts-node": "~10.9.0",
42
- "typescript": "~5.3.0"
43
- },
44
- "workspaces": [
45
- "test"
46
- ]
53
+ "tsx": "^4.19.4",
54
+ "typescript": "~5.6.0"
55
+ }
47
56
  }
@@ -1,102 +0,0 @@
1
- import { Backend, Strand } from '@4players/odin-common';
2
- import { DeviceParameters } from '.';
3
- import { CaptureSink, PlaybackId, PlaybackWorker } from '../worker';
4
- import { RoomConnection } from './roomConnection';
5
- export type Volume = Backend.Volume;
6
- export type Activity = Backend.Activity;
7
- export type CreateAudioPlaybackParameters = Backend.CreateAudioPlaybackParameters;
8
- export type CreateAudioCaptureParameters = Backend.CreateAudioCaptureParameters & {
9
- readonly device?: Device;
10
- };
11
- export type AudioContextFactory = (sampleRate: number | undefined) => Promise<AudioContext>;
12
- export interface GlobalMediaId extends PlaybackId {
13
- }
14
- declare global {
15
- interface AudioSinkOptions {
16
- type: 'none';
17
- }
18
- interface AudioContext {
19
- setSinkId?: (sinkId: string | undefined | AudioSinkOptions) => Promise<undefined>;
20
- }
21
- }
22
- export declare class AudioContextCollection {
23
- readonly audioContextFactory: AudioContextFactory;
24
- readonly entries: Array<{
25
- sampleRate: undefined | number;
26
- audioContext: AudioContext;
27
- references: number;
28
- }>;
29
- constructor(audioContextFactory: AudioContextFactory);
30
- acquire(sampleRate: number | undefined): Promise<AudioContext>;
31
- release(audioContext: BaseAudioContext): Promise<void>;
32
- close(): void;
33
- }
34
- export declare class AudioController {
35
- readonly audioContexts: AudioContextCollection;
36
- readonly sink: CaptureSink;
37
- playbackWorker: PlaybackWorker | undefined;
38
- globalVolume: number;
39
- playbacks: Map<string, {
40
- id: GlobalMediaId | undefined;
41
- volume: Volume;
42
- playback: AudioPlayback;
43
- }>;
44
- setPlaybackStrand: Strand;
45
- create(audioContexts: AudioContextCollection, sink: CaptureSink): Promise<AudioController>;
46
- constructor(audioContexts: AudioContextCollection, sink: CaptureSink);
47
- receivePacket(connectionId: number, packet: Uint8Array): void;
48
- createAudioPlayback(parameters: CreateAudioPlaybackParameters): Promise<AudioPlayback>;
49
- createAudioCapture(parameters: CreateAudioCaptureParameters): Promise<AudioCapture>;
50
- enumerateDevices(): Promise<Device[]>;
51
- playbackSetDevice(device?: Device): Promise<void>;
52
- playbackSetGlobalVolume(value: Backend.Volume): void;
53
- playbackStart(uid: string, id: GlobalMediaId): void;
54
- playbackStop(uid: string, id: GlobalMediaId): void;
55
- playbackGetActivity(uid: string): Activity;
56
- playbackSetVolume(uid: string, volume: Volume): void;
57
- playbackGetVolume(uid: string): Volume;
58
- closePlayback(uid: string): void;
59
- close(): void;
60
- }
61
- export declare class Device implements Backend.Device {
62
- readonly device: MediaDeviceInfo;
63
- readonly isDefault: boolean;
64
- constructor(device: MediaDeviceInfo, isDefault?: boolean);
65
- get type(): "AudioPlayback" | "AudioCapture";
66
- get name(): string;
67
- }
68
- export declare class AudioPlayback implements Backend.AudioPlayback {
69
- readonly controller: AudioController;
70
- readonly uid: Backend.UID;
71
- get volume(): Backend.Volume;
72
- get activity(): Backend.Activity;
73
- constructor(controller: AudioController, uid: Backend.UID);
74
- start(id: GlobalMediaId): void;
75
- stop(id: GlobalMediaId): void;
76
- setVolume(value: Backend.Volume): void;
77
- close(): void;
78
- }
79
- export declare class AudioCapture implements Backend.AudioCapture {
80
- readonly controller: AudioController;
81
- private _Capture;
82
- private readonly _Medias;
83
- private _Vad;
84
- private _Apm;
85
- private _Volume;
86
- private _deviceParameters?;
87
- get vad(): Backend.VadConfig;
88
- get apm(): Backend.ApmConfig;
89
- get volume(): Backend.Volume;
90
- get activity(): import("../worker").Activity;
91
- get speechProbability(): number;
92
- constructor(controller: AudioController, parameters: CreateAudioCaptureParameters);
93
- start(room: RoomConnection, media: GlobalMediaId, uid: Backend.UID): void;
94
- stop(room: RoomConnection, media: GlobalMediaId): void;
95
- setVad(value: Backend.VadConfig): void;
96
- setApm(config: Backend.ApmConfig): Promise<void>;
97
- setDevice(parameters: DeviceParameters): Promise<import("@4players/odin-common").Success<void> | undefined>;
98
- setVolume(value: Backend.Volume): void;
99
- close(): void;
100
- _UpdateMedias(): Promise<void>;
101
- }
102
- //# sourceMappingURL=audioController.d.ts.map
@@ -1,442 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { Strand, assert, failure, sleep, success, } from '@4players/odin-common';
11
- import { createCaptureWorker, createPlaybackWorker, silence, } from '../worker';
12
- const defaultVad = {
13
- voiceActivity: {
14
- attackThreshold: 0.9,
15
- releaseThreshold: 0.8,
16
- },
17
- volumeGate: {
18
- attackThreshold: -30,
19
- releaseThreshold: -40,
20
- },
21
- };
22
- const defaultApm = {
23
- echoCanceller: false,
24
- highPassFilter: false,
25
- preAmplifier: false,
26
- captureLevelAdjustment: false,
27
- noiseSuppression: 'None',
28
- transientSuppressor: false,
29
- gainController: false,
30
- };
31
- export class AudioContextCollection {
32
- constructor(audioContextFactory) {
33
- this.audioContextFactory = audioContextFactory;
34
- this.entries = [];
35
- }
36
- acquire(sampleRate) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- for (const entry of this.entries) {
39
- if (entry.sampleRate === sampleRate) {
40
- entry.references += 1;
41
- return entry.audioContext;
42
- }
43
- else if (entry.sampleRate === undefined) {
44
- const audioContext = entry.audioContext;
45
- if (audioContext.sampleRate === sampleRate) {
46
- entry.references += 1;
47
- return entry.audioContext;
48
- }
49
- }
50
- }
51
- const entry = {
52
- sampleRate,
53
- audioContext: yield this.audioContextFactory(sampleRate),
54
- references: 1,
55
- };
56
- this.entries.push(entry);
57
- return entry.audioContext;
58
- });
59
- }
60
- release(audioContext) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- const index = this.entries.findIndex((entry) => entry.audioContext === audioContext);
63
- if (index < 0)
64
- return;
65
- this.entries[index].references -= 1;
66
- if (this.entries[index].references <= 0) {
67
- const context = this.entries[index].audioContext;
68
- this.entries.splice(index, 1);
69
- yield context.close();
70
- }
71
- });
72
- }
73
- close() {
74
- for (const entry of this.entries) {
75
- entry.audioContext.close();
76
- }
77
- }
78
- }
79
- export class AudioController {
80
- create(audioContexts, sink) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- return new AudioController(audioContexts, sink);
83
- });
84
- }
85
- constructor(audioContexts, sink) {
86
- this.audioContexts = audioContexts;
87
- this.sink = sink;
88
- this.globalVolume = 1;
89
- this.playbacks = new Map();
90
- this.setPlaybackStrand = new Strand();
91
- }
92
- receivePacket(connectionId, packet) {
93
- var _a;
94
- (_a = this.playbackWorker) === null || _a === void 0 ? void 0 : _a.receivePacket(connectionId, packet);
95
- }
96
- createAudioPlayback(parameters) {
97
- return __awaiter(this, void 0, void 0, function* () {
98
- let entry = this.playbacks.get(parameters.uid);
99
- let volume = parameters.volume;
100
- if (entry === undefined) {
101
- volume = volume !== null && volume !== void 0 ? volume : 1;
102
- const playback = new AudioPlayback(this, parameters.uid);
103
- entry = { id: undefined, volume, playback };
104
- this.playbacks.set(parameters.uid, entry);
105
- }
106
- if (volume !== undefined) {
107
- entry.playback.setVolume(volume);
108
- }
109
- return entry.playback;
110
- });
111
- }
112
- createAudioCapture(parameters) {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- const capture = new AudioCapture(this, parameters);
115
- yield capture.setDevice(parameters);
116
- return capture;
117
- });
118
- }
119
- enumerateDevices() {
120
- return __awaiter(this, void 0, void 0, function* () {
121
- const mediaDeviceInfos = yield navigator.mediaDevices.enumerateDevices();
122
- const devices = [];
123
- let outputDeviceIndex = 0;
124
- let inputDeviceIndex = 0;
125
- for (const mediaDeviceInfo of mediaDeviceInfos) {
126
- if (mediaDeviceInfo.kind === 'audioinput') {
127
- if (inputDeviceIndex === 0) {
128
- devices.push(new Device(mediaDeviceInfo, true));
129
- }
130
- else {
131
- devices.push(new Device(mediaDeviceInfo, false));
132
- }
133
- inputDeviceIndex++;
134
- }
135
- if (mediaDeviceInfo.kind === 'audiooutput') {
136
- if (outputDeviceIndex === 0) {
137
- devices.push(new Device(mediaDeviceInfo, true));
138
- }
139
- else {
140
- devices.push(new Device(mediaDeviceInfo, false));
141
- }
142
- outputDeviceIndex++;
143
- }
144
- }
145
- return devices;
146
- });
147
- }
148
- playbackSetDevice(device) {
149
- return this.setPlaybackStrand.enqueue(() => __awaiter(this, void 0, void 0, function* () {
150
- var _a;
151
- let deviceId = (_a = device === null || device === void 0 ? void 0 : device.device.deviceId) !== null && _a !== void 0 ? _a : '';
152
- if (deviceId === 'default') {
153
- deviceId = '';
154
- }
155
- let audioContext;
156
- if (this.playbackWorker === undefined) {
157
- audioContext = yield this.audioContexts.acquire(48000);
158
- this.playbackWorker = yield createPlaybackWorker(audioContext);
159
- this.playbackWorker.setGlobalVolume(this.globalVolume);
160
- }
161
- else {
162
- audioContext = this.playbackWorker.audioContext;
163
- }
164
- if (audioContext.setSinkId !== undefined && device && audioContext.state === 'running') {
165
- yield audioContext.setSinkId(deviceId);
166
- }
167
- }));
168
- }
169
- playbackSetGlobalVolume(value) {
170
- var _a;
171
- this.globalVolume = value === 'muted' ? 0 : value;
172
- (_a = this.playbackWorker) === null || _a === void 0 ? void 0 : _a.setGlobalVolume(this.globalVolume);
173
- }
174
- playbackStart(uid, id) {
175
- var _a;
176
- const entry = this.playbacks.get(uid);
177
- if (entry === undefined)
178
- return;
179
- if (entry.id !== undefined) {
180
- this.playbackStop(uid, entry.id);
181
- }
182
- entry.id = id;
183
- (_a = this.playbackWorker) === null || _a === void 0 ? void 0 : _a.addMedias(id.connectionId, [id.mediaId]);
184
- this.playbackSetVolume(uid, entry.volume);
185
- }
186
- playbackStop(uid, id) {
187
- var _a;
188
- const entry = this.playbacks.get(uid);
189
- if (entry === undefined)
190
- return;
191
- if (entry.id !== id)
192
- console.error('playback mediaId out of sync!');
193
- entry.id = undefined;
194
- (_a = this.playbackWorker) === null || _a === void 0 ? void 0 : _a.removeMedias(id.connectionId, [id.mediaId]);
195
- }
196
- playbackGetActivity(uid) {
197
- var _a, _b;
198
- const entry = this.playbacks.get(uid);
199
- if ((entry === null || entry === void 0 ? void 0 : entry.id) === undefined)
200
- return silence;
201
- return (_b = (_a = this.playbackWorker) === null || _a === void 0 ? void 0 : _a.getActivity(entry.id)) !== null && _b !== void 0 ? _b : silence;
202
- }
203
- playbackSetVolume(uid, volume) {
204
- var _a;
205
- const entry = this.playbacks.get(uid);
206
- if (entry === undefined)
207
- return;
208
- entry.volume = volume === 'muted' ? 0 : volume;
209
- if (entry.id !== undefined) {
210
- (_a = this.playbackWorker) === null || _a === void 0 ? void 0 : _a.setVolume(entry.id, entry.volume);
211
- }
212
- }
213
- playbackGetVolume(uid) {
214
- var _a;
215
- const entry = this.playbacks.get(uid);
216
- return (_a = entry === null || entry === void 0 ? void 0 : entry.volume) !== null && _a !== void 0 ? _a : 1;
217
- }
218
- closePlayback(uid) {
219
- const entry = this.playbacks.get(uid);
220
- if (entry === undefined)
221
- return;
222
- if (entry.id !== undefined)
223
- this.playbackStop(uid, entry.id);
224
- this.playbacks.delete(uid);
225
- }
226
- close() {
227
- var _a;
228
- (_a = this.playbackWorker) === null || _a === void 0 ? void 0 : _a.close();
229
- this.audioContexts.close();
230
- }
231
- }
232
- export class Device {
233
- constructor(device, isDefault = false) {
234
- this.device = device;
235
- this.isDefault = isDefault;
236
- }
237
- get type() {
238
- switch (this.device.kind) {
239
- case 'audioinput':
240
- return 'AudioCapture';
241
- case 'audiooutput':
242
- return 'AudioPlayback';
243
- default:
244
- assert(false, 'not supported device');
245
- }
246
- }
247
- get name() {
248
- return this.device.label;
249
- }
250
- }
251
- export class AudioPlayback {
252
- get volume() {
253
- return this.controller.playbackGetVolume(this.uid);
254
- }
255
- get activity() {
256
- return this.controller.playbackGetActivity(this.uid);
257
- }
258
- constructor(controller, uid) {
259
- this.controller = controller;
260
- this.uid = uid;
261
- }
262
- start(id) {
263
- this.controller.playbackStart(this.uid, id);
264
- }
265
- stop(id) {
266
- this.controller.playbackStop(this.uid, id);
267
- }
268
- setVolume(value) {
269
- this.controller.playbackSetVolume(this.uid, value);
270
- }
271
- close() {
272
- this.controller.closePlayback(this.uid);
273
- }
274
- }
275
- export class AudioCapture {
276
- get vad() {
277
- return this._Vad;
278
- }
279
- get apm() {
280
- return this._Apm;
281
- }
282
- get volume() {
283
- return this._Volume;
284
- }
285
- get activity() {
286
- var _a, _b;
287
- return (_b = (_a = this._Capture) === null || _a === void 0 ? void 0 : _a.worker.activity) !== null && _b !== void 0 ? _b : silence;
288
- }
289
- get speechProbability() {
290
- var _a, _b;
291
- return (_b = (_a = this._Capture) === null || _a === void 0 ? void 0 : _a.worker.speechProbability) !== null && _b !== void 0 ? _b : 0;
292
- }
293
- constructor(controller, parameters) {
294
- this.controller = controller;
295
- this._Medias = new Map();
296
- this._Vad = defaultVad;
297
- this._Apm = defaultApm;
298
- this._Volume = 1;
299
- if (parameters.apm) {
300
- this.setApm(parameters.apm);
301
- }
302
- if (parameters.vad) {
303
- this.setVad(parameters.vad);
304
- }
305
- if (parameters.volume) {
306
- this.setVolume(parameters.volume);
307
- }
308
- }
309
- start(room, media, uid) {
310
- var _a;
311
- let entry = this._Medias.get(media.connectionId);
312
- if (entry === undefined) {
313
- this._Medias.set(media.connectionId, (entry = new Set()));
314
- }
315
- if (entry.has(media.mediaId))
316
- return;
317
- entry.add(media.mediaId);
318
- if (((_a = room.mainConnection) === null || _a === void 0 ? void 0 : _a.id) === media.connectionId) {
319
- room
320
- .typedRequest('StartMedia', {
321
- media_id: media.mediaId,
322
- properties: { kind: 'audio', uid },
323
- })
324
- .catch((reason) => console.error(`StartMedia got rejected; ${reason}`));
325
- }
326
- this._UpdateMedias();
327
- }
328
- stop(room, media) {
329
- var _a;
330
- const entry = this._Medias.get(media.connectionId);
331
- if (!(entry === null || entry === void 0 ? void 0 : entry.delete(media.mediaId)))
332
- return;
333
- if (((_a = room.mainConnection) === null || _a === void 0 ? void 0 : _a.id) === media.connectionId) {
334
- room
335
- .typedRequest('StopMedia', { media_id: media.mediaId })
336
- .catch((reason) => console.error(`StopMedia got rejected; ${reason}`));
337
- }
338
- this._UpdateMedias();
339
- }
340
- setVad(value) {
341
- this._Vad = value;
342
- if (this._Capture) {
343
- this._Capture.worker.setVad(value);
344
- }
345
- }
346
- setApm(config) {
347
- return __awaiter(this, void 0, void 0, function* () {
348
- this._Apm = config;
349
- if (this._deviceParameters) {
350
- yield this.setDevice(this._deviceParameters);
351
- }
352
- });
353
- }
354
- setDevice(parameters) {
355
- var _a;
356
- return __awaiter(this, void 0, void 0, function* () {
357
- const device = yield openCaptureDevice(this.controller, parameters, this._Apm);
358
- if (device.type !== 'Success') {
359
- console.error(`unable to open capture device; ${device.reason}`);
360
- return;
361
- }
362
- this._deviceParameters = parameters;
363
- if (this._Capture !== undefined) {
364
- this._Capture.source.disconnect(this._Capture.worker.worklet);
365
- }
366
- if (this._Capture === undefined ||
367
- this._Capture.worker.worklet.context !== device.value.context) {
368
- (_a = this._Capture) === null || _a === void 0 ? void 0 : _a.worker.close();
369
- this._Capture = {
370
- worker: yield createCaptureWorker(device.value.context, this.controller.sink),
371
- source: device.value,
372
- };
373
- yield this._UpdateMedias();
374
- this.setVolume(this.volume);
375
- this.setVad(this.vad);
376
- }
377
- else {
378
- this._Capture.source = device.value;
379
- }
380
- this._Capture.source.connect(this._Capture.worker.worklet);
381
- return success();
382
- });
383
- }
384
- setVolume(value) {
385
- this._Volume = value;
386
- if (this._Capture) {
387
- this._Capture.worker.setVolume(value === 'muted' ? 0 : value);
388
- }
389
- }
390
- close() {
391
- if (this._Capture !== undefined) {
392
- this._Capture.worker.close();
393
- this._Capture.source.disconnect(this._Capture.worker.worklet);
394
- this.controller.audioContexts.release(this._Capture.source.context);
395
- }
396
- this._Capture = undefined;
397
- }
398
- _UpdateMedias() {
399
- return __awaiter(this, void 0, void 0, function* () {
400
- if (this._Capture !== undefined) {
401
- const connections = Array.from(this._Medias).map(([key, value]) => {
402
- return { id: key, mediaIds: Array.from(value) };
403
- });
404
- this._Capture.worker.setMedias(connections);
405
- }
406
- });
407
- }
408
- }
409
- function openCaptureDevice(controller, parameters, apm) {
410
- return __awaiter(this, void 0, void 0, function* () {
411
- const deviceId = parameters.device
412
- ? { exact: parameters.device.device.deviceId }
413
- : undefined;
414
- let stream;
415
- try {
416
- const result = yield Promise.race([
417
- navigator.mediaDevices.getUserMedia({
418
- audio: {
419
- echoCancellation: apm.echoCanceller,
420
- noiseSuppression: apm.noiseSuppression !== 'None',
421
- autoGainControl: apm.gainController,
422
- // @ts-ignore chrome fix
423
- echoCancellationType: 'system',
424
- // sampleRate: 48000,
425
- deviceId,
426
- },
427
- }),
428
- sleep(30000, 'timeout'),
429
- ]);
430
- if (result === 'timeout')
431
- return failure('getUserMedia; timeout');
432
- stream = result;
433
- }
434
- catch (reason) {
435
- return failure(`getUserMedia; ${reason}`);
436
- }
437
- const sampleRate = stream.getAudioTracks()[0].getSettings().sampleRate;
438
- const context = yield controller.audioContexts.acquire(sampleRate);
439
- return success(context.createMediaStreamSource(stream));
440
- });
441
- }
442
- //# sourceMappingURL=audioController.js.map
@@ -1,11 +0,0 @@
1
- export declare const HealthCheckTimeout = 1000;
2
- export declare const ClockJumpCheckInterval = 1000;
3
- export declare const ClockJumpThreshold = 10000;
4
- export declare const MainConnectionPingInterval = 10000;
5
- export declare const WebRTCIceTimeout = 3000;
6
- export declare const WebRTCTimeout = 10000;
7
- export declare const ConnectTimeout = 5000;
8
- export declare const MinTokenLifetime = 60000;
9
- export declare const MinTokenRefreshInterval = 5000;
10
- export declare const ConnectInterval: number[];
11
- //# sourceMappingURL=config.d.ts.map
@@ -1,11 +0,0 @@
1
- export const HealthCheckTimeout = 1000; /* ms */
2
- export const ClockJumpCheckInterval = 1000; /* ms */
3
- export const ClockJumpThreshold = 10000; /* ms */
4
- export const MainConnectionPingInterval = 10000; /* ms */
5
- export const WebRTCIceTimeout = 3000; /* ms */
6
- export const WebRTCTimeout = 10000; /* ms */
7
- export const ConnectTimeout = 5000; /* ms */
8
- export const MinTokenLifetime = 60000; /* 1min */
9
- export const MinTokenRefreshInterval = 5000; /* 5sec */
10
- export const ConnectInterval = [0, 100, 200, 200, 500, 1000, 2000]; /* ms */
11
- //# sourceMappingURL=config.js.map
@@ -1,17 +0,0 @@
1
- import { DatagramHandler, MainConnection } from './mainConnection';
2
- import { Result } from '@4players/odin-common';
3
- export declare class ConnectionPool {
4
- readonly onDatagram: DatagramHandler;
5
- private _LastConnectionId;
6
- private readonly _ConnectionsByUrl;
7
- private readonly _ConnectionsById;
8
- private readonly _Close;
9
- get closed(): boolean;
10
- constructor(onDatagram: DatagramHandler);
11
- sendDatagram(connectionId: number, packet: Uint8Array): void;
12
- acquireConnection(url: URL, signal: AbortSignal): Promise<Result<MainConnection> | 'closed'>;
13
- releaseConnection(connection: MainConnection): void;
14
- checkHealth(): Promise<void>;
15
- close(): void;
16
- }
17
- //# sourceMappingURL=connectionPool.d.ts.map