Move voice packet types into voelin-audio
voelin-audio no longer depends on tsclientlib or tsproto-packets. Its boundary is now plain types in packet.rs: TalkerId, VoiceCodec, VoicePacket (talker, seq, codec, whisper, payload) and EncodedVoice (codec, payload; an empty payload ends the transmission). The jitter buffer moves from tsclientlib::audio into jitter.rs and reads VoicePacket fields; the encoder returns EncodedVoice and the mixer is keyed by TalkerId. In voelin-core, voice.rs is the only place that wraps EncodedVoice into a TeamSpeak audio packet and reads one into a VoicePacket (codecs other than Opus are dropped there, where the jitter buffer rejected them before); audio.rs and session.rs work on the new types. voelinctl converts at its own edge. Behaviour is unchanged: the one-hour drift simulation gives the same latencies as before. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1bee9c94e8
commit
df7be67d4c
15 files changed
+1352
-227
No files matched your search
@@ -70,7 +70,7 @@ fuzz/ cargo-fuzz targets
|
||||
| `voelin-observer` | Presence tracker + chat relay pool over `voelin-query` | done |
|
||||
| `voelin-gateway-proto`, `voelin-gateway` (`tsgw`) | Companion service for server admins: identity-challenge auth, permission-mirroring authorization, presence stream, chat relay, SQLite history, WebSocket + JSON (`tsgw.v1+json`) | done |
|
||||
| `voelin-store` | Identities, bookmarks, settings, chat history (dedupe, paging, sync cursors, where each chat was read), contacts, secrets (keyring / Android Keystore); versioned schema | done |
|
||||
| `voelin-audio` | Capture/playback, Opus, echo cancellation, resampling, jitter buffer, mixer, VAD/push-to-talk | v0 (no AEC yet) |
|
||||
| `voelin-audio` | Capture/playback, Opus, echo cancellation, resampling, jitter buffer, mixer, VAD/push-to-talk; the voice packet types (`TalkerId`, `VoicePacket`, `EncodedVoice`), so it depends on no voice transport | v0 (no AEC yet) |
|
||||
| `voelin-stream` | TS6 stream commands, JSON signalling, str0m peer connections, host/STUN candidates, streamer/viewer sessions, frame-source seam | sessions + transport |
|
||||
| `voelin-core` | Engine: runtime, per-server sessions, merge of voice/gateway/query sources, event bus, command API, chat history, the gateway's features, audio settings and volumes, streams on TS6, files, avatar and icon cache, pokes, offline messages, contacts; `media` module (capture → encoder → stream, stream → decoder) | done |
|
||||
| `voelin-ui` | Slint UI and the desktop binary: streams panel, viewer, share dialog, audio / hotkey / codec settings | done (desktop) |
|
||||
|
||||
+27
-7
@@ -2,10 +2,10 @@
|
||||
|
||||
```
|
||||
microphone ─ cpal ─ resample 48 kHz mono ─ Processor (AEC3, NS, AGC2) ─ 20 ms frames
|
||||
─ Vad / push-to-talk / continuous ─ Opus ─ voice connection
|
||||
─ Vad / push-to-talk / continuous ─ Opus ─ EncodedVoice ─ voice connection
|
||||
|
||||
voice connection ─ Mixer (jitter buffer, Opus decode, per-client volume/mute,
|
||||
priority speaker dimming)
|
||||
voice connection ─ VoicePacket ─ Mixer (jitter buffer, Opus decode, per-talker
|
||||
volume/mute, priority speaker dimming)
|
||||
─ output volume ─┬─ resample to device ─ cpal ─ speakers
|
||||
└─ Processor::render (echo canceller reference)
|
||||
```
|
||||
@@ -13,6 +13,25 @@ voice connection ─ Mixer (jitter buffer, Opus decode, per-client volume/mute,
|
||||
The audio thread lives in `voelin-core/src/audio.rs`; the building blocks are in
|
||||
`voelin-audio`. All user settings are one serde struct, `voelin_audio::AudioSettings`.
|
||||
|
||||
## Voice packets
|
||||
|
||||
`voelin-audio` knows no voice transport (it depends on no TeamSpeak crate). What
|
||||
crosses its boundary are the plain types of `voelin_audio::packet`:
|
||||
|
||||
| Type | Meaning |
|
||||
|---|---|
|
||||
| `TalkerId(u16)` | who is talking; the key of the mixer's queues, volumes and mutes (TeamSpeak's client id is used as is, watched streams get made-up ids) |
|
||||
| `VoiceCodec` | `Voice` (mono Opus, speech) or `Music` (stereo Opus) |
|
||||
| `VoicePacket { talker, seq, codec, whisper, payload }` | one received Opus packet; `seq` counts up per talker and wraps, an empty `payload` (or a single byte) ends the talk |
|
||||
| `EncodedVoice { codec, payload }` | one frame from `VoiceEncoder`, an empty `payload` ends the transmission |
|
||||
|
||||
The transport adapter converts between these and its wire format; for the
|
||||
TeamSpeak connection that is `out_audio` and `voice_packet` in
|
||||
`voelin-core/src/voice.rs`, the only place that builds TeamSpeak audio packets
|
||||
from `EncodedVoice` or reads them into `VoicePacket`s (codecs other than Opus
|
||||
are dropped there, as the jitter buffer never played them). The audio thread,
|
||||
the session and the mixer see only the types above.
|
||||
|
||||
## Echo cancellation, noise suppression, gain control
|
||||
|
||||
[sonora](https://crates.io/crates/sonora) 0.2 (BSD-3-Clause), a pure Rust port of
|
||||
@@ -51,9 +70,10 @@ two 20 ms frames before the gate opened are sent too, so onsets are not cut.
|
||||
|
||||
## Jitter buffer and clock drift
|
||||
|
||||
`Mixer` wraps the vendored `tsclientlib::audio::AudioHandler` (one queue per
|
||||
talker) and adds per-client volume and mute, and priority speaker dimming. The
|
||||
handler absorbs sender clock drift: an underrun plays Opus loss concealment for
|
||||
`Mixer` wraps `voelin_audio::jitter::AudioHandler` (one queue per talker; it
|
||||
started as `tsclientlib::audio::AudioHandler` and now reads `VoicePacket`s) and
|
||||
adds per-talker volume and mute, and priority speaker dimming. The handler
|
||||
absorbs sender clock drift: an underrun plays Opus loss concealment for
|
||||
the missing frame (one inserted frame, and the talker is dropped after three in a
|
||||
row), and when the smallest queue length over the last 255 packets exceeds its
|
||||
spread, it drops every 100th sample (1 % faster) until the surplus is gone;
|
||||
@@ -86,7 +106,7 @@ settings page shows as a meter with the threshold. Without a voice connection,
|
||||
Per-client volume and mute are local (`SetClientVolume`, `SetClientMuted`); the
|
||||
app keeps them by unique id and sends them again when the client shows up. Client
|
||||
ids are reused, so the session forgets the settings of clients that left.
|
||||
Watched streams play through the same mixer under made-up client ids (counting
|
||||
Watched streams play through the same mixer under made-up talker ids (counting
|
||||
down from 65535) with their own volume (`SetStreamVolume`).
|
||||
|
||||
While a priority speaker has a queue (talking, or buffering before it plays)
|
||||
|
||||
+1
-1
@@ -294,7 +294,7 @@ viewer: Engine::subscribe_frames ─ VideoPipeline (thread) ─ VideoDecoder
|
||||
its layers live is seen with its next offer.
|
||||
- The audio of watched streams does not go through this module: the session
|
||||
hands the Opus frames to its audio thread, which plays them through the
|
||||
jitter buffer and mixer under a made-up client id, with its own volume.
|
||||
jitter buffer and mixer under a made-up talker id, with its own volume.
|
||||
Playback is mono like the rest of the audio path.
|
||||
|
||||
## Stream audio
|
||||
|
||||
Reference in new issue
Block a user