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

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

Issue 10536014: Implement ISO BMFF support in Media Source. (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 #pragma once
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 remove
strobe_ 2012/06/07 16:33:54 Done.
8
9 #include "base/basictypes.h"
10 #include "media/mp4/avc.h"
11 #include "media/mp4/fourccs.h"
12 #include <string>
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 goes before non-system includes
strobe_ 2012/06/07 16:33:54 Done.
13
14 #define ARRAY_LENGTH(x) (sizeof(x) / sizeof(*(x)))
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 remove. Use arraysize() from basictypes.h instead
strobe_ 2012/06/07 16:33:54 Done.
15
16 namespace media {
17 namespace mp4 {
18
19 class BoxReader;
20
21 enum TrackType {
22 kInvalid = 0,
23 kVideo,
24 kAudio,
25 kHint
26 };
27
28 struct FileType {
29 FourCC major_brand;
30 uint32 minor_version;
31
32 FileType();
33 ~FileType();
34 };
35
36 struct ProtectionSystemSpecificHeader {
37 std::vector<uint8> system_id;
38 std::vector<uint8> data;
39
40 ProtectionSystemSpecificHeader();
41 ~ProtectionSystemSpecificHeader();
42 };
43
44 struct SampleAuxiliaryInformationOffset {
45 std::vector<uint64> offsets;
46
47 SampleAuxiliaryInformationOffset();
48 ~SampleAuxiliaryInformationOffset();
49 };
50
51 struct SampleAuxiliaryInformationSize {
52 uint8 default_sample_info_size;
53 uint32 sample_count;
54 std::vector<uint8> sample_info_sizes;
55
56 SampleAuxiliaryInformationSize();
57 ~SampleAuxiliaryInformationSize();
58 };
59
60 struct OriginalFormat {
61 FourCC format;
62 };
63
64 struct SchemeType {
65 FourCC type;
66 uint32 version;
67
68 SchemeType() : type(0), version(0) {}
69 };
70
71 struct TrackEncryption {
72 // Note: this definition is specific to the CENC protection type.
73 bool is_encrypted;
74 uint8 default_iv_size;
75 std::vector<uint8> default_kid;
76
77 TrackEncryption();
78 ~TrackEncryption();
79 };
80
81 struct SchemeInfo {
82 TrackEncryption track_encryption;
83 };
84
85 struct ProtectionSchemeInfo {
86 OriginalFormat format;
87 SchemeType type;
88 SchemeInfo info;
89 };
90
91 struct MovieHeader {
92 uint64 creation_time;
93 uint64 modification_time;
94 uint32 timescale;
95 uint64 duration;
96 int32 rate;
97 int16 volume;
98 uint32 next_track_id;
99 };
100
101 struct TrackHeader {
102 static const uint32 kTrackEnabled = 1;
103 static const uint32 kTrackInMovie = 2;
104 static const uint32 kTrackInPreview = 4;
105
106 uint64 creation_time;
107 uint64 modification_time;
108 uint32 track_id;
109 uint64 duration;
110 int16 layer;
111 int16 alternate_group;
112 int16 volume;
113 uint32 width;
114 uint32 height;
115
116 TrackHeader();
117 ~TrackHeader();
118 };
119
120 struct EditListEntry {
121 uint64 segment_duration;
122 int64 media_time;
123 int16 media_rate_integer;
124 int16 media_rate_fraction;
125 };
126
127 struct EditList {
128 std::vector<EditListEntry> edits;
129
130 EditList();
131 ~EditList();
132 };
133
134 struct Edit {
135 EditList list;
136
137 Edit();
138 ~Edit();
139 };
140
141 struct HandlerReference {
142 TrackType type;
143 };
144
145 struct SampleEntry {
146 FourCC format;
147 uint16 data_reference_index;
148
149 ProtectionSchemeInfo sinf;
150
151 SampleEntry();
152 ~SampleEntry();
153 };
154
155 struct VideoSampleEntry : SampleEntry {
156 uint16 width;
157 uint16 height;
158
159 // Present iff format or original_format is 'avc1'.
160 AVCDecoderConfigurationRecord avcc;
161
162 VideoSampleEntry();
163 ~VideoSampleEntry();
164 };
165
166 struct AudioSampleEntry : SampleEntry {
167 uint16 channelcount;
168 uint16 samplesize;
169 uint32 samplerate;
170
171 AudioSampleEntry();
172 ~AudioSampleEntry();
173 };
174
175 struct SampleDescription {
176 TrackType type;
177 std::vector<VideoSampleEntry> video_entries;
178 std::vector<AudioSampleEntry> audio_entries;
179
180 SampleDescription();
181 ~SampleDescription();
182 };
183
184 struct SampleTable {
185 // Media Source specific: we ignore many of the sub-boxes in this box,
186 // including some that are required to be present in the BMFF spec.
187 SampleDescription description;
188
189 SampleTable();
190 ~SampleTable();
191 };
192
193 struct MediaHeader {
194 uint64 creation_time;
195 uint64 modification_time;
196 uint32 timescale;
197 uint64 duration;
198
199 MediaHeader();
200 ~MediaHeader();
201 };
202
203 struct MediaInformation {
204 SampleTable sample_table;
205 };
206
207 struct Media {
208 MediaHeader header;
209 HandlerReference handler;
210 MediaInformation information;
211 };
212
213 struct Track {
214 TrackHeader header;
215 Media media;
216 Edit edit;
217 };
218
219 struct MovieExtendsHeader {
220 uint64 fragment_duration;
221 };
222
223 struct TrackExtends {
224 uint32 track_id;
225 uint32 default_sample_description_index;
226 uint32 default_sample_duration;
227 uint32 default_sample_size;
228 uint32 default_sample_flags;
229 };
230
231 struct MovieExtends {
232 MovieExtendsHeader header;
233 std::vector<TrackExtends> tracks;
234
235 MovieExtends();
236 ~MovieExtends();
237 };
238
239 struct Movie {
240 bool fragmented;
241 MovieHeader header;
242 MovieExtends extends;
243 std::vector<Track> tracks;
244 std::vector<ProtectionSystemSpecificHeader> pssh;
245
246 Movie();
247 ~Movie();
248 };
249
250 struct TrackFragmentDecodeTime {
251 uint64 decode_time;
252 };
253
254 struct MovieFragmentHeader {
255 uint32 sequence_number;
256 };
257
258 struct TrackFragmentHeader {
259 uint32 track_id;
260 uint32 default_sample_duration;
261 uint32 default_sample_size;
262 uint32 default_sample_flags;
263
264 // As 'flags' might be all zero, we cannot use zeroness alone to identify
265 // when default_sample_flags wasn't specified, unlike the other values.
266 bool has_default_sample_flags;
267 };
268
269 struct TrackFragmentRun {
270 TrackFragmentRun();
271 ~TrackFragmentRun();
272
273 uint32 sample_count;
274 uint32 data_offset;
275 std::vector<uint32> sample_flags;
276 std::vector<uint32> sample_sizes;
277 std::vector<uint32> sample_durations;
278 std::vector<uint32> sample_composition_time_offsets;
279 };
280
281 struct TrackFragment {
282 TrackFragmentHeader header;
283 std::vector<TrackFragmentRun> runs;
284 TrackFragmentDecodeTime decode_time;
285 SampleAuxiliaryInformationOffset auxiliary_offset;
286 SampleAuxiliaryInformationSize auxiliary_size;
287
288 TrackFragment();
289 ~TrackFragment();
290 };
291
292 struct MovieFragment {
293 MovieFragmentHeader header;
294 std::vector<TrackFragment> tracks;
295 std::vector<ProtectionSystemSpecificHeader> pssh;
296
297 MovieFragment();
298 ~MovieFragment();
299 };
300
301 struct SegmentIndex {
302 uint32 reference_id;
303 uint32 timescale;
304 uint64 earliest_presentation_time;
305 uint64 first_offset;
306 std::vector<uint32> sizes;
307 std::vector<uint32> durations;
308
309 SegmentIndex();
310 ~SegmentIndex();
311 };
312
313 template<typename T> FourCC GetBoxType();
314
315 #define DECLARE_BOX(T, F) \
316 bool Parse(BoxReader* r, T* box); \
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 WDYT about bool T::Parse(BoxReader* reader) so thi
strobe_ 2012/06/07 16:33:54 I'm provisionally cool with that, and will give it
317 template<> inline FourCC GetBoxType<T>() { return FOURCC_ ## F; }
318
319 DECLARE_BOX(AVCDecoderConfigurationRecord, AVCC);
320 DECLARE_BOX(Edit, EDTS);
321 DECLARE_BOX(EditList, ELST);
322 DECLARE_BOX(FileType, FTYP);
323 DECLARE_BOX(HandlerReference, HDLR);
324 DECLARE_BOX(Media, MDIA);
325 DECLARE_BOX(MediaHeader, MDHD);
326 DECLARE_BOX(MediaInformation, MINF);
327 DECLARE_BOX(Movie, MOOV);
328 DECLARE_BOX(MovieExtends, MVEX);
329 DECLARE_BOX(MovieExtendsHeader, MEHD);
330 DECLARE_BOX(MovieFragment, MOOF);
331 DECLARE_BOX(MovieFragmentHeader, MFHD);
332 DECLARE_BOX(MovieHeader, MVHD);
333 DECLARE_BOX(OriginalFormat, FRMA);
334 DECLARE_BOX(ProtectionSchemeInfo, SINF);
335 DECLARE_BOX(ProtectionSystemSpecificHeader, PSSH);
336 DECLARE_BOX(SampleAuxiliaryInformationOffset, SAIO);
337 DECLARE_BOX(SampleAuxiliaryInformationSize, SAIZ);
338 DECLARE_BOX(SampleDescription, STSD);
339 DECLARE_BOX(SampleTable, STBL);
340 DECLARE_BOX(SchemeInfo, SCHI);
341 DECLARE_BOX(SchemeType, SCHM);
342 DECLARE_BOX(Track, TRAK);
343 DECLARE_BOX(TrackEncryption, TENC);
344 DECLARE_BOX(TrackExtends, TREX);
345 DECLARE_BOX(TrackFragment, TRAF);
346 DECLARE_BOX(TrackFragmentDecodeTime, TFDT);
347 DECLARE_BOX(TrackFragmentHeader, TFHD);
348 DECLARE_BOX(TrackFragmentRun, TRUN);
349 DECLARE_BOX(TrackHeader, TKHD);
350
351 #undef DECLARE_BOX
352
353 // These boxes do not have an associated FourCC.
354 bool Parse(BoxReader* r, VideoSampleEntry* entry);
355 bool Parse(BoxReader* r, AudioSampleEntry* entry);
356
357 } // namespace mp4
358 } // namespace media
359
360 #endif // MEDIA_MP4_BOX_DEFINITIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698