oximedia_proxy/conform/
xml.rs1use super::engine::ConformResult;
4use crate::{ProxyError, ProxyLinkManager, Result};
5use std::path::Path;
6
7pub struct XmlConformer<'a> {
9 #[allow(dead_code)]
10 link_manager: &'a ProxyLinkManager,
11}
12
13impl<'a> XmlConformer<'a> {
14 #[must_use]
16 pub const fn new(link_manager: &'a ProxyLinkManager) -> Self {
17 Self { link_manager }
18 }
19
20 pub async fn conform(
26 &self,
27 xml_path: impl AsRef<Path>,
28 output: impl AsRef<Path>,
29 ) -> Result<ConformResult> {
30 let xml_path = xml_path.as_ref();
31 let output = output.as_ref();
32
33 if !xml_path.exists() {
35 return Err(ProxyError::FileNotFound(xml_path.display().to_string()));
36 }
37
38 tracing::info!(
46 "Conforming XML {} to {}",
47 xml_path.display(),
48 output.display()
49 );
50
51 Ok(ConformResult {
52 output_path: output.to_path_buf(),
53 clips_relinked: 0,
54 clips_failed: 0,
55 total_duration: 0.0,
56 frame_accurate: true,
57 })
58 }
59
60 pub fn detect_format(&self, xml_path: impl AsRef<Path>) -> Result<XmlFormat> {
62 let _xml_path = xml_path.as_ref();
63
64 Ok(XmlFormat::FinalCutPro)
66 }
67}
68
69#[derive(Debug, Clone, Copy, PartialEq, Eq)]
71pub enum XmlFormat {
72 FinalCutPro,
74 PremierePro,
76 Resolve,
78 Unknown,
80}
81
82#[cfg(test)]
83mod tests {
84 use super::*;
85
86 #[tokio::test]
87 async fn test_xml_conformer() {
88 let temp_dir = std::env::temp_dir();
89 let db_path = temp_dir.join("test_xml_conform.json");
90
91 let manager = ProxyLinkManager::new(&db_path)
92 .await
93 .expect("should succeed in test");
94 let conformer = XmlConformer::new(&manager);
95
96 let format = conformer
97 .detect_format("test.xml")
98 .expect("should succeed in test");
99 assert_eq!(format, XmlFormat::FinalCutPro);
100
101 let _ = std::fs::remove_file(db_path);
103 }
104}