Reducing rtp stats memory consumption - part 2 (#2078)

* WIP commit

* move a struct to sender only

* Snapshot intervals

* make receiver history 4K too
This commit is contained in:
Raja Subramanian
2023-09-16 18:54:18 +05:30
committed by GitHub
parent 340906267f
commit 97048a923c
3 changed files with 352 additions and 249 deletions
+5 -4
View File
@@ -26,7 +26,7 @@ import (
)
const (
cHistorySize = 2048
cHistorySize = 4096
)
type RTPFlowState struct {
@@ -69,7 +69,7 @@ func (r *RTPStatsReceiver) NewSnapshotId() uint32 {
r.lock.Lock()
defer r.lock.Unlock()
return r.newSnapshotID(r.sequenceNumber.GetExtendedStart())
return r.newSnapshotID(r.sequenceNumber.GetExtendedHighest())
}
func (r *RTPStatsReceiver) Update(
@@ -114,7 +114,7 @@ func (r *RTPStatsReceiver) Update(
resTS = r.timestamp.Update(timestamp)
// initialize snapshots if any
for i := uint32(cFirstSnapshotID); i < r.nextSnapshotID; i++ {
for i := uint32(0); i < r.nextSnapshotID-cFirstSnapshotID; i++ {
r.snapshots[i] = r.initSnapshot(r.startTime, r.sequenceNumber.GetExtendedStart())
}
@@ -154,7 +154,8 @@ func (r *RTPStatsReceiver) Update(
r.packetsLost += resSN.PreExtendedStart - resSN.ExtendedVal
extStartSN := r.sequenceNumber.GetExtendedStart()
for _, s := range r.snapshots {
for i := uint32(0); i < r.nextSnapshotID-cFirstSnapshotID; i++ {
s := &r.snapshots[i]
if s.extStartSN == resSN.PreExtendedStart {
s.extStartSN = extStartSN
}