mirror of
https://github.com/pion/webrtc.git
synced 2025-09-27 03:25:58 +08:00
Read/Write RTP/RTCP packets with context
Control cancel/timeout by context.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
@@ -23,7 +24,7 @@ func saveToDisk(i media.Writer, track *webrtc.TrackRemote) {
|
||||
}()
|
||||
|
||||
for {
|
||||
rtpPacket, err := track.ReadRTP()
|
||||
rtpPacket, err := track.ReadRTP(context.TODO())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -96,7 +97,9 @@ func main() {
|
||||
go func() {
|
||||
ticker := time.NewTicker(time.Second * 3)
|
||||
for range ticker.C {
|
||||
errSend := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}})
|
||||
errSend := peerConnection.WriteRTCP(
|
||||
context.TODO(), []rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}},
|
||||
)
|
||||
if errSend != nil {
|
||||
fmt.Println(errSend)
|
||||
}
|
||||
|
Reference in New Issue
Block a user