use crate::{Result, VirtualProductionError};
pub struct ForegroundProcessor {
edge_refinement: bool,
}
impl ForegroundProcessor {
pub fn new() -> Result<Self> {
Ok(Self {
edge_refinement: true,
})
}
pub fn process(&mut self, frame: &[u8], width: usize, height: usize) -> Result<Vec<u8>> {
if frame.len() != width * height * 3 {
return Err(VirtualProductionError::Compositing(
"Invalid frame size".to_string(),
));
}
Ok(frame.to_vec())
}
pub fn set_edge_refinement(&mut self, enabled: bool) {
self.edge_refinement = enabled;
}
}
impl Default for ForegroundProcessor {
fn default() -> Self {
Self::new().expect("invariant: ForegroundProcessor::new is infallible")
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_foreground_processor() {
let processor = ForegroundProcessor::new();
assert!(processor.is_ok());
}
}