mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1215696 - Update mp4parse-rust to v0.1.1. r=kinetik
Change is just to loop over the input buffer in read_box_from_buffer() so we parse the entire contents instead of just the first box. 'extern crate byteorder' converted to 'mod byteorder'.
This commit is contained in:
parent
3ae91b2ba9
commit
2e0c0bdbde
@ -266,8 +266,7 @@ fn recurse<T: Read>(f: &mut T, h: &BoxHeader, context: &mut MediaContext) -> byt
|
||||
}
|
||||
|
||||
/// Read the contents of a box, including sub boxes.
|
||||
/// Right now it just prints the box value rather than
|
||||
/// returning anything.
|
||||
/// Metadata is accumulated in the passed-through MediaContext struct.
|
||||
pub fn read_box<T: BufRead>(f: &mut T, context: &mut MediaContext) -> byteorder::Result<()> {
|
||||
read_box_header(f).and_then(|h| {
|
||||
let mut content = limit(f, &h);
|
||||
@ -329,11 +328,12 @@ pub fn read_box<T: BufRead>(f: &mut T, context: &mut MediaContext) -> byteorder:
|
||||
"soun" => Some(TrackType::Audio),
|
||||
_ => None
|
||||
};
|
||||
// Ignore unrecognized track types.
|
||||
track_type.map(|track_type|
|
||||
context.tracks.push(Track { track_type: track_type }))
|
||||
.or_else(|| { println!("unknown track type!"); None } );
|
||||
println!(" {}", hdlr);
|
||||
// Save track types with recognized types.
|
||||
match track_type {
|
||||
Some(track_type) =>
|
||||
context.tracks.push(Track { track_type: track_type }),
|
||||
None => println!("unknown track type!"),
|
||||
};
|
||||
},
|
||||
"stsd" => {
|
||||
let track = &context.tracks[context.tracks.len() - 1];
|
||||
@ -343,11 +343,11 @@ pub fn read_box<T: BufRead>(f: &mut T, context: &mut MediaContext) -> byteorder:
|
||||
_ => {
|
||||
// Skip the contents of unknown chunks.
|
||||
println!("{} (skipped)", h);
|
||||
try!(skip_box_content(&mut content, &h).and(Ok(())));
|
||||
try!(skip_box_content(&mut content, &h));
|
||||
},
|
||||
};
|
||||
assert!(content.limit() == 0);
|
||||
println!("Parse result: {}", context);
|
||||
println!("read_box context: {}", context);
|
||||
Ok(()) // and_then needs a Result to return.
|
||||
})
|
||||
}
|
||||
@ -373,14 +373,13 @@ pub extern fn read_box_from_buffer(buffer: *const u8, size: usize) -> i32 {
|
||||
// Parse in a subthread.
|
||||
let task = thread::spawn(move || {
|
||||
let mut context = MediaContext { tracks: Vec::new() };
|
||||
read_box(&mut c, &mut context)
|
||||
.or_else(|e| { match e {
|
||||
// TODO: Catch EOF earlier so we can get the return value.
|
||||
// Catch EOF. We naturally hit it at end-of-input.
|
||||
byteorder::Error::UnexpectedEOF => { Ok(()) },
|
||||
e => { Err(e) },
|
||||
}})
|
||||
.unwrap();
|
||||
loop {
|
||||
match read_box(&mut c, &mut context) {
|
||||
Ok(_) => {},
|
||||
Err(byteorder::Error::UnexpectedEOF) => { break },
|
||||
Err(e) => { panic!(e) },
|
||||
}
|
||||
}
|
||||
// Make sure the track count fits in an i32 so we can use
|
||||
// negative values for failure.
|
||||
assert!(context.tracks.len() < i32::MAX as usize);
|
||||
|
Loading…
Reference in New Issue
Block a user