- 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.
67 lines
1.8 KiB
Rust
67 lines
1.8 KiB
Rust
use crate::domain::entities::{AudioTrack, SubtitleTrack};
|
|
use crate::domain::value_objects::{SyncOffset, TrackId, TrackLanguage};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// Faixa externa adicionada pelo usuário ao projeto.
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub enum Track {
|
|
Audio(AudioTrack),
|
|
Subtitle(SubtitleTrack),
|
|
}
|
|
|
|
impl Track {
|
|
pub fn id(&self) -> TrackId {
|
|
match self {
|
|
Track::Audio(t) => t.id,
|
|
Track::Subtitle(t) => t.id,
|
|
}
|
|
}
|
|
|
|
pub fn offset(&self) -> SyncOffset {
|
|
match self {
|
|
Track::Audio(t) => t.offset,
|
|
Track::Subtitle(t) => t.offset,
|
|
}
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub fn language(&self) -> &TrackLanguage {
|
|
match self {
|
|
Track::Audio(t) => &t.language,
|
|
Track::Subtitle(t) => &t.language,
|
|
}
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub fn set_offset(&mut self, offset: SyncOffset) {
|
|
match self {
|
|
Track::Audio(t) => t.offset = offset,
|
|
Track::Subtitle(t) => t.offset = offset,
|
|
}
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub fn set_language(&mut self, language: TrackLanguage) {
|
|
match self {
|
|
Track::Audio(t) => t.language = language,
|
|
Track::Subtitle(t) => t.language = language,
|
|
}
|
|
}
|
|
|
|
/// Retorna o fator de escala temporal da faixa.
|
|
pub fn drift_scale(&self) -> f64 {
|
|
match self {
|
|
Track::Audio(t) => t.drift_scale,
|
|
Track::Subtitle(t) => t.drift_scale,
|
|
}
|
|
}
|
|
|
|
/// Define o fator de escala temporal da faixa.
|
|
pub fn set_drift_scale(&mut self, scale: f64) {
|
|
match self {
|
|
Track::Audio(t) => t.drift_scale = scale,
|
|
Track::Subtitle(t) => t.drift_scale = scale,
|
|
}
|
|
}
|
|
}
|