pub struct BitrateEstimator {
pub mode: RateControlMode,
pub history: Vec<u32>,
}Expand description
Tracks per-frame sizes and derives a rolling bitrate estimate.
Fields§
§mode: RateControlModeRate-control mode in use.
history: Vec<u32>History of frame sizes in bytes (most recent last).
Implementations§
Source§impl BitrateEstimator
impl BitrateEstimator
Sourcepub fn new(mode: RateControlMode) -> Self
pub fn new(mode: RateControlMode) -> Self
Creates a new estimator for the given mode.
Sourcepub fn add_frame_size_bytes(&mut self, size: u32)
pub fn add_frame_size_bytes(&mut self, size: u32)
Appends a frame’s encoded size (in bytes) to the history.
Sourcepub fn current_kbps(&self, fps: f32) -> f32
pub fn current_kbps(&self, fps: f32) -> f32
Estimates the current bitrate in kbps given the encoding frame rate.
Returns 0.0 if no frames have been recorded or fps is zero/negative.
Trait Implementations§
Source§impl Clone for BitrateEstimator
impl Clone for BitrateEstimator
Source§fn clone(&self) -> BitrateEstimator
fn clone(&self) -> BitrateEstimator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BitrateEstimator
impl RefUnwindSafe for BitrateEstimator
impl Send for BitrateEstimator
impl Sync for BitrateEstimator
impl Unpin for BitrateEstimator
impl UnsafeUnpin for BitrateEstimator
impl UnwindSafe for BitrateEstimator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more