Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1395)

Unified Diff: media/mp4/box_definitions.h

Issue 10536014: Implement ISO BMFF support in Media Source. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: A thorough sign-ification Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..97d95f2b0613f8ca3579a2a7b6bfa3c563a570cf
--- /dev/null
+++ b/media/mp4/box_definitions.h
@@ -0,0 +1,332 @@
+// 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>
acolwell GONE FROM CHROMIUM 2012/06/08 16:10:38 lint nit: #include <vector>
strobe_ 2012/06/11 18:44:21 Done.
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.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(T) \
acolwell GONE FROM CHROMIUM 2012/06/08 16:10:38 WDYT about DECLARE_BOX_METHODS instead?
strobe_ 2012/06/11 18:44:21 Done.
+ T(); \
+ virtual ~T(); \
+ virtual bool Parse(BoxReader* reader) OVERRIDE; \
+ virtual FourCC BoxType() const OVERRIDE; \
+
+struct FileType : Box {
+ FourCC major_brand;
+ uint32 minor_version;
+
+ DECLARE_BOX(FileType);
acolwell GONE FROM CHROMIUM 2012/06/08 16:10:38 WDYT about putting these at the top of the decls i
strobe_ 2012/06/11 18:44:21 Done.
+};
+
+struct ProtectionSystemSpecificHeader : Box {
+ std::vector<uint8> system_id;
+ std::vector<uint8> data;
+
+ DECLARE_BOX(ProtectionSystemSpecificHeader);
+};
+
+struct SampleAuxiliaryInformationOffset : Box {
+ std::vector<uint64> offsets;
+
+ DECLARE_BOX(SampleAuxiliaryInformationOffset);
+};
+
+struct SampleAuxiliaryInformationSize : Box {
+ uint8 default_sample_info_size;
+ uint32 sample_count;
+ std::vector<uint8> sample_info_sizes;
+
+ DECLARE_BOX(SampleAuxiliaryInformationSize);
+};
+
+struct OriginalFormat : Box {
+ FourCC format;
+
+ DECLARE_BOX(OriginalFormat);
+};
+
+struct SchemeType : Box {
+ FourCC type;
+ uint32 version;
+
+ DECLARE_BOX(SchemeType);
+};
+
+struct TrackEncryption : Box {
+ // Note: this definition is specific to the CENC protection type.
+ bool is_encrypted;
+ uint8 default_iv_size;
+ std::vector<uint8> default_kid;
+
+ DECLARE_BOX(TrackEncryption);
+};
+
+struct SchemeInfo : Box {
+ TrackEncryption track_encryption;
+
+ DECLARE_BOX(SchemeInfo);
+};
+
+struct ProtectionSchemeInfo : Box {
+ OriginalFormat format;
+ SchemeType type;
+ SchemeInfo info;
+
+ DECLARE_BOX(ProtectionSchemeInfo);
+};
+
+struct MovieHeader : Box {
+ uint64 creation_time;
+ uint64 modification_time;
+ uint32 timescale;
+ uint64 duration;
+ int32 rate;
+ int16 volume;
+ uint32 next_track_id;
+
+ DECLARE_BOX(MovieHeader);
+};
+
+struct TrackHeader : Box {
+ 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;
+
+ DECLARE_BOX(TrackHeader);
+};
+
+struct EditListEntry {
+ uint64 segment_duration;
+ int64 media_time;
+ int16 media_rate_integer;
+ int16 media_rate_fraction;
+};
+
+struct EditList : Box {
+ std::vector<EditListEntry> edits;
+
+ DECLARE_BOX(EditList);
+};
+
+struct Edit : Box {
+ EditList list;
+
+ DECLARE_BOX(Edit);
+};
+
+struct HandlerReference : Box {
+ TrackType type;
+
+ DECLARE_BOX(HandlerReference);
+};
+
+struct AVCDecoderConfigurationRecord : Box {
+ uint8 version;
+ uint8 profile_indication;
+ uint8 profile_compatibility;
+ uint8 avc_level;
+ uint8 length_size;
+
+ typedef std::vector<uint8> SPS;
+ typedef std::vector<uint8> PPS;
+
+ std::vector<SPS> sps_list;
+ std::vector<PPS> pps_list;
+
+ DECLARE_BOX(AVCDecoderConfigurationRecord);
+};
+
+struct VideoSampleEntry : Box {
+ FourCC format;
+ uint16 data_reference_index;
+ uint16 width;
+ uint16 height;
+
+ ProtectionSchemeInfo sinf;
+ // Present iff format or original_format is 'avc1'.
+ // TODO(strobe): This may not be true of PIFF; decide how to handle this.
+ AVCDecoderConfigurationRecord avcc;
+
+ DECLARE_BOX(VideoSampleEntry);
+};
+
+struct AudioSampleEntry : Box {
+ FourCC format;
+ uint16 data_reference_index;
+ uint16 channelcount;
+ uint16 samplesize;
+ uint32 samplerate;
+
+ ProtectionSchemeInfo sinf;
+
+ DECLARE_BOX(AudioSampleEntry);
+};
+
+struct SampleDescription : Box {
+ TrackType type;
+ std::vector<VideoSampleEntry> video_entries;
+ std::vector<AudioSampleEntry> audio_entries;
+
+ DECLARE_BOX(SampleDescription);
+};
+
+struct SampleTable : Box {
+ // 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;
+
+ DECLARE_BOX(SampleTable);
+};
+
+struct MediaHeader : Box {
+ uint64 creation_time;
+ uint64 modification_time;
+ uint32 timescale;
+ uint64 duration;
+
+ DECLARE_BOX(MediaHeader);
+};
+
+struct MediaInformation : Box {
+ SampleTable sample_table;
+
+ DECLARE_BOX(MediaInformation);
+};
+
+struct Media : Box {
+ MediaHeader header;
+ HandlerReference handler;
+ MediaInformation information;
+
+ DECLARE_BOX(Media);
+};
+
+struct Track : Box {
+ TrackHeader header;
+ Media media;
+ Edit edit;
+
+ DECLARE_BOX(Track);
+};
+
+struct MovieExtendsHeader : Box {
+ uint64 fragment_duration;
+
+ DECLARE_BOX(MovieExtendsHeader);
+};
+
+struct TrackExtends : Box {
+ uint32 track_id;
+ uint32 default_sample_description_index;
+ uint32 default_sample_duration;
+ uint32 default_sample_size;
+ uint32 default_sample_flags;
+
+ DECLARE_BOX(TrackExtends);
+};
+
+struct MovieExtends : Box {
+ MovieExtendsHeader header;
+ std::vector<TrackExtends> tracks;
+
+ DECLARE_BOX(MovieExtends);
+};
+
+struct Movie : Box {
+ bool fragmented;
+ MovieHeader header;
+ MovieExtends extends;
+ std::vector<Track> tracks;
+ std::vector<ProtectionSystemSpecificHeader> pssh;
+
+ DECLARE_BOX(Movie);
+};
+
+struct TrackFragmentDecodeTime : Box {
+ uint64 decode_time;
+
+ DECLARE_BOX(TrackFragmentDecodeTime);
+};
+
+struct MovieFragmentHeader : Box {
+ uint32 sequence_number;
+
+ DECLARE_BOX(MovieFragmentHeader);
+};
+
+struct TrackFragmentHeader : Box {
+ 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;
+
+ DECLARE_BOX(TrackFragmentHeader);
+};
+
+struct TrackFragmentRun : Box {
+ 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;
+
+ DECLARE_BOX(TrackFragmentRun);
+};
+
+struct TrackFragment : Box {
+ TrackFragmentHeader header;
+ std::vector<TrackFragmentRun> runs;
+ TrackFragmentDecodeTime decode_time;
+ SampleAuxiliaryInformationOffset auxiliary_offset;
+ SampleAuxiliaryInformationSize auxiliary_size;
+
+ DECLARE_BOX(TrackFragment);
+};
+
+struct MovieFragment : Box {
+ MovieFragmentHeader header;
+ std::vector<TrackFragment> tracks;
+ std::vector<ProtectionSystemSpecificHeader> pssh;
+
+ DECLARE_BOX(MovieFragment);
+};
+
+#undef DECLARE_BOX
+
+} // namespace mp4
+} // namespace media
+
+#endif // MEDIA_MP4_BOX_DEFINITIONS_H_

Powered by Google App Engine
This is Rietveld 408576698