From 2efb5b3cea559be99d5f3f80b9a8a486212132f9 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sat, 31 Oct 2020 21:31:05 +0100 Subject: [PATCH] Improve timing of nackWriter. --- rtpconn/rtpwriter.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rtpconn/rtpwriter.go b/rtpconn/rtpwriter.go index 5ba2ded..86c753e 100644 --- a/rtpconn/rtpwriter.go +++ b/rtpconn/rtpwriter.go @@ -384,17 +384,19 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) { func nackWriter(conn *rtpUpConnection, track *rtpUpTrack) { // a client might send us a NACK for a packet that has already // been nacked by the reader loop. Give recovery a chance. - time.Sleep(100 * time.Millisecond) + time.Sleep(50 * time.Millisecond) track.mu.Lock() nacks := track.bufferedNACKs track.bufferedNACKs = nil track.mu.Unlock() - if !track.hasRtcpFb("nack", "") { + if len(nacks) == 0 || !track.hasRtcpFb("nack", "") { return } + time.Sleep(50 * time.Millisecond) + // drop any nacks before the last keyframe var cutoff uint16 found, seqno, _ := track.cache.KeyframeSeqno()