mirror of
https://github.com/jech/galene.git
synced 2024-12-27 01:35:48 +01:00
Rate-limit PLI.
This commit is contained in:
parent
bfeeeb4bcd
commit
e5dae16da1
2 changed files with 12 additions and 1 deletions
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 {
|
||||
switch p := p.(type) {
|
||||
case *rtcp.PictureLossIndication:
|
||||
err := sendPLI(conn.remote.pc, p.MediaSSRC)
|
||||
err := conn.remote.sendPLI(track.remote)
|
||||
if err != nil {
|
||||
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 {
|
||||
return pc.WriteRTCP([]rtcp.Packet{
|
||||
&rtcp.PictureLossIndication{MediaSSRC: ssrc},
|
||||
|
|
1
group.go
1
group.go
|
@ -24,6 +24,7 @@ type upTrack struct {
|
|||
track *webrtc.Track
|
||||
list *packetlist.List
|
||||
maxBitrate uint64
|
||||
lastPLI uint64
|
||||
|
||||
mu sync.Mutex
|
||||
local []*downTrack
|
||||
|
|
Loading…
Reference in a new issue