Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: media/test/pipeline_integration_test.cc

Issue 1935873002: Implement disabling and enabling media tracks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@track-control2
Patch Set: Rebase + improve tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/renderers/video_renderer_impl.cc ('k') | media/test/pipeline_integration_test_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::FromSeconds(0)));
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 rendered, 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 rendered 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::FromSeconds(0)));
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 audio has been rendered, since we disabled audio 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());
chcunningham 2016/06/29 22:58:29 Make sure you run these 10 times or so on your loc
servolk 2016/06/29 23:40:13 Yes, my first attempts were also flaky at first, s
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
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
OLDNEW
« no previous file with comments | « media/renderers/video_renderer_impl.cc ('k') | media/test/pipeline_integration_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698