PacketConsumer


@ExperimentalApi
interface PacketConsumer<T : Any?>

Known direct subclasses
PacketProcessor

A PacketConsumer that processes Packets and forwards them to a downstream PacketConsumer.

RecordingPacketConsumer

A PacketConsumer implementation that holds a reference to all queued packets, and optionally releases the underlying frames.

RenderingPacketConsumer

A PacketConsumer that renders input Packets to an output O.


A consumer that accepts Packets.

This interface is experimental and will be renamed or removed in a future release.

Parameters
<T : Any?>

The type of Packet.payload being consumed.

Summary

Nested types

fun interface PacketConsumer.Factory<T : Any?>

A factory for PacketConsumer instances.

sealed interface PacketConsumer.Packet<T : Any?>

Represents a packet.

A Packet implementation to represent an end of stream (EOS) signal.

A Packet implementation to wrap a payload of type T.

Public functions

suspend Unit

Queues a Packet for processing, suspending the caller if the consumer is at capacity.

suspend Unit

Releases all resources.

Public functions

queuePacket

suspend fun queuePacket(packet: PacketConsumer.Packet<T>): Unit

Queues a Packet for processing, suspending the caller if the consumer is at capacity.

Once this method returns, the ownership of the packet is transferred to this PacketConsumer, and the caller should not modify the packet.

Parameters
packet: PacketConsumer.Packet<T>

The Packet to process.

release

suspend fun release(): Unit

Releases all resources.