Skip to main content

oxpulse_sfu_kit/
bandwidth.rs

1//! Bandwidth estimation types for the kit.
2//!
3//! str0m 0.18 internally runs a libWebRTC GoogCC (`src/bwe/`) — trendline delay
4//! estimator + MLE loss controller + leaky-bucket pacer — and surfaces its output
5//! via `str0m::Event::EgressBitrateEstimate(BweKind)`. The kit translates that
6//! event into `Propagated::BandwidthEstimate` so downstream room logic or a
7//! `LayerSelector` implementation can adapt forwarding without importing str0m types.
8//!
9//! # str0m 0.18 divergence
10//!
11//! str0m's `BweKind` carries only a single `Bitrate` value (either from TWCC or
12//! REMB). There are no min/max bounds or estimator uptime fields on the event.
13//! `BandwidthEstimate` therefore exposes only `bps`; callers should not assume
14//! lower/upper bounds are available from this event type.
15
16/// Aggregated egress bandwidth estimate for a peer's outgoing stream.
17///
18/// Units: bits per second. `0` is legal — it means the estimator has observed
19/// network failure or has no data yet.
20///
21/// Emitted from str0m's internal GoogCC each time the estimator produces a new
22/// value (typically every 100–500 ms, driven by TWCC or REMB feedback).
23#[derive(Debug, Clone, Copy, PartialEq)]
24pub struct BandwidthEstimate {
25    /// Current estimate in bits per second.
26    pub bps: u64,
27}
28
29impl BandwidthEstimate {
30    /// Zero-bandwidth fallback useful in tests and as a safe initializer.
31    pub fn zero() -> Self {
32        Self { bps: 0 }
33    }
34}