| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/formats/mp4/box_definitions.h" | 5 #include "media/formats/mp4/box_definitions.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/formats/mp4/es_descriptor.h" | 8 #include "media/formats/mp4/es_descriptor.h" |
| 9 #include "media/formats/mp4/rcheck.h" | 9 #include "media/formats/mp4/rcheck.h" |
| 10 | 10 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // Note: this value is preset before scanning begins. See comments in the | 293 // Note: this value is preset before scanning begins. See comments in the |
| 294 // Parse(Media*) function. | 294 // Parse(Media*) function. |
| 295 if (type == kVideo) { | 295 if (type == kVideo) { |
| 296 RCHECK(reader->ReadAllChildren(&video_entries)); | 296 RCHECK(reader->ReadAllChildren(&video_entries)); |
| 297 } else if (type == kAudio) { | 297 } else if (type == kAudio) { |
| 298 RCHECK(reader->ReadAllChildren(&audio_entries)); | 298 RCHECK(reader->ReadAllChildren(&audio_entries)); |
| 299 } | 299 } |
| 300 return true; | 300 return true; |
| 301 } | 301 } |
| 302 | 302 |
| 303 SyncSample::SyncSample() : is_present(false) {} | |
| 304 SyncSample::~SyncSample() {} | |
| 305 FourCC SyncSample::BoxType() const { return FOURCC_STSS; } | |
| 306 | |
| 307 bool SyncSample::Parse(BoxReader* reader) { | |
| 308 uint32 entry_count; | |
| 309 RCHECK(reader->ReadFullBoxHeader() && | |
| 310 reader->Read4(&entry_count)); | |
| 311 | |
| 312 is_present = true; | |
| 313 | |
| 314 entries.resize(entry_count); | |
| 315 | |
| 316 if (entry_count == 0) | |
| 317 return true; | |
| 318 | |
| 319 for (size_t i = 0; i < entry_count; ++i) | |
| 320 RCHECK(reader->Read4(&entries[i])); | |
| 321 | |
| 322 return true; | |
| 323 } | |
| 324 | |
| 325 bool SyncSample::IsSyncSample(size_t k) const { | |
| 326 // ISO/IEC 14496-12 Section 8.6.2.1 : If the sync sample box is not present, | |
| 327 // every sample is a sync sample. | |
| 328 if (!is_present) | |
| 329 return true; | |
| 330 | |
| 331 // ISO/IEC 14496-12 Section 8.6.2.3 : If entry_count is zero, there are no | |
| 332 // sync samples within the stream. | |
| 333 if (entries.size() == 0u) | |
| 334 return false; | |
| 335 | |
| 336 for (size_t i = 0; i < entries.size(); ++i) { | |
| 337 if (entries[i] == k) | |
| 338 return true; | |
| 339 } | |
| 340 | |
| 341 return false; | |
| 342 } | |
| 343 | |
| 344 SampleTable::SampleTable() {} | 303 SampleTable::SampleTable() {} |
| 345 SampleTable::~SampleTable() {} | 304 SampleTable::~SampleTable() {} |
| 346 FourCC SampleTable::BoxType() const { return FOURCC_STBL; } | 305 FourCC SampleTable::BoxType() const { return FOURCC_STBL; } |
| 347 | 306 |
| 348 bool SampleTable::Parse(BoxReader* reader) { | 307 bool SampleTable::Parse(BoxReader* reader) { |
| 349 RCHECK(reader->ScanChildren() && | 308 RCHECK(reader->ScanChildren() && |
| 350 reader->ReadChild(&description) && | 309 reader->ReadChild(&description)); |
| 351 reader->MaybeReadChild(&sync_sample)); | |
| 352 // There could be multiple SampleGroupDescription boxes with different | 310 // There could be multiple SampleGroupDescription boxes with different |
| 353 // grouping types. For common encryption, the relevant grouping type is | 311 // grouping types. For common encryption, the relevant grouping type is |
| 354 // 'seig'. Continue reading until 'seig' is found, or until running out of | 312 // 'seig'. Continue reading until 'seig' is found, or until running out of |
| 355 // child boxes. | 313 // child boxes. |
| 356 while (reader->HasChild(&sample_group_description)) { | 314 while (reader->HasChild(&sample_group_description)) { |
| 357 RCHECK(reader->ReadChild(&sample_group_description)); | 315 RCHECK(reader->ReadChild(&sample_group_description)); |
| 358 if (sample_group_description.grouping_type == FOURCC_SEIG) | 316 if (sample_group_description.grouping_type == FOURCC_SEIG) |
| 359 break; | 317 break; |
| 360 sample_group_description.entries.clear(); | 318 sample_group_description.entries.clear(); |
| 361 } | 319 } |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on( | 987 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on( |
| 1030 size_t i) const { | 988 size_t i) const { |
| 1031 if (i >= sample_depends_on_.size()) | 989 if (i >= sample_depends_on_.size()) |
| 1032 return kSampleDependsOnUnknown; | 990 return kSampleDependsOnUnknown; |
| 1033 | 991 |
| 1034 return sample_depends_on_[i]; | 992 return sample_depends_on_[i]; |
| 1035 } | 993 } |
| 1036 | 994 |
| 1037 } // namespace mp4 | 995 } // namespace mp4 |
| 1038 } // namespace media | 996 } // namespace media |
| OLD | NEW |