StreamDecoder

One decoder driven explicitly by the caller.

The send/receive shape preserves FFmpeg's state machine: one packet can produce no frames or several frames, and the decoder may need its output queue drained before accepting more input.

A false send means the packet was not consumed: drain receive, then retry the same packet. Send null at input EOF, receive until isDrained, and call flush after every seek only after discarding packets and frames from the old position. Sending a closed packet is rejected at the call site rather than allowing a dangling payload to reach the decoder.

One decoder driven explicitly by the caller.

The send/receive shape preserves FFmpeg's state machine: one packet can produce no frames or several frames, and the decoder may need its output queue drained before accepting more input.

A false send means the packet was not consumed: drain receive, then retry the same packet. Send null at input EOF, receive until isDrained, and call flush after every seek only after discarding packets and frames from the old position. Sending a closed packet is rejected at the call site rather than allowing a dangling payload to reach the decoder.

One decoder, driven by the caller.

The send and receive shape mirrors libavcodec, including the cases a simpler interface cannot express: one packet producing no frames, one packet producing several, and a decoder that must be drained before it accepts more input.

Three rules that are easy to get wrong and expensive to debug:

  1. Drain with receive until it returns null before assuming send will accept anything.

  2. When send returns false the packet was not consumed. Drain, then offer the same packet again. Discarding it loses frames silently.

  3. flush after every seek, and only after the caller has cleared its own queues. Flushing first lets a packet from the old position reach a freshly reset decoder.

One decoder driven explicitly by the caller.

The send/receive shape preserves FFmpeg's state machine: one packet can produce no frames or several frames, and the decoder may need its output queue drained before accepting more input.

A false send means the packet was not consumed: drain receive, then retry the same packet. Send null at input EOF, receive until isDrained, and call flush after every seek only after discarding packets and frames from the old position. Sending a closed packet is rejected at the call site rather than allowing a dangling payload to reach the decoder.

One decoder driven explicitly by the caller.

The send/receive shape preserves FFmpeg's state machine: one packet can produce no frames or several frames, and the decoder may need its output queue drained before accepting more input.

A false send means the packet was not consumed: drain receive, then retry the same packet. Send null at input EOF, receive until isDrained, and call flush after every seek only after discarding packets and frames from the old position. Sending a closed packet is rejected at the call site rather than allowing a dangling payload to reach the decoder.

Properties

Link copied to clipboard

Packets and frames this decoder skipped as damaged since it was opened, or since flush.

Packets and frames this decoder skipped as damaged since it was opened, or since flush.

Packets and frames this decoder skipped as damaged since it was opened, or since flush.

Packets and frames this decoder skipped as damaged since it was opened, or since flush.

Packets and frames this decoder skipped as damaged since it was opened, or since flush.

Link copied to clipboard
expect var isDrained: Boolean

True after the decoder reports EOF, until flush.

actual var isDrained: Boolean

True after the decoder reports EOF, until flush.

actual var isDrained: Boolean

True once this decoder has emitted its last frame and will emit no more without a flush.

actual var isDrained: Boolean

True after the decoder reports EOF, until flush.

actual var isDrained: Boolean

True after the decoder reports EOF, until flush.

Link copied to clipboard
expect val stream: StreamInfo
actual val stream: StreamInfo
actual val stream: StreamInfo
actual val stream: StreamInfo
actual val stream: StreamInfo

Functions

Link copied to clipboard
expect open override fun close()
actual open override fun close()
actual open override fun close()
actual open override fun close()
actual open override fun close()
Link copied to clipboard
expect fun flush()

Discards buffered decode state and makes the decoder accept a new seek generation. Call this after clearing old caller-owned queues; doing it first would let an old packet enter a freshly reset decoder. Clears isDrained.

actual fun flush()

Discards buffered decode state and makes the decoder accept a new seek generation. Call this after clearing old caller-owned queues; doing it first would let an old packet enter a freshly reset decoder. Clears isDrained.

actual fun flush()

Discards the decoder's internal state.

actual fun flush()

Discards buffered decode state and makes the decoder accept a new seek generation. Call this after clearing old caller-owned queues; doing it first would let an old packet enter a freshly reset decoder. Clears isDrained.

actual fun flush()

Discards buffered decode state and makes the decoder accept a new seek generation. Call this after clearing old caller-owned queues; doing it first would let an old packet enter a freshly reset decoder. Clears isDrained.

Link copied to clipboard
expect fun receive(): Frame?

Returns one owned frame, or null when more input is needed or the decoder is drained. Inspect isDrained to distinguish those two null cases. The frame is an O(1) owned clone and may be queued independently of later decoder calls.

actual fun receive(): Frame?

Returns one owned frame, or null when more input is needed or the decoder is drained. Inspect isDrained to distinguish those two null cases. The frame is an O(1) owned clone and may be queued independently of later decoder calls.

actual fun receive(): Frame?

Takes the next decoded frame.

actual fun receive(): Frame?

Returns one owned frame, or null when more input is needed or the decoder is drained. Inspect isDrained to distinguish those two null cases. The frame is an O(1) owned clone and may be queued independently of later decoder calls.

actual fun receive(): Frame?

Returns one owned frame, or null when more input is needed or the decoder is drained. Inspect isDrained to distinguish those two null cases. The frame is an O(1) owned clone and may be queued independently of later decoder calls.

Link copied to clipboard
expect fun send(packet: Packet?): Boolean

Offers packet, or null to start the decoder drain.

actual fun send(packet: Packet?): Boolean

Offers packet, or null to start the decoder drain.

actual fun send(packet: Packet?): Boolean

Offers a packet, or null to begin the end-of-stream drain.

actual fun send(packet: Packet?): Boolean

Offers packet, or null to start the decoder drain.

actual fun send(packet: Packet?): Boolean

Offers packet, or null to start the decoder drain.