Protect against incorrect temporal layer. (#4327)

Seeing some tracks with temporal layer higher than array bounds.
Protect against it and log some info to understand better.
This commit is contained in:
Raja Subramanian
2026-02-19 23:57:58 +05:30
committed by Paul Wells
parent ee664e7adc
commit a82d88a7a7

View File

@@ -69,8 +69,8 @@ type StreamTracker struct {
lastNotifiedStatus StreamStatus
lastBitrateReport time.Time
bytesForBitrate [4]int64
bitrate [4]int64
bytesForBitrate [buffer.DefaultMaxLayerTemporal + 1]int64
bitrate [buffer.DefaultMaxLayerTemporal + 1]int64
isStopped bool
}
@@ -207,8 +207,17 @@ func (s *StreamTracker) Observe(
go s.worker(s.generation.Load())
}
if temporalLayer >= 0 {
if temporalLayer >= 0 && int(temporalLayer) < len(s.bytesForBitrate) {
s.bytesForBitrate[temporalLayer] += int64(pktSize)
} else if int(temporalLayer) >= len(s.bytesForBitrate) {
s.params.Logger.Warnw(
"invalid temporal layer", nil,
"temporalLayer", temporalLayer,
"pktSize", pktSize,
"payloadSize", payloadSize,
"hasMarker", hasMarker,
"ts", ts,
)
}
s.lock.Unlock()