getStats: add remote-outbound-rtp + inbound jitter/loss/kind/codecId#40
Merged
Conversation
The receive path tracked only packetsReceived/bytesReceived, so InboundRtpStats exposed neither loss nor jitter, and webdartc emitted RTCP RR report blocks with hard-coded fractionLost=0/cumulativeLost=0/ jitter=0 — giving remote senders no real reception feedback. There was also no remote-outbound-rtp stat despite SR being parsed. - New `RtpReceptionTracker` (lib/rtp/receive_stats.dart): pure RFC 3550 §A.3 loss + §A.8 interarrival jitter accounting per SSRC, unit-tested in isolation. - `_RtpRecvStats` now drives the tracker (lazily bound to the stream's clock rate on the first packet) and captures the latest SR detail. - RTCP RR blocks now carry real fractionLost / cumulativeLost / extendedHighestSeq / jitter instead of zeros — fixes the all-zero feedback gap. - InboundRtpStats gains `kind`, `packetsLost`, `jitter` (seconds), and `codecId`; new RemoteOutboundRtpStats emitted from received SR (packetsSent/bytesSent/remoteTimestamp/reportsReceived), paired with the inbound entry via localId. - `ntpToDateTime` helper (rtcp_math.dart) for the SR remoteTimestamp. Tracker has direct unit tests (loss/dup/wrap/fraction/jitter); the getStats loopback test asserts the new inbound fields and the remote-outbound pairing. Full suite + e2e (Chrome RTP/RTCP) pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
nus
added a commit
that referenced
this pull request
Jun 8, 2026
…edia (#43) Scenario 2 only asserted onTrack — the receive-side getStats fields added in #40 (inbound jitter/packetsLost/kind/codecId, and the SR-derived remote-outbound-rtp) were never checked against a real sender. Extend the media-receiver helper to poll getStats once a track is flowing and assert: - inbound-rtp: packetsReceived>0, jitter>=0 (real interarrival jitter), kind, and a resolvable codecId; - remote-outbound-rtp: present and linked to the inbound entry via localId, with reportsReceived>0 and a non-null remoteTimestamp. packetsSent is only required non-negative, not positive: it's the SR's sender packet count, which is browser/timing-dependent (Firefox's first SR reports 0, Chrome ~120) — caught by running the Firefox e2e too. Validated against both browsers, including under 5% loss where the helper observed real packetsLost: e.g. Chrome jitter≈0.0012s / packetsSent=122, and a lossy run "packets=119 lost=7". Confirms #40's jitter and loss computation against conditions the loopback unit test can't reproduce. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the W3C getStats gap from the RFC/W3C divergence audit, and fixes a latent RTCP-feedback bug found along the way.
Problem
The receive path tracked only
packetsReceived/bytesReceived, soInboundRtpStatsexposed neither loss nor jitter, and there was noremote-outbound-rtpstat despite RTCP SR being parsed. Worse, webdartc emitted RTCP RR report blocks with hard-codedfractionLost=0/cumulativeLost=0/jitter=0— so remote senders received no real reception feedback.Change
RtpReceptionTracker(receive_stats.dart): pure RFC 3550 §A.3 loss + §A.8 interarrival jitter accounting per SSRC, unit-tested in isolation (mirrors howrtcp_math.dartisolates pure RTCP math)._RtpRecvStatsdrives the tracker (bound to the stream's clock rate on the first packet) and captures the latest SR detail.fractionLost/cumulativeLost/extendedHighestSeq/jitterinstead of zeros.InboundRtpStatsgainskind,packetsLost,jitter(seconds),codecId; newRemoteOutboundRtpStatsemitted from received SR (packetsSent/bytesSent/remoteTimestamp/reportsReceived), paired to the inbound entry vialocalId.ntpToDateTimehelper (rtcp_math.dart) for the SRremoteTimestamp.Notes (from /simplify)
a=rtpmapclock rate (new_ptClockRateMap, mirroring_ptKindMap), not a hardcoded 48k/90k guess — correct for G.711/8 kHz and other non-default codecs.Tests
dart analyzeclean; 642 unit + 22 e2e pass (Chrome RTP/RTCP interop intact with the corrected non-zero RR feedback).🤖 Generated with Claude Code