| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 protected: | 80 protected: |
| 81 void Destroy() { | 81 void Destroy() { |
| 82 renderer_impl_.reset(); | 82 renderer_impl_.reset(); |
| 83 base::RunLoop().RunUntilIdle(); | 83 base::RunLoop().RunUntilIdle(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 std::unique_ptr<StrictMock<MockDemuxerStream>> CreateStream( | 86 std::unique_ptr<StrictMock<MockDemuxerStream>> CreateStream( |
| 87 DemuxerStream::Type type) { | 87 DemuxerStream::Type type) { |
| 88 std::unique_ptr<StrictMock<MockDemuxerStream>> stream( | 88 std::unique_ptr<StrictMock<MockDemuxerStream>> stream( |
| 89 new StrictMock<MockDemuxerStream>(type)); | 89 new StrictMock<MockDemuxerStream>(type)); |
| 90 EXPECT_CALL(*stream, SetStreamRestartedCB(_)).Times(testing::AnyNumber()); | 90 EXPECT_CALL(*stream, SetStreamStatusChangeCB(_)) |
| 91 .Times(testing::AnyNumber()); |
| 91 return stream; | 92 return stream; |
| 92 } | 93 } |
| 93 | 94 |
| 94 // Sets up expectations to allow the audio renderer to initialize. | 95 // Sets up expectations to allow the audio renderer to initialize. |
| 95 void SetAudioRendererInitializeExpectations(PipelineStatus status) { | 96 void SetAudioRendererInitializeExpectations(PipelineStatus status) { |
| 96 EXPECT_CALL(*audio_renderer_, Initialize(audio_stream_.get(), _, _, _)) | 97 EXPECT_CALL(*audio_renderer_, Initialize(audio_stream_.get(), _, _, _)) |
| 97 .WillOnce( | 98 .WillOnce( |
| 98 DoAll(SaveArg<2>(&audio_renderer_client_), RunCallback<3>(status))); | 99 DoAll(SaveArg<2>(&audio_renderer_client_), RunCallback<3>(status))); |
| 99 } | 100 } |
| 100 | 101 |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 EXPECT_CALL(*audio_renderer_, StartPlaying()) | 707 EXPECT_CALL(*audio_renderer_, StartPlaying()) |
| 707 .WillOnce( | 708 .WillOnce( |
| 708 SetBufferingState(&audio_renderer_client_, BUFFERING_HAVE_ENOUGH)); | 709 SetBufferingState(&audio_renderer_client_, BUFFERING_HAVE_ENOUGH)); |
| 709 EXPECT_CALL(*video_renderer_, StartPlayingFrom(kStartTime)); | 710 EXPECT_CALL(*video_renderer_, StartPlayingFrom(kStartTime)); |
| 710 renderer_impl_->StartPlayingFrom(kStartTime); | 711 renderer_impl_->StartPlayingFrom(kStartTime); |
| 711 | 712 |
| 712 // Nothing else should primed on the message loop. | 713 // Nothing else should primed on the message loop. |
| 713 base::RunLoop().RunUntilIdle(); | 714 base::RunLoop().RunUntilIdle(); |
| 714 } | 715 } |
| 715 | 716 |
| 717 TEST_F(RendererImplTest, StreamStatusNotificationHandling) { |
| 718 CreateAudioAndVideoStream(); |
| 719 |
| 720 DemuxerStream::StreamStatusChangeCB audio_stream_status_change_cb; |
| 721 DemuxerStream::StreamStatusChangeCB video_stream_status_change_cb; |
| 722 EXPECT_CALL(*audio_stream_, SetStreamStatusChangeCB(_)) |
| 723 .WillOnce(SaveArg<0>(&audio_stream_status_change_cb)); |
| 724 EXPECT_CALL(*video_stream_, SetStreamStatusChangeCB(_)) |
| 725 .WillOnce(SaveArg<0>(&video_stream_status_change_cb)); |
| 726 SetAudioRendererInitializeExpectations(PIPELINE_OK); |
| 727 SetVideoRendererInitializeExpectations(PIPELINE_OK); |
| 728 InitializeAndExpect(PIPELINE_OK); |
| 729 Play(); |
| 730 |
| 731 // Verify that DemuxerStream status changes cause the corresponding |
| 732 // audio/video renderer to be flushed and restarted. |
| 733 base::TimeDelta time0; |
| 734 EXPECT_CALL(time_source_, StopTicking()); |
| 735 EXPECT_CALL(*audio_renderer_, Flush(_)).WillOnce(RunClosure<0>()); |
| 736 EXPECT_CALL(*audio_renderer_, StartPlaying()).Times(1); |
| 737 audio_stream_status_change_cb.Run(false, time0); |
| 738 |
| 739 EXPECT_CALL(*video_renderer_, Flush(_)).WillOnce(RunClosure<0>()); |
| 740 EXPECT_CALL(*video_renderer_, StartPlayingFrom(_)).Times(1); |
| 741 video_stream_status_change_cb.Run(false, time0); |
| 742 } |
| 743 |
| 716 } // namespace media | 744 } // namespace media |
| OLD | NEW |