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

Side by Side Diff: media/base/pipeline_unittest.cc

Issue 403723006: Make media::AudioRenderer inherit from media::TimeSource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: composition Created 6 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 | Annotate | Revision Log
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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/test/simple_test_tick_clock.h" 10 #include "base/test/simple_test_tick_clock.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 // Sets up expectations on the callback and initializes the pipeline. Called 195 // Sets up expectations on the callback and initializes the pipeline. Called
196 // after tests have set expectations any filters they wish to use. 196 // after tests have set expectations any filters they wish to use.
197 void StartPipeline(PipelineStatus start_status) { 197 void StartPipeline(PipelineStatus start_status) {
198 EXPECT_CALL(callbacks_, OnStart(start_status)); 198 EXPECT_CALL(callbacks_, OnStart(start_status));
199 199
200 if (start_status == PIPELINE_OK) { 200 if (start_status == PIPELINE_OK) {
201 EXPECT_CALL(callbacks_, OnMetadata(_)).WillOnce(SaveArg<0>(&metadata_)); 201 EXPECT_CALL(callbacks_, OnMetadata(_)).WillOnce(SaveArg<0>(&metadata_));
202 202
203 if (audio_stream_) { 203 if (audio_stream_) {
204 EXPECT_CALL(*audio_renderer_, SetPlaybackRate(0.0f)); 204 EXPECT_CALL(*audio_renderer_, GetTimeSource())
205 .WillOnce(Return(&time_source_));
206 EXPECT_CALL(time_source_, SetPlaybackRate(0.0f));
207 EXPECT_CALL(time_source_, SetMediaTime(base::TimeDelta()));
208 EXPECT_CALL(time_source_, StartTicking());
205 EXPECT_CALL(*audio_renderer_, SetVolume(1.0f)); 209 EXPECT_CALL(*audio_renderer_, SetVolume(1.0f));
206 EXPECT_CALL(*audio_renderer_, SetMediaTime(base::TimeDelta()));
207 EXPECT_CALL(*audio_renderer_, StartPlaying()) 210 EXPECT_CALL(*audio_renderer_, StartPlaying())
208 .WillOnce(SetBufferingState(&audio_buffering_state_cb_, 211 .WillOnce(SetBufferingState(&audio_buffering_state_cb_,
209 BUFFERING_HAVE_ENOUGH)); 212 BUFFERING_HAVE_ENOUGH));
210 EXPECT_CALL(*audio_renderer_, StartRendering());
211 } 213 }
212 214
213 if (video_stream_) { 215 if (video_stream_) {
214 EXPECT_CALL(*video_renderer_, StartPlaying()) 216 EXPECT_CALL(*video_renderer_, StartPlaying())
215 .WillOnce(SetBufferingState(&video_buffering_state_cb_, 217 .WillOnce(SetBufferingState(&video_buffering_state_cb_,
216 BUFFERING_HAVE_ENOUGH)); 218 BUFFERING_HAVE_ENOUGH));
217 } 219 }
218 220
219 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); 221 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
220 } 222 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 return text_stream_.get(); 261 return text_stream_.get();
260 } 262 }
261 263
262 void ExpectSeek(const base::TimeDelta& seek_time, bool underflowed) { 264 void ExpectSeek(const base::TimeDelta& seek_time, bool underflowed) {
263 // Every filter should receive a call to Seek(). 265 // Every filter should receive a call to Seek().
264 EXPECT_CALL(*demuxer_, Seek(seek_time, _)) 266 EXPECT_CALL(*demuxer_, Seek(seek_time, _))
265 .WillOnce(RunCallback<1>(PIPELINE_OK)); 267 .WillOnce(RunCallback<1>(PIPELINE_OK));
266 268
267 if (audio_stream_) { 269 if (audio_stream_) {
268 if (!underflowed) 270 if (!underflowed)
269 EXPECT_CALL(*audio_renderer_, StopRendering()); 271 EXPECT_CALL(time_source_, StopTicking());
270 EXPECT_CALL(*audio_renderer_, Flush(_)) 272 EXPECT_CALL(*audio_renderer_, Flush(_))
271 .WillOnce(DoAll(SetBufferingState(&audio_buffering_state_cb_, 273 .WillOnce(DoAll(SetBufferingState(&audio_buffering_state_cb_,
272 BUFFERING_HAVE_NOTHING), 274 BUFFERING_HAVE_NOTHING),
273 RunClosure<0>())); 275 RunClosure<0>()));
274 EXPECT_CALL(*audio_renderer_, SetMediaTime(seek_time)); 276 EXPECT_CALL(time_source_, SetMediaTime(seek_time));
277 EXPECT_CALL(time_source_, SetPlaybackRate(_));
278 EXPECT_CALL(time_source_, StartTicking());
275 EXPECT_CALL(*audio_renderer_, StartPlaying()) 279 EXPECT_CALL(*audio_renderer_, StartPlaying())
276 .WillOnce(SetBufferingState(&audio_buffering_state_cb_, 280 .WillOnce(SetBufferingState(&audio_buffering_state_cb_,
277 BUFFERING_HAVE_ENOUGH)); 281 BUFFERING_HAVE_ENOUGH));
278 EXPECT_CALL(*audio_renderer_, SetPlaybackRate(_));
279 EXPECT_CALL(*audio_renderer_, SetVolume(_)); 282 EXPECT_CALL(*audio_renderer_, SetVolume(_));
280 EXPECT_CALL(*audio_renderer_, StartRendering());
281 } 283 }
282 284
283 if (video_stream_) { 285 if (video_stream_) {
284 EXPECT_CALL(*video_renderer_, Flush(_)) 286 EXPECT_CALL(*video_renderer_, Flush(_))
285 .WillOnce(DoAll(SetBufferingState(&video_buffering_state_cb_, 287 .WillOnce(DoAll(SetBufferingState(&video_buffering_state_cb_,
286 BUFFERING_HAVE_NOTHING), 288 BUFFERING_HAVE_NOTHING),
287 RunClosure<0>())); 289 RunClosure<0>()));
288 EXPECT_CALL(*video_renderer_, StartPlaying()) 290 EXPECT_CALL(*video_renderer_, StartPlaying())
289 .WillOnce(SetBufferingState(&video_buffering_state_cb_, 291 .WillOnce(SetBufferingState(&video_buffering_state_cb_,
290 BUFFERING_HAVE_ENOUGH)); 292 BUFFERING_HAVE_ENOUGH));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // Fixture members. 331 // Fixture members.
330 StrictMock<CallbackHelper> callbacks_; 332 StrictMock<CallbackHelper> callbacks_;
331 base::SimpleTestTickClock test_tick_clock_; 333 base::SimpleTestTickClock test_tick_clock_;
332 base::MessageLoop message_loop_; 334 base::MessageLoop message_loop_;
333 scoped_ptr<Pipeline> pipeline_; 335 scoped_ptr<Pipeline> pipeline_;
334 336
335 scoped_ptr<FilterCollection> filter_collection_; 337 scoped_ptr<FilterCollection> filter_collection_;
336 scoped_ptr<StrictMock<MockDemuxer> > demuxer_; 338 scoped_ptr<StrictMock<MockDemuxer> > demuxer_;
337 StrictMock<MockVideoRenderer>* video_renderer_; 339 StrictMock<MockVideoRenderer>* video_renderer_;
338 StrictMock<MockAudioRenderer>* audio_renderer_; 340 StrictMock<MockAudioRenderer>* audio_renderer_;
341 StrictMock<MockTimeSource> time_source_;
339 StrictMock<CallbackHelper> text_renderer_callbacks_; 342 StrictMock<CallbackHelper> text_renderer_callbacks_;
340 TextRenderer* text_renderer_; 343 TextRenderer* text_renderer_;
341 scoped_ptr<StrictMock<MockDemuxerStream> > audio_stream_; 344 scoped_ptr<StrictMock<MockDemuxerStream> > audio_stream_;
342 scoped_ptr<StrictMock<MockDemuxerStream> > video_stream_; 345 scoped_ptr<StrictMock<MockDemuxerStream> > video_stream_;
343 scoped_ptr<FakeTextTrackStream> text_stream_; 346 scoped_ptr<FakeTextTrackStream> text_stream_;
344 AudioRenderer::TimeCB audio_time_cb_; 347 AudioRenderer::TimeCB audio_time_cb_;
345 BufferingStateCB audio_buffering_state_cb_; 348 BufferingStateCB audio_buffering_state_cb_;
346 BufferingStateCB video_buffering_state_cb_; 349 BufferingStateCB video_buffering_state_cb_;
347 base::Closure audio_ended_cb_; 350 base::Closure audio_ended_cb_;
348 base::Closure video_ended_cb_; 351 base::Closure video_ended_cb_;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 604
602 AddTextStream(); 605 AddTextStream();
603 606
604 // The ended callback shouldn't run until all renderers have ended. 607 // The ended callback shouldn't run until all renderers have ended.
605 audio_ended_cb_.Run(); 608 audio_ended_cb_.Run();
606 message_loop_.RunUntilIdle(); 609 message_loop_.RunUntilIdle();
607 610
608 video_ended_cb_.Run(); 611 video_ended_cb_.Run();
609 message_loop_.RunUntilIdle(); 612 message_loop_.RunUntilIdle();
610 613
611 EXPECT_CALL(*audio_renderer_, StopRendering()); 614 EXPECT_CALL(time_source_, StopTicking());
612 EXPECT_CALL(callbacks_, OnEnded()); 615 EXPECT_CALL(callbacks_, OnEnded());
613 text_stream()->SendEosNotification(); 616 text_stream()->SendEosNotification();
614 message_loop_.RunUntilIdle(); 617 message_loop_.RunUntilIdle();
615 } 618 }
616 619
617 TEST_F(PipelineTest, AudioStreamShorterThanVideo) { 620 TEST_F(PipelineTest, AudioStreamShorterThanVideo) {
618 base::TimeDelta duration = base::TimeDelta::FromSeconds(10); 621 base::TimeDelta duration = base::TimeDelta::FromSeconds(10);
619 622
620 CreateAudioStream(); 623 CreateAudioStream();
621 CreateVideoStream(); 624 CreateVideoStream();
622 MockDemuxerStreamVector streams; 625 MockDemuxerStreamVector streams;
623 streams.push_back(audio_stream()); 626 streams.push_back(audio_stream());
624 streams.push_back(video_stream()); 627 streams.push_back(video_stream());
625 628
626 // Replace what's used for interpolating to simulate wall clock time. 629 // Replace what's used for interpolating to simulate wall clock time.
627 pipeline_->SetTimeDeltaInterpolatorForTesting( 630 pipeline_->SetTimeDeltaInterpolatorForTesting(
628 new TimeDeltaInterpolator(&test_tick_clock_)); 631 new TimeDeltaInterpolator(&test_tick_clock_));
629 632
630 SetDemuxerExpectations(&streams, duration); 633 SetDemuxerExpectations(&streams, duration);
631 SetAudioRendererExpectations(audio_stream()); 634 SetAudioRendererExpectations(audio_stream());
632 SetVideoRendererExpectations(video_stream()); 635 SetVideoRendererExpectations(video_stream());
633 StartPipeline(PIPELINE_OK); 636 StartPipeline(PIPELINE_OK);
634 637
635 EXPECT_EQ(0, pipeline_->GetMediaTime().ToInternalValue()); 638 EXPECT_EQ(0, pipeline_->GetMediaTime().ToInternalValue());
636 639
637 float playback_rate = 1.0f; 640 float playback_rate = 1.0f;
638 EXPECT_CALL(*audio_renderer_, SetPlaybackRate(playback_rate)); 641 EXPECT_CALL(time_source_, SetPlaybackRate(playback_rate));
639 pipeline_->SetPlaybackRate(playback_rate); 642 pipeline_->SetPlaybackRate(playback_rate);
640 message_loop_.RunUntilIdle(); 643 message_loop_.RunUntilIdle();
641 644
642 InSequence s; 645 InSequence s;
643 646
644 // Verify that the clock doesn't advance since it hasn't been started by 647 // Verify that the clock doesn't advance since it hasn't been started by
645 // a time update from the audio stream. 648 // a time update from the audio stream.
646 int64 start_time = pipeline_->GetMediaTime().ToInternalValue(); 649 int64 start_time = pipeline_->GetMediaTime().ToInternalValue();
647 test_tick_clock_.Advance(base::TimeDelta::FromMilliseconds(100)); 650 test_tick_clock_.Advance(base::TimeDelta::FromMilliseconds(100));
648 EXPECT_EQ(pipeline_->GetMediaTime().ToInternalValue(), start_time); 651 EXPECT_EQ(pipeline_->GetMediaTime().ToInternalValue(), start_time);
649 652
650 // Signal end of audio stream. 653 // Signal end of audio stream.
651 audio_ended_cb_.Run(); 654 audio_ended_cb_.Run();
652 message_loop_.RunUntilIdle(); 655 message_loop_.RunUntilIdle();
653 656
654 // Verify that the clock advances. 657 // Verify that the clock advances.
655 start_time = pipeline_->GetMediaTime().ToInternalValue(); 658 start_time = pipeline_->GetMediaTime().ToInternalValue();
656 test_tick_clock_.Advance(base::TimeDelta::FromMilliseconds(100)); 659 test_tick_clock_.Advance(base::TimeDelta::FromMilliseconds(100));
657 EXPECT_GT(pipeline_->GetMediaTime().ToInternalValue(), start_time); 660 EXPECT_GT(pipeline_->GetMediaTime().ToInternalValue(), start_time);
658 661
659 // Signal end of video stream and make sure OnEnded() callback occurs. 662 // Signal end of video stream and make sure OnEnded() callback occurs.
660 EXPECT_CALL(*audio_renderer_, StopRendering()); 663 EXPECT_CALL(time_source_, StopTicking());
661 EXPECT_CALL(callbacks_, OnEnded()); 664 EXPECT_CALL(callbacks_, OnEnded());
662 video_ended_cb_.Run(); 665 video_ended_cb_.Run();
663 } 666 }
664 667
665 TEST_F(PipelineTest, ErrorDuringSeek) { 668 TEST_F(PipelineTest, ErrorDuringSeek) {
666 CreateAudioStream(); 669 CreateAudioStream();
667 MockDemuxerStreamVector streams; 670 MockDemuxerStreamVector streams;
668 streams.push_back(audio_stream()); 671 streams.push_back(audio_stream());
669 672
670 SetDemuxerExpectations(&streams); 673 SetDemuxerExpectations(&streams);
671 SetAudioRendererExpectations(audio_stream()); 674 SetAudioRendererExpectations(audio_stream());
672 StartPipeline(PIPELINE_OK); 675 StartPipeline(PIPELINE_OK);
673 676
674 float playback_rate = 1.0f; 677 float playback_rate = 1.0f;
675 EXPECT_CALL(*audio_renderer_, SetPlaybackRate(playback_rate)); 678 EXPECT_CALL(time_source_, SetPlaybackRate(playback_rate));
676 pipeline_->SetPlaybackRate(playback_rate); 679 pipeline_->SetPlaybackRate(playback_rate);
677 message_loop_.RunUntilIdle(); 680 message_loop_.RunUntilIdle();
678 681
679 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); 682 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5);
680 683
681 // Preroll() isn't called as the demuxer errors out first. 684 // Preroll() isn't called as the demuxer errors out first.
682 EXPECT_CALL(*audio_renderer_, StopRendering()); 685 EXPECT_CALL(time_source_, StopTicking());
683 EXPECT_CALL(*audio_renderer_, Flush(_)) 686 EXPECT_CALL(*audio_renderer_, Flush(_))
684 .WillOnce(DoAll(SetBufferingState(&audio_buffering_state_cb_, 687 .WillOnce(DoAll(SetBufferingState(&audio_buffering_state_cb_,
685 BUFFERING_HAVE_NOTHING), 688 BUFFERING_HAVE_NOTHING),
686 RunClosure<0>())); 689 RunClosure<0>()));
687 EXPECT_CALL(*audio_renderer_, Stop(_)) 690 EXPECT_CALL(*audio_renderer_, Stop(_))
688 .WillOnce(RunClosure<0>()); 691 .WillOnce(RunClosure<0>());
689 692
690 EXPECT_CALL(*demuxer_, Seek(seek_time, _)) 693 EXPECT_CALL(*demuxer_, Seek(seek_time, _))
691 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ)); 694 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ));
692 EXPECT_CALL(*demuxer_, Stop(_)) 695 EXPECT_CALL(*demuxer_, Stop(_))
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 731
729 // Trigger additional requests on the pipeline during tear down from error. 732 // Trigger additional requests on the pipeline during tear down from error.
730 base::Callback<void(PipelineStatus)> cb = base::Bind( 733 base::Callback<void(PipelineStatus)> cb = base::Bind(
731 &TestNoCallsAfterError, pipeline_.get(), &message_loop_); 734 &TestNoCallsAfterError, pipeline_.get(), &message_loop_);
732 ON_CALL(callbacks_, OnError(_)) 735 ON_CALL(callbacks_, OnError(_))
733 .WillByDefault(Invoke(&cb, &base::Callback<void(PipelineStatus)>::Run)); 736 .WillByDefault(Invoke(&cb, &base::Callback<void(PipelineStatus)>::Run));
734 737
735 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); 738 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5);
736 739
737 // Seek() isn't called as the demuxer errors out first. 740 // Seek() isn't called as the demuxer errors out first.
738 EXPECT_CALL(*audio_renderer_, StopRendering()); 741 EXPECT_CALL(time_source_, StopTicking());
739 EXPECT_CALL(*audio_renderer_, Flush(_)) 742 EXPECT_CALL(*audio_renderer_, Flush(_))
740 .WillOnce(DoAll(SetBufferingState(&audio_buffering_state_cb_, 743 .WillOnce(DoAll(SetBufferingState(&audio_buffering_state_cb_,
741 BUFFERING_HAVE_NOTHING), 744 BUFFERING_HAVE_NOTHING),
742 RunClosure<0>())); 745 RunClosure<0>()));
743 EXPECT_CALL(*audio_renderer_, Stop(_)) 746 EXPECT_CALL(*audio_renderer_, Stop(_))
744 .WillOnce(RunClosure<0>()); 747 .WillOnce(RunClosure<0>());
745 748
746 EXPECT_CALL(*demuxer_, Seek(seek_time, _)) 749 EXPECT_CALL(*demuxer_, Seek(seek_time, _))
747 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ)); 750 .WillOnce(RunCallback<1>(PIPELINE_ERROR_READ));
748 EXPECT_CALL(*demuxer_, Stop(_)) 751 EXPECT_CALL(*demuxer_, Stop(_))
(...skipping 15 matching lines...) Expand all
764 TEST_F(PipelineTest, AudioTimeUpdateDuringSeek) { 767 TEST_F(PipelineTest, AudioTimeUpdateDuringSeek) {
765 CreateAudioStream(); 768 CreateAudioStream();
766 MockDemuxerStreamVector streams; 769 MockDemuxerStreamVector streams;
767 streams.push_back(audio_stream()); 770 streams.push_back(audio_stream());
768 771
769 SetDemuxerExpectations(&streams); 772 SetDemuxerExpectations(&streams);
770 SetAudioRendererExpectations(audio_stream()); 773 SetAudioRendererExpectations(audio_stream());
771 StartPipeline(PIPELINE_OK); 774 StartPipeline(PIPELINE_OK);
772 775
773 float playback_rate = 1.0f; 776 float playback_rate = 1.0f;
774 EXPECT_CALL(*audio_renderer_, SetPlaybackRate(playback_rate)); 777 EXPECT_CALL(time_source_, SetPlaybackRate(playback_rate));
775 pipeline_->SetPlaybackRate(playback_rate); 778 pipeline_->SetPlaybackRate(playback_rate);
776 message_loop_.RunUntilIdle(); 779 message_loop_.RunUntilIdle();
777 780
778 // Provide an initial time update so that the pipeline transitions out of the 781 // Provide an initial time update so that the pipeline transitions out of the
779 // "waiting for time update" state. 782 // "waiting for time update" state.
780 audio_time_cb_.Run(base::TimeDelta::FromMilliseconds(100), 783 audio_time_cb_.Run(base::TimeDelta::FromMilliseconds(100),
781 base::TimeDelta::FromMilliseconds(500)); 784 base::TimeDelta::FromMilliseconds(500));
782 785
783 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); 786 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5);
784 787
785 // Arrange to trigger a time update while the demuxer is in the middle of 788 // Arrange to trigger a time update while the demuxer is in the middle of
786 // seeking. This update should be ignored by the pipeline and the clock should 789 // seeking. This update should be ignored by the pipeline and the clock should
787 // not get updated. 790 // not get updated.
788 base::Closure closure = base::Bind(&RunTimeCB, audio_time_cb_, 300, 700); 791 base::Closure closure = base::Bind(&RunTimeCB, audio_time_cb_, 300, 700);
789 EXPECT_CALL(*demuxer_, Seek(seek_time, _)) 792 EXPECT_CALL(*demuxer_, Seek(seek_time, _))
790 .WillOnce(DoAll(InvokeWithoutArgs(&closure, &base::Closure::Run), 793 .WillOnce(DoAll(InvokeWithoutArgs(&closure, &base::Closure::Run),
791 RunCallback<1>(PIPELINE_OK))); 794 RunCallback<1>(PIPELINE_OK)));
792 795
793 EXPECT_CALL(*audio_renderer_, StopRendering()); 796 EXPECT_CALL(time_source_, StopTicking());
794 EXPECT_CALL(*audio_renderer_, Flush(_)) 797 EXPECT_CALL(*audio_renderer_, Flush(_))
795 .WillOnce(DoAll(SetBufferingState(&audio_buffering_state_cb_, 798 .WillOnce(DoAll(SetBufferingState(&audio_buffering_state_cb_,
796 BUFFERING_HAVE_NOTHING), 799 BUFFERING_HAVE_NOTHING),
797 RunClosure<0>())); 800 RunClosure<0>()));
798 EXPECT_CALL(*audio_renderer_, SetMediaTime(seek_time)); 801 EXPECT_CALL(time_source_, SetMediaTime(seek_time));
802 EXPECT_CALL(time_source_, SetPlaybackRate(_));
803 EXPECT_CALL(time_source_, StartTicking());
799 EXPECT_CALL(*audio_renderer_, StartPlaying()) 804 EXPECT_CALL(*audio_renderer_, StartPlaying())
800 .WillOnce(SetBufferingState(&audio_buffering_state_cb_, 805 .WillOnce(SetBufferingState(&audio_buffering_state_cb_,
801 BUFFERING_HAVE_ENOUGH)); 806 BUFFERING_HAVE_ENOUGH));
802 EXPECT_CALL(*audio_renderer_, SetPlaybackRate(_));
803 EXPECT_CALL(*audio_renderer_, SetVolume(_)); 807 EXPECT_CALL(*audio_renderer_, SetVolume(_));
804 EXPECT_CALL(*audio_renderer_, StartRendering());
805 808
806 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); 809 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK));
807 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); 810 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
808 DoSeek(seek_time); 811 DoSeek(seek_time);
809 812
810 EXPECT_EQ(pipeline_->GetMediaTime(), seek_time); 813 EXPECT_EQ(pipeline_->GetMediaTime(), seek_time);
811 814
812 // Now that the seek is complete, verify that time updates advance the current 815 // Now that the seek is complete, verify that time updates advance the current
813 // time. 816 // time.
814 base::TimeDelta new_time = seek_time + base::TimeDelta::FromMilliseconds(100); 817 base::TimeDelta new_time = seek_time + base::TimeDelta::FromMilliseconds(100);
(...skipping 27 matching lines...) Expand all
842 MockDemuxerStreamVector streams; 845 MockDemuxerStreamVector streams;
843 streams.push_back(audio_stream()); 846 streams.push_back(audio_stream());
844 streams.push_back(video_stream()); 847 streams.push_back(video_stream());
845 848
846 SetDemuxerExpectations(&streams); 849 SetDemuxerExpectations(&streams);
847 SetAudioRendererExpectations(audio_stream()); 850 SetAudioRendererExpectations(audio_stream());
848 SetVideoRendererExpectations(video_stream()); 851 SetVideoRendererExpectations(video_stream());
849 StartPipeline(PIPELINE_OK); 852 StartPipeline(PIPELINE_OK);
850 853
851 // Simulate underflow. 854 // Simulate underflow.
852 EXPECT_CALL(*audio_renderer_, StopRendering()); 855 EXPECT_CALL(time_source_, StopTicking());
853 audio_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); 856 audio_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING);
854 857
855 // Seek while underflowed. We shouldn't call StopRendering() again. 858 // Seek while underflowed. We shouldn't call StopTicking() again.
856 base::TimeDelta expected = base::TimeDelta::FromSeconds(5); 859 base::TimeDelta expected = base::TimeDelta::FromSeconds(5);
857 ExpectSeek(expected, true); 860 ExpectSeek(expected, true);
858 DoSeek(expected); 861 DoSeek(expected);
859 } 862 }
860 863
861 class PipelineTeardownTest : public PipelineTest { 864 class PipelineTeardownTest : public PipelineTest {
862 public: 865 public:
863 enum TeardownState { 866 enum TeardownState {
864 kInitDemuxer, 867 kInitDemuxer,
865 kInitAudioRenderer, 868 kInitAudioRenderer,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 return status; 992 return status;
990 } 993 }
991 994
992 EXPECT_CALL(*video_renderer_, Initialize(_, _, _, _, _, _, _, _, _, _)) 995 EXPECT_CALL(*video_renderer_, Initialize(_, _, _, _, _, _, _, _, _, _))
993 .WillOnce(DoAll(SaveArg<5>(&video_buffering_state_cb_), 996 .WillOnce(DoAll(SaveArg<5>(&video_buffering_state_cb_),
994 RunCallback<2>(PIPELINE_OK))); 997 RunCallback<2>(PIPELINE_OK)));
995 998
996 EXPECT_CALL(callbacks_, OnMetadata(_)); 999 EXPECT_CALL(callbacks_, OnMetadata(_));
997 1000
998 // If we get here it's a successful initialization. 1001 // If we get here it's a successful initialization.
999 EXPECT_CALL(*audio_renderer_, SetMediaTime(base::TimeDelta())); 1002 EXPECT_CALL(*audio_renderer_, GetTimeSource())
1003 .WillOnce(Return(&time_source_));
1004 EXPECT_CALL(time_source_, SetMediaTime(base::TimeDelta()));
1005 EXPECT_CALL(time_source_, SetPlaybackRate(0.0f));
1006 EXPECT_CALL(time_source_, StartTicking());
1007 EXPECT_CALL(*audio_renderer_, SetVolume(1.0f));
1000 EXPECT_CALL(*audio_renderer_, StartPlaying()) 1008 EXPECT_CALL(*audio_renderer_, StartPlaying())
1001 .WillOnce(SetBufferingState(&audio_buffering_state_cb_, 1009 .WillOnce(SetBufferingState(&audio_buffering_state_cb_,
1002 BUFFERING_HAVE_ENOUGH)); 1010 BUFFERING_HAVE_ENOUGH));
1003 EXPECT_CALL(*video_renderer_, StartPlaying()) 1011 EXPECT_CALL(*video_renderer_, StartPlaying())
1004 .WillOnce(SetBufferingState(&video_buffering_state_cb_, 1012 .WillOnce(SetBufferingState(&video_buffering_state_cb_,
1005 BUFFERING_HAVE_ENOUGH)); 1013 BUFFERING_HAVE_ENOUGH));
1006 1014
1007 EXPECT_CALL(*audio_renderer_, SetPlaybackRate(0.0f));
1008 EXPECT_CALL(*audio_renderer_, SetVolume(1.0f));
1009 EXPECT_CALL(*audio_renderer_, StartRendering());
1010
1011 if (status == PIPELINE_OK) 1015 if (status == PIPELINE_OK)
1012 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); 1016 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
1013 1017
1014 return status; 1018 return status;
1015 } 1019 }
1016 1020
1017 void DoSeek(TeardownState state, StopOrError stop_or_error) { 1021 void DoSeek(TeardownState state, StopOrError stop_or_error) {
1018 InSequence s; 1022 InSequence s;
1019 PipelineStatus status = SetSeekExpectations(state, stop_or_error); 1023 PipelineStatus status = SetSeekExpectations(state, stop_or_error);
1020 1024
(...skipping 10 matching lines...) Expand all
1031 &CallbackHelper::OnSeek, base::Unretained(&callbacks_))); 1035 &CallbackHelper::OnSeek, base::Unretained(&callbacks_)));
1032 message_loop_.RunUntilIdle(); 1036 message_loop_.RunUntilIdle();
1033 } 1037 }
1034 1038
1035 PipelineStatus SetSeekExpectations(TeardownState state, 1039 PipelineStatus SetSeekExpectations(TeardownState state,
1036 StopOrError stop_or_error) { 1040 StopOrError stop_or_error) {
1037 PipelineStatus status = PIPELINE_OK; 1041 PipelineStatus status = PIPELINE_OK;
1038 base::Closure stop_cb = base::Bind( 1042 base::Closure stop_cb = base::Bind(
1039 &CallbackHelper::OnStop, base::Unretained(&callbacks_)); 1043 &CallbackHelper::OnStop, base::Unretained(&callbacks_));
1040 1044
1041 EXPECT_CALL(*audio_renderer_, StopRendering()); 1045 EXPECT_CALL(time_source_, StopTicking());
1042 1046
1043 if (state == kFlushing) { 1047 if (state == kFlushing) {
1044 if (stop_or_error == kStop) { 1048 if (stop_or_error == kStop) {
1045 EXPECT_CALL(*audio_renderer_, Flush(_)) 1049 EXPECT_CALL(*audio_renderer_, Flush(_))
1046 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb), 1050 .WillOnce(DoAll(Stop(pipeline_.get(), stop_cb),
1047 SetBufferingState(&audio_buffering_state_cb_, 1051 SetBufferingState(&audio_buffering_state_cb_,
1048 BUFFERING_HAVE_NOTHING), 1052 BUFFERING_HAVE_NOTHING),
1049 RunClosure<0>())); 1053 RunClosure<0>()));
1050 } else { 1054 } else {
1051 status = PIPELINE_ERROR_READ; 1055 status = PIPELINE_ERROR_READ;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer); 1138 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer);
1135 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); 1139 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer);
1136 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); 1140 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer);
1137 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); 1141 INSTANTIATE_TEARDOWN_TEST(Error, Flushing);
1138 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); 1142 INSTANTIATE_TEARDOWN_TEST(Error, Seeking);
1139 INSTANTIATE_TEARDOWN_TEST(Error, Playing); 1143 INSTANTIATE_TEARDOWN_TEST(Error, Playing);
1140 1144
1141 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); 1145 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing);
1142 1146
1143 } // namespace media 1147 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698