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