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 (
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user