webrtc_rtcp_interval (webrtc v0.1.0)
View SourceRTCP transmission interval (RFC 3550 §6.2, §6.3 and Appendix A.7) with the RTP/AVPF rules of RFC 4585 §3.4 and §3.5 and the reduced minimum interval required by RFC 8834 §5.1.
reconsider/4 and reverse_reconsider/5 give the timer reconsideration (§6.3.6) and reverse reconsideration (§6.3.4) steps that the RTCP scheduler of the transport runs; this module keeps no state.
Everything here is a pure function. The randomisation factor is passed in as U, a float in [0, 1); interval/1 draws it from crypto:strong_rand_bytes/1.
Parameters (params()):
members,senders: session membership counts;rtcp_bw: RTCP bandwidth in octets per second (5% of the session bandwidth by default, RFC 3550 §6.2);we_sent: true when we sent RTP since the last two reports;avg_rtcp_size: average compound RTCP size in octets, including UDP and IP headers;tmin: minimum interval in seconds, seemin_interval/1.
Summary
Functions
Update the average compound RTCP size with a packet of Size octets (§6.3.3): avg = 1/16 * size + 15/16 * avg.
Deterministic interval Td (§6.3.1): when senders are at most a quarter of the members, senders and receivers share 25% and 75% of the RTCP bandwidth separately.
T_dither_max for early feedback (RFC 4585 §3.5.2 step 2b): 0 in a point-to-point session, half the regular interval otherwise.
Randomised interval with a strong random factor.
Randomised interval of Appendix A.7 in seconds: the deterministic interval times a factor uniformly spread over [0.5, 1.5), divided by e - 3/2.
Minimum interval Tmin in seconds.
Timer reconsideration when the transmission timer expires at Tc (§6.3.6, Appendix A.7 OnExpire). Tp is the time of the last report and Params the current membership. Returns send when Tp + T =< Tc: the caller sends the report, then arms the timer at Tc plus a fresh interval/2. Otherwise returns {wait, Tn} with Tn = Tp + T and nothing is sent. Times are in seconds.
Reverse reconsideration after a BYE lowers Members below PMembers (§6.3.4): returns the new {Tn, Tp}, both moved towards Tc by the ratio members / pmembers.
Participant timeout in seconds (§6.3.5): M * Td with M = 5. Td is computed with the fixed 5 s minimum even when the reduced minimum is used for sending (RFC 8834 §5.1), or with trr_interval when an AVPF session sets one (RFC 4585 §3.5.3). The tmin of Params is ignored.
AVPF dithered minimal interval between regular reports, RND * T_rr_interval with RND in [0.5, 1.5) (RFC 4585 §3.5.3).
Uniform float in [0, 1) from a strong random source.
Types
-type params() :: #{members := pos_integer(), senders := non_neg_integer(), rtcp_bw := number(), we_sent := boolean(), avg_rtcp_size := number(), tmin := number(), trr_interval => number()}.
Functions
-spec avg_rtcp_size(number(), non_neg_integer()) -> float().
Update the average compound RTCP size with a packet of Size octets (§6.3.3): avg = 1/16 * size + 15/16 * avg.
Deterministic interval Td (§6.3.1): when senders are at most a quarter of the members, senders and receivers share 25% and 75% of the RTCP bandwidth separately.
T_dither_max for early feedback (RFC 4585 §3.5.2 step 2b): 0 in a point-to-point session, half the regular interval otherwise.
Randomised interval with a strong random factor.
Randomised interval of Appendix A.7 in seconds: the deterministic interval times a factor uniformly spread over [0.5, 1.5), divided by e - 3/2.
Minimum interval Tmin in seconds.
RTP/AVP (RFC 3550 §6.2): 5 s, or with reduced the reduced minimum of 360 / session bandwidth in kbit/s (required by RFC 8834 §5.1); the first report uses half of it (Appendix A.7).
RTP/AVPF (RFC 4585 §3.4 d, §3.5.1): before the first regular report Tmin is 0 in a point-to-point session and 1 s otherwise; it is 0 after the first regular report.
Timer reconsideration when the transmission timer expires at Tc (§6.3.6, Appendix A.7 OnExpire). Tp is the time of the last report and Params the current membership. Returns send when Tp + T =< Tc: the caller sends the report, then arms the timer at Tc plus a fresh interval/2. Otherwise returns {wait, Tn} with Tn = Tp + T and nothing is sent. Times are in seconds.
-spec reverse_reconsider(number(), number(), number(), pos_integer(), pos_integer()) -> {float(), float()}.
Reverse reconsideration after a BYE lowers Members below PMembers (§6.3.4): returns the new {Tn, Tp}, both moved towards Tc by the ratio members / pmembers.
Participant timeout in seconds (§6.3.5): M * Td with M = 5. Td is computed with the fixed 5 s minimum even when the reduced minimum is used for sending (RFC 8834 §5.1), or with trr_interval when an AVPF session sets one (RFC 4585 §3.5.3). The tmin of Params is ignored.
AVPF dithered minimal interval between regular reports, RND * T_rr_interval with RND in [0.5, 1.5) (RFC 4585 §3.5.3).
-spec uniform() -> float().
Uniform float in [0, 1) from a strong random source.