1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/encoder/fmp4_muxer/ISOMediaBoxes.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,781 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef ISOMediaBoxes_h_ 1.10 +#define ISOMediaBoxes_h_ 1.11 + 1.12 +#include <bitset> 1.13 +#include "nsString.h" 1.14 +#include "nsTArray.h" 1.15 +#include "nsAutoPtr.h" 1.16 +#include "MuxerOperation.h" 1.17 + 1.18 +#define WRITE_FULLBOX(_compositor, _size) \ 1.19 + BoxSizeChecker checker(_compositor, _size); \ 1.20 + FullBox::Write(); 1.21 + 1.22 +#define FOURCC(a, b, c, d) ( ((a) << 24) | ((b) << 16) | ((c) << 8) | (d) ) 1.23 + 1.24 +namespace mozilla { 1.25 + 1.26 +/** 1.27 + * track type from spec 8.4.3.3 1.28 + */ 1.29 +#define Audio_Track 0x01 1.30 +#define Video_Track 0x02 1.31 + 1.32 +class AudioTrackMetadata; 1.33 +class VideoTrackMetadata; 1.34 +class ES_Descriptor; 1.35 +class ISOControl; 1.36 + 1.37 +/** 1.38 + * This is the base class for all ISO media format boxes. 1.39 + * It provides the fields of box type(four CC) and size. 1.40 + * The data members in the beginning of a Box (or its descendants) 1.41 + * are the 14496-12 defined member. Other members prefix with 'm' 1.42 + * are private control data. 1.43 + * 1.44 + * This class is for inherited only, it shouldn't be instanced directly. 1.45 + */ 1.46 +class Box : public MuxerOperation { 1.47 +protected: 1.48 + // ISO BMFF members 1.49 + uint32_t size; // 14496-12 4-2 'Object Structure'. Size of this box. 1.50 + nsCString boxType; // four CC name, all table names are listed in 1.51 + // 14496-12 table 1. 1.52 + 1.53 +public: 1.54 + // MuxerOperation methods 1.55 + nsresult Write() MOZ_OVERRIDE; 1.56 + nsresult Find(const nsACString& aType, 1.57 + nsTArray<nsRefPtr<MuxerOperation>>& aOperations) MOZ_OVERRIDE; 1.58 + 1.59 + // This helper class will compare the written size in Write() and the size in 1.60 + // Generate(). If their are not equal, it will assert. 1.61 + class BoxSizeChecker { 1.62 + public: 1.63 + BoxSizeChecker(ISOControl* aControl, uint32_t aSize); 1.64 + ~BoxSizeChecker(); 1.65 + 1.66 + uint32_t ori_size; 1.67 + uint32_t box_size; 1.68 + ISOControl* mControl; 1.69 + }; 1.70 + 1.71 +protected: 1.72 + Box() MOZ_DELETE; 1.73 + Box(const nsACString& aType, ISOControl* aControl); 1.74 + 1.75 + ISOControl* mControl; 1.76 + nsRefPtr<AudioTrackMetadata> mAudioMeta; 1.77 + nsRefPtr<VideoTrackMetadata> mVideoMeta; 1.78 +}; 1.79 + 1.80 +/** 1.81 + * FullBox (and its descendants) is the box which contains the 'real' data 1.82 + * members. It is the edge in the ISO box structure and it doesn't contain 1.83 + * any box. 1.84 + * 1.85 + * This class is for inherited only, it shouldn't be instanced directly. 1.86 + */ 1.87 +class FullBox : public Box { 1.88 +public: 1.89 + // ISO BMFF members 1.90 + uint8_t version; // 14496-12 4.2 'Object Structure' 1.91 + std::bitset<24> flags; // 1.92 + 1.93 + // MuxerOperation methods 1.94 + nsresult Write() MOZ_OVERRIDE; 1.95 + 1.96 +protected: 1.97 + // FullBox methods 1.98 + FullBox(const nsACString& aType, uint8_t aVersion, uint32_t aFlags, 1.99 + ISOControl* aControl); 1.100 + FullBox() MOZ_DELETE; 1.101 +}; 1.102 + 1.103 +/** 1.104 + * The default implementation of the container box. 1.105 + * Basically, the container box inherits this class and overrides the 1.106 + * constructor only. 1.107 + * 1.108 + * According to 14496-12 3.1.1 'container box', a container box is 1.109 + * 'box whose sole purpose is to contain and group a set of related boxes' 1.110 + * 1.111 + * This class is for inherited only, it shouldn't be instanced directly. 1.112 + */ 1.113 +class DefaultContainerImpl : public Box { 1.114 +public: 1.115 + // MuxerOperation methods 1.116 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.117 + nsresult Write() MOZ_OVERRIDE; 1.118 + nsresult Find(const nsACString& aType, 1.119 + nsTArray<nsRefPtr<MuxerOperation>>& aOperations) MOZ_OVERRIDE; 1.120 + 1.121 +protected: 1.122 + // DefaultContainerImpl methods 1.123 + DefaultContainerImpl(const nsACString& aType, ISOControl* aControl); 1.124 + DefaultContainerImpl() MOZ_DELETE; 1.125 + 1.126 + nsTArray<nsRefPtr<MuxerOperation>> boxes; 1.127 +}; 1.128 + 1.129 +// 14496-12 4.3 'File Type Box' 1.130 +// Box type: 'ftyp' 1.131 +class FileTypeBox : public Box { 1.132 +public: 1.133 + // ISO BMFF members 1.134 + nsCString major_brand; // four chars 1.135 + uint32_t minor_version; 1.136 + nsTArray<nsCString> compatible_brands; 1.137 + 1.138 + // MuxerOperation methods 1.139 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.140 + nsresult Write() MOZ_OVERRIDE; 1.141 + 1.142 + // FileTypeBox methods 1.143 + FileTypeBox(ISOControl* aControl); 1.144 + ~FileTypeBox(); 1.145 +}; 1.146 + 1.147 +// 14496-12 8.2.1 'Movie Box' 1.148 +// Box type: 'moov' 1.149 +// MovieBox contains MovieHeaderBox, TrackBox and MovieExtendsBox. 1.150 +class MovieBox : public DefaultContainerImpl { 1.151 +public: 1.152 + MovieBox(ISOControl* aControl); 1.153 + ~MovieBox(); 1.154 +}; 1.155 + 1.156 +// 14496-12 8.2.2 'Movie Header Box' 1.157 +// Box type: 'mvhd' 1.158 +class MovieHeaderBox : public FullBox { 1.159 +public: 1.160 + // ISO BMFF members 1.161 + uint32_t creation_time; 1.162 + uint32_t modification_time; 1.163 + uint32_t timescale; 1.164 + uint32_t duration; 1.165 + uint32_t rate; 1.166 + uint16_t volume; 1.167 + uint16_t reserved16; 1.168 + uint32_t reserved32[2]; 1.169 + uint32_t matrix[9]; 1.170 + uint32_t pre_defined[6]; 1.171 + uint32_t next_track_ID; 1.172 + 1.173 + // MuxerOperation methods 1.174 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.175 + nsresult Write() MOZ_OVERRIDE; 1.176 + 1.177 + // MovieHeaderBox methods 1.178 + MovieHeaderBox(ISOControl* aControl); 1.179 + ~MovieHeaderBox(); 1.180 + uint32_t GetTimeScale(); 1.181 +}; 1.182 + 1.183 +// 14496-12 8.4.2 'Media Header Box' 1.184 +// Box type: 'mdhd' 1.185 +class MediaHeaderBox : public FullBox { 1.186 +public: 1.187 + // ISO BMFF members 1.188 + uint32_t creation_time; 1.189 + uint32_t modification_time; 1.190 + uint32_t timescale; 1.191 + uint32_t duration; 1.192 + std::bitset<1> pad; 1.193 + std::bitset<5> lang1; 1.194 + std::bitset<5> lang2; 1.195 + std::bitset<5> lang3; 1.196 + uint16_t pre_defined; 1.197 + 1.198 + // MuxerOperation methods 1.199 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.200 + nsresult Write() MOZ_OVERRIDE; 1.201 + 1.202 + // MediaHeaderBox methods 1.203 + MediaHeaderBox(uint32_t aType, ISOControl* aControl); 1.204 + ~MediaHeaderBox(); 1.205 + uint32_t GetTimeScale(); 1.206 + 1.207 +protected: 1.208 + uint32_t mTrackType; 1.209 +}; 1.210 + 1.211 +// 14496-12 8.3.1 'Track Box' 1.212 +// Box type: 'trak' 1.213 +// TrackBox contains TrackHeaderBox and MediaBox. 1.214 +class TrackBox : public DefaultContainerImpl { 1.215 +public: 1.216 + TrackBox(uint32_t aTrackType, ISOControl* aControl); 1.217 + ~TrackBox(); 1.218 +}; 1.219 + 1.220 +// 14496-12 8.1.1 'Media Data Box' 1.221 +// Box type: 'mdat' 1.222 +class MediaDataBox : public Box { 1.223 +public: 1.224 + // MuxerOperation methods 1.225 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.226 + nsresult Write() MOZ_OVERRIDE; 1.227 + 1.228 + // MediaDataBox methods 1.229 + uint32_t GetAllSampleSize() { return mAllSampleSize; } 1.230 + uint32_t FirstSampleOffsetInMediaDataBox() { return mFirstSampleOffset; } 1.231 + MediaDataBox(uint32_t aTrackType, ISOControl* aControl); 1.232 + ~MediaDataBox(); 1.233 + 1.234 +protected: 1.235 + uint32_t mAllSampleSize; // All audio and video sample size in this box. 1.236 + uint32_t mFirstSampleOffset; // The offset of first sample in this box from 1.237 + // the beginning of this mp4 file. 1.238 + uint32_t mTrackType; 1.239 +}; 1.240 + 1.241 +// flags for TrackRunBox::flags, 14496-12 8.8.8.1. 1.242 +#define flags_data_offset_present 0x000001 1.243 +#define flags_first_sample_flags_present 0x000002 1.244 +#define flags_sample_duration_present 0x000100 1.245 +#define flags_sample_size_present 0x000200 1.246 +#define flags_sample_flags_present 0x000400 1.247 +#define flags_sample_composition_time_offsets_present 0x000800 1.248 + 1.249 +// flag for TrackRunBox::tbl::sample_flags and TrackExtendsBox::default_sample_flags 1.250 +// which is defined in 14496-12 8.8.3.1. 1.251 +uint32_t set_sample_flags(bool aSync); 1.252 + 1.253 +// 14496-12 8.8.8 'Track Fragment Run Box' 1.254 +// Box type: 'trun' 1.255 +class TrackRunBox : public FullBox { 1.256 +public: 1.257 + // ISO BMFF members 1.258 + typedef struct { 1.259 + uint32_t sample_duration; 1.260 + uint32_t sample_size; 1.261 + uint32_t sample_flags; 1.262 + uint32_t sample_composition_time_offset; 1.263 + } tbl; 1.264 + 1.265 + uint32_t sample_count; 1.266 + // the following are optional fields 1.267 + uint32_t data_offset; // data offset exists when audio/video are present in file. 1.268 + uint32_t first_sample_flags; 1.269 + nsAutoArrayPtr<tbl> sample_info_table; 1.270 + 1.271 + // MuxerOperation methods 1.272 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.273 + nsresult Write() MOZ_OVERRIDE; 1.274 + 1.275 + // TrackRunBox methods 1.276 + uint32_t GetAllSampleSize() { return mAllSampleSize; } 1.277 + nsresult SetDataOffset(uint32_t aOffset); 1.278 + 1.279 + TrackRunBox(uint32_t aType, uint32_t aFlags, ISOControl* aControl); 1.280 + ~TrackRunBox(); 1.281 + 1.282 +protected: 1.283 + uint32_t fillSampleTable(); 1.284 + 1.285 + uint32_t mAllSampleSize; 1.286 + uint32_t mTrackType; 1.287 +}; 1.288 + 1.289 +// tf_flags in TrackFragmentHeaderBox, 14496-12 8.8.7.1. 1.290 +#define base_data_offset_present 0x000001 1.291 +#define sample_description_index_present 0x000002 1.292 +#define default_sample_duration_present 0x000008 1.293 +#define default_sample_size_present 0x000010 1.294 +#define default_sample_flags_present 0x000020 1.295 +#define duration_is_empty 0x010000 1.296 +#define default_base_is_moof 0x020000 1.297 + 1.298 +// 14496-12 8.8.7 'Track Fragment Header Box' 1.299 +// Box type: 'tfhd' 1.300 +class TrackFragmentHeaderBox : public FullBox { 1.301 +public: 1.302 + // ISO BMFF members 1.303 + uint32_t track_ID; 1.304 + uint64_t base_data_offset; 1.305 + uint32_t default_sample_duration; 1.306 + 1.307 + // MuxerOperation methods 1.308 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.309 + nsresult Write() MOZ_OVERRIDE; 1.310 + 1.311 + // TrackFragmentHeaderBox methods 1.312 + nsresult UpdateBaseDataOffset(uint64_t aOffset); // The offset of the first 1.313 + // sample in file. 1.314 + 1.315 + TrackFragmentHeaderBox(uint32_t aType, uint32_t aFlags, ISOControl* aControl); 1.316 + ~TrackFragmentHeaderBox(); 1.317 + 1.318 +protected: 1.319 + uint32_t mTrackType; 1.320 +}; 1.321 + 1.322 +// 14496-12 8.8.6 'Track Fragment Box' 1.323 +// Box type: 'traf' 1.324 +// TrackFragmentBox cotains TrackFragmentHeaderBox and TrackRunBox. 1.325 +class TrackFragmentBox : public DefaultContainerImpl { 1.326 +public: 1.327 + TrackFragmentBox(uint32_t aType, ISOControl* aControl); 1.328 + ~TrackFragmentBox(); 1.329 + 1.330 +protected: 1.331 + uint32_t mTrackType; 1.332 +}; 1.333 + 1.334 +// 14496-12 8.8.5 'Movie Fragment Header Box' 1.335 +// Box type: 'mfhd' 1.336 +class MovieFragmentHeaderBox : public FullBox { 1.337 +public: 1.338 + // ISO BMFF members 1.339 + uint32_t sequence_number; 1.340 + 1.341 + // MuxerOperation methods 1.342 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.343 + nsresult Write() MOZ_OVERRIDE; 1.344 + 1.345 + // MovieFragmentHeaderBox methods 1.346 + MovieFragmentHeaderBox(uint32_t aType, ISOControl* aControl); 1.347 + ~MovieFragmentHeaderBox(); 1.348 + 1.349 +protected: 1.350 + uint32_t mTrackType; 1.351 +}; 1.352 + 1.353 +// 14496-12 8.8.4 'Movie Fragment Box' 1.354 +// Box type: 'moof' 1.355 +// MovieFragmentBox contains MovieFragmentHeaderBox and TrackFragmentBox. 1.356 +class MovieFragmentBox : public DefaultContainerImpl { 1.357 +public: 1.358 + // MuxerOperation methods 1.359 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.360 + 1.361 + // MovieFragmentBox methods 1.362 + MovieFragmentBox(uint32_t aType, ISOControl* aControl); 1.363 + ~MovieFragmentBox(); 1.364 + 1.365 +protected: 1.366 + uint32_t mTrackType; 1.367 +}; 1.368 + 1.369 +// 14496-12 8.8.3 'Track Extends Box' 1.370 +// Box type: 'trex' 1.371 +class TrackExtendsBox : public FullBox { 1.372 +public: 1.373 + // ISO BMFF members 1.374 + uint32_t track_ID; 1.375 + uint32_t default_sample_description_index; 1.376 + uint32_t default_sample_duration; 1.377 + uint32_t default_sample_size; 1.378 + uint32_t default_sample_flags; 1.379 + 1.380 + // MuxerOperation methods 1.381 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.382 + nsresult Write() MOZ_OVERRIDE; 1.383 + 1.384 + // TrackExtendsBox methods 1.385 + TrackExtendsBox(uint32_t aType, ISOControl* aControl); 1.386 + ~TrackExtendsBox(); 1.387 + 1.388 +protected: 1.389 + uint32_t mTrackType; 1.390 +}; 1.391 + 1.392 +// 14496-12 8.8.1 'Movie Extends Box' 1.393 +// Box type: 'mvex' 1.394 +// MovieExtendsBox contains TrackExtendsBox. 1.395 +class MovieExtendsBox : public DefaultContainerImpl { 1.396 +public: 1.397 + MovieExtendsBox(ISOControl* aControl); 1.398 + ~MovieExtendsBox(); 1.399 +}; 1.400 + 1.401 +// 14496-12 8.7.5 'Chunk Offset Box' 1.402 +// Box type: 'stco' 1.403 +class ChunkOffsetBox : public FullBox { 1.404 +public: 1.405 + // ISO BMFF members 1.406 + typedef struct { 1.407 + uint32_t chunk_offset; 1.408 + } tbl; 1.409 + 1.410 + uint32_t entry_count; 1.411 + nsAutoArrayPtr<tbl> sample_tbl; 1.412 + 1.413 + // MuxerOperation methods 1.414 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.415 + nsresult Write() MOZ_OVERRIDE; 1.416 + 1.417 + // ChunkOffsetBox methods 1.418 + ChunkOffsetBox(uint32_t aType, ISOControl* aControl); 1.419 + ~ChunkOffsetBox(); 1.420 + 1.421 +protected: 1.422 + uint32_t mTrackType; 1.423 +}; 1.424 + 1.425 +// 14496-12 8.7.4 'Sample To Chunk Box' 1.426 +// Box type: 'stsc' 1.427 +class SampleToChunkBox : public FullBox { 1.428 +public: 1.429 + // ISO BMFF members 1.430 + typedef struct { 1.431 + uint32_t first_chunk; 1.432 + uint32_t sample_per_chunk; 1.433 + uint32_t sample_description_index; 1.434 + } tbl; 1.435 + 1.436 + uint32_t entry_count; 1.437 + nsAutoArrayPtr<tbl> sample_tbl; 1.438 + 1.439 + // MuxerOperation methods 1.440 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.441 + nsresult Write() MOZ_OVERRIDE; 1.442 + 1.443 + // SampleToChunkBox methods 1.444 + SampleToChunkBox(uint32_t aType, ISOControl* aControl); 1.445 + ~SampleToChunkBox(); 1.446 + 1.447 +protected: 1.448 + uint32_t mTrackType; 1.449 +}; 1.450 + 1.451 +// 14496-12 8.6.1.2 'Decoding Time to Sample Box' 1.452 +// Box type: 'stts' 1.453 +class TimeToSampleBox : public FullBox { 1.454 +public: 1.455 + // ISO BMFF members 1.456 + typedef struct { 1.457 + uint32_t sample_count; 1.458 + uint32_t sample_delta; 1.459 + } tbl; 1.460 + 1.461 + uint32_t entry_count; 1.462 + nsAutoArrayPtr<tbl> sample_tbl; 1.463 + 1.464 + // MuxerOperation methods 1.465 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.466 + nsresult Write() MOZ_OVERRIDE; 1.467 + 1.468 + // TimeToSampleBox methods 1.469 + TimeToSampleBox(uint32_t aType, ISOControl* aControl); 1.470 + ~TimeToSampleBox(); 1.471 + 1.472 +protected: 1.473 + uint32_t mTrackType; 1.474 +}; 1.475 + 1.476 +/** 1.477 + * 14496-12 8.5.2 'Sample Description Box' 1.478 + * This is the base class for VisualSampleEntry and AudioSampleEntry. 1.479 + * 1.480 + * This class is for inherited only, it shouldn't be instanced directly. 1.481 + * 1.482 + * The inhertied tree of a codec box should be: 1.483 + * 1.484 + * +--> AVCSampleEntry 1.485 + * +--> VisualSampleEntryBox + 1.486 + * | +--> ... 1.487 + * SampleEntryBox + 1.488 + * | +--> MP4AudioSampleEntry 1.489 + * +--> AudioSampleEntryBox + 1.490 + * +--> AMRSampleEntry 1.491 + * + 1.492 + * +--> ... 1.493 + * 1.494 + */ 1.495 +class SampleEntryBox : public Box { 1.496 +public: 1.497 + // ISO BMFF members 1.498 + uint8_t reserved[6]; 1.499 + uint16_t data_reference_index; 1.500 + 1.501 + // sampleentrybox methods 1.502 + SampleEntryBox(const nsACString& aFormat, ISOControl* aControl); 1.503 + 1.504 + // MuxerOperation methods 1.505 + nsresult Write() MOZ_OVERRIDE; 1.506 + 1.507 +protected: 1.508 + SampleEntryBox() MOZ_DELETE; 1.509 +}; 1.510 + 1.511 +// 14496-12 8.5.2 'Sample Description Box' 1.512 +// Box type: 'stsd' 1.513 +class SampleDescriptionBox : public FullBox { 1.514 +public: 1.515 + // ISO BMFF members 1.516 + uint32_t entry_count; 1.517 + nsRefPtr<SampleEntryBox> sample_entry_box; 1.518 + 1.519 + // MuxerOperation methods 1.520 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.521 + nsresult Write() MOZ_OVERRIDE; 1.522 + 1.523 + // SampleDescriptionBox methods 1.524 + SampleDescriptionBox(uint32_t aType, ISOControl* aControl); 1.525 + ~SampleDescriptionBox(); 1.526 + 1.527 +protected: 1.528 + nsresult CreateAudioSampleEntry(nsRefPtr<SampleEntryBox>& aSampleEntry); 1.529 + nsresult CreateVideoSampleEntry(nsRefPtr<SampleEntryBox>& aSampleEntry); 1.530 + 1.531 + uint32_t mTrackType; 1.532 +}; 1.533 + 1.534 +// 14496-12 8.5.2.2 1.535 +// The base class for audio codec box. 1.536 +// This class is for inherited only, it shouldn't be instanced directly. 1.537 +class AudioSampleEntry : public SampleEntryBox { 1.538 +public: 1.539 + // ISO BMFF members 1.540 + uint16_t sound_version; 1.541 + uint8_t reserved2[6]; 1.542 + uint16_t channels; 1.543 + uint16_t sample_size; 1.544 + uint16_t compressionId; 1.545 + uint16_t packet_size; 1.546 + uint32_t timeScale; // (sample rate of media) <<16 1.547 + 1.548 + // MuxerOperation methods 1.549 + nsresult Write() MOZ_OVERRIDE; 1.550 + 1.551 + ~AudioSampleEntry(); 1.552 + 1.553 +protected: 1.554 + AudioSampleEntry(const nsACString& aFormat, ISOControl* aControl); 1.555 +}; 1.556 + 1.557 +// 14496-12 8.5.2.2 1.558 +// The base class for video codec box. 1.559 +// This class is for inherited only, it shouldn't be instanced directly. 1.560 +class VisualSampleEntry : public SampleEntryBox { 1.561 +public: 1.562 + // ISO BMFF members 1.563 + uint8_t reserved[16]; 1.564 + uint16_t width; 1.565 + uint16_t height; 1.566 + 1.567 + uint32_t horizresolution; // 72 dpi 1.568 + uint32_t vertresolution; // 72 dpi 1.569 + uint32_t reserved2; 1.570 + uint16_t frame_count; // 1, defined in 14496-12 8.5.2.2 1.571 + 1.572 + uint8_t compressorName[32]; 1.573 + uint16_t depth; // 0x0018, defined in 14496-12 8.5.2.2; 1.574 + uint16_t pre_defined; // -1, defined in 14496-12 8.5.2.2; 1.575 + 1.576 + // MuxerOperation methods 1.577 + nsresult Write() MOZ_OVERRIDE; 1.578 + 1.579 + // VisualSampleEntry methods 1.580 + ~VisualSampleEntry(); 1.581 + 1.582 +protected: 1.583 + VisualSampleEntry(const nsACString& aFormat, ISOControl* aControl); 1.584 +}; 1.585 + 1.586 +// 14496-12 8.7.3.2 'Sample Size Box' 1.587 +// Box type: 'stsz' 1.588 +class SampleSizeBox : public FullBox { 1.589 +public: 1.590 + // ISO BMFF members 1.591 + uint32_t sample_size; 1.592 + uint32_t sample_count; 1.593 + 1.594 + // MuxerOperation methods 1.595 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.596 + nsresult Write() MOZ_OVERRIDE; 1.597 + 1.598 + // SampleSizeBox methods 1.599 + SampleSizeBox(ISOControl* aControl); 1.600 + ~SampleSizeBox(); 1.601 +}; 1.602 + 1.603 +// 14496-12 8.5.1 'Sample Table Box' 1.604 +// Box type: 'stbl' 1.605 +// 1.606 +// SampleTableBox contains SampleDescriptionBox, 1.607 +// TimeToSampleBox, 1.608 +// SampleToChunkBox, 1.609 +// SampleSizeBox and 1.610 +// ChunkOffsetBox. 1.611 +class SampleTableBox : public DefaultContainerImpl { 1.612 +public: 1.613 + SampleTableBox(uint32_t aType, ISOControl* aControl); 1.614 + ~SampleTableBox(); 1.615 +}; 1.616 + 1.617 +// 14496-12 8.7.2 'Data Reference Box' 1.618 +// Box type: 'url ' 1.619 +class DataEntryUrlBox : public FullBox { 1.620 +public: 1.621 + // ISO BMFF members 1.622 + // flags in DataEntryUrlBox::flags 1.623 + const static uint16_t flags_media_at_the_same_file = 0x0001; 1.624 + 1.625 + nsCString location; 1.626 + 1.627 + // MuxerOperation methods 1.628 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.629 + nsresult Write() MOZ_OVERRIDE; 1.630 + 1.631 + // DataEntryUrlBox methods 1.632 + DataEntryUrlBox(); 1.633 + DataEntryUrlBox(ISOControl* aControl); 1.634 + DataEntryUrlBox(const DataEntryUrlBox& aBox); 1.635 + ~DataEntryUrlBox(); 1.636 +}; 1.637 + 1.638 +// 14496-12 8.7.2 'Data Reference Box' 1.639 +// Box type: 'dref' 1.640 +class DataReferenceBox : public FullBox { 1.641 +public: 1.642 + // ISO BMFF members 1.643 + uint32_t entry_count; 1.644 + nsTArray<nsAutoPtr<DataEntryUrlBox>> urls; 1.645 + 1.646 + // MuxerOperation methods 1.647 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.648 + nsresult Write() MOZ_OVERRIDE; 1.649 + 1.650 + // DataReferenceBox methods 1.651 + DataReferenceBox(ISOControl* aControl); 1.652 + ~DataReferenceBox(); 1.653 +}; 1.654 + 1.655 +// 14496-12 8.7.1 'Data Information Box' 1.656 +// Box type: 'dinf' 1.657 +// DataInformationBox contains DataReferenceBox. 1.658 +class DataInformationBox : public DefaultContainerImpl { 1.659 +public: 1.660 + DataInformationBox(ISOControl* aControl); 1.661 + ~DataInformationBox(); 1.662 +}; 1.663 + 1.664 +// 14496-12 8.4.5.2 'Video Media Header Box' 1.665 +// Box type: 'vmhd' 1.666 +class VideoMediaHeaderBox : public FullBox { 1.667 +public: 1.668 + // ISO BMFF members 1.669 + uint16_t graphicsmode; 1.670 + uint16_t opcolor[3]; 1.671 + 1.672 + // MuxerOperation methods 1.673 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.674 + nsresult Write() MOZ_OVERRIDE; 1.675 + 1.676 + // VideoMediaHeaderBox methods 1.677 + VideoMediaHeaderBox(ISOControl* aControl); 1.678 + ~VideoMediaHeaderBox(); 1.679 +}; 1.680 + 1.681 +// 14496-12 8.4.5.3 'Sound Media Header Box' 1.682 +// Box type: 'smhd' 1.683 +class SoundMediaHeaderBox : public FullBox { 1.684 +public: 1.685 + // ISO BMFF members 1.686 + uint16_t balance; 1.687 + uint16_t reserved; 1.688 + 1.689 + // MuxerOperation methods 1.690 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.691 + nsresult Write() MOZ_OVERRIDE; 1.692 + 1.693 + // SoundMediaHeaderBox methods 1.694 + SoundMediaHeaderBox(ISOControl* aControl); 1.695 + ~SoundMediaHeaderBox(); 1.696 +}; 1.697 + 1.698 +// 14496-12 8.4.4 'Media Information Box' 1.699 +// Box type: 'minf' 1.700 +// MediaInformationBox contains SoundMediaHeaderBox, DataInformationBox and 1.701 +// SampleTableBox. 1.702 +class MediaInformationBox : public DefaultContainerImpl { 1.703 +public: 1.704 + MediaInformationBox(uint32_t aType, ISOControl* aControl); 1.705 + ~MediaInformationBox(); 1.706 + 1.707 +protected: 1.708 + uint32_t mTrackType; 1.709 +}; 1.710 + 1.711 +// flags for TrackHeaderBox::flags. 1.712 +#define flags_track_enabled 0x000001 1.713 +#define flags_track_in_movie 0x000002 1.714 +#define flags_track_in_preview 0x000004 1.715 + 1.716 +// 14496-12 8.3.2 'Track Header Box' 1.717 +// Box type: 'tkhd' 1.718 +class TrackHeaderBox : public FullBox { 1.719 +public: 1.720 + // ISO BMFF members 1.721 + // version = 0 1.722 + uint32_t creation_time; 1.723 + uint32_t modification_time; 1.724 + uint32_t track_ID; 1.725 + uint32_t reserved; 1.726 + uint32_t duration; 1.727 + 1.728 + uint32_t reserved2[2]; 1.729 + uint16_t layer; 1.730 + uint16_t alternate_group; 1.731 + uint16_t volume; 1.732 + uint16_t reserved3; 1.733 + uint32_t matrix[9]; 1.734 + uint32_t width; 1.735 + uint32_t height; 1.736 + 1.737 + // MuxerOperation methods 1.738 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.739 + nsresult Write() MOZ_OVERRIDE; 1.740 + 1.741 + // TrackHeaderBox methods 1.742 + TrackHeaderBox(uint32_t aType, ISOControl* aControl); 1.743 + ~TrackHeaderBox(); 1.744 + 1.745 +protected: 1.746 + uint32_t mTrackType; 1.747 +}; 1.748 + 1.749 +// 14496-12 8.4.3 'Handler Reference Box' 1.750 +// Box type: 'hdlr' 1.751 +class HandlerBox : public FullBox { 1.752 +public: 1.753 + // ISO BMFF members 1.754 + uint32_t pre_defined; 1.755 + uint32_t handler_type; 1.756 + uint32_t reserved[3]; 1.757 + nsCString name; 1.758 + 1.759 + // MuxerOperation methods 1.760 + nsresult Generate(uint32_t* aBoxSize) MOZ_OVERRIDE; 1.761 + nsresult Write() MOZ_OVERRIDE; 1.762 + 1.763 + // HandlerBox methods 1.764 + HandlerBox(uint32_t aType, ISOControl* aControl); 1.765 + ~HandlerBox(); 1.766 + 1.767 +protected: 1.768 + uint32_t mTrackType; 1.769 +}; 1.770 + 1.771 +// 14496-12 8.4.1 'Media Box' 1.772 +// Box type: 'mdia' 1.773 +// MediaBox contains MediaHeaderBox, HandlerBox, and MediaInformationBox. 1.774 +class MediaBox : public DefaultContainerImpl { 1.775 +public: 1.776 + MediaBox(uint32_t aType, ISOControl* aControl); 1.777 + ~MediaBox(); 1.778 + 1.779 +protected: 1.780 + uint32_t mTrackType; 1.781 +}; 1.782 + 1.783 +} 1.784 +#endif // ISOMediaBoxes_h_