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

Unified Diff: media/test/pipeline_integration_test.cc

Issue 1812543003: Allow muting/unmuting audio through media track API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink-sb-tracks6
Patch Set: Avoid ChunkDemuxer/PipelineImpl deadlock Created 4 years, 8 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/renderer_impl.cc ('k') | media/test/pipeline_integration_test_base.cc » ('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 ea8cd6e8c0c97eefdad2279f2c2917ed69362621..f4f4676f29f245b1dad9dcb5699208dcc7c04dc7 100644
--- a/media/test/pipeline_integration_test.cc
+++ b/media/test/pipeline_integration_test.cc
@@ -617,7 +617,7 @@ class MockMediaSource {
CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk);
chunk_demuxer_->SetTracksWatcher(
- kSourceId, base::Bind(&MockMediaSource::InitSegmentReceivedWrapper,
+ kSourceId, base::Bind(&MockMediaSource::InitSegmentReceived,
base::Unretained(this)));
AppendData(initial_append_size_);
@@ -634,12 +634,21 @@ class MockMediaSource {
return last_timestamp_offset_;
}
- // A workaround for gtest mocks not allowing moving scoped_ptrs.
- void InitSegmentReceivedWrapper(scoped_ptr<MediaTracks> tracks) {
- InitSegmentReceived(tracks);
+ void InitSegmentReceived(scoped_ptr<MediaTracks> tracks) {
+ CHECK(tracks.get());
+ EXPECT_GT(tracks->tracks().size(), 0u);
+ CHECK(chunk_demuxer_);
+ // Generate track ids.
+ std::vector<unsigned> track_ids;
+ for (size_t track_id = 1; track_id <= tracks->tracks().size(); ++track_id) {
+ track_ids.push_back(track_id);
+ }
+
+ chunk_demuxer_->OnTrackIdsAssigned(*tracks.get(), track_ids);
+ InitSegmentReceivedMock(tracks);
}
- MOCK_METHOD1(InitSegmentReceived, void(scoped_ptr<MediaTracks>&));
+ MOCK_METHOD1(InitSegmentReceivedMock, void(scoped_ptr<MediaTracks>&));
private:
scoped_refptr<DecoderBuffer> file_data_;
@@ -693,7 +702,7 @@ class PipelineIntegrationTest : public PipelineIntegrationTestHost {
hashing_enabled_ = test_type & kHashed;
clockless_playback_ = test_type & kClockless;
- EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1));
+ EXPECT_CALL(*source, InitSegmentReceivedMock(_)).Times(AtLeast(1));
EXPECT_CALL(*this, OnMetadata(_))
.Times(AtMost(1))
.WillRepeatedly(SaveArg<0>(&metadata_));
@@ -727,7 +736,7 @@ class PipelineIntegrationTest : public PipelineIntegrationTestHost {
void StartPipelineWithEncryptedMedia(MockMediaSource* source,
FakeEncryptedMedia* encrypted_media) {
- EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1));
+ EXPECT_CALL(*source, InitSegmentReceivedMock(_)).Times(AtLeast(1));
EXPECT_CALL(*this, OnMetadata(_))
.Times(AtMost(1))
.WillRepeatedly(SaveArg<0>(&metadata_));
@@ -2135,4 +2144,63 @@ TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
demuxer_->GetStartTime());
}
+TEST_F(PipelineIntegrationTest, AudioTrackMuteUnmute) {
+ ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm"));
+
+ // Start playback and play a little, to ensure demuxer streams are created.
+ Play();
+ ASSERT_TRUE(
+ WaitUntilCurrentTimeIsAfter(base::TimeDelta::FromMilliseconds(200)));
+ Pause();
+
+ const DemuxerStream* demux_stream = demuxer_->GetDemuxerStreamByTrackId(2);
+ EXPECT_NE(demux_stream, nullptr);
+ EXPECT_EQ(demux_stream->type(), DemuxerStream::AUDIO);
+
+ // TODO(servolk): Find a way to verify that audio is really muted/unmuted.
+ // This should mute the audio stream.
+ std::vector<const DemuxerStream*> enabledAudioStreams;
+ pipeline_->OnEnabledAudioStreamsChanged(enabledAudioStreams);
+
+ Play();
+ ASSERT_TRUE(
+ WaitUntilCurrentTimeIsAfter(base::TimeDelta::FromMilliseconds(500)));
+ Pause();
+
+ // This should unmute the audio stream.
+ enabledAudioStreams.push_back(demux_stream);
+ pipeline_->OnEnabledAudioStreamsChanged(enabledAudioStreams);
+
+ Play();
+ ASSERT_TRUE(WaitUntilOnEnded());
+}
+
+TEST_F(PipelineIntegrationTest, VideoTrackSelectDeselect) {
+ ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm"));
+
+ // Start playback and play a little, to ensure demuxer streams are created.
+ Play();
+ ASSERT_TRUE(
+ WaitUntilCurrentTimeIsAfter(base::TimeDelta::FromMilliseconds(200)));
+ Pause();
+
+ const DemuxerStream* demux_stream = demuxer_->GetDemuxerStreamByTrackId(1);
+ EXPECT_NE(demux_stream, nullptr);
+ EXPECT_EQ(demux_stream->type(), DemuxerStream::VIDEO);
+
+ // Deselect video stream.
+ pipeline_->OnSelectedVideoStreamChanged(nullptr);
+
+ Play();
+ ASSERT_TRUE(
+ WaitUntilCurrentTimeIsAfter(base::TimeDelta::FromMilliseconds(500)));
+ Pause();
+
+ // Select video stream.
+ pipeline_->OnSelectedVideoStreamChanged(demux_stream);
+
+ Play();
+ ASSERT_TRUE(WaitUntilOnEnded());
+}
+
} // namespace media
« no previous file with comments | « media/renderers/renderer_impl.cc ('k') | media/test/pipeline_integration_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698