Skip to main content

ffmpeg_the_third/filter/
mod.rs

1pub mod flag;
2pub use self::flag::Flags;
3
4pub mod pad;
5pub use self::pad::Pad;
6
7pub mod filter;
8pub use self::filter::Filter;
9
10pub mod context;
11pub use self::context::{Context, Sink, Source};
12
13pub mod graph;
14pub use self::graph::Graph;
15
16use std::ffi::CString;
17
18use crate::ffi::*;
19use crate::utils;
20
21pub fn version() -> u32 {
22    unsafe { avfilter_version() }
23}
24
25pub fn configuration() -> &'static str {
26    unsafe { utils::str_from_c_ptr(avfilter_configuration()) }
27}
28
29pub fn license() -> &'static str {
30    unsafe { utils::str_from_c_ptr(avfilter_license()) }
31}
32
33pub fn find(name: &str) -> Option<Filter> {
34    unsafe {
35        let name = CString::new(name).unwrap();
36        let ptr = avfilter_get_by_name(name.as_ptr());
37
38        if ptr.is_null() {
39            None
40        } else {
41            Some(Filter::wrap(ptr as *mut _))
42        }
43    }
44}
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_paditer() {
52        assert_eq!(
53            find("overlay")
54                .unwrap()
55                .inputs()
56                .unwrap()
57                .map(|input| input.name().unwrap().to_string())
58                .collect::<Vec<_>>(),
59            vec!("main", "overlay")
60        );
61    }
62}