Use monotonic clock in packet path. (#2940)
Set up a base time when starting a receiver and use that clock as base for other packet times to ensure that clock is monotonic.
This commit is contained in:
@@ -948,7 +948,7 @@ func (d *DownTrack) WritePaddingRTP(bytesToSend int, paddingOnMute bool, forceMa
|
||||
&hdr,
|
||||
len(payload),
|
||||
&sendPacketMetadata{
|
||||
packetTime: time.Now().UnixNano(),
|
||||
packetTime: d.params.Receiver.GetMonotonicNowUnixNano(),
|
||||
extSequenceNumber: snts[i].extSequenceNumber,
|
||||
extTimestamp: snts[i].extTimestamp,
|
||||
isPadding: true,
|
||||
@@ -1491,7 +1491,7 @@ func (d *DownTrack) writeBlankFrameRTP(duration float32, generation uint32) chan
|
||||
}
|
||||
|
||||
d.sendingPacket(&hdr, len(payload), &sendPacketMetadata{
|
||||
packetTime: time.Now().UnixNano(),
|
||||
packetTime: d.params.Receiver.GetMonotonicNowUnixNano(),
|
||||
extSequenceNumber: snts[i].extSequenceNumber,
|
||||
extTimestamp: snts[i].extTimestamp,
|
||||
})
|
||||
@@ -1854,7 +1854,7 @@ func (d *DownTrack) retransmitPackets(nacks []uint16) {
|
||||
len(payload),
|
||||
&sendPacketMetadata{
|
||||
layer: int32(epm.layer),
|
||||
packetTime: time.Now().UnixNano(),
|
||||
packetTime: d.params.Receiver.GetMonotonicNowUnixNano(),
|
||||
extSequenceNumber: epm.extSequenceNumber,
|
||||
extTimestamp: epm.extTimestamp,
|
||||
isRTX: true,
|
||||
@@ -2076,7 +2076,7 @@ func (d *DownTrack) sendSilentFrameOnMuteForOpus() {
|
||||
&hdr,
|
||||
len(payload),
|
||||
&sendPacketMetadata{
|
||||
packetTime: time.Now().UnixNano(),
|
||||
packetTime: d.params.Receiver.GetMonotonicNowUnixNano(),
|
||||
extSequenceNumber: snts[i].extSequenceNumber,
|
||||
extTimestamp: snts[i].extTimestamp,
|
||||
// although this is using empty frames, mark as padding as these are used to trigger Pion OnTrack only
|
||||
|
||||
Reference in New Issue
Block a user