Tigether scoping on connection stats lock. (#415)
This commit is contained in:
@@ -111,7 +111,10 @@ func (cs *ConnectionStats) UpdateWindow(ssrc uint32, extHighestSeqNum uint32, pa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *ConnectionStats) updateScore() {
|
func (cs *ConnectionStats) updateScore() float32 {
|
||||||
|
cs.lock.Lock()
|
||||||
|
defer cs.lock.Unlock()
|
||||||
|
|
||||||
expectedPacketsInInterval := uint32(0)
|
expectedPacketsInInterval := uint32(0)
|
||||||
lostPacketsInInterval := uint32(0)
|
lostPacketsInInterval := uint32(0)
|
||||||
maxRTT := uint32(0)
|
maxRTT := uint32(0)
|
||||||
@@ -150,12 +153,11 @@ func (cs *ConnectionStats) updateScore() {
|
|||||||
}
|
}
|
||||||
cs.score = VideoConnectionScore(pctLoss, isReducedQuality)
|
cs.score = VideoConnectionScore(pctLoss, isReducedQuality)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return cs.score
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *ConnectionStats) getStat() *livekit.AnalyticsStat {
|
func (cs *ConnectionStats) getStat() *livekit.AnalyticsStat {
|
||||||
cs.lock.Lock()
|
|
||||||
defer cs.lock.Unlock()
|
|
||||||
|
|
||||||
if cs.params.GetTrackStats == nil {
|
if cs.params.GetTrackStats == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -191,10 +193,10 @@ func (cs *ConnectionStats) getStat() *livekit.AnalyticsStat {
|
|||||||
analyticsStreams = append(analyticsStreams, as)
|
analyticsStreams = append(analyticsStreams, as)
|
||||||
}
|
}
|
||||||
|
|
||||||
cs.updateScore()
|
score := cs.updateScore()
|
||||||
|
|
||||||
return &livekit.AnalyticsStat{
|
return &livekit.AnalyticsStat{
|
||||||
Score: float32(cs.score),
|
Score: score,
|
||||||
Streams: analyticsStreams,
|
Streams: analyticsStreams,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user