Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Unified Diff: media/formats/mp4/box_definitions.cc

Issue 1149023002: Combine 'pssh' parsing routines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: size_t Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/formats/mp4/box_definitions.h ('k') | media/formats/mp4/box_reader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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; }
« no previous file with comments | « media/formats/mp4/box_definitions.h ('k') | media/formats/mp4/box_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698