use crate::{
core::CoreRef,
filter::{FilterDependency, FilterMode},
format::{AudioInfo, VideoInfo},
frame::{Frame, FrameContext},
map::MapRef,
};
pub trait Filter<'core>: Send + Sync + Clone + 'core {
const NAME: &'static str;
const ARGS: &'static str;
const RETURNTYPE: &'static str;
const MODE: FilterMode;
fn from_args(args: &MapRef<'core>, core: &CoreRef<'core>) -> Result<Self, String>
where
Self: Sized;
fn get_dependencies(&self) -> Vec<FilterDependency<'core>>;
fn get_video_info(&self) -> Result<VideoInfo, String> {
let deps = self.get_dependencies();
if let Some(dep) = deps.first() {
match dep.source.video_info() {
Some(vi) => Ok(vi),
None => Err("Input node has no video info".to_string()),
}
} else {
Err("No dependencies and get_video_info not implemented".to_string())
}
}
fn get_audio_info(&self) -> Result<AudioInfo, String> {
let deps = self.get_dependencies();
if let Some(dep) = deps.first() {
match dep.source.audio_info() {
Some(ai) => Ok(ai),
None => Err("Input node has no audio info".to_string()),
}
} else {
Err("No dependencies and get_audio_info not implemented".to_string())
}
}
fn request_input_frames(&self, n: i32, frame_ctx: &FrameContext);
fn process_frame(
&mut self,
n: i32,
_frame_data: &[u8; 4],
frame_ctx: &FrameContext,
core: CoreRef<'core>,
) -> Result<Frame<'core>, String>;
fn cleanup_frame_data(&self, _frame_data: &[u8; 4]) {
}
fn cleanup(&self) {
}
}