5 #ifndef PACKAGER_MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_ 6 #define PACKAGER_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;
86 bool ReadWrite(uint8_t iv_size,
95 bool ParseFromBuffer(uint8_t iv_size,
102 uint32_t GetTotalSizeOfSubsamples()
const;
104 std::vector<uint8_t> initialization_vector;
105 std::vector<SubsampleEntry> subsamples;
109 enum SampleEncryptionFlags {
110 kUseSubsampleEncryption = 2,
119 bool ParseFromSampleEncryptionData(
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);
242 DECLARE_BOX_METHODS(
ID3v2);
245 std::vector<uint8_t> id3v2_data;
267 std::vector<uint8_t> data;
280 FourCC GetActualFormat()
const {
281 return format == FOURCC_encv ? sinf.format.format : format;
284 FourCC GetCodecConfigurationBoxType(FourCC format)
const;
287 uint16_t data_reference_index;
306 uint32_t sampling_frequency;
307 uint32_t max_bitrate;
308 uint32_t avg_bitrate;
309 uint8_t pcm_sample_depth;
310 std::vector<uint8_t> extra_data;
316 std::vector<uint8_t> data;
322 std::vector<uint8_t> data;
328 std::vector<uint8_t> opus_identification_header;
339 std::vector<uint8_t> data;
345 FourCC GetActualFormat()
const {
346 return format == FOURCC_enca ? sinf.format.format : format;
350 uint16_t data_reference_index;
351 uint16_t channelcount;
372 std::string source_label;
382 uint16_t data_reference_index;
396 std::vector<VideoSampleEntry> video_entries;
397 std::vector<AudioSampleEntry> audio_entries;
398 std::vector<TextSampleEntry> text_entries;
402 uint32_t sample_count;
403 uint32_t sample_delta;
410 std::vector<DecodingTime> decoding_time;
414 uint32_t sample_count;
418 int64_t sample_offset;
425 std::vector<CompositionOffset> composition_offset;
429 uint32_t first_chunk;
430 uint32_t samples_per_chunk;
431 uint32_t sample_description_index;
438 std::vector<ChunkInfo> chunk_info;
445 uint32_t sample_size;
446 uint32_t sample_count;
447 std::vector<uint32_t> sizes;
455 std::vector<uint32_t> sizes;
462 std::vector<uint64_t> offsets;
474 std::vector<uint32_t> sample_number;
484 uint8_t is_protected;
485 uint8_t per_sample_iv_size;
486 std::vector<uint8_t> key_id;
489 uint8_t crypt_byte_block;
490 uint8_t skip_byte_block;
493 std::vector<uint8_t> constant_iv;
503 int16_t roll_distance;
509 template <
typename T>
510 bool ReadWriteEntries(
BoxBuffer* buffer, std::vector<T>* entries);
512 uint32_t grouping_type;
514 std::vector<CencSampleEncryptionInfoEntry>
515 cenc_sample_encryption_info_entries;
517 std::vector<AudioRollRecoveryEntry> audio_roll_recovery_entries;
521 enum GroupDescriptionIndexBase {
522 kTrackGroupDescriptionIndexBase = 0,
523 kTrackFragmentGroupDescriptionIndexBase = 0x10000,
526 uint32_t sample_count;
527 uint32_t group_description_index;
533 uint32_t grouping_type;
534 uint32_t grouping_type_parameter;
535 std::vector<SampleToGroupEntry> entries;
551 std::vector<SampleGroupDescription> sample_group_descriptions;
552 std::vector<SampleToGroup> sample_to_groups;
558 uint64_t creation_time;
559 uint64_t modification_time;
568 uint16_t graphicsmode;
569 uint16_t opcolor_red;
570 uint16_t opcolor_green;
571 uint16_t opcolor_blue;
587 std::vector<uint8_t> location;
594 std::vector<DataEntryUrl> data_entry;
615 DECLARE_BOX_METHODS(
Media);
623 DECLARE_BOX_METHODS(
Track);
634 uint64_t fragment_duration;
641 uint32_t default_sample_description_index;
642 uint32_t default_sample_duration;
643 uint32_t default_sample_size;
644 uint32_t default_sample_flags;
651 std::vector<TrackExtends> tracks;
655 DECLARE_BOX_METHODS(
Movie);
660 std::vector<Track> tracks;
661 std::vector<ProtectionSystemSpecificHeader> pssh;
667 uint64_t decode_time;
673 uint32_t sequence_number;
677 enum TrackFragmentFlagsMasks {
678 kBaseDataOffsetPresentMask = 0x000001,
679 kSampleDescriptionIndexPresentMask = 0x000002,
680 kDefaultSampleDurationPresentMask = 0x000008,
681 kDefaultSampleSizePresentMask = 0x000010,
682 kDefaultSampleFlagsPresentMask = 0x000020,
683 kDurationIsEmptyMask = 0x010000,
684 kDefaultBaseIsMoofMask = 0x020000,
687 enum SampleFlagsMasks {
688 kReservedMask = 0xFC000000,
689 kSampleDependsOnMask = 0x03000000,
690 kSampleIsDependedOnMask = 0x00C00000,
691 kSampleHasRedundancyMask = 0x00300000,
692 kSamplePaddingValueMask = 0x000E0000,
693 kNonKeySampleMask = 0x00010000,
694 kSampleDegradationPriorityMask = 0x0000FFFF,
700 uint32_t sample_description_index;
701 uint32_t default_sample_duration;
702 uint32_t default_sample_size;
703 uint32_t default_sample_flags;
707 enum TrackFragmentFlagsMasks {
708 kDataOffsetPresentMask = 0x000001,
709 kFirstSampleFlagsPresentMask = 0x000004,
710 kSampleDurationPresentMask = 0x000100,
711 kSampleSizePresentMask = 0x000200,
712 kSampleFlagsPresentMask = 0x000400,
713 kSampleCompTimeOffsetsPresentMask = 0x000800,
718 uint32_t sample_count;
719 uint32_t data_offset;
720 std::vector<uint32_t> sample_flags;
721 std::vector<uint32_t> sample_sizes;
722 std::vector<uint32_t> sample_durations;
723 std::vector<int64_t> sample_composition_time_offsets;
730 std::vector<TrackFragmentRun> runs;
731 bool decode_time_absent;
733 std::vector<SampleGroupDescription> sample_group_descriptions;
734 std::vector<SampleToGroup> sample_to_groups;
744 std::vector<TrackFragment> tracks;
745 std::vector<ProtectionSystemSpecificHeader> pssh;
760 uint32_t referenced_size;
761 uint32_t subsegment_duration;
762 bool starts_with_sap;
764 uint32_t sap_delta_time;
767 uint64_t earliest_presentation_time;
773 uint32_t reference_id;
775 uint64_t earliest_presentation_time;
776 uint64_t first_offset;
777 std::vector<SegmentReference> references;
794 std::string cue_current_time;
804 std::string settings;
809 std::string cue_text;
818 std::string cue_additional_text;
837 #endif // PACKAGER_MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
All the methods that are virtual are virtual for mocking.