OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 | 937 |
938 Play(); | 938 Play(); |
939 | 939 |
940 ASSERT_TRUE(WaitUntilOnEnded()); | 940 ASSERT_TRUE(WaitUntilOnEnded()); |
941 | 941 |
942 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); | 942 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); |
943 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); | 943 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); |
944 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); | 944 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); |
945 } | 945 } |
946 | 946 |
| 947 TEST_F(PipelineIntegrationTest, PlaybackWithAudioTrackDisabledThenEnabled) { |
| 948 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
| 949 |
| 950 // Disable audio. |
| 951 std::vector<MediaTrack::Id> empty; |
| 952 pipeline_->OnEnabledAudioTracksChanged(empty); |
| 953 message_loop_.RunUntilIdle(); |
| 954 |
| 955 // Seek to flush the pipeline and ensure there's no prerolled audio data. |
| 956 ASSERT_TRUE(Seek(base::TimeDelta())); |
| 957 |
| 958 Play(); |
| 959 const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500); |
| 960 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); |
| 961 Pause(); |
| 962 |
| 963 // Verify that no audio has been played, since we disabled audio tracks. |
| 964 EXPECT_HASH_EQ(kNullAudioHash, GetAudioHash()); |
| 965 |
| 966 // Re-enable audio. |
| 967 std::vector<MediaTrack::Id> audioTrackId; |
| 968 audioTrackId.push_back("2"); |
| 969 pipeline_->OnEnabledAudioTracksChanged(audioTrackId); |
| 970 message_loop_.RunUntilIdle(); |
| 971 |
| 972 // Restart playback from 500ms position. |
| 973 ASSERT_TRUE(Seek(k500ms)); |
| 974 Play(); |
| 975 ASSERT_TRUE(WaitUntilOnEnded()); |
| 976 |
| 977 // Verify that audio has been playing after being enabled. |
| 978 EXPECT_HASH_EQ("-1.53,0.21,1.23,1.56,-0.34,-0.94,", GetAudioHash()); |
| 979 } |
| 980 |
| 981 TEST_F(PipelineIntegrationTest, PlaybackWithVideoTrackDisabledThenEnabled) { |
| 982 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
| 983 |
| 984 // Disable video. |
| 985 std::vector<MediaTrack::Id> empty; |
| 986 pipeline_->OnSelectedVideoTrackChanged(empty); |
| 987 message_loop_.RunUntilIdle(); |
| 988 |
| 989 // Seek to flush the pipeline and ensure there's no prerolled video data. |
| 990 ASSERT_TRUE(Seek(base::TimeDelta())); |
| 991 |
| 992 // Reset the video hash in case some of the prerolled video frames have been |
| 993 // hashed already. |
| 994 ResetVideoHash(); |
| 995 |
| 996 Play(); |
| 997 const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500); |
| 998 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); |
| 999 Pause(); |
| 1000 |
| 1001 // Verify that no video has been rendered, since we disabled video tracks. |
| 1002 EXPECT_HASH_EQ(kNullVideoHash, GetVideoHash()); |
| 1003 |
| 1004 // Re-enable video. |
| 1005 std::vector<MediaTrack::Id> videoTrackId; |
| 1006 videoTrackId.push_back("1"); |
| 1007 pipeline_->OnSelectedVideoTrackChanged(videoTrackId); |
| 1008 message_loop_.RunUntilIdle(); |
| 1009 |
| 1010 // Seek to flush video pipeline and reset the video hash again to clear state |
| 1011 // if some prerolled frames got hashed after enabling video. |
| 1012 ASSERT_TRUE(Seek(base::TimeDelta())); |
| 1013 ResetVideoHash(); |
| 1014 |
| 1015 // Restart playback from 500ms position. |
| 1016 ASSERT_TRUE(Seek(k500ms)); |
| 1017 Play(); |
| 1018 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1019 |
| 1020 // Verify that video has been rendered after being enabled. |
| 1021 EXPECT_HASH_EQ("fd59357dfd9c144ab4fb8181b2de32c3", GetVideoHash()); |
| 1022 } |
| 1023 |
947 TEST_F(PipelineIntegrationTest, | 1024 TEST_F(PipelineIntegrationTest, |
948 MAYBE_CLOCKLESS(BasicPlaybackOpusOggTrimmingHashed)) { | 1025 MAYBE_CLOCKLESS(BasicPlaybackOpusOggTrimmingHashed)) { |
949 ASSERT_EQ(PIPELINE_OK, | 1026 ASSERT_EQ(PIPELINE_OK, |
950 Start("opus-trimming-test.webm", kHashed | kClockless)); | 1027 Start("opus-trimming-test.webm", kHashed | kClockless)); |
951 | 1028 |
952 Play(); | 1029 Play(); |
953 | 1030 |
954 ASSERT_TRUE(WaitUntilOnEnded()); | 1031 ASSERT_TRUE(WaitUntilOnEnded()); |
955 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); | 1032 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); |
956 | 1033 |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2321 | 2398 |
2322 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2399 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
2323 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2400 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
2324 Play(); | 2401 Play(); |
2325 ASSERT_TRUE(WaitUntilOnEnded()); | 2402 ASSERT_TRUE(WaitUntilOnEnded()); |
2326 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2403 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
2327 demuxer_->GetStartTime()); | 2404 demuxer_->GetStartTime()); |
2328 } | 2405 } |
2329 | 2406 |
2330 } // namespace media | 2407 } // namespace media |
OLD | NEW |