use default max playout delay as chrome (#2411)

This commit is contained in:
cnderrauber
2024-01-26 13:32:54 +08:00
committed by GitHub
parent 995fddbaf9
commit 9b4ba2d41d
3 changed files with 19 additions and 7 deletions
+5 -2
View File
@@ -46,8 +46,11 @@ type PlayoutDelayController struct {
}
func NewPlayoutDelayController(minDelay, maxDelay uint32, logger logger.Logger, rtpStats *buffer.RTPStatsSender) (*PlayoutDelayController, error) {
if maxDelay == 0 || maxDelay > rtpextension.PlayoutDelayDefaultMax {
maxDelay = rtpextension.PlayoutDelayDefaultMax
if maxDelay == 0 && minDelay > 0 {
maxDelay = rtpextension.MaxPlayoutDelayDefault
}
if maxDelay > rtpextension.PlayoutDelayMaxValue {
maxDelay = rtpextension.PlayoutDelayMaxValue
}
c := &PlayoutDelayController{
currentDelay: minDelay,
+6 -5
View File
@@ -7,7 +7,8 @@ import (
const (
PlayoutDelayURI = "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"
PlayoutDelayDefaultMax = 4000 // 4s
MaxPlayoutDelayDefault = 10000 // 10s, equal to chrome's default max playout delay
PlayoutDelayMaxValue = 10 * (1<<12 - 1) // max value for playout delay can be represented
playoutDelayExtensionSize = 3
)
@@ -28,11 +29,11 @@ type PlayOutDelay struct {
}
func PlayoutDelayFromValue(min, max uint16) PlayOutDelay {
if min >= (1<<12)*10 {
min = (1<<12 - 1) * 10
if min > PlayoutDelayMaxValue {
min = PlayoutDelayMaxValue
}
if max >= (1<<12)*10 {
max = (1<<12 - 1) * 10
if max > PlayoutDelayMaxValue {
max = PlayoutDelayMaxValue
}
return PlayOutDelay{Min: min, Max: max}
}
@@ -32,4 +32,12 @@ func TestPlayoutDelay(t *testing.T) {
require.NoError(t, err)
require.Equal(t, uint16((1<<12)-1)*10, p5.Min)
require.Equal(t, uint16((1<<12)-1)*10, p5.Max)
p6 := PlayOutDelay{Min: 100, Max: PlayoutDelayMaxValue}
bytes, err := p6.Marshal()
require.NoError(t, err)
p6Unmarshal := PlayOutDelay{}
err = p6Unmarshal.Unmarshal(bytes)
require.NoError(t, err)
require.Equal(t, p6, p6Unmarshal)
}