rtpjitterbuffer: clean up and improve missing packets handling
-
Try to make variable and function names more clear.
-
Add plenty of comments describing the logic step-by-step.
-
Improve the logging around this, making the logs easier to read and understand when debugging these issues.
-
Revise the logic of packets that are actually beyond saving in doing the following:
- Do an optimistic estimation of which packets can still arrive.
- Based on this, find which packets (and duration) are now hopelessly lost.
- Issue an immediate lost-event for the hopelessly lost and then add lost/rtx timers for the ones we still hope to save, meaning that if they are to arrive, they will not be discarded.
-
Revise the use of rtx-delay: Earlier the rtx-delay would vary, depending on the pts of the latest packet and the estimated pts of the packet it being issued a RTX for, but now that we aim to estimate the PTS of the missing packet accurately, the RTX delay should remain the same for all packets. Meaning: If the packet have a PTS of X, the delay in asked for a RTX for this packet is always a constant X + delay, not a variable one.
-
Finally ensure that the chaotic "check-for-stall" tests uses timestamps that starts from 0 to make them easier to debug.