Only send PLIs for video tracks in examples

This commit is contained in:
Tristan Matthews
2024-08-15 16:50:10 -04:00
committed by Sean DuBois
parent ddb9219c84
commit d54f7870eb
2 changed files with 15 additions and 11 deletions

View File

@@ -111,6 +111,7 @@ func main() {
// Start reading from all the streams and sending them to the related output track // Start reading from all the streams and sending them to the related output track
rid := track.RID() rid := track.RID()
if track.Kind() == webrtc.RTPCodecTypeVideo {
go func() { go func() {
ticker := time.NewTicker(3 * time.Second) ticker := time.NewTicker(3 * time.Second)
defer ticker.Stop() defer ticker.Stop()
@@ -121,6 +122,7 @@ func main() {
} }
} }
}() }()
}
for { for {
// Read RTP packets being sent to Pion // Read RTP packets being sent to Pion
packet, _, readErr := track.ReadRTP() packet, _, readErr := track.ReadRTP()

View File

@@ -119,10 +119,12 @@ func main() { // nolint:gocognit
// If just switched to this track, send PLI to get picture refresh // If just switched to this track, send PLI to get picture refresh
if !isCurrTrack { if !isCurrTrack {
isCurrTrack = true isCurrTrack = true
if track.Kind() == webrtc.RTPCodecTypeVideo {
if writeErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}}); writeErr != nil { if writeErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}}); writeErr != nil {
fmt.Println(writeErr) fmt.Println(writeErr)
} }
} }
}
packets <- rtp packets <- rtp
} else { } else {
isCurrTrack = false isCurrTrack = false