oximedia_proxy/conform/
engine.rs1use super::edl::EdlConformer;
4use crate::{ProxyLinkManager, Result};
5use std::path::Path;
6
7pub struct ConformEngine {
9 link_manager: ProxyLinkManager,
10}
11
12impl ConformEngine {
13 pub async fn new(db_path: impl AsRef<Path>) -> Result<Self> {
19 let link_manager = ProxyLinkManager::new(db_path).await?;
20 Ok(Self { link_manager })
21 }
22
23 pub async fn conform_from_edl(
29 &self,
30 edl_path: impl AsRef<Path>,
31 output: impl AsRef<Path>,
32 ) -> Result<ConformResult> {
33 let conformer = EdlConformer::new(&self.link_manager);
34 conformer.conform(edl_path, output).await
35 }
36
37 pub fn relink(&self, proxy_path: impl AsRef<Path>) -> Result<&Path> {
43 self.link_manager.get_original(proxy_path)
44 }
45
46 #[must_use]
48 pub const fn link_manager(&self) -> &ProxyLinkManager {
49 &self.link_manager
50 }
51}
52
53#[derive(Debug, Clone)]
55pub struct ConformResult {
56 pub output_path: std::path::PathBuf,
58
59 pub clips_relinked: usize,
61
62 pub clips_failed: usize,
64
65 pub total_duration: f64,
67
68 pub frame_accurate: bool,
70}
71
72#[cfg(test)]
73mod tests {
74 use super::*;
75
76 #[tokio::test]
77 async fn test_conform_engine_creation() {
78 let temp_dir = std::env::temp_dir();
79 let db_path = temp_dir.join("test_conform.json");
80
81 let engine = ConformEngine::new(&db_path).await;
82 assert!(engine.is_ok());
83
84 let _ = std::fs::remove_file(db_path);
86 }
87}