Merge Wave 6A: studio outputs, cameras, viewer counts and layers
RTMP output for the Stream Studio through libavformat (any stream codec, pushed as H.264 + AAC; tested against `ffmpeg -listen 1`, ffprobe checks), MJPEG cameras (decoded off the capture thread), TeamSpeak 6's own viewer counts (`viewer` of `notifystreaminfo`, refreshed round robin), a viewer quality picker for Voelin streams (`a=x-voelin-layers` in the offer, an `x-voelin-layer` signal only Voelin streamers get), viewer-side stats over the player, Windows cameras through Media Foundation (compile-checked only), and the docs for all of them. Merged cleanly with server-wide stream discovery and renegotiation; the viewer-count refresh now covers every channel's streams. fmt, clippy and the tests of stream, media, core, ui and voelinctl pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
3bd230767c
41 files changed
+3878
-233
No files matched your search
+100
-6
@@ -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
|
||||
|
||||
@@ -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.
|
||||
@@ -297,8 +335,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 +515,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 | |
|
||||
@@ -901,6 +989,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 +1015,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,7 +1040,10 @@ 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 |
|
||||
|
||||
@@ -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
|
||||
|
||||
+74
-12
@@ -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,35 @@ 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.
|
||||
|
||||
## Background replacement (`studio::segment`)
|
||||
|
||||
A source's `background` is `keep`, `blur` (`strength`: radius as a fraction
|
||||
@@ -171,9 +195,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 +248,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 +308,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 +349,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 | – | not implemented: `camera::list()` has only the test pattern there |
|
||||
| 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 |
|
||||
@@ -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
|
||||
|
||||
|
||||
+8
-6
@@ -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
|
||||
@@ -314,9 +314,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 +326,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.
|
||||
Reference in new issue
Block a user