pub struct CueSheet { /* private fields */ }Expand description
One composition clock for narration, captions and named animation markers. This plans media; it never synthesizes speech or reads a playback clock.
Implementations§
Source§impl CueSheet
impl CueSheet
Sourcepub fn new(
duration: Duration,
captions: CaptionTrack,
) -> Result<Self, ValidationError>
pub fn new( duration: Duration, captions: CaptionTrack, ) -> Result<Self, ValidationError>
Validates a positive duration of at most 24 hours and contained captions.
Sourcepub fn mark(
self,
name: impl Into<String>,
time: Duration,
) -> Result<Self, ValidationError>
pub fn mark( self, name: impl Into<String>, time: Duration, ) -> Result<Self, ValidationError>
Adds one unique marker, including an optional exact end marker. At most 256 names of 1..=128 UTF-8 bytes without controls are accepted.
Sourcepub fn duration(&self) -> Duration
pub fn duration(&self) -> Duration
Returns the declared duration, without rounding it to a frame rate.
Sourcepub fn captions(&self) -> &CaptionTrack
pub fn captions(&self) -> &CaptionTrack
Returns captions in their original order, including intentional overlaps.
Sourcepub fn retimed(&self, duration: Duration) -> Result<Self, ValidationError>
pub fn retimed(&self, duration: Duration) -> Result<Self, ValidationError>
Uniformly retimes captions and markers to a new duration in (0,24h].
Exact integer ratios round nanoseconds to nearest, ties upward; collapsed
cues are errors. Rebuild cached captions afterward. Audio is NOT stretched:
remeasure/re-record it and use audio_clip to check the new intervals.
Sourcepub fn time(&self, name: &str) -> Result<Duration, ValidationError>
pub fn time(&self, name: &str) -> Result<Duration, ValidationError>
Resolves a name; missing names are errors rather than time zero.
Sourcepub fn elapsed(
&self,
time: Time,
name: &str,
) -> Result<Option<Duration>, ValidationError>
pub fn elapsed( &self, time: Time, name: &str, ) -> Result<Option<Duration>, ValidationError>
Returns elapsed time since a marker while this composition is active. Frame and marker times share one clock; sequence-local frames are not rebased. Comparisons use exact integer cross-products; elapsed nanoseconds round down.
Sourcepub fn progress(
&self,
time: Time,
start: &str,
end: &str,
) -> Result<f64, ValidationError>
pub fn progress( &self, time: Time, start: &str, end: &str, ) -> Result<f64, ValidationError>
Samples clamped animation progress between two strictly ordered markers.
Sourcepub fn audio_clip(
&self,
cue: usize,
audio: Arc<dyn AudioSource>,
source: (Time, Time),
) -> Result<AudioClip>
pub fn audio_clip( &self, cue: usize, audio: Arc<dyn AudioSource>, source: (Time, Time), ) -> Result<AudioClip>
Places a measured source interval at a caption’s start, without truncation. The caller obtains source duration separately; this does not probe media.