Skip to content

Commit 3063e33

Browse files
committed
Update last packet time only on change
With large samples like key frame, they could be hundreds of packets. Updating the last packet time on each of those packets means the sender report could be off by the amount of time it takes to send the full sample which could be a few ms.
1 parent 51d58cb commit 3063e33

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/report/sender_stream.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ func (stream *senderStream) processRTP(now time.Time, header *rtp.Header, payloa
4343
if stream.useLatestPacket || stream.packetCount == 0 || (diff > 0 && diff < (1<<15)) {
4444
// Told to consider every packet, or this was the first packet, or it's in-order
4545
stream.lastRTPSN = header.SequenceNumber
46-
stream.lastRTPTimeRTP = header.Timestamp
47-
stream.lastRTPTimeTime = now
46+
// update only on first packet of a frame to ensure sender report does not get affected by
47+
// processing delay of pushing a large frame which could span multiple packets
48+
if header.Timestamp != stream.lastRTPTimeRTP {
49+
stream.lastRTPTimeRTP = header.Timestamp
50+
stream.lastRTPTimeTime = now
51+
}
4852
}
4953

5054
stream.packetCount++

0 commit comments

Comments
 (0)