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