webrtc_tmmbr (webrtc v0.1.0)

View Source

Temporary maximum media stream bit rate limits of one media stream we send (RFC 5104 §3.5.4, §4.2), as a sans-IO state.

Each TMMBR tuple {Owner, Bitrate, Overhead} is the line NetRate = Bitrate - 8 x Overhead x PacketRate. The bounding set is the subset of tuples forming the lower envelope of those lines for packet rates from 0 up to where the envelope meets zero: the most limiting requests (§3.5.4.2, computed here with exact rationals).

  • request/6 adds or replaces the owner's tuple and recomputes the set from the previous set and the new tuple (§4.2.2.2): a tuple outside the set is not kept, its owner asks again after the TMMBN if it must.
  • leave/4 removes an owner that sent BYE, expire/4 the owners silent for the given time (RFC 3550 §6.3.5).
  • A limit never rises at once: the previous set stays enforced for the hold-off the caller gives, 2 x RTT + T_dither_max (§4.2.1.2), so other receivers can answer the TMMBN first. A lower limit applies immediately.

Summary

Functions

The bounding set of Tuples, ordered by increasing overhead.

The tuples the sender follows at Now.

Remove the owners not heard from for Timeout ms. Returns the owners removed from the set.

End the hold-off once due.

The owner left (RTCP BYE). {true, S} when it owned a tuple of the set: send a TMMBN with what remains.

The net media bit rate (payload bits per second) the tuples allow at PacketRate packets per second: the lowest of Bitrate - 8 x Overhead x PacketRate, at least 0.

A TMMBR tuple from Owner. Returns the new state; the caller sends a TMMBN with set/1 whether or not the set changed.

The bounding set reported in TMMBN.

A packet from Ssrc was received: an owner is still there. Other SSRCs are not recorded.

Types

state/0

-opaque state()

tuple_/0

-type tuple_() :: {Owner :: 0..4294967295, Bitrate :: non_neg_integer(), Overhead :: 0..511}.

Functions

bounding_set(Tuples)

-spec bounding_set([tuple_()]) -> [tuple_()].

The bounding set of Tuples, ordered by increasing overhead.

enforced(Now, Tmmbr)

-spec enforced(integer(), state()) -> [tuple_()].

The tuples the sender follows at Now.

expire(Now, Timeout, HoldOff, Tmmbr)

-spec expire(integer(), pos_integer(), non_neg_integer(), state()) -> {[non_neg_integer()], state()}.

Remove the owners not heard from for Timeout ms. Returns the owners removed from the set.

handle_timeout(Now, Tmmbr)

-spec handle_timeout(integer(), state()) -> state().

End the hold-off once due.

leave(Owner, Now, HoldOff, Tmmbr)

-spec leave(non_neg_integer(), integer(), non_neg_integer(), state()) -> {boolean(), state()}.

The owner left (RTCP BYE). {true, S} when it owned a tuple of the set: send a TMMBN with what remains.

net_rate(Set, PacketRate)

-spec net_rate([tuple_()], number()) -> non_neg_integer() | infinity.

The net media bit rate (payload bits per second) the tuples allow at PacketRate packets per second: the lowest of Bitrate - 8 x Overhead x PacketRate, at least 0.

new()

-spec new() -> state().

next_timeout(Tmmbr)

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

request(Owner, Bitrate, Overhead, Now, HoldOff, Tmmbr)

-spec request(non_neg_integer(), non_neg_integer(), 0..511, integer(), non_neg_integer(), state()) ->
                 state().

A TMMBR tuple from Owner. Returns the new state; the caller sends a TMMBN with set/1 whether or not the set changed.

set(Tmmbr)

-spec set(state()) -> [tuple_()].

The bounding set reported in TMMBN.

touch(Ssrc, Now, Tmmbr)

-spec touch(non_neg_integer(), integer(), state()) -> state().

A packet from Ssrc was received: an owner is still there. Other SSRCs are not recorded.