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 <noreply@anthropic.com>
This commit is contained in:
1 parent
96819366f9
commit
a7d7234451
4 files changed
+70
-23
No files matched your search
@@ -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<LayerSet
|
||||
|
||||
/// The preset of a list of layers: 0 Auto (none), 1..3 a preset size, -1
|
||||
/// other layers.
|
||||
/// The layers of quality preset `quality` (0: none, the source's size;
|
||||
/// then [`PRESETS`]) at `kbps` (0: automatic, for the preset's size and
|
||||
/// `fps`); `None` for no preset (layers of one's own).
|
||||
fn preset_layers(quality: i32, kbps: u32, fps: u32) -> Option<Vec<LayerSetting>> {
|
||||
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<Vec<LayerSetting>>| 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);
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user