| 1 | use std::collections::VecDeque; |
| 2 | use std::time::{Duration, Instant}; |
| 3 | |
| 4 | use libwebrtc::stats::{QualityLimitationReason, RtcStats}; |
| 5 | |
| 6 | use crate::renegotiation::MediaPath; |
| 7 | |
| 8 | const SUSTAIN: Duration = Duration::from_secs(5); |
| 9 | const RECOVERY: Duration = Duration::from_secs(10); |
| 10 | const LIMIT_WINDOW: Duration = Duration::from_secs(10); |
| 11 | const LIMIT_SHARE: f32 = 0.5; |
| 12 | const POOR_LOSS_PERCENT: f64 = 5.; |
| 13 | const POOR_ROUND_TRIP_MS: f64 = 400.; |
| 14 | const POOR_JITTER_MS: f64 = 30.; |
| 15 | const BAD_LOSS_PERCENT: f64 = 10.; |
| 16 | const BAD_ROUND_TRIP_MS: f64 = 500.; |
| 17 | |
| 18 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] |
| 19 | pub enum NetworkLevel { |
| 20 | Good, |
| 21 | Poor, |
| 22 | Bad, |
| 23 | } |
| 24 | |
| 25 | impl NetworkLevel { |
| 26 | fn better(self) -> Self { |
| 27 | match self { |
| 28 | NetworkLevel::Bad => NetworkLevel::Poor, |
| 29 | _ => NetworkLevel::Good, |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] |
| 35 | pub enum Limitation { |
| 36 | #[default] |
| 37 | None, |
| 38 | Cpu, |
| 39 | Bandwidth, |
| 40 | } |
| 41 | |
| 42 | #[derive(Debug, Clone, Copy, PartialEq, Default)] |
| 43 | pub struct HealthSample { |
| 44 | pub loss_percent: f64, |
| 45 | pub round_trip_ms: f64, |
| 46 | pub jitter_ms: f64, |
| 47 | pub sent_kbps: f64, |
| 48 | pub received_kbps: f64, |
| 49 | pub limitation: Limitation, |
| 50 | } |
| 51 | |
| 52 | impl HealthSample { |
| 53 | fn is_bad(&self) -> bool { |
| 54 | self.loss_percent > BAD_LOSS_PERCENT || self.round_trip_ms > BAD_ROUND_TRIP_MS |
| 55 | } |
| 56 | |
| 57 | fn is_poor(&self) -> bool { |
| 58 | self.is_bad() |
| 59 | || self.loss_percent > POOR_LOSS_PERCENT |
| 60 | || self.round_trip_ms > POOR_ROUND_TRIP_MS |
| 61 | || self.jitter_ms > POOR_JITTER_MS |
| 62 | } |
| 63 | |
| 64 | fn instant_level(&self) -> NetworkLevel { |
| 65 | if self.is_bad() { |
| 66 | NetworkLevel::Bad |
| 67 | } else if self.is_poor() { |
| 68 | NetworkLevel::Poor |
| 69 | } else { |
| 70 | NetworkLevel::Good |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | #[derive(Debug, Clone, PartialEq, Eq, Default)] |
| 76 | pub struct TransportDetails { |
| 77 | pub dtls_state: String, |
| 78 | pub tls_version: String, |
| 79 | pub dtls_cipher: String, |
| 80 | pub srtp_cipher: String, |
| 81 | pub local_fingerprint: String, |
| 82 | pub remote_fingerprint: String, |
| 83 | } |
| 84 | |
| 85 | #[derive(Debug, Clone, PartialEq)] |
| 86 | pub struct CallHealth { |
| 87 | pub level: NetworkLevel, |
| 88 | pub cpu_limited: bool, |
| 89 | pub sample: HealthSample, |
| 90 | pub transport: TransportDetails, |
| 91 | pub path: MediaPath, |
| 92 | } |
| 93 | |
| 94 | #[derive(Debug, Clone, Copy, PartialEq)] |
| 95 | pub struct Quality { |
| 96 | pub level: NetworkLevel, |
| 97 | pub cpu_limited: bool, |
| 98 | } |
| 99 | |
| 100 | pub struct QualityTracker { |
| 101 | level: NetworkLevel, |
| 102 | poor_since: Option<Instant>, |
| 103 | bad_since: Option<Instant>, |
| 104 | recovering_since: Option<Instant>, |
| 105 | limits: VecDeque<(Instant, Limitation)>, |
| 106 | } |
| 107 | |
| 108 | impl Default for QualityTracker { |
| 109 | fn default() -> Self { |
| 110 | QualityTracker { |
| 111 | level: NetworkLevel::Good, |
| 112 | poor_since: None, |
| 113 | bad_since: None, |
| 114 | recovering_since: None, |
| 115 | limits: VecDeque::new(), |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | fn run_since(since: &mut Option<Instant>, holds: bool, now: Instant) -> bool { |
| 121 | if !holds { |
| 122 | *since = None; |
| 123 | return false; |
| 124 | } |
| 125 | now.duration_since(*since.get_or_insert(now)) >= SUSTAIN |
| 126 | } |
| 127 | |
| 128 | impl QualityTracker { |
| 129 | pub fn observe(&mut self, now: Instant, sample: &HealthSample) -> Quality { |
| 130 | self.limits.push_back((now, sample.limitation)); |
| 131 | while self.limits.front().is_some_and(|(at, _)| now.duration_since(*at) > LIMIT_WINDOW) { |
| 132 | self.limits.pop_front(); |
| 133 | } |
| 134 | let bad = run_since(&mut self.bad_since, sample.is_bad(), now); |
| 135 | let poor = run_since(&mut self.poor_since, sample.is_poor(), now); |
| 136 | let target = if bad { |
| 137 | NetworkLevel::Bad |
| 138 | } else if poor { |
| 139 | NetworkLevel::Poor |
| 140 | } else { |
| 141 | NetworkLevel::Good |
| 142 | }; |
| 143 | if target > self.level { |
| 144 | self.level = target; |
| 145 | self.recovering_since = None; |
| 146 | } else if sample.instant_level() < self.level { |
| 147 | let since = *self.recovering_since.get_or_insert(now); |
| 148 | if now.duration_since(since) >= RECOVERY { |
| 149 | self.level = self.level.better(); |
| 150 | self.recovering_since = None; |
| 151 | } |
| 152 | } else { |
| 153 | self.recovering_since = None; |
| 154 | } |
| 155 | Quality { level: self.level, cpu_limited: self.share_of(Limitation::Cpu, now) > LIMIT_SHARE } |
| 156 | } |
| 157 | |
| 158 | fn share_of(&self, limitation: Limitation, now: Instant) -> f32 { |
| 159 | let spans_window = self.limits.front().is_some_and(|(at, _)| now.duration_since(*at) >= SUSTAIN); |
| 160 | if !spans_window { |
| 161 | return 0.; |
| 162 | } |
| 163 | let matching = self.limits.iter().filter(|(_, found)| *found == limitation).count(); |
| 164 | matching as f32 / self.limits.len() as f32 |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | #[derive(Debug, Clone, Copy, PartialEq, Default)] |
| 169 | pub struct HealthCounters { |
| 170 | pub packets_received: u64, |
| 171 | pub packets_lost: u64, |
| 172 | pub bytes_sent: u64, |
| 173 | pub bytes_received: u64, |
| 174 | pub jitter_ms: f64, |
| 175 | pub round_trip_ms: f64, |
| 176 | pub outbound_loss_percent: f64, |
| 177 | pub limitation: Limitation, |
| 178 | } |
| 179 | |
| 180 | #[derive(Default)] |
| 181 | pub struct HealthSampler { |
| 182 | previous: Option<(Instant, HealthCounters)>, |
| 183 | } |
| 184 | |
| 185 | impl HealthSampler { |
| 186 | pub fn sample(&mut self, now: Instant, counters: HealthCounters) -> Option<HealthSample> { |
| 187 | let (then, before) = self.previous.replace((now, counters))?; |
| 188 | let seconds = now.duration_since(then).as_secs_f64(); |
| 189 | if seconds <= 0. { |
| 190 | return None; |
| 191 | } |
| 192 | let received = counters.packets_received.saturating_sub(before.packets_received); |
| 193 | let lost = counters.packets_lost.saturating_sub(before.packets_lost); |
| 194 | let inbound_loss_percent = if received + lost == 0 { 0. } else { lost as f64 * 100. / (received + lost) as f64 }; |
| 195 | let kbps = |after: u64, before: u64| after.saturating_sub(before) as f64 * 8. / seconds / 1000.; |
| 196 | Some(HealthSample { |
| 197 | loss_percent: inbound_loss_percent.max(counters.outbound_loss_percent), |
| 198 | round_trip_ms: counters.round_trip_ms, |
| 199 | jitter_ms: counters.jitter_ms, |
| 200 | sent_kbps: kbps(counters.bytes_sent, before.bytes_sent), |
| 201 | received_kbps: kbps(counters.bytes_received, before.bytes_received), |
| 202 | limitation: counters.limitation, |
| 203 | }) |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | fn limitation_of(reason: QualityLimitationReason) -> Limitation { |
| 208 | match reason { |
| 209 | QualityLimitationReason::Cpu => Limitation::Cpu, |
| 210 | QualityLimitationReason::Bandwidth => Limitation::Bandwidth, |
| 211 | _ => Limitation::None, |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | pub fn health_from_stats(stats: &[RtcStats]) -> (HealthCounters, TransportDetails) { |
| 216 | let mut counters = HealthCounters::default(); |
| 217 | let mut transport = TransportDetails::default(); |
| 218 | let mut certificate_ids = (String::new(), String::new()); |
| 219 | let mut selected_pair_id = String::new(); |
| 220 | let mut remote_round_trip_ms = 0f64; |
| 221 | for entry in stats { |
| 222 | match entry { |
| 223 | RtcStats::InboundRtp(inbound) => { |
| 224 | counters.packets_received += inbound.received.packets_received; |
| 225 | counters.packets_lost += inbound.received.packets_lost.max(0) as u64; |
| 226 | counters.bytes_received += inbound.inbound.bytes_received; |
| 227 | if inbound.stream.kind == "audio" { |
| 228 | counters.jitter_ms = counters.jitter_ms.max(inbound.received.jitter * 1000.); |
| 229 | } |
| 230 | } |
| 231 | RtcStats::OutboundRtp(outbound) => { |
| 232 | counters.bytes_sent += outbound.sent.bytes_sent; |
| 233 | if outbound.stream.kind == "video" && outbound.outbound.active { |
| 234 | let limitation = limitation_of(outbound.outbound.quality_limitation_reason); |
| 235 | counters.limitation = counters.limitation.max_with(limitation); |
| 236 | } |
| 237 | } |
| 238 | RtcStats::RemoteInboundRtp(remote) => { |
| 239 | counters.outbound_loss_percent = counters.outbound_loss_percent.max(remote.remote_inbound.fraction_lost * 100.); |
| 240 | remote_round_trip_ms = remote_round_trip_ms.max(remote.remote_inbound.round_trip_time * 1000.); |
| 241 | } |
| 242 | RtcStats::Transport(found) => { |
| 243 | transport.dtls_state = found.transport.dtls_state.map(|state| format!("{state:?}")).unwrap_or_default(); |
| 244 | transport.tls_version = found.transport.tls_version.clone(); |
| 245 | transport.dtls_cipher = found.transport.dtls_cipher.clone(); |
| 246 | transport.srtp_cipher = found.transport.srtp_cipher.clone(); |
| 247 | certificate_ids = (found.transport.local_certificate_id.clone(), found.transport.remote_certificate_id.clone()); |
| 248 | selected_pair_id = found.transport.selected_candidate_pair_id.clone(); |
| 249 | } |
| 250 | _ => {} |
| 251 | } |
| 252 | } |
| 253 | let fingerprint = |certificate_id: &str| { |
| 254 | stats |
| 255 | .iter() |
| 256 | .find_map(|entry| match entry { |
| 257 | RtcStats::Certificate(certificate) if certificate.rtc.id == certificate_id => { |
| 258 | Some(format!("{} {}", certificate.certificate.fingerprint_algorithm, certificate.certificate.fingerprint)) |
| 259 | } |
| 260 | _ => None, |
| 261 | }) |
| 262 | .unwrap_or_default() |
| 263 | }; |
| 264 | transport.local_fingerprint = fingerprint(&certificate_ids.0); |
| 265 | transport.remote_fingerprint = fingerprint(&certificate_ids.1); |
| 266 | let pair_round_trip_ms = stats.iter().find_map(|entry| match entry { |
| 267 | RtcStats::CandidatePair(pair) if pair.rtc.id == selected_pair_id => Some(pair.candidate_pair.current_round_trip_time * 1000.), |
| 268 | _ => None, |
| 269 | }); |
| 270 | counters.round_trip_ms = pair_round_trip_ms.filter(|milliseconds| *milliseconds > 0.).unwrap_or(remote_round_trip_ms); |
| 271 | (counters, transport) |
| 272 | } |
| 273 | |
| 274 | impl Limitation { |
| 275 | fn max_with(self, other: Limitation) -> Limitation { |
| 276 | match (self, other) { |
| 277 | (Limitation::Cpu, _) | (_, Limitation::Cpu) => Limitation::Cpu, |
| 278 | (Limitation::Bandwidth, _) | (_, Limitation::Bandwidth) => Limitation::Bandwidth, |
| 279 | _ => Limitation::None, |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | #[cfg(test)] |
| 285 | mod tests { |
| 286 | use libwebrtc::stats::dictionaries::{CandidatePairStats, CertificateStats, InboundRtpStreamStats, OutboundRtpStreamStats, ReceivedRtpStreamStats, RtcStats as RtcStatsBase, RtpStreamStats, SentRtpStreamStats, TransportStats as TransportDictionary}; |
| 287 | use libwebrtc::stats::{CandidatePairStats as PairEntry, CertificateStats as CertificateEntry, InboundRtpStats, OutboundRtpStats, TransportStats}; |
| 288 | |
| 289 | use super::*; |
| 290 | |
| 291 | fn at(start: Instant, seconds: u64) -> Instant { |
| 292 | start + Duration::from_secs(seconds) |
| 293 | } |
| 294 | |
| 295 | fn lossy(loss_percent: f64) -> HealthSample { |
| 296 | HealthSample { loss_percent, ..HealthSample::default() } |
| 297 | } |
| 298 | |
| 299 | fn feed(tracker: &mut QualityTracker, start: Instant, from: u64, to: u64, sample: &HealthSample) -> Quality { |
| 300 | let mut quality = Quality { level: NetworkLevel::Good, cpu_limited: false }; |
| 301 | for seconds in (from..=to).step_by(2) { |
| 302 | quality = tracker.observe(at(start, seconds), sample); |
| 303 | } |
| 304 | quality |
| 305 | } |
| 306 | |
| 307 | #[test] |
| 308 | fn a_brief_spike_does_not_degrade_the_level() { |
| 309 | let (mut tracker, start) = (QualityTracker::default(), Instant::now()); |
| 310 | assert_eq!(feed(&mut tracker, start, 0, 2, &lossy(8.)).level, NetworkLevel::Good); |
| 311 | assert_eq!(feed(&mut tracker, start, 4, 20, &lossy(0.)).level, NetworkLevel::Good); |
| 312 | } |
| 313 | |
| 314 | #[test] |
| 315 | fn poor_needs_five_seconds_of_loss_over_five_percent() { |
| 316 | let (mut tracker, start) = (QualityTracker::default(), Instant::now()); |
| 317 | assert_eq!(feed(&mut tracker, start, 0, 4, &lossy(6.)).level, NetworkLevel::Good); |
| 318 | assert_eq!(feed(&mut tracker, start, 6, 6, &lossy(6.)).level, NetworkLevel::Poor); |
| 319 | } |
| 320 | |
| 321 | #[test] |
| 322 | fn round_trip_and_jitter_also_make_it_poor() { |
| 323 | for sample in [HealthSample { round_trip_ms: 450., ..Default::default() }, HealthSample { jitter_ms: 35., ..Default::default() }] { |
| 324 | let (mut tracker, start) = (QualityTracker::default(), Instant::now()); |
| 325 | assert_eq!(feed(&mut tracker, start, 0, 6, &sample).level, NetworkLevel::Poor); |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | #[test] |
| 330 | fn bad_needs_five_seconds_over_ten_percent_loss_or_500_ms() { |
| 331 | let (mut tracker, start) = (QualityTracker::default(), Instant::now()); |
| 332 | assert_eq!(feed(&mut tracker, start, 0, 6, &lossy(12.)).level, NetworkLevel::Bad); |
| 333 | let (mut tracker, start) = (QualityTracker::default(), Instant::now()); |
| 334 | let slow = HealthSample { round_trip_ms: 600., ..Default::default() }; |
| 335 | assert_eq!(feed(&mut tracker, start, 0, 6, &slow).level, NetworkLevel::Bad); |
| 336 | } |
| 337 | |
| 338 | #[test] |
| 339 | fn the_level_drops_fast_and_recovers_one_step_per_ten_seconds() { |
| 340 | let (mut tracker, start) = (QualityTracker::default(), Instant::now()); |
| 341 | assert_eq!(feed(&mut tracker, start, 0, 6, &lossy(12.)).level, NetworkLevel::Bad); |
| 342 | assert_eq!(feed(&mut tracker, start, 8, 16, &lossy(0.)).level, NetworkLevel::Bad); |
| 343 | assert_eq!(feed(&mut tracker, start, 18, 18, &lossy(0.)).level, NetworkLevel::Poor); |
| 344 | assert_eq!(feed(&mut tracker, start, 20, 28, &lossy(0.)).level, NetworkLevel::Poor); |
| 345 | assert_eq!(feed(&mut tracker, start, 30, 30, &lossy(0.)).level, NetworkLevel::Good); |
| 346 | } |
| 347 | |
| 348 | #[test] |
| 349 | fn a_relapse_restarts_the_recovery_timer() { |
| 350 | let (mut tracker, start) = (QualityTracker::default(), Instant::now()); |
| 351 | feed(&mut tracker, start, 0, 6, &lossy(7.)); |
| 352 | feed(&mut tracker, start, 8, 16, &lossy(0.)); |
| 353 | feed(&mut tracker, start, 18, 18, &lossy(7.)); |
| 354 | assert_eq!(feed(&mut tracker, start, 20, 28, &lossy(0.)).level, NetworkLevel::Poor); |
| 355 | assert_eq!(feed(&mut tracker, start, 30, 30, &lossy(0.)).level, NetworkLevel::Good); |
| 356 | } |
| 357 | |
| 358 | #[test] |
| 359 | fn bandwidth_limits_alone_keep_it_good() { |
| 360 | let (mut tracker, start) = (QualityTracker::default(), Instant::now()); |
| 361 | let limited = HealthSample { limitation: Limitation::Bandwidth, ..Default::default() }; |
| 362 | assert_eq!(feed(&mut tracker, start, 0, 30, &limited).level, NetworkLevel::Good); |
| 363 | } |
| 364 | |
| 365 | #[test] |
| 366 | fn cpu_limits_raise_their_own_flag_without_touching_the_level() { |
| 367 | let (mut tracker, start) = (QualityTracker::default(), Instant::now()); |
| 368 | let limited = HealthSample { limitation: Limitation::Cpu, ..Default::default() }; |
| 369 | let quality = feed(&mut tracker, start, 0, 6, &limited); |
| 370 | assert!(quality.cpu_limited); |
| 371 | assert_eq!(quality.level, NetworkLevel::Good); |
| 372 | assert!(!feed(&mut tracker, start, 8, 20, &HealthSample::default()).cpu_limited); |
| 373 | } |
| 374 | |
| 375 | #[test] |
| 376 | fn the_sampler_turns_counter_deltas_into_loss_and_bitrate() { |
| 377 | let (mut sampler, start) = (HealthSampler::default(), Instant::now()); |
| 378 | let first = HealthCounters { packets_received: 100, packets_lost: 0, bytes_sent: 1000, bytes_received: 2000, ..Default::default() }; |
| 379 | assert_eq!(sampler.sample(start, first), None); |
| 380 | let second = HealthCounters { packets_received: 190, packets_lost: 10, bytes_sent: 51_000, bytes_received: 27_000, round_trip_ms: 80., jitter_ms: 4., ..first }; |
| 381 | let sample = sampler.sample(at(start, 2), second).unwrap(); |
| 382 | assert_eq!(sample.loss_percent, 10.); |
| 383 | assert_eq!(sample.sent_kbps, 200.); |
| 384 | assert_eq!(sample.received_kbps, 100.); |
| 385 | assert_eq!((sample.round_trip_ms, sample.jitter_ms), (80., 4.)); |
| 386 | } |
| 387 | |
| 388 | #[test] |
| 389 | fn the_sampler_reports_outbound_loss_from_the_remote_report() { |
| 390 | let (mut sampler, start) = (HealthSampler::default(), Instant::now()); |
| 391 | sampler.sample(start, HealthCounters::default()); |
| 392 | let counters = HealthCounters { outbound_loss_percent: 7., ..Default::default() }; |
| 393 | assert_eq!(sampler.sample(at(start, 2), counters).unwrap().loss_percent, 7.); |
| 394 | } |
| 395 | |
| 396 | #[test] |
| 397 | fn stats_parse_into_counters_and_transport_details() { |
| 398 | let stats = vec![ |
| 399 | RtcStats::InboundRtp(InboundRtpStats { |
| 400 | stream: RtpStreamStats { kind: "audio".into(), ..Default::default() }, |
| 401 | received: ReceivedRtpStreamStats { packets_received: 50, packets_lost: 5, jitter: 0.012 }, |
| 402 | inbound: InboundRtpStreamStats { bytes_received: 4000, ..Default::default() }, |
| 403 | ..Default::default() |
| 404 | }), |
| 405 | RtcStats::OutboundRtp(OutboundRtpStats { |
| 406 | stream: RtpStreamStats { kind: "video".into(), ..Default::default() }, |
| 407 | sent: SentRtpStreamStats { bytes_sent: 9000, ..Default::default() }, |
| 408 | outbound: OutboundRtpStreamStats { active: true, quality_limitation_reason: QualityLimitationReason::Cpu, ..Default::default() }, |
| 409 | ..Default::default() |
| 410 | }), |
| 411 | RtcStats::Transport(TransportStats { |
| 412 | transport: TransportDictionary { |
| 413 | dtls_cipher: "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256".into(), |
| 414 | srtp_cipher: "AEAD_AES_128_GCM".into(), |
| 415 | tls_version: "FEFD".into(), |
| 416 | local_certificate_id: "CF1".into(), |
| 417 | remote_certificate_id: "CF2".into(), |
| 418 | selected_candidate_pair_id: "CP1".into(), |
| 419 | ..Default::default() |
| 420 | }, |
| 421 | ..Default::default() |
| 422 | }), |
| 423 | RtcStats::CandidatePair(PairEntry { |
| 424 | rtc: RtcStatsBase { id: "CP1".into(), ..Default::default() }, |
| 425 | candidate_pair: CandidatePairStats { current_round_trip_time: 0.045, ..Default::default() }, |
| 426 | }), |
| 427 | RtcStats::Certificate(CertificateEntry { |
| 428 | rtc: RtcStatsBase { id: "CF1".into(), ..Default::default() }, |
| 429 | certificate: CertificateStats { fingerprint: "AA:BB".into(), fingerprint_algorithm: "sha-256".into(), ..Default::default() }, |
| 430 | }), |
| 431 | ]; |
| 432 | let (counters, transport) = health_from_stats(&stats); |
| 433 | assert_eq!((counters.packets_received, counters.packets_lost), (50, 5)); |
| 434 | assert_eq!((counters.bytes_received, counters.bytes_sent), (4000, 9000)); |
| 435 | assert_eq!(counters.jitter_ms, 12.); |
| 436 | assert_eq!(counters.round_trip_ms, 45.); |
| 437 | assert_eq!(counters.limitation, Limitation::Cpu); |
| 438 | assert_eq!(transport.srtp_cipher, "AEAD_AES_128_GCM"); |
| 439 | assert_eq!(transport.local_fingerprint, "sha-256 AA:BB"); |
| 440 | assert_eq!(transport.remote_fingerprint, ""); |
| 441 | } |
| 442 | |
| 443 | #[test] |
| 444 | fn inactive_video_streams_do_not_count_as_limited() { |
| 445 | let stats = vec![RtcStats::OutboundRtp(OutboundRtpStats { |
| 446 | stream: RtpStreamStats { kind: "video".into(), ..Default::default() }, |
| 447 | outbound: OutboundRtpStreamStats { active: false, quality_limitation_reason: QualityLimitationReason::Bandwidth, ..Default::default() }, |
| 448 | ..Default::default() |
| 449 | })]; |
| 450 | assert_eq!(health_from_stats(&stats).0.limitation, Limitation::None); |
| 451 | } |
| 452 | } |