@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.
- package/.idea/.name +1 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/misc.xml +4 -0
- package/.idea/modules.xml +9 -0
- package/.idea/odin-nodejs.iml +8 -0
- package/.idea/odin_nodejs.iml +2 -0
- package/.idea/php.xml +19 -0
- package/.idea/vcs.xml +6 -0
- package/CMakeLists.txt +25 -0
- package/README.md +53 -0
- package/binding.gyp +61 -0
- package/build/Makefile +352 -0
- package/build/Release/.deps/Release/nothing.a.d +1 -0
- package/build/Release/.deps/Release/obj.target/nothing/node_modules/node-addon-api/nothing.o.d +4 -0
- package/build/Release/.deps/Release/obj.target/odin/cppsrc/binding.o.d +27 -0
- package/build/Release/.deps/Release/obj.target/odin/cppsrc/odinbindings.o.d +24 -0
- package/build/Release/.deps/Release/obj.target/odin/cppsrc/odinclient.o.d +24 -0
- package/build/Release/.deps/Release/obj.target/odin/cppsrc/odinmedia.o.d +24 -0
- package/build/Release/.deps/Release/obj.target/odin/cppsrc/odinroom.o.d +24 -0
- package/build/Release/.deps/Release/obj.target/odin/cppsrc/utilities.o.d +21 -0
- package/build/Release/.deps/Release/odin.node.d +1 -0
- package/build/Release/nothing.a +0 -0
- package/build/Release/obj.target/nothing/node_modules/node-addon-api/nothing.o +0 -0
- package/build/Release/obj.target/odin/cppsrc/binding.o +0 -0
- package/build/Release/obj.target/odin/cppsrc/odinbindings.o +0 -0
- package/build/Release/obj.target/odin/cppsrc/odinclient.o +0 -0
- package/build/Release/obj.target/odin/cppsrc/odinmedia.o +0 -0
- package/build/Release/obj.target/odin/cppsrc/odinroom.o +0 -0
- package/build/Release/obj.target/odin/cppsrc/utilities.o +0 -0
- package/build/binding.Makefile +6 -0
- package/build/gyp-mac-tool +772 -0
- package/build/node_modules/node-addon-api/node_api.Makefile +6 -0
- package/build/node_modules/node-addon-api/nothing.target.mk +186 -0
- package/build/odin.target.mk +201 -0
- package/cmake-build-debug/.cmake/api/v1/query/cache-v2 +0 -0
- package/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 +0 -0
- package/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 +0 -0
- package/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 +0 -0
- package/cmake-build-debug/.cmake/api/v1/reply/cache-v2-912a6d0c3c2c7ebbadf8.json +1183 -0
- package/cmake-build-debug/.cmake/api/v1/reply/cmakeFiles-v1-0825651e80f1fb47890c.json +161 -0
- package/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-bc24edc239de864eb886.json +60 -0
- package/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json +14 -0
- package/cmake-build-debug/.cmake/api/v1/reply/index-2023-03-18T11-25-22-0179.json +108 -0
- package/cmake-build-debug/.cmake/api/v1/reply/target-odin_nodejs-Debug-1ac16802f252a85492c7.json +322 -0
- package/cmake-build-debug/.cmake/api/v1/reply/toolchains-v1-b57293a485ebf36c82cc.json +88 -0
- package/cmake-build-debug/.ninja_log +1 -0
- package/cmake-build-debug/CMakeCache.txt +367 -0
- package/cmake-build-debug/CMakeFiles/3.24.2/CMakeCCompiler.cmake +72 -0
- package/cmake-build-debug/CMakeFiles/3.24.2/CMakeCXXCompiler.cmake +83 -0
- package/cmake-build-debug/CMakeFiles/3.24.2/CMakeDetermineCompilerABI_C.bin +0 -0
- package/cmake-build-debug/CMakeFiles/3.24.2/CMakeDetermineCompilerABI_CXX.bin +0 -0
- package/cmake-build-debug/CMakeFiles/3.24.2/CMakeSystem.cmake +15 -0
- package/cmake-build-debug/CMakeFiles/3.24.2/CompilerIdC/CMakeCCompilerId.c +838 -0
- package/cmake-build-debug/CMakeFiles/3.24.2/CompilerIdC/CMakeCCompilerId.o +0 -0
- package/cmake-build-debug/CMakeFiles/3.24.2/CompilerIdCXX/CMakeCXXCompilerId.cpp +826 -0
- package/cmake-build-debug/CMakeFiles/3.24.2/CompilerIdCXX/CMakeCXXCompilerId.o +0 -0
- package/cmake-build-debug/CMakeFiles/CMakeError.log +22 -0
- package/cmake-build-debug/CMakeFiles/CMakeOutput.log +250 -0
- package/cmake-build-debug/CMakeFiles/TargetDirectories.txt +3 -0
- package/cmake-build-debug/CMakeFiles/clion-Debug-log.txt +4 -0
- package/cmake-build-debug/CMakeFiles/clion-environment.txt +3 -0
- package/cmake-build-debug/CMakeFiles/cmake.check_cache +1 -0
- package/cmake-build-debug/CMakeFiles/rules.ninja +74 -0
- package/cmake-build-debug/Testing/Temporary/LastTest.log +3 -0
- package/cmake-build-debug/build.ninja +205 -0
- package/cmake-build-debug/cmake_install.cmake +49 -0
- package/cppsrc/binding.cpp +15 -0
- package/cppsrc/odinbindings.cpp +58 -0
- package/cppsrc/odinbindings.h +9 -0
- package/cppsrc/odinclient.cpp +162 -0
- package/cppsrc/odinclient.h +17 -0
- package/cppsrc/odinmedia.cpp +242 -0
- package/cppsrc/odinmedia.h +35 -0
- package/cppsrc/odinroom.cpp +738 -0
- package/cppsrc/odinroom.h +65 -0
- package/cppsrc/utilities.cpp +102 -0
- package/cppsrc/utilities.h +175 -0
- package/index.cjs +2 -0
- package/index.d.ts +5 -0
- package/libs/bin/linux/arm64/libodin_static.a +0 -0
- package/libs/bin/linux/ia32/libodin_static.a +0 -0
- package/libs/bin/linux/x64/libodin_static.a +0 -0
- package/libs/bin/macos/arm64/libodin_static.a +0 -0
- package/libs/bin/macos/x64/libodin_static.a +0 -0
- package/libs/bin/windows/arm64/odin_static.lib +0 -0
- package/libs/bin/windows/ia32/odin_static.lib +0 -0
- package/libs/bin/windows/x64/odin_static.lib +0 -0
- package/libs/include/odin.h +896 -0
- package/odin.client.d.ts +22 -0
- package/odin.media.d.ts +33 -0
- package/odin.room.d.ts +473 -0
- package/package.json +50 -0
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/test.js +211 -0
- package/tests/audio-recording/README.md +24 -0
- package/tests/audio-recording/index.js +148 -0
- package/tests/sending-audio/README.md +20 -0
- package/tests/sending-audio/index.js +81 -0
- package/tests/sending-audio/santa.mp3 +0 -0
|
@@ -0,0 +1,896 @@
|
|
|
1
|
+
/* Copyright (c) 4Players GmbH. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
/** @file */
|
|
6
|
+
|
|
7
|
+
#include <stdarg.h>
|
|
8
|
+
#include <stdbool.h>
|
|
9
|
+
#include <stddef.h>
|
|
10
|
+
#include <stdint.h>
|
|
11
|
+
#include <stdlib.h>
|
|
12
|
+
|
|
13
|
+
#define ODIN_VERSION "1.4.0"
|
|
14
|
+
|
|
15
|
+
#define Frame_SAMPLE_RATE 48000
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Supported channel layouts in audio functions.
|
|
19
|
+
*/
|
|
20
|
+
typedef enum OdinChannelLayout {
|
|
21
|
+
/**
|
|
22
|
+
* Samples are sequential
|
|
23
|
+
*/
|
|
24
|
+
OdinChannelLayout_Mono,
|
|
25
|
+
/**
|
|
26
|
+
* Channels are interleaved
|
|
27
|
+
*/
|
|
28
|
+
OdinChannelLayout_Stereo,
|
|
29
|
+
} OdinChannelLayout;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Known types of a media stream.
|
|
33
|
+
*
|
|
34
|
+
* Note: Video streams are not supported yet.
|
|
35
|
+
*/
|
|
36
|
+
typedef enum OdinMediaStreamType {
|
|
37
|
+
/**
|
|
38
|
+
* Media stream is of type audio
|
|
39
|
+
*/
|
|
40
|
+
OdinMediaStreamType_Audio,
|
|
41
|
+
/**
|
|
42
|
+
* Media stream is of type video
|
|
43
|
+
*/
|
|
44
|
+
OdinMediaStreamType_Video,
|
|
45
|
+
/**
|
|
46
|
+
* Media stream is invalid
|
|
47
|
+
*/
|
|
48
|
+
OdinMediaStreamType_Invalid,
|
|
49
|
+
} OdinMediaStreamType;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Valid levels for aggressiveness of the noise suppression. A higher level will reduce the noise
|
|
53
|
+
* level at the expense of a higher speech distortion.
|
|
54
|
+
*/
|
|
55
|
+
typedef enum OdinNoiseSuppressionLevel {
|
|
56
|
+
/**
|
|
57
|
+
* Noise suppression is disabled
|
|
58
|
+
*/
|
|
59
|
+
OdinNoiseSuppressionLevel_None,
|
|
60
|
+
/**
|
|
61
|
+
* Use low suppression (6 dB)
|
|
62
|
+
*/
|
|
63
|
+
OdinNoiseSuppressionLevel_Low,
|
|
64
|
+
/**
|
|
65
|
+
* Use moderate suppression (12 dB)
|
|
66
|
+
*/
|
|
67
|
+
OdinNoiseSuppressionLevel_Moderate,
|
|
68
|
+
/**
|
|
69
|
+
* Use high suppression (18 dB)
|
|
70
|
+
*/
|
|
71
|
+
OdinNoiseSuppressionLevel_High,
|
|
72
|
+
/**
|
|
73
|
+
* Use very high suppression (21 dB)
|
|
74
|
+
*/
|
|
75
|
+
OdinNoiseSuppressionLevel_VeryHigh,
|
|
76
|
+
} OdinNoiseSuppressionLevel;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* All valid connection states for an ODIN room.
|
|
80
|
+
*/
|
|
81
|
+
typedef enum OdinRoomConnectionState {
|
|
82
|
+
/**
|
|
83
|
+
* Connection is being established
|
|
84
|
+
*/
|
|
85
|
+
OdinRoomConnectionState_Connecting,
|
|
86
|
+
/**
|
|
87
|
+
* Connection is established
|
|
88
|
+
*/
|
|
89
|
+
OdinRoomConnectionState_Connected,
|
|
90
|
+
/**
|
|
91
|
+
* Connection is being closed
|
|
92
|
+
*/
|
|
93
|
+
OdinRoomConnectionState_Disconnecting,
|
|
94
|
+
/**
|
|
95
|
+
* Connection is closed
|
|
96
|
+
*/
|
|
97
|
+
OdinRoomConnectionState_Disconnected,
|
|
98
|
+
} OdinRoomConnectionState;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Possible reasons for connection state changes of an ODIN room.
|
|
102
|
+
*/
|
|
103
|
+
typedef enum OdinRoomConnectionStateChangeReason {
|
|
104
|
+
/**
|
|
105
|
+
* Connection state change was initiated by the user
|
|
106
|
+
*/
|
|
107
|
+
OdinRoomConnectionStateChangeReason_ClientRequested,
|
|
108
|
+
/**
|
|
109
|
+
* Connection state change was initiated by the server (e.g. peer was kicked)
|
|
110
|
+
*/
|
|
111
|
+
OdinRoomConnectionStateChangeReason_ServerRequested,
|
|
112
|
+
/**
|
|
113
|
+
* Connection state change was caused by a timeout
|
|
114
|
+
*/
|
|
115
|
+
OdinRoomConnectionStateChangeReason_ConnectionLost,
|
|
116
|
+
} OdinRoomConnectionStateChangeReason;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Valid audiences for ODIN room tokens.
|
|
120
|
+
*/
|
|
121
|
+
typedef enum OdinTokenAudience {
|
|
122
|
+
/**
|
|
123
|
+
* JWT has no audience
|
|
124
|
+
*/
|
|
125
|
+
OdinTokenAudience_None,
|
|
126
|
+
/**
|
|
127
|
+
* JWT is accepted the ODIN gateway
|
|
128
|
+
*/
|
|
129
|
+
OdinTokenAudience_Gateway,
|
|
130
|
+
/**
|
|
131
|
+
* JWT is accepted by the ODIN server
|
|
132
|
+
*/
|
|
133
|
+
OdinTokenAudience_Sfu,
|
|
134
|
+
} OdinTokenAudience;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Supported targets for user data updates.
|
|
138
|
+
*/
|
|
139
|
+
typedef enum OdinUserDataTarget {
|
|
140
|
+
/**
|
|
141
|
+
* Individual user data for your own peer
|
|
142
|
+
*/
|
|
143
|
+
OdinUserDataTarget_Peer,
|
|
144
|
+
/**
|
|
145
|
+
* Global user data for the room
|
|
146
|
+
*/
|
|
147
|
+
OdinUserDataTarget_Room,
|
|
148
|
+
} OdinUserDataTarget;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* A pointer to a local ODIN token generator used to generate signed room tokens based based on an
|
|
152
|
+
* access key. Please note, that access keys are your the unique authentication keys to be used to
|
|
153
|
+
* generate room tokens for accessing the ODIN server network. For your own security, we strongly
|
|
154
|
+
* recommend that you _NEVER_ put an access key in your client code and generate room tokens on a
|
|
155
|
+
* server.
|
|
156
|
+
*/
|
|
157
|
+
typedef struct OdinTokenGenerator OdinTokenGenerator;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A numeric code returned by ODIN function calls. Use `odin_is_error` to determine whether the
|
|
161
|
+
* code represents an error or an actual result value.
|
|
162
|
+
*
|
|
163
|
+
* Note: Use `odin_error_format` to get a human readable string to represent error codes.
|
|
164
|
+
*/
|
|
165
|
+
typedef uint32_t OdinReturnCode;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Internal handle identifier for an ODIN room to interact with.
|
|
169
|
+
*/
|
|
170
|
+
typedef size_t OdinRoomHandle;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Internal handle identifier for an ODIN audio/video stream used to send/receive data.
|
|
174
|
+
*/
|
|
175
|
+
typedef size_t OdinMediaStreamHandle;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* All the different events emitted from an ODIN room.
|
|
179
|
+
*/
|
|
180
|
+
typedef enum OdinEventTag {
|
|
181
|
+
/**
|
|
182
|
+
* Emitted after joining once initial room information was processed
|
|
183
|
+
*/
|
|
184
|
+
OdinEvent_Joined,
|
|
185
|
+
/**
|
|
186
|
+
* Emitted when other peers joined the room
|
|
187
|
+
*/
|
|
188
|
+
OdinEvent_PeerJoined,
|
|
189
|
+
/**
|
|
190
|
+
* Emitted when other peers left the room
|
|
191
|
+
*/
|
|
192
|
+
OdinEvent_PeerLeft,
|
|
193
|
+
/**
|
|
194
|
+
* Emitted when other peers updated their user data
|
|
195
|
+
*/
|
|
196
|
+
OdinEvent_PeerUserDataChanged,
|
|
197
|
+
/**
|
|
198
|
+
* Emitted when other peers started a media stream
|
|
199
|
+
*/
|
|
200
|
+
OdinEvent_MediaAdded,
|
|
201
|
+
/**
|
|
202
|
+
* Emitted when other peers stopped a media stream
|
|
203
|
+
*/
|
|
204
|
+
OdinEvent_MediaRemoved,
|
|
205
|
+
/**
|
|
206
|
+
* Emitted whenever data is sent/received over any known media
|
|
207
|
+
*/
|
|
208
|
+
OdinEvent_MediaActiveStateChanged,
|
|
209
|
+
/**
|
|
210
|
+
* Emitted when other peers changed the global user data of the room itself
|
|
211
|
+
*/
|
|
212
|
+
OdinEvent_RoomUserDataChanged,
|
|
213
|
+
/**
|
|
214
|
+
* Emitted when the internal room connection state of the ODIN client changed
|
|
215
|
+
*/
|
|
216
|
+
OdinEvent_RoomConnectionStateChanged,
|
|
217
|
+
/**
|
|
218
|
+
* Emitted when others peers sent arbitrary data
|
|
219
|
+
*/
|
|
220
|
+
OdinEvent_MessageReceived,
|
|
221
|
+
} OdinEventTag;
|
|
222
|
+
|
|
223
|
+
typedef struct OdinEvent_JoinedData {
|
|
224
|
+
/**
|
|
225
|
+
* Name of the joined room (null-terminated)
|
|
226
|
+
*/
|
|
227
|
+
const char *room_id;
|
|
228
|
+
/**
|
|
229
|
+
* Length of the room name
|
|
230
|
+
*/
|
|
231
|
+
size_t room_id_len;
|
|
232
|
+
/**
|
|
233
|
+
* Byte array with arbitrary user data of the room
|
|
234
|
+
*/
|
|
235
|
+
const uint8_t *room_user_data;
|
|
236
|
+
/**
|
|
237
|
+
* Length of the room user data array
|
|
238
|
+
*/
|
|
239
|
+
size_t room_user_data_len;
|
|
240
|
+
/**
|
|
241
|
+
* Identifier of the customer the room is assigned to (nul-terminated)
|
|
242
|
+
*/
|
|
243
|
+
const char *customer;
|
|
244
|
+
/**
|
|
245
|
+
* Length of the customer identifier
|
|
246
|
+
*/
|
|
247
|
+
size_t customer_len;
|
|
248
|
+
/**
|
|
249
|
+
* Own peer ID assigned by the server
|
|
250
|
+
*/
|
|
251
|
+
uint64_t own_peer_id;
|
|
252
|
+
/**
|
|
253
|
+
* Own user identifier of the peer specified during authentication (null-terminated)
|
|
254
|
+
*/
|
|
255
|
+
const char *own_user_id;
|
|
256
|
+
/**
|
|
257
|
+
* Length of the own user identifier
|
|
258
|
+
*/
|
|
259
|
+
size_t own_user_id_len;
|
|
260
|
+
} OdinEvent_JoinedData;
|
|
261
|
+
|
|
262
|
+
typedef struct OdinEvent_PeerJoinedData {
|
|
263
|
+
/**
|
|
264
|
+
* ID of the peer
|
|
265
|
+
*/
|
|
266
|
+
uint64_t peer_id;
|
|
267
|
+
/**
|
|
268
|
+
* Byte array with arbitrary user data of the peer
|
|
269
|
+
*/
|
|
270
|
+
const uint8_t *peer_user_data;
|
|
271
|
+
/**
|
|
272
|
+
* Length of the room user data array
|
|
273
|
+
*/
|
|
274
|
+
size_t peer_user_data_len;
|
|
275
|
+
/**
|
|
276
|
+
* User identifier of the peer specified during authentication (null-terminated)
|
|
277
|
+
*/
|
|
278
|
+
const char *user_id;
|
|
279
|
+
/**
|
|
280
|
+
* Length of the user identifier
|
|
281
|
+
*/
|
|
282
|
+
size_t user_id_len;
|
|
283
|
+
} OdinEvent_PeerJoinedData;
|
|
284
|
+
|
|
285
|
+
typedef struct OdinEvent_PeerLeftData {
|
|
286
|
+
/**
|
|
287
|
+
* ID of the peer
|
|
288
|
+
*/
|
|
289
|
+
uint64_t peer_id;
|
|
290
|
+
} OdinEvent_PeerLeftData;
|
|
291
|
+
|
|
292
|
+
typedef struct OdinEvent_PeerUserDataChangedData {
|
|
293
|
+
/**
|
|
294
|
+
* ID of the peer
|
|
295
|
+
*/
|
|
296
|
+
uint64_t peer_id;
|
|
297
|
+
/**
|
|
298
|
+
* Byte array with arbitrary user data of the peer
|
|
299
|
+
*/
|
|
300
|
+
const uint8_t *peer_user_data;
|
|
301
|
+
/**
|
|
302
|
+
* Length of the room user data array
|
|
303
|
+
*/
|
|
304
|
+
size_t peer_user_data_len;
|
|
305
|
+
} OdinEvent_PeerUserDataChangedData;
|
|
306
|
+
|
|
307
|
+
typedef struct OdinEvent_MediaAddedData {
|
|
308
|
+
/**
|
|
309
|
+
* ID of the peer this media belongs to
|
|
310
|
+
*/
|
|
311
|
+
uint64_t peer_id;
|
|
312
|
+
/**
|
|
313
|
+
* Handle identifier of the new audio/video stream
|
|
314
|
+
*/
|
|
315
|
+
OdinMediaStreamHandle media_handle;
|
|
316
|
+
} OdinEvent_MediaAddedData;
|
|
317
|
+
|
|
318
|
+
typedef struct OdinEvent_MediaRemovedData {
|
|
319
|
+
/**
|
|
320
|
+
* ID of the peer this media belongs to
|
|
321
|
+
*/
|
|
322
|
+
uint64_t peer_id;
|
|
323
|
+
/**
|
|
324
|
+
* Handle identifier of the audio/video stream
|
|
325
|
+
*/
|
|
326
|
+
OdinMediaStreamHandle media_handle;
|
|
327
|
+
} OdinEvent_MediaRemovedData;
|
|
328
|
+
|
|
329
|
+
typedef struct OdinEvent_MediaActiveStateChangedData {
|
|
330
|
+
/**
|
|
331
|
+
* ID of the peer this media belongs to
|
|
332
|
+
*/
|
|
333
|
+
uint64_t peer_id;
|
|
334
|
+
/**
|
|
335
|
+
* Handle identifier of the audio/video stream
|
|
336
|
+
*/
|
|
337
|
+
OdinMediaStreamHandle media_handle;
|
|
338
|
+
/**
|
|
339
|
+
* Indicator for whether or not the media is sending/receiving data
|
|
340
|
+
*/
|
|
341
|
+
bool active;
|
|
342
|
+
} OdinEvent_MediaActiveStateChangedData;
|
|
343
|
+
|
|
344
|
+
typedef struct OdinEvent_RoomUserDataChangedData {
|
|
345
|
+
/**
|
|
346
|
+
* Byte array with arbitrary user data of the room
|
|
347
|
+
*/
|
|
348
|
+
const uint8_t *room_user_data;
|
|
349
|
+
/**
|
|
350
|
+
* Length of the room user data array
|
|
351
|
+
*/
|
|
352
|
+
size_t room_user_data_len;
|
|
353
|
+
} OdinEvent_RoomUserDataChangedData;
|
|
354
|
+
|
|
355
|
+
typedef struct OdinEvent_RoomConnectionStateChangedData {
|
|
356
|
+
/**
|
|
357
|
+
* Status of the room connection
|
|
358
|
+
*/
|
|
359
|
+
enum OdinRoomConnectionState state;
|
|
360
|
+
/**
|
|
361
|
+
* Reason for this update
|
|
362
|
+
*/
|
|
363
|
+
enum OdinRoomConnectionStateChangeReason reason;
|
|
364
|
+
} OdinEvent_RoomConnectionStateChangedData;
|
|
365
|
+
|
|
366
|
+
typedef struct OdinEvent_MessageReceivedData {
|
|
367
|
+
/**
|
|
368
|
+
* ID of the peer who sent this message
|
|
369
|
+
*/
|
|
370
|
+
uint64_t peer_id;
|
|
371
|
+
/**
|
|
372
|
+
* Byte array with arbitrary data received
|
|
373
|
+
*/
|
|
374
|
+
const uint8_t *data;
|
|
375
|
+
/**
|
|
376
|
+
* Length of the data array
|
|
377
|
+
*/
|
|
378
|
+
size_t data_len;
|
|
379
|
+
} OdinEvent_MessageReceivedData;
|
|
380
|
+
|
|
381
|
+
typedef struct OdinEvent {
|
|
382
|
+
OdinEventTag tag;
|
|
383
|
+
union {
|
|
384
|
+
OdinEvent_JoinedData joined;
|
|
385
|
+
OdinEvent_PeerJoinedData peer_joined;
|
|
386
|
+
OdinEvent_PeerLeftData peer_left;
|
|
387
|
+
OdinEvent_PeerUserDataChangedData peer_user_data_changed;
|
|
388
|
+
OdinEvent_MediaAddedData media_added;
|
|
389
|
+
OdinEvent_MediaRemovedData media_removed;
|
|
390
|
+
OdinEvent_MediaActiveStateChangedData media_active_state_changed;
|
|
391
|
+
OdinEvent_RoomUserDataChangedData room_user_data_changed;
|
|
392
|
+
OdinEvent_RoomConnectionStateChangedData room_connection_state_changed;
|
|
393
|
+
OdinEvent_MessageReceivedData message_received;
|
|
394
|
+
};
|
|
395
|
+
} OdinEvent;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Statistics for the underlying connection of a room.
|
|
399
|
+
*/
|
|
400
|
+
typedef struct OdinConnectionStats {
|
|
401
|
+
/**
|
|
402
|
+
* The amount of outgoing UDP datagrams observed
|
|
403
|
+
*/
|
|
404
|
+
uint64_t udp_tx_datagrams;
|
|
405
|
+
/**
|
|
406
|
+
* The amount of outgoing acknowledgement frames observed
|
|
407
|
+
*/
|
|
408
|
+
uint64_t udp_tx_acks;
|
|
409
|
+
/**
|
|
410
|
+
* The total amount of bytes which have been transferred inside outgoing UDP datagrams
|
|
411
|
+
*/
|
|
412
|
+
uint64_t udp_tx_bytes;
|
|
413
|
+
/**
|
|
414
|
+
* The amount of incoming UDP datagrams observed
|
|
415
|
+
*/
|
|
416
|
+
uint64_t udp_rx_datagrams;
|
|
417
|
+
/**
|
|
418
|
+
* The amount of incoming acknowledgement frames observed
|
|
419
|
+
*/
|
|
420
|
+
uint64_t udp_rx_acks;
|
|
421
|
+
/**
|
|
422
|
+
* The total amount of bytes which have been transferred inside incoming UDP datagrams
|
|
423
|
+
*/
|
|
424
|
+
uint64_t udp_rx_bytes;
|
|
425
|
+
/**
|
|
426
|
+
* Current congestion window of the connection
|
|
427
|
+
*/
|
|
428
|
+
uint64_t cwnd;
|
|
429
|
+
/**
|
|
430
|
+
* Congestion events on the connection
|
|
431
|
+
*/
|
|
432
|
+
uint64_t congestion_events;
|
|
433
|
+
/**
|
|
434
|
+
* Current best estimate of the connection latency (round-trip-time) in milliseconds
|
|
435
|
+
*/
|
|
436
|
+
float rtt;
|
|
437
|
+
} OdinConnectionStats;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Per-room configuration of the ODIN audio processing module which provides a variety of smart
|
|
441
|
+
* enhancement algorithms.
|
|
442
|
+
*/
|
|
443
|
+
typedef struct OdinApmConfig {
|
|
444
|
+
/**
|
|
445
|
+
* Enables or disables voice activity detection (VAD)
|
|
446
|
+
*/
|
|
447
|
+
bool voice_activity_detection;
|
|
448
|
+
/**
|
|
449
|
+
* Voice probability value when the VAD should engage
|
|
450
|
+
*/
|
|
451
|
+
float voice_activity_detection_attack_probability;
|
|
452
|
+
/**
|
|
453
|
+
* Voice probability value when the VAD should disengage
|
|
454
|
+
*/
|
|
455
|
+
float voice_activity_detection_release_probability;
|
|
456
|
+
/**
|
|
457
|
+
* Enables or disables the input volume gate
|
|
458
|
+
*/
|
|
459
|
+
bool volume_gate;
|
|
460
|
+
/**
|
|
461
|
+
* Root mean square power (dBFS) when the volume gate should engage
|
|
462
|
+
*/
|
|
463
|
+
float volume_gate_attack_loudness;
|
|
464
|
+
/**
|
|
465
|
+
* Root mean square power (dBFS) when the volume gate should disengage
|
|
466
|
+
*/
|
|
467
|
+
float volume_gate_release_loudness;
|
|
468
|
+
/**
|
|
469
|
+
* Enable or disable echo cancellation
|
|
470
|
+
*/
|
|
471
|
+
bool echo_canceller;
|
|
472
|
+
/**
|
|
473
|
+
* Enable or disable high pass filtering
|
|
474
|
+
*/
|
|
475
|
+
bool high_pass_filter;
|
|
476
|
+
/**
|
|
477
|
+
* Enable or disable the pre amplifier
|
|
478
|
+
*/
|
|
479
|
+
bool pre_amplifier;
|
|
480
|
+
/**
|
|
481
|
+
* Set the aggressiveness of the suppression
|
|
482
|
+
*/
|
|
483
|
+
enum OdinNoiseSuppressionLevel noise_suppression_level;
|
|
484
|
+
/**
|
|
485
|
+
* Enable or disable the transient suppressor
|
|
486
|
+
*/
|
|
487
|
+
bool transient_suppressor;
|
|
488
|
+
/**
|
|
489
|
+
* Enable or disable the gain controller
|
|
490
|
+
*/
|
|
491
|
+
bool gain_controller;
|
|
492
|
+
} OdinApmConfig;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Audio stream configuration.
|
|
496
|
+
*/
|
|
497
|
+
typedef struct OdinAudioStreamConfig {
|
|
498
|
+
/**
|
|
499
|
+
* The number of samples per second in hertz (between 8000 and 192000)
|
|
500
|
+
*/
|
|
501
|
+
uint32_t sample_rate;
|
|
502
|
+
/**
|
|
503
|
+
* The number of channels for the new audio stream (between 1 and 2)
|
|
504
|
+
*/
|
|
505
|
+
uint8_t channel_count;
|
|
506
|
+
} OdinAudioStreamConfig;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Audio stream statistics.
|
|
510
|
+
*/
|
|
511
|
+
typedef struct OdinAudioStreamStats {
|
|
512
|
+
/**
|
|
513
|
+
* The total number of packets seen by the medias jitter buffer.
|
|
514
|
+
*/
|
|
515
|
+
uint32_t packets_total;
|
|
516
|
+
/**
|
|
517
|
+
* The number of packets processed by the medias jitter buffer.
|
|
518
|
+
*/
|
|
519
|
+
uint32_t packets_processed;
|
|
520
|
+
/**
|
|
521
|
+
* The number of packets dropped because they seemed to arrive too early.
|
|
522
|
+
*/
|
|
523
|
+
uint32_t packets_arrived_too_early;
|
|
524
|
+
/**
|
|
525
|
+
* The number of packets dropped because they seemed to arrive too late.
|
|
526
|
+
*/
|
|
527
|
+
uint32_t packets_arrived_too_late;
|
|
528
|
+
/**
|
|
529
|
+
* The number of packets dropped due to a jitter buffer reset.
|
|
530
|
+
*/
|
|
531
|
+
uint32_t packets_dropped;
|
|
532
|
+
/**
|
|
533
|
+
* The number of packets marked as invalid.
|
|
534
|
+
*/
|
|
535
|
+
uint32_t packets_invalid;
|
|
536
|
+
/**
|
|
537
|
+
* The number of packets marked as duplicates.
|
|
538
|
+
*/
|
|
539
|
+
uint32_t packets_repeated;
|
|
540
|
+
/**
|
|
541
|
+
* The number of packets marked as lost during transmission.
|
|
542
|
+
*/
|
|
543
|
+
uint32_t packets_lost;
|
|
544
|
+
} OdinAudioStreamStats;
|
|
545
|
+
|
|
546
|
+
typedef size_t OdinResamplerHandle;
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Options for ODIN room tokens.
|
|
550
|
+
*/
|
|
551
|
+
typedef struct OdinTokenOptions {
|
|
552
|
+
/**
|
|
553
|
+
* Customer identifier (you should _NOT_ set this unless connecting directly to an ODIN server)
|
|
554
|
+
*/
|
|
555
|
+
const char *customer;
|
|
556
|
+
/**
|
|
557
|
+
* Audience of the token
|
|
558
|
+
*/
|
|
559
|
+
enum OdinTokenAudience audience;
|
|
560
|
+
/**
|
|
561
|
+
* Token lifetime in seconds
|
|
562
|
+
*/
|
|
563
|
+
uint64_t lifetime;
|
|
564
|
+
} OdinTokenOptions;
|
|
565
|
+
|
|
566
|
+
#ifdef __cplusplus
|
|
567
|
+
extern "C" {
|
|
568
|
+
#endif // __cplusplus
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Formats an ODIN return code into a human readable string representation for use in logging and
|
|
572
|
+
* diagnostics. If `buf` is `NULL` this functions simply returns the required buffer length to
|
|
573
|
+
* store the output buffer.
|
|
574
|
+
*/
|
|
575
|
+
size_t odin_error_format(OdinReturnCode error, char *buf, size_t buf_len);
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Checks whether the code returned from ODIN function calls represents an error or an actual
|
|
579
|
+
* result. This is used to easier work with certain functions that might return an error or a
|
|
580
|
+
* valid result like `odin_audio_data_len`.
|
|
581
|
+
* Internally this simply does `(code >> 29) > 0`.
|
|
582
|
+
*/
|
|
583
|
+
bool odin_is_error(OdinReturnCode code);
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Starts the internal ODIN client runtime using recommended settings for audio output and verifies
|
|
587
|
+
* that the correct API header file is used. This is ref-counted so you need matching calls of startup
|
|
588
|
+
* and shutdown in your application. A lot of the functions in the API require a running ODIN runtime.
|
|
589
|
+
* With the only exception being the `access_key` and `token_generator` related functions.
|
|
590
|
+
*
|
|
591
|
+
* Note: Use `ODIN_VERSION` to pass the `version` argument.
|
|
592
|
+
*/
|
|
593
|
+
bool odin_startup(const char *version);
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Starts the internal ODIN client runtime and allows passing the sample rate and channel layout
|
|
597
|
+
* for audio output. This is ref-counted so you need matching calls of startup and shutdown in your
|
|
598
|
+
* application.
|
|
599
|
+
*
|
|
600
|
+
* Note: Make sure to use the same settings on consecutive calls of this function.
|
|
601
|
+
*/
|
|
602
|
+
bool odin_startup_ex(const char *version,
|
|
603
|
+
uint32_t output_sample_rate,
|
|
604
|
+
enum OdinChannelLayout output_channel_layout);
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Terminates the internal ODIN runtime. This function _should_ be called before shutting down
|
|
608
|
+
* the application. After calling this function all `odin_*` methods will fail immediately.
|
|
609
|
+
* (Given the internal ref-count reached zero. See `odin_startup` for more information)
|
|
610
|
+
*/
|
|
611
|
+
void odin_shutdown(void);
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Creates a new ODIN room handle in an unconnected state and returns its handle identifier. This
|
|
615
|
+
* will return `0` when the internal ODIN client runtime is not initialized using `odin_startup`
|
|
616
|
+
* or has already been terminated using `odin_shutdown`.
|
|
617
|
+
*/
|
|
618
|
+
OdinRoomHandle odin_room_create(void);
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Closes the specified ODIN room handle, thus making our own peer leave the room on the server
|
|
622
|
+
* and closing the connection if needed.
|
|
623
|
+
*/
|
|
624
|
+
OdinReturnCode odin_room_close(OdinRoomHandle room);
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Destroys the specified ODIN room handle.
|
|
628
|
+
*/
|
|
629
|
+
OdinReturnCode odin_room_destroy(OdinRoomHandle room);
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Sets the event callback on the the specified `OdinRoomHandle`. Generally this should be called
|
|
633
|
+
* _once_ before joining a room.
|
|
634
|
+
*/
|
|
635
|
+
OdinReturnCode odin_room_set_event_callback(OdinRoomHandle room,
|
|
636
|
+
void (*callback)(OdinRoomHandle room,
|
|
637
|
+
const struct OdinEvent *event,
|
|
638
|
+
void *extra_data),
|
|
639
|
+
void *extra_data);
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Sets the scaling used for all coordinates passed to `odin_room_update_position`. This allows
|
|
643
|
+
* adapting to the individual needs of your game coordinate system if necessary. Only peers within
|
|
644
|
+
* a unit circle with a radius of `1.0` are able to 'see' each other. When changing the position
|
|
645
|
+
* of a peer, the position must be scaled such as that the maximum distance is one or less. The
|
|
646
|
+
* scaling can be done either manually or by setting the multiplicative scale here.
|
|
647
|
+
*
|
|
648
|
+
* Note: Please make sure that all of your client apps use the same scaling.
|
|
649
|
+
*/
|
|
650
|
+
OdinReturnCode odin_room_set_position_scale(OdinRoomHandle room, float scale);
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Joins a room on an ODIN server. This function takes an URL to an ODIN gateway and a signed room
|
|
654
|
+
* token obtained externally that authorizes the client to establish the connection. Unless you're
|
|
655
|
+
* hosting your own servers, always use gateway running at `https://gateway.odin.4players.io`.
|
|
656
|
+
*/
|
|
657
|
+
OdinReturnCode odin_room_join(OdinRoomHandle room, const char *url, const char *token);
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Retrieves the room ID (e.g. the name of the room) from the specified `OdinRoomHandle`.
|
|
661
|
+
*/
|
|
662
|
+
OdinReturnCode odin_room_id(OdinRoomHandle room, char *out_id, size_t out_id_len);
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Retrieves the identifier of the customer the room is assigned to from the specified `OdinRoomHandle`.
|
|
666
|
+
*/
|
|
667
|
+
OdinReturnCode odin_room_customer(OdinRoomHandle room,
|
|
668
|
+
char *out_customer,
|
|
669
|
+
size_t out_customer_len);
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Retrieves your own peer ID from the specified `OdinRoomHandle`.
|
|
673
|
+
*/
|
|
674
|
+
OdinReturnCode odin_room_peer_id(OdinRoomHandle room, uint64_t *out_peer_id);
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Retrieves statistics for the underlying connection of the specified `OdinRoomHandle`.
|
|
678
|
+
*/
|
|
679
|
+
OdinReturnCode odin_room_connection_stats(OdinRoomHandle room, struct OdinConnectionStats *stats);
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Updates the custom user data for either your own peer or the specified `OdinRoomHandle` itself.
|
|
683
|
+
* All user data is synced automatically, which allows storing of arbitrary information for each
|
|
684
|
+
* individual peer and even globally for the room if needed.
|
|
685
|
+
*
|
|
686
|
+
* Note: Use this before calling `odin_room_join` to set initial peer user data upon connect.
|
|
687
|
+
*/
|
|
688
|
+
OdinReturnCode odin_room_update_user_data(OdinRoomHandle room,
|
|
689
|
+
enum OdinUserDataTarget target,
|
|
690
|
+
const uint8_t *user_data,
|
|
691
|
+
size_t user_data_length);
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Updates the two-dimensional position of your own peer in the given `OdinRoomHandle`. The server
|
|
695
|
+
* will use the specified coordinates for each peer in the same room to apply automatic culling
|
|
696
|
+
* based on unit circles with a radius of `1.0`. This is ideal for any scenario, where you want to
|
|
697
|
+
* put a very large number of peers into the same room and make them only 'see' each other while
|
|
698
|
+
* being in proximity. Additionally, you can use `odin_room_set_position_scale` to adjust the
|
|
699
|
+
* distance multiplier for position updates if needed.
|
|
700
|
+
*
|
|
701
|
+
* Note: Use this before calling `odin_room_join` to set the initial peer position upon connect.
|
|
702
|
+
*/
|
|
703
|
+
OdinReturnCode odin_room_update_position(OdinRoomHandle room, float x, float y);
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Sends arbitrary data to a list of target peers over the ODIN server. If `NULL` is specified, the
|
|
707
|
+
* message will be sent to all other peers in the same room.
|
|
708
|
+
*/
|
|
709
|
+
OdinReturnCode odin_room_send_message(OdinRoomHandle room,
|
|
710
|
+
const uint64_t *peer_id_list,
|
|
711
|
+
size_t peer_id_list_size,
|
|
712
|
+
const uint8_t *data,
|
|
713
|
+
size_t data_length);
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Adds a specified `OdinMediaStreamHandle` to the room. Please note, that this can only be done
|
|
717
|
+
* _once_ on a given media. Trying to do it more than once will return an error on subsequent calls
|
|
718
|
+
* to this function.
|
|
719
|
+
*/
|
|
720
|
+
OdinReturnCode odin_room_add_media(OdinRoomHandle room, OdinMediaStreamHandle media);
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Configures the ODIN audio processing module on the room with the specified config.
|
|
724
|
+
*/
|
|
725
|
+
OdinReturnCode odin_room_configure_apm(OdinRoomHandle room, struct OdinApmConfig config);
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Creates a new audio stream, which can be added to a room and send data over it.
|
|
729
|
+
*/
|
|
730
|
+
OdinMediaStreamHandle odin_audio_stream_create(struct OdinAudioStreamConfig config);
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Creates a new video stream, which can be added to a room and send data over it.
|
|
734
|
+
*
|
|
735
|
+
* Note: Video streams are not supported yet.
|
|
736
|
+
*/
|
|
737
|
+
OdinMediaStreamHandle odin_video_stream_create(void);
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Destroys the specified `OdinMediaStreamHandle`, after which you will no longer be able to
|
|
741
|
+
* receive or send any data over it. If the media is currently 'attached' to a room it will be
|
|
742
|
+
* removed.
|
|
743
|
+
*/
|
|
744
|
+
OdinReturnCode odin_media_stream_destroy(OdinMediaStreamHandle stream);
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Retrieves the media ID of the specified `OdinMediaStreamHandle`.
|
|
748
|
+
*/
|
|
749
|
+
OdinReturnCode odin_media_stream_media_id(OdinMediaStreamHandle stream, uint16_t *out_media_id);
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Retrieves the peer ID of the specified `OdinMediaStreamHandle`.
|
|
753
|
+
*/
|
|
754
|
+
OdinReturnCode odin_media_stream_peer_id(OdinMediaStreamHandle stream, uint64_t *out_peer_id);
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Returns the type of the specified media stream.
|
|
758
|
+
*
|
|
759
|
+
* Note: This function will always return `OdinMediaStreamType_Audio` at the moment.
|
|
760
|
+
*/
|
|
761
|
+
enum OdinMediaStreamType odin_media_stream_type(OdinMediaStreamHandle stream);
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Sends data to the audio stream. The data has to be interleaved [-1, 1] float data.
|
|
765
|
+
*/
|
|
766
|
+
OdinReturnCode odin_audio_push_data(OdinMediaStreamHandle stream, const float *buf, size_t buf_len);
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Reads audio data from the specified `OdinMediaStreamHandle`. This will return audio data in
|
|
770
|
+
* 48kHz interleaved.
|
|
771
|
+
*
|
|
772
|
+
* Note: `out_channel_layout` is reserved for future use.
|
|
773
|
+
*/
|
|
774
|
+
OdinReturnCode odin_audio_read_data(OdinMediaStreamHandle stream,
|
|
775
|
+
float *out_buffer,
|
|
776
|
+
size_t out_buffer_len);
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Retrieves statistics for the specified `OdinMediaStreamHandle`.
|
|
780
|
+
*
|
|
781
|
+
* Note: This will only work for output streams.
|
|
782
|
+
*/
|
|
783
|
+
OdinReturnCode odin_audio_stats(OdinMediaStreamHandle stream, struct OdinAudioStreamStats *stats);
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Reads up to `out_buffer_len` samples from the given streams and mixes them into the `out_buffer`.
|
|
787
|
+
* All audio streams will be read based on a 48khz sample rate so make sure to allocate the buffer
|
|
788
|
+
* accordingly. After the call the `out_buffer_len` will contain the amount of samples that have
|
|
789
|
+
* actually been read and mixed into `out_buffer`.
|
|
790
|
+
*
|
|
791
|
+
* If enabled this will also apply any audio processing to the output stream and feed back required
|
|
792
|
+
* data to the internal audio processing pipeline which requires a final mix.
|
|
793
|
+
*/
|
|
794
|
+
OdinReturnCode odin_audio_mix_streams(OdinRoomHandle room,
|
|
795
|
+
const OdinMediaStreamHandle *streams,
|
|
796
|
+
size_t stream_count,
|
|
797
|
+
float *out_buffer,
|
|
798
|
+
size_t out_buffer_len);
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Processes the reverse audio stream, also known as the loopback data to be used in the ODIN echo
|
|
802
|
+
* canceller. This should only be done if you are _NOT_ using `odin_audio_mix_streams`.
|
|
803
|
+
*/
|
|
804
|
+
OdinReturnCode odin_audio_process_reverse(OdinRoomHandle room, float *buffer, size_t buffer_len);
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Creates a new ODIN resampler instance. This is intended for situations where your audio pipeline
|
|
808
|
+
* doesn't support 48 kHz.
|
|
809
|
+
*
|
|
810
|
+
* Note: One resampler should be used exclusively per audio stream.
|
|
811
|
+
*/
|
|
812
|
+
OdinResamplerHandle odin_resampler_create(uint32_t from_rate,
|
|
813
|
+
uint32_t to_rate,
|
|
814
|
+
uint16_t channel_count);
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Resamples a single chunk of audio. If the ODIN resampler instance was created with multiple
|
|
818
|
+
* channels, the data is assumed to be interleaved. The `output_capacity` argument also serves as
|
|
819
|
+
* an out parameter when the provided capacity wasn't enough to fulfill the resample request, in
|
|
820
|
+
* which case this function will write the minimum required buffer size into the given variable.
|
|
821
|
+
* On success, the written size for the processed sample is returned in both, the return value
|
|
822
|
+
* and the `output_capacity` out parameter.
|
|
823
|
+
*/
|
|
824
|
+
OdinReturnCode odin_resampler_process(OdinResamplerHandle resampler,
|
|
825
|
+
const float *input,
|
|
826
|
+
size_t input_len,
|
|
827
|
+
float *output,
|
|
828
|
+
size_t *output_capacity);
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* Destroys the given ODIN resampler instance. After this call, all attempts to use this handle
|
|
832
|
+
* will fail.
|
|
833
|
+
*/
|
|
834
|
+
OdinReturnCode odin_resampler_destroy(OdinResamplerHandle resampler);
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Creates a new access key required to access the ODIN network. An access key is a 44 character
|
|
838
|
+
* long Base64-String, which consists of a version, random bytes and a checksum.
|
|
839
|
+
*/
|
|
840
|
+
OdinReturnCode odin_access_key_generate(char *buf, size_t buf_len);
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* Retrieves the key ID from a specified access key. The key ID is included in room tokens,
|
|
844
|
+
* making it possible to identify which public key must be used for verification.
|
|
845
|
+
*/
|
|
846
|
+
OdinReturnCode odin_access_key_id(const char *access_key, char *out_key_id, size_t out_key_id_len);
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Retrieves the public key from a specified access key. The public key is based on the Ed25519
|
|
850
|
+
* curve and must be submitted to _4Players_ so that a generated room token can be verified.
|
|
851
|
+
*/
|
|
852
|
+
OdinReturnCode odin_access_key_public_key(const char *access_key,
|
|
853
|
+
char *out_public_key,
|
|
854
|
+
size_t out_public_key_len);
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Retrieves the secret key from a specified access key. The secret key is based on the Ed25519
|
|
858
|
+
* curve and used to sign a generated room token to access the ODIN network.
|
|
859
|
+
*/
|
|
860
|
+
OdinReturnCode odin_access_key_secret_key(const char *access_key,
|
|
861
|
+
char *out_secret_key,
|
|
862
|
+
size_t out_secret_key_len);
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* Creates a new token generator instance.
|
|
866
|
+
*/
|
|
867
|
+
struct OdinTokenGenerator *odin_token_generator_create(const char *access_key);
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Destroys an existing token generator instance.
|
|
871
|
+
*/
|
|
872
|
+
void odin_token_generator_destroy(struct OdinTokenGenerator *generator);
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Generates a signed JWT, which can be used by an ODIN client to join a room.
|
|
876
|
+
*/
|
|
877
|
+
OdinReturnCode odin_token_generator_create_token(struct OdinTokenGenerator *generator,
|
|
878
|
+
const char *room_id,
|
|
879
|
+
const char *user_id,
|
|
880
|
+
char *out_token,
|
|
881
|
+
size_t out_token_len);
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Generates a signed JWT such as `odin_token_generator_create_token` and allows passing a custom
|
|
885
|
+
* set of `OdinTokenOptions` for advanced use-cases.
|
|
886
|
+
*/
|
|
887
|
+
OdinReturnCode odin_token_generator_create_token_ex(struct OdinTokenGenerator *generator,
|
|
888
|
+
const char *room_id,
|
|
889
|
+
const char *user_id,
|
|
890
|
+
const struct OdinTokenOptions *options,
|
|
891
|
+
char *out_token,
|
|
892
|
+
size_t out_token_len);
|
|
893
|
+
|
|
894
|
+
#ifdef __cplusplus
|
|
895
|
+
} // extern "C"
|
|
896
|
+
#endif // __cplusplus
|