- Implemented AdjustExistingTrackDrift struct with execute method to modify drift scale of existing tracks in a project. - Added tests for adjusting drift scale, handling non-existent track IDs, and invalid scale values. - Updated MediaTrackInfo and AudioTrack entities to include drift_scale field. - Enhanced Project entity with needs_mkvmerge method to determine if mkvmerge is required based on drift scale. - Integrated drift scale adjustments into existing track list UI, allowing users to modify drift values. - Updated various use cases and UI components to support drift scale functionality, including add audio/subtitle forms and batch processing. - Implemented mkvmerge availability check and integrated it into the application workflow for conditional processing.
58 lines
1.6 KiB
Rust
58 lines
1.6 KiB
Rust
use crate::domain::entities::Project;
|
|
use crate::domain::value_objects::TrackId;
|
|
use anyhow::{Result, anyhow};
|
|
|
|
/// Remove uma faixa externa do projeto pelo seu TrackId.
|
|
pub struct RemoveTrack;
|
|
|
|
impl RemoveTrack {
|
|
pub fn execute(project: &mut Project, id: TrackId) -> Result<()> {
|
|
if project.remove_track(id) {
|
|
Ok(())
|
|
} else {
|
|
Err(anyhow!("Faixa com id {:?} não encontrada.", id))
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use crate::domain::entities::{AudioTrack, MkvOutput, Project, Track, VideoFile};
|
|
use crate::domain::value_objects::{FilePath, SyncOffset, TrackId, TrackLanguage};
|
|
|
|
fn make_project() -> Project {
|
|
Project::new(
|
|
VideoFile::new(FilePath::from("input.mkv")),
|
|
MkvOutput::new(FilePath::from("output.mkv")),
|
|
)
|
|
.unwrap()
|
|
}
|
|
|
|
#[test]
|
|
fn remove_faixa_existente() {
|
|
let mut project = make_project();
|
|
let id = project.next_track_id();
|
|
project.tracks.push(Track::Audio(AudioTrack::new(
|
|
id,
|
|
FilePath::from("audio.aac"),
|
|
SyncOffset::from_ms(0),
|
|
TrackLanguage::new("por").unwrap(),
|
|
false,
|
|
String::new(),
|
|
1.0,
|
|
)));
|
|
assert_eq!(project.tracks.len(), 1);
|
|
|
|
RemoveTrack::execute(&mut project, id).unwrap();
|
|
assert!(project.tracks.is_empty());
|
|
}
|
|
|
|
#[test]
|
|
fn erro_se_id_inexistente() {
|
|
let mut project = make_project();
|
|
let result = RemoveTrack::execute(&mut project, TrackId::new(99));
|
|
assert!(result.is_err());
|
|
}
|
|
}
|