Crate mp4parse_capi

Source
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§

Mp4parseAvifImage
Mp4parseAvifInfo
Mp4parseAvifParser
Mp4parseByteData
Mp4parseFragmentInfo
Mp4parseIo
Mp4parseParser
Mp4parsePsshInfo
Mp4parseSinfInfo
Mp4parseTrackAudioInfo
Mp4parseTrackAudioSampleInfo
Mp4parseTrackInfo
Mp4parseTrackVideoInfo
Mp4parseTrackVideoSampleInfo

Enums§

Mp4ParseEncryptionSchemeType
Mp4parseAvifLoopMode
Mp4parseCodec
Mp4parseStatus
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.
Mp4parseTrackType
OptionalFourCc
ParseStrictness

Functions§

mp4parse_avif_free
Free an Mp4parseAvifParser* allocated by mp4parse_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 from track.
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 supplied Mp4parseIo.
mp4parse_free
Free an Mp4parseParser* allocated by mp4parse_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 from track.
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 for track.
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 for track.
mp4parse_get_track_video_info
Fill the supplied Mp4parseTrackVideoInfo with metadata for track.
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 supplied Mp4parseIo and parse the content from the Mp4parseIo argument until EOF or error.