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_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 build(self) -> UlpfecSendInterceptor

Build the interceptor.

Auto Trait Implementations§

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.