Add max playout delay config (#2089)
* Add max playout delay * config sample
This commit is contained in:
@@ -205,6 +205,7 @@ type StreamTrackersConfig struct {
|
||||
type PlayoutDelayConfig struct {
|
||||
Enabled bool `yaml:"enabled,omitempty"`
|
||||
Min int `yaml:"min,omitempty"`
|
||||
Max int `yaml:"max,omitempty"`
|
||||
}
|
||||
|
||||
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 {
|
||||
internal = &livekit.RoomInternal{TrackEgress: req.Egress.Tracks}
|
||||
}
|
||||
if req.MinPlayoutDelay > 0 {
|
||||
if req.MinPlayoutDelay > 0 || req.MaxPlayoutDelay > 0 {
|
||||
rm.PlayoutDelay = &livekit.PlayoutDelay{
|
||||
Enabled: true,
|
||||
Min: req.MinPlayoutDelay,
|
||||
Max: req.MaxPlayoutDelay,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,5 +161,6 @@ func applyDefaultRoomConfig(room *livekit.Room, conf *config.RoomConfig) {
|
||||
room.PlayoutDelay = &livekit.PlayoutDelay{
|
||||
Enabled: conf.PlayoutDelay.Enabled,
|
||||
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
|
||||
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(
|
||||
uint16(d.params.PlayoutDelayLimit.GetMin()),
|
||||
rtpextension.PlayoutDelayDefaultMax,
|
||||
uint16(maxDelay),
|
||||
)
|
||||
b, err := delay.Marshal()
|
||||
if err == nil {
|
||||
d.playoutDelayBytes.Store(b)
|
||||
} else {
|
||||
d.params.Logger.Errorw("failed to marshal playout delay", err, "playoutDelay", d.params.PlayoutDelayLimit)
|
||||
}
|
||||
}
|
||||
if d.kind == webrtc.RTPCodecTypeVideo {
|
||||
|
||||
Reference in New Issue
Block a user