record-daemon: refactor and cleanup

This commit is contained in:
2026-03-21 00:05:46 +01:00
parent 1166424c29
commit 03e36d0f1b
12 changed files with 140 additions and 139 deletions
+1 -28
View File
@@ -193,33 +193,6 @@ pub enum SourceType {
MonitorCapture,
}
/// Find the League of Legends game window.
///
/// Returns the window title if found, or a default if not found.
pub fn find_league_window() -> Option<String> {
#[cfg(target_os = "windows")]
{
// On Windows, we can use the Win32 API to find the window
// For now, return the expected window title
Some("League of Legends (TM) Client".to_string())
}
#[cfg(target_os = "linux")]
{
// On Linux, we would use X11 or Wayland APIs
// For now, return the expected window title
Some("League of Legends (TM) Client".to_string())
}
#[cfg(not(any(target_os = "linux", target_os = "windows")))]
None
}
/// Get the default capture configuration for League of Legends.
pub fn league_capture_config() -> GameCapture {
GameCapture::for_league_of_legends()
}
#[cfg(test)]
mod tests {
use super::*;
@@ -244,7 +217,7 @@ mod tests {
#[test]
fn test_league_capture_config() {
let capture = league_capture_config();
let capture = GameCapture::for_league_of_legends();
assert_eq!(capture.name, "League of Legends Capture");
assert_eq!(
capture.process_name,
+7 -1
View File
@@ -11,7 +11,7 @@ mod output;
pub use capture::{CaptureMode, GameCapture, MonitorCapture, SourceType, WindowCapture};
pub use encoder::{AudioEncoderConfig, EncoderCapability, EncoderConfig, EncoderSettings};
pub use obs_context::{ObsContext, ObsContextBuilder};
pub use output::{OutputConfig, RecordingOutput, RecordingResult};
pub use output::{OutputConfig, OutputFormat, RecordingOutput, RecordingResult, RecordingStats};
use std::sync::Arc;
@@ -86,6 +86,11 @@ impl RecordingEngine {
self.is_recording
}
/// Get the current game ID if recording.
pub fn current_game_id(&self) -> Option<u64> {
self.current_output.as_ref().and_then(|o| o.game_id)
}
/// Start recording.
///
/// # Arguments
@@ -170,6 +175,7 @@ impl RecordingEngine {
start_time,
end_time,
duration,
stats: None, // Stats would be populated from OBS context if available
};
info!("Recording stopped: {:?}", result.path);
@@ -129,6 +129,11 @@ impl ObsContext {
&self.video_settings
}
/// Get the output directory for recordings.
pub fn output_dir(&self) -> &std::path::Path {
&self.output_dir
}
/// Initialize OBS.
fn initialize(&mut self) -> Result<()> {
if self.context.is_some() {
+4
View File
@@ -59,6 +59,9 @@ pub struct RecordingResult {
/// Recording duration.
// #[serde(with = "chrono::serde::seconds")]
pub duration: Duration,
/// Recording statistics (if available).
#[serde(skip_serializing_if = "Option::is_none")]
pub stats: Option<RecordingStats>,
}
impl RecordingResult {
@@ -209,6 +212,7 @@ mod tests {
start_time: Utc::now(),
end_time: Utc::now() + Duration::seconds(125),
duration: Duration::seconds(125),
stats: None,
};
assert_eq!(result.duration_human(), "2m 5s");