Read/Write RTP/RTCP packets with context

Control cancel/timeout by context.
This commit is contained in:
Atsushi Watanabe
2020-11-30 17:24:54 +09:00
parent 16b313b492
commit 47a7a64898
39 changed files with 329 additions and 205 deletions

View File

@@ -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)
}