pub struct ResolutionSelector {
pub max_bandwidth_bps: u64,
pub min_tier: ResolutionTier,
pub max_tier: ResolutionTier,
pub headroom_factor: f64,
}Expand description
Selects a resolution tier based on bandwidth or quality constraints.
Fields§
§max_bandwidth_bps: u64Maximum available bandwidth in bits per second.
min_tier: ResolutionTierMinimum acceptable tier.
max_tier: ResolutionTierMaximum acceptable tier.
headroom_factor: f64Headroom factor applied to the recommended bitrate when fitting. A value of 1.2 means 20 % safety margin is required.
Implementations§
Source§impl ResolutionSelector
impl ResolutionSelector
Sourcepub fn new(max_bandwidth_bps: u64) -> Self
pub fn new(max_bandwidth_bps: u64) -> Self
Create a selector with a specific bandwidth ceiling.
Sourcepub fn with_min_tier(self, tier: ResolutionTier) -> Self
pub fn with_min_tier(self, tier: ResolutionTier) -> Self
Set the minimum tier floor.
Sourcepub fn with_max_tier(self, tier: ResolutionTier) -> Self
pub fn with_max_tier(self, tier: ResolutionTier) -> Self
Set the maximum tier ceiling.
Sourcepub fn with_headroom(self, factor: f64) -> Self
pub fn with_headroom(self, factor: f64) -> Self
Set the headroom factor (must be >= 1.0).
Sourcepub fn select_for_bandwidth(&self) -> Option<ResolutionTier>
pub fn select_for_bandwidth(&self) -> Option<ResolutionTier>
Select the highest tier that fits within the configured bandwidth budget.
Returns None if no tier (not even the minimum) fits.
Sourcepub fn select_for_quality(&self) -> ResolutionTier
pub fn select_for_quality(&self) -> ResolutionTier
Select the maximum tier within the configured min/max bounds (ignores bandwidth).
Sourcepub fn all_tiers(&self) -> Vec<ResolutionTier>
pub fn all_tiers(&self) -> Vec<ResolutionTier>
Return all tiers that fall within the configured min/max bounds.
Sourcepub fn abr_ladder(&self) -> Vec<ResolutionTier>
pub fn abr_ladder(&self) -> Vec<ResolutionTier>
Build an ABR ladder: return all tiers that fit within the bandwidth budget.
Trait Implementations§
Source§impl Clone for ResolutionSelector
impl Clone for ResolutionSelector
Source§fn clone(&self) -> ResolutionSelector
fn clone(&self) -> ResolutionSelector
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResolutionSelector
impl Debug for ResolutionSelector
Source§impl Default for ResolutionSelector
impl Default for ResolutionSelector
Source§impl<'de> Deserialize<'de> for ResolutionSelector
impl<'de> Deserialize<'de> for ResolutionSelector
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ResolutionSelector
impl RefUnwindSafe for ResolutionSelector
impl Send for ResolutionSelector
impl Sync for ResolutionSelector
impl Unpin for ResolutionSelector
impl UnsafeUnpin for ResolutionSelector
impl UnwindSafe for ResolutionSelector
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
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>
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>
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