Bug 1415807 - remove 'chan' box becuase it could exist with other codec types. r?kinetik
MozReview-Commit-ID: EGjjIZQHgYO
--- a/media/libstagefright/binding/mp4parse/src/boxes.rs
+++ b/media/libstagefright/binding/mp4parse/src/boxes.rs
@@ -132,11 +132,10 @@ box_database!(
QTWaveAtom 0x77617665, // "wave" - quicktime atom
ProtectionSystemSpecificHeaderBox 0x70737368, // "pssh"
SchemeInformationBox 0x73636869, // "schi"
TrackEncryptionBox 0x74656e63, // "tenc"
ProtectionSchemeInformationBox 0x73696e66, // "sinf"
OriginalFormatBox 0x66726d61, // "frma"
MP3AudioSampleEntry 0x2e6d7033, // ".mp3" - from F4V.
CompositionOffsetBox 0x63747473, // "ctts"
- AudioChannelLayoutAtom 0x6368616E, // "chan" - quicktime atom
LPCMAudioSampleEntry 0x6C70636D, // "lpcm" - quicktime atom
);
--- a/media/libstagefright/binding/mp4parse/src/lib.rs
+++ b/media/libstagefright/binding/mp4parse/src/lib.rs
@@ -1858,22 +1858,21 @@ fn read_audio_sample_entry<T: Read>(src:
skip(src, 4)?;
samplerate = f64::from_bits(be_u64(src)?);
channelcount = be_u32(src)?;
skip(src, 20)?;
}
_ => return Err(Error::Unsupported("unsupported non-isom audio sample entry")),
}
- let mut codec_type = CodecType::Unknown;
- let mut codec_specific = None;
- if name == BoxType::MP3AudioSampleEntry {
- codec_type = CodecType::MP3;
- codec_specific = Some(AudioCodecSpecific::MP3);
- }
+ let (mut codec_type, mut codec_specific) = match name {
+ BoxType::MP3AudioSampleEntry => (CodecType::MP3, Some(AudioCodecSpecific::MP3)),
+ BoxType::LPCMAudioSampleEntry => (CodecType::LPCM, Some(AudioCodecSpecific::LPCM)),
+ _ => (CodecType::Unknown, None),
+ };
let mut protection_info = Vec::new();
let mut iter = src.box_iter();
while let Some(mut b) = iter.next_box()? {
match b.head.name {
BoxType::ESDBox => {
if (name != BoxType::MP4AudioSampleEntry &&
name != BoxType::ProtectedAudioSampleEntry) ||
codec_specific.is_some() {
@@ -1911,25 +1910,16 @@ fn read_audio_sample_entry<T: Read>(src:
if name != BoxType::ProtectedAudioSampleEntry {
return Err(Error::InvalidData("malformed audio sample entry"));
}
let sinf = read_sinf(&mut b)?;
log!("{:?} (sinf)", sinf);
codec_type = CodecType::EncryptedAudio;
vec_push(&mut protection_info, sinf)?;
}
- BoxType::AudioChannelLayoutAtom => {
- if name != BoxType::LPCMAudioSampleEntry {
- return Err(Error::InvalidData("malformed audio sample entry"));
- }
- // skip 'chan' for now.
- skip_box_content(&mut b)?;
- codec_type = CodecType::LPCM;
- codec_specific = Some(AudioCodecSpecific::LPCM);
- }
_ => {
log!("Unsupported audio codec, box {:?} found", b.head.name);
skip_box_content(&mut b)?;
}
}
check_parser_state!(b.content);
}
--- a/media/libstagefright/binding/mp4parse/src/tests.rs
+++ b/media/libstagefright/binding/mp4parse/src/tests.rs
@@ -843,30 +843,34 @@ fn read_qt_wave_atom() {
.B8(0x12) // esds length
.append_repeated(0, 2)
.B8(0x00) // flags
.B8(0x04) // decoder config descriptor tag
.B8(0x0d) // dcds length
.B8(0x6b) // mp3
.append_repeated(0, 12)
}).into_inner();
+ let chan = make_box(BoxSize::Auto, b"chan", |s| {
+ s.append_repeated(0, 10) // we don't care its data.
+ }).into_inner();
let wave = make_box(BoxSize::Auto, b"wave", |s| {
s.append_bytes(esds.as_slice())
}).into_inner();
let mut stream = make_box(BoxSize::Auto, b"mp4a", |s| {
s.append_repeated(0, 6)
.B16(1) // data_reference_count
.B16(1) // verion: qt -> 1
.append_repeated(0, 6)
.B16(2)
.B16(16)
.append_repeated(0, 4)
.B32(48000 << 16)
.append_repeated(0, 16)
.append_bytes(wave.as_slice())
+ .append_bytes(chan.as_slice())
});
let mut iter = super::BoxIter::new(&mut stream);
let mut stream = iter.next_box().unwrap().unwrap();
let (codec_type, _) = super::read_audio_sample_entry(&mut stream)
.expect("fail to read qt wave atom");
assert_eq!(codec_type, super::CodecType::MP3);
}
@@ -1167,9 +1171,8 @@ fn read_stsd_lpcm() {
super::AudioCodecSpecific::LPCM => (),
_ => panic!("it should be LPCM!"),
}
},
_ => panic!("it should be a audio sample entry!"),
}
}
-
--- a/media/libstagefright/binding/update-rust.sh
+++ b/media/libstagefright/binding/update-rust.sh
@@ -1,13 +1,13 @@
#!/bin/sh -e
# Script to update mp4parse-rust sources to latest upstream
# Default version.
-VER=17debc745a3c97ddaed61dde8caabce461d5001a
+VER=0f39f07145522019638c3f051720b6a8ae26448f
# Accept version or commit from the command line.
if test -n "$1"; then
VER=$1
fi
echo "Fetching sources..."
rm -rf _upstream