From 59be7c601bca4d0b9dc79cdde61edbf146b73257 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Tue, 28 Jan 2025 14:10:23 +0530 Subject: [PATCH] Declare congestion none only if both methods are in DQR. (#3372) * Declare congestion none only if both emthods are in DQR. * do not change congestion reason unless queuing region changes --- .../bwe/sendsidebwe/congestion_detector.go | 25 +++++++++++-------- pkg/sfu/bwe/sendsidebwe/traffic_stats.go | 4 +-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/pkg/sfu/bwe/sendsidebwe/congestion_detector.go b/pkg/sfu/bwe/sendsidebwe/congestion_detector.go index 567143b89..5785e17c9 100644 --- a/pkg/sfu/bwe/sendsidebwe/congestion_detector.go +++ b/pkg/sfu/bwe/sendsidebwe/congestion_detector.go @@ -250,8 +250,10 @@ func (q *qdMeasurement) ProcessPacketGroup(pg *packetGroup, groupIdx int) { } default: - // broken continuity, seal - q.isSealed = true + if q.numDQRGroups > 0 || q.numJQRGroups > 0 { + // broken continuity, seal + q.isSealed = true + } } } @@ -875,15 +877,18 @@ func (c *congestionDetector) updateCongestionSignal( } } - c.congestionReason = congestionReasonNone - c.queuingRegion = c.qdMeasurement.QueuingRegion() - if c.queuingRegion == queuingRegionJQR { + qdQueuingRegion := c.qdMeasurement.QueuingRegion() + lossQueuingRegion := c.lossMeasurement.QueuingRegion() + switch { + case qdQueuingRegion == queuingRegionJQR: + c.queuingRegion = queuingRegionJQR c.congestionReason = congestionReasonQueuingDelay - } else { - c.queuingRegion = c.lossMeasurement.QueuingRegion() - if c.queuingRegion == queuingRegionJQR { - c.congestionReason = congestionReasonLoss - } + case lossQueuingRegion == queuingRegionJQR: + c.queuingRegion = queuingRegionJQR + c.congestionReason = congestionReasonLoss + case qdQueuingRegion == queuingRegionDQR && lossQueuingRegion == queuingRegionDQR: + c.queuingRegion = queuingRegionDQR + c.congestionReason = congestionReasonNone } } diff --git a/pkg/sfu/bwe/sendsidebwe/traffic_stats.go b/pkg/sfu/bwe/sendsidebwe/traffic_stats.go index 480878ac6..f1c07d54e 100644 --- a/pkg/sfu/bwe/sendsidebwe/traffic_stats.go +++ b/pkg/sfu/bwe/sendsidebwe/traffic_stats.go @@ -95,8 +95,8 @@ func (ts *trafficStats) AcknowledgedBitrate() int64 { return 0 } - ackedBitrate := int64(ts.ackedBytes) * 8 * 1e6 / ts.Duration() - return int64(float64(ackedBitrate) * ts.CapturedTrafficRatio()) + ackedBitrate := float64(ts.ackedBytes) * 8 * 1e6 / float64(ts.Duration()) + return int64(ackedBitrate * ts.CapturedTrafficRatio()) } func (ts *trafficStats) CapturedTrafficRatio() float64 {