webrtc_rtp_seq (webrtc v0.1.0)
View SourceWrapping arithmetic for RTP sequence numbers (16 bits) and timestamps (32 bits), RFC 3550 §5.1 and Appendix A.1.
Comparisons use serial number arithmetic: A is before B when the forward distance from A to B is less than half the space. A distance of exactly half the space counts as negative, so that seq_diff/2 stays in -32768..32767.
seq_unwrap/2 and ts_unwrap/2 extend a wrapped value to the unbounded integer closest to a previous extended value, which is how receivers keep a monotonic index across wraparound.
Summary
Functions
Seq + N modulo 2^16 (N may be negative).
Signed distance from B to A (A - B), in -32768..32767.
True when A comes strictly before B.
Extend Seq to the extended sequence number closest to Last (itself extended). Use undefined for the first packet.
Signed distance A - B modulo 2^32.
Types
Functions
Seq + N modulo 2^16 (N may be negative).
Signed distance from B to A (A - B), in -32768..32767.
True when A comes strictly before B.
Extend Seq to the extended sequence number closest to Last (itself extended). Use undefined for the first packet.
Signed distance A - B modulo 2^32.