Adjust drift calculations for pass through. (#3129)

No functional effect, but was logging more than expected drift in the
down stream direction. Reason is that when passing through, we could be
using an older report. But, the adjustment was applied to the monotonic
clock and not the RTP timestamp. So, it looked like more time had
elapsed for the same RTP clock elapsed and logging higher than expected
drift. Correcting it so that the log is not misleading/confusing.
This commit is contained in:
Raja Subramanian
2024-10-23 11:03:43 +05:30
committed by GitHub
parent 487a3fc3fb
commit 7ab6e5df09

View File

@@ -630,17 +630,24 @@ func (r *RTPStatsSender) GetRtcpSenderReport(ssrc uint32, publisherSRData *livek
return nil
}
timeSincePublisherSRAdjusted := time.Since(time.Unix(0, publisherSRData.AtAdjusted))
now := publisherSRData.AtAdjusted + timeSincePublisherSRAdjusted.Nanoseconds()
var (
nowNTP mediatransportutil.NtpTime
nowRTPExt uint64
reportTime int64
reportTimeAdjusted int64
nowNTP mediatransportutil.NtpTime
nowRTPExt uint64
)
if passThrough {
reportTime = publisherSRData.At
reportTimeAdjusted = publisherSRData.AtAdjusted
nowNTP = mediatransportutil.NtpTime(publisherSRData.NtpTimestamp)
nowRTPExt = publisherSRData.RtpTimestampExt - tsOffset
} else {
nowNTP = mediatransportutil.ToNtpTime(time.Unix(0, now))
timeSincePublisherSRAdjusted := time.Since(time.Unix(0, publisherSRData.AtAdjusted))
reportTimeAdjusted = publisherSRData.AtAdjusted + timeSincePublisherSRAdjusted.Nanoseconds()
reportTime = reportTimeAdjusted
nowNTP = mediatransportutil.ToNtpTime(time.Unix(0, reportTime))
nowRTPExt = publisherSRData.RtpTimestampExt - tsOffset + uint64(timeSincePublisherSRAdjusted.Nanoseconds()*int64(r.params.ClockRate)/1e9)
}
@@ -650,8 +657,8 @@ func (r *RTPStatsSender) GetRtcpSenderReport(ssrc uint32, publisherSRData *livek
NtpTimestamp: uint64(nowNTP),
RtpTimestamp: uint32(nowRTPExt),
RtpTimestampExt: nowRTPExt,
At: now,
AtAdjusted: now,
At: reportTime,
AtAdjusted: reportTimeAdjusted,
Packets: packetCount,
Octets: octetCount,
}
@@ -661,10 +668,11 @@ func (r *RTPStatsSender) GetRtcpSenderReport(ssrc uint32, publisherSRData *livek
"feed", WrappedRTCPSenderReportStateLogger{publisherSRData},
"tsOffset", tsOffset,
"timeNow", time.Now(),
"now", time.Unix(0, now),
"timeSinceHighest", time.Duration(now-r.highestTime),
"timeSinceFirst", time.Duration(now-r.firstTime),
"timeSincePublisherSRAdjusted", timeSincePublisherSRAdjusted,
"reportTime", time.Unix(0, reportTime),
"reportTimeAdjusted", time.Unix(0, reportTimeAdjusted),
"timeSinceHighest", time.Since(time.Unix(0, r.highestTime)),
"timeSinceFirst", time.Since(time.Unix(0, r.firstTime)),
"timeSincePublisherSRAdjusted", time.Since(time.Unix(0, publisherSRData.AtAdjusted)),
"timeSincePublisherSR", time.Since(time.Unix(0, publisherSRData.At)),
"nowRTPExt", nowRTPExt,
"rtpStats", lockedRTPStatsSenderLogEncoder{r},