From 1b1f7087c23e6f0f423b273f8ef8557e0221a74d Mon Sep 17 00:00:00 2001 From: selikhov Date: Sun, 4 Oct 2026 10:19:54 +0300 Subject: [PATCH] voelin-ui: 60 Mbit/s, 8K and 320 fps in the new settings pages Wave 4B's settings pages arrived with their own stream controls, written for the old limits: the Video page's bitrate slider stopped at 20 Mbit/s, its frame rates at 120 and its quality presets at 1440p, and with the automatic bitrate (0, now the default) any change on that page stored a bitrate of 1 kbit/s (`form.bitrate.round().max(1.0)`), while the Streaming page could not set the automatic bitrate back. Kept 4B's layout and put the controls into it: frame rates up to 320, quality presets 4K and 8K (`PRESETS`), the slider up to 60 Mbit/s with the field empty (and a note) for the automatic bitrate, which a preset turns into the automatic bitrate of its size and the frame rate (`preset_layers`, tested); the Streaming page takes empty, 0 or "auto" as automatic and says so. Co-Authored-By: Claude Opus 5.5 --- crates/voelin-ui/src/settings_pages.rs | 50 ++++++++++++++----- .../voelin-ui/ui/screens/settings-pages.slint | 2 +- crates/voelin-ui/ui/screens/settings.slint | 39 ++++++++++++--- docs/ui.md | 2 +- 4 files changed, 70 insertions(+), 23 deletions(-) diff --git a/crates/voelin-ui/src/settings_pages.rs b/crates/voelin-ui/src/settings_pages.rs index b4f41aa..ca2f50d 100644 --- a/crates/voelin-ui/src/settings_pages.rs +++ b/crates/voelin-ui/src/settings_pages.rs @@ -12,6 +12,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use slint::{ComponentHandle, Model, SharedString}; use tracing::warn; +use voelin_core::media::auto_bitrate; use voelin_core::settings::{ AudioSourceKindSetting, AudioSourceSetting, BlockMode, CACHE_FETCH_IMAGES, CACHE_MAX_MB, CHAT_DEDUPE_TOLERANCE_MS, CHAT_HISTORY_PAGE, CHAT_RETENTION_DAYS, CHAT_STORE_HISTORY, @@ -39,7 +40,8 @@ use crate::settings::{ use crate::social::{allowed_index, allowed_of}; /// Sizes of the stream quality presets (Auto: the source's size). -const PRESETS: [(u32, u32); 3] = [(1280, 720), (1920, 1080), (2560, 1440)]; +const PRESETS: [(u32, u32); 5] = + [(1280, 720), (1920, 1080), (2560, 1440), (3840, 2160), (7680, 4320)]; /// An identity whose level is being raised. pub(crate) struct Improving { @@ -109,6 +111,22 @@ pub(crate) fn layer_of(item: &LayerItem, base: &LayerSetting) -> Option Option> { + match usize::try_from(quality).ok()? { + 0 => Some(Vec::new()), + q => PRESETS.get(q - 1).map(|&(width, height)| { + let bitrate = match kbps { + 0 => auto_bitrate(width, height, fps), + kbps => u64::from(kbps) * 1000, + }; + vec![LayerSetting { size: Some((width, height)), bitrate, ..LayerSetting::default() }] + }), + } +} + pub(crate) fn quality_of(layers: &[LayerSetting]) -> i32 { match layers { [] => 0, @@ -401,21 +419,15 @@ impl App { if self.prefs.get(&STREAM_PERMISSIONS) != permissions { self.put(&STREAM_PERMISSIONS, permissions); } - let bitrate = form.bitrate.round().max(1.0) as u32; + // 0: automatic. + let bitrate = form.bitrate.round().max(0.0) as u32; if self.prefs.get(&STREAM_BITRATE_KBPS) != bitrate { self.put(&STREAM_BITRATE_KBPS, bitrate); } - // A preset: one layer of that size at the bitrate; Auto: none. + // A preset: one layer of that size at the bitrate (an automatic one + // for that size and the frame rate); Auto: none. let layers = self.prefs.get(&STREAM_LAYERS); - let wanted = match form.quality { - 0 => Some(Vec::new()), - q @ 1..=3 => Some(vec![LayerSetting { - size: Some(PRESETS[q as usize - 1]), - bitrate: u64::from(bitrate) * 1000, - ..LayerSetting::default() - }]), - _ => None, - }; + let wanted = preset_layers(form.quality, bitrate, self.prefs.get(&STREAM_FPS)); if let Some(wanted) = wanted.filter(|w| *w != layers) { self.put(&STREAM_LAYERS, wanted); } @@ -426,7 +438,10 @@ impl App { if let Some(fps) = crate::settings::parse_positive(&form.fps) { self.put(&STREAM_FPS, fps); } - if let Some(bitrate) = crate::settings::parse_positive(&form.bitrate) { + // Nothing, 0 or "auto": automatic. + let bitrate = form.bitrate.trim(); + let auto = bitrate.is_empty() || bitrate == "0" || bitrate.eq_ignore_ascii_case("auto"); + if let Some(bitrate) = crate::settings::parse_positive(bitrate).or(auto.then_some(0)) { self.put(&STREAM_BITRATE_KBPS, bitrate); } self.put(&STREAM_CODEC, codec_of(form.codec)); @@ -1377,7 +1392,16 @@ mod tests { assert_eq!(quality_of(&[]), 0); let layer = |size| LayerSetting { size: Some(size), ..LayerSetting::default() }; assert_eq!(quality_of(&[layer((1920, 1080))]), 2); + assert_eq!(quality_of(&[layer((3840, 2160))]), 4); + assert_eq!(quality_of(&[layer((7680, 4320))]), 5); assert_eq!(quality_of(&[layer((800, 600))]), -1); + // A preset at the bitrate, or the automatic one of its size and rate. + let one = |l: Option>| l.map(|l| (l[0].size, l[0].bitrate)); + assert_eq!(one(preset_layers(5, 60_000, 30)), Some((Some((7680, 4320)), 60_000_000))); + assert_eq!(one(preset_layers(4, 0, 60)), Some((Some((3840, 2160)), 59_719_680))); + assert_eq!(preset_layers(0, 0, 60), Some(Vec::new())); + assert_eq!(preset_layers(-1, 0, 60), None); + assert_eq!(preset_layers(6, 0, 60), None); assert_eq!(quality_of(&[layer((1280, 720)), layer((640, 360))]), -1); for i in 0..5 { assert_eq!(codec_index(codec_of(i)), i); diff --git a/crates/voelin-ui/ui/screens/settings-pages.slint b/crates/voelin-ui/ui/screens/settings-pages.slint index dd19d6c..40ed831 100644 --- a/crates/voelin-ui/ui/screens/settings-pages.slint +++ b/crates/voelin-ui/ui/screens/settings-pages.slint @@ -620,7 +620,7 @@ export component StreamingSection inherits VerticalLayout { } NumberRow { text: @tr("Video bitrate"); - description: @tr("Of the single layer, when no layers are set below."); + description: @tr("Of the single layer, when no layers are set below. 0: automatic, from the size and frame rate, up to 60 Mbit/s."); value: Bridge.streaming.bitrate; unit: "kbit/s"; accepted(t) => { diff --git a/crates/voelin-ui/ui/screens/settings.slint b/crates/voelin-ui/ui/screens/settings.slint index eebcf13..9fb9128 100644 --- a/crates/voelin-ui/ui/screens/settings.slint +++ b/crates/voelin-ui/ui/screens/settings.slint @@ -411,11 +411,11 @@ component VideoCard inherits Card { Field { label: @tr("Frame Rate"); Select { - model: ["15 FPS", "24 FPS", "30 FPS", "60 FPS", "120 FPS"]; - current-index: Bridge.video.fps == "15" ? 0 : Bridge.video.fps == "24" ? 1 : Bridge.video.fps == "30" ? 2 : Bridge.video.fps == "120" ? 4 : 3; + model: ["15 FPS", "24 FPS", "30 FPS", "60 FPS", "120 FPS", "144 FPS", "240 FPS", "320 FPS"]; + current-index: Bridge.video.fps == "15" ? 0 : Bridge.video.fps == "24" ? 1 : Bridge.video.fps == "30" ? 2 : Bridge.video.fps == "120" ? 4 : Bridge.video.fps == "144" ? 5 : Bridge.video.fps == "240" ? 6 : Bridge.video.fps == "320" ? 7 : 3; label: @tr("Frame rate"); selected => { - Bridge.video.fps = self.current-index == 0 ? "15" : self.current-index == 1 ? "24" : self.current-index == 2 ? "30" : self.current-index == 4 ? "120" : "60"; + Bridge.video.fps = ["15", "24", "30", "60", "120", "144", "240", "320"][self.current-index]; Bridge.video-changed(Bridge.video); } } @@ -544,6 +544,24 @@ component QualityCard inherits Card { Bridge.video-changed(Bridge.video); } } + PresetTile { + text: "4K"; + detail: "2160p"; + selected: Bridge.video.quality == 4; + clicked => { + Bridge.video.quality = 4; + Bridge.video-changed(Bridge.video); + } + } + PresetTile { + text: "8K"; + detail: "4320p"; + selected: Bridge.video.quality == 5; + clicked => { + Bridge.video.quality = 5; + Bridge.video-changed(Bridge.video); + } + } } if Bridge.video.quality < 0: Text { text: @tr("Your own simulcast layers are set (Streaming page); a preset replaces them."); @@ -562,7 +580,8 @@ component QualityCard inherits Card { y: (parent.height - self.height) / 2; horizontal-stretch: 1; minimum: 500; - maximum: 20000; + // 60 Mbit/s; any number can be typed, and 0 is automatic. + maximum: 60000; step: 250; value: Bridge.video.bitrate; label: @tr("Stream bitrate"); @@ -573,12 +592,14 @@ component QualityCard inherits Card { } TextField { width: 80px; - text: round(Bridge.video.bitrate); + // Empty: automatic (from the size and frame rate, up to 60 Mbit/s). + text: Bridge.video.bitrate == 0 ? "" : round(Bridge.video.bitrate); + placeholder: @tr("auto"); input-type: number; label: @tr("Stream bitrate in kbit/s"); accepted(t) => { - if t.is-float() && t.to-float() >= 1 { - Bridge.video.bitrate = t.to-float(); + if t == "" || (t.is-float() && t.to-float() >= 0) { + Bridge.video.bitrate = t == "" ? 0 : t.to-float(); Bridge.video-changed(Bridge.video); } } @@ -598,7 +619,9 @@ component QualityCard inherits Card { y: (parent.height - self.height) / 2; } Text { - text: @tr("Estimated Upload Usage: ~{} GB per hour", round(Bridge.video.bitrate * 3600 / 8 / 100000) / 10); + text: Bridge.video.bitrate == 0 + ? @tr("Automatic: from the size and frame rate, up to 60 Mbit/s (~27 GB per hour)") + : @tr("Estimated Upload Usage: ~{} GB per hour", round(Bridge.video.bitrate * 3600 / 8 / 100000) / 10); color: Theme.text-muted; font-size: Theme.font-sm; } diff --git a/docs/ui.md b/docs/ui.md index a67bee6..6d739a6 100644 --- a/docs/ui.md +++ b/docs/ui.md @@ -180,7 +180,7 @@ Settings sections (`settings:
`): | `account` | The identity in use (nickname, TeamSpeak 3 and 6 unique ids, security level) and why there is no myTeamSpeak sign-in | | `profiles` (also `identities`) | Identities with where they came from: rename, use as default (the store's default, `Store::set_default_identity`), export as a TeamSpeak 3 .ini, delete, raise the security level on every core; the import of the official clients' identities on start (`identity.import_from_teamspeak`) and by hand from their settings and .ini files (key material is never shown); the identity per server | | `appearance` | Theme, text size, the phone layout's width, the image cache | -| `voice` | Microphone (device, test, level, noise suppression, echo cancellation, automatic gain), output (device, test sound, volume), streaming permissions, camera (device, preview with the background effect), video settings (resolution, frame rate, codec, hardware acceleration, mirror), stream quality presets with free bitrate entry and the upload it takes | +| `voice` | Microphone (device, test, level, noise suppression, echo cancellation, automatic gain), output (device, test sound, volume), streaming permissions, camera (device, preview with the background effect), video settings (resolution, frame rate 15 to 320 fps, codec, hardware acceleration, mirror), stream quality presets (Auto, 720p to 8K) with free bitrate entry (slider up to 60 Mbit/s, empty: automatic) and the upload it takes | | `streaming` | Frame rate, bitrate, codec, capture backend, simulcast layers, the stream's audio sources (desktop without Voelin, applications, the shared window's application, microphone; gain and mute each), recording and replay | | `devices` | Microphones, speakers, cameras and what can be shared | | `notifications` | Each kind of notification: off, in the app, on the desktop; a test notification |