Use purely RR based RTT. (#1351)
* Use purely RR based RTT. With normalization of NTP time stamp to local time, don't need to keep track of NTP time of publisher + local time of when a report is sent. RTT calculations can happen with RR only. Also, do not log errors when RTT cannot be calculated due to no last SR. This can happen if the receiver sends an RR before it receives an SR. As SFU is doing SRs once in 5 seconds, it is possible some RRs happen before the first SR. * use error type * correct error name
This commit is contained in:
@@ -172,8 +172,6 @@ type RTPStats struct {
|
||||
maxRtt uint32
|
||||
|
||||
srDataExt *RTCPSenderReportDataExt
|
||||
lastSRNTP mediatransportutil.NtpTime
|
||||
lastSRAt time.Time
|
||||
|
||||
nextSnapshotId uint32
|
||||
snapshots map[uint32]*Snapshot
|
||||
@@ -269,8 +267,6 @@ func (r *RTPStats) Seed(from *RTPStats) {
|
||||
} else {
|
||||
r.srDataExt = nil
|
||||
}
|
||||
r.lastSRNTP = from.lastSRNTP
|
||||
r.lastSRAt = from.lastSRAt
|
||||
|
||||
r.nextSnapshotId = from.nextSnapshotId
|
||||
for id, ss := range from.snapshots {
|
||||
@@ -478,11 +474,13 @@ func (r *RTPStats) UpdateFromReceiverReport(rr rtcp.ReceptionReport) (rtt uint32
|
||||
return
|
||||
}
|
||||
|
||||
rtt, err := mediatransportutil.GetRttMs(&rr, r.lastSRNTP, r.lastSRAt)
|
||||
rtt, err := mediatransportutil.GetRttMsFromReceiverReportOnly(&rr)
|
||||
if err == nil {
|
||||
isRttChanged = rtt != r.rtt
|
||||
} else {
|
||||
r.logger.Warnw("error getting rtt", err)
|
||||
if err != mediatransportutil.ErrRttNoLastSenderReport {
|
||||
r.logger.Warnw("error getting rtt", err)
|
||||
}
|
||||
}
|
||||
|
||||
if r.lastRRTime.IsZero() || r.extHighestSNOverridden <= rr.LastSequenceNumber {
|
||||
@@ -766,9 +764,6 @@ func (r *RTPStats) GetRtcpSenderReport(ssrc uint32, srDataExt *RTCPSenderReportD
|
||||
nowRTP = srDataExt.SenderReportData.RTPTimestamp + uint32(now.Sub(smoothedLocalTimeOfLatestSenderReportNTP).Milliseconds()*int64(r.params.ClockRate)/1000)
|
||||
}
|
||||
|
||||
r.lastSRNTP = nowNTP
|
||||
r.lastSRAt = time.Now()
|
||||
|
||||
return &rtcp.SenderReport{
|
||||
SSRC: ssrc,
|
||||
NTPTime: uint64(nowNTP),
|
||||
|
||||
Reference in New Issue
Block a user