Support XR request/response for rtt calculation (#2536)
* Support XR request/response for rtt calculation * Update pkg/sfu/downtrack.go Co-authored-by: David Zhao <dz@livekit.io> --------- Co-authored-by: David Zhao <dz@livekit.io>
This commit is contained in:
co-authored by
David Zhao
parent
cbc1d1b1ce
commit
b58307f144
@@ -206,6 +206,7 @@ type DowntrackParams struct {
|
||||
Pacer pacer.Pacer
|
||||
Logger logger.Logger
|
||||
Trailer []byte
|
||||
RTCPWriter func([]rtcp.Packet) error
|
||||
}
|
||||
|
||||
// DownTrack implements TrackLocal, is the track used to write packets
|
||||
@@ -1567,6 +1568,34 @@ func (d *DownTrack) handleRTCP(bytes []byte) {
|
||||
sal.OnTransportCCFeedback(d, p)
|
||||
}
|
||||
}
|
||||
|
||||
case *rtcp.ExtendedReport:
|
||||
// SFU only responds with the DLRRReport for the track has the sender SSRC, the behavior is different with
|
||||
// browser's implementation, which includes all sent tracks. It is ok since all the tracks
|
||||
// use the same connection, and server-sdk-go can get the rtt from the first DLRRReport
|
||||
// (libwebrtc/browsers don't send XR to calculate rtt, it only responds)
|
||||
var lastRR uint32
|
||||
for _, report := range p.Reports {
|
||||
if rr, ok := report.(*rtcp.ReceiverReferenceTimeReportBlock); ok {
|
||||
lastRR = uint32(rr.NTPTimestamp >> 16)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if lastRR > 0 {
|
||||
d.params.RTCPWriter([]rtcp.Packet{&rtcp.ExtendedReport{
|
||||
SenderSSRC: d.ssrc,
|
||||
Reports: []rtcp.ReportBlock{
|
||||
&rtcp.DLRRReportBlock{
|
||||
Reports: []rtcp.DLRRReport{{
|
||||
SSRC: p.SenderSSRC,
|
||||
LastRR: lastRR,
|
||||
DLRR: 0, // no delay
|
||||
}},
|
||||
},
|
||||
},
|
||||
}})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user