From 174e69c81d10c7ee373425a9e81b8d2dec892d40 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Fri, 2 Feb 2024 08:52:52 +0530 Subject: [PATCH] Restore min score to 30. (#2435) Was at 20 when LOST was introduced, but was going to 20 even when under not LOST conditions. When there are packets, want the min to be at 30. Going down to 20 resulted in reporting LOST quality even when packets were flowing (although they were experiencing heavy loss and quality would have been very bad, yet they are not lost). Also, sample warning about adding packet to bucket even more. --- pkg/sfu/buffer/buffer.go | 2 +- pkg/sfu/connectionquality/scorer.go | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pkg/sfu/buffer/buffer.go b/pkg/sfu/buffer/buffer.go index d0147bab6..f27946064 100644 --- a/pkg/sfu/buffer/buffer.go +++ b/pkg/sfu/buffer/buffer.go @@ -476,7 +476,7 @@ func (b *Buffer) calc(pkt []byte, arrivalTime time.Time) { if err != nil { if errors.Is(err, bucket.ErrPacketTooOld) { packetTooOldCount := b.packetTooOldCount.Inc() - if packetTooOldCount%20 == 0 { + if (packetTooOldCount-1)%100 == 0 { b.logger.Warnw("could not add packet to bucket", err, "count", packetTooOldCount) } } else if err != bucket.ErrRTXPacket { diff --git a/pkg/sfu/connectionquality/scorer.go b/pkg/sfu/connectionquality/scorer.go index ffc3961da..d5c3b019c 100644 --- a/pkg/sfu/connectionquality/scorer.go +++ b/pkg/sfu/connectionquality/scorer.go @@ -29,9 +29,8 @@ const ( MaxMOS = float32(4.5) MinMOS = float32(1.0) - cMaxScore = float64(100.0) - cMinScore = float64(20.0) - cPausedPoorScore = float64(30.0) + cMaxScore = float64(100.0) + cMinScore = float64(30.0) increaseFactor = float64(0.4) // slower increase, i. e. when score is recovering move up slower -> conservative decreaseFactor = float64(0.7) // faster decrease, i. e. when score is dropping move down faster -> aggressive to be responsive to quality drops @@ -305,7 +304,7 @@ func (q *qualityScorer) updatePauseAtLocked(isPaused bool, at time.Time) { q.layerDistance.Reset() q.pausedAt = at - q.score = cPausedPoorScore + q.score = cMinScore } } else { if q.isPaused() { @@ -364,7 +363,7 @@ func (q *qualityScorer) updateAtLocked(stat *windowStat, at time.Time) { // considered (as long as enough time has passed since unmute). // // Similarly, when paused (possibly due to congestion), score is immediately - // set to cPausedPoorScore for responsiveness. The layer transision is reest. + // set to cMinScore for responsiveness. The layer transision is reest. // On a resume, quality climbs back up using normal operation. if q.isMuted() || !q.isUnmutedEnough(at) || q.isLayerMuted() || q.isPaused() { q.lastUpdateAt = at @@ -404,12 +403,12 @@ func (q *qualityScorer) updateAtLocked(stat *windowStat, at time.Time) { factor = decreaseFactor } score = factor*score + (1.0-factor)*q.score - } - if score < cMinScore { - // lower bound to prevent score from becoming very small values due to extreme conditions. - // Without a lower bound, it can get so low that it takes a long time to climb back to - // better quality even under excellent conditions. - score = cMinScore + if score < cMinScore { + // lower bound to prevent score from becoming very small values due to extreme conditions. + // Without a lower bound, it can get so low that it takes a long time to climb back to + // better quality even under excellent conditions. + score = cMinScore + } } prevCQ := scoreToConnectionQuality(q.score) currCQ := scoreToConnectionQuality(score)