content/media/encoder/fmp4_muxer/ISOMediaBoxes.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial