Use start time stamp to calculate down stream sender report. (#2564)

* Use start time stamp to calculate down stream sender report.

With first packet time adjustment, using the first time stamp is more
accurate.

This still suffers if the up stream clock rate changes (happens in cases
like noise suppression which is not well understood). Will be looking at
pass through of sender report from publisher to subscriber.

* similar log strings

* avoid early sender reports

* log messages

* Reduce first packet adjustment threshold to 15 seconds
This commit is contained in:
Raja Subramanian
2024-03-10 23:18:54 +05:30
committed by GitHub
parent a08b058abc
commit bdbc9dcbc7
3 changed files with 47 additions and 66 deletions
+12 -12
View File
@@ -34,7 +34,7 @@ const (
cFirstSnapshotID = 1
cFirstPacketTimeAdjustWindow = 2 * time.Minute
cFirstPacketTimeAdjustThreshold = 5 * time.Minute
cFirstPacketTimeAdjustThreshold = 15 * time.Second
)
// -------------------------------------------------------
@@ -506,18 +506,8 @@ func (r *rtpStatsBase) maybeAdjustFirstPacketTime(ts uint32, startTS uint32) {
now := r.firstTime.Add(timeSinceFirst)
firstTime := now.Add(-samplesDuration)
if firstTime.Before(r.firstTime) {
r.logger.Debugw(
"adjusting first packet time",
"startTime", r.startTime.String(),
"nowTime", now.String(),
"before", r.firstTime.String(),
"after", firstTime.String(),
"adjustment", r.firstTime.Sub(firstTime).String(),
"nowTS", ts,
"startTS", startTS,
)
if r.firstTime.Sub(firstTime) > cFirstPacketTimeAdjustThreshold {
r.logger.Infow("first packet time adjustment too big, ignoring",
r.logger.Infow("adjusting first packet time, too big, ignoring",
"startTime", r.startTime.String(),
"nowTime", now.String(),
"before", r.firstTime.String(),
@@ -527,6 +517,16 @@ func (r *rtpStatsBase) maybeAdjustFirstPacketTime(ts uint32, startTS uint32) {
"startTS", startTS,
)
} else {
r.logger.Debugw(
"adjusting first packet time",
"startTime", r.startTime.String(),
"nowTime", now.String(),
"before", r.firstTime.String(),
"after", firstTime.String(),
"adjustment", r.firstTime.Sub(firstTime).String(),
"nowTS", ts,
"startTS", startTS,
)
r.firstTime = firstTime
}
}