use std::time::Instant;
#[allow(dead_code)]
pub struct SfuRtc(pub(crate) str0m::Rtc);
impl std::fmt::Debug for SfuRtc {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("SfuRtc").finish_non_exhaustive()
}
}
impl SfuRtc {
pub fn from_raw(rtc: str0m::Rtc) -> Self {
Self(rtc)
}
}
#[derive(Debug)]
pub struct SfuRtcBuilder {
inner: str0m::RtcConfig,
}
impl Default for SfuRtcBuilder {
fn default() -> Self {
Self::new()
}
}
impl SfuRtcBuilder {
#[must_use]
pub fn new() -> Self {
Self {
inner: str0m::RtcConfig::default(),
}
}
#[must_use]
pub fn enable_bwe(mut self, initial_bitrate_bps: u64) -> Self {
self.inner = self
.inner
.enable_bwe(Some(str0m::bwe::Bitrate::bps(initial_bitrate_bps)));
self
}
#[must_use]
pub fn build(self) -> SfuRtc {
SfuRtc(self.inner.build(Instant::now()))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn builder_produces_sfu_rtc() {
let rtc = SfuRtcBuilder::new().build();
let dbg = format!("{rtc:?}");
assert!(dbg.contains("SfuRtc"), "Debug output should mention SfuRtc");
}
#[test]
fn from_raw_preserves_rtc() {
let raw = str0m::Rtc::new(Instant::now());
let sfu = SfuRtc::from_raw(raw);
let dbg = format!("{sfu:?}");
assert!(dbg.contains("SfuRtc"));
}
}