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.
|
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#ifndef MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
|
|
|
|
#define MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/media/formats/mp4/aac_audio_specific_config.h"
|
|
|
|
#include "packager/media/formats/mp4/box.h"
|
|
|
|
#include "packager/media/formats/mp4/es_descriptor.h"
|
|
|
|
#include "packager/media/formats/mp4/fourccs.h"
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
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,
|
|
|
|
kHint
|
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
class BoxBuffer;
|
|
|
|
|
|
|
|
#define DECLARE_BOX_METHODS(T) \
|
|
|
|
T(); \
|
2015-07-22 23:40:45 +00:00
|
|
|
~T() override; \
|
|
|
|
bool ReadWrite(BoxBuffer* buffer) override; \
|
|
|
|
FourCC BoxType() const override; \
|
|
|
|
uint32_t ComputeSize() override;
|
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);
|
|
|
|
|
|
|
|
FourCC major_brand;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t minor_version;
|
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 {
|
|
|
|
DECLARE_BOX_METHODS(SegmentType);
|
|
|
|
};
|
|
|
|
|
|
|
|
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> system_id;
|
|
|
|
std::vector<uint8_t> data;
|
|
|
|
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);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t default_sample_info_size;
|
|
|
|
uint32_t sample_count;
|
|
|
|
std::vector<uint8_t> sample_info_sizes;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct OriginalFormat : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(OriginalFormat);
|
|
|
|
|
|
|
|
FourCC format;
|
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct SchemeType : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(SchemeType);
|
|
|
|
|
|
|
|
FourCC type;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t version;
|
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);
|
|
|
|
|
|
|
|
// Note: this definition is specific to the CENC protection type.
|
|
|
|
bool is_encrypted;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t default_iv_size;
|
|
|
|
std::vector<uint8_t> default_kid;
|
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);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
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;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct TrackHeader : FullBox {
|
|
|
|
enum TrackHeaderFlags {
|
|
|
|
kTrackEnabled = 0x000001,
|
|
|
|
kTrackInMovie = 0x000002,
|
|
|
|
kTrackInPreview = 0x000004,
|
|
|
|
};
|
|
|
|
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(TrackHeader);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
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;
|
2015-08-05 23:39:03 +00:00
|
|
|
// width and height specify the track's visual presentation size as
|
|
|
|
// fixed-point 16.16 values.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct EditListEntry {
|
2014-09-30 21:52:21 +00:00
|
|
|
uint64_t segment_duration;
|
|
|
|
int64_t media_time;
|
|
|
|
int16_t media_rate_integer;
|
|
|
|
int16_t media_rate_fraction;
|
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);
|
|
|
|
|
|
|
|
TrackType type;
|
|
|
|
};
|
|
|
|
|
2015-10-27 00:52:57 +00:00
|
|
|
struct CodecConfigurationRecord : Box {
|
|
|
|
DECLARE_BOX_METHODS(CodecConfigurationRecord);
|
2013-10-14 20:55:48 +00:00
|
|
|
|
2015-10-27 00:52:57 +00:00
|
|
|
FourCC box_type;
|
|
|
|
// 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
|
|
|
};
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
struct PixelAspectRatioBox : Box {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(PixelAspectRatioBox);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t h_spacing;
|
|
|
|
uint32_t v_spacing;
|
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);
|
2015-10-27 00:52:57 +00:00
|
|
|
// Returns actual format of this sample entry.
|
|
|
|
FourCC GetActualFormat() const {
|
|
|
|
return format == FOURCC_ENCV ? sinf.format.format : format;
|
|
|
|
}
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
FourCC format;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint16_t data_reference_index;
|
|
|
|
uint16_t width;
|
|
|
|
uint16_t height;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
PixelAspectRatioBox pixel_aspect;
|
|
|
|
ProtectionSchemeInfo sinf;
|
2015-10-27 00:52:57 +00:00
|
|
|
CodecConfigurationRecord codec_config_record;
|
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-07 19:56:07 +00:00
|
|
|
struct DTSSpecificBox : Box {
|
|
|
|
DECLARE_BOX_METHODS(DTSSpecificBox);
|
|
|
|
|
|
|
|
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);
|
2015-10-27 00:52:57 +00:00
|
|
|
// Returns actual format of this sample entry.
|
|
|
|
FourCC GetActualFormat() const {
|
|
|
|
return format == FOURCC_ENCA ? sinf.format.format : format;
|
|
|
|
}
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
FourCC format;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint16_t data_reference_index;
|
|
|
|
uint16_t channelcount;
|
|
|
|
uint16_t samplesize;
|
|
|
|
uint32_t samplerate;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
ProtectionSchemeInfo sinf;
|
|
|
|
ElementaryStreamDescriptor esds;
|
2015-12-07 19:56:07 +00:00
|
|
|
DTSSpecificBox ddts;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct SampleDescription : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(SampleDescription);
|
|
|
|
|
|
|
|
TrackType type;
|
|
|
|
std::vector<VideoSampleEntry> video_entries;
|
|
|
|
std::vector<AudioSampleEntry> audio_entries;
|
|
|
|
};
|
|
|
|
|
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);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t sample_size;
|
|
|
|
uint32_t sample_count;
|
|
|
|
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
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t field_size;
|
|
|
|
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
|
|
|
};
|
|
|
|
|
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;
|
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);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint64_t creation_time;
|
|
|
|
uint64_t modification_time;
|
|
|
|
uint32_t timescale;
|
|
|
|
uint64_t duration;
|
2013-10-14 20:55:48 +00:00
|
|
|
// 3-char language code + 1 null terminating char.
|
|
|
|
char language[4];
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct VideoMediaHeader : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(VideoMediaHeader);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint16_t graphicsmode;
|
|
|
|
uint16_t opcolor_red;
|
|
|
|
uint16_t opcolor_green;
|
|
|
|
uint16_t opcolor_blue;
|
2013-11-27 01:52:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SoundMediaHeader : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(SoundMediaHeader);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint16_t balance;
|
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);
|
|
|
|
|
|
|
|
// data entry can be either url or urn box. Fix to url box for now.
|
|
|
|
std::vector<DataEntryUrl> data_entry;
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
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;
|
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct MovieExtendsHeader : FullBox {
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(MovieExtendsHeader);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint64_t fragment_duration;
|
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);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
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;
|
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;
|
|
|
|
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);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint64_t decode_time;
|
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);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t sequence_number;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct TrackFragmentHeader : FullBox {
|
|
|
|
enum TrackFragmentFlagsMasks {
|
2015-01-31 01:03:38 +00:00
|
|
|
kBaseDataOffsetPresentMask = 0x000001,
|
2013-11-27 01:52:13 +00:00
|
|
|
kSampleDescriptionIndexPresentMask = 0x000002,
|
|
|
|
kDefaultSampleDurationPresentMask = 0x000008,
|
|
|
|
kDefaultSampleSizePresentMask = 0x000010,
|
|
|
|
kDefaultSampleFlagsPresentMask = 0x000020,
|
|
|
|
kDurationIsEmptyMask = 0x010000,
|
|
|
|
kDefaultBaseIsMoofMask = 0x020000,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SampleFlagsMasks {
|
|
|
|
kReservedMask = 0xFC000000,
|
|
|
|
kSampleDependsOnMask = 0x03000000,
|
|
|
|
kSampleIsDependedOnMask = 0x00C00000,
|
|
|
|
kSampleHasRedundancyMask = 0x00300000,
|
|
|
|
kSamplePaddingValueMask = 0x000E0000,
|
|
|
|
kNonKeySampleMask = 0x00010000,
|
|
|
|
kSampleDegradationPriorityMask = 0x0000FFFF,
|
|
|
|
};
|
|
|
|
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(TrackFragmentHeader);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t track_id;
|
|
|
|
uint32_t sample_description_index;
|
|
|
|
uint32_t default_sample_duration;
|
|
|
|
uint32_t default_sample_size;
|
|
|
|
uint32_t default_sample_flags;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2013-11-27 01:52:13 +00:00
|
|
|
struct TrackFragmentRun : FullBox {
|
|
|
|
enum TrackFragmentFlagsMasks {
|
|
|
|
kDataOffsetPresentMask = 0x000001,
|
|
|
|
kFirstSampleFlagsPresentMask = 0x000004,
|
|
|
|
kSampleDurationPresentMask = 0x000100,
|
|
|
|
kSampleSizePresentMask = 0x000200,
|
|
|
|
kSampleFlagsPresentMask = 0x000400,
|
|
|
|
kSampleCompTimeOffsetsPresentMask = 0x000800,
|
|
|
|
};
|
|
|
|
|
2013-09-24 01:35:40 +00:00
|
|
|
DECLARE_BOX_METHODS(TrackFragmentRun);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t sample_count;
|
|
|
|
uint32_t data_offset;
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2014-03-24 21:09:58 +00:00
|
|
|
struct SampleToGroupEntry {
|
|
|
|
enum GroupDescriptionIndexBase {
|
|
|
|
kTrackGroupDescriptionIndexBase = 0,
|
|
|
|
kTrackFragmentGroupDescriptionIndexBase = 0x10000,
|
|
|
|
};
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t sample_count;
|
|
|
|
uint32_t group_description_index;
|
2014-03-24 21:09:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SampleToGroup : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(SampleToGroup);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t grouping_type;
|
|
|
|
uint32_t grouping_type_parameter; // Version 1 only.
|
2014-03-24 21:09:58 +00:00
|
|
|
std::vector<SampleToGroupEntry> entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CencSampleEncryptionInfoEntry {
|
|
|
|
CencSampleEncryptionInfoEntry();
|
|
|
|
~CencSampleEncryptionInfoEntry();
|
|
|
|
|
|
|
|
bool is_encrypted;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t iv_size;
|
|
|
|
std::vector<uint8_t> key_id;
|
2014-03-24 21:09:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SampleGroupDescription : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(SampleGroupDescription);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t grouping_type;
|
2014-03-24 21:09:58 +00:00
|
|
|
std::vector<CencSampleEncryptionInfoEntry> entries;
|
|
|
|
};
|
|
|
|
|
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;
|
2015-01-31 01:03:38 +00:00
|
|
|
bool decode_time_absent;
|
2013-09-24 01:35:40 +00:00
|
|
|
TrackFragmentDecodeTime decode_time;
|
2014-03-24 21:09:58 +00:00
|
|
|
SampleToGroup sample_to_group;
|
|
|
|
SampleGroupDescription sample_group_description;
|
2013-09-24 01:35:40 +00:00
|
|
|
SampleAuxiliaryInformationSize auxiliary_size;
|
2014-03-24 21:09:58 +00:00
|
|
|
SampleAuxiliaryInformationOffset auxiliary_offset;
|
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)
|
|
|
|
};
|
|
|
|
|
|
|
|
bool reference_type;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t referenced_size;
|
|
|
|
uint32_t subsegment_duration;
|
2013-11-27 01:52:13 +00:00
|
|
|
bool starts_with_sap;
|
|
|
|
SAPType sap_type;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t sap_delta_time;
|
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.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint64_t earliest_presentation_time;
|
2013-11-27 01:52:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SegmentIndex : FullBox {
|
|
|
|
DECLARE_BOX_METHODS(SegmentIndex);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t reference_id;
|
|
|
|
uint32_t timescale;
|
|
|
|
uint64_t earliest_presentation_time;
|
|
|
|
uint64_t first_offset;
|
2013-11-27 01:52:13 +00:00
|
|
|
std::vector<SegmentReference> references;
|
|
|
|
};
|
|
|
|
|
|
|
|
// The actual data is parsed and written separately, so we do not inherit it
|
|
|
|
// from Box.
|
|
|
|
struct MediaData {
|
|
|
|
MediaData();
|
|
|
|
~MediaData();
|
|
|
|
void Write(BufferWriter* buffer_writer);
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t ComputeSize();
|
2013-11-27 01:52:13 +00:00
|
|
|
FourCC BoxType() const;
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t data_size;
|
2013-11-27 01:52:13 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 01:35:40 +00:00
|
|
|
#undef DECLARE_BOX
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
} // namespace media
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#endif // MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
|