Skip to content

Commit

Permalink
Fix our-of-order twcc fb cause by rtx blocked
Browse files Browse the repository at this point in the history
Fix #2830. The TrackRemote.Read could block in
readRTP if the buffer is empty then rtx packets
arrival before next media rtp packet will be
readed after the next media rtp packet and cause
out-of-order fb and mess up remote peer's
bandwidth estimation.
  • Loading branch information
cnderrauber authored and Sean-Der committed Jul 26, 2024
1 parent bdbeb0c commit 021c271
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rtpreceiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ func (r *RTPReceiver) receiveForRtx(ssrc SSRC, rsid string, streamInfo *intercep
track.repairInterceptor = rtpInterceptor
track.repairRtcpReadStream = rtcpReadStream
track.repairRtcpInterceptor = rtcpInterceptor
track.repairStreamChannel = make(chan rtxPacketWithAttributes)
track.repairStreamChannel = make(chan rtxPacketWithAttributes, 50)

go func() {
for {
Expand Down Expand Up @@ -483,6 +483,8 @@ func (r *RTPReceiver) receiveForRtx(ssrc SSRC, rsid string, streamInfo *intercep
r.rtxPool.Put(b) // nolint:staticcheck
return
case track.repairStreamChannel <- rtxPacketWithAttributes{pkt: b[:i-2], attributes: attributes, pool: &r.rtxPool}:
default:
// skip the RTX packet if the repair stream channel is full, could be blocked in the application's read loop
}
}
}()
Expand Down

0 comments on commit 021c271

Please sign in to comment.