| Index: media/mp4/box_definitions.h
|
| diff --git a/media/mp4/box_definitions.h b/media/mp4/box_definitions.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5a652dda616385a6febe287f02fd7ed9423fffbe
|
| --- /dev/null
|
| +++ b/media/mp4/box_definitions.h
|
| @@ -0,0 +1,358 @@
|
| +// 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 <string>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "media/mp4/avc.h"
|
| +#include "media/mp4/fourccs.h"
|
| +
|
| +namespace media {
|
| +namespace mp4 {
|
| +
|
| +class BoxReader;
|
| +
|
| +enum TrackType {
|
| + kInvalid = 0,
|
| + kVideo,
|
| + kAudio,
|
| + kHint
|
| +};
|
| +
|
| +struct FileType {
|
| + FourCC major_brand;
|
| + uint32 minor_version;
|
| +
|
| + FileType();
|
| + ~FileType();
|
| +};
|
| +
|
| +struct ProtectionSystemSpecificHeader {
|
| + std::vector<uint8> system_id;
|
| + std::vector<uint8> data;
|
| +
|
| + ProtectionSystemSpecificHeader();
|
| + ~ProtectionSystemSpecificHeader();
|
| +};
|
| +
|
| +struct SampleAuxiliaryInformationOffset {
|
| + std::vector<uint64> offsets;
|
| +
|
| + SampleAuxiliaryInformationOffset();
|
| + ~SampleAuxiliaryInformationOffset();
|
| +};
|
| +
|
| +struct SampleAuxiliaryInformationSize {
|
| + uint8 default_sample_info_size;
|
| + uint32 sample_count;
|
| + std::vector<uint8> sample_info_sizes;
|
| +
|
| + SampleAuxiliaryInformationSize();
|
| + ~SampleAuxiliaryInformationSize();
|
| +};
|
| +
|
| +struct OriginalFormat {
|
| + FourCC format;
|
| +};
|
| +
|
| +struct SchemeType {
|
| + FourCC type;
|
| + uint32 version;
|
| +
|
| + SchemeType() : type(FOURCC_NULL), version(0) {}
|
| +};
|
| +
|
| +struct TrackEncryption {
|
| + // Note: this definition is specific to the CENC protection type.
|
| + bool is_encrypted;
|
| + uint8 default_iv_size;
|
| + std::vector<uint8> default_kid;
|
| +
|
| + TrackEncryption();
|
| + ~TrackEncryption();
|
| +};
|
| +
|
| +struct SchemeInfo {
|
| + TrackEncryption track_encryption;
|
| +};
|
| +
|
| +struct ProtectionSchemeInfo {
|
| + OriginalFormat format;
|
| + SchemeType type;
|
| + SchemeInfo info;
|
| +};
|
| +
|
| +struct MovieHeader {
|
| + uint64 creation_time;
|
| + uint64 modification_time;
|
| + uint32 timescale;
|
| + uint64 duration;
|
| + int32 rate;
|
| + int16 volume;
|
| + uint32 next_track_id;
|
| +};
|
| +
|
| +struct TrackHeader {
|
| + static const uint32 kTrackEnabled = 1;
|
| + static const uint32 kTrackInMovie = 2;
|
| + static const uint32 kTrackInPreview = 4;
|
| +
|
| + uint64 creation_time;
|
| + uint64 modification_time;
|
| + uint32 track_id;
|
| + uint64 duration;
|
| + int16 layer;
|
| + int16 alternate_group;
|
| + int16 volume;
|
| + uint32 width;
|
| + uint32 height;
|
| +
|
| + TrackHeader();
|
| + ~TrackHeader();
|
| +};
|
| +
|
| +struct EditListEntry {
|
| + uint64 segment_duration;
|
| + int64 media_time;
|
| + int16 media_rate_integer;
|
| + int16 media_rate_fraction;
|
| +};
|
| +
|
| +struct EditList {
|
| + std::vector<EditListEntry> edits;
|
| +
|
| + EditList();
|
| + ~EditList();
|
| +};
|
| +
|
| +struct Edit {
|
| + EditList list;
|
| +
|
| + Edit();
|
| + ~Edit();
|
| +};
|
| +
|
| +struct HandlerReference {
|
| + TrackType type;
|
| +};
|
| +
|
| +struct SampleEntry {
|
| + FourCC format;
|
| + uint16 data_reference_index;
|
| +
|
| + ProtectionSchemeInfo sinf;
|
| +
|
| + SampleEntry();
|
| + ~SampleEntry();
|
| +};
|
| +
|
| +struct VideoSampleEntry : SampleEntry {
|
| + uint16 width;
|
| + uint16 height;
|
| +
|
| + // Present iff format or original_format is 'avc1'.
|
| + AVCDecoderConfigurationRecord avcc;
|
| +
|
| + VideoSampleEntry();
|
| + ~VideoSampleEntry();
|
| +};
|
| +
|
| +struct AudioSampleEntry : SampleEntry {
|
| + uint16 channelcount;
|
| + uint16 samplesize;
|
| + uint32 samplerate;
|
| +
|
| + AudioSampleEntry();
|
| + ~AudioSampleEntry();
|
| +};
|
| +
|
| +struct SampleDescription {
|
| + TrackType type;
|
| + std::vector<VideoSampleEntry> video_entries;
|
| + std::vector<AudioSampleEntry> audio_entries;
|
| +
|
| + SampleDescription();
|
| + ~SampleDescription();
|
| +};
|
| +
|
| +struct 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;
|
| +
|
| + SampleTable();
|
| + ~SampleTable();
|
| +};
|
| +
|
| +struct MediaHeader {
|
| + uint64 creation_time;
|
| + uint64 modification_time;
|
| + uint32 timescale;
|
| + uint64 duration;
|
| +
|
| + MediaHeader();
|
| + ~MediaHeader();
|
| +};
|
| +
|
| +struct MediaInformation {
|
| + SampleTable sample_table;
|
| +};
|
| +
|
| +struct Media {
|
| + MediaHeader header;
|
| + HandlerReference handler;
|
| + MediaInformation information;
|
| +};
|
| +
|
| +struct Track {
|
| + TrackHeader header;
|
| + Media media;
|
| + Edit edit;
|
| +};
|
| +
|
| +struct MovieExtendsHeader {
|
| + uint64 fragment_duration;
|
| +};
|
| +
|
| +struct TrackExtends {
|
| + uint32 track_id;
|
| + uint32 default_sample_description_index;
|
| + uint32 default_sample_duration;
|
| + uint32 default_sample_size;
|
| + uint32 default_sample_flags;
|
| +};
|
| +
|
| +struct MovieExtends {
|
| + MovieExtendsHeader header;
|
| + std::vector<TrackExtends> tracks;
|
| +
|
| + MovieExtends();
|
| + ~MovieExtends();
|
| +};
|
| +
|
| +struct Movie {
|
| + bool fragmented;
|
| + MovieHeader header;
|
| + MovieExtends extends;
|
| + std::vector<Track> tracks;
|
| + std::vector<ProtectionSystemSpecificHeader> pssh;
|
| +
|
| + Movie();
|
| + ~Movie();
|
| +};
|
| +
|
| +struct TrackFragmentDecodeTime {
|
| + uint64 decode_time;
|
| +};
|
| +
|
| +struct MovieFragmentHeader {
|
| + uint32 sequence_number;
|
| +};
|
| +
|
| +struct 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 {
|
| + TrackFragmentRun();
|
| + ~TrackFragmentRun();
|
| +
|
| + uint32 sample_count;
|
| + uint32 data_offset;
|
| + std::vector<uint32> sample_flags;
|
| + std::vector<uint32> sample_sizes;
|
| + std::vector<uint32> sample_durations;
|
| + std::vector<uint32> sample_composition_time_offsets;
|
| +};
|
| +
|
| +struct TrackFragment {
|
| + TrackFragmentHeader header;
|
| + std::vector<TrackFragmentRun> runs;
|
| + TrackFragmentDecodeTime decode_time;
|
| + SampleAuxiliaryInformationOffset auxiliary_offset;
|
| + SampleAuxiliaryInformationSize auxiliary_size;
|
| +
|
| + TrackFragment();
|
| + ~TrackFragment();
|
| +};
|
| +
|
| +struct MovieFragment {
|
| + MovieFragmentHeader header;
|
| + std::vector<TrackFragment> tracks;
|
| + std::vector<ProtectionSystemSpecificHeader> pssh;
|
| +
|
| + MovieFragment();
|
| + ~MovieFragment();
|
| +};
|
| +
|
| +struct SegmentIndex {
|
| + uint32 reference_id;
|
| + uint32 timescale;
|
| + uint64 earliest_presentation_time;
|
| + uint64 first_offset;
|
| + std::vector<uint32> sizes;
|
| + std::vector<uint32> durations;
|
| +
|
| + SegmentIndex();
|
| + ~SegmentIndex();
|
| +};
|
| +
|
| +template<typename T> FourCC GetBoxType();
|
| +
|
| +#define DECLARE_BOX(T, F) \
|
| + bool Parse(BoxReader* r, T* box); \
|
| + template<> inline FourCC GetBoxType<T>() { return FOURCC_ ## F; }
|
| +
|
| +DECLARE_BOX(AVCDecoderConfigurationRecord, AVCC);
|
| +DECLARE_BOX(Edit, EDTS);
|
| +DECLARE_BOX(EditList, ELST);
|
| +DECLARE_BOX(FileType, FTYP);
|
| +DECLARE_BOX(HandlerReference, HDLR);
|
| +DECLARE_BOX(Media, MDIA);
|
| +DECLARE_BOX(MediaHeader, MDHD);
|
| +DECLARE_BOX(MediaInformation, MINF);
|
| +DECLARE_BOX(Movie, MOOV);
|
| +DECLARE_BOX(MovieExtends, MVEX);
|
| +DECLARE_BOX(MovieExtendsHeader, MEHD);
|
| +DECLARE_BOX(MovieFragment, MOOF);
|
| +DECLARE_BOX(MovieFragmentHeader, MFHD);
|
| +DECLARE_BOX(MovieHeader, MVHD);
|
| +DECLARE_BOX(OriginalFormat, FRMA);
|
| +DECLARE_BOX(ProtectionSchemeInfo, SINF);
|
| +DECLARE_BOX(ProtectionSystemSpecificHeader, PSSH);
|
| +DECLARE_BOX(SampleAuxiliaryInformationOffset, SAIO);
|
| +DECLARE_BOX(SampleAuxiliaryInformationSize, SAIZ);
|
| +DECLARE_BOX(SampleDescription, STSD);
|
| +DECLARE_BOX(SampleTable, STBL);
|
| +DECLARE_BOX(SchemeInfo, SCHI);
|
| +DECLARE_BOX(SchemeType, SCHM);
|
| +DECLARE_BOX(Track, TRAK);
|
| +DECLARE_BOX(TrackEncryption, TENC);
|
| +DECLARE_BOX(TrackExtends, TREX);
|
| +DECLARE_BOX(TrackFragment, TRAF);
|
| +DECLARE_BOX(TrackFragmentDecodeTime, TFDT);
|
| +DECLARE_BOX(TrackFragmentHeader, TFHD);
|
| +DECLARE_BOX(TrackFragmentRun, TRUN);
|
| +DECLARE_BOX(TrackHeader, TKHD);
|
| +
|
| +#undef DECLARE_BOX
|
| +
|
| +// These boxes do not have an associated FourCC.
|
| +bool Parse(BoxReader* r, VideoSampleEntry* entry);
|
| +bool Parse(BoxReader* r, AudioSampleEntry* entry);
|
| +
|
| +} // namespace mp4
|
| +} // namespace media
|
| +
|
| +#endif // MEDIA_MP4_BOX_DEFINITIONS_H_
|
|
|