Struct subtr_actor::collector::decorator::FrameRateDecorator
source · pub struct FrameRateDecorator<'a, C> { /* private fields */ }
Expand description
A struct which decorates a Collector
implementation with a target frame
duration, in order to control the frame rate of the replay processing. If a
frame is processed and the next desired frame time is before the
target_frame_duration
, TimeAdvance::Time
is used to ensure the next
frame will only be processed after the target_frame_duration
has passed.
Implementations§
source§impl<'a, C> FrameRateDecorator<'a, C>
impl<'a, C> FrameRateDecorator<'a, C>
sourcepub fn new(target_frame_duration: f32, collector: &'a mut C) -> Self
pub fn new(target_frame_duration: f32, collector: &'a mut C) -> Self
Constructs a new FrameRateDecorator
instance with a given target
frame duration and underlying Collector
reference.
Arguments
target_frame_duration
: The target duration for each frame in seconds.collector
: A mutable reference to the underlyingCollector
instance.
sourcepub fn new_from_fps(fps: f32, collector: &'a mut C) -> Self
pub fn new_from_fps(fps: f32, collector: &'a mut C) -> Self
Constructs a new FrameRateDecorator
instance with a desired frames
per second (fps) rate and underlying Collector
reference. The target
frame duration is computed as the reciprocal of the fps value.
Arguments
fps
: The desired frame rate in frames per second.collector
: A mutable reference to the underlyingCollector
instance.
Trait Implementations§
source§impl<'a, C: Collector> Collector for FrameRateDecorator<'a, C>
impl<'a, C: Collector> Collector for FrameRateDecorator<'a, C>
source§fn process_frame(
&mut self,
processor: &ReplayProcessor<'_>,
frame: &Frame,
frame_number: usize,
current_time: f32
) -> SubtrActorResult<TimeAdvance>
fn process_frame( &mut self, processor: &ReplayProcessor<'_>, frame: &Frame, frame_number: usize, current_time: f32 ) -> SubtrActorResult<TimeAdvance>
Processes the given frame, delegating to the underlying Collector
’s
process_frame
method, then adjusts the
returned TimeAdvance
based on the target frame duration.
If the original TimeAdvance
was TimeAdvance::NextFrame
or a
TimeAdvance::Time
less than the target frame duration, this method
returns a TimeAdvance::Time
equal to the current time plus the
target frame duration.
If the original TimeAdvance
was a TimeAdvance::Time
greater than
the target frame duration, this method returns the original
TimeAdvance::Time
.