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
@@ -19,7 +19,8 @@ use crate::app::{
|
||||
App, Bridge, ShareForm, SourceItem, StreamItem, ViewerItem, later, model, with_app,
|
||||
};
|
||||
use crate::settings::{
|
||||
BITRATE_CHOICES, FPS_CHOICES, ShareDefaults, nearest_choice, parse_positive,
|
||||
BITRATE_CHOICES, FPS_CHOICES, LEGACY_BITRATE_CHOICES, LEGACY_FPS_CHOICES, ShareDefaults,
|
||||
nearest_choice, parse_positive,
|
||||
};
|
||||
use crate::video::{self, Capture, CaptureRequest, Decoder};
|
||||
|
||||
@@ -540,7 +541,8 @@ impl App {
|
||||
fps_index: nearest_choice(&FPS_CHOICES, fps) as i32,
|
||||
fps: fps.to_string().into(),
|
||||
bitrate_index: nearest_choice(&BITRATE_CHOICES, bitrate) as i32,
|
||||
bitrate: bitrate.to_string().into(),
|
||||
// Automatic (0): the field stays empty.
|
||||
bitrate: if bitrate == 0 { String::new() } else { bitrate.to_string() }.into(),
|
||||
audio: defaults.audio,
|
||||
auto_accept: defaults.auto_accept,
|
||||
}
|
||||
@@ -586,7 +588,8 @@ impl App {
|
||||
self.refresh_streams();
|
||||
return;
|
||||
}
|
||||
// Typed values (no maximum), else the chosen presets.
|
||||
// Typed values (no maximum), else the chosen presets (bitrate 0:
|
||||
// automatic).
|
||||
let choice = |i: i32, choices: &[u32]| {
|
||||
choices[usize::try_from(i).unwrap_or(0).min(choices.len() - 1)]
|
||||
};
|
||||
@@ -602,8 +605,8 @@ impl App {
|
||||
}
|
||||
}
|
||||
let defaults = ShareDefaults {
|
||||
fps_index: nearest_choice(&FPS_CHOICES, fps),
|
||||
bitrate_index: nearest_choice(&BITRATE_CHOICES, bitrate),
|
||||
fps_index: nearest_choice(&LEGACY_FPS_CHOICES, fps),
|
||||
bitrate_index: nearest_choice(&LEGACY_BITRATE_CHOICES, bitrate),
|
||||
audio: form.audio,
|
||||
auto_accept: form.auto_accept,
|
||||
};
|
||||
@@ -650,6 +653,10 @@ impl App {
|
||||
self.settings.portal_restore_token = Some(token);
|
||||
self.store_settings();
|
||||
}
|
||||
if setup.bitrate == 0 {
|
||||
// Automatic: what it comes to for the size captured.
|
||||
setup.bitrate = capture.streamer().bitrate_kbps();
|
||||
}
|
||||
if setup.audio && !capture.has_audio() {
|
||||
setup.audio = false;
|
||||
let reason = capture.audio_error().unwrap_or_default();
|
||||
@@ -660,6 +667,8 @@ impl App {
|
||||
(true, demo_viewers())
|
||||
} else {
|
||||
let session = session as u64;
|
||||
// One layer, whatever a studio stream had before.
|
||||
self.engine.send(Command::SetStreamLayers { session, layers: Vec::new() });
|
||||
self.engine.send(Command::StartStream { session, setup, auto_accept });
|
||||
(false, Vec::new())
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user