webrtc_flexfec (webrtc v0.1.0)
View SourceFlexFEC (RFC 8627): parity FEC repair packets on their own RTP stream, protecting the packets of a source stream named in the repair packet's CSRC list (§4.2.1).
The FEC header (§4.2.2) starts with R and F, then the P, X, CC, M and PT recovery fields, the length recovery and the TS recovery fields. With R = 0 and F = 0 an SN base and a flexible mask of 15, 46 or 110 bits follow for each protected SSRC (§4.2.2.1: k = 1, another mask block follows; k = 0, the last); with F = 1 an SN base and L columns and D rows (§4.2.2.2); with R = 1 the packet is a retransmission of a source packet (§4.2.2.3). The repair payload is the XOR of everything after the 12 byte RTP header of each source packet (§6.2).
protect/2 builds flexible mask repair payloads. decode/2 reads a repair payload for the given CSRC count; the recovery itself is the same XOR as ULPFEC's and is done by webrtc_ulpfec.
Summary
Functions
Read a repair payload whose RTP header has Count CSRCs (the protected SSRCs). A parity repair gives, per protected SSRC in CSRC order, {Base, Offsets}, and the recovery fields; a retransmission gives the source packet.
K repair payloads protecting Packets ([{Seq, Bin}], one SSRC, in sequence order, at most 110), packet I in payload I rem K.
Functions
-spec decode(binary(), non_neg_integer()) -> {ok, #{blocks := [{0..65535, [non_neg_integer()]}], atom() => term()}} | {retransmission, binary()} | {error, term()}.
Read a repair payload whose RTP header has Count CSRCs (the protected SSRCs). A parity repair gives, per protected SSRC in CSRC order, {Base, Offsets}, and the recovery fields; a retransmission gives the source packet.
-spec protect([{0..65535, binary()}], pos_integer()) -> [binary()].
K repair payloads protecting Packets ([{Seq, Bin}], one SSRC, in sequence order, at most 110), packet I in payload I rem K.