app: offer the encoders this machine has and save from the tab
The encoder picker listed every kind the daemon knows, so a machine with an AMD card could choose NVENC and only find out when a recording failed to start. The list now holds what the encoder probe reports as present, hardware before software, and a saved preset the machine cannot run switches to the first one with a note saying so. Recording drops the hardware acceleration switch and the frame rate field. Both were decided by the encoder and the quality preset, and the switch in particular changed nothing the daemon reads. The tab lists the audio sources it will mix, so the game, the microphone and the added applications are visible without opening the Audio tab, and the open folder button sits at the right of the recording folder row where the other rows keep their controls. Save now writes. The reply to updateSettings carries no settings, which parsed into a set of defaults and started the screen over; a reply without them is an error instead. The button shows Saving while the round trip runs and the form goes clean only once the daemon has the values.
This commit is contained in:
1 parent
c7fee5beeb
commit
976fcdc354
3 files changed
+207
-138
No files matched your search
+118
-114
@@ -17,7 +17,6 @@ pub struct Form {
|
||||
pub open_select: Option<&'static str>,
|
||||
pub path: TextEdit,
|
||||
pub naming: TextEdit,
|
||||
pub frame_rate: TextEdit,
|
||||
pub split_size: TextEdit,
|
||||
pub split_time: TextEdit,
|
||||
pub poll_interval: TextEdit,
|
||||
@@ -33,7 +32,6 @@ impl Form {
|
||||
Self {
|
||||
path: TextEdit::new(&draft.output.path),
|
||||
naming: TextEdit::new(&draft.output.naming_pattern),
|
||||
frame_rate: TextEdit::new(draft.video.frame_rate.to_string()),
|
||||
split_size: TextEdit::new(draft.output.split_size_mb.to_string()),
|
||||
split_time: TextEdit::new(draft.output.split_time_minutes.to_string()),
|
||||
poll_interval: TextEdit::new(draft.daemon.poll_interval_ms.to_string()),
|
||||
@@ -57,8 +55,6 @@ impl Form {
|
||||
self.draft = settings.clone();
|
||||
self.path.replace_text(&settings.output.path);
|
||||
self.naming.replace_text(&settings.output.naming_pattern);
|
||||
self.frame_rate
|
||||
.replace_text(settings.video.frame_rate.to_string());
|
||||
self.split_size
|
||||
.replace_text(settings.output.split_size_mb.to_string());
|
||||
self.split_time
|
||||
@@ -77,13 +73,6 @@ impl Form {
|
||||
let mut out = self.draft.clone();
|
||||
out.output.path = self.path.text.trim().to_string();
|
||||
out.output.naming_pattern = self.naming.text.trim().to_string();
|
||||
out.video.frame_rate = self
|
||||
.frame_rate
|
||||
.text
|
||||
.trim()
|
||||
.parse()
|
||||
.unwrap_or(60)
|
||||
.clamp(1, 240);
|
||||
out.output.split_size_mb = self.split_size.text.trim().parse().unwrap_or(0);
|
||||
out.output.split_time_minutes = self.split_time.text.trim().parse().unwrap_or(0);
|
||||
out.daemon.poll_interval_ms = self
|
||||
@@ -271,6 +260,7 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
if !app.form.loaded {
|
||||
return;
|
||||
}
|
||||
app.form.saving = true;
|
||||
let settings = app.form.settings();
|
||||
match serde_json::to_value(&settings) {
|
||||
Ok(value) => app.daemon.save_settings(value),
|
||||
@@ -303,6 +293,8 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
fn save_label(app: &App, p: Paint) -> (String, rune::Color) {
|
||||
if !app.connected {
|
||||
("Daemon offline".into(), p.danger)
|
||||
} else if app.form.saving {
|
||||
("Saving\u{2026}".into(), p.muted())
|
||||
} else if app.form.dirty {
|
||||
("Unsaved changes".into(), p.warning)
|
||||
} else if app.form.loaded {
|
||||
@@ -397,37 +389,30 @@ fn quick(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content:
|
||||
},
|
||||
)],
|
||||
))
|
||||
.child(ui::card(
|
||||
.child(ui::card_action(
|
||||
p,
|
||||
Some("Files"),
|
||||
vec![
|
||||
ui::setting_row(
|
||||
p,
|
||||
"recordings-folder",
|
||||
"Recordings folder",
|
||||
text(short_path(&app.form.draft.output.path))
|
||||
.key("path")
|
||||
.font(body(12.0))
|
||||
.color(p.muted()),
|
||||
),
|
||||
row()
|
||||
.key("files-actions")
|
||||
.px(space::S3)
|
||||
.pb(space::S2)
|
||||
.child(ui::button(
|
||||
p,
|
||||
"open-recordings",
|
||||
"Open folder",
|
||||
false,
|
||||
|_app: &mut App| {
|
||||
crate::daemon::open_folder(&crate::daemon::recordings_dir());
|
||||
},
|
||||
)),
|
||||
],
|
||||
Some(ui::button(
|
||||
p,
|
||||
"open-recordings",
|
||||
"Open folder",
|
||||
false,
|
||||
|_app: &mut App| {
|
||||
crate::daemon::open_folder(&crate::daemon::recordings_dir());
|
||||
},
|
||||
)),
|
||||
vec![ui::setting_row(
|
||||
p,
|
||||
"recordings-folder",
|
||||
"Recordings folder",
|
||||
text(short_path(&app.form.draft.output.path))
|
||||
.key("path")
|
||||
.font(body(12.0))
|
||||
.color(p.muted()),
|
||||
)],
|
||||
))
|
||||
}
|
||||
|
||||
/// A path as it fits on a row: the last two segments, with the rest elided.
|
||||
/// A path as it fits on a row: the last two segments, with the rest elided.
|
||||
fn short_path(path: &str) -> String {
|
||||
let sep = std::path::MAIN_SEPARATOR;
|
||||
@@ -442,83 +427,62 @@ fn short_path(path: &str) -> String {
|
||||
|
||||
fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content: El) -> El {
|
||||
let v = &app.form.draft.video;
|
||||
let a = &app.form.draft.audio;
|
||||
let o = &app.form.draft.output;
|
||||
let available = if app.encoders.available.is_empty() {
|
||||
String::new()
|
||||
|
||||
// Only the encoders this machine reports are offered. The static list stands in until the
|
||||
// daemon has answered.
|
||||
let offered = app.runnable_encoders();
|
||||
let encoders: Vec<&str> = if offered.is_empty() {
|
||||
ENCODERS.to_vec()
|
||||
} else {
|
||||
app.encoders
|
||||
.available
|
||||
.iter()
|
||||
.filter(|e| e.available)
|
||||
.map(|e| {
|
||||
let kind = if e.is_hardware {
|
||||
"hardware"
|
||||
} else {
|
||||
"software"
|
||||
};
|
||||
format!("{} ({}, {kind})", e.name, e.id)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
offered
|
||||
};
|
||||
let mut video_rows = vec![
|
||||
select_row(
|
||||
p,
|
||||
kit,
|
||||
layer,
|
||||
"encoder",
|
||||
"Encoder",
|
||||
"Hardware encoding is faster; x264 uses the CPU",
|
||||
&ENCODERS,
|
||||
Some(v.encoder_preset.label().to_string()),
|
||||
app,
|
||||
),
|
||||
select_row(
|
||||
p,
|
||||
kit,
|
||||
layer,
|
||||
"quality",
|
||||
"Quality",
|
||||
v.quality.detail(),
|
||||
&QUALITIES,
|
||||
Some(v.quality.label().to_string()),
|
||||
app,
|
||||
),
|
||||
text_row(
|
||||
p,
|
||||
"frame-rate",
|
||||
"Frame rate",
|
||||
"Frames per second the daemon records",
|
||||
&app.form.frame_rate,
|
||||
|app| &mut app.form.frame_rate,
|
||||
),
|
||||
ui::toggle_row(
|
||||
p,
|
||||
"hardware",
|
||||
"Hardware acceleration",
|
||||
v.hardware_acceleration,
|
||||
|app: &mut App| {
|
||||
app.form.draft.video.hardware_acceleration ^= true;
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
];
|
||||
if !available.is_empty() {
|
||||
video_rows.push(
|
||||
text(format!("Available on this machine: {available}"))
|
||||
.key("encoder-note")
|
||||
.font(body(11.0))
|
||||
.color(p.muted())
|
||||
.ml(space::S3)
|
||||
.mb(6.0),
|
||||
);
|
||||
}
|
||||
// The stored encoder is shown as it is, even when this machine cannot run it, so the row
|
||||
// never claims something the daemon does not hold.
|
||||
let encoder = Some(v.encoder_preset.label().to_string());
|
||||
|
||||
content
|
||||
.child(ui::card(p, Some("Video"), video_rows))
|
||||
.child(ui::card(
|
||||
p,
|
||||
Some("Video"),
|
||||
vec![
|
||||
select_row(
|
||||
p,
|
||||
kit,
|
||||
layer,
|
||||
"encoder",
|
||||
"Encoder",
|
||||
"The encoders this machine can run",
|
||||
&encoders,
|
||||
encoder,
|
||||
app,
|
||||
),
|
||||
select_row(
|
||||
p,
|
||||
kit,
|
||||
layer,
|
||||
"quality",
|
||||
"Quality",
|
||||
v.quality.detail(),
|
||||
&QUALITIES,
|
||||
Some(v.quality.label().to_string()),
|
||||
app,
|
||||
),
|
||||
],
|
||||
))
|
||||
.child(ui::card_action(
|
||||
p,
|
||||
Some("Output"),
|
||||
Some(ui::button(
|
||||
p,
|
||||
"open-output",
|
||||
"Open folder",
|
||||
false,
|
||||
|_app: &mut App| {
|
||||
crate::daemon::open_folder(&crate::daemon::recordings_dir());
|
||||
},
|
||||
)),
|
||||
vec![
|
||||
text_row(
|
||||
p,
|
||||
@@ -565,15 +529,55 @@ fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, cont
|
||||
),
|
||||
],
|
||||
))
|
||||
.child(row().key("recording-actions").gap(8.0).child(ui::button(
|
||||
.child(ui::card(
|
||||
p,
|
||||
"open-output",
|
||||
"Open recordings folder",
|
||||
false,
|
||||
|_app: &mut App| {
|
||||
crate::daemon::open_folder(&crate::daemon::recordings_dir());
|
||||
},
|
||||
)))
|
||||
Some("Audio"),
|
||||
vec![
|
||||
ui::toggle_row(
|
||||
p,
|
||||
"rec-game",
|
||||
"Game audio",
|
||||
a.enabled && a.capture_game,
|
||||
|app: &mut App| {
|
||||
let on =
|
||||
!(app.form.draft.audio.enabled && app.form.draft.audio.capture_game);
|
||||
app.form.draft.audio.enabled = on;
|
||||
app.form.draft.audio.capture_game = on;
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
ui::toggle_row(
|
||||
p,
|
||||
"rec-mic",
|
||||
"Microphone",
|
||||
a.capture_mic,
|
||||
|app: &mut App| {
|
||||
app.form.draft.audio.capture_mic ^= true;
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
mic_row(p, kit, layer, app, "rec-mic-device"),
|
||||
ui::setting_row_with(
|
||||
p,
|
||||
"rec-apps",
|
||||
"Applications",
|
||||
&source_summary(&a.capture_apps),
|
||||
ui::button(p, "edit-apps", "Edit", false, |app: &mut App| {
|
||||
app.settings_tab = SettingsTab::Audio;
|
||||
}),
|
||||
),
|
||||
],
|
||||
))
|
||||
}
|
||||
|
||||
/// The applications a clip takes sound from, as one line.
|
||||
fn source_summary(sources: &[AudioSource]) -> String {
|
||||
match sources.len() {
|
||||
0 => "None yet".to_string(),
|
||||
1 => sources[0].name.clone(),
|
||||
2 => format!("{} and {}", sources[0].name, sources[1].name),
|
||||
n => format!("{} and {} more", sources[0].name, n - 1),
|
||||
}
|
||||
}
|
||||
|
||||
/// The microphone picker: the system default plus every input device the daemon reports.
|
||||
|
||||
Reference in new issue
Block a user