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

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

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

Powered by Google App Engine
This is Rietveld 408576698