diff --git a/pkg/sfu/buffer/rtpstats_sender.go b/pkg/sfu/buffer/rtpstats_sender.go index 6dafb104..6f32ac0a 100644 --- a/pkg/sfu/buffer/rtpstats_sender.go +++ b/pkg/sfu/buffer/rtpstats_sender.go @@ -31,6 +31,8 @@ const ( cSnInfoMask = cSnInfoSize - 1 cSenderReportInitialWait = time.Second + + cPassthroughNTPTimestamp = true ) // ------------------------------------------------------------------- @@ -645,10 +647,19 @@ func (r *RTPStatsSender) GetRtcpSenderReport(ssrc uint32, publisherSRData *RTCPS return nil } - timeSincePublisherSR := time.Since(publisherSRData.AtAdjusted) - now := publisherSRData.AtAdjusted.Add(timeSincePublisherSR) - nowNTP := mediatransportutil.ToNtpTime(now) - nowRTPExt := publisherSRData.RTPTimestampExt - tsOffset + uint64(timeSincePublisherSR.Nanoseconds()*int64(r.params.ClockRate)/1e9) + timeSincePublisherSRAdjusted := time.Since(publisherSRData.AtAdjusted) + now := publisherSRData.AtAdjusted.Add(timeSincePublisherSRAdjusted) + var ( + nowNTP mediatransportutil.NtpTime + nowRTPExt uint64 + ) + if cPassthroughNTPTimestamp { + nowNTP = publisherSRData.NTPTimestamp + nowRTPExt = publisherSRData.RTPTimestampExt - tsOffset + } else { + nowNTP = mediatransportutil.ToNtpTime(now) + nowRTPExt = publisherSRData.RTPTimestampExt - tsOffset + uint64(timeSincePublisherSRAdjusted.Nanoseconds()*int64(r.params.ClockRate)/1e9) + } srData := &RTCPSenderReportData{ NTPTimestamp: nowNTP, @@ -666,13 +677,15 @@ func (r *RTPStatsSender) GetRtcpSenderReport(ssrc uint32, publisherSRData *RTCPS "feed", publisherSRData, "tsOffset", tsOffset, "timeNow", time.Now().String(), + "now", now.String(), "extStartTS", r.extStartTS, "extHighestTS", r.extHighestTS, "highestTime", r.highestTime.String(), "timeSinceHighest", now.Sub(r.highestTime).String(), "firstTime", r.firstTime.String(), "timeSinceFirst", now.Sub(r.firstTime).String(), - "timeSincePublisherSR", timeSincePublisherSR.String(), + "timeSincePublisherSRAdjusted", timeSincePublisherSRAdjusted.String(), + "timeSincePublisherSR", time.Since(publisherSRData.At).String(), "nowRTPExt", nowRTPExt, } }