mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Drop until end of frame when writer is congested.
This commit is contained in:
parent
e32f911ab9
commit
0e1f3cafea
1 changed files with 19 additions and 2 deletions
21
client.go
21
client.go
|
@ -388,12 +388,14 @@ type packetIndex struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readLoop(conn *upConnection, track *upTrack) {
|
func readLoop(conn *upConnection, track *upTrack) {
|
||||||
|
isvideo := track.track.Kind() == webrtc.RTPCodecTypeVideo
|
||||||
ch := make(chan packetIndex, 32)
|
ch := make(chan packetIndex, 32)
|
||||||
defer close(ch)
|
defer close(ch)
|
||||||
go writeLoop(conn, track, ch)
|
go writeLoop(conn, track, ch)
|
||||||
|
|
||||||
buf := make([]byte, packetcache.BufSize)
|
buf := make([]byte, packetcache.BufSize)
|
||||||
var packet rtp.Packet
|
var packet rtp.Packet
|
||||||
|
drop := 0
|
||||||
for {
|
for {
|
||||||
bytes, err := track.track.Read(buf)
|
bytes, err := track.track.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -424,11 +426,26 @@ func readLoop(conn *upConnection, track *upTrack) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if drop > 0 {
|
||||||
|
if packet.Marker {
|
||||||
|
// last packet in frame
|
||||||
|
drop = 0
|
||||||
|
} else {
|
||||||
|
drop--
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case ch <- packetIndex{packet.SequenceNumber, index}:
|
case ch <- packetIndex{packet.SequenceNumber, index}:
|
||||||
default:
|
default:
|
||||||
// The writer is congested. Drop the packet, and
|
if isvideo {
|
||||||
// leave it to NACK recovery if possible.
|
// the writer is congested. Drop until
|
||||||
|
// the end of the frame.
|
||||||
|
if isvideo && !packet.Marker {
|
||||||
|
drop = 7
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue