michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef ISOMediaBoxes_h_ michael@0: #define ISOMediaBoxes_h_ michael@0: michael@0: #include michael@0: #include "nsString.h" michael@0: #include "nsTArray.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "MuxerOperation.h" michael@0: michael@0: #define WRITE_FULLBOX(_compositor, _size) \ michael@0: BoxSizeChecker checker(_compositor, _size); \ michael@0: FullBox::Write(); michael@0: michael@0: #define FOURCC(a, b, c, d) ( ((a) << 24) | ((b) << 16) | ((c) << 8) | (d) ) michael@0: michael@0: namespace mozilla { michael@0: michael@0: /** michael@0: * track type from spec 8.4.3.3 michael@0: */ michael@0: #define Audio_Track 0x01 michael@0: #define Video_Track 0x02 michael@0: michael@0: class AudioTrackMetadata; michael@0: class VideoTrackMetadata; michael@0: class ES_Descriptor; michael@0: class ISOControl; michael@0: michael@0: /** michael@0: * This is the base class for all ISO media format boxes. michael@0: * It provides the fields of box type(four CC) and size. michael@0: * The data members in the beginning of a Box (or its descendants) michael@0: * are the 14496-12 defined member. Other members prefix with 'm' michael@0: * are private control data. michael@0: * michael@0: * This class is for inherited only, it shouldn't be instanced directly. michael@0: */ michael@0: class Box : public MuxerOperation { michael@0: protected: michael@0: // ISO BMFF members michael@0: uint32_t size; // 14496-12 4-2 'Object Structure'. Size of this box. michael@0: nsCString boxType; // four CC name, all table names are listed in michael@0: // 14496-12 table 1. michael@0: michael@0: public: michael@0: // MuxerOperation methods michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: nsresult Find(const nsACString& aType, michael@0: nsTArray>& aOperations) MOZ_OVERRIDE; michael@0: michael@0: // This helper class will compare the written size in Write() and the size in michael@0: // Generate(). If their are not equal, it will assert. michael@0: class BoxSizeChecker { michael@0: public: michael@0: BoxSizeChecker(ISOControl* aControl, uint32_t aSize); michael@0: ~BoxSizeChecker(); michael@0: michael@0: uint32_t ori_size; michael@0: uint32_t box_size; michael@0: ISOControl* mControl; michael@0: }; michael@0: michael@0: protected: michael@0: Box() MOZ_DELETE; michael@0: Box(const nsACString& aType, ISOControl* aControl); michael@0: michael@0: ISOControl* mControl; michael@0: nsRefPtr mAudioMeta; michael@0: nsRefPtr mVideoMeta; michael@0: }; michael@0: michael@0: /** michael@0: * FullBox (and its descendants) is the box which contains the 'real' data michael@0: * members. It is the edge in the ISO box structure and it doesn't contain michael@0: * any box. michael@0: * michael@0: * This class is for inherited only, it shouldn't be instanced directly. michael@0: */ michael@0: class FullBox : public Box { michael@0: public: michael@0: // ISO BMFF members michael@0: uint8_t version; // 14496-12 4.2 'Object Structure' michael@0: std::bitset<24> flags; // michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: // FullBox methods michael@0: FullBox(const nsACString& aType, uint8_t aVersion, uint32_t aFlags, michael@0: ISOControl* aControl); michael@0: FullBox() MOZ_DELETE; michael@0: }; michael@0: michael@0: /** michael@0: * The default implementation of the container box. michael@0: * Basically, the container box inherits this class and overrides the michael@0: * constructor only. michael@0: * michael@0: * According to 14496-12 3.1.1 'container box', a container box is michael@0: * 'box whose sole purpose is to contain and group a set of related boxes' michael@0: * michael@0: * This class is for inherited only, it shouldn't be instanced directly. michael@0: */ michael@0: class DefaultContainerImpl : public Box { michael@0: public: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: nsresult Find(const nsACString& aType, michael@0: nsTArray>& aOperations) MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: // DefaultContainerImpl methods michael@0: DefaultContainerImpl(const nsACString& aType, ISOControl* aControl); michael@0: DefaultContainerImpl() MOZ_DELETE; michael@0: michael@0: nsTArray> boxes; michael@0: }; michael@0: michael@0: // 14496-12 4.3 'File Type Box' michael@0: // Box type: 'ftyp' michael@0: class FileTypeBox : public Box { michael@0: public: michael@0: // ISO BMFF members michael@0: nsCString major_brand; // four chars michael@0: uint32_t minor_version; michael@0: nsTArray compatible_brands; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // FileTypeBox methods michael@0: FileTypeBox(ISOControl* aControl); michael@0: ~FileTypeBox(); michael@0: }; michael@0: michael@0: // 14496-12 8.2.1 'Movie Box' michael@0: // Box type: 'moov' michael@0: // MovieBox contains MovieHeaderBox, TrackBox and MovieExtendsBox. michael@0: class MovieBox : public DefaultContainerImpl { michael@0: public: michael@0: MovieBox(ISOControl* aControl); michael@0: ~MovieBox(); michael@0: }; michael@0: michael@0: // 14496-12 8.2.2 'Movie Header Box' michael@0: // Box type: 'mvhd' michael@0: class MovieHeaderBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint32_t creation_time; michael@0: uint32_t modification_time; michael@0: uint32_t timescale; michael@0: uint32_t duration; michael@0: uint32_t rate; michael@0: uint16_t volume; michael@0: uint16_t reserved16; michael@0: uint32_t reserved32[2]; michael@0: uint32_t matrix[9]; michael@0: uint32_t pre_defined[6]; michael@0: uint32_t next_track_ID; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // MovieHeaderBox methods michael@0: MovieHeaderBox(ISOControl* aControl); michael@0: ~MovieHeaderBox(); michael@0: uint32_t GetTimeScale(); michael@0: }; michael@0: michael@0: // 14496-12 8.4.2 'Media Header Box' michael@0: // Box type: 'mdhd' michael@0: class MediaHeaderBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint32_t creation_time; michael@0: uint32_t modification_time; michael@0: uint32_t timescale; michael@0: uint32_t duration; michael@0: std::bitset<1> pad; michael@0: std::bitset<5> lang1; michael@0: std::bitset<5> lang2; michael@0: std::bitset<5> lang3; michael@0: uint16_t pre_defined; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // MediaHeaderBox methods michael@0: MediaHeaderBox(uint32_t aType, ISOControl* aControl); michael@0: ~MediaHeaderBox(); michael@0: uint32_t GetTimeScale(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // 14496-12 8.3.1 'Track Box' michael@0: // Box type: 'trak' michael@0: // TrackBox contains TrackHeaderBox and MediaBox. michael@0: class TrackBox : public DefaultContainerImpl { michael@0: public: michael@0: TrackBox(uint32_t aTrackType, ISOControl* aControl); michael@0: ~TrackBox(); michael@0: }; michael@0: michael@0: // 14496-12 8.1.1 'Media Data Box' michael@0: // Box type: 'mdat' michael@0: class MediaDataBox : public Box { michael@0: public: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // MediaDataBox methods michael@0: uint32_t GetAllSampleSize() { return mAllSampleSize; } michael@0: uint32_t FirstSampleOffsetInMediaDataBox() { return mFirstSampleOffset; } michael@0: MediaDataBox(uint32_t aTrackType, ISOControl* aControl); michael@0: ~MediaDataBox(); michael@0: michael@0: protected: michael@0: uint32_t mAllSampleSize; // All audio and video sample size in this box. michael@0: uint32_t mFirstSampleOffset; // The offset of first sample in this box from michael@0: // the beginning of this mp4 file. michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // flags for TrackRunBox::flags, 14496-12 8.8.8.1. michael@0: #define flags_data_offset_present 0x000001 michael@0: #define flags_first_sample_flags_present 0x000002 michael@0: #define flags_sample_duration_present 0x000100 michael@0: #define flags_sample_size_present 0x000200 michael@0: #define flags_sample_flags_present 0x000400 michael@0: #define flags_sample_composition_time_offsets_present 0x000800 michael@0: michael@0: // flag for TrackRunBox::tbl::sample_flags and TrackExtendsBox::default_sample_flags michael@0: // which is defined in 14496-12 8.8.3.1. michael@0: uint32_t set_sample_flags(bool aSync); michael@0: michael@0: // 14496-12 8.8.8 'Track Fragment Run Box' michael@0: // Box type: 'trun' michael@0: class TrackRunBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: typedef struct { michael@0: uint32_t sample_duration; michael@0: uint32_t sample_size; michael@0: uint32_t sample_flags; michael@0: uint32_t sample_composition_time_offset; michael@0: } tbl; michael@0: michael@0: uint32_t sample_count; michael@0: // the following are optional fields michael@0: uint32_t data_offset; // data offset exists when audio/video are present in file. michael@0: uint32_t first_sample_flags; michael@0: nsAutoArrayPtr sample_info_table; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // TrackRunBox methods michael@0: uint32_t GetAllSampleSize() { return mAllSampleSize; } michael@0: nsresult SetDataOffset(uint32_t aOffset); michael@0: michael@0: TrackRunBox(uint32_t aType, uint32_t aFlags, ISOControl* aControl); michael@0: ~TrackRunBox(); michael@0: michael@0: protected: michael@0: uint32_t fillSampleTable(); michael@0: michael@0: uint32_t mAllSampleSize; michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // tf_flags in TrackFragmentHeaderBox, 14496-12 8.8.7.1. michael@0: #define base_data_offset_present 0x000001 michael@0: #define sample_description_index_present 0x000002 michael@0: #define default_sample_duration_present 0x000008 michael@0: #define default_sample_size_present 0x000010 michael@0: #define default_sample_flags_present 0x000020 michael@0: #define duration_is_empty 0x010000 michael@0: #define default_base_is_moof 0x020000 michael@0: michael@0: // 14496-12 8.8.7 'Track Fragment Header Box' michael@0: // Box type: 'tfhd' michael@0: class TrackFragmentHeaderBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint32_t track_ID; michael@0: uint64_t base_data_offset; michael@0: uint32_t default_sample_duration; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // TrackFragmentHeaderBox methods michael@0: nsresult UpdateBaseDataOffset(uint64_t aOffset); // The offset of the first michael@0: // sample in file. michael@0: michael@0: TrackFragmentHeaderBox(uint32_t aType, uint32_t aFlags, ISOControl* aControl); michael@0: ~TrackFragmentHeaderBox(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // 14496-12 8.8.6 'Track Fragment Box' michael@0: // Box type: 'traf' michael@0: // TrackFragmentBox cotains TrackFragmentHeaderBox and TrackRunBox. michael@0: class TrackFragmentBox : public DefaultContainerImpl { michael@0: public: michael@0: TrackFragmentBox(uint32_t aType, ISOControl* aControl); michael@0: ~TrackFragmentBox(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // 14496-12 8.8.5 'Movie Fragment Header Box' michael@0: // Box type: 'mfhd' michael@0: class MovieFragmentHeaderBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint32_t sequence_number; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // MovieFragmentHeaderBox methods michael@0: MovieFragmentHeaderBox(uint32_t aType, ISOControl* aControl); michael@0: ~MovieFragmentHeaderBox(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // 14496-12 8.8.4 'Movie Fragment Box' michael@0: // Box type: 'moof' michael@0: // MovieFragmentBox contains MovieFragmentHeaderBox and TrackFragmentBox. michael@0: class MovieFragmentBox : public DefaultContainerImpl { michael@0: public: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: michael@0: // MovieFragmentBox methods michael@0: MovieFragmentBox(uint32_t aType, ISOControl* aControl); michael@0: ~MovieFragmentBox(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // 14496-12 8.8.3 'Track Extends Box' michael@0: // Box type: 'trex' michael@0: class TrackExtendsBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint32_t track_ID; michael@0: uint32_t default_sample_description_index; michael@0: uint32_t default_sample_duration; michael@0: uint32_t default_sample_size; michael@0: uint32_t default_sample_flags; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // TrackExtendsBox methods michael@0: TrackExtendsBox(uint32_t aType, ISOControl* aControl); michael@0: ~TrackExtendsBox(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // 14496-12 8.8.1 'Movie Extends Box' michael@0: // Box type: 'mvex' michael@0: // MovieExtendsBox contains TrackExtendsBox. michael@0: class MovieExtendsBox : public DefaultContainerImpl { michael@0: public: michael@0: MovieExtendsBox(ISOControl* aControl); michael@0: ~MovieExtendsBox(); michael@0: }; michael@0: michael@0: // 14496-12 8.7.5 'Chunk Offset Box' michael@0: // Box type: 'stco' michael@0: class ChunkOffsetBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: typedef struct { michael@0: uint32_t chunk_offset; michael@0: } tbl; michael@0: michael@0: uint32_t entry_count; michael@0: nsAutoArrayPtr sample_tbl; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // ChunkOffsetBox methods michael@0: ChunkOffsetBox(uint32_t aType, ISOControl* aControl); michael@0: ~ChunkOffsetBox(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // 14496-12 8.7.4 'Sample To Chunk Box' michael@0: // Box type: 'stsc' michael@0: class SampleToChunkBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: typedef struct { michael@0: uint32_t first_chunk; michael@0: uint32_t sample_per_chunk; michael@0: uint32_t sample_description_index; michael@0: } tbl; michael@0: michael@0: uint32_t entry_count; michael@0: nsAutoArrayPtr sample_tbl; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // SampleToChunkBox methods michael@0: SampleToChunkBox(uint32_t aType, ISOControl* aControl); michael@0: ~SampleToChunkBox(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // 14496-12 8.6.1.2 'Decoding Time to Sample Box' michael@0: // Box type: 'stts' michael@0: class TimeToSampleBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: typedef struct { michael@0: uint32_t sample_count; michael@0: uint32_t sample_delta; michael@0: } tbl; michael@0: michael@0: uint32_t entry_count; michael@0: nsAutoArrayPtr sample_tbl; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // TimeToSampleBox methods michael@0: TimeToSampleBox(uint32_t aType, ISOControl* aControl); michael@0: ~TimeToSampleBox(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: /** michael@0: * 14496-12 8.5.2 'Sample Description Box' michael@0: * This is the base class for VisualSampleEntry and AudioSampleEntry. michael@0: * michael@0: * This class is for inherited only, it shouldn't be instanced directly. michael@0: * michael@0: * The inhertied tree of a codec box should be: michael@0: * michael@0: * +--> AVCSampleEntry michael@0: * +--> VisualSampleEntryBox + michael@0: * | +--> ... michael@0: * SampleEntryBox + michael@0: * | +--> MP4AudioSampleEntry michael@0: * +--> AudioSampleEntryBox + michael@0: * +--> AMRSampleEntry michael@0: * + michael@0: * +--> ... michael@0: * michael@0: */ michael@0: class SampleEntryBox : public Box { michael@0: public: michael@0: // ISO BMFF members michael@0: uint8_t reserved[6]; michael@0: uint16_t data_reference_index; michael@0: michael@0: // sampleentrybox methods michael@0: SampleEntryBox(const nsACString& aFormat, ISOControl* aControl); michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: SampleEntryBox() MOZ_DELETE; michael@0: }; michael@0: michael@0: // 14496-12 8.5.2 'Sample Description Box' michael@0: // Box type: 'stsd' michael@0: class SampleDescriptionBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint32_t entry_count; michael@0: nsRefPtr sample_entry_box; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // SampleDescriptionBox methods michael@0: SampleDescriptionBox(uint32_t aType, ISOControl* aControl); michael@0: ~SampleDescriptionBox(); michael@0: michael@0: protected: michael@0: nsresult CreateAudioSampleEntry(nsRefPtr& aSampleEntry); michael@0: nsresult CreateVideoSampleEntry(nsRefPtr& aSampleEntry); michael@0: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // 14496-12 8.5.2.2 michael@0: // The base class for audio codec box. michael@0: // This class is for inherited only, it shouldn't be instanced directly. michael@0: class AudioSampleEntry : public SampleEntryBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint16_t sound_version; michael@0: uint8_t reserved2[6]; michael@0: uint16_t channels; michael@0: uint16_t sample_size; michael@0: uint16_t compressionId; michael@0: uint16_t packet_size; michael@0: uint32_t timeScale; // (sample rate of media) <<16 michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: ~AudioSampleEntry(); michael@0: michael@0: protected: michael@0: AudioSampleEntry(const nsACString& aFormat, ISOControl* aControl); michael@0: }; michael@0: michael@0: // 14496-12 8.5.2.2 michael@0: // The base class for video codec box. michael@0: // This class is for inherited only, it shouldn't be instanced directly. michael@0: class VisualSampleEntry : public SampleEntryBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint8_t reserved[16]; michael@0: uint16_t width; michael@0: uint16_t height; michael@0: michael@0: uint32_t horizresolution; // 72 dpi michael@0: uint32_t vertresolution; // 72 dpi michael@0: uint32_t reserved2; michael@0: uint16_t frame_count; // 1, defined in 14496-12 8.5.2.2 michael@0: michael@0: uint8_t compressorName[32]; michael@0: uint16_t depth; // 0x0018, defined in 14496-12 8.5.2.2; michael@0: uint16_t pre_defined; // -1, defined in 14496-12 8.5.2.2; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // VisualSampleEntry methods michael@0: ~VisualSampleEntry(); michael@0: michael@0: protected: michael@0: VisualSampleEntry(const nsACString& aFormat, ISOControl* aControl); michael@0: }; michael@0: michael@0: // 14496-12 8.7.3.2 'Sample Size Box' michael@0: // Box type: 'stsz' michael@0: class SampleSizeBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint32_t sample_size; michael@0: uint32_t sample_count; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // SampleSizeBox methods michael@0: SampleSizeBox(ISOControl* aControl); michael@0: ~SampleSizeBox(); michael@0: }; michael@0: michael@0: // 14496-12 8.5.1 'Sample Table Box' michael@0: // Box type: 'stbl' michael@0: // michael@0: // SampleTableBox contains SampleDescriptionBox, michael@0: // TimeToSampleBox, michael@0: // SampleToChunkBox, michael@0: // SampleSizeBox and michael@0: // ChunkOffsetBox. michael@0: class SampleTableBox : public DefaultContainerImpl { michael@0: public: michael@0: SampleTableBox(uint32_t aType, ISOControl* aControl); michael@0: ~SampleTableBox(); michael@0: }; michael@0: michael@0: // 14496-12 8.7.2 'Data Reference Box' michael@0: // Box type: 'url ' michael@0: class DataEntryUrlBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: // flags in DataEntryUrlBox::flags michael@0: const static uint16_t flags_media_at_the_same_file = 0x0001; michael@0: michael@0: nsCString location; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // DataEntryUrlBox methods michael@0: DataEntryUrlBox(); michael@0: DataEntryUrlBox(ISOControl* aControl); michael@0: DataEntryUrlBox(const DataEntryUrlBox& aBox); michael@0: ~DataEntryUrlBox(); michael@0: }; michael@0: michael@0: // 14496-12 8.7.2 'Data Reference Box' michael@0: // Box type: 'dref' michael@0: class DataReferenceBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint32_t entry_count; michael@0: nsTArray> urls; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // DataReferenceBox methods michael@0: DataReferenceBox(ISOControl* aControl); michael@0: ~DataReferenceBox(); michael@0: }; michael@0: michael@0: // 14496-12 8.7.1 'Data Information Box' michael@0: // Box type: 'dinf' michael@0: // DataInformationBox contains DataReferenceBox. michael@0: class DataInformationBox : public DefaultContainerImpl { michael@0: public: michael@0: DataInformationBox(ISOControl* aControl); michael@0: ~DataInformationBox(); michael@0: }; michael@0: michael@0: // 14496-12 8.4.5.2 'Video Media Header Box' michael@0: // Box type: 'vmhd' michael@0: class VideoMediaHeaderBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint16_t graphicsmode; michael@0: uint16_t opcolor[3]; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // VideoMediaHeaderBox methods michael@0: VideoMediaHeaderBox(ISOControl* aControl); michael@0: ~VideoMediaHeaderBox(); michael@0: }; michael@0: michael@0: // 14496-12 8.4.5.3 'Sound Media Header Box' michael@0: // Box type: 'smhd' michael@0: class SoundMediaHeaderBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint16_t balance; michael@0: uint16_t reserved; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // SoundMediaHeaderBox methods michael@0: SoundMediaHeaderBox(ISOControl* aControl); michael@0: ~SoundMediaHeaderBox(); michael@0: }; michael@0: michael@0: // 14496-12 8.4.4 'Media Information Box' michael@0: // Box type: 'minf' michael@0: // MediaInformationBox contains SoundMediaHeaderBox, DataInformationBox and michael@0: // SampleTableBox. michael@0: class MediaInformationBox : public DefaultContainerImpl { michael@0: public: michael@0: MediaInformationBox(uint32_t aType, ISOControl* aControl); michael@0: ~MediaInformationBox(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // flags for TrackHeaderBox::flags. michael@0: #define flags_track_enabled 0x000001 michael@0: #define flags_track_in_movie 0x000002 michael@0: #define flags_track_in_preview 0x000004 michael@0: michael@0: // 14496-12 8.3.2 'Track Header Box' michael@0: // Box type: 'tkhd' michael@0: class TrackHeaderBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: // version = 0 michael@0: uint32_t creation_time; michael@0: uint32_t modification_time; michael@0: uint32_t track_ID; michael@0: uint32_t reserved; michael@0: uint32_t duration; michael@0: michael@0: uint32_t reserved2[2]; michael@0: uint16_t layer; michael@0: uint16_t alternate_group; michael@0: uint16_t volume; michael@0: uint16_t reserved3; michael@0: uint32_t matrix[9]; michael@0: uint32_t width; michael@0: uint32_t height; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // TrackHeaderBox methods michael@0: TrackHeaderBox(uint32_t aType, ISOControl* aControl); michael@0: ~TrackHeaderBox(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // 14496-12 8.4.3 'Handler Reference Box' michael@0: // Box type: 'hdlr' michael@0: class HandlerBox : public FullBox { michael@0: public: michael@0: // ISO BMFF members michael@0: uint32_t pre_defined; michael@0: uint32_t handler_type; michael@0: uint32_t reserved[3]; michael@0: nsCString name; michael@0: michael@0: // MuxerOperation methods michael@0: nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; michael@0: nsresult Write() MOZ_OVERRIDE; michael@0: michael@0: // HandlerBox methods michael@0: HandlerBox(uint32_t aType, ISOControl* aControl); michael@0: ~HandlerBox(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: // 14496-12 8.4.1 'Media Box' michael@0: // Box type: 'mdia' michael@0: // MediaBox contains MediaHeaderBox, HandlerBox, and MediaInformationBox. michael@0: class MediaBox : public DefaultContainerImpl { michael@0: public: michael@0: MediaBox(uint32_t aType, ISOControl* aControl); michael@0: ~MediaBox(); michael@0: michael@0: protected: michael@0: uint32_t mTrackType; michael@0: }; michael@0: michael@0: } michael@0: #endif // ISOMediaBoxes_h_