Set SSRC for RTCP (#760)

- SenderSSRC was not set for NACK, RTCP_RR - so SRTP context
was using SSRC = 0 which is not bad, but let us set the SSRC properly.
- PLI was using a random SSRC on every PLI. So, that would have
created a new SRTP stream (not bad as that stream context is small)
on every PLI. It is wasteful. So, set the SenderSSRC to the mediaSSRC.
- Reduce re-start of higher layers to 10 seconds. That is long enough
to declare that a stream layer has restarted.
This commit is contained in:
Raja Subramanian
2022-06-16 12:07:21 +05:30
committed by GitHub
parent 558be854be
commit 83b71fce50
2 changed files with 7 additions and 6 deletions
+5 -4
View File
@@ -3,7 +3,6 @@ package buffer
import ( import (
"encoding/binary" "encoding/binary"
"io" "io"
"math/rand"
"strings" "strings"
"sync" "sync"
"time" "time"
@@ -324,7 +323,7 @@ func (b *Buffer) SendPLI(force bool) {
b.logger.Debugw("send pli", "ssrc", b.mediaSSRC, "force", force) b.logger.Debugw("send pli", "ssrc", b.mediaSSRC, "force", force)
pli := []rtcp.Packet{ pli := []rtcp.Packet{
&rtcp.PictureLossIndication{SenderSSRC: rand.Uint32(), MediaSSRC: b.mediaSSRC}, &rtcp.PictureLossIndication{SenderSSRC: b.mediaSSRC, MediaSSRC: b.mediaSSRC},
} }
if b.onRtcpFeedback != nil { if b.onRtcpFeedback != nil {
@@ -529,8 +528,9 @@ func (b *Buffer) buildNACKPacket() ([]rtcp.Packet, int) {
var pkts []rtcp.Packet var pkts []rtcp.Packet
if len(nacks) > 0 { if len(nacks) > 0 {
pkts = []rtcp.Packet{&rtcp.TransportLayerNack{ pkts = []rtcp.Packet{&rtcp.TransportLayerNack{
MediaSSRC: b.mediaSSRC, SenderSSRC: b.mediaSSRC,
Nacks: nacks, MediaSSRC: b.mediaSSRC,
Nacks: nacks,
}} }}
} }
@@ -571,6 +571,7 @@ func (b *Buffer) getRTCP() []rtcp.Packet {
rr := b.buildReceptionReport() rr := b.buildReceptionReport()
if rr != nil { if rr != nil {
pkts = append(pkts, &rtcp.ReceiverReport{ pkts = append(pkts, &rtcp.ReceiverReport{
SSRC: b.mediaSSRC,
Reports: []rtcp.ReceptionReport{*rr}, Reports: []rtcp.ReceptionReport{*rr},
}) })
} }
+2 -2
View File
@@ -25,13 +25,13 @@ var (
}, },
{ {
SamplesRequired: 5, SamplesRequired: 5,
CyclesRequired: 60, CyclesRequired: 20,
CycleDuration: 500 * time.Millisecond, CycleDuration: 500 * time.Millisecond,
BitrateReportInterval: 1 * time.Second, BitrateReportInterval: 1 * time.Second,
}, },
{ {
SamplesRequired: 5, SamplesRequired: 5,
CyclesRequired: 60, CyclesRequired: 20,
CycleDuration: 500 * time.Millisecond, CycleDuration: 500 * time.Millisecond,
BitrateReportInterval: 1 * time.Second, BitrateReportInterval: 1 * time.Second,
}, },