From f277b42e2605fff39becfb893396868b5b4cf55e Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Tue, 9 Jun 2020 13:46:04 +0200 Subject: [PATCH] Check for connection state if not sending report packet. This avoids a situation when an RTCP sender never terminates. --- rtpconn.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rtpconn.go b/rtpconn.go index f32fb06..2802ae0 100644 --- a/rtpconn.go +++ b/rtpconn.go @@ -799,6 +799,10 @@ func sendRR(conn *rtpUpConnection) error { defer conn.mu.Unlock() if len(conn.tracks) == 0 { + state := conn.pc.ConnectionState() + if state == webrtc.PeerConnectionStateClosed { + return io.ErrClosedPipe + } return nil } @@ -899,6 +903,10 @@ func sendSR(conn *rtpDownConnection) error { } if len(packets) == 0 { + state := conn.pc.ConnectionState() + if state == webrtc.PeerConnectionStateClosed { + return io.ErrClosedPipe + } return nil }