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

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

Powered by Google App Engine
This is Rietveld 408576698