@4players/odin-plugin-web 1.0.0-alpha.18 → 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/index.d.ts +1 -1
- package/lib/plugin/index.js +1 -1
- package/lib/plugin/medias/audio-capture.d.ts +4 -3
- package/lib/plugin/medias/audio-capture.js +33 -23
- package/lib/plugin/medias/audio-playback.d.ts +1 -1
- package/lib/plugin/medias/audio-playback.js +13 -2
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
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;
|
|
@@ -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,6 +58,7 @@ 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
64
|
logger.debug(['Audio'], 'AudioCapture._DeviceCb()');
|
|
@@ -165,40 +165,50 @@ export class AudioCapture {
|
|
|
165
165
|
source: device.value,
|
|
166
166
|
};
|
|
167
167
|
yield this._UpdateMedias();
|
|
168
|
-
this.setVolume(this.
|
|
168
|
+
yield this.setVolume(this._Volume);
|
|
169
169
|
this.setVad(this.vad);
|
|
170
170
|
}
|
|
171
171
|
else {
|
|
172
172
|
this._Capture.source = device.value;
|
|
173
173
|
}
|
|
174
174
|
this._Capture.source.connect(this._Capture.worker.worklet);
|
|
175
|
-
return success();
|
|
176
175
|
});
|
|
177
176
|
}
|
|
178
177
|
setVolume(value) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
this.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (
|
|
187
|
-
this.
|
|
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();
|
|
188
187
|
}
|
|
189
|
-
|
|
190
|
-
|
|
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
|
+
});
|
|
191
199
|
}
|
|
192
200
|
close() {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
this._Capture
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
+
});
|
|
202
212
|
}
|
|
203
213
|
_UpdateMedias() {
|
|
204
214
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -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,12 @@
|
|
|
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
|
+
};
|
|
1
10
|
import { logger } from '../config';
|
|
2
11
|
export class AudioPlayback {
|
|
3
12
|
get volume() {
|
|
@@ -19,8 +28,10 @@ export class AudioPlayback {
|
|
|
19
28
|
this.controller.playbackStop(this.uid, id);
|
|
20
29
|
}
|
|
21
30
|
setVolume(value) {
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
logger.debug(['Audio'], 'AudioPlayback.setVolume()', value);
|
|
33
|
+
this.controller.playbackSetVolume(this.uid, value);
|
|
34
|
+
});
|
|
24
35
|
}
|
|
25
36
|
close() {
|
|
26
37
|
logger.debug(['Audio'], 'AudioPlayback.close()');
|
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",
|