Merge the development branch: share menu, codec order, segmentation
Brings in the Share button's menu (Share screen / Stream Studio) and the removal of the separate Stream Studio button from the headers, the codecs every TeamSpeak client decodes ahead of H.264, the portal fix and person segmentation. The phone header keeps this branch's voice-channel button and hides the bell on the voice screen, and loses the Stream Studio button as the development branch wants. The studio's test table takes the segmentation rows and the Android camera row. MediaCodec follows the new codec order with no code change (Codecs orders every hardware factory's codecs); its description and docs/media.md now say so, including what that means on a phone without a hardware VP8, VP9 or AV1 encoder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
698e5f911e
35 files changed
+24436
-224
No files matched your search
@@ -420,7 +420,8 @@ impl App {
|
||||
let test_pattern = cfg!(debug_assertions)
|
||||
|| self.demo
|
||||
|| std::env::var("VOELIN_TEST_PATTERN").is_ok_and(|v| v == "1");
|
||||
let sources = match self.video.sources(test_pattern) {
|
||||
let restorable = self.settings.portal_restore_token.is_some();
|
||||
let sources = match self.video.sources(test_pattern, restorable) {
|
||||
Ok(sources) => {
|
||||
if self.share.is_none() {
|
||||
self.share_error.clear();
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::sync::Arc;
|
||||
use slint::{Image, Rgba8Pixel, SharedPixelBuffer};
|
||||
use tokio::runtime::Handle;
|
||||
use tracing::warn;
|
||||
use voelin_core::media::voelin_media::capture::SourceId;
|
||||
use voelin_core::media::voelin_media::capture::{CaptureSource, SourceId};
|
||||
use voelin_core::media::voelin_media::{Codec, Codecs, EncoderReport, VideoFrame, convert};
|
||||
use voelin_core::media::{
|
||||
self, AudioSourceSpec, EncoderPreference, Latest, LocalPreview, Streamer, StreamerConfig,
|
||||
@@ -63,7 +63,7 @@ pub(crate) struct Video {
|
||||
encoder: EncoderPreference,
|
||||
codec: Option<Codec>,
|
||||
/// Sources of the share dialog, by index.
|
||||
sources: Vec<(SourceId, String)>,
|
||||
sources: Vec<ShareEntry>,
|
||||
}
|
||||
|
||||
impl Video {
|
||||
@@ -199,8 +199,14 @@ impl Video {
|
||||
}
|
||||
|
||||
/// Screens and windows to share, as (name, detail); the test pattern too
|
||||
/// when asked for.
|
||||
pub fn sources(&mut self, test_pattern: bool) -> Result<Vec<(String, String)>, String> {
|
||||
/// when asked for. With `restorable` (a portal restore token from an
|
||||
/// earlier share) the portal comes twice: its dialog, which always asks,
|
||||
/// and the last choice again without the dialog.
|
||||
pub fn sources(
|
||||
&mut self,
|
||||
test_pattern: bool,
|
||||
restorable: bool,
|
||||
) -> Result<Vec<(String, String)>, String> {
|
||||
let mut error = None;
|
||||
let mut sources = match media::screen_sources() {
|
||||
Ok(list) => list,
|
||||
@@ -215,26 +221,9 @@ impl Video {
|
||||
if sources.is_empty() {
|
||||
return Err(error.unwrap_or_else(|| "Nothing to share was found.".into()));
|
||||
}
|
||||
self.sources = sources.iter().map(|s| (s.id.clone(), s.name.clone())).collect();
|
||||
Ok(sources
|
||||
.iter()
|
||||
.map(|s| {
|
||||
let name = match s.id {
|
||||
SourceId::Portal => "Choose via system dialog".to_owned(),
|
||||
_ => s.name.clone(),
|
||||
};
|
||||
let detail = match (&s.id, s.primary) {
|
||||
(SourceId::Monitor(_), true) => {
|
||||
format!("{} · primary", size_text(s.width, s.height))
|
||||
}
|
||||
(SourceId::Window(_), _) => {
|
||||
format!("window {}", size_text(s.width, s.height)).trim().to_owned()
|
||||
}
|
||||
_ => size_text(s.width, s.height),
|
||||
};
|
||||
(name, detail)
|
||||
})
|
||||
.collect())
|
||||
let (rows, entries) = share_rows(&sources, restorable);
|
||||
self.sources = entries;
|
||||
Ok(rows)
|
||||
}
|
||||
|
||||
/// Start capturing source `index` of [`Video::sources`]; `done` runs on
|
||||
@@ -246,7 +235,7 @@ impl Video {
|
||||
options: CaptureRequest,
|
||||
done: impl FnOnce(Result<Capture, String>) + Send + 'static,
|
||||
) {
|
||||
let Some((source, name)) = self.sources.get(index).cloned() else {
|
||||
let Some((source, name, restore)) = self.sources.get(index).cloned() else {
|
||||
done(Err("Pick something to share.".into()));
|
||||
return;
|
||||
};
|
||||
@@ -264,7 +253,8 @@ impl Video {
|
||||
encoder: self.encoder.clone(),
|
||||
audio: options.audio,
|
||||
audio_sources: options.audio_sources,
|
||||
restore_token: options.restore_token,
|
||||
// The portal skips its dialog with a token: only when asked to.
|
||||
restore_token: options.restore_token.filter(|_| restore),
|
||||
..StreamerConfig::default()
|
||||
};
|
||||
runtime.spawn(async move {
|
||||
@@ -368,6 +358,40 @@ fn deliver(
|
||||
}
|
||||
}
|
||||
|
||||
/// What a row of the share dialog starts: the source, its name, and whether
|
||||
/// to restore the portal's last choice instead of asking.
|
||||
type ShareEntry = (SourceId, String, bool);
|
||||
|
||||
/// The share dialog's rows (name, detail) for `sources`, and what each row
|
||||
/// starts (restoring only in the extra portal row with `restorable`).
|
||||
fn share_rows(
|
||||
sources: &[CaptureSource],
|
||||
restorable: bool,
|
||||
) -> (Vec<(String, String)>, Vec<ShareEntry>) {
|
||||
let mut rows = Vec::with_capacity(sources.len() + 1);
|
||||
let mut entries = Vec::with_capacity(sources.len() + 1);
|
||||
for s in sources {
|
||||
let name = match s.id {
|
||||
SourceId::Portal => "Choose via system dialog".to_owned(),
|
||||
_ => s.name.clone(),
|
||||
};
|
||||
let detail = match (&s.id, s.primary) {
|
||||
(SourceId::Monitor(_), true) => format!("{} · primary", size_text(s.width, s.height)),
|
||||
(SourceId::Window(_), _) => {
|
||||
format!("window {}", size_text(s.width, s.height)).trim().to_owned()
|
||||
}
|
||||
_ => size_text(s.width, s.height),
|
||||
};
|
||||
rows.push((name, detail));
|
||||
entries.push((s.id.clone(), s.name.clone(), false));
|
||||
if s.id == SourceId::Portal && restorable {
|
||||
rows.push(("Same as last time".to_owned(), "without the dialog".to_owned()));
|
||||
entries.push((s.id.clone(), s.name.clone(), true));
|
||||
}
|
||||
}
|
||||
(rows, entries)
|
||||
}
|
||||
|
||||
/// Share settings from the dialog.
|
||||
pub(crate) struct CaptureRequest {
|
||||
pub fps: u32,
|
||||
@@ -473,3 +497,30 @@ impl Decoder {
|
||||
stats.error.filter(|_| stats.decoded == 0)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// "Choose via system dialog" never passes the restore token, so the
|
||||
/// portal always asks; with a token the last choice gets its own row.
|
||||
#[test]
|
||||
fn the_portal_dialog_always_asks() {
|
||||
let portal = CaptureSource {
|
||||
id: SourceId::Portal,
|
||||
name: "Screen".into(),
|
||||
width: 0,
|
||||
height: 0,
|
||||
primary: false,
|
||||
};
|
||||
let (rows, entries) = share_rows(std::slice::from_ref(&portal), false);
|
||||
assert_eq!(rows.len(), 1);
|
||||
assert_eq!(rows[0].0, "Choose via system dialog");
|
||||
assert!(!entries[0].2);
|
||||
let (rows, entries) = share_rows(&[portal], true);
|
||||
let names: Vec<_> = rows.iter().map(|(name, _)| name.as_str()).collect();
|
||||
assert_eq!(names, ["Choose via system dialog", "Same as last time"]);
|
||||
let restore: Vec<_> = entries.iter().map(|e| e.2).collect();
|
||||
assert_eq!(restore, [false, true]);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import { StreamsPanel } from "streams.slint";
|
||||
import { PinsDrawer, TopicsDrawer } from "drawers.slint";
|
||||
import { MembersPanel } from "members.slint";
|
||||
import { VoiceCard, VoiceButtons } from "../shells/common.slint";
|
||||
import { StudioBridge } from "../studio-bridge.slint";
|
||||
import { ShareMenu } from "../share-menu.slint";
|
||||
|
||||
// Servers as a horizontal strip, the current server, its channels.
|
||||
export component MobileServers inherits VerticalLayout {
|
||||
@@ -169,11 +171,15 @@ export component YouPage inherits ScrollView {
|
||||
enabled: Bridge.voice-connected;
|
||||
clicked => { Bridge.set-output-muted(!Bridge.output-muted); }
|
||||
}
|
||||
if Bridge.streams-available && Bridge.can-share: ActionButton {
|
||||
icon: Icons.radio;
|
||||
text: Bridge.share-state == "live" ? @tr("Live") : @tr("Go Live");
|
||||
checked: Bridge.share-state == "live";
|
||||
clicked => { Nav.open-share(); }
|
||||
// A screen or the Stream Studio (ShareMenu).
|
||||
if Bridge.streams-available && Bridge.can-share: VerticalLayout {
|
||||
live := ActionButton {
|
||||
icon: Icons.radio;
|
||||
text: Bridge.share-state == "live" || StudioBridge.status.live ? @tr("Live") : @tr("Go Live");
|
||||
checked: Bridge.share-state == "live" || StudioBridge.status.live;
|
||||
clicked => { share-menu.open(0, - live.height - share-menu.menu-height - 4px); }
|
||||
}
|
||||
share-menu := ShareMenu { }
|
||||
}
|
||||
ActionButton {
|
||||
icon: Icons.phone-off;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// What a Share button opens: a quick share of a screen or a window (the
|
||||
// share dialog) or the Stream Studio. While a share runs it opens the share
|
||||
// dialog right away, to manage it.
|
||||
|
||||
import { Theme } from "theme.slint";
|
||||
import { Icons } from "icons.slint";
|
||||
import { PopupMenu } from "components/index.slint";
|
||||
import { Bridge } from "bridge.slint";
|
||||
import { StudioBridge } from "studio-bridge.slint";
|
||||
import { Nav } from "nav.slint";
|
||||
|
||||
export component ShareMenu inherits Rectangle {
|
||||
// The menu's height, to open it above a button.
|
||||
out property <length> menu-height: 2 * Theme.control-height + 2 * Theme.space-2 + 2px;
|
||||
width: 0;
|
||||
height: 0;
|
||||
|
||||
// Open at (x, y), relative to this element.
|
||||
public function open(x: length, y: length) {
|
||||
if Bridge.share-state == "live" || Bridge.share-state == "starting" {
|
||||
Nav.open-share();
|
||||
} else {
|
||||
menu.show(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
menu := PopupMenu {
|
||||
menu-width: 220px;
|
||||
entries: [
|
||||
// The studio's stream takes the place of a simple share.
|
||||
{ text: @tr("Share screen"), icon: Icons.monitor-up, enabled: !StudioBridge.status.live },
|
||||
{ text: @tr("Stream Studio"), icon: Icons.radio, enabled: true },
|
||||
];
|
||||
activated(i) => {
|
||||
if i == 0 {
|
||||
Nav.open-share();
|
||||
} else {
|
||||
Nav.open-studio();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import { Theme } from "../theme.slint";
|
||||
import { Icons } from "../icons.slint";
|
||||
import { Bridge } from "../bridge.slint";
|
||||
import { Nav, SettingsSection } from "../nav.slint";
|
||||
import { StudioBridge } from "../studio-bridge.slint";
|
||||
import { ShareMenu } from "../share-menu.slint";
|
||||
import { Icon, IconButton, Avatar, Status } from "../components/index.slint";
|
||||
|
||||
// A rounded panel of the frame (sidebar, main area, right panel).
|
||||
@@ -143,12 +145,16 @@ export component VoiceButtons inherits HorizontalLayout {
|
||||
enabled: Bridge.voice-connected;
|
||||
clicked => { Bridge.set-output-muted(!Bridge.output-muted); }
|
||||
}
|
||||
if Bridge.streams-available && Bridge.can-share: IconButton {
|
||||
icon: Icons.monitor-up;
|
||||
label: Bridge.share-state == "live" ? @tr("Sharing") : @tr("Share screen");
|
||||
checked: Bridge.share-state == "live";
|
||||
size: root.size;
|
||||
clicked => { Nav.open-share(); }
|
||||
// A screen or window, or the Stream Studio (ShareMenu).
|
||||
if Bridge.streams-available && Bridge.can-share: VerticalLayout {
|
||||
IconButton {
|
||||
icon: Icons.monitor-up;
|
||||
label: Bridge.share-state == "live" ? @tr("Sharing") : StudioBridge.status.live ? @tr("Live in the Stream Studio") : @tr("Share or go live");
|
||||
checked: Bridge.share-state == "live" || StudioBridge.status.live;
|
||||
size: root.size;
|
||||
clicked => { share-menu.open(0, - root.size - share-menu.menu-height - 4px); }
|
||||
}
|
||||
share-menu := ShareMenu { }
|
||||
}
|
||||
IconButton {
|
||||
icon: Icons.settings;
|
||||
|
||||
@@ -218,13 +218,6 @@ export component TopBar inherits Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
IconButton {
|
||||
icon: Icons.radio;
|
||||
label: @tr("Stream Studio");
|
||||
checked: Nav.page == Page.studio;
|
||||
y: (parent.height - self.height) / 2;
|
||||
clicked => { Nav.open-studio(); }
|
||||
}
|
||||
IconButton {
|
||||
icon: Icons.users;
|
||||
label: @tr("Members");
|
||||
|
||||
@@ -172,15 +172,6 @@ export component MobileShell inherits Rectangle {
|
||||
Nav.show-voice(true);
|
||||
}
|
||||
}
|
||||
if !root.voice: IconButton {
|
||||
icon: Icons.radio;
|
||||
label: @tr("Stream Studio");
|
||||
round: true;
|
||||
filled: true;
|
||||
checked: Nav.page == Page.studio;
|
||||
y: (parent.height - self.height) / 2;
|
||||
clicked => { Nav.open-studio(); }
|
||||
}
|
||||
if !root.voice: IconButton {
|
||||
icon: Icons.bell;
|
||||
label: @tr("Notifications");
|
||||
|
||||
Reference in new issue
Block a user