From 0bb89575eb114488ec68f182ad73c47c5f4698df Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Fri, 19 May 2023 12:43:19 +0530 Subject: [PATCH] Fix min TS before first sender report (#1724) --- pkg/sfu/buffer/rtpstats.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/sfu/buffer/rtpstats.go b/pkg/sfu/buffer/rtpstats.go index 873c8d59d..abc5dda08 100644 --- a/pkg/sfu/buffer/rtpstats.go +++ b/pkg/sfu/buffer/rtpstats.go @@ -808,6 +808,11 @@ func (r *RTPStats) GetExpectedRTPTimestamp(at time.Time) (uint32, uint32, error) timeDiff := at.Sub(r.firstTime) expectedRTPDiff := timeDiff.Nanoseconds() * int64(r.params.ClockRate) / 1e9 expectedExtRTP := r.extStartTS + uint64(expectedRTPDiff) + + minTS := r.lastSRRTP + if r.lastSRNTP == 0 { + minTS = uint32(expectedExtRTP) + } r.logger.Debugw( "expected RTP timestamp", "firstTime", r.firstTime.String(), @@ -817,10 +822,11 @@ func (r *RTPStats) GetExpectedRTPTimestamp(at time.Time) (uint32, uint32, error) "expectedRTPDiff", expectedRTPDiff, "expectedExtRTP", expectedExtRTP, "expectedRTP", uint32(expectedExtRTP), + "minTS", minTS, "highestTS", r.highestTS, "highestTime", r.highestTime.String(), ) - return uint32(expectedExtRTP), r.lastSRRTP, nil + return uint32(expectedExtRTP), minTS, nil } func (r *RTPStats) GetRtcpSenderReport(ssrc uint32) (*rtcp.SenderReport, float64) {