OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/formats/mp4/box_definitions.h" | 5 #include "media/formats/mp4/box_definitions.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/formats/mp4/es_descriptor.h" | 8 #include "media/formats/mp4/es_descriptor.h" |
9 #include "media/formats/mp4/rcheck.h" | 9 #include "media/formats/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 // Don't bother validating the box's contents. |
30 RCHECK(reader->ReadFullBoxHeader() && | |
31 reader->ReadVec(&system_id, 16)); | |
32 | |
33 // Copy the entire box, including the header, for passing to EME as initData. | 30 // Copy the entire box, including the header, for passing to EME as initData. |
34 DCHECK(raw_box.empty()); | 31 DCHECK(raw_box.empty()); |
35 raw_box.assign(reader->data(), reader->data() + reader->size()); | 32 raw_box.assign(reader->data(), reader->data() + reader->size()); |
36 return true; | 33 return true; |
37 } | 34 } |
38 | 35 |
| 36 FullProtectionSystemSpecificHeader::FullProtectionSystemSpecificHeader() {} |
| 37 FullProtectionSystemSpecificHeader::~FullProtectionSystemSpecificHeader() {} |
| 38 FourCC FullProtectionSystemSpecificHeader::BoxType() const { |
| 39 return FOURCC_PSSH; |
| 40 } |
| 41 |
| 42 // The format of a 'pssh' box is as follows: |
| 43 // unsigned int(32) size; |
| 44 // unsigned int(32) type = "pssh"; |
| 45 // if (size==1) { |
| 46 // unsigned int(64) largesize; |
| 47 // } else if (size==0) { |
| 48 // -- box extends to end of file |
| 49 // } |
| 50 // unsigned int(8) version; |
| 51 // bit(24) flags; |
| 52 // unsigned int(8)[16] SystemID; |
| 53 // if (version > 0) |
| 54 // { |
| 55 // unsigned int(32) KID_count; |
| 56 // { |
| 57 // unsigned int(8)[16] KID; |
| 58 // } [KID_count] |
| 59 // } |
| 60 // unsigned int(32) DataSize; |
| 61 // unsigned int(8)[DataSize] Data; |
| 62 |
| 63 bool FullProtectionSystemSpecificHeader::Parse(mp4::BoxReader* reader) { |
| 64 RCHECK(reader->type() == BoxType() && reader->ReadFullBoxHeader()); |
| 65 |
| 66 // Only versions 0 and 1 of the 'pssh' boxes are supported. Any other |
| 67 // versions are ignored. |
| 68 RCHECK(reader->version() == 0 || reader->version() == 1); |
| 69 RCHECK(reader->flags() == 0); |
| 70 RCHECK(reader->ReadVec(&system_id, 16)); |
| 71 |
| 72 if (reader->version() > 0) { |
| 73 uint32_t kid_count; |
| 74 RCHECK(reader->Read4(&kid_count)); |
| 75 for (uint32_t i = 0; i < kid_count; ++i) { |
| 76 std::vector<uint8_t> kid; |
| 77 RCHECK(reader->ReadVec(&kid, 16)); |
| 78 key_ids.push_back(kid); |
| 79 } |
| 80 } |
| 81 |
| 82 uint32_t data_size; |
| 83 RCHECK(reader->Read4(&data_size)); |
| 84 RCHECK(reader->ReadVec(&data, data_size)); |
| 85 return true; |
| 86 } |
| 87 |
39 SampleAuxiliaryInformationOffset::SampleAuxiliaryInformationOffset() {} | 88 SampleAuxiliaryInformationOffset::SampleAuxiliaryInformationOffset() {} |
40 SampleAuxiliaryInformationOffset::~SampleAuxiliaryInformationOffset() {} | 89 SampleAuxiliaryInformationOffset::~SampleAuxiliaryInformationOffset() {} |
41 FourCC SampleAuxiliaryInformationOffset::BoxType() const { return FOURCC_SAIO; } | 90 FourCC SampleAuxiliaryInformationOffset::BoxType() const { return FOURCC_SAIO; } |
42 | 91 |
43 bool SampleAuxiliaryInformationOffset::Parse(BoxReader* reader) { | 92 bool SampleAuxiliaryInformationOffset::Parse(BoxReader* reader) { |
44 RCHECK(reader->ReadFullBoxHeader()); | 93 RCHECK(reader->ReadFullBoxHeader()); |
45 if (reader->flags() & 1) | 94 if (reader->flags() & 1) |
46 RCHECK(reader->SkipBytes(8)); | 95 RCHECK(reader->SkipBytes(8)); |
47 | 96 |
48 uint32 count; | 97 uint32 count; |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on( | 999 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on( |
951 size_t i) const { | 1000 size_t i) const { |
952 if (i >= sample_depends_on_.size()) | 1001 if (i >= sample_depends_on_.size()) |
953 return kSampleDependsOnUnknown; | 1002 return kSampleDependsOnUnknown; |
954 | 1003 |
955 return sample_depends_on_[i]; | 1004 return sample_depends_on_[i]; |
956 } | 1005 } |
957 | 1006 |
958 } // namespace mp4 | 1007 } // namespace mp4 |
959 } // namespace media | 1008 } // namespace media |
OLD | NEW |