| 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 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 | 916 |
| 917 Play(); | 917 Play(); |
| 918 | 918 |
| 919 ASSERT_TRUE(WaitUntilOnEnded()); | 919 ASSERT_TRUE(WaitUntilOnEnded()); |
| 920 | 920 |
| 921 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); | 921 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); |
| 922 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); | 922 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); |
| 923 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); | 923 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); |
| 924 } | 924 } |
| 925 | 925 |
| 926 base::TimeDelta TimestampMs(int milliseconds) { | |
| 927 return base::TimeDelta::FromMilliseconds(milliseconds); | |
| 928 } | |
| 929 | |
| 930 TEST_F(PipelineIntegrationTest, PlaybackWithAudioTrackDisabledThenEnabled) { | 926 TEST_F(PipelineIntegrationTest, PlaybackWithAudioTrackDisabledThenEnabled) { |
| 931 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | 927 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
| 932 | 928 |
| 933 // Disable audio. | 929 // Disable audio. |
| 934 std::vector<MediaTrack::Id> empty; | 930 std::vector<MediaTrack::Id> empty; |
| 935 pipeline_->OnEnabledAudioTracksChanged(empty); | 931 pipeline_->OnEnabledAudioTracksChanged(empty); |
| 936 base::RunLoop().RunUntilIdle(); | 932 base::RunLoop().RunUntilIdle(); |
| 937 | 933 |
| 938 // Seek to flush the pipeline and ensure there's no prerolled audio data. | 934 // Seek to flush the pipeline and ensure there's no prerolled audio data. |
| 939 ASSERT_TRUE(Seek(base::TimeDelta())); | 935 ASSERT_TRUE(Seek(base::TimeDelta())); |
| 940 | 936 |
| 941 Play(); | 937 Play(); |
| 942 const base::TimeDelta k500ms = TimestampMs(500); | 938 const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500); |
| 943 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); | 939 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); |
| 944 Pause(); | 940 Pause(); |
| 945 | 941 |
| 946 // Verify that no audio has been played, since we disabled audio tracks. | 942 // Verify that no audio has been played, since we disabled audio tracks. |
| 947 EXPECT_HASH_EQ(kNullAudioHash, GetAudioHash()); | 943 EXPECT_HASH_EQ(kNullAudioHash, GetAudioHash()); |
| 948 | 944 |
| 949 // Re-enable audio. | 945 // Re-enable audio. |
| 950 std::vector<MediaTrack::Id> audioTrackId; | 946 std::vector<MediaTrack::Id> audioTrackId; |
| 951 audioTrackId.push_back("2"); | 947 audioTrackId.push_back("2"); |
| 952 pipeline_->OnEnabledAudioTracksChanged(audioTrackId); | 948 pipeline_->OnEnabledAudioTracksChanged(audioTrackId); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 970 base::RunLoop().RunUntilIdle(); | 966 base::RunLoop().RunUntilIdle(); |
| 971 | 967 |
| 972 // Seek to flush the pipeline and ensure there's no prerolled video data. | 968 // Seek to flush the pipeline and ensure there's no prerolled video data. |
| 973 ASSERT_TRUE(Seek(base::TimeDelta())); | 969 ASSERT_TRUE(Seek(base::TimeDelta())); |
| 974 | 970 |
| 975 // Reset the video hash in case some of the prerolled video frames have been | 971 // Reset the video hash in case some of the prerolled video frames have been |
| 976 // hashed already. | 972 // hashed already. |
| 977 ResetVideoHash(); | 973 ResetVideoHash(); |
| 978 | 974 |
| 979 Play(); | 975 Play(); |
| 980 const base::TimeDelta k500ms = TimestampMs(500); | 976 const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500); |
| 981 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); | 977 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); |
| 982 Pause(); | 978 Pause(); |
| 983 | 979 |
| 984 // Verify that no video has been rendered, since we disabled video tracks. | 980 // Verify that no video has been rendered, since we disabled video tracks. |
| 985 EXPECT_HASH_EQ(kNullVideoHash, GetVideoHash()); | 981 EXPECT_HASH_EQ(kNullVideoHash, GetVideoHash()); |
| 986 | 982 |
| 987 // Re-enable video. | 983 // Re-enable video. |
| 988 std::vector<MediaTrack::Id> videoTrackId; | 984 std::vector<MediaTrack::Id> videoTrackId; |
| 989 videoTrackId.push_back("1"); | 985 videoTrackId.push_back("1"); |
| 990 pipeline_->OnSelectedVideoTrackChanged(videoTrackId); | 986 pipeline_->OnSelectedVideoTrackChanged(videoTrackId); |
| 991 base::RunLoop().RunUntilIdle(); | 987 base::RunLoop().RunUntilIdle(); |
| 992 | 988 |
| 993 // Seek to flush video pipeline and reset the video hash again to clear state | 989 // Seek to flush video pipeline and reset the video hash again to clear state |
| 994 // if some prerolled frames got hashed after enabling video. | 990 // if some prerolled frames got hashed after enabling video. |
| 995 ASSERT_TRUE(Seek(base::TimeDelta())); | 991 ASSERT_TRUE(Seek(base::TimeDelta())); |
| 996 ResetVideoHash(); | 992 ResetVideoHash(); |
| 997 | 993 |
| 998 // Restart playback from 500ms position. | 994 // Restart playback from 500ms position. |
| 999 ASSERT_TRUE(Seek(k500ms)); | 995 ASSERT_TRUE(Seek(k500ms)); |
| 1000 Play(); | 996 Play(); |
| 1001 ASSERT_TRUE(WaitUntilOnEnded()); | 997 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1002 | 998 |
| 1003 // Verify that video has been rendered after being enabled. | 999 // Verify that video has been rendered after being enabled. |
| 1004 EXPECT_HASH_EQ("fd59357dfd9c144ab4fb8181b2de32c3", GetVideoHash()); | 1000 EXPECT_HASH_EQ("fd59357dfd9c144ab4fb8181b2de32c3", GetVideoHash()); |
| 1005 } | 1001 } |
| 1006 | 1002 |
| 1007 TEST_F(PipelineIntegrationTest, TrackStatusChangesAfterPipelineEnded) { | |
| 1008 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | |
| 1009 Play(); | |
| 1010 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 1011 std::vector<MediaTrack::Id> track_ids; | |
| 1012 // Disable audio track. | |
| 1013 pipeline_->OnEnabledAudioTracksChanged(track_ids); | |
| 1014 // Re-enable audio track. | |
| 1015 track_ids.push_back("2"); | |
| 1016 pipeline_->OnEnabledAudioTracksChanged(track_ids); | |
| 1017 // Disable video track. | |
| 1018 track_ids.clear(); | |
| 1019 pipeline_->OnSelectedVideoTrackChanged(track_ids); | |
| 1020 // Re-enable video track. | |
| 1021 track_ids.push_back("1"); | |
| 1022 pipeline_->OnSelectedVideoTrackChanged(track_ids); | |
| 1023 } | |
| 1024 | |
| 1025 TEST_F(PipelineIntegrationTest, TrackStatusChangesWhileSuspended) { | |
| 1026 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | |
| 1027 Play(); | |
| 1028 | |
| 1029 ASSERT_TRUE(Suspend()); | |
| 1030 | |
| 1031 // These get triggered every time playback is resumed. | |
| 1032 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))) | |
| 1033 .Times(AnyNumber()); | |
| 1034 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(AnyNumber()); | |
| 1035 | |
| 1036 std::vector<MediaTrack::Id> track_ids; | |
| 1037 | |
| 1038 // Disable audio track. | |
| 1039 pipeline_->OnEnabledAudioTracksChanged(track_ids); | |
| 1040 ASSERT_TRUE(Resume(TimestampMs(100))); | |
| 1041 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); | |
| 1042 ASSERT_TRUE(Suspend()); | |
| 1043 | |
| 1044 // Re-enable audio track. | |
| 1045 track_ids.push_back("2"); | |
| 1046 pipeline_->OnEnabledAudioTracksChanged(track_ids); | |
| 1047 ASSERT_TRUE(Resume(TimestampMs(200))); | |
| 1048 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(300))); | |
| 1049 ASSERT_TRUE(Suspend()); | |
| 1050 | |
| 1051 // Disable video track. | |
| 1052 track_ids.clear(); | |
| 1053 pipeline_->OnSelectedVideoTrackChanged(track_ids); | |
| 1054 ASSERT_TRUE(Resume(TimestampMs(300))); | |
| 1055 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(400))); | |
| 1056 ASSERT_TRUE(Suspend()); | |
| 1057 | |
| 1058 // Re-enable video track. | |
| 1059 track_ids.push_back("1"); | |
| 1060 pipeline_->OnSelectedVideoTrackChanged(track_ids); | |
| 1061 ASSERT_TRUE(Resume(TimestampMs(400))); | |
| 1062 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 1063 } | |
| 1064 | |
| 1065 TEST_F(PipelineIntegrationTest, | 1003 TEST_F(PipelineIntegrationTest, |
| 1066 MAYBE_CLOCKLESS(BasicPlaybackOpusOggTrimmingHashed)) { | 1004 MAYBE_CLOCKLESS(BasicPlaybackOpusOggTrimmingHashed)) { |
| 1067 ASSERT_EQ(PIPELINE_OK, | 1005 ASSERT_EQ(PIPELINE_OK, |
| 1068 Start("opus-trimming-test.webm", kHashed | kClockless)); | 1006 Start("opus-trimming-test.webm", kHashed | kClockless)); |
| 1069 | 1007 |
| 1070 Play(); | 1008 Play(); |
| 1071 | 1009 |
| 1072 ASSERT_TRUE(WaitUntilOnEnded()); | 1010 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1073 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); | 1011 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); |
| 1074 | 1012 |
| (...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2439 | 2377 |
| 2440 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2378 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
| 2441 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2379 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
| 2442 Play(); | 2380 Play(); |
| 2443 ASSERT_TRUE(WaitUntilOnEnded()); | 2381 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2444 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2382 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
| 2445 demuxer_->GetStartTime()); | 2383 demuxer_->GetStartTime()); |
| 2446 } | 2384 } |
| 2447 | 2385 |
| 2448 } // namespace media | 2386 } // namespace media |
| OLD | NEW |