initialize bucket size by publish bitrates (#2763)

This commit is contained in:
cnderrauber
2024-06-06 14:31:20 +08:00
committed by GitHub
parent f1886ece42
commit 908baeb942
3 changed files with 20 additions and 7 deletions
+9 -1
View File
@@ -194,7 +194,7 @@ func (b *Buffer) SetAudioLossProxying(enable bool) {
b.enableAudioLossProxying = enable
}
func (b *Buffer) Bind(params webrtc.RTPParameters, codec webrtc.RTPCodecCapability) {
func (b *Buffer) Bind(params webrtc.RTPParameters, codec webrtc.RTPCodecCapability, bitrates int) {
b.Lock()
defer b.Unlock()
if b.bound {
@@ -264,6 +264,14 @@ func (b *Buffer) Bind(params webrtc.RTPParameters, codec webrtc.RTPCodecCapabili
}
}
}
if bitrates > 0 {
pps := bitrates / 8 / 1200
for pps > b.bucket.Capacity() {
if b.bucket.Grow() >= b.maxVideoPkts {
break
}
}
}
default:
b.codecType = webrtc.RTPCodecType(0)