ac_ffmpeg_features/
lib.rs1use std::{
2 ffi::CStr,
3 os::raw::{c_char, c_void},
4};
5
6type FeatureCallback = unsafe extern "C" fn(ctx: *mut c_void, feature: *const c_char);
7
8extern "C" {
9 fn get_ffmpeg_features(ctx: *mut c_void, all: u8, cb: FeatureCallback);
10}
11
12pub fn ffmpeg_features(all: bool) -> Vec<String> {
18 let mut res = Vec::new();
19
20 unsafe {
21 get_ffmpeg_features(&mut res as *mut Vec<String> as _, all as _, push_feature);
22 }
23
24 res
25}
26
27unsafe extern "C" fn push_feature(ctx: *mut c_void, feature: *const c_char) {
29 let features = &mut *(ctx as *mut Vec<String>);
30
31 let feature = CStr::from_ptr(feature).to_str().map(String::from);
32
33 if let Ok(f) = feature {
34 features.push(f);
35 }
36}