Put the voice source behind a ServerLink
The session no longer spawns the TeamSpeak connection itself. link.rs adds ServerLink (spawn(options, ctx, cmds, events)) with LinkCmd and LinkEvent, VoiceCmd and VoiceEvent moved and renamed, plus ConnectOptions (VoiceOptions stays as its name for the app), LinkCtx and Remote. TsLink (ts_link.rs) is the TeamSpeak implementation and the engine's default; Engine::start_with_link takes another. The stream task moves inside the connection: voice.rs spawns it when the server has streams, feeds it the server's notifications and the clients' channels, and sends its requests. The session reaches it only through LinkCmd::Stream(StreamCmd) and hears of our own stream (OwnStream) and the audio of watched streams (StreamAudio) as link events, so the link holds no handle on the audio thread. stream.rs keeps its tests, adapted to the split of StreamInput into StreamCmd and the link-private input. tests/link_fake.rs drives the session with an in-memory link: connect, presence, commands, a message sent and echoed, a message that comes twice, history, and a replaced connection, without a TeamSpeak crate. The architecture doc describes ServerLink and the planned move of TsLink to VoelinGateWay and the QUIC link of VoelinProtocol. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
da372dfe10
commit
6c1898bf5a
10 files changed
+1492
-563
No files matched your search
+64
-7
@@ -72,7 +72,7 @@ fuzz/ cargo-fuzz targets
|
||||
| `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; 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; its frame and simulcast layer types are `voelin-media`'s | 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); the stream types of its API are its own (`stream_types`, see Streams) | done |
|
||||
| `voelin-core` | Engine: runtime, per-server sessions, merge of voice/gateway/query sources, the `ServerLink` seam the voice source sits behind (`link.rs`; `TsLink` is the TeamSpeak implementation, for now in this crate), 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); the stream types of its API are its own (`stream_types`, see Streams) | done |
|
||||
| `voelin-ui` | Slint UI and the desktop binary: streams panel, viewer, share dialog, audio / hotkey / codec settings | done (desktop) |
|
||||
| `voelin-media` | Screen and system-audio capture backends (PipeWire portal, X11, Windows Graphics Capture, Android MediaProjection), video codecs; the frame and simulcast layer types of a stream (`stream::EncodedFrame`, `LayerSpec`, `LayerId`, `LayerSet`) | done (desktop hardware encoders through FFmpeg loaded at runtime, not run on a GPU yet; MediaCodec not run on a device yet) |
|
||||
| `voelin-platform` | Global hotkeys, notifications, paths, crash reports, notices | done |
|
||||
@@ -87,6 +87,60 @@ the native command only when voice-connected *and* in that channel, otherwise th
|
||||
gateway, otherwise a local query relay. UI states: `Offline`,
|
||||
`Observing (Gateway|Query)` (invisible), `Connecting`, `Connected`.
|
||||
|
||||
## The server link
|
||||
|
||||
A session's voice source, the connection that is visible on the server and
|
||||
can talk, is a `voelin_core::link::ServerLink`, not a TeamSpeak connection
|
||||
the session knows about. The trait has one method,
|
||||
`spawn(options, ctx, cmds, events)`, which starts a connection on its own
|
||||
task and returns:
|
||||
|
||||
- `options` is a `ConnectOptions` (the app calls it `VoiceOptions`): address,
|
||||
nickname, password, channel to join, whether to open the audio devices;
|
||||
- `ctx` is a `LinkCtx`: the session id, the event bus the link answers
|
||||
requests on (file lists, transfers, offline messages, stream state), the
|
||||
bus for the frames of watched streams, and the settings;
|
||||
- `cmds` carries `LinkCmd`s in: chat, moves, mute, pokes, the encoded
|
||||
voice frames from the audio thread, the file and offline-message requests,
|
||||
`Stream(StreamCmd)` and `Disconnect`;
|
||||
- `events` carries `LinkEvent`s out: `Connected` (name, `BackendInfo`,
|
||||
`Capabilities`, our client id, the server's unique id), `Presence` (a full
|
||||
snapshot each time), `OwnChannel`, `Chat`, `Poke`, `Audio` (a received
|
||||
`VoicePacket`), `Talking`, `OwnStream`, `StreamAudio` (the audio of a watched
|
||||
stream, for the audio thread's mixer), `Error` and, last, `Disconnected`.
|
||||
|
||||
Everything backend-neutral stays in `session.rs`: merging the three sources,
|
||||
the dedup of a message that arrives twice, the chat history, contacts, the
|
||||
privacy rules, the images and the gateway directory. The session tags each
|
||||
link with a generation, so events of a replaced one are ignored. A link
|
||||
reports what the server can do as `Capabilities`; with `streams` set it also
|
||||
runs the stream task (`stream.rs`), which the session reaches only through
|
||||
`LinkCmd::Stream(StreamCmd)` (start, stop, answer a viewer, watch, layers,
|
||||
frames, friends, the gateway directory, shutdown) and which reports our own
|
||||
stream's life back as `LinkEvent::OwnStream`. The stream task's requests
|
||||
and the server's stream notifications never leave the link.
|
||||
|
||||
`Engine::start_with_link(settings, history, link)` takes the link;
|
||||
`Engine::start` and `start_with` use `TsLink` (`ts_link.rs`), the
|
||||
TeamSpeak 3 and 6 connection of `tsclientlib`, which runs `voice.rs` with
|
||||
`book.rs`, `stream.rs`, `versions.rs` and `identity.rs`. `tests/link_fake.rs`
|
||||
drives the session with an in-memory link instead: it plays scripted
|
||||
`LinkEvent`s (connect, presence, a message twice, a disconnect, a replaced
|
||||
connection) and checks the presence, chat, dedup and history the session
|
||||
makes of them, and the commands it gives back, with no TeamSpeak server or
|
||||
crate involved.
|
||||
|
||||
Where this is going: `ServerLink` is this crate's interim seam. `TsLink` and
|
||||
the modules it owns move to VoelinGateWay (`voelin-gateway-ts`, the
|
||||
in-process TeamSpeak gateway), and the QUIC transport of VoelinProtocol
|
||||
becomes the other implementation, both behind the backend-neutral
|
||||
`voelin_proto::link::Session` that the protocol spec defines (the spec
|
||||
replaces `voelin_core::link::ServerLink` by it, because the gateway
|
||||
implements the trait and the client depends on the gateway). What still has
|
||||
TeamSpeak types in the seam, and leaves with `TsLink`: the identity and
|
||||
version in `ConnectOptions`, the myTeamSpeak account proof in `LinkCtx`, and the
|
||||
peer and media vocabulary of the stream API (below).
|
||||
|
||||
## What the engine tells of the server's software
|
||||
|
||||
`Event::ServerInfo { session, name, backend, capabilities }` is the one place
|
||||
@@ -98,7 +152,7 @@ kinds, files, offline messages). The UI shows `product` on a server's chip
|
||||
and `BackendInfo::label()` in the status line, and branches on capabilities
|
||||
only. The TeamSpeak 3 / 6 classification (`voelin_model::ServerFlavor`, from
|
||||
the `virtualserver_version` string) happens in the voice source
|
||||
(`voice.rs::backend_of`), which puts both in `VoiceEvent::Connected`; no
|
||||
(`voice.rs::backend_of`), which puts both in `LinkEvent::Connected`; no
|
||||
`ServerFlavor` appears in the engine's public API, so another link (a Voelin
|
||||
server) can fill the same two fields.
|
||||
|
||||
@@ -341,17 +395,20 @@ stream task converts what `Streams` reports, and what the UI asks for
|
||||
own types (its `StreamInfo`, `ViewerInfo`, `StreamSetup`, `SrtpProfile`,
|
||||
`EndReason`) no longer show in `Command` and `Event`. Still
|
||||
`voelin-stream`'s in the engine's API are the peer and media vocabulary:
|
||||
`PeerConfig` (in `VoiceOptions`), `MediaFrame` (the frames of watched
|
||||
`PeerConfig` (in `ConnectOptions`), `MediaFrame` (the frames of watched
|
||||
streams), `VideoFormat` and `VideoCodec` (on the `StreamSink`),
|
||||
`FrameSource`, `SyntheticSource`; they move out of the core with the stream
|
||||
task (the decoupling plan's next steps).
|
||||
|
||||
In `voelin-core` a stream task per voice connection runs `Streams`; the voice task
|
||||
forwards `MessageEvent`s and sends the requests. Encoders push frames through
|
||||
In `voelin-core` a stream task per voice connection runs `Streams`. The link
|
||||
owns the task (see [The server link](#the-server-link)): the TeamSpeak
|
||||
connection hands it the `MessageEvent`s as notifications and the clients'
|
||||
channels, and sends its requests; the session talks to it with
|
||||
`LinkCmd::Stream(StreamCmd)`. Encoders push frames through
|
||||
the `StreamSink` of `StreamState::Live`; received frames of watched streams go
|
||||
to `Engine::subscribe_frames`, not the event bus. The audio of watched streams
|
||||
goes straight to the session's audio thread, which mixes it like a talker
|
||||
with its own volume (`Command::SetStreamVolume`).
|
||||
goes to the session as `LinkEvent::StreamAudio` and on to its audio thread,
|
||||
which mixes it like a talker with its own volume (`Command::SetStreamVolume`).
|
||||
|
||||
`voelin-core::media` (feature `media`) connects this to `voelin-media`:
|
||||
`Streamer` captures (screen, window, portal or the test pattern, plus system
|
||||
|
||||
+3
-1
@@ -30,7 +30,9 @@ 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.
|
||||
the session and the mixer see only the types above, and so does the link's
|
||||
seam: `LinkCmd::Audio` carries an `EncodedVoice` out and `LinkEvent::Audio` a
|
||||
`VoicePacket` in (`voelin-core/src/link.rs`).
|
||||
|
||||
## Echo cancellation, noise suppression, gain control
|
||||
|
||||
|
||||
Reference in new issue
Block a user