Skip reading meta box as it may not be well formed

In the video captured by Android's default camera app, meta box is written as
as Box instead of FullBox specified in the spec.

Closes #319.

Change-Id: I526492fdd505d5929c5161cb1ed1503b724de7e9
This commit is contained in:
KongQun Yang 2018-03-01 08:18:22 -08:00
parent f8a1cb66ad
commit 9476e826d5
2 changed files with 12 additions and 6 deletions

View File

@ -2230,17 +2230,21 @@ Movie::~Movie() {}
FourCC Movie::BoxType() const { return FOURCC_moov; }
bool Movie::ReadWriteInternal(BoxBuffer* buffer) {
RCHECK(ReadWriteHeaderInternal(buffer) &&
buffer->PrepareChildren() &&
buffer->ReadWriteChild(&header) &&
buffer->TryReadWriteChild(&metadata));
RCHECK(ReadWriteHeaderInternal(buffer) && buffer->PrepareChildren() &&
buffer->ReadWriteChild(&header));
if (buffer->Reading()) {
BoxReader* reader = buffer->reader();
DCHECK(reader);
RCHECK(reader->ReadChildren(&tracks) &&
reader->TryReadChild(&extends) &&
RCHECK(reader->ReadChildren(&tracks) && reader->TryReadChild(&extends) &&
reader->TryReadChildren(&pssh));
} else {
// The 'meta' box is not well formed in the video captured by Android's
// default camera app: spec indicates that it is a FullBox but it is written
// as a Box. This results in the box failed to be parsed. See
// https://github.com/google/shaka-packager/issues/319 for details.
// We do not care the content of metadata box in the source content, so just
// skip reading the box.
RCHECK(buffer->TryReadWriteChild(&metadata));
for (uint32_t i = 0; i < tracks.size(); ++i)
RCHECK(buffer->ReadWriteChild(&tracks[i]));
RCHECK(buffer->TryReadWriteChild(&extends));

View File

@ -79,6 +79,8 @@ bool BoxReader::ScanChildren() {
size_t box_size = child->size();
children_.insert(std::pair<FourCC, std::unique_ptr<BoxReader>>(
box_type, std::move(child)));
VLOG(2) << "Child " << FourCCToString(box_type) << " size 0x" << std::hex
<< box_size << std::dec;
RCHECK(SkipBytes(box_size));
}