#capi #c-api

mp4parse_capi

Parser for ISO base media file format (mp4)

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

#150 in Images

Download history 23/week @ 2023-06-04 12/week @ 2023-06-11 36/week @ 2023-06-18 28/week @ 2023-06-25 26/week @ 2023-07-02 21/week @ 2023-07-09 43/week @ 2023-07-16 17/week @ 2023-07-23 16/week @ 2023-07-30 26/week @ 2023-08-06 30/week @ 2023-08-13 17/week @ 2023-08-20 34/week @ 2023-08-27 39/week @ 2023-09-03 53/week @ 2023-09-10 21/week @ 2023-09-17

150 downloads per month

MPL-2.0 license

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

~665KB
~12K SLoC