Propagate spreader threshold to RED receivers. (#4683)
Following up on this PR (https://github.com/livekit/livekit/pull/4678 - great catch btw, thank you), propagating the spreader threshold to RED receivers also. Removing the test as it was a simple case and that would not have caught the original issue.
This commit is contained in:
@@ -157,6 +157,7 @@ type TrackReceiver interface {
|
|||||||
|
|
||||||
type REDTransformer interface {
|
type REDTransformer interface {
|
||||||
TrackReceiver
|
TrackReceiver
|
||||||
|
SetLBThreshold(lbThreshold int)
|
||||||
ForwardRTP(pkt *buffer.ExtPacket, spatialLayer int32) int32
|
ForwardRTP(pkt *buffer.ExtPacket, spatialLayer int32) int32
|
||||||
ForwardRTCPSenderReport(
|
ForwardRTCPSenderReport(
|
||||||
payloadType webrtc.PayloadType,
|
payloadType webrtc.PayloadType,
|
||||||
@@ -312,6 +313,9 @@ func (r *ReceiverBase) SetEnableRTPStreamRestartDetection(enableRTPStremRestartD
|
|||||||
func (r *ReceiverBase) SetLBThreshold(lbThreshold int) {
|
func (r *ReceiverBase) SetLBThreshold(lbThreshold int) {
|
||||||
r.lbThreshold = lbThreshold
|
r.lbThreshold = lbThreshold
|
||||||
r.downTrackSpreader.SetThreshold(lbThreshold)
|
r.downTrackSpreader.SetThreshold(lbThreshold)
|
||||||
|
if rt := r.loadREDTransformer(); rt != nil {
|
||||||
|
rt.SetLBThreshold(lbThreshold)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ReceiverBase) SetForwardStats(forwardStats *ForwardStats) {
|
func (r *ReceiverBase) SetForwardStats(forwardStats *ForwardStats) {
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ func NewRedPrimaryReceiver(receiver TrackReceiver, dsp utils.DownTrackSpreaderPa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RedPrimaryReceiver) SetLBThreshold(lbThreshold int) {
|
||||||
|
r.downTrackSpreader.SetThreshold(lbThreshold)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *RedPrimaryReceiver) ForwardRTP(pkt *buffer.ExtPacket, spatialLayer int32) int32 {
|
func (r *RedPrimaryReceiver) ForwardRTP(pkt *buffer.ExtPacket, spatialLayer int32) int32 {
|
||||||
// extract primary payload from RED and forward to downtracks
|
// extract primary payload from RED and forward to downtracks
|
||||||
if r.downTrackSpreader.DownTrackCount() == 0 {
|
if r.downTrackSpreader.DownTrackCount() == 0 {
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ func NewRedReceiver(receiver TrackReceiver, dsp utils.DownTrackSpreaderParams) R
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RedReceiver) SetLBThreshold(lbThreshold int) {
|
||||||
|
r.downTrackSpreader.SetThreshold(lbThreshold)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *RedReceiver) ForwardRTP(pkt *buffer.ExtPacket, spatialLayer int32) int32 {
|
func (r *RedReceiver) ForwardRTP(pkt *buffer.ExtPacket, spatialLayer int32) int32 {
|
||||||
// encode RED payload from primary payload and forward to downtracks
|
// encode RED payload from primary payload and forward to downtracks
|
||||||
if r.downTrackSpreader.DownTrackCount() == 0 {
|
if r.downTrackSpreader.DownTrackCount() == 0 {
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
// Copyright 2026 LiveKit, Inc.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/livekit/protocol/livekit"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
|
||||||
|
|
||||||
type testSender struct {
|
|
||||||
subscriberID livekit.ParticipantID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t testSender) SubscriberID() livekit.ParticipantID {
|
|
||||||
return t.subscriberID
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDownTrackSpreaderSetThreshold(t *testing.T) {
|
|
||||||
spreader := NewDownTrackSpreader[testSender](DownTrackSpreaderParams{})
|
|
||||||
|
|
||||||
spreader.SetThreshold(20)
|
|
||||||
|
|
||||||
spreader.downTrackMu.RLock()
|
|
||||||
threshold := spreader.params.Threshold
|
|
||||||
spreader.downTrackMu.RUnlock()
|
|
||||||
|
|
||||||
require.Equal(t, 20, threshold)
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user