File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -389,11 +389,13 @@ func (p *MediaPort) rtpLoop(sess rtp.Session) {
389389}
390390
391391func (p * MediaPort ) rtpReadLoop (log logger.Logger , r rtp.ReadStream ) {
392+ const maxErrors = 50 // 1 sec, given 20 ms frames
392393 buf := make ([]byte , rtp .MTUSize + 1 )
393394 overflow := false
394395 var (
395396 h rtp.Header
396397 pipeline string
398+ errorCnt int
397399 )
398400 for {
399401 h = rtp.Header {}
@@ -426,14 +428,21 @@ func (p *MediaPort) rtpReadLoop(log logger.Logger, r rtp.ReadStream) {
426428 if pipeline == "" {
427429 pipeline = hnd .String ()
428430 }
429- log .Errorw ("handle RTP failed" , err ,
430- "payloadType" , h .PayloadType ,
431+ log := log .WithValues (
431432 "payloadSize" , n ,
432433 "rtpHeader" , h ,
433434 "pipeline" , pipeline ,
435+ "errorCount" , errorCnt ,
434436 )
437+ log .Debugw ("handle RTP failed" , "error" , err )
438+ errorCnt ++
439+ if errorCnt >= maxErrors {
440+ log .Errorw ("killing RTP loop due to persisted errors" , err )
441+ return
442+ }
435443 continue
436444 }
445+ errorCnt = 0
437446 pipeline = ""
438447 }
439448}
You can’t perform that action at this time.
0 commit comments