feat: implement project management and media track handling
- Added domain entities for audio, subtitle, and video tracks. - Created a Project entity to manage media editing sessions. - Implemented value objects for file paths, sync offsets, track IDs, and languages. - Developed infrastructure for asynchronous FFmpeg process execution. - Built a user interface for selecting video files, adding audio and subtitle tracks, and managing output settings. - Integrated error handling and logging for media processing tasks.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
use anyhow::Result;
|
||||
use crate::domain::entities::{AudioTrack, Project, Track};
|
||||
use crate::domain::value_objects::{FilePath, SyncOffset, TrackLanguage};
|
||||
|
||||
/// Adiciona uma faixa de áudio externa ao projeto.
|
||||
pub struct AddAudioTrack;
|
||||
|
||||
impl AddAudioTrack {
|
||||
pub fn execute(
|
||||
project: &mut Project,
|
||||
path: FilePath,
|
||||
offset: SyncOffset,
|
||||
language: TrackLanguage,
|
||||
) -> Result<()> {
|
||||
let id = project.next_track_id();
|
||||
let track = AudioTrack::new(id, path, offset, language);
|
||||
project.tracks.push(Track::Audio(track));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::domain::entities::{MkvOutput, VideoFile};
|
||||
use crate::domain::value_objects::FilePath;
|
||||
|
||||
#[test]
|
||||
fn adiciona_audio_no_projeto() {
|
||||
let mut project = Project::new(
|
||||
VideoFile::new(FilePath::from("input.mkv")),
|
||||
MkvOutput::new(FilePath::from("output.mkv")),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let lang = TrackLanguage::new("por").unwrap();
|
||||
AddAudioTrack::execute(
|
||||
&mut project,
|
||||
FilePath::from("audio_pt.aac"),
|
||||
SyncOffset::default(),
|
||||
lang,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(project.tracks.len(), 1);
|
||||
assert!(matches!(project.tracks[0], Track::Audio(_)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user