Expand description
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);
}
Structs§
- Mp4parse
Avif Image - Mp4parse
Avif Info - Mp4parse
Avif Parser - Mp4parse
Byte Data - Mp4parse
Fragment Info - Mp4parse
Io - Mp4parse
Parser - Mp4parse
Pssh Info - Mp4parse
Sinf Info - Mp4parse
Track Audio Info - Mp4parse
Track Audio Sample Info - Mp4parse
Track Info - Mp4parse
Track Video Info - Mp4parse
Track Video Sample Info
Enums§
- Mp4Parse
Encryption Scheme Type - Mp4parse
Avif Loop Mode - Mp4parse
Codec - Mp4parse
Status - The return value to the C API
Any detail that needs to be communicated to the caller must be encoded here
since the
Error
type’s associated data is part of the FFI. - Mp4parse
Track Type - Optional
Four Cc - Parse
Strictness
Functions§
- mp4parse_
avif_ ⚠free - Free an
Mp4parseAvifParser*
allocated bymp4parse_avif_new()
. - mp4parse_
avif_ ⚠get_ image - Return a pointer to the primary item parsed by previous
mp4parse_avif_new()
call. - mp4parse_
avif_ get_ image_ safe - mp4parse_
avif_ ⚠get_ indice_ table - Fill the supplied
Mp4parseByteData
with index information fromtrack
. - mp4parse_
avif_ ⚠get_ info - Return a struct containing meta information read by previous
mp4parse_avif_new()
call. - mp4parse_
avif_ ⚠new - Allocate an
Mp4parseAvifParser*
to read from the suppliedMp4parseIo
. - mp4parse_
free ⚠ - Free an
Mp4parseParser*
allocated bymp4parse_new()
. - mp4parse_
get_ ⚠fragment_ info - Fill the supplied
Mp4parseFragmentInfo
with metadata from fragmented file. - mp4parse_
get_ ⚠indice_ table - Fill the supplied
Mp4parseByteData
with index information fromtrack
. - mp4parse_
get_ ⚠pssh_ info - Get ‘pssh’ system id and ‘pssh’ box content for eme playback.
- mp4parse_
get_ ⚠track_ audio_ info - Fill the supplied
Mp4parseTrackAudioInfo
with metadata fortrack
. - mp4parse_
get_ ⚠track_ count - Return the number of tracks parsed by previous
mp4parse_read()
call. - mp4parse_
get_ ⚠track_ info - Fill the supplied
Mp4parseTrackInfo
with metadata fortrack
. - mp4parse_
get_ ⚠track_ video_ info - Fill the supplied
Mp4parseTrackVideoInfo
with metadata fortrack
. - mp4parse_
is_ ⚠fragmented - Determine if an mp4 file is fragmented. A fragmented file needs mvex table and contains no data in stts, stsc, and stco boxes.
- mp4parse_
new ⚠ - Allocate an
Mp4parseParser*
to read from the suppliedMp4parseIo
and parse the content from theMp4parseIo
argument until EOF or error.