15 releases (8 breaking)
0.17.0 | May 29, 2023 |
---|---|
0.12.0 | Oct 22, 2021 |
0.11.5 | Jan 19, 2021 |
0.11.2 | Dec 10, 2018 |
0.6.0 | Nov 1, 2016 |
#266 in Video
365KB
8K
SLoC
mp4parse-capi
is a C API that exposes the functionality of mp4parse
.
See the README in the mp4parse-rust repo for more details.
lib.rs
:
C API for mp4parse module.
Parses ISO Base Media Format aka video/mp4 streams.
Examples
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);
}
Dependencies
~660KB
~11K SLoC