Chromium Code Reviews| 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 #ifndef MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_ | 5 #ifndef MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_ |
| 6 #define MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_ | 6 #define MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "media/base/decrypt_config.h" | 15 #include "media/base/decrypt_config.h" |
| 16 #include "media/base/media_export.h" | 16 #include "media/base/media_export.h" |
| 17 #include "media/base/media_log.h" | 17 #include "media/base/media_log.h" |
| 18 #include "media/base/video_codecs.h" | 18 #include "media/base/video_codecs.h" |
| 19 #include "media/formats/mp4/aac.h" | 19 #include "media/formats/mp4/aac.h" |
| 20 #include "media/formats/mp4/avc.h" | 20 #include "media/formats/mp4/avc.h" |
| 21 #include "media/formats/mp4/box_reader.h" | 21 #include "media/formats/mp4/box_reader.h" |
| 22 #include "media/formats/mp4/fourccs.h" | 22 #include "media/formats/mp4/fourccs.h" |
| 23 #include "media/media_features.h" | |
| 23 | 24 |
| 24 namespace media { | 25 namespace media { |
| 25 namespace mp4 { | 26 namespace mp4 { |
| 26 | 27 |
| 28 const int kInitializationVectorSize = 16; | |
|
ddorwin
2016/11/06 00:57:51
Is this always constant for all types of CENC?
dougsteed
2016/12/01 19:45:32
Added comment. IV may be shorter but this is the s
| |
| 29 | |
| 27 enum TrackType { kInvalid = 0, kVideo, kAudio, kText, kHint }; | 30 enum TrackType { kInvalid = 0, kVideo, kAudio, kText, kHint }; |
| 28 | 31 |
| 29 enum SampleFlags { | 32 enum SampleFlags { |
| 30 kSampleIsNonSyncSample = 0x10000 | 33 kSampleIsNonSyncSample = 0x10000 |
| 31 }; | 34 }; |
| 32 | 35 |
| 33 #define DECLARE_BOX_METHODS(T) \ | 36 #define DECLARE_BOX_METHODS(T) \ |
| 34 T(); \ | 37 T(); \ |
| 35 T(const T& other); \ | 38 T(const T& other); \ |
| 36 ~T() override; \ | 39 ~T() override; \ |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 // Parse SampleEncryptionEntry from |reader|. | 87 // Parse SampleEncryptionEntry from |reader|. |
| 85 // |iv_size| specifies the size of initialization vector. |has_subsamples| | 88 // |iv_size| specifies the size of initialization vector. |has_subsamples| |
| 86 // indicates whether this sample encryption entry constains subsamples. | 89 // indicates whether this sample encryption entry constains subsamples. |
| 87 // Returns false if parsing fails. | 90 // Returns false if parsing fails. |
| 88 bool Parse(BufferReader* reader, uint8_t iv_size, bool has_subsamples); | 91 bool Parse(BufferReader* reader, uint8_t iv_size, bool has_subsamples); |
| 89 | 92 |
| 90 // Get accumulated size of subsamples. Returns false if there is an overflow | 93 // Get accumulated size of subsamples. Returns false if there is an overflow |
| 91 // anywhere. | 94 // anywhere. |
| 92 bool GetTotalSizeOfSubsamples(size_t* total_size) const; | 95 bool GetTotalSizeOfSubsamples(size_t* total_size) const; |
| 93 | 96 |
| 94 uint8_t initialization_vector[16]; | 97 uint8_t initialization_vector[kInitializationVectorSize]; |
| 95 std::vector<SubsampleEntry> subsamples; | 98 std::vector<SubsampleEntry> subsamples; |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 // ISO/IEC 23001-7:2015 8.1.1. | 101 // ISO/IEC 23001-7:2015 8.1.1. |
| 99 struct MEDIA_EXPORT SampleEncryption : Box { | 102 struct MEDIA_EXPORT SampleEncryption : Box { |
| 100 enum SampleEncryptionFlags { | 103 enum SampleEncryptionFlags { |
| 101 kUseSubsampleEncryption = 2, | 104 kUseSubsampleEncryption = 2, |
| 102 }; | 105 }; |
| 103 | 106 |
| 104 DECLARE_BOX_METHODS(SampleEncryption); | 107 DECLARE_BOX_METHODS(SampleEncryption); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 122 uint32_t version; | 125 uint32_t version; |
| 123 }; | 126 }; |
| 124 | 127 |
| 125 struct MEDIA_EXPORT TrackEncryption : Box { | 128 struct MEDIA_EXPORT TrackEncryption : Box { |
| 126 DECLARE_BOX_METHODS(TrackEncryption); | 129 DECLARE_BOX_METHODS(TrackEncryption); |
| 127 | 130 |
| 128 // Note: this definition is specific to the CENC protection type. | 131 // Note: this definition is specific to the CENC protection type. |
| 129 bool is_encrypted; | 132 bool is_encrypted; |
| 130 uint8_t default_iv_size; | 133 uint8_t default_iv_size; |
| 131 std::vector<uint8_t> default_kid; | 134 std::vector<uint8_t> default_kid; |
| 135 #if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME) | |
| 136 uint8_t default_crypt_byte_block; | |
| 137 uint8_t default_skip_byte_block; | |
| 138 uint8_t default_constant_iv_size; | |
| 139 uint8_t default_constant_iv[kInitializationVectorSize]; | |
| 140 #endif | |
| 132 }; | 141 }; |
| 133 | 142 |
| 134 struct MEDIA_EXPORT SchemeInfo : Box { | 143 struct MEDIA_EXPORT SchemeInfo : Box { |
| 135 DECLARE_BOX_METHODS(SchemeInfo); | 144 DECLARE_BOX_METHODS(SchemeInfo); |
| 136 | 145 |
| 137 TrackEncryption track_encryption; | 146 TrackEncryption track_encryption; |
| 138 }; | 147 }; |
| 139 | 148 |
| 140 struct MEDIA_EXPORT ProtectionSchemeInfo : Box { | 149 struct MEDIA_EXPORT ProtectionSchemeInfo : Box { |
| 141 DECLARE_BOX_METHODS(ProtectionSchemeInfo); | 150 DECLARE_BOX_METHODS(ProtectionSchemeInfo); |
| 142 | 151 |
| 143 OriginalFormat format; | 152 OriginalFormat format; |
| 144 SchemeType type; | 153 SchemeType type; |
| 145 SchemeInfo info; | 154 SchemeInfo info; |
| 155 | |
| 156 bool HasSupportedScheme() const; | |
| 146 }; | 157 }; |
| 147 | 158 |
| 148 struct MEDIA_EXPORT MovieHeader : Box { | 159 struct MEDIA_EXPORT MovieHeader : Box { |
| 149 DECLARE_BOX_METHODS(MovieHeader); | 160 DECLARE_BOX_METHODS(MovieHeader); |
| 150 | 161 |
| 151 uint8_t version; | 162 uint8_t version; |
| 152 uint64_t creation_time; | 163 uint64_t creation_time; |
| 153 uint64_t modification_time; | 164 uint64_t modification_time; |
| 154 uint32_t timescale; | 165 uint32_t timescale; |
| 155 uint64_t duration; | 166 uint64_t duration; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 | 293 |
| 283 TrackType type; | 294 TrackType type; |
| 284 std::vector<VideoSampleEntry> video_entries; | 295 std::vector<VideoSampleEntry> video_entries; |
| 285 std::vector<AudioSampleEntry> audio_entries; | 296 std::vector<AudioSampleEntry> audio_entries; |
| 286 }; | 297 }; |
| 287 | 298 |
| 288 struct MEDIA_EXPORT CencSampleEncryptionInfoEntry { | 299 struct MEDIA_EXPORT CencSampleEncryptionInfoEntry { |
| 289 CencSampleEncryptionInfoEntry(); | 300 CencSampleEncryptionInfoEntry(); |
| 290 CencSampleEncryptionInfoEntry(const CencSampleEncryptionInfoEntry& other); | 301 CencSampleEncryptionInfoEntry(const CencSampleEncryptionInfoEntry& other); |
| 291 ~CencSampleEncryptionInfoEntry(); | 302 ~CencSampleEncryptionInfoEntry(); |
| 303 bool Parse(BoxReader* reader); | |
| 292 | 304 |
| 293 bool is_encrypted; | 305 bool is_encrypted; |
| 294 uint8_t iv_size; | 306 uint8_t iv_size; |
| 295 std::vector<uint8_t> key_id; | 307 std::vector<uint8_t> key_id; |
| 308 #if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME) | |
| 309 uint8_t crypt_byte_block; | |
| 310 uint8_t skip_byte_block; | |
| 311 uint8_t constant_iv_size; | |
| 312 uint8_t constant_iv[kInitializationVectorSize]; | |
| 313 #endif | |
| 296 }; | 314 }; |
| 297 | 315 |
| 298 struct MEDIA_EXPORT SampleGroupDescription : Box { // 'sgpd'. | 316 struct MEDIA_EXPORT SampleGroupDescription : Box { // 'sgpd'. |
| 299 DECLARE_BOX_METHODS(SampleGroupDescription); | 317 DECLARE_BOX_METHODS(SampleGroupDescription); |
| 300 | 318 |
| 301 uint32_t grouping_type; | 319 uint32_t grouping_type; |
| 302 std::vector<CencSampleEncryptionInfoEntry> entries; | 320 std::vector<CencSampleEncryptionInfoEntry> entries; |
| 303 }; | 321 }; |
| 304 | 322 |
| 305 struct MEDIA_EXPORT SampleTable : Box { | 323 struct MEDIA_EXPORT SampleTable : Box { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 std::vector<TrackFragment> tracks; | 496 std::vector<TrackFragment> tracks; |
| 479 std::vector<ProtectionSystemSpecificHeader> pssh; | 497 std::vector<ProtectionSystemSpecificHeader> pssh; |
| 480 }; | 498 }; |
| 481 | 499 |
| 482 #undef DECLARE_BOX | 500 #undef DECLARE_BOX |
| 483 | 501 |
| 484 } // namespace mp4 | 502 } // namespace mp4 |
| 485 } // namespace media | 503 } // namespace media |
| 486 | 504 |
| 487 #endif // MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_ | 505 #endif // MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_ |
| OLD | NEW |