Skip to content

Commit e545d15

Browse files
author
alfredoyang
committed
fix review comments
1 parent ecff40e commit e545d15

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

mp4parse/src/lib.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ fn read_moov<T: Read>(f: &mut BMFFBox<T>, context: &mut MediaContext) -> Result<
627627
}
628628

629629
fn read_pssh<T: Read>(src: &mut BMFFBox<T>) -> Result<ProtectionSystemSpecificHeaderBox> {
630-
let mut box_content = Vec::new();
630+
let mut box_content = Vec::with_capacity(src.head.size as usize);
631631
try!(src.read_to_end(&mut box_content));
632632

633633
let (system_id, kid, data) = {
@@ -639,11 +639,10 @@ fn read_pssh<T: Read>(src: &mut BMFFBox<T>) -> Result<ProtectionSystemSpecificHe
639639

640640
let mut kid: Vec<ByteData> = Vec::new();
641641
if version > 0 {
642-
let mut count = try!(be_i32(pssh));
643-
while count > 0 {
642+
let count = try!(be_i32(pssh));
643+
for _ in 0..count {
644644
let item = try!(read_buf(pssh, 16));
645645
kid.push(item);
646-
count -= 1;
647646
}
648647
}
649648

@@ -655,7 +654,7 @@ fn read_pssh<T: Read>(src: &mut BMFFBox<T>) -> Result<ProtectionSystemSpecificHe
655654

656655
let mut pssh_box = Vec::new();
657656
try!(write_be_u32(&mut pssh_box, src.head.size as u32));
658-
pssh_box.append(&mut vec![b'p', b's', b's', b'h']);
657+
pssh_box.append(&mut b"pssh".to_vec());
659658
pssh_box.append(&mut box_content);
660659

661660
Ok(ProtectionSystemSpecificHeaderBox {

mp4parse_capi/src/lib.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,12 @@ pub unsafe extern fn mp4parse_is_fragmented(parser: *mut mp4parse_parser, track_
603603
MP4PARSE_OK
604604
}
605605

606-
/// Get pssh system id and pssh box content for eme playback.
606+
/// Get 'pssh' system id and 'pssh' box content for eme playback.
607+
///
608+
/// The data format in 'info' passing to gecko is:
609+
/// system_id
610+
/// pssh box size (in native endian)
611+
/// pssh box content (including header)
607612
#[no_mangle]
608613
pub unsafe extern fn mp4parse_get_pssh_info(parser: *mut mp4parse_parser, info: *mut mp4parse_pssh_info) -> mp4parse_error {
609614
if parser.is_null() || info.is_null() || (*parser).poisoned() {
@@ -623,10 +628,6 @@ pub unsafe extern fn mp4parse_get_pssh_info(parser: *mut mp4parse_parser, info:
623628
},
624629
_ => (),
625630
}
626-
// pssh data format in gecko:
627-
// system_id
628-
// pssh size (in native endian)
629-
// pssh box content (including header)
630631
pssh_data.extend_from_slice(pssh.system_id.as_slice());
631632
pssh_data.extend_from_slice(data_len.as_slice());
632633
pssh_data.extend_from_slice(pssh.box_content.as_slice());

0 commit comments

Comments
 (0)