@@ -127,31 +127,40 @@ func (p *Publisher) Matches(trackDescription event.SFUTrackDescription) bool {
127127
128128func (p * Publisher ) WriteRTCP (packets []rtcp.Packet ) {
129129 packetsToSend := []rtcp.Packet {}
130+ readSSRC := uint32 (p .Track .SSRC ())
130131
131132 for _ , packet := range packets {
132- // Since we sometimes spam the sender with PLIs, make sure we don't send
133- // them way too often
134- if _ , ok := packet .(* rtcp.PictureLossIndication ); ok {
133+ switch typedPacket := packet .(type ) {
134+ // We mung the packets here, so that the SSRCs match what the
135+ // receiver expects:
136+ // The media SSRC is the SSRC of the media about which the packet is
137+ // reporting; therefore, we mung it to be the SSRC of the publishing
138+ // participant's track. Without this, it would be SSRC of the SFU's
139+ // track which isn't right
140+ case * rtcp.PictureLossIndication :
141+ // Since we sometimes spam the sender with PLIs, make sure we don't send
142+ // them way too often
135143 if time .Now ().UnixNano ()- p .lastPLI .Load () < minimalPLIInterval .Nanoseconds () {
136144 continue
137145 }
138-
139146 p .lastPLI .Store (time .Now ().UnixNano ())
147+
148+ typedPacket .MediaSSRC = readSSRC
149+ packetsToSend = append (packetsToSend , typedPacket )
150+ case * rtcp.FullIntraRequest :
151+ typedPacket .MediaSSRC = readSSRC
152+ packetsToSend = append (packetsToSend , typedPacket )
140153 }
141154
142155 packetsToSend = append (packetsToSend , packet )
143156 }
144157
145- if len (packetsToSend ) < 1 {
146- return
147- }
148-
149- if err := p .Call .PeerConnection .WriteRTCP (packetsToSend ); err != nil {
150- if errors .Is (err , io .ErrClosedPipe ) {
151- return
158+ if len (packetsToSend ) != 1 {
159+ if err := p .Call .PeerConnection .WriteRTCP (packetsToSend ); err != nil {
160+ if ! errors .Is (err , io .ErrClosedPipe ) {
161+ p .logger .WithError (err ).Warn ("failed to write RTCP on track" )
162+ }
152163 }
153-
154- p .logger .WithError (err ).Warn ("failed to write RTCP on track" )
155164 }
156165}
157166
0 commit comments