Overview
The Producer and Consumer processors work as a pair to route frames between different parts of a pipeline, particularly useful when working withParallelPipeline. They allow you to selectively capture frames from one pipeline branch and inject them into another.
ProducerProcessor
ProducerProcessor examines frames flowing through the pipeline, applies a filter to decide which frames to share, and optionally transforms these frames before sending them to connected consumers.
Constructor Parameters
Callable[[Frame], Awaitable[bool]]
required
An async function that determines which frames should be sent to consumers.
Should return
True for frames to be shared.Callable[[Frame], Awaitable[Frame]]
default:"identity_transformer"
Optional async function that transforms frames before sending to consumers. By
default, passes frames unchanged.
bool
default:"True"
When
True, passes all frames through the normal pipeline flow. When False,
only passes through frames that don’t match the filter.ConsumerProcessor
ConsumerProcessor receives frames from a ProducerProcessor and injects them into its pipeline branch.
Constructor Parameters
ProducerProcessor
required
The producer processor that will send frames to this consumer.
Callable[[Frame], Awaitable[Frame]]
default:"identity_transformer"
Optional async function that transforms frames before injecting them into the
pipeline.
FrameDirection
default:"FrameDirection.DOWNSTREAM"
The direction in which to push received frames. Usually
DOWNSTREAM to send
frames forward in the pipeline.