Commit Graph
146 Commits
Author SHA1 Message Date
Claude c4021b9859 voelin-core: live test of a viewer that answers another codec
Against the TeamSpeak 6 dev server: the streamer offers VP9 (its stream
codec) and VP8, a viewer that decodes only VP8 answers VP8 and decodes
pictures from the encoder made for it, and the VP9 encoder, wanted by
nobody, idles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-29 01:12:15 +00:00
Claude d769ab8910 docs: FFmpeg encoders, per-viewer codecs, how to install FFmpeg
docs/media.md: how FFmpeg is found (VOELIN_FFMPEG_DIR, VOELIN_FFMPEG,
any major version), which struct fields are read and how they are
checked, the backends and their realtime settings, runtime bitrate and
size changes, buffers, what is zero-copy and what is missing (the GPU
colour conversion), installing FFmpeg per OS, the offer with several
codecs and an encoder per codec viewers chose, the computed H.264 level,
the new API, voelinctl, licenses and what was tested how.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-29 01:10:26 +00:00
Claude fec23905d6 voelin-media: DMA-BUF import into VA-API encoders, up to the GPU conversion
FfmpegEncoder::encode_dmabuf maps a DRM PRIME frame onto a VA-API surface
(av_hwframe_map) that the encoder reads without a copy. It needs
AVFrame.buf[0] and AVFrame.hw_frames_ctx, which have no accessor: their
offsets come from a table per libavutil major, buf[0] is checked on a
real frame at load and hw_frames_ctx on the encoder's first surface.
Only NV12 buffers are taken: screen capture delivers RGB, which needs a
colour conversion on the GPU (VA-API video processing) that is not
implemented; anything else is refused as unavailable so the caller maps
the buffer as before.

On the capture side, FrameSink::accepts_dmabuf / dmabuf let the portal
hand a buffer over before mapping it (and pass tiled ones through). No
sink accepts yet, and the portal still negotiates LINEAR buffers only.

The encoder ends its stream when dropped (SVT-AV1 logs an error
otherwise).

Untested on a GPU: this machine has no render node.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-29 01:02:36 +00:00
Claude 2927100b20 voelinctl: list the video encoders, bench and stream with any of them
`voelinctl stream encoders` prints the FFmpeg libraries found, every
encoder backend with its self-test result or why it cannot be used, and
the order the streamer tries them in (--encoder / --no-hardware rank as
the settings would). `stream bench` and `stream start` take --encoder,
--no-hardware and a --codec that defaults to the named encoder's codec
or the choice's first; they print the backend in use. `stream start`
feeds a FrameSource, which does not tell codecs apart, so it offers its
stream codec alone; with the test pattern the H.264 level follows its
size, rate and bitrate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-29 00:56:41 +00:00
Claude 7db95404f5 Merge the audio mixer (ba69a4f) into the FFmpeg encoders branch
Both add to StreamerConfig, the reconfigure docs and the imports of core
media.rs and the UI's video.rs; kept both sides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-29 00:39:15 +00:00
Claude 6e5e138cca Encode each layer once per codec its viewers chose (WIP)
Offers list the stream codec first, then the codecs of hardware encoders,
VP8 through libvpx and HEVC last; software encoders other than VP8 are
only ever the stream codec, so no answer starts an expensive one. The
streamer's peer reports the codec each answer chose, the session sends
video only to viewers of its codec and tells the encoders through
LayerFeedback which codecs are needed. Each layer's encoder thread keeps
one encoder per such codec, made when a viewer needs it and dropped when
none does; the stream codec is skipped while nobody takes it.

The H.264 profile-level-id is computed from macroblocks per second, frame
size and bitrate (Table A-1), at least 3.1 as before. Streamer takes an
encoder preference (hardware on/off, auto / software / a named backend)
that reconfigure can change live. HEVC is negotiable (str0m packetizes
it) and only offered when a hardware encoder has it.

Work in progress: committed early so it cannot be lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-29 00:33:16 +00:00
Claude ba69a4f62d Merge the stream audio mixer and application audio sources
Stream audio is mixed from any number of sources (desktop, chosen apps,
the shared window's app, the processed microphone), each with gain,
mute and meters, changeable while live. Desktop audio now leaves out
Voelin's own playback on Linux, Windows and Android.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 19:49:51 +00:00
Claude 29c70c824c voelin-core: live media test checks the mixed audio goes out
ts6_test_pattern_decoded checked only the decoded video. It now also
checks that the streamer sent at least 50 Opus frames of the mixed test
tone while the viewer decoded, and that no audio source reported an
error. Passes against the TeamSpeak 6 dev server (VOELIN_LIVE=1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 19:36:38 +00:00
Claude 8b9ea9ca1d voelin-media: test FFmpeg encoders end to end, fix what that found
The self-test and a roundtrip through our own decoders (OpenH264 for
H.264, dav1d for AV1) run for every FFmpeg software encoder present:
x264, SVT-AV1, rav1e and libaom all decode above 28 dB PSNR with the
keyframes where they were asked for.

Fixes: SVT-AV1 takes CBR from rc=2 and rejects a maximum rate equal to
the target; rav1e refuses a keyframe interval of 2^30 and holds about 20
frames even in low-latency mode, so it is only used when named; a new
session flushes the old one so delayed frames are not lost; the first
packet of a session counts as a keyframe; FFmpeg's log lines go to the
encoder they are about when backends are tested in parallel.

Codecs::builtin() gives the compiled-in codecs alone, for tests that
check libvpx or OpenH264 specifically.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 19:30:29 +00:00
Claude 757d7c6382 docs/media.md: stream audio sources, the mixer, application capture
A "Stream audio" section covers the source kinds, how the mixer
behaves (latency, underruns, drift, limiter, meters), the audio thread's
clock and RTP time, live reconfiguration and per-source errors, the
stream.audio_sources setting, and per platform how application audio is
captured (all but ours, one app, the app list). The PipeWire note no
longer says our voices reach viewers, the pipeline diagram and streamer
bullets name the mixer, and the verification table lists the new tests
and what is only type-checked (WASAPI) or only compiled (Android).

The link manager's module doc also covers the marker property used in
sandboxes and the skipping of loopback and filter outputs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 19:25:57 +00:00
Claude c4dd3f564b android: playback capture of one app, or of every app but us
ScreenCaptureService now keeps any number of AudioPlaybackCapture
recordings by id instead of a single one. Each matches media, game and
unknown usages, and either the uid of one app (addMatchingUid) or every
uid but ours (excludeUid), so a shared screen no longer carries our own
voices and watched streams. Recording 0 still feeds
Native.onSystemAudio; the others feed Native.onAudioInput(id, ...), which
goes to the stream mixer's inputs.

Bridge gains startAudioInput(id, package or null), which maps the
package to its uid, plus stopAudioInput(id) and launchableApps(). The
manifest declares a launcher-intent <queries> so those apps and their
uids are visible on Android 11+.

Compiled with gradlew compileDebugKotlin. javap shows the JNI
signatures match crates/voelin-android/src/bridge.rs. Not run on a
device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 19:24:00 +00:00
Claude 746ab6abef voelin-android: playback captures into mixer inputs (Rust side)
PlaybackAudio implements AudioProvider::start_input / stop_input / apps:
each capture gets an id, its SourceInput is kept in the capture state,
and the Kotlin side is asked (Bridge.startAudioInput) to capture
everything but our uid or the uid of one app's package, delivering to
Native.onAudioInput(id, ...), which pushes into that input from a reused
per-thread buffer. An app picked by name is looked up among the
launchable apps (label or package) and falls back to the name as a
package. Picking by process fails on Android. apps() lists the
launchable apps (Bridge.launchableApps, "label<TAB>package" lines),
because Android cannot tell which apps play.

The Kotlin counterpart follows in the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 19:20:19 +00:00
Claude badfb328a0 voelin-media: load FFmpeg at runtime for more video encoders (WIP)
Hardware encoders (VA-API, NVENC, Quick Sync, AMF, Media Foundation,
VideoToolbox) and more software ones (x264, OpenH264, SVT-AV1, rav1e,
libaom) through whatever FFmpeg is installed, found with libloading and
never linked. Codec settings go through AVOptions only; the few struct
fields without an accessor are located and checked at runtime, so any
major version with a matching layout works. Each backend encodes one
test frame at startup and is skipped with a reason if that fails.

Codecs gains an encoder preference (hardware on/off, auto / software /
a named backend) and a report of every backend for the UI. Codec gets
H265 for peers that negotiate HEVC.

Work in progress: committed early so it cannot be lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 19:15:38 +00:00
Claude 2c655048c0 voelin-core: stream audio mixed from any number of sources
The streamer captured one audio source (system audio, or a tone with the
test pattern), so viewers also heard the voices we play back, and there
was no choice of what to share.

StreamerConfig::audio_sources now takes any number of AudioSourceSpec
(kind, gain, mute): DesktopWithoutSelf, App(name or pid), WindowAudio
(the shared window's process, on X11 and Windows), Microphone (after
noise suppression, through the voelin-audio tap) and Synthetic. They feed
a StreamMixer whose thread encodes one Opus frame every 20 ms on the
monotonic clock, stamped with the block number, so the RTP time follows
real time across silences and stalls. Mixing goes on without a sink, so
source buffers keep moving.

StreamerConfigUpdate::audio_sources changes them live: kinds that stay
keep their capture and take the new gain and mute, new ones start,
removed ones stop, and an empty list leaves a silent track. A source that
cannot capture does not fail the stream; its error shows in
StreamerStats::audio_sources (with level, state, latency and underruns),
and in Streamer::audio_error, which now returns an owned String.
StreamerStats also carries the mix level and the limiter gain;
Streamer::audio_mixer gives the handle for lock-free meters, and
media::audio_apps lists the applications for a picker.

The settings key stream.audio_sources (JSON, default: desktop audio
without Voelin) stores the sources. The UI's share reads it, and an
empty list shares without sound. StreamAudio is boxed so a LocalPreview
held inline stays small.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 12:49:52 +00:00
Claude 1725b11f07 voelin-media: BlockClock::due returns the due block numbers
A block's number is the audio's position since the start, so a caller
can stamp RTP times with it. Previously a stall past max_behind restarted
the clock at block 1 and the count said nothing about where the audio
was. Now only the newest block is due after a stall, numbered by the
elapsed time, so timestamps keep following real time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 12:43:42 +00:00
Claude 897eec031d Merge chat history and the gateway's features in the engine
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
2026-09-28 12:37:29 +00:00
Claude 90d55bd4fa voelin-media: capture chosen applications' audio, and everything but ours
Screen-share audio took the default sink's monitor on Linux, so viewers
heard the TeamSpeak voices we play, and there was no way to share one
application's sound only.

capture::playback::start_playback(filter, source) now captures what
applications play into a mixer source, with PlaybackFilter::AllButSelf
(everything except our process and its descendants) or App(Pid | Name),
and audio_apps() lists the applications that play, updated live:

- Linux: a LinkManager (capture/pipewire_links.rs) watches the PipeWire
  registry for Stream/Output/Audio nodes and their clients, and links the
  output ports of every selected stream through the link-factory into a
  capture stream of ours that the session manager leaves unlinked
  (node.autoconnect = false). PipeWire sums the links, so one capture
  stream carries any number of applications; links follow streams as
  they come and go, and a restarted application is matched by name
  again. Our own streams are recognised by process id (node, client, or
  socket credentials; /proc parent chain); loopback and filter outputs
  (node.link-group) are skipped because their sources are captured
  directly. This depends on no session-manager policy, adds no sink,
  and leaves the user's routing and volumes alone.
- Windows: WASAPI process loopback per capture, exclude mode on our
  process tree for everything, include mode on the chosen process tree
  (for a name, one capture per matching audio session's process,
  matched again every two seconds); sessions of all playback devices
  for the list; the owner of an HWND for window audio. Only
  type-checked (x86_64-pc-windows-gnu).
- Platform providers (Android) get start_input / stop_input / apps.
- X11: window_pid() reads _NET_WM_PID, so a shared window's audio can be
  selected automatically.

tests/pipewire_apps.rs runs a private PipeWire, WirePlumber and D-Bus
(skipped without them) with two tone players in other processes and one
in ours, and checks by frequency that desktop audio has both players and
not us, that name and pid captures have only their application, that a
new player is linked live, a quit one dropped, and a restarted one
matched again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 07:55:00 +00:00
Claude f13b0a804a Merge the UI foundation: Voelin design system, desktop and phone shells
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
2026-09-28 07:53:58 +00:00
Claude 846f8e2f21 voelin-ui: build alone for Android with image support
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
2026-09-28 07:41:48 +00:00
Claude b0be382f1a Cargo.lock: rtrb for voelin-media
The lock file entry for the stream mixer's ring buffers, left out of
the mixer commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 07:36:24 +00:00
Claude 0cebc10e3b voelin-core: remember a server's addresses with the gateway's id
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
2026-09-28 03:01:30 +00:00
Claude 3cdf87b75e docs: the UI's structure, components and screenshots
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
2026-09-28 02:58:20 +00:00
Claude c1e96ac607 Docs: chat history and the gateway's features in the engine
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
2026-09-28 02:56:49 +00:00
Claude 1338a220b9 voelin-ui: fixes from the screenshots
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
2026-09-28 02:56:25 +00:00
Claude 3a703559e9 voelin-audio: tap for the processed microphone
The screen share should be able to carry our microphone as one of its
audio sources, and it should be the processed signal (echo
cancellation, noise suppression, gain control) the voice connection
sends, not a second raw capture of the device.

voelin_audio::tap::microphone() is a publish point the voice pipeline
feeds with every processed chunk. Without consumers that costs one
relaxed atomic load per chunk. Consumers attach a TapSink and get the
chunks on the audio thread; the publisher never waits (a try-lock that
only contends with attach and detach). Several pipelines (one per
server, the microphone test) may run at once: the tap follows one until
it is silent for 200 ms. A muted microphone publishes silence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 02:56:17 +00:00
Claude 2203e8f840 voelinctl, it-smoke: chat history, gateway features and the stream directory through the engine
`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
2026-09-28 02:55:29 +00:00
Claude 6d90f270e6 voelin-media: stream mixer for any number of audio sources
The stream's audio will come from several captures at once (desktop
audio without our own voices, single apps, the microphone), each
delivering at its own pace, rate and channel count. StreamMixer mixes
them on the streamer's clock into 48 kHz stereo:

- every source has a gain, a mute and any number of inputs; an input is
  a lock-free single-producer ring (rtrb) that the capture thread fills,
  mapping channels to stereo as it pushes
- each input is held at a small fixed latency (more for bursty or late
  inputs), starts once that much is buffered, fades out and waits when
  it runs dry, and never holds up the other sources
- rate conversion is per-input cubic interpolation; clock drift is
  absorbed by resampling up to 0.5 % while the buffer is off its
  settled level, otherwise 48 kHz input is copied bit-exact
- a soft limiter on the sum keeps the output within full scale
- peak/RMS meters per source and for the output are atomics that the
  UI reads without locks
- buffers are sized when sources and inputs are created; mixing
  allocates nothing per block (checked by a counting-allocator test)

Includes unit tests and a Criterion bench (benches/mix.rs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 02:50:45 +00:00
Claude e13fc8d785 voelin-core: tests for chat history, gateway requests and the directory
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
2026-09-28 02:44:46 +00:00
Claude d8077e139a voelin-ui: standard widgets follow the app theme
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
2026-09-28 02:43:04 +00:00
Claude 8982e1375d voelin-core: chat history and the gateway's features in the engine
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
2026-09-28 02:38:32 +00:00
Claude a668364bb2 Notices for the bundled font, icons and emoji
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
2026-09-28 02:35:53 +00:00
Claude d2a6f97b5d voelin-store: chat history schema 2 with dedupe, paging and sync cursors
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
2026-09-28 02:22:53 +00:00
Claude e40bce40e8 voelin-ui: design system, shells and view models for the new design
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
2026-09-28 02:22:25 +00:00
Claude b07c77bc5f Merge the faster screen-share pipeline
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
2026-09-28 02:21:24 +00:00
Claude 45889adf0b docs/media.md: before/after numbers of the streaming pipeline
`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 (a89ac5f). After: the
threaded pipeline (quiet column: ffc79e6; busy column: f6a4ae3).
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); f6a4ae3 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
2026-09-27 19:06:14 +00:00
Claude 456cafb1c7 Merge the gateway extension: pins, reactions, topics, events, stream directory, activity, runtime settings
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
2026-09-27 18:52:12 +00:00
Claude 91d69f1933 Docs: gateway runtime configuration, permission rules and protocol
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
2026-09-27 18:41:25 +00:00
Claude c84eaacbf5 voelin-core: typed gateway client for the new features
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
2026-09-27 18:38:48 +00:00
Claude f6a4ae35e7 Encoders use all CPUs but one by default
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
2026-09-27 18:38:33 +00:00
Claude 66b9ce444e voelin-ui: bundle Inter, Lucide icons and Twemoji
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
2026-09-27 13:57:16 +00:00
Claude ed86de3283 tsgw: in-process tests against a fake ServerQuery server; fix relay race
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
2026-09-27 13:56:05 +00:00
Claude ffc79e6835 libvpx speed control: no VP8 levels below 6, react to overload at once
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
2026-09-27 13:45:13 +00:00
Claude 6c6cd5b70f tsgw: runtime settings, versioned database, pins, reactions, topics, events, streams, activity
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
2026-09-27 13:44:49 +00:00
Claude 749171605c Gateway protocol: pins, reactions, topics, events, streams, activity, admin
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
2026-09-27 13:33:11 +00:00
Claude af09a2031a Criterion benches for conversion and scaling; media docs
`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
2026-09-27 09:06:29 +00:00
Claude 7b7c15a37f wlroots capture backend; portal and wlroots as streamer backends
`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
2026-09-27 09:04:05 +00:00
Claude c56315ce38 Streamer: threaded simulcast pipeline, per-stage stats, reconfigure
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
2026-09-27 08:58:24 +00:00
Claude 372d26fc2b Merge late-join stream discovery and the settings service
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
2026-09-27 08:58:21 +00:00
Claude 8a4f7e185f Encoder threads: an explicit count is a maximum the frame size still caps
`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
2026-09-27 08:54:37 +00:00
Claude 52a78c4195 libvpx: never budget a frame less than 3/4 of the frame interval
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
2026-09-27 08:44:26 +00:00