rtci_interceptor/fec_sent.rs
1//! A mark on the FEC an encoder sends, so the one who drives the chain can count it.
2
3/// FEC carried by an outgoing RTP packet, attached by the FEC encoder that wrote it
4/// ([`Attribute::Custom`](crate::Attribute::Custom)).
5///
6/// The packet may be a FEC packet of its own (a separate stream, a FEC session's stream, a
7/// FlexFEC repair packet, a RED packet holding only FEC) or a media packet in RED that FEC
8/// rides with (RFC 5109 section 14.2), so the count is the FEC it holds, not one per packet.
9/// Read where packets leave the chain, it counts what the pacer and the circuit breaker let
10/// through: `rtci`'s peer connection reports it as the FEC sent for `media_ssrc`
11/// (`RTCPeerConnection::fec_stats`).
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub struct FecSent {
14 /// The media stream the FEC protects (the first of them, for FlexFEC protecting several).
15 pub media_ssrc: u32,
16 /// FEC packets, or FEC blocks of a RED packet, in this packet.
17 pub packets: u32,
18 /// Their octets: the FEC payloads (FEC and level headers, or the FlexFEC header, and the
19 /// repair data), not the RTP or RED headers around them.
20 pub bytes: u64,
21}
22
23impl FecSent {
24 /// The mark for one FEC payload of `bytes` octets protecting `media_ssrc`.
25 pub fn one(media_ssrc: u32, bytes: usize) -> crate::Attribute {
26 crate::Attribute::Custom(std::sync::Arc::new(Self {
27 media_ssrc,
28 packets: 1,
29 bytes: bytes as u64,
30 }))
31 }
32}