Skip to content

Commit d54f787

Browse files
tmatthSean-Der
authored andcommitted
Only send PLIs for video tracks in examples
1 parent ddb9219 commit d54f787

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

examples/simulcast/main.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,18 @@ func main() {
111111

112112
// Start reading from all the streams and sending them to the related output track
113113
rid := track.RID()
114-
go func() {
115-
ticker := time.NewTicker(3 * time.Second)
116-
defer ticker.Stop()
117-
for range ticker.C {
118-
fmt.Printf("Sending pli for stream with rid: %q, ssrc: %d\n", track.RID(), track.SSRC())
119-
if writeErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}}); writeErr != nil {
120-
fmt.Println(writeErr)
114+
if track.Kind() == webrtc.RTPCodecTypeVideo {
115+
go func() {
116+
ticker := time.NewTicker(3 * time.Second)
117+
defer ticker.Stop()
118+
for range ticker.C {
119+
fmt.Printf("Sending pli for stream with rid: %q, ssrc: %d\n", track.RID(), track.SSRC())
120+
if writeErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}}); writeErr != nil {
121+
fmt.Println(writeErr)
122+
}
121123
}
122-
}
123-
}()
124+
}()
125+
}
124126
for {
125127
// Read RTP packets being sent to Pion
126128
packet, _, readErr := track.ReadRTP()

examples/swap-tracks/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ func main() { // nolint:gocognit
119119
// If just switched to this track, send PLI to get picture refresh
120120
if !isCurrTrack {
121121
isCurrTrack = true
122-
if writeErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}}); writeErr != nil {
123-
fmt.Println(writeErr)
122+
if track.Kind() == webrtc.RTPCodecTypeVideo {
123+
if writeErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}}); writeErr != nil {
124+
fmt.Println(writeErr)
125+
}
124126
}
125127
}
126128
packets <- rtp

0 commit comments

Comments
 (0)