Index: media/formats/mp4/box_definitions.cc |
diff --git a/media/formats/mp4/box_definitions.cc b/media/formats/mp4/box_definitions.cc |
index 5a15240ebbc0f8b860fa55dba16daaa63d9fe68d..72809cfdffdd542a7c97b2563f97bb935bc79779 100644 |
--- a/media/formats/mp4/box_definitions.cc |
+++ b/media/formats/mp4/box_definitions.cc |
@@ -26,16 +26,65 @@ ProtectionSystemSpecificHeader::~ProtectionSystemSpecificHeader() {} |
FourCC ProtectionSystemSpecificHeader::BoxType() const { return FOURCC_PSSH; } |
bool ProtectionSystemSpecificHeader::Parse(BoxReader* reader) { |
- // Validate the box's contents and hang on to the system ID. |
- RCHECK(reader->ReadFullBoxHeader() && |
- reader->ReadVec(&system_id, 16)); |
- |
+ // Don't bother validating the box's contents. |
// Copy the entire box, including the header, for passing to EME as initData. |
DCHECK(raw_box.empty()); |
raw_box.assign(reader->data(), reader->data() + reader->size()); |
return true; |
} |
+FullProtectionSystemSpecificHeader::FullProtectionSystemSpecificHeader() {} |
+FullProtectionSystemSpecificHeader::~FullProtectionSystemSpecificHeader() {} |
+FourCC FullProtectionSystemSpecificHeader::BoxType() const { |
+ return FOURCC_PSSH; |
+} |
+ |
+// The format of a 'pssh' box is as follows: |
+// unsigned int(32) size; |
+// unsigned int(32) type = "pssh"; |
+// if (size==1) { |
+// unsigned int(64) largesize; |
+// } else if (size==0) { |
+// -- box extends to end of file |
+// } |
+// unsigned int(8) version; |
+// bit(24) flags; |
+// unsigned int(8)[16] SystemID; |
+// if (version > 0) |
+// { |
+// unsigned int(32) KID_count; |
+// { |
+// unsigned int(8)[16] KID; |
+// } [KID_count] |
+// } |
+// unsigned int(32) DataSize; |
+// unsigned int(8)[DataSize] Data; |
+ |
+bool FullProtectionSystemSpecificHeader::Parse(mp4::BoxReader* reader) { |
+ RCHECK(reader->type() == BoxType() && reader->ReadFullBoxHeader()); |
+ |
+ // Only versions 0 and 1 of the 'pssh' boxes are supported. Any other |
+ // versions are ignored. |
+ RCHECK(reader->version() == 0 || reader->version() == 1); |
+ RCHECK(reader->flags() == 0); |
+ RCHECK(reader->ReadVec(&system_id, 16)); |
+ |
+ if (reader->version() > 0) { |
+ uint32_t kid_count; |
+ RCHECK(reader->Read4(&kid_count)); |
+ for (uint32_t i = 0; i < kid_count; ++i) { |
+ std::vector<uint8_t> kid; |
+ RCHECK(reader->ReadVec(&kid, 16)); |
+ key_ids.push_back(kid); |
+ } |
+ } |
+ |
+ uint32_t data_size; |
+ RCHECK(reader->Read4(&data_size)); |
+ RCHECK(reader->ReadVec(&data, data_size)); |
+ return true; |
+} |
+ |
SampleAuxiliaryInformationOffset::SampleAuxiliaryInformationOffset() {} |
SampleAuxiliaryInformationOffset::~SampleAuxiliaryInformationOffset() {} |
FourCC SampleAuxiliaryInformationOffset::BoxType() const { return FOURCC_SAIO; } |