Chromium Code Reviews| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 EXPECT_CALL(*stream, type()) | 124 EXPECT_CALL(*stream, type()) |
| 125 .WillRepeatedly(Return(type)); | 125 .WillRepeatedly(Return(type)); |
| 126 return stream; | 126 return stream; |
| 127 } | 127 } |
| 128 | 128 |
| 129 // Sets up expectations to allow the video decoder to initialize. | 129 // Sets up expectations to allow the video decoder to initialize. |
| 130 void InitializeVideoDecoder(MockDemuxerStream* stream) { | 130 void InitializeVideoDecoder(MockDemuxerStream* stream) { |
| 131 EXPECT_CALL(*mocks_->video_decoder(), | 131 EXPECT_CALL(*mocks_->video_decoder(), |
| 132 Initialize(stream, _, _)) | 132 Initialize(stream, _, _)) |
| 133 .WillOnce(WithArg<1>(Invoke(&RunPipelineStatusOKCB))); | 133 .WillOnce(WithArg<1>(Invoke(&RunPipelineStatusOKCB))); |
| 134 EXPECT_CALL(*mocks_->video_decoder(), SetPlaybackRate(0.0f)); | |
| 135 EXPECT_CALL(*mocks_->video_decoder(), | |
| 136 Seek(mocks_->demuxer()->GetStartTime(), _)) | |
| 137 .WillOnce(Invoke(&RunFilterStatusCB)); | |
| 138 EXPECT_CALL(*mocks_->video_decoder(), Stop(_)) | |
|
Ami GONE FROM CHROMIUM
2012/03/14 20:05:01
I'm a bit surprised that Stop() isn't being called
xhwang
2012/03/14 22:28:41
video_decoder()->Stop was called by pipeline. Now
| |
| 139 .WillOnce(Invoke(&RunStopFilterCallback)); | |
| 140 } | 134 } |
| 141 | 135 |
| 142 // Sets up expectations to allow the audio decoder to initialize. | 136 // Sets up expectations to allow the audio decoder to initialize. |
| 143 void InitializeAudioDecoder(const scoped_refptr<DemuxerStream>& stream) { | 137 void InitializeAudioDecoder(const scoped_refptr<DemuxerStream>& stream) { |
| 144 EXPECT_CALL(*mocks_->audio_decoder(), Initialize(stream, _, _)) | 138 EXPECT_CALL(*mocks_->audio_decoder(), Initialize(stream, _, _)) |
| 145 .WillOnce(Invoke(&RunPipelineStatusCB3)); | 139 .WillOnce(Invoke(&RunPipelineStatusCB3)); |
| 146 } | 140 } |
| 147 | 141 |
| 148 // Sets up expectations to allow the video renderer to initialize. | 142 // Sets up expectations to allow the video renderer to initialize. |
| 149 void InitializeVideoRenderer() { | 143 void InitializeVideoRenderer() { |
| 150 EXPECT_CALL(*mocks_->video_renderer(), | 144 EXPECT_CALL(*mocks_->video_renderer(), Initialize( |
| 151 Initialize(mocks_->video_decoder(), _, _, _)) | 145 scoped_refptr<VideoDecoder>(mocks_->video_decoder()), _, _, _)) |
| 152 .WillOnce(Invoke(&RunPipelineStatusCB4)); | 146 .WillOnce(Invoke(&RunPipelineStatusCB4)); |
| 153 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); | 147 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); |
| 154 EXPECT_CALL(*mocks_->video_renderer(), | 148 EXPECT_CALL(*mocks_->video_renderer(), |
| 155 Seek(mocks_->demuxer()->GetStartTime(), _)) | 149 Seek(mocks_->demuxer()->GetStartTime(), _)) |
| 156 .WillOnce(Invoke(&RunFilterStatusCB)); | 150 .WillOnce(Invoke(&RunFilterStatusCB)); |
| 157 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) | 151 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) |
| 158 .WillOnce(Invoke(&RunStopFilterCallback)); | 152 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 159 } | 153 } |
| 160 | 154 |
| 161 // Sets up expectations to allow the audio renderer to initialize. | 155 // Sets up expectations to allow the audio renderer to initialize. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 // Every filter should receive a call to Seek(). | 219 // Every filter should receive a call to Seek(). |
| 226 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) | 220 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) |
| 227 .WillOnce(Invoke(&RunFilterStatusCB)); | 221 .WillOnce(Invoke(&RunFilterStatusCB)); |
| 228 | 222 |
| 229 if (audio_stream_) { | 223 if (audio_stream_) { |
| 230 EXPECT_CALL(*mocks_->audio_renderer(), Seek(seek_time, _)) | 224 EXPECT_CALL(*mocks_->audio_renderer(), Seek(seek_time, _)) |
| 231 .WillOnce(Invoke(&RunFilterStatusCB)); | 225 .WillOnce(Invoke(&RunFilterStatusCB)); |
| 232 } | 226 } |
| 233 | 227 |
| 234 if (video_stream_) { | 228 if (video_stream_) { |
| 235 EXPECT_CALL(*mocks_->video_decoder(), Seek(seek_time, _)) | |
| 236 .WillOnce(Invoke(&RunFilterStatusCB)); | |
| 237 EXPECT_CALL(*mocks_->video_renderer(), Seek(seek_time, _)) | 229 EXPECT_CALL(*mocks_->video_renderer(), Seek(seek_time, _)) |
| 238 .WillOnce(Invoke(&RunFilterStatusCB)); | 230 .WillOnce(Invoke(&RunFilterStatusCB)); |
| 239 } | 231 } |
| 240 | 232 |
| 241 // We expect a successful seek callback. | 233 // We expect a successful seek callback. |
| 242 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); | 234 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); |
| 243 } | 235 } |
| 244 | 236 |
| 245 void DoSeek(const base::TimeDelta& seek_time) { | 237 void DoSeek(const base::TimeDelta& seek_time) { |
| 246 pipeline_->Seek(seek_time, | 238 pipeline_->Seek(seek_time, |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 561 EXPECT_TRUE(pipeline_->IsInitialized()); | 553 EXPECT_TRUE(pipeline_->IsInitialized()); |
| 562 EXPECT_TRUE(pipeline_->HasAudio()); | 554 EXPECT_TRUE(pipeline_->HasAudio()); |
| 563 EXPECT_TRUE(pipeline_->HasVideo()); | 555 EXPECT_TRUE(pipeline_->HasVideo()); |
| 564 | 556 |
| 565 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(1.0f)) | 557 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(1.0f)) |
| 566 .WillOnce(DisableAudioRenderer(mocks_->audio_renderer())); | 558 .WillOnce(DisableAudioRenderer(mocks_->audio_renderer())); |
| 567 EXPECT_CALL(*mocks_->demuxer(), | 559 EXPECT_CALL(*mocks_->demuxer(), |
| 568 OnAudioRendererDisabled()); | 560 OnAudioRendererDisabled()); |
| 569 EXPECT_CALL(*mocks_->audio_renderer(), | 561 EXPECT_CALL(*mocks_->audio_renderer(), |
| 570 OnAudioRendererDisabled()); | 562 OnAudioRendererDisabled()); |
| 571 EXPECT_CALL(*mocks_->video_decoder(), | |
| 572 OnAudioRendererDisabled()); | |
| 573 EXPECT_CALL(*mocks_->video_renderer(), | 563 EXPECT_CALL(*mocks_->video_renderer(), |
| 574 OnAudioRendererDisabled()); | 564 OnAudioRendererDisabled()); |
| 575 | 565 |
| 576 mocks_->audio_renderer()->SetPlaybackRate(1.0f); | 566 mocks_->audio_renderer()->SetPlaybackRate(1.0f); |
| 577 | 567 |
| 578 // Verify that ended event is fired when video ends. | 568 // Verify that ended event is fired when video ends. |
| 579 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 569 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
| 580 .WillOnce(Return(true)); | 570 .WillOnce(Return(true)); |
| 581 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); | 571 EXPECT_CALL(callbacks_, OnEnded(PIPELINE_OK)); |
| 582 FilterHost* host = pipeline_; | 572 FilterHost* host = pipeline_; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 593 InitializeDemuxer(&streams, base::TimeDelta()); | 583 InitializeDemuxer(&streams, base::TimeDelta()); |
| 594 InitializeAudioDecoder(audio_stream()); | 584 InitializeAudioDecoder(audio_stream()); |
| 595 InitializeAudioRenderer(true); | 585 InitializeAudioRenderer(true); |
| 596 InitializeVideoDecoder(video_stream()); | 586 InitializeVideoDecoder(video_stream()); |
| 597 InitializeVideoRenderer(); | 587 InitializeVideoRenderer(); |
| 598 | 588 |
| 599 EXPECT_CALL(*mocks_->demuxer(), | 589 EXPECT_CALL(*mocks_->demuxer(), |
| 600 OnAudioRendererDisabled()); | 590 OnAudioRendererDisabled()); |
| 601 EXPECT_CALL(*mocks_->audio_renderer(), | 591 EXPECT_CALL(*mocks_->audio_renderer(), |
| 602 OnAudioRendererDisabled()); | 592 OnAudioRendererDisabled()); |
| 603 EXPECT_CALL(*mocks_->video_decoder(), | |
| 604 OnAudioRendererDisabled()); | |
| 605 EXPECT_CALL(*mocks_->video_renderer(), | 593 EXPECT_CALL(*mocks_->video_renderer(), |
| 606 OnAudioRendererDisabled()); | 594 OnAudioRendererDisabled()); |
| 607 | 595 |
| 608 InitializePipeline(PIPELINE_OK); | 596 InitializePipeline(PIPELINE_OK); |
| 609 EXPECT_TRUE(pipeline_->IsInitialized()); | 597 EXPECT_TRUE(pipeline_->IsInitialized()); |
| 610 EXPECT_FALSE(pipeline_->HasAudio()); | 598 EXPECT_FALSE(pipeline_->HasAudio()); |
| 611 EXPECT_TRUE(pipeline_->HasVideo()); | 599 EXPECT_TRUE(pipeline_->HasVideo()); |
| 612 | 600 |
| 613 // Verify that ended event is fired when video ends. | 601 // Verify that ended event is fired when video ends. |
| 614 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) | 602 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 InitializeVideoRenderer(); | 669 InitializeVideoRenderer(); |
| 682 InitializePipeline(PIPELINE_OK); | 670 InitializePipeline(PIPELINE_OK); |
| 683 | 671 |
| 684 // For convenience to simulate filters calling the methods. | 672 // For convenience to simulate filters calling the methods. |
| 685 FilterHost* host = pipeline_; | 673 FilterHost* host = pipeline_; |
| 686 | 674 |
| 687 EXPECT_EQ(0, host->GetTime().ToInternalValue()); | 675 EXPECT_EQ(0, host->GetTime().ToInternalValue()); |
| 688 | 676 |
| 689 float playback_rate = 1.0f; | 677 float playback_rate = 1.0f; |
| 690 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); | 678 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); |
| 691 EXPECT_CALL(*mocks_->video_decoder(), SetPlaybackRate(playback_rate)); | |
| 692 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(playback_rate)); | 679 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(playback_rate)); |
| 693 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); | 680 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); |
| 694 pipeline_->SetPlaybackRate(playback_rate); | 681 pipeline_->SetPlaybackRate(playback_rate); |
| 695 message_loop_.RunAllPending(); | 682 message_loop_.RunAllPending(); |
| 696 | 683 |
| 697 InSequence s; | 684 InSequence s; |
| 698 | 685 |
| 699 // Verify that the clock doesn't advance since it hasn't been started by | 686 // Verify that the clock doesn't advance since it hasn't been started by |
| 700 // a time update from the audio stream. | 687 // a time update from the audio stream. |
| 701 int64 start_time = host->GetTime().ToInternalValue(); | 688 int64 start_time = host->GetTime().ToInternalValue(); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 898 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); | 885 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); |
| 899 } | 886 } |
| 900 | 887 |
| 901 // Test that different-thread, some-delay callback (the expected common case) | 888 // Test that different-thread, some-delay callback (the expected common case) |
| 902 // works correctly. | 889 // works correctly. |
| 903 TEST(PipelineStatusNotificationTest, DelayedCallback) { | 890 TEST(PipelineStatusNotificationTest, DelayedCallback) { |
| 904 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); | 891 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); |
| 905 } | 892 } |
| 906 | 893 |
| 907 } // namespace media | 894 } // namespace media |
| OLD | NEW |