ui: stream cards show the streamer's avatar on a painted scene

TeamSpeak streams carry no thumbnail, and a peek would be a join request
the streamer sees, so a stream card not being watched now shows the
streamer: their avatar, ringed, with what they share, on the art scene
tinted with their colour (Art moves from home.slint to components). The
compact rows and the phone's Activity cards show the avatar too, and our
own stream from the Stream Studio shows the studio's picture while live.
StreamItem gets avatar, initials, tint and studio; the kind label is the
pure vm::streams::kind_label, used by Home as well.

In the demo, the studio going live announces our stream, and studio:live
starts the studio itself, so studio:live,server,voice shows the card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
This commit is contained in:
Claude committed 2026-10-08 07:21:20 +00:00
1 parent 26c7d9c97c
commit e1b4a207c5
14 files changed
+254 -72

No files matched your search

+3 -1
View File
@@ -50,7 +50,9 @@
//! `integrations`, `advanced` (5-10);
//! `studio[:<what>]`: the Stream Studio (with `VOELIN_DEMO_UI` a demo
//! studio from synthetic sources), `studio:window` in a window of its own,
//! `studio:live` going live, `studio:record`, or a dialog: `studio:source`,
//! `studio:live` going live (also with a screen opened after it:
//! `studio:live,server,voice` shows our stream's card with the studio's
//! picture), `studio:record`, or a dialog: `studio:source`,
//! `studio:audio`, `studio:camera`, `studio:scene`, `studio:settings`.
//! A screenshot also saves the studio's window (`<name>-window.png`) and
//! draws it over the main window.
+2 -16
View File
@@ -24,12 +24,6 @@ pub(crate) enum Happening {
News(i64),
}
/// "screen" → "Screen".
fn kind_label(kind: &str) -> String {
let mut chars = kind.chars();
chars.next().map(|c| c.to_uppercase().chain(chars).collect()).unwrap_or_default()
}
impl App {
/// Streams on our servers: those the server lists (any channel; we can
/// watch them at once), the gateways' directories, and clients flagged
@@ -75,13 +69,7 @@ impl App {
let mut room = item(s.id.clone(), title, Some(s.streamer.0), None, name);
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",
voelin_core::stream::StreamKind::Window => "Window",
voelin_core::stream::StreamKind::Camera => "Camera",
voelin_core::stream::StreamKind::Other(_) => "",
}
.into();
room.kind = vm::streams::kind_label(&s.kind).into();
room.watchable = view.state.own_client != Some(s.streamer.0);
covered.push(s.streamer.0);
rooms.push(room);
@@ -105,7 +93,7 @@ impl App {
);
room.channel = channel_of(e.channel).into();
room.viewers = e.viewers.map_or(0, |v| v as i32);
room.kind = kind_label(&e.kind).into();
room.kind = vm::streams::directory_kind_label(&e.kind).into();
covered.extend(e.client_id);
rooms.push(room);
}
@@ -384,7 +372,5 @@ mod tests {
assert!(items.iter().any(|i| i.clip && i.detail.starts_with("2 B")));
assert!(recordings_in(&dir.join("missing")).is_empty());
std::fs::remove_dir_all(&dir).unwrap();
assert_eq!(kind_label("screen"), "Screen");
assert_eq!(kind_label(""), "");
}
}
+13 -14
View File
@@ -11,7 +11,7 @@ use voelin_core::settings::{
AudioSourceSetting, STREAM_AUDIO_SOURCES, STREAM_BITRATE_KBPS, STREAM_FPS,
};
use voelin_core::stream::{
EndReason, LayerId, LayerSpec, LeaveReason, StreamKind, StreamSetup, ViewerInfo, ViewerState,
EndReason, LayerId, LayerSpec, LeaveReason, StreamSetup, ViewerInfo, ViewerState,
};
use voelin_core::{Command, Event, StreamState, WatchState};
@@ -295,29 +295,30 @@ impl App {
let own_channel = view.state.own_channel;
let mut streams: Vec<_> = view.streams.iter().collect();
streams.sort_by_key(|s| view.channel_of(s.streamer.0) != own_channel);
// Our own stream from the studio shows its preview.
let studio = current.is_some_and(|c| self.studio_streams_to(c));
for s in streams {
let watching = self
.watch
.as_ref()
.is_some_and(|w| w.session == current && w.stream_id == s.id && !w.ended);
let own = view.state.own_client == Some(s.streamer.0);
items.push(StreamItem {
id: s.id.clone().into(),
name: s.name.clone().into(),
streamer: view.nickname(s.streamer.0).into(),
channel: view.other_channel_name(s.streamer.0).into(),
streamer_id: i32::from(s.streamer.0),
viewers: viewer_count(view, &s.id).unwrap_or(0) as i32,
audio: s.audio,
watching,
own: view.state.own_client == Some(s.streamer.0),
kind: match s.kind {
StreamKind::Screen => "Screen",
StreamKind::Window => "Window",
StreamKind::Camera => "Camera",
StreamKind::Other(_) => "",
}
.into(),
own,
studio: own && studio,
kind: crate::vm::streams::kind_label(&s.kind).into(),
bitrate: bitrate_text(s.bitrate).into(),
..crate::vm::streams::streamer(
&view.nickname(s.streamer.0),
view.avatar(s.streamer.0),
)
});
}
// Streams that started before we joined, or in another channel:
@@ -329,10 +330,9 @@ impl App {
if c.streaming == Some(true) && !announced && view.state.own_client != Some(c.id) {
items.push(StreamItem {
name: c.nickname.clone().into(),
streamer: c.nickname.clone().into(),
channel: view.other_channel_name(c.id).into(),
streamer_id: i32::from(c.id),
..StreamItem::default()
..crate::vm::streams::streamer(&c.nickname, view.avatar(c.id))
});
}
}
@@ -341,11 +341,10 @@ impl App {
items.push(StreamItem {
id: "demo".into(),
name: "Test pattern".into(),
streamer: "local preview".into(),
audio: false,
watching: self.watch.as_ref().is_some_and(|w| w.session.is_none() && !w.ended),
own: false,
..StreamItem::default()
..crate::vm::streams::streamer("local preview", None)
});
}
bridge.set_streams_available(self.demo || view.is_some_and(|v| v.streams_available()));
+34 -1
View File
@@ -36,7 +36,9 @@ use voelin_core::settings::{
STREAM_BITRATE_KBPS, STREAM_LAYERS, STUDIO_RECORDING_DIR, STUDIO_REPLAY_MEMORY_MB,
STUDIO_REPLAY_SECONDS, STUDIO_SCENES, Settings, layer_specs,
};
use voelin_core::stream::{EndReason, LayerSpec, StreamSetup, ViewerInfo, ViewerState};
use voelin_core::stream::{
EndReason, LayerSpec, StreamInfo, StreamKind, StreamSetup, ViewerInfo, ViewerState,
};
use voelin_core::studio::scene::{
Align, Background, Colour, Crop, Fit, Scene, Scenes, Source, SourceKind, Transform,
};
@@ -1998,6 +2000,7 @@ impl App {
pub(crate) fn studio_end(&mut self) {
let Some(out) = &self.studio.stream else { return };
if self.demo_ui {
self.studio_demo_announce(false);
self.studio_ended(None);
} else {
self.engine.send(Command::StopStream { session: out.session as u64 });
@@ -2170,6 +2173,12 @@ impl App {
match what {
"" => {}
"window" => self.studio_detach(),
// Started here: a screen opened after it (`studio:live,server`)
// leaves the studio page before it is drawn, which starts it.
"live" => {
self.studio.dev.push(what.into());
self.studio_open();
}
other => self.studio.dev.push(other.into()),
}
}
@@ -2245,6 +2254,30 @@ impl App {
viewer(6, ViewerState::Requested, 0),
];
}
self.studio_demo_announce(true);
self.studio_now_live();
}
/// VOELIN_DEMO_UI: the sample server announces our stream, or its end,
/// as a server would (the voice view shows its card).
fn studio_demo_announce(&mut self, live: bool) {
let Some(session) = self.studio.stream.as_ref().map(|s| s.session) else { return };
let name = stream_name(&self.studio.ui);
let audio = self.studio.ui.audio;
let Some(view) = self.sessions.get_mut(&session) else { return };
view.streams.retain(|s| s.id != "demo-studio");
if live && let Some(own) = view.state.own_client {
view.streams.push(StreamInfo {
id: "demo-studio".into(),
streamer: tsclientlib::ClientId(own),
name,
kind: StreamKind::Screen,
bitrate: 8000,
viewer_limit: 0,
audio,
viewers: Some(3),
});
}
self.refresh_streams();
}
}
+1
View File
@@ -10,5 +10,6 @@ pub mod home;
pub mod list;
pub mod servers;
pub mod social;
pub mod streams;
pub mod studio;
pub mod tree;
+69
View File
@@ -0,0 +1,69 @@
//! Streams on the voice view, the phone's Activity tab and Home: what is
//! shared, and who shares it.
use std::path::PathBuf;
use voelin_core::stream::StreamKind;
use crate::app::StreamItem;
use crate::vm::avatar;
/// "Screen", "Window", "Camera"; "" for a kind we do not know.
pub fn kind_label(kind: &StreamKind) -> &'static str {
match kind {
StreamKind::Screen => "Screen",
StreamKind::Window => "Window",
StreamKind::Camera => "Camera",
StreamKind::Other(_) => "",
}
}
/// A gateway directory's kind as a label: "screen" → "Screen".
pub fn directory_kind_label(kind: &str) -> String {
let mut chars = kind.chars();
chars.next().map(|c| c.to_uppercase().chain(chars).collect()).unwrap_or_default()
}
/// A stream with its streamer: the name, and the avatar as the members
/// show it (the picture from the engine's cache, else the initials on the
/// name's colour). The caller fills in the rest.
pub fn streamer(name: &str, picture: Option<&PathBuf>) -> StreamItem {
StreamItem {
streamer: name.into(),
initials: avatar::initials(name).into(),
tint: avatar::tint(name),
avatar: avatar::image(picture),
..StreamItem::default()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn kinds_have_labels() {
assert_eq!(kind_label(&StreamKind::Screen), "Screen");
assert_eq!(kind_label(&StreamKind::Window), "Window");
assert_eq!(kind_label(&StreamKind::Camera), "Camera");
assert_eq!(kind_label(&StreamKind::Other(9)), "");
assert_eq!(kind_label(&StreamKind::from_u8(2)), "Camera");
}
#[test]
fn directory_kinds_are_capitalised() {
assert_eq!(directory_kind_label("screen"), "Screen");
assert_eq!(directory_kind_label("Camera"), "Camera");
assert_eq!(directory_kind_label(""), "");
}
#[test]
fn streamers_look_as_in_the_members() {
let item = streamer("Nova Star", None);
assert_eq!(item.streamer, "Nova Star");
assert_eq!(item.initials, "NS");
assert_eq!(item.tint, avatar::tint("Nova Star"));
assert_eq!(item.avatar.size(), slint::Image::default().size());
assert!(item.id.is_empty() && !item.own && !item.studio);
}
}