Sequencer small optimisations (#2049)

* Sequencer small optimisations

1. Use range map to exclude padding only packets. Should take lesser
   space as we are not using slice to hold pointer to actual data.
2. Avoid `time.Now()` when adding each packet. Just use the arrival time
   as it should be close enough. `time.Now()` was showing up in
   profile.

* remove debug

* correct comment
This commit is contained in:
Raja Subramanian
2023-09-08 23:48:54 +05:30
committed by GitHub
parent 83353d821c
commit 492eb3bf18
7 changed files with 391 additions and 244 deletions
+7 -7
View File
@@ -1133,17 +1133,17 @@ func (r *RTPStats) SnapshotRtcpReceptionReport(ssrc uint32, proxyFracLost uint8,
fracLost = proxyFracLost
}
var dlsr uint32
if r.srNewest != nil && !r.srNewest.At.IsZero() {
delayMS := uint32(time.Since(r.srNewest.At).Milliseconds())
dlsr = (delayMS / 1e3) << 16
dlsr |= (delayMS % 1e3) * 65536 / 1000
}
lastSR := uint32(0)
dlsr := uint32(0)
if r.srNewest != nil {
lastSR = uint32(r.srNewest.NTPTimestamp >> 16)
if !r.srNewest.At.IsZero() {
delayMS := uint32(time.Since(r.srNewest.At).Milliseconds())
dlsr = (delayMS / 1e3) << 16
dlsr |= (delayMS % 1e3) * 65536 / 1000
}
}
return &rtcp.ReceptionReport{
SSRC: ssrc,
FractionLost: fracLost,