Bug 1314460 - Update rust mp4parse to v0.6.0. r?kinetik
Result of running the update script.
MozReview-Commit-ID: 4rqFqaFJ028
--- a/media/libstagefright/binding/mp4parse/Cargo.toml
+++ b/media/libstagefright/binding/mp4parse/Cargo.toml
@@ -1,14 +1,15 @@
[package]
name = "mp4parse"
-version = "0.5.1"
+version = "0.6.0"
authors = [
"Ralph Giles <giles@mozilla.com>",
"Matthew Gregan <kinetik@flim.org>",
+ "Alfredo Yang <ayang@mozilla.com>",
]
description = "Parser for ISO base media file format (mp4)"
documentation = "https://mp4parse-docs.surge.sh/mp4parse/"
license = "MPL-2.0"
repository = "https://github.com/mozilla/mp4parse-rust"
--- a/media/libstagefright/binding/mp4parse/src/lib.rs
+++ b/media/libstagefright/binding/mp4parse/src/lib.rs
@@ -204,16 +204,17 @@ pub enum SampleEntry {
Unknown,
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone)]
pub struct ES_Descriptor {
pub audio_codec: CodecType,
pub audio_sample_rate: Option<u32>,
+ pub audio_channel_count: Option<u16>,
pub codec_specific_config: Vec<u8>,
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone)]
pub enum AudioCodecSpecific {
ES_Descriptor(ES_Descriptor),
FLACSpecificBox(FLACSpecificBox),
@@ -1131,20 +1132,21 @@ fn read_esds<T: Read>(src: &mut BMFFBox<
let esds_size = src.head.size - src.head.offset - 4;
if esds_size > BUF_SIZE_LIMIT {
return Err(Error::InvalidData("esds box exceeds BUF_SIZE_LIMIT"));
}
let esds_array = try!(read_buf(src, esds_size as usize));
// Parsing DecoderConfig descriptor to get the object_profile_indicator
- // for correct codec type and audio sample rate.
- let (object_profile_indicator, sample_frequency) = {
+ // for correct codec type, audio sample rate and channel counts.
+ let (object_profile_indicator, sample_frequency, channels) = {
let mut object_profile: u8 = 0;
let mut sample_frequency = None;
+ let mut channels = None;
// clone a esds cursor for parsing.
let esds = &mut Cursor::new(&esds_array);
let next_tag = try!(esds.read_u8());
if next_tag != ESDESCR_TAG {
return Err(Error::Unsupported("fail to parse ES descriptor"));
}
@@ -1204,37 +1206,42 @@ fn read_esds<T: Read>(src: &mut BMFFBox<
// skip remains extension and length.
try!(skip(esds, 3));
}
let audio_specific_config = try!(be_u16(esds));
let sample_index = (audio_specific_config & 0x07FF) >> 7;
+ let channel_counts = (audio_specific_config & 0x007F) >> 3;
+
sample_frequency =
frequency_table.iter().find(|item| item.0 == sample_index).map(|x| x.1);
+
+ channels = Some(channel_counts);
}
}
- (object_profile, sample_frequency)
+ (object_profile, sample_frequency, channels)
};
let codec = match object_profile_indicator {
0x40 | 0x41 => CodecType::AAC,
0x6B => CodecType::MP3,
_ => CodecType::Unknown,
};
if codec == CodecType::Unknown {
return Err(Error::Unsupported("unknown audio codec"));
}
Ok(ES_Descriptor {
audio_codec: codec,
audio_sample_rate: sample_frequency,
+ audio_channel_count: channels,
codec_specific_config: esds_array,
})
}
/// Parse `FLACSpecificBox`.
fn read_dfla<T: Read>(src: &mut BMFFBox<T>) -> Result<FLACSpecificBox> {
let (version, flags) = try!(read_fullbox_extra(src));
if version != 0 {
--- a/media/libstagefright/binding/mp4parse_capi/Cargo.toml
+++ b/media/libstagefright/binding/mp4parse_capi/Cargo.toml
@@ -1,25 +1,26 @@
[package]
name = "mp4parse_capi"
-version = "0.5.1"
+version = "0.6.0"
authors = [
"Ralph Giles <giles@mozilla.com>",
"Matthew Gregan <kinetik@flim.org>",
+ "Alfredo Yang <ayang@mozilla.com>",
]
description = "Parser for ISO base media file format (mp4)"
documentation = "https://mp4parse-docs.surge.sh/mp4parse/"
license = "MPL-2.0"
repository = "https://github.com/mozilla/mp4parse-rust"
# Avoid complaints about trying to package test files.
exclude = [
"*.mp4",
]
[dependencies]
-"mp4parse" = {version = "0.5.1", path = "../mp4parse"}
+"mp4parse" = {version = "0.6.0", path = "../mp4parse"}
# Somewhat heavy-handed, but we want at least -Z force-overflow-checks=on.
[profile.release]
debug-assertions = true
--- a/media/libstagefright/binding/mp4parse_capi/src/lib.rs
+++ b/media/libstagefright/binding/mp4parse_capi/src/lib.rs
@@ -442,16 +442,19 @@ pub unsafe extern fn mp4parse_get_track_
if v.codec_specific_config.len() > std::u32::MAX as usize {
return MP4PARSE_ERROR_INVALID;
}
(*info).codec_specific_config.length = v.codec_specific_config.len() as u32;
(*info).codec_specific_config.data = v.codec_specific_config.as_ptr();
if let Some(rate) = v.audio_sample_rate {
(*info).sample_rate = rate;
}
+ if let Some(channels) = v.audio_channel_count {
+ (*info).channels = channels;
+ }
}
AudioCodecSpecific::FLACSpecificBox(ref flac) => {
// Return the STREAMINFO metadata block in the codec_specific.
let streaminfo = &flac.blocks[0];
if streaminfo.block_type != 0 || streaminfo.data.len() != 34 {
return MP4PARSE_ERROR_INVALID;
}
(*info).codec_specific_config.length = streaminfo.data.len() as u32;
@@ -796,17 +799,17 @@ fn arg_validation_with_data() {
assert_eq!(MP4PARSE_OK, mp4parse_get_track_video_info(parser, 0, &mut video));
assert_eq!(video.display_width, 320);
assert_eq!(video.display_height, 240);
assert_eq!(video.image_width, 320);
assert_eq!(video.image_height, 240);
let mut audio = Default::default();
assert_eq!(MP4PARSE_OK, mp4parse_get_track_audio_info(parser, 1, &mut audio));
- assert_eq!(audio.channels, 2);
+ assert_eq!(audio.channels, 1);
assert_eq!(audio.bit_depth, 16);
assert_eq!(audio.sample_rate, 48000);
// Test with an invalid track number.
let mut info = mp4parse_track_info {
track_type: MP4PARSE_TRACK_TYPE_VIDEO,
codec: mp4parse_codec::MP4PARSE_CODEC_UNKNOWN,
track_id: 0,
--- a/toolkit/library/gtest/rust/Cargo.lock
+++ b/toolkit/library/gtest/rust/Cargo.lock
@@ -11,17 +11,17 @@ dependencies = [
name = "byteorder"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "gkrust-shared"
version = "0.1.0"
dependencies = [
- "mp4parse_capi 0.5.1",
+ "mp4parse_capi 0.6.0",
"nsstring 0.1.0",
"rust_url_capi 0.0.1",
]
[[package]]
name = "idna"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -38,30 +38,30 @@ source = "registry+https://github.com/ru
[[package]]
name = "matches"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "mp4parse"
-version = "0.5.1"
+version = "0.6.0"
dependencies = [
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "mp4parse-gtest"
version = "0.1.0"
[[package]]
name = "mp4parse_capi"
-version = "0.5.1"
+version = "0.6.0"
dependencies = [
- "mp4parse 0.5.1",
+ "mp4parse 0.6.0",
]
[[package]]
name = "nsstring"
version = "0.1.0"
[[package]]
name = "nsstring-gtest"
--- a/toolkit/library/rust/Cargo.lock
+++ b/toolkit/library/rust/Cargo.lock
@@ -9,17 +9,17 @@ dependencies = [
name = "byteorder"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "gkrust-shared"
version = "0.1.0"
dependencies = [
- "mp4parse_capi 0.5.1",
+ "mp4parse_capi 0.6.0",
"nsstring 0.1.0",
"rust_url_capi 0.0.1",
]
[[package]]
name = "idna"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -36,26 +36,26 @@ source = "registry+https://github.com/ru
[[package]]
name = "matches"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "mp4parse"
-version = "0.5.1"
+version = "0.6.0"
dependencies = [
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "mp4parse_capi"
-version = "0.5.1"
+version = "0.6.0"
dependencies = [
- "mp4parse 0.5.1",
+ "mp4parse 0.6.0",
]
[[package]]
name = "nsstring"
version = "0.1.0"
[[package]]
name = "rust_url_capi"