Streams: an automatic bitrate up to 60 Mbit/s, and presets to match

The bitrate was a fixed 8 Mbit/s by default whatever was shared, and the
share dialog offered at most 10 Mbit/s and 60 fps. Asked for: Voelin
streams that can target 60 Mbit/s at up to 8K and 320 fps, with an
automatic bitrate that scales with the stream's resolution and frame rate
and follows it live, beyond 60 Mbit/s only when typed.

- `media::auto_bitrate(width, height, fps)`: 0.12 bits per pixel and
  frame (7.5 Mbit/s at 1080p30, 15 at 1080p60, 27 at 1440p60) between
  300 kbit/s and 60 Mbit/s, reached at 4K60 and 1080p240.
- `stream.bitrate_kbps` 0 is automatic and now the default. A streamer
  layer with bitrate 0 works it out per picture from the size encoded and
  the layer's frame rate, so a new resolution or frame rate moves it at
  once, and tells its sink (`MediaSink::auto_bitrate`). The engine's
  `StreamSink` puts it into the live stream's layer, so connections start
  their bandwidth estimate at it and probe for it; without that the
  stream would have kept the bitrate announced at the start.
  `Streamer::bitrate_kbps()` is what to announce.
- The quick share offers 15-320 fps and Auto, 2.5 to 60 Mbit/s (typed
  values still have no maximum; the `ui` blob keeps indices of the old
  lists for older versions). The studio offers 4K and 8K and 30-240 fps,
  takes an empty bitrate as automatic and derives its first simulcast
  layer from the automatic bitrate.
- The studio now tells the engine its layers when it goes live and when
  they change (`SetStreamLayers`), and a quick share resets them: the
  session sends only layers it knows of, so a studio's simulcast layers
  never reached a viewer, and its layer kept the bitrate announced.
- `voelinctl stream start` and `stream bench` default to the automatic
  bitrate too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-04 03:37:08 +03:00
1 parent 4fe7263553
commit 8917f7dab2
13 files changed
+375 -85

No files matched your search

+16
View File
@@ -126,6 +126,22 @@ viewer: Engine::subscribe_frames ─ VideoPipeline (thread) ─ VideoDecoder
`MediaSink::layer_bitrate(id)` when the sink knows it (capped by
`max_bitrate`), else its configured bitrate; libvpx changes it in place
without a keyframe.
- Automatic bitrate: `bitrate_kbps` 0 (the default of the setting
`stream.bitrate_kbps`) gives the single layer `auto_bitrate(width,
height, fps)`: 0.12 bits per pixel and frame of the size and rate it is
encoded at (7.5 Mbit/s at 1080p30, 15 at 1080p60, 27 at 1440p60), at
least 300 kbit/s and at most 60 Mbit/s (`AUTO_BITRATE_MAX`, reached at
3840x2160@60, 2560x1440@135, 1920x1080@240). It follows the stream live:
the encoder thread works it out from each picture's size and the layer's
frame rate, so a resolution or frame-rate change moves it at once. The
sink is told with the first frame and whenever it changes
(`MediaSink::auto_bitrate`); the engine's `StreamSink` puts it into the
live stream's layer, so new connections start their bandwidth estimate at
it and all of them probe for it. `Streamer::bitrate_kbps()` is what to
announce in `setupstream` (the share dialog and the studio do, up to the
65535 kbit/s a server keeps: [protocol notes](protocol-notes/ts6-streaming.md#what-setupstream-takes-confirmed-600-beta131-2026-10-04)).
A typed bitrate is used as it is, above 60 Mbit/s too; nothing in Voelin
caps it (encoders take up to 2^32-1 bit/s).
- `Streamer::reconfigure(&codecs, StreamerConfigUpdate { fps, bitrate_kbps,
codec, encoder, layers, audio_sources })` applies from the next frame without restarting the
capture: encoders are created first (an error changes nothing), layers