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 FourCC GetActualFormat()
const {
333 return format == FOURCC_enca ? sinf.format.format : format;
337 uint16_t data_reference_index;
338 uint16_t channelcount;
357 std::string source_label;
367 uint16_t data_reference_index;
381 std::vector<VideoSampleEntry> video_entries;
382 std::vector<AudioSampleEntry> audio_entries;
383 std::vector<TextSampleEntry> text_entries;
387 uint32_t sample_count;
388 uint32_t sample_delta;
395 std::vector<DecodingTime> decoding_time;
399 uint32_t sample_count;
403 int64_t sample_offset;
410 std::vector<CompositionOffset> composition_offset;
414 uint32_t first_chunk;
415 uint32_t samples_per_chunk;
416 uint32_t sample_description_index;
423 std::vector<ChunkInfo> chunk_info;
430 uint32_t sample_size;
431 uint32_t sample_count;
432 std::vector<uint32_t> sizes;
440 std::vector<uint32_t> sizes;
447 std::vector<uint64_t> offsets;
459 std::vector<uint32_t> sample_number;
480 uint64_t creation_time;
481 uint64_t modification_time;
490 uint16_t graphicsmode;
491 uint16_t opcolor_red;
492 uint16_t opcolor_green;
493 uint16_t opcolor_blue;
509 std::vector<uint8_t> location;
516 std::vector<DataEntryUrl> data_entry;
537 DECLARE_BOX_METHODS(
Media);
545 DECLARE_BOX_METHODS(
Track);
556 uint64_t fragment_duration;
563 uint32_t default_sample_description_index;
564 uint32_t default_sample_duration;
565 uint32_t default_sample_size;
566 uint32_t default_sample_flags;
573 std::vector<TrackExtends> tracks;
577 DECLARE_BOX_METHODS(
Movie);
582 std::vector<Track> tracks;
583 std::vector<ProtectionSystemSpecificHeader> pssh;
589 uint64_t decode_time;
595 uint32_t sequence_number;
599 enum TrackFragmentFlagsMasks {
600 kBaseDataOffsetPresentMask = 0x000001,
601 kSampleDescriptionIndexPresentMask = 0x000002,
602 kDefaultSampleDurationPresentMask = 0x000008,
603 kDefaultSampleSizePresentMask = 0x000010,
604 kDefaultSampleFlagsPresentMask = 0x000020,
605 kDurationIsEmptyMask = 0x010000,
606 kDefaultBaseIsMoofMask = 0x020000,
609 enum SampleFlagsMasks {
610 kReservedMask = 0xFC000000,
611 kSampleDependsOnMask = 0x03000000,
612 kSampleIsDependedOnMask = 0x00C00000,
613 kSampleHasRedundancyMask = 0x00300000,
614 kSamplePaddingValueMask = 0x000E0000,
615 kNonKeySampleMask = 0x00010000,
616 kSampleDegradationPriorityMask = 0x0000FFFF,
622 uint32_t sample_description_index;
623 uint32_t default_sample_duration;
624 uint32_t default_sample_size;
625 uint32_t default_sample_flags;
629 enum TrackFragmentFlagsMasks {
630 kDataOffsetPresentMask = 0x000001,
631 kFirstSampleFlagsPresentMask = 0x000004,
632 kSampleDurationPresentMask = 0x000100,
633 kSampleSizePresentMask = 0x000200,
634 kSampleFlagsPresentMask = 0x000400,
635 kSampleCompTimeOffsetsPresentMask = 0x000800,
640 uint32_t sample_count;
641 uint32_t data_offset;
642 std::vector<uint32_t> sample_flags;
643 std::vector<uint32_t> sample_sizes;
644 std::vector<uint32_t> sample_durations;
645 std::vector<int64_t> sample_composition_time_offsets;
649 enum GroupDescriptionIndexBase {
650 kTrackGroupDescriptionIndexBase = 0,
651 kTrackFragmentGroupDescriptionIndexBase = 0x10000,
654 uint32_t sample_count;
655 uint32_t group_description_index;
661 uint32_t grouping_type;
662 uint32_t grouping_type_parameter;
663 std::vector<SampleToGroupEntry> entries;
670 uint8_t is_protected;
671 uint8_t per_sample_iv_size;
672 std::vector<uint8_t> key_id;
675 uint8_t crypt_byte_block;
676 uint8_t skip_byte_block;
679 std::vector<uint8_t> constant_iv;
685 uint32_t grouping_type;
686 std::vector<CencSampleEncryptionInfoEntry> entries;
693 std::vector<TrackFragmentRun> runs;
694 bool decode_time_absent;
707 std::vector<TrackFragment> tracks;
708 std::vector<ProtectionSystemSpecificHeader> pssh;
723 uint32_t referenced_size;
724 uint32_t subsegment_duration;
725 bool starts_with_sap;
727 uint32_t sap_delta_time;
730 uint64_t earliest_presentation_time;
736 uint32_t reference_id;
738 uint64_t earliest_presentation_time;
739 uint64_t first_offset;
740 std::vector<SegmentReference> references;
757 std::string cue_current_time;
767 std::string settings;
772 std::string cue_text;
781 std::string cue_additional_text;
800 #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