use crate::rtp_transceiver::rtp_sender::RtpCodecKind;
use crate::statistics::stats::media::audio_playout::RTCAudioPlayoutStats;
use crate::statistics::stats::{RTCStats, RTCStatsType};
use std::time::Instant;
#[derive(Debug, Default)]
pub struct AudioPlayoutStatsAccumulator {
pub kind: RtpCodecKind,
pub synthesized_samples_duration: f64,
pub synthesized_samples_events: u32,
pub total_samples_duration: f64,
pub total_playout_delay: f64,
pub total_samples_count: u64,
}
impl AudioPlayoutStatsAccumulator {
pub fn snapshot(&self, now: Instant, id: &str) -> RTCAudioPlayoutStats {
RTCAudioPlayoutStats {
stats: RTCStats {
timestamp: now,
typ: RTCStatsType::MediaPlayout,
id: id.to_string(),
},
kind: self.kind,
synthesized_samples_duration: self.synthesized_samples_duration,
synthesized_samples_events: self.synthesized_samples_events,
total_samples_duration: self.total_samples_duration,
total_playout_delay: self.total_playout_delay,
total_samples_count: self.total_samples_count,
}
}
}