From 66c07ea023f898a9068de3032475acfa0dc7bdbc Mon Sep 17 00:00:00 2001 From: selikhov Date: Sun, 4 Oct 2026 04:06:50 +0300 Subject: [PATCH] Decoders next to the encoders; watch streams of any channel from home The engine now decodes with FFmpeg's decoders, hardware first, and has two settings for it (stream.hardware_decoding, stream.decoder_backend). Integrations lists the decoders under the encoders, each codec's in the order they are tried, with what works and why the rest does not; the Advanced page sets the decoder and hardware decoding next to the encoder and hardware acceleration (whose description no longer claims the decoders). Streams of every channel are listed now, so a home live room names the streamer's channel, not ours, and watching one, or a friend's stream, goes through watch_client: at once from any channel, or when the lookup brings a stream that is not known yet. Only without voice on that server does a friend's Watch still join them first. The friends page's own pending watch, which waited for us to be in the streamer's channel, is gone; the development branch's pending watch does that job. Home's hint for no servers no longer asks for a nickname: the add-server dialog takes an address and an optional password now. Co-Authored-By: Claude Opus 5.5 --- crates/voelin-ui/src/home.rs | 20 ++-- crates/voelin-ui/src/settings_pages.rs | 57 +++++---- crates/voelin-ui/src/social.rs | 39 ++---- crates/voelin-ui/ui/bridge.slint | 5 + crates/voelin-ui/ui/screens/home.slint | 4 +- .../voelin-ui/ui/screens/settings-pages.slint | 111 ++++++++++++------ crates/voelin-ui/ui/screens/settings.slint | 4 +- 7 files changed, 135 insertions(+), 105 deletions(-) diff --git a/crates/voelin-ui/src/home.rs b/crates/voelin-ui/src/home.rs index cb39da8..6f4a9e9 100644 --- a/crates/voelin-ui/src/home.rs +++ b/crates/voelin-ui/src/home.rs @@ -26,8 +26,9 @@ fn kind_label(kind: &str) -> String { } impl App { - /// Streams on our servers: those in our channel (we can watch them at - /// once), the gateways' directories, and clients flagged streaming. + /// Streams on our servers: those the server lists (any channel; we can + /// watch them at once), the gateways' directories, and clients flagged + /// streaming. fn live_rooms(&self) -> Vec { let mut rooms = Vec::new(); for b in &self.bookmarks { @@ -68,7 +69,7 @@ impl App { let title = if s.name.is_empty() { format!("{name}'s stream") } else { s.name.clone() }; let mut room = item(s.id.clone(), title, Some(s.streamer.0), None, name); - room.channel = channel_of(view.state.own_channel).into(); + room.channel = channel_of(view.channel_of(s.streamer.0)).into(); room.viewers = view.stream_viewers.get(&s.id).map_or(0, |v| *v as i32); room.kind = match s.kind { voelin_core::stream::StreamKind::Screen => "Screen", @@ -212,16 +213,9 @@ impl App { .find(|e| e.id == id) .and_then(|e| e.client_id) .or_else(|| id.strip_prefix("client/").and_then(|c| c.parse().ok())); - let Some(uid) = - client.and_then(|c| view.presence.clients.get(&c)).and_then(|c| c.uid.clone()) - else { - self.set_status("Join the streamer's channel with voice to watch."); - return; - }; - if view.state.voice == VoiceState::Connected { - self.contact_action(&uid, "watch"); - } else { - self.set_status("Connect with voice and join the streamer's channel to watch."); + match client { + Some(client) if view.state.voice == VoiceState::Connected => self.watch_client(client), + _ => self.set_status("Connect with voice to watch."), } } diff --git a/crates/voelin-ui/src/settings_pages.rs b/crates/voelin-ui/src/settings_pages.rs index 3ad5f5b..d5410f1 100644 --- a/crates/voelin-ui/src/settings_pages.rs +++ b/crates/voelin-ui/src/settings_pages.rs @@ -17,10 +17,10 @@ use voelin_core::settings::{ CHAT_DEDUPE_TOLERANCE_MS, CHAT_HISTORY_PAGE, CHAT_RETENTION_DAYS, CHAT_STORE_HISTORY, CaptureChoice, CodecChoice, FILES_PROGRESS_MS, Key, LayerSetting, PRIVACY_BLOCK_MODE, PRIVACY_POKES, PRIVACY_PRIVATE_MESSAGES, SRTP_PROFILES, STREAM_AUDIO_SOURCES, - STREAM_BITRATE_KBPS, STREAM_CAPTURE_BACKEND, STREAM_CODEC, STREAM_ENCODER_BACKEND, STREAM_FPS, - STREAM_HARDWARE_ACCELERATION, STREAM_LAYERS, STREAM_PERMISSIONS, STREAM_SRTP_PROFILES, - STUDIO_RECORDING_DIR, STUDIO_REPLAY_MEMORY_MB, STUDIO_REPLAY_SECONDS, Source as SettingSource, - StreamPermissions, + STREAM_BITRATE_KBPS, STREAM_CAPTURE_BACKEND, STREAM_CODEC, STREAM_DECODER_BACKEND, + STREAM_ENCODER_BACKEND, STREAM_FPS, STREAM_HARDWARE_ACCELERATION, STREAM_HARDWARE_DECODING, + STREAM_LAYERS, STREAM_PERMISSIONS, STREAM_SRTP_PROFILES, STUDIO_RECORDING_DIR, + STUDIO_REPLAY_MEMORY_MB, STUDIO_REPLAY_SECONDS, Source as SettingSource, StreamPermissions, }; use voelin_core::{Command, GatewayRequest}; use voelin_gateway_proto::{Action, ConfigSource, PermRule, UniqueIds, feature}; @@ -304,6 +304,8 @@ impl App { bridge.set_advanced(AdvancedForm { encoder: p.get(&STREAM_ENCODER_BACKEND).into(), hardware: p.get(&STREAM_HARDWARE_ACCELERATION), + decoder: p.get(&STREAM_DECODER_BACKEND).into(), + hardware_decoding: p.get(&STREAM_HARDWARE_DECODING), store_history: p.get(&CHAT_STORE_HISTORY), history_page: p.get(&CHAT_HISTORY_PAGE).to_string().into(), dedupe_ms: p.get(&CHAT_DEDUPE_TOLERANCE_MS).to_string().into(), @@ -592,6 +594,10 @@ impl App { self.put(&STREAM_ENCODER_BACKEND, form.encoder.trim().to_owned()); } self.put(&STREAM_HARDWARE_ACCELERATION, form.hardware); + if !form.decoder.trim().is_empty() { + self.put(&STREAM_DECODER_BACKEND, form.decoder.trim().to_owned()); + } + self.put(&STREAM_HARDWARE_DECODING, form.hardware_decoding); self.put(&CHAT_STORE_HISTORY, form.store_history); if let Some(v) = number(&form.history_page) { self.put(&CHAT_HISTORY_PAGE, v as u32); @@ -863,25 +869,30 @@ impl App { } .into(), ); - let items: Vec = report - .encoders - .iter() - .map(|e| EncoderItem { - name: e.name.clone().into(), - api: e.api.clone().into(), - codec: format!("{:?}", e.codec).to_uppercase().into(), - hardware: e.hardware, - ok: e.status.is_ok(), - status: match (&e.status, e.rank) { - (Err(why), _) => why.clone(), - (Ok(()), Some(0)) => format!("{} · used first", e.api), - (Ok(()), Some(n)) => format!("{} · choice {}", e.api, n + 1), - (Ok(()), None) => format!("{} · not used", e.api), - } - .into(), - }) - .collect(); - bridge.set_encoders(model(items)); + // A decoder's entry is an encoder's (its rank: the place in its + // codec's ladder). + let items = |list: &[voelin_core::media::voelin_media::EncoderInfo]| { + let items: Vec = list + .iter() + .map(|e| EncoderItem { + name: e.name.clone().into(), + api: e.api.clone().into(), + codec: format!("{:?}", e.codec).to_uppercase().into(), + hardware: e.hardware, + ok: e.status.is_ok(), + status: match (&e.status, e.rank) { + (Err(why), _) => why.clone(), + (Ok(()), Some(0)) => format!("{} · used first", e.api), + (Ok(()), Some(n)) => format!("{} · choice {}", e.api, n + 1), + (Ok(()), None) => format!("{} · not used", e.api), + } + .into(), + }) + .collect(); + model(items) + }; + bridge.set_encoders(items(&report.encoders)); + bridge.set_decoders(items(&report.decoders)); } /// The screens and windows that can be shared (Devices). diff --git a/crates/voelin-ui/src/social.rs b/crates/voelin-ui/src/social.rs index 982f194..670dbaf 100644 --- a/crates/voelin-ui/src/social.rs +++ b/crates/voelin-ui/src/social.rs @@ -156,8 +156,6 @@ pub(crate) struct Social { pub found: Vec, /// Our unique ids (TeamSpeak 3 and 6 of every identity). pub own_uids: HashSet, - /// Watch a friend's stream once it shows (we moved to their channel). - pub pending_watch: Option<(i64, u16)>, /// The direct messages (`messages.rs`). pub dm: crate::messages::Dms, } @@ -552,22 +550,17 @@ impl App { } } - /// Watch someone's stream: in our channel at once, else move there - /// first and watch once it shows. + /// Watch someone's stream: from any channel of a server we are on with + /// voice (once the lookup brings it), else join them first and watch it + /// when it shows. fn watch_person(&mut self, spots: &[Spot]) { let Some(s) = spots.iter().find(|s| s.streaming).cloned() else { return }; self.show_server(s.session); - let view = &self.sessions[&s.session]; - let ours = view.state.own_channel == Some(s.channel); - match view.streams.iter().find(|st| st.streamer.0 == s.client) { - Some(stream) if ours => { - let id = stream.id.clone(); - self.watch_stream(id); - } - _ => { - self.social.pending_watch = Some((s.session, s.client)); - self.join_person(&[s]); - } + if s.voice { + self.watch_client(s.client); + } else { + self.pending_watch = Some((s.session, s.client)); + self.join_person(&[s]); } } @@ -590,21 +583,6 @@ impl App { }); } - /// The pending watch (see [`Self::watch_person`]) once its stream shows. - fn pending_watch(&mut self) { - let Some((session, client)) = self.social.pending_watch else { return }; - let Some(view) = self.sessions.get(&session) else { return }; - let ours = view.presence.clients.get(&client).map(|c| c.channel) == view.state.own_channel; - if let Some(stream) = view.streams.iter().find(|s| s.streamer.0 == client).filter(|_| ours) - { - let id = stream.id.clone(); - self.social.pending_watch = None; - if self.current == Some(session) { - self.watch_stream(id); - } - } - } - // The bell. /// Add a notification as the kind's setting says. @@ -903,7 +881,6 @@ impl App { pub(crate) fn social_refresh(&mut self, touched: Touched) { if touched.people { self.refresh_people(); - self.pending_watch(); } if touched.chats { self.ask_inboxes(); diff --git a/crates/voelin-ui/ui/bridge.slint b/crates/voelin-ui/ui/bridge.slint index 0420fdb..20b9c33 100644 --- a/crates/voelin-ui/ui/bridge.slint +++ b/crates/voelin-ui/ui/bridge.slint @@ -725,6 +725,9 @@ export struct RecordingItem { export struct AdvancedForm { encoder: string, hardware: bool, + // `stream.decoder_backend`, `stream.hardware_decoding`. + decoder: string, + hardware-decoding: bool, store-history: bool, history-page: string, dedupe-ms: string, @@ -1100,6 +1103,8 @@ export global Bridge { in property ffmpeg-status; in property zero-copy-status; in property <[EncoderItem]> encoders; + // The decoders, each codec's in the order they are tried. + in property <[EncoderItem]> decoders; in property encoders-loading; callback gateway-admin(int); callback config-set(string, string); diff --git a/crates/voelin-ui/ui/screens/home.slint b/crates/voelin-ui/ui/screens/home.slint index 7755af6..d37ef44 100644 --- a/crates/voelin-ui/ui/screens/home.slint +++ b/crates/voelin-ui/ui/screens/home.slint @@ -998,7 +998,7 @@ export component HomePage inherits Rectangle { action-clicked => { Nav.add-server(); } } if root.compact && Bridge.servers.length == 0: Text { - text: @tr("No servers yet. Add one with its address and your nickname."); + text: @tr("No servers yet. Add one with its address."); color: Theme.text-muted; font-size: Theme.font-sm; wrap: word-wrap; @@ -1060,7 +1060,7 @@ export component HomePage inherits Rectangle { action-clicked => { Nav.add-server(); } } if !root.compact && Bridge.servers.length == 0: Text { - text: @tr("No servers yet. Add one with its address and your nickname."); + text: @tr("No servers yet. Add one with its address."); color: Theme.text-muted; font-size: Theme.font-sm; wrap: word-wrap; diff --git a/crates/voelin-ui/ui/screens/settings-pages.slint b/crates/voelin-ui/ui/screens/settings-pages.slint index f8c966b..e99176c 100644 --- a/crates/voelin-ui/ui/screens/settings-pages.slint +++ b/crates/voelin-ui/ui/screens/settings-pages.slint @@ -5,7 +5,7 @@ import { Theme } from "../theme.slint"; import { Icons } from "../icons.slint"; -import { Bridge, IdentityItem, LayerItem, AudioSourceItem, ConfigItem, PermItem, SettingItem } from "../bridge.slint"; +import { Bridge, IdentityItem, LayerItem, AudioSourceItem, ConfigItem, PermItem, SettingItem, EncoderItem } from "../bridge.slint"; import { Nav, SettingsSection } from "../nav.slint"; import { Icon, Button, ButtonKind, IconButton, TextField, Field, Select, Toggle, ToggleRow, Slider, SegmentedTabs, Card, Divider, Chip, Banner, Spinner, SearchBox, ScrollView } from "../components/index.slint"; @@ -847,6 +847,40 @@ component PermRow inherits HorizontalLayout { } } +// An encoder or decoder: works or not, its codec, name and why. +component CodecRow inherits HorizontalLayout { + in property item; + spacing: Theme.space-3; + Icon { + source: root.item.ok ? Icons.circle-check : Icons.circle-x; + size: Theme.icon-sm; + tint: root.item.ok ? Theme.success : Theme.text-disabled; + y: (parent.height - self.height) / 2; + } + Text { + width: Nav.narrow ? 54px : 90px; + text: root.item.codec; + color: Theme.text; + font-weight: Theme.weight-medium; + vertical-alignment: center; + } + Text { + width: Nav.narrow ? 110px : 170px; + text: root.item.name + (root.item.hardware ? " · GPU" : ""); + color: Theme.text-secondary; + vertical-alignment: center; + overflow: elide; + } + Text { + text: root.item.status; + color: root.item.ok ? Theme.text-secondary : Theme.text-muted; + font-size: Theme.font-sm; + vertical-alignment: center; + horizontal-stretch: 1; + overflow: elide; + } +} + export component IntegrationsSection inherits VerticalLayout { alignment: start; spacing: Theme.space-5; @@ -937,7 +971,7 @@ export component IntegrationsSection inherits VerticalLayout { } } Card { - title: @tr("Video encoders"); + title: @tr("Video encoders and decoders"); icon: Icons.cpu; HorizontalLayout { spacing: Theme.space-3; @@ -965,36 +999,24 @@ export component IntegrationsSection inherits VerticalLayout { font-size: Theme.font-sm; wrap: word-wrap; } - for e in Bridge.encoders: HorizontalLayout { - spacing: Theme.space-3; - Icon { - source: e.ok ? Icons.circle-check : Icons.circle-x; - size: Theme.icon-sm; - tint: e.ok ? Theme.success : Theme.text-disabled; - y: (parent.height - self.height) / 2; - } - Text { - width: 90px; - text: e.codec; - color: Theme.text; - font-weight: Theme.weight-medium; - vertical-alignment: center; - } - Text { - width: 170px; - text: e.name + (e.hardware ? " · GPU" : ""); - color: Theme.text-secondary; - vertical-alignment: center; - overflow: elide; - } - Text { - text: e.status; - color: e.ok ? Theme.text-secondary : Theme.text-muted; - font-size: Theme.font-sm; - vertical-alignment: center; - horizontal-stretch: 1; - overflow: elide; - } + Text { + text: @tr("Encoders"); + color: Theme.text; + font-weight: Theme.weight-semibold; + } + for e in Bridge.encoders: CodecRow { + item: e; + } + Text { + text: @tr("Decoders"); + color: Theme.text; + font-weight: Theme.weight-semibold; + } + Hint { + text: @tr("Each codec's decoders in the order they are tried: when one fails the next takes over."); + } + for e in Bridge.decoders: CodecRow { + item: e; } } } @@ -1058,7 +1080,7 @@ export component AdvancedSection inherits VerticalLayout { alignment: start; spacing: Theme.space-5; Card { - title: @tr("Video encoding"); + title: @tr("Video encoding and decoding"); icon: Icons.cpu; Field { label: @tr("Encoder"); @@ -1074,13 +1096,34 @@ export component AdvancedSection inherits VerticalLayout { } ToggleRow { text: @tr("Hardware acceleration"); - description: @tr("GPU encoders and decoders where available"); + description: @tr("GPU encoders where available"); checked: Bridge.advanced.hardware; toggled(on) => { Bridge.advanced.hardware = on; Bridge.advanced-changed(Bridge.advanced); } } + Field { + label: @tr("Decoder"); + hint: @tr("auto, software, or the name of a decoder from Integrations; for streams watched from now on. Press Enter to apply."); + TextField { + text: Bridge.advanced.decoder; + label: @tr("Decoder backend"); + accepted(t) => { + Bridge.advanced.decoder = t; + Bridge.advanced-changed(Bridge.advanced); + } + } + } + ToggleRow { + text: @tr("Hardware decoding"); + description: @tr("GPU decoders where available, before the software ones"); + checked: Bridge.advanced.hardware-decoding; + toggled(on) => { + Bridge.advanced.hardware-decoding = on; + Bridge.advanced-changed(Bridge.advanced); + } + } } Card { title: @tr("Stream encryption"); diff --git a/crates/voelin-ui/ui/screens/settings.slint b/crates/voelin-ui/ui/screens/settings.slint index 54d7555..f46d292 100644 --- a/crates/voelin-ui/ui/screens/settings.slint +++ b/crates/voelin-ui/ui/screens/settings.slint @@ -99,7 +99,7 @@ export component SettingsNav inherits VerticalLayout { NavItem { icon: Icons.puzzle; text: @tr("Integrations"); - subtitle: @tr("Gateways, encoders"); + subtitle: @tr("Gateways, encoders, decoders"); selected: Nav.settings-section == SettingsSection.integrations; clicked => { Nav.open-settings(SettingsSection.integrations); } } @@ -1117,7 +1117,7 @@ export component SettingsPage inherits Rectangle { : s == SettingsSection.profiles ? @tr("Your identities: each is a unique id on every server.") : s == SettingsSection.devices ? @tr("Microphones, speakers, cameras and screens.") : s == SettingsSection.notifications ? @tr("What the bell and the desktop tell you.") - : s == SettingsSection.integrations ? @tr("Gateways of your servers and the video encoders here.") + : s == SettingsSection.integrations ? @tr("Gateways of your servers, the video encoders and decoders here.") : s == SettingsSection.advanced ? @tr("Encoding, encryption, history, cache, every setting.") : @tr("Theme, text size and layout. Changes apply at once."); accessible-role: AccessibleRole.groupbox;