mirror of
https://github.com/pion/webrtc.git
synced 2025-10-09 09:00:35 +08:00
Only send PLIs for video tracks in examples
This commit is contained in:

committed by
Sean DuBois

parent
ddb9219c84
commit
d54f7870eb
@@ -111,16 +111,18 @@ 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()
|
||||||
go func() {
|
if track.Kind() == webrtc.RTPCodecTypeVideo {
|
||||||
ticker := time.NewTicker(3 * time.Second)
|
go func() {
|
||||||
defer ticker.Stop()
|
ticker := time.NewTicker(3 * time.Second)
|
||||||
for range ticker.C {
|
defer ticker.Stop()
|
||||||
fmt.Printf("Sending pli for stream with rid: %q, ssrc: %d\n", track.RID(), track.SSRC())
|
for range ticker.C {
|
||||||
if writeErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}}); writeErr != nil {
|
fmt.Printf("Sending pli for stream with rid: %q, ssrc: %d\n", track.RID(), track.SSRC())
|
||||||
fmt.Println(writeErr)
|
if writeErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}}); writeErr != nil {
|
||||||
|
fmt.Println(writeErr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}()
|
||||||
}()
|
}
|
||||||
for {
|
for {
|
||||||
// Read RTP packets being sent to Pion
|
// Read RTP packets being sent to Pion
|
||||||
packet, _, readErr := track.ReadRTP()
|
packet, _, readErr := track.ReadRTP()
|
||||||
|
@@ -119,8 +119,10 @@ 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 writeErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}}); writeErr != nil {
|
if track.Kind() == webrtc.RTPCodecTypeVideo {
|
||||||
fmt.Println(writeErr)
|
if writeErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}}); writeErr != nil {
|
||||||
|
fmt.Println(writeErr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
packets <- rtp
|
packets <- rtp
|
||||||
|
Reference in New Issue
Block a user