| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "media/formats/mp4/box_definitions.h" | 9 #include "media/formats/mp4/box_definitions.h" |
| 10 #include "media/formats/mp4/rcheck.h" | 10 #include "media/formats/mp4/rcheck.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 switch(str[0]) { | 101 switch(str[0]) { |
| 102 case 'U': | 102 case 'U': |
| 103 sample_depends_on = kSampleDependsOnUnknown; | 103 sample_depends_on = kSampleDependsOnUnknown; |
| 104 break; | 104 break; |
| 105 case 'O': | 105 case 'O': |
| 106 sample_depends_on = kSampleDependsOnOthers; | 106 sample_depends_on = kSampleDependsOnOthers; |
| 107 break; | 107 break; |
| 108 case 'N': | 108 case 'N': |
| 109 sample_depends_on = kSampleDependsOnNoOther; | 109 sample_depends_on = kSampleDependsOnNoOther; |
| 110 break; | 110 break; |
| 111 case 'R': |
| 112 sample_depends_on = kSampleDependsOnReserved; |
| 113 break; |
| 111 default: | 114 default: |
| 112 CHECK(false) << "Invalid sample dependency character '" | 115 CHECK(false) << "Invalid sample dependency character '" |
| 113 << str[0] << "'"; | 116 << str[0] << "'"; |
| 114 break; | 117 break; |
| 115 } | 118 } |
| 116 | 119 |
| 117 switch(str[1]) { | 120 switch(str[1]) { |
| 118 case 'S': | 121 case 'S': |
| 119 is_non_sync_sample = false; | 122 is_non_sync_sample = false; |
| 120 break; | 123 break; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 moof.tracks[1].header.default_sample_flags = ToSampleFlags("UN"); | 365 moof.tracks[1].header.default_sample_flags = ToSampleFlags("UN"); |
| 363 SetFlagsOnSamples("US", &moof.tracks[1].runs[0]); | 366 SetFlagsOnSamples("US", &moof.tracks[1].runs[0]); |
| 364 | 367 |
| 365 ASSERT_TRUE(iter_->Init(moof)); | 368 ASSERT_TRUE(iter_->Init(moof)); |
| 366 EXPECT_EQ("1 KR KR KR KR KR KR KR KR KR KR", KeyframeAndRAPInfo(iter_.get())); | 369 EXPECT_EQ("1 KR KR KR KR KR KR KR KR KR KR", KeyframeAndRAPInfo(iter_.get())); |
| 367 | 370 |
| 368 iter_->AdvanceRun(); | 371 iter_->AdvanceRun(); |
| 369 EXPECT_EQ("2 KR P P P P P P P P P", KeyframeAndRAPInfo(iter_.get())); | 372 EXPECT_EQ("2 KR P P P P P P P P P", KeyframeAndRAPInfo(iter_.get())); |
| 370 } | 373 } |
| 371 | 374 |
| 375 // Verify that parsing fails if a reserved value is in the sample flags. |
| 376 TEST_F(TrackRunIteratorTest, SampleInfoTest_ReservedInSampleFlags) { |
| 377 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); |
| 378 MovieFragment moof = CreateFragment(); |
| 379 // Change the "depends on" field on one of the samples to a |
| 380 // reserved value. |
| 381 moof.tracks[1].runs[0].sample_flags[0] = ToSampleFlags("RS"); |
| 382 ASSERT_FALSE(iter_->Init(moof)); |
| 383 } |
| 384 |
| 385 // Verify that parsing fails if a reserved value is in the default sample flags. |
| 386 TEST_F(TrackRunIteratorTest, SampleInfoTest_ReservedInDefaultSampleFlags) { |
| 387 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); |
| 388 MovieFragment moof = CreateFragment(); |
| 389 // Set the default flag to contain a reserved "depends on" value. |
| 390 moof.tracks[0].header.default_sample_flags = ToSampleFlags("RN"); |
| 391 ASSERT_FALSE(iter_->Init(moof)); |
| 392 } |
| 393 |
| 372 TEST_F(TrackRunIteratorTest, ReorderingTest) { | 394 TEST_F(TrackRunIteratorTest, ReorderingTest) { |
| 373 // Test frame reordering and edit list support. The frames have the following | 395 // Test frame reordering and edit list support. The frames have the following |
| 374 // decode timestamps: | 396 // decode timestamps: |
| 375 // | 397 // |
| 376 // 0ms 40ms 120ms 240ms | 398 // 0ms 40ms 120ms 240ms |
| 377 // | 0 | 1 - | 2 - - | | 399 // | 0 | 1 - | 2 - - | |
| 378 // | 400 // |
| 379 // ...and these composition timestamps, after edit list adjustment: | 401 // ...and these composition timestamps, after edit list adjustment: |
| 380 // | 402 // |
| 381 // 0ms 40ms 160ms 240ms | 403 // 0ms 40ms 160ms 240ms |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 | 679 |
| 658 iter_->AdvanceRun(); | 680 iter_->AdvanceRun(); |
| 659 | 681 |
| 660 // Verify that nothing is marked as a random access point. | 682 // Verify that nothing is marked as a random access point. |
| 661 EXPECT_EQ("2 KR P PR P KR K", KeyframeAndRAPInfo(iter_.get())); | 683 EXPECT_EQ("2 KR P PR P KR K", KeyframeAndRAPInfo(iter_.get())); |
| 662 } | 684 } |
| 663 | 685 |
| 664 | 686 |
| 665 } // namespace mp4 | 687 } // namespace mp4 |
| 666 } // namespace media | 688 } // namespace media |
| OLD | NEW |