Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/mp4/box_definitions.h" | 5 #include "media/mp4/box_definitions.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/mp4/es_descriptor.h" | 8 #include "media/mp4/es_descriptor.h" |
| 9 #include "media/mp4/rcheck.h" | 9 #include "media/mp4/rcheck.h" |
| 10 | 10 |
| 11 namespace media { | 11 namespace media { |
| 12 namespace mp4 { | 12 namespace mp4 { |
| 13 | 13 |
| 14 FileType::FileType() {} | 14 FileType::FileType() {} |
| 15 FileType::~FileType() {} | 15 FileType::~FileType() {} |
| 16 FourCC FileType::BoxType() const { return FOURCC_FTYP; } | 16 FourCC FileType::BoxType() const { return FOURCC_FTYP; } |
| 17 | 17 |
| 18 bool FileType::Parse(BoxReader* reader) { | 18 bool FileType::Parse(BoxReader* reader) { |
| 19 RCHECK(reader->ReadFourCC(&major_brand) && reader->Read4(&minor_version)); | 19 RCHECK(reader->ReadFourCC(&major_brand) && reader->Read4(&minor_version)); |
| 20 size_t num_brands = (reader->size() - reader->pos()) / sizeof(FourCC); | 20 size_t num_brands = (reader->size() - reader->pos()) / sizeof(FourCC); |
| 21 return reader->SkipBytes(sizeof(FourCC) * num_brands); // compatible_brands | 21 return reader->SkipBytes(sizeof(FourCC) * num_brands); // compatible_brands |
| 22 } | 22 } |
| 23 | 23 |
| 24 ProtectionSystemSpecificHeader::ProtectionSystemSpecificHeader() {} | 24 ProtectionSystemSpecificHeader::ProtectionSystemSpecificHeader() {} |
| 25 ProtectionSystemSpecificHeader::~ProtectionSystemSpecificHeader() {} | 25 ProtectionSystemSpecificHeader::~ProtectionSystemSpecificHeader() {} |
| 26 FourCC ProtectionSystemSpecificHeader::BoxType() const { return FOURCC_PSSH; } | 26 FourCC ProtectionSystemSpecificHeader::BoxType() const { return FOURCC_PSSH; } |
| 27 | 27 |
| 28 bool ProtectionSystemSpecificHeader::Parse(BoxReader* reader) { | 28 bool ProtectionSystemSpecificHeader::Parse(BoxReader* reader) { |
| 29 // Validate the box's contents and hang on to the system ID. | |
| 29 uint32 size; | 30 uint32 size; |
| 30 return reader->ReadFullBoxHeader() && | 31 RCHECK(reader->ReadFullBoxHeader() && |
| 31 reader->ReadVec(&system_id, 16) && | 32 reader->ReadVec(&system_id, 16) && |
| 32 reader->Read4(&size) && | 33 reader->Read4(&size) && |
| 33 reader->ReadVec(&data, size); | 34 reader->HasBytes(size)); |
| 35 | |
| 36 // Copy the entire box, including the header, for passing to EME as initData. | |
| 37 raw_box.clear(); | |
|
ddorwin
2012/09/21 04:04:28
Should it ever not be empty?
strobe_
2012/09/21 18:29:46
Changed to DCHECK(empty())
| |
| 38 raw_box.insert(raw_box.end(), | |
|
ddorwin
2012/09/21 04:04:28
Odd to use end() when you just cleared it. Can you
strobe_
2012/09/21 18:29:46
Done.
| |
| 39 reader->data(), reader->data() + reader->size()); | |
| 40 return true; | |
| 34 } | 41 } |
| 35 | 42 |
| 36 SampleAuxiliaryInformationOffset::SampleAuxiliaryInformationOffset() {} | 43 SampleAuxiliaryInformationOffset::SampleAuxiliaryInformationOffset() {} |
| 37 SampleAuxiliaryInformationOffset::~SampleAuxiliaryInformationOffset() {} | 44 SampleAuxiliaryInformationOffset::~SampleAuxiliaryInformationOffset() {} |
| 38 FourCC SampleAuxiliaryInformationOffset::BoxType() const { return FOURCC_SAIO; } | 45 FourCC SampleAuxiliaryInformationOffset::BoxType() const { return FOURCC_SAIO; } |
| 39 | 46 |
| 40 bool SampleAuxiliaryInformationOffset::Parse(BoxReader* reader) { | 47 bool SampleAuxiliaryInformationOffset::Parse(BoxReader* reader) { |
| 41 RCHECK(reader->ReadFullBoxHeader()); | 48 RCHECK(reader->ReadFullBoxHeader()); |
| 42 if (reader->flags() & 1) | 49 if (reader->flags() & 1) |
| 43 RCHECK(reader->SkipBytes(8)); | 50 RCHECK(reader->SkipBytes(8)); |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 bool MovieFragment::Parse(BoxReader* reader) { | 749 bool MovieFragment::Parse(BoxReader* reader) { |
| 743 RCHECK(reader->ScanChildren() && | 750 RCHECK(reader->ScanChildren() && |
| 744 reader->ReadChild(&header) && | 751 reader->ReadChild(&header) && |
| 745 reader->ReadChildren(&tracks) && | 752 reader->ReadChildren(&tracks) && |
| 746 reader->MaybeReadChildren(&pssh)); | 753 reader->MaybeReadChildren(&pssh)); |
| 747 return true; | 754 return true; |
| 748 } | 755 } |
| 749 | 756 |
| 750 } // namespace mp4 | 757 } // namespace mp4 |
| 751 } // namespace media | 758 } // namespace media |
| OLD | NEW |