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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "media/base/video_types.h" | 12 #include "media/base/video_types.h" |
13 #include "media/base/video_util.h" | 13 #include "media/base/video_util.h" |
14 #include "media/formats/mp4/avc.h" | 14 #include "media/formats/mp4/avc.h" |
15 #include "media/formats/mp4/es_descriptor.h" | 15 #include "media/formats/mp4/es_descriptor.h" |
16 #include "media/formats/mp4/rcheck.h" | 16 #include "media/formats/mp4/rcheck.h" |
17 #include "media/media_features.h" | 17 #include "media/media_features.h" |
18 | 18 |
19 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 19 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
20 #include "media/formats/mp4/hevc.h" | 20 #include "media/formats/mp4/hevc.h" |
21 #endif | 21 #endif |
22 | 22 |
23 namespace media { | 23 namespace media { |
24 namespace mp4 { | 24 namespace mp4 { |
25 | 25 |
26 namespace { | |
27 | |
28 const size_t kKeyIdSize = 16; | |
29 | |
30 } // namespace | |
31 | |
26 FileType::FileType() {} | 32 FileType::FileType() {} |
27 FileType::FileType(const FileType& other) = default; | 33 FileType::FileType(const FileType& other) = default; |
28 FileType::~FileType() {} | 34 FileType::~FileType() {} |
29 FourCC FileType::BoxType() const { return FOURCC_FTYP; } | 35 FourCC FileType::BoxType() const { return FOURCC_FTYP; } |
30 | 36 |
31 bool FileType::Parse(BoxReader* reader) { | 37 bool FileType::Parse(BoxReader* reader) { |
32 RCHECK(reader->ReadFourCC(&major_brand) && reader->Read4(&minor_version)); | 38 RCHECK(reader->ReadFourCC(&major_brand) && reader->Read4(&minor_version)); |
33 size_t num_brands = (reader->size() - reader->pos()) / sizeof(FourCC); | 39 size_t num_brands = (reader->size() - reader->pos()) / sizeof(FourCC); |
34 return reader->SkipBytes(sizeof(FourCC) * num_brands); // compatible_brands | 40 return reader->SkipBytes(sizeof(FourCC) * num_brands); // compatible_brands |
35 } | 41 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 | 156 |
151 SampleEncryptionEntry::SampleEncryptionEntry() {} | 157 SampleEncryptionEntry::SampleEncryptionEntry() {} |
152 SampleEncryptionEntry::SampleEncryptionEntry( | 158 SampleEncryptionEntry::SampleEncryptionEntry( |
153 const SampleEncryptionEntry& other) = default; | 159 const SampleEncryptionEntry& other) = default; |
154 SampleEncryptionEntry::~SampleEncryptionEntry() {} | 160 SampleEncryptionEntry::~SampleEncryptionEntry() {} |
155 | 161 |
156 bool SampleEncryptionEntry::Parse(BufferReader* reader, | 162 bool SampleEncryptionEntry::Parse(BufferReader* reader, |
157 uint8_t iv_size, | 163 uint8_t iv_size, |
158 bool has_subsamples) { | 164 bool has_subsamples) { |
159 // According to ISO/IEC FDIS 23001-7: CENC spec, IV should be either | 165 // According to ISO/IEC FDIS 23001-7: CENC spec, IV should be either |
160 // 64-bit (8-byte) or 128-bit (16-byte). | 166 // 64-bit (8-byte) or 128-bit (16-byte). Subsequent editions allow |iv_size| |
ddorwin
2016/06/17 23:32:40
nit: It would be nice to specify which edition add
dougsteed
2016/10/10 18:18:01
Done.
| |
161 RCHECK(iv_size == 8 || iv_size == 16); | 167 // to be 0, for the case of a "constant IV". In this case, the existence of |
168 // the constant IV must be ensured by the caller. | |
ddorwin
2016/06/17 23:32:40
Do you mean the caller of this function? I assume
dougsteed
2016/10/10 18:18:01
Actually it's in track_run_iterator.cc, line 502.
| |
169 RCHECK(iv_size == 0 || iv_size == 8 || iv_size == 16); | |
162 | 170 |
163 memset(initialization_vector, 0, sizeof(initialization_vector)); | 171 memset(initialization_vector, 0, sizeof(initialization_vector)); |
164 for (uint8_t i = 0; i < iv_size; i++) | 172 for (uint8_t i = 0; i < iv_size; i++) |
165 RCHECK(reader->Read1(initialization_vector + i)); | 173 RCHECK(reader->Read1(initialization_vector + i)); |
166 | 174 |
167 if (!has_subsamples) { | 175 if (!has_subsamples) { |
168 subsamples.clear(); | 176 subsamples.clear(); |
169 return true; | 177 return true; |
170 } | 178 } |
171 | 179 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 FourCC SchemeType::BoxType() const { return FOURCC_SCHM; } | 233 FourCC SchemeType::BoxType() const { return FOURCC_SCHM; } |
226 | 234 |
227 bool SchemeType::Parse(BoxReader* reader) { | 235 bool SchemeType::Parse(BoxReader* reader) { |
228 RCHECK(reader->ReadFullBoxHeader() && | 236 RCHECK(reader->ReadFullBoxHeader() && |
229 reader->ReadFourCC(&type) && | 237 reader->ReadFourCC(&type) && |
230 reader->Read4(&version)); | 238 reader->Read4(&version)); |
231 return true; | 239 return true; |
232 } | 240 } |
233 | 241 |
234 TrackEncryption::TrackEncryption() | 242 TrackEncryption::TrackEncryption() |
235 : is_encrypted(false), default_iv_size(0) { | 243 : is_encrypted(false), |
244 default_iv_size(0) | |
245 #if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME) | |
246 , | |
247 default_crypt_byte_block(0), | |
248 default_skip_byte_block(0), | |
249 default_constant_iv_size(0) | |
250 #endif | |
251 { | |
236 } | 252 } |
237 TrackEncryption::TrackEncryption(const TrackEncryption& other) = default; | 253 TrackEncryption::TrackEncryption(const TrackEncryption& other) = default; |
238 TrackEncryption::~TrackEncryption() {} | 254 TrackEncryption::~TrackEncryption() {} |
239 FourCC TrackEncryption::BoxType() const { return FOURCC_TENC; } | 255 FourCC TrackEncryption::BoxType() const { return FOURCC_TENC; } |
240 | 256 |
241 bool TrackEncryption::Parse(BoxReader* reader) { | 257 bool TrackEncryption::Parse(BoxReader* reader) { |
242 uint8_t flag; | 258 uint8_t flag; |
243 RCHECK(reader->ReadFullBoxHeader() && | 259 uint8_t possible_pattern_info; |
244 reader->SkipBytes(2) && | 260 RCHECK(reader->ReadFullBoxHeader() && reader->SkipBytes(1) && |
ddorwin
2016/06/17 23:32:40
What is being skipped? Should we document this?
dougsteed
2016/10/10 18:18:01
A reserved byte.
| |
245 reader->Read1(&flag) && | 261 reader->Read1(&possible_pattern_info) && reader->Read1(&flag) && |
ddorwin
2016/06/17 23:32:40
Did they use reserved bits or something? Why is th
dougsteed
2016/10/10 18:18:01
Yes. There were two reserved bytes. They reassigne
| |
246 reader->Read1(&default_iv_size) && | 262 reader->Read1(&default_iv_size) && |
247 reader->ReadVec(&default_kid, 16)); | 263 reader->ReadVec(&default_kid, kKeyIdSize)); |
248 is_encrypted = (flag != 0); | 264 is_encrypted = (flag != 0); |
249 if (is_encrypted) { | 265 if (default_iv_size != 0) { |
250 RCHECK(default_iv_size == 8 || default_iv_size == 16); | 266 RCHECK(default_iv_size == 8 || default_iv_size == 16); |
267 #if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME) | |
ddorwin
2016/06/17 23:32:40
Should this be inside the else if - with a #else t
dougsteed
2016/10/10 18:18:01
I agree. It was unclear. Rearranged it a bit to (h
| |
268 } else if (is_encrypted) { | |
ddorwin
2016/06/17 23:32:40
What is the relationship between this block and de
dougsteed
2016/10/10 18:18:01
see above.
| |
269 if (reader->version() > 0) { | |
270 default_crypt_byte_block = (possible_pattern_info >> 4) & 0x0f; | |
271 default_skip_byte_block = possible_pattern_info & 0x0f; | |
272 } | |
273 RCHECK(reader->Read1(&default_constant_iv_size) && | |
274 (default_constant_iv_size == 8 || default_constant_iv_size == 16)); | |
275 memset(default_constant_iv, 0, sizeof(default_constant_iv)); | |
276 for (uint8_t i = 0; i < default_constant_iv_size; i++) | |
277 RCHECK(reader->Read1(default_constant_iv + i)); | |
278 #endif | |
251 } else { | 279 } else { |
252 RCHECK(default_iv_size == 0); | 280 RCHECK(!is_encrypted); |
253 } | 281 } |
254 return true; | 282 return true; |
255 } | 283 } |
256 | 284 |
257 SchemeInfo::SchemeInfo() {} | 285 SchemeInfo::SchemeInfo() {} |
258 SchemeInfo::SchemeInfo(const SchemeInfo& other) = default; | 286 SchemeInfo::SchemeInfo(const SchemeInfo& other) = default; |
259 SchemeInfo::~SchemeInfo() {} | 287 SchemeInfo::~SchemeInfo() {} |
260 FourCC SchemeInfo::BoxType() const { return FOURCC_SCHI; } | 288 FourCC SchemeInfo::BoxType() const { return FOURCC_SCHI; } |
261 | 289 |
262 bool SchemeInfo::Parse(BoxReader* reader) { | 290 bool SchemeInfo::Parse(BoxReader* reader) { |
263 return reader->ScanChildren() && reader->ReadChild(&track_encryption); | 291 return reader->ScanChildren() && reader->ReadChild(&track_encryption); |
264 } | 292 } |
265 | 293 |
266 ProtectionSchemeInfo::ProtectionSchemeInfo() {} | 294 ProtectionSchemeInfo::ProtectionSchemeInfo() {} |
267 ProtectionSchemeInfo::ProtectionSchemeInfo(const ProtectionSchemeInfo& other) = | 295 ProtectionSchemeInfo::ProtectionSchemeInfo(const ProtectionSchemeInfo& other) = |
268 default; | 296 default; |
269 ProtectionSchemeInfo::~ProtectionSchemeInfo() {} | 297 ProtectionSchemeInfo::~ProtectionSchemeInfo() {} |
270 FourCC ProtectionSchemeInfo::BoxType() const { return FOURCC_SINF; } | 298 FourCC ProtectionSchemeInfo::BoxType() const { return FOURCC_SINF; } |
271 | 299 |
272 bool ProtectionSchemeInfo::Parse(BoxReader* reader) { | 300 bool ProtectionSchemeInfo::Parse(BoxReader* reader) { |
273 RCHECK(reader->ScanChildren() && | 301 RCHECK(reader->ScanChildren() && |
274 reader->ReadChild(&format) && | 302 reader->ReadChild(&format) && |
275 reader->ReadChild(&type)); | 303 reader->ReadChild(&type)); |
276 if (type.type == FOURCC_CENC) | 304 if (HasSupportedScheme()) |
277 RCHECK(reader->ReadChild(&info)); | 305 RCHECK(reader->ReadChild(&info)); |
278 // Other protection schemes are silently ignored. Since the protection scheme | 306 // Other protection schemes are silently ignored. Since the protection scheme |
279 // type can't be determined until this box is opened, we return 'true' for | 307 // type can't be determined until this box is opened, we return 'true' for |
280 // non-CENC protection scheme types. It is the parent box's responsibility to | 308 // non-CENC protection scheme types. It is the parent box's responsibility to |
281 // ensure that this scheme type is a supported one. | 309 // ensure that this scheme type is a supported one. |
282 return true; | 310 return true; |
283 } | 311 } |
284 | 312 |
313 bool ProtectionSchemeInfo::HasSupportedScheme() const { | |
314 FourCC fourCC = type.type; | |
315 if (fourCC == FOURCC_CENC) | |
316 return true; | |
317 #if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME) | |
318 return fourCC == FOURCC_CBCS; | |
ddorwin
2016/06/17 23:32:40
nit: If you follow the style for CENC, you don't n
dougsteed
2016/10/10 18:18:01
Done.
| |
319 #else | |
320 return false; | |
321 #endif | |
322 } | |
323 | |
285 MovieHeader::MovieHeader() | 324 MovieHeader::MovieHeader() |
286 : creation_time(0), | 325 : creation_time(0), |
287 modification_time(0), | 326 modification_time(0), |
288 timescale(0), | 327 timescale(0), |
289 duration(0), | 328 duration(0), |
290 rate(-1), | 329 rate(-1), |
291 volume(-1), | 330 volume(-1), |
292 next_track_id(0) {} | 331 next_track_id(0) {} |
293 MovieHeader::MovieHeader(const MovieHeader& other) = default; | 332 MovieHeader::MovieHeader(const MovieHeader& other) = default; |
294 MovieHeader::~MovieHeader() {} | 333 MovieHeader::~MovieHeader() {} |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 reader->Read2(&width) && | 641 reader->Read2(&width) && |
603 reader->Read2(&height) && | 642 reader->Read2(&height) && |
604 reader->SkipBytes(50)); | 643 reader->SkipBytes(50)); |
605 | 644 |
606 RCHECK(reader->ScanChildren() && | 645 RCHECK(reader->ScanChildren() && |
607 reader->MaybeReadChild(&pixel_aspect)); | 646 reader->MaybeReadChild(&pixel_aspect)); |
608 | 647 |
609 if (format == FOURCC_ENCV) { | 648 if (format == FOURCC_ENCV) { |
610 // Continue scanning until a recognized protection scheme is found, or until | 649 // Continue scanning until a recognized protection scheme is found, or until |
611 // we run out of protection schemes. | 650 // we run out of protection schemes. |
612 while (sinf.type.type != FOURCC_CENC) { | 651 while (!sinf.HasSupportedScheme()) { |
613 if (!reader->ReadChild(&sinf)) | 652 if (!reader->ReadChild(&sinf)) |
614 return false; | 653 return false; |
615 } | 654 } |
616 } | 655 } |
617 | 656 |
618 const FourCC actual_format = | 657 const FourCC actual_format = |
619 format == FOURCC_ENCV ? sinf.format.format : format; | 658 format == FOURCC_ENCV ? sinf.format.format : format; |
620 switch (actual_format) { | 659 switch (actual_format) { |
621 case FOURCC_AVC1: | 660 case FOURCC_AVC1: |
622 case FOURCC_AVC3: { | 661 case FOURCC_AVC3: { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
742 reader->Read2(&samplesize) && | 781 reader->Read2(&samplesize) && |
743 reader->SkipBytes(4) && | 782 reader->SkipBytes(4) && |
744 reader->Read4(&samplerate)); | 783 reader->Read4(&samplerate)); |
745 // Convert from 16.16 fixed point to integer | 784 // Convert from 16.16 fixed point to integer |
746 samplerate >>= 16; | 785 samplerate >>= 16; |
747 | 786 |
748 RCHECK(reader->ScanChildren()); | 787 RCHECK(reader->ScanChildren()); |
749 if (format == FOURCC_ENCA) { | 788 if (format == FOURCC_ENCA) { |
750 // Continue scanning until a recognized protection scheme is found, or until | 789 // Continue scanning until a recognized protection scheme is found, or until |
751 // we run out of protection schemes. | 790 // we run out of protection schemes. |
752 while (sinf.type.type != FOURCC_CENC) { | 791 while (!sinf.HasSupportedScheme()) { |
753 if (!reader->ReadChild(&sinf)) | 792 if (!reader->ReadChild(&sinf)) |
754 return false; | 793 return false; |
755 } | 794 } |
756 } | 795 } |
757 | 796 |
758 // ESDS is not valid in case of EAC3. | 797 // ESDS is not valid in case of EAC3. |
759 RCHECK(reader->MaybeReadChild(&esds)); | 798 RCHECK(reader->MaybeReadChild(&esds)); |
760 return true; | 799 return true; |
761 } | 800 } |
762 | 801 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1082 RCHECK(reader->Read4(&count)); | 1121 RCHECK(reader->Read4(&count)); |
1083 entries.resize(count); | 1122 entries.resize(count); |
1084 for (uint32_t i = 0; i < count; ++i) { | 1123 for (uint32_t i = 0; i < count; ++i) { |
1085 RCHECK(reader->Read4(&entries[i].sample_count) && | 1124 RCHECK(reader->Read4(&entries[i].sample_count) && |
1086 reader->Read4(&entries[i].group_description_index)); | 1125 reader->Read4(&entries[i].group_description_index)); |
1087 } | 1126 } |
1088 return true; | 1127 return true; |
1089 } | 1128 } |
1090 | 1129 |
1091 CencSampleEncryptionInfoEntry::CencSampleEncryptionInfoEntry() | 1130 CencSampleEncryptionInfoEntry::CencSampleEncryptionInfoEntry() |
1092 : is_encrypted(false), iv_size(0) {} | 1131 : is_encrypted(false), |
1132 iv_size(0) | |
1133 #if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME) | |
1134 , | |
1135 crypt_byte_block(0), | |
1136 skip_byte_block(0), | |
1137 constant_iv_size(0) | |
1138 #endif | |
1139 { | |
1140 } | |
1093 CencSampleEncryptionInfoEntry::CencSampleEncryptionInfoEntry( | 1141 CencSampleEncryptionInfoEntry::CencSampleEncryptionInfoEntry( |
1094 const CencSampleEncryptionInfoEntry& other) = default; | 1142 const CencSampleEncryptionInfoEntry& other) = default; |
1095 CencSampleEncryptionInfoEntry::~CencSampleEncryptionInfoEntry() {} | 1143 CencSampleEncryptionInfoEntry::~CencSampleEncryptionInfoEntry() {} |
1096 | 1144 |
1145 bool CencSampleEncryptionInfoEntry::Parse(BoxReader* reader) { | |
1146 uint8_t flag; | |
1147 uint8_t possible_pattern_info; | |
1148 RCHECK(reader->SkipBytes(1) && // reserved. | |
1149 reader->Read1(&possible_pattern_info) && reader->Read1(&flag) && | |
1150 reader->Read1(&iv_size) && reader->ReadVec(&key_id, kKeyIdSize)); | |
1151 | |
1152 is_encrypted = (flag != 0); | |
1153 if (iv_size != 0) { | |
ddorwin
2016/06/17 23:32:40
ditto on structure
note to self: I skipped this.
dougsteed
2016/10/10 18:18:01
Done.
| |
1154 RCHECK(iv_size == 8 || iv_size == 16); | |
1155 #if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME) | |
1156 } else if (is_encrypted) { | |
1157 crypt_byte_block = (possible_pattern_info >> 4) & 0x0f; | |
1158 skip_byte_block = possible_pattern_info & 0x0f; | |
1159 RCHECK(reader->Read1(&constant_iv_size) && | |
1160 (constant_iv_size == 8 || constant_iv_size == 16)); | |
1161 memset(constant_iv, 0, sizeof(constant_iv)); | |
1162 for (uint8_t i = 0; i < constant_iv_size; i++) | |
1163 RCHECK(reader->Read1(constant_iv + i)); | |
1164 #endif | |
1165 } else { | |
1166 RCHECK(!is_encrypted); | |
1167 } | |
1168 return true; | |
1169 } | |
1170 | |
1097 SampleGroupDescription::SampleGroupDescription() : grouping_type(0) {} | 1171 SampleGroupDescription::SampleGroupDescription() : grouping_type(0) {} |
1098 SampleGroupDescription::SampleGroupDescription( | 1172 SampleGroupDescription::SampleGroupDescription( |
1099 const SampleGroupDescription& other) = default; | 1173 const SampleGroupDescription& other) = default; |
1100 SampleGroupDescription::~SampleGroupDescription() {} | 1174 SampleGroupDescription::~SampleGroupDescription() {} |
1101 FourCC SampleGroupDescription::BoxType() const { return FOURCC_SGPD; } | 1175 FourCC SampleGroupDescription::BoxType() const { return FOURCC_SGPD; } |
1102 | 1176 |
1103 bool SampleGroupDescription::Parse(BoxReader* reader) { | 1177 bool SampleGroupDescription::Parse(BoxReader* reader) { |
1104 RCHECK(reader->ReadFullBoxHeader() && | 1178 RCHECK(reader->ReadFullBoxHeader() && |
1105 reader->Read4(&grouping_type)); | 1179 reader->Read4(&grouping_type)); |
1106 | 1180 |
1107 if (grouping_type != FOURCC_SEIG) { | 1181 if (grouping_type != FOURCC_SEIG) { |
1108 DLOG(WARNING) << "SampleGroupDescription box with grouping_type '" | 1182 DLOG(WARNING) << "SampleGroupDescription box with grouping_type '" |
1109 << grouping_type << "' is not supported."; | 1183 << grouping_type << "' is not supported."; |
1110 return true; | 1184 return true; |
1111 } | 1185 } |
1112 | 1186 |
1113 const uint8_t version = reader->version(); | 1187 const uint8_t version = reader->version(); |
1114 | 1188 |
1115 const size_t kKeyIdSize = 16; | |
1116 const size_t kEntrySize = sizeof(uint32_t) + kKeyIdSize; | 1189 const size_t kEntrySize = sizeof(uint32_t) + kKeyIdSize; |
1117 uint32_t default_length = 0; | 1190 uint32_t default_length = 0; |
1118 if (version == 1) { | 1191 if (version == 1) { |
1119 RCHECK(reader->Read4(&default_length)); | 1192 RCHECK(reader->Read4(&default_length)); |
1120 RCHECK(default_length == 0 || default_length >= kEntrySize); | 1193 RCHECK(default_length == 0 || default_length >= kEntrySize); |
1121 } | 1194 } |
1122 | 1195 |
1123 uint32_t count; | 1196 uint32_t count; |
1124 RCHECK(reader->Read4(&count)); | 1197 RCHECK(reader->Read4(&count)); |
1125 entries.resize(count); | 1198 entries.resize(count); |
1126 for (uint32_t i = 0; i < count; ++i) { | 1199 for (uint32_t i = 0; i < count; ++i) { |
1127 if (version == 1) { | 1200 if (version == 1) { |
1128 if (default_length == 0) { | 1201 if (default_length == 0) { |
1129 uint32_t description_length = 0; | 1202 uint32_t description_length = 0; |
1130 RCHECK(reader->Read4(&description_length)); | 1203 RCHECK(reader->Read4(&description_length)); |
1131 RCHECK(description_length >= kEntrySize); | 1204 RCHECK(description_length >= kEntrySize); |
1132 } | 1205 } |
1133 } | 1206 } |
1134 | 1207 RCHECK(entries[i].Parse(reader)); |
1135 uint8_t flag; | |
1136 RCHECK(reader->SkipBytes(2) && // reserved. | |
1137 reader->Read1(&flag) && | |
1138 reader->Read1(&entries[i].iv_size) && | |
1139 reader->ReadVec(&entries[i].key_id, kKeyIdSize)); | |
1140 | |
1141 entries[i].is_encrypted = (flag != 0); | |
1142 if (entries[i].is_encrypted) { | |
1143 RCHECK(entries[i].iv_size == 8 || entries[i].iv_size == 16); | |
1144 } else { | |
1145 RCHECK(entries[i].iv_size == 0); | |
1146 } | |
1147 } | 1208 } |
1148 return true; | 1209 return true; |
1149 } | 1210 } |
1150 | 1211 |
1151 TrackFragment::TrackFragment() {} | 1212 TrackFragment::TrackFragment() {} |
1152 TrackFragment::TrackFragment(const TrackFragment& other) = default; | 1213 TrackFragment::TrackFragment(const TrackFragment& other) = default; |
1153 TrackFragment::~TrackFragment() {} | 1214 TrackFragment::~TrackFragment() {} |
1154 FourCC TrackFragment::BoxType() const { return FOURCC_TRAF; } | 1215 FourCC TrackFragment::BoxType() const { return FOURCC_TRAF; } |
1155 | 1216 |
1156 bool TrackFragment::Parse(BoxReader* reader) { | 1217 bool TrackFragment::Parse(BoxReader* reader) { |
1157 RCHECK(reader->ScanChildren() && | 1218 RCHECK(reader->ScanChildren() && reader->ReadChild(&header) && |
1158 reader->ReadChild(&header) && | |
1159 // Media Source specific: 'tfdt' required | 1219 // Media Source specific: 'tfdt' required |
1160 reader->ReadChild(&decode_time) && | 1220 reader->ReadChild(&decode_time) && reader->MaybeReadChildren(&runs) && |
1161 reader->MaybeReadChildren(&runs) && | |
1162 reader->MaybeReadChild(&auxiliary_offset) && | 1221 reader->MaybeReadChild(&auxiliary_offset) && |
1163 reader->MaybeReadChild(&auxiliary_size) && | 1222 reader->MaybeReadChild(&auxiliary_size) && |
1164 reader->MaybeReadChild(&sdtp)); | 1223 reader->MaybeReadChild(&sdtp) && |
1224 reader->MaybeReadChild(&sample_encryption)); | |
ddorwin
2016/06/17 23:32:40
Was this missed in a previous CL?
dougsteed
2016/10/10 18:18:01
It looks like this box was added in the 2nd Editio
| |
1165 | 1225 |
1166 // There could be multiple SampleGroupDescription and SampleToGroup boxes with | 1226 // There could be multiple SampleGroupDescription and SampleToGroup boxes with |
1167 // different grouping types. For common encryption, the relevant grouping type | 1227 // different grouping types. For common encryption, the relevant grouping type |
1168 // is 'seig'. Continue reading until 'seig' is found, or until running out of | 1228 // is 'seig'. Continue reading until 'seig' is found, or until running out of |
1169 // child boxes. | 1229 // child boxes. |
1170 while (reader->HasChild(&sample_group_description)) { | 1230 while (reader->HasChild(&sample_group_description)) { |
1171 RCHECK(reader->ReadChild(&sample_group_description)); | 1231 RCHECK(reader->ReadChild(&sample_group_description)); |
1172 if (sample_group_description.grouping_type == FOURCC_SEIG) | 1232 if (sample_group_description.grouping_type == FOURCC_SEIG) |
1173 break; | 1233 break; |
1174 sample_group_description.entries.clear(); | 1234 sample_group_description.entries.clear(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1224 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on( | 1284 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on( |
1225 size_t i) const { | 1285 size_t i) const { |
1226 if (i >= sample_depends_on_.size()) | 1286 if (i >= sample_depends_on_.size()) |
1227 return kSampleDependsOnUnknown; | 1287 return kSampleDependsOnUnknown; |
1228 | 1288 |
1229 return sample_depends_on_[i]; | 1289 return sample_depends_on_[i]; |
1230 } | 1290 } |
1231 | 1291 |
1232 } // namespace mp4 | 1292 } // namespace mp4 |
1233 } // namespace media | 1293 } // namespace media |
OLD | NEW |