package engine import ( "github.com/Monibuca/utils/v3/go2" ) type TrackPack interface { type VideoPack,AudioPack } type Track[T TrackPack] struct { Buffer *go2.Ring[T] PacketCount int CodecID byte BPS int lastIndex byte } func (t *Track[T]) GetBPS(payloadLen int){ t.PacketCount++ if lastTimestamp := t.Buffer.GetAt(t.lastIndex).Timestamp;lastTimestamp > 0 && lastTimestamp != t.Buffer.Current.Timestamp { t.BPS = payloadLen * 1000 / int(t.Buffer.Current.Timestamp-lastTimestamp) } t.lastIndex = t.Buffer.Index }