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

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

Issue 1996763002: Make painting a single frame a permanent API on VideoRendererSink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 4 years, 7 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') | media/test/pipeline_integration_test_base.h » ('j') | 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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } 717 }
718 718
719 TEST_F(VideoRendererImplTest, UnderflowRecovery_LowDelay) { 719 TEST_F(VideoRendererImplTest, UnderflowRecovery_LowDelay) {
720 UnderflowRecoveryTest(UnderflowTestType::LOW_DELAY); 720 UnderflowRecoveryTest(UnderflowTestType::LOW_DELAY);
721 } 721 }
722 722
723 TEST_F(VideoRendererImplTest, UnderflowRecovery_CantReadWithoutStalling) { 723 TEST_F(VideoRendererImplTest, UnderflowRecovery_CantReadWithoutStalling) {
724 UnderflowRecoveryTest(UnderflowTestType::CANT_READ_WITHOUT_STALLING); 724 UnderflowRecoveryTest(UnderflowTestType::CANT_READ_WITHOUT_STALLING);
725 } 725 }
726 726
727 // Verifies that the sink is stopped after rendering the first frame if 727 // Verifies that the first frame is painted w/o rendering being started.
728 // playback hasn't started.
729 TEST_F(VideoRendererImplTest, RenderingStopsAfterFirstFrame) { 728 TEST_F(VideoRendererImplTest, RenderingStopsAfterFirstFrame) {
730 InitializeWithLowDelay(true); 729 InitializeWithLowDelay(true);
731 QueueFrames("0"); 730 QueueFrames("0");
732 731
733 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0)));
734 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); 732 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
735 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); 733 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber());
736 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); 734 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1);
737 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); 735 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1);
738 EXPECT_CALL(mock_cb_, OnEnded()).Times(0); 736 EXPECT_CALL(mock_cb_, OnEnded()).Times(0);
739 737
740 { 738 {
741 SCOPED_TRACE("Waiting for sink to stop."); 739 SCOPED_TRACE("Waiting for first frame to be painted.");
742 WaitableMessageLoopEvent event; 740 WaitableMessageLoopEvent event;
743 741
744 null_video_sink_->set_background_render(true); 742 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0)))
745 null_video_sink_->set_stop_cb(event.GetClosure()); 743 .WillOnce(RunClosure(event.GetClosure()));
746 StartPlayingFrom(0); 744 StartPlayingFrom(0);
747 745
748 EXPECT_TRUE(IsReadPending()); 746 EXPECT_TRUE(IsReadPending());
749 SatisfyPendingReadWithEndOfStream(); 747 SatisfyPendingReadWithEndOfStream();
750 748
751 event.RunAndWait(); 749 event.RunAndWait();
752 } 750 }
753 751
754 Destroy(); 752 Destroy();
755 } 753 }
756 754
757 // Verifies that the sink is stopped after rendering the first frame if 755 // Verifies that the sink is stopped after rendering the first frame if
758 // playback ha started. 756 // playback has started.
759 TEST_F(VideoRendererImplTest, RenderingStopsAfterOneFrameWithEOS) { 757 TEST_F(VideoRendererImplTest, RenderingStopsAfterOneFrameWithEOS) {
760 InitializeWithLowDelay(true); 758 InitializeWithLowDelay(true);
761 QueueFrames("0"); 759 QueueFrames("0");
762 760
763 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); 761 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))).Times(2);
764 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); 762 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
765 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber()); 763 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_)).Times(AnyNumber());
766 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); 764 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1);
767 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); 765 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1);
768 766
769 { 767 {
770 SCOPED_TRACE("Waiting for sink to stop."); 768 SCOPED_TRACE("Waiting for sink to stop.");
771 WaitableMessageLoopEvent event; 769 WaitableMessageLoopEvent event;
772 770
773 null_video_sink_->set_stop_cb(event.GetClosure()); 771 null_video_sink_->set_stop_cb(event.GetClosure());
(...skipping 19 matching lines...) Expand all
793 791
794 // Start the sink and wait for the first callback. Set statistics to a non 792 // Start the sink and wait for the first callback. Set statistics to a non
795 // zero value, once we have some decoded frames they should be overwritten. 793 // zero value, once we have some decoded frames they should be overwritten.
796 PipelineStatistics last_pipeline_statistics; 794 PipelineStatistics last_pipeline_statistics;
797 last_pipeline_statistics.video_frames_dropped = 1; 795 last_pipeline_statistics.video_frames_dropped = 1;
798 { 796 {
799 WaitableMessageLoopEvent event; 797 WaitableMessageLoopEvent event;
800 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)); 798 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
801 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))) 799 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0)))
802 .WillOnce(RunClosure(event.GetClosure())); 800 .WillOnce(RunClosure(event.GetClosure()));
803 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_))
804 .WillRepeatedly(SaveArg<0>(&last_pipeline_statistics));
805 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1); 801 EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1);
806 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1); 802 EXPECT_CALL(mock_cb_, OnVideoOpacityChange(_)).Times(1);
807 StartPlayingFrom(0); 803 StartPlayingFrom(0);
808 event.RunAndWait(); 804 event.RunAndWait();
809 Mock::VerifyAndClearExpectations(&mock_cb_); 805 Mock::VerifyAndClearExpectations(&mock_cb_);
810 EXPECT_EQ(0u, last_pipeline_statistics.video_frames_dropped);
811 EXPECT_EQ(460800, last_pipeline_statistics.video_memory_usage);
812 } 806 }
813 807
814 // Consider the case that rendering is faster than we setup the test event. 808 // Consider the case that rendering is faster than we setup the test event.
815 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will 809 // In that case, when we run out of the frames, BUFFERING_HAVE_NOTHING will
816 // be called. And then during SatisfyPendingReadWithEndOfStream, 810 // be called. And then during SatisfyPendingReadWithEndOfStream,
817 // BUFFER_HAVE_ENOUGH will be called again. 811 // BUFFER_HAVE_ENOUGH will be called again.
818 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) 812 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
819 .Times(testing::AtMost(1)); 813 .Times(testing::AtMost(1));
820 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) 814 EXPECT_CALL(mock_cb_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING))
821 .Times(testing::AtMost(1)); 815 .Times(testing::AtMost(1));
816 EXPECT_CALL(mock_cb_, OnStatisticsUpdate(_))
817 .WillRepeatedly(SaveArg<0>(&last_pipeline_statistics));
822 renderer_->OnTimeStateChanged(true); 818 renderer_->OnTimeStateChanged(true);
823 time_source_.StartTicking(); 819 time_source_.StartTicking();
824 820
825 // Suspend all future callbacks and synthetically advance the media time, 821 // Suspend all future callbacks and synthetically advance the media time,
826 // because this is a background render, we won't underflow by waiting until 822 // because this is a background render, we won't underflow by waiting until
827 // a pending read is ready. 823 // a pending read is ready.
828 null_video_sink_->set_background_render(true); 824 null_video_sink_->set_background_render(true);
829 AdvanceTimeInMs(91); 825 AdvanceTimeInMs(91);
830 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(90))); 826 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(90)));
831 WaitForPendingRead(); 827 WaitForPendingRead();
832 SatisfyPendingReadWithEndOfStream(); 828 SatisfyPendingReadWithEndOfStream();
833 829
834 // If this wasn't background rendering mode, this would result in two frames 830 // If this wasn't background rendering mode, this would result in two frames
835 // being dropped, but since we set background render to true, none should be 831 // being dropped, but since we set background render to true, none should be
836 // reported 832 // reported
837 EXPECT_EQ(0u, last_pipeline_statistics.video_frames_dropped); 833 EXPECT_EQ(0u, last_pipeline_statistics.video_frames_dropped);
838 EXPECT_EQ(4u, last_pipeline_statistics.video_frames_decoded); 834 EXPECT_EQ(4u, last_pipeline_statistics.video_frames_decoded);
839 EXPECT_EQ(460800, last_pipeline_statistics.video_memory_usage); 835 EXPECT_EQ(115200, last_pipeline_statistics.video_memory_usage);
840 836
841 AdvanceTimeInMs(30); 837 AdvanceTimeInMs(30);
842 WaitForEnded(); 838 WaitForEnded();
843 Destroy(); 839 Destroy();
844 } 840 }
845 841
846 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) { 842 TEST_F(VideoRendererImplTest, StartPlayingFromThenFlushThenEOS) {
847 Initialize(); 843 Initialize();
848 QueueFrames("0 30 60 90"); 844 QueueFrames("0 30 60 90");
849 845
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 QueueFrames("0 10 20 30"); 1067 QueueFrames("0 10 20 30");
1072 StartPlayingFrom(0); 1068 StartPlayingFrom(0);
1073 Flush(); 1069 Flush();
1074 ASSERT_EQ(1u, frame_ready_cbs_.size()); 1070 ASSERT_EQ(1u, frame_ready_cbs_.size());
1075 // This frame will be discarded. 1071 // This frame will be discarded.
1076 frame_ready_cbs_.front().Run(); 1072 frame_ready_cbs_.front().Run();
1077 Destroy(); 1073 Destroy();
1078 } 1074 }
1079 1075
1080 } // namespace media 1076 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/video_renderer_impl.cc ('k') | media/test/pipeline_integration_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698