Minimal Command Line Client
We provide a comprehensive C++ example that demonstrates how to build a fully functional Voice Chat client using the ODIN Core SDK. This example handles:
- Connection Pooling and Room Management
- Microphone Capture and Audio Playback (via
miniaudio) - RPC Event Handling (Room/Peer updates)
- Media Signaling (Start/Stop Media)
The source code is located in the test directory of the ODIN SDK repository.
Building the Sample
Prerequisites
- CMake (3.10+)
- C++17 compatible compiler
- Git (with LFS support)
Steps
-
Clone the repository with LFS support:
-
Navigate to the test directory and build:
Code Overview
The sample is structured around a State class that manages the ODIN room, audio devices, and active media streams.
1. Initialization & Connection Pool
The application starts by initializing the ODIN SDK and creating a OdinConnectionPool. This pool manages the underlying network socket and dispatches events.
2. Handling RPC Events
The on_rpc callback is the central hub for all signaling. It deserializes incoming MessagePack data into JSON and dispatches it to the appropriate handler in the State class.
3. Media Signaling
When a peer joins or starts talking, the client receives PeerUpdateMediaStarted events. The sample responds by creating a decoder for that stream. Conversely, when the local user joins, the sample sends a StartMedia RPC to announce its own audio stream.
4. Audio Processing Loop
The miniaudio callback handles the actual audio data flow.
- Capture: Reads from microphone -> pushes to
OdinEncoder-> specific media ID. - Playback: Reads from
OdinDecoder-> mixes into output buffer.
Running the Client
Run the client with your Room ID and Gateway info:
Use --help to see all available options including input/output device selection and APM configuration.