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/base/mock_media_log.h" | |
10 #include "media/formats/mp4/box_definitions.h" | 9 #include "media/formats/mp4/box_definitions.h" |
11 #include "media/formats/mp4/rcheck.h" | 10 #include "media/formats/mp4/rcheck.h" |
12 #include "media/formats/mp4/track_run_iterator.h" | 11 #include "media/formats/mp4/track_run_iterator.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | |
14 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
15 | 13 |
16 using ::testing::StrictMock; | |
17 | |
18 // The sum of the elements in a vector initialized with SumAscending, | 14 // The sum of the elements in a vector initialized with SumAscending, |
19 // less the value of the last element. | 15 // less the value of the last element. |
20 static const int kSumAscending1 = 45; | 16 static const int kSumAscending1 = 45; |
21 | 17 |
22 static const int kAudioScale = 48000; | 18 static const int kAudioScale = 48000; |
23 static const int kVideoScale = 25; | 19 static const int kVideoScale = 25; |
24 | 20 |
25 static const uint8 kAuxInfo[] = { | 21 static const uint8 kAuxInfo[] = { |
26 0x41, 0x54, 0x65, 0x73, 0x74, 0x49, 0x76, 0x31, | 22 0x41, 0x54, 0x65, 0x73, 0x74, 0x49, 0x76, 0x31, |
27 0x41, 0x54, 0x65, 0x73, 0x74, 0x49, 0x76, 0x32, | 23 0x41, 0x54, 0x65, 0x73, 0x74, 0x49, 0x76, 0x32, |
(...skipping 18 matching lines...) Expand all Loading... |
46 }; | 42 }; |
47 | 43 |
48 static const uint8 kFragmentCencSampleGroupKeyId[] = { | 44 static const uint8 kFragmentCencSampleGroupKeyId[] = { |
49 0x6b, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, | 45 0x6b, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, |
50 0x74, 0x43, 0x65, 0x6e, 0x63, 0x53, 0x61, 0x6d | 46 0x74, 0x43, 0x65, 0x6e, 0x63, 0x53, 0x61, 0x6d |
51 }; | 47 }; |
52 | 48 |
53 namespace media { | 49 namespace media { |
54 namespace mp4 { | 50 namespace mp4 { |
55 | 51 |
56 MATCHER(ReservedValueInSampleDependencyInfo, "") { | |
57 return CONTAINS_STRING(arg, "Reserved value used in sample dependency info."); | |
58 } | |
59 | |
60 class TrackRunIteratorTest : public testing::Test { | 52 class TrackRunIteratorTest : public testing::Test { |
61 public: | 53 public: |
62 TrackRunIteratorTest() : media_log_(new StrictMock<MockMediaLog>()) { | 54 TrackRunIteratorTest() : media_log_(new MediaLog()) { CreateMovie(); } |
63 CreateMovie(); | |
64 } | |
65 | 55 |
66 protected: | 56 protected: |
67 Movie moov_; | 57 Movie moov_; |
68 scoped_refptr<StrictMock<MockMediaLog>> media_log_; | 58 scoped_refptr<MediaLog> media_log_; |
69 scoped_ptr<TrackRunIterator> iter_; | 59 scoped_ptr<TrackRunIterator> iter_; |
70 | 60 |
71 void CreateMovie() { | 61 void CreateMovie() { |
72 moov_.header.timescale = 1000; | 62 moov_.header.timescale = 1000; |
73 moov_.tracks.resize(3); | 63 moov_.tracks.resize(3); |
74 moov_.extends.tracks.resize(2); | 64 moov_.extends.tracks.resize(2); |
75 moov_.tracks[0].header.track_id = 1; | 65 moov_.tracks[0].header.track_id = 1; |
76 moov_.tracks[0].media.header.timescale = kAudioScale; | 66 moov_.tracks[0].media.header.timescale = kAudioScale; |
77 SampleDescription& desc1 = | 67 SampleDescription& desc1 = |
78 moov_.tracks[0].media.information.sample_table.description; | 68 moov_.tracks[0].media.information.sample_table.description; |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 382 |
393 ASSERT_TRUE(iter_->Init(moof)); | 383 ASSERT_TRUE(iter_->Init(moof)); |
394 EXPECT_EQ("1 KR KR KR KR KR KR KR KR KR KR", KeyframeAndRAPInfo(iter_.get())); | 384 EXPECT_EQ("1 KR KR KR KR KR KR KR KR KR KR", KeyframeAndRAPInfo(iter_.get())); |
395 | 385 |
396 iter_->AdvanceRun(); | 386 iter_->AdvanceRun(); |
397 EXPECT_EQ("2 KR P P P P P P P P P", KeyframeAndRAPInfo(iter_.get())); | 387 EXPECT_EQ("2 KR P P P P P P P P P", KeyframeAndRAPInfo(iter_.get())); |
398 } | 388 } |
399 | 389 |
400 // Verify that parsing fails if a reserved value is in the sample flags. | 390 // Verify that parsing fails if a reserved value is in the sample flags. |
401 TEST_F(TrackRunIteratorTest, SampleInfoTest_ReservedInSampleFlags) { | 391 TEST_F(TrackRunIteratorTest, SampleInfoTest_ReservedInSampleFlags) { |
402 EXPECT_MEDIA_LOG(ReservedValueInSampleDependencyInfo()); | |
403 iter_.reset(new TrackRunIterator(&moov_, media_log_)); | 392 iter_.reset(new TrackRunIterator(&moov_, media_log_)); |
404 MovieFragment moof = CreateFragment(); | 393 MovieFragment moof = CreateFragment(); |
405 // Change the "depends on" field on one of the samples to a | 394 // Change the "depends on" field on one of the samples to a |
406 // reserved value. | 395 // reserved value. |
407 moof.tracks[1].runs[0].sample_flags[0] = ToSampleFlags("RS"); | 396 moof.tracks[1].runs[0].sample_flags[0] = ToSampleFlags("RS"); |
408 ASSERT_FALSE(iter_->Init(moof)); | 397 ASSERT_FALSE(iter_->Init(moof)); |
409 } | 398 } |
410 | 399 |
411 // Verify that parsing fails if a reserved value is in the default sample flags. | 400 // Verify that parsing fails if a reserved value is in the default sample flags. |
412 TEST_F(TrackRunIteratorTest, SampleInfoTest_ReservedInDefaultSampleFlags) { | 401 TEST_F(TrackRunIteratorTest, SampleInfoTest_ReservedInDefaultSampleFlags) { |
413 EXPECT_MEDIA_LOG(ReservedValueInSampleDependencyInfo()); | |
414 iter_.reset(new TrackRunIterator(&moov_, media_log_)); | 402 iter_.reset(new TrackRunIterator(&moov_, media_log_)); |
415 MovieFragment moof = CreateFragment(); | 403 MovieFragment moof = CreateFragment(); |
416 // Set the default flag to contain a reserved "depends on" value. | 404 // Set the default flag to contain a reserved "depends on" value. |
417 moof.tracks[0].header.default_sample_flags = ToSampleFlags("RN"); | 405 moof.tracks[0].header.default_sample_flags = ToSampleFlags("RN"); |
418 ASSERT_FALSE(iter_->Init(moof)); | 406 ASSERT_FALSE(iter_->Init(moof)); |
419 } | 407 } |
420 | 408 |
421 TEST_F(TrackRunIteratorTest, ReorderingTest) { | 409 TEST_F(TrackRunIteratorTest, ReorderingTest) { |
422 // Test frame reordering and edit list support. The frames have the following | 410 // Test frame reordering and edit list support. The frames have the following |
423 // decode timestamps: | 411 // decode timestamps: |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 | 707 |
720 iter_->AdvanceRun(); | 708 iter_->AdvanceRun(); |
721 | 709 |
722 // Verify that nothing is marked as a random access point. | 710 // Verify that nothing is marked as a random access point. |
723 EXPECT_EQ("2 KR P PR P KR K", KeyframeAndRAPInfo(iter_.get())); | 711 EXPECT_EQ("2 KR P PR P KR K", KeyframeAndRAPInfo(iter_.get())); |
724 } | 712 } |
725 | 713 |
726 | 714 |
727 } // namespace mp4 | 715 } // namespace mp4 |
728 } // namespace media | 716 } // namespace media |
OLD | NEW |