New crate voelin-ui-vm with no UI toolkit in its tree: ImageRef (Arc<ImageSource>: File, Rgba, Svg, Memory, None, with size()), Rgb for colours, list::diff(old, new) -> Changes (updates, removals and insertions by index) and the bridge structs as plain Clone + PartialEq values (the 51 of bridge.slint without the account's two, and the 10 of studio-bridge.slint). Strings are Arc<str>, lists Vec. voelin-ui keeps the temporary seam: From impls between every bridge struct and its Slint twin (bind/convert), and bind/rows.rs, which applies Changes to a VecModel and converts only the rows that changed. The viewer's quality list is the first model on it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
196 lines
5.4 KiB
Rust
196 lines
5.4 KiB
Rust
//! The Stream Studio's structs: the plain counterparts of
|
||
//! `crates/voelin-ui/ui/studio-bridge.slint`, as [`crate::bridge`] has those of
|
||
//! `bridge.slint`.
|
||
|
||
use std::sync::Arc;
|
||
|
||
use crate::image::ImageRef;
|
||
|
||
/// A scene of the studio.
|
||
#[derive(Clone, Debug, Default, PartialEq)]
|
||
pub struct StudioScene {
|
||
pub id: i32,
|
||
pub name: Arc<str>,
|
||
/// Its sources, front first: "Screen + Camera + Text".
|
||
pub detail: Arc<str>,
|
||
/// Composited now (the live scene).
|
||
pub live: bool,
|
||
/// The kind of its front-most source (for the icon).
|
||
pub kind: Arc<str>,
|
||
}
|
||
|
||
/// A source of the live scene, front first.
|
||
#[derive(Clone, Debug, Default, PartialEq)]
|
||
pub struct StudioSource {
|
||
pub id: i32,
|
||
pub name: Arc<str>,
|
||
/// screen, window, portal, camera, image, text, colour, pattern
|
||
pub kind: Arc<str>,
|
||
pub visible: bool,
|
||
pub locked: bool,
|
||
/// keep, blur, image, colour
|
||
pub background: Arc<str>,
|
||
/// Why it shows nothing ("" while it works).
|
||
pub error: Arc<str>,
|
||
/// "1920×1080 · 60 fps"
|
||
pub info: Arc<str>,
|
||
/// At the front or the back (cannot move further).
|
||
pub front: bool,
|
||
pub back: bool,
|
||
}
|
||
|
||
/// An audio source of the stream (`stream.audio_sources`).
|
||
#[derive(Clone, Debug, Default, PartialEq)]
|
||
pub struct StudioAudio {
|
||
pub name: Arc<str>,
|
||
/// "Elgato Wave:3", the application...
|
||
pub detail: Arc<str>,
|
||
/// microphone, desktop, app, window, tone
|
||
pub kind: Arc<str>,
|
||
pub gain_db: f32,
|
||
pub muted: bool,
|
||
/// The meter in dBFS, after the gain.
|
||
pub level: f32,
|
||
/// Why it captures nothing.
|
||
pub error: Arc<str>,
|
||
}
|
||
|
||
/// A simulcast layer (`stream.layers`) as typed: any numbers.
|
||
#[derive(Clone, Debug, Default, PartialEq)]
|
||
pub struct StudioLayer {
|
||
/// "1280x720"; empty: `scale` of the output.
|
||
pub size: Arc<str>,
|
||
pub scale: Arc<str>,
|
||
/// Frame-rate cap; empty: the output's.
|
||
pub fps: Arc<str>,
|
||
/// kbit/s.
|
||
pub bitrate: Arc<str>,
|
||
/// kbit/s a viewer needs for this layer.
|
||
pub min_bitrate: Arc<str>,
|
||
}
|
||
|
||
/// A viewer of the studio's stream.
|
||
#[derive(Clone, Debug, Default, PartialEq)]
|
||
pub struct StudioViewer {
|
||
pub client: i32,
|
||
pub name: Arc<str>,
|
||
/// requested, connecting, connected
|
||
pub state: Arc<str>,
|
||
}
|
||
|
||
/// An entry of a picker (screens, windows, cameras, audio sources).
|
||
#[derive(Clone, Debug, Default, PartialEq)]
|
||
pub struct StudioPick {
|
||
pub name: Arc<str>,
|
||
pub detail: Arc<str>,
|
||
/// For the icon: monitor, window, portal, camera, microphone, desktop, app, tone
|
||
pub kind: Arc<str>,
|
||
/// The application's own icon (audio), if it has one.
|
||
pub icon: ImageRef,
|
||
/// Already mixed in (audio): picking it again takes it out.
|
||
pub selected: bool,
|
||
}
|
||
|
||
/// The header, the preview's badges and the bottom bar.
|
||
#[derive(Clone, Debug, Default, PartialEq)]
|
||
pub struct StudioStatus {
|
||
/// The engine runs (preview, mixer, replay buffer).
|
||
pub running: bool,
|
||
/// "Chill Zone • Starfall Community"; empty without a destination.
|
||
pub destination: Arc<str>,
|
||
/// 0: not live, 1: poor, 2: fair, 3: good, 4: excellent.
|
||
pub quality: i32,
|
||
pub quality_text: Arc<str>,
|
||
/// "1080p • 60 FPS • 8,250 kbps"
|
||
pub format: Arc<str>,
|
||
/// The numbers behind it, for the info button.
|
||
pub details: Arc<str>,
|
||
pub live: bool,
|
||
/// Going live: waiting for the server.
|
||
pub starting: bool,
|
||
/// "00:12:34"
|
||
pub elapsed: Arc<str>,
|
||
pub viewers: i32,
|
||
pub participants: i32,
|
||
pub can_go_live: bool,
|
||
/// Why Go Live is off, or what goes wrong.
|
||
pub hint: Arc<str>,
|
||
pub recording: bool,
|
||
pub recorded: Arc<str>,
|
||
/// The replay buffer's window (0: off) and what it holds now.
|
||
pub replay_seconds: i32,
|
||
pub replay_held: Arc<str>,
|
||
pub output_width: i32,
|
||
pub output_height: i32,
|
||
pub fps: i32,
|
||
pub detached: bool,
|
||
/// A window of its own is possible (not on Android).
|
||
pub can_detach: bool,
|
||
/// The live scene shows a screen, a camera, a window (the phone's cards).
|
||
pub screen_shown: bool,
|
||
pub camera_shown: bool,
|
||
pub window_shown: bool,
|
||
}
|
||
|
||
/// The stream settings panel (`studio.stream`, `stream.bitrate_kbps`).
|
||
#[derive(Clone, Debug, Default, PartialEq)]
|
||
pub struct StudioForm {
|
||
pub destination: i32,
|
||
pub title: Arc<str>,
|
||
pub game: Arc<str>,
|
||
pub message: Arc<str>,
|
||
pub show_viewers: bool,
|
||
pub show_chat: bool,
|
||
pub show_now_playing: bool,
|
||
pub audio: bool,
|
||
/// kbit/s of the stream without layers, as typed.
|
||
pub bitrate: Arc<str>,
|
||
}
|
||
|
||
/// The source properties dialog (also for adding text, colour and image
|
||
/// sources: `id` -1). Numbers as typed.
|
||
#[derive(Clone, Debug, Default, PartialEq)]
|
||
pub struct StudioSourceForm {
|
||
pub id: i32,
|
||
pub name: Arc<str>,
|
||
pub kind: Arc<str>,
|
||
pub x: Arc<str>,
|
||
pub y: Arc<str>,
|
||
/// Empty: the source's own size times `scale`.
|
||
pub width: Arc<str>,
|
||
pub height: Arc<str>,
|
||
pub scale: Arc<str>,
|
||
/// contain, cover, stretch
|
||
pub fit: Arc<str>,
|
||
pub crop_left: Arc<str>,
|
||
pub crop_top: Arc<str>,
|
||
pub crop_right: Arc<str>,
|
||
pub crop_bottom: Arc<str>,
|
||
/// Percent.
|
||
pub opacity: f32,
|
||
pub locked: bool,
|
||
pub visible: bool,
|
||
/// keep, blur, image, colour
|
||
pub background: Arc<str>,
|
||
/// Blur radius in percent of the picture's height.
|
||
pub blur: Arc<str>,
|
||
pub background_path: Arc<str>,
|
||
pub background_colour: Arc<str>,
|
||
/// Text, colour ("#rrggbb" or "#rrggbbaa") and image sources.
|
||
pub text: Arc<str>,
|
||
pub text_size: Arc<str>,
|
||
pub colour: Arc<str>,
|
||
pub path: Arc<str>,
|
||
pub mirror: bool,
|
||
}
|
||
|
||
/// The studio settings dialog (`studio.*` keys and the preview).
|
||
#[derive(Clone, Debug, Default, PartialEq)]
|
||
pub struct StudioSettingsForm {
|
||
pub replay_seconds: Arc<str>,
|
||
pub replay_memory: Arc<str>,
|
||
pub recording_dir: Arc<str>,
|
||
pub preview_width: Arc<str>,
|
||
pub preview_fps: Arc<str>,
|
||
}
|