Skip to content

Commit 8834ba4

Browse files
committed
Rename ProtectionSchemeInfoBox struct member.
Rename `code_name` -> `original_format` as the latter is the name used in the spec and is a also clearer, IMO. Change it's type to FourCC and amend tests as needed.
1 parent 9d58d7f commit 8834ba4

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

mp4parse/src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ pub struct TrackEncryptionBox {
538538

539539
#[derive(Debug, Default)]
540540
pub struct ProtectionSchemeInfoBox {
541-
pub code_name: TryString,
541+
pub original_format: FourCC,
542542
pub scheme_type: Option<SchemeTypeBox>,
543543
pub tenc: Option<TrackEncryptionBox>,
544544
}
@@ -3163,8 +3163,7 @@ fn read_sinf<T: Read>(src: &mut BMFFBox<T>) -> Result<ProtectionSchemeInfoBox> {
31633163
while let Some(mut b) = iter.next_box()? {
31643164
match b.head.name {
31653165
BoxType::OriginalFormatBox => {
3166-
let frma = read_frma(&mut b)?;
3167-
sinf.code_name = frma;
3166+
sinf.original_format = FourCC::from(be_u32(&mut b)?);
31683167
}
31693168
BoxType::SchemeTypeBox => {
31703169
sinf.scheme_type = Some(read_schm(&mut b)?);
@@ -3241,10 +3240,6 @@ fn read_tenc<T: Read>(src: &mut BMFFBox<T>) -> Result<TrackEncryptionBox> {
32413240
})
32423241
}
32433242

3244-
fn read_frma<T: Read>(src: &mut BMFFBox<T>) -> Result<TryString> {
3245-
read_buf(src, 4)
3246-
}
3247-
32483243
fn read_schm<T: Read>(src: &mut BMFFBox<T>) -> Result<SchemeTypeBox> {
32493244
// Flags can be used to signal presence of URI in the box, but we don't
32503245
// use the URI so don't bother storing the flags.

mp4parse/tests/public.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ fn public_audio_tenc() {
309309
assert_eq!(a.codec_type, mp4::CodecType::EncryptedAudio);
310310
match a.protection_info.iter().find(|sinf| sinf.tenc.is_some()) {
311311
Some(ref p) => {
312-
assert_eq!(p.code_name, "mp4a");
312+
assert_eq!(p.original_format.value, *b"mp4a");
313313
if let Some(ref schm) = p.scheme_type {
314314
assert_eq!(schm.scheme_type.value, *b"cenc");
315315
} else {
@@ -368,7 +368,7 @@ fn public_video_cenc() {
368368
assert_eq!(v.codec_type, mp4::CodecType::EncryptedVideo);
369369
match v.protection_info.iter().find(|sinf| sinf.tenc.is_some()) {
370370
Some(ref p) => {
371-
assert_eq!(p.code_name, "avc1");
371+
assert_eq!(p.original_format.value, *b"avc1");
372372
if let Some(ref schm) = p.scheme_type {
373373
assert_eq!(schm.scheme_type.value, *b"cenc");
374374
} else {
@@ -441,7 +441,7 @@ fn public_audio_cbcs() {
441441
mp4::SampleEntry::Audio(ref a) => {
442442
if let Some(p) = a.protection_info.iter().find(|sinf| sinf.tenc.is_some()) {
443443
found_encrypted_sample_description = true;
444-
assert_eq!(p.code_name, "mp4a");
444+
assert_eq!(p.original_format.value, *b"mp4a");
445445
if let Some(ref schm) = p.scheme_type {
446446
assert_eq!(schm.scheme_type.value, *b"cbcs");
447447
} else {
@@ -526,7 +526,7 @@ fn public_video_cbcs() {
526526
assert_eq!(v.height, 300);
527527
if let Some(p) = v.protection_info.iter().find(|sinf| sinf.tenc.is_some()) {
528528
found_encrypted_sample_description = true;
529-
assert_eq!(p.code_name, "avc1");
529+
assert_eq!(p.original_format.value, *b"avc1");
530530
if let Some(ref schm) = p.scheme_type {
531531
assert_eq!(schm.scheme_type.value, *b"cbcs");
532532
} else {

0 commit comments

Comments
 (0)