Skip to main content

Module session

Module session 

Source
Expand description

Codec sessions: packets in, frames out (VideoDecoder); frames in, packets out (VideoEncoder).

The protocol, for both directions:

  • send offers one input. SendStatus::Accepted means the session took it (a packet’s payload is taken; a frame handle is cloned). SendStatus::ReceivePending means “receive first”: the input is left untouched for the retry, and at least one receive now returns Receive::Ready. That is the backpressure: a session never queues without bound and never blocks.
  • receive returns one output, Receive::NeedInput, or, after end_input and once everything is drained, Receive::EndOfStream, which is stable.
  • end_input declares the end; it is idempotent. Sending after it is a ProtocolViolation::SendAfterEnd.
  • A decoder’s reset discards queued input, output and references and keeps the configuration; frames already returned stay valid. Seeking is reset and configure (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§

CodecConfig
What a decoder needs before the first packet of a configuration epoch: derived from a TrackInfo, or from a muxer’s expectations.
ErasedError
A codec error with its type erased: the error type of DynIncrementalDecoder.
FusedDecoder
Makes errors and cancellation terminal for any decoder, as Fused does for IncrementalDecode. A successful reset reopens the session.
FusedEncoder
Makes every encoder error and cancellation terminal, including native validation errors that an unwrapped backend might otherwise permit retrying.
VideoDecoderShim
Erases a decoder’s error type.
VideoEncoderShim
Erases an encoder’s error type.
VideoStreamInfo
Per-stream facts, known once the stream has been seen; not static flags.

Enums§

ProtocolViolation
A caller or a session broke the protocol.
PumpError
Where a pump failed: the stage being driven, or the stage it feeds.
Receive
What receive returned.
SendStatus
What send did with an input.
SessionError
Every session error is terminal for the session except Codec errors a backend documents as retryable validation.
UnsupportedMedia
A valid request this implementation does not support.

Traits§

VideoDecoder
A video decoder session: packets in, frames out, in presentation order. See the module docs for the protocol.
VideoEncoder
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 Ready goes to on_output until EndOfStream.
drain_encoder
The encoder twin of drain_decoder.
erase_video_decoder
Erase a decoder: errors become ErasedError, and errors and cancellation become terminal until reset (FusedDecoder).
erase_video_encoder
Erase an encoder’s error type and make all errors/cancellation terminal (FusedEncoder). Use VideoEncoderShim directly 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 into on_output and retry; then deliver whatever output is ready.

Type Aliases§

DynVideoDecoder
A type-erased, sendable decoder session.
DynVideoEncoder
A type-erased, sendable encoder session.