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/codecs/aac_audio_specific_config.h"
13 #include "packager/media/codecs/es_descriptor.h"
14 #include "packager/media/formats/mp4/box.h"
33 #define DECLARE_BOX_METHODS(T) \
37 FourCC BoxType() const override; \
40 bool ReadWriteInternal(BoxBuffer* buffer) override; \
41 size_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);
279 std::vector<uint8_t> data;
292 FourCC GetActualFormat()
const {
293 return format == FOURCC_encv ? sinf.format.format : format;
296 FourCC GetCodecConfigurationBoxType(FourCC format)
const;
299 uint16_t data_reference_index;
318 uint32_t sampling_frequency;
319 uint32_t max_bitrate;
320 uint32_t avg_bitrate;
321 uint8_t pcm_sample_depth;
322 std::vector<uint8_t> extra_data;
328 std::vector<uint8_t> data;
334 std::vector<uint8_t> data;
340 std::vector<uint8_t> opus_identification_header;
348 FourCC GetActualFormat()
const {
349 return format == FOURCC_enca ? sinf.format.format : format;
353 uint16_t data_reference_index;
354 uint16_t channelcount;
374 std::string source_label;
384 uint16_t data_reference_index;
398 std::vector<VideoSampleEntry> video_entries;
399 std::vector<AudioSampleEntry> audio_entries;
400 std::vector<TextSampleEntry> text_entries;
404 uint32_t sample_count;
405 uint32_t sample_delta;
412 std::vector<DecodingTime> decoding_time;
416 uint32_t sample_count;
420 int64_t sample_offset;
427 std::vector<CompositionOffset> composition_offset;
431 uint32_t first_chunk;
432 uint32_t samples_per_chunk;
433 uint32_t sample_description_index;
440 std::vector<ChunkInfo> chunk_info;
447 uint32_t sample_size;
448 uint32_t sample_count;
449 std::vector<uint32_t> sizes;
457 std::vector<uint32_t> sizes;
464 std::vector<uint64_t> offsets;
476 std::vector<uint32_t> sample_number;
484 uint32_t ComputeSize()
const;
486 uint8_t is_protected;
487 uint8_t per_sample_iv_size;
488 std::vector<uint8_t> key_id;
491 uint8_t crypt_byte_block;
492 uint8_t skip_byte_block;
495 std::vector<uint8_t> constant_iv;
503 uint32_t ComputeSize()
const;
505 int16_t roll_distance;
511 template <
typename T>
512 bool ReadWriteEntries(
BoxBuffer* buffer, std::vector<T>* entries);
514 uint32_t grouping_type;
516 std::vector<CencSampleEncryptionInfoEntry>
517 cenc_sample_encryption_info_entries;
519 std::vector<AudioRollRecoveryEntry> audio_roll_recovery_entries;
523 enum GroupDescriptionIndexBase {
524 kTrackGroupDescriptionIndexBase = 0,
525 kTrackFragmentGroupDescriptionIndexBase = 0x10000,
528 uint32_t sample_count;
529 uint32_t group_description_index;
535 uint32_t grouping_type;
536 uint32_t grouping_type_parameter;
537 std::vector<SampleToGroupEntry> entries;
553 std::vector<SampleGroupDescription> sample_group_descriptions;
554 std::vector<SampleToGroup> sample_to_groups;
560 uint64_t creation_time;
561 uint64_t modification_time;
570 uint16_t graphicsmode;
571 uint16_t opcolor_red;
572 uint16_t opcolor_green;
573 uint16_t opcolor_blue;
589 std::vector<uint8_t> location;
596 std::vector<DataEntryUrl> data_entry;
617 DECLARE_BOX_METHODS(
Media);
625 DECLARE_BOX_METHODS(
Track);
636 uint64_t fragment_duration;
643 uint32_t default_sample_description_index;
644 uint32_t default_sample_duration;
645 uint32_t default_sample_size;
646 uint32_t default_sample_flags;
653 std::vector<TrackExtends> tracks;
657 DECLARE_BOX_METHODS(
Movie);
662 std::vector<Track> tracks;
663 std::vector<ProtectionSystemSpecificHeader> pssh;
669 uint64_t decode_time;
675 uint32_t sequence_number;
679 enum TrackFragmentFlagsMasks {
680 kBaseDataOffsetPresentMask = 0x000001,
681 kSampleDescriptionIndexPresentMask = 0x000002,
682 kDefaultSampleDurationPresentMask = 0x000008,
683 kDefaultSampleSizePresentMask = 0x000010,
684 kDefaultSampleFlagsPresentMask = 0x000020,
685 kDurationIsEmptyMask = 0x010000,
686 kDefaultBaseIsMoofMask = 0x020000,
689 enum SampleFlagsMasks {
690 kReservedMask = 0xFC000000,
691 kSampleDependsOnMask = 0x03000000,
692 kSampleIsDependedOnMask = 0x00C00000,
693 kSampleHasRedundancyMask = 0x00300000,
694 kSamplePaddingValueMask = 0x000E0000,
695 kNonKeySampleMask = 0x00010000,
696 kSampleDegradationPriorityMask = 0x0000FFFF,
702 uint32_t sample_description_index;
703 uint32_t default_sample_duration;
704 uint32_t default_sample_size;
705 uint32_t default_sample_flags;
709 enum TrackFragmentFlagsMasks {
710 kDataOffsetPresentMask = 0x000001,
711 kFirstSampleFlagsPresentMask = 0x000004,
712 kSampleDurationPresentMask = 0x000100,
713 kSampleSizePresentMask = 0x000200,
714 kSampleFlagsPresentMask = 0x000400,
715 kSampleCompTimeOffsetsPresentMask = 0x000800,
720 uint32_t sample_count;
721 uint32_t data_offset;
722 std::vector<uint32_t> sample_flags;
723 std::vector<uint32_t> sample_sizes;
724 std::vector<uint32_t> sample_durations;
725 std::vector<int64_t> sample_composition_time_offsets;
732 std::vector<TrackFragmentRun> runs;
733 bool decode_time_absent;
735 std::vector<SampleGroupDescription> sample_group_descriptions;
736 std::vector<SampleToGroup> sample_to_groups;
746 std::vector<TrackFragment> tracks;
747 std::vector<ProtectionSystemSpecificHeader> pssh;
762 uint32_t referenced_size;
763 uint32_t subsegment_duration;
764 bool starts_with_sap;
766 uint32_t sap_delta_time;
769 uint64_t earliest_presentation_time;
775 uint32_t reference_id;
777 uint64_t earliest_presentation_time;
778 uint64_t first_offset;
779 std::vector<SegmentReference> references;
796 std::string cue_current_time;
806 std::string settings;
811 std::string cue_text;
820 std::string cue_additional_text;
839 #endif // MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
bool ParseFromBuffer(uint8_t iv_size, bool has_subsamples, BufferReader *reader)
uint32_t GetTotalSizeOfSubsamples() const
bool ReadWrite(uint8_t iv_size, bool has_subsamples, BoxBuffer *buffer)
uint32_t ComputeSize() const