Commit 49195ef9 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Improve error handling in sendPLI.

parent 519cb2db
...@@ -886,14 +886,17 @@ func updateUpBitrate(up *upConnection, maxVideoRate uint64) { ...@@ -886,14 +886,17 @@ func updateUpBitrate(up *upConnection, maxVideoRate uint64) {
} }
} }
var ErrUnsupportedFeedback = errors.New("unsupported feedback type")
var ErrRateLimited = errors.New("rate limited")
func (up *upConnection) sendPLI(track *upTrack) error { func (up *upConnection) sendPLI(track *upTrack) error {
if !track.hasRtcpFb("nack", "pli") { if !track.hasRtcpFb("nack", "pli") {
return nil return ErrUnsupportedFeedback
} }
last := atomic.LoadUint64(&track.lastPLI) last := atomic.LoadUint64(&track.lastPLI)
now := mono.Microseconds() now := mono.Microseconds()
if now >= last && now-last < 200000 { if now >= last && now-last < 200000 {
return nil return ErrRateLimited
} }
atomic.StoreUint64(&track.lastPLI, now) atomic.StoreUint64(&track.lastPLI, now)
return sendPLI(up.pc, track.track.SSRC()) return sendPLI(up.pc, track.track.SSRC())
......
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