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;
287 FourCC format = FOURCC_NULL;
290 uint16_t data_reference_index = 1u;
292 uint16_t height = 0u;
309 uint32_t sampling_frequency = 0u;
310 uint32_t max_bitrate = 0u;
311 uint32_t avg_bitrate = 0u;
312 uint8_t pcm_sample_depth = 0u;
313 std::vector<uint8_t> extra_data;
319 std::vector<uint8_t> data;
325 std::vector<uint8_t> data;
331 std::vector<uint8_t> opus_identification_header;
333 uint16_t preskip = 0u;
342 std::vector<uint8_t> data;
349 FourCC GetActualFormat()
const {
350 return format == FOURCC_enca ? sinf.format.format : format;
353 FourCC format = FOURCC_NULL;
356 uint16_t data_reference_index = 1u;
357 uint16_t channelcount = 2u;
358 uint16_t samplesize = 16u;
359 uint32_t samplerate = 0u;
380 std::string source_label;
389 FourCC format = FOURCC_NULL;
393 uint16_t data_reference_index = 1u;
404 TrackType type = kInvalid;
407 std::vector<VideoSampleEntry> video_entries;
408 std::vector<AudioSampleEntry> audio_entries;
409 std::vector<TextSampleEntry> text_entries;
413 uint32_t sample_count;
414 uint32_t sample_delta;
421 std::vector<DecodingTime> decoding_time;
425 uint32_t sample_count;
429 int64_t sample_offset;
436 std::vector<CompositionOffset> composition_offset;
440 uint32_t first_chunk;
441 uint32_t samples_per_chunk;
442 uint32_t sample_description_index;
449 std::vector<ChunkInfo> chunk_info;
456 uint32_t sample_size = 0u;
457 uint32_t sample_count = 0u;
458 std::vector<uint32_t> sizes;
465 uint8_t field_size = 0u;
466 std::vector<uint32_t> sizes;
473 std::vector<uint64_t> offsets;
485 std::vector<uint32_t> sample_number;
492 uint8_t is_protected = 0u;
493 uint8_t per_sample_iv_size = 0u;
494 std::vector<uint8_t> key_id;
497 uint8_t crypt_byte_block = 0u;
498 uint8_t skip_byte_block = 0u;
501 std::vector<uint8_t> constant_iv;
508 int16_t roll_distance = 0;
514 template <
typename T>
515 bool ReadWriteEntries(
BoxBuffer* buffer, std::vector<T>* entries);
517 uint32_t grouping_type = 0;
519 std::vector<CencSampleEncryptionInfoEntry>
520 cenc_sample_encryption_info_entries;
522 std::vector<AudioRollRecoveryEntry> audio_roll_recovery_entries;
526 enum GroupDescriptionIndexBase {
527 kTrackGroupDescriptionIndexBase = 0,
528 kTrackFragmentGroupDescriptionIndexBase = 0x10000,
531 uint32_t sample_count = 0u;
532 uint32_t group_description_index = 0u;
538 uint32_t grouping_type = 0u;
539 uint32_t grouping_type_parameter = 0u;
540 std::vector<SampleToGroupEntry> entries;
556 std::vector<SampleGroupDescription> sample_group_descriptions;
557 std::vector<SampleToGroup> sample_to_groups;
563 uint64_t creation_time = 0u;
564 uint64_t modification_time = 0u;
565 uint32_t timescale = 0u;
566 uint64_t duration = 0u;
573 uint16_t graphicsmode = 0u;
574 uint16_t opcolor_red = 0u;
575 uint16_t opcolor_green = 0u;
576 uint16_t opcolor_blue = 0u;
582 uint16_t balance = 0u;
592 std::vector<uint8_t> location;
599 std::vector<DataEntryUrl> data_entry = std::vector<DataEntryUrl>(1);
620 DECLARE_BOX_METHODS(
Media);
628 DECLARE_BOX_METHODS(
Track);
639 uint64_t fragment_duration = 0u;
645 uint32_t track_id = 0u;
646 uint32_t default_sample_description_index = 0u;
647 uint32_t default_sample_duration = 0u;
648 uint32_t default_sample_size = 0u;
649 uint32_t default_sample_flags = 0u;
656 std::vector<TrackExtends> tracks;
660 DECLARE_BOX_METHODS(
Movie);
665 std::vector<Track> tracks;
666 std::vector<ProtectionSystemSpecificHeader> pssh;
672 uint64_t decode_time = 0u;
678 uint32_t sequence_number = 0u;
682 enum TrackFragmentFlagsMasks {
683 kBaseDataOffsetPresentMask = 0x000001,
684 kSampleDescriptionIndexPresentMask = 0x000002,
685 kDefaultSampleDurationPresentMask = 0x000008,
686 kDefaultSampleSizePresentMask = 0x000010,
687 kDefaultSampleFlagsPresentMask = 0x000020,
688 kDurationIsEmptyMask = 0x010000,
689 kDefaultBaseIsMoofMask = 0x020000,
692 enum SampleFlagsMasks {
693 kReservedMask = 0xFC000000,
694 kSampleDependsOnMask = 0x03000000,
695 kSampleIsDependedOnMask = 0x00C00000,
696 kSampleHasRedundancyMask = 0x00300000,
697 kSamplePaddingValueMask = 0x000E0000,
698 kNonKeySampleMask = 0x00010000,
699 kSampleDegradationPriorityMask = 0x0000FFFF,
704 uint32_t track_id = 0u;
705 uint32_t sample_description_index = 0u;
706 uint32_t default_sample_duration = 0u;
707 uint32_t default_sample_size = 0u;
708 uint32_t default_sample_flags = 0u;
712 enum TrackFragmentFlagsMasks {
713 kDataOffsetPresentMask = 0x000001,
714 kFirstSampleFlagsPresentMask = 0x000004,
715 kSampleDurationPresentMask = 0x000100,
716 kSampleSizePresentMask = 0x000200,
717 kSampleFlagsPresentMask = 0x000400,
718 kSampleCompTimeOffsetsPresentMask = 0x000800,
723 uint32_t sample_count = 0u;
724 uint32_t data_offset = 0u;
725 std::vector<uint32_t> sample_flags;
726 std::vector<uint32_t> sample_sizes;
727 std::vector<uint32_t> sample_durations;
728 std::vector<int64_t> sample_composition_time_offsets;
735 std::vector<TrackFragmentRun> runs;
736 bool decode_time_absent =
false;
738 std::vector<SampleGroupDescription> sample_group_descriptions;
739 std::vector<SampleToGroup> sample_to_groups;
749 std::vector<TrackFragment> tracks;
750 std::vector<ProtectionSystemSpecificHeader> pssh;
764 bool reference_type =
false;
765 uint32_t referenced_size = 0u;
766 uint32_t subsegment_duration = 0u;
767 bool starts_with_sap =
false;
768 SAPType sap_type = TypeUnknown;
769 uint32_t sap_delta_time = 0u;
772 uint64_t earliest_presentation_time = 0u;
778 uint32_t reference_id = 0u;
779 uint32_t timescale = 0u;
780 uint64_t earliest_presentation_time = 0u;
781 uint64_t first_offset = 0u;
782 std::vector<SegmentReference> references;
789 uint32_t data_size = 0u;
794 const int kCueSourceIdNotSet = -1;
799 int32_t source_id = kCueSourceIdNotSet;
805 std::string cue_current_time;
817 std::string settings;
823 std::string cue_text;
833 std::string cue_additional_text;
852 #endif // PACKAGER_MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
All the methods that are virtual are virtual for mocking.