Skip to content

Commit b82ab74

Browse files
committed
[*] refactoring ui
1 parent 3a45903 commit b82ab74

File tree

12 files changed

+263
-516
lines changed

12 files changed

+263
-516
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ crossbeam = "0.8"
9999
spin_sleep = "1.3"
100100
nnnoiseless = "0.5"
101101
h264-reader = "0.8"
102-
ffmpeg-sidecar = "2.2"
103102
derive_builder = "0.20"
104103
wayland-client = "0.31"
105104
fast_image_resize = "5.3"

lib/recorder/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ derive_setters.workspace = true
2929
yuv = { workspace = true, features = ["rayon"] }
3030
fast_image_resize = { workspace = true, features = ["rayon"] }
3131

32-
# ffmpeg-sidecar.workspace = true
33-
3432
[dev-dependencies]
3533
ctrlc.workspace = true
3634
env_logger.workspace = true

lib/recorder/examples/recording_10m_demo.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,23 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
2929
let config = RecorderConfig::new(
3030
screen_infos[0].name.clone(),
3131
screen_infos[0].logical_size.clone(),
32-
RecorderConfig::make_filename("target"),
32+
RecorderConfig::make_filename("/tmp"),
3333
)
3434
.with_enable_recording_speaker(true)
35-
// .with_audio_device_name(Some(default_input.name))
35+
.with_audio_device_name(Some(default_input.name))
36+
.with_resolution(recorder::Resolution::Original((
37+
screen_infos[0].logical_size.width as u32,
38+
screen_infos[0].logical_size.height as u32,
39+
)))
3640
.with_fps(FPS::Fps30);
37-
// .with_resolution(recorder::Resolution::Original((
38-
// screen_infos[0].logical_size.width as u32,
39-
// screen_infos[0].logical_size.height as u32,
40-
// )));
4141

4242
log::debug!("Recording configuration: {:#?}", config);
4343

4444
let mut session = RecordingSession::new(config);
4545

4646
let stop_sig = session.get_stop_sig().clone();
47-
48-
// Start a timer thread that stops recording after 5 seconds
4947
thread::spawn(move || {
50-
thread::sleep(Duration::from_secs(3600));
48+
thread::sleep(Duration::from_secs(600));
5149
log::debug!("5 seconds elapsed, stopping recording...");
5250
stop_sig.store(true, Ordering::Relaxed);
5351
});

lib/recorder/src/recorder.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use mp4m::{
1515
use once_cell::sync::Lazy;
1616
use spin_sleep::SpinSleeper;
1717
use std::{
18+
path::PathBuf,
1819
sync::{
1920
Arc, Mutex,
2021
atomic::{AtomicBool, AtomicU64, Ordering},
@@ -115,6 +116,22 @@ impl RecordingSession {
115116
}
116117

117118
pub fn start(&mut self) -> Result<(), RecorderError> {
119+
if !self
120+
.config
121+
.save_path
122+
.parent()
123+
.ok_or(RecorderError::InvalidConfig(format!(
124+
"No parent directory found: {}",
125+
self.config.save_path.display()
126+
)))?
127+
.exists()
128+
{
129+
return Err(RecorderError::InvalidConfig(format!(
130+
"Save directory no found: {}",
131+
self.config.save_path.parent().unwrap().display()
132+
)));
133+
}
134+
118135
let thread_counts = self.evaluate_need_threads();
119136
if thread_counts == 0 {
120137
return Err(RecorderError::Other(format!("capture thread counts is 0")));
@@ -655,6 +672,10 @@ impl RecordingSession {
655672
Ok(img.convert())
656673
}
657674

675+
pub fn save_path(&self) -> PathBuf {
676+
self.config.save_path.clone()
677+
}
678+
658679
pub fn stop(&self) {
659680
self.stop_sig.store(true, Ordering::Relaxed);
660681
}

wayshot/src/config.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,10 @@ pub struct Preference {
120120
#[from("UISettingRecorder")]
121121
pub struct Recorder {
122122
pub save_dir: String,
123-
pub remove_temporary_files: bool,
124123

125124
#[derivative(Default(value = "true"))]
126125
pub include_cursor: bool,
127126

128-
#[derivative(Default(value = "true"))]
129-
pub enable_preview: bool,
130-
131127
pub enable_denoise: bool,
132128

133129
pub convert_to_mono: bool,
@@ -147,21 +143,21 @@ crate::impl_slint_enum_serde!(UIResolution, Original, P720, P1080, P2K, P4K);
147143
#[from("UISettingControl")]
148144
pub struct Control {
149145
pub screen: String,
150-
pub input_audio: String,
146+
pub audio: String,
151147

152148
// db
153149
#[derivative(Default(value = "0.0"))]
154-
pub input_audio_gain: f32,
150+
pub audio_gain: f32,
155151

156152
#[derivative(Default(value = "true"))]
157-
pub enable_input_audio: bool,
153+
pub enable_audio: bool,
158154

159155
// db
160156
#[derivative(Default(value = "0.0"))]
161-
pub desktop_speaker_gain: f32,
157+
pub speaker_gain: f32,
162158

163159
#[derivative(Default(value = "true"))]
164-
pub enable_desktop_speaker: bool,
160+
pub enable_speaker: bool,
165161
}
166162

167163
impl Config {

0 commit comments

Comments
 (0)