// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_MP4_BOX_DEFINITIONS_H_ #define MEDIA_MP4_BOX_DEFINITIONS_H_ #include #include #include "base/basictypes.h" #include "base/compiler_specific.h" #include "media/base/media_export.h" #include "media/mp4/avc.h" #include "media/mp4/box_reader.h" #include "media/mp4/fourccs.h" namespace media { namespace mp4 { enum TrackType { kInvalid = 0, kVideo, kAudio, kHint }; #define DECLARE_BOX_METHODS(T) \ T(); \ virtual ~T(); \ virtual bool Parse(BoxReader* reader) OVERRIDE; \ virtual FourCC BoxType() const OVERRIDE; \ struct FileType : Box { DECLARE_BOX_METHODS(FileType); FourCC major_brand; uint32 minor_version; }; struct ProtectionSystemSpecificHeader : Box { DECLARE_BOX_METHODS(ProtectionSystemSpecificHeader); std::vector system_id; std::vector data; }; struct SampleAuxiliaryInformationOffset : Box { DECLARE_BOX_METHODS(SampleAuxiliaryInformationOffset); std::vector offsets; }; struct SampleAuxiliaryInformationSize : Box { DECLARE_BOX_METHODS(SampleAuxiliaryInformationSize); uint8 default_sample_info_size; uint32 sample_count; std::vector sample_info_sizes; }; struct OriginalFormat : Box { DECLARE_BOX_METHODS(OriginalFormat); FourCC format; }; struct SchemeType : Box { DECLARE_BOX_METHODS(SchemeType); FourCC type; uint32 version; }; struct TrackEncryption : Box { DECLARE_BOX_METHODS(TrackEncryption); // Note: this definition is specific to the CENC protection type. bool is_encrypted; uint8 default_iv_size; std::vector default_kid; }; struct SchemeInfo : Box { DECLARE_BOX_METHODS(SchemeInfo); TrackEncryption track_encryption; }; struct ProtectionSchemeInfo : Box { DECLARE_BOX_METHODS(ProtectionSchemeInfo); OriginalFormat format; SchemeType type; SchemeInfo info; }; struct MovieHeader : Box { DECLARE_BOX_METHODS(MovieHeader); uint64 creation_time; uint64 modification_time; uint32 timescale; uint64 duration; int32 rate; int16 volume; uint32 next_track_id; }; struct TrackHeader : Box { DECLARE_BOX_METHODS(TrackHeader); uint64 creation_time; uint64 modification_time; uint32 track_id; uint64 duration; int16 layer; int16 alternate_group; int16 volume; uint32 width; uint32 height; }; struct EditListEntry { uint64 segment_duration; int64 media_time; int16 media_rate_integer; int16 media_rate_fraction; }; struct EditList : Box { DECLARE_BOX_METHODS(EditList); std::vector edits; }; struct Edit : Box { DECLARE_BOX_METHODS(Edit); EditList list; }; struct HandlerReference : Box { DECLARE_BOX_METHODS(HandlerReference); TrackType type; }; struct MEDIA_EXPORT AVCDecoderConfigurationRecord : Box { DECLARE_BOX_METHODS(AVCDecoderConfigurationRecord); uint8 version; uint8 profile_indication; uint8 profile_compatibility; uint8 avc_level; uint8 length_size; typedef std::vector SPS; typedef std::vector PPS; std::vector sps_list; std::vector pps_list; }; struct VideoSampleEntry : Box { DECLARE_BOX_METHODS(VideoSampleEntry); FourCC format; uint16 data_reference_index; uint16 width; uint16 height; ProtectionSchemeInfo sinf; // Currently expected to be present regardless of format. AVCDecoderConfigurationRecord avcc; }; struct AudioSampleEntry : Box { DECLARE_BOX_METHODS(AudioSampleEntry); FourCC format; uint16 data_reference_index; uint16 channelcount; uint16 samplesize; uint32 samplerate; ProtectionSchemeInfo sinf; }; struct SampleDescription : Box { DECLARE_BOX_METHODS(SampleDescription); TrackType type; std::vector video_entries; std::vector audio_entries; }; struct SampleTable : Box { DECLARE_BOX_METHODS(SampleTable); // Media Source specific: we ignore many of the sub-boxes in this box, // including some that are required to be present in the BMFF spec. SampleDescription description; }; struct MediaHeader : Box { DECLARE_BOX_METHODS(MediaHeader); uint64 creation_time; uint64 modification_time; uint32 timescale; uint64 duration; }; struct MediaInformation : Box { DECLARE_BOX_METHODS(MediaInformation); SampleTable sample_table; }; struct Media : Box { DECLARE_BOX_METHODS(Media); MediaHeader header; HandlerReference handler; MediaInformation information; }; struct Track : Box { DECLARE_BOX_METHODS(Track); TrackHeader header; Media media; Edit edit; }; struct MovieExtendsHeader : Box { DECLARE_BOX_METHODS(MovieExtendsHeader); uint64 fragment_duration; }; struct TrackExtends : Box { DECLARE_BOX_METHODS(TrackExtends); uint32 track_id; uint32 default_sample_description_index; uint32 default_sample_duration; uint32 default_sample_size; uint32 default_sample_flags; }; struct MovieExtends : Box { DECLARE_BOX_METHODS(MovieExtends); MovieExtendsHeader header; std::vector tracks; }; struct Movie : Box { DECLARE_BOX_METHODS(Movie); bool fragmented; MovieHeader header; MovieExtends extends; std::vector tracks; std::vector pssh; }; struct TrackFragmentDecodeTime : Box { DECLARE_BOX_METHODS(TrackFragmentDecodeTime); uint64 decode_time; }; struct MovieFragmentHeader : Box { DECLARE_BOX_METHODS(MovieFragmentHeader); uint32 sequence_number; }; struct TrackFragmentHeader : Box { DECLARE_BOX_METHODS(TrackFragmentHeader); uint32 track_id; uint32 default_sample_duration; uint32 default_sample_size; uint32 default_sample_flags; // As 'flags' might be all zero, we cannot use zeroness alone to identify // when default_sample_flags wasn't specified, unlike the other values. bool has_default_sample_flags; }; struct TrackFragmentRun : Box { DECLARE_BOX_METHODS(TrackFragmentRun); uint32 sample_count; uint32 data_offset; std::vector sample_flags; std::vector sample_sizes; std::vector sample_durations; std::vector sample_composition_time_offsets; }; struct TrackFragment : Box { DECLARE_BOX_METHODS(TrackFragment); TrackFragmentHeader header; std::vector runs; TrackFragmentDecodeTime decode_time; SampleAuxiliaryInformationOffset auxiliary_offset; SampleAuxiliaryInformationSize auxiliary_size; }; struct MovieFragment : Box { DECLARE_BOX_METHODS(MovieFragment); MovieFragmentHeader header; std::vector tracks; std::vector pssh; }; #undef DECLARE_BOX } // namespace mp4 } // namespace media #endif // MEDIA_MP4_BOX_DEFINITIONS_H_