author | Wes Kocher <wkocher@mozilla.com> |
Mon, 19 Oct 2015 15:02:56 -0700 | |
changeset 268387 | ebad4f2326b0743115142e8105f0878000d0f410 |
parent 268386 | c1c69af32aa76b15b16b706d3babfaef2ce0695f |
child 268388 | d61b658a2a1a9ec5abc425b79fbddcbeb1bbb300 |
push id | 66802 |
push user | kwierso@gmail.com |
push date | Mon, 19 Oct 2015 22:03:00 +0000 |
treeherder | mozilla-inbound@ebad4f2326b0 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1215696 |
milestone | 44.0a1 |
backs out | c1c69af32aa76b15b16b706d3babfaef2ce0695f a186c0afb34f1cf5d17ac9b5c959f5f9a434a65f |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
media/libstagefright/binding/MP4Metadata.rs | file | annotate | diff | comparison | revisions | |
media/libstagefright/gtest/TestMP4Rust.cpp | file | annotate | diff | comparison | revisions |
--- a/media/libstagefright/binding/MP4Metadata.rs +++ b/media/libstagefright/binding/MP4Metadata.rs @@ -261,17 +261,18 @@ fn recurse<T: Read>(f: &mut T, h: &BoxHe } } assert!(content.position() == h.size - h.offset); println!("{} -- end", h); Ok(()) } /// Read the contents of a box, including sub boxes. -/// Metadata is accumulated in the passed-through MediaContext struct. +/// Right now it just prints the box value rather than +/// returning anything. 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); match &fourcc_to_string(h.name)[..] { "ftyp" => { let ftyp = try!(read_ftyp(&mut content, &h)); println!("{}", ftyp); }, @@ -323,36 +324,35 @@ pub fn read_box<T: BufRead>(f: &mut T, c }, "hdlr" => { let hdlr = try!(read_hdlr(&mut content, &h)); let track_type = match &fourcc_to_string(hdlr.handler_type)[..] { "vide" => Some(TrackType::Video), "soun" => Some(TrackType::Audio), _ => None }; - // 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!"), - }; + // 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); }, "stsd" => { let track = &context.tracks[context.tracks.len() - 1]; let stsd = try!(read_stsd(&mut content, &h, &track)); println!(" {}", stsd); }, _ => { // Skip the contents of unknown chunks. println!("{} (skipped)", h); - try!(skip_box_content(&mut content, &h)); + try!(skip_box_content(&mut content, &h).and(Ok(()))); }, }; assert!(content.limit() == 0); - println!("read_box context: {}", context); + println!("Parse result: {}", context); Ok(()) // and_then needs a Result to return. }) } /// Entry point for C language callers. /// Take a buffer and call read_box() on it, /// returning the number of detected tracks. #[no_mangle] @@ -368,23 +368,24 @@ pub extern fn read_box_from_buffer(buffe // Wrap the buffer we've been give in a slice. let b = unsafe { slice::from_raw_parts(buffer, size) }; let mut c = Cursor::new(b); // Parse in a subthread. let task = thread::spawn(move || { let mut context = MediaContext { tracks: Vec::new() }; - loop { - match read_box(&mut c, &mut context) { - Ok(_) => {}, - Err(byteorder::Error::UnexpectedEOF) => { break }, - Err(e) => { panic!(e) }, - } - } + 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(); // 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); context.tracks.len() as i32 }); // Catch any panics. task.join().unwrap_or(-1) }
--- a/media/libstagefright/gtest/TestMP4Rust.cpp +++ b/media/libstagefright/gtest/TestMP4Rust.cpp @@ -40,11 +40,11 @@ TEST(rust, MP4Metadata) ASSERT_TRUE(f != nullptr); size_t len = 4096; std::vector<uint8_t> buf(len); size_t read = fread(buf.data(), sizeof(decltype(buf)::value_type), buf.size(), f); buf.resize(read); fclose(f); - int32_t rv = read_box_from_buffer(buf.data(), buf.size()); - EXPECT_EQ(rv, 2); + bool rv = read_box_from_buffer(buf.data(), buf.size()); + EXPECT_EQ(rv, 0); // XFAIL: Should find 2 tracks in the first 4K. }