Add an initial, very simple, jitter buffer #222
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a very simple jitter buffer for RTP packets. The goal of this is to slowly introduce jitter buffers in places which network jitter can critically impact stream performance without causing unnecessary delay. Right now the heuristic is set at a fixed packet count before moving to the playback state, but this algorithm will be adjusted (and additional dynamic algorithms introduced) in future work.
This jitter buffer relies on a priority queue based on the RTP packet's sequence number. It will insert new packets in priority of sequence number, tracks when its current simplistic total packet count is met to emit a playback event and allows Pop-ing packets off either from the play head (defined as the head position when the jitter buffer met its minimum length) or at a specific timestamp.
For elements which need to exhaust all packets at a specific timestamp, call PopAtTimestamp with the timestamp in a loop and wait for an error response.
More to come, statistics suggestions welcome, as well as any other feedback on approach or suggested algorithms.