mediamtx/internal/stream/stream_media.go
Alessandro Ros 986e270862
Some checks are pending
code_lint / golangci_lint (push) Waiting to run
code_lint / mod_tidy (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_highlevel (push) Waiting to run
count and log all discarded frames, decode errors, lost packets (#4363)
Discarded frames, decode errors and lost packets were logged
individually, then there was a mechanism that prevented more than 1 log
entry per second from being printed, resulting in inaccurate reports.

Now discarded frames, decode errors and lost packets are accurately
counted, and their count is printed once every second.
2025-03-25 21:59:58 +01:00

36 lines
827 B
Go

package stream
import (
"github.com/bluenviron/gortsplib/v4/pkg/description"
"github.com/bluenviron/gortsplib/v4/pkg/format"
"github.com/bluenviron/mediamtx/internal/counterdumper"
)
type streamMedia struct {
UDPMaxPayloadSize int
Media *description.Media
GenerateRTPPackets bool
DecodeErrors *counterdumper.CounterDumper
formats map[format.Format]*streamFormat
}
func (sm *streamMedia) initialize() error {
sm.formats = make(map[format.Format]*streamFormat)
for _, forma := range sm.Media.Formats {
sf := &streamFormat{
UDPMaxPayloadSize: sm.UDPMaxPayloadSize,
Format: forma,
GenerateRTPPackets: sm.GenerateRTPPackets,
DecodeErrors: sm.DecodeErrors,
}
err := sf.initialize()
if err != nil {
return err
}
sm.formats[forma] = sf
}
return nil
}