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
@@ -105,10 +105,16 @@ pub fn appearance_keys() -> [&'static dyn voelin_core::settings::Setting; 5] {
|
||||
[&UI_THEME, &UI_FONT_SCALE, &UI_NARROW_BREAKPOINT, &UI_IMAGE_CACHE_MB, &UI_MEMBERS_WIDTH]
|
||||
}
|
||||
|
||||
/// Frame rates and bitrates (kbit/s) the share dialog offers; any other
|
||||
/// value can be typed in.
|
||||
pub const FPS_CHOICES: [u32; 3] = [15, 30, 60];
|
||||
pub const BITRATE_CHOICES: [u32; 4] = [2500, 4608, 8000, 10_000];
|
||||
/// Frame rates and bitrates (kbit/s; 0: automatic) the share dialog
|
||||
/// offers, in the order of its lists (`dialogs.slint`); any other value can
|
||||
/// be typed in.
|
||||
pub const FPS_CHOICES: [u32; 7] = [15, 30, 60, 120, 144, 240, 320];
|
||||
pub const BITRATE_CHOICES: [u32; 8] = [0, 2500, 4608, 8000, 10_000, 20_000, 40_000, 60_000];
|
||||
|
||||
/// The share dialog's lists before they grew, which [`ShareDefaults`]
|
||||
/// indexes for older versions.
|
||||
pub const LEGACY_FPS_CHOICES: [u32; 3] = [15, 30, 60];
|
||||
pub const LEGACY_BITRATE_CHOICES: [u32; 4] = [2500, 4608, 8000, 10_000];
|
||||
|
||||
/// The index of the choice closest to `value`.
|
||||
pub fn nearest_choice(choices: &[u32], value: u32) -> usize {
|
||||
@@ -151,7 +157,8 @@ impl Default for UiSettings {
|
||||
|
||||
/// The last choices in the share dialog. Frame rate and bitrate are the
|
||||
/// settings `stream.fps` and `stream.bitrate_kbps`; the indices of the
|
||||
/// closest choices are kept for older versions.
|
||||
/// closest choices of the old lists ([`LEGACY_FPS_CHOICES`],
|
||||
/// [`LEGACY_BITRATE_CHOICES`]) are kept for older versions.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct ShareDefaults {
|
||||
@@ -356,9 +363,12 @@ mod tests {
|
||||
#[test]
|
||||
fn free_values() {
|
||||
assert_eq!(nearest_choice(&FPS_CHOICES, 60), 2);
|
||||
assert_eq!(nearest_choice(&FPS_CHOICES, 144), 2);
|
||||
assert_eq!(nearest_choice(&BITRATE_CHOICES, 3000), 0);
|
||||
assert_eq!(nearest_choice(&BITRATE_CHOICES, 50_000), 3);
|
||||
assert_eq!(nearest_choice(&FPS_CHOICES, 144), 4);
|
||||
assert_eq!(nearest_choice(&FPS_CHOICES, 1000), 6);
|
||||
assert_eq!(nearest_choice(&BITRATE_CHOICES, 0), 0, "automatic");
|
||||
assert_eq!(nearest_choice(&BITRATE_CHOICES, 3000), 1);
|
||||
assert_eq!(nearest_choice(&BITRATE_CHOICES, 55_000), 7);
|
||||
assert_eq!(nearest_choice(&BITRATE_CHOICES, 120_000), 7);
|
||||
assert_eq!(parse_positive(" 144 "), Some(144));
|
||||
assert_eq!(parse_positive("0"), None);
|
||||
assert_eq!(parse_positive("fast"), None);
|
||||
|
||||
Reference in new issue
Block a user