Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_MP4_BOX_DEFINITIONS_H_ | |
| 6 #define MEDIA_MP4_BOX_DEFINITIONS_H_ | |
| 7 | |
| 8 #include <string> | |
|
acolwell GONE FROM CHROMIUM
2012/06/08 16:10:38
lint nit: #include <vector>
strobe_
2012/06/11 18:44:21
Done.
| |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "media/mp4/avc.h" | |
| 13 #include "media/mp4/box_reader.h" | |
| 14 #include "media/mp4/fourccs.h" | |
| 15 | |
| 16 namespace media { | |
| 17 namespace mp4 { | |
| 18 | |
| 19 enum TrackType { | |
| 20 kInvalid = 0, | |
| 21 kVideo, | |
| 22 kAudio, | |
| 23 kHint | |
| 24 }; | |
| 25 | |
| 26 #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.
| |
| 27 T(); \ | |
| 28 virtual ~T(); \ | |
| 29 virtual bool Parse(BoxReader* reader) OVERRIDE; \ | |
| 30 virtual FourCC BoxType() const OVERRIDE; \ | |
| 31 | |
| 32 struct FileType : Box { | |
| 33 FourCC major_brand; | |
| 34 uint32 minor_version; | |
| 35 | |
| 36 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.
| |
| 37 }; | |
| 38 | |
| 39 struct ProtectionSystemSpecificHeader : Box { | |
| 40 std::vector<uint8> system_id; | |
| 41 std::vector<uint8> data; | |
| 42 | |
| 43 DECLARE_BOX(ProtectionSystemSpecificHeader); | |
| 44 }; | |
| 45 | |
| 46 struct SampleAuxiliaryInformationOffset : Box { | |
| 47 std::vector<uint64> offsets; | |
| 48 | |
| 49 DECLARE_BOX(SampleAuxiliaryInformationOffset); | |
| 50 }; | |
| 51 | |
| 52 struct SampleAuxiliaryInformationSize : Box { | |
| 53 uint8 default_sample_info_size; | |
| 54 uint32 sample_count; | |
| 55 std::vector<uint8> sample_info_sizes; | |
| 56 | |
| 57 DECLARE_BOX(SampleAuxiliaryInformationSize); | |
| 58 }; | |
| 59 | |
| 60 struct OriginalFormat : Box { | |
| 61 FourCC format; | |
| 62 | |
| 63 DECLARE_BOX(OriginalFormat); | |
| 64 }; | |
| 65 | |
| 66 struct SchemeType : Box { | |
| 67 FourCC type; | |
| 68 uint32 version; | |
| 69 | |
| 70 DECLARE_BOX(SchemeType); | |
| 71 }; | |
| 72 | |
| 73 struct TrackEncryption : Box { | |
| 74 // Note: this definition is specific to the CENC protection type. | |
| 75 bool is_encrypted; | |
| 76 uint8 default_iv_size; | |
| 77 std::vector<uint8> default_kid; | |
| 78 | |
| 79 DECLARE_BOX(TrackEncryption); | |
| 80 }; | |
| 81 | |
| 82 struct SchemeInfo : Box { | |
| 83 TrackEncryption track_encryption; | |
| 84 | |
| 85 DECLARE_BOX(SchemeInfo); | |
| 86 }; | |
| 87 | |
| 88 struct ProtectionSchemeInfo : Box { | |
| 89 OriginalFormat format; | |
| 90 SchemeType type; | |
| 91 SchemeInfo info; | |
| 92 | |
| 93 DECLARE_BOX(ProtectionSchemeInfo); | |
| 94 }; | |
| 95 | |
| 96 struct MovieHeader : Box { | |
| 97 uint64 creation_time; | |
| 98 uint64 modification_time; | |
| 99 uint32 timescale; | |
| 100 uint64 duration; | |
| 101 int32 rate; | |
| 102 int16 volume; | |
| 103 uint32 next_track_id; | |
| 104 | |
| 105 DECLARE_BOX(MovieHeader); | |
| 106 }; | |
| 107 | |
| 108 struct TrackHeader : Box { | |
| 109 static const uint32 kTrackEnabled = 1; | |
| 110 static const uint32 kTrackInMovie = 2; | |
| 111 static const uint32 kTrackInPreview = 4; | |
| 112 | |
| 113 uint64 creation_time; | |
| 114 uint64 modification_time; | |
| 115 uint32 track_id; | |
| 116 uint64 duration; | |
| 117 int16 layer; | |
| 118 int16 alternate_group; | |
| 119 int16 volume; | |
| 120 uint32 width; | |
| 121 uint32 height; | |
| 122 | |
| 123 DECLARE_BOX(TrackHeader); | |
| 124 }; | |
| 125 | |
| 126 struct EditListEntry { | |
| 127 uint64 segment_duration; | |
| 128 int64 media_time; | |
| 129 int16 media_rate_integer; | |
| 130 int16 media_rate_fraction; | |
| 131 }; | |
| 132 | |
| 133 struct EditList : Box { | |
| 134 std::vector<EditListEntry> edits; | |
| 135 | |
| 136 DECLARE_BOX(EditList); | |
| 137 }; | |
| 138 | |
| 139 struct Edit : Box { | |
| 140 EditList list; | |
| 141 | |
| 142 DECLARE_BOX(Edit); | |
| 143 }; | |
| 144 | |
| 145 struct HandlerReference : Box { | |
| 146 TrackType type; | |
| 147 | |
| 148 DECLARE_BOX(HandlerReference); | |
| 149 }; | |
| 150 | |
| 151 struct AVCDecoderConfigurationRecord : Box { | |
| 152 uint8 version; | |
| 153 uint8 profile_indication; | |
| 154 uint8 profile_compatibility; | |
| 155 uint8 avc_level; | |
| 156 uint8 length_size; | |
| 157 | |
| 158 typedef std::vector<uint8> SPS; | |
| 159 typedef std::vector<uint8> PPS; | |
| 160 | |
| 161 std::vector<SPS> sps_list; | |
| 162 std::vector<PPS> pps_list; | |
| 163 | |
| 164 DECLARE_BOX(AVCDecoderConfigurationRecord); | |
| 165 }; | |
| 166 | |
| 167 struct VideoSampleEntry : Box { | |
| 168 FourCC format; | |
| 169 uint16 data_reference_index; | |
| 170 uint16 width; | |
| 171 uint16 height; | |
| 172 | |
| 173 ProtectionSchemeInfo sinf; | |
| 174 // Present iff format or original_format is 'avc1'. | |
| 175 // TODO(strobe): This may not be true of PIFF; decide how to handle this. | |
| 176 AVCDecoderConfigurationRecord avcc; | |
| 177 | |
| 178 DECLARE_BOX(VideoSampleEntry); | |
| 179 }; | |
| 180 | |
| 181 struct AudioSampleEntry : Box { | |
| 182 FourCC format; | |
| 183 uint16 data_reference_index; | |
| 184 uint16 channelcount; | |
| 185 uint16 samplesize; | |
| 186 uint32 samplerate; | |
| 187 | |
| 188 ProtectionSchemeInfo sinf; | |
| 189 | |
| 190 DECLARE_BOX(AudioSampleEntry); | |
| 191 }; | |
| 192 | |
| 193 struct SampleDescription : Box { | |
| 194 TrackType type; | |
| 195 std::vector<VideoSampleEntry> video_entries; | |
| 196 std::vector<AudioSampleEntry> audio_entries; | |
| 197 | |
| 198 DECLARE_BOX(SampleDescription); | |
| 199 }; | |
| 200 | |
| 201 struct SampleTable : Box { | |
| 202 // Media Source specific: we ignore many of the sub-boxes in this box, | |
| 203 // including some that are required to be present in the BMFF spec. | |
| 204 SampleDescription description; | |
| 205 | |
| 206 DECLARE_BOX(SampleTable); | |
| 207 }; | |
| 208 | |
| 209 struct MediaHeader : Box { | |
| 210 uint64 creation_time; | |
| 211 uint64 modification_time; | |
| 212 uint32 timescale; | |
| 213 uint64 duration; | |
| 214 | |
| 215 DECLARE_BOX(MediaHeader); | |
| 216 }; | |
| 217 | |
| 218 struct MediaInformation : Box { | |
| 219 SampleTable sample_table; | |
| 220 | |
| 221 DECLARE_BOX(MediaInformation); | |
| 222 }; | |
| 223 | |
| 224 struct Media : Box { | |
| 225 MediaHeader header; | |
| 226 HandlerReference handler; | |
| 227 MediaInformation information; | |
| 228 | |
| 229 DECLARE_BOX(Media); | |
| 230 }; | |
| 231 | |
| 232 struct Track : Box { | |
| 233 TrackHeader header; | |
| 234 Media media; | |
| 235 Edit edit; | |
| 236 | |
| 237 DECLARE_BOX(Track); | |
| 238 }; | |
| 239 | |
| 240 struct MovieExtendsHeader : Box { | |
| 241 uint64 fragment_duration; | |
| 242 | |
| 243 DECLARE_BOX(MovieExtendsHeader); | |
| 244 }; | |
| 245 | |
| 246 struct TrackExtends : Box { | |
| 247 uint32 track_id; | |
| 248 uint32 default_sample_description_index; | |
| 249 uint32 default_sample_duration; | |
| 250 uint32 default_sample_size; | |
| 251 uint32 default_sample_flags; | |
| 252 | |
| 253 DECLARE_BOX(TrackExtends); | |
| 254 }; | |
| 255 | |
| 256 struct MovieExtends : Box { | |
| 257 MovieExtendsHeader header; | |
| 258 std::vector<TrackExtends> tracks; | |
| 259 | |
| 260 DECLARE_BOX(MovieExtends); | |
| 261 }; | |
| 262 | |
| 263 struct Movie : Box { | |
| 264 bool fragmented; | |
| 265 MovieHeader header; | |
| 266 MovieExtends extends; | |
| 267 std::vector<Track> tracks; | |
| 268 std::vector<ProtectionSystemSpecificHeader> pssh; | |
| 269 | |
| 270 DECLARE_BOX(Movie); | |
| 271 }; | |
| 272 | |
| 273 struct TrackFragmentDecodeTime : Box { | |
| 274 uint64 decode_time; | |
| 275 | |
| 276 DECLARE_BOX(TrackFragmentDecodeTime); | |
| 277 }; | |
| 278 | |
| 279 struct MovieFragmentHeader : Box { | |
| 280 uint32 sequence_number; | |
| 281 | |
| 282 DECLARE_BOX(MovieFragmentHeader); | |
| 283 }; | |
| 284 | |
| 285 struct TrackFragmentHeader : Box { | |
| 286 uint32 track_id; | |
| 287 uint32 default_sample_duration; | |
| 288 uint32 default_sample_size; | |
| 289 uint32 default_sample_flags; | |
| 290 | |
| 291 // As 'flags' might be all zero, we cannot use zeroness alone to identify | |
| 292 // when default_sample_flags wasn't specified, unlike the other values. | |
| 293 bool has_default_sample_flags; | |
| 294 | |
| 295 DECLARE_BOX(TrackFragmentHeader); | |
| 296 }; | |
| 297 | |
| 298 struct TrackFragmentRun : Box { | |
| 299 uint32 sample_count; | |
| 300 uint32 data_offset; | |
| 301 std::vector<uint32> sample_flags; | |
| 302 std::vector<uint32> sample_sizes; | |
| 303 std::vector<uint32> sample_durations; | |
| 304 std::vector<uint32> sample_composition_time_offsets; | |
| 305 | |
| 306 DECLARE_BOX(TrackFragmentRun); | |
| 307 }; | |
| 308 | |
| 309 struct TrackFragment : Box { | |
| 310 TrackFragmentHeader header; | |
| 311 std::vector<TrackFragmentRun> runs; | |
| 312 TrackFragmentDecodeTime decode_time; | |
| 313 SampleAuxiliaryInformationOffset auxiliary_offset; | |
| 314 SampleAuxiliaryInformationSize auxiliary_size; | |
| 315 | |
| 316 DECLARE_BOX(TrackFragment); | |
| 317 }; | |
| 318 | |
| 319 struct MovieFragment : Box { | |
| 320 MovieFragmentHeader header; | |
| 321 std::vector<TrackFragment> tracks; | |
| 322 std::vector<ProtectionSystemSpecificHeader> pssh; | |
| 323 | |
| 324 DECLARE_BOX(MovieFragment); | |
| 325 }; | |
| 326 | |
| 327 #undef DECLARE_BOX | |
| 328 | |
| 329 } // namespace mp4 | |
| 330 } // namespace media | |
| 331 | |
| 332 #endif // MEDIA_MP4_BOX_DEFINITIONS_H_ | |
| OLD | NEW |