mirror of
https://github.com/livekit/livekit.git
synced 2026-05-15 16:06:09 +00:00
use default max playout delay as chrome (#2411)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user