diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index f8384792..e55883d7 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -147,7 +147,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) { } p := &ParticipantImpl{ params: params, - rtcpCh: make(chan []rtcp.Packet, 50), + rtcpCh: make(chan []rtcp.Packet, 100), pendingTracks: make(map[string]*pendingTrackInfo), subscribedTracks: make(map[livekit.TrackID]types.SubscribedTrack), subscribedTracksSettings: make(map[livekit.TrackID]*livekit.UpdateTrackSettings), @@ -1468,7 +1468,7 @@ func (p *ParticipantImpl) mediaTrackReceived(track *webrtc.TrackRemote, rtpRecei if p.twcc == nil { p.twcc = twcc.NewTransportWideCCResponder(ssrc) p.twcc.OnFeedback(func(pkt rtcp.RawPacket) { - p.rtcpCh <- []rtcp.Packet{&pkt} + p.postRtcp([]rtcp.Packet{&pkt}) }) } p.pendingTracksLock.Unlock() @@ -1506,7 +1506,7 @@ func (p *ParticipantImpl) hasPendingMigratedTrack() bool { } func (p *ParticipantImpl) onUpTrackManagerClose() { - p.rtcpCh <- nil + p.postRtcp(nil) } func (p *ParticipantImpl) getPendingTrack(clientId string, kind livekit.TrackType) (string, *livekit.TrackInfo) { @@ -1659,3 +1659,11 @@ func (p *ParticipantImpl) incActiveCounter() { p.updateState(livekit.ParticipantInfo_ACTIVE) } } + +func (p *ParticipantImpl) postRtcp(pkts []rtcp.Packet) { + select { + case p.rtcpCh <- pkts: + default: + p.params.Logger.Warnw("rtcp channel full", nil) + } +} diff --git a/pkg/sfu/streamallocator.go b/pkg/sfu/streamallocator.go index 48e0e31b..1850c650 100644 --- a/pkg/sfu/streamallocator.go +++ b/pkg/sfu/streamallocator.go @@ -354,7 +354,11 @@ func (s *StreamAllocator) postEvent(event Event) { return } - s.eventCh <- event + select { + case s.eventCh <- event: + default: + s.params.Logger.Warnw("event queue full", nil) + } s.eventChMu.RUnlock() }