print last processing error (#5323)

This commit is contained in:
Alessandro Ros
2026-01-06 21:48:36 +01:00
committed by GitHub
parent cd34de8770
commit eba3b828a6
4 changed files with 17 additions and 19 deletions
+2 -1
View File
@@ -57,7 +57,8 @@ func (c *Dumper) run() {
case <-t.C:
c.mutex.Lock()
counter := c.counter
var counter uint64
counter, c.counter = c.counter, 0
last := c.last
c.mutex.Unlock()
+9 -12
View File
@@ -11,7 +11,7 @@ import (
"github.com/bluenviron/gortsplib/v5/pkg/format"
"github.com/pion/rtp"
"github.com/bluenviron/mediamtx/internal/counterdumper"
"github.com/bluenviron/mediamtx/internal/errordumper"
"github.com/bluenviron/mediamtx/internal/logger"
"github.com/bluenviron/mediamtx/internal/unit"
)
@@ -33,7 +33,7 @@ type Stream struct {
rtspStream *gortsplib.ServerStream
rtspsStream *gortsplib.ServerStream
readers map[*Reader]struct{}
processingErrors *counterdumper.Dumper
processingErrors *errordumper.Dumper
}
// Initialize initializes a Stream.
@@ -43,16 +43,13 @@ func (s *Stream) Initialize() error {
s.medias = make(map[*description.Media]*streamMedia)
s.readers = make(map[*Reader]struct{})
s.processingErrors = &counterdumper.Dumper{
OnReport: func(val uint64) {
s.Parent.Log(logger.Warn, "%d processing %s",
val,
func() string {
if val == 1 {
return "error"
}
return "errors"
}())
s.processingErrors = &errordumper.Dumper{
OnReport: func(val uint64, last error) {
if val == 1 {
s.Parent.Log(logger.Warn, "processing error: %v", last)
} else {
s.Parent.Log(logger.Warn, "%d processing errors, last was: %v", val, last)
}
},
}
s.processingErrors.Start()
+4 -4
View File
@@ -9,7 +9,7 @@ import (
"github.com/pion/rtp"
"github.com/bluenviron/mediamtx/internal/codecprocessor"
"github.com/bluenviron/mediamtx/internal/counterdumper"
"github.com/bluenviron/mediamtx/internal/errordumper"
"github.com/bluenviron/mediamtx/internal/logger"
"github.com/bluenviron/mediamtx/internal/ntpestimator"
"github.com/bluenviron/mediamtx/internal/unit"
@@ -28,7 +28,7 @@ type streamFormat struct {
format format.Format
generateRTPPackets bool
fillNTP bool
processingErrors *counterdumper.Dumper
processingErrors *errordumper.Dumper
parent logger.Writer
proc codecprocessor.Processor
@@ -55,7 +55,7 @@ func (sf *streamFormat) initialize() error {
func (sf *streamFormat) writeUnit(s *Stream, medi *description.Media, u *unit.Unit) {
err := sf.proc.ProcessUnit(u)
if err != nil {
sf.processingErrors.Increase()
sf.processingErrors.Add(err)
return
}
@@ -79,7 +79,7 @@ func (sf *streamFormat) writeRTPPacket(
err := sf.proc.ProcessRTPPacket(u, hasNonRTSPReaders)
if err != nil {
sf.processingErrors.Increase()
sf.processingErrors.Add(err)
return
}
+2 -2
View File
@@ -3,7 +3,7 @@ package stream
import (
"github.com/bluenviron/gortsplib/v5/pkg/description"
"github.com/bluenviron/gortsplib/v5/pkg/format"
"github.com/bluenviron/mediamtx/internal/counterdumper"
"github.com/bluenviron/mediamtx/internal/errordumper"
"github.com/bluenviron/mediamtx/internal/logger"
)
@@ -12,7 +12,7 @@ type streamMedia struct {
media *description.Media
generateRTPPackets bool
fillNTP bool
processingErrors *counterdumper.Dumper
processingErrors *errordumper.Dumper
parent logger.Writer
formats map[format.Format]*streamFormat