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

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

Issue 1246033008: media: In low delay mode, do not accumulate frames earlier than the start time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/debug/stack_trace.h" 10 #include "base/debug/stack_trace.h"
(...skipping 28 matching lines...) Expand all
39 39
40 ACTION_P(RunClosure, closure) { 40 ACTION_P(RunClosure, closure) {
41 closure.Run(); 41 closure.Run();
42 } 42 }
43 43
44 MATCHER_P(HasTimestamp, ms, "") { 44 MATCHER_P(HasTimestamp, ms, "") {
45 *result_listener << "has timestamp " << arg->timestamp().InMilliseconds(); 45 *result_listener << "has timestamp " << arg->timestamp().InMilliseconds();
46 return arg->timestamp().InMilliseconds() == ms; 46 return arg->timestamp().InMilliseconds() == ms;
47 } 47 }
48 48
49 class VideoRendererImplTest : public testing::TestWithParam<bool> { 49 class VideoRendererImplTest
50 : public testing::TestWithParam<bool /* new_video_renderer */> {
50 public: 51 public:
51 VideoRendererImplTest() 52 VideoRendererImplTest()
52 : tick_clock_(new base::SimpleTestTickClock()), 53 : tick_clock_(new base::SimpleTestTickClock()),
53 decoder_(new MockVideoDecoder()), 54 decoder_(new MockVideoDecoder()),
54 demuxer_stream_(DemuxerStream::VIDEO) { 55 demuxer_stream_(DemuxerStream::VIDEO) {
55 ScopedVector<VideoDecoder> decoders; 56 ScopedVector<VideoDecoder> decoders;
56 decoders.push_back(decoder_); 57 decoders.push_back(decoder_);
57 58
58 null_video_sink_.reset(new NullVideoSink( 59 null_video_sink_.reset(new NullVideoSink(
59 false, base::TimeDelta::FromSecondsD(1.0 / 60), 60 false, base::TimeDelta::FromSecondsD(1.0 / 60),
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 Initialize(); 481 Initialize();
481 QueueFrames("50 60 70 80 90"); 482 QueueFrames("50 60 70 80 90");
482 483
483 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(60))); 484 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(60)));
484 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); 485 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH));
485 StartPlayingFrom(61); 486 StartPlayingFrom(61);
486 Destroy(); 487 Destroy();
487 } 488 }
488 489
489 TEST_P(VideoRendererImplTest, StartPlayingFrom_LowDelay) { 490 TEST_P(VideoRendererImplTest, StartPlayingFrom_LowDelay) {
490 // In low-delay mode only one frame is required to finish preroll. 491 // In low-delay mode only one frame is required to finish preroll. But frames
492 // prior to the start time will not be used.
491 InitializeWithLowDelay(true); 493 InitializeWithLowDelay(true);
492 QueueFrames("0"); 494 QueueFrames("0 10");
493 495
496 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(10)));
494 // Expect some amount of have enough/nothing due to only requiring one frame. 497 // Expect some amount of have enough/nothing due to only requiring one frame.
495 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0)));
496 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) 498 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH))
497 .Times(AnyNumber()); 499 .Times(AnyNumber());
498 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)) 500 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING))
499 .Times(AnyNumber()); 501 .Times(AnyNumber());
xhwang 2015/07/21 20:30:26 When using the old rendering path, we declare HAVE
DaleCurtis 2015/07/21 21:16:50 I was planning to delete the old path this week as
500 StartPlayingFrom(0); 502 StartPlayingFrom(10);
501 503
502 QueueFrames("10"); 504 QueueFrames("20");
503 SatisfyPendingRead(); 505 SatisfyPendingRead();
504 506
505 renderer_->OnTimeStateChanged(true); 507 renderer_->OnTimeStateChanged(true);
506 time_source_.StartTicking(); 508 time_source_.StartTicking();
507 509
508 WaitableMessageLoopEvent event; 510 WaitableMessageLoopEvent event;
509 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(10))) 511 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(20)))
510 .WillOnce(RunClosure(event.GetClosure())); 512 .WillOnce(RunClosure(event.GetClosure()));
511 AdvanceTimeInMs(10); 513 AdvanceTimeInMs(20);
512 event.RunAndWait(); 514 event.RunAndWait();
513 515
514 Destroy(); 516 Destroy();
515 } 517 }
516 518
517 // Verify that a late decoder response doesn't break invariants in the renderer. 519 // Verify that a late decoder response doesn't break invariants in the renderer.
518 TEST_P(VideoRendererImplTest, DestroyDuringOutstandingRead) { 520 TEST_P(VideoRendererImplTest, DestroyDuringOutstandingRead) {
519 Initialize(); 521 Initialize();
520 QueueFrames("0 10 20 30"); 522 QueueFrames("0 10 20 30");
521 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); 523 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0)));
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 } 748 }
747 749
748 INSTANTIATE_TEST_CASE_P(OldVideoRenderer, 750 INSTANTIATE_TEST_CASE_P(OldVideoRenderer,
749 VideoRendererImplTest, 751 VideoRendererImplTest,
750 testing::Values(false)); 752 testing::Values(false));
751 INSTANTIATE_TEST_CASE_P(NewVideoRenderer, 753 INSTANTIATE_TEST_CASE_P(NewVideoRenderer,
752 VideoRendererImplTest, 754 VideoRendererImplTest,
753 testing::Values(true)); 755 testing::Values(true));
754 756
755 } // namespace media 757 } // namespace media
OLDNEW
« media/renderers/video_renderer_impl.cc ('K') | « media/renderers/video_renderer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698