Add max playout delay config (#2089)
* Add max playout delay * config sample
This commit is contained in:
@@ -161,6 +161,7 @@ keys:
|
|||||||
# playout_delay:
|
# playout_delay:
|
||||||
# enabled: true
|
# enabled: true
|
||||||
# min: 100
|
# min: 100
|
||||||
|
# max: 2000
|
||||||
|
|
||||||
# Webhooks
|
# Webhooks
|
||||||
# when configured, LiveKit notifies your URL handler with room events
|
# when configured, LiveKit notifies your URL handler with room events
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ require (
|
|||||||
github.com/jxskiss/base62 v1.1.0
|
github.com/jxskiss/base62 v1.1.0
|
||||||
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
|
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
|
||||||
github.com/livekit/mediatransportutil v0.0.0-20230906055425-e81fd5f6fb3f
|
github.com/livekit/mediatransportutil v0.0.0-20230906055425-e81fd5f6fb3f
|
||||||
github.com/livekit/protocol v1.7.3-0.20230915202328-cf9f95141e0e
|
github.com/livekit/protocol v1.7.3-0.20230918130519-dd24d071834c
|
||||||
github.com/livekit/psrpc v0.3.3
|
github.com/livekit/psrpc v0.3.3
|
||||||
github.com/mackerelio/go-osstat v0.2.4
|
github.com/mackerelio/go-osstat v0.2.4
|
||||||
github.com/magefile/mage v1.15.0
|
github.com/magefile/mage v1.15.0
|
||||||
|
|||||||
@@ -129,6 +129,8 @@ github.com/livekit/mediatransportutil v0.0.0-20230906055425-e81fd5f6fb3f h1:b4ri
|
|||||||
github.com/livekit/mediatransportutil v0.0.0-20230906055425-e81fd5f6fb3f/go.mod h1:+WIOYwiBMive5T81V8B2wdAc2zQNRjNQiJIcPxMTILY=
|
github.com/livekit/mediatransportutil v0.0.0-20230906055425-e81fd5f6fb3f/go.mod h1:+WIOYwiBMive5T81V8B2wdAc2zQNRjNQiJIcPxMTILY=
|
||||||
github.com/livekit/protocol v1.7.3-0.20230915202328-cf9f95141e0e h1:WEet0iH/JazBFNhhH+YuZHtXpKefb7mnbCC2al3peyA=
|
github.com/livekit/protocol v1.7.3-0.20230915202328-cf9f95141e0e h1:WEet0iH/JazBFNhhH+YuZHtXpKefb7mnbCC2al3peyA=
|
||||||
github.com/livekit/protocol v1.7.3-0.20230915202328-cf9f95141e0e/go.mod h1:zbh0QPUcLGOeZeIO/VeigwWWbudz4Lv+Px94FnVfQH0=
|
github.com/livekit/protocol v1.7.3-0.20230915202328-cf9f95141e0e/go.mod h1:zbh0QPUcLGOeZeIO/VeigwWWbudz4Lv+Px94FnVfQH0=
|
||||||
|
github.com/livekit/protocol v1.7.3-0.20230918130519-dd24d071834c h1:Z44UEdskI35V3nDJfVvYuJ4DOW1wQLku32wbNyz23MM=
|
||||||
|
github.com/livekit/protocol v1.7.3-0.20230918130519-dd24d071834c/go.mod h1:zbh0QPUcLGOeZeIO/VeigwWWbudz4Lv+Px94FnVfQH0=
|
||||||
github.com/livekit/psrpc v0.3.3 h1:+lltbuN39IdaynXhLLxRShgYqYsRMWeeXKzv60oqyWo=
|
github.com/livekit/psrpc v0.3.3 h1:+lltbuN39IdaynXhLLxRShgYqYsRMWeeXKzv60oqyWo=
|
||||||
github.com/livekit/psrpc v0.3.3/go.mod h1:n6JntEg+zT6Ji8InoyTpV7wusPNwGqqtxmHlkNhDN0U=
|
github.com/livekit/psrpc v0.3.3/go.mod h1:n6JntEg+zT6Ji8InoyTpV7wusPNwGqqtxmHlkNhDN0U=
|
||||||
github.com/mackerelio/go-osstat v0.2.4 h1:qxGbdPkFo65PXOb/F/nhDKpF2nGmGaCFDLXoZjJTtUs=
|
github.com/mackerelio/go-osstat v0.2.4 h1:qxGbdPkFo65PXOb/F/nhDKpF2nGmGaCFDLXoZjJTtUs=
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ type StreamTrackersConfig struct {
|
|||||||
type PlayoutDelayConfig struct {
|
type PlayoutDelayConfig struct {
|
||||||
Enabled bool `yaml:"enabled,omitempty"`
|
Enabled bool `yaml:"enabled,omitempty"`
|
||||||
Min int `yaml:"min,omitempty"`
|
Min int `yaml:"min,omitempty"`
|
||||||
|
Max int `yaml:"max,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type VideoConfig struct {
|
type VideoConfig struct {
|
||||||
|
|||||||
@@ -85,10 +85,11 @@ func (r *StandardRoomAllocator) CreateRoom(ctx context.Context, req *livekit.Cre
|
|||||||
if req.Egress != nil && req.Egress.Tracks != nil {
|
if req.Egress != nil && req.Egress.Tracks != nil {
|
||||||
internal = &livekit.RoomInternal{TrackEgress: req.Egress.Tracks}
|
internal = &livekit.RoomInternal{TrackEgress: req.Egress.Tracks}
|
||||||
}
|
}
|
||||||
if req.MinPlayoutDelay > 0 {
|
if req.MinPlayoutDelay > 0 || req.MaxPlayoutDelay > 0 {
|
||||||
rm.PlayoutDelay = &livekit.PlayoutDelay{
|
rm.PlayoutDelay = &livekit.PlayoutDelay{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Min: req.MinPlayoutDelay,
|
Min: req.MinPlayoutDelay,
|
||||||
|
Max: req.MaxPlayoutDelay,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,5 +161,6 @@ func applyDefaultRoomConfig(room *livekit.Room, conf *config.RoomConfig) {
|
|||||||
room.PlayoutDelay = &livekit.PlayoutDelay{
|
room.PlayoutDelay = &livekit.PlayoutDelay{
|
||||||
Enabled: conf.PlayoutDelay.Enabled,
|
Enabled: conf.PlayoutDelay.Enabled,
|
||||||
Min: uint32(conf.PlayoutDelay.Min),
|
Min: uint32(conf.PlayoutDelay.Min),
|
||||||
|
Max: uint32(conf.PlayoutDelay.Max),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -326,14 +326,20 @@ func NewDownTrack(params DowntrackParams) (*DownTrack, error) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// set initial playout delay to minimum value
|
// set initial playout delay to minimum value
|
||||||
if d.params.PlayoutDelayLimit.GetEnabled() && d.params.PlayoutDelayLimit.GetMin() > 0 {
|
if d.params.PlayoutDelayLimit.GetEnabled() {
|
||||||
|
maxDelay := uint32(rtpextension.PlayoutDelayDefaultMax)
|
||||||
|
if d.params.PlayoutDelayLimit.GetMax() > 0 {
|
||||||
|
maxDelay = d.params.PlayoutDelayLimit.GetMax()
|
||||||
|
}
|
||||||
delay := rtpextension.PlayoutDelayFromValue(
|
delay := rtpextension.PlayoutDelayFromValue(
|
||||||
uint16(d.params.PlayoutDelayLimit.GetMin()),
|
uint16(d.params.PlayoutDelayLimit.GetMin()),
|
||||||
rtpextension.PlayoutDelayDefaultMax,
|
uint16(maxDelay),
|
||||||
)
|
)
|
||||||
b, err := delay.Marshal()
|
b, err := delay.Marshal()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
d.playoutDelayBytes.Store(b)
|
d.playoutDelayBytes.Store(b)
|
||||||
|
} else {
|
||||||
|
d.params.Logger.Errorw("failed to marshal playout delay", err, "playoutDelay", d.params.PlayoutDelayLimit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if d.kind == webrtc.RTPCodecTypeVideo {
|
if d.kind == webrtc.RTPCodecTypeVideo {
|
||||||
|
|||||||
Reference in New Issue
Block a user