-
Notifications
You must be signed in to change notification settings - Fork 64
Parse 'pssh' box for eme playback. #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
_ => try!(skip_box_content(&mut b)), | ||
}; | ||
check_parser_state!(b.content); | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn read_pssh<T: Read>(src: &mut BMFFBox<T>) -> Result<ProtectionSystemSpecificHeaderBox> { | ||
let mut box_content = Vec::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might save some allocations here if you use Vec::with_capacity(src.head.size);
but it probably doesn't matter.
let item = try!(read_buf(pssh, 16)); | ||
kid.push(item); | ||
count -= 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for _ in 0..count
would be better than a while
loop here. It's a little awkward, but there's one less line of code, and count
doesn't need to be mut
.
// pssh data format in gecko: | ||
// system_id | ||
// pssh size (in native endian) | ||
// pssh box content (including header) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to put this description in the function-level doc-comment above, since it's something a caller would need to know, not just an internal implementation detail.
|
||
let mut pssh_box = Vec::new(); | ||
try!(write_be_u32(&mut pssh_box, src.head.size as u32)); | ||
pssh_box.append(&mut vec![b'p', b's', b's', b'h']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pssh_box.extend(b"pssh");
which is a bit easier to read.
NB there's also Vec::extend_from_slice()
but extend
is equally fast in rust 1.14, so I don't think it's worth using the longer method name here. rust-lang/rust#37094
Thanks for review. All comments addressed. |
61b3a46
to
c7f93c2
Compare
c7f93c2
to
e545d15
Compare
Thanks! |
No description provided.