@4players/odin-nodejs
v0.10.3
Published
NodeJS bindings for the ODIN SDK. Use for AI enhanced human interactions, content moderation and audio processing features in a backend.
Downloads
307
Readme
ODIN Node JS
Native Node JS bindings for the ODIN SDK. It is based on the ODIN Native SDK and wraps the C++ code into a Node JS module.
Check out documentation and guides at developers.4players.io.
Beta!
This SDK is currently in beta. This means that the API is not final and might change in the future. It's also not ready for production use as there might be bugs, memory leaks or other issues. But it's good enough for testing AI integration, recording or other interesting use cases.
If you have any questions or feedback, please reach out to us at our Discord Server.
ODIN Node JS compared to Web SDK
We have a JavaScript/TypeScript SDK that has fallback code for WebRTC and can be used in the browser. While this also works on NodeJS (to some extent) it is not as performant as the native bindings and also has some limitations. For bots and other advanced use cases we provide this native Node JS SDK.
While we try to keep the API as similar as possible, there are some differences. While wrapping things in objects in
JavaScript and TypeScript for better separating doing so in native C/C++ is harder and error prone. Therefore we decided
to only use C/C++ and objects where required. For example, the WebSDK provides an OdinPeer
object that wraps various
methods and properties. For bots and other NodeJS use cases you typically don't need that and therefore we decided to
not make things more complex than required. You typically only get a peerId
and mediaId
and that's it. But for most
use cases this is enough, and you are always free to build your own wrapper where required.
The most prominent difference is, that the NodeJS SDK allows you to get the raw audio data from the ODIN server. This allows you to record audio or sending audio into the room. While the WebSDK provides a similar functionality it is based on Web Audio that is not available on NodeJS - therefore it does not make much sense to wrap and polyfill all of that while it's super easy (and fast) to wrap the ODIN native SDK into NodeJS bindings.
Having two libs also allows us to optimize for each platform without having to work through many use cases.
Prerequisites
This NodeJS SDK is based on the native ODIN SDK and is implemented via Native NodeJS bindings. This means that during
npm install
this module will be compiled, which means you may need to have a compiler installed.
For some target systems, precompiled libraries are provided:
- macOS (x86_64 and arm64)
- Windows (x86_64)
- Linux (x86_64)
Otherwise you need to have a C++ compiler installed. On macOS, you can install XCode and the command line tools. On Linux you need to have GCC installed. More information can be found here: node-gyp.
Getting Started and compiling
Add the package to your project:
npm install --save @4players/odin-nodejs
This will compile the NodeJS bindings for the "local" machine. We provide a few precompiled libraries so you don't need to have GCC and compilers installed. This is especially useful for CI/CD pipelines.
Dependencies
It has deps to the native ODIN SDK. A couple of libraries for typical use cases (i.e. macOS, Windows and Linux) is provided
in the libs
folder. If you have some fancy platform, you might need to compile the ODIN SDK and put the lib in the
folder according this name scheme: platform
-arch
.
Examples
We provide a few examples in the tests
folder to get you started quickly.