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::{CStr, CString};
17use std::str::from_utf8_unchecked;
18
19use ffi::*;
20#[cfg(not(feature = "ffmpeg_5_0"))]
21use Error;
22
23#[cfg(not(feature = "ffmpeg_5_0"))]
24pub fn register_all() {
25 unsafe {
26 avfilter_register_all();
27 }
28}
29
30#[cfg(not(feature = "ffmpeg_5_0"))]
31pub fn register(filter: &Filter) -> Result<(), Error> {
32 unsafe {
33 match avfilter_register(filter.as_ptr() as *mut _) {
34 0 => Ok(()),
35 _ => Err(Error::InvalidData),
36 }
37 }
38}
39
40pub fn version() -> u32 {
41 unsafe { avfilter_version() }
42}
43
44pub fn configuration() -> &'static str {
45 unsafe { from_utf8_unchecked(CStr::from_ptr(avfilter_configuration()).to_bytes()) }
46}
47
48pub fn license() -> &'static str {
49 unsafe { from_utf8_unchecked(CStr::from_ptr(avfilter_license()).to_bytes()) }
50}
51
52pub fn find(name: &str) -> Option<Filter> {
53 unsafe {
54 let name: CString = CString::new(name).unwrap();
55 let ptr = avfilter_get_by_name(name.as_ptr());
56
57 if ptr.is_null() {
58 None
59 } else {
60 Some(Filter::wrap(ptr as *mut _))
61 }
62 }
63}
64
65#[cfg(test)]
66mod tests {
67 use super::*;
68
69 #[test]
70 fn test_paditer() {
71 #[cfg(not(feature = "ffmpeg_5_0"))]
72 register_all();
73 assert_eq!(
74 find("overlay")
75 .unwrap()
76 .inputs()
77 .unwrap()
78 .map(|input| input.name().unwrap().to_string())
79 .collect::<Vec<_>>(),
80 vec!("main", "overlay")
81 );
82 }
83}
84