pub struct UlpfecSendBuilder { /* private fields */ }Expand description
Builder for UlpfecSendInterceptor.
§Example
use rtci_interceptor::{Registry, Slot, UlpfecSendBuilder};
// `a=rtpmap:116 red/90000`, `a=rtpmap:117 ulpfec/90000`
let chain = Registry::new()
.with(Slot::FecEncoder, UlpfecSendBuilder::red(116, 117).build())
.build();Implementations§
Source§impl UlpfecSendBuilder
impl UlpfecSendBuilder
Sourcepub fn with_mutable_extensions_zeroed(self, zero: bool) -> Self
pub fn with_mutable_extensions_zeroed(self, zero: bool) -> Self
Protect each media packet with the values of its transport-wide sequence number,
abs-send-time and toffset extensions zeroed, as libwebrtc’s sender does (false by
default; the Chrome profile’s DefaultInterceptorOptions::ulpfec_zero_mutable_extensions).
libwebrtc computes its FEC before it writes those values (RtpSenderEgress::SendPacket
at a222406d: AddPacketAndGenerateFec comes before the SetExtension<TransmissionOffset>,
<AbsoluteSendTime> and <TransportSequenceNumber> calls, “these modifications of the
header below are happening after the FEC protection packets are calculated”; the packet
reserved them as zeros), and its receiver zeroes them in its copy of each media packet
before recovering (UlpfecReceiver::ProcessReceivedFec, ZeroMutableExtensions). With
this on, a packet libwebrtc rebuilds from this engine’s FEC is exactly the one its own
FEC would rebuild: as sent, those values zero. Off (RFC 5109 section 8), the FEC covers
the packet as it left, and those octets of a packet libwebrtc rebuilds are XOR noise.
Sourcepub fn red(red_payload_type: u8, fec_payload_type: u8) -> Self
pub fn red(red_payload_type: u8, fec_payload_type: u8) -> Self
FEC as a redundant encoding (RFC 5109 14.2): every packet of a protected stream leaves as
a RED packet of red_payload_type, and FEC data has fec_payload_type. Both come from
the negotiated a=rtpmap lines (red, ulpfec).
Sourcepub fn stream() -> Self
pub fn stream() -> Self
FEC as a stream of its own (RFC 5109 14.1), on the repair SSRC and payload type of
StreamInfo::ssrc_fec / StreamInfo::payload_type_fec. A stream without both is not
protected. See UlpfecStreamPacketizer for why this is not the media SSRC.
Sourcepub fn with_red_placement(self, placement: RedPlacement) -> Self
pub fn with_red_placement(self, placement: RedPlacement) -> Self
Where FEC data goes in a RED stream. Ignored for a separate stream.
Sourcepub fn with_num_media_packets(self, num_media_packets: usize) -> Self
pub fn with_num_media_packets(self, num_media_packets: usize) -> Self
How many media packets one block of FEC protects, 1 to 48 (the long mask’s reach).
Sourcepub fn with_num_fec_packets(self, num_fec_packets: usize) -> Self
pub fn with_num_fec_packets(self, num_fec_packets: usize) -> Self
How many FEC packets each block produces. The block’s packets are dealt to them in turn,
so n FEC packets recover a burst of up to n losses. Zero sends no FEC.
Sourcepub fn with_level_lengths(self, lengths: impl Into<Vec<u16>>) -> Self
pub fn with_level_lengths(self, lengths: impl Into<Vec<u16>>) -> Self
Protection lengths of the levels, level 0 first, for uneven protection: level 0 covers the
first lengths[0] octets after the fixed RTP header, level 1 the next lengths[1], and
so on; what lies beyond the last level is not protected.
Empty, the default, is one level as long as the block’s longest packet: full protection.
Sourcepub fn with_one_level_only(self, one_level_only: bool) -> Self
pub fn with_one_level_only(self, one_level_only: bool) -> Self
Use one level only, whatever with_level_lengths says: for a
stream whose ulpfec format carries onelevelonly=1 (RFC 5109 13). See
one_level_only_from_fmtp.
Sourcepub fn with_flush_on_marker(self, flush_on_marker: bool) -> Self
pub fn with_flush_on_marker(self, flush_on_marker: bool) -> Self
Also close a block at a packet with the marker bit (the last packet of a video frame), so FEC never waits for the next frame.
Sourcepub fn with_fec_after_frame(self, fec_after_frame: bool) -> Self
pub fn with_fec_after_frame(self, fec_after_frame: bool) -> Self
With RedPlacement::OwnPacket: whether the FEC packets of the blocks that close
inside a frame wait for the frame’s last packet (the one with the marker bit) and take
the sequence numbers after it (true, the default), or each block’s FEC packets follow
the block’s last packet wherever in the frame that is (false).
A FEC packet of this placement takes a sequence number of the media stream. A receiver
puts a frame together from consecutive sequence numbers, so a number inside a frame
that is not media leaves the frame incomplete: libwebrtc’s packet buffer finds a frame
only over packets it holds without a gap, and a received FEC packet closes a gap between
frames only (modules/video_coding/packet_buffer.cc:168-174, InsertPadding, and
FindFrames, at a222406d). libwebrtc’s sender therefore produces FEC only at a packet
that completes a frame (modules/rtp_rtcp/source/ulpfec_generator.cc:134 and
:157-159: complete_frame = packet.Marker(), if (complete_frame && ...)
EncodeFec), and its FEC packets follow that packet. RFC 5109 and RFC 2198 say nothing
about where in a stream a FEC packet lies: only the order on the wire changes, each FEC
packet protects the same media packets either way.
At most ULPFEC_MAX_HELD_FEC_PACKETS FEC packets wait; they leave when that many
have gathered, so a stream that never sets the marker bit is still protected. No
effect on the other placements and carriages, whose FEC takes no sequence number of
the media stream.
Sourcepub fn with_initial_fec_sequence_number(self, sequence_number: u16) -> Self
pub fn with_initial_fec_sequence_number(self, sequence_number: u16) -> Self
The first sequence number of a separate FEC stream. Random when not set, as an RTP stream’s is (RFC 3550 5.1); a test pins it.
Sourcepub fn with_stream_filter(
self,
filter: impl Fn(&StreamInfo) -> bool + Send + Sync + 'static,
) -> Self
pub fn with_stream_filter( self, filter: impl Fn(&StreamInfo) -> bool + Send + Sync + 'static, ) -> Self
Which bound local streams are protected. The default is every video/ stream.
Sourcepub fn with_adaptive_rate(self, adaptive: bool) -> Self
pub fn with_adaptive_rate(self, adaptive: bool) -> Self
Whether the amount of FEC follows the loss the receiver reports (the default), or
stays as configured. See FecRate: no repair under 0.5% loss, enough
for twice the loss above it, at most half the block; the FEC sent is taken out of the
target the application encodes at.
Sourcepub fn build(self) -> UlpfecSendInterceptor
pub fn build(self) -> UlpfecSendInterceptor
Build the interceptor.