Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use uint64_t for containers with RTP seq number as key #1370

Open
ibc opened this issue Apr 9, 2024 · 0 comments
Open

Use uint64_t for containers with RTP seq number as key #1370

ibc opened this issue Apr 9, 2024 · 0 comments
Assignees
Milestone

Comments

@ibc
Copy link
Member

ibc commented Apr 9, 2024

As discussed in issue #1366 (this comment by @penguinol: #1366 (comment)) we may use uint64_t in C++ maps and sets in which the key is a RTP seq number or similar. This would allow us to use our SeqManager compare functions into those containers without violating transitivity, i.e. comp(a,b) && comp(b,c) -> comp(a,c), which currently we are violating (see the referenced issue for details).

libwebrtc uses uint64_t for seq nums, it takes more memory and cpu usage, but it's easier to understand and more reliable. uint64_t is big enougth to avoid wrap around. When receiving a packet, unwrap uint16_t seq num to uint64_t by roc * 65535 + seq (where roc is the cycle number), and then store and use the uint64_t value as in https://webrtc.googlesource.com/src/+/refs/heads/main/rtc_base/numerics/sequence_number_unwrapper.h. libwebrtc creates a SeqNumUnwrapper object for every stream which stores the uint64_t value of the last packet. When a new packet arrives, it calculates the distance between the seq of the packet and the last seq in SeqNumUnwrapper by something like our SeqManager::SeqLowerThan to determine which cycle does the packet belongs to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants