use std::time::Duration;
use str0m::bwe::BweKind;
use str0m::stats::PeerStats;
use crate::bandwidth::BandwidthEstimate;
use crate::propagate::{ClientId, Propagated};
use crate::rtcp_stats::PeerRtcpStats;
pub(super) fn propagate_bwe(peer_id: ClientId, bwe: BweKind) -> Propagated {
let bps = match bwe {
BweKind::Twcc(bitrate) | BweKind::Remb(_, bitrate) => bitrate.as_u64(),
_ => 0,
};
Propagated::BandwidthEstimate {
peer_id,
estimate: BandwidthEstimate { bps },
}
}
pub(super) fn propagate_peer_stats(peer_id: ClientId, s: PeerStats) -> Propagated {
Propagated::RtcpStats {
peer_id,
stats: PeerRtcpStats {
fraction_lost: s.egress_loss_fraction.unwrap_or(0.0),
rtt: s.rtt.unwrap_or(Duration::ZERO),
jitter: Duration::ZERO,
},
}
}