From f543e3f8d0ac842c7b2363de2d85c410248cf96b Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Tue, 9 May 2023 18:46:30 +0530 Subject: [PATCH] Send left over RTCP packets. (#1699) --- pkg/rtc/participant.go | 16 +++++++++++++++- pkg/sfu/buffer/rtpstats.go | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index ebe987428..9e37fe99c 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -1347,7 +1347,9 @@ func (p *ParticipantImpl) subscriberRTCPWorker() { sd = append(sd, chunks...) batchSize = batchSize + 1 + len(chunks) if batchSize >= sdBatchSize { - pkts = append(pkts, &rtcp.SourceDescription{Chunks: sd}) + if len(sd) != 0 { + pkts = append(pkts, &rtcp.SourceDescription{Chunks: sd}) + } if err := p.TransportManager.WriteSubscriberRTCP(pkts); err != nil { if err == io.EOF || err == io.ErrClosedPipe { return @@ -1361,6 +1363,18 @@ func (p *ParticipantImpl) subscriberRTCPWorker() { } } + if len(pkts) != 0 || len(sd) != 0 { + if len(sd) != 0 { + pkts = append(pkts, &rtcp.SourceDescription{Chunks: sd}) + } + if err := p.TransportManager.WriteSubscriberRTCP(pkts); err != nil { + if err == io.EOF || err == io.ErrClosedPipe { + return + } + p.params.Logger.Errorw("could not send down track reports", err) + } + } + time.Sleep(3 * time.Second) } } diff --git a/pkg/sfu/buffer/rtpstats.go b/pkg/sfu/buffer/rtpstats.go index 33de3c19d..7e2871f7b 100644 --- a/pkg/sfu/buffer/rtpstats.go +++ b/pkg/sfu/buffer/rtpstats.go @@ -1107,7 +1107,7 @@ func (r *RTPStats) ToString() string { str := fmt.Sprintf("t: %+v|%+v|%.2fs", p.StartTime.AsTime().Format(time.UnixDate), p.EndTime.AsTime().Format(time.UnixDate), p.Duration) - str += fmt.Sprintf(" sn: %d|%d", r.extStartSN, r.getExtHighestSN()) + str += fmt.Sprintf(", sn: %d|%d", r.extStartSN, r.getExtHighestSN()) str += fmt.Sprintf(", ep: %d|%.2f/s", expectedPackets, expectedPacketRate) str += fmt.Sprintf(", p: %d|%.2f/s", p.Packets, p.PacketRate)