mirror of https://github.com/jech/galene.git
Rate-limit PLI.
This commit is contained in:
parent
bfeeeb4bcd
commit
e5dae16da1
12
client.go
12
client.go
|
@ -511,7 +511,7 @@ func rtcpListener(g *group, conn *downConnection, track *downTrack, s *webrtc.RT
|
||||||
for _, p := range ps {
|
for _, p := range ps {
|
||||||
switch p := p.(type) {
|
switch p := p.(type) {
|
||||||
case *rtcp.PictureLossIndication:
|
case *rtcp.PictureLossIndication:
|
||||||
err := sendPLI(conn.remote.pc, p.MediaSSRC)
|
err := conn.remote.sendPLI(track.remote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("sendPLI: %v", err)
|
log.Printf("sendPLI: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -585,6 +585,16 @@ func updateUpBitrate(up *upConnection) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (up *upConnection) sendPLI(track *upTrack) error {
|
||||||
|
last := atomic.LoadUint64(&track.lastPLI)
|
||||||
|
now := msSinceEpoch()
|
||||||
|
if now >= last && now - last < 200 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
atomic.StoreUint64(&track.lastPLI, now)
|
||||||
|
return sendPLI(up.pc, track.track.SSRC())
|
||||||
|
}
|
||||||
|
|
||||||
func sendPLI(pc *webrtc.PeerConnection, ssrc uint32) error {
|
func sendPLI(pc *webrtc.PeerConnection, ssrc uint32) error {
|
||||||
return pc.WriteRTCP([]rtcp.Packet{
|
return pc.WriteRTCP([]rtcp.Packet{
|
||||||
&rtcp.PictureLossIndication{MediaSSRC: ssrc},
|
&rtcp.PictureLossIndication{MediaSSRC: ssrc},
|
||||||
|
|
Loading…
Reference in New Issue