4 Commits
Author SHA1 Message Date
vhaudiquet fac1ec00da bump version (0.3.1)
record-daemon / Check and lint (Linux) (push) Successful in 1m10s
record-daemon / Build (Windows x64) (push) Successful in 1m47s
2026-11-21 19:32:38 +01:00
vhaudiquet b173d75e98 app: use the tauri-app medallion icon on the window, taskbar and tray
record-daemon / Check and lint (Linux) (push) Successful in 1m12s
record-daemon / Build (Windows x64) (push) Successful in 1m44s
The exe carried no icon resource and the tray drew a stand-in disc, so
Explorer, the taskbar and the tray each guessed at what to show. The
old front end's medallion was already in the tree and identical to the
installer's icon.ico, so the whole shell now draws it: set_app_icon
feeds icons/icon_full.png to rune before the event loop, the tray
decodes the bundled 32 px, and build.rs bakes icon.ico into the exe
for Explorer and shortcuts. The 128 px variants stay in tauri-app,
which rune's own resizing makes redundant here.
2026-11-21 19:19:58 +01:00
vhaudiquet 6ca825990d app: delete a recording from its card's menu
The list could only open the review, so a clip that was not worth
keeping stayed on disk forever. The dots beside Review open a menu
drawn over this window, so it stays inside it, with room for more
actions later. Delete asks before the clip and its timeline leave
the disk and the row leaves the list.
2026-11-21 19:01:41 +01:00
vhaudiquet b1cde7e783 record: size recordings from the screen, not the quality preset
The quality preset chose the OBS canvas while the capture ran at the
game's real size, and the scene item carries no transform, so picking
1080p on a 1440p screen recorded only the top-left 1920x1080 crop of
the game.

Recordings now always run at the primary monitor's resolution, queried
in device pixels so display scaling cannot skew them, and a recording
start re-checks the screen so a display change mid-session cannot
bring the crop back. Quality presets keep their bitrate meaning and
nothing else; they never reached the encoder before, so High, Ultra
and friends now actually change what a recording costs on disk.
2026-11-21 18:15:52 +01:00
20 changed files with 496 additions and 127 deletions

No files matched your search

+45 -3
View File
@@ -1536,11 +1536,12 @@ checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
[[package]] [[package]]
name = "leaguerecorder" name = "leaguerecorder"
version = "0.3.0" version = "0.3.1"
dependencies = [ dependencies = [
"chrono", "chrono",
"directories", "directories",
"ffmpeg-sidecar", "ffmpeg-sidecar",
"image",
"rune", "rune",
"rune-kit", "rune-kit",
"rune-notify", "rune-notify",
@@ -1551,6 +1552,7 @@ dependencies = [
"uuid", "uuid",
"windows", "windows",
"winreg", "winreg",
"winresource",
] ]
[[package]] [[package]]
@@ -3068,6 +3070,15 @@ dependencies = [
"syn 3.0.10", "syn 3.0.10",
] ]
[[package]]
name = "serde_spanned"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782"
dependencies = [
"serde_core",
]
[[package]] [[package]]
name = "shlex" name = "shlex"
version = "2.0.1" version = "2.0.1"
@@ -3553,6 +3564,21 @@ dependencies = [
"syn 3.0.10", "syn 3.0.10",
] ]
[[package]]
name = "toml"
version = "1.2.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5426cb1b964690d913f6c5c1a1ae0b42f428ec506bb4d452876d7a209c9bca3b"
dependencies = [
"indexmap",
"serde_core",
"serde_spanned",
"toml_datetime",
"toml_parser",
"toml_writer",
"winnow",
]
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "1.1.3+spec-1.1.0" version = "1.1.3+spec-1.1.0"
@@ -3576,13 +3602,19 @@ dependencies = [
[[package]] [[package]]
name = "toml_parser" name = "toml_parser"
version = "1.1.5+spec-1.1.0" version = "1.1.6+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" checksum = "e6769c452d71ba30696c6b37770c439a9cc9110f47f7d5cdbeda79840ef5ea31"
dependencies = [ dependencies = [
"winnow", "winnow",
] ]
[[package]]
name = "toml_writer"
version = "1.2.0+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a"
[[package]] [[package]]
name = "tracing" name = "tracing"
version = "0.1.44" version = "0.1.44"
@@ -4432,6 +4464,16 @@ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "winresource"
version = "0.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2bc6d36480b829272a5bdabf08e6dca8004761c1da7e35efef800540c66221b"
dependencies = [
"toml",
"version_check",
]
[[package]] [[package]]
name = "wit-bindgen" name = "wit-bindgen"
version = "0.57.1" version = "0.57.1"
+7 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "leaguerecorder" name = "leaguerecorder"
version = "0.3.0" version = "0.3.1"
edition = "2024" edition = "2024"
description = "Native League Recorder desktop app (rune)" description = "Native League Recorder desktop app (rune)"
license = "MIT" license = "MIT"
@@ -9,6 +9,10 @@ license = "MIT"
name = "leaguerecorder" name = "leaguerecorder"
path = "src/main.rs" path = "src/main.rs"
[build-dependencies]
# Bakes icons/icon.ico into the exe's resources (build.rs), for Explorer and shortcuts.
winresource = "0.1"
[dependencies] [dependencies]
rune = { git = "https://github.com/anomalyco/rune", rev = "4ddf696b0f13ec618fdeb80b4c9ea1a6246547f1" } rune = { git = "https://github.com/anomalyco/rune", rev = "4ddf696b0f13ec618fdeb80b4c9ea1a6246547f1" }
rune-kit = { git = "https://github.com/anomalyco/rune", rev = "4ddf696b0f13ec618fdeb80b4c9ea1a6246547f1" } rune-kit = { git = "https://github.com/anomalyco/rune", rev = "4ddf696b0f13ec618fdeb80b4c9ea1a6246547f1" }
@@ -22,6 +26,8 @@ tokio = { version = "1", features = ["rt", "net", "io-util", "time", "sync"] }
uuid = { version = "1", features = ["v4", "serde"] } uuid = { version = "1", features = ["v4", "serde"] }
ffmpeg-sidecar = "2.7" ffmpeg-sidecar = "2.7"
ureq = "3.5" ureq = "3.5"
# PNG decode of the bundled tray icon; the same crate and features rune itself uses.
image = { version = "0.25", default-features = false, features = ["png"] }
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
winreg = "0.56" winreg = "0.56"
+11
View File
@@ -0,0 +1,11 @@
//! Bakes `icons/icon.ico` into the exe as its resource, so Explorer, shortcuts and the
//! installer show the medallion the window and the tray also draw.
fn main() {
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {
return;
}
let mut resource = winresource::WindowsResource::new();
resource.set_icon("icons/icon.ico");
resource.compile().expect("the icon resource compiles");
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 KiB

+1 -1
View File
@@ -8,7 +8,7 @@
name = "leaguerecorder" name = "leaguerecorder"
product-name = "League Recorder" product-name = "League Recorder"
identifier = "v.leaguerecorder" identifier = "v.leaguerecorder"
version = "0.3.0" version = "0.3.1"
description = "Records League of Legends games through the record-daemon." description = "Records League of Legends games through the record-daemon."
out-dir = "dist" out-dir = "dist"
# A config file is not read from Cargo.toml, so the binary has to be named. The app crate # A config file is not read from Cargo.toml, so the binary has to be named. The app crate
+39 -3
View File
@@ -133,6 +133,11 @@ pub struct App {
/// The timeline the review is waiting for, once a row is opened. /// The timeline the review is waiting for, once a row is opened.
pub review_rx: Option<Receiver<Option<Timeline>>>, pub review_rx: Option<Receiver<Option<Timeline>>>,
pub filter: Option<QueueCategory>, pub filter: Option<QueueCategory>,
/// The row the delete dialog is about, once its menu has asked to delete it.
pub confirm_delete: Option<String>,
/// The card whose actions menu is open, if any. The card's position, not its recording:
/// demo data repeats ids across rows, and a menu opens for one card alone.
pub menu_open: Option<usize>,
pub review: screens::review::Review, pub review: screens::review::Review,
pub portraits: Option<portraits::Portraits>, pub portraits: Option<portraits::Portraits>,
/// The icons of the processes the audio sources name, decoded from their executables. /// The icons of the processes the audio sources name, decoded from their executables.
@@ -183,6 +188,8 @@ impl App {
games_next: 0, games_next: 0,
review_rx: None, review_rx: None,
filter: None, filter: None,
confirm_delete: None,
menu_open: None,
review: screens::review::Review::default(), review: screens::review::Review::default(),
portraits: None, portraits: None,
icons: None, icons: None,
@@ -461,6 +468,23 @@ impl App {
self.games_next < self.games_paths.len() self.games_next < self.games_paths.len()
} }
/// Drop a recording out of the list once it has been deleted from disk, and drop a page
/// of rows already on its way: it may still hold the deleted file.
pub fn forget_game(&mut self, recording_id: &str) {
self.games.retain(|game| game.recording_id != recording_id);
if let Some(at) = self
.games_paths
.iter()
.position(|path| path.file_stem().and_then(|s| s.to_str()) == Some(recording_id))
{
self.games_paths.remove(at);
if at < self.games_next {
self.games_next -= 1;
}
}
self.games_rx = None;
}
/// The game the review screen is showing, if any. /// The game the review screen is showing, if any.
pub fn reviewed(&self) -> Option<&Timeline> { pub fn reviewed(&self) -> Option<&Timeline> {
self.review.game.as_ref() self.review.game.as_ref()
@@ -824,10 +848,12 @@ pub fn on_key(app: &mut App, event: &KeyEvent, _tx: &mut Tx) -> bool {
let command = event.mods.ctrl || event.mods.cmd; let command = event.mods.ctrl || event.mods.cmd;
match (&event.key, command) { match (&event.key, command) {
(Key::Text(t), false) if t == "1" => { (Key::Text(t), false) if t == "1" => {
app.menu_open = None;
app.screen = Screen::History; app.screen = Screen::History;
true true
} }
(Key::Text(t), false) if t == "2" => { (Key::Text(t), false) if t == "2" => {
app.menu_open = None;
app.screen = Screen::Settings; app.screen = Screen::Settings;
true true
} }
@@ -835,12 +861,17 @@ pub fn on_key(app: &mut App, event: &KeyEvent, _tx: &mut Tx) -> bool {
app.form.close_add(); app.form.close_add();
true true
} }
(Key::Escape, _) if app.confirm_delete.is_some() => {
app.confirm_delete = None;
true
}
(Key::Escape, _) if app.screen == Screen::Review => { (Key::Escape, _) if app.screen == Screen::Review => {
screens::review::leave(app); screens::review::leave(app);
app.screen = Screen::History; app.screen = Screen::History;
true true
} }
(Key::Escape, _) if app.screen == Screen::Settings => { (Key::Escape, _) if app.screen == Screen::Settings => {
app.menu_open = None;
app.screen = Screen::History; app.screen = Screen::History;
true true
} }
@@ -958,6 +989,7 @@ fn titlebar(p: Paint, app: &App) -> El {
"Settings", "Settings",
false, false,
|app: &mut App| { |app: &mut App| {
app.menu_open = None;
screens::review::leave(app); screens::review::leave(app);
app.screen = Screen::Settings; app.screen = Screen::Settings;
}, },
@@ -1011,9 +1043,12 @@ fn notice(p: Paint, notice: &Notice) -> El {
pub fn view(app: &App, cx: &mut Cx<App>) -> El { pub fn view(app: &App, cx: &mut Cx<App>) -> El {
let p = Paint::new(app.dark, cx.env().scale); let p = Paint::new(app.dark, cx.env().scale);
// Menus and dialogs cover the whole window, title bar and status bar included: the
// history row menus, the add-application form and the delete confirmation.
let mut overlays = Vec::new();
let content = match app.screen { let content = match app.screen {
Screen::Settings => screens::settings::view(app, p), Screen::Settings => screens::settings::view(app, p),
Screen::History => screens::history::view(app, p), Screen::History => screens::history::view(app, p, &mut overlays),
Screen::Review => screens::review::view(app, p), Screen::Review => screens::review::view(app, p),
}; };
let mut main = col().key("main").grow(1.0).min_h(0.0).w_full().fill(p.t.bg); let mut main = col().key("main").grow(1.0).min_h(0.0).w_full().fill(p.t.bg);
@@ -1049,11 +1084,12 @@ pub fn view(app: &App, cx: &mut Cx<App>) -> El {
}, },
)), )),
}; };
// The add-application dialog covers the whole window, title bar included.
let mut overlays = Vec::new();
if app.screen == Screen::Settings && app.form.add_open { if app.screen == Screen::Settings && app.form.add_open {
screens::settings::add_dialog(app, p, &mut overlays); screens::settings::add_dialog(app, p, &mut overlays);
} }
if app.confirm_delete.is_some() {
screens::history::delete_dialog(app, p, &mut overlays);
}
rune_kit::root(content, overlays) rune_kit::root(content, overlays)
} }
+48
View File
@@ -186,6 +186,8 @@ pub struct Summary {
pub recording_id: String, pub recording_id: String,
pub start_time: DateTime<Utc>, pub start_time: DateTime<Utc>,
pub duration_secs: i64, pub duration_secs: i64,
/// The video file the row names, kept so deleting a row does not re-read its timeline.
pub video_file: Option<String>,
champion: Option<String>, champion: Option<String>,
summoner: Option<String>, summoner: Option<String>,
queue_label: String, queue_label: String,
@@ -233,6 +235,7 @@ impl Timeline {
recording_id: self.recording_id.clone(), recording_id: self.recording_id.clone(),
start_time: self.start_time, start_time: self.start_time,
duration_secs: self.duration_secs, duration_secs: self.duration_secs,
video_file: self.video_file.clone(),
champion: self.champion(), champion: self.champion(),
summoner: self.summoner(), summoner: self.summoner(),
queue_label: self.queue_label(), queue_label: self.queue_label(),
@@ -251,6 +254,35 @@ pub fn load(recording_id: &str) -> Option<Timeline> {
serde_json::from_str(&text).ok() serde_json::from_str(&text).ok()
} }
/// Remove a recording: its timeline JSON and its video file.
///
/// The video is found the way review finds it, so a clip renamed but keeping the timestamp
/// prefix goes too. A file that is already gone is fine: the list shows what was read
/// earlier, and a tidy-up elsewhere should not turn into an error here.
pub fn delete(recording_id: &str, video_file: Option<&str>) -> Result<(), String> {
delete_in(recording_id, video_file, &daemon::recordings_dir())
}
/// [`delete`] inside one recordings folder, so a test can point it at a temporary one.
fn delete_in(
recording_id: &str,
video_file: Option<&str>,
recordings: &Path,
) -> Result<(), String> {
let json = recordings
.join("timelines")
.join(format!("{recording_id}.json"));
if json.exists() {
std::fs::remove_file(&json)
.map_err(|e| format!("could not delete {}: {e}", json.display()))?;
}
if let Some(video) = video_file.and_then(|name| find_video_file(recordings, name)) {
std::fs::remove_file(&video)
.map_err(|e| format!("could not delete {}: {e}", video.display()))?;
}
Ok(())
}
impl Timeline { impl Timeline {
fn end_stats(&self) -> Option<&Value> { fn end_stats(&self) -> Option<&Value> {
self.raw_end_game_stats.as_ref() self.raw_end_game_stats.as_ref()
@@ -682,4 +714,20 @@ mod tests {
assert!(found.ends_with("2026-03-27_16-42-52_kai_sa.mp4")); assert!(found.ends_with("2026-03-27_16-42-52_kai_sa.mp4"));
let _ = std::fs::remove_dir_all(dir); let _ = std::fs::remove_dir_all(dir);
} }
#[test]
fn deleting_a_recording_removes_its_timeline_and_its_clip() {
let dir = std::env::temp_dir().join(format!("leaguerecorder-{}", uuid::Uuid::new_v4()));
std::fs::create_dir_all(dir.join("timelines")).unwrap();
std::fs::write(dir.join("timelines").join("game.json"), TIMELINE).unwrap();
std::fs::write(dir.join("2026-03-27_16-42-52_kai_sa.mp4"), b"x").unwrap();
delete_in("game", Some("2026-03-27_16-42-52_unknown.mp4"), &dir).unwrap();
assert!(!dir.join("timelines").join("game.json").exists());
assert!(!dir.join("2026-03-27_16-42-52_kai_sa.mp4").exists());
// What is already gone is not an error.
delete_in("game", Some("2026-03-27_16-42-52_unknown.mp4"), &dir).unwrap();
let _ = std::fs::remove_dir_all(dir);
}
} }
+7
View File
@@ -42,3 +42,10 @@ pub static CHEVRON_RIGHT: Icon = Icon {
view: 16.0, view: 16.0,
body: r#"<path d="M6 3.6 10.6 8 6 12.4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>"#, body: r#"<path d="M6 3.6 10.6 8 6 12.4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>"#,
}; };
/// Three vertical dots: the button that opens a card's menu of actions.
pub static DOTS: Icon = Icon {
name: "app-dots",
view: 16.0,
body: r#"<circle cx="8" cy="3.6" r="1.7" fill="currentColor"/><circle cx="8" cy="8" r="1.7" fill="currentColor"/><circle cx="8" cy="12.4" r="1.7" fill="currentColor"/>"#,
};
+4
View File
@@ -63,6 +63,7 @@ fn main() {
if !app::headless() && !rune::single_instance(os::APP_ID) { if !app::headless() && !rune::single_instance(os::APP_ID) {
return; return;
} }
os::set_app_icon();
os::register_notifications(); os::register_notifications();
rune_notify::on_click(|_| rune_notify::bring_to_front()); rune_notify::on_click(|_| rune_notify::bring_to_front());
@@ -97,6 +98,9 @@ fn main() {
app.form.source_name = rune::TextEdit::new("Discord"); app.form.source_name = rune::TextEdit::new("Discord");
app.form.source_device = rune::TextEdit::new("Discord.exe"); app.form.source_device = rune::TextEdit::new("Discord.exe");
}), }),
("delete", |app| {
app.confirm_delete = app.games.first().map(|game| game.recording_id.clone());
}),
("daemon", |app| { ("daemon", |app| {
app.screen = app::Screen::Settings; app.screen = app::Screen::Settings;
app.settings_tab = app::SettingsTab::Advanced; app.settings_tab = app::SettingsTab::Advanced;
+33 -38
View File
@@ -71,45 +71,28 @@ pub fn notify(id: &str, title: &str, body: &str) {
rune_notify::post(&notification); rune_notify::post(&notification);
} }
/// A 32 px tray icon: an accent disc with a white play mark. /// The app's icon for the title bar, the taskbar and Alt+Tab: the same medallion the exe
/// carries and the installer shows. Call once at startup, before the event loop; rune sizes
/// it for each use and a headless run sets nothing.
pub fn set_app_icon() {
let bytes = include_bytes!("../icons/icon_full.png").as_slice();
if let Err(e) = rune::set_app_icon(bytes) {
eprintln!("app icon unavailable: {e}");
}
}
/// A 32 px tray icon: the app's medallion, decoded to the straight RGBA rows the tray takes.
pub fn tray_icon() -> rune::TrayIcon { pub fn tray_icon() -> rune::TrayIcon {
const SIZE: u32 = 32; let (width, height, pixels) = tray_icon_pixels();
let mut pixels = vec![0u8; (SIZE * SIZE * 4) as usize]; rune::TrayIcon::rgba(width, height, pixels)
let accent = [0x5b, 0x7c, 0xfa]; }
let half = SIZE as f32 / 2.0;
let radius = half - 1.0; /// The medallion at its bundled 32 px: straight RGBA rows for [`rune::TrayIcon`].
// Play triangle: apex right of centre, base left of centre. fn tray_icon_pixels() -> (u32, u32, Vec<u8>) {
let (ax, ay) = (half + 4.5, half); let image = image::load_from_memory(include_bytes!("../icons/32x32.png"))
let (bx, by) = (half - 4.0, half - 6.0); .expect("the bundled tray icon decodes")
let (cx, cy) = (half - 4.0, half + 6.0); .into_rgba8();
let edge = |px: f32, py: f32, x1: f32, y1: f32, x2: f32, y2: f32| { (image.width(), image.height(), image.into_raw())
(x2 - x1) * (py - y1) - (y2 - y1) * (px - x1)
};
for y in 0..SIZE {
for x in 0..SIZE {
let px = x as f32 + 0.5;
let py = y as f32 + 0.5;
let dx = px - half;
let dy = py - half;
// Three pixels of antialiasing at the disc edge.
let coverage = (radius - (dx * dx + dy * dy).sqrt()).clamp(0.0, 1.0);
if coverage <= 0.0 {
continue;
}
let e1 = edge(px, py, ax, ay, bx, by);
let e2 = edge(px, py, bx, by, cx, cy);
let e3 = edge(px, py, cx, cy, ax, ay);
let inside =
(e1 >= 0.0 && e2 >= 0.0 && e3 >= 0.0) || (e1 <= 0.0 && e2 <= 0.0 && e3 <= 0.0);
let ink = if inside { [255, 255, 255] } else { accent };
let i = ((y * SIZE + x) * 4) as usize;
pixels[i] = ink[0];
pixels[i + 1] = ink[1];
pixels[i + 2] = ink[2];
pixels[i + 3] = (coverage * 255.0) as u8;
}
}
rune::TrayIcon::rgba(SIZE, SIZE, pixels)
} }
/// The tray menu. `recording` flips the record item's label. /// The tray menu. `recording` flips the record item's label.
@@ -130,3 +113,15 @@ pub fn tray_menu(recording: bool) -> Vec<rune::TrayItem> {
rune::TrayItem::action("quit", "Quit"), rune::TrayItem::action("quit", "Quit"),
] ]
} }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_tray_icon_decodes_to_32_px_of_rgba() {
let (width, height, pixels) = tray_icon_pixels();
assert_eq!((width, height), (32, 32));
assert_eq!(pixels.len(), (32 * 32 * 4) as usize);
}
}
+142 -4
View File
@@ -8,10 +8,13 @@ use rune::{Color, El, col, el, row, text};
use crate::app::App; use crate::app::App;
use crate::format; use crate::format;
use crate::history::{Outcome, QueueCategory, Summary}; use crate::history::{self, Outcome, QueueCategory, Summary};
use crate::icons;
use crate::screens::review; use crate::screens::review;
use crate::ui::{self, Paint, body, heading}; use crate::ui::{self, Paint, body, heading};
use rune_kit::{Kit, Menu, MenuItem, Placement};
const FILTERS: [Option<QueueCategory>; 6] = [ const FILTERS: [Option<QueueCategory>; 6] = [
None, None,
Some(QueueCategory::RankedSolo), Some(QueueCategory::RankedSolo),
@@ -33,7 +36,8 @@ fn outcome_color(p: Paint, outcome: Outcome) -> Color {
} }
} }
pub fn view(app: &App, p: Paint) -> El { pub fn view(app: &App, p: Paint, layer: &mut Vec<El>) -> El {
let kit = rune_kit::Kit::neutral(app.dark);
let filtered: Vec<&Summary> = app let filtered: Vec<&Summary> = app
.games .games
.iter() .iter()
@@ -64,7 +68,7 @@ pub fn view(app: &App, p: Paint) -> El {
)); ));
} else { } else {
for (index, game) in filtered.iter().enumerate() { for (index, game) in filtered.iter().enumerate() {
list = list.child(game_card(app, p, game, index)); list = list.child(game_card(app, p, &kit, layer, game, index));
} }
} }
@@ -159,7 +163,14 @@ fn empty(p: Paint, title: &str, detail: &str) -> El {
) )
} }
fn game_card(app: &App, p: Paint, game: &Summary, index: usize) -> El { fn game_card(
app: &App,
p: Paint,
k: &Kit,
layer: &mut Vec<El>,
game: &Summary,
index: usize,
) -> El {
let outcome = game.outcome(); let outcome = game.outcome();
let ink = outcome_color(p, outcome); let ink = outcome_color(p, outcome);
let id = game.recording_id.clone(); let id = game.recording_id.clone();
@@ -304,11 +315,18 @@ fn game_card(app: &App, p: Paint, game: &Summary, index: usize) -> El {
), ),
) )
.child(stats_row) .child(stats_row)
.child(
row()
.key("actions")
.gap(space::S3)
.center_y()
.child( .child(
text("Review →") text("Review →")
.key("open") .key("open")
.font(type_::LABEL) .font(type_::LABEL)
.color(p.accent), .color(p.accent),
)
.child(card_menu(app, k, layer, p, game, index)),
), ),
), ),
) )
@@ -326,3 +344,123 @@ fn stat(p: Paint, value: &str, label: &str) -> El {
) )
.child(text(label).key("label").font(body(10.5)).color(p.muted())) .child(text(label).key("label").font(body(10.5)).color(p.muted()))
} }
/// The dots at the end of a card: they open the menu of actions a recording offers. The menu
/// is drawn over this window, so it stays inside it, and more actions can join `Delete` later.
/// The key is the card's position, so rows stay distinct even where ids repeat.
fn card_menu(
app: &App,
k: &Kit,
layer: &mut Vec<El>,
p: Paint,
game: &Summary,
index: usize,
) -> El {
let menu = Menu::new(format!("menu-{index}"))
.trigger(ui::menu_button(
p,
format!("menu-{index}"),
&icons::DOTS,
"Recording options",
move |app: &mut App| app.menu_open = Some(index),
))
.placement(Placement::BottomEnd)
.open(app.menu_open == Some(index))
.on_close(|app: &mut App| app.menu_open = None)
.item({
let id = game.recording_id.clone();
MenuItem::new("Delete")
.danger(true)
.on_select(move |app: &mut App| {
app.menu_open = None;
app.confirm_delete = Some(id.clone());
})
});
menu.build(k, layer)
}
/// The confirmation the menu's Delete opens: the row leaves the list and its files leave the
/// disk. `app::view` draws it over the whole window, title bar included.
pub fn delete_dialog(app: &App, p: Paint, layer: &mut Vec<El>) {
let panel = col()
.key("delete-dialog")
.role("dialog")
.label("Delete this recording")
.w(380.0)
.padding(space::S6)
.gap(space::S3)
.radius(radius::LG)
.fill(p.t.card)
.border(p.hair, p.t.card_border)
.shadow(4.0, 12.0, p.t.shadow)
.shadow(24.0, 48.0, p.t.shadow_soft)
.modal(true, |app: &mut App| app.confirm_delete = None)
.child(
text("Are you sure you want to delete this entry?")
.key("delete-question")
.font(heading(15.0))
.color(p.t.text),
)
.child(
text("The recording and its timeline are removed from disk.")
.key("delete-note")
.font(body(12.0))
.color(p.muted()),
)
.child(
row()
.key("delete-actions")
.w_full()
.gap(space::S2)
.justify_end()
.child(ui::button(p, "delete-no", "No", false, |app: &mut App| {
app.confirm_delete = None;
}))
.child(ui::button_danger(
p,
"delete-yes",
"Yes",
|app: &mut App| {
delete_confirmed(app);
},
)),
);
layer.push(
el().key("delete-scrim")
.absolute(0.0, 0.0)
.w_full()
.h_full()
.fill(Color::BLACK.alpha(if app.dark { 0.55 } else { 0.28 }))
.a11y_hidden(),
);
layer.push(
el().key("delete-layer")
.absolute(0.0, 0.0)
.w_full()
.h_full()
.padding(16.0)
.center()
.child(panel),
);
}
/// Yes on the dialog: the files go, the row goes, the dialog closes.
fn delete_confirmed(app: &mut App) {
let Some(id) = app.confirm_delete.take() else {
return;
};
// A review left open keeps the clip's file in use, and the delete would fail on it.
if app.reviewed().is_some_and(|game| game.recording_id == id) {
review::leave(app);
}
let Some(summary) = app.games.iter().find(|g| g.recording_id == id).cloned() else {
return;
};
if let Err(e) = history::delete(&id, summary.video_file.as_deref()) {
app.notify_error(e);
return;
}
app.forget_game(&id);
app.notify("Recording deleted");
}
+5 -4
View File
@@ -171,12 +171,13 @@ impl Quality {
} }
} }
/// What a quality level records at: the screen's resolution, at this bitrate.
pub fn detail(self) -> &'static str { pub fn detail(self) -> &'static str {
match self { match self {
Quality::Low => "720p @ 30fps", Quality::Low => "Your screen's resolution at 4.5 Mbps",
Quality::Medium => "1080p @ 30fps", Quality::Medium => "Your screen's resolution at 6 Mbps",
Quality::High => "1080p @ 60fps", Quality::High => "Your screen's resolution at 8 Mbps",
Quality::Ultra => "1440p @ 60fps", Quality::Ultra => "Your screen's resolution at 12 Mbps",
} }
} }
} }
+51
View File
@@ -754,3 +754,54 @@ fn place(thumb: &rune::Live<[f32; 4]>, [x, y, w, h]: [f32; 4], at: rune::ScrollP
let progress = (at.offset[1] / at.max[1]).clamp(0.0, 1.0); let progress = (at.offset[1] / at.max[1]).clamp(0.0, 1.0);
thumb.set([x + w - 12.0, y + progress * (h - height), 10.0, height]); thumb.set([x + w - 12.0, y + progress * (h - height), 10.0, height]);
} }
/// A small square button holding an icon: the trigger a menu opens from. Its handler says what
/// opening means; the menu itself is drawn in the window, so it can never leave it.
pub fn menu_button(
p: Paint,
key: impl Into<String>,
icon: &'static rune::Icon,
label: &str,
on_press: impl Fn(&mut App) + Send + Sync + 'static,
) -> El {
el().key(key.into())
.role("button")
.label(label)
.focusable(true)
.size(24.0, 24.0)
.center()
.radius(radius::MD)
.hover(p.t.hover)
.press(p.t.press)
.on_press(on_press)
.child(rune::icon(icon, 18.0).color(p.muted()).a11y_hidden())
}
/// A quiet destructive button: danger ink for a confirm whose answer cannot be undone.
pub fn button_danger(
p: Paint,
key: &str,
label: &str,
on_press: impl Fn(&mut App) + Send + Sync + 'static,
) -> El {
el().key(key)
.role("button")
.label(label)
.focusable(true)
.h(28.0)
.px(14.0)
.center()
.radius(radius::MD)
.fill(p.danger.alpha(0.14))
.border(p.hair, p.danger.alpha(0.32))
.hover(p.danger.alpha(0.22))
.press(p.danger.alpha(0.3))
.on_press(on_press)
.child(
text(label)
.key("label")
.font(type_::LABEL)
.color(p.danger)
.a11y_hidden(),
)
}
+6 -4
View File
@@ -201,11 +201,13 @@ enum EncoderPreset {
} }
enum QualityLevel { enum QualityLevel {
Low, // 720p30, lower bitrate Low, // 4.5 Mbps bitrate tier
Medium, // 1080p30, moderate bitrate Medium, // 6 Mbps
High, // 1080p60, high bitrate High, // 8 Mbps
Ultra, // 1440p60, max quality Ultra, // 12 Mbps
} }
// Recordings always run at the screen resolution: the daemon sizes the OBS
// canvas from the primary monitor, and quality only trades bitrate.
``` ```
### 2. LQP Client ### 2. LQP Client
+1 -1
View File
@@ -2387,7 +2387,7 @@ dependencies = [
[[package]] [[package]]
name = "record-daemon" name = "record-daemon"
version = "0.3.0" version = "0.3.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "record-daemon" name = "record-daemon"
version = "0.3.0" version = "0.3.1"
edition = "2021" edition = "2021"
description = "High-performance League of Legends recording daemon using libobs" description = "High-performance League of Legends recording daemon using libobs"
authors = ["LeagueRecorder"] authors = ["LeagueRecorder"]
+21 -40
View File
@@ -89,43 +89,26 @@ pub enum AmfQuality {
Quality, Quality,
} }
/// Quality level presets that configure resolution and other parameters. /// Quality level presets as bitrate tiers.
///
/// Recordings always run at the screen's resolution; these only trade file size
/// against detail. Frame rate comes from `VideoSettings::frame_rate`.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)] #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
pub enum QualityLevel { pub enum QualityLevel {
/// 720p @ 30fps, lower bitrate. /// 4500 kbps, smaller files.
Low, Low,
/// 1080p @ 30fps, moderate bitrate. /// 6000 kbps.
Medium, Medium,
/// 1080p @ 60fps, high bitrate. /// 8000 kbps.
#[default] #[default]
High, High,
/// 1440p @ 60fps, maximum quality. /// 12000 kbps, largest files.
Ultra, Ultra,
} }
impl QualityLevel { impl QualityLevel {
/// Get the target resolution for this quality level. /// Get the bitrate in kbps this quality level records at.
pub fn resolution(&self) -> (u32, u32) {
match self {
QualityLevel::Low => (1280, 720),
QualityLevel::Medium => (1920, 1080),
QualityLevel::High => (1920, 1080),
QualityLevel::Ultra => (2560, 1440),
}
}
/// Get the recommended frame rate for this quality level.
pub fn frame_rate(&self) -> u32 {
match self {
QualityLevel::Low => 30,
QualityLevel::Medium => 30,
QualityLevel::High => 60,
QualityLevel::Ultra => 60,
}
}
/// Get the recommended bitrate in kbps for this quality level.
pub fn recommended_bitrate(&self) -> u32 { pub fn recommended_bitrate(&self) -> u32 {
match self { match self {
QualityLevel::Low => 4500, QualityLevel::Low => 4500,
@@ -342,15 +325,6 @@ impl EncoderPreset {
} }
} }
/// Get the effective bitrate for this preset.
pub fn effective_bitrate(&self) -> u32 {
match self {
EncoderPreset::Nvenc { bitrate, .. } => *bitrate,
EncoderPreset::Amf { bitrate, .. } => *bitrate,
EncoderPreset::X264 { bitrate, .. } => *bitrate,
}
}
/// Create a preset optimized for the given quality level. /// Create a preset optimized for the given quality level.
pub fn for_quality(quality: QualityLevel, capability: EncoderCapability) -> Self { pub fn for_quality(quality: QualityLevel, capability: EncoderCapability) -> Self {
let bitrate = quality.recommended_bitrate(); let bitrate = quality.recommended_bitrate();
@@ -384,10 +358,10 @@ mod tests {
use super::*; use super::*;
#[test] #[test]
fn test_quality_level_resolution() { fn test_quality_level_bitrate() {
assert_eq!(QualityLevel::Low.resolution(), (1280, 720)); assert_eq!(QualityLevel::Low.recommended_bitrate(), 4500);
assert_eq!(QualityLevel::High.resolution(), (1920, 1080)); assert_eq!(QualityLevel::High.recommended_bitrate(), 8000);
assert_eq!(QualityLevel::Ultra.resolution(), (2560, 1440)); assert_eq!(QualityLevel::Ultra.recommended_bitrate(), 12000);
} }
#[test] #[test]
@@ -410,7 +384,14 @@ mod tests {
#[test] #[test]
fn test_preset_for_quality() { fn test_preset_for_quality() {
let preset = EncoderPreset::for_quality(QualityLevel::High, EncoderCapability::Nvenc); let preset = EncoderPreset::for_quality(QualityLevel::High, EncoderCapability::Nvenc);
assert_eq!(preset.effective_bitrate(), 8000); assert_eq!(
preset,
EncoderPreset::Nvenc {
bitrate: 8000,
cq_level: 20,
two_pass: true
}
);
assert!(preset.is_hardware()); assert!(preset.is_hardware());
} }
} }
+7
View File
@@ -46,6 +46,13 @@ pub struct VideoSettings {
pub hardware_acceleration: bool, pub hardware_acceleration: bool,
} }
impl VideoSettings {
/// The bitrate a recording runs at: the quality tier's.
pub fn video_bitrate(&self) -> u32 {
self.quality.recommended_bitrate()
}
}
impl Default for VideoSettings { impl Default for VideoSettings {
fn default() -> Self { fn default() -> Self {
Self { Self {
+67 -27
View File
@@ -127,6 +127,7 @@ impl ObsContextBuilder {
recording: false, recording: false,
pending_audio: None, pending_audio: None,
encoder_capability: None, encoder_capability: None,
canvas: (0, 0),
tracks: Vec::new(), tracks: Vec::new(),
}) })
} }
@@ -157,6 +158,9 @@ pub struct ObsContext {
/// Settings that arrived while a recording was running, applied once it stops. /// Settings that arrived while a recording was running, applied once it stops.
pending_audio: Option<(VideoSettings, AudioSettings)>, pending_audio: Option<(VideoSettings, AudioSettings)>,
encoder_capability: Option<EncoderCapability>, encoder_capability: Option<EncoderCapability>,
/// The canvas the video pipeline currently runs at, so a settings change or
/// a new recording can tell whether the screen resolution moved under it.
canvas: (u32, u32),
/// What each audio track of the running recording carries, in file order. /// What each audio track of the running recording carries, in file order.
tracks: Vec<String>, tracks: Vec<String>,
} }
@@ -191,7 +195,7 @@ impl ObsContext {
self.encoder_capability = Some(encoder); self.encoder_capability = Some(encoder);
info!("OBS encoder: {:?}", encoder); info!("OBS encoder: {:?}", encoder);
let (width, height) = self.video_settings.quality.resolution(); let (width, height) = canvas_resolution();
let fps = self.video_settings.frame_rate; let fps = self.video_settings.frame_rate;
let video_info = ObsVideoInfoBuilder::new() let video_info = ObsVideoInfoBuilder::new()
@@ -232,6 +236,7 @@ impl ObsContext {
)); ));
self.scene = Some(scene); self.scene = Some(scene);
self.context = Some(context); self.context = Some(context);
self.canvas = (width, height);
info!( info!(
"OBS context initialized ({}x{} @ {}fps)", "OBS context initialized ({}x{} @ {}fps)",
@@ -260,31 +265,7 @@ impl ObsContext {
return self.start(); return self.start();
} }
if video.frame_rate != self.video_settings.frame_rate self.reset_video_if_changed(video.frame_rate)?;
|| video.quality != self.video_settings.quality
{
let encoder = self
.encoder_capability
.unwrap_or_else(best_available_encoder);
let (width, height) = video.quality.resolution();
let video_info = ObsVideoInfoBuilder::new()
.fps_num(video.frame_rate)
.fps_den(1)
.base_width(width)
.base_height(height)
.output_width(width)
.output_height(height)
.build();
if let Some(context) = self.context.as_mut() {
context.reset_video(video_info).map_err(|e| {
RecordingError::StartError(format!("failed to reset video: {:?}", e))
})?;
}
info!(
"video reset to {}x{} @ {}fps ({:?})",
width, height, video.frame_rate, encoder
);
}
if audio != self.audio_settings { if audio != self.audio_settings {
let context = self let context = self
@@ -319,6 +300,7 @@ impl ObsContext {
self.apply_now(video, audio)?; self.apply_now(video, audio)?;
} }
self.start()?; self.start()?;
self.reset_video_if_changed(self.video_settings.frame_rate)?;
let context = self let context = self
.context .context
@@ -332,7 +314,7 @@ impl ObsContext {
let encoder = self let encoder = self
.encoder_capability .encoder_capability
.unwrap_or_else(best_available_encoder); .unwrap_or_else(best_available_encoder);
let bitrate = self.video_settings.encoder_preset.effective_bitrate(); let bitrate = self.video_settings.video_bitrate();
let obs_path = ObsPath::new(&output_path.to_string_lossy()); let obs_path = ObsPath::new(&output_path.to_string_lossy());
let mut builder = let mut builder =
@@ -447,6 +429,39 @@ impl ObsContext {
self.context = None; self.context = None;
Ok(()) Ok(())
} }
/// Rebuild the video pipeline when the frame rate or the screen moved.
///
/// Both a settings change and a recording start go through here, so the canvas
/// always matches the capture and the recording never crops the game.
fn reset_video_if_changed(&mut self, fps: u32) -> Result<()> {
let (width, height) = canvas_resolution();
if fps == self.video_settings.frame_rate && (width, height) == self.canvas {
return Ok(());
}
let encoder = self
.encoder_capability
.unwrap_or_else(best_available_encoder);
let video_info = ObsVideoInfoBuilder::new()
.fps_num(fps)
.fps_den(1)
.base_width(width)
.base_height(height)
.output_width(width)
.output_height(height)
.build();
if let Some(context) = self.context.as_mut() {
context.reset_video(video_info).map_err(|e| {
RecordingError::StartError(format!("failed to reset video: {:?}", e))
})?;
}
self.canvas = (width, height);
info!(
"video reset to {}x{} @ {}fps ({:?})",
width, height, fps, encoder
);
Ok(())
}
} }
impl Drop for ObsContext { impl Drop for ObsContext {
@@ -479,6 +494,31 @@ fn audio_source(
Ok(source) Ok(source)
} }
/// The resolution to record at: the primary monitor's, in device pixels.
///
/// The capture fills the canvas one to one, so a recording never crops or rescales
/// the game, whatever preset is set. Falls back to 1080p if the display query fails.
fn canvas_resolution() -> (u32, u32) {
const FALLBACK: (u32, u32) = (1920, 1080);
let displays = match display_info::DisplayInfo::all() {
Ok(displays) if !displays.is_empty() => displays,
_ => {
warn!(
"could not list displays, recording at {}x{}",
FALLBACK.0, FALLBACK.1
);
return FALLBACK;
}
};
let screen = displays
.iter()
.find(|d| d.is_primary)
.unwrap_or_else(|| displays.iter().max_by_key(|d| d.width * d.height).unwrap());
// H.264 encoders want even dimensions.
let even = |v: u32| v & !1;
(even(screen.width), even(screen.height))
}
/// Audio that comes from a device: the microphone and any configured second device. /// Audio that comes from a device: the microphone and any configured second device.
/// ///
/// These live in the scene for the whole session. Process captures are in the scene as well, /// These live in the scene for the whole session. Process captures are in the scene as well,