| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/threading/simple_thread.h" | 10 #include "base/threading/simple_thread.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(0.0f)); | 146 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(0.0f)); |
| 147 EXPECT_CALL(*mocks_->audio_decoder(), Seek(base::TimeDelta(), _)) | 147 EXPECT_CALL(*mocks_->audio_decoder(), Seek(base::TimeDelta(), _)) |
| 148 .WillOnce(Invoke(&RunFilterStatusCB)); | 148 .WillOnce(Invoke(&RunFilterStatusCB)); |
| 149 EXPECT_CALL(*mocks_->audio_decoder(), Stop(_)) | 149 EXPECT_CALL(*mocks_->audio_decoder(), Stop(_)) |
| 150 .WillOnce(Invoke(&RunStopFilterCallback)); | 150 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 // Sets up expectations to allow the video renderer to initialize. | 153 // Sets up expectations to allow the video renderer to initialize. |
| 154 void InitializeVideoRenderer() { | 154 void InitializeVideoRenderer() { |
| 155 EXPECT_CALL(*mocks_->video_renderer(), | 155 EXPECT_CALL(*mocks_->video_renderer(), |
| 156 Initialize(mocks_->video_decoder(), _, _)) | 156 Initialize(mocks_->video_decoder(), _, _, _)) |
| 157 .WillOnce(Invoke(&RunPipelineStatusCB3)); | 157 .WillOnce(Invoke(&RunPipelineStatusCB4)); |
| 158 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); | 158 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); |
| 159 EXPECT_CALL(*mocks_->video_renderer(), | 159 EXPECT_CALL(*mocks_->video_renderer(), |
| 160 Seek(mocks_->demuxer()->GetStartTime(), _)) | 160 Seek(mocks_->demuxer()->GetStartTime(), _)) |
| 161 .WillOnce(Invoke(&RunFilterStatusCB)); | 161 .WillOnce(Invoke(&RunFilterStatusCB)); |
| 162 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) | 162 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) |
| 163 .WillOnce(Invoke(&RunStopFilterCallback)); | 163 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 164 } | 164 } |
| 165 | 165 |
| 166 // Sets up expectations to allow the audio renderer to initialize. | 166 // Sets up expectations to allow the audio renderer to initialize. |
| 167 void InitializeAudioRenderer(bool disable_after_init_callback = false) { | 167 void InitializeAudioRenderer(bool disable_after_init_callback = false) { |
| 168 if (disable_after_init_callback) { | 168 if (disable_after_init_callback) { |
| 169 EXPECT_CALL(*mocks_->audio_renderer(), | 169 EXPECT_CALL(*mocks_->audio_renderer(), |
| 170 Initialize(mocks_->audio_decoder(), _, _)) | 170 Initialize(mocks_->audio_decoder(), _, _, _)) |
| 171 .WillOnce(DoAll(Invoke(&RunPipelineStatusCB3), | 171 .WillOnce(DoAll(Invoke(&RunPipelineStatusCB4), |
| 172 DisableAudioRenderer(mocks_->audio_renderer()))); | 172 DisableAudioRenderer(mocks_->audio_renderer()))); |
| 173 } else { | 173 } else { |
| 174 EXPECT_CALL(*mocks_->audio_renderer(), | 174 EXPECT_CALL(*mocks_->audio_renderer(), |
| 175 Initialize(mocks_->audio_decoder(), _, _)) | 175 Initialize(mocks_->audio_decoder(), _, _, _)) |
| 176 .WillOnce(Invoke(&RunPipelineStatusCB3)); | 176 .WillOnce(Invoke(&RunPipelineStatusCB4)); |
| 177 } | 177 } |
| 178 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); | 178 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); |
| 179 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); | 179 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); |
| 180 EXPECT_CALL(*mocks_->audio_renderer(), Seek(base::TimeDelta(), _)) | 180 EXPECT_CALL(*mocks_->audio_renderer(), Seek(base::TimeDelta(), _)) |
| 181 .WillOnce(Invoke(&RunFilterStatusCB)); | 181 .WillOnce(Invoke(&RunFilterStatusCB)); |
| 182 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) | 182 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) |
| 183 .WillOnce(Invoke(&RunStopFilterCallback)); | 183 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 // Sets up expectations on the callback and initializes the pipeline. Called | 186 // Sets up expectations on the callback and initializes the pipeline. Called |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 | 674 |
| 675 TEST_F(PipelineTest, AudioStreamShorterThanVideo) { | 675 TEST_F(PipelineTest, AudioStreamShorterThanVideo) { |
| 676 base::TimeDelta duration = base::TimeDelta::FromSeconds(10); | 676 base::TimeDelta duration = base::TimeDelta::FromSeconds(10); |
| 677 | 677 |
| 678 CreateAudioStream(); | 678 CreateAudioStream(); |
| 679 CreateVideoStream(); | 679 CreateVideoStream(); |
| 680 MockDemuxerStreamVector streams; | 680 MockDemuxerStreamVector streams; |
| 681 streams.push_back(audio_stream()); | 681 streams.push_back(audio_stream()); |
| 682 streams.push_back(video_stream()); | 682 streams.push_back(video_stream()); |
| 683 | 683 |
| 684 // Replace the clock so we can simulate wallclock time advancing w/o using |
| 685 // Sleep(). |
| 686 pipeline_->SetClockForTesting(new Clock(&StaticClockFunction)); |
| 687 |
| 684 InitializeDemuxer(&streams, duration); | 688 InitializeDemuxer(&streams, duration); |
| 685 InitializeAudioDecoder(audio_stream()); | 689 InitializeAudioDecoder(audio_stream()); |
| 686 InitializeAudioRenderer(); | 690 InitializeAudioRenderer(); |
| 687 InitializeVideoDecoder(video_stream()); | 691 InitializeVideoDecoder(video_stream()); |
| 688 InitializeVideoRenderer(); | 692 InitializeVideoRenderer(); |
| 689 InitializePipeline(PIPELINE_OK); | 693 InitializePipeline(PIPELINE_OK); |
| 690 | 694 |
| 691 // For convenience to simulate filters calling the methods. | 695 // For convenience to simulate filters calling the methods. |
| 692 FilterHost* host = pipeline_; | 696 FilterHost* host = pipeline_; |
| 693 | 697 |
| 694 // Replace the clock so we can simulate wallclock time advancing w/o using | |
| 695 // Sleep(). | |
| 696 pipeline_->SetClockForTesting(new Clock(&StaticClockFunction)); | |
| 697 | |
| 698 EXPECT_EQ(0, host->GetTime().ToInternalValue()); | 698 EXPECT_EQ(0, host->GetTime().ToInternalValue()); |
| 699 | 699 |
| 700 float playback_rate = 1.0f; | 700 float playback_rate = 1.0f; |
| 701 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); | 701 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); |
| 702 EXPECT_CALL(*mocks_->video_decoder(), SetPlaybackRate(playback_rate)); | 702 EXPECT_CALL(*mocks_->video_decoder(), SetPlaybackRate(playback_rate)); |
| 703 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(playback_rate)); | 703 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(playback_rate)); |
| 704 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(playback_rate)); | 704 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(playback_rate)); |
| 705 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); | 705 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); |
| 706 pipeline_->SetPlaybackRate(playback_rate); | 706 pipeline_->SetPlaybackRate(playback_rate); |
| 707 message_loop_.RunAllPending(); | 707 message_loop_.RunAllPending(); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); | 911 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); |
| 912 } | 912 } |
| 913 | 913 |
| 914 // Test that different-thread, some-delay callback (the expected common case) | 914 // Test that different-thread, some-delay callback (the expected common case) |
| 915 // works correctly. | 915 // works correctly. |
| 916 TEST(PipelineStatusNotificationTest, DelayedCallback) { | 916 TEST(PipelineStatusNotificationTest, DelayedCallback) { |
| 917 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); | 917 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); |
| 918 } | 918 } |
| 919 | 919 |
| 920 } // namespace media | 920 } // namespace media |
| OLD | NEW |