-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
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.