mirror of
https://github.com/livekit/livekit.git
synced 2026-03-30 17:45:40 +00:00
Retain previous audio score if number of packets is low (#793)
* Retain previous audio score if number of packets is low * better comment and correct spelling
This commit is contained in:
@@ -14,7 +14,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
UpdateInterval = 2 * time.Second
|
||||
UpdateInterval = 2 * time.Second
|
||||
audioPacketRateThreshold = float64(25.0)
|
||||
)
|
||||
|
||||
type ConnectionStatsParams struct {
|
||||
@@ -118,11 +119,18 @@ func (cs *ConnectionStats) updateScore(streams map[uint32]*buffer.StreamStatsWit
|
||||
params.IsReducedQuality = cs.params.GetIsReducedQuality()
|
||||
}
|
||||
cs.score = ScreenshareTrackScore(params)
|
||||
|
||||
case cs.params.CodecType == webrtc.RTPCodecTypeAudio:
|
||||
if cs.params.IsDtxDisabled != nil {
|
||||
params.DtxDisabled = cs.params.IsDtxDisabled()
|
||||
packetRate := float64(params.PacketsExpected) / maxAvailableLayerStats.Duration.Seconds()
|
||||
if packetRate > audioPacketRateThreshold {
|
||||
// With DTX, it is possible to have fewer packets per second.
|
||||
// A loss with reduced packet rate has amplified negative effect on quality.
|
||||
// Opus uses 20 ms packetisation (50 pps). Calculate score only if packet rate is at least half of that.
|
||||
if cs.params.IsDtxDisabled != nil {
|
||||
params.DtxDisabled = cs.params.IsDtxDisabled()
|
||||
}
|
||||
cs.score = AudioTrackScore(params)
|
||||
}
|
||||
cs.score = AudioTrackScore(params)
|
||||
|
||||
case cs.params.CodecType == webrtc.RTPCodecTypeVideo:
|
||||
// See note below about muxed tracks quality calculation challenged.
|
||||
@@ -156,6 +164,10 @@ func (cs *ConnectionStats) updateScore(streams map[uint32]*buffer.StreamStatsWit
|
||||
cs.score = VideoTrackScore(params)
|
||||
}
|
||||
|
||||
if cs.score < 4.0 {
|
||||
cs.params.Logger.Infow("low score", "score", cs.score, "params", params)
|
||||
}
|
||||
|
||||
return cs.score
|
||||
}
|
||||
|
||||
|
||||
@@ -67,8 +67,8 @@ func getRtcMosStat(params TrackScoreParams) rtcmos.Stat {
|
||||
func AudioTrackScore(params TrackScoreParams) float32 {
|
||||
stat := getRtcMosStat(params)
|
||||
stat.AudioConfig = &rtcmos.AudioConfig{}
|
||||
if params.DtxDisabled {
|
||||
flag := false
|
||||
if !params.DtxDisabled {
|
||||
flag := true
|
||||
stat.AudioConfig.Dtx = &flag
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user