mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1437351 - Update mp4parse to v0.10.0. r=kinetik
Import v0.10.0 of the mp4parse and mp4parse_capi crates and update dependencies. Reduces library size by removing debug tracing in release builds. Also adds recognition of the ALAC codec, although we don't plan to support it. MozReview-Commit-ID: F1bnotCmbDf --HG-- extra : rebase_source : 55bc014378d7f65fca8af82a9222edd36870b351
This commit is contained in:
parent
68efe6ba72
commit
62e62e57a2
@ -16,17 +16,18 @@ extern "C" {
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum {
|
||||
MP4PARSE_CODEC_UNKNOWN = 0,
|
||||
MP4PARSE_CODEC_AAC = 1,
|
||||
MP4PARSE_CODEC_FLAC = 2,
|
||||
MP4PARSE_CODEC_OPUS = 3,
|
||||
MP4PARSE_CODEC_AVC = 4,
|
||||
MP4PARSE_CODEC_VP9 = 5,
|
||||
MP4PARSE_CODEC_MP3 = 6,
|
||||
MP4PARSE_CODEC_MP4V = 7,
|
||||
MP4PARSE_CODEC_JPEG = 8,
|
||||
MP4PARSE_CODEC_AC3 = 9,
|
||||
MP4PARSE_CODEC_EC3 = 10,
|
||||
MP4PARSE_CODEC_UNKNOWN,
|
||||
MP4PARSE_CODEC_AAC,
|
||||
MP4PARSE_CODEC_FLAC,
|
||||
MP4PARSE_CODEC_OPUS,
|
||||
MP4PARSE_CODEC_AVC,
|
||||
MP4PARSE_CODEC_VP9,
|
||||
MP4PARSE_CODEC_MP3,
|
||||
MP4PARSE_CODEC_MP4V,
|
||||
MP4PARSE_CODEC_JPEG,
|
||||
MP4PARSE_CODEC_AC3,
|
||||
MP4PARSE_CODEC_EC3,
|
||||
MP4PARSE_CODEC_ALAC,
|
||||
} Mp4parseCodec;
|
||||
|
||||
typedef enum {
|
||||
@ -168,11 +169,6 @@ Mp4parseStatus mp4parse_is_fragmented(Mp4parseParser *parser,
|
||||
uint32_t track_id,
|
||||
uint8_t *fragmented);
|
||||
|
||||
/*
|
||||
* Enable `mp4_parser` log.
|
||||
*/
|
||||
void mp4parse_log(bool enable);
|
||||
|
||||
/*
|
||||
* Allocate an `Mp4parseParser*` to read from the supplied `Mp4parseIo`.
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mp4parse"
|
||||
version = "0.9.1"
|
||||
version = "0.10.0"
|
||||
authors = [
|
||||
"Ralph Giles <giles@mozilla.com>",
|
||||
"Matthew Gregan <kinetik@flim.org>",
|
||||
@ -21,11 +21,11 @@ exclude = [
|
||||
|
||||
|
||||
[dependencies]
|
||||
byteorder = "1.0.0"
|
||||
byteorder = "1.2.1"
|
||||
bitreader = { version = "0.3.0" }
|
||||
num-traits = "0.1.37"
|
||||
num-traits = "0.2.0"
|
||||
mp4parse_fallible = { version = "0.0.1", optional = true }
|
||||
log = "0.4"
|
||||
|
||||
[dev-dependencies]
|
||||
test-assembler = "0.1.2"
|
||||
|
||||
|
@ -138,4 +138,5 @@ box_database!(
|
||||
MP3AudioSampleEntry 0x2e6d7033, // ".mp3" - from F4V.
|
||||
CompositionOffsetBox 0x63747473, // "ctts"
|
||||
LPCMAudioSampleEntry 0x6C70636D, // "lpcm" - quicktime atom
|
||||
ALACSpecificBox 0x616C6163, // "alac" - Also used by ALACSampleEntry
|
||||
);
|
||||
|
@ -6,6 +6,9 @@
|
||||
#[cfg(feature = "fuzz")]
|
||||
extern crate afl;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
extern crate byteorder;
|
||||
extern crate bitreader;
|
||||
extern crate num_traits;
|
||||
@ -36,25 +39,6 @@ const BUF_SIZE_LIMIT: usize = 1024 * 1024;
|
||||
// frame per table entry in 30 fps.
|
||||
const TABLE_SIZE_LIMIT: u32 = 30 * 60 * 60 * 24 * 7;
|
||||
|
||||
static DEBUG_MODE: std::sync::atomic::AtomicBool = std::sync::atomic::ATOMIC_BOOL_INIT;
|
||||
|
||||
pub fn set_debug_mode(mode: bool) {
|
||||
DEBUG_MODE.store(mode, std::sync::atomic::Ordering::SeqCst);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn get_debug_mode() -> bool {
|
||||
DEBUG_MODE.load(std::sync::atomic::Ordering::Relaxed)
|
||||
}
|
||||
|
||||
macro_rules! log {
|
||||
($($args:tt)*) => (
|
||||
if get_debug_mode() {
|
||||
println!( $( $args )* );
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: vec_push() and vec_reserve() needs to be replaced when Rust supports
|
||||
// fallible memory allocation in raw_vec.
|
||||
#[allow(unreachable_code)]
|
||||
@ -316,6 +300,7 @@ pub enum AudioCodecSpecific {
|
||||
ES_Descriptor(ES_Descriptor),
|
||||
FLACSpecificBox(FLACSpecificBox),
|
||||
OpusSpecificBox(OpusSpecificBox),
|
||||
ALACSpecificBox(ALACSpecificBox),
|
||||
MP3,
|
||||
LPCM,
|
||||
}
|
||||
@ -392,6 +377,13 @@ pub struct OpusSpecificBox {
|
||||
channel_mapping_table: Option<ChannelMappingTable>,
|
||||
}
|
||||
|
||||
/// Represent an ALACSpecificBox 'alac'
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ALACSpecificBox {
|
||||
version: u8,
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MovieExtendsBox {
|
||||
pub fragment_duration: Option<MediaScaledTime>,
|
||||
@ -464,6 +456,7 @@ pub enum CodecType {
|
||||
EncryptedVideo,
|
||||
EncryptedAudio,
|
||||
LPCM, // QT
|
||||
ALAC,
|
||||
}
|
||||
|
||||
impl Default for CodecType {
|
||||
@ -573,7 +566,7 @@ impl<'a, T: Read> Drop for BMFFBox<'a, T> {
|
||||
fn drop(&mut self) {
|
||||
if self.content.limit() > 0 {
|
||||
let name: FourCC = From::from(self.head.name);
|
||||
log!("Dropping {} bytes in '{}'", self.content.limit(), name);
|
||||
debug!("Dropping {} bytes in '{}'", self.content.limit(), name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -627,7 +620,7 @@ fn skip_box_content<T: Read>(src: &mut BMFFBox<T>) -> Result<()> {
|
||||
// Skip the contents of unknown chunks.
|
||||
let to_skip = {
|
||||
let header = src.get_header();
|
||||
log!("{:?} (skipped)", header);
|
||||
debug!("{:?} (skipped)", header);
|
||||
(header.size - header.offset) as usize
|
||||
};
|
||||
assert_eq!(to_skip, src.bytes_left());
|
||||
@ -639,7 +632,7 @@ fn skip_box_remain<T: Read>(src: &mut BMFFBox<T>) -> Result<()> {
|
||||
let remain = {
|
||||
let header = src.get_header();
|
||||
let len = src.bytes_left();
|
||||
log!("remain {} (skipped) in {:?}", len, header);
|
||||
debug!("remain {} (skipped) in {:?}", len, header);
|
||||
len
|
||||
};
|
||||
skip(src, remain)
|
||||
@ -648,7 +641,7 @@ fn skip_box_remain<T: Read>(src: &mut BMFFBox<T>) -> Result<()> {
|
||||
macro_rules! check_parser_state {
|
||||
( $src:expr ) => {
|
||||
if $src.limit() > 0 {
|
||||
log!("bad parser state: {} content bytes left", $src.limit());
|
||||
debug!("bad parser state: {} content bytes left", $src.limit());
|
||||
return Err(Error::InvalidData("unread box content or bad parser sync"));
|
||||
}
|
||||
}
|
||||
@ -684,7 +677,7 @@ pub fn read_mp4<T: Read>(f: &mut T, context: &mut MediaContext) -> Result<()> {
|
||||
BoxType::FileTypeBox => {
|
||||
let ftyp = read_ftyp(&mut b)?;
|
||||
found_ftyp = true;
|
||||
log!("{:?}", ftyp);
|
||||
debug!("{:?}", ftyp);
|
||||
}
|
||||
BoxType::MovieBox => {
|
||||
read_moov(&mut b, context)?;
|
||||
@ -694,7 +687,7 @@ pub fn read_mp4<T: Read>(f: &mut T, context: &mut MediaContext) -> Result<()> {
|
||||
};
|
||||
check_parser_state!(b.content);
|
||||
if found_moov {
|
||||
log!("found moov {}, could stop pure 'moov' parser now", if found_ftyp {
|
||||
debug!("found moov {}, could stop pure 'moov' parser now", if found_ftyp {
|
||||
"and ftyp"
|
||||
} else {
|
||||
"but no ftyp"
|
||||
@ -728,7 +721,7 @@ fn read_moov<T: Read>(f: &mut BMFFBox<T>, context: &mut MediaContext) -> Result<
|
||||
BoxType::MovieHeaderBox => {
|
||||
let (mvhd, timescale) = parse_mvhd(&mut b)?;
|
||||
context.timescale = timescale;
|
||||
log!("{:?}", mvhd);
|
||||
debug!("{:?}", mvhd);
|
||||
}
|
||||
BoxType::TrackBox => {
|
||||
let mut track = Track::new(context.tracks.len());
|
||||
@ -737,12 +730,12 @@ fn read_moov<T: Read>(f: &mut BMFFBox<T>, context: &mut MediaContext) -> Result<
|
||||
}
|
||||
BoxType::MovieExtendsBox => {
|
||||
let mvex = read_mvex(&mut b)?;
|
||||
log!("{:?}", mvex);
|
||||
debug!("{:?}", mvex);
|
||||
context.mvex = Some(mvex);
|
||||
}
|
||||
BoxType::ProtectionSystemSpecificHeaderBox => {
|
||||
let pssh = read_pssh(&mut b)?;
|
||||
log!("{:?}", pssh);
|
||||
debug!("{:?}", pssh);
|
||||
vec_push(&mut context.psshs, pssh)?;
|
||||
}
|
||||
_ => skip_box_content(&mut b)?,
|
||||
@ -825,7 +818,7 @@ fn read_trak<T: Read>(f: &mut BMFFBox<T>, track: &mut Track) -> Result<()> {
|
||||
let tkhd = read_tkhd(&mut b)?;
|
||||
track.track_id = Some(tkhd.track_id);
|
||||
track.tkhd = Some(tkhd.clone());
|
||||
log!("{:?}", tkhd);
|
||||
debug!("{:?}", tkhd);
|
||||
}
|
||||
BoxType::EditBox => read_edts(&mut b, track)?,
|
||||
BoxType::MediaBox => read_mdia(&mut b, track)?,
|
||||
@ -860,7 +853,7 @@ fn read_edts<T: Read>(f: &mut BMFFBox<T>, track: &mut Track) -> Result<()> {
|
||||
}
|
||||
track.media_time = Some(TrackScaledTime::<u64>(elst.edits[idx].media_time as u64,
|
||||
track.id));
|
||||
log!("{:?}", elst);
|
||||
debug!("{:?}", elst);
|
||||
}
|
||||
_ => skip_box_content(&mut b)?,
|
||||
};
|
||||
@ -890,7 +883,7 @@ fn read_mdia<T: Read>(f: &mut BMFFBox<T>, track: &mut Track) -> Result<()> {
|
||||
let (mdhd, duration, timescale) = parse_mdhd(&mut b, track)?;
|
||||
track.duration = duration;
|
||||
track.timescale = timescale;
|
||||
log!("{:?}", mdhd);
|
||||
debug!("{:?}", mdhd);
|
||||
}
|
||||
BoxType::HandlerBox => {
|
||||
let hdlr = read_hdlr(&mut b)?;
|
||||
@ -900,7 +893,7 @@ fn read_mdia<T: Read>(f: &mut BMFFBox<T>, track: &mut Track) -> Result<()> {
|
||||
"soun" => track.track_type = TrackType::Audio,
|
||||
_ => (),
|
||||
}
|
||||
log!("{:?}", hdlr);
|
||||
debug!("{:?}", hdlr);
|
||||
}
|
||||
BoxType::MediaInformationBox => read_minf(&mut b, track)?,
|
||||
_ => skip_box_content(&mut b)?,
|
||||
@ -928,41 +921,41 @@ fn read_stbl<T: Read>(f: &mut BMFFBox<T>, track: &mut Track) -> Result<()> {
|
||||
match b.head.name {
|
||||
BoxType::SampleDescriptionBox => {
|
||||
let stsd = read_stsd(&mut b, track)?;
|
||||
log!("{:?}", stsd);
|
||||
debug!("{:?}", stsd);
|
||||
}
|
||||
BoxType::TimeToSampleBox => {
|
||||
let stts = read_stts(&mut b)?;
|
||||
log!("{:?}", stts);
|
||||
debug!("{:?}", stts);
|
||||
track.stts = Some(stts);
|
||||
}
|
||||
BoxType::SampleToChunkBox => {
|
||||
let stsc = read_stsc(&mut b)?;
|
||||
log!("{:?}", stsc);
|
||||
debug!("{:?}", stsc);
|
||||
track.stsc = Some(stsc);
|
||||
}
|
||||
BoxType::SampleSizeBox => {
|
||||
let stsz = read_stsz(&mut b)?;
|
||||
log!("{:?}", stsz);
|
||||
debug!("{:?}", stsz);
|
||||
track.stsz = Some(stsz);
|
||||
}
|
||||
BoxType::ChunkOffsetBox => {
|
||||
let stco = read_stco(&mut b)?;
|
||||
log!("{:?}", stco);
|
||||
debug!("{:?}", stco);
|
||||
track.stco = Some(stco);
|
||||
}
|
||||
BoxType::ChunkLargeOffsetBox => {
|
||||
let co64 = read_co64(&mut b)?;
|
||||
log!("{:?}", co64);
|
||||
debug!("{:?}", co64);
|
||||
track.stco = Some(co64);
|
||||
}
|
||||
BoxType::SyncSampleBox => {
|
||||
let stss = read_stss(&mut b)?;
|
||||
log!("{:?}", stss);
|
||||
debug!("{:?}", stss);
|
||||
track.stss = Some(stss);
|
||||
}
|
||||
BoxType::CompositionOffsetBox => {
|
||||
let ctts = read_ctts(&mut b)?;
|
||||
log!("{:?}", ctts);
|
||||
debug!("{:?}", ctts);
|
||||
track.ctts = Some(ctts);
|
||||
}
|
||||
_ => skip_box_content(&mut b)?,
|
||||
@ -1409,7 +1402,7 @@ fn find_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
|
||||
read_ds_descriptor(descriptor, esds)?;
|
||||
},
|
||||
_ => {
|
||||
log!("Unsupported descriptor, tag {}", tag);
|
||||
debug!("Unsupported descriptor, tag {}", tag);
|
||||
},
|
||||
}
|
||||
|
||||
@ -1462,7 +1455,7 @@ fn read_ds_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
|
||||
// When channel_counts is 0, we need to parse the program_config_element
|
||||
// to calculate the channel counts.
|
||||
if channel_counts == 0 {
|
||||
log!("Parsing program_config_element for channel counts");
|
||||
debug!("Parsing program_config_element for channel counts");
|
||||
|
||||
bit_reader.skip(4)?; // element_instance_tag
|
||||
bit_reader.skip(2)?; // object_type
|
||||
@ -1689,6 +1682,28 @@ pub fn serialize_opus_header<W: byteorder::WriteBytesExt + std::io::Write>(opus:
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Parse `ALACSpecificBox`.
|
||||
fn read_alac<T: Read>(src: &mut BMFFBox<T>) -> Result<ALACSpecificBox> {
|
||||
let (version, flags) = read_fullbox_extra(src)?;
|
||||
if version != 0 {
|
||||
return Err(Error::Unsupported("unknown alac (ALAC) version"));
|
||||
}
|
||||
if flags != 0 {
|
||||
return Err(Error::InvalidData("no-zero alac (ALAC) flags"));
|
||||
}
|
||||
|
||||
let length = src.bytes_left();
|
||||
if length != 24 && length != 48 {
|
||||
return Err(Error::InvalidData("ALACSpecificBox magic cookie is the wrong size"));
|
||||
}
|
||||
let data = read_buf(src, length)?;
|
||||
|
||||
Ok(ALACSpecificBox {
|
||||
version: version,
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
/// Parse a hdlr box.
|
||||
fn read_hdlr<T: Read>(src: &mut BMFFBox<T>) -> Result<HandlerBox> {
|
||||
let (_, _) = read_fullbox_extra(src)?;
|
||||
@ -1719,7 +1734,7 @@ fn read_video_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<(CodecType,
|
||||
BoxType::VP9SampleEntry => CodecType::VP9,
|
||||
BoxType::ProtectedVisualSampleEntry => CodecType::EncryptedVideo,
|
||||
_ => {
|
||||
log!("Unsupported video codec, box {:?} found", name);
|
||||
debug!("Unsupported video codec, box {:?} found", name);
|
||||
CodecType::Unknown
|
||||
}
|
||||
};
|
||||
@ -1753,7 +1768,7 @@ fn read_video_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<(CodecType,
|
||||
}
|
||||
let avcc_size = b.head.size - b.head.offset;
|
||||
let avcc = read_buf(&mut b.content, avcc_size as usize)?;
|
||||
log!("{:?} (avcc)", avcc);
|
||||
debug!("{:?} (avcc)", avcc);
|
||||
// TODO(kinetik): Parse avcC box? For now we just stash the data.
|
||||
codec_specific = Some(VideoCodecSpecific::AVCConfig(avcc));
|
||||
}
|
||||
@ -1781,11 +1796,11 @@ fn read_video_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<(CodecType,
|
||||
return Err(Error::InvalidData("malformed video sample entry"));
|
||||
}
|
||||
let sinf = read_sinf(&mut b)?;
|
||||
log!("{:?} (sinf)", sinf);
|
||||
debug!("{:?} (sinf)", sinf);
|
||||
vec_push(&mut protection_info, sinf)?;
|
||||
}
|
||||
_ => {
|
||||
log!("Unsupported video codec, box {:?} found", b.head.name);
|
||||
debug!("Unsupported video codec, box {:?} found", b.head.name);
|
||||
skip_box_content(&mut b)?;
|
||||
}
|
||||
}
|
||||
@ -1900,6 +1915,15 @@ fn read_audio_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<(CodecType,
|
||||
codec_type = CodecType::Opus;
|
||||
codec_specific = Some(AudioCodecSpecific::OpusSpecificBox(dops));
|
||||
}
|
||||
BoxType::ALACSpecificBox => {
|
||||
if name != BoxType::ALACSpecificBox ||
|
||||
codec_specific.is_some() {
|
||||
return Err(Error::InvalidData("malformed audio sample entry"));
|
||||
}
|
||||
let alac = read_alac(&mut b)?;
|
||||
codec_type = CodecType::ALAC;
|
||||
codec_specific = Some(AudioCodecSpecific::ALACSpecificBox(alac));
|
||||
}
|
||||
BoxType::QTWaveAtom => {
|
||||
let qt_esds = read_qt_wave_atom(&mut b)?;
|
||||
codec_type = qt_esds.audio_codec;
|
||||
@ -1910,12 +1934,12 @@ fn read_audio_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<(CodecType,
|
||||
return Err(Error::InvalidData("malformed audio sample entry"));
|
||||
}
|
||||
let sinf = read_sinf(&mut b)?;
|
||||
log!("{:?} (sinf)", sinf);
|
||||
debug!("{:?} (sinf)", sinf);
|
||||
codec_type = CodecType::EncryptedAudio;
|
||||
vec_push(&mut protection_info, sinf)?;
|
||||
}
|
||||
_ => {
|
||||
log!("Unsupported audio codec, box {:?} found", b.head.name);
|
||||
debug!("Unsupported audio codec, box {:?} found", b.head.name);
|
||||
skip_box_content(&mut b)?;
|
||||
}
|
||||
}
|
||||
@ -1968,7 +1992,7 @@ fn read_stsd<T: Read>(src: &mut BMFFBox<T>, track: &mut Track) -> Result<SampleD
|
||||
if track.data.is_none() {
|
||||
track.data = Some(description.clone());
|
||||
} else {
|
||||
log!("** don't know how to handle multiple descriptions **");
|
||||
debug!("** don't know how to handle multiple descriptions **");
|
||||
}
|
||||
vec_push(&mut descriptions, description)?;
|
||||
check_parser_state!(b.content);
|
||||
|
@ -653,6 +653,28 @@ fn serialize_opus_header() {
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_alac() {
|
||||
let mut stream = make_box(BoxSize::Auto, b"alac", |s| {
|
||||
s.append_repeated(0, 6) // reserved
|
||||
.B16(1) // data reference index
|
||||
.B32(0) // reserved
|
||||
.B32(0) // reserved
|
||||
.B16(2) // channel count
|
||||
.B16(16) // bits per sample
|
||||
.B16(0) // pre_defined
|
||||
.B16(0) // reserved
|
||||
.B32(44100 << 16) // Sample rate
|
||||
.append_bytes(&make_fullbox(BoxSize::Auto, b"alac", 0, |s| {
|
||||
s.append_bytes(&vec![0xfa; 24])
|
||||
}).into_inner())
|
||||
});
|
||||
let mut iter = super::BoxIter::new(&mut stream);
|
||||
let mut stream = iter.next_box().unwrap().unwrap();
|
||||
let r = super::read_audio_sample_entry(&mut stream);
|
||||
assert!(r.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn avcc_limit() {
|
||||
let mut stream = make_box(BoxSize::Auto, b"avc1", |s| {
|
||||
|
@ -96,6 +96,10 @@ fn public_api() {
|
||||
assert!(opus.version > 0);
|
||||
"Opus"
|
||||
}
|
||||
mp4::AudioCodecSpecific::ALACSpecificBox(alac) => {
|
||||
assert!(alac.data.len() == 24 || alac.data.len() == 48);
|
||||
"ALAC"
|
||||
}
|
||||
mp4::AudioCodecSpecific::MP3 => {
|
||||
"MP3"
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mp4parse_capi"
|
||||
version = "0.9.1"
|
||||
version = "0.10.0"
|
||||
authors = [
|
||||
"Ralph Giles <giles@mozilla.com>",
|
||||
"Matthew Gregan <kinetik@flim.org>",
|
||||
@ -18,14 +18,13 @@ exclude = [
|
||||
"*.mp4",
|
||||
]
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "https://github.com/mozilla/mp4parse-rust" }
|
||||
build = false
|
||||
|
||||
[dependencies]
|
||||
byteorder = "1.0.0"
|
||||
byteorder = "1.2.1"
|
||||
log = "0.4"
|
||||
|
||||
# To enable fallible memory allocation, add 'features = ["mp4parse_fallible"]'
|
||||
# in mp4parse brace.
|
||||
mp4parse = {version = "0.9.1", path = "../mp4parse", features = ["mp4parse_fallible"]}
|
||||
num-traits = "0.1.37"
|
||||
|
||||
mp4parse = {version = "0.10.0", path = "../mp4parse", features = ["mp4parse_fallible"]}
|
||||
num-traits = "0.2.0"
|
||||
|
@ -98,6 +98,7 @@ pub enum Mp4parseCodec {
|
||||
Jpeg, // for QT JPEG atom in video track
|
||||
Ac3,
|
||||
Ec3,
|
||||
Alac,
|
||||
}
|
||||
|
||||
impl Default for Mp4parseCodec {
|
||||
@ -297,12 +298,6 @@ pub unsafe extern fn mp4parse_free(parser: *mut Mp4parseParser) {
|
||||
let _ = Box::from_raw(parser);
|
||||
}
|
||||
|
||||
/// Enable `mp4_parser` log.
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn mp4parse_log(enable: bool) {
|
||||
mp4parse::set_debug_mode(enable);
|
||||
}
|
||||
|
||||
/// Run the `Mp4parseParser*` allocated by `mp4parse_new()` until EOF or error.
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn mp4parse_read(parser: *mut Mp4parseParser) -> Mp4parseStatus {
|
||||
@ -429,6 +424,8 @@ pub unsafe extern fn mp4parse_get_track_info(parser: *mut Mp4parseParser, track_
|
||||
Mp4parseCodec::Unknown,
|
||||
AudioCodecSpecific::MP3 =>
|
||||
Mp4parseCodec::Mp3,
|
||||
AudioCodecSpecific::ALACSpecificBox(_) =>
|
||||
Mp4parseCodec::Alac,
|
||||
},
|
||||
Some(SampleEntry::Video(ref video)) => match video.codec_specific {
|
||||
VideoCodecSpecific::VPxConfig(_) =>
|
||||
@ -565,6 +562,10 @@ pub unsafe extern fn mp4parse_get_track_audio_info(parser: *mut Mp4parseParser,
|
||||
}
|
||||
}
|
||||
}
|
||||
AudioCodecSpecific::ALACSpecificBox(ref alac) => {
|
||||
(*info).extra_data.length = alac.data.len() as u32;
|
||||
(*info).extra_data.data = alac.data.as_ptr();
|
||||
}
|
||||
AudioCodecSpecific::MP3 | AudioCodecSpecific::LPCM => (),
|
||||
}
|
||||
|
||||
@ -1141,14 +1142,6 @@ fn new_parser() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "assertion failed")]
|
||||
fn free_null_parser() {
|
||||
unsafe {
|
||||
mp4parse_free(std::ptr::null_mut());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_track_count_null_parser() {
|
||||
unsafe {
|
||||
|
20
toolkit/library/gtest/rust/Cargo.lock
generated
20
toolkit/library/gtest/rust/Cargo.lock
generated
@ -618,7 +618,7 @@ dependencies = [
|
||||
"encoding_glue 0.1.0",
|
||||
"geckoservo 0.0.1",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mp4parse_capi 0.9.1",
|
||||
"mp4parse_capi 0.10.0",
|
||||
"netwerk_helper 0.0.1",
|
||||
"nserror 0.1.0",
|
||||
"nsstring 0.1.0",
|
||||
@ -870,12 +870,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "mp4parse"
|
||||
version = "0.9.1"
|
||||
version = "0.10.0"
|
||||
dependencies = [
|
||||
"bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mp4parse_fallible 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -884,11 +885,12 @@ version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "mp4parse_capi"
|
||||
version = "0.9.1"
|
||||
version = "0.10.0"
|
||||
dependencies = [
|
||||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mp4parse 0.9.1",
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mp4parse 0.10.0",
|
||||
"num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -960,6 +962,11 @@ name = "num-traits"
|
||||
version = "0.1.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.7.0"
|
||||
@ -1825,6 +1832,7 @@ dependencies = [
|
||||
"checksum nom 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce"
|
||||
"checksum num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "d1452e8b06e448a07f0e6ebb0bb1d92b8890eea63288c0b627331d53514d0fba"
|
||||
"checksum num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cacfcab5eb48250ee7d0c7896b51a2c5eec99c1feea5f32025635f5ae4b00070"
|
||||
"checksum num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7de20f146db9d920c45ee8ed8f71681fd9ade71909b48c3acbd766aa504cf10"
|
||||
"checksum num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "514f0d73e64be53ff320680ca671b64fe3fb91da01e1ae2ddc99eb51d453b20d"
|
||||
"checksum ordered-float 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "da12c96037889ae0be29dd2bdd260e5a62a7df24e6466d5a15bb8131c1c200a8"
|
||||
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
|
||||
|
20
toolkit/library/rust/Cargo.lock
generated
20
toolkit/library/rust/Cargo.lock
generated
@ -616,7 +616,7 @@ dependencies = [
|
||||
"encoding_glue 0.1.0",
|
||||
"geckoservo 0.0.1",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mp4parse_capi 0.9.1",
|
||||
"mp4parse_capi 0.10.0",
|
||||
"netwerk_helper 0.0.1",
|
||||
"nserror 0.1.0",
|
||||
"nsstring 0.1.0",
|
||||
@ -868,21 +868,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "mp4parse"
|
||||
version = "0.9.1"
|
||||
version = "0.10.0"
|
||||
dependencies = [
|
||||
"bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mp4parse_fallible 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mp4parse_capi"
|
||||
version = "0.9.1"
|
||||
version = "0.10.0"
|
||||
dependencies = [
|
||||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mp4parse 0.9.1",
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mp4parse 0.10.0",
|
||||
"num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -947,6 +949,11 @@ name = "num-traits"
|
||||
version = "0.1.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.7.0"
|
||||
@ -1828,6 +1835,7 @@ dependencies = [
|
||||
"checksum nom 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce"
|
||||
"checksum num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "d1452e8b06e448a07f0e6ebb0bb1d92b8890eea63288c0b627331d53514d0fba"
|
||||
"checksum num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cacfcab5eb48250ee7d0c7896b51a2c5eec99c1feea5f32025635f5ae4b00070"
|
||||
"checksum num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7de20f146db9d920c45ee8ed8f71681fd9ade71909b48c3acbd766aa504cf10"
|
||||
"checksum num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "514f0d73e64be53ff320680ca671b64fe3fb91da01e1ae2ddc99eb51d453b20d"
|
||||
"checksum ordered-float 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "da12c96037889ae0be29dd2bdd260e5a62a7df24e6466d5a15bb8131c1c200a8"
|
||||
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
|
||||
|
Loading…
Reference in New Issue
Block a user