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 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
956 ASSERT_TRUE(WaitUntilOnEnded()); | 956 ASSERT_TRUE(WaitUntilOnEnded()); |
957 | 957 |
958 // Verify that audio has been playing after being enabled. | 958 // Verify that audio has been playing after being enabled. |
959 EXPECT_HASH_EQ("-1.53,0.21,1.23,1.56,-0.34,-0.94,", GetAudioHash()); | 959 EXPECT_HASH_EQ("-1.53,0.21,1.23,1.56,-0.34,-0.94,", GetAudioHash()); |
960 } | 960 } |
961 | 961 |
962 TEST_F(PipelineIntegrationTest, PlaybackWithVideoTrackDisabledThenEnabled) { | 962 TEST_F(PipelineIntegrationTest, PlaybackWithVideoTrackDisabledThenEnabled) { |
963 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | 963 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
964 | 964 |
965 // Disable video. | 965 // Disable video. |
966 std::vector<MediaTrack::Id> empty; | 966 pipeline_->OnSelectedVideoTrackChanged(base::Optional<MediaTrack::Id>()); |
watk
2017/02/23 20:57:54
should be able to write nullopt here and elsewhere
servolk
2017/02/23 21:15:48
Done.
| |
967 pipeline_->OnSelectedVideoTrackChanged(empty); | |
968 base::RunLoop().RunUntilIdle(); | 967 base::RunLoop().RunUntilIdle(); |
969 | 968 |
970 // Seek to flush the pipeline and ensure there's no prerolled video data. | 969 // Seek to flush the pipeline and ensure there's no prerolled video data. |
971 ASSERT_TRUE(Seek(base::TimeDelta())); | 970 ASSERT_TRUE(Seek(base::TimeDelta())); |
972 | 971 |
973 // Reset the video hash in case some of the prerolled video frames have been | 972 // Reset the video hash in case some of the prerolled video frames have been |
974 // hashed already. | 973 // hashed already. |
975 ResetVideoHash(); | 974 ResetVideoHash(); |
976 | 975 |
977 Play(); | 976 Play(); |
978 const base::TimeDelta k500ms = TimestampMs(500); | 977 const base::TimeDelta k500ms = TimestampMs(500); |
979 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); | 978 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms)); |
980 Pause(); | 979 Pause(); |
981 | 980 |
982 // Verify that no video has been rendered, since we disabled video tracks. | 981 // Verify that no video has been rendered, since we disabled video tracks. |
983 EXPECT_HASH_EQ(kNullVideoHash, GetVideoHash()); | 982 EXPECT_HASH_EQ(kNullVideoHash, GetVideoHash()); |
984 | 983 |
985 // Re-enable video. | 984 // Re-enable video. |
986 std::vector<MediaTrack::Id> videoTrackId; | 985 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); |
987 videoTrackId.push_back("1"); | |
988 pipeline_->OnSelectedVideoTrackChanged(videoTrackId); | |
989 base::RunLoop().RunUntilIdle(); | 986 base::RunLoop().RunUntilIdle(); |
990 | 987 |
991 // Seek to flush video pipeline and reset the video hash again to clear state | 988 // Seek to flush video pipeline and reset the video hash again to clear state |
992 // if some prerolled frames got hashed after enabling video. | 989 // if some prerolled frames got hashed after enabling video. |
993 ASSERT_TRUE(Seek(base::TimeDelta())); | 990 ASSERT_TRUE(Seek(base::TimeDelta())); |
994 ResetVideoHash(); | 991 ResetVideoHash(); |
995 | 992 |
996 // Restart playback from 500ms position. | 993 // Restart playback from 500ms position. |
997 ASSERT_TRUE(Seek(k500ms)); | 994 ASSERT_TRUE(Seek(k500ms)); |
998 Play(); | 995 Play(); |
999 ASSERT_TRUE(WaitUntilOnEnded()); | 996 ASSERT_TRUE(WaitUntilOnEnded()); |
1000 | 997 |
1001 // Verify that video has been rendered after being enabled. | 998 // Verify that video has been rendered after being enabled. |
1002 EXPECT_HASH_EQ("fd59357dfd9c144ab4fb8181b2de32c3", GetVideoHash()); | 999 EXPECT_HASH_EQ("fd59357dfd9c144ab4fb8181b2de32c3", GetVideoHash()); |
1003 } | 1000 } |
1004 | 1001 |
1005 TEST_F(PipelineIntegrationTest, TrackStatusChangesBeforePipelineStarted) { | 1002 TEST_F(PipelineIntegrationTest, TrackStatusChangesBeforePipelineStarted) { |
1006 std::vector<MediaTrack::Id> empty_track_ids; | 1003 std::vector<MediaTrack::Id> empty_track_ids; |
1007 pipeline_->OnEnabledAudioTracksChanged(empty_track_ids); | 1004 pipeline_->OnEnabledAudioTracksChanged(empty_track_ids); |
1008 pipeline_->OnSelectedVideoTrackChanged(empty_track_ids); | 1005 pipeline_->OnSelectedVideoTrackChanged(base::Optional<MediaTrack::Id>()); |
1009 } | 1006 } |
1010 | 1007 |
1011 TEST_F(PipelineIntegrationTest, TrackStatusChangesAfterPipelineEnded) { | 1008 TEST_F(PipelineIntegrationTest, TrackStatusChangesAfterPipelineEnded) { |
1012 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | 1009 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
1013 Play(); | 1010 Play(); |
1014 ASSERT_TRUE(WaitUntilOnEnded()); | 1011 ASSERT_TRUE(WaitUntilOnEnded()); |
1015 std::vector<MediaTrack::Id> track_ids; | 1012 std::vector<MediaTrack::Id> track_ids; |
1016 // Disable audio track. | 1013 // Disable audio track. |
1017 pipeline_->OnEnabledAudioTracksChanged(track_ids); | 1014 pipeline_->OnEnabledAudioTracksChanged(track_ids); |
1018 // Re-enable audio track. | 1015 // Re-enable audio track. |
1019 track_ids.push_back("2"); | 1016 track_ids.push_back("2"); |
1020 pipeline_->OnEnabledAudioTracksChanged(track_ids); | 1017 pipeline_->OnEnabledAudioTracksChanged(track_ids); |
1021 // Disable video track. | 1018 // Disable video track. |
1022 track_ids.clear(); | 1019 pipeline_->OnSelectedVideoTrackChanged(base::Optional<MediaTrack::Id>()); |
1023 pipeline_->OnSelectedVideoTrackChanged(track_ids); | |
1024 // Re-enable video track. | 1020 // Re-enable video track. |
1025 track_ids.push_back("1"); | 1021 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); |
1026 pipeline_->OnSelectedVideoTrackChanged(track_ids); | |
1027 } | 1022 } |
1028 | 1023 |
1029 TEST_F(PipelineIntegrationTest, TrackStatusChangesWhileSuspended) { | 1024 TEST_F(PipelineIntegrationTest, TrackStatusChangesWhileSuspended) { |
1030 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | 1025 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
1031 Play(); | 1026 Play(); |
1032 | 1027 |
1033 ASSERT_TRUE(Suspend()); | 1028 ASSERT_TRUE(Suspend()); |
1034 | 1029 |
1035 // These get triggered every time playback is resumed. | 1030 // These get triggered every time playback is resumed. |
1036 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))) | 1031 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))) |
1037 .Times(AnyNumber()); | 1032 .Times(AnyNumber()); |
1038 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(AnyNumber()); | 1033 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(AnyNumber()); |
1039 | 1034 |
1040 std::vector<MediaTrack::Id> track_ids; | 1035 std::vector<MediaTrack::Id> track_ids; |
1041 | 1036 |
1042 // Disable audio track. | 1037 // Disable audio track. |
1043 pipeline_->OnEnabledAudioTracksChanged(track_ids); | 1038 pipeline_->OnEnabledAudioTracksChanged(track_ids); |
1044 ASSERT_TRUE(Resume(TimestampMs(100))); | 1039 ASSERT_TRUE(Resume(TimestampMs(100))); |
1045 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); | 1040 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); |
1046 ASSERT_TRUE(Suspend()); | 1041 ASSERT_TRUE(Suspend()); |
1047 | 1042 |
1048 // Re-enable audio track. | 1043 // Re-enable audio track. |
1049 track_ids.push_back("2"); | 1044 track_ids.push_back("2"); |
1050 pipeline_->OnEnabledAudioTracksChanged(track_ids); | 1045 pipeline_->OnEnabledAudioTracksChanged(track_ids); |
1051 ASSERT_TRUE(Resume(TimestampMs(200))); | 1046 ASSERT_TRUE(Resume(TimestampMs(200))); |
1052 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(300))); | 1047 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(300))); |
1053 ASSERT_TRUE(Suspend()); | 1048 ASSERT_TRUE(Suspend()); |
1054 | 1049 |
1055 // Disable video track. | 1050 // Disable video track. |
1056 track_ids.clear(); | 1051 pipeline_->OnSelectedVideoTrackChanged(base::Optional<MediaTrack::Id>()); |
1057 pipeline_->OnSelectedVideoTrackChanged(track_ids); | |
1058 ASSERT_TRUE(Resume(TimestampMs(300))); | 1052 ASSERT_TRUE(Resume(TimestampMs(300))); |
1059 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(400))); | 1053 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(400))); |
1060 ASSERT_TRUE(Suspend()); | 1054 ASSERT_TRUE(Suspend()); |
1061 | 1055 |
1062 // Re-enable video track. | 1056 // Re-enable video track. |
1063 track_ids.push_back("1"); | 1057 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); |
1064 pipeline_->OnSelectedVideoTrackChanged(track_ids); | |
1065 ASSERT_TRUE(Resume(TimestampMs(400))); | 1058 ASSERT_TRUE(Resume(TimestampMs(400))); |
1066 ASSERT_TRUE(WaitUntilOnEnded()); | 1059 ASSERT_TRUE(WaitUntilOnEnded()); |
1067 } | 1060 } |
1068 | 1061 |
1069 TEST_F(PipelineIntegrationTest, PipelineStoppedWhileAudioRestartPending) { | 1062 TEST_F(PipelineIntegrationTest, PipelineStoppedWhileAudioRestartPending) { |
1070 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 1063 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
1071 Play(); | 1064 Play(); |
1072 | 1065 |
1073 // Disable audio track first, to re-enable it later and stop the pipeline | 1066 // Disable audio track first, to re-enable it later and stop the pipeline |
1074 // (which destroys the media renderer) while audio restart is pending. | 1067 // (which destroys the media renderer) while audio restart is pending. |
1075 std::vector<MediaTrack::Id> track_ids; | 1068 std::vector<MediaTrack::Id> track_ids; |
1076 pipeline_->OnEnabledAudioTracksChanged(track_ids); | 1069 pipeline_->OnEnabledAudioTracksChanged(track_ids); |
1077 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); | 1070 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); |
1078 | 1071 |
1079 track_ids.push_back("2"); | 1072 track_ids.push_back("2"); |
1080 pipeline_->OnEnabledAudioTracksChanged(track_ids); | 1073 pipeline_->OnEnabledAudioTracksChanged(track_ids); |
1081 Stop(); | 1074 Stop(); |
1082 } | 1075 } |
1083 | 1076 |
1084 TEST_F(PipelineIntegrationTest, PipelineStoppedWhileVideoRestartPending) { | 1077 TEST_F(PipelineIntegrationTest, PipelineStoppedWhileVideoRestartPending) { |
1085 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 1078 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
1086 Play(); | 1079 Play(); |
1087 | 1080 |
1088 // Disable video track first, to re-enable it later and stop the pipeline | 1081 // Disable video track first, to re-enable it later and stop the pipeline |
1089 // (which destroys the media renderer) while video restart is pending. | 1082 // (which destroys the media renderer) while video restart is pending. |
1090 std::vector<MediaTrack::Id> track_ids; | 1083 pipeline_->OnSelectedVideoTrackChanged(base::Optional<MediaTrack::Id>()); |
1091 pipeline_->OnSelectedVideoTrackChanged(track_ids); | |
1092 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); | 1084 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); |
1093 | 1085 |
1094 track_ids.push_back("1"); | 1086 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); |
1095 pipeline_->OnSelectedVideoTrackChanged(track_ids); | |
1096 Stop(); | 1087 Stop(); |
1097 } | 1088 } |
1098 | 1089 |
1099 TEST_F(PipelineIntegrationTest, | 1090 TEST_F(PipelineIntegrationTest, |
1100 MAYBE_CLOCKLESS(BasicPlaybackOpusOggTrimmingHashed)) { | 1091 MAYBE_CLOCKLESS(BasicPlaybackOpusOggTrimmingHashed)) { |
1101 ASSERT_EQ(PIPELINE_OK, | 1092 ASSERT_EQ(PIPELINE_OK, |
1102 Start("opus-trimming-test.webm", kHashed | kClockless)); | 1093 Start("opus-trimming-test.webm", kHashed | kClockless)); |
1103 | 1094 |
1104 Play(); | 1095 Play(); |
1105 | 1096 |
(...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2583 | 2574 |
2584 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2575 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
2585 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2576 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
2586 Play(); | 2577 Play(); |
2587 ASSERT_TRUE(WaitUntilOnEnded()); | 2578 ASSERT_TRUE(WaitUntilOnEnded()); |
2588 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2579 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
2589 demuxer_->GetStartTime()); | 2580 demuxer_->GetStartTime()); |
2590 } | 2581 } |
2591 | 2582 |
2592 } // namespace media | 2583 } // namespace media |
OLD | NEW |