@4players/odin-nodejs 0.7.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.
Files changed (99) hide show
  1. package/.idea/.name +1 -0
  2. package/.idea/jsLibraryMappings.xml +6 -0
  3. package/.idea/misc.xml +4 -0
  4. package/.idea/modules.xml +9 -0
  5. package/.idea/odin-nodejs.iml +8 -0
  6. package/.idea/odin_nodejs.iml +2 -0
  7. package/.idea/php.xml +19 -0
  8. package/.idea/vcs.xml +6 -0
  9. package/CMakeLists.txt +25 -0
  10. package/README.md +53 -0
  11. package/binding.gyp +61 -0
  12. package/build/Makefile +352 -0
  13. package/build/Release/.deps/Release/nothing.a.d +1 -0
  14. package/build/Release/.deps/Release/obj.target/nothing/node_modules/node-addon-api/nothing.o.d +4 -0
  15. package/build/Release/.deps/Release/obj.target/odin/cppsrc/binding.o.d +27 -0
  16. package/build/Release/.deps/Release/obj.target/odin/cppsrc/odinbindings.o.d +24 -0
  17. package/build/Release/.deps/Release/obj.target/odin/cppsrc/odinclient.o.d +24 -0
  18. package/build/Release/.deps/Release/obj.target/odin/cppsrc/odinmedia.o.d +24 -0
  19. package/build/Release/.deps/Release/obj.target/odin/cppsrc/odinroom.o.d +24 -0
  20. package/build/Release/.deps/Release/obj.target/odin/cppsrc/utilities.o.d +21 -0
  21. package/build/Release/.deps/Release/odin.node.d +1 -0
  22. package/build/Release/nothing.a +0 -0
  23. package/build/Release/obj.target/nothing/node_modules/node-addon-api/nothing.o +0 -0
  24. package/build/Release/obj.target/odin/cppsrc/binding.o +0 -0
  25. package/build/Release/obj.target/odin/cppsrc/odinbindings.o +0 -0
  26. package/build/Release/obj.target/odin/cppsrc/odinclient.o +0 -0
  27. package/build/Release/obj.target/odin/cppsrc/odinmedia.o +0 -0
  28. package/build/Release/obj.target/odin/cppsrc/odinroom.o +0 -0
  29. package/build/Release/obj.target/odin/cppsrc/utilities.o +0 -0
  30. package/build/binding.Makefile +6 -0
  31. package/build/gyp-mac-tool +772 -0
  32. package/build/node_modules/node-addon-api/node_api.Makefile +6 -0
  33. package/build/node_modules/node-addon-api/nothing.target.mk +186 -0
  34. package/build/odin.target.mk +201 -0
  35. package/cmake-build-debug/.cmake/api/v1/query/cache-v2 +0 -0
  36. package/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 +0 -0
  37. package/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 +0 -0
  38. package/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 +0 -0
  39. package/cmake-build-debug/.cmake/api/v1/reply/cache-v2-912a6d0c3c2c7ebbadf8.json +1183 -0
  40. package/cmake-build-debug/.cmake/api/v1/reply/cmakeFiles-v1-0825651e80f1fb47890c.json +161 -0
  41. package/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-bc24edc239de864eb886.json +60 -0
  42. package/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json +14 -0
  43. package/cmake-build-debug/.cmake/api/v1/reply/index-2023-03-18T11-25-22-0179.json +108 -0
  44. package/cmake-build-debug/.cmake/api/v1/reply/target-odin_nodejs-Debug-1ac16802f252a85492c7.json +322 -0
  45. package/cmake-build-debug/.cmake/api/v1/reply/toolchains-v1-b57293a485ebf36c82cc.json +88 -0
  46. package/cmake-build-debug/.ninja_log +1 -0
  47. package/cmake-build-debug/CMakeCache.txt +367 -0
  48. package/cmake-build-debug/CMakeFiles/3.24.2/CMakeCCompiler.cmake +72 -0
  49. package/cmake-build-debug/CMakeFiles/3.24.2/CMakeCXXCompiler.cmake +83 -0
  50. package/cmake-build-debug/CMakeFiles/3.24.2/CMakeDetermineCompilerABI_C.bin +0 -0
  51. package/cmake-build-debug/CMakeFiles/3.24.2/CMakeDetermineCompilerABI_CXX.bin +0 -0
  52. package/cmake-build-debug/CMakeFiles/3.24.2/CMakeSystem.cmake +15 -0
  53. package/cmake-build-debug/CMakeFiles/3.24.2/CompilerIdC/CMakeCCompilerId.c +838 -0
  54. package/cmake-build-debug/CMakeFiles/3.24.2/CompilerIdC/CMakeCCompilerId.o +0 -0
  55. package/cmake-build-debug/CMakeFiles/3.24.2/CompilerIdCXX/CMakeCXXCompilerId.cpp +826 -0
  56. package/cmake-build-debug/CMakeFiles/3.24.2/CompilerIdCXX/CMakeCXXCompilerId.o +0 -0
  57. package/cmake-build-debug/CMakeFiles/CMakeError.log +22 -0
  58. package/cmake-build-debug/CMakeFiles/CMakeOutput.log +250 -0
  59. package/cmake-build-debug/CMakeFiles/TargetDirectories.txt +3 -0
  60. package/cmake-build-debug/CMakeFiles/clion-Debug-log.txt +4 -0
  61. package/cmake-build-debug/CMakeFiles/clion-environment.txt +3 -0
  62. package/cmake-build-debug/CMakeFiles/cmake.check_cache +1 -0
  63. package/cmake-build-debug/CMakeFiles/rules.ninja +74 -0
  64. package/cmake-build-debug/Testing/Temporary/LastTest.log +3 -0
  65. package/cmake-build-debug/build.ninja +205 -0
  66. package/cmake-build-debug/cmake_install.cmake +49 -0
  67. package/cppsrc/binding.cpp +15 -0
  68. package/cppsrc/odinbindings.cpp +58 -0
  69. package/cppsrc/odinbindings.h +9 -0
  70. package/cppsrc/odinclient.cpp +162 -0
  71. package/cppsrc/odinclient.h +17 -0
  72. package/cppsrc/odinmedia.cpp +242 -0
  73. package/cppsrc/odinmedia.h +35 -0
  74. package/cppsrc/odinroom.cpp +738 -0
  75. package/cppsrc/odinroom.h +65 -0
  76. package/cppsrc/utilities.cpp +102 -0
  77. package/cppsrc/utilities.h +175 -0
  78. package/index.cjs +2 -0
  79. package/index.d.ts +5 -0
  80. package/libs/bin/linux/arm64/libodin_static.a +0 -0
  81. package/libs/bin/linux/ia32/libodin_static.a +0 -0
  82. package/libs/bin/linux/x64/libodin_static.a +0 -0
  83. package/libs/bin/macos/arm64/libodin_static.a +0 -0
  84. package/libs/bin/macos/x64/libodin_static.a +0 -0
  85. package/libs/bin/windows/arm64/odin_static.lib +0 -0
  86. package/libs/bin/windows/ia32/odin_static.lib +0 -0
  87. package/libs/bin/windows/x64/odin_static.lib +0 -0
  88. package/libs/include/odin.h +896 -0
  89. package/odin.client.d.ts +22 -0
  90. package/odin.media.d.ts +33 -0
  91. package/odin.room.d.ts +473 -0
  92. package/package.json +50 -0
  93. package/prebuilds/darwin-arm64/node.napi.node +0 -0
  94. package/test.js +211 -0
  95. package/tests/audio-recording/README.md +24 -0
  96. package/tests/audio-recording/index.js +148 -0
  97. package/tests/sending-audio/README.md +20 -0
  98. package/tests/sending-audio/index.js +81 -0
  99. package/tests/sending-audio/santa.mp3 +0 -0
@@ -0,0 +1,22 @@
1
+ import {OdinRoom} from "./odin.room";
2
+
3
+ /**
4
+ * The Odin client is the main entry point for the Odin SDK. It is used to create rooms. Create an instance with your
5
+ * access key and use it to create rooms.
6
+ */
7
+ export declare class OdinClient {
8
+ /**
9
+ * Creates a new instance of a client with an access key.
10
+ * @param accessKey {string} The access key to use for this client. You can get one from https://developers.4players.io
11
+ * @param sampleRate {number} The sample rate of the audio stream (between 8000 and 48000)
12
+ * @param channelCount {number} The number of channels of the audio stream (1 or 2)
13
+ */
14
+ constructor(accessKey: string, sampleRate?: number, channelCount?: number);
15
+
16
+ /**
17
+ * Creates a new local room instance with the given ID and user ID. Use join to connect to that room.
18
+ * @param roomId {string} The ID of the room to create.
19
+ * @param userId {string} The ID of the user to create the room for.
20
+ */
21
+ createRoom(roomId: string, userId: string): OdinRoom;
22
+ }
@@ -0,0 +1,33 @@
1
+ import {OdinRoom} from "./odin.room";
2
+
3
+ /**
4
+ * The OdinMedia class. Represents a local media stream added to the room - i.e. a microphone, another audio stream like files.
5
+ * Don't create OdinMedia instances directly, use `createAudioStream` from OdinRoom instead.
6
+ */
7
+ export declare class OdinMedia {
8
+ /**
9
+ * Creates a new instance of a media object. Don't create OdinMedia directly, use `createAudioStream` from OdinRoom instead.
10
+ * @param room {OdinRoom} The room to add the media to.
11
+ * @param sampleRate {number} The sample rate of the audio stream (between 8000 and 48000)
12
+ * @param channelCount {number} The number of channels of the audio stream (1 or 2)
13
+ */
14
+ constructor(room: OdinRoom, sampleRate: number, channelCount: number);
15
+
16
+ /**
17
+ * Closes the local audio stream and removed the media from the room
18
+ */
19
+ close(): void;
20
+
21
+ /**
22
+ * Sends audio data to the room. The data must be in the format specified when creating the media as a 32-bit float array.
23
+ * Samples need to be between -1 and 1. Audio data needs to be sent in regular intervals, otherwise the audio will be sound
24
+ * interrupted. See the example for more details.
25
+ * @param data
26
+ */
27
+ sendAudioData(data: Float32Array): void;
28
+
29
+ /**
30
+ * Gets the ID of the media.
31
+ */
32
+ get id(): string;
33
+ }
package/odin.room.d.ts ADDED
@@ -0,0 +1,473 @@
1
+ import {OdinMedia} from "./odin.media";
2
+
3
+ declare interface OdinEvents {
4
+ /**
5
+ * Fired when the local user connected to the room (successfully joined).
6
+ */
7
+ Joined: OdinJoinedEvent;
8
+
9
+ /**
10
+ * Fired when the local user disconnected from the room (left).
11
+ */
12
+ Left: OdinLeftEvent;
13
+
14
+ /**
15
+ * Fired when a remote peer joined the room. This event is fired for all existing peers in the room before the Joined event is fired.
16
+ */
17
+ PeerJoined: OdinPeerJoinedEvent;
18
+
19
+ /**
20
+ * Fired when a remote peer left the room.
21
+ */
22
+ PeerLeft: OdinPeerLeftEvent;
23
+
24
+ /**
25
+ * Fired when a remote peer sent a message to the room.
26
+ */
27
+ MessageReceived: OdinMessageReceivedEvent;
28
+
29
+ /**
30
+ * Fired when the user data of a remote peer changed.
31
+ */
32
+ PeerUserDataChanged: OdinPeerUserDataChangedEvent;
33
+
34
+ /**
35
+ * Fired when the user data of the room changed.
36
+ */
37
+ RoomUserDataChanged: OdinRoomUserDataChangedEvent;
38
+
39
+ /**
40
+ * Fired when the connection state of the room changed.
41
+ */
42
+ ConnectionStateChanged: OdinConnectionStateChangedEvent;
43
+
44
+ /**
45
+ * Fired when a media stream was added to a peer. This happens for example if a peer adds a microphone to the room
46
+ */
47
+ MediaAdded: OdinMediaAddedEvent;
48
+
49
+ /**
50
+ * Fired when a media stream was removed from a peer. This happens for example if a peer removes a microphone from the room
51
+ */
52
+ MediaRemoved: OdinMediaRemovedEvent;
53
+
54
+ /**
55
+ * Fired when a media stream was activated or deactivated. The active flag is true if the user started to talk and false if the user stopped talking.
56
+ */
57
+ MediaActivity: OdinMediaActivityEvent;
58
+
59
+ /**
60
+ * Fired when audio data is available for media streams. Audio comes in 16 bit and 32 bit float samples and are available individually for each peer.
61
+ * You can use the samples to record audio or send them to an AI for transcription.
62
+ */
63
+ AudioDataReceived: OdinAudioDataReceivedEvent;
64
+ }
65
+
66
+ export type OdinConnectionStateChangedEvent = (event: OdinConnectionStateChangedEventPayload) => void;
67
+ export type OdinJoinedEvent = (event: OdinJoinedEventPayload) => void;
68
+ export type OdinLeftEvent = (event: OdinLeftEventPayload) => void;
69
+ export type OdinPeerJoinedEvent = (event: OdinPeerJoinedEventPayload) => void;
70
+ export type OdinPeerLeftEvent = (event: OdinPeerLeftEventPayload) => void;
71
+ export type OdinMessageReceivedEvent = (event: OdinMessageReceivedEventPayload) => void;
72
+ export type OdinPeerUserDataChangedEvent = (event: OdinPeerUserDataChangedEventPayload) => void;
73
+ export type OdinRoomUserDataChangedEvent = (event: OdinRoomUserDataChangedEventPayload) => void;
74
+ export type OdinMediaAddedEvent = (event: OdinMediaAddedEventPayload) => void;
75
+ export type OdinMediaRemovedEvent = (event: OdinMediaRemovedEventPayload) => void;
76
+ export type OdinMediaActivityEvent = (event: OdinMediaActivityEventPayload) => void;
77
+ export type OdinAudioDataReceivedEvent = (event: OdinAudioDataReceivedEventPayload) => void;
78
+
79
+ /**
80
+ * The base event payload that is passed to all events.
81
+ */
82
+ declare interface OdinEventPayload {
83
+ /**
84
+ * The name of the event that was fired (see keys of OdinEvents for possible values).
85
+ */
86
+ event: keyof OdinEvents;
87
+
88
+ /**
89
+ * An internal integer representing the type of the event. This is mainly used internally for testing purposes.
90
+ */
91
+ tag: number;
92
+ }
93
+
94
+ /**
95
+ * The payload for the Joined event.
96
+ */
97
+ export declare interface OdinJoinedEventPayload extends OdinEventPayload {
98
+ /**
99
+ * The ID of the room that was joined. It's the same as the room id that was passed to join.
100
+ */
101
+ roomId: string;
102
+
103
+ /**
104
+ * The ID of the local peer.
105
+ */
106
+ ownPeerId: number;
107
+
108
+ /**
109
+ * The ID of the local user. It is the same as the user id that was passed to join.
110
+ */
111
+ ownUserId: string;
112
+
113
+ /**
114
+ * The current user data of the room
115
+ */
116
+ roomUserData: Uint8Array | undefined;
117
+ }
118
+
119
+ /**
120
+ * The payload for the Left event.
121
+ */
122
+ export declare interface OdinLeftEventPayload extends OdinEventPayload {
123
+ /**
124
+ * The ID of the room that was left. It's the same as the room id that was passed to join.
125
+ */
126
+ roomId: string;
127
+ }
128
+
129
+ /**
130
+ * The payload for the PeerJoined event.
131
+ */
132
+ export declare interface OdinPeerJoinedEventPayload extends OdinEventPayload {
133
+ /**
134
+ * The ID of the peer that joined.
135
+ */
136
+ peerId: number;
137
+
138
+ /**
139
+ * The ID of the user that joined.
140
+ */
141
+ userId: string;
142
+
143
+ /**
144
+ * The user data of the peer that joined.
145
+ */
146
+ userData: Uint8Array | undefined;
147
+ }
148
+
149
+ /**
150
+ * The payload for the PeerLeft event.
151
+ */
152
+ export declare interface OdinPeerLeftEventPayload extends OdinEventPayload {
153
+ /**
154
+ * The ID of the peer that left.
155
+ */
156
+ peerId: number;
157
+ }
158
+
159
+ /**
160
+ * The payload for the PeerUserDataChanged event.
161
+ */
162
+ export declare interface OdinPeerUserDataChangedEventPayload extends OdinEventPayload {
163
+ /**
164
+ * The ID of the peer that changed the user data.
165
+ */
166
+ peerId: number;
167
+
168
+ /**
169
+ * The new user data of the peer.
170
+ */
171
+ userData: Uint8Array | undefined;
172
+ }
173
+
174
+ /**
175
+ * The payload for the RoomUserDataChanged event.
176
+ */
177
+ export declare interface OdinRoomUserDataChangedEventPayload extends OdinEventPayload {
178
+ /**
179
+ * The new user data of the room.
180
+ */
181
+ userData: Uint8Array | undefined;
182
+ }
183
+
184
+ /**
185
+ * Connection states of the room
186
+ */
187
+ export declare type OdinConnectionState = 'connecting' | 'connected' | 'disconnecting' | 'disconnected' | 'unknown';
188
+
189
+ /**
190
+ * Change reasons for the connection state
191
+ */
192
+ export declare type OdinConnectionStateChangeReason = 'client_request' | 'server_request' | 'timeout' | 'unknown';
193
+
194
+ /**
195
+ * The payload for the ConnectionStateChanged event.
196
+ */
197
+ export declare interface OdinConnectionStateChangedEventPayload extends OdinEventPayload {
198
+ /**
199
+ * The new connection state of the room.
200
+ */
201
+ state: OdinConnectionState;
202
+
203
+ /**
204
+ * The error code if the connection state is Error.
205
+ */
206
+ reason: OdinConnectionStateChangeReason;
207
+ }
208
+
209
+ /**
210
+ * The payload for the MessageReceived event.
211
+ */
212
+ export declare interface OdinMessageReceivedEventPayload extends OdinEventPayload {
213
+ /**
214
+ * The ID of the peer that sent the message.
215
+ */
216
+ peerId: number;
217
+
218
+ /**
219
+ * The message data received from the peer.
220
+ */
221
+ messageData: Uint8Array;
222
+ }
223
+
224
+ /**
225
+ * The payload for the MediaAdded event.
226
+ */
227
+ export declare interface OdinMediaAddedEventPayload extends OdinEventPayload {
228
+ /**
229
+ * The ID of the peer that added the media.
230
+ */
231
+ peerId: number;
232
+
233
+ /**
234
+ * The ID of the media that was added.
235
+ */
236
+ mediaId: number;
237
+ }
238
+
239
+ /**
240
+ * The payload for the MediaRemoved event.
241
+ */
242
+ export declare interface OdinMediaRemovedEventPayload extends OdinEventPayload {
243
+ /**
244
+ * The ID of the peer that removed the media.
245
+ */
246
+ peerId: number;
247
+
248
+ /**
249
+ * The ID of the media that was removed.
250
+ */
251
+ mediaId: number;
252
+ }
253
+
254
+ /**
255
+ * The payload for the MediaActivity event.
256
+ */
257
+ export declare interface OdinMediaActivityEventPayload extends OdinEventPayload {
258
+ /**
259
+ * The ID of the peer that changed the media activity.
260
+ */
261
+ peerId: number;
262
+
263
+ /**
264
+ * The ID of the media that changed the activity.
265
+ */
266
+ mediaId: number;
267
+
268
+ /**
269
+ * Indicates if the media is currently active or not (i.e. user talking or not).
270
+ */
271
+ state: boolean;
272
+ }
273
+
274
+ /**
275
+ * The payload for the AudioDataReceived event.
276
+ */
277
+ export declare interface OdinAudioDataReceivedEventPayload {
278
+ /**
279
+ * The ID of the peer that sent the audio data.
280
+ */
281
+ peerId: number;
282
+
283
+ /**
284
+ * The ID of the media that sent the audio data.
285
+ */
286
+ mediaId: number;
287
+
288
+ /**
289
+ * The audio data received from the peer as 16-bit PCM samples ranging from -32768 to 32767 as a byte array.
290
+ * Use `const samplesArray = new Int16Array(samples16.buffer)` to get an actual array
291
+ */
292
+ samples16: Uint8Array;
293
+
294
+ /**
295
+ * The audio data received from the peer as 32-bit PCM samples ranging from -1 to 1.
296
+ * Use `const floats = new Float32Array(samples32.buffer)` to get an actual array
297
+ */
298
+ samples32: Uint8Array;
299
+ }
300
+
301
+ /**
302
+ * Noise suppression levels
303
+ */
304
+ export declare enum OdinNoiseSuppressionLevel {
305
+ /**
306
+ * Noise suppression is disabled
307
+ */
308
+ None = 0,
309
+
310
+ /**
311
+ * Use low suppression (6 dB)
312
+ */
313
+ Low = 1,
314
+
315
+ /**
316
+ * Use moderate suppression (12 dB)
317
+ */
318
+ Moderate = 2,
319
+
320
+ /**
321
+ * Use high suppression (18 dB)
322
+ */
323
+ High = 3,
324
+
325
+ /**
326
+ * Use very high suppression (21 dB)
327
+ */
328
+ VeryHigh = 4
329
+ }
330
+
331
+ export declare interface OdinAPMSettings {
332
+ /**
333
+ * Enables or disables voice activity detection (VAD)
334
+ */
335
+ voiceActivityDetection: boolean,
336
+
337
+ /**
338
+ * Voice probability value when the VAD should engage
339
+ */
340
+ voiceActivityDetectionAttackProbability: number,
341
+
342
+ /**
343
+ * Voice probability value when the VAD should disengage
344
+ */
345
+ voiceActivityDetectionReleaseProbability: number,
346
+
347
+ /**
348
+ * Enables or disables the input volume gate
349
+ */
350
+ volumeGate: boolean,
351
+
352
+ /**
353
+ * Root-mean-square power (dBFS) when the volume gate should engage
354
+ */
355
+ volumeGateAttackLoudness: number,
356
+
357
+ /**
358
+ * Root-mean-square power (dBFS) when the volume gate should disengage
359
+ */
360
+ volumeGateReleaseLoudness: number,
361
+
362
+ /**
363
+ * Enable or disable echo cancellation
364
+ */
365
+ echoCanceller: boolean,
366
+
367
+ /**
368
+ * Enable or disable high pass filtering
369
+ */
370
+ highPassFilter: boolean,
371
+
372
+ /**
373
+ * Enable or disable the pre amplifier
374
+ */
375
+ preAmplifier: boolean,
376
+
377
+ /**
378
+ * Set the aggressiveness of the suppression
379
+ */
380
+ noiseSuppressionLevel: OdinNoiseSuppressionLevel,
381
+
382
+ /**
383
+ * Enable or disable the transient suppressor
384
+ */
385
+ transientSuppressor: boolean,
386
+
387
+ /**
388
+ * Enable or disable the gain controller
389
+ */
390
+ gainController: boolean
391
+ }
392
+
393
+ /**
394
+ * The OdinRoom class. Use createRoom from OdinClient instance to create a room. The OdinRoom requires a token to connect
395
+ * to a room. OdinClients handles token creation for you, so its easier to just use OdinClient for room creation.
396
+ * Typical procedure is to create an OdinClient instance with an access key and call its `createRoom` function to create
397
+ * a room with a name and for a user id. Then add event listeners to the room and call `join` to connect to the room.
398
+ */
399
+ export declare class OdinRoom {
400
+ /**
401
+ * Creates a new instance of a room with a token. Use OdinClient if you don't want to manage tokens yourself.
402
+ * @param token {string} The token to use for this room.
403
+ */
404
+ constructor(token: string);
405
+
406
+ /**
407
+ * Joins the room with the given gateway URL and optional user data.
408
+ * @param gatewayUrl {string} The gateway URL to connect to. Use gateway.odin.4players.io if you are unsure.
409
+ * @param userData {Uint8Array} The user data to send to the room. This can be used to identify the user.
410
+ */
411
+ join(gatewayUrl: string, userData?: Uint8Array): void;
412
+
413
+ /**
414
+ * Sends a message to the room.
415
+ * @param message {Uint8Array} The message to send as a byte array.
416
+ * @param peerIdList {number[]} The list of peer IDs to send the message to. If this is undefined, the message will be sent to all peers. If the list is defined and empty an error will be thrown.
417
+ */
418
+ sendMessage(message: Uint8Array, peerIdList?: number[]): void;
419
+
420
+ /**
421
+ * Adds an event listener to the room for specific events.
422
+ * @param event {Event} The event to listen for (see keys of OdinEvents for possible values)
423
+ * @param callback {(data: any) => void} The callback to call when the event is fired.
424
+ */
425
+ addEventListener<Event extends keyof OdinEvents>(eventName: Event, handler: OdinEvents[Event]): void;
426
+
427
+ /**
428
+ * Removes an event listener from the room for specific events.
429
+ * @param event {Event} The event to remove the listener from (see keys of OdinEvents for possible values)
430
+ */
431
+ removeEventListener<Event extends keyof OdinEvents>(eventName: Event): void;
432
+
433
+ /**
434
+ * Sets a global event listener that received all events, this can be helpful for debugging. Please use addEventListener instead for production code.
435
+ * @param callback {(data: any) => void} The callback to call when the event is fired.
436
+ */
437
+ setEventListener(callback: (data: OdinEventPayload) => void): void;
438
+
439
+ /**
440
+ * Updates the peer user data of the local peer
441
+ * @param userData {Uint8Array} The new user data to set.
442
+ */
443
+ updateOwnUserData(userData: Uint8Array): void;
444
+
445
+ /**
446
+ * Updates the room user data (for all peers)
447
+ * @param userData {Uint8Array} The new user data to set.
448
+ */
449
+ updateRoomUserData(userData: Uint8Array): void;
450
+
451
+ /**
452
+ * Closes the room and disconnects from the server.
453
+ */
454
+ close(): void;
455
+
456
+ /**
457
+ * Gets the ID of the room.
458
+ */
459
+ get id(): string;
460
+
461
+ /**
462
+ * Gets the ID of the local peer joined to the room.
463
+ */
464
+ get ownPeerId(): number;
465
+
466
+ /**
467
+ * Creates a local audio stream and adds it to the room. An OdinMedia object will be returned that allows you to send
468
+ * audio data.
469
+ * @param sampleRate {number} The sample rate of the audio stream. Can be between 8000 and 48000.
470
+ * @param channels {number} The number of channels of the audio stream. Can be 1 or 2.
471
+ */
472
+ createAudioStream(sampleRate: number, channels: number, apmSettings?: OdinAPMSettings): OdinMedia;
473
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@4players/odin-nodejs",
3
+ "version": "0.7.0",
4
+ "description": "",
5
+ "main": "index.cjs",
6
+ "types": "index.d.ts",
7
+ "scripts": {
8
+ "build:debug": "node-gyp rebuild --debug",
9
+ "build:release": "node-gyp rebuild",
10
+ "build": "npm run build:release",
11
+ "clean": "node-gyp clean",
12
+ "install": "node-gyp-build"
13
+ },
14
+ "keywords": [],
15
+ "author": "Phillip Schuster",
16
+ "license": "MIT",
17
+ "private": false,
18
+ "gypfile": true,
19
+ "type": "module",
20
+ "dependencies": {
21
+ "@4players/odin-foundation": "^0.1.3",
22
+ "@4players/odin-tokens": "^1.3.0",
23
+ "audio-buffer-stream": "^1.1.0",
24
+ "audio-decode": "^2.1.1",
25
+ "audio-lena": "^2.3.0",
26
+ "node-addon-api": "^5.1.0",
27
+ "node-gyp-build": "^4.6.0",
28
+ "openai": "^3.2.1",
29
+ "prompt-sync": "^4.2.0",
30
+ "segfault-handler": "^1.3.0",
31
+ "throttle": "^1.0.3",
32
+ "wav": "^1.0.2"
33
+ },
34
+ "devDependencies": {
35
+ "node-gyp": "^9.3.1",
36
+ "prebuildify": "^5.0.1"
37
+ },
38
+ "engines": {
39
+ "node": ">=18"
40
+ },
41
+ "os": [
42
+ "darwin",
43
+ "linux",
44
+ "win32"
45
+ ],
46
+ "cpu": [
47
+ "x64",
48
+ "arm64"
49
+ ]
50
+ }