mirror of
https://github.com/pion/webrtc.git
synced 2025-11-03 09:40:59 +08:00
Read/Write RTP/RTCP packets with context
Control cancel/timeout by context.
This commit is contained in:
@@ -107,7 +107,9 @@ func main() {
|
||||
go func() {
|
||||
ticker := time.NewTicker(time.Second * 2)
|
||||
for range ticker.C {
|
||||
if rtcpErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}}); rtcpErr != nil {
|
||||
if rtcpErr := peerConnection.WriteRTCP(
|
||||
context.TODO(), []rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}},
|
||||
); rtcpErr != nil {
|
||||
fmt.Println(rtcpErr)
|
||||
}
|
||||
}
|
||||
@@ -116,7 +118,7 @@ func main() {
|
||||
b := make([]byte, 1500)
|
||||
for {
|
||||
// Read
|
||||
n, readErr := track.Read(b)
|
||||
n, readErr := track.Read(context.TODO(), b)
|
||||
if readErr != nil {
|
||||
panic(readErr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user