@4players/odin-plugin-web 1.0.0-alpha.17 → 1.0.0-alpha.19
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/lib/plugin/connectionPool.js +2 -0
- package/lib/plugin/index.d.ts +1 -1
- package/lib/plugin/index.js +3 -1
- package/lib/plugin/medias/audio-capture.d.ts +4 -3
- package/lib/plugin/medias/audio-capture.js +39 -21
- package/lib/plugin/medias/audio-playback.d.ts +1 -1
- package/lib/plugin/medias/audio-playback.js +17 -1
- package/lib/plugin/roomConnection.js +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
|
@@ -99,7 +99,9 @@ export class ConnectionPool {
|
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
releaseConnection(connection) {
|
|
102
|
+
logger.log(['Connection'], 'ConnectionPool.releaseConnection()');
|
|
102
103
|
const entry = this._ConnectionsById.get(connection.id);
|
|
104
|
+
logger.log(['Connection'], 'ConnectionPool.releaseConnection() entry refs', entry === null || entry === void 0 ? void 0 : entry.references);
|
|
103
105
|
if (entry === undefined)
|
|
104
106
|
return;
|
|
105
107
|
if (entry.status === 'init') {
|
package/lib/plugin/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface WebPluginOptions {
|
|
|
23
23
|
}
|
|
24
24
|
export declare class WebPlugin implements Plugin {
|
|
25
25
|
readonly options: WebPluginOptions;
|
|
26
|
-
readonly version = "
|
|
26
|
+
readonly version = "2";
|
|
27
27
|
private _NextRoomId;
|
|
28
28
|
private _PlaybackVolume;
|
|
29
29
|
private readonly _ConnectionPool;
|
package/lib/plugin/index.js
CHANGED
|
@@ -42,7 +42,7 @@ export class WebPlugin {
|
|
|
42
42
|
}
|
|
43
43
|
constructor(connectionPool, audioController, options = { transport: Transport.H3 }) {
|
|
44
44
|
this.options = options;
|
|
45
|
-
this.version = '
|
|
45
|
+
this.version = '2';
|
|
46
46
|
this._NextRoomId = 0;
|
|
47
47
|
this._PlaybackVolume = 1;
|
|
48
48
|
this._ConnectionPool = connectionPool;
|
|
@@ -117,6 +117,7 @@ export class Room {
|
|
|
117
117
|
link(media) {
|
|
118
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
119
|
var _a, _b, _c, _d;
|
|
120
|
+
logger.debug(['Audio'], 'Room.link() media', media);
|
|
120
121
|
if (media instanceof AudioPlayback) {
|
|
121
122
|
const entry = (_a = this._Playbacks.get(media.uid)) !== null && _a !== void 0 ? _a : {
|
|
122
123
|
media: undefined,
|
|
@@ -199,6 +200,7 @@ export class Room {
|
|
|
199
200
|
}
|
|
200
201
|
unlink(media) {
|
|
201
202
|
var _a, _b;
|
|
203
|
+
logger.debug(['Audio'], 'Room.unlink() media', media);
|
|
202
204
|
if (media instanceof AudioPlayback || media instanceof VideoPlayback) {
|
|
203
205
|
const entry = this._Playbacks.get(media.uid);
|
|
204
206
|
if ((entry === null || entry === void 0 ? void 0 : entry.playback) !== media)
|
|
@@ -10,6 +10,7 @@ export declare class AudioCapture implements Backend.AudioCapture {
|
|
|
10
10
|
private _Apm;
|
|
11
11
|
private _Volume;
|
|
12
12
|
private _DeviceParameters?;
|
|
13
|
+
private _ProcessingSetDevice;
|
|
13
14
|
private _DeviceCb;
|
|
14
15
|
get vad(): Backend.VadConfig;
|
|
15
16
|
get apm(): Backend.ApmConfig;
|
|
@@ -22,8 +23,8 @@ export declare class AudioCapture implements Backend.AudioCapture {
|
|
|
22
23
|
stop(room: RoomConnection, media: GlobalMediaId): void;
|
|
23
24
|
setVad(value: Backend.VadConfig): void;
|
|
24
25
|
setApm(config: Backend.ApmConfig): Promise<void>;
|
|
25
|
-
setDevice(parameters: DeviceParameters): Promise<
|
|
26
|
-
setVolume(value: Backend.Volume): void
|
|
27
|
-
close(): void
|
|
26
|
+
setDevice(parameters: DeviceParameters): Promise<void>;
|
|
27
|
+
setVolume(value: Backend.Volume): Promise<void>;
|
|
28
|
+
close(): Promise<void>;
|
|
28
29
|
_UpdateMedias(): Promise<void>;
|
|
29
30
|
}
|
|
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { success } from '@4players/odin-common';
|
|
11
10
|
import { Silence } from '../../worker/common';
|
|
12
11
|
import { logger } from '../index';
|
|
13
12
|
import { createCaptureWorker } from '../../worker';
|
|
@@ -59,8 +58,10 @@ export class AudioCapture {
|
|
|
59
58
|
this._Vad = defaultVad;
|
|
60
59
|
this._Apm = defaultApm;
|
|
61
60
|
this._Volume = 1;
|
|
61
|
+
this._ProcessingSetDevice = false;
|
|
62
62
|
this._DeviceCb = () => __awaiter(this, void 0, void 0, function* () {
|
|
63
63
|
var _a, _b;
|
|
64
|
+
logger.debug(['Audio'], 'AudioCapture._DeviceCb()');
|
|
64
65
|
const devices = yield enumerateDevices();
|
|
65
66
|
const isListed = devices.some((device) => {
|
|
66
67
|
var _a, _b;
|
|
@@ -84,6 +85,7 @@ export class AudioCapture {
|
|
|
84
85
|
}
|
|
85
86
|
start(room, media, uid) {
|
|
86
87
|
var _a;
|
|
88
|
+
logger.debug(['Audio'], 'AudioCapture.start()', media);
|
|
87
89
|
let entry = this._Medias.get(media.connectionId);
|
|
88
90
|
if (entry === undefined) {
|
|
89
91
|
this._Medias.set(media.connectionId, (entry = new Set()));
|
|
@@ -103,6 +105,7 @@ export class AudioCapture {
|
|
|
103
105
|
}
|
|
104
106
|
stop(room, media) {
|
|
105
107
|
var _a;
|
|
108
|
+
logger.debug(['Audio'], 'AudioCapture.stop()', media);
|
|
106
109
|
const entry = this._Medias.get(media.connectionId);
|
|
107
110
|
if (!(entry === null || entry === void 0 ? void 0 : entry.delete(media.mediaId)))
|
|
108
111
|
return;
|
|
@@ -114,6 +117,7 @@ export class AudioCapture {
|
|
|
114
117
|
this._UpdateMedias();
|
|
115
118
|
}
|
|
116
119
|
setVad(value) {
|
|
120
|
+
logger.debug(['Audio'], 'AudioCapture.setVad() config', value);
|
|
117
121
|
this._Vad = value;
|
|
118
122
|
if (this._Capture) {
|
|
119
123
|
this._Capture.worker.setVad(value);
|
|
@@ -121,6 +125,7 @@ export class AudioCapture {
|
|
|
121
125
|
}
|
|
122
126
|
setApm(config) {
|
|
123
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
logger.debug(['Audio'], 'AudioCapture.setApm() config', config);
|
|
124
129
|
this._Apm = config;
|
|
125
130
|
if (this._DeviceParameters) {
|
|
126
131
|
yield this.setDevice(this._DeviceParameters);
|
|
@@ -160,41 +165,54 @@ export class AudioCapture {
|
|
|
160
165
|
source: device.value,
|
|
161
166
|
};
|
|
162
167
|
yield this._UpdateMedias();
|
|
163
|
-
this.setVolume(this.
|
|
168
|
+
yield this.setVolume(this._Volume);
|
|
164
169
|
this.setVad(this.vad);
|
|
165
170
|
}
|
|
166
171
|
else {
|
|
167
172
|
this._Capture.source = device.value;
|
|
168
173
|
}
|
|
169
174
|
this._Capture.source.connect(this._Capture.worker.worklet);
|
|
170
|
-
return success();
|
|
171
175
|
});
|
|
172
176
|
}
|
|
173
177
|
setVolume(value) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
this.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
var _a;
|
|
180
|
+
logger.debug(['Audio'], 'AudioCapture.setVolume()', value);
|
|
181
|
+
this._Volume = value;
|
|
182
|
+
if (this._ProcessingSetDevice)
|
|
183
|
+
return;
|
|
184
|
+
this._ProcessingSetDevice = true;
|
|
185
|
+
if (value === 'muted') {
|
|
186
|
+
yield this.close();
|
|
182
187
|
}
|
|
183
|
-
|
|
184
|
-
|
|
188
|
+
else {
|
|
189
|
+
if (!this._Capture && this._DeviceParameters) {
|
|
190
|
+
yield this.setDevice(this._DeviceParameters);
|
|
191
|
+
}
|
|
192
|
+
(_a = this._Capture) === null || _a === void 0 ? void 0 : _a.worker.setVolume(value);
|
|
193
|
+
}
|
|
194
|
+
this._ProcessingSetDevice = false;
|
|
195
|
+
if (value !== this._Volume) {
|
|
196
|
+
yield this.setVolume(this._Volume);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
185
199
|
}
|
|
186
200
|
close() {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
201
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
logger.debug(['Audio'], 'AudioCapture.close()');
|
|
203
|
+
if (this._Capture !== undefined) {
|
|
204
|
+
this._Capture.worker.close();
|
|
205
|
+
stopMediaStream(this._Capture.source.mediaStream);
|
|
206
|
+
this._Capture.source.disconnect(this._Capture.worker.worklet);
|
|
207
|
+
yield this.controller.audioContexts.release(this._Capture.source.context);
|
|
208
|
+
}
|
|
209
|
+
navigator.mediaDevices.removeEventListener('devicechange', this._DeviceCb);
|
|
210
|
+
this._Capture = undefined;
|
|
211
|
+
});
|
|
195
212
|
}
|
|
196
213
|
_UpdateMedias() {
|
|
197
214
|
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
logger.debug(['Audio'], 'AudioCapture._UpdateMedias()');
|
|
198
216
|
if (this._Capture !== undefined) {
|
|
199
217
|
const connections = Array.from(this._Medias).map(([key, value]) => {
|
|
200
218
|
return { id: key, mediaIds: Array.from(value) };
|
|
@@ -8,6 +8,6 @@ export declare class AudioPlayback implements Backend.AudioPlayback {
|
|
|
8
8
|
constructor(controller: MediaController, uid: Backend.UID);
|
|
9
9
|
start(id: GlobalMediaId): void;
|
|
10
10
|
stop(id: GlobalMediaId): void;
|
|
11
|
-
setVolume(value: Backend.Volume): void
|
|
11
|
+
setVolume(value: Backend.Volume): Promise<void>;
|
|
12
12
|
close(): void;
|
|
13
13
|
}
|
|
@@ -1,3 +1,13 @@
|
|
|
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 { logger } from '../config';
|
|
1
11
|
export class AudioPlayback {
|
|
2
12
|
get volume() {
|
|
3
13
|
return this.controller.playbackGetVolume(this.uid);
|
|
@@ -10,15 +20,21 @@ export class AudioPlayback {
|
|
|
10
20
|
this.uid = uid;
|
|
11
21
|
}
|
|
12
22
|
start(id) {
|
|
23
|
+
logger.debug(['Audio'], 'AudioPlayback.start()', id);
|
|
13
24
|
this.controller.playbackStart(this.uid, id);
|
|
14
25
|
}
|
|
15
26
|
stop(id) {
|
|
27
|
+
logger.debug(['Audio'], 'AudioPlayback.stop()', id);
|
|
16
28
|
this.controller.playbackStop(this.uid, id);
|
|
17
29
|
}
|
|
18
30
|
setVolume(value) {
|
|
19
|
-
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
logger.debug(['Audio'], 'AudioPlayback.setVolume()', value);
|
|
33
|
+
this.controller.playbackSetVolume(this.uid, value);
|
|
34
|
+
});
|
|
20
35
|
}
|
|
21
36
|
close() {
|
|
37
|
+
logger.debug(['Audio'], 'AudioPlayback.close()');
|
|
22
38
|
this.controller.closePlayback(this.uid);
|
|
23
39
|
}
|
|
24
40
|
}
|
|
@@ -215,6 +215,7 @@ export class RoomConnection {
|
|
|
215
215
|
case 'closed':
|
|
216
216
|
logger.debug(['Connection'], 'RoomConnection._HandleConnection: closed');
|
|
217
217
|
(_a = this._RoomConnection) === null || _a === void 0 ? void 0 : _a.close();
|
|
218
|
+
this.connectionPool.releaseConnection(main);
|
|
218
219
|
return;
|
|
219
220
|
case 'renewToken':
|
|
220
221
|
this._RenewToken();
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.0-alpha.
|
|
1
|
+
export declare const version = "1.0.0-alpha.19";
|
package/lib/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '1.0.0-alpha.
|
|
2
|
+
export const version = '1.0.0-alpha.19';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4players/odin-plugin-web",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.19",
|
|
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": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"bundle": "npm run build && esbuild lib/plugin/index.js --bundle --outfile=dist/plugin.js"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
|
|
31
|
+
"@4players/odin-common": "~2.5.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "~20.12.0",
|