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,44 @@
|
||||
use anyhow::{anyhow, Result};
|
||||
use crate::domain::entities::Project;
|
||||
use crate::domain::value_objects::{TrackId, TrackLanguage};
|
||||
|
||||
/// Altera o idioma de uma faixa externa pelo TrackId.
|
||||
pub struct SetTrackLanguage;
|
||||
|
||||
impl SetTrackLanguage {
|
||||
pub fn execute(project: &mut Project, id: TrackId, language: TrackLanguage) -> Result<()> {
|
||||
let track = project
|
||||
.find_track_mut(id)
|
||||
.ok_or_else(|| anyhow!("Faixa não encontrada: {:?}", id))?;
|
||||
track.set_language(language);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::application::use_cases::add_audio_track::AddAudioTrack;
|
||||
use crate::domain::entities::{MkvOutput, Project, VideoFile};
|
||||
use crate::domain::value_objects::{FilePath, SyncOffset};
|
||||
|
||||
#[test]
|
||||
fn altera_idioma_da_faixa() {
|
||||
let mut project = Project::new(
|
||||
VideoFile::new(FilePath::from("input.mkv")),
|
||||
MkvOutput::new(FilePath::from("output.mkv")),
|
||||
)
|
||||
.unwrap();
|
||||
AddAudioTrack::execute(
|
||||
&mut project,
|
||||
FilePath::from("audio.aac"),
|
||||
SyncOffset::default(),
|
||||
TrackLanguage::new("por").unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let id = project.tracks[0].id();
|
||||
|
||||
SetTrackLanguage::execute(&mut project, id, TrackLanguage::new("eng").unwrap()).unwrap();
|
||||
assert_eq!(project.tracks[0].language().as_str(), "eng");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user