| Index: media/formats/mp4/box_definitions.cc
|
| diff --git a/media/formats/mp4/box_definitions.cc b/media/formats/mp4/box_definitions.cc
|
| index 5b67633252c58565a15da78626f328e7237351cd..f3d8db24a244b21c01ddaa8a4697771f47492ec1 100644
|
| --- a/media/formats/mp4/box_definitions.cc
|
| +++ b/media/formats/mp4/box_definitions.cc
|
| @@ -771,19 +771,116 @@ bool TrackFragmentRun::Parse(BoxReader* reader) {
|
| return true;
|
| }
|
|
|
| +SampleToGroup::SampleToGroup() : grouping_type(0), grouping_type_parameter(0) {}
|
| +SampleToGroup::~SampleToGroup() {}
|
| +FourCC SampleToGroup::BoxType() const { return FOURCC_SBGP; }
|
| +
|
| +bool SampleToGroup::Parse(BoxReader* reader) {
|
| + RCHECK(reader->ReadFullBoxHeader() &&
|
| + reader->Read4(&grouping_type));
|
| +
|
| + if (reader->version() == 1)
|
| + RCHECK(reader->Read4(&grouping_type_parameter));
|
| +
|
| + if (grouping_type != FOURCC_SEIG) {
|
| + DLOG(WARNING) << "SampleToGroup box with grouping_type '" << grouping_type
|
| + << "' is not supported.";
|
| + return true;
|
| + }
|
| +
|
| + uint32 count;
|
| + RCHECK(reader->Read4(&count));
|
| + entries.resize(count);
|
| + for (uint32 i = 0; i < count; ++i) {
|
| + RCHECK(reader->Read4(&entries[i].sample_count) &&
|
| + reader->Read4(&entries[i].group_description_index));
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +CencSampleEncryptionInfoEntry::CencSampleEncryptionInfoEntry()
|
| + : is_encrypted(false), iv_size(0) {}
|
| +CencSampleEncryptionInfoEntry::~CencSampleEncryptionInfoEntry() {}
|
| +
|
| +SampleGroupDescription::SampleGroupDescription() : grouping_type(0) {}
|
| +SampleGroupDescription::~SampleGroupDescription() {}
|
| +FourCC SampleGroupDescription::BoxType() const { return FOURCC_SGPD; }
|
| +
|
| +bool SampleGroupDescription::Parse(BoxReader* reader) {
|
| + RCHECK(reader->ReadFullBoxHeader() &&
|
| + reader->Read4(&grouping_type));
|
| +
|
| + if (grouping_type != FOURCC_SEIG) {
|
| + DLOG(WARNING) << "SampleGroupDescription box with grouping_type '"
|
| + << grouping_type << "' is not supported.";
|
| + return true;
|
| + }
|
| +
|
| + const uint8 version = reader->version();
|
| +
|
| + const size_t kKeyIdSize = 16;
|
| + const size_t kEntrySize = sizeof(uint32) + kKeyIdSize;
|
| + uint32 default_length = 0;
|
| + if (version == 1) {
|
| + RCHECK(reader->Read4(&default_length));
|
| + RCHECK(default_length == 0 || default_length >= kEntrySize);
|
| + }
|
| +
|
| + uint32 count;
|
| + RCHECK(reader->Read4(&count));
|
| + entries.resize(count);
|
| + for (uint32 i = 0; i < count; ++i) {
|
| + if (version == 1) {
|
| + if (default_length == 0) {
|
| + uint32 description_length = 0;
|
| + RCHECK(reader->Read4(&description_length));
|
| + RCHECK(description_length >= kEntrySize);
|
| + }
|
| + }
|
| +
|
| + uint8 flag;
|
| + RCHECK(reader->SkipBytes(2) && // reserved.
|
| + reader->Read1(&flag) &&
|
| + reader->Read1(&entries[i].iv_size) &&
|
| + reader->ReadVec(&entries[i].key_id, kKeyIdSize));
|
| +
|
| + entries[i].is_encrypted = (flag != 0);
|
| + if (entries[i].is_encrypted) {
|
| + RCHECK(entries[i].iv_size == 8 || entries[i].iv_size == 16);
|
| + } else {
|
| + RCHECK(entries[i].iv_size == 0);
|
| + }
|
| + }
|
| + return true;
|
| +}
|
| +
|
| TrackFragment::TrackFragment() {}
|
| TrackFragment::~TrackFragment() {}
|
| FourCC TrackFragment::BoxType() const { return FOURCC_TRAF; }
|
|
|
| bool TrackFragment::Parse(BoxReader* reader) {
|
| - return reader->ScanChildren() &&
|
| + RCHECK(reader->ScanChildren() &&
|
| reader->ReadChild(&header) &&
|
| // Media Source specific: 'tfdt' required
|
| reader->ReadChild(&decode_time) &&
|
| reader->MaybeReadChildren(&runs) &&
|
| reader->MaybeReadChild(&auxiliary_offset) &&
|
| reader->MaybeReadChild(&auxiliary_size) &&
|
| - reader->MaybeReadChild(&sdtp);
|
| + reader->MaybeReadChild(&sdtp));
|
| +
|
| + // There could be multiple SampleGroupDescription and SampleToGroup boxes with
|
| + // different grouping types. For common encryption, the relevant grouping type
|
| + // is 'seig'. Continue reading until 'seig' is found, or until running out of
|
| + // child boxes.
|
| + while (sample_group_description.grouping_type != FOURCC_SEIG &&
|
| + reader->HasChild(&sample_group_description)) {
|
| + RCHECK(reader->ReadChild(&sample_group_description));
|
| + }
|
| + while (sample_to_group.grouping_type != FOURCC_SEIG &&
|
| + reader->HasChild(&sample_to_group)) {
|
| + RCHECK(reader->ReadChild(&sample_to_group));
|
| + }
|
| + return true;
|
| }
|
|
|
| MovieFragment::MovieFragment() {}
|
|
|