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:
1 parent
4fe7263553
commit
8917f7dab2
13 files changed
+375
-85
No files matched your search
@@ -831,14 +831,15 @@ pub static STREAM_FPS: Key<u32> =
|
||||
Key::new("stream.fps", Kind::UInt { min: 1 }, "Frames per second of our stream.", || 60)
|
||||
.validated(at_least_one);
|
||||
|
||||
/// Video bitrate of our stream in kbit/s (no maximum).
|
||||
/// Video bitrate of our stream in kbit/s (no maximum); 0, the default:
|
||||
/// automatic, from the size and frame rate streamed
|
||||
/// (`media::auto_bitrate`, up to 60 Mbit/s), following both live.
|
||||
pub static STREAM_BITRATE_KBPS: Key<u32> = Key::new(
|
||||
"stream.bitrate_kbps",
|
||||
Kind::UInt { min: 1 },
|
||||
"Video bitrate of our stream in kbit/s.",
|
||||
|| 8000,
|
||||
)
|
||||
.validated(at_least_one);
|
||||
Kind::UInt { min: 0 },
|
||||
"Video bitrate of our stream in kbit/s (0: automatic, up to 60 Mbit/s).",
|
||||
|| 0,
|
||||
);
|
||||
|
||||
/// One simulcast layer as stored; see [`LayerSpec`] for the fields. The
|
||||
/// serde form of a layer: `{"scale": 0.5, "max_fps": 30, "bitrate": 1500000}`
|
||||
@@ -1342,7 +1343,7 @@ mod tests {
|
||||
fn defaults_and_registry() {
|
||||
let s = Settings::in_memory();
|
||||
assert_eq!(s.get(&STREAM_FPS), 60);
|
||||
assert_eq!(s.get(&STREAM_BITRATE_KBPS), 8000);
|
||||
assert_eq!(s.get(&STREAM_BITRATE_KBPS), 0, "automatic");
|
||||
assert!(s.get(&STREAM_LAYERS).is_empty());
|
||||
assert_eq!(s.get(&STREAM_CODEC), CodecChoice::Auto);
|
||||
assert_eq!(s.get(&STREAM_PERMISSIONS), StreamPermissions::Channel);
|
||||
@@ -1416,6 +1417,8 @@ mod tests {
|
||||
s.set_json("stream.fps", json!(1000)).unwrap();
|
||||
s.set(&STREAM_BITRATE_KBPS, u32::MAX).unwrap();
|
||||
assert_eq!(s.get(&STREAM_BITRATE_KBPS), u32::MAX);
|
||||
// 0 is automatic again.
|
||||
s.set(&STREAM_BITRATE_KBPS, 0).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user