Filters
FunctionFilter
Processor that filters frames using a custom filter function
Overview
FunctionFilter
is a flexible processor that uses a custom async function to determine which frames to pass through. This allows for complex, dynamic filtering logic beyond simple type checking.
Constructor Parameters
Async function that examines each frame and returns True to allow it or False to filter it out
Which direction of frames to filter (DOWNSTREAM or UPSTREAM)
Functionality
When a frame passes through the processor:
- System frames and end frames are always passed through
- Frames moving in a different direction than specified are always passed through
- Other frames are passed to the filter function
- If the filter function returns True, the frame is passed through
Output Frames
The processor conditionally passes through frames based on:
- Frame type (system frames and end frames always pass)
- Frame direction (only filters in the specified direction)
- Result of the custom filter function
Usage Example
Frame Flow
Notes
- Provides maximum flexibility for complex filtering logic
- Can incorporate dynamic conditions that change at runtime
- Only filters frames moving in the specified direction
- Always passes through system frames for proper pipeline operation
- Can be used to create sophisticated content-based filters
- Supports async filter functions for complex processing