handle when RTCP comes in after track is closed
package rtc
import (
- "context"
"io"
"sync"
"time"
@@ -31,7 +30,6 @@ var (
// MediaTrack represents a WebRTC track that needs to be forwarded
// Implements the PublishedTrack interface
type MediaTrack struct {
- ctx context.Context
id string
participantId string
muted bool
@@ -57,7 +55,6 @@ type MediaTrack struct {
func NewMediaTrack(trackId string, pId string, rtcpCh chan []rtcp.Packet, track *webrtc.TrackRemote, receiver types.Receiver) *MediaTrack {
t := &MediaTrack{
- ctx: context.Background(),
id: trackId,
participantId: pId,
ssrc: track.SSRC(),
@@ -332,6 +329,10 @@ func (t *MediaTrack) handleRTCP(dt *sfu.DownTrack, rtcpBuf []byte) {
for _, pair := range p.Nacks {
nackedPackets = append(nackedPackets, dt.GetNACKSeqNo(pair.PacketList())...)
}
+
+ if t.nackWorker.Stopped() {
+ return
+ }
t.nackWorker.Submit(func() {
pktBuf := packetFactory.Get().([]byte)
for _, sn := range nackedPackets {
