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;
}
FullBox::FullBox() : version(0), flags(0) {}
FullBox::~FullBox() {}
FullBox::FullBox() = default;
FullBox::~FullBox() = default;
uint32_t FullBox::HeaderSize() const {
// Additional 1-byte version and 3-byte flags.

View File

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

View File

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

View File

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