Skip to content

Commit

Permalink
do not stop rtcp reading loop on read error
Browse files Browse the repository at this point in the history
  • Loading branch information
EmrysMyrddin committed Aug 7, 2022
1 parent 655151a commit 10d2c03
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions track.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -240,20 +242,25 @@ 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 {
switch pkt.(type) {
case *rtcp.PictureLossIndication, *rtcp.FullIntraRequest:
if err := keyFrameController.ForceKeyFrame(); err != nil {
logger.Warnf("failed to force key frame: %s", err)
continue readLoop
}
}
}
Expand Down

0 comments on commit 10d2c03

Please sign in to comment.