- 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.
50 lines
1.5 KiB
Rust
50 lines
1.5 KiB
Rust
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.
|
|
#[allow(dead_code)]
|
|
pub struct SetTrackLanguage;
|
|
|
|
impl SetTrackLanguage {
|
|
#[allow(dead_code)]
|
|
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(),
|
|
false,
|
|
String::new(),
|
|
1.0,
|
|
)
|
|
.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");
|
|
}
|
|
}
|