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_
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"
29 #define DECLARE_BOX_METHODS(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
);
42 struct MEDIA_EXPORT ProtectionSystemSpecificHeader
: Box
{
43 DECLARE_BOX_METHODS(ProtectionSystemSpecificHeader
);
45 std::vector
<uint8
> system_id
;
46 std::vector
<uint8
> raw_box
;
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
;
60 std::vector
<uint8
> sample_info_sizes
;
63 struct MEDIA_EXPORT OriginalFormat
: Box
{
64 DECLARE_BOX_METHODS(OriginalFormat
);
69 struct MEDIA_EXPORT SchemeType
: Box
{
70 DECLARE_BOX_METHODS(SchemeType
);
76 struct MEDIA_EXPORT TrackEncryption
: Box
{
77 DECLARE_BOX_METHODS(TrackEncryption
);
79 // Note: this definition is specific to the CENC protection type.
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
;
99 struct MEDIA_EXPORT MovieHeader
: Box
{
100 DECLARE_BOX_METHODS(MovieHeader
);
102 uint64 creation_time
;
103 uint64 modification_time
;
108 uint32 next_track_id
;
111 struct MEDIA_EXPORT TrackHeader
: Box
{
112 DECLARE_BOX_METHODS(TrackHeader
);
114 uint64 creation_time
;
115 uint64 modification_time
;
119 int16 alternate_group
;
125 struct MEDIA_EXPORT EditListEntry
{
126 uint64 segment_duration
;
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
);
144 struct MEDIA_EXPORT HandlerReference
: Box
{
145 DECLARE_BOX_METHODS(HandlerReference
);
150 struct MEDIA_EXPORT AVCDecoderConfigurationRecord
: Box
{
151 DECLARE_BOX_METHODS(AVCDecoderConfigurationRecord
);
154 uint8 profile_indication
;
155 uint8 profile_compatibility
;
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
);
173 struct MEDIA_EXPORT VideoSampleEntry
: Box
{
174 DECLARE_BOX_METHODS(VideoSampleEntry
);
177 uint16 data_reference_index
;
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
);
195 struct MEDIA_EXPORT AudioSampleEntry
: Box
{
196 DECLARE_BOX_METHODS(AudioSampleEntry
);
199 uint16 data_reference_index
;
204 ProtectionSchemeInfo sinf
;
205 ElementaryStreamDescriptor esds
;
208 struct MEDIA_EXPORT SampleDescription
: Box
{
209 DECLARE_BOX_METHODS(SampleDescription
);
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
;
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
);
245 HandlerReference handler
;
246 MediaInformation information
;
249 struct MEDIA_EXPORT Track
: Box
{
250 DECLARE_BOX_METHODS(Track
);
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
);
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
);
285 MovieExtends extends
;
286 std::vector
<Track
> tracks
;
287 std::vector
<ProtectionSystemSpecificHeader
> pssh
;
290 struct MEDIA_EXPORT TrackFragmentDecodeTime
: Box
{
291 DECLARE_BOX_METHODS(TrackFragmentDecodeTime
);
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
);
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
);
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
;
351 #endif // MEDIA_MP4_BOX_DEFINITIONS_H_