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/formats/mp4/aac_audio_specific_config.h"
12 #include "packager/media/formats/mp4/box.h"
13 #include "packager/media/formats/mp4/es_descriptor.h"
14 #include "packager/media/formats/mp4/fourccs.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;
149 uint8_t default_iv_size;
150 std::vector<uint8_t> default_kid;
170 uint64_t creation_time;
171 uint64_t modification_time;
176 uint32_t next_track_id;
180 enum TrackHeaderFlags {
181 kTrackEnabled = 0x000001,
182 kTrackInMovie = 0x000002,
183 kTrackInPreview = 0x000004,
188 uint64_t creation_time;
189 uint64_t modification_time;
193 int16_t alternate_group;
202 uint64_t segment_duration;
204 int16_t media_rate_integer;
205 int16_t media_rate_fraction;
211 std::vector<EditListEntry> edits;
215 DECLARE_BOX_METHODS(
Edit);
228 uint32_t ComputeSize()
const;
236 uint32_t ComputeSize()
const;
245 DECLARE_BOX_METHODS(
ID3v2);
266 std::vector<uint8_t> data;
279 FourCC GetActualFormat()
const {
280 return format == FOURCC_ENCV ? sinf.format.format : format;
284 uint16_t data_reference_index;
303 uint32_t sampling_frequency;
304 uint32_t max_bitrate;
305 uint32_t avg_bitrate;
306 uint8_t pcm_sample_depth;
307 std::vector<uint8_t> extra_data;
313 std::vector<uint8_t> data;
319 std::vector<uint8_t> data;
325 FourCC GetActualFormat()
const {
326 return format == FOURCC_ENCA ? sinf.format.format : format;
330 uint16_t data_reference_index;
331 uint16_t channelcount;
350 std::string source_label;
360 uint16_t data_reference_index;
374 std::vector<VideoSampleEntry> video_entries;
375 std::vector<AudioSampleEntry> audio_entries;
376 std::vector<TextSampleEntry> text_entries;
380 uint32_t sample_count;
381 uint32_t sample_delta;
388 std::vector<DecodingTime> decoding_time;
392 uint32_t sample_count;
396 int64_t sample_offset;
403 std::vector<CompositionOffset> composition_offset;
407 uint32_t first_chunk;
408 uint32_t samples_per_chunk;
409 uint32_t sample_description_index;
416 std::vector<ChunkInfo> chunk_info;
423 uint32_t sample_size;
424 uint32_t sample_count;
425 std::vector<uint32_t> sizes;
433 std::vector<uint32_t> sizes;
440 std::vector<uint64_t> offsets;
452 std::vector<uint32_t> sample_number;
473 uint64_t creation_time;
474 uint64_t modification_time;
483 uint16_t graphicsmode;
484 uint16_t opcolor_red;
485 uint16_t opcolor_green;
486 uint16_t opcolor_blue;
502 std::vector<uint8_t> location;
509 std::vector<DataEntryUrl> data_entry;
530 DECLARE_BOX_METHODS(
Media);
538 DECLARE_BOX_METHODS(
Track);
549 uint64_t fragment_duration;
556 uint32_t default_sample_description_index;
557 uint32_t default_sample_duration;
558 uint32_t default_sample_size;
559 uint32_t default_sample_flags;
566 std::vector<TrackExtends> tracks;
570 DECLARE_BOX_METHODS(
Movie);
575 std::vector<Track> tracks;
576 std::vector<ProtectionSystemSpecificHeader> pssh;
582 uint64_t decode_time;
588 uint32_t sequence_number;
592 enum TrackFragmentFlagsMasks {
593 kBaseDataOffsetPresentMask = 0x000001,
594 kSampleDescriptionIndexPresentMask = 0x000002,
595 kDefaultSampleDurationPresentMask = 0x000008,
596 kDefaultSampleSizePresentMask = 0x000010,
597 kDefaultSampleFlagsPresentMask = 0x000020,
598 kDurationIsEmptyMask = 0x010000,
599 kDefaultBaseIsMoofMask = 0x020000,
602 enum SampleFlagsMasks {
603 kReservedMask = 0xFC000000,
604 kSampleDependsOnMask = 0x03000000,
605 kSampleIsDependedOnMask = 0x00C00000,
606 kSampleHasRedundancyMask = 0x00300000,
607 kSamplePaddingValueMask = 0x000E0000,
608 kNonKeySampleMask = 0x00010000,
609 kSampleDegradationPriorityMask = 0x0000FFFF,
615 uint32_t sample_description_index;
616 uint32_t default_sample_duration;
617 uint32_t default_sample_size;
618 uint32_t default_sample_flags;
622 enum TrackFragmentFlagsMasks {
623 kDataOffsetPresentMask = 0x000001,
624 kFirstSampleFlagsPresentMask = 0x000004,
625 kSampleDurationPresentMask = 0x000100,
626 kSampleSizePresentMask = 0x000200,
627 kSampleFlagsPresentMask = 0x000400,
628 kSampleCompTimeOffsetsPresentMask = 0x000800,
633 uint32_t sample_count;
634 uint32_t data_offset;
635 std::vector<uint32_t> sample_flags;
636 std::vector<uint32_t> sample_sizes;
637 std::vector<uint32_t> sample_durations;
638 std::vector<int64_t> sample_composition_time_offsets;
642 enum GroupDescriptionIndexBase {
643 kTrackGroupDescriptionIndexBase = 0,
644 kTrackFragmentGroupDescriptionIndexBase = 0x10000,
647 uint32_t sample_count;
648 uint32_t group_description_index;
654 uint32_t grouping_type;
655 uint32_t grouping_type_parameter;
656 std::vector<SampleToGroupEntry> entries;
665 std::vector<uint8_t> key_id;
671 uint32_t grouping_type;
672 std::vector<CencSampleEncryptionInfoEntry> entries;
679 std::vector<TrackFragmentRun> runs;
680 bool decode_time_absent;
693 std::vector<TrackFragment> tracks;
694 std::vector<ProtectionSystemSpecificHeader> pssh;
709 uint32_t referenced_size;
710 uint32_t subsegment_duration;
711 bool starts_with_sap;
713 uint32_t sap_delta_time;
716 uint64_t earliest_presentation_time;
722 uint32_t reference_id;
724 uint64_t earliest_presentation_time;
725 uint64_t first_offset;
726 std::vector<SegmentReference> references;
743 std::string cue_current_time;
753 std::string settings;
758 std::string cue_text;
767 std::string cue_additional_text;
786 #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