Skip to main content

TrackVideoEncoder

Enum TrackVideoEncoder 

Source
#[non_exhaustive]
pub enum TrackVideoEncoder { PreEncoded(PreEncodedOptions), Inline(InlineEncoderCallback), }
Expand description

How a video track produces its encoded bitstream, replacing libwebrtc’s builtin encoder for that track only.

One mechanism, two feeding styles:

  • PreEncoded — asynchronous: you push already-encoded bytes at your own pace, from any thread (a hardware encoder callback, a relay, a file dumper). A queue decouples your producer from the encoder thread. The track comes back as LocalVideoTrack::Encoded and you feed it with [EncodedVideoTrack::push_encoded_frame].
  • Inline — synchronous: libwebrtc calls your closure on the encoder thread with every raw I420 frame; return Some(encoded) to inject bytes into the RTP stack or None to drop the frame. Right when your pipeline is raw-in/encoded-out and you want libwebrtc to drive the cadence. The track comes back as LocalVideoTrack::Raw and you feed it like any raw track.

Either way, the bytes you produce must match the codec negotiated for the track’s transceiver — read RawVideoFrame::codec (inline) or set codec preferences to pin it.

§Slot assignment order — positional, with fresh upgrades

Slots route encoder instances ↔ tracks positionally: reservation order (track creation) must match the negotiation order of the transceivers carrying those tracks. Create encoder-carrying tracks before the peer connection they’re attached to negotiates (before create_offer), or the registry may not yet see a reservation to bind to; ordering across multiple peer connections sharing one factory follows whichever negotiates first, not track creation order.

Dropping an encoder-carrying track retracts its pending slots and degrades any surviving assigned slot to Builtin (loud fallback, never another track’s). libwebrtc may recreate encoder instances on internal errors or renegotiation past a dead track; that path degrades the same way rather than re-routing another live track’s pipeline.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

PreEncoded(PreEncodedOptions)

You push already-encoded bytes at your own pace.

§

Inline(InlineEncoderCallback)

libwebrtc calls your encoder synchronously with every raw I420 frame.

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.