Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef ISOMediaBoxes_h_
7 #define ISOMediaBoxes_h_
9 #include <bitset>
10 #include "nsString.h"
11 #include "nsTArray.h"
12 #include "nsAutoPtr.h"
13 #include "MuxerOperation.h"
15 #define WRITE_FULLBOX(_compositor, _size) \
16 BoxSizeChecker checker(_compositor, _size); \
17 FullBox::Write();
19 #define FOURCC(a, b, c, d) ( ((a) << 24) | ((b) << 16) | ((c) << 8) | (d) )
21 namespace mozilla {
23 /**
24 * track type from spec 8.4.3.3
25 */
26 #define Audio_Track 0x01
27 #define Video_Track 0x02
29 class AudioTrackMetadata;
30 class VideoTrackMetadata;
31 class ES_Descriptor;
32 class ISOControl;
34 /**
35 * This is the base class for all ISO media format boxes.
36 * It provides the fields of box type(four CC) and size.
37 * The data members in the beginning of a Box (or its descendants)
38 * are the 14496-12 defined member. Other members prefix with 'm'
39 * are private control data.
40 *
41 * This class is for inherited only, it shouldn't be instanced directly.
42 */
43 class Box : public MuxerOperation {
44 protected:
45 // ISO BMFF members
46 uint32_t size; // 14496-12 4-2 'Object Structure'. Size of this box.
47 nsCString boxType; // four CC name, all table names are listed in
48 // 14496-12 table 1.
50 public:
51 // MuxerOperation methods
52 nsresult Write() MOZ_OVERRIDE;
53 nsresult Find(const nsACString& aType,
54 nsTArray<nsRefPtr<MuxerOperation>>& aOperations) MOZ_OVERRIDE;
56 // This helper class will compare the written size in Write() and the size in
57 // Generate(). If their are not equal, it will assert.
58 class BoxSizeChecker {
59 public:
60 BoxSizeChecker(ISOControl* aControl, uint32_t aSize);
61 ~BoxSizeChecker();
63 uint32_t ori_size;
64 uint32_t box_size;
65 ISOControl* mControl;
66 };
68 protected:
69 Box() MOZ_DELETE;
70 Box(const nsACString& aType, ISOControl* aControl);
72 ISOControl* mControl;
73 nsRefPtr<AudioTrackMetadata> mAudioMeta;
74 nsRefPtr<VideoTrackMetadata> mVideoMeta;
75 };
77 /**
78 * FullBox (and its descendants) is the box which contains the 'real' data
79 * members. It is the edge in the ISO box structure and it doesn't contain
80 * any box.
81 *
82 * This class is for inherited only, it shouldn't be instanced directly.
83 */
84 class FullBox : public Box {
85 public:
86 // ISO BMFF members
87 uint8_t version; // 14496-12 4.2 'Object Structure'
88 std::bitset<24> flags; //
90 // MuxerOperation methods
91 nsresult Write() MOZ_OVERRIDE;
93 protected:
94 // FullBox methods
95 FullBox(const nsACString& aType, uint8_t aVersion, uint32_t aFlags,
96 ISOControl* aControl);
97 FullBox() MOZ_DELETE;
98 };
100 /**
101 * The default implementation of the container box.
102 * Basically, the container box inherits this class and overrides the
103 * constructor only.
104 *
105 * According to 14496-12 3.1.1 'container box', a container box is
106 * 'box whose sole purpose is to contain and group a set of related boxes'
107 *
108 * This class is for inherited only, it shouldn't be instanced directly.
109 */
110 class DefaultContainerImpl : public Box {
111 public:
112 // MuxerOperation methods
113 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
114 nsresult Write() MOZ_OVERRIDE;
115 nsresult Find(const nsACString& aType,
116 nsTArray<nsRefPtr<MuxerOperation>>& aOperations) MOZ_OVERRIDE;
118 protected:
119 // DefaultContainerImpl methods
120 DefaultContainerImpl(const nsACString& aType, ISOControl* aControl);
121 DefaultContainerImpl() MOZ_DELETE;
123 nsTArray<nsRefPtr<MuxerOperation>> boxes;
124 };
126 // 14496-12 4.3 'File Type Box'
127 // Box type: 'ftyp'
128 class FileTypeBox : public Box {
129 public:
130 // ISO BMFF members
131 nsCString major_brand; // four chars
132 uint32_t minor_version;
133 nsTArray<nsCString> compatible_brands;
135 // MuxerOperation methods
136 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
137 nsresult Write() MOZ_OVERRIDE;
139 // FileTypeBox methods
140 FileTypeBox(ISOControl* aControl);
141 ~FileTypeBox();
142 };
144 // 14496-12 8.2.1 'Movie Box'
145 // Box type: 'moov'
146 // MovieBox contains MovieHeaderBox, TrackBox and MovieExtendsBox.
147 class MovieBox : public DefaultContainerImpl {
148 public:
149 MovieBox(ISOControl* aControl);
150 ~MovieBox();
151 };
153 // 14496-12 8.2.2 'Movie Header Box'
154 // Box type: 'mvhd'
155 class MovieHeaderBox : public FullBox {
156 public:
157 // ISO BMFF members
158 uint32_t creation_time;
159 uint32_t modification_time;
160 uint32_t timescale;
161 uint32_t duration;
162 uint32_t rate;
163 uint16_t volume;
164 uint16_t reserved16;
165 uint32_t reserved32[2];
166 uint32_t matrix[9];
167 uint32_t pre_defined[6];
168 uint32_t next_track_ID;
170 // MuxerOperation methods
171 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
172 nsresult Write() MOZ_OVERRIDE;
174 // MovieHeaderBox methods
175 MovieHeaderBox(ISOControl* aControl);
176 ~MovieHeaderBox();
177 uint32_t GetTimeScale();
178 };
180 // 14496-12 8.4.2 'Media Header Box'
181 // Box type: 'mdhd'
182 class MediaHeaderBox : public FullBox {
183 public:
184 // ISO BMFF members
185 uint32_t creation_time;
186 uint32_t modification_time;
187 uint32_t timescale;
188 uint32_t duration;
189 std::bitset<1> pad;
190 std::bitset<5> lang1;
191 std::bitset<5> lang2;
192 std::bitset<5> lang3;
193 uint16_t pre_defined;
195 // MuxerOperation methods
196 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
197 nsresult Write() MOZ_OVERRIDE;
199 // MediaHeaderBox methods
200 MediaHeaderBox(uint32_t aType, ISOControl* aControl);
201 ~MediaHeaderBox();
202 uint32_t GetTimeScale();
204 protected:
205 uint32_t mTrackType;
206 };
208 // 14496-12 8.3.1 'Track Box'
209 // Box type: 'trak'
210 // TrackBox contains TrackHeaderBox and MediaBox.
211 class TrackBox : public DefaultContainerImpl {
212 public:
213 TrackBox(uint32_t aTrackType, ISOControl* aControl);
214 ~TrackBox();
215 };
217 // 14496-12 8.1.1 'Media Data Box'
218 // Box type: 'mdat'
219 class MediaDataBox : public Box {
220 public:
221 // MuxerOperation methods
222 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
223 nsresult Write() MOZ_OVERRIDE;
225 // MediaDataBox methods
226 uint32_t GetAllSampleSize() { return mAllSampleSize; }
227 uint32_t FirstSampleOffsetInMediaDataBox() { return mFirstSampleOffset; }
228 MediaDataBox(uint32_t aTrackType, ISOControl* aControl);
229 ~MediaDataBox();
231 protected:
232 uint32_t mAllSampleSize; // All audio and video sample size in this box.
233 uint32_t mFirstSampleOffset; // The offset of first sample in this box from
234 // the beginning of this mp4 file.
235 uint32_t mTrackType;
236 };
238 // flags for TrackRunBox::flags, 14496-12 8.8.8.1.
239 #define flags_data_offset_present 0x000001
240 #define flags_first_sample_flags_present 0x000002
241 #define flags_sample_duration_present 0x000100
242 #define flags_sample_size_present 0x000200
243 #define flags_sample_flags_present 0x000400
244 #define flags_sample_composition_time_offsets_present 0x000800
246 // flag for TrackRunBox::tbl::sample_flags and TrackExtendsBox::default_sample_flags
247 // which is defined in 14496-12 8.8.3.1.
248 uint32_t set_sample_flags(bool aSync);
250 // 14496-12 8.8.8 'Track Fragment Run Box'
251 // Box type: 'trun'
252 class TrackRunBox : public FullBox {
253 public:
254 // ISO BMFF members
255 typedef struct {
256 uint32_t sample_duration;
257 uint32_t sample_size;
258 uint32_t sample_flags;
259 uint32_t sample_composition_time_offset;
260 } tbl;
262 uint32_t sample_count;
263 // the following are optional fields
264 uint32_t data_offset; // data offset exists when audio/video are present in file.
265 uint32_t first_sample_flags;
266 nsAutoArrayPtr<tbl> sample_info_table;
268 // MuxerOperation methods
269 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
270 nsresult Write() MOZ_OVERRIDE;
272 // TrackRunBox methods
273 uint32_t GetAllSampleSize() { return mAllSampleSize; }
274 nsresult SetDataOffset(uint32_t aOffset);
276 TrackRunBox(uint32_t aType, uint32_t aFlags, ISOControl* aControl);
277 ~TrackRunBox();
279 protected:
280 uint32_t fillSampleTable();
282 uint32_t mAllSampleSize;
283 uint32_t mTrackType;
284 };
286 // tf_flags in TrackFragmentHeaderBox, 14496-12 8.8.7.1.
287 #define base_data_offset_present 0x000001
288 #define sample_description_index_present 0x000002
289 #define default_sample_duration_present 0x000008
290 #define default_sample_size_present 0x000010
291 #define default_sample_flags_present 0x000020
292 #define duration_is_empty 0x010000
293 #define default_base_is_moof 0x020000
295 // 14496-12 8.8.7 'Track Fragment Header Box'
296 // Box type: 'tfhd'
297 class TrackFragmentHeaderBox : public FullBox {
298 public:
299 // ISO BMFF members
300 uint32_t track_ID;
301 uint64_t base_data_offset;
302 uint32_t default_sample_duration;
304 // MuxerOperation methods
305 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
306 nsresult Write() MOZ_OVERRIDE;
308 // TrackFragmentHeaderBox methods
309 nsresult UpdateBaseDataOffset(uint64_t aOffset); // The offset of the first
310 // sample in file.
312 TrackFragmentHeaderBox(uint32_t aType, uint32_t aFlags, ISOControl* aControl);
313 ~TrackFragmentHeaderBox();
315 protected:
316 uint32_t mTrackType;
317 };
319 // 14496-12 8.8.6 'Track Fragment Box'
320 // Box type: 'traf'
321 // TrackFragmentBox cotains TrackFragmentHeaderBox and TrackRunBox.
322 class TrackFragmentBox : public DefaultContainerImpl {
323 public:
324 TrackFragmentBox(uint32_t aType, ISOControl* aControl);
325 ~TrackFragmentBox();
327 protected:
328 uint32_t mTrackType;
329 };
331 // 14496-12 8.8.5 'Movie Fragment Header Box'
332 // Box type: 'mfhd'
333 class MovieFragmentHeaderBox : public FullBox {
334 public:
335 // ISO BMFF members
336 uint32_t sequence_number;
338 // MuxerOperation methods
339 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
340 nsresult Write() MOZ_OVERRIDE;
342 // MovieFragmentHeaderBox methods
343 MovieFragmentHeaderBox(uint32_t aType, ISOControl* aControl);
344 ~MovieFragmentHeaderBox();
346 protected:
347 uint32_t mTrackType;
348 };
350 // 14496-12 8.8.4 'Movie Fragment Box'
351 // Box type: 'moof'
352 // MovieFragmentBox contains MovieFragmentHeaderBox and TrackFragmentBox.
353 class MovieFragmentBox : public DefaultContainerImpl {
354 public:
355 // MuxerOperation methods
356 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
358 // MovieFragmentBox methods
359 MovieFragmentBox(uint32_t aType, ISOControl* aControl);
360 ~MovieFragmentBox();
362 protected:
363 uint32_t mTrackType;
364 };
366 // 14496-12 8.8.3 'Track Extends Box'
367 // Box type: 'trex'
368 class TrackExtendsBox : public FullBox {
369 public:
370 // ISO BMFF members
371 uint32_t track_ID;
372 uint32_t default_sample_description_index;
373 uint32_t default_sample_duration;
374 uint32_t default_sample_size;
375 uint32_t default_sample_flags;
377 // MuxerOperation methods
378 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
379 nsresult Write() MOZ_OVERRIDE;
381 // TrackExtendsBox methods
382 TrackExtendsBox(uint32_t aType, ISOControl* aControl);
383 ~TrackExtendsBox();
385 protected:
386 uint32_t mTrackType;
387 };
389 // 14496-12 8.8.1 'Movie Extends Box'
390 // Box type: 'mvex'
391 // MovieExtendsBox contains TrackExtendsBox.
392 class MovieExtendsBox : public DefaultContainerImpl {
393 public:
394 MovieExtendsBox(ISOControl* aControl);
395 ~MovieExtendsBox();
396 };
398 // 14496-12 8.7.5 'Chunk Offset Box'
399 // Box type: 'stco'
400 class ChunkOffsetBox : public FullBox {
401 public:
402 // ISO BMFF members
403 typedef struct {
404 uint32_t chunk_offset;
405 } tbl;
407 uint32_t entry_count;
408 nsAutoArrayPtr<tbl> sample_tbl;
410 // MuxerOperation methods
411 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
412 nsresult Write() MOZ_OVERRIDE;
414 // ChunkOffsetBox methods
415 ChunkOffsetBox(uint32_t aType, ISOControl* aControl);
416 ~ChunkOffsetBox();
418 protected:
419 uint32_t mTrackType;
420 };
422 // 14496-12 8.7.4 'Sample To Chunk Box'
423 // Box type: 'stsc'
424 class SampleToChunkBox : public FullBox {
425 public:
426 // ISO BMFF members
427 typedef struct {
428 uint32_t first_chunk;
429 uint32_t sample_per_chunk;
430 uint32_t sample_description_index;
431 } tbl;
433 uint32_t entry_count;
434 nsAutoArrayPtr<tbl> sample_tbl;
436 // MuxerOperation methods
437 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
438 nsresult Write() MOZ_OVERRIDE;
440 // SampleToChunkBox methods
441 SampleToChunkBox(uint32_t aType, ISOControl* aControl);
442 ~SampleToChunkBox();
444 protected:
445 uint32_t mTrackType;
446 };
448 // 14496-12 8.6.1.2 'Decoding Time to Sample Box'
449 // Box type: 'stts'
450 class TimeToSampleBox : public FullBox {
451 public:
452 // ISO BMFF members
453 typedef struct {
454 uint32_t sample_count;
455 uint32_t sample_delta;
456 } tbl;
458 uint32_t entry_count;
459 nsAutoArrayPtr<tbl> sample_tbl;
461 // MuxerOperation methods
462 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
463 nsresult Write() MOZ_OVERRIDE;
465 // TimeToSampleBox methods
466 TimeToSampleBox(uint32_t aType, ISOControl* aControl);
467 ~TimeToSampleBox();
469 protected:
470 uint32_t mTrackType;
471 };
473 /**
474 * 14496-12 8.5.2 'Sample Description Box'
475 * This is the base class for VisualSampleEntry and AudioSampleEntry.
476 *
477 * This class is for inherited only, it shouldn't be instanced directly.
478 *
479 * The inhertied tree of a codec box should be:
480 *
481 * +--> AVCSampleEntry
482 * +--> VisualSampleEntryBox +
483 * | +--> ...
484 * SampleEntryBox +
485 * | +--> MP4AudioSampleEntry
486 * +--> AudioSampleEntryBox +
487 * +--> AMRSampleEntry
488 * +
489 * +--> ...
490 *
491 */
492 class SampleEntryBox : public Box {
493 public:
494 // ISO BMFF members
495 uint8_t reserved[6];
496 uint16_t data_reference_index;
498 // sampleentrybox methods
499 SampleEntryBox(const nsACString& aFormat, ISOControl* aControl);
501 // MuxerOperation methods
502 nsresult Write() MOZ_OVERRIDE;
504 protected:
505 SampleEntryBox() MOZ_DELETE;
506 };
508 // 14496-12 8.5.2 'Sample Description Box'
509 // Box type: 'stsd'
510 class SampleDescriptionBox : public FullBox {
511 public:
512 // ISO BMFF members
513 uint32_t entry_count;
514 nsRefPtr<SampleEntryBox> sample_entry_box;
516 // MuxerOperation methods
517 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
518 nsresult Write() MOZ_OVERRIDE;
520 // SampleDescriptionBox methods
521 SampleDescriptionBox(uint32_t aType, ISOControl* aControl);
522 ~SampleDescriptionBox();
524 protected:
525 nsresult CreateAudioSampleEntry(nsRefPtr<SampleEntryBox>& aSampleEntry);
526 nsresult CreateVideoSampleEntry(nsRefPtr<SampleEntryBox>& aSampleEntry);
528 uint32_t mTrackType;
529 };
531 // 14496-12 8.5.2.2
532 // The base class for audio codec box.
533 // This class is for inherited only, it shouldn't be instanced directly.
534 class AudioSampleEntry : public SampleEntryBox {
535 public:
536 // ISO BMFF members
537 uint16_t sound_version;
538 uint8_t reserved2[6];
539 uint16_t channels;
540 uint16_t sample_size;
541 uint16_t compressionId;
542 uint16_t packet_size;
543 uint32_t timeScale; // (sample rate of media) <<16
545 // MuxerOperation methods
546 nsresult Write() MOZ_OVERRIDE;
548 ~AudioSampleEntry();
550 protected:
551 AudioSampleEntry(const nsACString& aFormat, ISOControl* aControl);
552 };
554 // 14496-12 8.5.2.2
555 // The base class for video codec box.
556 // This class is for inherited only, it shouldn't be instanced directly.
557 class VisualSampleEntry : public SampleEntryBox {
558 public:
559 // ISO BMFF members
560 uint8_t reserved[16];
561 uint16_t width;
562 uint16_t height;
564 uint32_t horizresolution; // 72 dpi
565 uint32_t vertresolution; // 72 dpi
566 uint32_t reserved2;
567 uint16_t frame_count; // 1, defined in 14496-12 8.5.2.2
569 uint8_t compressorName[32];
570 uint16_t depth; // 0x0018, defined in 14496-12 8.5.2.2;
571 uint16_t pre_defined; // -1, defined in 14496-12 8.5.2.2;
573 // MuxerOperation methods
574 nsresult Write() MOZ_OVERRIDE;
576 // VisualSampleEntry methods
577 ~VisualSampleEntry();
579 protected:
580 VisualSampleEntry(const nsACString& aFormat, ISOControl* aControl);
581 };
583 // 14496-12 8.7.3.2 'Sample Size Box'
584 // Box type: 'stsz'
585 class SampleSizeBox : public FullBox {
586 public:
587 // ISO BMFF members
588 uint32_t sample_size;
589 uint32_t sample_count;
591 // MuxerOperation methods
592 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
593 nsresult Write() MOZ_OVERRIDE;
595 // SampleSizeBox methods
596 SampleSizeBox(ISOControl* aControl);
597 ~SampleSizeBox();
598 };
600 // 14496-12 8.5.1 'Sample Table Box'
601 // Box type: 'stbl'
602 //
603 // SampleTableBox contains SampleDescriptionBox,
604 // TimeToSampleBox,
605 // SampleToChunkBox,
606 // SampleSizeBox and
607 // ChunkOffsetBox.
608 class SampleTableBox : public DefaultContainerImpl {
609 public:
610 SampleTableBox(uint32_t aType, ISOControl* aControl);
611 ~SampleTableBox();
612 };
614 // 14496-12 8.7.2 'Data Reference Box'
615 // Box type: 'url '
616 class DataEntryUrlBox : public FullBox {
617 public:
618 // ISO BMFF members
619 // flags in DataEntryUrlBox::flags
620 const static uint16_t flags_media_at_the_same_file = 0x0001;
622 nsCString location;
624 // MuxerOperation methods
625 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
626 nsresult Write() MOZ_OVERRIDE;
628 // DataEntryUrlBox methods
629 DataEntryUrlBox();
630 DataEntryUrlBox(ISOControl* aControl);
631 DataEntryUrlBox(const DataEntryUrlBox& aBox);
632 ~DataEntryUrlBox();
633 };
635 // 14496-12 8.7.2 'Data Reference Box'
636 // Box type: 'dref'
637 class DataReferenceBox : public FullBox {
638 public:
639 // ISO BMFF members
640 uint32_t entry_count;
641 nsTArray<nsAutoPtr<DataEntryUrlBox>> urls;
643 // MuxerOperation methods
644 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
645 nsresult Write() MOZ_OVERRIDE;
647 // DataReferenceBox methods
648 DataReferenceBox(ISOControl* aControl);
649 ~DataReferenceBox();
650 };
652 // 14496-12 8.7.1 'Data Information Box'
653 // Box type: 'dinf'
654 // DataInformationBox contains DataReferenceBox.
655 class DataInformationBox : public DefaultContainerImpl {
656 public:
657 DataInformationBox(ISOControl* aControl);
658 ~DataInformationBox();
659 };
661 // 14496-12 8.4.5.2 'Video Media Header Box'
662 // Box type: 'vmhd'
663 class VideoMediaHeaderBox : public FullBox {
664 public:
665 // ISO BMFF members
666 uint16_t graphicsmode;
667 uint16_t opcolor[3];
669 // MuxerOperation methods
670 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
671 nsresult Write() MOZ_OVERRIDE;
673 // VideoMediaHeaderBox methods
674 VideoMediaHeaderBox(ISOControl* aControl);
675 ~VideoMediaHeaderBox();
676 };
678 // 14496-12 8.4.5.3 'Sound Media Header Box'
679 // Box type: 'smhd'
680 class SoundMediaHeaderBox : public FullBox {
681 public:
682 // ISO BMFF members
683 uint16_t balance;
684 uint16_t reserved;
686 // MuxerOperation methods
687 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
688 nsresult Write() MOZ_OVERRIDE;
690 // SoundMediaHeaderBox methods
691 SoundMediaHeaderBox(ISOControl* aControl);
692 ~SoundMediaHeaderBox();
693 };
695 // 14496-12 8.4.4 'Media Information Box'
696 // Box type: 'minf'
697 // MediaInformationBox contains SoundMediaHeaderBox, DataInformationBox and
698 // SampleTableBox.
699 class MediaInformationBox : public DefaultContainerImpl {
700 public:
701 MediaInformationBox(uint32_t aType, ISOControl* aControl);
702 ~MediaInformationBox();
704 protected:
705 uint32_t mTrackType;
706 };
708 // flags for TrackHeaderBox::flags.
709 #define flags_track_enabled 0x000001
710 #define flags_track_in_movie 0x000002
711 #define flags_track_in_preview 0x000004
713 // 14496-12 8.3.2 'Track Header Box'
714 // Box type: 'tkhd'
715 class TrackHeaderBox : public FullBox {
716 public:
717 // ISO BMFF members
718 // version = 0
719 uint32_t creation_time;
720 uint32_t modification_time;
721 uint32_t track_ID;
722 uint32_t reserved;
723 uint32_t duration;
725 uint32_t reserved2[2];
726 uint16_t layer;
727 uint16_t alternate_group;
728 uint16_t volume;
729 uint16_t reserved3;
730 uint32_t matrix[9];
731 uint32_t width;
732 uint32_t height;
734 // MuxerOperation methods
735 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
736 nsresult Write() MOZ_OVERRIDE;
738 // TrackHeaderBox methods
739 TrackHeaderBox(uint32_t aType, ISOControl* aControl);
740 ~TrackHeaderBox();
742 protected:
743 uint32_t mTrackType;
744 };
746 // 14496-12 8.4.3 'Handler Reference Box'
747 // Box type: 'hdlr'
748 class HandlerBox : public FullBox {
749 public:
750 // ISO BMFF members
751 uint32_t pre_defined;
752 uint32_t handler_type;
753 uint32_t reserved[3];
754 nsCString name;
756 // MuxerOperation methods
757 nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE;
758 nsresult Write() MOZ_OVERRIDE;
760 // HandlerBox methods
761 HandlerBox(uint32_t aType, ISOControl* aControl);
762 ~HandlerBox();
764 protected:
765 uint32_t mTrackType;
766 };
768 // 14496-12 8.4.1 'Media Box'
769 // Box type: 'mdia'
770 // MediaBox contains MediaHeaderBox, HandlerBox, and MediaInformationBox.
771 class MediaBox : public DefaultContainerImpl {
772 public:
773 MediaBox(uint32_t aType, ISOControl* aControl);
774 ~MediaBox();
776 protected:
777 uint32_t mTrackType;
778 };
780 }
781 #endif // ISOMediaBoxes_h_