lib.rs |
C API for mp4parse module.
Parses ISO Base Media Format aka video/mp4 streams.
# Examples
```rust
use std::io::Read;
extern fn buf_read(buf: *mut u8, size: usize, userdata: *mut std::os::raw::c_void) -> isize {
let mut input: &mut std::fs::File = unsafe { &mut *(userdata as *mut _) };
let mut buf = unsafe { std::slice::from_raw_parts_mut(buf, size) };
match input.read(&mut buf) {
Ok(n) => n as isize,
Err(_) => -1,
}
}
let capi_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let mut file = std::fs::File::open(capi_dir + "/../mp4parse/tests/minimal.mp4").unwrap();
let io = mp4parse_capi::Mp4parseIo {
read: Some(buf_read),
userdata: &mut file as *mut _ as *mut std::os::raw::c_void
};
let mut parser = std::ptr::null_mut();
unsafe {
let rv = mp4parse_capi::mp4parse_new(&io, &mut parser);
assert_eq!(rv, mp4parse_capi::Mp4parseStatus::Ok);
assert!(!parser.is_null());
mp4parse_capi::mp4parse_free(parser);
}
``` |
61753 |