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) \ 38 FourCC BoxType() const override; \ 41 bool ReadWriteInternal(BoxBuffer* buffer) override; \ 42 size_t ComputeSizeInternal() override; \ 49 FourCC major_brand = FOURCC_NULL;
50 uint32_t minor_version = 0;
51 std::vector<FourCC> compatible_brands;
55 FourCC
BoxType()
const override;
61 std::vector<uint8_t> raw_box;
67 std::vector<uint64_t> offsets;
73 uint8_t default_sample_info_size = 0;
74 uint32_t sample_count = 0;
75 std::vector<uint8_t> sample_info_sizes;
85 bool ReadWrite(uint8_t iv_size,
bool has_subsamples,
BoxBuffer* buffer);
92 bool ParseFromBuffer(uint8_t iv_size,
99 uint32_t GetTotalSizeOfSubsamples()
const;
101 std::vector<uint8_t> initialization_vector;
102 std::vector<SubsampleEntry> subsamples;
106 static const uint8_t kInvalidIvSize = 1;
108 enum SampleEncryptionFlags {
109 kUseSubsampleEncryption = 2,
118 bool ParseFromSampleEncryptionData(
120 std::vector<SampleEncryptionEntry>* sample_encryption_entries)
const;
126 uint8_t iv_size = kInvalidIvSize;
127 std::vector<SampleEncryptionEntry> sample_encryption_entries;
133 FourCC format = FOURCC_NULL;
139 FourCC type = FOURCC_NULL;
140 uint32_t version = 0u;
146 uint8_t default_is_protected = 0;
147 uint8_t default_per_sample_iv_size = 0;
149 std::vector<uint8_t> default_kid = std::vector<uint8_t>(16, 0);
152 uint8_t default_crypt_byte_block = 0;
153 uint8_t default_skip_byte_block = 0;
157 std::vector<uint8_t> default_constant_iv;
177 uint64_t creation_time = 0;
178 uint64_t modification_time = 0;
179 uint32_t timescale = 0;
180 uint64_t duration = 0;
181 int32_t rate = 1 << 16;
182 int16_t volume = 1 << 8;
183 uint32_t next_track_id = 0;
187 enum TrackHeaderFlags {
188 kTrackEnabled = 0x000001,
189 kTrackInMovie = 0x000002,
190 kTrackInPreview = 0x000004,
195 uint64_t creation_time = 0;
196 uint64_t modification_time = 0;
197 uint32_t track_id = 0;
198 uint64_t duration = 0;
200 int16_t alternate_group = 0;
209 uint64_t segment_duration = 0;
210 int64_t media_time = 0;
211 int16_t media_rate_integer = 0;
212 int16_t media_rate_fraction = 0;
218 std::vector<EditListEntry> edits;
222 DECLARE_BOX_METHODS(
Edit);
230 FourCC handler_type = FOURCC_NULL;
242 DECLARE_BOX_METHODS(
ID3v2);
245 std::vector<uint8_t> id3v2_data;
264 FourCC box_type = FOURCC_NULL;
267 std::vector<uint8_t> data;
273 uint32_t h_spacing = 0u;
274 uint32_t v_spacing = 0u;
281 FourCC GetActualFormat()
const {
282 return format == FOURCC_encv ? sinf.format.format : format;
285 FourCC GetCodecConfigurationBoxType(FourCC format)
const;
288 std::vector<uint8_t> ExtraCodecConfigsAsVector()
const;
290 bool ParseExtraCodecConfigsVector(
const std::vector<uint8_t>& data);
292 FourCC format = FOURCC_NULL;
295 uint16_t data_reference_index = 1u;
297 uint16_t height = 0u;
304 std::vector<CodecConfiguration> extra_codec_configs;
317 uint32_t sampling_frequency = 0u;
318 uint32_t max_bitrate = 0u;
319 uint32_t avg_bitrate = 0u;
320 uint8_t pcm_sample_depth = 0u;
321 std::vector<uint8_t> extra_data;
327 std::vector<uint8_t> data;
333 std::vector<uint8_t> data;
339 std::vector<uint8_t> opus_identification_header;
341 uint16_t preskip = 0u;
350 std::vector<uint8_t> data;
357 FourCC GetActualFormat()
const {
358 return format == FOURCC_enca ? sinf.format.format : format;
361 FourCC format = FOURCC_NULL;
364 uint16_t data_reference_index = 1u;
365 uint16_t channelcount = 2u;
366 uint16_t samplesize = 16u;
367 uint32_t samplerate = 0u;
388 std::string source_label;
397 FourCC format = FOURCC_NULL;
401 uint16_t data_reference_index = 1u;
412 TrackType type = kInvalid;
415 std::vector<VideoSampleEntry> video_entries;
416 std::vector<AudioSampleEntry> audio_entries;
417 std::vector<TextSampleEntry> text_entries;
421 uint32_t sample_count;
422 uint32_t sample_delta;
429 std::vector<DecodingTime> decoding_time;
433 uint32_t sample_count;
437 int64_t sample_offset;
444 std::vector<CompositionOffset> composition_offset;
448 uint32_t first_chunk;
449 uint32_t samples_per_chunk;
450 uint32_t sample_description_index;
457 std::vector<ChunkInfo> chunk_info;
464 uint32_t sample_size = 0u;
465 uint32_t sample_count = 0u;
466 std::vector<uint32_t> sizes;
473 uint8_t field_size = 0u;
474 std::vector<uint32_t> sizes;
481 std::vector<uint64_t> offsets;
493 std::vector<uint32_t> sample_number;
500 uint8_t is_protected = 0u;
501 uint8_t per_sample_iv_size = 0u;
502 std::vector<uint8_t> key_id;
505 uint8_t crypt_byte_block = 0u;
506 uint8_t skip_byte_block = 0u;
509 std::vector<uint8_t> constant_iv;
516 int16_t roll_distance = 0;
522 template <
typename T>
523 bool ReadWriteEntries(
BoxBuffer* buffer, std::vector<T>* entries);
525 uint32_t grouping_type = 0;
527 std::vector<CencSampleEncryptionInfoEntry>
528 cenc_sample_encryption_info_entries;
530 std::vector<AudioRollRecoveryEntry> audio_roll_recovery_entries;
534 enum GroupDescriptionIndexBase {
535 kTrackGroupDescriptionIndexBase = 0,
536 kTrackFragmentGroupDescriptionIndexBase = 0x10000,
539 uint32_t sample_count = 0u;
540 uint32_t group_description_index = 0u;
546 uint32_t grouping_type = 0u;
547 uint32_t grouping_type_parameter = 0u;
548 std::vector<SampleToGroupEntry> entries;
564 std::vector<SampleGroupDescription> sample_group_descriptions;
565 std::vector<SampleToGroup> sample_to_groups;
571 uint64_t creation_time = 0u;
572 uint64_t modification_time = 0u;
573 uint32_t timescale = 0u;
574 uint64_t duration = 0u;
581 uint16_t graphicsmode = 0u;
582 uint16_t opcolor_red = 0u;
583 uint16_t opcolor_green = 0u;
584 uint16_t opcolor_blue = 0u;
590 uint16_t balance = 0u;
600 std::vector<uint8_t> location;
607 std::vector<DataEntryUrl> data_entry = std::vector<DataEntryUrl>(1);
628 DECLARE_BOX_METHODS(
Media);
636 DECLARE_BOX_METHODS(
Track);
647 uint64_t fragment_duration = 0u;
653 uint32_t track_id = 0u;
654 uint32_t default_sample_description_index = 0u;
655 uint32_t default_sample_duration = 0u;
656 uint32_t default_sample_size = 0u;
657 uint32_t default_sample_flags = 0u;
664 std::vector<TrackExtends> tracks;
668 DECLARE_BOX_METHODS(
Movie);
673 std::vector<Track> tracks;
674 std::vector<ProtectionSystemSpecificHeader> pssh;
680 uint64_t decode_time = 0u;
686 uint32_t sequence_number = 0u;
690 enum TrackFragmentFlagsMasks {
691 kBaseDataOffsetPresentMask = 0x000001,
692 kSampleDescriptionIndexPresentMask = 0x000002,
693 kDefaultSampleDurationPresentMask = 0x000008,
694 kDefaultSampleSizePresentMask = 0x000010,
695 kDefaultSampleFlagsPresentMask = 0x000020,
696 kDurationIsEmptyMask = 0x010000,
697 kDefaultBaseIsMoofMask = 0x020000,
700 enum SampleFlagsMasks {
701 kReservedMask = 0xFC000000,
702 kSampleDependsOnMask = 0x03000000,
703 kSampleIsDependedOnMask = 0x00C00000,
704 kSampleHasRedundancyMask = 0x00300000,
705 kSamplePaddingValueMask = 0x000E0000,
706 kNonKeySampleMask = 0x00010000,
707 kSampleDegradationPriorityMask = 0x0000FFFF,
712 uint32_t track_id = 0u;
713 uint32_t sample_description_index = 0u;
714 uint32_t default_sample_duration = 0u;
715 uint32_t default_sample_size = 0u;
716 uint32_t default_sample_flags = 0u;
720 enum TrackFragmentFlagsMasks {
721 kDataOffsetPresentMask = 0x000001,
722 kFirstSampleFlagsPresentMask = 0x000004,
723 kSampleDurationPresentMask = 0x000100,
724 kSampleSizePresentMask = 0x000200,
725 kSampleFlagsPresentMask = 0x000400,
726 kSampleCompTimeOffsetsPresentMask = 0x000800,
731 uint32_t sample_count = 0u;
732 uint32_t data_offset = 0u;
733 std::vector<uint32_t> sample_flags;
734 std::vector<uint32_t> sample_sizes;
735 std::vector<uint32_t> sample_durations;
736 std::vector<int64_t> sample_composition_time_offsets;
743 std::vector<TrackFragmentRun> runs;
744 bool decode_time_absent =
false;
746 std::vector<SampleGroupDescription> sample_group_descriptions;
747 std::vector<SampleToGroup> sample_to_groups;
757 std::vector<TrackFragment> tracks;
758 std::vector<ProtectionSystemSpecificHeader> pssh;
772 bool reference_type =
false;
773 uint32_t referenced_size = 0u;
774 uint32_t subsegment_duration = 0u;
775 bool starts_with_sap =
false;
776 SAPType sap_type = TypeUnknown;
777 uint32_t sap_delta_time = 0u;
780 uint64_t earliest_presentation_time = 0u;
786 uint32_t reference_id = 0u;
787 uint32_t timescale = 0u;
788 uint64_t earliest_presentation_time = 0u;
789 uint64_t first_offset = 0u;
790 std::vector<SegmentReference> references;
797 uint32_t data_size = 0u;
802 const int kCueSourceIdNotSet = -1;
807 int32_t source_id = kCueSourceIdNotSet;
813 std::string cue_current_time;
825 std::string settings;
831 std::string cue_text;
841 std::string cue_additional_text;
860 #endif // PACKAGER_MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
All the methods that are virtual are virtual for mocking.