Alternative way to define the files used by iOS in ui.
[chromium-blink-merge.git] / media / mp4 / box_definitions.h
blobb78ebdd6d5934fc3804f8d869b83cb80066eb120
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_MP4_BOX_DEFINITIONS_H_
6 #define MEDIA_MP4_BOX_DEFINITIONS_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "media/base/media_export.h"
14 #include "media/mp4/aac.h"
15 #include "media/mp4/avc.h"
16 #include "media/mp4/box_reader.h"
17 #include "media/mp4/fourccs.h"
19 namespace media {
20 namespace mp4 {
22 enum TrackType {
23 kInvalid = 0,
24 kVideo,
25 kAudio,
26 kHint
29 #define DECLARE_BOX_METHODS(T) \
30 T(); \
31 virtual ~T(); \
32 virtual bool Parse(BoxReader* reader) OVERRIDE; \
33 virtual FourCC BoxType() const OVERRIDE; \
35 struct MEDIA_EXPORT FileType : Box {
36 DECLARE_BOX_METHODS(FileType);
38 FourCC major_brand;
39 uint32 minor_version;
42 struct MEDIA_EXPORT ProtectionSystemSpecificHeader : Box {
43 DECLARE_BOX_METHODS(ProtectionSystemSpecificHeader);
45 std::vector<uint8> system_id;
46 std::vector<uint8> data;
49 struct MEDIA_EXPORT SampleAuxiliaryInformationOffset : Box {
50 DECLARE_BOX_METHODS(SampleAuxiliaryInformationOffset);
52 std::vector<uint64> offsets;
55 struct MEDIA_EXPORT SampleAuxiliaryInformationSize : Box {
56 DECLARE_BOX_METHODS(SampleAuxiliaryInformationSize);
58 uint8 default_sample_info_size;
59 uint32 sample_count;
60 std::vector<uint8> sample_info_sizes;
63 struct MEDIA_EXPORT OriginalFormat : Box {
64 DECLARE_BOX_METHODS(OriginalFormat);
66 FourCC format;
69 struct MEDIA_EXPORT SchemeType : Box {
70 DECLARE_BOX_METHODS(SchemeType);
72 FourCC type;
73 uint32 version;
76 struct MEDIA_EXPORT TrackEncryption : Box {
77 DECLARE_BOX_METHODS(TrackEncryption);
79 // Note: this definition is specific to the CENC protection type.
80 bool is_encrypted;
81 uint8 default_iv_size;
82 std::vector<uint8> default_kid;
85 struct MEDIA_EXPORT SchemeInfo : Box {
86 DECLARE_BOX_METHODS(SchemeInfo);
88 TrackEncryption track_encryption;
91 struct MEDIA_EXPORT ProtectionSchemeInfo : Box {
92 DECLARE_BOX_METHODS(ProtectionSchemeInfo);
94 OriginalFormat format;
95 SchemeType type;
96 SchemeInfo info;
99 struct MEDIA_EXPORT MovieHeader : Box {
100 DECLARE_BOX_METHODS(MovieHeader);
102 uint64 creation_time;
103 uint64 modification_time;
104 uint32 timescale;
105 uint64 duration;
106 int32 rate;
107 int16 volume;
108 uint32 next_track_id;
111 struct MEDIA_EXPORT TrackHeader : Box {
112 DECLARE_BOX_METHODS(TrackHeader);
114 uint64 creation_time;
115 uint64 modification_time;
116 uint32 track_id;
117 uint64 duration;
118 int16 layer;
119 int16 alternate_group;
120 int16 volume;
121 uint32 width;
122 uint32 height;
125 struct MEDIA_EXPORT EditListEntry {
126 uint64 segment_duration;
127 int64 media_time;
128 int16 media_rate_integer;
129 int16 media_rate_fraction;
132 struct MEDIA_EXPORT EditList : Box {
133 DECLARE_BOX_METHODS(EditList);
135 std::vector<EditListEntry> edits;
138 struct MEDIA_EXPORT Edit : Box {
139 DECLARE_BOX_METHODS(Edit);
141 EditList list;
144 struct MEDIA_EXPORT HandlerReference : Box {
145 DECLARE_BOX_METHODS(HandlerReference);
147 TrackType type;
150 struct MEDIA_EXPORT AVCDecoderConfigurationRecord : Box {
151 DECLARE_BOX_METHODS(AVCDecoderConfigurationRecord);
153 uint8 version;
154 uint8 profile_indication;
155 uint8 profile_compatibility;
156 uint8 avc_level;
157 uint8 length_size;
159 typedef std::vector<uint8> SPS;
160 typedef std::vector<uint8> PPS;
162 std::vector<SPS> sps_list;
163 std::vector<PPS> pps_list;
166 struct MEDIA_EXPORT PixelAspectRatioBox : Box {
167 DECLARE_BOX_METHODS(PixelAspectRatioBox);
169 uint32 h_spacing;
170 uint32 v_spacing;
173 struct MEDIA_EXPORT VideoSampleEntry : Box {
174 DECLARE_BOX_METHODS(VideoSampleEntry);
176 FourCC format;
177 uint16 data_reference_index;
178 uint16 width;
179 uint16 height;
181 PixelAspectRatioBox pixel_aspect;
182 ProtectionSchemeInfo sinf;
184 // Currently expected to be present regardless of format.
185 AVCDecoderConfigurationRecord avcc;
188 struct MEDIA_EXPORT ElementaryStreamDescriptor : Box {
189 DECLARE_BOX_METHODS(ElementaryStreamDescriptor);
191 uint8 object_type;
192 AAC aac;
195 struct MEDIA_EXPORT AudioSampleEntry : Box {
196 DECLARE_BOX_METHODS(AudioSampleEntry);
198 FourCC format;
199 uint16 data_reference_index;
200 uint16 channelcount;
201 uint16 samplesize;
202 uint32 samplerate;
204 ProtectionSchemeInfo sinf;
205 ElementaryStreamDescriptor esds;
208 struct MEDIA_EXPORT SampleDescription : Box {
209 DECLARE_BOX_METHODS(SampleDescription);
211 TrackType type;
212 std::vector<VideoSampleEntry> video_entries;
213 std::vector<AudioSampleEntry> audio_entries;
216 struct MEDIA_EXPORT SampleTable : Box {
217 DECLARE_BOX_METHODS(SampleTable);
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. This
221 // includes the 'stts', 'stsc', and 'stco' boxes, which must contain no
222 // samples in order to be compliant files.
223 SampleDescription description;
226 struct MEDIA_EXPORT MediaHeader : Box {
227 DECLARE_BOX_METHODS(MediaHeader);
229 uint64 creation_time;
230 uint64 modification_time;
231 uint32 timescale;
232 uint64 duration;
235 struct MEDIA_EXPORT MediaInformation : Box {
236 DECLARE_BOX_METHODS(MediaInformation);
238 SampleTable sample_table;
241 struct MEDIA_EXPORT Media : Box {
242 DECLARE_BOX_METHODS(Media);
244 MediaHeader header;
245 HandlerReference handler;
246 MediaInformation information;
249 struct MEDIA_EXPORT Track : Box {
250 DECLARE_BOX_METHODS(Track);
252 TrackHeader header;
253 Media media;
254 Edit edit;
257 struct MEDIA_EXPORT MovieExtendsHeader : Box {
258 DECLARE_BOX_METHODS(MovieExtendsHeader);
260 uint64 fragment_duration;
263 struct MEDIA_EXPORT TrackExtends : Box {
264 DECLARE_BOX_METHODS(TrackExtends);
266 uint32 track_id;
267 uint32 default_sample_description_index;
268 uint32 default_sample_duration;
269 uint32 default_sample_size;
270 uint32 default_sample_flags;
273 struct MEDIA_EXPORT MovieExtends : Box {
274 DECLARE_BOX_METHODS(MovieExtends);
276 MovieExtendsHeader header;
277 std::vector<TrackExtends> tracks;
280 struct MEDIA_EXPORT Movie : Box {
281 DECLARE_BOX_METHODS(Movie);
283 bool fragmented;
284 MovieHeader header;
285 MovieExtends extends;
286 std::vector<Track> tracks;
287 std::vector<ProtectionSystemSpecificHeader> pssh;
290 struct MEDIA_EXPORT TrackFragmentDecodeTime : Box {
291 DECLARE_BOX_METHODS(TrackFragmentDecodeTime);
293 uint64 decode_time;
296 struct MEDIA_EXPORT MovieFragmentHeader : Box {
297 DECLARE_BOX_METHODS(MovieFragmentHeader);
299 uint32 sequence_number;
302 struct MEDIA_EXPORT TrackFragmentHeader : Box {
303 DECLARE_BOX_METHODS(TrackFragmentHeader);
305 uint32 track_id;
307 uint32 sample_description_index;
308 uint32 default_sample_duration;
309 uint32 default_sample_size;
310 uint32 default_sample_flags;
312 // As 'flags' might be all zero, we cannot use zeroness alone to identify
313 // when default_sample_flags wasn't specified, unlike the other values.
314 bool has_default_sample_flags;
317 struct MEDIA_EXPORT TrackFragmentRun : Box {
318 DECLARE_BOX_METHODS(TrackFragmentRun);
320 uint32 sample_count;
321 uint32 data_offset;
322 std::vector<uint32> sample_flags;
323 std::vector<uint32> sample_sizes;
324 std::vector<uint32> sample_durations;
325 std::vector<int32> sample_composition_time_offsets;
328 struct MEDIA_EXPORT TrackFragment : Box {
329 DECLARE_BOX_METHODS(TrackFragment);
331 TrackFragmentHeader header;
332 std::vector<TrackFragmentRun> runs;
333 TrackFragmentDecodeTime decode_time;
334 SampleAuxiliaryInformationOffset auxiliary_offset;
335 SampleAuxiliaryInformationSize auxiliary_size;
338 struct MEDIA_EXPORT MovieFragment : Box {
339 DECLARE_BOX_METHODS(MovieFragment);
341 MovieFragmentHeader header;
342 std::vector<TrackFragment> tracks;
343 std::vector<ProtectionSystemSpecificHeader> pssh;
346 #undef DECLARE_BOX
348 } // namespace mp4
349 } // namespace media
351 #endif // MEDIA_MP4_BOX_DEFINITIONS_H_