#[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 asLocalVideoTrack::Encodedand you feed it with [EncodedVideoTrack::push_encoded_frame].Inline— synchronous: libwebrtc calls your closure on the encoder thread with every raw I420 frame; returnSome(encoded)to inject bytes into the RTP stack orNoneto drop the frame. Right when your pipeline is raw-in/encoded-out and you want libwebrtc to drive the cadence. The track comes back asLocalVideoTrack::Rawand 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
PreEncoded(PreEncodedOptions)
You push already-encoded bytes at your own pace.
Inline(InlineEncoderCallback)
libwebrtc calls your encoder synchronously with every raw I420 frame.