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:
Raja Subramanian
2022-06-29 14:48:06 +05:30
committed by GitHub
parent 1e39a680ac
commit 2c48eafd6e
2 changed files with 18 additions and 6 deletions
+16 -4
View File
@@ -14,7 +14,8 @@ import (
) )
const ( const (
UpdateInterval = 2 * time.Second UpdateInterval = 2 * time.Second
audioPacketRateThreshold = float64(25.0)
) )
type ConnectionStatsParams struct { type ConnectionStatsParams struct {
@@ -118,11 +119,18 @@ func (cs *ConnectionStats) updateScore(streams map[uint32]*buffer.StreamStatsWit
params.IsReducedQuality = cs.params.GetIsReducedQuality() params.IsReducedQuality = cs.params.GetIsReducedQuality()
} }
cs.score = ScreenshareTrackScore(params) cs.score = ScreenshareTrackScore(params)
case cs.params.CodecType == webrtc.RTPCodecTypeAudio: case cs.params.CodecType == webrtc.RTPCodecTypeAudio:
if cs.params.IsDtxDisabled != nil { packetRate := float64(params.PacketsExpected) / maxAvailableLayerStats.Duration.Seconds()
params.DtxDisabled = cs.params.IsDtxDisabled() 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: case cs.params.CodecType == webrtc.RTPCodecTypeVideo:
// See note below about muxed tracks quality calculation challenged. // 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) cs.score = VideoTrackScore(params)
} }
if cs.score < 4.0 {
cs.params.Logger.Infow("low score", "score", cs.score, "params", params)
}
return cs.score return cs.score
} }
+2 -2
View File
@@ -67,8 +67,8 @@ func getRtcMosStat(params TrackScoreParams) rtcmos.Stat {
func AudioTrackScore(params TrackScoreParams) float32 { func AudioTrackScore(params TrackScoreParams) float32 {
stat := getRtcMosStat(params) stat := getRtcMosStat(params)
stat.AudioConfig = &rtcmos.AudioConfig{} stat.AudioConfig = &rtcmos.AudioConfig{}
if params.DtxDisabled { if !params.DtxDisabled {
flag := false flag := true
stat.AudioConfig.Dtx = &flag stat.AudioConfig.Dtx = &flag
} }