Skip to content

Commit

Permalink
fix: make targetTime passed to listener, not current
Browse files Browse the repository at this point in the history
  • Loading branch information
kjs001127 authored and kjs001127 committed Apr 28, 2023
1 parent 41cfeb9 commit c161a98
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/jitter/jitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (b *Jitter) Put(p *Packet) {
b.Lock()
defer b.Unlock()

b.listener.OnPacketEnqueue(b.current, b.sumRemainingTs(), p)
b.listener.OnPacketEnqueue(b.targetTime(), b.sumRemainingTs(), p)

if !b.marked || math.Abs(float64(p.Timestamp-b.targetTime())) > 100_000 {
b.init(p.Timestamp)
Expand Down Expand Up @@ -125,15 +125,15 @@ func (b *Jitter) Get() ([]*Packet, bool) {
if len(ret) == 0 {
b.loss.Set(targetTime, nil)
b.current += b.defaultTickInterval
b.listener.OnPacketLoss(b.current, b.sumRemainingTs())
b.listener.OnPacketLoss(b.targetTime(), b.sumRemainingTs())
return nil, false
}

lastPkt := ret[len(ret)-1]
newTargetTime := lastPkt.Timestamp + lastPkt.SampleCnt
incr := newTargetTime - targetTime
b.current += incr
b.listener.OnPacketDequeue(b.current, b.sumRemainingTs(), ret)
b.listener.OnPacketDequeue(b.targetTime(), b.sumRemainingTs(), ret)

return ret, true
}
Expand Down

0 comments on commit c161a98

Please sign in to comment.