Set Box Definition Defaults in Header

To ensure that every variable in a box is explicitly set
every variable has been assigned a default in the header.

Change-Id: Iaa806c4058ac6621a64363a00040fbd9903c6710
This commit is contained in:
Aaron Vaage 2018-06-04 15:07:00 -07:00
parent 47f20031dd
commit cc1d4b765a
4 changed files with 334 additions and 336 deletions

View File

@ -69,8 +69,8 @@ bool Box::ReadWriteHeaderInternal(BoxBuffer* buffer) {
return true; return true;
} }
FullBox::FullBox() : version(0), flags(0) {} FullBox::FullBox() = default;
FullBox::~FullBox() {} FullBox::~FullBox() = default;
uint32_t FullBox::HeaderSize() const { uint32_t FullBox::HeaderSize() const {
// Additional 1-byte version and 3-byte flags. // Additional 1-byte version and 3-byte flags.

View File

@ -87,8 +87,8 @@ struct FullBox : Box {
uint32_t HeaderSize() const final; uint32_t HeaderSize() const final;
uint8_t version; uint8_t version = 0;
uint32_t flags; uint32_t flags = 0;
protected: protected:
bool ReadWriteHeaderInternal(BoxBuffer* buffer) final; bool ReadWriteHeaderInternal(BoxBuffer* buffer) final;

View File

@ -38,11 +38,6 @@ const char kAvcCompressorName[] = "\012AVC Coding";
const char kHevcCompressorName[] = "\013HEVC Coding"; const char kHevcCompressorName[] = "\013HEVC Coding";
const char kVpcCompressorName[] = "\012VPC Coding"; const char kVpcCompressorName[] = "\012VPC Coding";
// Using negative value as "not set". It is very unlikely that 2^31 cues happen
// at once.
const int kCueSourceIdNotSet = -1;
const size_t kInvalidIvSize = 1;
// According to ISO/IEC FDIS 23001-7: CENC spec, IV should be either // According to ISO/IEC FDIS 23001-7: CENC spec, IV should be either
// 64-bit (8-byte) or 128-bit (16-byte). // 64-bit (8-byte) or 128-bit (16-byte).
// |per_sample_iv_size| of 0 means constant_iv is used. // |per_sample_iv_size| of 0 means constant_iv is used.
@ -128,8 +123,9 @@ bool IsProtectionSchemeSupported(FourCC scheme) {
} // namespace } // namespace
FileType::FileType() : major_brand(FOURCC_NULL), minor_version(0) {} FileType::FileType() = default;
FileType::~FileType() {} FileType::~FileType() = default;
FourCC FileType::BoxType() const { FourCC FileType::BoxType() const {
return FOURCC_ftyp; return FOURCC_ftyp;
} }
@ -160,8 +156,9 @@ FourCC SegmentType::BoxType() const {
return FOURCC_styp; return FOURCC_styp;
} }
ProtectionSystemSpecificHeader::ProtectionSystemSpecificHeader() {} ProtectionSystemSpecificHeader::ProtectionSystemSpecificHeader() = default;
ProtectionSystemSpecificHeader::~ProtectionSystemSpecificHeader() {} ProtectionSystemSpecificHeader::~ProtectionSystemSpecificHeader() = default;
FourCC ProtectionSystemSpecificHeader::BoxType() const { FourCC ProtectionSystemSpecificHeader::BoxType() const {
return FOURCC_pssh; return FOURCC_pssh;
} }
@ -183,8 +180,9 @@ size_t ProtectionSystemSpecificHeader::ComputeSizeInternal() {
return raw_box.size(); return raw_box.size();
} }
SampleAuxiliaryInformationOffset::SampleAuxiliaryInformationOffset() {} SampleAuxiliaryInformationOffset::SampleAuxiliaryInformationOffset() = default;
SampleAuxiliaryInformationOffset::~SampleAuxiliaryInformationOffset() {} SampleAuxiliaryInformationOffset::~SampleAuxiliaryInformationOffset() = default;
FourCC SampleAuxiliaryInformationOffset::BoxType() const { FourCC SampleAuxiliaryInformationOffset::BoxType() const {
return FOURCC_saio; return FOURCC_saio;
} }
@ -212,9 +210,9 @@ size_t SampleAuxiliaryInformationOffset::ComputeSizeInternal() {
return HeaderSize() + sizeof(uint32_t) + num_bytes * offsets.size(); return HeaderSize() + sizeof(uint32_t) + num_bytes * offsets.size();
} }
SampleAuxiliaryInformationSize::SampleAuxiliaryInformationSize() SampleAuxiliaryInformationSize::SampleAuxiliaryInformationSize() = default;
: default_sample_info_size(0), sample_count(0) {} SampleAuxiliaryInformationSize::~SampleAuxiliaryInformationSize() = default;
SampleAuxiliaryInformationSize::~SampleAuxiliaryInformationSize() {}
FourCC SampleAuxiliaryInformationSize::BoxType() const { FourCC SampleAuxiliaryInformationSize::BoxType() const {
return FOURCC_saiz; return FOURCC_saiz;
} }
@ -240,9 +238,6 @@ size_t SampleAuxiliaryInformationSize::ComputeSizeInternal() {
(default_sample_info_size == 0 ? sample_info_sizes.size() : 0); (default_sample_info_size == 0 ? sample_info_sizes.size() : 0);
} }
SampleEncryptionEntry::SampleEncryptionEntry() {}
SampleEncryptionEntry::~SampleEncryptionEntry() {}
bool SampleEncryptionEntry::ReadWrite(uint8_t iv_size, bool SampleEncryptionEntry::ReadWrite(uint8_t iv_size,
bool has_subsamples, bool has_subsamples,
BoxBuffer* buffer) { BoxBuffer* buffer) {
@ -309,8 +304,9 @@ uint32_t SampleEncryptionEntry::GetTotalSizeOfSubsamples() const {
return size; return size;
} }
SampleEncryption::SampleEncryption() : iv_size(kInvalidIvSize) {} SampleEncryption::SampleEncryption() = default;
SampleEncryption::~SampleEncryption() {} SampleEncryption::~SampleEncryption() = default;
FourCC SampleEncryption::BoxType() const { FourCC SampleEncryption::BoxType() const {
return FOURCC_senc; return FOURCC_senc;
} }
@ -320,7 +316,7 @@ bool SampleEncryption::ReadWriteInternal(BoxBuffer* buffer) {
// If we don't know |iv_size|, store sample encryption data to parse later // If we don't know |iv_size|, store sample encryption data to parse later
// after we know iv_size. // after we know iv_size.
if (buffer->Reading() && iv_size == kInvalidIvSize) { if (buffer->Reading() && iv_size == SampleEncryption::kInvalidIvSize) {
RCHECK( RCHECK(
buffer->ReadWriteVector(&sample_encryption_data, buffer->BytesLeft())); buffer->ReadWriteVector(&sample_encryption_data, buffer->BytesLeft()));
return true; return true;
@ -384,8 +380,9 @@ bool SampleEncryption::ParseFromSampleEncryptionData(
return true; return true;
} }
OriginalFormat::OriginalFormat() : format(FOURCC_NULL) {} OriginalFormat::OriginalFormat() = default;
OriginalFormat::~OriginalFormat() {} OriginalFormat::~OriginalFormat() = default;
FourCC OriginalFormat::BoxType() const { FourCC OriginalFormat::BoxType() const {
return FOURCC_frma; return FOURCC_frma;
} }
@ -398,8 +395,9 @@ size_t OriginalFormat::ComputeSizeInternal() {
return HeaderSize() + kFourCCSize; return HeaderSize() + kFourCCSize;
} }
SchemeType::SchemeType() : type(FOURCC_NULL), version(0) {} SchemeType::SchemeType() = default;
SchemeType::~SchemeType() {} SchemeType::~SchemeType() = default;
FourCC SchemeType::BoxType() const { FourCC SchemeType::BoxType() const {
return FOURCC_schm; return FOURCC_schm;
} }
@ -414,13 +412,9 @@ size_t SchemeType::ComputeSizeInternal() {
return HeaderSize() + kFourCCSize + sizeof(version); return HeaderSize() + kFourCCSize + sizeof(version);
} }
TrackEncryption::TrackEncryption() TrackEncryption::TrackEncryption() = default;
: default_is_protected(0), TrackEncryption::~TrackEncryption() = default;
default_per_sample_iv_size(0),
default_kid(16, 0),
default_crypt_byte_block(0),
default_skip_byte_block(0) {}
TrackEncryption::~TrackEncryption() {}
FourCC TrackEncryption::BoxType() const { FourCC TrackEncryption::BoxType() const {
return FOURCC_tenc; return FOURCC_tenc;
} }
@ -482,8 +476,9 @@ size_t TrackEncryption::ComputeSizeInternal() {
: (sizeof(uint8_t) + default_constant_iv.size())); : (sizeof(uint8_t) + default_constant_iv.size()));
} }
SchemeInfo::SchemeInfo() {} SchemeInfo::SchemeInfo() = default;
SchemeInfo::~SchemeInfo() {} SchemeInfo::~SchemeInfo() = default;
FourCC SchemeInfo::BoxType() const { FourCC SchemeInfo::BoxType() const {
return FOURCC_schi; return FOURCC_schi;
} }
@ -498,8 +493,9 @@ size_t SchemeInfo::ComputeSizeInternal() {
return HeaderSize() + track_encryption.ComputeSize(); return HeaderSize() + track_encryption.ComputeSize();
} }
ProtectionSchemeInfo::ProtectionSchemeInfo() {} ProtectionSchemeInfo::ProtectionSchemeInfo() = default;
ProtectionSchemeInfo::~ProtectionSchemeInfo() {} ProtectionSchemeInfo::~ProtectionSchemeInfo() = default;
FourCC ProtectionSchemeInfo::BoxType() const { FourCC ProtectionSchemeInfo::BoxType() const {
return FOURCC_sinf; return FOURCC_sinf;
} }
@ -528,15 +524,9 @@ size_t ProtectionSchemeInfo::ComputeSizeInternal() {
info.ComputeSize(); info.ComputeSize();
} }
MovieHeader::MovieHeader() MovieHeader::MovieHeader() = default;
: creation_time(0), MovieHeader::~MovieHeader() = default;
modification_time(0),
timescale(0),
duration(0),
rate(1 << 16),
volume(1 << 8),
next_track_id(0) {}
MovieHeader::~MovieHeader() {}
FourCC MovieHeader::BoxType() const { FourCC MovieHeader::BoxType() const {
return FOURCC_mvhd; return FOURCC_mvhd;
} }
@ -568,19 +558,12 @@ size_t MovieHeader::ComputeSizeInternal() {
24; // 10 bytes reserved, 24 bytes predefined. 24; // 10 bytes reserved, 24 bytes predefined.
} }
TrackHeader::TrackHeader() TrackHeader::TrackHeader() {
: creation_time(0),
modification_time(0),
track_id(0),
duration(0),
layer(0),
alternate_group(0),
volume(-1),
width(0),
height(0) {
flags = kTrackEnabled | kTrackInMovie | kTrackInPreview; flags = kTrackEnabled | kTrackInMovie | kTrackInPreview;
} }
TrackHeader::~TrackHeader() {}
TrackHeader::~TrackHeader() = default;
FourCC TrackHeader::BoxType() const { FourCC TrackHeader::BoxType() const {
return FOURCC_tkhd; return FOURCC_tkhd;
} }
@ -620,8 +603,9 @@ size_t TrackHeader::ComputeSizeInternal() {
sizeof(height) + sizeof(kUnityMatrix) + 14; // 14 bytes reserved. sizeof(height) + sizeof(kUnityMatrix) + 14; // 14 bytes reserved.
} }
SampleDescription::SampleDescription() : type(kInvalid) {} SampleDescription::SampleDescription() = default;
SampleDescription::~SampleDescription() {} SampleDescription::~SampleDescription() = default;
FourCC SampleDescription::BoxType() const { FourCC SampleDescription::BoxType() const {
return FOURCC_stsd; return FOURCC_stsd;
} }
@ -694,8 +678,9 @@ size_t SampleDescription::ComputeSizeInternal() {
return box_size; return box_size;
} }
DecodingTimeToSample::DecodingTimeToSample() {} DecodingTimeToSample::DecodingTimeToSample() = default;
DecodingTimeToSample::~DecodingTimeToSample() {} DecodingTimeToSample::~DecodingTimeToSample() = default;
FourCC DecodingTimeToSample::BoxType() const { FourCC DecodingTimeToSample::BoxType() const {
return FOURCC_stts; return FOURCC_stts;
} }
@ -717,8 +702,9 @@ size_t DecodingTimeToSample::ComputeSizeInternal() {
sizeof(DecodingTime) * decoding_time.size(); sizeof(DecodingTime) * decoding_time.size();
} }
CompositionTimeToSample::CompositionTimeToSample() {} CompositionTimeToSample::CompositionTimeToSample() = default;
CompositionTimeToSample::~CompositionTimeToSample() {} CompositionTimeToSample::~CompositionTimeToSample() = default;
FourCC CompositionTimeToSample::BoxType() const { FourCC CompositionTimeToSample::BoxType() const {
return FOURCC_ctts; return FOURCC_ctts;
} }
@ -769,8 +755,9 @@ size_t CompositionTimeToSample::ComputeSizeInternal() {
kCompositionOffsetSize * composition_offset.size(); kCompositionOffsetSize * composition_offset.size();
} }
SampleToChunk::SampleToChunk() {} SampleToChunk::SampleToChunk() = default;
SampleToChunk::~SampleToChunk() {} SampleToChunk::~SampleToChunk() = default;
FourCC SampleToChunk::BoxType() const { FourCC SampleToChunk::BoxType() const {
return FOURCC_stsc; return FOURCC_stsc;
} }
@ -796,8 +783,9 @@ size_t SampleToChunk::ComputeSizeInternal() {
sizeof(ChunkInfo) * chunk_info.size(); sizeof(ChunkInfo) * chunk_info.size();
} }
SampleSize::SampleSize() : sample_size(0), sample_count(0) {} SampleSize::SampleSize() = default;
SampleSize::~SampleSize() {} SampleSize::~SampleSize() = default;
FourCC SampleSize::BoxType() const { FourCC SampleSize::BoxType() const {
return FOURCC_stsz; return FOURCC_stsz;
} }
@ -823,8 +811,9 @@ size_t SampleSize::ComputeSizeInternal() {
(sample_size == 0 ? sizeof(uint32_t) * sizes.size() : 0); (sample_size == 0 ? sizeof(uint32_t) * sizes.size() : 0);
} }
CompactSampleSize::CompactSampleSize() : field_size(0) {} CompactSampleSize::CompactSampleSize() = default;
CompactSampleSize::~CompactSampleSize() {} CompactSampleSize::~CompactSampleSize() = default;
FourCC CompactSampleSize::BoxType() const { FourCC CompactSampleSize::BoxType() const {
return FOURCC_stz2; return FOURCC_stz2;
} }
@ -879,8 +868,9 @@ size_t CompactSampleSize::ComputeSizeInternal() {
(field_size * sizes.size() + 7) / 8; (field_size * sizes.size() + 7) / 8;
} }
ChunkOffset::ChunkOffset() {} ChunkOffset::ChunkOffset() = default;
ChunkOffset::~ChunkOffset() {} ChunkOffset::~ChunkOffset() = default;
FourCC ChunkOffset::BoxType() const { FourCC ChunkOffset::BoxType() const {
return FOURCC_stco; return FOURCC_stco;
} }
@ -899,8 +889,9 @@ size_t ChunkOffset::ComputeSizeInternal() {
return HeaderSize() + sizeof(uint32_t) + sizeof(uint32_t) * offsets.size(); return HeaderSize() + sizeof(uint32_t) + sizeof(uint32_t) * offsets.size();
} }
ChunkLargeOffset::ChunkLargeOffset() {} ChunkLargeOffset::ChunkLargeOffset() = default;
ChunkLargeOffset::~ChunkLargeOffset() {} ChunkLargeOffset::~ChunkLargeOffset() = default;
FourCC ChunkLargeOffset::BoxType() const { FourCC ChunkLargeOffset::BoxType() const {
return FOURCC_co64; return FOURCC_co64;
} }
@ -936,8 +927,9 @@ size_t ChunkLargeOffset::ComputeSizeInternal() {
sizeof(uint32_t) * (1 + use_large_offset) * offsets.size(); sizeof(uint32_t) * (1 + use_large_offset) * offsets.size();
} }
SyncSample::SyncSample() {} SyncSample::SyncSample() = default;
SyncSample::~SyncSample() {} SyncSample::~SyncSample() = default;
FourCC SyncSample::BoxType() const { FourCC SyncSample::BoxType() const {
return FOURCC_stss; return FOURCC_stss;
} }
@ -960,13 +952,6 @@ size_t SyncSample::ComputeSizeInternal() {
sizeof(uint32_t) * sample_number.size(); sizeof(uint32_t) * sample_number.size();
} }
CencSampleEncryptionInfoEntry::CencSampleEncryptionInfoEntry()
: is_protected(0),
per_sample_iv_size(0),
crypt_byte_block(0),
skip_byte_block(0) {}
CencSampleEncryptionInfoEntry::~CencSampleEncryptionInfoEntry(){};
bool CencSampleEncryptionInfoEntry::ReadWrite(BoxBuffer* buffer) { bool CencSampleEncryptionInfoEntry::ReadWrite(BoxBuffer* buffer) {
if (!buffer->Reading()) { if (!buffer->Reading()) {
if (key_id.size() != kCencKeyIdSize) { if (key_id.size() != kCencKeyIdSize) {
@ -1014,9 +999,6 @@ uint32_t CencSampleEncryptionInfoEntry::ComputeSize() const {
(constant_iv.empty() ? 0 : (sizeof(uint8_t) + constant_iv.size()))); (constant_iv.empty() ? 0 : (sizeof(uint8_t) + constant_iv.size())));
} }
AudioRollRecoveryEntry::AudioRollRecoveryEntry() : roll_distance(0) {}
AudioRollRecoveryEntry::~AudioRollRecoveryEntry() {}
bool AudioRollRecoveryEntry::ReadWrite(BoxBuffer* buffer) { bool AudioRollRecoveryEntry::ReadWrite(BoxBuffer* buffer) {
RCHECK(buffer->ReadWriteInt16(&roll_distance)); RCHECK(buffer->ReadWriteInt16(&roll_distance));
return true; return true;
@ -1026,8 +1008,9 @@ uint32_t AudioRollRecoveryEntry::ComputeSize() const {
return sizeof(roll_distance); return sizeof(roll_distance);
} }
SampleGroupDescription::SampleGroupDescription() : grouping_type(0) {} SampleGroupDescription::SampleGroupDescription() = default;
SampleGroupDescription::~SampleGroupDescription() {} SampleGroupDescription::~SampleGroupDescription() = default;
FourCC SampleGroupDescription::BoxType() const { FourCC SampleGroupDescription::BoxType() const {
return FOURCC_sgpd; return FOURCC_sgpd;
} }
@ -1107,8 +1090,9 @@ size_t SampleGroupDescription::ComputeSizeInternal() {
entries_size; entries_size;
} }
SampleToGroup::SampleToGroup() : grouping_type(0), grouping_type_parameter(0) {} SampleToGroup::SampleToGroup() = default;
SampleToGroup::~SampleToGroup() {} SampleToGroup::~SampleToGroup() = default;
FourCC SampleToGroup::BoxType() const { FourCC SampleToGroup::BoxType() const {
return FOURCC_sbgp; return FOURCC_sbgp;
} }
@ -1145,8 +1129,9 @@ size_t SampleToGroup::ComputeSizeInternal() {
sizeof(uint32_t) + entries.size() * sizeof(entries[0]); sizeof(uint32_t) + entries.size() * sizeof(entries[0]);
} }
SampleTable::SampleTable() {} SampleTable::SampleTable() = default;
SampleTable::~SampleTable() {} SampleTable::~SampleTable() = default;
FourCC SampleTable::BoxType() const { FourCC SampleTable::BoxType() const {
return FOURCC_stbl; return FOURCC_stbl;
} }
@ -1213,8 +1198,9 @@ size_t SampleTable::ComputeSizeInternal() {
return box_size; return box_size;
} }
EditList::EditList() {} EditList::EditList() = default;
EditList::~EditList() {} EditList::~EditList() = default;
FourCC EditList::BoxType() const { FourCC EditList::BoxType() const {
return FOURCC_elst; return FOURCC_elst;
} }
@ -1252,8 +1238,9 @@ size_t EditList::ComputeSizeInternal() {
edits.size(); edits.size();
} }
Edit::Edit() {} Edit::Edit() = default;
Edit::~Edit() {} Edit::~Edit() = default;
FourCC Edit::BoxType() const { FourCC Edit::BoxType() const {
return FOURCC_edts; return FOURCC_edts;
} }
@ -1270,8 +1257,9 @@ size_t Edit::ComputeSizeInternal() {
return HeaderSize() + list.ComputeSize(); return HeaderSize() + list.ComputeSize();
} }
HandlerReference::HandlerReference() : handler_type(FOURCC_NULL) {} HandlerReference::HandlerReference() = default;
HandlerReference::~HandlerReference() {} HandlerReference::~HandlerReference() = default;
FourCC HandlerReference::BoxType() const { FourCC HandlerReference::BoxType() const {
return FOURCC_hdlr; return FOURCC_hdlr;
} }
@ -1365,8 +1353,8 @@ uint32_t Language::ComputeSize() const {
return 2; return 2;
} }
ID3v2::ID3v2() {} ID3v2::ID3v2() = default;
ID3v2::~ID3v2() {} ID3v2::~ID3v2() = default;
FourCC ID3v2::BoxType() const { FourCC ID3v2::BoxType() const {
return FOURCC_ID32; return FOURCC_ID32;
@ -1387,8 +1375,8 @@ size_t ID3v2::ComputeSizeInternal() {
: HeaderSize() + language.ComputeSize() + id3v2_data.size(); : HeaderSize() + language.ComputeSize() + id3v2_data.size();
} }
Metadata::Metadata() {} Metadata::Metadata() = default;
Metadata::~Metadata() {} Metadata::~Metadata() = default;
FourCC Metadata::BoxType() const { FourCC Metadata::BoxType() const {
return FOURCC_meta; return FOURCC_meta;
@ -1407,8 +1395,8 @@ size_t Metadata::ComputeSizeInternal() {
: HeaderSize() + handler.ComputeSize() + id3v2_size; : HeaderSize() + handler.ComputeSize() + id3v2_size;
} }
CodecConfiguration::CodecConfiguration() : box_type(FOURCC_NULL) {} CodecConfiguration::CodecConfiguration() = default;
CodecConfiguration::~CodecConfiguration() {} CodecConfiguration::~CodecConfiguration() = default;
FourCC CodecConfiguration::BoxType() const { FourCC CodecConfiguration::BoxType() const {
// CodecConfiguration box should be parsed according to format recovered in // CodecConfiguration box should be parsed according to format recovered in
@ -1446,8 +1434,9 @@ size_t CodecConfiguration::ComputeSizeInternal() {
return HeaderSize() + (box_type == FOURCC_vpcC ? 4 : 0) + data.size(); return HeaderSize() + (box_type == FOURCC_vpcC ? 4 : 0) + data.size();
} }
PixelAspectRatio::PixelAspectRatio() : h_spacing(0), v_spacing(0) {} PixelAspectRatio::PixelAspectRatio() = default;
PixelAspectRatio::~PixelAspectRatio() {} PixelAspectRatio::~PixelAspectRatio() = default;
FourCC PixelAspectRatio::BoxType() const { FourCC PixelAspectRatio::BoxType() const {
return FOURCC_pasp; return FOURCC_pasp;
} }
@ -1468,10 +1457,9 @@ size_t PixelAspectRatio::ComputeSizeInternal() {
return HeaderSize() + sizeof(h_spacing) + sizeof(v_spacing); return HeaderSize() + sizeof(h_spacing) + sizeof(v_spacing);
} }
VideoSampleEntry::VideoSampleEntry() VideoSampleEntry::VideoSampleEntry() = default;
: format(FOURCC_NULL), data_reference_index(1), width(0), height(0) {} VideoSampleEntry::~VideoSampleEntry() = default;
VideoSampleEntry::~VideoSampleEntry() {}
FourCC VideoSampleEntry::BoxType() const { FourCC VideoSampleEntry::BoxType() const {
if (format == FOURCC_NULL) { if (format == FOURCC_NULL) {
LOG(ERROR) << "VideoSampleEntry should be parsed according to the " LOG(ERROR) << "VideoSampleEntry should be parsed according to the "
@ -1599,8 +1587,9 @@ FourCC VideoSampleEntry::GetCodecConfigurationBoxType(FourCC format) const {
} }
} }
ElementaryStreamDescriptor::ElementaryStreamDescriptor() {} ElementaryStreamDescriptor::ElementaryStreamDescriptor() = default;
ElementaryStreamDescriptor::~ElementaryStreamDescriptor() {} ElementaryStreamDescriptor::~ElementaryStreamDescriptor() = default;
FourCC ElementaryStreamDescriptor::BoxType() const { FourCC ElementaryStreamDescriptor::BoxType() const {
return FOURCC_esds; return FOURCC_esds;
} }
@ -1629,12 +1618,10 @@ size_t ElementaryStreamDescriptor::ComputeSizeInternal() {
return HeaderSize() + es_descriptor.ComputeSize(); return HeaderSize() + es_descriptor.ComputeSize();
} }
DTSSpecific::DTSSpecific() DTSSpecific::DTSSpecific() = default;
: sampling_frequency(0), DTSSpecific::~DTSSpecific() = default;
max_bitrate(0), ;
avg_bitrate(0),
pcm_sample_depth(0) {}
DTSSpecific::~DTSSpecific() {}
FourCC DTSSpecific::BoxType() const { FourCC DTSSpecific::BoxType() const {
return FOURCC_ddts; return FOURCC_ddts;
} }
@ -1667,8 +1654,8 @@ size_t DTSSpecific::ComputeSizeInternal() {
sizeof(kDdtsExtraData); sizeof(kDdtsExtraData);
} }
AC3Specific::AC3Specific() {} AC3Specific::AC3Specific() = default;
AC3Specific::~AC3Specific() {} AC3Specific::~AC3Specific() = default;
FourCC AC3Specific::BoxType() const { FourCC AC3Specific::BoxType() const {
return FOURCC_dac3; return FOURCC_dac3;
@ -1688,8 +1675,8 @@ size_t AC3Specific::ComputeSizeInternal() {
return HeaderSize() + data.size(); return HeaderSize() + data.size();
} }
EC3Specific::EC3Specific() {} EC3Specific::EC3Specific() = default;
EC3Specific::~EC3Specific() {} EC3Specific::~EC3Specific() = default;
FourCC EC3Specific::BoxType() const { FourCC EC3Specific::BoxType() const {
return FOURCC_dec3; return FOURCC_dec3;
@ -1709,8 +1696,8 @@ size_t EC3Specific::ComputeSizeInternal() {
return HeaderSize() + data.size(); return HeaderSize() + data.size();
} }
OpusSpecific::OpusSpecific() : preskip(0) {} OpusSpecific::OpusSpecific() = default;
OpusSpecific::~OpusSpecific() {} OpusSpecific::~OpusSpecific() = default;
FourCC OpusSpecific::BoxType() const { FourCC OpusSpecific::BoxType() const {
return FOURCC_dOps; return FOURCC_dOps;
@ -1762,8 +1749,8 @@ size_t OpusSpecific::ComputeSizeInternal() {
kOpusMagicSignatureSize; kOpusMagicSignatureSize;
} }
FlacSpecific::FlacSpecific() {} FlacSpecific::FlacSpecific() = default;
FlacSpecific::~FlacSpecific() {} FlacSpecific::~FlacSpecific() = default;
FourCC FlacSpecific::BoxType() const { FourCC FlacSpecific::BoxType() const {
return FOURCC_dfLa; return FOURCC_dfLa;
@ -1783,14 +1770,8 @@ size_t FlacSpecific::ComputeSizeInternal() {
return HeaderSize() + data.size(); return HeaderSize() + data.size();
} }
AudioSampleEntry::AudioSampleEntry() AudioSampleEntry::AudioSampleEntry() = default;
: format(FOURCC_NULL), AudioSampleEntry::~AudioSampleEntry() = default;
data_reference_index(1),
channelcount(2),
samplesize(16),
samplerate(0) {}
AudioSampleEntry::~AudioSampleEntry() {}
FourCC AudioSampleEntry::BoxType() const { FourCC AudioSampleEntry::BoxType() const {
if (format == FOURCC_NULL) { if (format == FOURCC_NULL) {
@ -1858,8 +1839,8 @@ size_t AudioSampleEntry::ComputeSizeInternal() {
4; // 4 bytes predefined. 4; // 4 bytes predefined.
} }
WebVTTConfigurationBox::WebVTTConfigurationBox() {} WebVTTConfigurationBox::WebVTTConfigurationBox() = default;
WebVTTConfigurationBox::~WebVTTConfigurationBox() {} WebVTTConfigurationBox::~WebVTTConfigurationBox() = default;
FourCC WebVTTConfigurationBox::BoxType() const { FourCC WebVTTConfigurationBox::BoxType() const {
return FOURCC_vttC; return FOURCC_vttC;
@ -1875,8 +1856,8 @@ size_t WebVTTConfigurationBox::ComputeSizeInternal() {
return HeaderSize() + config.size(); return HeaderSize() + config.size();
} }
WebVTTSourceLabelBox::WebVTTSourceLabelBox() {} WebVTTSourceLabelBox::WebVTTSourceLabelBox() = default;
WebVTTSourceLabelBox::~WebVTTSourceLabelBox() {} WebVTTSourceLabelBox::~WebVTTSourceLabelBox() = default;
FourCC WebVTTSourceLabelBox::BoxType() const { FourCC WebVTTSourceLabelBox::BoxType() const {
return FOURCC_vlab; return FOURCC_vlab;
@ -1895,11 +1876,8 @@ size_t WebVTTSourceLabelBox::ComputeSizeInternal() {
return HeaderSize() + source_label.size(); return HeaderSize() + source_label.size();
} }
// data_reference_index is 1-based and "dref" box is mandatory so it is TextSampleEntry::TextSampleEntry() = default;
// always present. TextSampleEntry::~TextSampleEntry() = default;
TextSampleEntry::TextSampleEntry()
: format(FOURCC_NULL), data_reference_index(1u) {}
TextSampleEntry::~TextSampleEntry() {}
FourCC TextSampleEntry::BoxType() const { FourCC TextSampleEntry::BoxType() const {
if (format == FOURCC_NULL) { if (format == FOURCC_NULL) {
@ -1933,9 +1911,9 @@ size_t TextSampleEntry::ComputeSizeInternal() {
config.ComputeSize() + label.ComputeSize(); config.ComputeSize() + label.ComputeSize();
} }
MediaHeader::MediaHeader() MediaHeader::MediaHeader() = default;
: creation_time(0), modification_time(0), timescale(0), duration(0) {} MediaHeader::~MediaHeader() = default;
MediaHeader::~MediaHeader() {}
FourCC MediaHeader::BoxType() const { FourCC MediaHeader::BoxType() const {
return FOURCC_mdhd; return FOURCC_mdhd;
} }
@ -1961,12 +1939,13 @@ size_t MediaHeader::ComputeSizeInternal() {
2; // 2 bytes predefined. 2; // 2 bytes predefined.
} }
VideoMediaHeader::VideoMediaHeader() VideoMediaHeader::VideoMediaHeader() {
: graphicsmode(0), opcolor_red(0), opcolor_green(0), opcolor_blue(0) {
const uint32_t kVideoMediaHeaderFlags = 1; const uint32_t kVideoMediaHeaderFlags = 1;
flags = kVideoMediaHeaderFlags; flags = kVideoMediaHeaderFlags;
} }
VideoMediaHeader::~VideoMediaHeader() {}
VideoMediaHeader::~VideoMediaHeader() = default;
FourCC VideoMediaHeader::BoxType() const { FourCC VideoMediaHeader::BoxType() const {
return FOURCC_vmhd; return FOURCC_vmhd;
} }
@ -1984,11 +1963,13 @@ size_t VideoMediaHeader::ComputeSizeInternal() {
sizeof(opcolor_green) + sizeof(opcolor_blue); sizeof(opcolor_green) + sizeof(opcolor_blue);
} }
SoundMediaHeader::SoundMediaHeader() : balance(0) {} SoundMediaHeader::SoundMediaHeader() = default;
SoundMediaHeader::~SoundMediaHeader() {} SoundMediaHeader::~SoundMediaHeader() = default;
FourCC SoundMediaHeader::BoxType() const { FourCC SoundMediaHeader::BoxType() const {
return FOURCC_smhd; return FOURCC_smhd;
} }
bool SoundMediaHeader::ReadWriteInternal(BoxBuffer* buffer) { bool SoundMediaHeader::ReadWriteInternal(BoxBuffer* buffer) {
RCHECK(ReadWriteHeaderInternal(buffer) && buffer->ReadWriteUInt16(&balance) && RCHECK(ReadWriteHeaderInternal(buffer) && buffer->ReadWriteUInt16(&balance) &&
buffer->IgnoreBytes(2)); // reserved. buffer->IgnoreBytes(2)); // reserved.
@ -1999,8 +1980,8 @@ size_t SoundMediaHeader::ComputeSizeInternal() {
return HeaderSize() + sizeof(balance) + sizeof(uint16_t); return HeaderSize() + sizeof(balance) + sizeof(uint16_t);
} }
SubtitleMediaHeader::SubtitleMediaHeader() {} SubtitleMediaHeader::SubtitleMediaHeader() = default;
SubtitleMediaHeader::~SubtitleMediaHeader() {} SubtitleMediaHeader::~SubtitleMediaHeader() = default;
FourCC SubtitleMediaHeader::BoxType() const { FourCC SubtitleMediaHeader::BoxType() const {
return FOURCC_sthd; return FOURCC_sthd;
@ -2018,7 +1999,9 @@ DataEntryUrl::DataEntryUrl() {
const uint32_t kDataEntryUrlFlags = 1; const uint32_t kDataEntryUrlFlags = 1;
flags = kDataEntryUrlFlags; flags = kDataEntryUrlFlags;
} }
DataEntryUrl::~DataEntryUrl() {}
DataEntryUrl::~DataEntryUrl() = default;
FourCC DataEntryUrl::BoxType() const { FourCC DataEntryUrl::BoxType() const {
return FOURCC_url; return FOURCC_url;
} }
@ -2036,11 +2019,9 @@ size_t DataEntryUrl::ComputeSizeInternal() {
return HeaderSize() + location.size(); return HeaderSize() + location.size();
} }
DataReference::DataReference() { DataReference::DataReference() = default;
// Default 1 entry. DataReference::~DataReference() = default;
data_entry.resize(1);
}
DataReference::~DataReference() {}
FourCC DataReference::BoxType() const { FourCC DataReference::BoxType() const {
return FOURCC_dref; return FOURCC_dref;
} }
@ -2063,8 +2044,9 @@ size_t DataReference::ComputeSizeInternal() {
return box_size; return box_size;
} }
DataInformation::DataInformation() {} DataInformation::DataInformation() = default;
DataInformation::~DataInformation() {} DataInformation::~DataInformation() = default;
FourCC DataInformation::BoxType() const { FourCC DataInformation::BoxType() const {
return FOURCC_dinf; return FOURCC_dinf;
} }
@ -2078,8 +2060,9 @@ size_t DataInformation::ComputeSizeInternal() {
return HeaderSize() + dref.ComputeSize(); return HeaderSize() + dref.ComputeSize();
} }
MediaInformation::MediaInformation() {} MediaInformation::MediaInformation() = default;
MediaInformation::~MediaInformation() {} MediaInformation::~MediaInformation() = default;
FourCC MediaInformation::BoxType() const { FourCC MediaInformation::BoxType() const {
return FOURCC_minf; return FOURCC_minf;
} }
@ -2124,8 +2107,9 @@ size_t MediaInformation::ComputeSizeInternal() {
return box_size; return box_size;
} }
Media::Media() {} Media::Media() = default;
Media::~Media() {} Media::~Media() = default;
FourCC Media::BoxType() const { FourCC Media::BoxType() const {
return FOURCC_mdia; return FOURCC_mdia;
} }
@ -2160,8 +2144,9 @@ size_t Media::ComputeSizeInternal() {
information.ComputeSize(); information.ComputeSize();
} }
Track::Track() {} Track::Track() = default;
Track::~Track() {} Track::~Track() = default;
FourCC Track::BoxType() const { FourCC Track::BoxType() const {
return FOURCC_trak; return FOURCC_trak;
} }
@ -2179,8 +2164,9 @@ size_t Track::ComputeSizeInternal() {
edit.ComputeSize(); edit.ComputeSize();
} }
MovieExtendsHeader::MovieExtendsHeader() : fragment_duration(0) {} MovieExtendsHeader::MovieExtendsHeader() = default;
MovieExtendsHeader::~MovieExtendsHeader() {} MovieExtendsHeader::~MovieExtendsHeader() = default;
FourCC MovieExtendsHeader::BoxType() const { FourCC MovieExtendsHeader::BoxType() const {
return FOURCC_mehd; return FOURCC_mehd;
} }
@ -2200,13 +2186,9 @@ size_t MovieExtendsHeader::ComputeSizeInternal() {
return HeaderSize() + sizeof(uint32_t) * (1 + version); return HeaderSize() + sizeof(uint32_t) * (1 + version);
} }
TrackExtends::TrackExtends() TrackExtends::TrackExtends() = default;
: track_id(0), TrackExtends::~TrackExtends() = default;
default_sample_description_index(0),
default_sample_duration(0),
default_sample_size(0),
default_sample_flags(0) {}
TrackExtends::~TrackExtends() {}
FourCC TrackExtends::BoxType() const { FourCC TrackExtends::BoxType() const {
return FOURCC_trex; return FOURCC_trex;
} }
@ -2228,8 +2210,9 @@ size_t TrackExtends::ComputeSizeInternal() {
sizeof(default_sample_flags); sizeof(default_sample_flags);
} }
MovieExtends::MovieExtends() {} MovieExtends::MovieExtends() = default;
MovieExtends::~MovieExtends() {} MovieExtends::~MovieExtends() = default;
FourCC MovieExtends::BoxType() const { FourCC MovieExtends::BoxType() const {
return FOURCC_mvex; return FOURCC_mvex;
} }
@ -2257,8 +2240,9 @@ size_t MovieExtends::ComputeSizeInternal() {
return box_size; return box_size;
} }
Movie::Movie() {} Movie::Movie() = default;
Movie::~Movie() {} Movie::~Movie() = default;
FourCC Movie::BoxType() const { FourCC Movie::BoxType() const {
return FOURCC_moov; return FOURCC_moov;
} }
@ -2298,8 +2282,9 @@ size_t Movie::ComputeSizeInternal() {
return box_size; return box_size;
} }
TrackFragmentDecodeTime::TrackFragmentDecodeTime() : decode_time(0) {} TrackFragmentDecodeTime::TrackFragmentDecodeTime() = default;
TrackFragmentDecodeTime::~TrackFragmentDecodeTime() {} TrackFragmentDecodeTime::~TrackFragmentDecodeTime() = default;
FourCC TrackFragmentDecodeTime::BoxType() const { FourCC TrackFragmentDecodeTime::BoxType() const {
return FOURCC_tfdt; return FOURCC_tfdt;
} }
@ -2316,8 +2301,9 @@ size_t TrackFragmentDecodeTime::ComputeSizeInternal() {
return HeaderSize() + sizeof(uint32_t) * (1 + version); return HeaderSize() + sizeof(uint32_t) * (1 + version);
} }
MovieFragmentHeader::MovieFragmentHeader() : sequence_number(0) {} MovieFragmentHeader::MovieFragmentHeader() = default;
MovieFragmentHeader::~MovieFragmentHeader() {} MovieFragmentHeader::~MovieFragmentHeader() = default;
FourCC MovieFragmentHeader::BoxType() const { FourCC MovieFragmentHeader::BoxType() const {
return FOURCC_mfhd; return FOURCC_mfhd;
} }
@ -2331,14 +2317,9 @@ size_t MovieFragmentHeader::ComputeSizeInternal() {
return HeaderSize() + sizeof(sequence_number); return HeaderSize() + sizeof(sequence_number);
} }
TrackFragmentHeader::TrackFragmentHeader() TrackFragmentHeader::TrackFragmentHeader() = default;
: track_id(0), TrackFragmentHeader::~TrackFragmentHeader() = default;
sample_description_index(0),
default_sample_duration(0),
default_sample_size(0),
default_sample_flags(0) {}
TrackFragmentHeader::~TrackFragmentHeader() {}
FourCC TrackFragmentHeader::BoxType() const { FourCC TrackFragmentHeader::BoxType() const {
return FOURCC_tfhd; return FOURCC_tfhd;
} }
@ -2393,8 +2374,9 @@ size_t TrackFragmentHeader::ComputeSizeInternal() {
return box_size; return box_size;
} }
TrackFragmentRun::TrackFragmentRun() : sample_count(0), data_offset(0) {} TrackFragmentRun::TrackFragmentRun() = default;
TrackFragmentRun::~TrackFragmentRun() {} TrackFragmentRun::~TrackFragmentRun() = default;
FourCC TrackFragmentRun::BoxType() const { FourCC TrackFragmentRun::BoxType() const {
return FOURCC_trun; return FOURCC_trun;
} }
@ -2516,8 +2498,9 @@ size_t TrackFragmentRun::ComputeSizeInternal() {
return box_size; return box_size;
} }
TrackFragment::TrackFragment() : decode_time_absent(false) {} TrackFragment::TrackFragment() = default;
TrackFragment::~TrackFragment() {} TrackFragment::~TrackFragment() = default;
FourCC TrackFragment::BoxType() const { FourCC TrackFragment::BoxType() const {
return FOURCC_traf; return FOURCC_traf;
} }
@ -2562,8 +2545,9 @@ size_t TrackFragment::ComputeSizeInternal() {
return box_size; return box_size;
} }
MovieFragment::MovieFragment() {} MovieFragment::MovieFragment() = default;
MovieFragment::~MovieFragment() {} MovieFragment::~MovieFragment() = default;
FourCC MovieFragment::BoxType() const { FourCC MovieFragment::BoxType() const {
return FOURCC_moof; return FOURCC_moof;
} }
@ -2593,12 +2577,9 @@ size_t MovieFragment::ComputeSizeInternal() {
return box_size; return box_size;
} }
SegmentIndex::SegmentIndex() SegmentIndex::SegmentIndex() = default;
: reference_id(0), SegmentIndex::~SegmentIndex() = default;
timescale(0),
earliest_presentation_time(0),
first_offset(0) {}
SegmentIndex::~SegmentIndex() {}
FourCC SegmentIndex::BoxType() const { FourCC SegmentIndex::BoxType() const {
return FOURCC_sidx; return FOURCC_sidx;
} }
@ -2651,8 +2632,9 @@ size_t SegmentIndex::ComputeSizeInternal() {
3 * sizeof(uint32_t) * references.size(); 3 * sizeof(uint32_t) * references.size();
} }
MediaData::MediaData() : data_size(0) {} MediaData::MediaData() = default;
MediaData::~MediaData() {} MediaData::~MediaData() = default;
FourCC MediaData::BoxType() const { FourCC MediaData::BoxType() const {
return FOURCC_mdat; return FOURCC_mdat;
} }
@ -2666,8 +2648,8 @@ size_t MediaData::ComputeSizeInternal() {
return HeaderSize() + data_size; return HeaderSize() + data_size;
} }
CueSourceIDBox::CueSourceIDBox() : source_id(kCueSourceIdNotSet) {} CueSourceIDBox::CueSourceIDBox() = default;
CueSourceIDBox::~CueSourceIDBox() {} CueSourceIDBox::~CueSourceIDBox() = default;
FourCC CueSourceIDBox::BoxType() const { FourCC CueSourceIDBox::BoxType() const {
return FOURCC_vsid; return FOURCC_vsid;
@ -2684,8 +2666,8 @@ size_t CueSourceIDBox::ComputeSizeInternal() {
return HeaderSize() + sizeof(source_id); return HeaderSize() + sizeof(source_id);
} }
CueTimeBox::CueTimeBox() {} CueTimeBox::CueTimeBox() = default;
CueTimeBox::~CueTimeBox() {} CueTimeBox::~CueTimeBox() = default;
FourCC CueTimeBox::BoxType() const { FourCC CueTimeBox::BoxType() const {
return FOURCC_ctim; return FOURCC_ctim;
@ -2704,8 +2686,8 @@ size_t CueTimeBox::ComputeSizeInternal() {
return HeaderSize() + cue_current_time.size(); return HeaderSize() + cue_current_time.size();
} }
CueIDBox::CueIDBox() {} CueIDBox::CueIDBox() = default;
CueIDBox::~CueIDBox() {} CueIDBox::~CueIDBox() = default;
FourCC CueIDBox::BoxType() const { FourCC CueIDBox::BoxType() const {
return FOURCC_iden; return FOURCC_iden;
@ -2723,8 +2705,8 @@ size_t CueIDBox::ComputeSizeInternal() {
return HeaderSize() + cue_id.size(); return HeaderSize() + cue_id.size();
} }
CueSettingsBox::CueSettingsBox() {} CueSettingsBox::CueSettingsBox() = default;
CueSettingsBox::~CueSettingsBox() {} CueSettingsBox::~CueSettingsBox() = default;
FourCC CueSettingsBox::BoxType() const { FourCC CueSettingsBox::BoxType() const {
return FOURCC_sttg; return FOURCC_sttg;
@ -2742,8 +2724,8 @@ size_t CueSettingsBox::ComputeSizeInternal() {
return HeaderSize() + settings.size(); return HeaderSize() + settings.size();
} }
CuePayloadBox::CuePayloadBox() {} CuePayloadBox::CuePayloadBox() = default;
CuePayloadBox::~CuePayloadBox() {} CuePayloadBox::~CuePayloadBox() = default;
FourCC CuePayloadBox::BoxType() const { FourCC CuePayloadBox::BoxType() const {
return FOURCC_payl; return FOURCC_payl;
@ -2759,8 +2741,8 @@ size_t CuePayloadBox::ComputeSizeInternal() {
return HeaderSize() + cue_text.size(); return HeaderSize() + cue_text.size();
} }
VTTEmptyCueBox::VTTEmptyCueBox() {} VTTEmptyCueBox::VTTEmptyCueBox() = default;
VTTEmptyCueBox::~VTTEmptyCueBox() {} VTTEmptyCueBox::~VTTEmptyCueBox() = default;
FourCC VTTEmptyCueBox::BoxType() const { FourCC VTTEmptyCueBox::BoxType() const {
return FOURCC_vtte; return FOURCC_vtte;
@ -2774,8 +2756,8 @@ size_t VTTEmptyCueBox::ComputeSizeInternal() {
return HeaderSize(); return HeaderSize();
} }
VTTAdditionalTextBox::VTTAdditionalTextBox() {} VTTAdditionalTextBox::VTTAdditionalTextBox() = default;
VTTAdditionalTextBox::~VTTAdditionalTextBox() {} VTTAdditionalTextBox::~VTTAdditionalTextBox() = default;
FourCC VTTAdditionalTextBox::BoxType() const { FourCC VTTAdditionalTextBox::BoxType() const {
return FOURCC_vtta; return FOURCC_vtta;
@ -2792,8 +2774,8 @@ size_t VTTAdditionalTextBox::ComputeSizeInternal() {
return HeaderSize() + cue_additional_text.size(); return HeaderSize() + cue_additional_text.size();
} }
VTTCueBox::VTTCueBox() {} VTTCueBox::VTTCueBox() = default;
VTTCueBox::~VTTCueBox() {} VTTCueBox::~VTTCueBox() = default;
FourCC VTTCueBox::BoxType() const { FourCC VTTCueBox::BoxType() const {
return FOURCC_vttc; return FOURCC_vttc;

View File

@ -34,6 +34,7 @@ class BoxBuffer;
public: \ public: \
T(); \ T(); \
~T() override; \ ~T() override; \
\
FourCC BoxType() const override; \ FourCC BoxType() const override; \
\ \
private: \ private: \
@ -45,8 +46,8 @@ class BoxBuffer;
struct FileType : Box { struct FileType : Box {
DECLARE_BOX_METHODS(FileType); DECLARE_BOX_METHODS(FileType);
FourCC major_brand; FourCC major_brand = FOURCC_NULL;
uint32_t minor_version; uint32_t minor_version = 0;
std::vector<FourCC> compatible_brands; std::vector<FourCC> compatible_brands;
}; };
@ -69,14 +70,12 @@ struct SampleAuxiliaryInformationOffset : FullBox {
struct SampleAuxiliaryInformationSize : FullBox { struct SampleAuxiliaryInformationSize : FullBox {
DECLARE_BOX_METHODS(SampleAuxiliaryInformationSize); DECLARE_BOX_METHODS(SampleAuxiliaryInformationSize);
uint8_t default_sample_info_size; uint8_t default_sample_info_size = 0;
uint32_t sample_count; uint32_t sample_count = 0;
std::vector<uint8_t> sample_info_sizes; std::vector<uint8_t> sample_info_sizes;
}; };
struct SampleEncryptionEntry { struct SampleEncryptionEntry {
SampleEncryptionEntry();
~SampleEncryptionEntry();
/// Read/Write SampleEncryptionEntry. /// Read/Write SampleEncryptionEntry.
/// @param iv_size specifies the size of initialization vector. /// @param iv_size specifies the size of initialization vector.
/// @param has_subsamples indicates whether this sample encryption entry /// @param has_subsamples indicates whether this sample encryption entry
@ -104,6 +103,8 @@ struct SampleEncryptionEntry {
}; };
struct SampleEncryption : FullBox { struct SampleEncryption : FullBox {
static const uint8_t kInvalidIvSize = 1;
enum SampleEncryptionFlags { enum SampleEncryptionFlags {
kUseSubsampleEncryption = 2, kUseSubsampleEncryption = 2,
}; };
@ -122,33 +123,34 @@ struct SampleEncryption : FullBox {
/// store sample encryption data for parsing later when @a iv_size is known. /// store sample encryption data for parsing later when @a iv_size is known.
std::vector<uint8_t> sample_encryption_data; std::vector<uint8_t> sample_encryption_data;
uint8_t iv_size; uint8_t iv_size = kInvalidIvSize;
std::vector<SampleEncryptionEntry> sample_encryption_entries; std::vector<SampleEncryptionEntry> sample_encryption_entries;
}; };
struct OriginalFormat : Box { struct OriginalFormat : Box {
DECLARE_BOX_METHODS(OriginalFormat); DECLARE_BOX_METHODS(OriginalFormat);
FourCC format; FourCC format = FOURCC_NULL;
}; };
struct SchemeType : FullBox { struct SchemeType : FullBox {
DECLARE_BOX_METHODS(SchemeType); DECLARE_BOX_METHODS(SchemeType);
FourCC type; FourCC type = FOURCC_NULL;
uint32_t version; uint32_t version = 0u;
}; };
struct TrackEncryption : FullBox { struct TrackEncryption : FullBox {
DECLARE_BOX_METHODS(TrackEncryption); DECLARE_BOX_METHODS(TrackEncryption);
uint8_t default_is_protected; uint8_t default_is_protected = 0;
uint8_t default_per_sample_iv_size; uint8_t default_per_sample_iv_size = 0;
std::vector<uint8_t> default_kid; // Default to a vector of 16 zeros.
std::vector<uint8_t> default_kid = std::vector<uint8_t>(16, 0);
// For pattern-based encryption. // For pattern-based encryption.
uint8_t default_crypt_byte_block; uint8_t default_crypt_byte_block = 0;
uint8_t default_skip_byte_block; uint8_t default_skip_byte_block = 0;
// Present only if // Present only if
// |default_is_protected == 1 && default_per_sample_iv_size == 0|. // |default_is_protected == 1 && default_per_sample_iv_size == 0|.
@ -172,13 +174,13 @@ struct ProtectionSchemeInfo : Box {
struct MovieHeader : FullBox { struct MovieHeader : FullBox {
DECLARE_BOX_METHODS(MovieHeader); DECLARE_BOX_METHODS(MovieHeader);
uint64_t creation_time; uint64_t creation_time = 0;
uint64_t modification_time; uint64_t modification_time = 0;
uint32_t timescale; uint32_t timescale = 0;
uint64_t duration; uint64_t duration = 0;
int32_t rate; int32_t rate = 1 << 16;
int16_t volume; int16_t volume = 1 << 8;
uint32_t next_track_id; uint32_t next_track_id = 0;
}; };
struct TrackHeader : FullBox { struct TrackHeader : FullBox {
@ -190,24 +192,24 @@ struct TrackHeader : FullBox {
DECLARE_BOX_METHODS(TrackHeader); DECLARE_BOX_METHODS(TrackHeader);
uint64_t creation_time; uint64_t creation_time = 0;
uint64_t modification_time; uint64_t modification_time = 0;
uint32_t track_id; uint32_t track_id = 0;
uint64_t duration; uint64_t duration = 0;
int16_t layer; int16_t layer = 0;
int16_t alternate_group; int16_t alternate_group = 0;
int16_t volume; int16_t volume = -1;
// width and height specify the track's visual presentation size as // width and height specify the track's visual presentation size as
// fixed-point 16.16 values. // fixed-point 16.16 values.
uint32_t width; uint32_t width = 0;
uint32_t height; uint32_t height = 0;
}; };
struct EditListEntry { struct EditListEntry {
uint64_t segment_duration; uint64_t segment_duration = 0;
int64_t media_time; int64_t media_time = 0;
int16_t media_rate_integer; int16_t media_rate_integer = 0;
int16_t media_rate_fraction; int16_t media_rate_fraction = 0;
}; };
struct EditList : FullBox { struct EditList : FullBox {
@ -225,7 +227,7 @@ struct Edit : Box {
struct HandlerReference : FullBox { struct HandlerReference : FullBox {
DECLARE_BOX_METHODS(HandlerReference); DECLARE_BOX_METHODS(HandlerReference);
FourCC handler_type; FourCC handler_type = FOURCC_NULL;
}; };
struct Language { struct Language {
@ -259,7 +261,7 @@ struct Metadata : FullBox {
struct CodecConfiguration : Box { struct CodecConfiguration : Box {
DECLARE_BOX_METHODS(CodecConfiguration); DECLARE_BOX_METHODS(CodecConfiguration);
FourCC box_type; FourCC box_type = FOURCC_NULL;
// Contains full codec configuration record, including possible extension // Contains full codec configuration record, including possible extension
// boxes. // boxes.
std::vector<uint8_t> data; std::vector<uint8_t> data;
@ -268,12 +270,13 @@ struct CodecConfiguration : Box {
struct PixelAspectRatio : Box { struct PixelAspectRatio : Box {
DECLARE_BOX_METHODS(PixelAspectRatio); DECLARE_BOX_METHODS(PixelAspectRatio);
uint32_t h_spacing; uint32_t h_spacing = 0u;
uint32_t v_spacing; uint32_t v_spacing = 0u;
}; };
struct VideoSampleEntry : Box { struct VideoSampleEntry : Box {
DECLARE_BOX_METHODS(VideoSampleEntry); DECLARE_BOX_METHODS(VideoSampleEntry);
// Returns actual format of this sample entry. // Returns actual format of this sample entry.
FourCC GetActualFormat() const { FourCC GetActualFormat() const {
return format == FOURCC_encv ? sinf.format.format : format; return format == FOURCC_encv ? sinf.format.format : format;
@ -281,10 +284,12 @@ struct VideoSampleEntry : Box {
// Returns the box type of codec configuration box from video format. // Returns the box type of codec configuration box from video format.
FourCC GetCodecConfigurationBoxType(FourCC format) const; FourCC GetCodecConfigurationBoxType(FourCC format) const;
FourCC format; FourCC format = FOURCC_NULL;
uint16_t data_reference_index; // data_reference_index is 1-based and "dref" box is mandatory so it is
uint16_t width; // always present.
uint16_t height; uint16_t data_reference_index = 1u;
uint16_t width = 0u;
uint16_t height = 0u;
PixelAspectRatio pixel_aspect; PixelAspectRatio pixel_aspect;
ProtectionSchemeInfo sinf; ProtectionSchemeInfo sinf;
@ -301,10 +306,10 @@ struct ElementaryStreamDescriptor : FullBox {
struct DTSSpecific : Box { struct DTSSpecific : Box {
DECLARE_BOX_METHODS(DTSSpecific); DECLARE_BOX_METHODS(DTSSpecific);
uint32_t sampling_frequency; uint32_t sampling_frequency = 0u;
uint32_t max_bitrate; uint32_t max_bitrate = 0u;
uint32_t avg_bitrate; uint32_t avg_bitrate = 0u;
uint8_t pcm_sample_depth; uint8_t pcm_sample_depth = 0u;
std::vector<uint8_t> extra_data; std::vector<uint8_t> extra_data;
}; };
@ -325,7 +330,7 @@ struct OpusSpecific : Box {
std::vector<uint8_t> opus_identification_header; std::vector<uint8_t> opus_identification_header;
// The number of priming samples. Extracted from |opus_identification_header|. // The number of priming samples. Extracted from |opus_identification_header|.
uint16_t preskip; uint16_t preskip = 0u;
}; };
// FLAC specific decoder configuration box: // FLAC specific decoder configuration box:
@ -339,16 +344,19 @@ struct FlacSpecific : FullBox {
struct AudioSampleEntry : Box { struct AudioSampleEntry : Box {
DECLARE_BOX_METHODS(AudioSampleEntry); DECLARE_BOX_METHODS(AudioSampleEntry);
// Returns actual format of this sample entry. // Returns actual format of this sample entry.
FourCC GetActualFormat() const { FourCC GetActualFormat() const {
return format == FOURCC_enca ? sinf.format.format : format; return format == FOURCC_enca ? sinf.format.format : format;
} }
FourCC format; FourCC format = FOURCC_NULL;
uint16_t data_reference_index; // data_reference_index is 1-based and "dref" box is mandatory so it is
uint16_t channelcount; // always present.
uint16_t samplesize; uint16_t data_reference_index = 1u;
uint32_t samplerate; uint16_t channelcount = 2u;
uint16_t samplesize = 16u;
uint32_t samplerate = 0u;
ProtectionSchemeInfo sinf; ProtectionSchemeInfo sinf;
@ -362,11 +370,13 @@ struct AudioSampleEntry : Box {
struct WebVTTConfigurationBox : Box { struct WebVTTConfigurationBox : Box {
DECLARE_BOX_METHODS(WebVTTConfigurationBox); DECLARE_BOX_METHODS(WebVTTConfigurationBox);
std::string config; std::string config;
}; };
struct WebVTTSourceLabelBox : Box { struct WebVTTSourceLabelBox : Box {
DECLARE_BOX_METHODS(WebVTTSourceLabelBox); DECLARE_BOX_METHODS(WebVTTSourceLabelBox);
std::string source_label; std::string source_label;
}; };
@ -376,9 +386,11 @@ struct TextSampleEntry : Box {
// Specifies fourcc of this sample entry. It needs to be set on write, e.g. // Specifies fourcc of this sample entry. It needs to be set on write, e.g.
// set to 'wvtt' to write WVTTSampleEntry; On read, it is recovered from box // set to 'wvtt' to write WVTTSampleEntry; On read, it is recovered from box
// header. // header.
FourCC format; FourCC format = FOURCC_NULL;
uint16_t data_reference_index; // data_reference_index is 1-based and "dref" box is mandatory so it is
// always present.
uint16_t data_reference_index = 1u;
// Sub boxes for wvtt text sample entry. // Sub boxes for wvtt text sample entry.
WebVTTConfigurationBox config; WebVTTConfigurationBox config;
@ -389,7 +401,7 @@ struct TextSampleEntry : Box {
struct SampleDescription : FullBox { struct SampleDescription : FullBox {
DECLARE_BOX_METHODS(SampleDescription); DECLARE_BOX_METHODS(SampleDescription);
TrackType type; TrackType type = kInvalid;
// TODO(kqyang): Clean up the code to have one single member, e.g. by creating // TODO(kqyang): Clean up the code to have one single member, e.g. by creating
// SampleEntry struct, std::vector<SampleEntry> sample_entries. // SampleEntry struct, std::vector<SampleEntry> sample_entries.
std::vector<VideoSampleEntry> video_entries; std::vector<VideoSampleEntry> video_entries;
@ -441,8 +453,8 @@ struct SampleToChunk : FullBox {
struct SampleSize : FullBox { struct SampleSize : FullBox {
DECLARE_BOX_METHODS(SampleSize); DECLARE_BOX_METHODS(SampleSize);
uint32_t sample_size; uint32_t sample_size = 0u;
uint32_t sample_count; uint32_t sample_count = 0u;
std::vector<uint32_t> sizes; std::vector<uint32_t> sizes;
}; };
@ -450,7 +462,7 @@ struct SampleSize : FullBox {
struct CompactSampleSize : FullBox { struct CompactSampleSize : FullBox {
DECLARE_BOX_METHODS(CompactSampleSize); DECLARE_BOX_METHODS(CompactSampleSize);
uint8_t field_size; uint8_t field_size = 0u;
std::vector<uint32_t> sizes; std::vector<uint32_t> sizes;
}; };
@ -474,32 +486,26 @@ struct SyncSample : FullBox {
}; };
struct CencSampleEncryptionInfoEntry { struct CencSampleEncryptionInfoEntry {
CencSampleEncryptionInfoEntry();
~CencSampleEncryptionInfoEntry();
bool ReadWrite(BoxBuffer* buffer); bool ReadWrite(BoxBuffer* buffer);
uint32_t ComputeSize() const; uint32_t ComputeSize() const;
uint8_t is_protected; uint8_t is_protected = 0u;
uint8_t per_sample_iv_size; uint8_t per_sample_iv_size = 0u;
std::vector<uint8_t> key_id; std::vector<uint8_t> key_id;
// For pattern-based encryption. // For pattern-based encryption.
uint8_t crypt_byte_block; uint8_t crypt_byte_block = 0u;
uint8_t skip_byte_block; uint8_t skip_byte_block = 0u;
// Present only if |is_protected == 1 && per_sample_iv_size == 0|. // Present only if |is_protected == 1 && per_sample_iv_size == 0|.
std::vector<uint8_t> constant_iv; std::vector<uint8_t> constant_iv;
}; };
struct AudioRollRecoveryEntry { struct AudioRollRecoveryEntry {
AudioRollRecoveryEntry();
~AudioRollRecoveryEntry();
bool ReadWrite(BoxBuffer* buffer); bool ReadWrite(BoxBuffer* buffer);
uint32_t ComputeSize() const; uint32_t ComputeSize() const;
int16_t roll_distance; int16_t roll_distance = 0;
}; };
struct SampleGroupDescription : FullBox { struct SampleGroupDescription : FullBox {
@ -508,7 +514,7 @@ struct SampleGroupDescription : FullBox {
template <typename T> template <typename T>
bool ReadWriteEntries(BoxBuffer* buffer, std::vector<T>* entries); bool ReadWriteEntries(BoxBuffer* buffer, std::vector<T>* entries);
uint32_t grouping_type; uint32_t grouping_type = 0;
// Only present if grouping_type == 'seig'. // Only present if grouping_type == 'seig'.
std::vector<CencSampleEncryptionInfoEntry> std::vector<CencSampleEncryptionInfoEntry>
cenc_sample_encryption_info_entries; cenc_sample_encryption_info_entries;
@ -522,15 +528,15 @@ struct SampleToGroupEntry {
kTrackFragmentGroupDescriptionIndexBase = 0x10000, kTrackFragmentGroupDescriptionIndexBase = 0x10000,
}; };
uint32_t sample_count; uint32_t sample_count = 0u;
uint32_t group_description_index; uint32_t group_description_index = 0u;
}; };
struct SampleToGroup : FullBox { struct SampleToGroup : FullBox {
DECLARE_BOX_METHODS(SampleToGroup); DECLARE_BOX_METHODS(SampleToGroup);
uint32_t grouping_type; uint32_t grouping_type = 0u;
uint32_t grouping_type_parameter; // Version 1 only. uint32_t grouping_type_parameter = 0u; // Version 1 only.
std::vector<SampleToGroupEntry> entries; std::vector<SampleToGroupEntry> entries;
}; };
@ -554,26 +560,26 @@ struct SampleTable : Box {
struct MediaHeader : FullBox { struct MediaHeader : FullBox {
DECLARE_BOX_METHODS(MediaHeader); DECLARE_BOX_METHODS(MediaHeader);
uint64_t creation_time; uint64_t creation_time = 0u;
uint64_t modification_time; uint64_t modification_time = 0u;
uint32_t timescale; uint32_t timescale = 0u;
uint64_t duration; uint64_t duration = 0u;
Language language; Language language;
}; };
struct VideoMediaHeader : FullBox { struct VideoMediaHeader : FullBox {
DECLARE_BOX_METHODS(VideoMediaHeader); DECLARE_BOX_METHODS(VideoMediaHeader);
uint16_t graphicsmode; uint16_t graphicsmode = 0u;
uint16_t opcolor_red; uint16_t opcolor_red = 0u;
uint16_t opcolor_green; uint16_t opcolor_green = 0u;
uint16_t opcolor_blue; uint16_t opcolor_blue = 0u;
}; };
struct SoundMediaHeader : FullBox { struct SoundMediaHeader : FullBox {
DECLARE_BOX_METHODS(SoundMediaHeader); DECLARE_BOX_METHODS(SoundMediaHeader);
uint16_t balance; uint16_t balance = 0u;
}; };
struct SubtitleMediaHeader : FullBox { struct SubtitleMediaHeader : FullBox {
@ -589,8 +595,8 @@ struct DataEntryUrl : FullBox {
struct DataReference : FullBox { struct DataReference : FullBox {
DECLARE_BOX_METHODS(DataReference); DECLARE_BOX_METHODS(DataReference);
// data entry can be either url or urn box. Fix to url box for now. // Can be either url or urn box. Fix to url box for now.
std::vector<DataEntryUrl> data_entry; std::vector<DataEntryUrl> data_entry = std::vector<DataEntryUrl>(1);
}; };
struct DataInformation : Box { struct DataInformation : Box {
@ -630,17 +636,17 @@ struct Track : Box {
struct MovieExtendsHeader : FullBox { struct MovieExtendsHeader : FullBox {
DECLARE_BOX_METHODS(MovieExtendsHeader); DECLARE_BOX_METHODS(MovieExtendsHeader);
uint64_t fragment_duration; uint64_t fragment_duration = 0u;
}; };
struct TrackExtends : FullBox { struct TrackExtends : FullBox {
DECLARE_BOX_METHODS(TrackExtends); DECLARE_BOX_METHODS(TrackExtends);
uint32_t track_id; uint32_t track_id = 0u;
uint32_t default_sample_description_index; uint32_t default_sample_description_index = 0u;
uint32_t default_sample_duration; uint32_t default_sample_duration = 0u;
uint32_t default_sample_size; uint32_t default_sample_size = 0u;
uint32_t default_sample_flags; uint32_t default_sample_flags = 0u;
}; };
struct MovieExtends : Box { struct MovieExtends : Box {
@ -663,13 +669,13 @@ struct Movie : Box {
struct TrackFragmentDecodeTime : FullBox { struct TrackFragmentDecodeTime : FullBox {
DECLARE_BOX_METHODS(TrackFragmentDecodeTime); DECLARE_BOX_METHODS(TrackFragmentDecodeTime);
uint64_t decode_time; uint64_t decode_time = 0u;
}; };
struct MovieFragmentHeader : FullBox { struct MovieFragmentHeader : FullBox {
DECLARE_BOX_METHODS(MovieFragmentHeader); DECLARE_BOX_METHODS(MovieFragmentHeader);
uint32_t sequence_number; uint32_t sequence_number = 0u;
}; };
struct TrackFragmentHeader : FullBox { struct TrackFragmentHeader : FullBox {
@ -695,11 +701,11 @@ struct TrackFragmentHeader : FullBox {
DECLARE_BOX_METHODS(TrackFragmentHeader); DECLARE_BOX_METHODS(TrackFragmentHeader);
uint32_t track_id; uint32_t track_id = 0u;
uint32_t sample_description_index; uint32_t sample_description_index = 0u;
uint32_t default_sample_duration; uint32_t default_sample_duration = 0u;
uint32_t default_sample_size; uint32_t default_sample_size = 0u;
uint32_t default_sample_flags; uint32_t default_sample_flags = 0u;
}; };
struct TrackFragmentRun : FullBox { struct TrackFragmentRun : FullBox {
@ -714,8 +720,8 @@ struct TrackFragmentRun : FullBox {
DECLARE_BOX_METHODS(TrackFragmentRun); DECLARE_BOX_METHODS(TrackFragmentRun);
uint32_t sample_count; uint32_t sample_count = 0u;
uint32_t data_offset; uint32_t data_offset = 0u;
std::vector<uint32_t> sample_flags; std::vector<uint32_t> sample_flags;
std::vector<uint32_t> sample_sizes; std::vector<uint32_t> sample_sizes;
std::vector<uint32_t> sample_durations; std::vector<uint32_t> sample_durations;
@ -727,7 +733,7 @@ struct TrackFragment : Box {
TrackFragmentHeader header; TrackFragmentHeader header;
std::vector<TrackFragmentRun> runs; std::vector<TrackFragmentRun> runs;
bool decode_time_absent; bool decode_time_absent = false;
TrackFragmentDecodeTime decode_time; TrackFragmentDecodeTime decode_time;
std::vector<SampleGroupDescription> sample_group_descriptions; std::vector<SampleGroupDescription> sample_group_descriptions;
std::vector<SampleToGroup> sample_to_groups; std::vector<SampleToGroup> sample_to_groups;
@ -755,24 +761,24 @@ struct SegmentReference {
Type6 = 6, // T(ept) < T(dec) < T(sap) Type6 = 6, // T(ept) < T(dec) < T(sap)
}; };
bool reference_type; bool reference_type = false;
uint32_t referenced_size; uint32_t referenced_size = 0u;
uint32_t subsegment_duration; uint32_t subsegment_duration = 0u;
bool starts_with_sap; bool starts_with_sap = false;
SAPType sap_type; SAPType sap_type = TypeUnknown;
uint32_t sap_delta_time; uint32_t sap_delta_time = 0u;
// We add this field to keep track of earliest_presentation_time in this // We add this field to keep track of earliest_presentation_time in this
// subsegment. It is not part of SegmentReference. // subsegment. It is not part of SegmentReference.
uint64_t earliest_presentation_time; uint64_t earliest_presentation_time = 0u;
}; };
struct SegmentIndex : FullBox { struct SegmentIndex : FullBox {
DECLARE_BOX_METHODS(SegmentIndex); DECLARE_BOX_METHODS(SegmentIndex);
uint32_t reference_id; uint32_t reference_id = 0u;
uint32_t timescale; uint32_t timescale = 0u;
uint64_t earliest_presentation_time; uint64_t earliest_presentation_time = 0u;
uint64_t first_offset; uint64_t first_offset = 0u;
std::vector<SegmentReference> references; std::vector<SegmentReference> references;
}; };
@ -780,31 +786,40 @@ struct SegmentIndex : FullBox {
struct MediaData : Box { struct MediaData : Box {
DECLARE_BOX_METHODS(MediaData); DECLARE_BOX_METHODS(MediaData);
uint32_t data_size; uint32_t data_size = 0u;
}; };
// Using negative value as "not set". It is very unlikely that 2^31 cues happen
// at once.
const int kCueSourceIdNotSet = -1;
struct CueSourceIDBox : Box { struct CueSourceIDBox : Box {
DECLARE_BOX_METHODS(CueSourceIDBox); DECLARE_BOX_METHODS(CueSourceIDBox);
int32_t source_id;
int32_t source_id = kCueSourceIdNotSet;
}; };
struct CueTimeBox : Box { struct CueTimeBox : Box {
DECLARE_BOX_METHODS(CueTimeBox); DECLARE_BOX_METHODS(CueTimeBox);
std::string cue_current_time; std::string cue_current_time;
}; };
struct CueIDBox : Box { struct CueIDBox : Box {
DECLARE_BOX_METHODS(CueIDBox); DECLARE_BOX_METHODS(CueIDBox);
std::string cue_id; std::string cue_id;
}; };
struct CueSettingsBox : Box { struct CueSettingsBox : Box {
DECLARE_BOX_METHODS(CueSettingsBox); DECLARE_BOX_METHODS(CueSettingsBox);
std::string settings; std::string settings;
}; };
struct CuePayloadBox : Box { struct CuePayloadBox : Box {
DECLARE_BOX_METHODS(CuePayloadBox); DECLARE_BOX_METHODS(CuePayloadBox);
std::string cue_text; std::string cue_text;
}; };
@ -814,6 +829,7 @@ struct VTTEmptyCueBox : Box {
struct VTTAdditionalTextBox : Box { struct VTTAdditionalTextBox : Box {
DECLARE_BOX_METHODS(VTTAdditionalTextBox); DECLARE_BOX_METHODS(VTTAdditionalTextBox);
std::string cue_additional_text; std::string cue_additional_text;
}; };