mediamtx/internal/stream/stream_media.go
Alessandro Ros 0cdae40fe3
estimate absolute timestamp more precisely (#5078)
When the absolute timestamp of incoming frames was not available, it
was filled with the current timestamp, which is influenced by latency
over time.

This mechanism is replaced by an algorithm that detects when latency is
the lowest, stores the current timestamp and uses it as reference
throughout the rest of the stream.
2025-10-12 11:02:14 +02:00

41 lines
1,009 B
Go

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/logger"
)
type streamMedia struct {
rtpMaxPayloadSize int
media *description.Media
generateRTPPackets bool
fillNTP bool
processingErrors *counterdumper.CounterDumper
parent logger.Writer
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{
rtpMaxPayloadSize: sm.rtpMaxPayloadSize,
format: forma,
generateRTPPackets: sm.generateRTPPackets,
fillNTP: sm.fillNTP,
processingErrors: sm.processingErrors,
parent: sm.parent,
}
err := sf.initialize()
if err != nil {
return err
}
sm.formats[forma] = sf
}
return nil
}