Skip to content

sender: add LookupNetStatsBySSRC for senders added outside AddVideoTrack - #165

Merged
lkang-nuro merged 1 commit into
mainfrom
lkang/lookup-netstats-by-ssrc
Jul 1, 2026
Merged

sender: add LookupNetStatsBySSRC for senders added outside AddVideoTrack#165
lkang-nuro merged 1 commit into
mainfrom
lkang/lookup-netstats-by-ssrc

Conversation

@lkang-nuro

Copy link
Copy Markdown
Contributor

Summary

RTCSender.GetTrackStats(trackID) walks s.tracks, which only holds entries created through AddVideoTrack. Consumers that add senders directly to the underlying PeerConnection (e.g. via pc.AddTrack for pre-encoded sample tracks published alongside bwe-test-managed video tracks) currently have no way to read their pion stats-interceptor counters — the getter is private, and pion's own pc.GetStats() does not emit OutboundRTPStreamStats in this code path.

This adds a small by-SSRC variant, LookupNetStatsBySSRC, returning just the network-side fields via a new SenderNetStats type (no pipeline/encoder counters, which don't apply to externally-added senders). RTT-bearing fields stay zero until an RTCP RR arrives for the SSRC, matching GetTrackStats' contract.

No behavior change for existing callers.

Changes

  • SenderNetStats type: per-SSRC network-side subset of TrackStats.
  • RTCSender.LookupNetStatsBySSRC(ssrc): returns nil when the stats interceptor is unbound or has no entry for the SSRC.

Testing

  • go build ./..., go vet ./sender/ clean.
  • New tests: nil-getter, missing-SSRC, and full field population — all pass.
  • Full sender package test suite passes.

🤖 Generated with Claude Code

@lkang-nuro
lkang-nuro requested a review from jayli-nuro July 1, 2026 03:38
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.27%. Comparing base (64a421c) to head (c502d75).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #165      +/-   ##
==========================================
+ Coverage   46.63%   47.27%   +0.63%     
==========================================
  Files          18       18              
  Lines        1829     1851      +22     
==========================================
+ Hits          853      875      +22     
  Misses        907      907              
  Partials       69       69              
Flag Coverage Δ
go 47.27% <100.00%> (+0.63%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkang-nuro
lkang-nuro requested a review from hanguyen-nuro July 1, 2026 03:38
RTCSender's existing GetTrackStats(trackID) walks s.tracks, which
holds only entries created through AddVideoTrack. Consumers that add
senders directly to the underlying PeerConnection (e.g. via
pc.AddTrack for pre-encoded sample tracks published alongside the
bwe-test-managed video tracks) currently have no way to read their
pion stats-interceptor counters: the getter is private, and pion's
own pc.GetStats() does not emit OutboundRTPStreamStats in this path.

Expose a small by-SSRC variant that returns just the network-side
fields (no pipeline / encoder counters, which don't apply to
externally-added senders). RTT-bearing fields stay zero until an
RTCP RR arrives for the SSRC, matching GetTrackStats' contract.

No behavior change for existing callers.

Co-Authored-By: Seung Yang <syang@nuro.ai>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lkang-nuro
lkang-nuro force-pushed the lkang/lookup-netstats-by-ssrc branch from cd7fa51 to c502d75 Compare July 1, 2026 03:41
@lkang-nuro
lkang-nuro merged commit d6fa118 into main Jul 1, 2026
19 checks passed
@lkang-nuro
lkang-nuro deleted the lkang/lookup-netstats-by-ssrc branch July 1, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants