Skip to main content

FrameProcessor

Trait FrameProcessor 

Source
pub trait FrameProcessor: Send + 'static {
    // Required method
    fn name(&self) -> &str;

    // Provided methods
    fn start<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        _setup: &'life1 ProcessorSetup,
        _params: &'life2 StartParams,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn process_frame<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        env: Envelope,
        link: &'life1 Link,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn stop<'life0, 'async_trait>(
        &'life0 mut self,
        _reason: StopReason,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn can_generate_metrics(&self) -> bool { ... }
}
Expand description

The building block (PROCESSOR-DESIGN §2.1). Each processor runs in its own tokio task fed by a bounded mpsc channel; the framework owns the task loop, an impl writes only process_frame (and optional start/stop).

§Lifecycle frames bypass process_frame (read this before writing a processor)

The framework — not the processor — owns the lifecycle. The per-processor task loop (run_processor) intercepts lifecycle frames and routes them to the hooks instead of process_frame:

So your process_frame never sees these frames — observe lifecycle via the start/stop hooks (this is why the internal Sink taps from the hooks). An upstream End/Stop/Cancel is the exception: it is a “request to end” and DOES reach process_frame (the default forwards it upstream so the Source can convert it to a downstream drain — pipecat’s EndTaskFrame vs EndFrame). Keep process_frame about data; do not try to handle Start/terminal frames there.

Mirrors pipecat FrameProcessor (frame_processor.py:175).

Required Methods§

Source

fn name(&self) -> &str

Stable, human-readable name (observer events, error attribution, tracing).

Provided Methods§

Source

fn start<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, _setup: &'life1 ProcessorSetup, _params: &'life2 StartParams, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Called once when the Frame::Start frame reaches this processor, before any data frame. Open sockets / spawn provider readers here. Default: no-op.

Source

fn process_frame<'life0, 'life1, 'async_trait>( &'life0 mut self, env: Envelope, link: &'life1 Link, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handle one frame. Push results via link. Must not block: long work (a provider round-trip) is driven by an internally-spawned task that feeds results back as frames. The default impl forwards the frame unchanged in its direction — so a pure observer/no-op processor is process_frame = default.

Source

fn stop<'life0, 'async_trait>( &'life0 mut self, _reason: StopReason, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Called on End/Stop/Cancel after the terminal frame is forwarded. Flush + close. Default: no-op.

Source

fn can_generate_metrics(&self) -> bool

Whether this processor produces metrics (pipecat can_generate_metrics, :395). Services override to true.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl FrameProcessor for AssistantContextAggregator

Source§

impl FrameProcessor for FunctionCallFilter

Source§

impl FrameProcessor for IvrNavigator

Source§

impl FrameProcessor for ParallelPipeline

Source§

impl FrameProcessor for Pipeline

Source§

impl FrameProcessor for RecorderProcessor

Source§

impl FrameProcessor for TranscriptProcessor

Source§

impl FrameProcessor for TransportInput

Source§

impl FrameProcessor for UserContextAggregator

Source§

impl FrameProcessor for VoicemailDetector

Source§

impl FrameProcessor for WakeCheckFilter

Source§

impl FrameProcessor for WakeNotifierProcessor

Source§

impl<A: TextAggregator + 'static> FrameProcessor for TextAggregatorProcessor<A>

Source§

impl<B: AgentBrain + 'static, Rl: ToolRelay + 'static> FrameProcessor for BrainProcessor<B, Rl>

Source§

impl<F: AudioFilter + 'static> FrameProcessor for AudioFilterProcessor<F>

Source§

impl<F: TextFilter + 'static> FrameProcessor for TextFilterProcessor<F>

Source§

impl<L: LlmService + 'static> FrameProcessor for LlmProcessor<L>

Source§

impl<M: AudioMixer + 'static> FrameProcessor for MixerProcessor<M>

Source§

impl<R: RealtimeLlm + RealtimeKickoff + 'static> FrameProcessor for RealtimeServiceProcessor<R>

Source§

impl<S: SessionSource + 'static> FrameProcessor for FinalizeProcessor<S>

Source§

impl<S: SttService + 'static> FrameProcessor for SttProcessor<S>

Source§

impl<T: MediaTransport + 'static> FrameProcessor for TransportOutput<T>

Source§

impl<T: TtsService + 'static> FrameProcessor for TtsProcessor<T>

Source§

impl<T: TurnAnalyzer + 'static> FrameProcessor for TurnProcessor<T>

Source§

impl<V: VadAnalyzer + 'static> FrameProcessor for VadProcessor<V>