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