2013-09-24 01:35:40 +00:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
|
|
|
|
#define PACKAGER_MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2023-12-01 17:32:19 +00:00
|
|
|
#include <packager/media/base/decrypt_config.h>
|
|
|
|
#include <packager/media/base/fourccs.h>
|
|
|
|
#include <packager/media/codecs/aac_audio_specific_config.h>
|
|
|
|
#include <packager/media/codecs/es_descriptor.h>
|
|
|
|
#include <packager/media/formats/mp4/box.h>
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-09-24 01:35:40 +00:00
|
|
|
namespace media {
|
2013-11-27 01:52:13 +00:00
|
|
|
|
|
|
|
class BufferReader;
|
|
|
|
|
2013-09-24 01:35:40 +00:00
|
|
|
namespace mp4 {
|
|
|
|
|
|
|
|
enum TrackType {
|
|
|
|
kInvalid = 0,
|
|
|
|
kVideo,
|
|
|
|
kAudio,
|
2015-11-23 23:12:04 +00:00
|
|
|
kHint,
|
|
|
|
kText,
|
2020-10-13 21:43:18 +00:00
|
|
|
kSubtitle,
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
class BoxBuffer;
|
|
|
|
|
|
|
|
#define DECLARE_BOX_METHODS(T) \
|
2015-12-15 00:07:51 +00:00
|
|
|
public: \
|
2013-11-27 01:52:13 +00:00
|
|
|
T(); \
|
2015-12-15 00:07:51 +00:00
|
|
|
~T() override; \
|
2018-06-04 22:07:00 +00:00
|
|
|
\
|
2015-12-15 00:07:51 +00:00
|
|
|
FourCC BoxType() const override; \
|
|
|
|
\
|
|
|
|
private: \
|
|
|
|
bool ReadWriteInternal(BoxBuffer* buffer) override; \
|
2016-11-09 02:11:13 +00:00
|
|
|
size_t ComputeSizeInternal() override; \
|
2015-12-15 00:07:51 +00:00
|
|
|
\
|
|
|
|
public:
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct FileType : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(FileType);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
FourCC major_brand = FOURCC_NULL;
|
|
|
|
uint32_t minor_version = 0;
|
2013-11-27 01:52:13 +00:00
|
|
|
std::vector<FourCC> compatible_brands;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct SegmentType : FileType {
|
2015-12-15 00:07:51 +00:00
|
|
|
FourCC BoxType() const override;
|
2013-11-27 01:52:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ProtectionSystemSpecificHeader : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(ProtectionSystemSpecificHeader);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint8_t> raw_box;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct SampleAuxiliaryInformationOffset : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(SampleAuxiliaryInformationOffset);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint64_t> offsets;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct SampleAuxiliaryInformationSize : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(SampleAuxiliaryInformationSize);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint8_t default_sample_info_size = 0;
|
|
|
|
uint32_t sample_count = 0;
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint8_t> sample_info_sizes;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2015-12-21 18:34:21 +00:00
|
|
|
struct SampleEncryptionEntry {
|
|
|
|
/// Read/Write SampleEncryptionEntry.
|
|
|
|
/// @param iv_size specifies the size of initialization vector.
|
|
|
|
/// @param has_subsamples indicates whether this sample encryption entry
|
|
|
|
/// constains subsamples.
|
|
|
|
/// @param buffer points to the box buffer for reading or writing.
|
|
|
|
/// @return true on success, false otherwise.
|
2018-05-24 22:47:56 +00:00
|
|
|
bool ReadWrite(uint8_t iv_size, bool has_subsamples, BoxBuffer* buffer);
|
2015-12-21 18:34:21 +00:00
|
|
|
/// Parse SampleEncryptionEntry from buffer.
|
|
|
|
/// @param iv_size specifies the size of initialization vector.
|
|
|
|
/// @param has_subsamples indicates whether this sample encryption entry
|
|
|
|
/// constains subsamples.
|
|
|
|
/// @param reader points to the buffer reader. Cannot be NULL.
|
|
|
|
/// @return true on success, false otherwise.
|
|
|
|
bool ParseFromBuffer(uint8_t iv_size,
|
|
|
|
bool has_subsamples,
|
|
|
|
BufferReader* reader);
|
|
|
|
/// @return The size of the structure in bytes when it is stored.
|
|
|
|
uint32_t ComputeSize() const;
|
|
|
|
/// @return The accumulated size of subsamples. Returns 0 if there is no
|
|
|
|
/// subsamples.
|
|
|
|
uint32_t GetTotalSizeOfSubsamples() const;
|
|
|
|
|
|
|
|
std::vector<uint8_t> initialization_vector;
|
|
|
|
std::vector<SubsampleEntry> subsamples;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SampleEncryption : FullBox {
|
2018-06-04 22:07:00 +00:00
|
|
|
static const uint8_t kInvalidIvSize = 1;
|
|
|
|
|
2015-12-21 18:34:21 +00:00
|
|
|
enum SampleEncryptionFlags {
|
|
|
|
kUseSubsampleEncryption = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
DECLARE_BOX_METHODS(SampleEncryption);
|
|
|
|
/// Parse from @a sample_encryption_data.
|
|
|
|
/// @param iv_size specifies the size of initialization vector.
|
|
|
|
/// @param[out] sample_encryption_entries receives parsed sample encryption
|
|
|
|
/// entries.
|
|
|
|
/// @return true on success, false otherwise.
|
|
|
|
bool ParseFromSampleEncryptionData(
|
2023-12-01 17:32:19 +00:00
|
|
|
uint8_t l_iv_size,
|
|
|
|
std::vector<SampleEncryptionEntry>* l_sample_encryption_entries) const;
|
2015-12-21 18:34:21 +00:00
|
|
|
|
|
|
|
/// We may not know @a iv_size before reading this box. In this case, we will
|
|
|
|
/// store sample encryption data for parsing later when @a iv_size is known.
|
|
|
|
std::vector<uint8_t> sample_encryption_data;
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint8_t iv_size = kInvalidIvSize;
|
2015-12-21 18:34:21 +00:00
|
|
|
std::vector<SampleEncryptionEntry> sample_encryption_entries;
|
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct OriginalFormat : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(OriginalFormat);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
FourCC format = FOURCC_NULL;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct SchemeType : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(SchemeType);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
FourCC type = FOURCC_NULL;
|
|
|
|
uint32_t version = 0u;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct TrackEncryption : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(TrackEncryption);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
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);
|
2016-04-12 22:39:10 +00:00
|
|
|
|
|
|
|
// For pattern-based encryption.
|
2018-06-04 22:07:00 +00:00
|
|
|
uint8_t default_crypt_byte_block = 0;
|
|
|
|
uint8_t default_skip_byte_block = 0;
|
2016-04-12 22:39:10 +00:00
|
|
|
|
|
|
|
// Present only if
|
|
|
|
// |default_is_protected == 1 && default_per_sample_iv_size == 0|.
|
|
|
|
std::vector<uint8_t> default_constant_iv;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct SchemeInfo : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(SchemeInfo);
|
|
|
|
|
|
|
|
TrackEncryption track_encryption;
|
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct ProtectionSchemeInfo : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(ProtectionSchemeInfo);
|
|
|
|
|
|
|
|
OriginalFormat format;
|
|
|
|
SchemeType type;
|
|
|
|
SchemeInfo info;
|
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct MovieHeader : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(MovieHeader);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
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;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct TrackHeader : FullBox {
|
|
|
|
enum TrackHeaderFlags {
|
2018-05-24 22:47:56 +00:00
|
|
|
kTrackEnabled = 0x000001,
|
|
|
|
kTrackInMovie = 0x000002,
|
2013-11-27 01:52:13 +00:00
|
|
|
kTrackInPreview = 0x000004,
|
|
|
|
};
|
|
|
|
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(TrackHeader);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
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;
|
2015-08-05 23:39:03 +00:00
|
|
|
// width and height specify the track's visual presentation size as
|
|
|
|
// fixed-point 16.16 values.
|
2018-06-04 22:07:00 +00:00
|
|
|
uint32_t width = 0;
|
|
|
|
uint32_t height = 0;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct EditListEntry {
|
2018-06-04 22:07:00 +00:00
|
|
|
uint64_t segment_duration = 0;
|
|
|
|
int64_t media_time = 0;
|
|
|
|
int16_t media_rate_integer = 0;
|
|
|
|
int16_t media_rate_fraction = 0;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct EditList : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(EditList);
|
|
|
|
|
|
|
|
std::vector<EditListEntry> edits;
|
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct Edit : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(Edit);
|
|
|
|
|
|
|
|
EditList list;
|
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct HandlerReference : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(HandlerReference);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
FourCC handler_type = FOURCC_NULL;
|
2015-12-21 23:10:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Language {
|
|
|
|
bool ReadWrite(BoxBuffer* buffer);
|
|
|
|
uint32_t ComputeSize() const;
|
|
|
|
|
|
|
|
std::string code;
|
|
|
|
};
|
|
|
|
|
2018-05-07 22:57:56 +00:00
|
|
|
/// Implemented per http://mp4ra.org/#/references.
|
2015-12-21 23:10:17 +00:00
|
|
|
struct ID3v2 : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(ID3v2);
|
|
|
|
|
|
|
|
Language language;
|
2018-05-07 22:57:56 +00:00
|
|
|
std::vector<uint8_t> id3v2_data;
|
2015-12-21 23:10:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Metadata : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(Metadata);
|
|
|
|
|
|
|
|
HandlerReference handler;
|
|
|
|
ID3v2 id3v2;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2016-05-25 01:07:14 +00:00
|
|
|
// This defines a common structure for various CodecConfiguration boxes:
|
|
|
|
// AVCConfiguration, HEVCConfiguration and VPCodecConfiguration.
|
|
|
|
// Note that unlike the other two CodecConfiguration boxes, VPCodecConfiguration
|
|
|
|
// box inherits from FullBox instead of Box, according to VP Codec ISO Media
|
|
|
|
// File Format Binding specification. It will be handled properly in the
|
|
|
|
// implementation.
|
2018-05-24 22:47:56 +00:00
|
|
|
struct CodecConfiguration : Box {
|
2016-05-25 01:07:14 +00:00
|
|
|
DECLARE_BOX_METHODS(CodecConfiguration);
|
2013-10-14 20:55:48 +00:00
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
FourCC box_type = FOURCC_NULL;
|
2015-12-15 00:07:51 +00:00
|
|
|
// Contains full codec configuration record, including possible extension
|
|
|
|
// boxes.
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint8_t> data;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2023-08-04 16:00:59 +00:00
|
|
|
struct ColorParameters : Box {
|
|
|
|
DECLARE_BOX_METHODS(ColorParameters);
|
|
|
|
|
|
|
|
FourCC color_parameter_type = FOURCC_NULL;
|
|
|
|
uint16_t color_primaries = 1;
|
|
|
|
uint16_t transfer_characteristics = 1;
|
|
|
|
uint16_t matrix_coefficients = 1;
|
|
|
|
uint8_t video_full_range_flag = 0;
|
2023-08-30 01:46:19 +00:00
|
|
|
std::vector<uint8_t> raw_box;
|
2023-08-04 16:00:59 +00:00
|
|
|
};
|
|
|
|
|
2015-12-15 00:07:51 +00:00
|
|
|
struct PixelAspectRatio : Box {
|
|
|
|
DECLARE_BOX_METHODS(PixelAspectRatio);
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint32_t h_spacing = 0u;
|
|
|
|
uint32_t v_spacing = 0u;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct VideoSampleEntry : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(VideoSampleEntry);
|
2018-06-04 22:07:00 +00:00
|
|
|
|
2015-10-27 00:52:57 +00:00
|
|
|
// Returns actual format of this sample entry.
|
|
|
|
FourCC GetActualFormat() const {
|
2016-04-06 23:21:45 +00:00
|
|
|
return format == FOURCC_encv ? sinf.format.format : format;
|
2015-10-27 00:52:57 +00:00
|
|
|
}
|
2016-05-25 01:07:14 +00:00
|
|
|
// Returns the box type of codec configuration box from video format.
|
2023-12-01 17:32:19 +00:00
|
|
|
FourCC GetCodecConfigurationBoxType(FourCC l_format) const;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2019-09-21 01:02:13 +00:00
|
|
|
// Convert |extra_codec_configs| to vector.
|
|
|
|
std::vector<uint8_t> ExtraCodecConfigsAsVector() const;
|
|
|
|
// Parse |extra_codec_configs| from vector.
|
|
|
|
bool ParseExtraCodecConfigsVector(const std::vector<uint8_t>& data);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
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;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2023-08-04 16:00:59 +00:00
|
|
|
ColorParameters colr;
|
2015-12-15 00:07:51 +00:00
|
|
|
PixelAspectRatio pixel_aspect;
|
2013-09-24 01:35:40 +00:00
|
|
|
ProtectionSchemeInfo sinf;
|
2016-05-25 01:07:14 +00:00
|
|
|
CodecConfiguration codec_configuration;
|
2019-09-21 01:02:13 +00:00
|
|
|
// Some codecs, e.g. Dolby Vision, have extra codec configuration boxes that
|
|
|
|
// need to be propagated to muxers.
|
|
|
|
std::vector<CodecConfiguration> extra_codec_configs;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct ElementaryStreamDescriptor : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(ElementaryStreamDescriptor);
|
|
|
|
|
2014-01-10 00:21:06 +00:00
|
|
|
AACAudioSpecificConfig aac_audio_specific_config;
|
2013-11-27 01:52:13 +00:00
|
|
|
ESDescriptor es_descriptor;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2015-12-15 00:07:51 +00:00
|
|
|
struct DTSSpecific : Box {
|
|
|
|
DECLARE_BOX_METHODS(DTSSpecific);
|
2015-12-07 19:56:07 +00:00
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint32_t sampling_frequency = 0u;
|
|
|
|
uint32_t max_bitrate = 0u;
|
|
|
|
uint32_t avg_bitrate = 0u;
|
|
|
|
uint8_t pcm_sample_depth = 0u;
|
2016-01-04 18:57:05 +00:00
|
|
|
std::vector<uint8_t> extra_data;
|
2015-12-07 19:56:07 +00:00
|
|
|
};
|
|
|
|
|
2024-02-15 07:03:03 +00:00
|
|
|
struct UDTSSpecific : Box {
|
|
|
|
DECLARE_BOX_METHODS(UDTSSpecific);
|
|
|
|
|
|
|
|
std::vector<uint8_t> data;
|
|
|
|
};
|
|
|
|
|
2016-01-08 23:56:33 +00:00
|
|
|
struct AC3Specific : Box {
|
|
|
|
DECLARE_BOX_METHODS(AC3Specific);
|
|
|
|
|
|
|
|
std::vector<uint8_t> data;
|
|
|
|
};
|
|
|
|
|
2021-06-30 06:10:53 +00:00
|
|
|
struct MHAConfiguration : Box {
|
|
|
|
DECLARE_BOX_METHODS(MHAConfiguration);
|
|
|
|
|
|
|
|
std::vector<uint8_t> data;
|
|
|
|
uint8_t mpeg_h_3da_profile_level_indication;
|
|
|
|
};
|
|
|
|
|
2016-01-15 21:40:44 +00:00
|
|
|
struct EC3Specific : Box {
|
|
|
|
DECLARE_BOX_METHODS(EC3Specific);
|
|
|
|
|
|
|
|
std::vector<uint8_t> data;
|
|
|
|
};
|
|
|
|
|
2020-07-04 21:55:28 +00:00
|
|
|
struct AC4Specific : Box {
|
|
|
|
DECLARE_BOX_METHODS(AC4Specific);
|
|
|
|
|
|
|
|
std::vector<uint8_t> data;
|
|
|
|
};
|
|
|
|
|
2016-05-09 18:55:14 +00:00
|
|
|
struct OpusSpecific : Box {
|
|
|
|
DECLARE_BOX_METHODS(OpusSpecific);
|
|
|
|
|
|
|
|
std::vector<uint8_t> opus_identification_header;
|
|
|
|
// The number of priming samples. Extracted from |opus_identification_header|.
|
2018-06-04 22:07:00 +00:00
|
|
|
uint16_t preskip = 0u;
|
2016-05-09 18:55:14 +00:00
|
|
|
};
|
|
|
|
|
2024-10-25 16:56:28 +00:00
|
|
|
struct IAMFSpecific : Box {
|
|
|
|
DECLARE_BOX_METHODS(IAMFSpecific);
|
|
|
|
|
|
|
|
std::vector<uint8_t> data;
|
|
|
|
};
|
|
|
|
|
2018-04-25 18:27:53 +00:00
|
|
|
// FLAC specific decoder configuration box:
|
|
|
|
// https://github.com/xiph/flac/blob/master/doc/isoflac.txt
|
|
|
|
// We do not care about the actual data inside, which is simply copied over.
|
|
|
|
struct FlacSpecific : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(FlacSpecific);
|
|
|
|
|
|
|
|
std::vector<uint8_t> data;
|
|
|
|
};
|
|
|
|
|
2024-02-26 21:39:30 +00:00
|
|
|
// ALAC specific decoder configuration box:
|
|
|
|
// https://wiki.multimedia.cx/index.php/Apple_Lossless_Audio_Coding
|
|
|
|
// We do not care about the actual data inside, which is simply copied over.
|
|
|
|
struct ALACSpecific : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(ALACSpecific);
|
|
|
|
|
|
|
|
std::vector<uint8_t> data;
|
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct AudioSampleEntry : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(AudioSampleEntry);
|
2018-06-04 22:07:00 +00:00
|
|
|
|
2015-10-27 00:52:57 +00:00
|
|
|
// Returns actual format of this sample entry.
|
|
|
|
FourCC GetActualFormat() const {
|
2016-04-06 23:21:45 +00:00
|
|
|
return format == FOURCC_enca ? sinf.format.format : format;
|
2015-10-27 00:52:57 +00:00
|
|
|
}
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
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;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
ProtectionSchemeInfo sinf;
|
2016-01-15 21:40:44 +00:00
|
|
|
|
2013-09-24 01:35:40 +00:00
|
|
|
ElementaryStreamDescriptor esds;
|
2015-12-15 00:07:51 +00:00
|
|
|
DTSSpecific ddts;
|
2024-02-15 07:03:03 +00:00
|
|
|
UDTSSpecific udts;
|
2016-01-08 23:56:33 +00:00
|
|
|
AC3Specific dac3;
|
2016-01-15 21:40:44 +00:00
|
|
|
EC3Specific dec3;
|
2020-07-04 21:55:28 +00:00
|
|
|
AC4Specific dac4;
|
2016-05-09 18:55:14 +00:00
|
|
|
OpusSpecific dops;
|
2024-10-25 16:56:28 +00:00
|
|
|
IAMFSpecific iacb;
|
2018-04-25 18:27:53 +00:00
|
|
|
FlacSpecific dfla;
|
2021-06-30 06:10:53 +00:00
|
|
|
MHAConfiguration mhac;
|
2024-02-26 21:39:30 +00:00
|
|
|
ALACSpecific alac;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2015-11-23 23:12:04 +00:00
|
|
|
struct WebVTTConfigurationBox : Box {
|
|
|
|
DECLARE_BOX_METHODS(WebVTTConfigurationBox);
|
2018-06-04 22:07:00 +00:00
|
|
|
|
2015-11-23 23:12:04 +00:00
|
|
|
std::string config;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WebVTTSourceLabelBox : Box {
|
|
|
|
DECLARE_BOX_METHODS(WebVTTSourceLabelBox);
|
2018-06-04 22:07:00 +00:00
|
|
|
|
2015-11-23 23:12:04 +00:00
|
|
|
std::string source_label;
|
|
|
|
};
|
|
|
|
|
2016-02-03 23:58:35 +00:00
|
|
|
struct TextSampleEntry : Box {
|
|
|
|
DECLARE_BOX_METHODS(TextSampleEntry);
|
2015-11-23 23:12:04 +00:00
|
|
|
|
2016-02-03 23:58:35 +00:00
|
|
|
// 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.
|
2018-06-04 22:07:00 +00:00
|
|
|
FourCC format = FOURCC_NULL;
|
2018-05-25 16:04:46 +00:00
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
// data_reference_index is 1-based and "dref" box is mandatory so it is
|
|
|
|
// always present.
|
|
|
|
uint16_t data_reference_index = 1u;
|
2015-11-23 23:12:04 +00:00
|
|
|
|
2020-10-13 21:43:18 +00:00
|
|
|
// Sub fields for ttml text sample entry.
|
|
|
|
std::string namespace_;
|
|
|
|
std::string schema_location;
|
|
|
|
// Optional MPEG4BitRateBox.
|
|
|
|
|
2016-02-03 23:58:35 +00:00
|
|
|
// Sub boxes for wvtt text sample entry.
|
2015-11-23 23:12:04 +00:00
|
|
|
WebVTTConfigurationBox config;
|
|
|
|
WebVTTSourceLabelBox label;
|
|
|
|
// Optional MPEG4BitRateBox.
|
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct SampleDescription : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(SampleDescription);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
TrackType type = kInvalid;
|
2015-12-21 18:34:21 +00:00
|
|
|
// TODO(kqyang): Clean up the code to have one single member, e.g. by creating
|
|
|
|
// SampleEntry struct, std::vector<SampleEntry> sample_entries.
|
2013-09-24 01:35:40 +00:00
|
|
|
std::vector<VideoSampleEntry> video_entries;
|
|
|
|
std::vector<AudioSampleEntry> audio_entries;
|
2016-02-03 23:58:35 +00:00
|
|
|
std::vector<TextSampleEntry> text_entries;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-10-08 17:37:58 +00:00
|
|
|
struct DecodingTime {
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t sample_count;
|
|
|
|
uint32_t sample_delta;
|
2013-10-08 17:37:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// stts.
|
2013-11-27 01:52:13 +00:00
|
|
|
struct DecodingTimeToSample : FullBox {
|
2013-10-08 17:37:58 +00:00
|
|
|
DECLARE_BOX_METHODS(DecodingTimeToSample);
|
|
|
|
|
|
|
|
std::vector<DecodingTime> decoding_time;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CompositionOffset {
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t sample_count;
|
|
|
|
// If version == 0, sample_offset is uint32_t;
|
|
|
|
// If version == 1, sample_offset is int32_t.
|
2015-08-04 21:11:15 +00:00
|
|
|
// Use int64_t so both can be supported properly.
|
|
|
|
int64_t sample_offset;
|
2013-10-08 17:37:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ctts. Optional.
|
2013-11-27 01:52:13 +00:00
|
|
|
struct CompositionTimeToSample : FullBox {
|
2013-10-08 17:37:58 +00:00
|
|
|
DECLARE_BOX_METHODS(CompositionTimeToSample);
|
|
|
|
|
|
|
|
std::vector<CompositionOffset> composition_offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ChunkInfo {
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t first_chunk;
|
|
|
|
uint32_t samples_per_chunk;
|
|
|
|
uint32_t sample_description_index;
|
2013-10-08 17:37:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// stsc.
|
2013-11-27 01:52:13 +00:00
|
|
|
struct SampleToChunk : FullBox {
|
2013-10-08 17:37:58 +00:00
|
|
|
DECLARE_BOX_METHODS(SampleToChunk);
|
|
|
|
|
|
|
|
std::vector<ChunkInfo> chunk_info;
|
|
|
|
};
|
|
|
|
|
|
|
|
// stsz.
|
2013-11-27 01:52:13 +00:00
|
|
|
struct SampleSize : FullBox {
|
2013-10-08 17:37:58 +00:00
|
|
|
DECLARE_BOX_METHODS(SampleSize);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint32_t sample_size = 0u;
|
|
|
|
uint32_t sample_count = 0u;
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint32_t> sizes;
|
2013-10-08 17:37:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// stz2.
|
2013-11-27 01:52:13 +00:00
|
|
|
struct CompactSampleSize : FullBox {
|
2013-10-08 17:37:58 +00:00
|
|
|
DECLARE_BOX_METHODS(CompactSampleSize);
|
2013-11-27 01:52:13 +00:00
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint8_t field_size = 0u;
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint32_t> sizes;
|
2013-10-08 17:37:58 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
// co64.
|
|
|
|
struct ChunkLargeOffset : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(ChunkLargeOffset);
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint64_t> offsets;
|
2013-10-08 17:37:58 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
// stco.
|
|
|
|
struct ChunkOffset : ChunkLargeOffset {
|
|
|
|
DECLARE_BOX_METHODS(ChunkOffset);
|
2013-10-08 17:37:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// stss. Optional.
|
2013-11-27 01:52:13 +00:00
|
|
|
struct SyncSample : FullBox {
|
2013-10-08 17:37:58 +00:00
|
|
|
DECLARE_BOX_METHODS(SyncSample);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint32_t> sample_number;
|
2013-10-08 17:37:58 +00:00
|
|
|
};
|
|
|
|
|
2016-05-06 23:56:50 +00:00
|
|
|
struct CencSampleEncryptionInfoEntry {
|
|
|
|
bool ReadWrite(BoxBuffer* buffer);
|
|
|
|
uint32_t ComputeSize() const;
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint8_t is_protected = 0u;
|
|
|
|
uint8_t per_sample_iv_size = 0u;
|
2016-05-06 23:56:50 +00:00
|
|
|
std::vector<uint8_t> key_id;
|
|
|
|
|
|
|
|
// For pattern-based encryption.
|
2018-06-04 22:07:00 +00:00
|
|
|
uint8_t crypt_byte_block = 0u;
|
|
|
|
uint8_t skip_byte_block = 0u;
|
2016-05-06 23:56:50 +00:00
|
|
|
|
|
|
|
// Present only if |is_protected == 1 && per_sample_iv_size == 0|.
|
|
|
|
std::vector<uint8_t> constant_iv;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AudioRollRecoveryEntry {
|
|
|
|
bool ReadWrite(BoxBuffer* buffer);
|
|
|
|
uint32_t ComputeSize() const;
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
int16_t roll_distance = 0;
|
2016-05-06 23:56:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SampleGroupDescription : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(SampleGroupDescription);
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
bool ReadWriteEntries(BoxBuffer* buffer, std::vector<T>* entries);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint32_t grouping_type = 0;
|
2016-05-06 23:56:50 +00:00
|
|
|
// Only present if grouping_type == 'seig'.
|
|
|
|
std::vector<CencSampleEncryptionInfoEntry>
|
|
|
|
cenc_sample_encryption_info_entries;
|
|
|
|
// Only present if grouping_type == 'roll'.
|
|
|
|
std::vector<AudioRollRecoveryEntry> audio_roll_recovery_entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SampleToGroupEntry {
|
|
|
|
enum GroupDescriptionIndexBase {
|
|
|
|
kTrackGroupDescriptionIndexBase = 0,
|
|
|
|
kTrackFragmentGroupDescriptionIndexBase = 0x10000,
|
|
|
|
};
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint32_t sample_count = 0u;
|
|
|
|
uint32_t group_description_index = 0u;
|
2016-05-06 23:56:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SampleToGroup : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(SampleToGroup);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint32_t grouping_type = 0u;
|
|
|
|
uint32_t grouping_type_parameter = 0u; // Version 1 only.
|
2016-05-06 23:56:50 +00:00
|
|
|
std::vector<SampleToGroupEntry> entries;
|
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct SampleTable : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(SampleTable);
|
|
|
|
|
|
|
|
SampleDescription description;
|
2013-10-08 17:37:58 +00:00
|
|
|
DecodingTimeToSample decoding_time_to_sample;
|
|
|
|
CompositionTimeToSample composition_time_to_sample;
|
|
|
|
SampleToChunk sample_to_chunk;
|
|
|
|
// Either SampleSize or CompactSampleSize must present. Store in SampleSize.
|
|
|
|
SampleSize sample_size;
|
2013-11-27 01:52:13 +00:00
|
|
|
// Either ChunkOffset or ChunkLargeOffset must present. Store in
|
|
|
|
// ChunkLargeOffset.
|
|
|
|
ChunkLargeOffset chunk_large_offset;
|
2013-10-08 17:37:58 +00:00
|
|
|
SyncSample sync_sample;
|
2016-05-06 23:56:50 +00:00
|
|
|
std::vector<SampleGroupDescription> sample_group_descriptions;
|
|
|
|
std::vector<SampleToGroup> sample_to_groups;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct MediaHeader : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(MediaHeader);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint64_t creation_time = 0u;
|
|
|
|
uint64_t modification_time = 0u;
|
|
|
|
uint32_t timescale = 0u;
|
|
|
|
uint64_t duration = 0u;
|
2015-12-21 23:10:17 +00:00
|
|
|
Language language;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct VideoMediaHeader : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(VideoMediaHeader);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint16_t graphicsmode = 0u;
|
|
|
|
uint16_t opcolor_red = 0u;
|
|
|
|
uint16_t opcolor_green = 0u;
|
|
|
|
uint16_t opcolor_blue = 0u;
|
2013-11-27 01:52:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SoundMediaHeader : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(SoundMediaHeader);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint16_t balance = 0u;
|
2013-11-27 01:52:13 +00:00
|
|
|
};
|
|
|
|
|
2020-10-13 21:43:18 +00:00
|
|
|
struct NullMediaHeader : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(NullMediaHeader);
|
|
|
|
};
|
|
|
|
|
2015-11-23 23:12:04 +00:00
|
|
|
struct SubtitleMediaHeader : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(SubtitleMediaHeader);
|
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct DataEntryUrl : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(DataEntryUrl);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint8_t> location;
|
2013-11-27 01:52:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DataReference : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(DataReference);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
// Can be either url or urn box. Fix to url box for now.
|
|
|
|
std::vector<DataEntryUrl> data_entry = std::vector<DataEntryUrl>(1);
|
2013-11-27 01:52:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DataInformation : Box {
|
|
|
|
DECLARE_BOX_METHODS(DataInformation);
|
|
|
|
|
|
|
|
DataReference dref;
|
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct MediaInformation : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(MediaInformation);
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
DataInformation dinf;
|
2013-09-24 01:35:40 +00:00
|
|
|
SampleTable sample_table;
|
2013-11-27 01:52:13 +00:00
|
|
|
// Exactly one specific meida header shall be present, vmhd, smhd, hmhd, nmhd.
|
|
|
|
VideoMediaHeader vmhd;
|
|
|
|
SoundMediaHeader smhd;
|
2020-10-13 21:43:18 +00:00
|
|
|
NullMediaHeader nmhd;
|
2015-11-23 23:12:04 +00:00
|
|
|
SubtitleMediaHeader sthd;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct Media : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(Media);
|
|
|
|
|
|
|
|
MediaHeader header;
|
|
|
|
HandlerReference handler;
|
|
|
|
MediaInformation information;
|
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct Track : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(Track);
|
|
|
|
|
|
|
|
TrackHeader header;
|
|
|
|
Media media;
|
|
|
|
Edit edit;
|
2015-12-21 18:34:21 +00:00
|
|
|
SampleEncryption sample_encryption;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct MovieExtendsHeader : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(MovieExtendsHeader);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint64_t fragment_duration = 0u;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct TrackExtends : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(TrackExtends);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
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;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct MovieExtends : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(MovieExtends);
|
|
|
|
|
|
|
|
MovieExtendsHeader header;
|
|
|
|
std::vector<TrackExtends> tracks;
|
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct Movie : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(Movie);
|
|
|
|
|
|
|
|
MovieHeader header;
|
2015-12-21 23:10:17 +00:00
|
|
|
Metadata metadata; // Used to hold version information.
|
2013-09-24 01:35:40 +00:00
|
|
|
MovieExtends extends;
|
|
|
|
std::vector<Track> tracks;
|
|
|
|
std::vector<ProtectionSystemSpecificHeader> pssh;
|
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct TrackFragmentDecodeTime : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(TrackFragmentDecodeTime);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint64_t decode_time = 0u;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct MovieFragmentHeader : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(MovieFragmentHeader);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint32_t sequence_number = 0u;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct TrackFragmentHeader : FullBox {
|
|
|
|
enum TrackFragmentFlagsMasks {
|
2018-05-24 22:47:56 +00:00
|
|
|
kBaseDataOffsetPresentMask = 0x000001,
|
|
|
|
kSampleDescriptionIndexPresentMask = 0x000002,
|
|
|
|
kDefaultSampleDurationPresentMask = 0x000008,
|
|
|
|
kDefaultSampleSizePresentMask = 0x000010,
|
|
|
|
kDefaultSampleFlagsPresentMask = 0x000020,
|
|
|
|
kDurationIsEmptyMask = 0x010000,
|
|
|
|
kDefaultBaseIsMoofMask = 0x020000,
|
2013-11-27 01:52:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum SampleFlagsMasks {
|
2023-12-01 17:32:19 +00:00
|
|
|
kUnset = 0x00000000,
|
2018-05-24 22:47:56 +00:00
|
|
|
kReservedMask = 0xFC000000,
|
|
|
|
kSampleDependsOnMask = 0x03000000,
|
|
|
|
kSampleIsDependedOnMask = 0x00C00000,
|
|
|
|
kSampleHasRedundancyMask = 0x00300000,
|
|
|
|
kSamplePaddingValueMask = 0x000E0000,
|
|
|
|
kNonKeySampleMask = 0x00010000,
|
2013-11-27 01:52:13 +00:00
|
|
|
kSampleDegradationPriorityMask = 0x0000FFFF,
|
|
|
|
};
|
|
|
|
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(TrackFragmentHeader);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
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;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct TrackFragmentRun : FullBox {
|
|
|
|
enum TrackFragmentFlagsMasks {
|
2018-05-24 22:47:56 +00:00
|
|
|
kDataOffsetPresentMask = 0x000001,
|
|
|
|
kFirstSampleFlagsPresentMask = 0x000004,
|
|
|
|
kSampleDurationPresentMask = 0x000100,
|
|
|
|
kSampleSizePresentMask = 0x000200,
|
|
|
|
kSampleFlagsPresentMask = 0x000400,
|
|
|
|
kSampleCompTimeOffsetsPresentMask = 0x000800,
|
2013-11-27 01:52:13 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(TrackFragmentRun);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint32_t sample_count = 0u;
|
|
|
|
uint32_t data_offset = 0u;
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint32_t> sample_flags;
|
|
|
|
std::vector<uint32_t> sample_sizes;
|
|
|
|
std::vector<uint32_t> sample_durations;
|
2015-08-04 21:11:15 +00:00
|
|
|
std::vector<int64_t> sample_composition_time_offsets;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct TrackFragment : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(TrackFragment);
|
|
|
|
|
|
|
|
TrackFragmentHeader header;
|
|
|
|
std::vector<TrackFragmentRun> runs;
|
2018-06-04 22:07:00 +00:00
|
|
|
bool decode_time_absent = false;
|
2013-09-24 01:35:40 +00:00
|
|
|
TrackFragmentDecodeTime decode_time;
|
2016-05-06 23:56:50 +00:00
|
|
|
std::vector<SampleGroupDescription> sample_group_descriptions;
|
|
|
|
std::vector<SampleToGroup> sample_to_groups;
|
2013-09-24 01:35:40 +00:00
|
|
|
SampleAuxiliaryInformationSize auxiliary_size;
|
2014-03-24 21:09:58 +00:00
|
|
|
SampleAuxiliaryInformationOffset auxiliary_offset;
|
2015-12-21 18:34:21 +00:00
|
|
|
SampleEncryption sample_encryption;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct MovieFragment : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(MovieFragment);
|
|
|
|
|
|
|
|
MovieFragmentHeader header;
|
|
|
|
std::vector<TrackFragment> tracks;
|
|
|
|
std::vector<ProtectionSystemSpecificHeader> pssh;
|
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct SegmentReference {
|
|
|
|
enum SAPType {
|
|
|
|
TypeUnknown = 0,
|
|
|
|
Type1 = 1, // T(ept) = T(dec) = T(sap) = T(ptf)
|
|
|
|
Type2 = 2, // T(ept) = T(dec) = T(sap) < T(ptf)
|
|
|
|
Type3 = 3, // T(ept) < T(dec) = T(sap) <= T(ptf)
|
|
|
|
Type4 = 4, // T(ept) <= T(ptf) < T(dec) = T(sap)
|
|
|
|
Type5 = 5, // T(ept) = T(dec) < T(sap)
|
|
|
|
Type6 = 6, // T(ept) < T(dec) < T(sap)
|
|
|
|
};
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
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;
|
2013-11-27 01:52:13 +00:00
|
|
|
// We add this field to keep track of earliest_presentation_time in this
|
|
|
|
// subsegment. It is not part of SegmentReference.
|
2018-06-04 22:07:00 +00:00
|
|
|
uint64_t earliest_presentation_time = 0u;
|
2013-11-27 01:52:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SegmentIndex : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(SegmentIndex);
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint32_t reference_id = 0u;
|
|
|
|
uint32_t timescale = 0u;
|
|
|
|
uint64_t earliest_presentation_time = 0u;
|
|
|
|
uint64_t first_offset = 0u;
|
2013-11-27 01:52:13 +00:00
|
|
|
std::vector<SegmentReference> references;
|
|
|
|
};
|
|
|
|
|
2015-12-15 00:07:51 +00:00
|
|
|
// The actual data is parsed and written separately.
|
|
|
|
struct MediaData : Box {
|
|
|
|
DECLARE_BOX_METHODS(MediaData);
|
2013-11-27 01:52:13 +00:00
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
uint32_t data_size = 0u;
|
2013-11-27 01:52:13 +00:00
|
|
|
};
|
|
|
|
|
2018-06-04 22:07:00 +00:00
|
|
|
// Using negative value as "not set". It is very unlikely that 2^31 cues happen
|
|
|
|
// at once.
|
|
|
|
const int kCueSourceIdNotSet = -1;
|
|
|
|
|
2015-11-23 23:12:04 +00:00
|
|
|
struct CueSourceIDBox : Box {
|
|
|
|
DECLARE_BOX_METHODS(CueSourceIDBox);
|
2018-06-04 22:07:00 +00:00
|
|
|
|
|
|
|
int32_t source_id = kCueSourceIdNotSet;
|
2015-11-23 23:12:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CueTimeBox : Box {
|
|
|
|
DECLARE_BOX_METHODS(CueTimeBox);
|
2018-06-04 22:07:00 +00:00
|
|
|
|
2015-11-23 23:12:04 +00:00
|
|
|
std::string cue_current_time;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CueIDBox : Box {
|
|
|
|
DECLARE_BOX_METHODS(CueIDBox);
|
2018-06-04 22:07:00 +00:00
|
|
|
|
2015-11-23 23:12:04 +00:00
|
|
|
std::string cue_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CueSettingsBox : Box {
|
|
|
|
DECLARE_BOX_METHODS(CueSettingsBox);
|
2018-06-04 22:07:00 +00:00
|
|
|
|
2015-11-23 23:12:04 +00:00
|
|
|
std::string settings;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CuePayloadBox : Box {
|
|
|
|
DECLARE_BOX_METHODS(CuePayloadBox);
|
2018-06-04 22:07:00 +00:00
|
|
|
|
2015-11-23 23:12:04 +00:00
|
|
|
std::string cue_text;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VTTEmptyCueBox : Box {
|
|
|
|
DECLARE_BOX_METHODS(VTTEmptyCueBox);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VTTAdditionalTextBox : Box {
|
|
|
|
DECLARE_BOX_METHODS(VTTAdditionalTextBox);
|
2018-06-04 22:07:00 +00:00
|
|
|
|
2015-11-23 23:12:04 +00:00
|
|
|
std::string cue_additional_text;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VTTCueBox : Box {
|
|
|
|
DECLARE_BOX_METHODS(VTTCueBox);
|
|
|
|
|
|
|
|
CueSourceIDBox cue_source_id;
|
|
|
|
CueIDBox cue_id;
|
|
|
|
CueTimeBox cue_time;
|
|
|
|
CueSettingsBox cue_settings;
|
|
|
|
CuePayloadBox cue_payload;
|
|
|
|
};
|
|
|
|
|
2013-09-24 01:35:40 +00:00
|
|
|
#undef DECLARE_BOX
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
|