Bug 1656616 - Update mp4parse-rust to 63325444 r=kinetik

Differential Revision: https://phabricator.services.mozilla.com/D85646
This commit is contained in:
Jon Bauman 2020-08-01 05:39:00 +00:00
parent d143e89e7f
commit 8cf9cec211
13 changed files with 111 additions and 51 deletions

View File

@ -15,7 +15,7 @@ tag = "v0.4.8"
[source."https://github.com/mozilla/mp4parse-rust"]
git = "https://github.com/mozilla/mp4parse-rust"
replace-with = "vendored-sources"
rev = "0dc3e6e7c5371fe21f69b847f61c65fe6d6dc317"
rev = "63325444ae3388599f2f222775eebdde4c2f9f30"
[source."https://github.com/mozilla/application-services"]
git = "https://github.com/mozilla/application-services"

4
Cargo.lock generated
View File

@ -3072,7 +3072,7 @@ dependencies = [
[[package]]
name = "mp4parse"
version = "0.11.4"
source = "git+https://github.com/mozilla/mp4parse-rust?rev=0dc3e6e7c5371fe21f69b847f61c65fe6d6dc317#0dc3e6e7c5371fe21f69b847f61c65fe6d6dc317"
source = "git+https://github.com/mozilla/mp4parse-rust?rev=63325444ae3388599f2f222775eebdde4c2f9f30#63325444ae3388599f2f222775eebdde4c2f9f30"
dependencies = [
"bitreader",
"byteorder",
@ -3089,7 +3089,7 @@ version = "0.1.0"
[[package]]
name = "mp4parse_capi"
version = "0.11.4"
source = "git+https://github.com/mozilla/mp4parse-rust?rev=0dc3e6e7c5371fe21f69b847f61c65fe6d6dc317#0dc3e6e7c5371fe21f69b847f61c65fe6d6dc317"
source = "git+https://github.com/mozilla/mp4parse-rust?rev=63325444ae3388599f2f222775eebdde4c2f9f30#63325444ae3388599f2f222775eebdde4c2f9f30"
dependencies = [
"byteorder",
"log",

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"107804fbf8f667fbad45e7dea9fa1bb32ce8ef5580b543a54455e678d7769708","src/boxes.rs":"623f948e69244db586d7cc1855e0a1828766cbe2d4998277d170047d0ae0fce0","src/fallible.rs":"836a36c2bc9803aead4bb24621e4fa6176c77b3752e69459a1f36555eb8bf2ec","src/lib.rs":"05d2e8523eab120bbc712adea9cd47979da3e95f54ff5816e6738ebeaf90afb2","src/macros.rs":"76c840f9299797527fe71aa5b378ffb01312767372b45cc62deddb19775400ae","src/tests.rs":"7c7f69051f8b8edcb994d3813bcca7277cc71bcfb0a6eaadbbdbb9a1f777ff88","tests/overflow.rs":"16b591d8def1a155b3b997622f6ea255536870d99c3d8f97c51755b77a50de3c","tests/public.rs":"eb02970aa69c31855936b4ec24dcf09b300fad274b620c879d9b6dfbcd89444c"},"package":null}
{"files":{"Cargo.toml":"107804fbf8f667fbad45e7dea9fa1bb32ce8ef5580b543a54455e678d7769708","src/boxes.rs":"5f84805435af90034075709867e02c74a198e26dc628a9fc95df034928ee5bbc","src/fallible.rs":"836a36c2bc9803aead4bb24621e4fa6176c77b3752e69459a1f36555eb8bf2ec","src/lib.rs":"7c8bde48b42f5470a937d3affc4452e06b2158ff07c207f39376bdca11efa832","src/macros.rs":"76c840f9299797527fe71aa5b378ffb01312767372b45cc62deddb19775400ae","src/tests.rs":"f1a27e785d4006cd910ca3c48c8a972da1db9c9b4a67185f67a191ddc3c69328","tests/bug-1655846.avif":"e0a5a06225800fadf05f5352503a4cec11af73eef705c43b4acab5f4a99dea50","tests/overflow.rs":"16b591d8def1a155b3b997622f6ea255536870d99c3d8f97c51755b77a50de3c","tests/public.rs":"fd646ffd5fab8beed5949b87482048ba400438fa90860f86f357a7f6141dc649"},"package":null}

View File

@ -94,6 +94,12 @@ impl fmt::Display for FourCC {
}
}
impl PartialEq<&[u8; 4]> for FourCC {
fn eq(&self, other: &&[u8; 4]) -> bool {
self.value.eq(*other)
}
}
box_database!(
FileTypeBox 0x6674_7970, // "ftyp"
MediaDataBox 0x6d64_6174, // "mdat"

View File

@ -214,6 +214,8 @@ pub type Result<T> = std::result::Result<T, Error>;
/// begins with a header describing the length of the box's data and a
/// four-byte box type which identifies the type of the box. Together these
/// are enough to interpret the contents of that section of the file.
///
/// See ISO 14496-12:2015 § 4.2
#[derive(Debug, Clone, Copy)]
struct BoxHeader {
/// Box type.
@ -226,6 +228,11 @@ struct BoxHeader {
uuid: Option<[u8; 16]>,
}
impl BoxHeader {
const MIN_SIZE: u64 = 8; // 4-byte size + 4-byte type
const MIN_LARGE_SIZE: u64 = 16; // 4-byte size + 4-byte type + 16-byte size
}
/// File type box 'ftyp'.
#[derive(Debug)]
struct FileTypeBox {
@ -367,6 +374,8 @@ pub enum SampleEntry {
Unknown,
}
/// An Elementary Stream Descriptor
/// See ISO 14496-1:2010 § 7.2.6.5
#[allow(non_camel_case_types)]
#[derive(Debug, Default)]
pub struct ES_Descriptor {
@ -538,7 +547,7 @@ pub struct TrackEncryptionBox {
#[derive(Debug, Default)]
pub struct ProtectionSchemeInfoBox {
pub code_name: TryString,
pub original_format: FourCC,
pub scheme_type: Option<SchemeTypeBox>,
pub tenc: Option<TrackEncryptionBox>,
}
@ -1007,6 +1016,7 @@ impl Track {
}
}
/// See ISO 14496-12:2015 § 4.2
struct BMFFBox<'a, T: 'a> {
head: BoxHeader,
content: Take<&'a mut T>,
@ -1115,6 +1125,8 @@ impl<'a, T> Drop for BMFFBox<'a, T> {
/// and its length. Used internally for dispatching to specific
/// parsers for the internal content, or to get the length to
/// skip unknown or uninteresting boxes.
///
/// See ISO 14496-12:2015 § 4.2
fn read_box_header<T: ReadBytesExt>(src: &mut T) -> Result<BoxHeader> {
let size32 = be_u32(src)?;
let name = BoxType::from(be_u32(src)?);
@ -1123,17 +1135,21 @@ fn read_box_header<T: ReadBytesExt>(src: &mut T) -> Result<BoxHeader> {
0 => return Err(Error::Unsupported("unknown sized box")),
1 => {
let size64 = be_u64(src)?;
if size64 < 16 {
if size64 < BoxHeader::MIN_LARGE_SIZE {
return Err(Error::InvalidData("malformed wide size"));
}
size64
}
2..=7 => return Err(Error::InvalidData("malformed size")),
_ => u64::from(size32),
_ => {
if u64::from(size32) < BoxHeader::MIN_SIZE {
return Err(Error::InvalidData("malformed size"));
}
u64::from(size32)
}
};
let mut offset = match size32 {
1 => 4 + 4 + 8,
_ => 4 + 4,
1 => BoxHeader::MIN_LARGE_SIZE,
_ => BoxHeader::MIN_SIZE,
};
let uuid = if name == BoxType::UuidBox {
if size >= offset + 16 {
@ -1587,9 +1603,11 @@ fn read_iloc<T: Read>(src: &mut BMFFBox<T>) -> Result<TryVec<ItemLocationBoxItem
})?;
}
debug_assert_eq!(iloc.remaining(), 0);
if iloc.remaining() == 0 {
Ok(items)
} else {
Err(Error::InvalidData("invalid iloc size"))
}
}
/// Read the contents of a box, including sub boxes.
@ -2389,6 +2407,7 @@ fn read_flac_metadata<T: Read>(src: &mut BMFFBox<T>) -> Result<FLACMetadataBlock
Ok(FLACMetadataBlock { block_type, data })
}
/// See ISO 14496-1:2010 § 7.2.6.5
fn find_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
// Tags for elementary stream description
const ESDESCR_TAG: u8 = 0x03;
@ -2402,6 +2421,8 @@ fn find_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
let des = &mut Cursor::new(remains);
let tag = des.read_u8()?;
// See ISO 14496-1:2010 § 8.3.3 for interpreting size of exandable classes
let mut end: u32 = 0; // It's u8 without declaration type that is incorrect.
// MSB of extend_or_len indicates more bytes, up to 4 bytes.
for _ in 0..4 {
@ -2413,7 +2434,7 @@ fn find_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
}
let extend_or_len = des.read_u8()?;
end = (end << 7) + u32::from(extend_or_len & 0x7F);
if (extend_or_len & 0x80) == 0 {
if (extend_or_len & 0b1000_0000) == 0 {
end += des.position() as u32;
break;
}
@ -2441,6 +2462,7 @@ fn find_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
}
remains = &remains[end.to_usize()..remains.len()];
debug!("remains.len(): {}", remains.len());
}
Ok(())
@ -2457,6 +2479,7 @@ fn get_audio_object_type(bit_reader: &mut BitReader) -> Result<u16> {
Ok(audio_object_type)
}
/// See ISO 14496-1:2010 § 7.2.6.7 and probably 14496-3 somewhere?
fn read_ds_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
let frequency_table = vec![
(0x0, 96000),
@ -2623,6 +2646,7 @@ fn read_surround_channel_count(bit_reader: &mut BitReader, channels: u8) -> Resu
Ok(count)
}
/// See ISO 14496-1:2010 § 7.2.6.6
fn read_dc_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
let des = &mut Cursor::new(data);
let object_profile = des.read_u8()?;
@ -2643,6 +2667,7 @@ fn read_dc_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
Ok(())
}
/// See ISO 14496-1:2010 § 7.2.6.5
fn read_es_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
let des = &mut Cursor::new(data);
@ -2673,14 +2698,7 @@ fn read_es_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
fn read_esds<T: Read>(src: &mut BMFFBox<T>) -> Result<ES_Descriptor> {
let (_, _) = read_fullbox_extra(src)?;
// Subtract 4 extra to offset the members of fullbox not accounted for in
// head.offset
let esds_size = src
.head
.size
.checked_sub(src.head.offset + 4)
.expect("offset invalid");
let esds_array = read_buf(src, esds_size)?;
let esds_array = read_buf(src, src.bytes_left())?;
let mut es_data = ES_Descriptor::default();
find_descriptor(&esds_array, &mut es_data)?;
@ -2983,6 +3001,7 @@ fn read_qt_wave_atom<T: Read>(src: &mut BMFFBox<T>) -> Result<ES_Descriptor> {
}
/// Parse an audio description inside an stsd box.
/// See ISO 14496-12:2015 § 12.2.3
fn read_audio_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<SampleEntry> {
let name = src.get_header().name;
@ -3115,6 +3134,7 @@ fn read_audio_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<SampleEntry>
}
/// Parse a stsd box.
/// See ISO 14496-12:2015 § 8.5.2
fn read_stsd<T: Read>(src: &mut BMFFBox<T>, track: &mut Track) -> Result<SampleDescriptionBox> {
let (_, _) = read_fullbox_extra(src)?;
@ -3163,8 +3183,7 @@ fn read_sinf<T: Read>(src: &mut BMFFBox<T>) -> Result<ProtectionSchemeInfoBox> {
while let Some(mut b) = iter.next_box()? {
match b.head.name {
BoxType::OriginalFormatBox => {
let frma = read_frma(&mut b)?;
sinf.code_name = frma;
sinf.original_format = FourCC::from(be_u32(&mut b)?);
}
BoxType::SchemeTypeBox => {
sinf.scheme_type = Some(read_schm(&mut b)?);
@ -3241,10 +3260,6 @@ fn read_tenc<T: Read>(src: &mut BMFFBox<T>) -> Result<TrackEncryptionBox> {
})
}
fn read_frma<T: Read>(src: &mut BMFFBox<T>) -> Result<TryString> {
read_buf(src, 4)
}
fn read_schm<T: Read>(src: &mut BMFFBox<T>) -> Result<SchemeTypeBox> {
// Flags can be used to signal presence of URI in the box, but we don't
// use the URI so don't bother storing the flags.

View File

@ -17,7 +17,7 @@ use std::io::Read as _;
extern crate test_assembler;
use self::test_assembler::*;
use boxes::{BoxType, FourCC};
use boxes::BoxType;
enum BoxSize {
Short(u32),
@ -181,11 +181,11 @@ fn read_ftyp() {
assert_eq!(stream.head.name, BoxType::FileTypeBox);
assert_eq!(stream.head.size, 24);
let parsed = super::read_ftyp(&mut stream).unwrap();
assert_eq!(parsed.major_brand, FourCC::from(*b"mp42")); // mp42
assert_eq!(parsed.major_brand, b"mp42"); // mp42
assert_eq!(parsed.minor_version, 0);
assert_eq!(parsed.compatible_brands.len(), 2);
assert_eq!(parsed.compatible_brands[0], FourCC::from(*b"isom")); // isom
assert_eq!(parsed.compatible_brands[1], FourCC::from(*b"mp42")); // mp42
assert_eq!(parsed.compatible_brands[0], b"isom"); // isom
assert_eq!(parsed.compatible_brands[1], b"mp42"); // mp42
}
#[test]
@ -223,11 +223,11 @@ fn read_ftyp_case() {
assert_eq!(stream.head.name, BoxType::FileTypeBox);
assert_eq!(stream.head.size, 24);
let parsed = super::read_ftyp(&mut stream).unwrap();
assert_eq!(parsed.major_brand, FourCC::from(*b"MP42"));
assert_eq!(parsed.major_brand, b"MP42");
assert_eq!(parsed.minor_version, 0);
assert_eq!(parsed.compatible_brands.len(), 2);
assert_eq!(parsed.compatible_brands[0], FourCC::from(*b"ISOM")); // ISOM
assert_eq!(parsed.compatible_brands[1], FourCC::from(*b"MP42")); // MP42
assert_eq!(parsed.compatible_brands[0], b"ISOM"); // ISOM
assert_eq!(parsed.compatible_brands[1], b"MP42"); // MP42
}
#[test]
@ -474,7 +474,7 @@ fn read_hdlr() {
assert_eq!(stream.head.name, BoxType::HandlerBox);
assert_eq!(stream.head.size, 45);
let parsed = super::read_hdlr(&mut stream).unwrap();
assert_eq!(parsed.handler_type, FourCC::from(*b"vide"));
assert_eq!(parsed.handler_type, b"vide");
}
#[test]
@ -487,7 +487,7 @@ fn read_hdlr_short_name() {
assert_eq!(stream.head.name, BoxType::HandlerBox);
assert_eq!(stream.head.size, 33);
let parsed = super::read_hdlr(&mut stream).unwrap();
assert_eq!(parsed.handler_type, FourCC::from(*b"vide"));
assert_eq!(parsed.handler_type, b"vide");
}
#[test]
@ -500,7 +500,7 @@ fn read_hdlr_zero_length_name() {
assert_eq!(stream.head.name, BoxType::HandlerBox);
assert_eq!(stream.head.size, 32);
let parsed = super::read_hdlr(&mut stream).unwrap();
assert_eq!(parsed.handler_type, FourCC::from(*b"vide"));
assert_eq!(parsed.handler_type, b"vide");
}
fn flac_streaminfo() -> Vec<u8> {

Binary file not shown.

View File

@ -28,6 +28,7 @@ static AUDIO_EME_CBCS_MP4: &str = "tests/bipbop_cbcs_audio_init.mp4";
static VIDEO_EME_CBCS_MP4: &str = "tests/bipbop_cbcs_video_init.mp4";
static VIDEO_AV1_MP4: &str = "tests/tiny_av1.mp4";
static IMAGE_AVIF: &str = "av1-avif/testFiles/Microsoft/Monochrome.avif";
static IMAGE_AVIF_CORRUPT: &str = "tests/bug-1655846.avif";
static IMAGE_AVIF_GRID: &str = "av1-avif/testFiles/Microsoft/Summer_in_Tomsk_720p_5x4_grid.avif";
static AVIF_TEST_DIR: &str = "av1-avif/testFiles";
@ -309,9 +310,9 @@ fn public_audio_tenc() {
assert_eq!(a.codec_type, mp4::CodecType::EncryptedAudio);
match a.protection_info.iter().find(|sinf| sinf.tenc.is_some()) {
Some(ref p) => {
assert_eq!(p.code_name, "mp4a");
assert_eq!(p.original_format, b"mp4a");
if let Some(ref schm) = p.scheme_type {
assert_eq!(schm.scheme_type.value, *b"cenc");
assert_eq!(schm.scheme_type, b"cenc");
} else {
panic!("Expected scheme type info");
}
@ -368,9 +369,9 @@ fn public_video_cenc() {
assert_eq!(v.codec_type, mp4::CodecType::EncryptedVideo);
match v.protection_info.iter().find(|sinf| sinf.tenc.is_some()) {
Some(ref p) => {
assert_eq!(p.code_name, "avc1");
assert_eq!(p.original_format, b"avc1");
if let Some(ref schm) = p.scheme_type {
assert_eq!(schm.scheme_type.value, *b"cenc");
assert_eq!(schm.scheme_type, b"cenc");
} else {
panic!("Expected scheme type info");
}
@ -441,9 +442,9 @@ fn public_audio_cbcs() {
mp4::SampleEntry::Audio(ref a) => {
if let Some(p) = a.protection_info.iter().find(|sinf| sinf.tenc.is_some()) {
found_encrypted_sample_description = true;
assert_eq!(p.code_name, "mp4a");
assert_eq!(p.original_format, b"mp4a");
if let Some(ref schm) = p.scheme_type {
assert_eq!(schm.scheme_type.value, *b"cbcs");
assert_eq!(schm.scheme_type, b"cbcs");
} else {
panic!("Expected scheme type info");
}
@ -526,9 +527,9 @@ fn public_video_cbcs() {
assert_eq!(v.height, 300);
if let Some(p) = v.protection_info.iter().find(|sinf| sinf.tenc.is_some()) {
found_encrypted_sample_description = true;
assert_eq!(p.code_name, "avc1");
assert_eq!(p.original_format, b"avc1");
if let Some(ref schm) = p.scheme_type {
assert_eq!(schm.scheme_type.value, *b"cbcs");
assert_eq!(schm.scheme_type, b"cbcs");
} else {
panic!("Expected scheme type info");
}
@ -627,6 +628,13 @@ fn public_avif_primary_item() {
assert_eq!(context.primary_item[0..4], [0x12, 0x00, 0x0a, 0x0a]);
}
#[test]
fn public_avif_bug_1655846() {
let context = &mut mp4::AvifContext::new();
let input = &mut File::open(IMAGE_AVIF_CORRUPT).expect("Unknown file");
assert!(mp4::read_avif(input, context).is_err());
}
#[test]
#[ignore] // Remove when we add support; see https://github.com/mozilla/mp4parse-rust/issues/198
fn public_avif_primary_item_is_grid() {

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"13408d7785c5fe40f9db2bac1f93e8cf2aca7c35b5d2ba9acbbb23eb3a71e40a","cbindgen.toml":"5c9429f271d6e914d81b63e6509c04ffe84cab11ed3a53a2ed4715e5d5ace80e","examples/dump.rs":"2db33a7ffbb20880d140e95c93cdeabe7e2ff41e5c09d80aa10dfdda9277942d","src/lib.rs":"deff68e6d20bc20167aa94cc0aaa541d83ca80bd0f18d9524530706a51782f5c","tests/test_chunk_out_of_range.rs":"b5da583218d98027ed973a29c67434a91a1306f2d2fb39ec4d640d4824c308ce","tests/test_encryption.rs":"a26f2fdb40e1fb3619a0625d0afbd677c6bdff1e2e640962197142656499c409","tests/test_fragment.rs":"e90eb5a4418d30002655466c0c4b3125c7fd70a74b6871471eaa172f1def9db8","tests/test_rotation.rs":"fb43c2f2dfa496d151c33bdd46c0fd3252387c23cc71e2cac9ed0234de715a81","tests/test_sample_table.rs":"adc8d264c46aef78c047377fbb792a4400d6db98bc44583b464d7b3dc182c884","tests/test_workaround_stsc.rs":"7dd419f3d55b9a3a039cac57e58a9240a9c8166bcd4356c24f69f731c3ced83b"},"package":null}
{"files":{"Cargo.toml":"13408d7785c5fe40f9db2bac1f93e8cf2aca7c35b5d2ba9acbbb23eb3a71e40a","cbindgen.toml":"5c9429f271d6e914d81b63e6509c04ffe84cab11ed3a53a2ed4715e5d5ace80e","examples/dump.rs":"598f828f07bac9b204d3eb7af4efd7158087382fc322dcce913a28729f854f70","src/lib.rs":"dfd3bccfb80aaab2389d11ae00242709d6c5dae8a299b55098bf5ec39698a097","tests/test_chunk_out_of_range.rs":"b5da583218d98027ed973a29c67434a91a1306f2d2fb39ec4d640d4824c308ce","tests/test_encryption.rs":"ca98516ff423c03b5fcc17b05f993f13b32485e4cf3ba86faf1bea72681d75ce","tests/test_fragment.rs":"e90eb5a4418d30002655466c0c4b3125c7fd70a74b6871471eaa172f1def9db8","tests/test_rotation.rs":"fb43c2f2dfa496d151c33bdd46c0fd3252387c23cc71e2cac9ed0234de715a81","tests/test_sample_table.rs":"adc8d264c46aef78c047377fbb792a4400d6db98bc44583b464d7b3dc182c884","tests/test_workaround_stsc.rs":"7dd419f3d55b9a3a039cac57e58a9240a9c8166bcd4356c24f69f731c3ced83b"},"package":null}

View File

@ -34,7 +34,7 @@ fn dump_file(filename: &str) {
match rv {
Mp4parseStatus::Ok => (),
_ => {
println!("-- fail to parse, '-v' for more info");
println!("-- fail to parse: {:?}, '-v' for more info", rv);
return;
}
}
@ -44,8 +44,8 @@ fn dump_file(filename: &str) {
Mp4parseStatus::Ok => {
println!("-- mp4parse_fragment_info {:?}", frag_info);
}
_ => {
println!("-- mp4parse_fragment_info failed");
rv => {
println!("-- mp4parse_fragment_info failed with {:?}", rv);
return;
}
}

View File

@ -217,9 +217,23 @@ pub struct Mp4parsePsshInfo {
pub data: Mp4parseByteData,
}
#[repr(u8)]
#[derive(Debug, PartialEq)]
pub enum OptionalFourCC {
None,
Some([u8; 4]),
}
impl Default for OptionalFourCC {
fn default() -> Self {
Self::None
}
}
#[repr(C)]
#[derive(Default, Debug)]
pub struct Mp4parseSinfInfo {
pub original_format: OptionalFourCC,
pub scheme_type: Mp4ParseEncryptionSchemeType,
pub is_encrypted: u8,
pub iv_size: u8,
@ -827,6 +841,8 @@ fn get_track_audio_info(
.iter()
.find(|sinf| sinf.tenc.is_some())
{
sample_info.protected_data.original_format =
OptionalFourCC::Some(p.original_format.value);
sample_info.protected_data.scheme_type = match p.scheme_type {
Some(ref scheme_type_box) => {
match scheme_type_box.scheme_type.value.as_ref() {
@ -987,6 +1003,8 @@ fn mp4parse_get_track_video_info_safe(
.iter()
.find(|sinf| sinf.tenc.is_some())
{
sample_info.protected_data.original_format =
OptionalFourCC::Some(p.original_format.value);
sample_info.protected_data.scheme_type = match p.scheme_type {
Some(ref scheme_type_box) => {
match scheme_type_box.scheme_type.value.as_ref() {

View File

@ -51,6 +51,10 @@ fn parse_cenc() {
assert_eq!((*video.sample_info).image_width, 320);
assert_eq!((*video.sample_info).image_height, 240);
let protected_data = &(*video.sample_info).protected_data;
assert_eq!(
protected_data.original_format,
OptionalFourCC::Some(*b"avc1")
);
assert_eq!(
protected_data.scheme_type,
Mp4ParseEncryptionSchemeType::Cenc
@ -79,6 +83,10 @@ fn parse_cenc() {
assert_eq!((*audio.sample_info).bit_depth, 16);
assert_eq!((*audio.sample_info).sample_rate, 44100);
let protected_data = &(*audio.sample_info).protected_data;
assert_eq!(
protected_data.original_format,
OptionalFourCC::Some(*b"mp4a")
);
assert_eq!(protected_data.is_encrypted, 0x01);
assert_eq!(protected_data.iv_size, 16);
assert_eq!(protected_data.kid.length, 16);
@ -128,6 +136,10 @@ fn parse_cbcs() {
assert_eq!((*video.sample_info).image_width, 400);
assert_eq!((*video.sample_info).image_height, 300);
let protected_data = &(*video.sample_info).protected_data;
assert_eq!(
protected_data.original_format,
OptionalFourCC::Some(*b"avc1")
);
assert_eq!(
protected_data.scheme_type,
Mp4ParseEncryptionSchemeType::Cbcs
@ -186,6 +198,7 @@ fn parse_unencrypted() {
assert_eq!(rv, Mp4parseStatus::Ok);
assert_eq!(audio.sample_info_count, 1);
let protected_data = &(*audio.sample_info).protected_data;
assert_eq!(protected_data.original_format, OptionalFourCC::None);
assert_eq!(
protected_data.scheme_type,
Mp4ParseEncryptionSchemeType::None

View File

@ -9,7 +9,7 @@ description = "Shared Rust code for libxul"
geckoservo = { path = "../../../../servo/ports/geckolib" }
kvstore = { path = "../../../components/kvstore" }
lmdb-rkv-sys = { version = "0.11", features = ["mdb_idl_logn_9"] }
mp4parse_capi = { git = "https://github.com/mozilla/mp4parse-rust", rev = "0dc3e6e7c5371fe21f69b847f61c65fe6d6dc317" }
mp4parse_capi = { git = "https://github.com/mozilla/mp4parse-rust", rev = "63325444ae3388599f2f222775eebdde4c2f9f30" }
nserror = { path = "../../../../xpcom/rust/nserror" }
nsstring = { path = "../../../../xpcom/rust/nsstring" }
netwerk_helper = { path = "../../../../netwerk/base/rust-helper" }