oximedia_proxy/workflow/
roundtrip.rs1use crate::{OfflineWorkflow, ProxyPreset, Result};
4use std::path::Path;
5
6pub struct RoundtripWorkflow {
8 offline: OfflineWorkflow,
9}
10
11impl RoundtripWorkflow {
12 pub async fn new(db_path: impl AsRef<Path>) -> Result<Self> {
18 let offline = OfflineWorkflow::new(db_path).await?;
19 Ok(Self { offline })
20 }
21
22 pub async fn phase_ingest(
28 &mut self,
29 originals: &[impl AsRef<Path>],
30 proxy_dir: impl AsRef<Path>,
31 preset: ProxyPreset,
32 ) -> Result<()> {
33 for original in originals {
34 let filename = original
35 .as_ref()
36 .file_name()
37 .and_then(|n| n.to_str())
38 .unwrap_or("proxy.mp4");
39
40 let proxy_path = proxy_dir.as_ref().join(filename);
41
42 self.offline.ingest(original, proxy_path, preset).await?;
43 }
44
45 Ok(())
46 }
47
48 pub fn phase_edit(&self) -> Result<String> {
50 Ok("Edit with your NLE using proxy files".to_string())
51 }
52
53 pub async fn phase_conform(
59 &self,
60 edl_path: impl AsRef<Path>,
61 output: impl AsRef<Path>,
62 ) -> Result<crate::ConformResult> {
63 self.offline.conform(edl_path, output).await
64 }
65
66 pub async fn phase_deliver(&self, _output: impl AsRef<Path>) -> Result<()> {
68 Ok(())
70 }
71}
72
73#[cfg(test)]
74mod tests {
75 use super::*;
76
77 #[tokio::test]
78 async fn test_roundtrip_workflow_creation() {
79 let temp_dir = std::env::temp_dir();
80 let db_path = temp_dir.join("test_roundtrip.json");
81
82 let workflow = RoundtripWorkflow::new(&db_path).await;
83 assert!(workflow.is_ok());
84
85 let _ = std::fs::remove_file(db_path);
87 }
88}