From 10d2c032225b3f9764965d9d3d4b625e71278397 Mon Sep 17 00:00:00 2001 From: Valentin Cocaud Date: Sun, 7 Aug 2022 09:47:25 +0200 Subject: [PATCH] do not stop rtcp reading loop on read error --- track.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/track.go b/track.go index da592625..47c77767 100644 --- a/track.go +++ b/track.go @@ -231,6 +231,8 @@ func (track *baseTrack) bind(ctx webrtc.TrackLocalContext, specializedTrack Trac func (track *baseTrack) rtcpReadLoop(reader interceptor.RTCPReader, keyFrameController codec.KeyFrameController, stopRead chan struct{}) { readerBuffer := make([]byte, rtcpInboundMTU) + +readLoop: for { select { case <-stopRead: @@ -240,13 +242,17 @@ func (track *baseTrack) rtcpReadLoop(reader interceptor.RTCPReader, keyFrameCont readLength, _, err := reader.Read(readerBuffer, interceptor.Attributes{}) if err != nil { - track.onError(err) - return + if errors.Is(err, io.EOF) { + return + } + logger.Warnf("failed to unmarshal rtcp packet: %s", err) + continue } pkts, err := rtcp.Unmarshal(readerBuffer[:readLength]) if err != nil { logger.Warnf("failed to unmarshal rtcp packet: %s", err) + continue } for _, pkt := range pkts { @@ -254,6 +260,7 @@ func (track *baseTrack) rtcpReadLoop(reader interceptor.RTCPReader, keyFrameCont case *rtcp.PictureLossIndication, *rtcp.FullIntraRequest: if err := keyFrameController.ForceKeyFrame(); err != nil { logger.Warnf("failed to force key frame: %s", err) + continue readLoop } } }