Skip to content

Commit

Permalink
Save old TCC feedback timestamps, in case of packet reordering.
Browse files Browse the repository at this point in the history
Based on libwebrtc's equivalent code (as used in Chrome).
  • Loading branch information
JonathanLennox committed Feb 24, 2020
1 parent a32b5b4 commit 4c5056b
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ class TccGeneratorNode(
private fun addPacket(tccSeqNum: Int, timestamp: Long, isMarked: Boolean, ssrc: Long) {
synchronized(lock) {
if (packetArrivalTimes.ceilingKey(windowStartSeq) == null) {
// Packets in map are all older than the start of the next tcc feedback packet,
// remove them
// TODO: Chrome does something more advanced, keeping older sequences to replay on packet reordering.
packetArrivalTimes.clear()
// Start new feedback packet, cull old packets.
packetArrivalTimes.entries.removeIf {
entry -> entry.key < tccSeqNum &&
timestamp - entry.value >= BACK_WINDOW_MS
}
}
if (windowStartSeq == -1 || tccSeqNum < windowStartSeq) {
windowStartSeq = tccSeqNum
Expand Down Expand Up @@ -183,4 +184,10 @@ class TccGeneratorNode(
addBoolean("enabled", enabled)
}
}

companion object {
/** The number of milliseconds of old tcc reports to save */
/** TODO: Chrome makes this a field trial param; do we need to make it configurable? */
private val BACK_WINDOW_MS = 500
}
}

0 comments on commit 4c5056b

Please sign in to comment.