pub mod fcall_filter;
pub mod ivr;
pub mod text_filter;
pub mod voicemail;
pub mod wakeword;
#[cfg(test)]
pub(crate) mod test_harness {
use std::sync::atomic::AtomicI64;
use std::sync::Arc;
use std::time::Duration;
use crate::processor::frame::{Direction, Frame};
use crate::processor::runtime::{channel, NORMAL_CHAN_CAP};
use crate::processor::{Envelope, FrameProcessor, Link};
pub(crate) async fn drive(
mut proc: Box<dyn FrameProcessor>,
frames: Vec<Frame>,
direction: Direction,
) -> Vec<Frame> {
let (cap_tx, mut cap_rx) = channel(Arc::from("capture"), NORMAL_CHAN_CAP);
let link = Link {
next: Some(cap_tx.clone()),
prev: Some(cap_tx),
name: Arc::from(proc.name().to_string()),
clock: crate::processor::Clock::new(),
observer: None,
enable_metrics: false,
enable_usage_metrics: false,
ttfb_start: Arc::new(AtomicI64::new(0)),
processing_start: Arc::new(AtomicI64::new(0)),
};
for frame in frames {
let env = Envelope::new(frame, direction);
proc.process_frame(env, &link)
.await
.expect("process_frame errored");
}
let mut out = Vec::new();
loop {
tokio::select! {
biased;
Some(e) = cap_rx.system.recv() => out.push(e.frame),
Some(e) = cap_rx.normal.recv() => out.push(e.frame),
_ = tokio::time::sleep(Duration::from_millis(20)) => break,
}
}
out
}
}