diff --git a/mp4parse/src/lib.rs b/mp4parse/src/lib.rs index 9942288a..948eeffb 100644 --- a/mp4parse/src/lib.rs +++ b/mp4parse/src/lib.rs @@ -379,6 +379,7 @@ pub enum SampleEntry { #[allow(non_camel_case_types)] #[derive(Debug, Default)] pub struct ES_Descriptor { + pub object_profile: u8, pub audio_codec: CodecType, pub audio_object_type: Option, pub extended_audio_object_type: Option, @@ -2452,7 +2453,16 @@ fn find_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> { read_dc_descriptor(descriptor, esds)?; } DECODER_SPECIFIC_TAG => { - read_ds_descriptor(descriptor, esds)?; + match esds.object_profile { + 0x69 | 0x6B => { + // Could parse these object types' decoder specific info + // to discover the MPEG audio layer, etc., if needed. + break; + } + _ => { + read_ds_descriptor(descriptor, esds)?; + } + }; } _ => { debug!("Unsupported descriptor, tag {}", tag); @@ -2647,7 +2657,7 @@ fn read_surround_channel_count(bit_reader: &mut BitReader, channels: u8) -> Resu /// 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()?; + esds.object_profile = des.read_u8()?; // Skip uninteresting fields. skip(des, 12)?; @@ -2656,9 +2666,9 @@ fn read_dc_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> { find_descriptor(&data[des.position().try_into()?..data.len()], esds)?; } - esds.audio_codec = match object_profile { + esds.audio_codec = match esds.object_profile { 0x40 | 0x41 => CodecType::AAC, - 0x6B => CodecType::MP3, + 0x69 | 0x6B => CodecType::MP3, _ => CodecType::Unknown, };