webrtc_twcc_sender (webrtc v0.1.0)
View SourceSender side of transport-wide congestion control (draft-holmer-rmcat-transport-wide-cc-extensions-01).
Every RTP packet sent on the transport, media and retransmissions alike, carries the next transport-wide sequence number in the transport-wide-cc header extension (§2). next_seq/1 returns the number to put in the packet and sent/3 records its send time and size once it leaves; numbers are consecutive, so the two calls must alternate.
feedback/3 consumes a decoded #rtcp_twcc{} (§3.1) and returns one result per packet it reports, in sequence order: {SendTimeUs, ArrivalTimeUs | lost, Size}. Send times are on the sender clock (the Now of sent/3, converted to microseconds), arrival times on the receiver clock, so only differences of arrival times are meaningful. A packet reported twice is returned once as received; a packet first reported lost and then received (late or reordered) is returned again as received. Sequence numbers we never sent, or forgot, are ignored.
The send history is bounded: max_packets entries (default 8192) and max_age milliseconds (default 10000).
Summary
Functions
Number of recorded packets not yet reported received.
The transport-wide sequence number of the next packet.
Record the packet carrying next_seq/1 as sent at Now (ms).
The same with a tag returned by tagged_feedback/3 (a probe cluster, for instance).
feedback/3, plus {Tag, SendUs, ArrivalUs | lost, Size} for the reported packets that were sent with a tag.
Types
-type result() :: {SendUs :: integer(), ArrivalUs :: integer() | lost, Size :: non_neg_integer()}.
-type rtcp_u32() :: 0..4294967295.
-opaque state()
Functions
-spec in_flight(state()) -> non_neg_integer().
Number of recorded packets not yet reported received.
-spec next_seq(state()) -> 0..65535.
The transport-wide sequence number of the next packet.
-spec sent(non_neg_integer(), integer(), state()) -> state().
Record the packet carrying next_seq/1 as sent at Now (ms).
-spec sent(non_neg_integer(), integer(), term(), state()) -> state().
The same with a tag returned by tagged_feedback/3 (a probe cluster, for instance).
-spec tagged_feedback(#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}]}, integer(), state()) -> {[result()], [{term(), integer(), integer() | lost, non_neg_integer()}], state()}.
feedback/3, plus {Tag, SendUs, ArrivalUs | lost, Size} for the reported packets that were sent with a tag.