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

Unified 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 Created 4 years, 6 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/test/pipeline_integration_test.cc
diff --git a/media/test/pipeline_integration_test.cc b/media/test/pipeline_integration_test.cc
index 2cd26bd8431ad268ee157359f97459347b75dfd3..1445aaca8a8f91592964e37a764f5a4917bdb368 100644
--- a/media/test/pipeline_integration_test.cc
+++ b/media/test/pipeline_integration_test.cc
@@ -944,6 +944,83 @@ TEST_F(PipelineIntegrationTest, BasicPlaybackHashed) {
EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null());
}
+TEST_F(PipelineIntegrationTest, PlaybackWithAudioTrackDisabledThenEnabled) {
+ ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed));
+
+ // Disable audio.
+ std::vector<MediaTrack::Id> empty;
+ pipeline_->OnEnabledAudioTracksChanged(empty);
+ message_loop_.RunUntilIdle();
+
+ // Seek to flush the pipeline and ensure there's no prerolled audio data.
+ ASSERT_TRUE(Seek(base::TimeDelta()));
+
+ Play();
+ const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500);
+ ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms));
+ Pause();
+
+ // Verify that no audio has been played, since we disabled audio tracks.
+ EXPECT_HASH_EQ(kNullAudioHash, GetAudioHash());
+
+ // Re-enable audio.
+ std::vector<MediaTrack::Id> audioTrackId;
+ audioTrackId.push_back("2");
+ pipeline_->OnEnabledAudioTracksChanged(audioTrackId);
+ message_loop_.RunUntilIdle();
+
+ // Restart playback from 500ms position.
+ ASSERT_TRUE(Seek(k500ms));
+ Play();
+ ASSERT_TRUE(WaitUntilOnEnded());
+
+ // Verify that audio has been playing after being enabled.
+ EXPECT_HASH_EQ("-1.53,0.21,1.23,1.56,-0.34,-0.94,", GetAudioHash());
+}
+
+TEST_F(PipelineIntegrationTest, PlaybackWithVideoTrackDisabledThenEnabled) {
+ ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed));
+
+ // Disable video.
+ std::vector<MediaTrack::Id> empty;
+ pipeline_->OnSelectedVideoTrackChanged(empty);
+ message_loop_.RunUntilIdle();
+
+ // Seek to flush the pipeline and ensure there's no prerolled video data.
+ ASSERT_TRUE(Seek(base::TimeDelta()));
+
+ // Reset the video hash in case some of the prerolled video frames have been
+ // hashed already.
+ ResetVideoHash();
+
+ Play();
+ const base::TimeDelta k500ms = base::TimeDelta::FromMilliseconds(500);
+ ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(k500ms));
+ Pause();
+
+ // Verify that no video has been rendered, since we disabled video tracks.
+ EXPECT_HASH_EQ(kNullVideoHash, GetVideoHash());
+
+ // Re-enable video.
+ std::vector<MediaTrack::Id> videoTrackId;
+ videoTrackId.push_back("1");
+ pipeline_->OnSelectedVideoTrackChanged(videoTrackId);
+ message_loop_.RunUntilIdle();
+
+ // Seek to flush video pipeline and reset the video hash again to clear state
+ // if some prerolled frames got hashed after enabling video.
+ ASSERT_TRUE(Seek(base::TimeDelta()));
+ ResetVideoHash();
+
+ // Restart playback from 500ms position.
+ ASSERT_TRUE(Seek(k500ms));
+ Play();
+ ASSERT_TRUE(WaitUntilOnEnded());
+
+ // Verify that video has been rendered after being enabled.
+ EXPECT_HASH_EQ("fd59357dfd9c144ab4fb8181b2de32c3", GetVideoHash());
+}
+
TEST_F(PipelineIntegrationTest,
MAYBE_CLOCKLESS(BasicPlaybackOpusOggTrimmingHashed)) {
ASSERT_EQ(PIPELINE_OK,
« 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