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

Side by Side Diff: media/renderers/video_renderer_impl_unittest.cc

Issue 2007463005: Paint first frame faster, don't crash with no frames during EOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Whoops, fix comment. Created 4 years, 6 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
« no previous file with comments | « media/renderers/video_renderer_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 // when the renderer paints the first frame. 406 // when the renderer paints the first frame.
407 { 407 {
408 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); 408 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH");
409 WaitableMessageLoopEvent event; 409 WaitableMessageLoopEvent event;
410 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(80))).Times(1); 410 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(80))).Times(1);
411 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) 411 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
412 .WillOnce(RunClosure(event.GetClosure())); 412 .WillOnce(RunClosure(event.GetClosure()));
413 if (type == UnderflowTestType::NORMAL) 413 if (type == UnderflowTestType::NORMAL)
414 QueueFrames("80 100 120 140 160"); 414 QueueFrames("80 100 120 140 160");
415 else 415 else
416 QueueFrames("40 60 80"); 416 QueueFrames("40 60 80 90");
417 SatisfyPendingRead(); 417 SatisfyPendingRead();
418 event.RunAndWait(); 418 event.RunAndWait();
419 } 419 }
420 420
421 Destroy(); 421 Destroy();
422 } 422 }
423 423
424 protected: 424 protected:
425 // Fixture members. 425 // Fixture members.
426 std::unique_ptr<VideoRendererImpl> renderer_; 426 std::unique_ptr<VideoRendererImpl> renderer_;
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 772
773 Destroy(); 773 Destroy();
774 } 774 }
775 775
776 // Verifies that the sink is stopped after rendering the first frame if 776 // Verifies that the sink is stopped after rendering the first frame if
777 // playback has started. 777 // playback has started.
778 TEST_F(VideoRendererImplTest, RenderingStopsAfterOneFrameWithEOS) { 778 TEST_F(VideoRendererImplTest, RenderingStopsAfterOneFrameWithEOS) {
779 InitializeWithLowDelay(true); 779 InitializeWithLowDelay(true);
780 QueueFrames("0"); 780 QueueFrames("0");
781 781
782 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))).Times(2); 782 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))).Times(1);
783 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); 783 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
784 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); 784 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber());
785 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); 785 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1);
786 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); 786 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1);
787 787
788 { 788 {
789 SCOPED_TRACE("Waiting for sink to stop."); 789 SCOPED_TRACE("Waiting for sink to stop.");
790 WaitableMessageLoopEvent event; 790 WaitableMessageLoopEvent event;
791 791
792 null_video_sink_->set_stop_cb(event.GetClosure()); 792 null_video_sink_->set_stop_cb(event.GetClosure());
(...skipping 16 matching lines...) Expand all
809 TEST_F(VideoRendererImplTest, RenderingStartedThenStopped) { 809 TEST_F(VideoRendererImplTest, RenderingStartedThenStopped) {
810 Initialize(); 810 Initialize();
811 QueueFrames("0 30 60 90"); 811 QueueFrames("0 30 60 90");
812 812
813 // Start the sink and wait for the first callback. Set statistics to a non 813 // Start the sink and wait for the first callback. Set statistics to a non
814 // zero value, once we have some decoded frames they should be overwritten. 814 // zero value, once we have some decoded frames they should be overwritten.
815 PipelineStatistics last_pipeline_statistics; 815 PipelineStatistics last_pipeline_statistics;
816 last_pipeline_statistics.video_frames_dropped = 1; 816 last_pipeline_statistics.video_frames_dropped = 1;
817 { 817 {
818 WaitableMessageLoopEvent event; 818 WaitableMessageLoopEvent event;
819 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); 819 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
820 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0)))
821 .WillOnce(RunClosure(event.GetClosure())); 820 .WillOnce(RunClosure(event.GetClosure()));
821 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0)));
822 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); 822 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1);
823 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); 823 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1);
824 StartPlayingFrom(0); 824 StartPlayingFrom(0);
825 event.RunAndWait(); 825 event.RunAndWait();
826 Mock::VerifyAndClearExpectations(&mock_cb_); 826 Mock::VerifyAndClearExpectations(&mock_cb_);
827 } 827 }
828 828
829 // Consider the case that rendering is faster than we setup the test event. 829 // Consider the case that rendering is faster than we setup the test event.
830 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will 830 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will
831 // be called. And then during SatisfyPendingReadWithEndOfStream, 831 // be called. And then during SatisfyPendingReadWithEndOfStream,
(...skipping 21 matching lines...) Expand all
853 // reported 853 // reported
854 EXPECT_EQ(0u, last_pipeline_statistics.video_frames_dropped); 854 EXPECT_EQ(0u, last_pipeline_statistics.video_frames_dropped);
855 EXPECT_EQ(4u, last_pipeline_statistics.video_frames_decoded); 855 EXPECT_EQ(4u, last_pipeline_statistics.video_frames_decoded);
856 EXPECT_EQ(115200, last_pipeline_statistics.video_memory_usage); 856 EXPECT_EQ(115200, last_pipeline_statistics.video_memory_usage);
857 857
858 AdvanceTimeInMs(30); 858 AdvanceTimeInMs(30);
859 WaitForEnded(); 859 WaitForEnded();
860 Destroy(); 860 Destroy();
861 } 861 }
862 862
863 // Tests the case where underflow evicts all frames before EOS.
864 TEST_F(VideoRendererImplTest, UnderflowEvictionBeforeEOS) {
865 Initialize();
866 QueueFrames("0 30 60 90 100");
867
868 {
869 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH");
870 WaitableMessageLoopEvent event;
871 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
872 .WillOnce(RunClosure(event.GetClosure()));
873 EXPECT_CALL(mock_cb_, FrameReceived(_)).Times(AnyNumber());
874 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1);
875 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1);
876 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber());
877 StartPlayingFrom(0);
878 event.RunAndWait();
879 }
880
881 {
882 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING");
883 WaitableMessageLoopEvent event;
884 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING))
885 .WillOnce(RunClosure(event.GetClosure()));
886 renderer_->OnTimeStateChanged(true);
887 time_source_.StartTicking();
888 event.RunAndWait();
889 }
890
891 WaitForPendingRead();
892
893 // Jump time far enough forward that no frames are valid.
894 renderer_->OnTimeStateChanged(false);
895 AdvanceTimeInMs(1000);
896 time_source_.StopTicking();
897
898 // Providing the end of stream packet should remove all frames and exit.
899 SatisfyPendingReadWithEndOfStream();
900 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
901 WaitForEnded();
902 Destroy();
903 }
904
863 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { 905 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) {
864 Initialize(); 906 Initialize();
865 QueueFrames("0 30 60 90"); 907 QueueFrames("0 30 60 90");
866 908
867 WaitableMessageLoopEvent event; 909 WaitableMessageLoopEvent event;
868 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); 910 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0)));
869 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) 911 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
870 .WillOnce(RunClosure(event.GetClosure())); 912 .WillOnce(RunClosure(event.GetClosure()));
871 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); 913 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber());
872 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); 914 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 QueueFrames("0 10 20 30"); 1130 QueueFrames("0 10 20 30");
1089 StartPlayingFrom(0); 1131 StartPlayingFrom(0);
1090 Flush(); 1132 Flush();
1091 ASSERT_EQ(1u, frame_ready_cbs_.size()); 1133 ASSERT_EQ(1u, frame_ready_cbs_.size());
1092 // This frame will be discarded. 1134 // This frame will be discarded.
1093 frame_ready_cbs_.front().Run(); 1135 frame_ready_cbs_.front().Run();
1094 Destroy(); 1136 Destroy();
1095 } 1137 }
1096 1138
1097 } // namespace media 1139 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/video_renderer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698