5 #ifndef MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
6 #define MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
10 #include "packager/media/base/decrypt_config.h"
11 #include "packager/media/base/fourccs.h"
12 #include "packager/media/formats/mp4/aac_audio_specific_config.h"
13 #include "packager/media/formats/mp4/box.h"
14 #include "packager/media/formats/mp4/es_descriptor.h"
16 namespace edash_packager {
33 #define DECLARE_BOX_METHODS(T) \
37 FourCC BoxType() const override; \
40 bool ReadWriteInternal(BoxBuffer* buffer) override; \
41 uint32_t ComputeSizeInternal() override; \
49 uint32_t minor_version;
50 std::vector<FourCC> compatible_brands;
54 FourCC
BoxType()
const override;
60 std::vector<uint8_t> raw_box;
66 std::vector<uint64_t> offsets;
72 uint8_t default_sample_info_size;
73 uint32_t sample_count;
74 std::vector<uint8_t> sample_info_sizes;
104 std::vector<uint8_t> initialization_vector;
105 std::vector<SubsampleEntry> subsamples;
109 enum SampleEncryptionFlags {
110 kUseSubsampleEncryption = 2,
121 std::vector<SampleEncryptionEntry>* sample_encryption_entries)
const;
128 std::vector<SampleEncryptionEntry> sample_encryption_entries;
147 uint8_t default_is_protected;
148 uint8_t default_per_sample_iv_size;
149 std::vector<uint8_t> default_kid;
152 uint8_t default_crypt_byte_block;
153 uint8_t default_skip_byte_block;
157 std::vector<uint8_t> default_constant_iv;
177 uint64_t creation_time;
178 uint64_t modification_time;
183 uint32_t next_track_id;
187 enum TrackHeaderFlags {
188 kTrackEnabled = 0x000001,
189 kTrackInMovie = 0x000002,
190 kTrackInPreview = 0x000004,
195 uint64_t creation_time;
196 uint64_t modification_time;
200 int16_t alternate_group;
209 uint64_t segment_duration;
211 int16_t media_rate_integer;
212 int16_t media_rate_fraction;
218 std::vector<EditListEntry> edits;
222 DECLARE_BOX_METHODS(
Edit);
235 uint32_t ComputeSize()
const;
243 uint32_t ComputeSize()
const;
252 DECLARE_BOX_METHODS(
ID3v2);
273 std::vector<uint8_t> data;
286 FourCC GetActualFormat()
const {
287 return format == FOURCC_encv ? sinf.format.format : format;
291 uint16_t data_reference_index;
310 uint32_t sampling_frequency;
311 uint32_t max_bitrate;
312 uint32_t avg_bitrate;
313 uint8_t pcm_sample_depth;
314 std::vector<uint8_t> extra_data;
320 std::vector<uint8_t> data;
326 std::vector<uint8_t> data;
332 std::vector<uint8_t> opus_identification_header;
340 FourCC GetActualFormat()
const {
341 return format == FOURCC_enca ? sinf.format.format : format;
345 uint16_t data_reference_index;
346 uint16_t channelcount;
366 std::string source_label;
376 uint16_t data_reference_index;
390 std::vector<VideoSampleEntry> video_entries;
391 std::vector<AudioSampleEntry> audio_entries;
392 std::vector<TextSampleEntry> text_entries;
396 uint32_t sample_count;
397 uint32_t sample_delta;
404 std::vector<DecodingTime> decoding_time;
408 uint32_t sample_count;
412 int64_t sample_offset;
419 std::vector<CompositionOffset> composition_offset;
423 uint32_t first_chunk;
424 uint32_t samples_per_chunk;
425 uint32_t sample_description_index;
432 std::vector<ChunkInfo> chunk_info;
439 uint32_t sample_size;
440 uint32_t sample_count;
441 std::vector<uint32_t> sizes;
449 std::vector<uint32_t> sizes;
456 std::vector<uint64_t> offsets;
468 std::vector<uint32_t> sample_number;
476 uint32_t ComputeSize()
const;
478 uint8_t is_protected;
479 uint8_t per_sample_iv_size;
480 std::vector<uint8_t> key_id;
483 uint8_t crypt_byte_block;
484 uint8_t skip_byte_block;
487 std::vector<uint8_t> constant_iv;
495 uint32_t ComputeSize()
const;
497 int16_t roll_distance;
503 template <
typename T>
504 bool ReadWriteEntries(
BoxBuffer* buffer, std::vector<T>* entries);
506 uint32_t grouping_type;
508 std::vector<CencSampleEncryptionInfoEntry>
509 cenc_sample_encryption_info_entries;
511 std::vector<AudioRollRecoveryEntry> audio_roll_recovery_entries;
515 enum GroupDescriptionIndexBase {
516 kTrackGroupDescriptionIndexBase = 0,
517 kTrackFragmentGroupDescriptionIndexBase = 0x10000,
520 uint32_t sample_count;
521 uint32_t group_description_index;
527 uint32_t grouping_type;
528 uint32_t grouping_type_parameter;
529 std::vector<SampleToGroupEntry> entries;
545 std::vector<SampleGroupDescription> sample_group_descriptions;
546 std::vector<SampleToGroup> sample_to_groups;
552 uint64_t creation_time;
553 uint64_t modification_time;
562 uint16_t graphicsmode;
563 uint16_t opcolor_red;
564 uint16_t opcolor_green;
565 uint16_t opcolor_blue;
581 std::vector<uint8_t> location;
588 std::vector<DataEntryUrl> data_entry;
609 DECLARE_BOX_METHODS(
Media);
617 DECLARE_BOX_METHODS(
Track);
628 uint64_t fragment_duration;
635 uint32_t default_sample_description_index;
636 uint32_t default_sample_duration;
637 uint32_t default_sample_size;
638 uint32_t default_sample_flags;
645 std::vector<TrackExtends> tracks;
649 DECLARE_BOX_METHODS(
Movie);
654 std::vector<Track> tracks;
655 std::vector<ProtectionSystemSpecificHeader> pssh;
661 uint64_t decode_time;
667 uint32_t sequence_number;
671 enum TrackFragmentFlagsMasks {
672 kBaseDataOffsetPresentMask = 0x000001,
673 kSampleDescriptionIndexPresentMask = 0x000002,
674 kDefaultSampleDurationPresentMask = 0x000008,
675 kDefaultSampleSizePresentMask = 0x000010,
676 kDefaultSampleFlagsPresentMask = 0x000020,
677 kDurationIsEmptyMask = 0x010000,
678 kDefaultBaseIsMoofMask = 0x020000,
681 enum SampleFlagsMasks {
682 kReservedMask = 0xFC000000,
683 kSampleDependsOnMask = 0x03000000,
684 kSampleIsDependedOnMask = 0x00C00000,
685 kSampleHasRedundancyMask = 0x00300000,
686 kSamplePaddingValueMask = 0x000E0000,
687 kNonKeySampleMask = 0x00010000,
688 kSampleDegradationPriorityMask = 0x0000FFFF,
694 uint32_t sample_description_index;
695 uint32_t default_sample_duration;
696 uint32_t default_sample_size;
697 uint32_t default_sample_flags;
701 enum TrackFragmentFlagsMasks {
702 kDataOffsetPresentMask = 0x000001,
703 kFirstSampleFlagsPresentMask = 0x000004,
704 kSampleDurationPresentMask = 0x000100,
705 kSampleSizePresentMask = 0x000200,
706 kSampleFlagsPresentMask = 0x000400,
707 kSampleCompTimeOffsetsPresentMask = 0x000800,
712 uint32_t sample_count;
713 uint32_t data_offset;
714 std::vector<uint32_t> sample_flags;
715 std::vector<uint32_t> sample_sizes;
716 std::vector<uint32_t> sample_durations;
717 std::vector<int64_t> sample_composition_time_offsets;
724 std::vector<TrackFragmentRun> runs;
725 bool decode_time_absent;
727 std::vector<SampleGroupDescription> sample_group_descriptions;
728 std::vector<SampleToGroup> sample_to_groups;
738 std::vector<TrackFragment> tracks;
739 std::vector<ProtectionSystemSpecificHeader> pssh;
754 uint32_t referenced_size;
755 uint32_t subsegment_duration;
756 bool starts_with_sap;
758 uint32_t sap_delta_time;
761 uint64_t earliest_presentation_time;
767 uint32_t reference_id;
769 uint64_t earliest_presentation_time;
770 uint64_t first_offset;
771 std::vector<SegmentReference> references;
788 std::string cue_current_time;
798 std::string settings;
803 std::string cue_text;
812 std::string cue_additional_text;
831 #endif // MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
uint32_t ComputeSize() const
bool ParseFromBuffer(uint8_t iv_size, bool has_subsamples, BufferReader *reader)
bool ReadWrite(uint8_t iv_size, bool has_subsamples, BoxBuffer *buffer)
uint32_t GetTotalSizeOfSubsamples() const