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

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.
Files changed (68) hide show
  1. package/lib/plugin/index.d.ts +127 -61
  2. package/lib/plugin/index.js +1 -405
  3. package/lib/worker/shared.js +1 -0
  4. package/lib/worker/unshared.js +1 -0
  5. package/package.json +22 -19
  6. package/lib/common/msgpack.d.ts +0 -2
  7. package/lib/common/msgpack.js +0 -117
  8. package/lib/plugin/config.d.ts +0 -12
  9. package/lib/plugin/config.js +0 -22
  10. package/lib/plugin/connectionPool.d.ts +0 -17
  11. package/lib/plugin/connectionPool.js +0 -130
  12. package/lib/plugin/deviceManager.d.ts +0 -12
  13. package/lib/plugin/deviceManager.js +0 -120
  14. package/lib/plugin/h3/mainConnection.d.ts +0 -30
  15. package/lib/plugin/h3/mainConnection.js +0 -196
  16. package/lib/plugin/mainConnection.d.ts +0 -30
  17. package/lib/plugin/mainConnection.js +0 -23
  18. package/lib/plugin/mediaController.d.ts +0 -66
  19. package/lib/plugin/mediaController.js +0 -215
  20. package/lib/plugin/medias/audio-capture.d.ts +0 -30
  21. package/lib/plugin/medias/audio-capture.js +0 -224
  22. package/lib/plugin/medias/audio-playback.d.ts +0 -13
  23. package/lib/plugin/medias/audio-playback.js +0 -40
  24. package/lib/plugin/medias/video-capture.d.ts +0 -15
  25. package/lib/plugin/medias/video-capture.js +0 -69
  26. package/lib/plugin/medias/video-playback.d.ts +0 -13
  27. package/lib/plugin/medias/video-playback.js +0 -20
  28. package/lib/plugin/roomConnection.d.ts +0 -40
  29. package/lib/plugin/roomConnection.js +0 -320
  30. package/lib/plugin/rpcConnection.d.ts +0 -57
  31. package/lib/plugin/rpcConnection.js +0 -281
  32. package/lib/plugin/token.d.ts +0 -13
  33. package/lib/plugin/token.js +0 -66
  34. package/lib/plugin/webrtc/mainConnection.d.ts +0 -52
  35. package/lib/plugin/webrtc/mainConnection.js +0 -455
  36. package/lib/plugin/webrtc/websocket.d.ts +0 -3
  37. package/lib/plugin/webrtc/websocket.js +0 -56
  38. package/lib/wasm/index.d.ts +0 -97
  39. package/lib/worker/buffers.d.ts +0 -42
  40. package/lib/worker/buffers.js +0 -79
  41. package/lib/worker/common.d.ts +0 -45
  42. package/lib/worker/common.js +0 -7
  43. package/lib/worker/config.d.ts +0 -8
  44. package/lib/worker/config.js +0 -11
  45. package/lib/worker/index.d.ts +0 -3
  46. package/lib/worker/index.js +0 -1
  47. package/lib/worker/memory.d.ts +0 -9
  48. package/lib/worker/memory.js +0 -29
  49. package/lib/worker/messages.d.ts +0 -14
  50. package/lib/worker/messages.js +0 -15
  51. package/lib/worker/packet.d.ts +0 -11
  52. package/lib/worker/packet.js +0 -59
  53. package/lib/worker/shared/capture.d.ts +0 -27
  54. package/lib/worker/shared/capture.js +0 -63
  55. package/lib/worker/shared/index.d.ts +0 -3
  56. package/lib/worker/shared/index.js +0 -147
  57. package/lib/worker/shared/messages.d.ts +0 -67
  58. package/lib/worker/shared/messages.js +0 -64
  59. package/lib/worker/shared/playback.d.ts +0 -20
  60. package/lib/worker/shared/playback.js +0 -78
  61. package/lib/worker/unshared/capture.d.ts +0 -27
  62. package/lib/worker/unshared/capture.js +0 -66
  63. package/lib/worker/unshared/index.d.ts +0 -3
  64. package/lib/worker/unshared/index.js +0 -170
  65. package/lib/worker/unshared/messages.d.ts +0 -81
  66. package/lib/worker/unshared/messages.js +0 -80
  67. package/lib/worker/unshared/playback.d.ts +0 -22
  68. package/lib/worker/unshared/playback.js +0 -83
@@ -1,64 +1,130 @@
1
- import { Backend } from '@4players/odin-common';
2
- import { AudioContextFactory, CreateAudioCaptureParameters, CreateAudioPlaybackParameters, Device } from './mediaController';
3
- import { ConnectionPool } from './connectionPool';
4
- import { MainConnection } from './mainConnection';
5
- import { AudioCapture } from './medias/audio-capture';
6
- import { VideoCapture } from './medias/video-capture';
7
- import { VideoPlayback } from './medias/video-playback';
8
- import { AudioPlayback } from './medias/audio-playback';
9
- import JoinRoomParameters = Backend.JoinRoomParameters;
10
- import Cipher = Backend.Cipher;
11
- export type { LogFilters } from '@4players/odin-common';
12
- export { logger } from './config';
13
- type Plugin = Backend.Plugin;
14
- export interface DeviceParameters {
15
- readonly device?: Device;
16
- onStatusChanged?: Backend.OnStatusChanged;
1
+ import { Backend, LogRecord, Logger } from '@4players/odin-common';
2
+
3
+ export interface DecoderSlot {
4
+ index: number;
5
+ connectionId: number;
6
+ mediaId: number;
7
+ volume?: number;
17
8
  }
18
- export declare class WebPlugin implements Plugin {
19
- readonly version = "3";
20
- readonly supportedTransports: Backend.Transport[];
21
- private _NextRoomId;
22
- private _PlaybackVolume;
23
- private readonly _ConnectionPool;
24
- private readonly _MediaController;
25
- get playbackVolume(): Backend.Volume;
26
- static create(audioContextFactory: AudioContextFactory): Promise<WebPlugin>;
27
- private constructor();
28
- joinRoom(parameters: JoinRoomParameters): Room;
29
- createAudioPlayback(parameters: CreateAudioPlaybackParameters): Promise<AudioPlayback>;
30
- createAudioCapture(parameters: CreateAudioCaptureParameters): Promise<AudioCapture>;
31
- createVideoCapture(ms: MediaStream, customType?: string): Promise<VideoCapture>;
32
- createVideoPlayback(parameters: Backend.CreateVideoPlaybackParameters): Promise<VideoPlayback>;
33
- enumerateDevices(): Promise<Device[]>;
34
- setOutputVolume(volume: Backend.Volume): void;
35
- setOutputDevice(device: DeviceParameters): Promise<void>;
36
- close(): void;
9
+ declare namespace Common {
10
+ type CaptureWorkletMessages = {
11
+ init: {
12
+ workerPort: MessagePort;
13
+ };
14
+ close: void;
15
+ dump: {
16
+ result: MessagePort;
17
+ };
18
+ };
19
+ type PlaybackWorkletMessages = {
20
+ init: {
21
+ workerPort: MessagePort;
22
+ };
23
+ samples: {
24
+ id: number;
25
+ buffer: Float32Array;
26
+ };
27
+ close: void;
28
+ dump: {
29
+ result: MessagePort;
30
+ };
31
+ };
32
+ type WorkerMessages = {
33
+ captureInit: {
34
+ sampleRate: number;
35
+ workletPort: MessagePort;
36
+ };
37
+ captureSetMedias: {
38
+ connections: Array<{
39
+ id: number;
40
+ mediaIds: number[];
41
+ }>;
42
+ };
43
+ captureSetVad: VadConfig;
44
+ captureTick: {};
45
+ playbackInit: {
46
+ workletPort: MessagePort;
47
+ };
48
+ playbackUpdateMedias: {
49
+ added: Array<DecoderSlot>;
50
+ removed: Array<DecoderSlot>;
51
+ };
52
+ playbackReceivePacket: {
53
+ connectionId: number;
54
+ packet: Uint8Array;
55
+ };
56
+ playbackTick: {};
57
+ close: void;
58
+ dump: {
59
+ result: MessagePort;
60
+ };
61
+ };
62
+ type MainMessages = {
63
+ sendPacket: {
64
+ connectionId: number;
65
+ packet: Uint8Array;
66
+ };
67
+ captureReady: {};
68
+ playbackReady: {};
69
+ stats: {
70
+ playback?: {
71
+ numberPackets: number;
72
+ numberPacketsMediaNotFound: number;
73
+ numberTicks: number;
74
+ numberPacketError: number;
75
+ numberTicksWithAudio: number;
76
+ };
77
+ capture?: {
78
+ numberPackets: number;
79
+ numberPacketsMediaNotFound: number;
80
+ numberTicks: number;
81
+ numberPacketError: number;
82
+ };
83
+ };
84
+ };
37
85
  }
38
- export declare class Room implements Backend.Room {
39
- private readonly _Id;
40
- private readonly _Connection;
41
- private readonly _OnEvent;
42
- private readonly _Captures;
43
- private readonly _Playbacks;
44
- private readonly _Peers;
45
- private readonly _AvailableMediaIds;
46
- get mainConnection(): MainConnection | undefined;
47
- constructor(id: number, connectionPool: ConnectionPool, parameters: JoinRoomParameters);
48
- get token(): string;
49
- get cipher(): Cipher | undefined;
50
- request(method: string, properties: unknown): Promise<unknown>;
51
- link(media: Backend.Media): Promise<void>;
52
- unlink(media: Backend.Media): void;
53
- close(): void;
54
- private _HandleEvent;
55
- private _HandleKnownEvent;
56
- private _HandleConnectionLost;
57
- private _HandleRoomUpdate;
58
- private _HandleRoomJoined;
59
- private _HandlePeerUpdate;
60
- private _HandlePeerJoined;
61
- private _HandlePeerLeft;
62
- private _HandleMediaStart;
63
- private _HandleMediaStopped;
86
+ export type OnLogMessage = (formattedString: string, record: LogRecord) => void;
87
+ export interface VadConfig {
88
+ volumeGate?: {
89
+ attackThreshold: number;
90
+ releaseThreshold: number;
91
+ };
92
+ voiceActivity?: {
93
+ attackThreshold: number;
94
+ releaseThreshold: number;
95
+ };
64
96
  }
97
+ export type ConnectionStats = {
98
+ numberRecvDatagrams: number;
99
+ numberRecvDatagramsNoMediaIds: number;
100
+ numberRecvDatagramsNoEntry: number;
101
+ numberRecvDatagramsDecryptInvalid: number;
102
+ mainConnectionIdHistory: number[];
103
+ };
104
+ export type AudioContextFactory = (sampleRate: number | undefined) => Promise<AudioContext>;
105
+ export type MoreConnectionStats = ConnectionStats & {
106
+ numberAudioChannelMessages: number;
107
+ };
108
+ export interface WebDevice extends Backend.Device {
109
+ readonly device: MediaDeviceInfo;
110
+ }
111
+ export interface WebDeviceParameters extends Backend.DeviceParameters {
112
+ readonly device?: WebDevice;
113
+ onStatusChanged?: Backend.OnStatusChanged;
114
+ }
115
+ export declare function createPlugin(audioContextFactory: AudioContextFactory, options?: WebPluginOptions): WebPlugin;
116
+ export interface WebPluginOptions {
117
+ logger?: Logger;
118
+ onLogMessage?: OnLogMessage;
119
+ }
120
+ export interface WebPlugin extends Backend.Plugin {
121
+ joinRoom(parameters: Backend.JoinRoomParameters): WebRoom;
122
+ enumerateDevices(): Promise<WebDevice[]>;
123
+ setOutputDevice(device: WebDeviceParameters): Promise<void>;
124
+ getAudioPlaybackStats(): undefined | Common.MainMessages["stats"]["playback"];
125
+ getConnectionStats(): MoreConnectionStats;
126
+ }
127
+ export interface WebRoom extends Backend.Room {
128
+ }
129
+
130
+ export {};