Merge the development branch: Wave 5B's phone screens and quick-share sound

Both sides kept. From the development branch: the phone's voice channel
screen, the pages over it (pins, topics, members), the voice button in
the phone's top bar, the quick share's mixer and picker, invite links,
viewer counts, the studio's cameras and RTMP output, and the Android
pieces.

The phone's top bar keeps this wave's search button next to the voice
button and the bell (the bell opens the notifications panel); its tabs
mark Home also on the friends, messages and Library pages and Servers on
a server's events page. The phone shell shows both sides' pages: this
wave's friends, messages, events and Library pages with their back
button, and the development branch's voice channel screen, which hides
the bottom navigation as before.

Home keeps this wave's page, which maps the design onto TeamSpeak as
decided for it (friends' presence across servers, the latest chats of
every server, live streams of all servers); the development branch's
interim home (people on the current server, its chats, its streams)
gives way to it. Its server cards still switch the phone to the Servers
tab through Nav.show. A server item keeps this wave's detail and flavor
with the development branch's wording of `live` (streams on the server).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-04 03:20:20 +03:00
commit cd5ac614ef
104 files changed
+8174 -574

No files matched your search

+97 -17
View File
@@ -2,23 +2,30 @@
The Android app is the desktop UI (`voelin-ui`, Slint) running in a
`NativeActivity`, plus a thin Kotlin layer for what only Java APIs can do:
foreground services, the screen-capture consent, the Keystore.
foreground services and their notifications, the screen-capture consent,
the cameras, the share sheet, the Keystore.
```
android/ Gradle project (AGP 8.13, Kotlin 2.3, Gradle 8.14.3 wrapper)
app/src/main/java/.../voelin/ MainActivity (NativeActivity), Bridge, Native,
VoiceService, ScreenCaptureService, SecretStore
app/src/main/java/.../voelin/ MainActivity (NativeActivity, Share to Voelin), Bridge,
Native, VoiceService, ScreenCaptureService, Notifications,
CameraCapture, SecretStore
crates/voelin-android/ libvoelin_android.so: android_main, engine host,
JNI glue, capture providers, Keystore secrets
JNI glue, capture and camera providers, notifications
(foreground.rs), Keystore secrets
```
The phone layout of the UI (the voice channel with a stream, the bottom
navigation, the studio, the share dialog) is described in
[ui.md](ui.md); its screenshots are taken on the desktop at 390×844.
## Building
Requirements:
- Android SDK with `platforms;android-36` and `build-tools;36.0.0`
(`ANDROID_HOME`, or `sdk.dir` in `android/local.properties`), NDK
`27.3.13750724` (`ndk;27.3.13750724`; the version is pinned in
`27.3.13750724` (`ndk;27.3.13750724`; the versions are pinned in
`app/build.gradle.kts`)
- JDK 17 or newer
- Rust targets: `rustup target add aarch64-linux-android x86_64-linux-android`
@@ -28,7 +35,7 @@ Requirements:
```sh
cd android
./gradlew assembleDebug # arm64-v8a + x86_64 (emulator)
./gradlew assembleDebug # arm64-v8a + x86_64 (emulator, Waydroid)
./gradlew assembleDebug -Pvoelin.abis=arm64-v8a # phones only, half the build
adb install -r app/build/outputs/apk/debug/app-debug.apk
adb logcat -s RustStdoutStderr ScreenCaptureService VoiceService SecretStore
@@ -79,19 +86,61 @@ capture, NDK MediaCodec format queries); targetSdk and compileSdk 36.
to the background instead of finishing the activity; configuration changes
do not recreate it.
- **Voice in the background**: while any session has a voice connection,
`VoiceService` runs as a foreground service of type `microphone` with a
notification ("In voice on …", Mute or Unmute, Disconnect). Rust drives it
from engine events (`foreground.rs`, `Bridge.setVoiceNotification`). Audio
itself is cpal on AAudio, as on desktop.
`VoiceService` runs as a foreground service of type `microphone`. Its
notification reads like the app's voice card: the channel as the title,
the server and who is there ("Home · 3 in voice", "just you"), the time
in voice as a chronometer, and Mute, Deafen and Leave, which act on every
voice session; with several servers, "In voice on 2 servers" and their
names. Tapping it opens the voice channel screen (the activity hands the
request to Rust, which queues it until the window runs:
`voelin_ui::request`). Rust drives it from engine events (`foreground.rs`,
`Bridge.setVoiceNotification`). Audio itself is cpal on AAudio, as on
desktop.
- **Sharing the screen**: `voelin_media::capture::default_screen_capture()`
returns the MediaProjection provider (`capture.rs`) registered at start.
Starting shows the system consent dialog; on consent `ScreenCaptureService`
(type `mediaProjection`) mirrors the display into an `ImageReader` at the
requested frame rate, longest side at most 1920 px, and hands RGBA frames to
`Native.onScreenFrame`. System audio (`default_audio_capture()`) is
(type `mediaProjection`) mirrors the display, longest side at most
1920 px. While one MediaCodec encoder runs (one simulcast layer, one
codec: the common case) the virtual display renders straight into that
encoder's input surface, with no copy of a frame on the CPU; with more
encoders (layers, or a codec a viewer chose) it renders into an
`ImageReader` again, whose RGBA buffers go to the encoders borrowed
(`Native.onScreenFrame`), until one encoder is left ([media.md](media.md),
MediaCodec). System audio (`default_audio_capture()`) is
`AudioPlaybackCapture` of media, game and unknown usages, 48 kHz stereo
float, only while the projection runs. Ending the projection from the
status bar or the notification closes the capture channels.
float, only while the projection runs; single apps are captured by their
uid (`addMatchingUid`), "every app but ours" excludes ours. While our
stream is live the notification says where and who watches ("Live in
Chill Zone", "Home · 2 watching") with Stop sharing. Ending the
projection from the status bar or the notification closes the capture
channels.
- **Choosing the stream's sound**: the share dialog and the Stream Studio
pick the sources of `stream.audio_sources` in the studio's picker:
the microphone, every app but ours, and the launchable apps
(PackageManager) with their own icons, several at once. Kotlin draws each
app's icon once per installed version into a 96 px PNG in the cache
(`Bridge.launchableApps`, `AudioApp::icon`). The shared window's audio is not
offered: a phone shares the whole screen.
- **Cameras** (the Stream Studio's camera sources): `CameraCapture.kt`
lists the Camera2 cameras (front first, their YUV sizes and highest frame
rate) and asks for the `CAMERA` permission when a camera is first opened
(the source shows why if it is refused). It opens the camera into an
`ImageReader` (`YUV_420_888`) at the wished size or the nearest (16:9
first, 1280×720 by default) and hands each frame's planes to Rust as
direct buffers valid during the call, with the turn that makes it
upright. Rust (`camera.rs`) passes upright planar or NV12 pictures on as
they are and gathers NV21 or turned ones into I420 in a buffer each
camera keeps: nothing is allocated per frame. Cameras that face the user
are mirrored by default; the source menu's Switch camera moves a source
to the next camera ([studio.md](studio.md)).
- **Share to Voelin**: the activity takes `ACTION_SEND` and
`ACTION_SEND_MULTIPLE` of any type. Text and links go into the composer
of the current chat, which the phone then shows (one tap sends them).
Files are copied out of the sending app while its content URIs are
readable, on a thread of their own, under the name the app gives (made
safe as a path component), then uploaded to the current chat's channel
(or the channel we are in) and linked there as the attach button does.
The copies live in the cache and are removed at the next start.
- **Watching and encoding**: `voelin_media::Codecs` uses the device's
MediaCodec encoders (hardware first) and decoders on Android
([media.md](media.md)).
@@ -107,7 +156,8 @@ capture, NDK MediaCodec format queries); targetSdk and compileSdk 36.
Permissions: `INTERNET`, `ACCESS_NETWORK_STATE`, `RECORD_AUDIO`,
`MODIFY_AUDIO_SETTINGS`, `FOREGROUND_SERVICE` with `_MICROPHONE` and
`_MEDIA_PROJECTION`, `POST_NOTIFICATIONS`.
`_MEDIA_PROJECTION`, `POST_NOTIFICATIONS`, `CAMERA` (asked for when a camera
is first opened; `android.hardware.camera.any` is optional).
## Status
@@ -115,8 +165,14 @@ Permissions: `INTERNET`, `ACCESS_NETWORK_STATE`, `RECORD_AUDIO`,
|---|---|---|
| `libvoelin_android.so` for `aarch64-linux-android` (Slint Android backend with Skia, AAudio, AWS-LC, SQLite, libopus) | `cargo ndk -t arm64-v8a build -p voelin-android` | builds; exports `android_main` and the `Native` methods |
| Debug APK | `./gradlew assembleDebug -Pvoelin.abis=arm64-v8a` | builds |
| Engine host replay, voice service policy | unit tests (`cargo test -p voelin-android`) | tested |
| Debug APK for phones and Waydroid (`arm64-v8a` + `x86_64`) | `./gradlew assembleDebug` on Linux: the Gradle 8.14.3 wrapper, Temurin JDK 17, an SDK with only `platforms;android-36`, `build-tools;36.0.0` and the NDK 27.3 | builds (Kotlin without warnings) |
| Engine host replay, voice service policy, the voice notification's text (deafen across sessions, several servers), the live stream's notice | unit tests (`cargo test -p voelin-android`) | tested |
| External capture providers, MediaCodec buffer layouts | `voelin-media` unit tests | tested |
| The phone screens: voice channel with a stream, Home, Servers, Chats, Activity, You, Settings, Stream Studio, the share dialog with its sound | headless screenshots at 390×844 ([ui.md](ui.md)) | tested on the desktop (the same Slint UI; not on a device) |
| A tapped voice notification opens the voice screen; text shared to the app lands in the composer | `VOELIN_OPEN=notification`, `VOELIN_OPEN=shared:<text>` on the desktop | the Rust side tested headless; the notifications, their actions, the share sheet and file uploads from it compile only |
| Cameras: YUV planes borrowed, gathered into I420, turned | `voelin-media` `camera::tests::camera_planes_are_borrowed_gathered_and_turned` | the Rust side tested; Camera2, the permission flow and switching compile only |
| The virtual display into the encoder's input surface, back to the reader for simulcast | `cargo ndk -t arm64-v8a clippy` | compiles only: frames per second and CPU use not measured (no device; Waydroid's encoders are software ones, if any) |
| The app picker with icons | the studio's and the share dialog's picker with sample data (headless) | the UI tested; the PackageManager list and its icons compile only |
| The app on a device: UI, voice in the background, screen sharing, watching, Keystore | manual matrix row IN3 and the Android rows | not run yet (no device or emulator in this environment) |
| Waydroid (Mesa GL) | the debug APK, `waydroid logcat` | works with the EGL workaround (below); before it, the app ended at start because Skia could not create its GL context |
@@ -128,6 +184,9 @@ Known gaps:
`Codecs` uses MediaCodec.
- Rotating the device while sharing letterboxes the picture (the virtual
display keeps its size).
- Cameras deliver while the app is in front: there is no foreground service
of type `camera`, so Android stops a camera source when the app goes to
the background (the screen share goes on).
- The safe area (status and navigation bars) and the on-screen keyboard pad
the main window; dialogs drawn over it do not account for them yet.
- Only `arm64-v8a` and `x86_64` are built; 32-bit devices are not supported.
@@ -154,3 +213,24 @@ I RustStdoutStderr: … Could not create Skia Direct Context from GL interface
at start, before Slint's surface, so they get slots first (logcat:
`EGL: N of 83 Skia extension functions resolved`). Vendor GPU drivers on
phones return nothing for desktop-only names and are not affected.
### Trying it on Waydroid
Waydroid on a PC runs the `x86_64` library, which the default
`assembleDebug` builds (`rustup target add x86_64-linux-android` first):
```sh
cd android && ./gradlew assembleDebug
waydroid app install app/build/outputs/apk/debug/app-debug.apk
waydroid app launch io.github.faumaray.Voelin
waydroid logcat | grep -E 'RustStdoutStderr|MainActivity|VoiceService|ScreenCaptureService|CameraCapture'
```
Things to try there: the bottom navigation (Home, Servers, Chats,
Activity, You), joining a voice channel and its screen from the top bar's
voice button, the voice notification (pull down the shade: Mute, Deafen,
Leave, tap it), Share from another app's share sheet (text, then a file),
the voice screen's Share (the screen share dialog) with sound from the
audio picker (app icons) and its gain and mute while live, and Go Live's
Stream Studio with a camera source (Waydroid usually has no camera: the
source then says why).
+140 -16
View File
@@ -8,8 +8,9 @@ MediaTime::new(frame.pts_90khz, Frequency::NINETY_KHZ), data)`), and received
`MediaFrame`s go to `VideoDecoder::decode`.
The Stream Studio (`studio`: scenes of sources composited into the stream's
video, recording, a replay buffer, WHIP) is described in
[studio.md](studio.md).
video, cameras among them (MJPEG ones decoded on a thread of their own,
Media Foundation on Windows); recording, a replay buffer, WHIP and RTMP) is
described in [studio.md](studio.md).
## API overview
@@ -20,8 +21,8 @@ video, recording, a replay buffer, WHIP) is described in
| `AudioBuffer { samples, channels, timestamp }` | interleaved `f32`, 48 kHz |
| `convert::to_rgba(&frame, out, stride)`, `to_rgba_vec`, `to_i420`, `psnr` | BT.601 limited range (the WebRTC default). `to_rgba` writes straight into a Slint `SharedPixelBuffer<Rgba8Pixel>` (`make_mut_bytes()`, stride `width * 4`) |
| `Codec` | `Vp8`, `Vp9`, `H264`, `Av1`; `FromStr` for SDP/MIME names; `From`/`TryFrom` `str0m::format::Codec` with feature `str0m` |
| `VideoEncoder` | `encode(&frame, force_keyframe) -> Vec<EncodedFrame>`; `encode_with(&frame, force_keyframe, &mut |EncodedChunk| ..)` hands out the encoder's own buffer (no copy); `set_bitrate(bps)` (libvpx: in place, no keyframe), `set_fps`, `speed()`, `codec()`, `backend()`; `gpu_alignment()` / `encode_gpu(&GpuFrame, ..)` for encoders that take frames in GPU memory (VA-API) |
| `GpuFrame` | a picture in GPU memory (an NV12 VA-API surface), made by `ffmpeg::GpuConverter` from a captured DMA-BUF; `width`, `height`, `timestamp`, `at(timestamp)` (the same surface at another time) |
| `VideoEncoder` | `encode(&frame, force_keyframe) -> Vec<EncodedFrame>`; `encode_with(&frame, force_keyframe, &mut |EncodedChunk| ..)` hands out the encoder's own buffer (no copy); `set_bitrate(bps)` (libvpx: in place, no keyframe), `set_fps`, `speed()`, `codec()`, `backend()`; `gpu_alignment()` / `encode_gpu(&GpuFrame, ..)` for encoders that take frames in GPU memory (VA-API; MediaCodec's surface path on Android) |
| `GpuFrame` | a picture in GPU memory (an NV12 VA-API surface), made by `ffmpeg::GpuConverter` from a captured DMA-BUF; `width`, `height`, `timestamp`, `at(timestamp)` (the same surface at another time). On Android `rendered(width, height, timestamp)`: a screen picture the virtual display renders straight into MediaCodec's input surface, only its size and time travel |
| `EncodedFrame { data, keyframe, pts_90khz }` | one frame for `Peer::write` |
| `VideoDecoder` | `decode(&[u8]) -> Option<VideoFrame>` (timestamp zero; the caller knows the RTP time) |
| `EncoderConfig { fps, bitrate_bps, keyframe_interval, content, threads, speed }` | resolution follows the frames; a size change restarts with a keyframe; `threads` is a maximum (0: all CPUs but one), still capped at one per 320x240 pixels; `speed: None` adapts libvpx `cpu-used` to the encode time |
@@ -30,6 +31,7 @@ video, recording, a replay buffer, WHIP) is described in
| `EncoderReport { ffmpeg, zero_copy, encoders: Vec<EncoderInfo> }` | for the UI: FFmpeg's release and path (or why none), whether DMA-BUF import works, and per backend `name`, `api`, `codec`, `hardware`, `status` (self-test result or why it cannot be used) and `rank` under the current preference |
| `EncoderBackend` | `Libvpx`, `OpenH264`, `Ffmpeg("h264_vaapi")`, `Hardware("mediacodec")`; `name()` is the settings spelling |
| `ffmpeg::{Ffmpeg, probe, FfmpegEncoder, BACKENDS}` | FFmpeg loaded at runtime (feature `ffmpeg`), see [FFmpeg encoders](#ffmpeg-encoders-loaded-at-runtime) |
| `ffmpeg::avio::Connection`, `ffmpeg::audio::AacEncoder` | bytes written through libavformat's protocols (`rtmp://`, `rtmps://`) with their write errors and an abort flag; the studio's Opus as AAC through FFmpeg's own codecs. See [RTMP output](#rtmp-output) |
| `ffmpeg::{GpuConverter, GpuLayer}` | an RGB DMA-BUF converted to NV12 and scaled for every simulcast layer on the GPU (`convert(&DmaBufRef, &[GpuLayer], out)`), `modifiers()` it imports; see zero-copy under [FFmpeg encoders](#ffmpeg-encoders-loaded-at-runtime) |
| `ScreenCapture` | `sources()`, `start_sink(&SourceId, &CaptureOptions, Box<dyn FrameSink>)` (frames borrowed from the capture buffer, on the backend's thread), `start(..)` (copies into a queue), `stop()`; async: the portal asks the user |
| `FrameSink` | `max_fps()` (may change while capturing), `wants(timestamp)` (asked before anything is mapped or copied), `frame(FrameRef) -> bool`; `accepts_dmabuf()`, `dmabuf(&DmaBufRef) -> Option<bool>` (a frame still in GPU memory, offered before it is mapped) and `dmabuf_modifiers()` (tiled layouts the sink imports) |
@@ -144,6 +146,11 @@ viewer: Engine::subscribe_frames ─ VideoPipeline (thread) ─ VideoDecoder
go out through `MediaSink::send_video(frame, codec)`. Sinks that do not
tell codecs apart (`EncodedSource`, a `FrameSource`) get the stream codec
only, so their offers must list it alone (`voelinctl stream start` does).
A studio's outputs count as viewers too: the stream codec always runs
for its recordings and replay buffer, and an output that needs a codec of
its own (RTMP: H.264) gets an encoder of the layer it takes
(`Studio::output_codecs`), whose packets reach only such outputs
(`Studio::write_output_packet`).
- `stats()`: `StreamerStats` with capture fps, convert time and threads,
the GPU path (`gpu_frames`, `gpu_convert_time`, `gpu_error`),
dropped frames, codec, and per layer (`LayerStats`) size, frames,
@@ -184,10 +191,41 @@ viewer: Engine::subscribe_frames ─ VideoPipeline (thread) ─ VideoDecoder
longer than 30 frames) or a decoder error it skips to the next keyframe,
asking for one at most every 500 ms. Keyframes are recognised from the
bitstream (VP8 frame tag, VP9 header, H.264 IDR/SPS NAL units, AV1
sequence header OBU).
sequence header OBU). `stats()` (`DecodeStats`) tells the codec, the
picture's size, pictures decoded and skipped, the video bytes received,
and the decoded frame rate and received bitrate since the previous call
(at least half a second); the watch screen shows codec, size, rate and
bitrate over the player and in Stream Info, refreshed once a second.
These are read from the pipeline, which runs in the app, not sent as
engine events: the engine never sees the decoded pictures.
- `Viewer` feeds a `VideoPipeline` from the engine and sends
`RequestStreamKeyframe`; `LocalPreview` runs capture → encoder → decoder
without a server (the desktop app's `VOELIN_DEMO_STREAM`).
- Viewer counts come from the server: `StreamInfo::viewers` in
`Event::StreamsChanged` is TeamSpeak 6's own count (`viewer` of
`notifystreaminfo`), counted up from `notifystreamclientjoined` and
refreshed with `requeststreaminfo`, one stream every 5 s, because the
server tells only the streamer and the viewer when someone leaves
([protocol notes](protocol-notes/ts6-streaming.md#viewer-counts-confirmed-600-beta131-2026-10-03)).
The app shows it, and the gateway directory's count where the server
gave none.
- A viewer picks a simulcast layer (the watch screen's quality picker): a
Voelin streamer with several layers lists them in its offer, in a
session-level SDP attribute (`a=x-voelin-layers:0/1/6000000
1/640x360/1500000/15`: id, size or scale, bitrate, frame-rate cap;
`voelin_stream::layer::SDP_ATTRIBUTE`). The viewer reports them
(`WatchEvent::Layers`, `Event::WatchLayers`), and `Command::SetWatchLayer`
sends `{"cmd":"x-voelin-layer","args":{"layer":1}}` through
`streamsignaling` (`Signal::Layer`; `null` is "Auto"). The streamer moves
that viewer to the layer at its next keyframe and keeps it there whatever
its estimate says, and such a viewer no longer lowers its layer's bitrate
for the others; "Auto" hands it back to the estimate. Official clients
never see either: libwebrtc skips session attributes it does not know
(headless Chromium 152 answers such an offer and decodes, see the
browser interop test), and a viewer sends the request only to a streamer
whose offer had the attribute, which only Voelin streamers add. Not with
RID simulcast (that viewer gets every layer), and a streamer that changes
its layers live is seen with its next offer.
- The audio of watched streams does not go through this module: the session
hands the Opus frames to its audio thread, which plays them through the
jitter buffer and mixer under a made-up client id, with its own volume.
@@ -234,9 +272,13 @@ The audio of our stream is a mix of any number of sources
`[{"kind": "desktop"}, {"kind": "app", "name": "firefox", "gain": 0.5},
{"kind": "microphone", "muted": true}]`. Other kinds are `"window"` and
`"synthetic"` (`frequency`), and an app can be given by `"pid"`. The
default is desktop audio; `[]` shares without sound. The desktop app
reads it when sharing starts (`media::audio_source_specs`).
`media::audio_apps()` lists the applications for a picker.
default is desktop audio; `[]` shares without sound. The app's share
dialog and the Stream Studio pick and mix the sources with the same
mixer rows and picker ([ui.md](ui.md#sound-in-the-quick-share)); a share
hands them to its capture when it starts (`media::audio_source_specs`),
and a running share or studio follows every change of the key through
`Streamer::reconfigure`. `media::audio_apps()` lists the applications
for a picker.
What applications play is captured by `capture::playback::start_playback`:
@@ -297,8 +339,8 @@ the software encoders above are used as before.
`/usr/local/lib`) and MacPorts (`/opt/local/lib`) (macOS). No version is
refused. libavutil's functions come from the libavutil libavcodec itself
loaded (through its handle; on Windows the already loaded DLL), so the two
always match; libavformat of the same major is opened if present (for RTMP
output later). `VOELIN_FFMPEG=0` disables FFmpeg. Only functions are
always match; libavformat of the same major is opened if present (for
[RTMP output](#rtmp-output)). `VOELIN_FFMPEG=0` disables FFmpeg. Only functions are
looked up by name (`sys.rs`); FFmpeg's warnings and errors go to
`tracing` (target `ffmpeg`) and into the self-test's failure reasons.
- ABI across major versions: every codec setting goes through AVOptions
@@ -477,6 +519,56 @@ the software encoders above are used as before.
(no compression metadata); the portal offers it ahead of LINEAR (see
[Capture](#capture)). See [the measurements](#zero-copy-measured).
### RTMP output
The studio's RTMP output ([studio.md](studio.md#outputs-studiooutput))
goes through the same runtime-loaded FFmpeg, libavformat included, and
links nothing.
- Connection (`ffmpeg/avio.rs`): `avio_open2` with libavformat's own
`rtmp://` / `rtmps://` protocols (handshake, `connect`, `publish`, TLS),
`avio_write`, `avio_flush`, `avio_closep` (unpublish). Five functions and
`AVIOInterruptCB` (two fields, unchanged since libavformat 53): every
blocking call polls an abort flag, so a stop or a stuck network never
holds a thread for longer than FFmpeg's 100 ms poll once it is set;
`rw_timeout` (10 s) bounds a connect or a send to a server that stopped
answering. Protocol options go in as an `AVDictionary` (`rtmp_app`,
`rtmp_playpath` for a key given apart, `tcp_nodelay`).
- What it sends is FLV (`studio/output/flv.rs`): libavformat's RTMP writer
reads an FLV byte stream and sends each tag as an RTMP message, so the
FLV is written by us like the recordings' Matroska and no muxer
(`AVFormatContext`, `AVStream`, codec parameters, all of which moved
between releases) is ever used.
- Write errors: `avio_write` and `avio_flush` return nothing; a failed
write is only stored in `AVIOContext.error`, which moved (120 bytes in
libavformat 58, 84 in 63). It is found at load by search
(`layout::avio_error`): a context of our own whose write callback fails
with a sentinel value is flushed, and the one `int` of its first 200
bytes that changed to the sentinel is the field. Checked against the
`offsetof` of FFmpeg 4.4.8 and 9.0.1.
- Audio (`ffmpeg/audio.rs`): RTMP services take AAC, so the studio's Opus
is decoded by FFmpeg's `opus` decoder and encoded by its native `aac`
encoder (AAC-LC, 48 kHz stereo, 160 kbit/s; `AudioSpecificConfig`
`11 90`). An audio encoder needs its sample format before it opens, and
`AVCodecContext.sample_fmt` has no AVOption: it is located like
`hw_frames_ctx`, from the option offsets of its neighbours (after
`sample_rate` directly from libavcodec 61 with `ch_layout` after it;
after `channels` up to 60), and checked to be `NONE` in a new context.
The encoder takes 1024-sample frames and Opus gives 960, so the samples
are queued and cut into frames of our own; such a frame needs its
channel layout, whose field also moved (`ch_layout` from libavutil 57,
`channels` and `channel_layout` before), and `avcodec_send_frame` copies
frames with `av_frame_ref`, which refuses one without a layout unless its
buffers are reference-counted. So the encoder's input frame is a
reference to the first frame the decoder made (FFmpeg filled in layout,
rate, format and buffer references), with only its leading fields
(`data`, `linesize`, `nb_samples`, unchanged since libavutil 51) and
`pts` pointed at our planes; the decoded buffers it keeps are never read.
The AAC frames carry the Opus packets' clock (less the encoder's 1024
samples of priming), and a gap in the studio's audio restarts it.
- Without libavformat, or when a check fails, `LibraryInfo::rtmp` says why
and adding an RTMP output fails with that reason.
Installing FFmpeg (runtime libraries only, no `-dev` packages):
| OS | |
@@ -496,9 +588,32 @@ takes and returns `VideoFrame`s like the software codecs. Encoders get NV12
`slice-height`, parsed by `codec::image_layout`, which is tested on every
platform); H.264 is High (preferably Constrained High) without B-frames, SPS/PPS
in front of every keyframe, keyframes on request (`request-sync`), bitrate
changes at runtime (`video-bitrate`). Encoder order: the device's hardware
encoders (H.264, VP9, VP8), then Google's software VP8 and H.264. Decoders
return the newest finished picture per `decode` call (NV12 or I420).
changes at runtime (`video-bitrate`). Encoders: the device's hardware ones
(H.264, VP9, VP8, AV1) and Google's software VP8 and H.264 (software VP9 and
AV1 are too slow), ordered by codec like every hardware encoder: the codecs
every TeamSpeak client decodes (AV1, VP9, VP8) before H.264. So a phone
without a hardware VP8, VP9 or AV1 encoder streams Google's software VP8 by
default; a stream codec set to H.264 uses its hardware H.264 encoder.
Decoders return the newest finished picture per `decode` call (NV12 or I420).
The zero-copy path for screen sharing: while it is the only MediaCodec
encoder in the process (one simulcast layer, one codec), an encoder reports a
`gpu_alignment`, and the capture's sink then takes `GpuFrame`s. The Android
provider's ticker hands it one per frame at the stream's rate; for the first
the encoder starts a codec with an input surface (`createInputSurface`,
`COLOR_FormatSurface`, `max-fps-to-encoder` at the stream's rate,
`repeat-previous-frame-after` 100 ms so a still screen still answers keyframe
requests) and publishes it (`mediacodec::input_surface`); the app points its
virtual display at that surface (`Bridge.setScreenSurface`, resized to the
layer's size), so the compositor renders the screen into the encoder: no
`ImageReader` frame, no RGBA to NV12 conversion, no copy. Each `GpuFrame`
then only collects what the codec encoded since; presentation times are the
display's (`CLOCK_MONOTONIC`), moved onto the capture's timeline. A second
encoder (another simulcast layer, another codec a viewer chose) turns the
path off for every encoder: the display goes back to the reader and frames
in memory, until it is the only one again. An encoder whose surface fails to
start stays on frames in memory. A frame-rate change restarts the surface
codec (the cap is fixed when it starts).
libvpx settings follow libwebrtc's realtime setup: one pass CBR, no lag,
`VPX_DL_REALTIME`, error resilient, keyframes only at start and on request
@@ -567,7 +682,7 @@ found at ...").
| Linux Wayland (`pipewire`, default) | `PortalCapture`: xdg-desktop-portal ScreenCast via `ashpd`, frames from a PipeWire video stream (LINEAR DMA-BUF or shared memory) | `PipeWireAudioCapture`: default sink monitor (`stream.capture.sink = true`) |
| Linux wlroots (`wlroots`, default) | `WlrootsCapture`: `ext-image-copy-capture-v1`, else `wlr-screencopy-unstable-v1`, outputs only, shared memory | |
| Windows | `WindowsCapture`: Windows Graphics Capture (`windows-capture`), monitors and windows | `WasapiLoopback`: process loopback excluding our own process tree, falling back to plain loopback |
| Android | `ExternalScreenCapture` fed by the app (MediaProjection → `ImageReader`, RGBA; see [android.md](android.md)) | `ExternalAudioCapture` fed by the app (`AudioPlaybackCapture` of every app but ours, 48 kHz float) |
| Android | `ExternalScreenCapture` fed by the app (MediaProjection → `ImageReader`, RGBA borrowed from the reader; or straight into the MediaCodec encoder's input surface, see [MediaCodec](#codecs); [android.md](android.md)) | `ExternalAudioCapture` fed by the app (`AudioPlaybackCapture` of every app but ours, 48 kHz float) |
`default_screen_capture()` picks a registered external provider first
(`capture::external::set_screen_provider`, which the Android app calls at
@@ -631,7 +746,8 @@ renders into one buffer, conversion and scaling write into recycled frames,
handoffs are atomic pointer swaps, and libvpx output is borrowed. The one
allocation per encoded frame is the `Arc<[u8]>` of `EncodedFrame`, whose size
varies per frame and so cannot be recycled. Backends outside our control add
their own (x11rb reply buffers; the Android provider hands owned frames).
their own (x11rb reply buffers; the Android provider's `start` path copies
frames into the queue, its `start_sink` path, the one streams use, does not).
```sh
# The real pipeline on the test pattern, no server:
@@ -901,6 +1017,8 @@ has not run on Windows yet.
| `wayland-client`, `wayland-protocols`, `wayland-protocols-wlr` | MIT | wlroots capture |
| `criterion` | Apache-2.0 OR MIT | benchmarks only (dev-dependency) |
| `ashpd`, `pipewire`, `libspa` / libpipewire | MIT | libpipewire is dynamic |
| `zune-jpeg`, `zune-core` | MIT OR Apache-2.0 OR Zlib | the studio's MJPEG cameras (`pipewire`) |
| `tract-onnx`; PP-HumanSeg (ONNX model) | MIT OR Apache-2.0; Apache-2.0 | the studio's person segmentation (`segment`); the model is bundled |
| `windows-capture`, `wasapi`, `windows` | MIT (`windows`: MIT OR Apache-2.0) | Windows only |
| FFmpeg (libavcodec, libavutil, libavformat) | LGPL-2.1+ (GPL-2+ in builds with x264 and other GPL parts) | the user's installed libraries, loaded at runtime; never linked or shipped |
| libva | MIT | the user's `libva.so.2` (the one FFmpeg's VA-API support uses), loaded at runtime for the GPU colour conversion; never linked or shipped |
@@ -925,6 +1043,7 @@ has not run on Windows yet.
| Portal / PipeWire error paths (no bus, bus without portal, no daemon) | unit tests, manual probe | tested |
| Portal capture (shared memory and DMA-BUF), PipeWire video and audio streams | `voelinctl stream bench --source portal` on a 2560x1440 Wayland desktop | tested: it delivered no frames at all (the DMA-BUF mapping length), and the DMA-BUF path cost 19.5 cores where shared memory costs 0.41. Both fixed; 1440p60 now runs on 0.55 cores (see the table above). Portal audio is still untested |
| Windows Graphics Capture, WASAPI | – | type-checked for `x86_64-pc-windows-gnu` only |
| RTMP through libavformat: write errors from `AVIOContext.error`, an abort ending a stuck connect, `AVCodecContext.sample_fmt`, Opus → AAC, FLV tags, a studio stream to FFmpeg's own RTMP server read back by ffprobe, a reconnect | `ffmpeg::avio`, `ffmpeg::audio`, `ffmpeg::tests`, `studio::output::{flv, rtmp}` tests, `voelin-core/tests/studio.rs` (see [studio.md](studio.md#status)) | tested with FFmpeg 9.0.1 and 4.4.8 (`VOELIN_FFMPEG_DIR`); no public service tried. FFmpeg 4.4.8 also showed that the existing `hw_frames_ctx` check refuses its layout there (VA-API off, as designed for a failed check) |
| FFmpeg loader: sonames, missing FFmpeg, layout checks on a real release | `ffmpeg::sys` / `ffmpeg` unit tests; mirrors compared with offsets compiled from the 4.4-9.0 headers | tested (FFmpeg 6.1.1 on Ubuntu 24.04; FFmpeg 9.0.1 / libavutil 61 / libavcodec 63 on Arch, every offset compared with that release's own headers) |
| FFmpeg software encoders → our decoders: x264 → OpenH264, SVT-AV1 / rav1e / libaom → dav1d (PSNR > 28 dB, keyframes at start and on request, timestamps, bitrate change, size change, odd sizes, Constrained High / Baseline) | `tests/ffmpeg.rs` (`VOELIN_OPENH264_LIB`, `--features av1`) | tested |
| Self-test failures (NVENC without CUDA, Quick Sync without a session, VA-API without a render node, encoders not in the build) | `tests/ffmpeg.rs`, `voelinctl stream encoders` | tested: each fails alone with FFmpeg's reason |
@@ -949,12 +1068,16 @@ has not run on Windows yet.
| Zero-copy from a real screen capture | `voelinctl stream bench --source portal --encoder h264_vaapi` | not run yet (a portal capture asks the person at the desktop); everything up to the portal is tested with the test pattern as DMA-BUFs (rows above, and the measurements) |
| Offer [VP9, VP8], a viewer that decodes only VP8 → its own VP8 encoder, VP9 idle, pictures decoded | `voelin-core/tests/media_live.rs` `ts6_viewer_gets_the_codec_it_chose` (`VOELIN_LIVE=1`) | tested against the TeamSpeak 6 dev server (our client on both ends) |
| Several codecs against official TeamSpeak viewers | – | not tested (no official client here) |
| Test pattern → VP8 → decoder, rectangle position and colour | `voelin-core` `media::tests::local_preview_decodes_the_pattern` | tested |
| Viewer counts: `viewer` of `notifystreaminfo`, counted up and down from the viewers joining and leaving, refreshed one stream at a time | `voelin-stream` `proto::tests::stream_info_answers`, `session::tests::viewer_counts`; `voelinctl stream list` | tested; against the TeamSpeak 6 dev server `stream list` printed "1 watching" while a viewer watched and "0 watching" after |
| A viewer picks a layer: the offer's `a=x-voelin-layers`, `Signal::Layer`, the streamer moving it (and back with "Auto"); no request to a streamer whose offer lists no layers | `voelin-stream` `layer::tests::layers_in_the_sdp`, `tests/sessions.rs` `viewer_picks_a_layer` and `no_layer_request_without_the_offer_listing_layers` (two sessions, peers on loopback); `voelinctl stream watch --layer 1` against `stream start --placeholder --layer 1.0:2000k --layer 0.5:500k` | tested, also through the TeamSpeak 6 dev server: the viewer stayed on layer 1 at a 2.5 Mbit/s estimate that fits layer 0, and with a real two-layer VP8 stream of the test pattern (`stream start --synthetic --size 1280x720 --layer 1.0:3000k --layer 0.5:800k`) it decoded 640x360 pictures at a 3 Mbit/s estimate |
| An offer with `a=x-voelin-layers` against libwebrtc | `tests/browser_interop.rs` `rust_streams_to_browser` (`VOELIN_INTEROP=1`, system Chromium 152 through `playwright-core`) | tested: answered and decoded as before. The official client itself not tried |
| Test pattern → VP8 → decoder, rectangle position and colour; decoded frame rate and received bitrate | `voelin-core` `media::tests::local_preview_decodes_the_pattern`; the watch screen with the sample stream (`scripts/shots.sh ... watch`) | tested: the screenshot showed "VP8 · 1280×720 · 30 fps · 0.4 Mbit/s" over the player |
| Test pattern → two engine stream tasks → str0m peers on loopback → decoder | `voelin-core` `stream::tests::test_pattern_through_stream_tasks` | tested |
| Stream audio (RTP time → jitter buffer ids, volume, end) | `voelin-core` `audio::tests::stream_audio_with_volume`, stream task test | tested |
| Stream mixer (latency, fade on underrun, drift correction, rate conversion, limiter, levels, live source changes), `BlockClock` | `voelin-media` `mix::tests`, `tests/mix_alloc.rs` (no allocation per block) | tested |
| Application audio on PipeWire: desktop without our own stream, by name, by pid, a new player linked live, a quit one dropped, a restarted one matched again, the app list | `voelin-media/tests/pipewire_apps.rs` (private PipeWire, WirePlumber and D-Bus; tones told apart by frequency) | tested with PipeWire 1.0 and WirePlumber 0.4; skipped without them |
| Streamer audio sources (mix levels, gain, mute, live change, microphone tap, window source error, silence) | `voelin-core` `media::tests::audio_sources_change_live`, `audio_sources_from_settings`, `settings::tests::audio_sources` | tested |
| The share dialog's audio: the picked sources (gain, mute) in the capture request, none with "Share system audio" off; a running share following `stream.audio_sources` (a share without sound left so) | `voelin-ui` `streams::tests::the_share_carries_the_picked_audio`, `video::tests::a_share_follows_its_audio_sources`; headless screenshots (`share`, `share:live`) | tested; the dialog itself only in headless screenshots (nothing clicked) |
| X11 `_NET_WM_PID` of the shared window | `tests/x11_capture.rs` under Xvfb (`VOELIN_X11_TEST_DISPLAY`) | tested |
| WASAPI per-process loopback, audio sessions, `HWND` owner | – | type-checked for `x86_64-pc-windows-gnu` only |
| Android per-app and all-but-ours playback capture | `cargo ndk -t arm64-v8a clippy`, `gradlew compileDebugKotlin` | compiles only (no device or emulator here) |
@@ -964,3 +1087,4 @@ has not run on Windows yet.
| External capture providers (start, refusal, end of capture, default selection) | unit tests | tested |
| MediaCodec buffer layouts (I420, NV12 with padding, `MediaImage2` NV21, crop) | unit tests (`codec::image_layout`) | tested |
| MediaCodec encoders and decoders | – | compiles for `aarch64-linux-android` only (no device or emulator here) |
| MediaCodec zero-copy screen path (virtual display into the encoder's input surface, back to the reader for simulcast) | `cargo ndk -t arm64-v8a clippy` | compiles only (no device or emulator here; fps and CPU not measured) |
+51
View File
@@ -196,6 +196,41 @@ Full transcript, all the variants tried, and what Voelin does with them:
looks up unannounced streams in its channel with `requeststreaminfo`
(`voelin_stream::discovery`).
### Viewer counts (confirmed, 6.0.0-beta13.1, 2026-10-03)
Streamer A, viewers B and B2, bystander C in one channel, every command
logged (`--log-commands`):
- `viewer` of `notifystreaminfo` is the number of viewers the streamer
accepted: `requeststreaminfo clid=<A>` answered `viewer=1` while B2
watched and `viewer=0` after it left.
- `notifystreamclientjoined clid=<viewer> id=<stream>` goes to everyone in
the channel (C got one for B and one for B2), but not to the viewer who
joined.
- `notifystreamclientleft clid=<viewer> id=<stream> reason=1` goes only to
the streamer and to the viewer who left (`joinstreamrequest ...
is_remove=1`); C got nothing, also not when B left the server.
- No `notifystreamupdated` when viewers come or go (`StreamUpdated` has no
viewer field).
So a client counts joins itself, and asks `requeststreaminfo` again now and
then for the leaves it is not told about: `StreamInfo::viewers`
(`voelin_stream`), kept by `StreamDirectory` and refreshed one stream at a
time every 5 s by the engine (`Streams::refresh_viewer_counts`).
### Voelin's own additions (not TeamSpeak's)
Between Voelin clients only, a viewer can pick the streamer's simulcast
layer: the offer of a Voelin streamer with several layers carries a
session-level `a=x-voelin-layers:<id>/<WxH or scale>/<bitrate>[/<fps>] ...`
line, and a Voelin viewer that saw it may send
`streamsignaling json={"cmd":"x-voelin-layer","args":{"layer":<id or null>}}`.
The server relays both unchanged (6.0.0-beta13.1). Official clients are not
affected: libwebrtc skips unknown session attributes (headless Chromium 152
answers and decodes such an offer), and official streamers never put the
attribute in their offers, so they are never sent the signal. Details in
[media.md](../media.md).
### WebRTC interop with Chromium (confirmed, Chromium 141, 2026-09-26)
`crates/voelin-stream/tests/browser_interop.rs` (`VOELIN_INTEROP=1`, see
@@ -262,6 +297,22 @@ the official client itself is still to be confirmed: the beta needs a
myTeamSpeak sign-in on first start, so it cannot run from a throwaway
profile.
### The official client re-offers (confirmed, client 6.0.0-beta4.1, 2026-10-03)
Streaming from the official client to Voelin, its log shows: our answer
(H.264, VP9, VP8 — no AV1, which the app did not decode) → "remote peer is
using unsupported codec, realign" → a new `offer` signal on the same
connection → our answer → `ENCODER create: H264`. The new offer is a
renegotiation of the running connection: the answer must come from the same
peer (same ICE credentials and DTLS fingerprint). Voelin answered every offer
with a new peer, so the connection broke and nothing was shown. Now
`Peer::renegotiate` answers an `offer` signal on the running connection (a
`reconnectOffer` still starts a new one), in the codec order of the new offer
(str0m keeps the first offer's order; `order_like_offer` fixes the answer's
`m=` lines), so the streamer switches to the codec it re-offered. Tested
against Chromium: `browser_renegotiates_with_rust` (VP8, then a re-offer of
VP9 on the same connection; VP9 frames arrive).
## Open questions
- [x] Viewer side: `joinstreamrequest id clid msg is_remove` (see above).
Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 30 KiB

+85 -12
View File
@@ -3,7 +3,8 @@
The Stream Studio composites scenes of sources (screens, windows, cameras,
images, text, colours) into one picture that becomes the video of our stream,
and keeps or forwards what the stream's encoders make: a recording, a replay
buffer to save clips from after the fact, and WHIP to a broadcast service. It
buffer to save clips from after the fact, and WHIP or RTMP to a broadcast
service. It
is the engine behind the Studio screen of the UI (scenes and sources, a live
preview, LIVE / timer, the audio mixer, Record Clip, Go Live / End Stream,
Share Window / Share Screen, a camera with background blur); this page is
@@ -21,7 +22,7 @@ sources (a thread each) ─ Feed (latest wins) ┐
Streamer::start_studio: convert → layers → encoders ─────┼─ MediaSink (the live stream, when attached)
audio sources → mixer → Opus ────┘
│ every packet of the stream codec, attached or not
└─ Studio::write_packet ─ replay buffer, recording, WHIP outputs
└─ Studio::write_packet ─ replay buffer, recording, WHIP and RTMP outputs
```
Everything is changeable while it runs, and nothing is capped: any number of
@@ -103,12 +104,46 @@ only three read-only enumeration ioctls are written by hand. Capture goes
through PipeWire, which owns the devices on a current desktop: from the
user's daemon, or in a sandbox from the XDG Camera portal (`ashpd`), both on
the same PipeWire thread as screen capture. Raw formats (YUYV, UYVY, NV12,
I420, packed RGB) are converted into pooled frames; MJPEG is not offered, so
a camera that has both gives its raw format (often at a lower size at the
highest rates). `camera::SYNTHETIC` is always listed: the test pattern, for
I420, packed RGB) are converted into pooled frames. MJPEG, which many USB
cameras offer for their large sizes only (the Fifine K420: 2560x1440 and
1920x1080 only as MJPEG, raw up to 1280x720), is decoded by `zune-jpeg`
straight into pooled RGBA frames on a thread of its own, latest-wins, so a
decode that falls behind drops pictures rather than holding up the camera;
the background filter then runs on that thread. A camera-like 1440p
picture takes about 30 ms to decode (one core), so 1440p at 30 fps is about
what that thread does.
What PipeWire is offered comes from the V4L2 list, best first: the wanted
size at the wanted rate in a raw format (nothing to decode), then the
wanted size at any rate with MJPEG first, then every format at the sizes it
lists, nearest the wanted size first. Every offer names sizes the driver
lists for that format: PipeWire's V4L2 source takes a size on trust and
then fails to set it (NV12 at 2560x1440 on a camera that has that size only
as MJPEG). `camera::SYNTHETIC` is always listed: the test pattern, for
tests and machines without a camera. `voelinctl studio cameras` prints the
list.
On Windows, Media Foundation (`camera::mf`): `MFEnumDeviceSources` lists the
cameras (the symbolic link is the id, then the friendly name, and every
native format with its sizes and rates), and an `IMFSourceReader` on a
thread of its own opens one at the native format nearest the wanted size,
the fastest up to the wanted rate, and hands out NV12 at that size: with
advanced video processing on, the reader decodes MJPEG and converts the
other formats itself. Frames go through the same pacer, pool and
background filter as on Linux. **Never run**: it is type-checked for
`x86_64-pc-windows-gnu` only, as nothing here runs Windows.
Android: the app registers a `camera::CameraProvider` (Camera2 through its
Kotlin side, [android.md](android.md#cameras)), whose cameras `list()` puts
first (front ones first). A camera opens into an `ImageReader`
(YUV_420_888) and its planes arrive as `camera::YuvPlanes` with the turn
that makes the picture upright for the screen's rotation: an upright planar
or NV12 picture goes to the source's sink as it is, NV21 and turned ones are
gathered into I420 in a buffer each camera keeps (nothing is allocated per
frame). `Camera::mirrored` is the default mirroring (a camera that faces the
user; not a phone's back camera); the source menu's Switch camera moves a
camera source to the next camera.
## Background replacement (`studio::segment`)
A source's `background` is `keep`, `blur` (`strength`: radius as a fraction
@@ -171,9 +206,36 @@ fails is removed and reported, and the rest go on.
that reaches the service: no STUN or TURN yet. It asks for a keyframe when
it starts, when ICE comes up, when the service sends a PLI and after its
queue overflowed.
- **RTMP** (`rtmp::Rtmp`): the seam only. It is meant to go through the
FFmpeg libraries loaded at runtime (libavformat's muxer side is not in the
loader yet); until then adding an `rtmp://` output fails with that reason.
- **RTMP and RTMPS** (`rtmp::Rtmp`, feature `ffmpeg`): through libavformat
loaded at runtime, never linked ([media.md](media.md#rtmp-output)). Its
`rtmp://` and `rtmps://` protocols do the handshake, `connect`, `publish`
and TLS and take an FLV byte stream; the FLV is ours (`flv`: `onMetaData`,
AVC and AAC sequence headers, then one tag per frame), as the recordings'
Matroska is, so no libavformat struct is touched. Video is H.264 of the
output's layer (classic RTMP carries nothing else; Enhanced RTMP's HEVC,
AV1, VP9 and Opus are not written): the stream's packets as they are
when it encodes H.264; with another stream codec the streamer runs an
H.264 encoder for that layer beside it, as for a viewer that chose
another codec (`OutputSink::video_codec`, `Studio::output_codecs`), and
its packets go to the outputs that asked for H.264 only, while the
recordings and the replay buffer keep the stream's codec. Audio is the
studio's Opus decoded and encoded as AAC-LC (160 kbit/s, 48 kHz stereo)
by FFmpeg's own `opus` decoder and `aac` encoder, on the output's
thread. The stream key is the
last part of the URL's path (`rtmp://host/app/key`) or the output's token
(sent as the play path, the URL's path as the application); the output's
name never shows it. The first connection is made when the output is
added, so a wrong address or key fails there; a connection that fails
later (the service restarting, the network) is made again after 1, 2, 4,
... up to 30 seconds for as long as the output exists, each new one
starting at a keyframe it asks for, while the stats show why it is down.
A thread of its own runs the connection behind a bounded queue (about two
seconds): a slow upload drops packets rather than holding up an encoder,
and video resumes at the next keyframe. Audio goes out in time order with
the video (it waits for the video of its time, at most a second), and the
audio of the first keyframe's moment, which comes before the keyframe,
is kept as a recording keeps it. `EndStream` unpublishes and closes; a
network that does not answer is cut off after three seconds.
Recording and the replay buffer need no live stream: a studio's streamer
encodes from the start (see below).
@@ -197,8 +259,8 @@ channel; late subscribers miss what came before).
| `SetPreview { width, height, fps }` | the preview tap's size and rate (default 480x270 at 15 fps) |
| `StartRecording { path }` / `StopRecording` | `.webm` or `.mkv` |
| `SetReplay { seconds, memory_mb }` / `SaveClip { path }` | the replay buffer (0 seconds: off) |
| `AddOutput(OutputSpec::Record { path } \| Url { url, token })` / `RemoveOutput { id }` | more recordings, WHIP (`http(s)://`), RTMP (refused for now) |
| `GoLive` / `EndStream` | the studio's state for the header (LIVE, timer); `EndStream` also closes the outputs that push (WHIP push from when they are added). The TeamSpeak stream itself is started and attached as usual |
| `AddOutput(OutputSpec::Record { path } \| Url { url, token })` / `RemoveOutput { id }` | more recordings, WHIP (`http(s)://`, `token`: the bearer token), RTMP (`rtmp(s)://`, `token`: the stream key unless the URL ends with it) |
| `GoLive` / `EndStream` | the studio's state for the header (LIVE, timer); `EndStream` also closes the outputs that push (WHIP and RTMP push from when they are added). The TeamSpeak stream itself is started and attached as usual |
| Event | |
|---|---|
@@ -257,6 +319,10 @@ voelinctl studio run scenes.json --seconds 10 --switch-to 2 \
--preview preview.png --record rec.webm --clip clip.mkv --replay 30 --tone 440 --codec vp8
# Push to a WHIP endpoint (token also from VOELIN_WHIP_TOKEN).
voelinctl studio run scenes.json --seconds 60 --whip https://ingest.example/whip --token ...
# Push over RTMP(S) (H.264, encoded besides the stream's unless --codec h264;
# the key in the URL or in --token).
voelinctl studio run scenes.json --seconds 60 --tone 440 \
--rtmp rtmps://live.example/app --token <stream key>
# The compositor alone: compose time and heap allocations per frame.
voelinctl studio bench --sources 4 --res 1920x1080 --fps 60
voelinctl studio cameras
@@ -294,9 +360,16 @@ two threads) takes about 3 ms at its own rate (15 fps by default).
| Settings ⇄ studio in both directions | `voelin-core` `studio::tests` | tested |
| WHIP: offer, answer, ICE, DTLS, VP8 and Opus arriving, refusal with the service's reason, `DELETE` on stop | `tests/studio_whip.rs` against a WHIP server built on str0m in the test (`--features whip`) | tested; no public WHIP service tried |
| Real camera through the user's PipeWire (Fifine K420, 1280x720) | `camera::tests::a_real_camera_delivers` (`--ignored`) | tested on one webcam |
| MJPEG: decoded into pooled frames (one frame reused), broken pictures refused, the decoder thread takes the newest | `camera::mjpeg::tests` | tested |
| MJPEG from a real camera (Fifine K420) at 2560x1440, 1920x1080 and 1280x720 | `camera::tests::a_real_camera_delivers_its_largest_mjpeg_size` (`--ignored`, `VOELIN_CAMERA_SIZE` picks a size) | tested on one webcam: each size arrived at 10 fps, which is what the camera sent in that light (`v4l2-ctl` measured the same 10 fps) |
| Camera through the XDG Camera portal (sandboxes) | – | compiles only |
| Screen, window and portal sources | the existing capture backends ([media.md](media.md#capture)) | as tested there; not run inside the studio here |
| Background blur, image and colour backdrops on the oval mask | `segment::tests` | tested |
| Person segmentation (PP-HumanSeg through tract): loads, 192x192 mask, nobody in an empty room, time per mask | `segment::tests::the_model_finds_nobody_in_an_empty_room` | tested (about 50 ms per mask); on a photo of a person the mask follows the silhouette, arms and legs included (checked by eye, the photo is not in the repository); not yet tried with a camera |
| Windows and Android cameras | – | not implemented: `camera::list()` has only the test pattern there |
| RTMP | – | the seam only (refuses with its reason) |
| Windows cameras (Media Foundation: listing, the native format nearest the wanted size, NV12 through the source reader, MJPEG decoded by it) | `cargo clippy --target x86_64-pc-windows-gnu -p voelin-media` | type-checked only, never run |
| Android cameras (Camera2): planes borrowed, gathered or turned | `camera::tests::camera_planes_are_borrowed_gathered_and_turned` (the Rust side) | tested on the host; the Camera2 side compiles only (no device here) |
| RTMP: the FLV tags (sizes, times past 24 bits, AVC from Annex B, `onMetaData` in AMF0), URL and key handling (the name hides the key), dead servers refused | `flv::tests`, `rtmp::tests` | tested |
| RTMP beside another stream codec: an output asks for H.264 of its layer only, its packets reach it alone, the recording and the replay buffer keep the stream's | `studio::tests::packets_reach_the_outputs_and_the_studio_is_a_capture_backend` | tested |
| RTMP: write errors seen (`AVIOContext.error`, found at load), an abort ends a stuck connect, the sample format field of the AAC encoder, Opus → AAC (frames back to back from the packets' clock, priming, a gap restarts the clock) | `ffmpeg::avio::tests`, `ffmpeg::audio::tests`, `ffmpeg::tests` | tested with FFmpeg 9.0.1 (libavformat 63: `error` at 84, `sample_fmt` at 348) and FFmpeg 4.4.8 (58: 120 and 408) |
| RTMP end to end: a studio stream (H.264 through the hardware encoder, a 440 Hz tone) pushed to FFmpeg's own RTMP server (`ffmpeg -listen 1`) with the key apart from the URL; the server killed and another started on its port; `EndStream` | `voelin-core/tests/studio.rs` `a_studio_stream_goes_out_over_rtmp_and_comes_back_after_the_server_did` | tested: ffprobe reads `h264` 320x180 and `aac` 48000 Hz stereo in both servers' files, each starting at a keyframe, every picture decodes (red), the audio decodes to 440 Hz; the key arrived as the stream name; the second server finished its file and exited by itself. No public service (Twitch, YouTube) tried; RTMPS only through FFmpeg's TLS, untried here |
| RTMP from a VP8 stream: the same server, the key in the URL, a recording at the same time | `voelin-core/tests/studio.rs` `a_vp8_stream_goes_out_over_rtmp_as_h264` | tested: the streamer's layer encodes VP8 and H.264; ffprobe reads `h264` 320x180 and `aac` 48000 Hz stereo, starting at a keyframe, every picture decodes (red), 440 Hz; the recording is VP8 and Opus |
+8
View File
@@ -50,6 +50,13 @@ noted.
- **ST5** H.264: enable OpenH264 (download on first use, attribution text
shown next to the switch), stream to the official client and watch its
H.264 stream. Disable it again: H.264 is no longer offered.
- **ST6** Our stream with two simulcast layers (Settings → Streaming, or
`voelinctl stream start --synthetic --layer 1.0:3000k --layer 0.5:800k
--auto-accept`): its offer then carries Voelin's `a=x-voelin-layers` line.
Pass: the official client watches as in ST1. While it watches the
official client's stream (ST2), our viewer shows no quality picker and
sends no `x-voelin-layer` signal (`RUST_LOG=voelin_stream=debug`, or
`--log-commands`: no `streamsignaling` with `x-voelin-layer`).
| ID | Platform | Result | Date | Version | Notes |
|---|---|---|---|---|---|
@@ -72,6 +79,7 @@ noted.
| ST4 | KDE | | | | |
| ST5 | GNOME or KDE | | | | |
| ST5 | Win11 | | | | |
| ST6 | any | | | | |
## Global push-to-talk
+31 -10
View File
@@ -136,8 +136,8 @@ comes from the engine's events; what a gateway adds is hidden without it.
| Member card | `member` | Description, groups, talk power, country; private message, poke, friend, block; volume and mute for us | `ContactsChanged`; `Command::SetContact`, `SetClientVolume`, `SetClientMuted`, `Poke` |
| Pinned messages | `pins` | In the members panel's place: cards with author, time, text, files and reactions; the pin unpins, a click jumps to the message | `Gateway` `Pins`, `Pinned`, `Unpinned`; `GatewayRequest::Pins`, `Unpin` |
| Topics | `topics`, `topic:<id>` | In the members panel's place: search, cards with the message count, creator and last activity, Create Topic; an open topic replaces the chat's messages and takes replies | `Gateway` `Topics`, `Topic`, `TopicHistory`; `GatewayRequest::Topics`, `TopicHistory`, `CreateTopic`, `Post` |
| Voice channel | `voice` | Title, topic, "5 in voice / 50 total", Voice Settings, Leave; the people as large avatars (talking ring and bars, muted, crown, streaming); the streams as cards (LIVE, viewers, kind, bitrate, sound, Watch Stream); the channel's chat | `Presence`, `Talking`, `StreamsChanged`, `Gateway` stream directory (viewer counts) |
| Watching a stream | `watch`, `popout` | The channel's header with "5 in voice" and Leave; the player with the streamer, title, viewers, LIVE, the picture's height (the simulcast picker when the streamer offers layers), volume, elapsed time, back to the chat, pop out, full screen; a note that the stream belongs to the channel; the channel's chat and a Stream Info tab. Popped out (and in full screen) it fills the window | `WatchState`, decoded frames (`src/video.rs`), `Gateway` stream directory |
| Voice channel | `voice` | Title, topic, "5 in voice / 50 total", Voice Settings, Leave; the people as large avatars (talking ring and bars, muted, crown, streaming); the streams as cards (LIVE, viewers, kind, bitrate, sound, Watch Stream); the channel's chat | `Presence`, `Talking`, `StreamsChanged`, viewer counts from `StreamsChanged`, else the `Gateway` stream directory |
| Watching a stream | `watch`, `popout` | The channel's header with "5 in voice" and Leave; the player with the streamer, title, viewers, LIVE, the picture's height (the simulcast picker when a Voelin streamer offers layers), volume, elapsed time, what arrives (codec, size, frame rate, bitrate), back to the chat, pop out, full screen; a note that the stream belongs to the channel; the channel's chat and a Stream Info tab. Popped out (and in full screen) it fills the window | `WatchState`, `WatchLayers`, decoded frames and their stats (`src/video.rs`), `StreamsChanged` (viewer counts; the `Gateway` stream directory where the server gives none) |
The pins and topics share the place of the members panel: opening one
closes the other, and the members button brings the panel back. On the
@@ -181,6 +181,25 @@ game"), which is also what the gateway's directory shows. With sample data
the synthetic camera with background blur, text, colours) and test tones,
on settings in memory, and recordings go to a temporary folder.
### Sound in the quick share
The share dialog (`share`, and `share:live` for a running share) mixes its
sound with the studio's pieces: while "Share system audio" is on (off: no
audio at all) it shows the studio's mixer rows (`MixerRow`: meter, gain,
mute, a menu) for `stream.audio_sources`, and Add opens the studio's picker
(`PickDialog`) over it: the microphone, desktop audio without Voelin, the
shared window's application, any application that plays (on Android the
launchable apps with their icons), several at once. The rows read the
main window's `StudioBridge`, filled without starting the studio
(`App::mixer_show`). Starting a share hands the sources to the capture
(`CaptureRequest::audio_sources`); while it runs the dialog shows the
same rows with the share mixer's meters (about 15 times a second), and
every change of `stream.audio_sources`, from the dialog or anywhere else,
goes to the running capture at once (`Capture::follow_audio`, which calls
`Streamer::reconfigure`). A share started without sound has no audio track
to add sources to. With sample data `share:live` shares the test pattern
with the sample studio's sources, live at once with sample viewers.
## Adding a screen
1. Write the screen in `ui/screens/<name>.slint` from the components
@@ -243,7 +262,7 @@ Environment variables (see `src/dev.rs`):
- `VOELIN_DEMO_UI=1`: sample servers, channels, members, chat with emoji and
a stream, without a server (nothing is stored).
- `VOELIN_OPEN=<what>[,<what>...]`: `home`, `server`, `settings[:voice|keybinds|streaming|privacy|appearance]`,
`about`, `share`, `bookmark`, `emoji`, `client`, `panel`, `no-panel`,
`about`, `share[:live]`, `bookmark`, `emoji`, `client`, `panel`, `no-panel`,
`voice`, `pins`, `topics`, `topic:<id>`, `member`, `watch`, `popout`
(the server page, above), `tab:<home|servers|chat|activity|you>` (phone
layout). With sample data, `watch` plays the local test pattern in the
@@ -296,13 +315,13 @@ the window's size so the pointer is not over the window, and passes
| ![home](screenshots/desktop-home.png) | ![light](screenshots/desktop-light.png) |
| ![settings](screenshots/desktop-settings-voice.png) | ![appearance](screenshots/desktop-settings-appearance.png) |
| ![emoji](screenshots/desktop-emoji-picker.png) | ![volume](screenshots/desktop-client-volume.png) |
| ![share](screenshots/desktop-share-dialog.png) | ![add server](screenshots/desktop-add-server.png) |
| ![about](screenshots/desktop-about.png) | |
| ![share](screenshots/desktop-share-dialog.png) | ![sharing](screenshots/desktop-share-live.png) |
| ![add server](screenshots/desktop-add-server.png) | ![about](screenshots/desktop-about.png) |
| Phone layout | | | | |
|---|---|---|---|---|
| ![chat](screenshots/mobile-chat.png) | ![servers](screenshots/mobile-servers.png) | ![home](screenshots/mobile-home.png) | ![you](screenshots/mobile-you.png) | ![settings](screenshots/mobile-settings.png) |
| ![studio](screenshots/mobile-studio.png) | | | | |
| ![voice channel](screenshots/mobile-voice.png) | ![activity](screenshots/mobile-activity.png) | ![studio](screenshots/mobile-studio.png) | ![share](screenshots/mobile-share.png) | ![sharing](screenshots/mobile-share-live.png) |
## Limits
@@ -314,9 +333,10 @@ the window's size so the pointer is not over the window, and passes
- The members panel lists the people online: TeamSpeak tells a client
nothing about offline members, so the mockup's "Offline" section and a
server-wide member count are left out.
- The quality picker shows only when the streamer's simulcast layers are
known; the engine does not yet tell a viewer which layers a stream has,
so in practice the player shows the decoded picture's height.
- The quality picker shows only when the streamer lists its simulcast
layers, which only a Voelin streamer does (`a=x-voelin-layers`, see
[media.md](media.md)); for the official client's streams the player
shows the decoded picture's height.
- Popping the stream out fills the main window (no second window yet).
- A jump to a pinned message scrolls to where an average row would be
(rows differ in height), and only to messages already loaded.
@@ -325,6 +345,7 @@ the window's size so the pointer is not over the window, and passes
stream belongs to its channel): its destination picks among the servers,
not among their channels. Image paths (image sources, backgrounds) are
typed, there is no file chooser. The background effect replaces what is
outside an oval (the engine has no person segmentation model yet). The
around the person the engine's segmentation model finds (an oval where
the model does not load). The
studio cannot be detached on Android (one window). Its own window shows
no toasts; status messages go to the main window.