Statistics
getStats per the W3C WebRTC Statistics API, for what a transport measures. The instant is passed in, so a snapshot is as reproducible as the rest of the session.
Take a report
use rtci::peer_connection::RTCPeerConnection;
use rtci::statistics::StatsSelector;
use std::time::Instant;
fn report(pc: &mut RTCPeerConnection) {
// The instant is passed in rather than read from the clock, so a stats
// snapshot is as reproducible as the rest of the session.
let report = pc.get_stats(Instant::now(), StatsSelector::None);
if let Some(stats) = report.peer_connection() {
println!("data channels opened: {}", stats.data_channels_opened);
}
for stream in report.inbound_rtp_streams() {
println!(
"ssrc {}: {} packets received",
stream.received_rtp_stream_stats.rtp_stream_stats.ssrc,
stream.received_rtp_stream_stats.packets_received
);
}
}
From README.md, “Statistics” at v0.5.0.
get_stats(now, selector) takes the current instant and a StatsSelector (the whole connection, or a sender or receiver). The report has typed accessors (peer_connection(), inbound_rtp_streams(), ...); the stats types follow the W3C dictionaries (statistics::stats has one module per stats type: codec, transport, candidate, candidate pair, certificate, data channel, peer connection, media source and the RTP stream types).
What is reported, and what is not
Statistics members are reported for what a transport measures. Members that need an encoder, decoder or playout (the engine has none) are left out of the report, not reported as 0. An application that encodes or plays out can supply those figures: rtci::statistics re-exports update types for them (EncoderStatsUpdate, DecoderStatsUpdate, AudioSourceStatsUpdate, VideoSourceStatsUpdate, AudioPlayoutStatsUpdate, ...).
The figures of the RTCP reports the engine receives (round trip, remote loss) appear as remote-inbound-rtp and remote-outbound-rtp stats: the RTCP session takes sender and receiver reports in itself, so they never reach poll_read.
FEC statistics
RTCPeerConnection::fec_stats() returns FecStats: the FEC each stream sent and received and what became of it, outside the W3C report.
Example
The repository's stats example prints a peer connection's statistics.
Conformance
The W3C statistics specification is one of the audited specifications (Conformance, file w3c-webrtc-stats.md).