Expand description
Codec sessions: packets in, frames out (VideoDecoder); frames in,
packets out (VideoEncoder).
The protocol, for both directions:
sendoffers one input.SendStatus::Acceptedmeans the session took it (a packet’s payload is taken; a frame handle is cloned).SendStatus::ReceivePendingmeans “receive first”: the input is left untouched for the retry, and at least onereceivenow returnsReceive::Ready. That is the backpressure: a session never queues without bound and never blocks.receivereturns one output,Receive::NeedInput, or, afterend_inputand once everything is drained,Receive::EndOfStream, which is stable.end_inputdeclares the end; it is idempotent. Sending after it is aProtocolViolation::SendAfterEnd.- A decoder’s
resetdiscards queued input, output and references and keeps the configuration; frames already returned stay valid. Seeking isresetandconfigure(to re-inject a sequence header), then packets from the new position.
Sessions do no I/O, need no async runtime and know nothing about
containers. Work calls take an Option<&dyn zencodec::Pulse>: None adds no
per-call control and never disables a session’s retained control or resource
checks. FusedDecoder makes errors
and cancellation terminal until a successful reset. FusedEncoder
makes encoder errors terminal; a fresh encoder starts a new operation.
Structs§
- Codec
Config - What a decoder needs before the first packet of a configuration epoch:
derived from a
TrackInfo, or from a muxer’s expectations. - Erased
Error - A codec error with its type erased: the error type of
DynIncrementalDecoder. - Fused
Decoder - Makes errors and cancellation terminal for any decoder, as
Fuseddoes forIncrementalDecode. A successfulresetreopens the session. - Fused
Encoder - Makes every encoder error and cancellation terminal, including native validation errors that an unwrapped backend might otherwise permit retrying.
- Video
Decoder Shim - Erases a decoder’s error type.
- Video
Encoder Shim - Erases an encoder’s error type.
- Video
Stream Info - Per-stream facts, known once the stream has been seen; not static flags.
Enums§
- Protocol
Violation - A caller or a session broke the protocol.
- Pump
Error - Where a pump failed: the stage being driven, or the stage it feeds.
- Receive
- What
receivereturned. - Send
Status - What
senddid with an input. - Session
Error - Every session error is terminal for the session except
Codecerrors a backend documents as retryable validation. - Unsupported
Media - A valid request this implementation does not support.
Traits§
- Video
Decoder - A video decoder session: packets in, frames out, in presentation order. See the module docs for the protocol.
- Video
Encoder - A video encoder session: frames in, packets out, in decode order. See the module docs for the protocol.
Functions§
- drain_
decoder - End input and drain: every
Readygoes toon_outputuntilEndOfStream. - drain_
encoder - The encoder twin of
drain_decoder. - erase_
video_ decoder - Erase a decoder: errors become
ErasedError, and errors and cancellation become terminal untilreset(FusedDecoder). - erase_
video_ encoder - Erase an encoder’s error type and make all errors/cancellation terminal
(
FusedEncoder). UseVideoEncoderShimdirectly when preserving a backend’s explicitly documented retryable validation contract is required. - send_
frame_ until_ accepted - The encoder twin of
send_packet_until_accepted. - send_
packet_ until_ accepted - The backpressure loop every driver writes once: send, and while the codec
says
ReceivePending, receive output intoon_outputand retry; then deliver whatever output is ready.
Type Aliases§
- DynVideo
Decoder - A type-erased, sendable decoder session.
- DynVideo
Encoder - A type-erased, sendable encoder session.