mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Make NACK threshold depend on the average packet rate.
This commit is contained in:
parent
4a8e48d146
commit
a233f10b0b
1 changed files with 28 additions and 5 deletions
|
@ -58,11 +58,35 @@ func readLoop(conn *rtpUpConnection, track *rtpUpTrack) {
|
||||||
}
|
}
|
||||||
|
|
||||||
first, index := track.cache.Store(
|
first, index := track.cache.Store(
|
||||||
packet.SequenceNumber, packet.Timestamp, kf, buf[:bytes],
|
packet.SequenceNumber, packet.Timestamp,
|
||||||
|
kf, buf[:bytes],
|
||||||
)
|
)
|
||||||
if packet.SequenceNumber-first > 24 {
|
|
||||||
found, first, bitmap :=
|
_, rate := track.rate.Estimate()
|
||||||
track.cache.BitmapGet(packet.SequenceNumber - 4)
|
|
||||||
|
delta := packet.SequenceNumber - first
|
||||||
|
if (delta & 0x8000) != 0 {
|
||||||
|
delta = 0
|
||||||
|
}
|
||||||
|
// send a NACK if a packet is late by 65ms or 2 packets,
|
||||||
|
// whichever is more
|
||||||
|
packets := rate / 16
|
||||||
|
if packets > 24 {
|
||||||
|
packets = 24
|
||||||
|
}
|
||||||
|
if packets < 2 {
|
||||||
|
packets = 2
|
||||||
|
}
|
||||||
|
// send NACKs for more recent packets, this makes better
|
||||||
|
// use of the NACK bitmap
|
||||||
|
unnacked := uint16(4)
|
||||||
|
if unnacked > uint16(packets) {
|
||||||
|
unnacked = uint16(packets)
|
||||||
|
}
|
||||||
|
if uint32(delta) > packets {
|
||||||
|
found, first, bitmap := track.cache.BitmapGet(
|
||||||
|
packet.SequenceNumber - unnacked,
|
||||||
|
)
|
||||||
if found {
|
if found {
|
||||||
err := conn.sendNACK(track, first, bitmap)
|
err := conn.sendNACK(track, first, bitmap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -71,7 +95,6 @@ func readLoop(conn *rtpUpConnection, track *rtpUpTrack) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, rate := track.rate.Estimate()
|
|
||||||
delay := uint32(rtptime.JiffiesPerSec / 1024)
|
delay := uint32(rtptime.JiffiesPerSec / 1024)
|
||||||
if rate > 512 {
|
if rate > 512 {
|
||||||
delay = rtptime.JiffiesPerSec / rate / 2
|
delay = rtptime.JiffiesPerSec / rate / 2
|
||||||
|
|
Loading…
Reference in a new issue