1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 16:45:58 +01:00

Don't mute clients unless they are suffering packet loss.

Otherwise we never recover from low throughput.
This commit is contained in:
Juliusz Chroboczek 2020-04-29 18:49:09 +02:00
parent aef0c731b3
commit 6ba5315a48

View file

@ -662,16 +662,34 @@ func updateUpBitrate(up *upConnection) {
for _, l := range local { for _, l := range local {
ms := atomic.LoadUint64(&l.maxBitrate.timestamp) ms := atomic.LoadUint64(&l.maxBitrate.timestamp)
bitrate := atomic.LoadUint64(&l.maxBitrate.bitrate) bitrate := atomic.LoadUint64(&l.maxBitrate.bitrate)
loss := atomic.LoadUint32(&l.loss)
if now < ms || now > ms+5000 || bitrate == 0 { if now < ms || now > ms+5000 || bitrate == 0 {
// no rate information
l.setMuted(false) l.setMuted(false)
continue continue
} }
if bitrate < 9600 ||
(l.track.Kind() == webrtc.RTPCodecTypeVideo && isvideo := l.track.Kind() == webrtc.RTPCodecTypeVideo
bitrate < 128000) { minrate1 := uint64(9600)
minrate2 := uint64(19200)
if isvideo {
minrate1 = 256000
minrate2 = 512000
}
if bitrate < minrate2 {
if loss <= 13 {
// less than 10% loss, go ahead
bitrate = minrate2
} else if loss <= 64 || !isvideo {
if bitrate < minrate1 {
bitrate = minrate1
}
} else {
// video track with dramatic loss
l.setMuted(true) l.setMuted(true)
continue continue
} }
}
l.setMuted(false) l.setMuted(false)
if track.maxBitrate > bitrate { if track.maxBitrate > bitrate {
track.maxBitrate = bitrate track.maxBitrate = bitrate