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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 EXPECT_CALL(*audio_renderer_, GetTimeSource()) | 129 EXPECT_CALL(*audio_renderer_, GetTimeSource()) |
130 .WillOnce(Return(&time_source_)); | 130 .WillOnce(Return(&time_source_)); |
131 } else { | 131 } else { |
132 renderer_impl_->set_time_source_for_testing(&time_source_); | 132 renderer_impl_->set_time_source_for_testing(&time_source_); |
133 } | 133 } |
134 | 134 |
135 renderer_impl_->Initialize(demuxer_.get(), &callbacks_, | 135 renderer_impl_->Initialize(demuxer_.get(), &callbacks_, |
136 base::Bind(&CallbackHelper::OnInitialize, | 136 base::Bind(&CallbackHelper::OnInitialize, |
137 base::Unretained(&callbacks_))); | 137 base::Unretained(&callbacks_))); |
138 base::RunLoop().RunUntilIdle(); | 138 base::RunLoop().RunUntilIdle(); |
| 139 |
| 140 if (start_status == PIPELINE_OK && audio_stream_) { |
| 141 ON_CALL(*audio_renderer_, Flush(_)) |
| 142 .WillByDefault(DoAll(SetBufferingState(&audio_renderer_client_, |
| 143 BUFFERING_HAVE_NOTHING), |
| 144 RunClosure<0>())); |
| 145 ON_CALL(*audio_renderer_, StartPlaying()) |
| 146 .WillByDefault(SetBufferingState(&audio_renderer_client_, |
| 147 BUFFERING_HAVE_ENOUGH)); |
| 148 } |
| 149 if (start_status == PIPELINE_OK && video_stream_) { |
| 150 ON_CALL(*video_renderer_, Flush(_)) |
| 151 .WillByDefault(DoAll(SetBufferingState(&video_renderer_client_, |
| 152 BUFFERING_HAVE_NOTHING), |
| 153 RunClosure<0>())); |
| 154 ON_CALL(*video_renderer_, StartPlayingFrom(_)) |
| 155 .WillByDefault(SetBufferingState(&video_renderer_client_, |
| 156 BUFFERING_HAVE_ENOUGH)); |
| 157 } |
139 } | 158 } |
140 | 159 |
141 void CreateAudioStream() { | 160 void CreateAudioStream() { |
142 audio_stream_ = CreateStream(DemuxerStream::AUDIO); | 161 audio_stream_ = CreateStream(DemuxerStream::AUDIO); |
143 streams_.push_back(audio_stream_.get()); | 162 streams_.push_back(audio_stream_.get()); |
144 EXPECT_CALL(*demuxer_, GetAllStreams()).WillRepeatedly(Return(streams_)); | 163 EXPECT_CALL(*demuxer_, GetAllStreams()).WillRepeatedly(Return(streams_)); |
145 } | 164 } |
146 | 165 |
147 void CreateVideoStream(bool is_encrypted = false) { | 166 void CreateVideoStream(bool is_encrypted = false) { |
148 video_stream_ = CreateStream(DemuxerStream::VIDEO); | 167 video_stream_ = CreateStream(DemuxerStream::VIDEO); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 void Play() { | 227 void Play() { |
209 DCHECK(audio_stream_ || video_stream_); | 228 DCHECK(audio_stream_ || video_stream_); |
210 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 229 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
211 | 230 |
212 base::TimeDelta start_time( | 231 base::TimeDelta start_time( |
213 base::TimeDelta::FromMilliseconds(kStartPlayingTimeInMs)); | 232 base::TimeDelta::FromMilliseconds(kStartPlayingTimeInMs)); |
214 EXPECT_CALL(time_source_, SetMediaTime(start_time)); | 233 EXPECT_CALL(time_source_, SetMediaTime(start_time)); |
215 EXPECT_CALL(time_source_, StartTicking()); | 234 EXPECT_CALL(time_source_, StartTicking()); |
216 | 235 |
217 if (audio_stream_) { | 236 if (audio_stream_) { |
218 EXPECT_CALL(*audio_renderer_, StartPlaying()) | 237 EXPECT_CALL(*audio_renderer_, StartPlaying()); |
219 .WillOnce(SetBufferingState(&audio_renderer_client_, | |
220 BUFFERING_HAVE_ENOUGH)); | |
221 } | 238 } |
222 | 239 |
223 if (video_stream_) { | 240 if (video_stream_) { |
224 EXPECT_CALL(*video_renderer_, StartPlayingFrom(start_time)) | 241 EXPECT_CALL(*video_renderer_, StartPlayingFrom(start_time)); |
225 .WillOnce(SetBufferingState(&video_renderer_client_, | |
226 BUFFERING_HAVE_ENOUGH)); | |
227 } | 242 } |
228 | 243 |
229 renderer_impl_->StartPlayingFrom(start_time); | 244 renderer_impl_->StartPlayingFrom(start_time); |
230 base::RunLoop().RunUntilIdle(); | 245 base::RunLoop().RunUntilIdle(); |
231 } | 246 } |
232 | 247 |
233 void SetFlushExpectationsForAVRenderers() { | 248 void SetFlushExpectationsForAVRenderers() { |
234 if (audio_stream_) { | 249 if (audio_stream_) |
235 EXPECT_CALL(*audio_renderer_, Flush(_)) | 250 EXPECT_CALL(*audio_renderer_, Flush(_)); |
236 .WillOnce(DoAll(SetBufferingState(&audio_renderer_client_, | |
237 BUFFERING_HAVE_NOTHING), | |
238 RunClosure<0>())); | |
239 } | |
240 | 251 |
241 if (video_stream_) { | 252 if (video_stream_) |
242 EXPECT_CALL(*video_renderer_, Flush(_)) | 253 EXPECT_CALL(*video_renderer_, Flush(_)); |
243 .WillOnce(DoAll(SetBufferingState(&video_renderer_client_, | |
244 BUFFERING_HAVE_NOTHING), | |
245 RunClosure<0>())); | |
246 } | |
247 } | 254 } |
248 | 255 |
249 void Flush(bool underflowed) { | 256 void Flush(bool underflowed) { |
250 if (!underflowed) | 257 if (!underflowed) |
251 EXPECT_CALL(time_source_, StopTicking()); | 258 EXPECT_CALL(time_source_, StopTicking()); |
252 | 259 |
253 SetFlushExpectationsForAVRenderers(); | 260 SetFlushExpectationsForAVRenderers(); |
254 EXPECT_CALL(callbacks_, OnFlushed()); | 261 EXPECT_CALL(callbacks_, OnFlushed()); |
255 | 262 |
256 renderer_impl_->Flush( | 263 renderer_impl_->Flush( |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 EXPECT_CALL(*video_renderer_, Flush(_)).WillOnce(RunClosure<0>()); | 751 EXPECT_CALL(*video_renderer_, Flush(_)).WillOnce(RunClosure<0>()); |
745 EXPECT_CALL(callbacks_, OnFlushed()); | 752 EXPECT_CALL(callbacks_, OnFlushed()); |
746 renderer_impl_->Flush( | 753 renderer_impl_->Flush( |
747 base::Bind(&CallbackHelper::OnFlushed, base::Unretained(&callbacks_))); | 754 base::Bind(&CallbackHelper::OnFlushed, base::Unretained(&callbacks_))); |
748 base::RunLoop().RunUntilIdle(); | 755 base::RunLoop().RunUntilIdle(); |
749 | 756 |
750 // Start playback after the flush, but never return BUFFERING_HAVE_ENOUGH from | 757 // Start playback after the flush, but never return BUFFERING_HAVE_ENOUGH from |
751 // the video renderer (which simulates spool up time for the video renderer). | 758 // the video renderer (which simulates spool up time for the video renderer). |
752 const base::TimeDelta kStartTime; | 759 const base::TimeDelta kStartTime; |
753 EXPECT_CALL(time_source_, SetMediaTime(kStartTime)); | 760 EXPECT_CALL(time_source_, SetMediaTime(kStartTime)); |
754 EXPECT_CALL(*audio_renderer_, StartPlaying()) | 761 EXPECT_CALL(time_source_, StartTicking()); |
755 .WillOnce( | 762 EXPECT_CALL(*audio_renderer_, StartPlaying()); |
756 SetBufferingState(&audio_renderer_client_, BUFFERING_HAVE_ENOUGH)); | |
757 EXPECT_CALL(*video_renderer_, StartPlayingFrom(kStartTime)); | 763 EXPECT_CALL(*video_renderer_, StartPlayingFrom(kStartTime)); |
| 764 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
758 renderer_impl_->StartPlayingFrom(kStartTime); | 765 renderer_impl_->StartPlayingFrom(kStartTime); |
759 | 766 |
760 // Nothing else should primed on the message loop. | 767 // Nothing else should primed on the message loop. |
761 base::RunLoop().RunUntilIdle(); | 768 base::RunLoop().RunUntilIdle(); |
762 } | 769 } |
763 | 770 |
764 TEST_F(RendererImplTest, StreamStatusNotificationHandling) { | 771 TEST_F(RendererImplTest, StreamStatusNotificationHandling) { |
765 CreateAudioAndVideoStream(); | 772 CreateAudioAndVideoStream(); |
766 | 773 |
767 StreamStatusChangeCB stream_status_change_cb; | 774 StreamStatusChangeCB stream_status_change_cb; |
768 EXPECT_CALL(*demuxer_, SetStreamStatusChangeCB(_)) | 775 EXPECT_CALL(*demuxer_, SetStreamStatusChangeCB(_)) |
769 .WillOnce(SaveArg<0>(&stream_status_change_cb)); | 776 .WillOnce(SaveArg<0>(&stream_status_change_cb)); |
770 SetAudioRendererInitializeExpectations(PIPELINE_OK); | 777 SetAudioRendererInitializeExpectations(PIPELINE_OK); |
771 SetVideoRendererInitializeExpectations(PIPELINE_OK); | 778 SetVideoRendererInitializeExpectations(PIPELINE_OK); |
772 InitializeAndExpect(PIPELINE_OK); | 779 InitializeAndExpect(PIPELINE_OK); |
773 Play(); | 780 Play(); |
774 | 781 |
| 782 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 783 |
775 // Verify that DemuxerStream status changes cause the corresponding | 784 // Verify that DemuxerStream status changes cause the corresponding |
776 // audio/video renderer to be flushed and restarted. | 785 // audio/video renderer to be flushed and restarted. |
777 EXPECT_CALL(time_source_, StopTicking()); | 786 EXPECT_CALL(time_source_, StopTicking()); |
778 EXPECT_CALL(*audio_renderer_, Flush(_)).WillOnce(RunClosure<0>()); | 787 EXPECT_CALL(*audio_renderer_, Flush(_)); |
779 EXPECT_CALL(*audio_renderer_, StartPlaying()) | 788 EXPECT_CALL(*audio_renderer_, StartPlaying()); |
780 .Times(1) | 789 EXPECT_CALL(time_source_, StartTicking()); |
781 .WillOnce( | |
782 SetBufferingState(&audio_renderer_client_, BUFFERING_HAVE_ENOUGH)); | |
783 stream_status_change_cb.Run(audio_stream_.get(), false, base::TimeDelta()); | 790 stream_status_change_cb.Run(audio_stream_.get(), false, base::TimeDelta()); |
784 | 791 |
785 EXPECT_CALL(*video_renderer_, Flush(_)).WillOnce(RunClosure<0>()); | 792 EXPECT_CALL(*video_renderer_, Flush(_)); |
786 EXPECT_CALL(*video_renderer_, StartPlayingFrom(_)) | 793 EXPECT_CALL(*video_renderer_, StartPlayingFrom(_)); |
787 .Times(1) | |
788 .WillOnce(DoAll( | |
789 SetBufferingState(&video_renderer_client_, BUFFERING_HAVE_ENOUGH), | |
790 PostQuitWhenIdle())); | |
791 | |
792 stream_status_change_cb.Run(video_stream_.get(), false, base::TimeDelta()); | 794 stream_status_change_cb.Run(video_stream_.get(), false, base::TimeDelta()); |
793 base::RunLoop().Run(); | 795 base::RunLoop().RunUntilIdle(); |
794 } | 796 } |
795 | 797 |
796 // Stream status changes are handled asynchronously by the renderer and may take | 798 // Stream status changes are handled asynchronously by the renderer and may take |
797 // some time to process. This test verifies that all status changes are | 799 // some time to process. This test verifies that all status changes are |
798 // processed correctly by the renderer even if status changes of the stream | 800 // processed correctly by the renderer even if status changes of the stream |
799 // happen much faster than the renderer can process them. In that case the | 801 // happen much faster than the renderer can process them. In that case the |
800 // renderer may postpone processing status changes, but still must process all | 802 // renderer may postpone processing status changes, but still must process all |
801 // of them eventually. | 803 // of them eventually. |
802 TEST_F(RendererImplTest, PostponedStreamStatusNotificationHandling) { | 804 TEST_F(RendererImplTest, PostponedStreamStatusNotificationHandling) { |
803 CreateAudioAndVideoStream(); | 805 CreateAudioAndVideoStream(); |
804 | 806 |
805 StreamStatusChangeCB stream_status_change_cb; | 807 StreamStatusChangeCB stream_status_change_cb; |
806 EXPECT_CALL(*demuxer_, SetStreamStatusChangeCB(_)) | 808 EXPECT_CALL(*demuxer_, SetStreamStatusChangeCB(_)) |
807 .WillOnce(SaveArg<0>(&stream_status_change_cb)); | 809 .WillOnce(SaveArg<0>(&stream_status_change_cb)); |
808 SetAudioRendererInitializeExpectations(PIPELINE_OK); | 810 SetAudioRendererInitializeExpectations(PIPELINE_OK); |
809 SetVideoRendererInitializeExpectations(PIPELINE_OK); | 811 SetVideoRendererInitializeExpectations(PIPELINE_OK); |
810 InitializeAndExpect(PIPELINE_OK); | 812 InitializeAndExpect(PIPELINE_OK); |
811 Play(); | 813 Play(); |
812 | 814 |
813 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 815 EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
814 .Times(2); | 816 .Times(2); |
815 | 817 |
816 EXPECT_CALL(time_source_, StopTicking()).Times(2); | 818 EXPECT_CALL(time_source_, StopTicking()).Times(2); |
817 EXPECT_CALL(time_source_, StartTicking()).Times(2); | 819 EXPECT_CALL(time_source_, StartTicking()).Times(2); |
818 EXPECT_CALL(*audio_renderer_, Flush(_)) | 820 EXPECT_CALL(*audio_renderer_, Flush(_)).Times(2); |
819 .Times(2) | 821 EXPECT_CALL(*audio_renderer_, StartPlaying()).Times(2); |
820 .WillRepeatedly(DoAll( | |
821 SetBufferingState(&audio_renderer_client_, BUFFERING_HAVE_NOTHING), | |
822 WithArg<0>(PostCallback()))); | |
823 EXPECT_CALL(*audio_renderer_, StartPlaying()) | |
824 .Times(2) | |
825 .WillOnce( | |
826 SetBufferingState(&audio_renderer_client_, BUFFERING_HAVE_ENOUGH)) | |
827 .WillOnce(DoAll( | |
828 SetBufferingState(&audio_renderer_client_, BUFFERING_HAVE_ENOUGH), | |
829 PostQuitWhenIdle())); | |
830 // The first stream status change will be processed immediately. Each status | 822 // The first stream status change will be processed immediately. Each status |
831 // change processing involves Flush + StartPlaying when the Flush is done. The | 823 // change processing involves Flush + StartPlaying when the Flush is done. The |
832 // Flush operation is async in this case, so the second status change will be | 824 // Flush operation is async in this case, so the second status change will be |
833 // postponed by renderer until after processing the first one is finished. But | 825 // postponed by renderer until after processing the first one is finished. But |
834 // we must still get two pairs of Flush/StartPlaying calls eventually. | 826 // we must still get two pairs of Flush/StartPlaying calls eventually. |
835 stream_status_change_cb.Run(audio_stream_.get(), false, base::TimeDelta()); | 827 stream_status_change_cb.Run(audio_stream_.get(), false, base::TimeDelta()); |
836 stream_status_change_cb.Run(audio_stream_.get(), true, base::TimeDelta()); | 828 stream_status_change_cb.Run(audio_stream_.get(), true, base::TimeDelta()); |
837 base::RunLoop().Run(); | 829 base::RunLoop().RunUntilIdle(); |
838 | 830 |
839 EXPECT_CALL(*video_renderer_, Flush(_)) | 831 EXPECT_CALL(*video_renderer_, Flush(_)).Times(2); |
840 .Times(2) | 832 EXPECT_CALL(*video_renderer_, StartPlayingFrom(base::TimeDelta())).Times(2); |
841 .WillRepeatedly(DoAll( | |
842 SetBufferingState(&video_renderer_client_, BUFFERING_HAVE_NOTHING), | |
843 WithArg<0>(PostCallback()))); | |
844 EXPECT_CALL(*video_renderer_, StartPlayingFrom(base::TimeDelta())) | |
845 .Times(2) | |
846 .WillOnce( | |
847 SetBufferingState(&video_renderer_client_, BUFFERING_HAVE_ENOUGH)) | |
848 .WillOnce(DoAll( | |
849 SetBufferingState(&video_renderer_client_, BUFFERING_HAVE_ENOUGH), | |
850 PostQuitWhenIdle())); | |
851 // The first stream status change will be processed immediately. Each status | 833 // The first stream status change will be processed immediately. Each status |
852 // change processing involves Flush + StartPlaying when the Flush is done. The | 834 // change processing involves Flush + StartPlaying when the Flush is done. The |
853 // Flush operation is async in this case, so the second status change will be | 835 // Flush operation is async in this case, so the second status change will be |
854 // postponed by renderer until after processing the first one is finished. But | 836 // postponed by renderer until after processing the first one is finished. But |
855 // we must still get two pairs of Flush/StartPlaying calls eventually. | 837 // we must still get two pairs of Flush/StartPlaying calls eventually. |
856 stream_status_change_cb.Run(video_stream_.get(), false, base::TimeDelta()); | 838 stream_status_change_cb.Run(video_stream_.get(), false, base::TimeDelta()); |
857 stream_status_change_cb.Run(video_stream_.get(), true, base::TimeDelta()); | 839 stream_status_change_cb.Run(video_stream_.get(), true, base::TimeDelta()); |
858 base::RunLoop().Run(); | 840 base::RunLoop().RunUntilIdle(); |
859 } | 841 } |
860 | 842 |
861 // Verify that a RendererImpl::Flush gets postponed until after stream status | 843 // Verify that a RendererImpl::Flush gets postponed until after stream status |
862 // change handling is completed. | 844 // change handling is completed. |
863 TEST_F(RendererImplTest, FlushDuringAudioReinit) { | 845 TEST_F(RendererImplTest, FlushDuringAudioReinit) { |
864 CreateAudioAndVideoStream(); | 846 CreateAudioAndVideoStream(); |
865 | 847 |
866 StreamStatusChangeCB stream_status_change_cb; | 848 StreamStatusChangeCB stream_status_change_cb; |
867 EXPECT_CALL(*demuxer_, SetStreamStatusChangeCB(_)) | 849 EXPECT_CALL(*demuxer_, SetStreamStatusChangeCB(_)) |
868 .WillOnce(SaveArg<0>(&stream_status_change_cb)); | 850 .WillOnce(SaveArg<0>(&stream_status_change_cb)); |
869 SetAudioRendererInitializeExpectations(PIPELINE_OK); | 851 SetAudioRendererInitializeExpectations(PIPELINE_OK); |
870 SetVideoRendererInitializeExpectations(PIPELINE_OK); | 852 SetVideoRendererInitializeExpectations(PIPELINE_OK); |
871 InitializeAndExpect(PIPELINE_OK); | 853 InitializeAndExpect(PIPELINE_OK); |
872 Play(); | 854 Play(); |
873 | 855 |
874 EXPECT_CALL(time_source_, StopTicking()).Times(testing::AnyNumber()); | 856 EXPECT_CALL(time_source_, StopTicking()).Times(testing::AnyNumber()); |
875 base::Closure audio_renderer_flush_cb; | 857 base::Closure audio_renderer_flush_cb; |
876 EXPECT_CALL(*audio_renderer_, Flush(_)) | 858 EXPECT_CALL(*audio_renderer_, Flush(_)) |
877 .WillOnce(SaveArg<0>(&audio_renderer_flush_cb)); | 859 .WillOnce(SaveArg<0>(&audio_renderer_flush_cb)); |
878 EXPECT_CALL(*audio_renderer_, StartPlaying()) | 860 EXPECT_CALL(*audio_renderer_, StartPlaying()); |
879 .Times(1) | |
880 .WillOnce( | |
881 SetBufferingState(&audio_renderer_client_, BUFFERING_HAVE_ENOUGH)); | |
882 | 861 |
883 // This should start flushing the audio renderer (due to audio stream status | 862 // This should start flushing the audio renderer (due to audio stream status |
884 // change) and should populate the |audio_renderer_flush_cb|. | 863 // change) and should populate the |audio_renderer_flush_cb|. |
885 stream_status_change_cb.Run(audio_stream_.get(), false, base::TimeDelta()); | 864 stream_status_change_cb.Run(audio_stream_.get(), false, base::TimeDelta()); |
886 EXPECT_TRUE(audio_renderer_flush_cb); | 865 EXPECT_TRUE(audio_renderer_flush_cb); |
887 base::RunLoop().RunUntilIdle(); | 866 base::RunLoop().RunUntilIdle(); |
888 | 867 |
889 bool flush_done = false; | 868 bool flush_done = false; |
890 | 869 |
891 // Now that audio stream change is being handled the RendererImpl::Flush | 870 // Now that audio stream change is being handled the RendererImpl::Flush |
(...skipping 20 matching lines...) Expand all Loading... |
912 .WillOnce(SaveArg<0>(&stream_status_change_cb)); | 891 .WillOnce(SaveArg<0>(&stream_status_change_cb)); |
913 SetAudioRendererInitializeExpectations(PIPELINE_OK); | 892 SetAudioRendererInitializeExpectations(PIPELINE_OK); |
914 SetVideoRendererInitializeExpectations(PIPELINE_OK); | 893 SetVideoRendererInitializeExpectations(PIPELINE_OK); |
915 InitializeAndExpect(PIPELINE_OK); | 894 InitializeAndExpect(PIPELINE_OK); |
916 Play(); | 895 Play(); |
917 | 896 |
918 EXPECT_CALL(time_source_, StopTicking()).Times(testing::AnyNumber()); | 897 EXPECT_CALL(time_source_, StopTicking()).Times(testing::AnyNumber()); |
919 base::Closure video_renderer_flush_cb; | 898 base::Closure video_renderer_flush_cb; |
920 EXPECT_CALL(*video_renderer_, Flush(_)) | 899 EXPECT_CALL(*video_renderer_, Flush(_)) |
921 .WillOnce(SaveArg<0>(&video_renderer_flush_cb)); | 900 .WillOnce(SaveArg<0>(&video_renderer_flush_cb)); |
922 EXPECT_CALL(*video_renderer_, StartPlayingFrom(_)) | 901 EXPECT_CALL(*video_renderer_, StartPlayingFrom(_)); |
923 .Times(1) | |
924 .WillOnce( | |
925 SetBufferingState(&video_renderer_client_, BUFFERING_HAVE_ENOUGH)); | |
926 | 902 |
927 // This should start flushing the video renderer (due to video stream status | 903 // This should start flushing the video renderer (due to video stream status |
928 // change) and should populate the |video_renderer_flush_cb|. | 904 // change) and should populate the |video_renderer_flush_cb|. |
929 stream_status_change_cb.Run(video_stream_.get(), false, base::TimeDelta()); | 905 stream_status_change_cb.Run(video_stream_.get(), false, base::TimeDelta()); |
930 EXPECT_TRUE(video_renderer_flush_cb); | 906 EXPECT_TRUE(video_renderer_flush_cb); |
931 base::RunLoop().RunUntilIdle(); | 907 base::RunLoop().RunUntilIdle(); |
932 | 908 |
933 bool flush_done = false; | 909 bool flush_done = false; |
934 | 910 |
935 // Now that video stream change is being handled the RendererImpl::Flush | 911 // Now that video stream change is being handled the RendererImpl::Flush |
(...skipping 24 matching lines...) Expand all Loading... |
960 | 936 |
961 StreamStatusChangeCB stream_status_change_cb; | 937 StreamStatusChangeCB stream_status_change_cb; |
962 EXPECT_CALL(*demuxer_, SetStreamStatusChangeCB(_)) | 938 EXPECT_CALL(*demuxer_, SetStreamStatusChangeCB(_)) |
963 .WillOnce(SaveArg<0>(&stream_status_change_cb)); | 939 .WillOnce(SaveArg<0>(&stream_status_change_cb)); |
964 SetAudioRendererInitializeExpectations(PIPELINE_OK); | 940 SetAudioRendererInitializeExpectations(PIPELINE_OK); |
965 SetVideoRendererInitializeExpectations(PIPELINE_OK); | 941 SetVideoRendererInitializeExpectations(PIPELINE_OK); |
966 InitializeAndExpect(PIPELINE_OK); | 942 InitializeAndExpect(PIPELINE_OK); |
967 Play(); | 943 Play(); |
968 | 944 |
969 EXPECT_CALL(time_source_, StopTicking()).Times(testing::AnyNumber()); | 945 EXPECT_CALL(time_source_, StopTicking()).Times(testing::AnyNumber()); |
970 EXPECT_CALL(*video_renderer_, Flush(_)) | 946 EXPECT_CALL(*video_renderer_, Flush(_)); |
971 .WillRepeatedly(DoAll( | |
972 SetBufferingState(&video_renderer_client_, BUFFERING_HAVE_NOTHING), | |
973 RunClosure<0>())); | |
974 | 947 |
975 // Initiate RendererImpl::Flush, but postpone its completion by not calling | 948 // Initiate RendererImpl::Flush, but postpone its completion by not calling |
976 // audio renderer flush callback right away, i.e. pretending audio renderer | 949 // audio renderer flush callback right away, i.e. pretending audio renderer |
977 // flush takes a while. | 950 // flush takes a while. |
978 base::Closure audio_renderer_flush_cb; | 951 base::Closure audio_renderer_flush_cb; |
979 EXPECT_CALL(*audio_renderer_, Flush(_)) | 952 EXPECT_CALL(*audio_renderer_, Flush(_)) |
980 .WillOnce(SaveArg<0>(&audio_renderer_flush_cb)); | 953 .WillOnce(SaveArg<0>(&audio_renderer_flush_cb)); |
981 EXPECT_CALL(callbacks_, OnFlushed()); | 954 EXPECT_CALL(callbacks_, OnFlushed()); |
982 renderer_impl_->Flush( | 955 renderer_impl_->Flush( |
983 base::Bind(&CallbackHelper::OnFlushed, base::Unretained(&callbacks_))); | 956 base::Bind(&CallbackHelper::OnFlushed, base::Unretained(&callbacks_))); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 StreamStatusChangeCB stream_status_change_cb; | 991 StreamStatusChangeCB stream_status_change_cb; |
1019 EXPECT_CALL(*demuxer_, SetStreamStatusChangeCB(_)) | 992 EXPECT_CALL(*demuxer_, SetStreamStatusChangeCB(_)) |
1020 .WillOnce(SaveArg<0>(&stream_status_change_cb)); | 993 .WillOnce(SaveArg<0>(&stream_status_change_cb)); |
1021 SetAudioRendererInitializeExpectations(PIPELINE_OK); | 994 SetAudioRendererInitializeExpectations(PIPELINE_OK); |
1022 SetVideoRendererInitializeExpectations(PIPELINE_OK); | 995 SetVideoRendererInitializeExpectations(PIPELINE_OK); |
1023 InitializeAndExpect(PIPELINE_OK); | 996 InitializeAndExpect(PIPELINE_OK); |
1024 Play(); | 997 Play(); |
1025 | 998 |
1026 EXPECT_CALL(time_source_, StopTicking()).Times(testing::AnyNumber()); | 999 EXPECT_CALL(time_source_, StopTicking()).Times(testing::AnyNumber()); |
1027 EXPECT_CALL(*video_renderer_, OnTimeStopped()).Times(testing::AnyNumber()); | 1000 EXPECT_CALL(*video_renderer_, OnTimeStopped()).Times(testing::AnyNumber()); |
1028 EXPECT_CALL(*audio_renderer_, Flush(_)) | 1001 EXPECT_CALL(*audio_renderer_, Flush(_)); |
1029 .WillRepeatedly(DoAll( | |
1030 SetBufferingState(&audio_renderer_client_, BUFFERING_HAVE_NOTHING), | |
1031 RunClosure<0>())); | |
1032 | 1002 |
1033 // Initiate RendererImpl::Flush, but postpone its completion by not calling | 1003 // Initiate RendererImpl::Flush, but postpone its completion by not calling |
1034 // video renderer flush callback right away, i.e. pretending video renderer | 1004 // video renderer flush callback right away, i.e. pretending video renderer |
1035 // flush takes a while. | 1005 // flush takes a while. |
1036 base::Closure video_renderer_flush_cb; | 1006 base::Closure video_renderer_flush_cb; |
1037 EXPECT_CALL(*video_renderer_, Flush(_)) | 1007 EXPECT_CALL(*video_renderer_, Flush(_)) |
1038 .WillOnce(SaveArg<0>(&video_renderer_flush_cb)); | 1008 .WillOnce(SaveArg<0>(&video_renderer_flush_cb)); |
1039 EXPECT_CALL(callbacks_, OnFlushed()); | 1009 EXPECT_CALL(callbacks_, OnFlushed()); |
1040 renderer_impl_->Flush( | 1010 renderer_impl_->Flush( |
1041 base::Bind(&CallbackHelper::OnFlushed, base::Unretained(&callbacks_))); | 1011 base::Bind(&CallbackHelper::OnFlushed, base::Unretained(&callbacks_))); |
(...skipping 15 matching lines...) Expand all Loading... |
1057 // Complete the video renderer flush, thus completing the renderer_impl_ Flush | 1027 // Complete the video renderer flush, thus completing the renderer_impl_ Flush |
1058 // initiated above. This will transition the RendererImpl into the FLUSHED | 1028 // initiated above. This will transition the RendererImpl into the FLUSHED |
1059 // state and will process pending track switch, which should result in the | 1029 // state and will process pending track switch, which should result in the |
1060 // reinitialization of the video renderer for the secondary video stream. | 1030 // reinitialization of the video renderer for the secondary video stream. |
1061 video_renderer_client_->OnBufferingStateChange(BUFFERING_HAVE_NOTHING); | 1031 video_renderer_client_->OnBufferingStateChange(BUFFERING_HAVE_NOTHING); |
1062 video_renderer_flush_cb.Run(); | 1032 video_renderer_flush_cb.Run(); |
1063 base::RunLoop().RunUntilIdle(); | 1033 base::RunLoop().RunUntilIdle(); |
1064 } | 1034 } |
1065 | 1035 |
1066 } // namespace media | 1036 } // namespace media |
OLD | NEW |