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 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 SchemeType::SchemeType() : type(FOURCC_NULL), version(0) {} | 86 SchemeType::SchemeType() : type(FOURCC_NULL), version(0) {} |
87 SchemeType::~SchemeType() {} | 87 SchemeType::~SchemeType() {} |
88 FourCC SchemeType::BoxType() const { return FOURCC_SCHM; } | 88 FourCC SchemeType::BoxType() const { return FOURCC_SCHM; } |
89 | 89 |
90 bool SchemeType::Parse(BoxReader* reader) { | 90 bool SchemeType::Parse(BoxReader* reader) { |
91 RCHECK(reader->ReadFullBoxHeader() && | 91 RCHECK(reader->ReadFullBoxHeader() && |
92 reader->ReadFourCC(&type) && | 92 reader->ReadFourCC(&type) && |
93 reader->Read4(&version)); | 93 reader->Read4(&version)); |
94 RCHECK(type == FOURCC_CENC); | |
95 return true; | 94 return true; |
96 } | 95 } |
97 | 96 |
98 TrackEncryption::TrackEncryption() | 97 TrackEncryption::TrackEncryption() |
99 : is_encrypted(false), default_iv_size(0) { | 98 : is_encrypted(false), default_iv_size(0) { |
100 } | 99 } |
101 TrackEncryption::~TrackEncryption() {} | 100 TrackEncryption::~TrackEncryption() {} |
102 FourCC TrackEncryption::BoxType() const { return FOURCC_TENC; } | 101 FourCC TrackEncryption::BoxType() const { return FOURCC_TENC; } |
103 | 102 |
104 bool TrackEncryption::Parse(BoxReader* reader) { | 103 bool TrackEncryption::Parse(BoxReader* reader) { |
(...skipping 20 matching lines...) Expand all Loading... |
125 return reader->ScanChildren() && reader->ReadChild(&track_encryption); | 124 return reader->ScanChildren() && reader->ReadChild(&track_encryption); |
126 } | 125 } |
127 | 126 |
128 ProtectionSchemeInfo::ProtectionSchemeInfo() {} | 127 ProtectionSchemeInfo::ProtectionSchemeInfo() {} |
129 ProtectionSchemeInfo::~ProtectionSchemeInfo() {} | 128 ProtectionSchemeInfo::~ProtectionSchemeInfo() {} |
130 FourCC ProtectionSchemeInfo::BoxType() const { return FOURCC_SINF; } | 129 FourCC ProtectionSchemeInfo::BoxType() const { return FOURCC_SINF; } |
131 | 130 |
132 bool ProtectionSchemeInfo::Parse(BoxReader* reader) { | 131 bool ProtectionSchemeInfo::Parse(BoxReader* reader) { |
133 RCHECK(reader->ScanChildren() && | 132 RCHECK(reader->ScanChildren() && |
134 reader->ReadChild(&format) && | 133 reader->ReadChild(&format) && |
135 reader->ReadChild(&type) && | 134 reader->ReadChild(&type)); |
136 reader->ReadChild(&info)); | 135 if (type.type == FOURCC_CENC) |
| 136 RCHECK(reader->ReadChild(&info)); |
| 137 // Other protection schemes are silently ignored. Since the protection scheme |
| 138 // type can't be determined until this box is opened, we return 'true' for |
| 139 // non-CENC protection scheme types. It is the parent box's responsibility to |
| 140 // ensure that this scheme type is a supported one. |
137 return true; | 141 return true; |
138 } | 142 } |
139 | 143 |
140 MovieHeader::MovieHeader() | 144 MovieHeader::MovieHeader() |
141 : creation_time(0), | 145 : creation_time(0), |
142 modification_time(0), | 146 modification_time(0), |
143 timescale(0), | 147 timescale(0), |
144 duration(0), | 148 duration(0), |
145 rate(-1), | 149 rate(-1), |
146 volume(-1), | 150 volume(-1), |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 RCHECK(reader->SkipBytes(6) && | 378 RCHECK(reader->SkipBytes(6) && |
375 reader->Read2(&data_reference_index) && | 379 reader->Read2(&data_reference_index) && |
376 reader->SkipBytes(16) && | 380 reader->SkipBytes(16) && |
377 reader->Read2(&width) && | 381 reader->Read2(&width) && |
378 reader->Read2(&height) && | 382 reader->Read2(&height) && |
379 reader->SkipBytes(50)); | 383 reader->SkipBytes(50)); |
380 | 384 |
381 RCHECK(reader->ScanChildren() && | 385 RCHECK(reader->ScanChildren() && |
382 reader->MaybeReadChild(&pixel_aspect)); | 386 reader->MaybeReadChild(&pixel_aspect)); |
383 | 387 |
384 if (format == FOURCC_ENCV) | 388 if (format == FOURCC_ENCV) { |
385 RCHECK(reader->ReadChild(&sinf)); | 389 // Continue scanning until a recognized protection scheme is found, or until |
| 390 // we run out of protection schemes. |
| 391 while (sinf.type.type != FOURCC_CENC) { |
| 392 if (!reader->ReadChild(&sinf)) |
| 393 return false; |
| 394 } |
| 395 } |
| 396 |
386 if (format == FOURCC_AVC1 || | 397 if (format == FOURCC_AVC1 || |
387 (format == FOURCC_ENCV && sinf.format.format == FOURCC_AVC1)) { | 398 (format == FOURCC_ENCV && sinf.format.format == FOURCC_AVC1)) { |
388 RCHECK(reader->ReadChild(&avcc)); | 399 RCHECK(reader->ReadChild(&avcc)); |
389 } | 400 } |
390 return true; | 401 return true; |
391 } | 402 } |
392 | 403 |
393 ElementaryStreamDescriptor::ElementaryStreamDescriptor() | 404 ElementaryStreamDescriptor::ElementaryStreamDescriptor() |
394 : object_type(kForbidden) {} | 405 : object_type(kForbidden) {} |
395 | 406 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 reader->Read2(&data_reference_index) && | 446 reader->Read2(&data_reference_index) && |
436 reader->SkipBytes(8) && | 447 reader->SkipBytes(8) && |
437 reader->Read2(&channelcount) && | 448 reader->Read2(&channelcount) && |
438 reader->Read2(&samplesize) && | 449 reader->Read2(&samplesize) && |
439 reader->SkipBytes(4) && | 450 reader->SkipBytes(4) && |
440 reader->Read4(&samplerate)); | 451 reader->Read4(&samplerate)); |
441 // Convert from 16.16 fixed point to integer | 452 // Convert from 16.16 fixed point to integer |
442 samplerate >>= 16; | 453 samplerate >>= 16; |
443 | 454 |
444 RCHECK(reader->ScanChildren()); | 455 RCHECK(reader->ScanChildren()); |
445 if (format == FOURCC_ENCA) | 456 if (format == FOURCC_ENCA) { |
446 RCHECK(reader->ReadChild(&sinf)); | 457 // Continue scanning until a recognized protection scheme is found, or until |
| 458 // we run out of protection schemes. |
| 459 while (sinf.type.type != FOURCC_CENC) { |
| 460 if (!reader->ReadChild(&sinf)) |
| 461 return false; |
| 462 } |
| 463 } |
| 464 |
447 RCHECK(reader->ReadChild(&esds)); | 465 RCHECK(reader->ReadChild(&esds)); |
448 return true; | 466 return true; |
449 } | 467 } |
450 | 468 |
451 MediaHeader::MediaHeader() | 469 MediaHeader::MediaHeader() |
452 : creation_time(0), | 470 : creation_time(0), |
453 modification_time(0), | 471 modification_time(0), |
454 timescale(0), | 472 timescale(0), |
455 duration(0) {} | 473 duration(0) {} |
456 MediaHeader::~MediaHeader() {} | 474 MediaHeader::~MediaHeader() {} |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 bool MovieFragment::Parse(BoxReader* reader) { | 742 bool MovieFragment::Parse(BoxReader* reader) { |
725 RCHECK(reader->ScanChildren() && | 743 RCHECK(reader->ScanChildren() && |
726 reader->ReadChild(&header) && | 744 reader->ReadChild(&header) && |
727 reader->ReadChildren(&tracks) && | 745 reader->ReadChildren(&tracks) && |
728 reader->MaybeReadChildren(&pssh)); | 746 reader->MaybeReadChildren(&pssh)); |
729 return true; | 747 return true; |
730 } | 748 } |
731 | 749 |
732 } // namespace mp4 | 750 } // namespace mp4 |
733 } // namespace media | 751 } // namespace media |
OLD | NEW |