diff --git a/pkg/rtc/participant_internal_test.go b/pkg/rtc/participant_internal_test.go index a182606e8..4d294c646 100644 --- a/pkg/rtc/participant_internal_test.go +++ b/pkg/rtc/participant_internal_test.go @@ -469,7 +469,7 @@ func TestPreferVideoCodecForPublisher(t *testing.T) { participant.SetResponseSink(sink) var answer webrtc.SessionDescription var answerReceived atomic.Bool - sink.WriteMessageStub = func(msg proto.Message) error { + sink.WriteMessageCalls(func(msg proto.Message) error { if res, ok := msg.(*livekit.SignalResponse); ok { if res.GetAnswer() != nil { answer = FromProtoSessionDescription(res.GetAnswer()) @@ -478,7 +478,7 @@ func TestPreferVideoCodecForPublisher(t *testing.T) { } } return nil - } + }) participant.HandleOffer(sdp) require.Eventually(t, func() bool { return answerReceived.Load() }, 5*time.Second, 10*time.Millisecond) diff --git a/pkg/sfu/downtrack.go b/pkg/sfu/downtrack.go index 4e89eed3e..0fee2e8ca 100644 --- a/pkg/sfu/downtrack.go +++ b/pkg/sfu/downtrack.go @@ -995,8 +995,7 @@ func (d *DownTrack) IsDeficient() bool { } func (d *DownTrack) BandwidthRequested() int64 { - _, brs := d.receiver.GetLayeredBitrate() - return d.forwarder.BandwidthRequested(brs) + return d.forwarder.BandwidthRequested() } func (d *DownTrack) DistanceToDesired() float64 { diff --git a/pkg/sfu/forwarder.go b/pkg/sfu/forwarder.go index fde7e1ccb..1ef7674f2 100644 --- a/pkg/sfu/forwarder.go +++ b/pkg/sfu/forwarder.go @@ -456,25 +456,11 @@ func (f *Forwarder) IsDeficient() bool { return f.isDeficientLocked() } -func (f *Forwarder) BandwidthRequested(brs Bitrates) int64 { +func (f *Forwarder) BandwidthRequested() int64 { f.lock.RLock() defer f.lock.RUnlock() - if !f.targetLayers.IsValid() { - if f.targetLayers != buffer.InvalidLayers { - f.logger.Warnw( - "unexpected target layers", nil, - "target", f.targetLayers, - "current", f.currentLayers, - "parked", f.parkedLayers, - "max", f.maxLayers, - "lastAllocation", f.lastAllocation, - ) - } - return 0 - } - - return brs[f.targetLayers.Spatial][f.targetLayers.Temporal] + return f.lastAllocation.BandwidthRequested } func (f *Forwarder) DistanceToDesired(availableLayers []int32, brs Bitrates) float64 {