Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: media/mp4/box_definitions.h

Issue 10651006: Add Common Encryption support to BMFF, including subsample decryption. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add wrong subsample size test Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef MEDIA_MP4_BOX_DEFINITIONS_H_ 5 #ifndef MEDIA_MP4_BOX_DEFINITIONS_H_
6 #define MEDIA_MP4_BOX_DEFINITIONS_H_ 6 #define MEDIA_MP4_BOX_DEFINITIONS_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 14 matching lines...) Expand all
25 kAudio, 25 kAudio,
26 kHint 26 kHint
27 }; 27 };
28 28
29 #define DECLARE_BOX_METHODS(T) \ 29 #define DECLARE_BOX_METHODS(T) \
30 T(); \ 30 T(); \
31 virtual ~T(); \ 31 virtual ~T(); \
32 virtual bool Parse(BoxReader* reader) OVERRIDE; \ 32 virtual bool Parse(BoxReader* reader) OVERRIDE; \
33 virtual FourCC BoxType() const OVERRIDE; \ 33 virtual FourCC BoxType() const OVERRIDE; \
34 34
35 struct FileType : Box { 35 struct MEDIA_EXPORT FileType : Box {
36 DECLARE_BOX_METHODS(FileType); 36 DECLARE_BOX_METHODS(FileType);
37 37
38 FourCC major_brand; 38 FourCC major_brand;
39 uint32 minor_version; 39 uint32 minor_version;
40 }; 40 };
41 41
42 struct ProtectionSystemSpecificHeader : Box { 42 struct MEDIA_EXPORT ProtectionSystemSpecificHeader : Box {
43 DECLARE_BOX_METHODS(ProtectionSystemSpecificHeader); 43 DECLARE_BOX_METHODS(ProtectionSystemSpecificHeader);
44 44
45 std::vector<uint8> system_id; 45 std::vector<uint8> system_id;
46 std::vector<uint8> data; 46 std::vector<uint8> data;
47 }; 47 };
48 48
49 struct SampleAuxiliaryInformationOffset : Box { 49 struct MEDIA_EXPORT SampleAuxiliaryInformationOffset : Box {
50 DECLARE_BOX_METHODS(SampleAuxiliaryInformationOffset); 50 DECLARE_BOX_METHODS(SampleAuxiliaryInformationOffset);
51 51
52 std::vector<uint64> offsets; 52 std::vector<uint64> offsets;
53 }; 53 };
54 54
55 struct SampleAuxiliaryInformationSize : Box { 55 struct MEDIA_EXPORT SampleAuxiliaryInformationSize : Box {
56 DECLARE_BOX_METHODS(SampleAuxiliaryInformationSize); 56 DECLARE_BOX_METHODS(SampleAuxiliaryInformationSize);
57 57
58 uint8 default_sample_info_size; 58 uint8 default_sample_info_size;
59 uint32 sample_count; 59 uint32 sample_count;
60 std::vector<uint8> sample_info_sizes; 60 std::vector<uint8> sample_info_sizes;
61 }; 61 };
62 62
63 struct OriginalFormat : Box { 63 struct MEDIA_EXPORT OriginalFormat : Box {
64 DECLARE_BOX_METHODS(OriginalFormat); 64 DECLARE_BOX_METHODS(OriginalFormat);
65 65
66 FourCC format; 66 FourCC format;
67 }; 67 };
68 68
69 struct SchemeType : Box { 69 struct MEDIA_EXPORT SchemeType : Box {
70 DECLARE_BOX_METHODS(SchemeType); 70 DECLARE_BOX_METHODS(SchemeType);
71 71
72 FourCC type; 72 FourCC type;
73 uint32 version; 73 uint32 version;
74 }; 74 };
75 75
76 struct TrackEncryption : Box { 76 struct MEDIA_EXPORT TrackEncryption : Box {
77 DECLARE_BOX_METHODS(TrackEncryption); 77 DECLARE_BOX_METHODS(TrackEncryption);
78 78
79 // Note: this definition is specific to the CENC protection type. 79 // Note: this definition is specific to the CENC protection type.
80 bool is_encrypted; 80 bool is_encrypted;
81 uint8 default_iv_size; 81 uint8 default_iv_size;
82 std::vector<uint8> default_kid; 82 std::vector<uint8> default_kid;
83 }; 83 };
84 84
85 struct SchemeInfo : Box { 85 struct MEDIA_EXPORT SchemeInfo : Box {
86 DECLARE_BOX_METHODS(SchemeInfo); 86 DECLARE_BOX_METHODS(SchemeInfo);
87 87
88 TrackEncryption track_encryption; 88 TrackEncryption track_encryption;
89 }; 89 };
90 90
91 struct ProtectionSchemeInfo : Box { 91 struct MEDIA_EXPORT ProtectionSchemeInfo : Box {
92 DECLARE_BOX_METHODS(ProtectionSchemeInfo); 92 DECLARE_BOX_METHODS(ProtectionSchemeInfo);
93 93
94 OriginalFormat format; 94 OriginalFormat format;
95 SchemeType type; 95 SchemeType type;
96 SchemeInfo info; 96 SchemeInfo info;
97 }; 97 };
98 98
99 struct MovieHeader : Box { 99 struct MEDIA_EXPORT MovieHeader : Box {
100 DECLARE_BOX_METHODS(MovieHeader); 100 DECLARE_BOX_METHODS(MovieHeader);
101 101
102 uint64 creation_time; 102 uint64 creation_time;
103 uint64 modification_time; 103 uint64 modification_time;
104 uint32 timescale; 104 uint32 timescale;
105 uint64 duration; 105 uint64 duration;
106 int32 rate; 106 int32 rate;
107 int16 volume; 107 int16 volume;
108 uint32 next_track_id; 108 uint32 next_track_id;
109 }; 109 };
110 110
111 struct TrackHeader : Box { 111 struct MEDIA_EXPORT TrackHeader : Box {
112 DECLARE_BOX_METHODS(TrackHeader); 112 DECLARE_BOX_METHODS(TrackHeader);
113 113
114 uint64 creation_time; 114 uint64 creation_time;
115 uint64 modification_time; 115 uint64 modification_time;
116 uint32 track_id; 116 uint32 track_id;
117 uint64 duration; 117 uint64 duration;
118 int16 layer; 118 int16 layer;
119 int16 alternate_group; 119 int16 alternate_group;
120 int16 volume; 120 int16 volume;
121 uint32 width; 121 uint32 width;
122 uint32 height; 122 uint32 height;
123 }; 123 };
124 124
125 struct EditListEntry { 125 struct MEDIA_EXPORT EditListEntry {
126 uint64 segment_duration; 126 uint64 segment_duration;
127 int64 media_time; 127 int64 media_time;
128 int16 media_rate_integer; 128 int16 media_rate_integer;
129 int16 media_rate_fraction; 129 int16 media_rate_fraction;
130 }; 130 };
131 131
132 struct EditList : Box { 132 struct MEDIA_EXPORT EditList : Box {
133 DECLARE_BOX_METHODS(EditList); 133 DECLARE_BOX_METHODS(EditList);
134 134
135 std::vector<EditListEntry> edits; 135 std::vector<EditListEntry> edits;
136 }; 136 };
137 137
138 struct Edit : Box { 138 struct MEDIA_EXPORT Edit : Box {
139 DECLARE_BOX_METHODS(Edit); 139 DECLARE_BOX_METHODS(Edit);
140 140
141 EditList list; 141 EditList list;
142 }; 142 };
143 143
144 struct HandlerReference : Box { 144 struct MEDIA_EXPORT HandlerReference : Box {
145 DECLARE_BOX_METHODS(HandlerReference); 145 DECLARE_BOX_METHODS(HandlerReference);
146 146
147 TrackType type; 147 TrackType type;
148 }; 148 };
149 149
150 struct MEDIA_EXPORT AVCDecoderConfigurationRecord : Box { 150 struct MEDIA_EXPORT AVCDecoderConfigurationRecord : Box {
151 DECLARE_BOX_METHODS(AVCDecoderConfigurationRecord); 151 DECLARE_BOX_METHODS(AVCDecoderConfigurationRecord);
152 152
153 uint8 version; 153 uint8 version;
154 uint8 profile_indication; 154 uint8 profile_indication;
155 uint8 profile_compatibility; 155 uint8 profile_compatibility;
156 uint8 avc_level; 156 uint8 avc_level;
157 uint8 length_size; 157 uint8 length_size;
158 158
159 typedef std::vector<uint8> SPS; 159 typedef std::vector<uint8> SPS;
160 typedef std::vector<uint8> PPS; 160 typedef std::vector<uint8> PPS;
161 161
162 std::vector<SPS> sps_list; 162 std::vector<SPS> sps_list;
163 std::vector<PPS> pps_list; 163 std::vector<PPS> pps_list;
164 }; 164 };
165 165
166 struct PixelAspectRatioBox : Box { 166 struct MEDIA_EXPORT PixelAspectRatioBox : Box {
167 DECLARE_BOX_METHODS(PixelAspectRatioBox); 167 DECLARE_BOX_METHODS(PixelAspectRatioBox);
168 168
169 uint32 h_spacing; 169 uint32 h_spacing;
170 uint32 v_spacing; 170 uint32 v_spacing;
171 }; 171 };
172 172
173 struct VideoSampleEntry : Box { 173 struct MEDIA_EXPORT VideoSampleEntry : Box {
174 DECLARE_BOX_METHODS(VideoSampleEntry); 174 DECLARE_BOX_METHODS(VideoSampleEntry);
175 175
176 FourCC format; 176 FourCC format;
177 uint16 data_reference_index; 177 uint16 data_reference_index;
178 uint16 width; 178 uint16 width;
179 uint16 height; 179 uint16 height;
180 180
181 PixelAspectRatioBox pixel_aspect; 181 PixelAspectRatioBox pixel_aspect;
182 ProtectionSchemeInfo sinf; 182 ProtectionSchemeInfo sinf;
183 183
184 // Currently expected to be present regardless of format. 184 // Currently expected to be present regardless of format.
185 AVCDecoderConfigurationRecord avcc; 185 AVCDecoderConfigurationRecord avcc;
186 }; 186 };
187 187
188 struct ElementaryStreamDescriptor : Box { 188 struct MEDIA_EXPORT ElementaryStreamDescriptor : Box {
189 DECLARE_BOX_METHODS(ElementaryStreamDescriptor); 189 DECLARE_BOX_METHODS(ElementaryStreamDescriptor);
190 190
191 uint8 object_type; 191 uint8 object_type;
192 AAC aac; 192 AAC aac;
193 }; 193 };
194 194
195 struct AudioSampleEntry : Box { 195 struct MEDIA_EXPORT AudioSampleEntry : Box {
196 DECLARE_BOX_METHODS(AudioSampleEntry); 196 DECLARE_BOX_METHODS(AudioSampleEntry);
197 197
198 FourCC format; 198 FourCC format;
199 uint16 data_reference_index; 199 uint16 data_reference_index;
200 uint16 channelcount; 200 uint16 channelcount;
201 uint16 samplesize; 201 uint16 samplesize;
202 uint32 samplerate; 202 uint32 samplerate;
203 203
204 ProtectionSchemeInfo sinf; 204 ProtectionSchemeInfo sinf;
205 ElementaryStreamDescriptor esds; 205 ElementaryStreamDescriptor esds;
206 }; 206 };
207 207
208 struct SampleDescription : Box { 208 struct MEDIA_EXPORT SampleDescription : Box {
209 DECLARE_BOX_METHODS(SampleDescription); 209 DECLARE_BOX_METHODS(SampleDescription);
210 210
211 TrackType type; 211 TrackType type;
212 std::vector<VideoSampleEntry> video_entries; 212 std::vector<VideoSampleEntry> video_entries;
213 std::vector<AudioSampleEntry> audio_entries; 213 std::vector<AudioSampleEntry> audio_entries;
214 }; 214 };
215 215
216 struct SampleTable : Box { 216 struct MEDIA_EXPORT SampleTable : Box {
217 DECLARE_BOX_METHODS(SampleTable); 217 DECLARE_BOX_METHODS(SampleTable);
218 218
219 // Media Source specific: we ignore many of the sub-boxes in this box, 219 // Media Source specific: we ignore many of the sub-boxes in this box,
220 // including some that are required to be present in the BMFF spec. 220 // including some that are required to be present in the BMFF spec. This
221 // includes the 'stts', 'stsc', and 'stco' boxes, which must contain no
222 // samples in order to be compliant files.
221 SampleDescription description; 223 SampleDescription description;
222 }; 224 };
223 225
224 struct MediaHeader : Box { 226 struct MEDIA_EXPORT MediaHeader : Box {
225 DECLARE_BOX_METHODS(MediaHeader); 227 DECLARE_BOX_METHODS(MediaHeader);
226 228
227 uint64 creation_time; 229 uint64 creation_time;
228 uint64 modification_time; 230 uint64 modification_time;
229 uint32 timescale; 231 uint32 timescale;
230 uint64 duration; 232 uint64 duration;
231 }; 233 };
232 234
233 struct MediaInformation : Box { 235 struct MEDIA_EXPORT MediaInformation : Box {
234 DECLARE_BOX_METHODS(MediaInformation); 236 DECLARE_BOX_METHODS(MediaInformation);
235 237
236 SampleTable sample_table; 238 SampleTable sample_table;
237 }; 239 };
238 240
239 struct Media : Box { 241 struct MEDIA_EXPORT Media : Box {
240 DECLARE_BOX_METHODS(Media); 242 DECLARE_BOX_METHODS(Media);
241 243
242 MediaHeader header; 244 MediaHeader header;
243 HandlerReference handler; 245 HandlerReference handler;
244 MediaInformation information; 246 MediaInformation information;
245 }; 247 };
246 248
247 struct Track : Box { 249 struct MEDIA_EXPORT Track : Box {
248 DECLARE_BOX_METHODS(Track); 250 DECLARE_BOX_METHODS(Track);
249 251
250 TrackHeader header; 252 TrackHeader header;
251 Media media; 253 Media media;
252 Edit edit; 254 Edit edit;
253 }; 255 };
254 256
255 struct MovieExtendsHeader : Box { 257 struct MEDIA_EXPORT MovieExtendsHeader : Box {
256 DECLARE_BOX_METHODS(MovieExtendsHeader); 258 DECLARE_BOX_METHODS(MovieExtendsHeader);
257 259
258 uint64 fragment_duration; 260 uint64 fragment_duration;
259 }; 261 };
260 262
261 struct TrackExtends : Box { 263 struct MEDIA_EXPORT TrackExtends : Box {
262 DECLARE_BOX_METHODS(TrackExtends); 264 DECLARE_BOX_METHODS(TrackExtends);
263 265
264 uint32 track_id; 266 uint32 track_id;
265 uint32 default_sample_description_index; 267 uint32 default_sample_description_index;
266 uint32 default_sample_duration; 268 uint32 default_sample_duration;
267 uint32 default_sample_size; 269 uint32 default_sample_size;
268 uint32 default_sample_flags; 270 uint32 default_sample_flags;
269 }; 271 };
270 272
271 struct MovieExtends : Box { 273 struct MEDIA_EXPORT MovieExtends : Box {
272 DECLARE_BOX_METHODS(MovieExtends); 274 DECLARE_BOX_METHODS(MovieExtends);
273 275
274 MovieExtendsHeader header; 276 MovieExtendsHeader header;
275 std::vector<TrackExtends> tracks; 277 std::vector<TrackExtends> tracks;
276 }; 278 };
277 279
278 struct Movie : Box { 280 struct MEDIA_EXPORT Movie : Box {
279 DECLARE_BOX_METHODS(Movie); 281 DECLARE_BOX_METHODS(Movie);
280 282
281 bool fragmented; 283 bool fragmented;
282 MovieHeader header; 284 MovieHeader header;
283 MovieExtends extends; 285 MovieExtends extends;
284 std::vector<Track> tracks; 286 std::vector<Track> tracks;
285 std::vector<ProtectionSystemSpecificHeader> pssh; 287 std::vector<ProtectionSystemSpecificHeader> pssh;
286 }; 288 };
287 289
288 struct TrackFragmentDecodeTime : Box { 290 struct MEDIA_EXPORT TrackFragmentDecodeTime : Box {
289 DECLARE_BOX_METHODS(TrackFragmentDecodeTime); 291 DECLARE_BOX_METHODS(TrackFragmentDecodeTime);
290 292
291 uint64 decode_time; 293 uint64 decode_time;
292 }; 294 };
293 295
294 struct MovieFragmentHeader : Box { 296 struct MEDIA_EXPORT MovieFragmentHeader : Box {
295 DECLARE_BOX_METHODS(MovieFragmentHeader); 297 DECLARE_BOX_METHODS(MovieFragmentHeader);
296 298
297 uint32 sequence_number; 299 uint32 sequence_number;
298 }; 300 };
299 301
300 struct TrackFragmentHeader : Box { 302 struct MEDIA_EXPORT TrackFragmentHeader : Box {
301 DECLARE_BOX_METHODS(TrackFragmentHeader); 303 DECLARE_BOX_METHODS(TrackFragmentHeader);
302 304
303 uint32 track_id; 305 uint32 track_id;
304 uint32 default_sample_duration; 306 uint32 default_sample_duration;
305 uint32 default_sample_size; 307 uint32 default_sample_size;
306 uint32 default_sample_flags; 308 uint32 default_sample_flags;
307 309
308 // As 'flags' might be all zero, we cannot use zeroness alone to identify 310 // As 'flags' might be all zero, we cannot use zeroness alone to identify
309 // when default_sample_flags wasn't specified, unlike the other values. 311 // when default_sample_flags wasn't specified, unlike the other values.
310 bool has_default_sample_flags; 312 bool has_default_sample_flags;
311 }; 313 };
312 314
313 struct TrackFragmentRun : Box { 315 struct MEDIA_EXPORT TrackFragmentRun : Box {
314 DECLARE_BOX_METHODS(TrackFragmentRun); 316 DECLARE_BOX_METHODS(TrackFragmentRun);
315 317
316 uint32 sample_count; 318 uint32 sample_count;
317 uint32 data_offset; 319 uint32 data_offset;
318 std::vector<uint32> sample_flags; 320 std::vector<uint32> sample_flags;
319 std::vector<uint32> sample_sizes; 321 std::vector<uint32> sample_sizes;
320 std::vector<uint32> sample_durations; 322 std::vector<uint32> sample_durations;
321 std::vector<int32> sample_composition_time_offsets; 323 std::vector<int32> sample_composition_time_offsets;
322 }; 324 };
323 325
324 struct TrackFragment : Box { 326 struct MEDIA_EXPORT TrackFragment : Box {
325 DECLARE_BOX_METHODS(TrackFragment); 327 DECLARE_BOX_METHODS(TrackFragment);
326 328
327 TrackFragmentHeader header; 329 TrackFragmentHeader header;
328 std::vector<TrackFragmentRun> runs; 330 std::vector<TrackFragmentRun> runs;
329 TrackFragmentDecodeTime decode_time; 331 TrackFragmentDecodeTime decode_time;
330 SampleAuxiliaryInformationOffset auxiliary_offset; 332 SampleAuxiliaryInformationOffset auxiliary_offset;
331 SampleAuxiliaryInformationSize auxiliary_size; 333 SampleAuxiliaryInformationSize auxiliary_size;
332 }; 334 };
333 335
334 struct MovieFragment : Box { 336 struct MEDIA_EXPORT MovieFragment : Box {
335 DECLARE_BOX_METHODS(MovieFragment); 337 DECLARE_BOX_METHODS(MovieFragment);
336 338
337 MovieFragmentHeader header; 339 MovieFragmentHeader header;
338 std::vector<TrackFragment> tracks; 340 std::vector<TrackFragment> tracks;
339 std::vector<ProtectionSystemSpecificHeader> pssh; 341 std::vector<ProtectionSystemSpecificHeader> pssh;
340 }; 342 };
341 343
342 #undef DECLARE_BOX 344 #undef DECLARE_BOX
343 345
344 } // namespace mp4 346 } // namespace mp4
345 } // namespace media 347 } // namespace media
346 348
347 #endif // MEDIA_MP4_BOX_DEFINITIONS_H_ 349 #endif // MEDIA_MP4_BOX_DEFINITIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698