The new UI needs a channel file browser, avatars and icons, pokes,
direct messages to anyone, the offline message inbox and a friends list.
The voice connection can do all of it; the engine did not offer it.
Files (module files): ListFiles, DownloadFile (to disk as <path>.part,
renamed when complete, resumable, or into memory), DownloadChatFile for
a FileRef from a chat message, UploadFile, CancelTransfer, DeleteFiles,
RenameFile, CreateDirectory. Transfers stream in 64 KiB pieces and
report Requested/Started/Progress (files.progress_interval_ms)/Done/
Failed/Cancelled; requests and transfers carry an id the caller picks.
Avatars and icons are fetched by themselves (cache.fetch_images) into a
content-addressed disk cache (module cache: avatars by MD5, icons by id,
LRU bounded by cache.max_mb, 0 = no limit, use times kept as file times,
concurrent downloads of one file deduplicated across sessions) and
reported as AvatarReady / IconReady. SetAvatar uploads ours and
announces its hash, or removes it.
Pokes are a command and a distinct event (they were stored as private
messages before). A failing voice command (e.g. a private message to a
client who left) is now an error event instead of ending the connection.
Offline messages (module offline) list, read, send, delete and mark.
Contacts (module contacts) are engine-wide and stored in the client
database: SetContact / RemoveContact, ContactsChanged, FriendPresence
across all sessions, last seen time and server, per-person volume and
mute applied in every session, blocked authors flagged in chat and
their pokes and private messages hidden or flagged (privacy.block_mode),
and stream.permissions = friends lets friends watch without asking.
ServerDetails and Groups events report the server's details and groups
when they change. The book mapping moved to its own module.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Home's friends list, blocking and per-person volume need a place for
people the user marked. Contacts are keyed by the client's unique id
(the same on every server) and carry a nickname hint, the relation
(friend, blocked, neutral), a note, mute and volume, when they were
added and when and where they were seen last.
Migration 3 adds the table; existing data stays. touch_contacts records
many sightings in one transaction and never moves last_seen back.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
A server refuses ftinitdownload/ftinitupload (file not found, missing
permission, quota) with an error for the command's return code. The
library turned that into a MessageResult whose handle the caller never
saw, so a refused transfer just hung. The pending transfer commands are
now remembered by return code and a refusal fails the transfer with
FiletransferFailed.
A server listening on all interfaces may announce 0.0.0.0 as the
transfer address; the server's own address is used then. The return
code and transfer id counters wrap instead of panicking on overflow in
debug builds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The new UI shows avatars, descriptions, talk power, group badges, the
host banner and welcome message, and file cards in chat. The voice
connection's book has all of it; the model did not carry it.
ClientInfo gains the avatar hash, description, talk power, channel
group, badges, icon and flags; ChannelInfo its icon; Presence the
server's details (welcome and host message, banner, host button, icon,
unique id, platform, version) and its server and channel groups. The
voice source fills everything (talking from its own talk detection), the
query observer what its rows carry. New fields are optional on the wire,
so gateways and clients of either version understand each other.
ChatMessage gains a `blocked` flag that the engine sets for authors the
user blocked (never serialized), and `file_refs()`, which parses
`[URL=ts3file://...]` links into FileRefs; FileRef::to_bbcode writes one.
Capabilities tell whether the server offers file transfer and offline
messages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Chats show their stored history at once and sync what the gateway kept
while we were away; messages seen over voice and the gateway are
stored once. Pins, reactions, topics, events, the stream directory,
activity and gateway administration are engine commands and events.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Theme tokens from the mockups, Inter, Lucide icons and Twemoji (with
their notices and About credits), a component library, desktop and
phone shells, today's screens re-skinned, view models and bindings
split out of app.rs, an image cache and live ui.* settings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The icons and emoji are SVG images, whose decoders Slint enables with a
backend. The Android app always brings the Android backend, but the UI
crate alone did not, so `cargo ndk clippy -p voelin-ui` failed; it now
asks for the same backend feature (no change to the app's build).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
When voice connected while the gateway was already up, the bookmark's
voice address was not remembered with the server's unique id, so a later
visit without the gateway could not show the stored history before the
voice connection was up. Addresses are now remembered with the key in
use (the gateway's) whichever source reports last.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
docs/ui.md describes the new UI for later work: the file layout, theme
tokens, the component catalogue, how to add a screen, the appearance
settings, how emoji are drawn, and the development switches for
screenshots. The screenshots are new (sample data from VOELIN_DEMO_UI,
256 colours); the old ones showed the previous design.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Architecture: how messages are stored and merged, what opening a chat and
paging back emit, the history settings, the gateway's requests and
updates in the engine, and the directory as a stream discovery source.
The protocol page points to the engine's mapping, the README and the
changelog mention chat history and voelinctl's engine mode.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The volume dialog of VOELIN_OPEN=client opens once our own client is
known (the state can come after the presence), scrolling pages keep
their content to the view's width (the phone home page scrolled
sideways), the sidebar grows with the text size, and the home page's
cards and banner fit narrow windows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
`voelinctl gateway --engine` runs one engine session against a gateway,
optionally with voice, and prints every history batch, gateway update
and stream event as a line: --chat opens chats (with --db, stored
history), --older pages back, --request sends any gateway request as
JSON (admin config, permission rules, events, ...), --roundtrip posts,
pins, reacts, starts a topic from the post, posts into it and reads it
back, --stream-seconds streams synthetic frames (registering in the
directory) and --watch-streamer watches a stream once found.
it-smoke adds three steps with the gateway running: messages sent while a
user is offline reach its stored history on the next connect (the admin
sets relay.pinned_channels at runtime for it); the pin/react/topic round
trip as a normal user with a permission rule the admin sets; and on
TeamSpeak 6 a stream registered in the directory found and watched by a
viewer that connects later. The gateway's port can be moved
(TSGW_PORT_TS3/TS6), and default builds go to $CARGO_TARGET_DIR.
A chat's first stored page is no longer marked complete while its
gateway is still connecting.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
A fake gateway (a WebSocket server speaking the tsgw protocol from
memory) drives the engine: the stored page then the gateway's latest page
on open, paging back through the gateway, messages and pin changes made
while away arriving on reconnect, the stored page found by the gateway's
URL after a restart with the gateway down, our own message stored once
with the gateway's copy, pins, reactions, topics, posts and refusals as
events, and chat.store_history off keeping the database empty. The
stream tasks show a late viewer finding a stream only the gateway
directory knows, and the streamer's reports for its directory entry; the
history writer answers batched writes in order.
The writer thread no longer joins itself when a job's callback drops the
last handle.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Scroll bars and context menus come from the standard widgets, which
follow Palette.color-scheme. The window now sets it from ui.theme: dark
or light explicitly, and in "system" mode it leaves the palette tracking
the system (or, after an explicit mode, uses the scheme seen at start,
since the tracking binding cannot be restored).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Chat lived only in the UI's memory. Every chat message a session sees
(voice, gateway pushes, query relays, our own sends) is now stored under
the server's unique id through a writer thread that batches writes, and
opening a chat or reconnecting emits the stored page at once, then syncs
with the gateway: the latest page on first contact, afterwards everything
past the chat's revision cursor, in pages of chat.history_page.
LoadOlderHistory pages back, merging the gateway's page for that range.
Copies of one message from different sources become one row, so the UI
upserts by local id (Event::ChatHistory).
The session's gateway now runs on the typed client, keeping presence and
relayed chat as they were, and takes Command::Gateway requests (pins,
reactions, topics and topic history, events with RSVP, the stream
directory, activity, permissions, runtime config and permission rules),
answered and pushed as Event::Gateway updates. It subscribes to events,
streams and activity when offered. Our own TeamSpeak 6 stream registers
itself in the directory when it goes live and leaves it when it ends, and
the directory's registered entries feed stream discovery (also as a
StreamLookup), so streams that started before we joined are found even
when the server's lookup does not answer.
The voice connection now reports the server's unique id (SHA-1 or SHA-256
of its key, per server generation) and ours, and files our own private
messages under the receiver. Settings: chat.store_history,
chat.history_page, chat.dedupe_tolerance_ms, chat.retention_days.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
cargo-about only sees crates, so the Inter font (OFL-1.1), the Lucide
icons (ISC, with the MIT notice of the icons from Feather) and the
Twemoji graphics (CC-BY 4.0) come from about-assets.md, which
scripts/notices.sh appends to its output; --check compares the whole
file as before. The About page credits them above the notices.
Also from the screenshots: a disabled primary button keeps its label
readable, badges size to their text, buttons and fields keep their
height in rows, the chat header shows the channel name without "#",
and the toast sits above the composer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The messages table was a cache nobody used: second timestamps, no source,
no gateway ids. Chat history on open needs rows that carry the gateway's
stable id and metadata, one row per message however many sources
delivered it, pages by time and a cursor per chat for gateway sync.
Migration 2 adds ts_ms, source, remote_id (unique per server and chat),
topic_id, rev, sync_state, pinned, reactions, a seen_by source mask and a
text hash for dedupe, an index for paging by (ts_ms, id), chat_cursors
and server_aliases; old rows keep their data. Migrations now run each in
one immediate transaction, so two connections opening a fresh file at
the same time cannot both apply one.
write_messages stores a batch in one transaction with cached statements
and merges copies of the same message from different sources (gateway id,
else text without relay prefix, author and a time tolerance).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The single 1700-line app.slint becomes a design system and screens that
later waves can compose:
- theme.slint: colour, radius, spacing and type tokens (dark and light,
a runtime font scale); icons.slint: Lucide icons as tintable images.
- components/: Button, IconButton, TextField, SearchBox, Select, Toggle,
Slider, SegmentedTabs, Avatar, badges, Card, Meter, NavItem, ListItem,
PopupMenu, Tooltip, Modal, Toast, ResizeHandle, Spinner, RichText and
the EmojiPicker.
- shells/: the desktop frame (server rail, top bar, sidebar with the user
card) and the phone frame with a bottom navigation, switched at a
breakpoint from the settings.
- screens/: today's screens re-skinned (channels, chat, streams panel and
viewer, settings page, home, dialogs, phone pages); all callbacks and
properties keep their behaviour. Navigation state is the Nav global.
On the Rust side app.rs keeps setup and event glue; servers.rs, chat.rs,
settings_page.rs and appearance.rs hold the logic, vm/ the pure view
models, bind/ the callbacks, dev.rs the development switches. Models are
created once and updated row by row (vm::list::sync); each chat tab owns
its lines model, so a message appends one row. Emoji come from the
bundled Twemoji archive through a size-bounded image cache, split into
runs that wrap with the text. New settings ui.theme, ui.font_scale,
ui.narrow_breakpoint and ui.image_cache_mb apply live.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Capture, conversion and encoding on their own threads with latest-wins
handoffs and frame pools, one encoder per simulcast layer, portal
DMA-BUF, a wlroots capture backend, tuned libvpx, per-stage statistics,
Streamer::reconfigure and voelinctl stream bench. Conflicts: the root
manifest (dimpl patch next to the release profile) and voelinctl's
command list (probe-stream next to the stream tools).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
`voelinctl stream bench`, release builds (fat LTO), VP8, desktop test
pattern, one layer, 8 s, shared 4-core VM, before/after interleaved.
Before: the single-threaded allocating pipeline (31b138a). After: the
threaded pipeline (quiet column: 6187cc2; busy column: 3e49849).
fps sent / CPU cores / heap allocations per encoded frame:
quiet (load 1-3) busy (load 6-12)
before after before after
720p30 29.4/0.48/7.1 30.0/0.40/1.05 7.9/1.71/10.0 6.6/1.24/1.25
720p60 14.7/2.37/10.2 60.0/0.69/1.03 4.6/1.23/19.1 6.4/1.28/1.25
1080p30 29.6/0.83/7.1 30.0/0.75/1.05 2.7/1.30/17.4 6.9/1.27/1.24
1080p60 57.2/1.47/7.1 53.7/1.42/1.03 2.4/1.33/31.4 5.7/1.40/1.28
1440p30 8.4/2.26/9.7 22.7/1.71/1.07 1.9/1.31/22.6 5.5/1.26/1.30
1440p60 52.5/2.24/7.2 3.2/2.02/1.50* 1.5/1.22/36.9 3.6/1.30/1.45
* libvpx with one thread per core collapsed when conversion competed for
a core (290 ms per frame); 3e49849 leaves a core free.
On an idle machine (load < 1, earlier) the old pipeline reached
30/60/30/58/30/60 fps at 0.4-1.8 cores; the machine never got that
quiet again for an after run. Allocations per encoded frame: 7-37 before
(5-450 MB), about 1 after (the `Arc<[u8]>` of the encoded frame, 10-130
KB); zero on the capture -> convert -> scale -> encode path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
tsgw keeps runtime-edited settings and permission rules in its database
(they win over --set, environment and tsgw.toml), migrates its database
in place, and serves the new features to clients that opt in; old
clients are unaffected. voelin-core gets a typed gateway client.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
gateway-admin.md explains bootstrap keys versus seeds, the precedence
(runtime > --set > environment > file > default), reloading, every key,
the admin commands, permission rules with their defaults and the data
the database keeps. The history retention default is now to keep
messages; the doc says how to get the old 30 days back.
gateway-protocol.md is the reference of tsgw.v1+json with the new
messages. The example config marks bootstrap keys and lists the seeds.
The systemd unit reloads with SIGHUP.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The engine's gateway module now builds on the typed client of
voelin-gateway-proto: connect() logs in with the user's TeamSpeak
identity and returns a GatewayClient with one async method per request
(history cursors, sync, post into topics, pins, reactions, topics,
events and RSVP, stream directory, activity, permissions, settings and
rules), capabilities() for hiding missing features, and typed Push
events. run() keeps its interface for the engine and uses the same
client; the UI and engine commands come later.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
libvpx's worker threads wait on each other by spinning. With one thread
per core, an encode slows down many times over as soon as anything else
wants a core: the capture and conversion of the next frame, another
layer, the desktop. The bench on a 4-core machine showed single frames
at 1080p and 1440p taking 130-290 ms with 4 threads under load, where the
same frames took 9-17 ms with 3 threads next to two other layers. The
default (`codec::encoder_cpus`) is now all CPUs but one, for single
encoders and for the streamer's split across layers; an explicit
`EncoderConfig::threads` still wins.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The new design needs a real UI font, a consistent icon set and colour
emoji. The software renderer cannot draw colour glyphs, so emoji become
images: scripts/pack-twemoji.py packs the 3720 Twemoji SVGs into 64 KiB
raw-deflate blocks with a sorted index and picker names (1.9 MB instead
of 17 MB of files), for decoding single emoji on demand.
Inter (OFL-1.1) and the Lucide icons used by the UI (ISC) are copied with
their licenses; the app mark is our own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The hub, observer, relays and sessions now run in tests against a fake
raw ServerQuery server, driven over a real WebSocket by the typed
client: chat with pins, reactions and topics (including the prefix in
TeamSpeak and topic posts from official clients), old clients still
getting chat_event, unknown message types answered without a
disconnect, events with RSVP and reminders, the stream directory
following presence and linking stream events, the activity feed, and
admin settings, permission rules, quotas and rate limits applied live.
An ignored test runs the same flows against a real server and tsgw.
The relay pump subscribed to a rebuilt pool 100 ms after the old one
closed, so channel chat in that gap was lost after a nickname change.
Each pool now gets its own pump, subscribed before it opens a relay.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The bench showed the adaptive `cpu-used` oscillating: with headroom at
-6 it stepped VP8 down to -5 and -4, which on screen content cost about
ten times the encode time for under 1 dB, the encoder fell behind, frames
were dropped, and it stepped back up. VP8 now stays within -10..-6. A
single frame that takes longer than the whole frame interval makes the
encoder faster at once, and when a slower level has to be undone, the
next attempt to go slower waits twice as long (up to 16x 15 frames).
The simulcast test also checks that `EncodedSource::set_layer_bitrate`
reaches exactly that layer's encoder.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Settings: every key is in one registry with type, default and
description. Values resolve as database (set at runtime) > --set >
TSGW_<KEY> environment > tsgw.toml > default; query login, addresses
and the database path are bootstrap-only. Changes are published on a
watch channel and applied live (relay nickname rebuilds the relay pool,
pinned channels open, retention re-prunes, capabilities are pushed).
SIGHUP or a changed file reloads it; values set at runtime keep
winning and differing keys are logged. ConfigReset falls back.
Database: user_version migrations keep existing data. Messages get
AUTOINCREMENT ids (never reused after pruning), topic ids and
revisions for sync; new tables for reactions, pins, topics, events,
RSVPs, reminder bookkeeping, the stream directory, activity and
settings. WAL with synchronous=NORMAL, cached statements, batched
inserts, an index for every query path (checked with EXPLAIN QUERY
PLAN on 12k messages). Retention 0 keeps forever; pinned messages
are kept.
No built-in caps: history pages are unlimited unless an admin sets
quota.history_page; pins, topics, events, reactions and streams have
quotas that default to none.
Permission rules per action (by server and channel groups) live in the
settings, with TeamSpeak-permission defaults. The stream directory
follows presence (left, stopped streaming, moved) and lists streams
without a registration as detected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The new Voelin UI needs Discord-like features that TeamSpeak does not
have. They run on tsgw, so the protocol grows, additively within v1:
- capabilities in hello (server-wide) and auth_ok (per user, with admin)
- query_history with before/after id and time cursors, optional limit,
topic filter; sync by revision for new and changed messages
- post (optionally into a topic), pins, reactions with per-user counts,
topics, scheduled events with RSVP and reminders, the stream directory,
the activity feed, runtime configuration and permission rules
- history entries carry topic, reactions, pinned flag and revision;
old clients ignore the extra fields
Old clients never see a new message type: extension pushes need enable
or a subscribe request. New error codes and enums have an unknown
fallback so older clients keep parsing newer gateways.
The optional client feature adds a typed client (request/answer by
envelope id, typed pushes), shared by the app engine and the gateway's
integration tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
`cargo bench -p voelin-media --bench convert` times, at 720p, 1080p and
1440p of the desktop test pattern: the old allocating one-thread
`to_i420`, the `Converter` on one thread and on all cores, the pyramid
(full, half and quarter size), and luma scaling to half (2x2 box) and to
2/3 (area average). criterion 0.8 is already in the lock file (the proto
crates use it), Apache-2.0 OR MIT.
docs/media.md describes the threaded simulcast pipeline, reconfigure and
the stats, the capture sinks, portal DMA-BUFs, the wlroots backend, the
libvpx settings, how to benchmark, the allocation behaviour, the modules
with unsafe code, and the test status.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
`capture::wlroots::WlrootsCapture` captures outputs of wlroots
compositors (Sway, Hyprland, river, labwc, ...) directly over Wayland,
for sessions without a working portal or to skip its dialog. It uses
`ext-image-copy-capture-v1` with `ext-output-image-capture-source-v1`
where the compositor has them, else `wlr-screencopy-unstable-v1`
(`copy_with_damage` from version 2). Both only complete a frame once the
screen changed, so a still screen costs nothing. The compositor copies
into shared-memory buffers allocated once per size (memfd, mapped once);
the sink reads straight from the mapping (y-inverted frames are flipped
into a reused buffer first). XRGB/ARGB (BGRx in memory) and XBGR/ABGR
are read. Events are dispatched with a poll timeout so stopping is
prompt. Feature `wlroots` (default; Linux), using the wayland-client,
wayland-protocols and wayland-protocols-wlr versions already in the lock
file; `with_display` connects to another socket.
Tested against a headless sway 1.9 (wlr-screencopy v3, pixman renderer):
outputs, the captured background colour, a colour change through sway's
IPC arriving as a new frame, and the queue API
(`tests/wlroots_capture.rs`, skipped without VOELIN_WLROOTS_TEST_DISPLAY).
The ext-image-copy-capture path is untested: sway 1.9 predates it.
`CaptureBackend` gains `Portal` and `Wlroots` (names `auto`, `portal`,
`x11`, `wlroots` with `name()` / `FromStr`, as the stream settings spell
them); `Auto` stays the session default (the portal on Wayland).
`EncodedSource` passes `FrameSource::set_layer_bitrate` to the encoders
(`MediaSink::layer_bitrate`).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The streamer converted and encoded on one thread, one frame after the
other, with the frame rate clamped to 1..=60 and one encoder. It is now
a pipeline of threads connected by latest-wins handoffs:
capture thread (backend) ── convert + scale (pool of all cores)
── Handoff per layer ── encoder thread per layer ── MediaSink
- The capture backend calls the pipeline's `FrameSink` with the frame
still in its capture buffer. Frames beyond the frame-rate cap are
skipped before anything is read. The `Pyramid` converts the frame once
and derives every due layer's size (`LayerSpec::output_size`) from
the nearest larger one, in recycled frames.
- Each layer (`StreamerConfig::layers`; empty: one layer at
`bitrate_kbps`) has its own encoder thread and encoder, its share of
the CPUs, its own frame-rate cap (`max_fps`, paced by timestamps),
and gets the newest frame through a one-slot handoff; frames it was
too busy for are dropped and counted, never queued.
- Keyframes: `take_layer_keyframes` is polled by whichever encoder
thread gets to it and each requested layer is flagged, so exactly the
requested layers encode a keyframe (kept due until one is produced).
A still screen sends no frames, so a request is answered by encoding
the last picture again.
- Bitrate: every frame, each layer follows `layer_bitrate(id)` when the
sink knows it (capped by `max_bitrate`), else its configured bitrate;
libvpx changes it in place, without a keyframe.
- `Streamer::reconfigure(&codecs, StreamerConfigUpdate { fps,
bitrate_kbps, codec, layers })` applies from the next frame without
restarting the capture: new encoders are created first (errors change
nothing), layers keep their encoder when their id stays, new ids get
threads, removed ones stop, a codec change swaps every encoder (first
frame a keyframe), the frame-rate cap reaches the capture backend.
- No built-in limits: any fps >= 1, any bitrate, any size; threads from
the CPU count.
- `StreamerStats` gains capture fps, convert time, convert threads,
dropped frames, codec and per-layer `LayerStats` (size, frames,
keyframes, dropped, fps, kbit/s, encode time, target bitrate, threads,
encoder speed); counters are atomics, rates are computed once a second
by a stats thread, which logs a one-line summary every 5 s at debug
level. `StreamerStats` is no longer `Eq` (it has rates).
- `EncodedSource` answers `request_layer_keyframe`; the local preview
shows the first layer.
- In steady state nothing is allocated per frame between capture and
encoder; the one allocation per encoded frame is the `Arc<[u8]>` of
`EncodedFrame` (encoded sizes vary, so it cannot be recycled).
`voelinctl stream bench` prints the new per-stage and per-layer numbers
and allocations per captured and per encoded frame.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Conflicts with the SRTP/BWE/simulcast work were in the engine's command
loop, session and stream tasks (both sides kept: SRTP order and layers
next to settings and discovery) and in the voelin-stream exports.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
`EncoderConfig::threads` used to override the frame-size heuristic. The
streamer now passes each layer its share of the CPUs, so a small layer
(or a 320x240 test stream on four cores) was encoded with four VP8
threads and four token partitions, which cost enough quality to push
decoded colours of the test pattern out of tolerance now and then. A set
count is now a maximum, still limited to one thread per 320x240 pixels.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Frame durations follow the timestamps (variable frame rate), but a frame
whose timestamp had to be bumped to stay after the previous one got a
duration of one 90 kHz tick. CBR rate control then gave it almost no
bits, and it came out as a smear. This happens right after a keyframe is
re-sent for a still screen (stamped "now") when the next capture carries
an earlier timestamp; it showed up as a rare wrong-coloured pixel in the
stream-task test under load.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Screen sharing was slow mostly because every frame was copied and
allocated several times on its way to the encoder: the PipeWire callback
copied the mapped buffer into a new Vec, X11 copied the shared-memory
segment, Windows copied twice, `to_i420` allocated fresh planes on one
thread, and libvpx output was copied into Vec after Vec.
Capture backends now hand each frame to a `FrameSink` on their own
thread, with the pixels still in the capture buffer (`FrameRef`: borrowed
planes with strides). `ScreenCapture::start_sink` is implemented by the
test pattern (renders into one reused buffer), X11 (the MIT-SHM segment,
cursor blended in place, monitor/window geometry looked up once a second
instead of every frame), the portal and Windows Graphics Capture (the
mapped staging texture with its row pitch); other backends get a
forwarding default. `start` keeps working through a queue adapter.
`FramePacer` caps frame rates by timestamps; sinks can change the cap
while capturing (X11 and the test pattern follow, the portal renegotiates
the frame rate).
Portal: LINEAR DMA-BUFs are negotiated in addition to shared memory
(mandatory modifier, fixated by us, `dataType` per buffer kind), mapped
once per buffer and read between DMA_BUF_IOCTL_SYNC start/end. When
reading them is slow (uncached VRAM), the stream renegotiates to shared
memory. Tiled modifiers are not offered (needs a GPU import).
The streaming path:
- `workers::Workers`: a fork-join pool that allocates nothing per job.
- `convert::Converter`: any stride, BGRx/BGRA/RGBx/RGBA (yuv's SIMD
paths), I420 and NV12 into a caller's I420 frame, in row bands on all
cores; handles buffers without padding after the last row.
- `scale`: separable area-average downscaling (bilinear up), weights per
size pair computed once, a 2x2 box fast path, row bands on the pool;
`Pyramid` converts a capture once and derives every requested size
from the nearest larger one, sharing equal sizes.
- `pool::FramePool`: recycled `Arc<VideoFrame>`s; `handoff::Handoff`: a
one-slot latest-wins atomic handoff that counts replaced frames.
Codecs: `VideoEncoder::encode_with` hands out encoded frames borrowed
from the encoder (libvpx's own buffer; OpenH264 into a reused buffer).
libvpx: `cpu-used` adapts to the measured encode time against the frame
interval (VP8 levels -10..-4, VP9 starting at 8 within 5..9), threads from
all CPUs the frame size can use, VP8 token partitions and VP9 tile
columns from the thread count and width, keyframes only on request,
frame durations from timestamps (variable frame rate), `set_fps`, and
`speed` for stats. A probe on the desktop test pattern showed VP8 speeds
beyond -10 are no faster on screen content, only worse (about 3 dB PSNR).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Layer ids given by position were assigned after the placeholder source was
created, so its frames carried id 65535 and no viewer got video. Found
streaming placeholder layers through the TeamSpeak 6 dev server.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The window read its blobs (ui, audio, client_playback) from the store once
and wrote them back. It now opens the settings service on the client
database, attaches it to the engine, registers its own keys (ui,
client_playback), and loads config file, VOELIN_SETTING_* and `--set
key=value` overrides below the stored values. Its edits are set on the
service, which stores them off the UI thread and flushes on exit; changes
made elsewhere (e.g. Command::SetSetting) update the window's copies of the
audio, crash report and client volume settings. The crash report opt-in is
the crash_reports key the Android app already read (and stays in the blob
for older versions).
The share dialog starts from stream.fps and stream.bitrate_kbps and takes
any value typed next to the presets, which remain as shortcuts; what was
used is stored back. docs/architecture.md describes stream discovery and
the settings service.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The interop test now reads the transport's getStats() and requires
srtpCipher AES_CM_128_HMAC_SHA1_80 in both directions, and bandwidth
estimates from Chromium's transport-cc feedback. The docs describe the SRTP
profile order, the bandwidth estimation and the simulcast layers of our
stream, and the findings with Chromium 141.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Settings were JSON blobs the UI read once at start and wrote back. The
engine had no way to read settings, nothing was notified of changes, and
there was no place for command line or config file values.
settings::Settings holds typed keys (a Key<T> carries its name, value type,
default, validation and a kind for a settings page; a registry lists the
registered keys). The effective value comes from the runtime value stored
in the client database, else the command line or environment
(VOELIN_SETTING_STREAM__FPS, --set key=value), else a config file (TOML or
JSON), else the default; reset() removes the runtime value. Reads come from
memory as Arc<T>; writes update memory, notify, and go to SQLite on a
writer thread in batches. Subscribers get every set and reset; a
SettingWatch per key gets value changes. Stored values are versioned: the
first migration copies the share dialog's frame rate and bitrate and the
crash report opt-in out of the UI's blob, which stays for older versions.
The keys the streaming work needs are defined: stream.fps (default 60),
stream.bitrate_kbps (8000), stream.layers (LayerSpec-compatible), codec,
capture and encoder backends, SRTP profiles, hardware acceleration and
stream.permissions, plus audio and crash_reports. No key has a maximum.
The engine takes Command::SetSetting/ResetSetting/AttachSettings and
reports Event::SettingChanged/SettingRejected for every change, also ones
made directly on the settings; a changed audio key is applied to the
sessions. stream.permissions answers join requests: everyone accepts,
channel accepts clients in our channel and denies others (the server
relays requests from any channel), nobody denies, friends asks (no
contacts yet). StartStream's auto_accept still accepts everyone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The settings service keeps every value in memory and writes changes from
its own thread, several at a time. The store gets what that needs: all
settings as JSON text, deleting one, and writing a batch in one
transaction. Statements go through rusqlite's prepared statement cache, and
with WAL the database uses synchronous=NORMAL, so a write does not wait
for an fsync (WAL keeps the database consistent; a power loss may lose the
last transactions).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Official TeamSpeak 6 clients use AES_CM_128_HMAC_SHA1_80, while our peers
negotiated AES-256-GCM. PeerConfig::srtp_profiles now sets the order (default
AES_CM_128_HMAC_SHA1_80, then the GCM profiles for peers without it); a
DTLS provider wrapping str0m's dimpl DTLS applies it and records the
negotiated profile. It can be changed at runtime (Streams::set_srtp_profiles,
Command::SetSrtpProfiles) for new connections.
Streamer peers now run str0m's bandwidth estimation and pacer. Each viewer
gets the simulcast layer its estimate allows (down at once, up after 2 s
above the next layer's minimum plus 20%), switching at a keyframe of the new
layer, which is requested. Keyframe requests and bitrate targets (lowest
estimate of a layer's viewers) are per layer and reach the encoders
lock-free through LayerFeedback (StreamSink::take_layer_keyframes,
layer_bitrate). Peers that negotiate RID simulcast (PeerConfig::simulcast,
for SFUs/WHIP) get every layer with its RID. Layers can change while live.
voelinctl stream start takes --layer, --simulcast, --srtp and --placeholder
(layered synthetic frames without an encoder) and prints each viewer's
layer, estimate and SRTP profile.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The server announces a stream (notifystreamstarted) only to the clients in
the streamer's channel when it starts. A client that connects or enters the
channel later saw the streamer's client_is_streaming flag but could not
watch. The probe (docs/research/ts6-late-join.md) found that
`requeststreaminfo clid=<streamer>` answers with notifystreaminfo, one part
per stream of the client, from any channel.
voelin-stream gets a discovery module. Streams::update_clients takes the
clients on the server (channel and streaming flag), keeps the directory to
the streams in our channel, and looks up the streams of streamers in our
channel we were not told about: after connecting, after we or they change
channels, and when an announcement did not come. The answer fills the
directory like an announcement, so Event::StreamsChanged lists the stream
and it is watched like any other. Where streams are looked up is a
StreamLookup trait (the server now; a gateway directory can plug in with
Streams::add_lookup and report through Streams::discovered).
notifystreamupdated (updatestream) now updates the directory.
The engine and `voelinctl stream list/watch` feed the client list in. The
declarations learn the notifystreaminfo answer's fields, notifystreamupdated
and requeststreaminfo. Tests: a fake-server session test and an engine live
test with a viewer that arrives after the stream is live, discovery unit
tests, parsing of the server's answers; it-smoke gets a late-viewer step.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
The server announces a stream only to the clients in the streamer's channel
when it starts; clients that arrive later see only client_is_streaming. To
find out what the server offers instead, probe-stream runs two clients:
A creates a channel and starts a stream, B arrives afterwards and tries
candidate commands from another channel and from A's channel
(requeststreaminfo spellings, clientgetvariables, clientinfo, list-like
command names, joinstreamrequest with the learned id), A tries updatestream
and client_meta_data. Every command both clients exchange is printed raw
through a listener on the tsproto connection (tsclientlib's unstable API),
so notifications the declarations do not know yet show up too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
`voelinctl stream bench [--res WxH] [--fps N] [--codec vp8|vp9|h264]
[--layer SPEC ...] [--seconds N]` runs the streamer's real pipeline on the
test pattern without a server, into a sink that counts frames, keyframes
and bytes per layer, and prints frame and bit rates, CPU use and heap
allocations per frame in the steady state. Allocations are counted by a
global allocator in voelinctl only (one relaxed atomic add each).
The flat test pattern costs an encoder next to nothing, so it cannot show
how the pipeline copes with real screens. `Pattern::Desktop` looks like a
desktop with a code editor (gradient title bar, side bar, coloured lines
of text) whose document scrolls three pixels per frame; it is rendered
once and copied per frame, so drawing it stays cheap. The bench uses it by
default (`--pattern simple` for the old one); `StreamerConfig` gets
`synthetic_pattern`. Drawing the pattern now reuses a buffer
(`SyntheticScreen::render`) and fills rows by copying.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
Screen sharing converts pixels, encodes and packetizes every frame. In a
debug build the pure-Rust parts of that path (yuv, voelin-media, str0m,
x11rb-protocol, pipewire/libspa, wayland-client, opus2, openh264, dav1d)
ran unoptimized, which alone cost a large share of the frame budget. They
now build with opt-level 3 in the dev profile, like sonora already does.
libvpx, libdav1d and libopus are system or release-built C libraries, so
their Rust bindings need nothing.
Release builds use fat LTO with one codegen unit, so the per-pixel and
per-packet code inlines across crates. Panics keep unwinding: a panic in
one tokio task or media thread must not end the app (tasks and threads
report it, mutexes recover from poisoning), and the crash reporter's hook
runs either way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
A DTLS 1.2 server in dimpl picks AES-256-GCM whenever the client offers it,
and there is no setting. Our str0m peers are the DTLS server for official
TeamSpeak 6 viewers, which offer all profiles, so our streams used GCM while
official streams use AES_CM_128_HMAC_SHA1_80.
ConfigBuilder::srtp_profiles sets the profiles in order of preference: the
server picks the first of them the client offered, clients offer them in
that order and reject a server that picks another. Unset, everything is as
upstream. VOELIN-PATCH.md describes the patch and how to drop it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
str0m's DTLS stack (dimpl) hard-codes the SRTP profile a DTLS server picks
(AES-256-GCM first), with no way to configure it. Official TeamSpeak 6
clients use AES_CM_128_HMAC_SHA1_80, so we need to patch dimpl. This commit
only vendors the crate as published and routes crates.io's dimpl to it;
the change follows separately so it can be reviewed and dropped on its own.
third_party is excluded from the workspace so dimpl's dev-dependencies and
tests stay out of our builds, and own-crates.sh skips it like crates/proto.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
LayerSpec describes one encoding (size or scale, fps cap, bitrate range,
minimum estimate, RID); LayerSet is a growable set of layers. Encoded
frames carry their layer, FrameSource and MediaSink gain per-layer
keyframe requests and bitrate targets, and StreamerOptions and
StreamerConfig take the layer list. Behaviour is unchanged: one layer, 0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G