webrtc_twcc_receiver (webrtc v0.1.0)

View Source

Receiver side of transport-wide congestion control (draft-holmer-rmcat-transport-wide-cc-extensions-01 §3), as a sans-IO engine.

packet/4 records the arrival time of a packet carrying a transport-wide sequence number. Feedback (#rtcp_twcc{}) is emitted by handle_timeout/2 every interval milliseconds (default 100) after the first unreported arrival, and by flush/2 on demand.

Each feedback message starts right after the highest sequence number of the previous one, so a packet lost between two messages is still reported as not_received. A packet arriving after feedback already covered its sequence number (reordering) is reported in the next message, which then covers everything from it on again, as libwebrtc does: the arrivals already reported are repeated from a bounded history (the sender ignores repeated reports). A gap of more than max_gap (default 1000) sequence numbers is treated as a restart of the sequence: not reported as losses, and packets that much older than reported ones are dropped and counted as late.

Pending arrivals are bounded by max_pending (default 1000): when reached, feedback is due at once; at twice that, new arrivals are dropped and counted until the next feedback.

Summary

Functions

Feedback for every pending arrival, now.

Record that the packet with transport-wide sequence number Seq from Ssrc arrived at Now (milliseconds).

Types

rtcp_u32/0

-type rtcp_u32() :: 0..4294967295.

state/0

-opaque state()

Functions

flush(Now, Rx)

-spec flush(integer(), state()) ->
               {[#rtcp_twcc{sender_ssrc :: rtcp_u32(),
                            media_ssrc :: rtcp_u32(),
                            base_seq :: 0..65535,
                            ref_time :: -8388608..8388607,
                            fb_count :: 0..255,
                            packets :: [{0..65535, not_received | -32768..32767}]}],
                state()}.

Feedback for every pending arrival, now.

handle_timeout(Now, Rx)

-spec handle_timeout(integer(), state()) ->
                        {[#rtcp_twcc{sender_ssrc :: rtcp_u32(),
                                     media_ssrc :: rtcp_u32(),
                                     base_seq :: 0..65535,
                                     ref_time :: -8388608..8388607,
                                     fb_count :: 0..255,
                                     packets :: [{0..65535, not_received | -32768..32767}]}],
                         state()}.

new(Opts)

-spec new(map()) -> state().

next_timeout(Rx)

-spec next_timeout(state()) -> integer() | infinity.

packet(Seq, Ssrc, Now, Rx)

-spec packet(0..65535, 0..4294967295, integer(), state()) -> state().

Record that the packet with transport-wide sequence number Seq from Ssrc arrived at Now (milliseconds).

stats(Rx)

-spec stats(state()) -> map().