Skip to main content

wedeo_filter/
lib.rs

1pub mod graph;
2pub mod registry;
3
4use bitflags::bitflags;
5
6use wedeo_core::error::Result;
7use wedeo_core::media_type::MediaType;
8
9bitflags! {
10    /// Filter flags.
11    #[derive(Debug, Clone, Copy, PartialEq, Eq)]
12    pub struct FilterFlags: u32 {
13        const DYNAMIC_INPUTS       = 1 << 0;
14        const DYNAMIC_OUTPUTS      = 1 << 1;
15        const SLICE_THREADS        = 1 << 2;
16        const METADATA_ONLY        = 1 << 3;
17        const SUPPORT_TIMELINE_GENERIC  = 1 << 16;
18        const SUPPORT_TIMELINE_INTERNAL = 1 << 17;
19    }
20}
21
22/// Filter pad direction.
23#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24pub enum FilterPadDirection {
25    Input,
26    Output,
27}
28
29/// Descriptor for a filter pad (input or output).
30#[derive(Debug, Clone)]
31pub struct FilterPadDescriptor {
32    pub name: &'static str,
33    pub media_type: MediaType,
34    pub direction: FilterPadDirection,
35}
36
37/// Descriptor for a filter type.
38#[derive(Debug, Clone)]
39pub struct FilterDescriptor {
40    pub name: &'static str,
41    pub description: &'static str,
42    pub inputs: &'static [FilterPadDescriptor],
43    pub outputs: &'static [FilterPadDescriptor],
44    pub flags: FilterFlags,
45}
46
47/// Filter trait — the main abstraction for filter implementations.
48pub trait Filter: Send {
49    fn descriptor(&self) -> &FilterDescriptor;
50    fn activate(&mut self) -> Result<()>;
51}