Commit Graph
172 Commits
Author SHA1 Message Date
selikhovandClaude Opus 5.5 92f49cdffd Merge the fix for AMF crashing the app during the encoder probe
AMD's AMF runtime is not safe to open on several threads at once; the
probe did exactly that and crashed the app inside avcodec_open2. AMF
opens are serialised, and on Linux AMF is used only on request
(VOELIN_FFMPEG_AMF=1): VA-API drives the same encoder there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 07:22:01 +03:00
selikhovandClaude Opus 5.5 5de0627a45 voelin-media: keep AMF's runtime from crashing the app during the probe
The desktop app died at startup under Xvfb with SIGSEGV in libamfrt64,
inside avcodec_open2 while the encoder probe opened h264_amf, hevc_amf
and av1_amf on parallel threads. Reproduced with the probe alone: 10 of
420 runs crashed with four to eight processes probing at once, every one
in AMF's process-wide AMFFactoryHelper (Init, or Terminate dlclose-ing a
library) while AMFContextImpl::InitVulkan created an encoder's device.
Serialising AMF opens within the process removed it: none of 600 runs
crashed, with the processes still probing together. So the race is
between threads of one process, not between processes.

Two changes:

- AMF encoders are opened and closed one at a time in the process. That
  fixes the race wherever AMF is used: the probe, simulcast layers
  opening together, and Windows, where AMF is the AMD encoder.

- On Linux AMF is not used unless VOELIN_FFMPEG_AMF=1. FfmpegEncoder::new
  refuses it with the reason, so neither the probe, nor the factories, nor
  a direct caller loads the runtime at all. VA-API drives the same VCN
  encoder there, measured as fast with less CPU, and only VA-API takes
  DMA-BUFs without a copy; AMF on Linux is AMD's closed runtime on top of
  Vulkan, and a library that is never loaded cannot crash the app.

Not done: running the self-tests in a child process. A clean child does
not reproduce the state of the process that opens the encoder afterwards
(here the race only showed under load), so it would pass a backend that
can still crash the app, and every binary's main would have to cooperate.

Tests: the AMF refusal through FfmpegEncoder::new, the probe reporting
the reason without libamfrt mapped into the process, and an ignored
stress test that opens every AMF encoder on parallel threads 40 times
(with VOELIN_FFMPEG_AMF=1 it passes; the probe loop it replaces crashed).

On this machine the automatic H.264 encoder changes from h264_amf to
h264_vaapi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 07:19:41 +03:00
selikhovandClaude Opus 5.5 08162182d4 Merge the server screens of the new design
Chat with author grouping, reactions, file cards and the composer;
a resizable members panel grouped by server group with badges and a
member card; pinned-message and topic drawers; the voice-channel grid
with stream cards; the watch-stream screen with viewers, volume, chat
and a full-window pop-out. Screenshots run headless on Xvfb with
WAYLAND_DISPLAY removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 07:07:08 +03:00
selikhovandClaude Opus 5.5 9960fe106e Describe the server page in docs/ui.md; screenshots of its final state
docs/ui.md gains a section on the server page: each part (chat, members
panel, member card, pins, topics, voice channel, watching a stream), the
`VOELIN_OPEN` switch that shows it, and the engine events and requests
it uses. The settings table lists `ui.members_width`, the switches and
the screenshot script are described as they now work, and the limits say
what the design shows that we leave out (offline members, a quality
picker without layer information, a second window for the pop-out).

The screenshots are taken again so they all show the chat at its newest
message. The user card's avatar has the green ring while our voice goes
out, the speaking indicator of the compact voice controls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 06:56:37 +03:00
selikhovandClaude Opus 5.5 5446cea567 tsclientlib: keep its tests from failing in a chain on test order
The tests share a tracing setup in a Lazy that called init(). When the
quickcheck test ran first, its logging (use_logging) had already
installed a log logger, init() panicked with SetLoggerError, the Lazy
was poisoned and every later test of the binary failed. Use try_init().
Recorded as local patch 10 in UPSTREAM.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 06:56:07 +03:00
selikhovandClaude Opus 5.5 cf0a0211c1 Merge the GPU validation of the hardware video path
Measured on a real RX 7900 GRE with FFmpeg 9: VA-API and AMF encode
1080p60 and 1440p60 at a quarter to half a core, simulcast included;
RGB DMA-BUFs are converted to NV12 on the GPU; Wayland screen capture
delivers frames again (it delivered none) and switches to shared memory
where reading GPU memory is slow; the H.264 level of the SPS matches
the offer; AV1 is cropped to what this GPU really encodes; FFmpeg 9's
structure offsets are checked against its headers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 06:55:32 +03:00
selikhovandClaude Opus 5.5 eef80b54a2 voelin-ui: open chats at the newest message, and jump to pins
Nothing set the position of the message list, so a chat opened at the
oldest loaded message and new ones arrived out of sight below. The list
now starts at its end and follows new messages while it is there;
scrolling up stops that until the end is reached again, and another tab
starts at its end.

Jumping to a pinned message highlighted it but did not scroll: it now
scrolls to the message (to where an average row would be, as the
standard list estimates it, since rows differ in height) and leaves an
open topic for the chat.

The members panel could be dragged no wider than 420 px; it can now
take what the window allows while the chat keeps 400 px.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 06:49:46 +03:00
selikhovandClaude Opus 5.5 1d7891d9b1 voelin-ui: show how many watch a stream, from the gateway's directory
The viewer count in the player and on the stream cards was never filled
in a real session: the engine subscribes to the gateway's stream
directory, whose entries carry the number of viewers, but the UI dropped
those updates. Keep the counts per session by stream id from
`GatewayUpdate::Streams`, `StreamStarted`, `StreamUpdated`,
`StreamRegistered` and `StreamEnded`, and show them in the player ("12
watching") and on the voice channel's stream cards. The sample data
answers with a directory, like a gateway, instead of setting the count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 06:40:50 +03:00
selikhovandClaude Opus 5.5 7a3f5b0436 Refuse streams without a common codec; voelinctl streams VP8 by default
On a machine with hardware encoders, voelinctl's streamer chose H.264
(the first hardware codec) and, sending through a FrameSource, offered
it alone. A viewer that cannot decode H.264 (no OpenH264 library)
answered with a video section that listed no payload type at all; the
streamer could not parse that answer and dropped the viewer, which only
saw "removed by the streamer (Failed)".

A viewer now refuses such an offer with the codecs on both sides, and
voelinctl's single-codec offer defaults to VP8, which every client
decodes; --codec or a named --encoder still pick another. The engine's
own streams are unaffected: they offer several codecs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 06:35:32 +03:00
selikhovandClaude Opus 5.5 9ebffac8af voelin-media: give av1_vaapi a two-second rate-control buffer
The measurements on the RX 7900 GRE had av1_vaapi as the one backend that
did not hold its bitrate: 3.5 % over at 1080p60 / 6 Mbit/s and 7.9 % over
at 1440p60 / 10 Mbit/s, on the desktop pattern, every frame encoded. A
stream that keeps sending more than the estimate allows is answered by
the congestion control with loss and a lower target.

Measured directly on the encoder, 600 frames after 120 of warm-up:
`maxrate`, `rc_mode`, `blbrc` and the QP bounds change nothing; only the
buffer does. With twice the bitrate as `bufsize` it lands at -0.8 %
(1440p60), -0.2 % (1080p60) and -1.2 % (720p30 / 2 Mbit/s), no frame
skipped, the largest frame 68 KB against 64 KB before (h264_vaapi's
largest at the same settings is 86 KB). Every other backend keeps the
one-second buffer it was within 2 % with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 06:35:27 +03:00
selikhovandClaude Opus 5.5 4747756f24 voelin-ui: new screenshots of the server screens
The pictures in docs/screenshots/ showed the server page before the
design's layout. They are taken again with scripts/shots.sh, and the new
screens get their own: the voice channel, the pins, the topics, an open
topic, the member card and the stream popped out.

`VOELIN_OPEN=topic:<id>` now fills the sample topic as the gateway would
when it is opened (it was answered once at start and then cleared), and
the top bar's members button also closes an open drawer, like the chat
header's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 06:33:35 +03:00
selikhovandClaude Opus 5.5 c4caeac168 voelin-ui: closer to the mockups in the details; steadier screenshots
The voice channel's buttons now sit beside its title, so the topic and
the count below use the whole width, as in the mockup. The stream card's
gradient has two stops: the software renderer drew a dotted seam at the
middle one. The resize handle is a grip of three dots.

Screenshots run with FFmpeg off (probing a hardware encoder crashed the
app now and then in this machine's AMF driver, which no picture needs),
on a screen twice the window's size so the pointer is not over the
window (it made a message show its hover actions), and take extra
arguments such as `--set ui.theme=light`. The development switches list
the new screens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:41:54 +03:00
selikhovandClaude Opus 5.5 a2c630358b voelin-media: build the FFmpeg encoders where rustix is not a dependency
rustix is a Linux-only dependency, but the code that redirects standard
error during the probe was compiled for every unix, so the default
`ffmpeg` feature did not build for Android (checked:
`cargo check --target aarch64-linux-android --no-default-features
--features ffmpeg`) and would not for macOS. On Windows the type had no
Drop impl, which `clippy --target x86_64-pc-windows-gnu`, the documented
check of the Windows code, refused (drop_non_drop).

Gate the redirection on Linux and keep a Drop impl everywhere. The new
LINEAR DMA-BUF test buffer (/dev/udmabuf) is Linux-only as well, so the
Windows check with --all-targets passes again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:41:17 +03:00
selikhovandClaude Opus 5.5 48a4ffc63f voelin-media: keep the PipeWire test off the machine's real speakers
The application-capture test runs a private PipeWire and WirePlumber,
but WirePlumber's default profile still monitors the sound cards,
Bluetooth and cameras. On a desktop with a sound card its 0.3-amplitude
test tones could therefore be routed to the real speakers or
headphones. Disable the hardware monitors (the 0.5 profile and the 0.4
Lua fragments) and give the null sink the highest priority, so the
private graph holds nothing but the test sink.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:35:43 +03:00
selikhovandClaude Opus 5.5 2bd78ca39d voelin-media: hand a DMA-BUF-taking sink the buffer's real size
The portal offers a sink that accepts DMA-BUFs the buffer as it is, with
its size taken from `mapoffset + maxsize`: the same fields 9b09e7b found
0 for every DMA-BUF this compositor sends, which left the mapping empty.
On the sink path the size goes into the DRM PRIME descriptor of the
import. Mesa happens to ignore it (an import with size 0 encoded the same
picture here), but the size is part of the descriptor and other drivers
use it, so ask the buffer object (lseek to the end, which a DMA-BUF
answers with its size) and fall back to the rows the format describes.

The module documentation now says what a DMA-BUF-taking sink gets, and
why tiled buffers are still not offered: the modifiers the encoder's
driver imports are not known on this side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:35:34 +03:00
selikhovandClaude Opus 5.5 92f5cd7c5b voelin-ui: watch a stream as the design shows it
The viewer put a title bar above the picture and the chat in a column
beside it. The design keeps the channel's header and puts the chat under
the player, so the members panel stays beside it with the people in the
channel first.

The player is a card with the streamer, the title and the number of
viewers over its top, LIVE and the picture's height (or the simulcast
picker when the streamer offers layers) at the right, and the controls
over its bottom: volume, the elapsed time, back to the chat while
watching on, pop out and full screen. Under it a note says the stream
belongs to the voice channel, then the chat and a Stream Info tab. In
full screen and on a phone the player is alone and carries Leave.

With sample data, `VOELIN_OPEN=watch` plays the local test pattern in
the sample stream's place, so the screenshot shows a picture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:33:03 +03:00
selikhovandClaude Opus 5.5 3982b8db71 voelin-media: convert RGB DMA-BUFs to NV12 on the GPU for VA-API encoders
Screen capture hands over RGB, and encode_dmabuf took only NV12, so the
zero-copy import never carried a captured frame. VA-API encoders now take
XR24, AR24, XB24 and AB24 buffers too: the buffer is mapped onto a VA-API
surface of its own size and converted into the session's NV12 surface by
VA-API video processing, cropped to the coded size on the way, and the
call returns once the GPU has read it, so the buffer can go back to the
compositor.

The conversion goes straight to libva (vaCreateConfig with
VAEntrypointVideoProc, one VAProcPipelineParameterBuffer per frame) on
FFmpeg's own VADisplay, found through AVHWDeviceContext.hwctx, located
and checked like the other fields. FFmpeg has the same conversion only in
libavfilter, which would be another library to find and a filter graph
to drive for one call. libva is the library FFmpeg's VA-API support
already loaded, and its ABI has not changed since libva 2.

Measured against the CPU's conversion of the same picture: Mesa converts
the transfer function as well unless told otherwise, and a dark pixel
came out 5 levels too bright (grey 30 as Y 47 instead of 42). Describing
the input with BT.601 primaries and transfer, as the output, leaves just
the matrix: Y now matches exactly, U and V within 0.7 on average.
Through h264_vaapi and av1_vaapi to our decoders the GPU path is within
0.3 dB of the CPU path, from the driver's own tiled buffer and from a
LINEAR one with a padded pitch (/dev/udmabuf), which is what the portal
negotiates.

CPU per 2560x1440 frame on the way into h264_vaapi (release): 4.3-5.2 ms
when the CPU converts and uploads, 0.08-0.09 ms from an RGB DMA-BUF;
0.26-0.31 cores at 60 fps against 0.005.

Also: dropping a VA-API encoder whose first frame failed (an import that
failed, here) drained a session that had never received a frame, and
FFmpeg 9's h264_vaapi crashes doing that (SIGSEGV in avcodec_send_frame,
reproduced with an empty session alone). Sessions remember whether a
frame went in and are only flushed then.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:32:22 +03:00
selikhovandClaude Opus 5.5 7d7e26a397 voelin-media: say how the background mask is really sampled
The segment docs promised a bilinear, feathered mask; the frame path
samples the nearest mask pixel and relies on the mask's own soft edge.
Say so, here and in docs/studio.md, rather than promise a smoothing that
is not there: a model's sharper mask will want it, and that is the place
to add it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:29:15 +03:00
selikhovandClaude Opus 5.5 5291f86147 voelin-media: stop copying an image backdrop every frame
Replacing a camera's background with an image cloned the whole scaled
image (3.7 MB at 720p) for every frame, on the camera's thread, only to
mix it and drop it: the mix only needs to read it. The image path had no
test; one now checks the image shows behind the subject and the subject
stays as it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:26:58 +03:00
selikhovandClaude Opus 5.5 d18f194c82 voelin-media: drop the unused v4l feature
The studio branch declared a `v4l` feature that nothing reads: cameras
are listed through V4L2 with the PipeWire feature and captured through
PipeWire. An empty feature only suggests a choice that does not exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:25:45 +03:00
selikhovandClaude Opus 5.5 8ac4575377 voelin-media: build the studio without the PipeWire feature
The camera list read V4L2 on any Linux build, but the ioctls go through
rustix, which only the capture features bring in: voelin-media without
default features (a core built with `media` alone) did not compile.
Devices are now listed where they can be captured, through PipeWire;
everywhere else the list is the test pattern. Checked with and without
default features, and for x86_64-pc-windows-gnu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:24:50 +03:00
selikhovandClaude Opus 5.5 decddc357f voelin-ui: lay the server screens out as the design mockups do
The screens were built before the mockups were at hand and guessed at
their layout: a strip of voice controls over the chat, pins and topics
floating over the messages, the voice channel as a grid of tiles and a
members panel of our channel only. The mockups put them elsewhere.

- The members panel lists everyone on the server, "Members — N" with a
  search: those streaming (or, in the voice channel and while watching,
  the people in our channel) first, then each server group in the
  server's order, people elsewhere with the channel they are in, and
  moderator groups as a role next to the name.
- Pinned messages and topics take the members panel's place, as cards;
  topics can be searched and show when they were last active, and the
  chat header opens them with labelled buttons.
- The voice channel view is a header with Voice Settings and Leave, the
  people as large avatars with talking and muted marks, the streams as
  large cards (with the picture while we watch) and the channel's chat.
- The chat drops the extra voice strip (the sidebar has the controls);
  messages are larger, times read "Today at 10:14", reactions end with
  an add button, and the composer has a round attach button.
- Hold-to-talk shows only with push-to-talk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:23:00 +03:00
selikhovandClaude Opus 5.5 f4fe3511f8 voelin-media: close the studio's pushing outputs when the stream ends
GoLive said it started the outputs that push and EndStream that it
stopped them, but both only changed the state: a WHIP output kept
pushing to the service after End Stream. WHIP outputs start when they are
added (that is when the service is asked), so GoLive now says just that,
and EndStream closes every output that pushes, reporting each removal;
recording and the replay buffer keep running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:22:41 +03:00
selikhovandClaude Opus 5.5 2a15f22313 voelin-media: restart a studio input only when it has to
Two rules said when a source's input restarts: the controller's own,
and SourceKind::same_input, which nothing called and which would have
kept a text source's old picture after its text changed. Now there is
one, same_input, and it also keeps a camera running when only its
mirroring changes: that is drawn by the compositor, and restarting the
camera for it meant a second of black while PipeWire renegotiated.

A WHIP output that drops a packet because its upload stalled now asks
for a keyframe, so the service's decoder recovers when the upload does
instead of showing a broken picture until somebody else asks.

The segmenter's input_size was never called (the frame path sizes the
segmenter's copy itself) and divided the height by the clamped width;
the trait now says what the segmenter is given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:21:36 +03:00
selikhovandClaude Opus 5.5 b8b357a00a voelin-media: keep the audio of a recording's first moment
A recording and a clip start at a video keyframe, and dropped all audio
that came before it. But the video encoder is behind the audio: by the
time the keyframe of a moment arrives, the audio of that moment and of
the encoder's whole delay has already gone by. With a hardware H.264
encoder starting up, a recording's audio began 285 ms after its picture.

The recorder now keeps the last two seconds of audio while it waits and,
once the keyframe is written, writes the part not older than it. The
replay buffer keeps waiting audio the same way, and when it trims to a
keyframe it keeps the audio of the keyframe's time that arrived before
it; a clip feeds everything to a recorder, which skips video up to its
first keyframe. The same recording now starts its audio 10 ms after the
picture (one Opus frame).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:10:43 +03:00
selikhovandClaude Opus 5.5 897087112e voelin-media: decode what the GPU encoders produce, and crop AV1 to what RDNA3 encodes
Nothing had ever decoded the output of a hardware encoder. The round-trip
the software encoders go through (our own decoders: OpenH264 for H.264,
dav1d for AV1; keyframes where asked, timestamps kept, PSNR above 28 dB)
now runs over every usable H.264 and AV1 hardware backend, at 320x240 and
at 1920x1080, which is not a whole number of macroblocks.

h264_vaapi and h264_amf decode exactly at both sizes (the SPS crops the
coded 1088 rows). av1_vaapi and av1_amf do not: on this RX 7900 GRE the
AV1 encoder pads the width to a multiple of 64 and the height to 16, and a
height 8 more than a multiple of 16 by 2 rows, so 1366x768 comes out as
1408x768, 1600x900 as 1600x912 and 1920x1080 as 1920x1082. AV1 has no
cropping like H.264's SPS, so every viewer would show the padding.

The self-test of AV1 backends now encodes 258x258, 2 more than a power of
two, reads the frame size the sequence header declares, and derives the
alignment the encoder pads to; encoders crop frames to it, as they already
cropped odd sizes to even ones. Measured here: (64, 16) for both AV1
hardware backends, (2, 2) for the software ones, so 1920x1080 is sent as
1920x1072 and decodes as exactly that. Taking the alignment from the
stream instead of from the GPU's name keeps hardware that does not pad
uncropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:04:03 +03:00
selikhovandClaude Opus 5.5 b048cacc82 voelin-core: stream the studio and keep its scenes in the settings
The studio composites, but nothing yet made its picture a stream or fed
its recording and replay buffer. Streamer::start_studio does both with the
smallest change to the streamer: the studio is one more capture backend,
and the packets the encoders already make are teed to the studio's outputs
where they are produced, with the frame size the recorder needs. Only the
stream codec's encoder is teed; a codec a viewer chose is never recorded.

Recording and the replay buffer must not need a live stream, so a studio's
streamer always has a sink: while no stream is attached it is one that
drops the frames after the tee. Its audio clock starts at the studio's
epoch, the clock the composite's timestamps already count from, so a
recording's audio and video start together (the test checks they do).

Outputs ask for keyframes of the layer they take only. The replay buffer
asks every two seconds while it is on: the encoders make keyframes only on
request, so without that the window could never move past the first one
and would grow for the whole session. WHIP asks once per need (start,
session up, the service's PLI) instead of on every frame until connected,
which would have made every frame a keyframe while ICE came up.

voelin_core::studio re-exports the studio, starts it from studio.scenes and
keeps the two in step both ways without echoes; studio.replay_seconds,
studio.replay_memory_mb and studio.recording_dir join the built-in keys
(with feature media). tests/studio.rs records a stream that switches scenes
live and saves a clip, and decodes both with ffmpeg: red before the switch,
blue after it, VP8 and Opus in sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 02:02:40 +03:00
selikhovandClaude Opus 5.5 6d1dd65c17 Take screenshots on the Xvfb server, not on the Wayland desktop
winit prefers Wayland when WAYLAND_DISPLAY is set, so `xvfb-run` in a
Wayland session still opened the window on the desktop, where the
compositor chose its size. That looked like the X server ignoring the
requested size. Remove the variable for the screenshot run, and size the
Xvfb screen like the window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 01:56:31 +03:00
selikhovandClaude Opus 5.5 2e4f282732 voelin-ui: give the window back its normal minimum width
A minimum width of 1600 px was left in from a debugging session in which
the headless X server seemed to ignore the requested window size; it
made the window unusable on smaller screens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 01:51:36 +03:00
selikhov 5b70c44ba9 Merge branch 'worktree-agent-a7f9f51b4ced7cef7' into worktree-agent-a97633f32fc7a58c8 2026-10-03 01:43:37 +03:00
selikhov 9cf1684988 Merge branch 'worktree-agent-ac629e6df2e4ff6f5' into worktree-agent-ae018f32455363dbb 2026-10-03 01:43:35 +03:00
selikhov a0ae5499ec Merge branch 'worktree-agent-a5c4db1cfdf260dca' into worktree-agent-a16cf8e8a11a0c01d 2026-10-03 01:43:33 +03:00
selikhovandClaude Opus 5.5 a5ec729234 WIP: round-trip test for the hardware encoders (interrupted by a session limit)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 01:42:18 +03:00
selikhovandClaude Opus 5.5 f47d85a85c WIP: voice grid sizing, more sample chat (interrupted by a session limit)
Saved as found when the agent stopped; app.slint still carries a
diagnostic min-width of 1600px that must be reverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 01:42:18 +03:00
selikhovandClaude Opus 5 7f184316a6 voelin-media: give the studio a controller and background blur
The UI needs one place to drive: a Command per thing a person can do, a
stream of Events back, and a preview it reads at its own size and rate
without ever holding up the composite. Studio is that place. It keeps the
scene graph, starts and stops the inputs the live scene needs, runs one
compose thread at the output rate, and tees encoded packets to the outputs.

Making the composite a ScreenCapture backend (StudioCapture, SourceId::Studio)
is what keeps the rest untouched: the streamer's conversion, simulcast,
encoders and peers see an ordinary screen source, and recording and the replay
buffer need no stream at all.

A source is restarted only when its input really changed -- a portal token
written back into the scene is not a reason to ask the user again -- so a drag
or an opacity change costs nothing but a replan.

Background replacement runs the segmenter on its own thread at a tenth of the
video rate and takes its newest mask latest-wins, because a mask a few frames
old is still right and segmentation costs far more than a frame. The blur is a
three-pass box blur, separable and with a running sum, so its cost is flat in
the radius; it is split into bands of rows on the worker pool over pooled
buffers. The vertical pass restarts its sum per band, which costs a few reads
and keeps the pass free of unsafe.

What segments is a centred oval, not a person: no ONNX model is loaded in this
build. The Segmenter trait is the seam for one, and segment.rs says so plainly
rather than implying the blur follows a person.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 23:51:03 +03:00
faumarayandClaude Opus 5 9b09e7bde2 voelin-media: fix Wayland screen capture delivering no frames at all
Measured on a real 2560x1440 Wayland desktop through the ScreenCast portal,
which nothing here had ever run against: every captured frame was dropped
and the viewer got nothing.

Two faults, one behind the other.

The mapping length came from `mapoffset + maxsize`. Those describe a
mapping, which only shared memory has; a DMA-BUF's size lives in its buffer
object, and this compositor leaves both fields 0 (the file descriptor and
the 10240-byte stride were fine). The length was therefore 0, every map was
refused, and the capture delivered nothing for as long as it ran. Derive the
length from the rows the negotiated format describes, which is exactly what
is read afterwards.

With frames flowing, the second fault showed: reading a LINEAR DMA-BUF from
this GPU's memory took 11.95 ms per frame and 19.5 CPU cores at 1440p60,
against 0.27 ms and 0.41 cores for the same capture over shared memory — 44
times the time, 48 times the CPU. The guard that exists for this switches at
6.0 ns per pixel and the DMA-BUF path only reaches 3.24, so it never fired.
Put the threshold between the two measurements, an order of magnitude above
the shared-memory figure so a GPU whose buffers the CPU can read keeps them.

After both: 2560x1440 at 60.0 fps on 0.55 cores, no dropped frames, the
bitrate honoured. A DMA-BUF that cannot be mapped at all now also falls back
to shared memory after a few failures instead of dropping frames forever.

`stream bench` was reporting the layer size from --res, which is not what a
real source encodes; it now prints the size that was really encoded.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 23:50:52 +03:00
selikhovandClaude Opus 5 9be547ed6d voelin-media: push the studio to a WHIP service
Going live to a broadcast service is the one output that is not a file, and
WHIP is the standard that makes it one HTTP request: post the offer, apply the
answer, delete the location to stop. str0m already drives WebRTC here, so the
session is a thread of its own fed through a bounded channel -- a slow or dead
upload drops its own packets instead of stalling an encoder.

The session offers only the codec the studio already encodes plus Opus, so the
service can never negotiate its way into a second encode.

Candidates are one host candidate on the interface that routes to the service,
found by connecting a throwaway socket: enough for a service with a public
address and for a server on this machine, not enough behind a NAT the service
cannot reach back through. STUN and TURN are not here yet.

tests/studio_whip.rs is a WHIP server built on str0m in the test: the offer is
posted, ICE and DTLS come up, real VP8 and Opus packets arrive, a refusal is
reported with the service's own words, and stopping deletes the resource.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 23:39:11 +03:00
faumarayandClaude Opus 5 221315c39b voelin-ui: sample data and switches for the new screens
The sample server had no groups, no stored messages and no gateway, so
none of the new screens could be seen without a real server. It now
comes with server groups and badges, a chat driven by the same
`Event::ChatHistory` a real session uses (reactions, pins, a file card,
a message in a topic), and a gateway that answers with pins and topics.

`VOELIN_OPEN` gained `voice`, `pins`, `topics`, `topic:<id>`, `member`,
`watch` and `popout`, and `scripts/shots.sh` takes a screenshot of one
of them headless, so the pictures in docs/screenshots/ are one command
each.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 23:34:28 +03:00
selikhovandClaude Opus 5 eb86ef9fba voelin-media: record the studio and keep a replay buffer
Recording and the replay buffer must work whether or not a stream is live,
and neither may cost a second encode, so both are fed the packets the
streamer's encoders already produce. That makes them output sinks over one
small trait rather than pipelines of their own.

The container is an own EBML writer: Matroska and WebM need so little of the
format for this (a header, one Info, one Tracks, clusters of SimpleBlocks)
that a dependency would be the larger cost. The segment size stays unknown
and there are no cues, so a recording cut short by a crash still plays; only
the duration is written back at the end, because a file of unknown length is
a poor thing to hand a player. H.264 is stored the way Matroska wants it,
length-prefixed with its parameter sets in CodecPrivate, which is why the
header waits for the first keyframe.

The replay buffer keeps whole keyframe groups so a clip always starts where a
decoder can, and a window longer than memory allows spills its oldest packets
to a temporary file it drops again once they age out -- the length is a
setting with no maximum, so it cannot be bounded by what fits in RAM.

RTMP is a seam that says what it is waiting for (the muxing side of the
FFmpeg loader) instead of dropping a stream silently.

tests/studio_record.rs runs real VP8 frames through both and reads the files
back with ffprobe: codecs, size, duration, and every frame of a clip decoded.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 23:32:23 +03:00
faumarayandClaude Opus 5 21843fd7c1 voelin-media: put a real DMA-BUF through the VA-API encoder
The probe reported the zero-copy import as available on the strength of the
struct offsets alone, and screen capture only ever hands over RGB, which the
import refuses, so no buffer had ever gone through it on hardware.

Make a VA-API surface, export it as a DRM PRIME DMA-BUF and feed it back to
a second encoder through encode_dmabuf. On this GPU it imports and encodes,
and the buffer carries an AMD tiling modifier (0x200000028a01f04), so tiled
buffers work and not only LINEAR ones.

It also showed that the import's shape is narrower than what drivers
produce: this driver describes an NV12 surface as two DRM layers, R8 for the
luma plane and GR88 for the chroma one, while encode_dmabuf takes a single
NV12 layer with two planes, which is how a compositor hands one over. Both
name the same bytes of the same buffer object, so the test flattens the
layers; whoever wires the portal to the encoder should accept either form.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 23:31:45 +03:00
faumarayandClaude Opus 5 ff7ef96b75 voelin-ui: the server screens of the new design
The server page had one layout: a channel tree, a chat and a panel of
members and streams. The design asks for more of it at once, so the same
page now carries the pieces it was missing.

The chat shows reactions, a pin marker, file cards and older messages,
and every message can be reacted to, pinned or made into a topic where
the gateway offers it. A compact voice bar sits over it with the
connected channel, who is talking and the voice controls, so the sidebar
card is no longer the only way to leave or mute.

The members panel groups people by server group with the group's icon,
shows the badges and talk power a TeamSpeak client expects, and opens a
card with the person's description, groups, private chat, poke, contact
and volume. Its width is the setting `ui.members_width`, so dragging the
handle keeps it.

Pins and topics are drawers over the chat, the voice channel can be seen
as a grid of tiles with the streams in it, and the stream viewer gained
the elapsed time, the viewer count, a quality picker, a mute button, the
chat beside the player and a pop-out that hides the shell.

The quality picker stays hidden for now: the engine tells a viewer
neither which simulcast layers a streamer offers nor lets it ask for
one, so there is nothing to choose between.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 18:38:04 +03:00
selikhovandClaude Opus 5 5fb93dc33d voelin-media: make a real camera negotiate
Tried against a real V4L2 camera through PipeWire, three things stopped it.
A camera offers fixed frame rates (often only 30), so a rate range capped at
the wanted rate never intersects: the offer now takes any rate and the frame
pacer brings it down. Camera nodes hand out buffer types the CPU cannot map
unless asked otherwise, as screen capture already does. And PipeWire takes
the first offer that fits, so a size range alone gave the camera's smallest
size: the exact size is offered first, the range second.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 18:37:48 +03:00
faumarayandClaude Opus 5 e599eab0ac voelin-media: stop probing absent GPUs and keep the encoder libraries quiet
The startup probe opened every encoder in the table, which took 1.77 s here
and froze the app's first use for that long, and it let the libraries behind
them print about thirty lines to standard error on every run.

Most of the time went on hardware that is not in the machine: a self-test of
a family whose vendor is absent still runs its driver's initialisation
before failing, 1.7 s for av1_nvenc and 1.2 s for vp9_qsv here. Read the PCI
vendors of the DRM render nodes once and skip those families outright; when
the vendors cannot be read nothing is skipped, so an unusual setup only pays
what it paid before. The report gains a plain reason ("no NVIDIA GPU in this
machine") in place of a CUDA error code.

FFmpeg's own log already goes to tracing, but SVT-AV1's build banner, AMF's
GetProperty warnings and Mesa's RADV_PERFTEST notice are written to the
descriptor by the libraries themselves. Point standard error at a temporary
file while the self-tests run and log what landed there as one debug record;
VOELIN_FFMPEG_PROBE_STDERR=1 leaves it alone.

Measured with `voelinctl stream encoders` (release): 1.77 s before, 0.93-1.12
s after, 12 backends tested instead of 20, and nothing on standard error.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 18:35:39 +03:00
selikhovandClaude Opus 5 a35d3b6784 voelin-media: give the studio its sources and cameras
A scene needs something behind each of its sources. Colour, text and image
are drawn once and put in the feed; screens, windows and the portal run the
existing capture backends through a sink that copies into pooled frames;
cameras get their own module. One broken source only sets its feed's error,
so it never stops the studio.

Text is rasterised with ab_glyph and the same Inter the UI bundles (reached
across crates rather than copied, and tools without the UI crate need it
too); images come from the `image` crate, which the tree already had.

Cameras are listed straight from V4L2 -- the card name and every pixel
format and resolution the driver reports, no hard-coded list -- but captured
through PipeWire, which already owns the devices; the connection comes from
the user's daemon or, in a sandbox, from the XDG Camera portal, and both
reuse the screen capture's PipeWire thread. Only the three read-only
enumeration ioctls are hand-written, so no bindgen build dependency joins
the tree. The test pattern is always listed as a camera, which is what the
tests use.

convert gained a borrowed-frame entry point so a capture buffer becomes RGBA
without an owned frame in between.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 18:34:16 +03:00
faumarayandClaude Opus 5 dda2ca0acc Add voelinctl identity import, export and list
Import and export have to be reachable before the Profiles screen exists, and
a headless command is also how the round trip gets tested against a real
client installation without any of its data entering the repository.

The listing prints nothing but the nickname, the unique id and the security
level: all three are public — servers see them — while everything else in an
identity is the private key. `--dry-run` reads and stores nothing. `list`
comes along because `export <id>` is unusable without a way to learn the id.

Prove the imported key pair is whole rather than merely parseable: the
clients' format carries the public point next to the private scalar and
`Identity` keeps only the scalar, so signing a nonce and verifying it with the
key derived from that scalar shows the two halves belong together. The same
check runs over a real database when `VOELIN_IDENTITY_IMPORT_CHECK` points at
one, which keeps that verification repeatable without committing a fixture
that could only come from someone's own identities.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 18:34:13 +03:00
faumarayandClaude Opus 5 90f234cff4 Import identities from the official clients
Switching to Voelin should not mean starting over on every server: the unique
id is the key pair, and a user who cannot bring it along loses every server
group they have. So read the forms the official clients keep it in — the
TeamSpeak 3 `.ini` export, the `ProtobufItems` items both clients write, and
the older `Identities/<n>/…` rows — and store them through voelin-store,
skipping unique ids the store already has instead of adding a second copy.

Export back to the `.ini` form in the same module: an importer without an
exporter traps people here, which is the thing being fixed.

The clients' databases hold private keys and may be open in a running client,
so they are opened read-only and `immutable`: no lock, no shared-memory file,
no write-ahead log replay, nothing of the user's changed to read it. The cost
is that an identity written but not yet checkpointed is not seen, which is the
right way round.

Three field numbers do not earn a protobuf dependency; the wire reader is
twenty lines and skips what it does not understand. An item is taken as an
identity only when its declared type says so, never because a field number
happens to match.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 13:44:41 +03:00
faumarayandClaude Opus 5 489bef8174 voelin-ui: take chat, avatars and groups from the engine's history
The chat view showed what `Event::Chat` reported: no ids, so nothing
could be pinned, reacted to or grouped into topics, and avatars were
always initials. Drive it from `Event::ChatHistory` instead, which
upserts messages by their local id, and keep the old path only for
sessions the engine stores no history for (it does not know the server
yet). Each tab now holds its messages and rebuilds its lines with
`vm::list::sync`, so a reaction changes one row.

Around that: the image cache decodes avatars and icons from the engine's
cache (`AvatarReady`, `IconReady`), members are grouped by server group
with badges and talk power, the member card carries contacts and
per-client volume, and file links in a message become cards that can be
downloaded. The composer's attach uses xdg-desktop-portal's file
chooser, which `voelin-platform` already had ashpd for.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 13:40:44 +03:00
faumarayandClaude Opus 5 b541ec8093 voelin-media: tell the H.264 encoders the level the offer advertises
The signalling computes profile-level-id from the stream's size, frame rate
and bitrate, but nothing told the encoder, so every wrapper picked its own
level. Measured on this GPU: h264_amf writes level 4.2 into the SPS of a
720p30 stream whose offer says 3.1, and 5.0 for a 1440p60 stream offered as
5.1. A viewer that sizes its decoder from our SDP can refuse a stream that
declares more than the offer did, which is what breaks official clients.

Compute the level from ITU-T Table A-1 and set it on both the codec context
and the wrapper's private option. A new test parses the SPS of every usable
H.264 backend at two sizes and both profiles and asserts profile_idc against
the offer and level_idc never above it; with the level set, all three
backends now emit exactly the offered level.

The level table is a second copy of the one in voelin-stream, because
neither crate can depend on the other, so a unit test pins them together
over a spread of sizes, rates, bitrates and profiles.

Remaining difference, only in the constraint-flag byte and left alone: the
offer claims Constrained High (0c) and Constrained Baseline (e0) as WebRTC
implementations conventionally do; the VA-API and AMF encoders emit 0c for
the former, libx264 emits 00, and all three emit 40 or c0 for the latter.
The bits do not change what a decoder can decode.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 13:39:37 +03:00
selikhovandClaude Opus 5 7b61fa9cad voelin-media: composite a studio scene into pooled frames
The studio needs one picture per output frame from any number of sources
that each run at their own pace, so the compositor takes each source's
newest frame through a latest-wins handoff and draws the scene back to
front into a pooled RGBA canvas, in bands of rows on a worker pool. The
plan (destination rectangles and filter weights) is kept while neither
the scene nor a source size changes, which is what lets a steady
composite allocate nothing per frame -- the property tests/studio_alloc.rs
pins down.

Frames are RGBA because alpha blending and text need it; the streamer's
existing conversion turns the canvas into I420 for the encoders in one
SIMD pass. Scaling reuses scale.rs's weight tables with an inner loop for
interleaved pixels, and a straight copy at 1:1, the common case for a
screen that already matches the canvas.

FramePool grew a format so the same recycling works for the canvas, and
the preview tap scales the canvas down through the same filter.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 13:39:12 +03:00
faumarayandClaude Opus 5 4fac682cae voelin-media: record the AVFrame offsets of libavutil 61 instead of guessing
The DMA-BUF import reads AVFrame.buf[0] and hw_frames_ctx at offsets the
loader keeps in a table per libavutil major. The table ended in an open
range that answered every major from 60 up with 60's offsets, so on this
machine (libavutil 61) the import ran on an unverified guess, and a future
major would get the same treatment.

Compiled offsetof from the headers installed next to the library: libavutil
61 puts buf at 184 and hw_frames_ctx at 328, which is what 60 uses, so the
guess happened to hold. Record 61 explicitly and stop answering unknown
majors: AVFrame has shrunk between majors (424 bytes in 61 against 536 in
56), so an offset guessed for an unknown layout can point past the end of
the struct. An unlisted major now turns the import off with a reason and
leaves everything else working.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-29 13:33:52 +03:00