Commit 88fbce26 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement sendFIR.

parent 49195ef9
...@@ -908,6 +908,41 @@ func sendPLI(pc *webrtc.PeerConnection, ssrc uint32) error { ...@@ -908,6 +908,41 @@ func sendPLI(pc *webrtc.PeerConnection, ssrc uint32) error {
}) })
} }
func (up *upConnection) sendFIR(track *upTrack, increment bool) error {
// we need to reliably increment the seqno, even if we are going
// to drop the packet due to rate limiting.
var seqno uint8
if increment {
seqno = uint8(atomic.AddUint32(&track.firSeqno, 1) & 0xFF)
} else {
seqno = uint8(atomic.LoadUint32(&track.firSeqno) & 0xFF)
}
if !track.hasRtcpFb("ccm", "fir") {
return ErrUnsupportedFeedback
}
last := atomic.LoadUint64(&track.lastFIR)
now := mono.Microseconds()
if now >= last && now-last < 200000 {
return ErrRateLimited
}
atomic.StoreUint64(&track.lastFIR, now)
return sendFIR(up.pc, track.track.SSRC(), seqno)
}
func sendFIR(pc *webrtc.PeerConnection, ssrc uint32, seqno uint8) error {
return pc.WriteRTCP([]rtcp.Packet{
&rtcp.FullIntraRequest{
FIR: []rtcp.FIREntry{
rtcp.FIREntry{
SSRC: ssrc,
SequenceNumber: seqno,
},
},
},
})
}
func sendREMB(pc *webrtc.PeerConnection, ssrc uint32, bitrate uint64) error { func sendREMB(pc *webrtc.PeerConnection, ssrc uint32, bitrate uint64) error {
return pc.WriteRTCP([]rtcp.Packet{ return pc.WriteRTCP([]rtcp.Packet{
&rtcp.ReceiverEstimatedMaximumBitrate{ &rtcp.ReceiverEstimatedMaximumBitrate{
......
...@@ -31,6 +31,8 @@ type upTrack struct { ...@@ -31,6 +31,8 @@ type upTrack struct {
jitter *jitter.Estimator jitter *jitter.Estimator
maxBitrate uint64 maxBitrate uint64
lastPLI uint64 lastPLI uint64
lastFIR uint64
firSeqno uint32
lastSenderReport uint32 lastSenderReport uint32
lastSenderReportTime uint32 lastSenderReportTime uint32
......
...@@ -112,6 +112,7 @@ func addGroup(name string, desc *groupDescription) (*group, error) { ...@@ -112,6 +112,7 @@ func addGroup(name string, desc *groupDescription) (*group, error) {
{"goog-remb", ""}, {"goog-remb", ""},
{"nack", ""}, {"nack", ""},
{"nack", "pli"}, {"nack", "pli"},
{"ccm", "fir"},
}, },
"", "",
)) ))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment