From 303d15539cc2b59facfc80e3a910093e3446a61e Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Mon, 1 Jun 2020 00:35:37 +0200 Subject: [PATCH] Handle sender reports for down tracks. In principle, we should be receiving receiver reports only, but let's be robust. --- webclient.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/webclient.go b/webclient.go index a552a62..6be50f7 100644 --- a/webclient.go +++ b/webclient.go @@ -866,16 +866,13 @@ func rtcpDownListener(conn *rtpDownConnection, track *rtpDownTrack, s *webrtc.RT case *rtcp.ReceiverReport: for _, r := range p.Reports { if r.SSRC == track.track.SSRC() { - now := mono.Microseconds() - track.stats.Set( - r.FractionLost, - r.Jitter, - now, - ) - track.updateRate( - r.FractionLost, - now, - ) + handleReport(track, r) + } + } + case *rtcp.SenderReport: + for _, r := range p.Reports { + if r.SSRC == track.track.SSRC() { + handleReport(track, r) } } case *rtcp.TransportLayerNack: @@ -891,6 +888,12 @@ func rtcpDownListener(conn *rtpDownConnection, track *rtpDownTrack, s *webrtc.RT } } +func handleReport(track *rtpDownTrack, report rtcp.ReceptionReport) { + now := mono.Microseconds() + track.stats.Set(report.FractionLost, report.Jitter, now) + track.updateRate(report.FractionLost, now) +} + func trackKinds(down *rtpDownConnection) (audio bool, video bool) { if down.pc == nil { return