LiveKit Integration
The Estuary Unity SDK uses LiveKit for low-latency WebRTC voice and video. These internal managers are created and used by EstuaryManager -- you normally do not interact with them directly, but they are documented here for advanced use cases.
LiveKitVoiceManager
Manages the LiveKit voice room connection, microphone publishing, and bot audio subscription.
Namespace: Estuary.Core
Properties
| Property | Type | Access | Description |
|---|---|---|---|
IsConnected | bool | get | true when connected to the LiveKit room |
State | LiveKitConnectionState | get | Current connection state |
RoomName | string | get | Name of the current LiveKit room |
BotAudioSource | AudioSource | get | The AudioSource playing the bot's voice (created at runtime) |
Methods
| Method | Returns | Description |
|---|---|---|
ConnectAsync(string token, string url, string roomName) | Task | Connect to a LiveKit room with the provided JWT token |
DisconnectAsync() | Task | Leave the room and clean up |
StartPublishingAsync() | Task | Publish the microphone track to the room |
StopPublishingAsync() | Task | Unpublish the microphone track |
MuteAsync() | Task | Mute the published microphone track |
UnmuteAsync() | Task | Unmute the published microphone track |
SignalInterruptAsync(string messageId) | Task | Signal an interrupt for the given message |
MuteBotAudio() | void | Mute the bot's audio track (used during interrupts) |
UnmuteBotAudio() | void | Unmute the bot's audio track |
NotifyAudioChunk(string messageId, double timestamp) | void | Track incoming audio chunks for interrupt filtering |
Events
| Event | Signature | Description |
|---|---|---|
OnStateChanged | Action<LiveKitConnectionState> | Connection state changed |
OnReady | Action<string> | Room is ready (room name) |
OnBotAudioSourceCreated | Action<AudioSource> | Bot's AudioSource was created (for lip sync integration) |
OnError | Action<string> | Connection or publishing error |
Connection Flow
1. EstuaryManager calls EstuaryClient.RequestLiveKitTokenAsync()
2. Server responds with livekit_token (JWT, URL, room name)
3. EstuaryManager calls LiveKitVoiceManager.ConnectAsync(token, url, room)
4. LiveKitVoiceManager connects to room, state → Connecting
5. EstuaryManager calls EstuaryClient.NotifyLiveKitJoinAsync()
6. Server joins the bot to the room, sends livekit_ready
7. State → WaitingForBot → Ready
8. LiveKitVoiceManager subscribes to the bot's audio track
9. OnBotAudioSourceCreated fires with the runtime AudioSource
Interrupt Handling
When an interrupt is signalled:
SignalInterruptAsyncsendsclient_interruptto the serverMuteBotAudio()is called to immediately silence the bot- The server stops generating audio and sends an
interruptconfirmation - Audio chunks with
message_idmatching the interrupted message are filtered out - Audio chunks with timestamps before the interrupt are also filtered
Dependencies
The LiveKit integration requires the io.livekit.livekit-sdk package (v1.3.3+), which is declared as a dependency in the Estuary SDK's package.json. It is automatically resolved by Unity Package Manager when you install the Estuary SDK.
The LiveKit Unity SDK provides:
Room-- Room connection managementLocalAudioTrack/LocalVideoTrack-- Publishing local mediaRemoteAudioTrack-- Subscribing to remote audioRtcAudioSource-- Native audio capture with AECAudioStream-- Audio playback from remote tracksDirectWebcamVideoSource-- Webcam capture for video tracks