Skip to main content

UlpfecSendBuilder

Struct UlpfecSendBuilder 

Source
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

Source

pub fn with_probe_fill(self, probe_fill: bool) -> Self

Whether bandwidth probe clusters are filled with FEC (RFC 8854 section 8: “when probing bandwidth, i.e., speculatively sending extra data to determine if additional link capacity exists, FEC data SHOULD be used as the additional data”; the default). When a cluster is asked for (the pacer’s ProbeFill says how much the media it holds leaves to fill; without a pacer, the whole cluster), the encoder sends up to that much in FEC packets over the newest media packets that left (at most 16, within one mask; at most one FEC packet each) of the stream that sent last, and the NACK responder pads only what they leave unfilled. These FEC packets are not taken out of the target the application encodes at: a cluster is sent above it.

Where the FEC can go: on a separate FEC stream of the media’s RTP session (Self::stream, the stream’s repair flow) always; never in a FEC session of its own (StreamInfo::fec_session: another transport, whose path a cluster of the media’s session does not measure); in RED with RedPlacement::OwnPacket as RED packets of their own that take the media stream’s next sequence numbers, so only between frames (the last packet written had the marker bit) and when every media packet written has left (none of their FEC is still to take a number); in RED with RedPlacement::WithNextMedia never (RFC 5109 section 14.2: “the FEC MUST NOT be sent by itself for this stream”, and a probe has no media to ride with). Where it cannot, the cluster is padded as before. Off, the NACK responder pads every cluster on the RTX stream, as libwebrtc does (the Chrome profile’s DefaultInterceptorOptions::fec_probe_fill).

Source

pub fn with_latency_budget(self, latency_budget: Option<Duration>) -> Self

The application’s latency budget (RFC 8854 section 8): while the round trip measured to the receiver is within it, a stream that can be repaired by RTX (nack and an RTX stream negotiated) gets no FEC. FEC_DEFAULT_LATENCY_BUDGET by default; None sends FEC by the loss whatever the round trip (proactive FEC).

Source

pub fn with_base_layer_only(self, base_layer_only: bool) -> Self

Whether only base-layer frames of a layered codec are protected (RFC 8854 section 8; the default): a packet of a temporal layer above the base (VP8, VP9, H.265, AV1) is left out of the blocks (it still goes in RED where the stream is carried in RED).

Source

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.

Source

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).

Source

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.

Source

pub fn with_red_placement(self, placement: RedPlacement) -> Self

Where FEC data goes in a RED stream. Ignored for a separate stream.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn with_source_rate_first(self, source_rate_first: bool) -> Self

Whether stronger FEC waits until the source rate has been reduced (RFC 8627 section 8: “stronger FEC protection MAY be applied only after the source rate has been reduced”; the default). Once a congestion controller’s target went by, the amount of FEC rises only when the source sent in the last second plus the FEC the higher amount adds fit within the target, and the target for the application is lowered by the FEC asked for so the source makes the room. See FecRate::with_source_rate_first.

Source

pub fn build(self) -> UlpfecSendInterceptor

Build the interceptor.

Auto Trait Implementations§

§

impl !RefUnwindSafe for UlpfecSendBuilder

§

impl !UnwindSafe for UlpfecSendBuilder

§

impl Forget for UlpfecSendBuilder

§

impl Freeze for UlpfecSendBuilder
where *const u8 is !null: Freeze, PhantomData<u16>: Freeze, *const ArcInner<dyn Fn(&StreamInfo) -> bool + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&StreamInfo) -> bool + Sync + Send>>: Freeze,

§

impl Move for UlpfecSendBuilder

§

impl Send for UlpfecSendBuilder
where RawVecInner: Send, Arc<dyn Fn(&StreamInfo) -> bool + Sync + Send>: Send,

§

impl Sync for UlpfecSendBuilder
where RawVecInner: Sync, Arc<dyn Fn(&StreamInfo) -> bool + Sync + Send>: Sync,

§

impl Unpin for UlpfecSendBuilder
where *const u8 is !null: Unpin, Arc<dyn Fn(&StreamInfo) -> bool + Sync + Send>: Unpin,

§

impl UnsafeUnpin for UlpfecSendBuilder
where *const u8 is !null: UnsafeUnpin, PhantomData<u16>: UnsafeUnpin, *const ArcInner<dyn Fn(&StreamInfo) -> bool + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&StreamInfo) -> bool + Sync + Send>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.